GroupsController.cs 1.2 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Dm.util;
  7. using Microsoft.AspNetCore.SignalR;
  8. using NPOI.SS.UserModel;
  9. using NPOI.SS.Util;
  10. using NPOI.XSSF.UserModel;
  11. using OASystem.API.Middlewares;
  12. using OASystem.API.OAMethodLib;
  13. using OASystem.API.OAMethodLib.APNs;
  14. using OASystem.API.OAMethodLib.File;
  15. using OASystem.API.OAMethodLib.Hub.HubClients;
  16. using OASystem.API.OAMethodLib.Hub.Hubs;
  17. using OASystem.API.OAMethodLib.JuHeAPI;
  18. using OASystem.API.OAMethodLib.KiMiApi;
  19. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  20. using OASystem.Domain.AesEncryption;
  21. using OASystem.Domain.Attributes;
  22. using OASystem.Domain.Dtos.CRM;
  23. using OASystem.Domain.Dtos.FileDto;
  24. using OASystem.Domain.Dtos.Financial;
  25. using OASystem.Domain.Dtos.Groups;
  26. using OASystem.Domain.Entities.Customer;
  27. using OASystem.Domain.Entities.Financial;
  28. using OASystem.Domain.Entities.Groups;
  29. using OASystem.Domain.ViewModels.Financial;
  30. using OASystem.Domain.ViewModels.Groups;
  31. using OASystem.Domain.ViewModels.OCR;
  32. using OASystem.Infrastructure.Repositories.CRM;
  33. using OASystem.Infrastructure.Repositories.Financial;
  34. using OASystem.Infrastructure.Repositories.Groups;
  35. using Quartz.Util;
  36. using SqlSugar.Extensions;
  37. using System.Collections;
  38. using System.Data;
  39. using System.Diagnostics;
  40. using System.Globalization;
  41. using System.IO.Compression;
  42. using System.Web;
  43. using static OASystem.API.OAMethodLib.JWTHelper;
  44. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  45. using Bookmark = Aspose.Words.Bookmark;
  46. using Cell = Aspose.Words.Tables.Cell;
  47. using Table = Aspose.Words.Tables.Table;
  48. namespace OASystem.API.Controllers
  49. {
  50. /// <summary>
  51. /// 团组相关
  52. /// </summary>
  53. //[Authorize]
  54. [Route("api/[controller]/[action]")]
  55. public class GroupsController : ControllerBase
  56. {
  57. private readonly ILogger<GroupsController> _logger;
  58. private readonly GrpScheduleRepository _grpScheduleRep;
  59. private readonly IMapper _mapper;
  60. private readonly DelegationInfoRepository _groupRepository;
  61. private readonly TaskAssignmentRepository _taskAssignmentRep;
  62. private readonly AirTicketResRepository _airTicketResRep;
  63. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  64. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  65. private readonly DelegationEnDataRepository _delegationEnDataRep;
  66. private readonly DelegationVisaRepository _delegationVisaRep;
  67. private readonly VisaPriceRepository _visaPriceRep;
  68. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  69. private readonly HotelPriceRepository _hotelPriceRep;
  70. private readonly CustomersRepository _customersRep;
  71. private readonly MessageRepository _message;
  72. private readonly SqlSugarClient _sqlSugar;
  73. private readonly TourClientListRepository _tourClientListRep;
  74. private readonly TeamRateRepository _teamRateRep;
  75. #region 成本相关
  76. private readonly CheckBoxsRepository _checkBoxs;
  77. private readonly GroupCostRepository _GroupCostRepository;
  78. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  79. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  80. #endregion
  81. private readonly SetDataRepository _setDataRep;
  82. private string url;
  83. private string path;
  84. private readonly EnterExitCostRepository _enterExitCostRep;
  85. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  86. private readonly UsersRepository _usersRep;
  87. private readonly IJuHeApiService _juHeApi;
  88. private readonly InvertedListRepository _invertedListRep;
  89. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  90. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  91. private readonly ThreeCodeRepository _threeCodeRepository;
  92. private readonly HotelInquiryRepository _hotelInquiryRep;
  93. private readonly FeeAuditRepository _feeAuditRep;
  94. private readonly VisaCommissionRepository _visaCommissionRep;
  95. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  96. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  97. private readonly List<CurrencyInfo> _currencyInit;
  98. private readonly List<int> _portTypeData;
  99. private readonly TableOperationRecordRepository _tableorRep;
  100. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  101. private readonly RestaurantRepository _restaurantRep;
  102. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  103. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  104. /// <summary>
  105. /// 构造函数
  106. /// </summary>
  107. /// <param name="logger"></param>
  108. /// <param name="mapper"></param>
  109. /// <param name="hubContext"></param>
  110. /// <param name="sqlSugar"></param>
  111. /// <param name="grpScheduleRep"></param>
  112. /// <param name="groupRepository"></param>
  113. /// <param name="taskAssignmentRep"></param>
  114. /// <param name="airTicketResRep"></param>
  115. /// <param name="decreasePaymentsRep"></param>
  116. /// <param name="InvitationOfficialActivitiesRep"></param>
  117. /// <param name="delegationEnDataRep"></param>
  118. /// <param name="enterExitCostRep"></param>
  119. /// <param name="delegationVisaRep"></param>
  120. /// <param name="message"></param>
  121. /// <param name="visaPriceRep"></param>
  122. /// <param name="carTouristGuideGroundRep"></param>
  123. /// <param name="checkBoxs"></param>
  124. /// <param name="GroupCostRepository"></param>
  125. /// <param name="CostTypeHotelNumberRepository"></param>
  126. /// <param name="GroupCostParameterRepository"></param>
  127. /// <param name="hotelPriceRep"></param>
  128. /// <param name="customersRep"></param>
  129. /// <param name="setDataRep"></param>
  130. /// <param name="tourClientListRep"></param>
  131. /// <param name="teamRateRep"></param>
  132. /// <param name="usersRep"></param>
  133. /// <param name="juHeApi"></param>
  134. /// <param name="invertedListRep"></param>
  135. /// <param name="visaFeeInfoRep"></param>
  136. /// <param name="ticketBlackCodeRep"></param>
  137. /// <param name="hotelInquiryRep"></param>
  138. /// <param name="threeCodeRepository"></param>
  139. /// <param name="feeAuditRep"></param>
  140. /// <param name="visaCommissionRep"></param>
  141. /// <param name="ffrRep"></param>
  142. /// <param name="opinionaireRep"></param>
  143. /// <param name="tableorRep"></param>
  144. /// <param name="enterExitCostDraftRep"></param>
  145. /// <param name="restaurantRep"></param>
  146. /// <param name="enterExitCostQuoteRep"></param>
  147. /// <param name="grpOrderPreInfoRep"></param>
  148. public GroupsController(
  149. ILogger<GroupsController> logger,
  150. IMapper mapper,
  151. IHubContext<ChatHub, IChatClient> hubContext,
  152. SqlSugarClient sqlSugar,
  153. GrpScheduleRepository grpScheduleRep,
  154. DelegationInfoRepository groupRepository,
  155. TaskAssignmentRepository taskAssignmentRep,
  156. AirTicketResRepository airTicketResRep,
  157. DecreasePaymentsRepository decreasePaymentsRep,
  158. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  159. DelegationEnDataRepository delegationEnDataRep,
  160. EnterExitCostRepository enterExitCostRep,
  161. DelegationVisaRepository delegationVisaRep,
  162. MessageRepository message,
  163. VisaPriceRepository visaPriceRep,
  164. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  165. CheckBoxsRepository checkBoxs,
  166. GroupCostRepository GroupCostRepository,
  167. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  168. GroupCostParameterRepository GroupCostParameterRepository,
  169. HotelPriceRepository hotelPriceRep,
  170. CustomersRepository customersRep,
  171. SetDataRepository setDataRep,
  172. TourClientListRepository tourClientListRep,
  173. TeamRateRepository teamRateRep,
  174. UsersRepository usersRep,
  175. IJuHeApiService juHeApi,
  176. InvertedListRepository invertedListRep,
  177. VisaFeeInfoRepository visaFeeInfoRep,
  178. TicketBlackCodeRepository ticketBlackCodeRep,
  179. HotelInquiryRepository hotelInquiryRep,
  180. ThreeCodeRepository threeCodeRepository,
  181. FeeAuditRepository feeAuditRep,
  182. VisaCommissionRepository visaCommissionRep,
  183. ForeignReceivablesRepository ffrRep,
  184. OpinionaireRepository opinionaireRep,
  185. TableOperationRecordRepository tableorRep,
  186. EnterExitCostDraftRepository enterExitCostDraftRep,
  187. RestaurantRepository restaurantRep,
  188. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  189. GroupOrderPreInfoRepository grpOrderPreInfoRep
  190. )
  191. {
  192. _logger = logger;
  193. _mapper = mapper;
  194. _grpScheduleRep = grpScheduleRep;
  195. _groupRepository = groupRepository;
  196. _taskAssignmentRep = taskAssignmentRep;
  197. _airTicketResRep = airTicketResRep;
  198. _sqlSugar = sqlSugar;
  199. url = AppSettingsHelper.Get("ExcelBaseUrl");
  200. path = AppSettingsHelper.Get("ExcelBasePath");
  201. if (!System.IO.Directory.Exists(path))
  202. {
  203. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  204. }
  205. _decreasePaymentsRep = decreasePaymentsRep;
  206. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  207. _delegationEnDataRep = delegationEnDataRep;
  208. _enterExitCostRep = enterExitCostRep;
  209. _delegationVisaRep = delegationVisaRep;
  210. _message = message;
  211. _visaPriceRep = visaPriceRep;
  212. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  213. _checkBoxs = checkBoxs;
  214. _GroupCostRepository = GroupCostRepository;
  215. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  216. _GroupCostParameterRepository = GroupCostParameterRepository;
  217. _hotelPriceRep = hotelPriceRep;
  218. _customersRep = customersRep;
  219. _setDataRep = setDataRep;
  220. _tourClientListRep = tourClientListRep;
  221. _teamRateRep = teamRateRep;
  222. _hubContext = hubContext;
  223. _usersRep = usersRep;
  224. _juHeApi = juHeApi;
  225. _invertedListRep = invertedListRep;
  226. _visaFeeInfoRep = visaFeeInfoRep;
  227. _ticketBlackCodeRep = ticketBlackCodeRep;
  228. _hotelInquiryRep = hotelInquiryRep;
  229. _threeCodeRepository = threeCodeRepository;
  230. _feeAuditRep = feeAuditRep;
  231. _visaCommissionRep = visaCommissionRep;
  232. _ffrRep = ffrRep;
  233. _opinionaireRep = opinionaireRep;
  234. _currencyInit = new List<CurrencyInfo>()
  235. {
  236. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  237. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  238. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  239. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  240. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  241. };
  242. _portTypeData = new List<int>() { 2, 3 };
  243. _tableorRep = tableorRep;
  244. _enterExitCostDraftRep = enterExitCostDraftRep;
  245. _restaurantRep = restaurantRep;
  246. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  247. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  248. }
  249. #region 流程管控
  250. /// <summary>
  251. /// 获取团组流程管控信息
  252. /// </summary>
  253. /// <param name="_jsonDto">查询参数</param>
  254. /// <returns></returns>
  255. [HttpPost]
  256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  257. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  258. {
  259. if (string.IsNullOrEmpty(_jsonDto.Paras))
  260. {
  261. return Ok(JsonView(false, "参数为空"));
  262. }
  263. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  264. if (_ScheduleDto != null)
  265. {
  266. if (_ScheduleDto.SearchType == 2)//获取列表
  267. {
  268. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  269. return Ok(JsonView(_grpScheduleViewList));
  270. }
  271. else//获取对象
  272. {
  273. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  274. if (_grpScheduleView != null)
  275. {
  276. return Ok(JsonView(_grpScheduleView));
  277. }
  278. }
  279. }
  280. else
  281. {
  282. return Ok(JsonView(false, "参数反序列化失败"));
  283. }
  284. return Ok(JsonView(false, "暂无数据!"));
  285. }
  286. /// <summary>
  287. /// 修改团组流程管控详细表数据
  288. /// </summary>
  289. /// <param name="dto"></param>
  290. /// <returns></returns>
  291. [HttpPost]
  292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  293. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  294. {
  295. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  296. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  297. .SetColumns(it => it.Duty == _detail.Duty)
  298. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  299. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  300. .SetColumns(it => it.JobContent == _detail.JobContent)
  301. .SetColumns(it => it.Remark == _detail.Remark)
  302. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  303. .Where(s => s.Id == dto.Id)
  304. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  305. .ExecuteCommandAsync();
  306. if (result > 0)
  307. {
  308. return Ok(JsonView(true, "保存成功!"));
  309. }
  310. return Ok(JsonView(false, "保存失败!"));
  311. }
  312. /// <summary>
  313. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  314. /// </summary>
  315. /// <param name="dto"></param>
  316. /// <returns></returns>
  317. [HttpPost]
  318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  319. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  320. {
  321. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  322. _detail.IsDel = 1;
  323. _detail.DeleteUserId = dto.Duty;
  324. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  325. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  326. .SetColumns(it => it.IsDel == _detail.IsDel)
  327. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  328. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  329. .Where(it => it.Id == dto.Id)
  330. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  331. //.WhereColumns(s => s.Id == dto.Id)
  332. .ExecuteCommandAsync();
  333. if (result > 0)
  334. {
  335. return Ok(JsonView(true, "删除成功!"));
  336. }
  337. return Ok(JsonView(false, "删除失败!"));
  338. }
  339. /// <summary>
  340. /// 增加团组流程管控详细表数据
  341. /// </summary>
  342. /// <param name="dto"></param>
  343. /// <returns></returns>
  344. [HttpPost]
  345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  346. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  347. {
  348. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  349. if (DateTime.Now < _detail.ExpectBeginDt)
  350. {
  351. _detail.StepStatus = 0;
  352. }
  353. else
  354. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  355. _detail.StepStatus = 1;
  356. }
  357. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  358. if (result > 0)
  359. {
  360. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  361. return Ok(JsonView(true, "添加成功!", _result));
  362. }
  363. return Ok(JsonView(false, "添加失败!"));
  364. }
  365. #endregion
  366. #region 团组前期信息
  367. /// <summary>
  368. /// 团组前期信息H5-URL(员工对应地址)
  369. /// </summary>
  370. /// <param name="name">用户名称</param>
  371. /// <returns></returns>
  372. [HttpGet]
  373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  374. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  375. {
  376. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  377. .Where(x => x.IsDel == 0)
  378. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  379. .OrderBy(x => x.Id)
  380. .Select(x => new
  381. {
  382. name = x.CnName,
  383. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  384. })
  385. .ToListAsync();
  386. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  387. }
  388. /// <summary>
  389. /// 团组前期信息 List
  390. /// </summary>
  391. /// <returns></returns>
  392. [HttpPost]
  393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  394. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  395. {
  396. var search = dto.Search;
  397. int[] nameTempIds = new int[] { 1, 12, 28 },
  398. countryTempIds = new int[] { 2, 13, 29 },
  399. daysTempIds = new int[] { 4, 15, 31 },
  400. ppNumTempIds = new int[] { 6 };
  401. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  402. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  403. .Where((opi, u) => opi.IsDel == 0)
  404. .OrderByDescending((opi, u) => opi.CreateTime)
  405. .Select((opi, u) => new GroupOrderPreInfoListView()
  406. {
  407. Id = opi.Id,
  408. Name = opi.Name,
  409. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  410. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  411. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  412. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  413. Operator = u.CnName,
  414. OperationTime = opi.CreateTime
  415. })
  416. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  417. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  418. .ToListAsync();
  419. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  420. int total = list.Count;
  421. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  422. var listPageData1 = listPageData
  423. .Skip((dto.PageIndex - 1) * dto.PageSize)
  424. .Take(dto.PageSize)
  425. .ToList();
  426. var infoIds = listPageData1.Select(x => x.Id).ToList();
  427. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  428. .Where(x => x.IsDel == 0 && x.STid == 109)
  429. .ToArrayAsync();
  430. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  431. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  432. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  433. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  434. .ToListAsync();
  435. foreach (var item in listPageData1)
  436. {
  437. var typeDatas1 = typeDatas.Select(x => new
  438. {
  439. x.Id,
  440. x.Name,
  441. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  442. }).ToArray();
  443. item.VersionDetails = typeDatas1;
  444. }
  445. return Ok(JsonView(listPageData1, listPageData1.Count));
  446. }
  447. /// <summary>
  448. /// 团组前期信息 Init
  449. /// </summary>
  450. /// <returns></returns>
  451. [HttpGet("{userId}")]
  452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  453. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  454. {
  455. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  456. }
  457. /// <summary>
  458. /// 国家数据源
  459. /// </summary>
  460. /// <param name="pageIndex">当前页码</param>
  461. /// <param name="pageSize">每页条数</param>
  462. /// <param name="search">查询条件</param>
  463. /// <returns></returns>
  464. [HttpGet]
  465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  466. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  467. {
  468. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  469. if (pageIndex == 0 && pageSize == 0)
  470. {
  471. //所有数据
  472. return Ok(JsonView(countrys, countrys.Count));
  473. }
  474. //分页
  475. int skip = (pageIndex - 1) * pageSize;
  476. int take = pageSize;
  477. if (!string.IsNullOrEmpty(search))
  478. {
  479. IEnumerable<char> charSequence = search.Select(c => c);
  480. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  481. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  482. return Ok(JsonView(pageData, pageResult1.Count));
  483. }
  484. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  485. return Ok(JsonView(pageResult2, countrys.Count));
  486. }
  487. /// <summary>
  488. /// 城市数据源
  489. /// </summary>
  490. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  491. /// <param name="pageIndex">当前页码</param>
  492. /// <param name="pageSize">每页条数</param>
  493. /// <param name="search">查询条件</param>
  494. /// <returns></returns>
  495. [HttpGet("{countryLabel}")]
  496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  497. public async Task<IActionResult> CityByCountry(
  498. string countryLabel,
  499. [FromQuery] int pageIndex,
  500. [FromQuery] int pageSize,
  501. [FromQuery] string search)
  502. {
  503. countryLabel = HttpUtility.UrlDecode(countryLabel);
  504. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  505. var citys = Array.Empty<string?>();
  506. if (countryList.Any())
  507. {
  508. var cityDatas = await _sqlSugar
  509. .Queryable<Grp_NationalTravelFee>()
  510. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  511. .ToArrayAsync();
  512. foreach (var item in cityDatas)
  513. {
  514. if (item.City.Contains("城市"))
  515. {
  516. item.City = item.Country + "-所有城市";
  517. }
  518. }
  519. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  520. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  521. }
  522. if (pageIndex == 0 && pageSize == 0)
  523. {
  524. //所有数据
  525. return Ok(JsonView(citys, citys?.Length ?? 0));
  526. }
  527. //分页
  528. int skip = (pageIndex - 1) * pageSize;
  529. int take = pageSize;
  530. if (!string.IsNullOrEmpty(search))
  531. {
  532. IEnumerable<char> charSequence = search.Select(c => c);
  533. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  534. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  535. return Ok(JsonView(pageData, pageResult1.Count));
  536. }
  537. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  538. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  539. }
  540. /// <summary>
  541. /// 团组前期信息 Info
  542. /// </summary>
  543. /// <param name="dto">Id</param>
  544. /// <param name="portType">Id</param>
  545. /// <returns></returns>
  546. [HttpGet("{Id}/{TempId}")]
  547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  548. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto, int portType = 1)
  549. {
  550. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  551. }
  552. /// <summary>
  553. /// 团组前期信息 移动端 Info
  554. /// </summary>
  555. /// <param name="dto">Id</param>
  556. /// <returns></returns>
  557. [HttpGet("{Id}/{TempId}")]
  558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  559. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  560. {
  561. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  562. }
  563. /// <summary>
  564. /// 团组前期信息 Save
  565. /// </summary>
  566. /// <param name="dto">Id</param>
  567. /// <returns></returns>
  568. [HttpPost]
  569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  570. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  571. {
  572. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  573. }
  574. /// <summary>
  575. /// 团组前期信息 Del
  576. /// </summary>
  577. /// <param name="dto">Id</param>
  578. /// <returns></returns>
  579. [HttpPost]
  580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  581. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  582. {
  583. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  584. }
  585. /// <summary>
  586. /// 团组前期信息 文件下载
  587. /// </summary>
  588. /// <param name="dto">Id</param>
  589. /// <returns></returns>
  590. [HttpGet("{Id}/{TempId}")]
  591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  592. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  593. {
  594. int id = dto.Id, tempId = dto.TempId;
  595. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  596. var data = view.Data as GrpOrderPreInfoView;
  597. #region Excel
  598. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  599. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  600. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  601. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  602. var fileNamePrefix = string.Empty;
  603. if (tempId == 1405)
  604. {
  605. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  606. fileNamePrefix = $"{data.Name}_无商邀版";
  607. }
  608. else if (tempId == 1406)
  609. {
  610. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  611. fileNamePrefix = $"{data.Name}_有商邀版";
  612. }
  613. else
  614. {
  615. //tempId == 1404 默认下载
  616. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  617. fileNamePrefix = $"{data.Name}_单接送机";
  618. }
  619. foreach (var item in data.Items)
  620. {
  621. var obj = item.NewValue;
  622. if (obj == null) item.OriginVal = "";
  623. else if (obj.Equals("有") || obj.Equals("无"))
  624. {
  625. item.OriginVal = obj.ToString();
  626. }
  627. else if (obj is object[] objArray)
  628. {
  629. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  630. item.OriginVal = string.Join("、", stringArray);
  631. }
  632. else if (obj is string[] stringArray)
  633. {
  634. item.OriginVal = string.Join("、", stringArray);
  635. }
  636. else if (obj.Equals("-"))
  637. {
  638. item.OriginVal = "";
  639. }
  640. }
  641. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  642. fileName = CommonFun.ValidFileName(fileName);
  643. //载入模板
  644. var designer = new WorkbookDesigner
  645. {
  646. Workbook = new Workbook(tempPath)
  647. };
  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. #region 页面操作权限验证
  745. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  746. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  747. #endregion
  748. #endregion
  749. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  750. {
  751. string sqlWhere = string.Empty;
  752. if (dto.IsSure == 0) //未完成
  753. {
  754. sqlWhere += string.Format(@" And IsSure = 0");
  755. }
  756. else if (dto.IsSure == 1) //已完成
  757. {
  758. sqlWhere += string.Format(@" And IsSure = 1");
  759. }
  760. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  761. {
  762. string tj = dto.SearchCriteria;
  763. 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}%')",
  764. tj, tj, tj, tj, tj);
  765. }
  766. if (int.TryParse(dto.Rank, out int rankId))
  767. {
  768. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  769. }
  770. string sqlWhere1 = string.Empty;
  771. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  772. {
  773. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  774. }
  775. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  776. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  777. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  778. JietuanOperator,IsSure,CreateTime,IsBid
  779. From (
  780. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  781. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  782. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  783. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  784. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  785. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  786. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  787. From Grp_DelegationInfo gdi
  788. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  789. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  790. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  791. Where gdi.IsDel = 0 {0}
  792. ) temp {1}", sqlWhere, sqlWhere1);
  793. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  794. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  795. //处理 团组模块实际操作人
  796. _DelegationList.ForEach(async x => {
  797. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  798. var operatorNames = new StringBuilder();
  799. //operatorNames.AppendLine("各模块实际操作人:");
  800. if (operators.Any())
  801. {
  802. operators.ForEach(y => {
  803. string label = string.Empty;
  804. if (y.OperationUsers.Any())
  805. {
  806. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  807. label = string.Join('、', users);
  808. }
  809. else label = "暂未指定";
  810. operatorNames.AppendLine($"{y.CTableName}:{label}");
  811. operatorNames.AppendLine();
  812. });
  813. }
  814. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  815. });
  816. var _view = new
  817. {
  818. PageFuncAuth = pageFunAuthView,
  819. Data = _DelegationList
  820. };
  821. return Ok(JsonView(true, "查询成功!", _view, total));
  822. }
  823. else
  824. {
  825. return Ok(JsonView(false, "查询失败"));
  826. }
  827. }
  828. /// <summary>
  829. /// 团组列表
  830. /// </summary>
  831. /// <returns></returns>
  832. [HttpPost]
  833. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  834. {
  835. #region 参数验证
  836. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  837. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  838. #region 页面操作权限验证
  839. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  840. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  841. #endregion
  842. #endregion
  843. if (dto.PortType != 1 && dto.PortType != 2)
  844. {
  845. return Ok(JsonView(false, "查询失败!"));
  846. }
  847. string orderbyStr = "order by gdi.CreateTime Desc";
  848. string sqlWhere = string.Empty;
  849. if (dto.IsSure == 0) //未完成
  850. {
  851. sqlWhere += string.Format(@" And IsSure = 0");
  852. }
  853. else if (dto.IsSure == 1) //已完成
  854. {
  855. sqlWhere += string.Format(@" And IsSure = 1");
  856. }
  857. //团组类型
  858. if (dto.TeamDid > 0)
  859. {
  860. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  861. }
  862. //团组名称
  863. if (!string.IsNullOrEmpty(dto.TeamName))
  864. {
  865. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  866. }
  867. //客户名称
  868. if (!string.IsNullOrEmpty(dto.ClientName))
  869. {
  870. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  871. }
  872. //客户单位
  873. if (!string.IsNullOrEmpty(dto.ClientUnit))
  874. {
  875. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  876. }
  877. //出访时间
  878. if (!string.IsNullOrEmpty(dto.visitDataTime))
  879. {
  880. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  881. orderbyStr = "order by gdi.VisitDate";
  882. }
  883. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  884. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  885. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  886. JietuanOperator,IsSure,CreateTime
  887. From (
  888. Select row_number() over({0}) as Row_Number,
  889. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  890. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  891. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  892. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  893. From Grp_DelegationInfo gdi
  894. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  895. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  896. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  897. Where gdi.IsDel = 0 {1}
  898. ) temp ", orderbyStr, sqlWhere);
  899. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  900. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  901. #region 处理所属部门
  902. /*
  903. * 1.sq 和 gyy 等显示 市场部
  904. * 2.王鸽和主管及张总还有管理员号统一国交部
  905. * 2-1. 4 管理员 ,21 张海麟
  906. */
  907. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  908. var userIds1 = new List<int>() { 4, 21 };
  909. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  910. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  911. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  912. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  913. .ToList();
  914. foreach (var item in _DelegationList)
  915. {
  916. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  917. }
  918. #endregion
  919. var _view = new
  920. {
  921. PageFuncAuth = pageFunAuthView,
  922. Data = _DelegationList
  923. };
  924. return Ok(JsonView(true, "查询成功!", _view, total));
  925. }
  926. /// <summary>
  927. /// 接团信息详情
  928. /// </summary>
  929. /// <param name="dto">团组info请求dto</param>
  930. /// <returns></returns>
  931. [HttpPost]
  932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  933. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  934. {
  935. var groupData = await _groupRepository.GetGroupInfo(dto);
  936. if (groupData.Code != 0)
  937. {
  938. return Ok(JsonView(false, groupData.Msg));
  939. }
  940. return Ok(JsonView(groupData.Data));
  941. }
  942. /// <summary>
  943. /// 接团信息 编辑添加
  944. /// 基础信息数据源
  945. /// </summary>
  946. /// <param name="dto"></param>
  947. /// <returns></returns>
  948. [HttpPost]
  949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  950. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  951. {
  952. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  953. if (groupData.Code != 0)
  954. {
  955. return Ok(JsonView(false, groupData.Msg));
  956. }
  957. return Ok(JsonView(groupData.Data));
  958. }
  959. /// <summary>
  960. /// 成本修改团组信息
  961. /// </summary>
  962. /// <param name="dto"></param>
  963. /// <returns></returns>
  964. [HttpPost]
  965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  966. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  967. {
  968. var jw = JsonView(false, "操作失败");
  969. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  970. if (di == null)
  971. {
  972. jw.Msg = "参数有误!";
  973. return Ok(jw);
  974. }
  975. #region 添加出访起止时间
  976. var startTime = new DateTime();
  977. var endTime = new DateTime();
  978. if (DateTime.TryParse(dto.VisitDate, out startTime))
  979. {
  980. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  981. }
  982. else
  983. {
  984. jw.Msg = "参数有误!";
  985. return Ok(jw);
  986. }
  987. #endregion
  988. di.VisitDate = startTime;
  989. di.VisitPNumber = dto.VisitPNumber;
  990. di.VisitDays = dto.VisitDays;
  991. di.VisitStartDate = startTime;
  992. di.VisitEndDate = endTime;
  993. var count = _sqlSugar.Updateable(di)
  994. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  995. .ExecuteCommand();
  996. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  997. }
  998. /// <summary>
  999. /// 接团信息 编辑添加
  1000. /// 省份-城市 基础信息数据源
  1001. /// </summary>
  1002. /// <param name="dto"></param>
  1003. /// <returns></returns>
  1004. [HttpPost]
  1005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1006. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1007. {
  1008. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1009. string search = dto.Search;
  1010. var data = await _groupRepository.CityBasicSource();
  1011. int total = data.Length;
  1012. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1013. .Skip((pageIndex - 1) * pageSize)
  1014. .Take(pageSize)
  1015. .ToArray();
  1016. return Ok(JsonView(data, total));
  1017. }
  1018. /// <summary>
  1019. /// 接团信息 操作(增改)
  1020. /// </summary>
  1021. /// <param name="dto"></param>
  1022. /// <returns></returns>
  1023. [HttpPost]
  1024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1025. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1026. {
  1027. // 创建 Stopwatch 实例
  1028. Stopwatch stopwatch = Stopwatch.StartNew();
  1029. decimal ffrPrice = 0.00M;
  1030. DateTime? visitDt = null;
  1031. if (dto.Status == 2)
  1032. {
  1033. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1034. if (groupInfo != null)
  1035. {
  1036. ffrPrice = groupInfo.PaymentMoney;
  1037. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1038. }
  1039. }
  1040. var groupData = await _groupRepository.GroupOperation(dto);
  1041. if (groupData.Code != 0)
  1042. {
  1043. return Ok(JsonView(false, groupData.Msg));
  1044. }
  1045. int diId = 0;
  1046. try
  1047. {
  1048. //添加时 默认加入团组汇率
  1049. if (dto.Status == 1) //添加
  1050. {
  1051. diId = groupData.Data;
  1052. //添加默认币种
  1053. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1054. //默认分配权限
  1055. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1056. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1057. var _managerIds = new List<int>() { 22, 32, 21 };
  1058. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1059. if (userIds.Count > 0)
  1060. {
  1061. userIds.Add(208);
  1062. //创建团组管控
  1063. GroupStepForDelegation.CreateWorkStep(diId);
  1064. //发送消息
  1065. string groupName = dto.TeamName;
  1066. string createGroupUser = string.Empty;
  1067. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1068. if (userInfo != null) createGroupUser = userInfo.CnName;
  1069. string title = $"系统通知";
  1070. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1071. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1072. }
  1073. //默认创建倒推表
  1074. await _invertedListRep._Create(dto.UserId, diId);
  1075. }
  1076. else if (dto.Status == 2)
  1077. {
  1078. diId = dto.Id;
  1079. }
  1080. #region 签证人员团组时间通知
  1081. #region 计算出访起止时间
  1082. var startTime = new DateTime();
  1083. var endTime = new DateTime();
  1084. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1085. {
  1086. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1087. }
  1088. #endregion
  1089. #endregion
  1090. #region 团组操作默认添加/修改收款账单
  1091. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1092. {
  1093. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1094. .Where(x => x.IsDel == 0 &&
  1095. x.Diid == diId &&
  1096. x.Remark.Equals("预付款")
  1097. )
  1098. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1099. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1100. .FirstAsync();
  1101. ffrInfo = new Fin_ForeignReceivables()
  1102. {
  1103. Diid = diId,
  1104. PriceName = dto.ClientUnit,
  1105. Price = dto.PaymentMoney,
  1106. Count = 1,
  1107. Unit = $"元",
  1108. ItemSumPrice = dto.PaymentMoney,
  1109. Rate = 1.0000M,
  1110. Currency = 836,
  1111. AddingWay = 0,
  1112. CreateUserId = dto.UserId,
  1113. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1114. Remark = $"预付款"
  1115. };
  1116. if (ffrInfo == null) //Add
  1117. {
  1118. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1119. }
  1120. else //修改
  1121. {
  1122. await _sqlSugar.Updateable(ffrInfo)
  1123. .UpdateColumns(x => new
  1124. {
  1125. x.PriceName,
  1126. x.Price,
  1127. x.ItemSumPrice,
  1128. x.CreateTime,
  1129. x.CreateUserId
  1130. })
  1131. .WhereColumns(x => x.Id)
  1132. .ExecuteCommandAsync();
  1133. }
  1134. }
  1135. #endregion
  1136. if (diId > 0)
  1137. {
  1138. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1139. }
  1140. // 停止计时
  1141. stopwatch.Stop();
  1142. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1143. }
  1144. catch (Exception ex)
  1145. {
  1146. // 停止计时
  1147. stopwatch.Stop();
  1148. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1149. Logs(ex.Message);
  1150. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1151. }
  1152. // 停止计时
  1153. stopwatch.Stop();
  1154. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1155. }
  1156. /// <summary>
  1157. /// 接团流程操作(增改)
  1158. /// 安卓端使用 建团时添加客户名单
  1159. /// </summary>
  1160. /// <param name="dto"></param>
  1161. /// <returns></returns>
  1162. [HttpPost]
  1163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1164. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1165. {
  1166. #region 参数验证
  1167. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1168. #region 页面操作权限验证
  1169. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1170. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1171. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1172. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1173. #endregion
  1174. #endregion
  1175. try
  1176. {
  1177. //_sqlSugar.BeginTran();
  1178. decimal ffrPrice = 0.00M;
  1179. DateTime? visitDt = null;
  1180. if (dto.Status == 2)
  1181. {
  1182. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1183. if (groupInfo != null)
  1184. {
  1185. ffrPrice = groupInfo.PaymentMoney;
  1186. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1187. }
  1188. }
  1189. var _dto = new GroupOperationDto();
  1190. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1191. var groupData = await _groupRepository.GroupOperation(_dto);
  1192. if (groupData.Code != 0)
  1193. {
  1194. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1195. }
  1196. int diId = 0;
  1197. //添加时 默认加入团组汇率
  1198. if (dto.Status == 1) //添加
  1199. {
  1200. diId = groupData.Data;
  1201. //添加默认币种
  1202. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1203. //默认分配权限
  1204. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1205. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1206. var _managerIds = new List<int>() { 21, 22, 32 };
  1207. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1208. if (userIds.Count > 0)
  1209. {
  1210. userIds.Add(208);
  1211. //创建团组管控
  1212. GroupStepForDelegation.CreateWorkStep(diId);
  1213. //发送消息
  1214. string groupName = dto.TeamName;
  1215. string createGroupUser = string.Empty;
  1216. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1217. if (userInfo != null) createGroupUser = userInfo.CnName;
  1218. string title = $"系统通知";
  1219. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1220. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1221. }
  1222. #region 应用推送
  1223. try
  1224. {
  1225. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1226. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1227. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1228. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1229. {
  1230. var userList = new List<string>() { users.QiyeChatUserId };
  1231. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1232. }
  1233. }
  1234. catch (Exception ex)
  1235. {
  1236. }
  1237. #endregion
  1238. //默认创建倒推表
  1239. await _invertedListRep._Create(dto.UserId, diId);
  1240. }
  1241. if (dto.Status == 2)
  1242. {
  1243. diId = dto.Id;
  1244. if (diId == 0)
  1245. {
  1246. //_sqlSugar.RollbackTran();
  1247. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1248. }
  1249. }
  1250. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1251. if (viewData.Code != 0)
  1252. {
  1253. //_sqlSugar.RollbackTran();
  1254. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1255. }
  1256. #region 团组操作默认添加/修改收款账单
  1257. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1258. {
  1259. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1260. .Where(x => x.IsDel == 0 &&
  1261. x.Diid == diId &&
  1262. x.Remark.Equals("预付款")
  1263. )
  1264. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1265. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1266. .FirstAsync();
  1267. ffrInfo = new Fin_ForeignReceivables()
  1268. {
  1269. Diid = diId,
  1270. PriceName = dto.ClientUnit,
  1271. Price = dto.PaymentMoney,
  1272. Count = 1,
  1273. Unit = $"元",
  1274. ItemSumPrice = dto.PaymentMoney,
  1275. Rate = 1.0000M,
  1276. Currency = 836,
  1277. AddingWay = 0,
  1278. CreateUserId = dto.UserId,
  1279. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1280. Remark = $"预付款"
  1281. };
  1282. if (ffrInfo == null) //Add
  1283. {
  1284. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1285. }
  1286. else //修改
  1287. {
  1288. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1289. .UpdateColumns(x => new
  1290. {
  1291. x.PriceName,
  1292. x.Price,
  1293. x.ItemSumPrice,
  1294. x.CreateTime,
  1295. x.CreateUserId
  1296. })
  1297. .WhereColumns(x => x.Id)
  1298. .ExecuteCommandAsync();
  1299. }
  1300. }
  1301. #endregion
  1302. #region 签证人员团组时间通知
  1303. #region 计算出访起止时间
  1304. var startTime = new DateTime();
  1305. var endTime = new DateTime();
  1306. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1307. {
  1308. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1309. }
  1310. #endregion
  1311. if (diId > 0)
  1312. {
  1313. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1314. }
  1315. #endregion
  1316. //_sqlSugar.CommitTran();
  1317. return Ok(JsonView(true, "添加成功"));
  1318. }
  1319. catch (Exception ex)
  1320. {
  1321. _sqlSugar.RollbackTran();
  1322. return Ok(JsonView(false, ex.Message));
  1323. }
  1324. }
  1325. /// <summary>
  1326. /// 接团流程操作(增改)
  1327. /// 安卓端使用 建团时添加客户名单
  1328. /// </summary>
  1329. /// <param name="dto"></param>
  1330. /// <returns></returns>
  1331. [HttpPost]
  1332. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1333. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1334. {
  1335. #region 参数验证
  1336. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1337. #region 页面操作权限验证
  1338. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1339. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1340. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1341. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1342. #endregion
  1343. #endregion
  1344. _sqlSugar.BeginTran();
  1345. decimal ffrPrice = 0.00M;
  1346. DateTime? visitDt = null;
  1347. if (dto.Status == 2)
  1348. {
  1349. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1350. if (groupInfo != null)
  1351. {
  1352. ffrPrice = groupInfo.PaymentMoney;
  1353. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1354. }
  1355. }
  1356. var _dto = new GroupOperationDto();
  1357. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1358. var groupData = await _groupRepository.GroupOperation(_dto);
  1359. if (groupData.Code != 0)
  1360. {
  1361. _sqlSugar.RollbackTran();
  1362. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1363. }
  1364. try
  1365. {
  1366. int diId = 0;
  1367. //添加时 默认加入团组汇率
  1368. if (dto.Status == 1) //添加
  1369. {
  1370. diId = groupData.Data;
  1371. //添加默认币种
  1372. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1373. //默认分配权限
  1374. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1375. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1376. var _managerIds = new List<int>() { 21, 22, 32 };
  1377. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1378. if (userIds.Count > 0)
  1379. {
  1380. userIds.Add(208);
  1381. //创建团组管控
  1382. GroupStepForDelegation.CreateWorkStep(diId);
  1383. //发送消息
  1384. string groupName = dto.TeamName;
  1385. string createGroupUser = string.Empty;
  1386. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1387. if (userInfo != null) createGroupUser = userInfo.CnName;
  1388. string title = $"系统通知";
  1389. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1390. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1391. }
  1392. #region 应用推送
  1393. try
  1394. {
  1395. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1396. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1397. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1398. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1399. {
  1400. var userList = new List<string>() { users.QiyeChatUserId };
  1401. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1402. }
  1403. }
  1404. catch (Exception ex)
  1405. {
  1406. _sqlSugar.CommitTran();
  1407. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1408. }
  1409. #endregion
  1410. //默认创建倒推表
  1411. await _invertedListRep._Create(dto.UserId, diId);
  1412. }
  1413. else if (dto.Status == 2)
  1414. {
  1415. diId = dto.Id;
  1416. if (diId == 0)
  1417. {
  1418. _sqlSugar.RollbackTran();
  1419. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1420. }
  1421. }
  1422. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1423. if (viewData.Code != 0)
  1424. {
  1425. _sqlSugar.RollbackTran();
  1426. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1427. }
  1428. #region 团组操作默认添加/修改收款账单
  1429. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1430. {
  1431. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1432. .Where(x => x.IsDel == 0 &&
  1433. x.Diid == diId &&
  1434. x.Remark.Equals("预付款")
  1435. )
  1436. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1437. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1438. .FirstAsync();
  1439. ffrInfo = new Fin_ForeignReceivables()
  1440. {
  1441. Diid = diId,
  1442. PriceName = dto.ClientUnit,
  1443. Price = dto.PaymentMoney,
  1444. Count = 1,
  1445. Unit = $"元",
  1446. ItemSumPrice = dto.PaymentMoney,
  1447. Rate = 1.0000M,
  1448. Currency = 836,
  1449. AddingWay = 0,
  1450. CreateUserId = dto.UserId,
  1451. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1452. Remark = $"预付款"
  1453. };
  1454. if (ffrInfo == null) //Add
  1455. {
  1456. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1457. }
  1458. else //修改
  1459. {
  1460. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1461. .UpdateColumns(x => new
  1462. {
  1463. x.PriceName,
  1464. x.Price,
  1465. x.ItemSumPrice,
  1466. x.CreateTime,
  1467. x.CreateUserId
  1468. })
  1469. .WhereColumns(x => x.Id)
  1470. .ExecuteCommandAsync();
  1471. }
  1472. }
  1473. #endregion
  1474. #region 签证人员团组时间通知
  1475. #region 计算出访起止时间
  1476. var startTime = new DateTime();
  1477. var endTime = new DateTime();
  1478. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1479. {
  1480. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1481. }
  1482. #endregion
  1483. if (diId > 0)
  1484. {
  1485. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1486. }
  1487. #endregion
  1488. _sqlSugar.CommitTran();
  1489. return Ok(JsonView(true));
  1490. }
  1491. catch (Exception ex)
  1492. {
  1493. _sqlSugar.RollbackTran();
  1494. return Ok(JsonView(false, ex.Message));
  1495. }
  1496. }
  1497. /// <summary>
  1498. /// 接团信息 操作(删除)
  1499. /// </summary>
  1500. /// <param name="dto"></param>
  1501. /// <returns></returns>
  1502. [HttpPost]
  1503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1504. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1505. {
  1506. var diId = dto.Id;
  1507. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1508. #region 删除 验证
  1509. /*
  1510. * 1、收款账单数据:0 条
  1511. * 2、收款退还数据:0 条
  1512. * 3、机票费用数据:0 条
  1513. * 4、签证费用数据:0 条
  1514. * 5、保险费用数据:0 条
  1515. * 6、酒店费用数据:0 条
  1516. * 7、公务出访数据:1 条
  1517. * 8、邀请公务活动费用数据:1 条
  1518. * 9、OP费用数据:5 条
  1519. * 10、其他费用数据:0 条
  1520. * 11、团组日付报销费用数据:0 条
  1521. *
  1522. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1523. */
  1524. //收款账单
  1525. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1526. //收款退还
  1527. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1528. //机票费用
  1529. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1530. //签证费用
  1531. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1532. //保险费用
  1533. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1534. //酒店费用
  1535. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1536. //公务出访
  1537. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1538. //邀请公务活动费用
  1539. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1540. //OP费用
  1541. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1542. //其他费用
  1543. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1544. //团组日付报销费用
  1545. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1546. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1547. if (feeCount > 0)
  1548. {
  1549. var delMsgTips = new StringBuilder();
  1550. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1551. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1552. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1553. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1554. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1555. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1556. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1557. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1558. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1559. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1560. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1561. delMsgTips.AppendLine($"");
  1562. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1563. return Ok(JsonView(false, delMsgTips.ToString()));
  1564. }
  1565. #endregion
  1566. var groupData = await _groupRepository.GroupDel(dto);
  1567. if (groupData.Code != 0)
  1568. {
  1569. return Ok(JsonView(false, groupData.Msg));
  1570. }
  1571. return Ok(JsonView(true));
  1572. }
  1573. /// <summary>
  1574. /// 获取团组销售报价号
  1575. /// 团组添加时 使用
  1576. /// </summary>
  1577. /// <returns></returns>
  1578. [HttpPost]
  1579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1580. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1581. {
  1582. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1583. if (groupData.Code != 0)
  1584. {
  1585. return Ok(JsonView(false, groupData.Msg));
  1586. }
  1587. object salesQuoteNo = new
  1588. {
  1589. SalesQuoteNo = groupData.Data
  1590. };
  1591. return Ok(JsonView(salesQuoteNo));
  1592. }
  1593. /// <summary>
  1594. /// 设置确认出团
  1595. /// </summary>
  1596. /// <param name="dto"></param>
  1597. /// <returns></returns>
  1598. [HttpPost]
  1599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1600. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1601. {
  1602. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1603. if (groupData.Code != 0)
  1604. {
  1605. return Ok(JsonView(false, groupData.Msg));
  1606. }
  1607. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1608. #region OA消息推送
  1609. try
  1610. {
  1611. string groupName = groupInfo.TeamName;
  1612. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1613. string title = $"系统通知";
  1614. string content = $"团组[{groupName}]已确认出团!";
  1615. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1616. }
  1617. catch (Exception ex)
  1618. {
  1619. }
  1620. #endregion
  1621. #region 应用推送
  1622. try
  1623. {
  1624. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1625. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1626. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1627. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1628. {
  1629. var userList = new List<string>() { users.QiyeChatUserId };
  1630. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1631. }
  1632. }
  1633. catch (Exception ex)
  1634. {
  1635. }
  1636. #endregion
  1637. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1638. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1639. }
  1640. /// <summary>
  1641. /// 获取团组名称data And 签证国别Data
  1642. /// </summary>
  1643. /// <param name="dto"></param>
  1644. /// <returns></returns>
  1645. [HttpPost]
  1646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1647. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1648. {
  1649. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1650. if (groupData.Code != 0)
  1651. {
  1652. return Ok(JsonView(false, groupData.Msg));
  1653. }
  1654. return Ok(JsonView(groupData.Data));
  1655. }
  1656. /// <summary>
  1657. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1658. /// </summary>
  1659. /// <returns></returns>
  1660. [HttpPost]
  1661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1662. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1663. {
  1664. try
  1665. {
  1666. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1667. if (groupData.Code != 0)
  1668. {
  1669. return Ok(JsonView(false, groupData.Msg));
  1670. }
  1671. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1672. }
  1673. catch (Exception ex)
  1674. {
  1675. return Ok(JsonView(false, ex.Message));
  1676. throw;
  1677. }
  1678. }
  1679. /// <summary>
  1680. /// 团组清单 Excel
  1681. /// </summary>
  1682. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1683. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1684. /// <returns></returns>
  1685. [HttpGet]
  1686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1687. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1688. {
  1689. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1690. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1691. if (!beginBool && !endBool)
  1692. {
  1693. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1694. }
  1695. string sql = string.Format(@"
  1696. SELECT
  1697. ROW_NUMBER,
  1698. Id,
  1699. SalesQuoteNo,
  1700. TourCode,
  1701. TeamTypeId,
  1702. TeamType,
  1703. TeamLevId,
  1704. TeamLev,
  1705. TeamName,
  1706. ClientName,
  1707. ClientUnit,
  1708. VisitDate,
  1709. VisitDays,
  1710. VisitPNumber,
  1711. JietuanOperatorId,
  1712. JietuanOperator,
  1713. IsSure,
  1714. CreateUserName,
  1715. IsBid
  1716. FROM
  1717. (
  1718. SELECT
  1719. ROW_NUMBER() OVER(
  1720. ORDER BY
  1721. gdi.VisitDate Desc
  1722. ) AS ROW_NUMBER,
  1723. gdi.Id,
  1724. SalesQuoteNo,
  1725. TourCode,
  1726. ssd.Id TeamTypeId,
  1727. ssd.Name TeamType,
  1728. ssd1.Id TeamLevId,
  1729. ssd1.Name TeamLev,
  1730. TeamName,
  1731. ClientName,
  1732. ClientUnit,
  1733. VisitDate,
  1734. VisitDays,
  1735. VisitPNumber,
  1736. JietuanOperator JietuanOperatorId,
  1737. su.CnName JietuanOperator,
  1738. IsSure,
  1739. gdi.CreateTime,
  1740. su1.CnName As CreateUserName,
  1741. gdi.IsBid
  1742. FROM
  1743. Grp_DelegationInfo gdi
  1744. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1745. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1746. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1747. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1748. WHERE
  1749. gdi.IsDel = 0
  1750. AND gdi.IsBid = 0
  1751. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1752. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1753. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1754. #region 处理所属部门
  1755. /*
  1756. * 1.sq 和 gyy 等显示 市场部
  1757. * 2.王鸽和主管及张总还有管理员号统一国交部
  1758. * 2-1. 4 管理员 ,21 张海麟
  1759. */
  1760. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1761. var userIds1 = new List<int>() { 4, 21 };
  1762. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1763. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1764. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1765. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1766. .ToListAsync();
  1767. var droupIds = groupList.Select(it => it.Id).ToList();
  1768. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1769. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1770. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1771. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1772. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1773. {
  1774. DiId = tcl.DiId,
  1775. LastName = dc.LastName,
  1776. FirstName = dc.FirstName,
  1777. Sex = dc.Sex,
  1778. Birthday = dc.BirthDay,
  1779. Company = cc.CompanyFullName,
  1780. Job = dc.Job,
  1781. CreateTime = tcl.CreateTime,
  1782. })
  1783. .ToList();
  1784. foreach (var item in groupList)
  1785. {
  1786. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1787. string groupFirstName = "";
  1788. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1789. if (currDatas.Any())
  1790. {
  1791. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1792. }
  1793. item.GroupFirst = groupFirstName;
  1794. }
  1795. #endregion
  1796. #region Excel
  1797. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1798. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1799. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1800. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1801. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1802. //载入模板
  1803. var designer = new WorkbookDesigner
  1804. {
  1805. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1806. };
  1807. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1808. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1809. dt.TableName = "GroupList";
  1810. designer.SetDataSource(dt);
  1811. designer.Process();
  1812. if (!Directory.Exists(savePath))
  1813. {
  1814. Directory.CreateDirectory(savePath);
  1815. }
  1816. string serverPath = $"{savePath}{fileName}";
  1817. designer.Workbook.Save(serverPath);
  1818. string rst = $"{servicePath}{ftpPath}{fileName}";
  1819. #endregion
  1820. return Ok(JsonView(true, "操作成功!", rst));
  1821. }
  1822. /// <summary>
  1823. /// 团组合同下载(1.付款80% 2.付全款)
  1824. /// </summary>
  1825. /// <param name="dto"></param>
  1826. /// <returns></returns>
  1827. /// <exception cref="Exception"></exception>
  1828. [HttpPost]
  1829. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1830. {
  1831. var jw = JsonView(false);
  1832. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1833. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1834. if (di == null)
  1835. {
  1836. jw.Msg = "团组Id有误!";
  1837. return Ok(jw);
  1838. }
  1839. #region 权限校验
  1840. var allDownFile = new List<int>() { 21 };
  1841. try
  1842. {
  1843. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1844. .First(x => x.Id == 1418 && x.IsDel == 0);
  1845. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1846. }
  1847. catch (Exception)
  1848. { }
  1849. var guojiaoDownFile = new List<int>() { 330 };
  1850. var shichangDownFile = new List<int>() { 95 };
  1851. if (allDownFile.Contains(dto.UserId))
  1852. {
  1853. }
  1854. else if (guojiaoDownFile.Contains(dto.UserId))
  1855. {
  1856. var guojiaobuDi = new List<int>() { 4, 21 };
  1857. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1858. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1859. .Where((d, u) => u.Id == di.JietuanOperator)
  1860. .Select((d, u) => d.DepName)
  1861. .First();
  1862. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1863. {
  1864. jw.Msg = "暂无下载权限!";
  1865. return Ok(jw);
  1866. }
  1867. }
  1868. else if (shichangDownFile.Contains(dto.UserId))
  1869. {
  1870. var dic = new Dictionary<int, int[]>()
  1871. {
  1872. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1873. };
  1874. try
  1875. {
  1876. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1877. if (sqSetting != null)
  1878. {
  1879. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1880. foreach (var item in result.Keys)
  1881. {
  1882. if (dic.ContainsKey(item))
  1883. {
  1884. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1885. Array.Copy(dic[item], dilatation, dic[item].Length);
  1886. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1887. dic[item] = dilatation;
  1888. }
  1889. else
  1890. {
  1891. dic.Add(item, result[item]);
  1892. }
  1893. }
  1894. }
  1895. if (!dic[95].Contains(di.CreateUserId))
  1896. {
  1897. jw.Msg = "暂无下载权限!";
  1898. return Ok(jw);
  1899. }
  1900. }
  1901. catch (Exception)
  1902. { }
  1903. }
  1904. else if (dto.UserId == di.CreateUserId)
  1905. {
  1906. }
  1907. else
  1908. {
  1909. jw.Msg = "暂无下载权限!";
  1910. return Ok(jw);
  1911. }
  1912. #endregion
  1913. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1914. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1915. .ToListAsync();
  1916. if (!blackCodeList.Any())
  1917. {
  1918. jw.Msg = "该团无机票行程代码!";
  1919. return Ok(jw);
  1920. }
  1921. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1922. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1923. if (groupEnterExitCost == null)
  1924. {
  1925. jw.Msg = "暂无三公费用信息!";
  1926. return Ok(jw);
  1927. }
  1928. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1929. rateList ??= new List<CurrencyInfo>();
  1930. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1931. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1932. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1933. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1934. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1935. .Select((x, a, b) => new
  1936. {
  1937. x.Index,
  1938. itemName = a.Name,
  1939. CurrencyStr = b.Name,
  1940. x.Cost,
  1941. x.SubTotal,
  1942. x.Remark
  1943. })
  1944. .OrderBy((x) => x.Index)
  1945. .ToList();
  1946. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1947. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1948. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1949. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1950. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1951. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1952. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1953. decimal subJJC = 0.00M,
  1954. subGWC = 0.00M,
  1955. subTDC = 0.00M;
  1956. //经济舱
  1957. if (groupEnterExitCost.SumJJC == 1)
  1958. {
  1959. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1960. }
  1961. //公务舱
  1962. if (groupEnterExitCost.SumGWC == 1)
  1963. {
  1964. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1965. }
  1966. //头等舱
  1967. if (groupEnterExitCost.SumTDC == 1)
  1968. {
  1969. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1970. }
  1971. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1972. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1973. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1974. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1975. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1976. .Select((x, s, dc, cc) => new groupClints
  1977. {
  1978. Id = x.Id,
  1979. Name = s.Name,
  1980. IsAccompany = x.IsAccompany,
  1981. CompanyFullName = cc.CompanyFullName
  1982. })
  1983. .ToListAsync();
  1984. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1985. //获取舱位人数
  1986. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  1987. .GroupBy(x => x.Name)
  1988. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1989. .ToList();
  1990. string cityPath = string.Empty;
  1991. string startCity = string.Empty;
  1992. string endCity = string.Empty;
  1993. foreach (var item in blackCodeList)
  1994. {
  1995. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1996. cityPath += city + "\r\n";
  1997. if (item.Equals(blackCodeList.First()))
  1998. {
  1999. var sp = city.Split('-');
  2000. startCity = sp[0];
  2001. endCity = sp[^1];
  2002. }
  2003. }
  2004. var bookMarkDic = new Dictionary<string, string>
  2005. {
  2006. { "ClientUnit", di.ClientUnit },
  2007. { "VisitCountry", di.VisitCountry },
  2008. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2009. { "VisitPNumber", di.VisitPNumber.ToString() },
  2010. { "CityPath", cityPath },
  2011. { "StartCity", startCity },
  2012. { "EndCity", endCity },
  2013. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2014. };
  2015. Document doc = null;
  2016. var percentage = 0.8M;
  2017. var fileNameadd = "预付";
  2018. if (dto.FileType == 1)
  2019. {
  2020. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2021. }
  2022. else if (dto.FileType == 2)
  2023. {
  2024. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2025. percentage = 1;
  2026. fileNameadd = "全款";
  2027. }
  2028. else
  2029. {
  2030. throw new Exception("FileType有误!");
  2031. }
  2032. var builder = new DocumentBuilder(doc);
  2033. decimal totalPrice = 0.00M;
  2034. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2035. if (firstTable != null)
  2036. {
  2037. // 遍历表格的行和单元格
  2038. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2039. {
  2040. for (int i = 0; i < row.Cells.Count; i++)
  2041. {
  2042. var cell = row.Cells[i];
  2043. // 读取单元格内容
  2044. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2045. if (cellTextFirst.Contains("舱位"))
  2046. {
  2047. break;
  2048. }
  2049. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2050. {
  2051. if (i == 2)
  2052. {
  2053. if (cellTextFirst == "经济舱")
  2054. {
  2055. // 设置单元格内容
  2056. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2057. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2058. }
  2059. else
  2060. {
  2061. // 设置单元格内容
  2062. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2063. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2064. }
  2065. }
  2066. if (i == 3)
  2067. {
  2068. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2069. if (count != null)
  2070. {
  2071. // 设置单元格内容
  2072. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2073. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2074. }
  2075. }
  2076. if (i == 4)
  2077. {
  2078. var rowPrice = 0.00M;
  2079. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2080. count ??= 0;
  2081. if (cellTextFirst == "经济舱")
  2082. {
  2083. rowPrice = subJJC * (int)count;
  2084. }
  2085. else
  2086. {
  2087. rowPrice = subGWC * (int)count;
  2088. }
  2089. totalPrice += rowPrice;
  2090. // 设置单元格内容
  2091. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2092. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2093. }
  2094. }
  2095. }
  2096. }
  2097. }
  2098. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2099. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2100. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2101. //--合同表格部分
  2102. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2103. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2104. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2105. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2106. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2107. bookMarkDic.Add("CityPath1", cityPath);
  2108. bookMarkDic.Add("CityPath2", cityPath);
  2109. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2110. if (contractTable != null)
  2111. {
  2112. //数据源
  2113. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2114. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2115. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2116. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2117. .Select((it, y, s) => new
  2118. {
  2119. it.Cost,
  2120. it.SubTotal,
  2121. it.Type,
  2122. y.Id,
  2123. y.City,
  2124. s.Name,
  2125. CurrencyCodeCn = s.Remark
  2126. })
  2127. .ToList()
  2128. .Select(x => new
  2129. {
  2130. CurrencyCode = x.Name,
  2131. CityId = x.Id,
  2132. x.City,
  2133. di.VisitPNumber,
  2134. x.Type,
  2135. x.Cost,
  2136. x.SubTotal,
  2137. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2138. x.CurrencyCodeCn,
  2139. });
  2140. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2141. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2142. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2143. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2144. var tableSettings = new List<tableSetting>()
  2145. {
  2146. new(){ Index = 1 , Property = "City"},
  2147. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2148. new(){ Index = 3 , Property = "Cost"},
  2149. new(){ Index = 4 , Property = "VisitPNumber"},
  2150. //new tableSetting{ Index = 5 , Property = ""},
  2151. //new tableSetting{ Index = 6 , Property = ""},
  2152. new(){ Index = 7 , Property = "Rate"},
  2153. //new tableSetting{ Index = 8 , Property = ""},
  2154. };
  2155. //1.住宿费
  2156. int cloneRow = 8;
  2157. int startDayPrice = 8; //写入index
  2158. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2159. foreach (var dac in dac1)
  2160. {
  2161. var first = dac.First();
  2162. var dayCount = dac.Count();
  2163. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2164. for (int i = 1; i < row.Cells.Count; i++)
  2165. {
  2166. var cell = row.Cells[i];
  2167. var findProperty = tableSettings.Find(x => x.Index == i);
  2168. if (findProperty != null)
  2169. {
  2170. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2171. // 设置单元格内容
  2172. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2173. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2174. }
  2175. else
  2176. {
  2177. switch (i)
  2178. {
  2179. case 5:
  2180. cell.FirstParagraph.Runs.Clear();
  2181. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2182. break;
  2183. case 6:
  2184. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2185. cell.FirstParagraph.Runs.Clear();
  2186. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2187. break;
  2188. case 8:
  2189. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2190. cell.FirstParagraph.Runs.Clear();
  2191. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2192. ZSPriceSum += xiaojiRMB;
  2193. break;
  2194. default:
  2195. break;
  2196. }
  2197. }
  2198. }
  2199. startDayPrice++;
  2200. if (!dac1.Last().Equals(dac))
  2201. {
  2202. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2203. // 将克隆的行追加到原行后面
  2204. contractTable.Rows.Insert(startDayPrice, newRow);
  2205. }
  2206. else
  2207. {
  2208. cloneRow += dac1.Count + 1;
  2209. startDayPrice = cloneRow;
  2210. }
  2211. }
  2212. //2.伙食费
  2213. foreach (var dac in dac2)
  2214. {
  2215. var first = dac.First();
  2216. var dayCount = dac.Count();
  2217. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2218. for (int i = 1; i < row.Cells.Count; i++)
  2219. {
  2220. var cell = row.Cells[i];
  2221. var findProperty = tableSettings.Find(x => x.Index == i);
  2222. if (findProperty != null)
  2223. {
  2224. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2225. // 设置单元格内容
  2226. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2227. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2228. }
  2229. else
  2230. {
  2231. switch (i)
  2232. {
  2233. case 5:
  2234. cell.FirstParagraph.Runs.Clear();
  2235. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2236. break;
  2237. case 6:
  2238. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2239. cell.FirstParagraph.Runs.Clear();
  2240. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2241. break;
  2242. case 8:
  2243. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2244. cell.FirstParagraph.Runs.Clear();
  2245. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2246. HSPriceSum += xiaojiRMB;
  2247. break;
  2248. default:
  2249. break;
  2250. }
  2251. }
  2252. }
  2253. startDayPrice++;
  2254. if (!dac2.Last().Equals(dac))
  2255. {
  2256. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2257. // 将克隆的行追加到原行后面
  2258. contractTable.Rows.Insert(startDayPrice, newRow);
  2259. }
  2260. else
  2261. {
  2262. cloneRow += dac2.Count + 1;
  2263. startDayPrice = cloneRow;
  2264. }
  2265. }
  2266. //3.公杂费
  2267. foreach (var dac in dac3)
  2268. {
  2269. var first = dac.First();
  2270. var dayCount = dac.Count();
  2271. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2272. for (int i = 1; i < row.Cells.Count; i++)
  2273. {
  2274. var cell = row.Cells[i];
  2275. var findProperty = tableSettings.Find(x => x.Index == i);
  2276. if (findProperty != null)
  2277. {
  2278. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2279. // 设置单元格内容
  2280. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2281. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2282. }
  2283. else
  2284. {
  2285. switch (i)
  2286. {
  2287. case 5:
  2288. cell.FirstParagraph.Runs.Clear();
  2289. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2290. break;
  2291. case 6:
  2292. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2293. cell.FirstParagraph.Runs.Clear();
  2294. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2295. break;
  2296. case 8:
  2297. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2298. cell.FirstParagraph.Runs.Clear();
  2299. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2300. GZPriceSum += xiaojiRMB;
  2301. break;
  2302. default:
  2303. break;
  2304. }
  2305. }
  2306. }
  2307. startDayPrice++;
  2308. if (!dac3.Last().Equals(dac))
  2309. {
  2310. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2311. // 将克隆的行追加到原行后面
  2312. contractTable.Rows.Insert(startDayPrice, newRow);
  2313. }
  2314. else
  2315. {
  2316. cloneRow += dac3.Count + 1;
  2317. startDayPrice = cloneRow;
  2318. }
  2319. }
  2320. //合并单元格
  2321. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2322. {
  2323. var currentRow = contractTable.Rows[i];
  2324. var nextRow = contractTable.Rows[i + 1];
  2325. // 获取当前行和下一行的第一个单元格
  2326. Cell currentCell = currentRow.Cells[0];
  2327. Cell nextCell = nextRow.Cells[0];
  2328. // 检查单元格内容是否一致(去除尾部的换行符)
  2329. string currentText = currentCell.GetText().Trim();
  2330. string nextText = nextCell.GetText().Trim();
  2331. if (currentText == nextText)
  2332. {
  2333. // 如果当前单元格已经被合并,找到合并的起始单元格
  2334. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2335. {
  2336. // 找到合并的起始单元格
  2337. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2338. // 将下一行的单元格设置为合并的后续单元格
  2339. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2340. }
  2341. else
  2342. {
  2343. // 如果当前单元格是合并的起始单元格
  2344. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2345. // 将下一行的单元格设置为合并的后续单元格
  2346. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2347. }
  2348. }
  2349. else
  2350. {
  2351. // 如果内容不一致,重置当前单元格的合并属性
  2352. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2353. {
  2354. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2355. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2356. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2357. }
  2358. else
  2359. {
  2360. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2361. }
  2362. }
  2363. }
  2364. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2365. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2366. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2367. }
  2368. foreach (var bookmarkName in bookMarkDic.Keys)
  2369. {
  2370. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2371. if (bookmark != null)
  2372. {
  2373. if (bookmarkName == "ClientUnit")
  2374. {
  2375. // 移动到书签位置
  2376. builder.MoveTo(bookmark.BookmarkStart);
  2377. // 设置字体样式为下划线
  2378. builder.Font.Underline = Aspose.Words.Underline.Single;
  2379. // 插入书签值
  2380. builder.Write(bookMarkDic[bookmarkName]);
  2381. // 清除字体格式,避免影响后续文本
  2382. builder.Font.ClearFormatting();
  2383. }
  2384. else
  2385. {
  2386. builder.MoveToBookmark(bookmarkName);
  2387. builder.Write(bookMarkDic[bookmarkName]);
  2388. }
  2389. }
  2390. }
  2391. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2392. doc.Save(savePaht);
  2393. jw.Msg = "生成成功!";
  2394. jw.Code = 200;
  2395. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2396. return Ok(jw);
  2397. }
  2398. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2399. {
  2400. int index = rowIndex;
  2401. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2402. {
  2403. index--;
  2404. }
  2405. return index;
  2406. }
  2407. #endregion
  2408. #region 团组&签证
  2409. #region 团组&签证 New
  2410. /// <summary>
  2411. /// 团组&签证 New
  2412. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2413. /// </summary>
  2414. /// <param name="file">请求dto</param>
  2415. /// <returns></returns>
  2416. [HttpPost]
  2417. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2418. public async Task<IActionResult> VisaFileUploadAndUpdate(FormFile file)
  2419. {
  2420. //文件验证
  2421. if (file.Length < 1)
  2422. {
  2423. }
  2424. return Ok(JsonView(true));
  2425. }
  2426. #endregion
  2427. /// <summary>
  2428. /// 根据团组Id获取签证客户信息List
  2429. /// </summary>
  2430. /// <param name="dto">请求dto</param>
  2431. /// <returns></returns>
  2432. [HttpPost]
  2433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2434. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2435. {
  2436. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2437. if (groupData.Code != 0)
  2438. {
  2439. return Ok(JsonView(false, groupData.Msg));
  2440. }
  2441. return Ok(JsonView(groupData.Data));
  2442. }
  2443. /// <summary>
  2444. /// IOS获取团组签证拍照上传进度01(团组列表)
  2445. /// </summary>
  2446. /// <param name="dto">请求dto</param>
  2447. /// <returns></returns>
  2448. [HttpPost]
  2449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2450. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2451. {
  2452. if (dto == null)
  2453. {
  2454. return Ok(JsonView(false, "参数为空"));
  2455. }
  2456. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2457. return Ok(JsonView(visaList));
  2458. }
  2459. /// <summary>
  2460. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2461. /// </summary>
  2462. /// <returns></returns>
  2463. [HttpPost]
  2464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2465. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2466. {
  2467. if (dto == null)
  2468. {
  2469. return Ok(JsonView(false, "请求错误:"));
  2470. }
  2471. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2472. return Ok(JsonView(list));
  2473. }
  2474. /// <summary>
  2475. /// IOS获取团组签证拍照上传进度03(相册)
  2476. /// </summary>
  2477. /// <returns></returns>
  2478. [HttpPost]
  2479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2480. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2481. {
  2482. if (dto == null)
  2483. {
  2484. return Ok(JsonView(false, "请求错误:"));
  2485. }
  2486. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2487. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2488. list.ForEach(s => s.url = url);
  2489. return Ok(JsonView(list));
  2490. }
  2491. /// <summary>
  2492. /// IOS获取团组签证拍照上传进度04(图片上传)
  2493. /// </summary>
  2494. /// <param name="dto"></param>
  2495. /// <returns></returns>
  2496. [HttpPost]
  2497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2498. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2499. {
  2500. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2501. //if (!string.IsNullOrEmpty(result))
  2502. //{
  2503. //}
  2504. //else {
  2505. // return Ok(JsonView(false, "上传失败"));
  2506. //}
  2507. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2508. int sucNum = 0;
  2509. try
  2510. {
  2511. foreach (var item in dto.base64DataList)
  2512. {
  2513. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2514. string result = DecodeBase64ToImage(item, imageName);
  2515. if (!string.IsNullOrEmpty(result))
  2516. {
  2517. var pic = new Grp_VisaProgressCustomerPicture
  2518. {
  2519. CreateUserId = dto.CreateUserId,
  2520. PicName = imageName,
  2521. PicPath = result,
  2522. VisaProgressCustomerId = dto.visaProgressCustomerId
  2523. };
  2524. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2525. if (insertResult > 0)
  2526. {
  2527. sucNum++;
  2528. }
  2529. }
  2530. }
  2531. }
  2532. catch (Exception ex)
  2533. {
  2534. return Ok(JsonView(false, ex.Message));
  2535. }
  2536. string msg = string.Format(@"成功上传{0}张", sucNum);
  2537. return Ok(JsonView(true, msg));
  2538. }
  2539. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2540. {
  2541. string filename = "";//声明一个string类型的相对路径
  2542. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2543. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2544. try//会有异常抛出,try,catch一下
  2545. {
  2546. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2547. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2548. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2549. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2550. //文件名称
  2551. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2552. //上传的文件的路径
  2553. string filePath = "";
  2554. if (!Directory.Exists(fileDir))
  2555. {
  2556. Directory.CreateDirectory(fileDir);
  2557. }
  2558. //上传的文件的路径
  2559. filePath = fileDir + filename;
  2560. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2561. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2562. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2563. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2564. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2565. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2566. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2567. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2568. bitmap.Dispose();
  2569. }
  2570. catch (Exception e)
  2571. {
  2572. string massage = e.Message;
  2573. Logs("IOS图片上传Error:" + massage);
  2574. //filename = e.Message;
  2575. }
  2576. return filename;//返回相对路径
  2577. }
  2578. /// <summary>
  2579. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2580. /// </summary>
  2581. /// <param name="dto"></param>
  2582. /// <returns></returns>
  2583. [HttpPost]
  2584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2585. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2586. {
  2587. if (dto == null)
  2588. {
  2589. return Ok(JsonView(false, "请求错误:"));
  2590. }
  2591. string msg = "参数错误";
  2592. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2593. {
  2594. try
  2595. {
  2596. //_delegationVisaRep.BeginTran();
  2597. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2598. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2599. .Where(s => s.Id == dto.visaProgressCustomerId)
  2600. .ExecuteCommandAsync();
  2601. if (updCount > 0 && dto.publishCode == 1)
  2602. {
  2603. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2604. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2605. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2606. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2607. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2608. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2609. if (groupData == null)
  2610. {
  2611. _delegationVisaRep.RollbackTran();
  2612. }
  2613. string title = string.Format(@"[签证进度更新]");
  2614. string content = string.Format(@"测试文本");
  2615. bool rst = await _message.AddMsg(new MessageDto()
  2616. {
  2617. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2618. IssuerId = dto.publisher,
  2619. Title = title,
  2620. Content = content,
  2621. ReleaseTime = DateTime.Now,
  2622. UIdList = new List<int> {
  2623. 234
  2624. }
  2625. });
  2626. if (rst)
  2627. {
  2628. return Ok(JsonView(true, "发送通知成功"));
  2629. }
  2630. }
  2631. //_delegationVisaRep.CommitTran();
  2632. }
  2633. catch (Exception)
  2634. {
  2635. //_delegationVisaRep.RollbackTran();
  2636. }
  2637. }
  2638. return Ok(JsonView(true, msg));
  2639. }
  2640. #endregion
  2641. #region 团组任务分配
  2642. /// <summary>
  2643. /// 团组任务分配初始化
  2644. /// </summary>
  2645. /// <returns></returns>
  2646. [HttpPost]
  2647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2648. public async Task<IActionResult> GetTaskAssignmen()
  2649. {
  2650. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2651. if (groupData.Code != 0)
  2652. {
  2653. return Ok(JsonView(false, groupData.Msg));
  2654. }
  2655. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2656. }
  2657. /// <summary>
  2658. /// 团组任务分配查询
  2659. /// </summary>
  2660. /// <param name="dto"></param>
  2661. /// <returns></returns>
  2662. [HttpPost]
  2663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2664. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2665. {
  2666. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2667. if (groupData.Code != 0)
  2668. {
  2669. return Ok(JsonView(false, groupData.Msg));
  2670. }
  2671. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2672. }
  2673. /// <summary>
  2674. /// 团组任务分配操作
  2675. /// </summary>
  2676. /// <param name="dto"></param>
  2677. /// <returns></returns>
  2678. [HttpPost]
  2679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2680. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2681. {
  2682. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2683. if (groupData.Code != 0)
  2684. {
  2685. return Ok(JsonView(false, groupData.Msg));
  2686. }
  2687. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2688. }
  2689. /// <summary>
  2690. /// 团组任务分配
  2691. /// 批量分配
  2692. /// 查询团组
  2693. /// </summary>
  2694. /// <param name="dto"></param>
  2695. /// <returns></returns>
  2696. [HttpPost]
  2697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2698. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2699. {
  2700. //参数验证
  2701. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2702. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2703. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2704. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2705. }
  2706. /// <summary>
  2707. /// 团组任务分配
  2708. /// 批量分配
  2709. /// </summary>
  2710. /// <param name="dto"></param>
  2711. /// <returns></returns>
  2712. [HttpPost]
  2713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2714. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2715. {
  2716. //参数验证
  2717. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2718. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2719. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2720. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2721. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2722. }
  2723. #endregion
  2724. #region 团组费用审核
  2725. /// <summary>
  2726. /// 费用审核
  2727. /// 团组列表 Page
  2728. /// </summary>
  2729. /// <param name="_dto">团组列表请求dto</param>
  2730. /// <returns></returns>
  2731. [HttpPost]
  2732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2733. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2734. {
  2735. #region 参数验证
  2736. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2737. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2738. #region 页面操作权限验证
  2739. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2740. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2741. #endregion
  2742. #endregion
  2743. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2744. {
  2745. string sqlWhere = string.Empty;
  2746. if (_dto.IsSure == 0) //未完成
  2747. {
  2748. sqlWhere += string.Format(@" And IsSure = 0");
  2749. }
  2750. else if (_dto.IsSure == 1) //已完成
  2751. {
  2752. sqlWhere += string.Format(@" And IsSure = 1");
  2753. }
  2754. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2755. {
  2756. string tj = _dto.SearchCriteria;
  2757. 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}%')",
  2758. tj, tj, tj, tj, tj);
  2759. }
  2760. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2761. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2762. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2763. From (
  2764. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2765. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2766. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2767. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2768. From Grp_DelegationInfo gdi
  2769. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2770. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2771. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2772. Where gdi.IsDel = 0 {0}
  2773. ) temp ", sqlWhere);
  2774. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2775. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2776. var _view = new
  2777. {
  2778. PageFuncAuth = pageFunAuthView,
  2779. Data = _DelegationList
  2780. };
  2781. return Ok(JsonView(true, "查询成功!", _view, total));
  2782. }
  2783. else
  2784. {
  2785. return Ok(JsonView(false, "查询失败"));
  2786. }
  2787. }
  2788. /// <summary>
  2789. /// 获取团组费用审核
  2790. /// </summary>
  2791. /// <param name="_dto"></param>
  2792. /// <returns></returns>
  2793. [HttpPost]
  2794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2795. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2796. {
  2797. try
  2798. {
  2799. #region 参数验证
  2800. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2801. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2802. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2803. #region 页面操作权限验证
  2804. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2805. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2806. #endregion
  2807. #endregion
  2808. var _view = new Grp_CreditCardPaymentView();
  2809. var clientNameList = GetSimplClientList(_dto.DiId);
  2810. #region 费用清单
  2811. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2812. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2813. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2814. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2815. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2816. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2817. /*
  2818. * 76://酒店预订
  2819. */
  2820. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2821. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2822. /*
  2823. * 79://车/导游地接
  2824. */
  2825. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2826. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2827. /*
  2828. * 80: //签证
  2829. */
  2830. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2831. /*
  2832. *81: //邀请/公务活动
  2833. */
  2834. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2835. /*
  2836. * 82: //团组客户保险
  2837. */
  2838. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2839. /*
  2840. * Lable = 85 机票预订
  2841. */
  2842. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2843. /*
  2844. * 85 机票预定
  2845. */
  2846. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2847. /*
  2848. * 98 其他款项
  2849. */
  2850. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2851. /*
  2852. * 285:收款退还
  2853. */
  2854. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2855. /*
  2856. * 1015: //超支费用
  2857. */
  2858. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2859. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2860. /*
  2861. * 币种信息
  2862. */
  2863. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2864. /*
  2865. * 车/导游地接 费用类型
  2866. */
  2867. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2868. /*
  2869. * 车/导游地接 费用类型
  2870. */
  2871. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2872. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2873. /*
  2874. * 用户信息
  2875. */
  2876. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2877. /*
  2878. * 费用模块
  2879. */
  2880. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2881. string priceModule = string.Empty;
  2882. if (sdPriceName != null)
  2883. {
  2884. priceModule = sdPriceName.Name;
  2885. }
  2886. /*
  2887. * 成本信息
  2888. */
  2889. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2890. decimal _groupRate = 0.0000M;
  2891. string _groupCurrencyCode = "-";
  2892. if (groupCost != null)
  2893. {
  2894. _groupRate = groupCost.Rate;
  2895. if (int.TryParse(groupCost.Currency, out int _currency))
  2896. {
  2897. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2898. }
  2899. else _groupCurrencyCode = groupCost.Currency;
  2900. }
  2901. string costContentSql = $"Select * From Grp_GroupCost";
  2902. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2903. //处理日期为空的天数
  2904. for (int i = 0; i < groupCostDetails.Count; i++)
  2905. if (i != 0)
  2906. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2907. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2908. /*
  2909. * 处理详情数据
  2910. */
  2911. foreach (var entity in entityList)
  2912. {
  2913. var _detail = new Grp_CreditCardPaymentDetailView
  2914. {
  2915. Id = entity.Id,
  2916. PriceName = priceModule,
  2917. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  2918. };
  2919. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2920. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2921. //处理金额
  2922. if (entity.CTable == 1015)
  2923. {
  2924. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2925. if (czInfo != null)
  2926. {
  2927. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2928. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2929. }
  2930. }
  2931. /*
  2932. * 应付款金额
  2933. */
  2934. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2935. string PaymentCurrency_WaitPay = "Unknown";
  2936. string hotelCurrncyCode = "Unknown";
  2937. string hotelCurrncyName = "Unknown";
  2938. if (sdPaymentCurrency_WaitPay != null)
  2939. {
  2940. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2941. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2942. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2943. if (hotelCurrncyCode.Equals("CNY"))
  2944. {
  2945. entity.DayRate = 1.0000M;
  2946. }
  2947. }
  2948. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2949. /*
  2950. * 此次付款金额
  2951. */
  2952. decimal CurrPayStr = 0.00M,
  2953. OriginalCurrPay = 0.00M;
  2954. if (entity.PayPercentage == 0)
  2955. {
  2956. if (entity.PayThenMoney != 0)
  2957. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2958. }
  2959. else
  2960. {
  2961. if (entity.PayMoney != 0)
  2962. {
  2963. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2964. }
  2965. }
  2966. //if (_dto.Label == 79)
  2967. //{
  2968. // string original = string.Empty;
  2969. // if (hotelCurrncyCode.Equals("CNY"))
  2970. // {
  2971. // OriginalCurrPay = CurrPayStr;
  2972. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2973. // }
  2974. // else
  2975. // {
  2976. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2977. // //760 EUR(7600.00 CNY)
  2978. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2979. // }
  2980. //}
  2981. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2982. string original = string.Empty;
  2983. if (hotelCurrncyCode.Equals("CNY"))
  2984. {
  2985. OriginalCurrPay = CurrPayStr;
  2986. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2987. }
  2988. else
  2989. {
  2990. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2991. //760 EUR(7600.00 CNY)
  2992. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  2993. }
  2994. /*
  2995. * 剩余尾款
  2996. */
  2997. decimal BalanceStr = 0;
  2998. if (CurrPayStr != 0)
  2999. {
  3000. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3001. BalanceStr = 0;
  3002. else
  3003. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3004. }
  3005. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3006. /*
  3007. * Bus名称
  3008. */
  3009. _detail.BusName = "待增加";
  3010. /*
  3011. *费用所属
  3012. */
  3013. switch (entity.CTable)
  3014. {
  3015. case 76://酒店预订
  3016. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3017. if (hotelReservations != null)
  3018. {
  3019. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3020. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3021. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3022. string roomFeeStr = "", roomFeestr1 = "";
  3023. //是否比较房型价格
  3024. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3025. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3026. roomFeeStr += $"<br/>";
  3027. var roomTotal = 0.00M;
  3028. if (hotelReservations.SingleRoomPrice > 0)
  3029. {
  3030. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3031. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3032. //__isSingle = true;
  3033. roomTotal += fee;
  3034. }
  3035. if (hotelReservations.DoubleRoomPrice > 0)
  3036. {
  3037. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3038. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3039. // __isDouble = true;
  3040. roomTotal += fee;
  3041. }
  3042. if (hotelReservations.SuiteRoomPrice > 0)
  3043. {
  3044. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3045. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3046. //__isSuite = true;
  3047. roomTotal += fee;
  3048. }
  3049. if (hotelReservations.OtherRoomPrice > 0)
  3050. {
  3051. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3052. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3053. //__isOther = true;
  3054. roomTotal += fee;
  3055. }
  3056. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3057. else roomFeeStr += " 0.00 * 0";
  3058. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3059. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3060. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3061. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3062. /*
  3063. * 费用类型
  3064. * 1:房费
  3065. * 2:早餐
  3066. * 3:地税
  3067. * 4:城市税
  3068. * </summary>
  3069. */
  3070. //地税
  3071. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3072. if (governmentRentData != null)
  3073. {
  3074. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3075. governmentRentFee = governmentRentData.Price;
  3076. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3077. if (governmentRentCurrData != null)
  3078. {
  3079. governmentRentCode = governmentRentCurrData.Name;
  3080. governmentRentName = $"({governmentRentCurrData.Remark})";
  3081. }
  3082. }
  3083. //城市税
  3084. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3085. if (cityTaxData != null)
  3086. {
  3087. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3088. cityTaxFee = cityTaxData.Price;
  3089. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3090. if (cityTaxCurrData != null)
  3091. {
  3092. cityTaxCode = cityTaxCurrData.Name;
  3093. cityTaxName = $"({cityTaxCurrData.Remark})";
  3094. }
  3095. }
  3096. //酒店早餐
  3097. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3098. if (breakfastData != null)
  3099. {
  3100. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3101. breakfastFee = breakfastData.Price;
  3102. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3103. if (breakfastCurrData != null)
  3104. {
  3105. breakfastCode = breakfastCurrData.Name;
  3106. breakfastName = $"({breakfastCurrData.Remark})";
  3107. }
  3108. }
  3109. //房间费用
  3110. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3111. if (roomData != null)
  3112. {
  3113. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3114. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3115. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3116. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3117. roomFee = roomData.Price;
  3118. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3119. if (roomCurrData != null)
  3120. {
  3121. roomCode = roomCurrData.Name;
  3122. roomName = $"({roomCurrData.Remark})";
  3123. }
  3124. }
  3125. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3126. string hotelCostStr = "";
  3127. decimal hotelCsotTotal = 0.00M;
  3128. if (groupCost != null)
  3129. {
  3130. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3131. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3132. }
  3133. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3134. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3135. string hotelCost_day = "";
  3136. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3137. foreach (var item in hotelCostDetails1)
  3138. {
  3139. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3140. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3141. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3142. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3143. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3144. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3145. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3146. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3147. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3148. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3149. hotelCost_day += @$"<br/>";
  3150. }
  3151. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3152. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3153. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3154. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3155. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3156. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3157. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3158. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3159. $"房间说明: {hotelReservations.Remark} <br/>" +
  3160. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3161. $"{hotelBreakfastStr}" +
  3162. $"{hotelGovernmentRentStr}" +
  3163. $"{hotelCityTaxStr}";
  3164. _detail.PriceNameContent = hotelReservations.HotelName;
  3165. }
  3166. break;
  3167. case 79://车/导游地接
  3168. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3169. if (touristGuideGroundReservations != null)
  3170. {
  3171. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3172. {
  3173. _detail.BusName = touristGuideGroundReservations.BusName;
  3174. }
  3175. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3176. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3177. //if (isInt)
  3178. //{
  3179. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3180. // if (cityInfo != null)
  3181. // {
  3182. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3183. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3184. // if (carFeeItem != null)
  3185. // {
  3186. // nameContent += $@"({carFeeItem.Name})";
  3187. // }
  3188. // _detail.PriceNameContent = nameContent;
  3189. // }
  3190. //}
  3191. //else
  3192. //{
  3193. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3194. //}
  3195. var touristGuideGroundReservationsContents =
  3196. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3197. var opContent_sb = new StringBuilder();
  3198. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3199. opContent_sb.AppendLine(contetTitle);
  3200. foreach (var item in touristGuideGroundReservationsContents)
  3201. {
  3202. string typeName = "Unknown";
  3203. string carCurrencyCode = "Unknown";
  3204. string carCurrencyName = "Unknown";
  3205. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3206. if (carTypeData != null) typeName = carTypeData.Name;
  3207. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3208. if (currencyData != null)
  3209. {
  3210. carCurrencyCode = currencyData.Name;
  3211. carCurrencyName = currencyData.Remark;
  3212. }
  3213. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3214. bool IsCurrencyAgreement = false;
  3215. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3216. string opCostStr = string.Empty;
  3217. decimal opCostTypePrice = 0.00M;
  3218. #region 处理成本各项费用
  3219. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3220. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3221. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3222. costOPFeeCNY = 0.00M, //团组成本 op费用
  3223. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3224. if (opCost.Count > 0)
  3225. {
  3226. switch (item.SId)
  3227. {
  3228. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3229. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3230. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3231. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3232. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3233. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3234. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3235. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3236. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3237. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3238. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3239. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3240. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3241. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3242. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3243. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3244. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3245. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3246. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3247. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3248. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3249. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3250. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3251. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3252. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3253. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3254. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3255. }
  3256. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3257. costOPFeeCNY = opCostTypePrice * _groupRate;
  3258. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3259. }
  3260. #endregion
  3261. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3262. aduitOPFeeCNY = item.Price * entity.DayRate;
  3263. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3264. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3265. $"{opTypeStr} {opCostStr}<br/>" +
  3266. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3267. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3268. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3269. {
  3270. if (IsCurrencyAgreement)
  3271. {
  3272. if (item.Price > opCostTypePrice)
  3273. {
  3274. opContent_sb.Append("<span style='color:red;'>");
  3275. opContent_sb.Append(opContent);
  3276. opContent_sb.Append("</span>");
  3277. opContent_sb.AppendLine();
  3278. }
  3279. else
  3280. {
  3281. opContent_sb.Append(opContent);
  3282. opContent_sb.AppendLine();
  3283. }
  3284. }
  3285. else
  3286. {
  3287. //验证是否超成本 按付款比例计算
  3288. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3289. {
  3290. opContent_sb.Append("<span style='color:red;'>");
  3291. opContent_sb.Append(opContent);
  3292. opContent_sb.Append("</span>");
  3293. opContent_sb.AppendLine();
  3294. }
  3295. else
  3296. {
  3297. opContent_sb.Append(opContent);
  3298. opContent_sb.AppendLine();
  3299. }
  3300. }
  3301. }
  3302. else
  3303. {
  3304. opContent_sb.Append(opContent);
  3305. opContent_sb.AppendLine();
  3306. }
  3307. }
  3308. _detail.PriceMsgContent = opContent_sb.ToString();
  3309. }
  3310. break;
  3311. case 80: //签证
  3312. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3313. if (visaInfo != null)
  3314. {
  3315. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  3316. _detail.PriceNameContent = visaInfo.VisaDescription;
  3317. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3318. }
  3319. break;
  3320. case 81: //邀请/公务活动
  3321. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3322. if (_ioa != null)
  3323. {
  3324. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3325. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3326. sendCurrName = "Unknown", //快递费用币种 Name
  3327. sendCurrCode = "Unknown", //快递费用币种 Code
  3328. eventsCurrName = "Unknown", //公务活动费币种 Name
  3329. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3330. translateCurrName = "Unknown", //公务翻译费 Name
  3331. translateCurrCode = "Unknown"; //公务翻译费 Code
  3332. #region 处理费用币种
  3333. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3334. if (inviteCurrData != null)
  3335. {
  3336. inviteCurrName = inviteCurrData.Remark;
  3337. inviteCurrCode = inviteCurrData.Name;
  3338. }
  3339. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3340. if (sendCurrData != null)
  3341. {
  3342. sendCurrName = sendCurrData.Remark;
  3343. sendCurrCode = sendCurrData.Name;
  3344. }
  3345. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3346. if (eventsCurrData != null)
  3347. {
  3348. eventsCurrName = eventsCurrData.Remark;
  3349. eventsCurrCode = eventsCurrData.Name;
  3350. }
  3351. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3352. if (translateCurrData != null)
  3353. {
  3354. translateCurrName = translateCurrData.Remark;
  3355. translateCurrCode = translateCurrData.Name;
  3356. }
  3357. #endregion
  3358. _detail.PriceNameContent = _ioa.InviterArea;
  3359. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  3360. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  3361. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  3362. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  3363. $@"备注:" + _ioa.Remark + "<br/>";
  3364. }
  3365. break;
  3366. case 82: //团组客户保险
  3367. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3368. if (customers != null)
  3369. {
  3370. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  3371. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3372. }
  3373. break;
  3374. case 85: //机票预订
  3375. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3376. if (jpRes != null)
  3377. {
  3378. string FlightsDescription = jpRes.FlightsDescription;
  3379. string PriceDescription = jpRes.PriceDescription;
  3380. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3381. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3382. }
  3383. break;
  3384. case 98://其他款项
  3385. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3386. if (gdpRes != null)
  3387. {
  3388. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3389. _detail.PriceNameContent = gdpRes.PriceName;
  3390. }
  3391. break;
  3392. case 285://收款退还
  3393. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3394. if (refundAndOtherMoney != null)
  3395. {
  3396. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3397. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3398. }
  3399. break;
  3400. case 751://酒店早餐
  3401. break;
  3402. case 1015://超支费用
  3403. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3404. if (groupExtraCost != null)
  3405. {
  3406. _detail.PriceNameContent = groupExtraCost.PriceName;
  3407. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3408. }
  3409. break;
  3410. default:
  3411. break;
  3412. }
  3413. /*
  3414. * 申请人
  3415. */
  3416. string operatorName = " - ";
  3417. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3418. if (_opUser != null)
  3419. {
  3420. operatorName = _opUser.CnName;
  3421. }
  3422. _detail.OperatorName = operatorName;
  3423. /*
  3424. * 审核人
  3425. */
  3426. string auditOperatorName = " - ";
  3427. if (entity.IsAuditGM != 0)
  3428. {
  3429. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3430. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3431. else
  3432. {
  3433. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3434. if (_adUser != null)
  3435. {
  3436. auditOperatorName = _adUser.CnName;
  3437. }
  3438. }
  3439. }
  3440. _detail.AuditOperatorName = auditOperatorName;
  3441. /*
  3442. * 超预算比例
  3443. */
  3444. string overBudgetStr = "";
  3445. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3446. else if (entity.ExceedBudget == 0)
  3447. {
  3448. if (entity.CTable == 76 || entity.CTable == 79)
  3449. {
  3450. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3451. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3452. }
  3453. else
  3454. {
  3455. overBudgetStr = "未超预算";
  3456. }
  3457. }
  3458. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3459. _detail.OverBudget = overBudgetStr;
  3460. decimal auditFee = 0.00M; //已审核金额 人名币
  3461. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3462. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3463. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3464. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3465. {
  3466. auditedFeeOriginal = entity.PayMoney;
  3467. auditFee = CurrPayStr;
  3468. }
  3469. else if (entity.IsAuditGM == 0)
  3470. {
  3471. unAuditFeeCNY = CurrPayStr;
  3472. unAuditFeeOriginal = OriginalCurrPay;
  3473. OriginalCurrPay = 0.00M;
  3474. }
  3475. /*
  3476. * 费用总计
  3477. */
  3478. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3479. {
  3480. CurrencyId = entity.PaymentCurrency,
  3481. CurrencyName = PaymentCurrency_WaitPay,
  3482. AmountPayable = entity.PayMoney,
  3483. ThisPayment = OriginalCurrPay,
  3484. BalancePayment = BalanceStr,
  3485. AuditedFunds = auditFee,
  3486. AuditedFundsOriginal = auditedFeeOriginal,
  3487. UnAuditFundsCNY = unAuditFeeCNY,
  3488. UnAuditFundsOriginal = unAuditFeeOriginal
  3489. });
  3490. _detail.IsAuditGM = entity.IsAuditGM;
  3491. detailList.Add(_detail);
  3492. }
  3493. #endregion
  3494. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3495. /*
  3496. * 下方描述处理
  3497. */
  3498. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3499. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3500. if (ccpCurrencyPrice != null)
  3501. {
  3502. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3503. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3504. }
  3505. else
  3506. {
  3507. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3508. }
  3509. string amountPayableStr = string.Format(@"应付款总金额: ");
  3510. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3511. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3512. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3513. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3514. foreach (var item in nonDuplicat)
  3515. {
  3516. var currencyName = item.CurrencyName;
  3517. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3518. if (strs.Count > 0)
  3519. {
  3520. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3521. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3522. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3523. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3524. //单独处理此次付款金额
  3525. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3526. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3527. //单独处理已审核费用
  3528. //if (item.CurrencyId == 836) //人民币
  3529. //{
  3530. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3531. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3532. //}
  3533. //else
  3534. //{
  3535. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3536. //}
  3537. if (currencyName.Equals("CNY"))
  3538. {
  3539. //已审核费用
  3540. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3541. //未审核费用
  3542. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3543. }
  3544. else
  3545. {
  3546. //已审核费用
  3547. 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"));
  3548. //未审核费用
  3549. 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"));
  3550. }
  3551. }
  3552. }
  3553. _view.TotalStr1 = amountPayableStr[..^1];
  3554. _view.TotalStr2 = thisPaymentStr[..^1];
  3555. _view.TotalStr3 = balancePaymentStr[..^1];
  3556. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3557. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3558. var _view1 = new
  3559. {
  3560. PageFuncAuth = pageFunAuthView,
  3561. Data = _view
  3562. };
  3563. return Ok(JsonView(_view1));
  3564. }
  3565. catch (Exception ex)
  3566. {
  3567. return Ok(JsonView(false, ex.Message));
  3568. }
  3569. }
  3570. /// <summary>
  3571. /// 费用审核
  3572. /// 修改团组费用审核状态
  3573. /// </summary>
  3574. /// <param name="_dto">参数Json字符串</param>
  3575. /// <returns></returns>
  3576. [HttpPost]
  3577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3578. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3579. {
  3580. #region 参数验证
  3581. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3582. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3583. #endregion
  3584. #region 页面操作权限验证
  3585. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3586. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3587. #endregion
  3588. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3589. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3590. DateTime dtNow = DateTime.Now;
  3591. _groupRepository.BeginTran();
  3592. int rst = 0;
  3593. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3594. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3595. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3596. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3597. var msgDatas = new List<dynamic>();
  3598. var dic_ccp_user = new Dictionary<int, int>() { };
  3599. foreach (var item in idList)
  3600. {
  3601. int CreditId = int.Parse(item);
  3602. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3603. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3604. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3605. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3606. .Where(s => s.Id == CreditId)
  3607. .ExecuteCommandAsync();
  3608. if (result < 1)
  3609. {
  3610. rst = -1;
  3611. _groupRepository.RollbackTran();
  3612. return Ok(JsonView(false, "操作失败并回滚!"));
  3613. }
  3614. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3615. if (creditData != null)
  3616. {
  3617. #region 应用通知配置
  3618. try
  3619. {
  3620. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3621. }
  3622. catch (Exception ex)
  3623. {
  3624. }
  3625. #endregion
  3626. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3627. string groupNameStr = string.Empty;
  3628. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3629. if (groupData != null) groupNameStr = groupData.TeamName;
  3630. string creditTypeStr = string.Empty;
  3631. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3632. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3633. string creditCurrency = string.Empty;
  3634. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3635. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3636. if (creditCurrency.Equals("CNY"))
  3637. {
  3638. creditData.DayRate = 1.0000M;
  3639. }
  3640. if (creditData.PayPercentage == 0.00M)
  3641. {
  3642. creditData.PayPercentage = 100M;
  3643. }
  3644. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3645. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3646. string msgContent = "";
  3647. if (creditCurrency.Equals("CNY"))
  3648. {
  3649. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  3650. }
  3651. else
  3652. {
  3653. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  3654. }
  3655. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3656. }
  3657. }
  3658. if (rst == 0)
  3659. {
  3660. _groupRepository.CommitTran();
  3661. foreach (var item in msgDatas)
  3662. {
  3663. //发送消息
  3664. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3665. }
  3666. #region 应用推送
  3667. try
  3668. {
  3669. foreach (var ccpId in dic_ccp_user.Keys)
  3670. {
  3671. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3672. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3673. }
  3674. }
  3675. catch (Exception)
  3676. {
  3677. }
  3678. #endregion
  3679. return Ok(JsonView(true, "操作成功!"));
  3680. }
  3681. return Ok(JsonView(false, "操作失败!"));
  3682. }
  3683. #endregion
  3684. #region 机票费用录入
  3685. /// <summary>
  3686. /// 机票录入当前登录人可操作团组
  3687. /// </summary>
  3688. /// <param name="dto"></param>
  3689. /// <returns></returns>
  3690. [HttpPost]
  3691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3692. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3693. {
  3694. try
  3695. {
  3696. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3697. if (groupData.Code != 0)
  3698. {
  3699. return Ok(JsonView(false, groupData.Msg));
  3700. }
  3701. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3702. }
  3703. catch (Exception ex)
  3704. {
  3705. return Ok(JsonView(false, ex.Message));
  3706. }
  3707. }
  3708. /// <summary>
  3709. /// 机票费用录入列表
  3710. /// </summary>
  3711. /// <param name="dto"></param>
  3712. /// <returns></returns>
  3713. [HttpPost]
  3714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3715. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3716. {
  3717. try
  3718. {
  3719. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3720. if (groupData.Code != 0)
  3721. {
  3722. return Ok(JsonView(false, groupData.Msg));
  3723. }
  3724. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3725. }
  3726. catch (Exception ex)
  3727. {
  3728. return Ok(JsonView(false, ex.Message));
  3729. throw;
  3730. }
  3731. }
  3732. /// <summary>
  3733. /// 根据id查询费用录入信息
  3734. /// </summary>
  3735. /// <param name="dto"></param>
  3736. /// <returns></returns>
  3737. [HttpPost]
  3738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3739. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3740. {
  3741. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3742. if (groupData.Code != 0)
  3743. {
  3744. return Ok(JsonView(false, groupData.Msg));
  3745. }
  3746. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3747. }
  3748. /// <summary>
  3749. /// 机票费用录入操作(Status:1.新增,2.修改)
  3750. /// </summary>
  3751. /// <param name="dto"></param>
  3752. /// <returns></returns>
  3753. [HttpPost]
  3754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3755. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3756. {
  3757. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3758. if (groupData.Code != 0)
  3759. {
  3760. return Ok(JsonView(false, groupData.Msg));
  3761. }
  3762. #region 应用推送
  3763. try
  3764. {
  3765. var diId = dto.AirTicketResOpData.DiId;
  3766. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3767. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3768. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3769. //自动审核
  3770. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  3771. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  3772. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  3773. $"GroupId:{diId};airId:{dataId};",
  3774. status,
  3775. auditMsg);
  3776. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3777. //2024-10-21 新增LZ UID
  3778. var userIds = new List<int>() { 21 };
  3779. string title = $"系统通知";
  3780. string content = "";
  3781. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3782. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3783. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3784. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3785. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3786. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3787. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3788. }
  3789. catch (Exception ex)
  3790. {
  3791. }
  3792. #endregion
  3793. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3794. }
  3795. /// <summary>
  3796. /// 机票费用自动审核 AI识别方式
  3797. /// </summary>
  3798. /// <returns></returns>
  3799. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  3800. {
  3801. var ecoTypeIds = new List<int>() {
  3802. 459, //超经舱
  3803. 460, //经济舱
  3804. 1430, //公务舱(实际经济舱)
  3805. 1432, //头等舱(实际经济舱)
  3806. };
  3807. var bizTypeIds = new List<int>() {
  3808. 457, //头等舱
  3809. 458, //公务舱
  3810. 1431, //头等舱(实际公务舱)
  3811. };
  3812. var auditFeeTypeIds = new List<int>() { };
  3813. auditFeeTypeIds.AddRange(ecoTypeIds);
  3814. auditFeeTypeIds.AddRange(bizTypeIds);
  3815. int currModule = 85;
  3816. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  3817. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  3818. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  3819. .Select((x, y) => new
  3820. {
  3821. x.Id,
  3822. CcpId = y.Id,
  3823. x.FlightsDate,
  3824. x.PrePrice,
  3825. x.CType,
  3826. x.ClientNum,
  3827. x.DIId
  3828. })
  3829. .FirstAsync();
  3830. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  3831. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  3832. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  3833. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  3834. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  3835. var groupCostContents = await _sqlSugar
  3836. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  3837. .Where(x => x.IsDel == 0 && x.Diid == diId)
  3838. .ToListAsync();
  3839. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  3840. //处理 成本详细信息日期为空 填装费用信息
  3841. var airFeeLabel = new StringBuilder();
  3842. airFeeLabel.AppendLine("费用成本:");
  3843. for (int i = 0; i < groupCostContents.Count; i++)
  3844. {
  3845. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  3846. {
  3847. int index = i - 1;
  3848. if (index >= 0)
  3849. {
  3850. groupCostContents[i].Date = groupCostContents[index].Date;
  3851. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3852. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3853. }
  3854. }
  3855. else
  3856. {
  3857. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3858. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3859. }
  3860. var item = groupCostContents[i];
  3861. airFeeLabel.AppendLine($"{item.Date}");
  3862. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  3863. }
  3864. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  3865. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  3866. //访问Kimi AI 返回价格结果
  3867. var msgs = new List<SeedMessages>()
  3868. {
  3869. new ()
  3870. {
  3871. Role = KimiRole.user,
  3872. Content = airFeeLabel.ToString()
  3873. }
  3874. };
  3875. var client = new KiMiApiClient();
  3876. var kimiApiResult = await client.SeedMessage(msgs);
  3877. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  3878. string clients = kimiApiResult_JObject["content"].ToString();
  3879. decimal ecoPri_kimiAI = 0.00M,
  3880. bizPri_kimiAI = 0.00M;
  3881. //单个价格: 经济舱价格
  3882. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  3883. //价格文本包含/:/前经济舱价格 /后公务舱价格
  3884. if (clients.Contains('/'))
  3885. {
  3886. var priArray = clients.Split('/');
  3887. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  3888. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  3889. }
  3890. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  3891. var isAutoAudit = false;
  3892. //价格验证处理
  3893. //经济舱
  3894. if (ecoTypeIds.Contains(airInfo.CType))
  3895. {
  3896. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  3897. }
  3898. //公务舱
  3899. else if (bizTypeIds.Contains(airInfo.CType))
  3900. {
  3901. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  3902. }
  3903. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  3904. //是否执行自动审核
  3905. if (isAutoAudit)
  3906. {
  3907. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3908. .SetColumns(x => x.IsAuditGM == 3)
  3909. .SetColumns(x => x.AuditGMOperate == 4)
  3910. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  3911. .Where(x => x.Id == airInfo.CcpId)
  3912. .ExecuteCommandAsync();
  3913. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  3914. }
  3915. return (false, "当前费用超过成本费用,不可自动审核!");
  3916. }
  3917. /// <summary>
  3918. /// 机票费用录入
  3919. /// 自动审核测试 - AI 识别
  3920. /// </summary>
  3921. /// <param name="groupId"></param>
  3922. /// <param name="Id"></param>
  3923. /// <returns></returns>
  3924. [HttpPost]
  3925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3926. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  3927. {
  3928. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  3929. return Ok(JsonView(status, msg));
  3930. }
  3931. /// <summary>
  3932. /// 根据舱位类型查询接团客户名单信息
  3933. /// </summary>
  3934. /// <param name="dto"></param>
  3935. /// <returns></returns>
  3936. [HttpPost]
  3937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3938. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  3939. {
  3940. try
  3941. {
  3942. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  3943. if (crm_Groups.Count != 0)
  3944. {
  3945. var Customer = new List<dynamic>();
  3946. foreach (var item in crm_Groups)
  3947. {
  3948. var data = new
  3949. {
  3950. item.Id,
  3951. item.Pinyin,
  3952. Name = item.LastName + item.FirstName
  3953. };
  3954. Customer.Add(data);
  3955. }
  3956. return Ok(JsonView(true, "查询成功!", Customer));
  3957. }
  3958. return Ok(JsonView(true, "暂无数据", crm_Groups));
  3959. }
  3960. catch (Exception ex)
  3961. {
  3962. return Ok(JsonView(false, "程序错误!"));
  3963. throw;
  3964. }
  3965. }
  3966. /// <summary>
  3967. /// 根据团号获取客户信息
  3968. /// </summary>
  3969. /// <param name="dto"></param>
  3970. /// <returns></returns>
  3971. [HttpPost]
  3972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3973. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  3974. {
  3975. var jw = JsonView(false);
  3976. if (dto.DIID < 1)
  3977. {
  3978. jw.Msg += "请输入正确的diid";
  3979. return Ok(jw);
  3980. }
  3981. var arr = GetSimplClientList(dto.DIID);
  3982. jw = JsonView(true, "获取成功!", arr);
  3983. return Ok(jw);
  3984. }
  3985. private List<SimplClientInfo> GetSimplClientList(int diId)
  3986. {
  3987. 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);
  3988. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3989. foreach (var item in arr)
  3990. {
  3991. EncryptionProcessor.DecryptProperties(item);
  3992. }
  3993. return arr;
  3994. }
  3995. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  3996. {
  3997. string result = origin;
  3998. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3999. {
  4000. string[] temparr = origin.Split(',');
  4001. string fistrStr = temparr[0];
  4002. int count = temparr.Length;
  4003. bool success = int.TryParse(fistrStr, out int tempId);
  4004. if (success)
  4005. {
  4006. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4007. if (tempInfo != null)
  4008. {
  4009. if (count > 1)
  4010. {
  4011. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4012. }
  4013. else
  4014. {
  4015. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4016. }
  4017. }
  4018. }
  4019. }
  4020. return result;
  4021. }
  4022. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4023. {
  4024. string result = origin;
  4025. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4026. {
  4027. string[] temparr = origin.Split(',');
  4028. result = "";
  4029. foreach (var item in temparr)
  4030. {
  4031. bool success = int.TryParse(item, out int tempId);
  4032. if (success)
  4033. {
  4034. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4035. if (tempInfo != null)
  4036. {
  4037. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4038. }
  4039. }
  4040. }
  4041. }
  4042. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4043. return result;
  4044. }
  4045. /// <summary>
  4046. /// 机票费用录入,删除
  4047. /// </summary>
  4048. /// <param name="dto"></param>
  4049. /// <returns></returns>
  4050. [HttpPost]
  4051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4052. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4053. {
  4054. try
  4055. {
  4056. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4057. if (res)
  4058. {
  4059. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4060. {
  4061. IsDel = 1,
  4062. DeleteUserId = dto.DeleteUserId,
  4063. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4064. }).ExecuteCommandAsync();
  4065. return Ok(JsonView(true, "删除成功!"));
  4066. }
  4067. return Ok(JsonView(false, "删除失败!"));
  4068. }
  4069. catch (Exception ex)
  4070. {
  4071. return Ok(JsonView(false, "程序错误!"));
  4072. throw;
  4073. }
  4074. }
  4075. /// <summary>
  4076. /// 导出机票录入报表
  4077. /// </summary>
  4078. /// <param name="dto"></param>
  4079. /// <returns></returns>
  4080. [HttpPost]
  4081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4082. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4083. {
  4084. try
  4085. {
  4086. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4087. if (groupData.Code != 0)
  4088. {
  4089. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4090. }
  4091. else
  4092. {
  4093. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4094. if (AirTicketReservations.Count != 0)
  4095. {
  4096. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4097. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4098. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4099. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4100. var designer = new WorkbookDesigner
  4101. {
  4102. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  4103. };
  4104. decimal countCost = 0;
  4105. foreach (var item in AirTicketReservations)
  4106. {
  4107. #region 处理客人姓名
  4108. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  4109. item.ClientName = clientNames;
  4110. #endregion
  4111. if (item.BankType == "其他")
  4112. {
  4113. item.BankNo = "--";
  4114. }
  4115. else
  4116. {
  4117. if (!string.IsNullOrEmpty(item.BankType))
  4118. {
  4119. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  4120. }
  4121. }
  4122. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4123. item.Price = System.Decimal.Round(item.Price, 2);
  4124. countCost += Convert.ToDecimal(item.Price);
  4125. }
  4126. designer.SetDataSource("Export", AirTicketReservations);
  4127. designer.SetDataSource("ExportDiCode", diCode);
  4128. designer.SetDataSource("ExportDiName", diName);
  4129. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4130. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4131. designer.Process();
  4132. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4133. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4134. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4135. return Ok(JsonView(true, "成功", url = rst));
  4136. }
  4137. else
  4138. {
  4139. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4140. }
  4141. }
  4142. }
  4143. catch (Exception ex)
  4144. {
  4145. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4146. throw;
  4147. }
  4148. }
  4149. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4150. /// <summary>
  4151. /// 行程单导出
  4152. /// </summary>
  4153. /// <param name="dto"></param>
  4154. /// <returns></returns>
  4155. [HttpPost]
  4156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4157. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4158. {
  4159. try
  4160. {
  4161. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4162. if (groupData.Code != 0)
  4163. {
  4164. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4165. }
  4166. else
  4167. {
  4168. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4169. if (dto.Language == "CN")
  4170. {
  4171. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4172. var builder = new DocumentBuilder(doc);
  4173. int tableIndex = 0;//表格索引
  4174. //得到文档中的第一个表格
  4175. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4176. foreach (var item in _AirTicketReservations)
  4177. {
  4178. #region 处理固定数据
  4179. string[] FlightsCode = item.FlightsCode.Split('/');
  4180. if (FlightsCode.Length != 0)
  4181. {
  4182. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4183. if (_AirCompany != null)
  4184. {
  4185. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4186. }
  4187. else
  4188. {
  4189. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4190. }
  4191. }
  4192. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4193. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4194. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4195. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4196. string name = "";
  4197. foreach (string clientName in nameArray)
  4198. {
  4199. if (!name.Contains(clientName))
  4200. {
  4201. name += clientName + ",";
  4202. }
  4203. }
  4204. if (!string.IsNullOrWhiteSpace(name))
  4205. {
  4206. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4207. }
  4208. else
  4209. {
  4210. table.Range.Bookmarks["ClientName"].Text = "--";
  4211. }
  4212. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4213. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4214. table.Range.Bookmarks["JointTicket"].Text = "--";
  4215. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4216. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4217. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4218. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4219. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4220. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4221. #endregion
  4222. #region 循环数据处理
  4223. var airs = new List<AirInfo>();
  4224. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4225. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4226. for (int i = 0; i < FlightsCode.Length; i++)
  4227. {
  4228. var air = new AirInfo();
  4229. string[] tempstr = DayArray[i]
  4230. .Replace("\r\n", string.Empty)
  4231. .Replace("\\r\\n", string.Empty)
  4232. .TrimStart().TrimEnd()
  4233. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4234. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4235. string starCity = "";
  4236. if (star_Three != null)
  4237. {
  4238. starCity = star_Three.AirPort;
  4239. }
  4240. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4241. string EndCity = "";
  4242. if (End_Three != null)
  4243. {
  4244. EndCity = End_Three.AirPort;
  4245. }
  4246. air.Destination = starCity + "/" + EndCity;
  4247. air.Flight = FlightsCode[i];
  4248. air.SeatingClass = item.CTypeName;
  4249. string dateTime = tempstr[2];
  4250. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4251. air.FlightDate = DateTemp;
  4252. air.DepartureTime = tempstr[5];
  4253. air.LandingTime = tempstr[6];
  4254. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4255. air.TicketStatus = "--";
  4256. air.Luggage = "--";
  4257. air.DepartureTerminal = "--";
  4258. air.LandingTerminal = "--";
  4259. airs.Add(air);
  4260. }
  4261. int row = 13;
  4262. for (int i = 0; i < airs.Count; i++)
  4263. {
  4264. if (airs.Count > 2)
  4265. {
  4266. for (int j = 0; j < airs.Count - 2; j++)
  4267. {
  4268. var CopyRow = table.Rows[12].Clone(true);
  4269. table.Rows.Add(CopyRow);
  4270. }
  4271. }
  4272. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4273. int index = 0;
  4274. foreach (PropertyInfo property in properties)
  4275. {
  4276. string value = property.GetValue(airs[i]).ToString();
  4277. Cell ishcel0 = table.Rows[row].Cells[index];
  4278. var p = new Paragraph(doc);
  4279. string s = value;
  4280. p.AppendChild(new Run(doc, s));
  4281. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4282. ishcel0.AppendChild(p);
  4283. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4284. index++;
  4285. }
  4286. row++;
  4287. }
  4288. #endregion
  4289. var lastParagraph = new Paragraph(doc);
  4290. //第一个表格末尾加段落
  4291. table.ParentNode.InsertAfter(lastParagraph, table);
  4292. //复制第一个表格
  4293. Table cloneTable = (Table)table.Clone(true);
  4294. //在文档末尾段落后面加入复制的表格
  4295. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4296. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4297. {
  4298. int rownewsIndex = 13;
  4299. for (int i = 0; i < 2; i++)
  4300. {
  4301. var CopyRow = table.Rows[12].Clone(true);
  4302. table.Rows.RemoveAt(13);
  4303. table.Rows.Add(CopyRow);
  4304. rownewsIndex++;
  4305. }
  4306. }
  4307. else
  4308. {
  4309. table.Rows.RemoveAt(12);
  4310. }
  4311. cloneTable.Rows.RemoveAt(12);
  4312. }
  4313. if (_AirTicketReservations.Count != 0)
  4314. {
  4315. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4316. if (FlightsCode.Length != 0)
  4317. {
  4318. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4319. if (_AirCompany != null)
  4320. {
  4321. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4322. }
  4323. else
  4324. {
  4325. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4326. }
  4327. }
  4328. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4329. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4330. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4331. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4332. string name = "";
  4333. foreach (string clientName in nameArray)
  4334. {
  4335. if (!name.Contains(clientName))
  4336. {
  4337. name += clientName + ",";
  4338. }
  4339. }
  4340. if (!string.IsNullOrWhiteSpace(name))
  4341. {
  4342. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4343. }
  4344. else
  4345. {
  4346. table.Range.Bookmarks["ClientName"].Text = "--";
  4347. }
  4348. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4349. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4350. table.Range.Bookmarks["JointTicket"].Text = "--";
  4351. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4352. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4353. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4354. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4355. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4356. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4357. }
  4358. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4359. //保存合并后的文档
  4360. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4361. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4362. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4363. return Ok(JsonView(true, "成功!", rst));
  4364. }
  4365. else
  4366. {
  4367. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4368. var builder = new DocumentBuilder(doc);
  4369. int tableIndex = 0;//表格索引
  4370. //得到文档中的第一个表格
  4371. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4372. var texts = new List<string>();
  4373. foreach (var item in _AirTicketReservations)
  4374. {
  4375. string[] FlightsCode = item.FlightsCode.Split('/');
  4376. if (FlightsCode.Length != 0)
  4377. {
  4378. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4379. if (_AirCompany != null)
  4380. {
  4381. if (!transDic.ContainsKey(_AirCompany.CnName))
  4382. {
  4383. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4384. }
  4385. }
  4386. else
  4387. {
  4388. if (!transDic.ContainsKey("--"))
  4389. {
  4390. transDic.Add("--", "--");
  4391. }
  4392. }
  4393. }
  4394. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4395. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4396. string name = "";
  4397. foreach (string clientName in nameArray)
  4398. {
  4399. name += clientName + ",";
  4400. }
  4401. if (!texts.Contains(name))
  4402. {
  4403. texts.Add(name);
  4404. }
  4405. var airs = new List<AirInfo>();
  4406. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4407. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4408. for (int i = 0; i < FlightsCode.Length; i++)
  4409. {
  4410. var air = new AirInfo();
  4411. string[] tempstr = DayArray[i]
  4412. .Replace("\r\n", string.Empty)
  4413. .Replace("\\r\\n", string.Empty)
  4414. .TrimStart().TrimEnd()
  4415. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4416. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4417. if (star_Three != null)
  4418. {
  4419. if (!transDic.ContainsKey(star_Three.AirPort))
  4420. {
  4421. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4422. }
  4423. }
  4424. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4425. if (End_Three != null)
  4426. {
  4427. if (!transDic.ContainsKey(End_Three.AirPort))
  4428. {
  4429. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4430. }
  4431. }
  4432. if (!texts.Contains(item.CTypeName))
  4433. {
  4434. texts.Add(item.CTypeName);
  4435. }
  4436. }
  4437. }
  4438. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4439. if (transData.Count > 0)
  4440. {
  4441. foreach (TranslateResult item in transData)
  4442. {
  4443. if (!transDic.ContainsKey(item.Query))
  4444. {
  4445. transDic.Add(item.Query, item.Translation);
  4446. }
  4447. }
  4448. }
  4449. foreach (var item in _AirTicketReservations)
  4450. {
  4451. #region 处理固定数据
  4452. string[] FlightsCode = item.FlightsCode.Split('/');
  4453. if (FlightsCode.Length != 0)
  4454. {
  4455. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4456. if (_AirCompany != null)
  4457. {
  4458. string str = "--";
  4459. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4460. if (!string.IsNullOrEmpty(translateResult))
  4461. {
  4462. str = translateResult;
  4463. str = _airTicketResRep.Processing(str);
  4464. }
  4465. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4466. }
  4467. else
  4468. {
  4469. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4470. }
  4471. }
  4472. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4473. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4474. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4475. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4476. string names = "";
  4477. foreach (string clientName in nameArray)
  4478. {
  4479. names += clientName + ",";
  4480. }
  4481. if (!string.IsNullOrWhiteSpace(names))
  4482. {
  4483. string str = "--";
  4484. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4485. if (!string.IsNullOrEmpty(translateResult))
  4486. {
  4487. str = translateResult;
  4488. str = _airTicketResRep.Processing(str);
  4489. }
  4490. table.Range.Bookmarks["ClientName"].Text = str;
  4491. }
  4492. else
  4493. {
  4494. table.Range.Bookmarks["ClientName"].Text = "--";
  4495. }
  4496. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4497. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4498. table.Range.Bookmarks["JointTicket"].Text = "--";
  4499. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4500. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4501. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4502. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4503. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4504. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4505. #endregion
  4506. #region 循环数据处理
  4507. var airs = new List<AirInfo>();
  4508. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4509. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4510. for (int i = 0; i < FlightsCode.Length; i++)
  4511. {
  4512. var air = new AirInfo();
  4513. string[] tempstr = DayArray[i]
  4514. .Replace("\r\n", string.Empty)
  4515. .Replace("\\r\\n", string.Empty)
  4516. .TrimStart().TrimEnd()
  4517. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4518. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4519. string starCity = "";
  4520. if (star_Three != null)
  4521. {
  4522. string str2 = "--";
  4523. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4524. if (!string.IsNullOrEmpty(translateResult2))
  4525. {
  4526. str2 = translateResult2;
  4527. str2 = _airTicketResRep.Processing(str2);
  4528. }
  4529. starCity = str2;
  4530. }
  4531. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4532. string EndCity = "";
  4533. if (End_Three != null)
  4534. {
  4535. string str1 = "--";
  4536. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4537. if (!string.IsNullOrEmpty(translateResult1))
  4538. {
  4539. str1 = translateResult1;
  4540. str1 = _airTicketResRep.Processing(str1);
  4541. }
  4542. EndCity = str1;
  4543. }
  4544. air.Destination = starCity + "/" + EndCity;
  4545. air.Flight = FlightsCode[i];
  4546. string str = "--";
  4547. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4548. if (!string.IsNullOrEmpty(translateResult))
  4549. {
  4550. str = translateResult;
  4551. str = _airTicketResRep.Processing(str);
  4552. }
  4553. air.SeatingClass = str;
  4554. string dateTime = tempstr[2];
  4555. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4556. air.FlightDate = DateTemp;
  4557. air.DepartureTime = tempstr[5];
  4558. air.LandingTime = tempstr[6];
  4559. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4560. air.TicketStatus = "--";
  4561. air.Luggage = "--";
  4562. air.DepartureTerminal = "--";
  4563. air.LandingTerminal = "--";
  4564. airs.Add(air);
  4565. }
  4566. int row = 13;
  4567. for (int i = 0; i < airs.Count; i++)
  4568. {
  4569. if (airs.Count > 2)
  4570. {
  4571. for (int j = 0; j < airs.Count - 2; j++)
  4572. {
  4573. var CopyRow = table.Rows[12].Clone(true);
  4574. table.Rows.Add(CopyRow);
  4575. }
  4576. }
  4577. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4578. int index = 0;
  4579. foreach (PropertyInfo property in properties)
  4580. {
  4581. string value = property.GetValue(airs[i]).ToString();
  4582. Cell ishcel0 = table.Rows[row].Cells[index];
  4583. var p = new Paragraph(doc);
  4584. string s = value;
  4585. p.AppendChild(new Run(doc, s));
  4586. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4587. ishcel0.AppendChild(p);
  4588. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4589. //ishcel0.CellFormat.VerticalAlignment=
  4590. index++;
  4591. }
  4592. row++;
  4593. }
  4594. #endregion
  4595. var lastParagraph = new Paragraph(doc);
  4596. //第一个表格末尾加段落
  4597. table.ParentNode.InsertAfter(lastParagraph, table);
  4598. //复制第一个表格
  4599. Table cloneTable = (Table)table.Clone(true);
  4600. //在文档末尾段落后面加入复制的表格
  4601. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4602. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4603. {
  4604. int rownewsIndex = 13;
  4605. for (int i = 0; i < 2; i++)
  4606. {
  4607. var CopyRow = table.Rows[12].Clone(true);
  4608. table.Rows.RemoveAt(13);
  4609. table.Rows.Add(CopyRow);
  4610. rownewsIndex++;
  4611. }
  4612. }
  4613. else
  4614. {
  4615. table.Rows.RemoveAt(12);
  4616. }
  4617. cloneTable.Rows.RemoveAt(12);
  4618. }
  4619. if (_AirTicketReservations.Count != 0)
  4620. {
  4621. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4622. if (FlightsCode.Length != 0)
  4623. {
  4624. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4625. if (_AirCompany != null)
  4626. {
  4627. string str = "--";
  4628. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4629. if (!string.IsNullOrEmpty(translateResult))
  4630. {
  4631. str = translateResult;
  4632. str = _airTicketResRep.Processing(str);
  4633. }
  4634. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4635. }
  4636. else
  4637. {
  4638. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4639. }
  4640. }
  4641. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4642. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4643. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4644. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4645. string names = "";
  4646. foreach (string clientName in nameArray)
  4647. {
  4648. names += clientName + ",";
  4649. }
  4650. if (!string.IsNullOrWhiteSpace(names))
  4651. {
  4652. string str = "--";
  4653. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4654. if (!string.IsNullOrEmpty(translateResult))
  4655. {
  4656. str = translateResult;
  4657. str = _airTicketResRep.Processing(str);
  4658. }
  4659. table.Range.Bookmarks["ClientName"].Text = str;
  4660. }
  4661. else
  4662. {
  4663. table.Range.Bookmarks["ClientName"].Text = "--";
  4664. }
  4665. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4666. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4667. table.Range.Bookmarks["JointTicket"].Text = "--";
  4668. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4669. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4670. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4671. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4672. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4673. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4674. }
  4675. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4676. //保存合并后的文档
  4677. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4678. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4679. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4680. return Ok(JsonView(true, "成功!", rst));
  4681. }
  4682. }
  4683. }
  4684. catch (Exception ex)
  4685. {
  4686. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4687. throw;
  4688. }
  4689. }
  4690. #endregion
  4691. #region 团组增减款项 --> 其他款项
  4692. /// <summary>
  4693. /// 团组增减款项下拉框绑定
  4694. /// </summary>
  4695. /// <param name="dto"></param>
  4696. /// <returns></returns>
  4697. [HttpPost]
  4698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4699. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4700. {
  4701. #region 参数验证
  4702. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4703. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4704. #endregion
  4705. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4706. }
  4707. /// <summary>
  4708. /// 根据团组Id查询团组增减款项
  4709. /// </summary>
  4710. /// <param name="dto"></param>
  4711. /// <returns></returns>
  4712. [HttpPost]
  4713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4714. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4715. {
  4716. #region 参数验证
  4717. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4718. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4719. #endregion
  4720. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4721. }
  4722. /// <summary>
  4723. /// 团组增减款项操作(Status:1.新增,2.修改)
  4724. /// </summary>
  4725. /// <param name="dto"></param>
  4726. /// <returns></returns>
  4727. [HttpPost]
  4728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4729. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4730. {
  4731. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4732. if (groupData.Code != 200)
  4733. {
  4734. return Ok(JsonView(false, groupData.Msg));
  4735. }
  4736. #region 应用推送
  4737. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4738. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4739. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4740. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4741. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4742. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4743. //自动审核
  4744. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4745. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4746. //2024-10-21 新增LZ UID
  4747. var userIds = new List<int>() { 21 };
  4748. string title = $"系统通知";
  4749. string content = "";
  4750. var diId = dto.DiId;
  4751. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4752. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4753. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4754. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4755. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4756. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4757. #endregion
  4758. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4759. }
  4760. /// <summary>
  4761. /// 团组增减款项操作 删除
  4762. /// </summary>
  4763. /// <param name="dto"></param>
  4764. /// <returns></returns>
  4765. [HttpPost]
  4766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4767. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4768. {
  4769. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4770. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4771. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4772. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  4773. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  4774. }
  4775. /// <summary>
  4776. /// 根据团组增减款项Id查询
  4777. /// </summary>
  4778. /// <param name="dto"></param>
  4779. /// <returns></returns>
  4780. [HttpPost]
  4781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4782. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4783. {
  4784. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4785. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4786. }
  4787. /// <summary>
  4788. /// 查询供应商名称
  4789. /// </summary>
  4790. /// <param name="dto"></param>
  4791. /// <returns></returns>
  4792. [HttpPost]
  4793. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4794. {
  4795. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4796. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4797. ?? new List<Grp_DecreasePayments>();
  4798. dbResult = dbResult.Distinct(new
  4799. ProductComparer()).ToList();
  4800. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4801. {
  4802. x.Id,
  4803. x.SupplierAddress,
  4804. x.SupplierArea,
  4805. x.SupplierContact,
  4806. x.SupplierContactNumber,
  4807. x.SupplierEmail,
  4808. x.SupplierName,
  4809. x.SupplierSocialAccount,
  4810. x.SupplierTypeId,
  4811. }).ToList());
  4812. return Ok(jw);
  4813. }
  4814. /// <summary>
  4815. /// 团组增减款项 OTA匹配
  4816. /// </summary>
  4817. /// <param name="file"></param>
  4818. /// <returns></returns>
  4819. [HttpPost]
  4820. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4821. {
  4822. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4823. string fileName = file.FileName;
  4824. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4825. {
  4826. return Ok(JsonView(false, "请上传Excel文件!"));
  4827. }
  4828. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4829. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4830. if (!Directory.Exists(path))
  4831. {
  4832. Directory.CreateDirectory(path);
  4833. }
  4834. var filePath = @$"{path}/{fileName}";
  4835. //保存文件
  4836. using (FileStream fs = System.IO.File.Create(filePath))
  4837. {
  4838. file.CopyTo(fs);
  4839. fs.Flush();
  4840. }
  4841. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4842. //读取ExcelFile
  4843. DataTable dt = ConvertExcelToDataTable(filePath);
  4844. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4845. dt.TableName = "TB";
  4846. //修改table列名
  4847. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4848. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4849. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4850. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4851. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4852. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4853. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4854. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4855. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4856. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4857. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4858. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4859. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4860. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4861. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4862. var otaOrderNos = new List<string>();
  4863. foreach (DataRow item in dt.Rows)
  4864. {
  4865. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4866. }
  4867. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4868. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4869. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4870. .Select((dp, di) => new
  4871. {
  4872. dp.PriceName,
  4873. dp.OTAOrderNo,
  4874. dp.FeeTotal,
  4875. di.TeamName,
  4876. })
  4877. .ToListAsync();
  4878. foreach (DataRow item in dt.Rows)
  4879. {
  4880. var otaOrderNo = item["OTAOrderNo"].ToString();
  4881. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4882. if (oaData == null) continue;
  4883. item["GroupName"] = oaData.TeamName;
  4884. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4885. }
  4886. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  4887. var pairs = new Dictionary<string, object>();
  4888. var datas = new List<DataTable>
  4889. {
  4890. dt
  4891. };
  4892. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4893. return Ok(JsonView(true, "操作成功", new { url }));
  4894. }
  4895. #region
  4896. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  4897. {
  4898. // 创建Workbook对象
  4899. var workbook = new Workbook(excelFilePath);
  4900. // 获取第一个工作表
  4901. var worksheet = workbook.Worksheets[0];
  4902. // 将工作表转换为DataTable
  4903. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4904. return dataTable;
  4905. }
  4906. #endregion
  4907. /// <summary>
  4908. /// 世运会数据
  4909. /// </summary>
  4910. /// <returns></returns>
  4911. [HttpGet]
  4912. public IActionResult WorldGamesData()
  4913. {
  4914. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  4915. var groupMenu = setData.GroupBy(x => x.T0);
  4916. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  4917. foreach (var item in groupMenu)
  4918. {
  4919. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  4920. {
  4921. Data = new SetDataView
  4922. {
  4923. Name = item.Key
  4924. },
  4925. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  4926. });
  4927. }
  4928. return Ok(JsonView(true, "success", resultArr));
  4929. }
  4930. #endregion
  4931. #region 文件上传、删除
  4932. /// <summary>
  4933. /// region 文件上传 可以带参数
  4934. /// </summary>
  4935. /// <param name="file"></param>
  4936. /// <returns></returns>
  4937. [HttpPost]
  4938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4939. public async Task<IActionResult> UploadProject(IFormFile file)
  4940. {
  4941. //var TypeName = Request.Headers["TypeName"].ToString();
  4942. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  4943. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4944. ////文件名称
  4945. //string projectFileName = file.FileName;
  4946. ////上传的文件的路径
  4947. //string filePath = $"{fileDir}/{projectFileName}";
  4948. //if (TypeName == "A")//A代表团组增减款项
  4949. //{
  4950. // filePath = fileDir + $@"\团组增减款项相关文件";
  4951. // if (!Directory.Exists(filePath))
  4952. // {
  4953. // Directory.CreateDirectory(filePath);
  4954. // }
  4955. // //上传的文件的路径
  4956. // filePath += $@"\{projectFileName}";
  4957. //}
  4958. //else if (TypeName == "B")//B代表商邀相关文件
  4959. //{
  4960. // //上传的文件的路径
  4961. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4962. // if (!Directory.Exists(filePath))
  4963. // {
  4964. // Directory.CreateDirectory(filePath);
  4965. // }
  4966. // //上传的文件的路径
  4967. // filePath = $@"\{projectFileName}";
  4968. //}
  4969. //try
  4970. //{
  4971. // using (FileStream fs = System.IO.File.Create(filePath))
  4972. // {
  4973. // file.CopyTo(fs);
  4974. // fs.Flush();
  4975. // }
  4976. //}
  4977. //catch (Exception ex)
  4978. //{
  4979. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  4980. //}
  4981. //return Ok(JsonView(true, "上传成功!", projectFileName));
  4982. try
  4983. {
  4984. var TypeName = Request.Headers["TypeName"].ToString();
  4985. if (file != null)
  4986. {
  4987. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4988. //文件名称
  4989. string projectFileName = file.FileName;
  4990. //上传的文件的路径
  4991. string filePath = $"{fileDir}/{projectFileName}";
  4992. if (TypeName == "A")//A代表团组增减款项
  4993. {
  4994. if (!Directory.Exists(fileDir))
  4995. {
  4996. Directory.CreateDirectory(fileDir);
  4997. }
  4998. //上传的文件的路径
  4999. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5000. }
  5001. else if (TypeName == "B")//B代表商邀相关文件
  5002. {
  5003. if (!Directory.Exists(fileDir))
  5004. {
  5005. Directory.CreateDirectory(fileDir);
  5006. }
  5007. //上传的文件的路径
  5008. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5009. }
  5010. using (FileStream fs = System.IO.File.Create(filePath))
  5011. {
  5012. file.CopyTo(fs);
  5013. fs.Flush();
  5014. }
  5015. return Ok(JsonView(true, "上传成功!", projectFileName));
  5016. }
  5017. else
  5018. {
  5019. return Ok(JsonView(false, "上传失败!"));
  5020. }
  5021. }
  5022. catch (Exception ex)
  5023. {
  5024. return Ok(JsonView(false, ex.Message));
  5025. }
  5026. }
  5027. /// <summary>
  5028. /// 删除指定文件
  5029. /// </summary>
  5030. /// <param name="dto"></param>
  5031. /// <returns></returns>
  5032. [HttpPost]
  5033. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5034. public async Task<IActionResult> DelFile(DelFileDto dto)
  5035. {
  5036. try
  5037. {
  5038. var TypeName = Request.Headers["TypeName"].ToString();
  5039. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5040. string filePath = "";
  5041. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5042. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5043. int id = 0;
  5044. if (TypeName == "A")
  5045. {
  5046. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5047. // 删除该文件
  5048. System.IO.File.Delete(filePath);
  5049. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5050. .Where(a => a.Id == dto.Id)
  5051. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5052. .ExecuteCommandAsync();
  5053. }
  5054. else if (TypeName == "B")
  5055. {
  5056. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5057. // 删除该文件
  5058. System.IO.File.Delete(filePath);
  5059. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5060. if (info != null)
  5061. {
  5062. string[] files = Array.Empty<string>();
  5063. if (!string.IsNullOrEmpty(info.Attachment))
  5064. {
  5065. try
  5066. {
  5067. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5068. }
  5069. catch (Exception)
  5070. {
  5071. files = new List<string>() { info.Attachment }.ToArray();
  5072. }
  5073. }
  5074. if (files.Length > 0)
  5075. {
  5076. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5077. string filePath2 = string.Empty;
  5078. if (files1.Length > 0)
  5079. {
  5080. filePath2 = JsonConvert.SerializeObject(files1);
  5081. }
  5082. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5083. .Where(a => a.Id == dto.Id)
  5084. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5085. .ExecuteCommandAsync();
  5086. }
  5087. }
  5088. }
  5089. if (id != 0)
  5090. {
  5091. return Ok(JsonView(true, "成功!"));
  5092. }
  5093. else
  5094. {
  5095. return Ok(JsonView(false, "失败!"));
  5096. }
  5097. }
  5098. catch (Exception ex)
  5099. {
  5100. return Ok(JsonView(false, "程序错误!"));
  5101. throw;
  5102. }
  5103. }
  5104. /// <summary>
  5105. /// 文件上传多个文件 可以带参数
  5106. /// </summary>
  5107. /// <param name="files"></param>
  5108. /// <returns></returns>
  5109. [HttpPost]
  5110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5111. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5112. {
  5113. try
  5114. {
  5115. var TypeName = Request.Headers["TypeName"].ToString();
  5116. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5117. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5118. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5119. var filePahts = new List<string>();
  5120. foreach (var file in files)
  5121. {
  5122. //文件名称
  5123. string projectFileName = file.FileName;
  5124. //上传的文件的路径
  5125. string filePath = $"{fileDir}/{projectFileName}";
  5126. if (TypeName == "A")//A代表团组增减款项
  5127. {
  5128. if (!Directory.Exists(fileDir))
  5129. {
  5130. Directory.CreateDirectory(fileDir);
  5131. }
  5132. //上传的文件的路径
  5133. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5134. }
  5135. else if (TypeName == "B")//B代表商邀相关文件
  5136. {
  5137. if (!Directory.Exists(fileDir))
  5138. {
  5139. Directory.CreateDirectory(fileDir);
  5140. }
  5141. //上传的文件的路径
  5142. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5143. }
  5144. using (FileStream fs = System.IO.File.Create(filePath))
  5145. {
  5146. file.CopyTo(fs);
  5147. fs.Flush();
  5148. }
  5149. filePahts.Add(projectFileName);
  5150. }
  5151. return Ok(JsonView(true, "上传成功!", filePahts));
  5152. }
  5153. catch (Exception ex)
  5154. {
  5155. return Ok(JsonView(false, ex.Message));
  5156. }
  5157. }
  5158. #endregion
  5159. #region 商邀费用录入
  5160. /// <summary>
  5161. /// 根据团组Id查询商邀费用列表
  5162. /// </summary>
  5163. /// <param name="dto"></param>
  5164. /// <returns></returns>
  5165. [HttpPost]
  5166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5167. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5168. {
  5169. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5170. if (groupData.Code != 0)
  5171. {
  5172. return Ok(JsonView(false, groupData.Msg));
  5173. }
  5174. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5175. }
  5176. /// <summary>
  5177. /// 商邀费用列表
  5178. /// 下载文件
  5179. /// </summary>
  5180. /// <param name="id"></param>
  5181. /// <returns></returns>
  5182. [HttpGet("{id}")]
  5183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5184. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5185. {
  5186. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5187. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5188. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5189. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5190. var filePaths = new List<string>();
  5191. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5192. try
  5193. {
  5194. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5195. }
  5196. catch (Exception ex)
  5197. {
  5198. filePaths.Add(info.Attachment);
  5199. }
  5200. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5201. for (int i = 0; i < filePaths.Count; i++)
  5202. {
  5203. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5204. }
  5205. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5206. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5207. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5208. {
  5209. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5210. {
  5211. foreach (string filePath in filePaths)
  5212. {
  5213. if (System.IO.File.Exists(filePath))
  5214. {
  5215. // 获取文件名
  5216. string fileName = Path.GetFileName(filePath);
  5217. // 将文件添加到ZIP归档中
  5218. zipArchive.CreateEntryFromFile(filePath, fileName);
  5219. }
  5220. }
  5221. }
  5222. }
  5223. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5224. }
  5225. /// <summary>
  5226. /// 商邀费用 Info Page 基础数据源
  5227. /// </summary>
  5228. /// <returns></returns>
  5229. [HttpPost]
  5230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5231. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5232. {
  5233. try
  5234. {
  5235. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  5236. if (groupData.Code != 0)
  5237. {
  5238. return Ok(JsonView(false, groupData.Msg));
  5239. }
  5240. return Ok(JsonView(true, "操作成功", groupData.Data));
  5241. }
  5242. catch (Exception ex)
  5243. {
  5244. return Ok(JsonView(false, ex.Message));
  5245. throw;
  5246. }
  5247. }
  5248. /// <summary>
  5249. /// 根据商邀费用ID查询C表和商邀费用数据
  5250. /// </summary>
  5251. /// <param name="dto"></param>
  5252. /// <returns></returns>
  5253. [HttpPost]
  5254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5255. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5256. {
  5257. try
  5258. {
  5259. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5260. if (groupData.Code != 0)
  5261. {
  5262. return Ok(JsonView(false, groupData.Msg));
  5263. }
  5264. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5265. }
  5266. catch (Exception ex)
  5267. {
  5268. return Ok(JsonView(false, ex.Message));
  5269. throw;
  5270. }
  5271. }
  5272. /// <summary>
  5273. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5274. /// </summary>
  5275. /// <param name="dto"></param>
  5276. /// <returns></returns>
  5277. [HttpPost]
  5278. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5279. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5280. {
  5281. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5282. if (groupData.Code != 0)
  5283. {
  5284. return Ok(JsonView(false, groupData.Msg));
  5285. }
  5286. #region 应用推送
  5287. try
  5288. {
  5289. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5290. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5291. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5292. //2024-10-21 新增LZ UID
  5293. var userIds = new List<int>() { 21 };
  5294. string title = $"系统通知";
  5295. string content = "";
  5296. var diId = dto.DiId;
  5297. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5298. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5299. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5300. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5301. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5302. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5303. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5304. }
  5305. catch (Exception ex)
  5306. {
  5307. }
  5308. #endregion
  5309. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5310. }
  5311. /// <summary>
  5312. /// 商邀删除
  5313. /// </summary>
  5314. /// <param name="dto"></param>
  5315. /// <returns></returns>
  5316. [HttpPost]
  5317. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5318. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5319. {
  5320. try
  5321. {
  5322. _sqlSugar.BeginTran();
  5323. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5324. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5325. {
  5326. IsDel = 1,
  5327. DeleteUserId = dto.DeleteUserId,
  5328. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5329. })
  5330. .Where(it => it.Id == dto.Id)
  5331. .ExecuteCommand();
  5332. if (res1 > 0)
  5333. {
  5334. int _diId = 0;
  5335. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5336. if (_ioaInfo != null)
  5337. {
  5338. _diId = _ioaInfo.DiId;
  5339. }
  5340. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5341. .SetColumns(a => new Grp_CreditCardPayment()
  5342. {
  5343. IsDel = 1,
  5344. DeleteUserId = dto.DeleteUserId,
  5345. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5346. })
  5347. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5348. .ExecuteCommand();
  5349. if (res2 > 0)
  5350. {
  5351. _sqlSugar.CommitTran();
  5352. return Ok(JsonView(true, "删除成功!"));
  5353. }
  5354. }
  5355. _sqlSugar.RollbackTran();
  5356. return Ok(JsonView(false, "删除失败"));
  5357. }
  5358. catch (Exception ex)
  5359. {
  5360. _sqlSugar.RollbackTran();
  5361. return Ok(JsonView(false, ex.Message));
  5362. }
  5363. }
  5364. #endregion
  5365. #region 票据上传
  5366. /// <summary>
  5367. /// 团组模块文件上传
  5368. /// </summary>
  5369. /// <param name="dto"></param>
  5370. /// <returns></returns>
  5371. [HttpPost]
  5372. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5373. {
  5374. var jw = JsonView(false);
  5375. long M = 1024 * 1024;
  5376. if (dto.Files == null || dto.Files.Count == 0)
  5377. {
  5378. jw.Msg = "无文件信息!";
  5379. return Ok(jw);
  5380. }
  5381. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5382. {
  5383. jw.Msg = "文件大小超过20M!";
  5384. return Ok(jw);
  5385. }
  5386. //var nameSp = dto.File.FileName.Split(".");
  5387. //if (nameSp.Length < 2)
  5388. //{
  5389. // jw.Msg = "拓展名称有误!";
  5390. // return Ok(jw);
  5391. //}
  5392. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5393. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5394. //{
  5395. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5396. // return Ok(jw);
  5397. //}
  5398. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5399. if (Ctable == null)
  5400. {
  5401. jw.Msg = "Ctable指向有误!";
  5402. return Ok(jw);
  5403. }
  5404. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5405. if (groupInfo == null)
  5406. {
  5407. jw.Msg = "团组信息不存在!";
  5408. return Ok(jw);
  5409. }
  5410. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5411. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5412. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5413. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5414. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5415. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5416. try
  5417. {
  5418. if (!Directory.Exists(fileBase))
  5419. {
  5420. Directory.CreateDirectory(fileBase);
  5421. }
  5422. var saveArr = new List<Grp_GroupModelFile>();
  5423. foreach (var fileStream in dto.Files)
  5424. {
  5425. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5426. var file = new Grp_GroupModelFile()
  5427. {
  5428. Cid = dto.Cid,
  5429. CreateTime = DateTime.Now,
  5430. CreateUserId = dto.Userid,
  5431. Ctable = dto.Ctable,
  5432. Diid = dto.Diid,
  5433. IsDel = 0,
  5434. FilePath = saveFilePath,
  5435. FileName = fileStream.FileName
  5436. };
  5437. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5438. {
  5439. fileStream.CopyTo(fs);
  5440. fs.Flush();
  5441. }
  5442. saveArr.Add(file);
  5443. }
  5444. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5445. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5446. jw = JsonView(true, "保存成功!", new
  5447. {
  5448. count = addResult,
  5449. filesName = saveArr.Select(x => x.FileName)
  5450. });
  5451. }
  5452. catch (Exception ex)
  5453. {
  5454. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5455. {
  5456. count = 0,
  5457. filesName = Array.Empty<string>(),
  5458. });
  5459. }
  5460. return Ok(jw);
  5461. }
  5462. /// <summary>
  5463. /// 查询各模块已保存文件
  5464. /// </summary>
  5465. /// <param name="dto"></param>
  5466. /// <returns></returns>
  5467. [HttpPost]
  5468. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5469. {
  5470. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5471. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5472. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5473. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5474. {
  5475. expression = Expressionable.Create<Grp_GroupModelFile>()
  5476. .And(x => visaIds.Contains(x.CreateUserId));
  5477. }
  5478. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5479. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5480. .Where(expression.ToExpression())
  5481. .ToList();
  5482. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5483. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5484. {
  5485. x.FileName,
  5486. x.Id,
  5487. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5488. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5489. })));
  5490. }
  5491. /// <summary>
  5492. /// 下载该团组下的所有文件
  5493. /// </summary>
  5494. /// <param name="dto"></param>
  5495. /// <returns></returns>
  5496. [HttpPost]
  5497. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5498. {
  5499. var jw = JsonView(false);
  5500. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5501. if (groupInfo == null)
  5502. {
  5503. jw.Msg = "团组信息不存在!";
  5504. return Ok(jw);
  5505. }
  5506. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5507. var isModule = Convert.ToBoolean(dto.isModule);
  5508. var Zips = new Dictionary<string, Stream>();
  5509. var io = new IOOperatorHelper();
  5510. if (isModule)
  5511. {
  5512. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5513. foreach (var moduleArr in moduleGroup)
  5514. {
  5515. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5516. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5517. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5518. var chiZips = new Dictionary<string, Stream>();
  5519. foreach (var item in moduleArr)
  5520. {
  5521. if (System.IO.File.Exists(item.FilePath))
  5522. {
  5523. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5524. {
  5525. byte[] bytes = new byte[fileStream.Length];
  5526. fileStream.Read(bytes, 0, bytes.Length);
  5527. fileStream.Close();
  5528. Stream stream = new MemoryStream(bytes);
  5529. chiZips.Add(item.FileName, stream);
  5530. }
  5531. }
  5532. }
  5533. if (chiZips.Count > 0)
  5534. {
  5535. var byts = io.ConvertZipStream(chiZips);
  5536. Stream stream = new MemoryStream(byts);
  5537. Zips.Add(key.Name + "_.zip", stream);
  5538. }
  5539. }
  5540. }
  5541. else
  5542. {
  5543. foreach (var item in dbQuery)
  5544. {
  5545. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5546. {
  5547. byte[] bytes = new byte[fileStream.Length];
  5548. fileStream.Read(bytes, 0, bytes.Length);
  5549. fileStream.Close();
  5550. var stream = new MemoryStream(bytes);
  5551. while (Zips.ContainsKey(item.FileName))
  5552. {
  5553. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5554. }
  5555. Zips.Add(item.FileName, stream);
  5556. }
  5557. }
  5558. }
  5559. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5560. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5561. if (Zips.Count > 0)
  5562. {
  5563. var byts = io.ConvertZipStream(Zips);
  5564. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5565. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5566. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5567. }
  5568. else
  5569. {
  5570. jw.Msg = "暂无生成文件!";
  5571. }
  5572. return Ok(jw);
  5573. }
  5574. /// <summary>
  5575. /// 下载该团组下此模块的所有文件
  5576. /// </summary>
  5577. /// <param name="dto"></param>
  5578. /// <returns></returns>
  5579. [HttpPost]
  5580. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5581. {
  5582. var jw = JsonView(false);
  5583. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5584. if (groupInfo == null)
  5585. {
  5586. jw.Msg = "团组信息不存在!";
  5587. return Ok(jw);
  5588. }
  5589. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5590. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5591. && x.IsDel == 0);
  5592. if (key == null)
  5593. {
  5594. jw.Msg = "Ctable指向错误!";
  5595. return Ok(jw);
  5596. }
  5597. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5598. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5599. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5600. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5601. var io = new IOOperatorHelper();
  5602. var Zips = new Dictionary<string, Stream>();
  5603. foreach (var item in dbQuery)
  5604. {
  5605. if (System.IO.File.Exists(item.FilePath))
  5606. {
  5607. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5608. {
  5609. byte[] bytes = new byte[fileStream.Length];
  5610. fileStream.Read(bytes, 0, bytes.Length);
  5611. fileStream.Close();
  5612. var stream = new MemoryStream(bytes);
  5613. while (Zips.ContainsKey(item.FileName))
  5614. {
  5615. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5616. }
  5617. Zips.Add(item.FileName, stream);
  5618. }
  5619. }
  5620. }
  5621. if (Zips.Count > 0)
  5622. {
  5623. var byts = io.ConvertZipStream(Zips);
  5624. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5625. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5626. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5627. }
  5628. else
  5629. {
  5630. jw.Msg = "暂无生成文件!";
  5631. }
  5632. return Ok(jw);
  5633. }
  5634. /// <summary>
  5635. /// 删除该团组下的指定文件
  5636. /// </summary>
  5637. /// <param name="dto"></param>
  5638. /// <returns></returns>
  5639. [HttpPost]
  5640. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5641. {
  5642. var jw = JsonView(false);
  5643. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5644. if (sing == null)
  5645. {
  5646. jw.Msg = "暂无";
  5647. return Ok(jw);
  5648. }
  5649. if (System.IO.File.Exists(sing.FilePath))
  5650. {
  5651. try
  5652. {
  5653. System.IO.File.Delete(sing.FilePath);
  5654. }
  5655. catch (Exception ex)
  5656. {
  5657. jw.Msg = "删除失败!" + ex.Message;
  5658. return Ok(jw);
  5659. }
  5660. }
  5661. sing.IsDel = 1;
  5662. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5663. sing.DeleteUserId = dto.UserId;
  5664. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5665. jw = JsonView(true, "删除成功!");
  5666. return Ok(jw);
  5667. }
  5668. #endregion
  5669. #region 共享文件上传
  5670. /// <summary>
  5671. /// 共享文件数据初始化
  5672. /// </summary>
  5673. /// <returns></returns>
  5674. [HttpGet]
  5675. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5676. {
  5677. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5678. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5679. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5680. .Select(x => x.Id)
  5681. .ToList()
  5682. .Contains(userid);
  5683. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5684. .Where(x => x.STid == 111 && x.IsDel == 0)
  5685. .Select(x => new
  5686. {
  5687. x.Name,
  5688. x.Id,
  5689. }).ToList();
  5690. if (isMarketingDepartment)
  5691. {
  5692. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5693. }
  5694. if (portType == 1)
  5695. {
  5696. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5697. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5698. .Where(x => x.IsDel == 0)
  5699. .OrderByDescending(x => x.VisitDate)
  5700. .Select(x => new
  5701. {
  5702. x.TeamName,
  5703. x.Id,
  5704. x.CityId,
  5705. })
  5706. .ToList()
  5707. .Select(x =>
  5708. {
  5709. var provinceId = x.CityId;
  5710. var isDefualtVal = true;
  5711. if (provinceId > 0)
  5712. {
  5713. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5714. if (parentId != null)
  5715. {
  5716. isDefualtVal = false;
  5717. provinceId = (int)parentId;
  5718. }
  5719. }
  5720. if (isDefualtVal)
  5721. {
  5722. provinceId = 122; //默认四川
  5723. }
  5724. return new
  5725. {
  5726. x.TeamName,
  5727. x.Id,
  5728. provinceId,
  5729. };
  5730. })
  5731. .ToList();
  5732. return Ok(JsonView(true, "SUCCESS!", new
  5733. {
  5734. dropDownType,
  5735. dropDownGroupList,
  5736. isMarketingDepartment
  5737. }));
  5738. }
  5739. else if (portType == 2 || portType == 3)
  5740. {
  5741. return Ok(JsonView(true, "SUCCESS!", new
  5742. {
  5743. dropDownType,
  5744. isMarketingDepartment
  5745. }));
  5746. }
  5747. else
  5748. {
  5749. return Ok(JsonView(false, "portType有误!"));
  5750. }
  5751. }
  5752. /// <summary>
  5753. /// 共享文件上传
  5754. /// </summary>
  5755. /// <param name="dto"></param>
  5756. /// <returns></returns>
  5757. [HttpPost]
  5758. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5759. {
  5760. var isGroup = new List<int> { 1412 };
  5761. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5762. {
  5763. return Ok(JsonView(false, "该文件需要关联团组!"));
  5764. }
  5765. if (dto.Files == null || dto.Files.Count == 0)
  5766. {
  5767. return Ok(JsonView(false, "无文件信息!"));
  5768. }
  5769. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5770. {
  5771. return Ok(JsonView(false, "文件大小超过20M!"));
  5772. }
  5773. if (dto.Userid < 1)
  5774. {
  5775. return Ok(JsonView(false, "请传入有效的Userid!"));
  5776. }
  5777. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5778. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5779. .Select((u, j) => new
  5780. {
  5781. u.CnName,
  5782. UserId = u.Id,
  5783. j.JobName,
  5784. })
  5785. .First();
  5786. if (jobInfo == null)
  5787. {
  5788. return Ok(JsonView(false, "请传入有效的Userid!"));
  5789. }
  5790. var commonFileExtensions = new List<string>
  5791. {
  5792. // 文本文件
  5793. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5794. // 图片文件
  5795. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5796. // 视频文件
  5797. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5798. // 音频文件
  5799. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5800. // 压缩文件
  5801. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5802. // 数据文件
  5803. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5804. };
  5805. try
  5806. {
  5807. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5808. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5809. commonFileExtensions.AddRange(settingExtend);
  5810. }
  5811. catch (Exception)
  5812. { }
  5813. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5814. if (setdata == null)
  5815. {
  5816. return Ok(JsonView(false, "请传入有效的FileType!"));
  5817. }
  5818. var insertList = new List<Grp_GroupShareFile>();
  5819. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5820. if (!Directory.Exists(winPath))
  5821. {
  5822. Directory.CreateDirectory(winPath);
  5823. }
  5824. foreach (var item in dto.Files)
  5825. {
  5826. var houzui = Path.GetExtension(item.FileName);
  5827. if (!commonFileExtensions.Contains(houzui))
  5828. {
  5829. return Ok(JsonView(false, "未知后缀名称!"));
  5830. }
  5831. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5832. var saveFilePath = winPath + fileName;
  5833. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5834. {
  5835. item.CopyTo(fs);
  5836. fs.Flush();
  5837. }
  5838. var fileDetail = new Grp_GroupShareFile()
  5839. {
  5840. CreateUserId = dto.Userid,
  5841. CreateTime = DateTime.Now,
  5842. UploadJob = jobInfo.JobName,
  5843. FileName = fileName,
  5844. FileType = dto.FileType,
  5845. Diid = dto.Diid,
  5846. FilePath = winPath + fileName,
  5847. };
  5848. insertList.Add(fileDetail);
  5849. }
  5850. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5851. return Ok(JsonView(true, "保存成功!"));
  5852. }
  5853. /// <summary>
  5854. /// 查询共享文件列表
  5855. /// </summary>
  5856. /// <param name="dto"></param>
  5857. /// <returns></returns>
  5858. [HttpPost]
  5859. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5860. {
  5861. var isGroup = new List<int> { 1412 };
  5862. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5863. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5864. .And(x => x.Diid == dto.Diid)
  5865. .And(x => x.FileType == dto.FileType)
  5866. .And(x => x.IsDel == 0)
  5867. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5868. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5869. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5870. int totalCount = 0;
  5871. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5872. .Where(queryExpression.ToExpression())
  5873. .OrderBy(x => x.UploadJob)
  5874. .Select(x => new
  5875. {
  5876. x.Id,
  5877. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5878. x.FileName,
  5879. x.FileType,
  5880. x.CreateTime,
  5881. })
  5882. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5883. return Ok(JsonView(true, "SUCCESS!", new
  5884. {
  5885. FileList = dbQuery,
  5886. dto.PageSize,
  5887. dto.PageIndex,
  5888. totalCount
  5889. }));
  5890. }
  5891. /// <summary>
  5892. /// 删除共享文件模块下的指定文件
  5893. /// </summary>
  5894. /// <param name="dto"></param>
  5895. /// <returns></returns>
  5896. [HttpPost]
  5897. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5898. {
  5899. var jw = JsonView(false);
  5900. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5901. if (sing == null)
  5902. {
  5903. jw.Msg = "暂无文件信息!";
  5904. return Ok(jw);
  5905. }
  5906. if (sing.CreateUserId != dto.UserId)
  5907. {
  5908. jw.Msg = "只能删除自己上传的文件!";
  5909. return Ok(jw);
  5910. }
  5911. if (System.IO.File.Exists(sing.FilePath))
  5912. {
  5913. try
  5914. {
  5915. System.IO.File.Delete(sing.FilePath);
  5916. }
  5917. catch (Exception ex)
  5918. {
  5919. jw.Msg = "删除失败!" + ex.Message;
  5920. return Ok(jw);
  5921. }
  5922. }
  5923. sing.IsDel = 1;
  5924. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5925. sing.DeleteUserId = dto.UserId;
  5926. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5927. jw = JsonView(true, "删除成功!");
  5928. return Ok(jw);
  5929. }
  5930. #endregion
  5931. #region 团组英文资料
  5932. /// <summary>
  5933. /// 查询团组英文所有资料
  5934. /// </summary>
  5935. /// <param name="dto"></param>
  5936. /// <returns></returns>
  5937. [HttpPost]
  5938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5939. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  5940. {
  5941. try
  5942. {
  5943. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  5944. if (groupData.Code != 0)
  5945. {
  5946. return Ok(JsonView(false, groupData.Msg));
  5947. }
  5948. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5949. }
  5950. catch (Exception ex)
  5951. {
  5952. return Ok(JsonView(false, ex.Message));
  5953. throw;
  5954. }
  5955. }
  5956. /// <summary>
  5957. /// 团组英文资料操作(Status:1.新增,2.修改)
  5958. /// </summary>
  5959. /// <param name="dto"></param>
  5960. /// <returns></returns>
  5961. [HttpPost]
  5962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5963. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  5964. {
  5965. try
  5966. {
  5967. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  5968. if (groupData.Code != 0)
  5969. {
  5970. return Ok(JsonView(false, groupData.Msg));
  5971. }
  5972. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5973. }
  5974. catch (Exception ex)
  5975. {
  5976. return Ok(JsonView(false, ex.Message));
  5977. throw;
  5978. }
  5979. }
  5980. /// <summary>
  5981. /// 团组英文资料Id查询数据
  5982. /// </summary>
  5983. /// <param name="dto"></param>
  5984. /// <returns></returns>
  5985. [HttpPost]
  5986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5987. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5988. {
  5989. try
  5990. {
  5991. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5992. if (_DelegationEnData != null)
  5993. {
  5994. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5995. }
  5996. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5997. }
  5998. catch (Exception ex)
  5999. {
  6000. return Ok(JsonView(false, "程序错误!"));
  6001. throw;
  6002. }
  6003. }
  6004. /// <summary>
  6005. /// 团组英文资料删除
  6006. /// </summary>
  6007. /// <param name="dto"></param>
  6008. /// <returns></returns>
  6009. [HttpPost]
  6010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6011. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6012. {
  6013. try
  6014. {
  6015. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6016. if (!res)
  6017. {
  6018. return Ok(JsonView(false, "删除失败"));
  6019. }
  6020. return Ok(JsonView(true, "删除成功!"));
  6021. }
  6022. catch (Exception ex)
  6023. {
  6024. return Ok(JsonView(false, ex.Message));
  6025. throw;
  6026. }
  6027. }
  6028. #endregion
  6029. #region 导出邀请函
  6030. /// <summary>
  6031. /// 导出邀请函页面初始化
  6032. /// </summary>
  6033. /// <param name="dto"></param>
  6034. /// <returns></returns>
  6035. [HttpPost]
  6036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6037. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6038. {
  6039. try
  6040. {
  6041. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6042. var crm_Deles = new List<Crm_DeleClient>();
  6043. if (dto.DiId == 0)
  6044. {
  6045. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6046. }
  6047. else
  6048. {
  6049. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6050. }
  6051. return Ok(JsonView(true, "查询成功!", new
  6052. {
  6053. deleClient = crm_Deles,
  6054. delegations = grp_Delegations
  6055. }));
  6056. }
  6057. catch (Exception ex)
  6058. {
  6059. return Ok(JsonView(false, "程序错误!"));
  6060. throw;
  6061. }
  6062. }
  6063. /// <summary>
  6064. /// 导出邀请函
  6065. /// </summary>
  6066. /// <param name="dto"></param>
  6067. /// <returns></returns>
  6068. [HttpPost]
  6069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6070. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6071. {
  6072. #region 参数验证
  6073. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6074. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6075. #endregion
  6076. try
  6077. {
  6078. var transDic = new Dictionary<string, string>();
  6079. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6080. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6081. From Grp_TourClientList tcl
  6082. Left Join
  6083. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6084. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6085. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6086. From Crm_DeleClient dc
  6087. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6088. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6089. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6090. Where dc.IsDel = 0) temp
  6091. On temp.DcId =tcl.ClientId
  6092. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6093. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6094. var texts = new List<string>();
  6095. if (datas.Count != 0)
  6096. {
  6097. foreach (TourClientListDetailsView item in datas)
  6098. {
  6099. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6100. {
  6101. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6102. }
  6103. else
  6104. {
  6105. string name = item.LastName + item.FirstName;
  6106. texts.Add(name);
  6107. }
  6108. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6109. {
  6110. if (!transDic.ContainsKey(item.Job))
  6111. {
  6112. texts.Add(item.Job);
  6113. }
  6114. }
  6115. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6116. {
  6117. texts.Add(item.CompanyFullName);
  6118. }
  6119. }
  6120. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6121. if (transData.Count > 0)
  6122. {
  6123. foreach (TranslateResult item in transData)
  6124. {
  6125. if (!transDic.ContainsKey(item.Query))
  6126. {
  6127. transDic.Add(item.Query, item.Translation);
  6128. }
  6129. }
  6130. }
  6131. var list = new List<GuestList>();
  6132. foreach (var dele in datas)
  6133. {
  6134. var guestList = new GuestList();
  6135. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6136. {
  6137. guestList.Name = dele.Pinyin;
  6138. }
  6139. else
  6140. {
  6141. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6142. guestList.Name = Name;
  6143. }
  6144. if (dele.Sex == 0)
  6145. {
  6146. guestList.Sex = "Male";
  6147. }
  6148. else if (dele.Sex == 1)
  6149. {
  6150. guestList.Sex = "Female";
  6151. }
  6152. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6153. if (!string.IsNullOrEmpty(dele.Job))
  6154. {
  6155. guestList.Job = dele.Job;
  6156. }
  6157. list.Add(guestList);
  6158. }
  6159. //载入模板
  6160. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6161. var builder = new DocumentBuilder(doc);
  6162. //获取word里所有表格
  6163. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6164. //获取所填表格的序数
  6165. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6166. var rowStart = tableOne.Rows[0]; //获取第1行
  6167. //循环赋值
  6168. for (int i = 0; i < list.Count; i++)
  6169. {
  6170. builder.MoveToCell(0, i + 1, 0, 0);
  6171. builder.Write(list[i].Name.ToString());
  6172. builder.MoveToCell(0, i + 1, 1, 0);
  6173. builder.Write(list[i].Sex.ToString());
  6174. builder.MoveToCell(0, i + 1, 2, 0);
  6175. builder.Write(list[i].DOB.ToString());
  6176. builder.MoveToCell(0, i + 1, 3, 0);
  6177. builder.Write(list[i].Job.ToString());
  6178. }
  6179. //删除多余行
  6180. while (tableOne.Rows.Count > list.Count + 1)
  6181. {
  6182. tableOne.Rows.RemoveAt(list.Count + 1);
  6183. }
  6184. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6185. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6186. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6187. doc.Save(filePath);
  6188. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6189. return Ok(JsonView(true, "操作成功!", Url));
  6190. }
  6191. else
  6192. {
  6193. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6194. }
  6195. }
  6196. catch (Exception ex)
  6197. {
  6198. return Ok(JsonView(false, ex.Message));
  6199. throw;
  6200. }
  6201. }
  6202. #endregion
  6203. #region 团组经理模块 出入境费用
  6204. /// <summary>
  6205. /// 团组模块 - 出入境费用 - 省份基础数据源
  6206. /// </summary>
  6207. /// <returns></returns>
  6208. [HttpGet]
  6209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6210. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6211. {
  6212. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6213. }
  6214. /// <summary>
  6215. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6216. /// </summary>
  6217. /// <param name="dto"></param>
  6218. /// <returns></returns>
  6219. [HttpPost]
  6220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6221. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6222. {
  6223. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6224. var groupNamFirst = groupNameData.FirstOrDefault();
  6225. //SetDataInfoView
  6226. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6227. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6228. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6229. //验证城市归属并给默认值
  6230. int provinceId = 122;
  6231. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6232. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6233. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6234. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6235. return Ok(JsonView(true, "查询成功!", new
  6236. {
  6237. GroupNameData = groupNameData,
  6238. CurrencyData = _CurrencyData,
  6239. WordTypeData = wordTypeData,
  6240. ExcelTypeData = excelTypeData,
  6241. CurrencyInit = _currencyInfos,
  6242. ViewPermissionData = viewPermissionData
  6243. }));
  6244. }
  6245. /// <summary>
  6246. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6247. /// </summary>
  6248. /// <returns></returns>
  6249. [HttpGet("{provinceId}")]
  6250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6251. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6252. {
  6253. //验证城市归属并给默认值
  6254. if (provinceId < 1) provinceId = 122;
  6255. /*
  6256. * 122 四川
  6257. * 108 贵州
  6258. * 103 重庆
  6259. * 132 云南
  6260. */
  6261. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6262. return Ok(JsonView(true, "查询成功!", new
  6263. {
  6264. WordTypeData = wordTypeData,
  6265. ExcelTypeData = excelTypeData,
  6266. }));
  6267. }
  6268. /// <summary>
  6269. /// 团组模块 - 出入境费用
  6270. /// 实时汇率 tips
  6271. /// 签证费用 tips
  6272. /// 机票费用 tips
  6273. /// </summary>
  6274. /// <returns></returns>
  6275. [HttpPost]
  6276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6277. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6278. {
  6279. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6280. //默认币种显示
  6281. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6282. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6283. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6284. return Ok(JsonView(true, "查询成功!", new
  6285. {
  6286. //GroupNameData = groupNameData.Data,
  6287. visaData = visaData.Data,
  6288. airData,
  6289. reteInfos
  6290. }));
  6291. }
  6292. /// <summary>
  6293. /// 团组模块 - 出入境费用 - Info
  6294. /// </summary>
  6295. /// <param name="dto"></param>
  6296. /// <returns></returns>
  6297. [HttpPost]
  6298. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6300. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6301. {
  6302. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6303. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6304. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6305. }
  6306. /// <summary>
  6307. /// 团组模块 - 出入境费用 - 设置view权限
  6308. /// </summary>
  6309. /// <returns></returns>
  6310. [HttpPost]
  6311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6312. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6313. {
  6314. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6315. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6316. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6317. var permissions = new List<Grp_EnterExitCostPermission>();
  6318. foreach (var userId in dto.UserIds)
  6319. {
  6320. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6321. }
  6322. if (permissions.Any())
  6323. {
  6324. _sqlSugar.BeginTran();
  6325. try
  6326. {
  6327. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6328. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6329. if (result < 1)
  6330. {
  6331. _sqlSugar.RollbackTran();
  6332. return Ok(JsonView(false));
  6333. }
  6334. }
  6335. catch (Exception ex)
  6336. {
  6337. _sqlSugar.RollbackTran();
  6338. return Ok(JsonView(false, ex.Message));
  6339. }
  6340. _sqlSugar.CommitTran();
  6341. return Ok(JsonView(true));
  6342. }
  6343. return Ok(JsonView(false));
  6344. }
  6345. /// <summary>
  6346. /// 团组模块 - 出入境费用 - Add And Update
  6347. /// </summary>
  6348. /// <returns></returns>
  6349. [HttpPost]
  6350. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6352. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6353. {
  6354. try
  6355. {
  6356. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6357. if (dto.DayOtherPriceData.Any())
  6358. {
  6359. var inserList = dto.DayOtherPriceData
  6360. .Where(x => x.Id == 0)
  6361. .Select(x => new Grp_DayOtherPrice
  6362. {
  6363. Cost = x.Cost,
  6364. Id = x.Id,
  6365. CreateTime = DateTime.Now,
  6366. CreateUserId = dto.UserId,
  6367. Currency = x.Currency,
  6368. Diid = x.DiId,
  6369. Index = x.Index,
  6370. IsDel = 0,
  6371. SetDataId = x.SetDataId,
  6372. SubTotal = x.SubTotal,
  6373. Remark = x.Remark
  6374. })
  6375. .ToList();
  6376. var updateList = dto.DayOtherPriceData
  6377. .Where(x => x.Id != 0)
  6378. .Select(x => new Grp_DayOtherPrice
  6379. {
  6380. Cost = x.Cost,
  6381. Id = x.Id,
  6382. CreateTime = DateTime.Now,
  6383. CreateUserId = dto.UserId,
  6384. Currency = x.Currency,
  6385. Diid = x.DiId,
  6386. Index = x.Index,
  6387. IsDel = 0,
  6388. SetDataId = x.SetDataId,
  6389. SubTotal = x.SubTotal,
  6390. Remark = x.Remark
  6391. })
  6392. .ToList();
  6393. //添加
  6394. _sqlSugar.BeginTran();
  6395. if (inserList.Any())
  6396. {
  6397. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6398. }
  6399. if (updateList.Any())
  6400. {
  6401. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6402. }
  6403. _sqlSugar.CommitTran();
  6404. }
  6405. if (data.Code != 0)
  6406. {
  6407. return Ok(JsonView(false, data.Msg));
  6408. }
  6409. //生成默认文件pdf并且通知人员
  6410. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6411. {
  6412. DiId = dto.DiId,
  6413. ExportType = 1,
  6414. SubTypeId = 1005
  6415. }, "pdf");
  6416. //发送通知
  6417. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6418. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6419. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6420. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6421. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6422. //汇率信息记录
  6423. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6424. return Ok(JsonView(true, data.Msg, data.Data));
  6425. }
  6426. catch (Exception ex)
  6427. {
  6428. return Ok(JsonView(false, ex.Message));
  6429. }
  6430. }
  6431. /// <summary>
  6432. /// 团组模块 - 出入境费用 - Confirm 费用
  6433. /// </summary>
  6434. /// <returns></returns>
  6435. [HttpPost]
  6436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6437. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6438. {
  6439. //TODO:测试完毕需把对应的用户ID更改
  6440. //1、数据表添加字段
  6441. //2、更改字段接口()
  6442. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6443. //3、确认成功 给财务发送消息
  6444. if (_view.Code == 200)
  6445. {
  6446. if (dto.Type == 1)
  6447. {
  6448. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6449. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6450. }
  6451. }
  6452. return Ok(_view);
  6453. }
  6454. /// <summary>
  6455. /// 团组模块 - 出入境费用 - File download
  6456. /// </summary>
  6457. /// <param name="dto"></param>
  6458. /// <returns></returns>
  6459. [HttpPost]
  6460. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6462. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6463. {
  6464. try
  6465. {
  6466. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6467. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6468. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6469. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6470. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6471. 3 团组成员名单 1 团组成员名单", ""));
  6472. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6473. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6474. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6475. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6476. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6477. //数据源
  6478. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6479. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6480. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6481. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6482. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6483. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6484. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6485. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6486. .Select((x, a, b) => new
  6487. {
  6488. x.Index,
  6489. itemName = a.Name,
  6490. CurrencyStr = b.Name,
  6491. x.Cost,
  6492. x.SubTotal,
  6493. x.Remark
  6494. })
  6495. .OrderBy((x) => x.Index)
  6496. .ToList(); //其他款项费用
  6497. var peiceItemCurrencys = new List<string>();
  6498. if (_DayAndCosts.Any())
  6499. {
  6500. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6501. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6502. }
  6503. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6504. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6505. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6506. {
  6507. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6508. }
  6509. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6510. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6511. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6512. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6513. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6514. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6515. .Select((tcl, dc, cc) => new ClientInfo
  6516. {
  6517. LastName = dc.LastName,
  6518. FirstName = dc.FirstName,
  6519. Sex = dc.Sex,
  6520. Birthday = dc.BirthDay,
  6521. Company = cc.CompanyFullName,
  6522. Job = dc.Job
  6523. })
  6524. .ToList();
  6525. foreach (var item in DeleClientList)
  6526. {
  6527. EncryptionProcessor.DecryptProperties(item);
  6528. }
  6529. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6530. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6531. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6532. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6533. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6534. if (dto.ExportType == 1) //明细表
  6535. {
  6536. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6537. {
  6538. //获取模板
  6539. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6540. //载入模板
  6541. var doc = new Document(tempPath);
  6542. var builder = new DocumentBuilder(doc);
  6543. var dic = new Dictionary<string, string>();
  6544. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6545. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6546. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6547. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6548. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6549. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6550. //境内费用(其他费用)
  6551. if (_EnterExitCosts.ChoiceOne == 1)
  6552. {
  6553. string row1_1 = "";
  6554. if (_EnterExitCosts.Visa > 0)
  6555. {
  6556. //insidePayTotal += _EnterExitCosts.Visa;
  6557. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 人民币/人";
  6558. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6559. //{
  6560. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6561. //}
  6562. }
  6563. string row1_2 = "";
  6564. if (_EnterExitCosts.YiMiao > 0)
  6565. {
  6566. //insidePayTotal += _EnterExitCosts.YiMiao;
  6567. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 人民币/人";
  6568. }
  6569. if (_EnterExitCosts.HeSuan > 0)
  6570. {
  6571. //insidePayTotal += _EnterExitCosts.HeSuan;
  6572. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 人民币/人";
  6573. }
  6574. if (_EnterExitCosts.Service > 0)
  6575. {
  6576. //insidePayTotal += _EnterExitCosts.Service;
  6577. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 人民币/人";
  6578. }
  6579. string row1_3 = "";
  6580. if (_EnterExitCosts.Safe > 0)
  6581. {
  6582. //insidePayTotal += _EnterExitCosts.Safe;
  6583. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 人民币/人";
  6584. }
  6585. if (_EnterExitCosts.Ticket > 0)
  6586. {
  6587. //insidePayTotal += _EnterExitCosts.Ticket;
  6588. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 人民币/人";
  6589. }
  6590. string row1 = "";
  6591. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6592. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6593. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6594. row1 += $"备注:{_EnterExitCosts.Remark}";
  6595. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6596. dic.Add("Row1Str", row1);
  6597. }
  6598. string airTotalStr = string.Empty,
  6599. airPriceStr = string.Empty;
  6600. //经济舱
  6601. if (_EnterExitCosts.SumJJC == 1)
  6602. {
  6603. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  6604. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  6605. }
  6606. //公务舱
  6607. if (_EnterExitCosts.SumGWC == 1)
  6608. {
  6609. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  6610. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  6611. }
  6612. //头等舱
  6613. if (_EnterExitCosts.SumTDC == 1)
  6614. {
  6615. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  6616. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  6617. }
  6618. //汇率描述
  6619. string rateStr = "";
  6620. if (peiceItemCurrencyInfos.Any())
  6621. {
  6622. rateStr = "\r\n汇率描述:";
  6623. foreach (var item in peiceItemCurrencyInfos)
  6624. {
  6625. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  6626. }
  6627. }
  6628. string twoItemRemark = "备注:";
  6629. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6630. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6631. dic.Add("AirTotalStr", airTotalStr);
  6632. dic.Add("AirPriceStr", airPriceStr);
  6633. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6634. dic.Add("TwoItemRemark", twoItemRemark);
  6635. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6636. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6637. int table1Row = 0,
  6638. table2Row = 0,
  6639. table3Row = 0,
  6640. table4Row = 0,
  6641. table5Row = 0;
  6642. //住宿费
  6643. if (_EnterExitCosts.ChoiceThree == 1)
  6644. {
  6645. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6646. table1Row = dac1.Count;
  6647. #region 填充word表格内容
  6648. for (int i = 0; i < dac1.Count; i++)
  6649. {
  6650. Grp_DayAndCost dac = dac1[i];
  6651. if (dac == null) continue;
  6652. builder.MoveToCell(0, i, 0, 0);
  6653. builder.Write("第" + dac.Days.ToString() + "晚:");
  6654. builder.MoveToCell(0, i, 1, 0);
  6655. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6656. //builder.Write(dac.Place == null ? "" : dac.Place);
  6657. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6658. builder.MoveToCell(0, i, 2, 0);
  6659. builder.Write("费用标准:");
  6660. string curr = "";
  6661. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6662. if (currData != null)
  6663. {
  6664. curr = currData.Name;
  6665. }
  6666. builder.MoveToCell(0, i, 3, 0);
  6667. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6668. builder.MoveToCell(0, i, 4, 0);
  6669. builder.Write("费用小计:");
  6670. builder.MoveToCell(0, i, 5, 0);
  6671. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6672. }
  6673. #endregion
  6674. }
  6675. else dic.Add("SubZS", "0.00");
  6676. //删除多余行
  6677. while (table1.Rows.Count > table1Row)
  6678. {
  6679. table1.Rows.RemoveAt(table1Row);
  6680. }
  6681. //伙食费
  6682. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6683. if (_EnterExitCosts.ChoiceFour == 1)
  6684. {
  6685. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6686. table2Row = dac2.Count;
  6687. #region 填充word表格内容
  6688. for (int i = 0; i < dac2.Count; i++)
  6689. {
  6690. Grp_DayAndCost dac = dac2[i];
  6691. if (dac == null) continue;
  6692. builder.MoveToCell(1, i, 0, 0);
  6693. builder.Write("第" + dac.Days.ToString() + "天:");
  6694. builder.MoveToCell(1, i, 1, 0);
  6695. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6696. builder.MoveToCell(1, i, 2, 0);
  6697. builder.Write("费用标准:");
  6698. string curr = "";
  6699. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6700. if (currData != null)
  6701. {
  6702. curr = currData.Name;
  6703. }
  6704. builder.MoveToCell(1, i, 3, 0);
  6705. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6706. builder.MoveToCell(1, i, 4, 0);
  6707. builder.Write("费用小计:");
  6708. builder.MoveToCell(1, i, 5, 0);
  6709. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6710. }
  6711. #endregion
  6712. }
  6713. else dic.Add("SubHS", "0.00");
  6714. //删除多余行
  6715. while (table2.Rows.Count > table2Row)
  6716. {
  6717. table2.Rows.RemoveAt(table2Row);
  6718. }
  6719. //公杂费
  6720. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6721. if (_EnterExitCosts.ChoiceFive == 1)
  6722. {
  6723. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6724. table3Row = dac3.Count;
  6725. #region 填充word表格内容
  6726. for (int i = 0; i < dac3.Count; i++)
  6727. {
  6728. Grp_DayAndCost dac = dac3[i];
  6729. if (dac == null) continue;
  6730. builder.MoveToCell(2, i, 0, 0);
  6731. builder.Write("第" + dac.Days.ToString() + "天:");
  6732. builder.MoveToCell(2, i, 1, 0);
  6733. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6734. builder.MoveToCell(2, i, 2, 0);
  6735. builder.Write("费用标准:");
  6736. string curr = "";
  6737. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6738. if (currData != null)
  6739. {
  6740. curr = currData.Name;
  6741. }
  6742. builder.MoveToCell(2, i, 3, 0);
  6743. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6744. builder.MoveToCell(2, i, 4, 0);
  6745. builder.Write("费用小计:");
  6746. builder.MoveToCell(2, i, 5, 0);
  6747. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6748. }
  6749. //删除多余行
  6750. while (table3.Rows.Count > table3Row)
  6751. {
  6752. table3.Rows.RemoveAt(table3Row);
  6753. }
  6754. #endregion
  6755. }
  6756. else dic.Add("SubGZF", "0.00");
  6757. //删除多余行
  6758. while (table3.Rows.Count > table3Row)
  6759. {
  6760. table3.Rows.RemoveAt(table3Row);
  6761. }
  6762. //培训费
  6763. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6764. if (_EnterExitCosts.ChoiceSix == 1)
  6765. {
  6766. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  6767. dic.Add("SubPX", pxStr);
  6768. table4Row = dac4.Count;
  6769. #region 填充word表格内容
  6770. for (int i = 0; i < dac4.Count; i++)
  6771. {
  6772. Grp_DayAndCost dac = dac4[i];
  6773. if (dac == null) continue;
  6774. builder.MoveToCell(3, i, 0, 0);
  6775. builder.Write("第" + dac.Days.ToString() + "天:");
  6776. builder.MoveToCell(3, i, 1, 0);
  6777. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6778. builder.MoveToCell(3, i, 2, 0);
  6779. builder.Write("费用标准:");
  6780. string curr = "";
  6781. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6782. if (currData != null)
  6783. {
  6784. curr = currData.Name;
  6785. }
  6786. builder.MoveToCell(3, i, 3, 0);
  6787. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6788. builder.MoveToCell(3, i, 4, 0);
  6789. builder.Write("费用小计:");
  6790. builder.MoveToCell(3, i, 5, 0);
  6791. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6792. }
  6793. #endregion
  6794. }
  6795. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6796. //删除多余行
  6797. while (table4.Rows.Count > table4Row)
  6798. {
  6799. table4.Rows.RemoveAt(table4Row);
  6800. }
  6801. //其他费用
  6802. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6803. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6804. {
  6805. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  6806. dic.Add("titleQi", qtStr);
  6807. table5Row = dac5.Count;
  6808. #region 填充word表格内容
  6809. for (int i = 0; i < dac5.Count; i++)
  6810. {
  6811. var dac = dac5[i];
  6812. if (dac == null) continue;
  6813. builder.MoveToCell(4, i, 0, 0);
  6814. builder.Write("第" + dac.Index.ToString() + "项:");
  6815. builder.MoveToCell(4, i, 1, 0);
  6816. builder.Write(dac.itemName);
  6817. builder.MoveToCell(4, i, 2, 0);
  6818. builder.Write("费用标准:");
  6819. builder.MoveToCell(4, i, 3, 0);
  6820. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6821. builder.MoveToCell(4, i, 4, 0);
  6822. builder.Write("费用小计:");
  6823. builder.MoveToCell(4, i, 5, 0);
  6824. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6825. builder.MoveToCell(4, i, 6, 0);
  6826. builder.Write("备注:");
  6827. builder.MoveToCell(4, i, 7, 0);
  6828. builder.Write(dac.Remark);
  6829. }
  6830. #endregion
  6831. }
  6832. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6833. //删除多余行
  6834. while (table5.Rows.Count > table5Row)
  6835. {
  6836. table5.Rows.RemoveAt(table5Row);
  6837. }
  6838. //加上其他费用
  6839. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6840. decimal subJJC = 0.00M,
  6841. subGWC = 0.00M,
  6842. subTDC = 0.00M;
  6843. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6844. string totalLabel = string.Format("全部费用总计:");
  6845. //经济舱
  6846. if (_EnterExitCosts.SumJJC == 1)
  6847. {
  6848. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6849. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  6850. }
  6851. //公务舱
  6852. if (_EnterExitCosts.SumGWC == 1)
  6853. {
  6854. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6855. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  6856. }
  6857. //头等舱
  6858. if (_EnterExitCosts.SumTDC == 1)
  6859. {
  6860. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6861. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  6862. }
  6863. //TotalLabel
  6864. dic.Add("TotalLabel", totalLabel);
  6865. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6866. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6867. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6868. #region 填充word模板书签内容
  6869. foreach (var key in dic.Keys)
  6870. {
  6871. Bookmark bookmark = doc.Range.Bookmarks[key];
  6872. if (bookmark != null)
  6873. {
  6874. builder.MoveToBookmark(key);
  6875. builder.Write(dic[key]);
  6876. }
  6877. }
  6878. #endregion
  6879. #region 设置页眉
  6880. string userLabel = string.Empty;
  6881. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6882. if (currUserInfo != null)
  6883. {
  6884. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6885. if (userInfo != null)
  6886. {
  6887. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6888. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6889. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6890. }
  6891. }
  6892. //设置页脚
  6893. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6894. #endregion
  6895. //文件名
  6896. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6897. AsposeHelper.removewatermark_v2180();
  6898. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6899. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6900. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6901. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6902. }
  6903. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6904. {
  6905. //获取模板
  6906. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6907. //载入模板
  6908. var doc = new Document(tempPath);
  6909. var builder = new DocumentBuilder(doc);
  6910. var dic = new Dictionary<string, string>();
  6911. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6912. {
  6913. var list = new List<string>();
  6914. try
  6915. {
  6916. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6917. foreach (var item in spilitArr)
  6918. {
  6919. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6920. var depCode = spDotandEmpty[2].Substring(0, 3);
  6921. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6922. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6923. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6924. list.Add(depName);
  6925. list.Add(arrName);
  6926. }
  6927. list = list.Distinct().ToList();
  6928. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6929. }
  6930. catch (Exception)
  6931. {
  6932. dic.Add("ReturnCode", "行程录入不正确!");
  6933. }
  6934. }
  6935. else
  6936. {
  6937. dic.Add("ReturnCode", "未录入行程!");
  6938. }
  6939. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6940. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6941. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6942. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6943. {
  6944. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6945. dic.Add("Day", sp.Days.ToString());
  6946. }
  6947. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6948. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6949. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6950. //dic.Add("Names", Names);
  6951. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6952. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6953. decimal dac1totalPrice = 0.00M;
  6954. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6955. foreach (var dac in dac1)
  6956. {
  6957. if (dac.SubTotal == 0.00M)
  6958. {
  6959. continue;
  6960. }
  6961. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6962. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6963. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6964. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6965. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6966. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6967. builder.Write(currency);//币种
  6968. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6969. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6970. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6971. builder.Write("");//人数
  6972. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6973. builder.Write("");//天数
  6974. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6975. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6976. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6977. decimal rate = 0.00M;
  6978. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6979. builder.Write(rate.ToString("#0.0000"));//汇率
  6980. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6981. decimal rbmPrice = dac.SubTotal;
  6982. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6983. accommodationStartIndex++;
  6984. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6985. }
  6986. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6987. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  6988. {
  6989. table1.Rows.RemoveAt(i - 1);
  6990. foodandotherStartIndex--;
  6991. }
  6992. if (dac2.Count == dac3.Count)//国家 币种 金额
  6993. {
  6994. for (int i = 0; i < dac2.Count; i++)
  6995. {
  6996. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6997. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6998. }
  6999. }
  7000. decimal dac2totalPrice = 0.00M;
  7001. foreach (var dac in dac2)
  7002. {
  7003. if (dac.SubTotal == 0)
  7004. {
  7005. continue;
  7006. }
  7007. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7008. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7009. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7010. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7011. builder.Write(currency);//币种
  7012. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7013. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7014. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7015. builder.Write("");//人数
  7016. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7017. builder.Write("");//天数
  7018. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7019. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7020. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7021. decimal rate = 0.00M;
  7022. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7023. builder.Write(rate.ToString("#0.0000"));//汇率
  7024. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7025. decimal rbmPrice = dac.SubTotal;
  7026. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7027. foodandotherStartIndex++;
  7028. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7029. }
  7030. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7031. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7032. {
  7033. table1.Rows.RemoveAt(i - 1);
  7034. }
  7035. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7036. string otherFeeStr = "";
  7037. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  7038. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  7039. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  7040. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7041. foreach (var otherInfo in dac5)
  7042. {
  7043. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7044. }
  7045. #endregion
  7046. if (otherFeeStr.Length > 0)
  7047. {
  7048. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7049. otherFeeStr = $"({otherFeeStr})";
  7050. dic.Add("OtherFeeStr", otherFeeStr);
  7051. }
  7052. //总计
  7053. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7054. //国际旅费
  7055. string outsideAir = string.Empty;
  7056. string allPriceAir = string.Empty;
  7057. if (_EnterExitCosts.SumJJC == 1)
  7058. {
  7059. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7060. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7061. }
  7062. if (_EnterExitCosts.SumGWC == 1)
  7063. {
  7064. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7065. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7066. }
  7067. if (_EnterExitCosts.SumTDC == 1)
  7068. {
  7069. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7070. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7071. }
  7072. dic.Add("InTravelPrice", $"({outsideAir})");
  7073. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7074. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7075. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7076. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7077. foreach (var key in dic.Keys)
  7078. {
  7079. builder.MoveToBookmark(key);
  7080. builder.Write(dic[key]);
  7081. }
  7082. //模板文件名
  7083. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7084. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7085. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7086. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7087. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7088. }
  7089. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7090. {
  7091. //获取模板
  7092. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7093. //载入模板
  7094. var designer = new WorkbookDesigner
  7095. {
  7096. Workbook = new Workbook(tempPath)
  7097. };
  7098. var dic = new Dictionary<string, string>();
  7099. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7100. {
  7101. var list = new List<string>();
  7102. try
  7103. {
  7104. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7105. foreach (var item in spilitArr)
  7106. {
  7107. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7108. var depCode = spDotandEmpty[2].Substring(0, 3);
  7109. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7110. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7111. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7112. list.Add(depName);
  7113. list.Add(arrName);
  7114. }
  7115. list = list.Distinct().ToList();
  7116. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7117. }
  7118. catch (Exception)
  7119. {
  7120. dic.Add("ReturnCode", "行程录入不正确!");
  7121. }
  7122. }
  7123. else
  7124. {
  7125. dic.Add("ReturnCode", "未录入行程!");
  7126. }
  7127. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7128. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7129. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7130. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7131. {
  7132. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7133. dic.Add("Day", sp.Days.ToString());
  7134. }
  7135. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7136. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7137. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7138. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7139. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7140. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7141. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7142. designer.SetDataSource("Name", Names);
  7143. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7144. designer.SetDataSource("Day", dic["Day"] + "天");
  7145. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7146. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7147. int startIndex = 10;
  7148. const int startIndexcopy = 10;
  7149. if (dac2.Count == dac3.Count)//国家 币种 金额
  7150. {
  7151. for (int i = 0; i < dac2.Count; i++)
  7152. {
  7153. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7154. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7155. }
  7156. }
  7157. var dtdac1 = new DataTable();
  7158. var place = new List<string>();
  7159. dtdac1.Columns.AddRange(new DataColumn[] {
  7160. new(){ ColumnName = "city"},
  7161. new(){ ColumnName = "curr"},
  7162. new(){ ColumnName = "criterion"},
  7163. new(){ ColumnName = "number",DataType = typeof(int)},
  7164. new(){ ColumnName = "day",DataType = typeof(int)},
  7165. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7166. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7167. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7168. });
  7169. var dtdac2 = new DataTable();
  7170. dtdac2.Columns.AddRange(new DataColumn[] {
  7171. new(){ ColumnName = "city"},
  7172. new(){ ColumnName = "curr"},
  7173. new(){ ColumnName = "criterion"},
  7174. new(){ ColumnName = "number",DataType = typeof(int)},
  7175. new(){ ColumnName = "day",DataType = typeof(int)},
  7176. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7177. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7178. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7179. });
  7180. dtdac1.TableName = "tb1";
  7181. dtdac2.TableName = "tb2";
  7182. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7183. foreach (var item in dac1)
  7184. {
  7185. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7186. if (place.Contains(item.Place))
  7187. {
  7188. continue;
  7189. }
  7190. DataRow row = dtdac1.NewRow();
  7191. row["city"] = item.Place;
  7192. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7193. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7194. row["curr"] = currency;
  7195. row["rate"] = rate.ToString("#0.0000");
  7196. row["criterion"] = item.Cost.ToString("#0.00");
  7197. row["number"] = 1;
  7198. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7199. //row["costRMB"] = rbmPrice;
  7200. dtdac1.Rows.Add(row);
  7201. place.Add(item.Place);
  7202. }
  7203. place = new List<string>();
  7204. foreach (var item in dac2)
  7205. {
  7206. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7207. if (place.Contains(item.Place))
  7208. {
  7209. continue;
  7210. }
  7211. DataRow row = dtdac2.NewRow();
  7212. row["city"] = item.Place;
  7213. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7214. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7215. row["curr"] = currency;
  7216. row["rate"] = rate.ToString("#0.0000");
  7217. row["criterion"] = item.Cost.ToString("#0.00");
  7218. row["number"] = 1;
  7219. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7220. //row["cost"] = item.SubTotal;
  7221. //row["costRMB"] = rbmPrice;
  7222. dtdac2.Rows.Add(row);
  7223. place.Add(item.Place);
  7224. //dac2totalPrice += rbmPrice;
  7225. }
  7226. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7227. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7228. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7229. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7230. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7231. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7232. string cell4Str1 = string.Empty;
  7233. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7234. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7235. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7236. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7237. string cellStr = $" 5.其他费用(";
  7238. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7239. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7240. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7241. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7242. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7243. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7244. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7245. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7246. foreach (var otherInfo in dac5)
  7247. {
  7248. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7249. }
  7250. #endregion
  7251. if (cellStr.Length > 8)
  7252. {
  7253. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7254. }
  7255. cellStr += ")";
  7256. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7257. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7258. decimal pxFee = dac4.Sum(it => it.Cost);
  7259. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7260. string celllastStr1 = "";
  7261. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7262. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7263. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7264. celllastStr1 += $",国际旅费 元";
  7265. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7266. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7267. designer.SetDataSource("cell4Str", cell4Str);
  7268. designer.SetDataSource("cellStr", cellStr);
  7269. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7270. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7271. designer.SetDataSource("celllastStr", celllastStr);
  7272. Workbook wb = designer.Workbook;
  7273. var sheet = wb.Worksheets[0];
  7274. //绑定datatable数据集
  7275. designer.SetDataSource(dtdac1);
  7276. designer.SetDataSource(dtdac2);
  7277. designer.Process();
  7278. var rowStart = dtdac1.Rows.Count;
  7279. while (rowStart > 0)
  7280. {
  7281. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7282. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7283. startIndex++;
  7284. rowStart--;
  7285. }
  7286. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7287. startIndex += 1; //总计行
  7288. rowStart = dtdac2.Rows.Count;
  7289. while (rowStart > 0)
  7290. {
  7291. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7292. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7293. startIndex++;
  7294. rowStart--;
  7295. }
  7296. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7297. wb.CalculateFormula(true);
  7298. //模板文件名
  7299. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7300. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7301. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7302. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7303. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7304. }
  7305. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7306. {
  7307. //获取模板
  7308. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7309. //载入模板
  7310. var doc = new Document(tempPath);
  7311. var builder = new DocumentBuilder(doc);
  7312. var dic = new Dictionary<string, string>
  7313. {
  7314. { "GroupName", _DelegationInfo.TeamName },
  7315. { "ClientUnit", _DelegationInfo.ClientUnit }
  7316. };
  7317. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7318. string missionLeaderJob = "";//负责人job
  7319. //int groupNumber = 0; //团人数
  7320. if (DeleClientList.Count > 0)
  7321. {
  7322. missionLeader = DeleClientList[0]?.Name ?? "";
  7323. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7324. }
  7325. dic.Add("MissionLeader", missionLeader); //团负责人
  7326. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7327. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7328. #region MyRegion
  7329. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7330. //{
  7331. // List<string> list = new List<string>();
  7332. // try
  7333. // {
  7334. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7335. // foreach (var item in spilitArr)
  7336. // {
  7337. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7338. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7339. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7340. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7341. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7342. // list.Add(depName);
  7343. // list.Add(arrName);
  7344. // }
  7345. // list = list.Distinct().ToList();
  7346. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7347. // }
  7348. // catch (Exception)
  7349. // {
  7350. // dic.Add("ReturnCode", "行程录入不正确!");
  7351. // }
  7352. //}
  7353. //else
  7354. //{
  7355. // dic.Add("ReturnCode", "未录入行程!");
  7356. //}
  7357. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7358. dic.Add("ReturnCode", string.Join("、", countrys));
  7359. #endregion
  7360. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7361. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7362. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7363. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7364. //{
  7365. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7366. // dic.Add("Day", sp.Days.ToString());
  7367. //}
  7368. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7369. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7370. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7371. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7372. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7373. //培训人员名单
  7374. int cultivateRowIndex = 7;
  7375. foreach (var item in DeleClientList)
  7376. {
  7377. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7378. builder.Write(item.Name);
  7379. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7380. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7381. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7382. string birthDay = "";
  7383. if (item.Birthday != null)
  7384. {
  7385. DateTime dt = Convert.ToDateTime(item.Birthday);
  7386. birthDay = $"{dt.Year}.{dt.Month}";
  7387. }
  7388. builder.Write(birthDay);
  7389. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7390. builder.Write(item.Company);
  7391. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7392. builder.Write(item.Job);
  7393. cultivateRowIndex++;
  7394. }
  7395. //删除多余行
  7396. //cultivateRowIndex -= 2;
  7397. int delRows = 10 + 7 - cultivateRowIndex;
  7398. if (delRows > 0)
  7399. {
  7400. for (int i = 0; i < delRows; i++)
  7401. {
  7402. table1.Rows.RemoveAt(cultivateRowIndex);
  7403. //cultivateRowIndex++;
  7404. }
  7405. }
  7406. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7407. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7408. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7409. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7410. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7411. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7412. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7413. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7414. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7415. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7416. //其他费用
  7417. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7418. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7419. //其他费用合计
  7420. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7421. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7422. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7423. //公务舱合计
  7424. //国际旅费
  7425. //string outsideJJ = "";
  7426. //string allPriceJJ = "";
  7427. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7428. {
  7429. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7430. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7431. }
  7432. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7433. {
  7434. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7435. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7436. }
  7437. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7438. {
  7439. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7440. dic.Add("AirFeeTotal", airFeeTotalStr);
  7441. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7442. dic.Add("FeeTotal", feeTotalStr);
  7443. }
  7444. foreach (var key in dic.Keys)
  7445. {
  7446. builder.MoveToBookmark(key);
  7447. builder.Write(dic[key]);
  7448. }
  7449. //模板文件名
  7450. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7451. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7452. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7453. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7454. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7455. }
  7456. }
  7457. else if (dto.ExportType == 2) //表格
  7458. {
  7459. //利用键值对存放数据
  7460. Dictionary<string, string> dic = new Dictionary<string, string>();
  7461. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7462. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7463. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7464. dic.Add("Day", sp.Days.ToString());
  7465. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7466. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7467. {
  7468. //获取模板
  7469. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7470. //载入模板
  7471. var doc = new Document(tempPath);
  7472. var builder = new DocumentBuilder(doc);
  7473. dic.Add("TeamName", _DelegationInfo.TeamName);
  7474. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7475. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7476. string missionLeaderName = "",
  7477. missionLeaderJob = "";
  7478. if (DeleClientList.Count > 0)
  7479. {
  7480. missionLeaderName = DeleClientList[0].Name;
  7481. missionLeaderJob = DeleClientList[0].Job;
  7482. }
  7483. dic.Add("MissionLeaderName", missionLeaderName);
  7484. dic.Add("MissionLeaderJob", missionLeaderJob);
  7485. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7486. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7487. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7488. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7489. int rowCount = 10;//总人数行
  7490. int startRowIndex = 7; //起始行
  7491. for (int i = 0; i < DeleClientList.Count; i++)
  7492. {
  7493. builder.MoveToCell(0, startRowIndex, 0, 0);
  7494. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7495. builder.MoveToCell(0, startRowIndex, 1, 0);
  7496. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7497. builder.Write(sex);//性别
  7498. builder.MoveToCell(0, startRowIndex, 2, 0);
  7499. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7500. builder.MoveToCell(0, startRowIndex, 3, 0);
  7501. builder.Write(DeleClientList[i].Company);//工作单位
  7502. builder.MoveToCell(0, startRowIndex, 4, 0);
  7503. builder.Write(DeleClientList[i].Job);//职务及级别
  7504. builder.MoveToCell(0, startRowIndex, 5, 0);
  7505. builder.Write("");//人员属性
  7506. builder.MoveToCell(0, startRowIndex, 6, 0);
  7507. builder.Write("");//上次出国时间
  7508. startRowIndex++;
  7509. }
  7510. int nullRow = rowCount - DeleClientList.Count;//空行
  7511. for (int i = 0; i < nullRow; i++)
  7512. {
  7513. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7514. }
  7515. foreach (var key in dic.Keys)
  7516. {
  7517. builder.MoveToBookmark(key);
  7518. builder.Write(dic[key]);
  7519. }
  7520. //模板文件名
  7521. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7522. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7523. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7524. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7525. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7526. }
  7527. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7528. {
  7529. //获取模板
  7530. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7531. //载入模板
  7532. var doc = new Document(tempPath);
  7533. var builder = new DocumentBuilder(doc);
  7534. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7535. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7536. dic.Add("Names", Names);
  7537. int accommodationRows = 12;
  7538. //int foodandotherRows = 12;
  7539. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7540. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7541. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7542. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7543. int accommodationStartIndex = 6;
  7544. decimal dac1totalPrice = 0.00M;
  7545. foreach (var dac in dac1)
  7546. {
  7547. if (dac.SubTotal == 0)
  7548. {
  7549. continue;
  7550. }
  7551. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7552. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7553. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7554. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7555. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7556. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7557. builder.Write(currency);//币种
  7558. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7559. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7560. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7561. builder.Write("");//人数
  7562. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7563. builder.Write("");//天数
  7564. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7565. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7566. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7567. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7568. builder.Write(rate.ToString("#0.0000"));//汇率
  7569. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7570. decimal rbmPrice = rate * dac.SubTotal;
  7571. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7572. accommodationStartIndex++;
  7573. dac1totalPrice += rbmPrice;
  7574. }
  7575. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7576. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7577. builder.Write("小计");
  7578. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7579. builder.Write(dac1totalPrice.ToString("#0.00"));
  7580. accommodationStartIndex++;
  7581. int nullRow = accommodationRows - dac1.Count;
  7582. //删除空行
  7583. //if (nullRow > 0)
  7584. //{
  7585. // int rowIndex = accommodationStartIndex;
  7586. // for (int i = 0; i < nullRow; i++)
  7587. // {
  7588. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7589. // row.Remove();
  7590. // rowIndex++;
  7591. // }
  7592. //}
  7593. if (dac2.Count == dac3.Count)//国家 币种 金额
  7594. {
  7595. for (int i = 0; i < dac2.Count; i++)
  7596. {
  7597. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7598. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7599. }
  7600. }
  7601. int foodandotherStartIndex = 19;//
  7602. decimal dac2totalPrice = 0.00M;
  7603. foreach (var dac in dac2)
  7604. {
  7605. if (dac.SubTotal == 0)
  7606. {
  7607. continue;
  7608. }
  7609. //foodandotherStartIndex = 12;
  7610. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7611. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7612. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7613. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7614. builder.Write(currency);//币种
  7615. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7616. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7617. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7618. builder.Write("");//人数
  7619. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7620. builder.Write("");//天数
  7621. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7622. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7623. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7624. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7625. builder.Write(rate.ToString("#0.0000"));//汇率
  7626. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7627. decimal rbmPrice = rate * dac.SubTotal;
  7628. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7629. foodandotherStartIndex++;
  7630. dac2totalPrice += rbmPrice;
  7631. }
  7632. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7633. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7634. //删除空行
  7635. //if (dac2.Count < foodandotherRows)
  7636. //{
  7637. // while (table2.Rows.Count > dac2.Count)
  7638. // {
  7639. // table2.Rows.RemoveAt(dac2.Count);
  7640. // }
  7641. //}
  7642. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7643. string otherFeeStr = "";
  7644. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7645. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7646. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7647. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7648. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7649. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7650. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7651. foreach (var otherInfo in dac5)
  7652. {
  7653. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7654. }
  7655. #endregion
  7656. if (otherFeeStr.Length > 0)
  7657. {
  7658. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7659. otherFeeStr = $"({otherFeeStr})";
  7660. dic.Add("OtherFeeStr", otherFeeStr);
  7661. }
  7662. foreach (var key in dic.Keys)
  7663. {
  7664. builder.MoveToBookmark(key);
  7665. builder.Write(dic[key]);
  7666. }
  7667. //模板文件名
  7668. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7669. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7670. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7671. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7672. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7673. }
  7674. }
  7675. else if (dto.ExportType == 3)
  7676. {
  7677. if (dto.SubTypeId == 1) //团组成员名单
  7678. {
  7679. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7680. //获取模板
  7681. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7682. //载入模板
  7683. var doc = new Document(tempPath);
  7684. var builder = new DocumentBuilder(doc);
  7685. //获取word里所有表格
  7686. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7687. //获取所填表格的序数
  7688. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7689. var rowStart = tableOne.Rows[0]; //获取第1行
  7690. //循环赋值
  7691. for (int i = 0; i < DeleClientList.Count; i++)
  7692. {
  7693. builder.MoveToCell(0, i + 1, 0, 0);
  7694. builder.Write(DeleClientList[i].Name);
  7695. builder.MoveToCell(0, i + 1, 1, 0);
  7696. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7697. builder.Write(sex);
  7698. builder.MoveToCell(0, i + 1, 2, 0);
  7699. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7700. builder.MoveToCell(0, i + 1, 3, 0);
  7701. builder.Write(DeleClientList[i].Company);
  7702. builder.MoveToCell(0, i + 1, 4, 0);
  7703. builder.Write(DeleClientList[i].Job);
  7704. }
  7705. //删除多余行
  7706. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7707. {
  7708. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7709. }
  7710. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7711. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7712. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7713. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7714. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7715. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7716. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7717. }
  7718. }
  7719. return Ok(JsonView(400, "操作失败!", ""));
  7720. }
  7721. catch (Exception ex)
  7722. {
  7723. return Ok(JsonView(400, ex.Message, ""));
  7724. }
  7725. }
  7726. /// <summary>
  7727. /// 获取三公费用标准city
  7728. /// </summary>
  7729. /// <param name="placeData"></param>
  7730. /// <param name="nationalTravelFeeId"></param>
  7731. /// <returns></returns>
  7732. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7733. {
  7734. string _city = string.Empty;
  7735. if (placeData.Count < 1) return _city;
  7736. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7737. if (data == null) return _city;
  7738. string country = data.Country;
  7739. string city = data.City;
  7740. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7741. else _city = city;
  7742. return _city;
  7743. }
  7744. ///// <summary>
  7745. ///// 团组模块 - 出入境费用 - 明细表导出
  7746. ///// </summary>
  7747. ///// <returns></returns>
  7748. //[HttpPost]
  7749. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7750. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7751. //{
  7752. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7753. // if (data.Code != 0)
  7754. // {
  7755. // return Ok(JsonView(false, data.Msg));
  7756. // }
  7757. // return Ok(JsonView(true, data.Msg, data.Data));
  7758. //}
  7759. /// <summary>
  7760. /// 团组模块 - 出入境费用 - 一键清空
  7761. /// </summary>
  7762. /// <returns></returns>
  7763. [HttpPost]
  7764. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7766. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7767. {
  7768. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7769. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7770. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7771. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7772. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7773. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7774. .SetColumns(x => new Grp_DayOtherPrice
  7775. {
  7776. IsDel = 1,
  7777. DeleteUserId = dto.UserId,
  7778. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7779. })
  7780. .ExecuteCommandAsync();
  7781. if (_view.Code == 0)
  7782. {
  7783. return Ok(JsonView(true, "操作成功"));
  7784. }
  7785. return Ok(JsonView(false, "操作失败"));
  7786. }
  7787. /// <summary>
  7788. /// 团组模块 - 出入境费用 - 子项删除
  7789. /// </summary>
  7790. /// <returns></returns>
  7791. [HttpPost]
  7792. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7794. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7795. {
  7796. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7797. if (data.Code != 0)
  7798. {
  7799. return Ok(JsonView(false, data.Msg));
  7800. }
  7801. return Ok(JsonView(true, "操作成功!", data.Data));
  7802. }
  7803. /// <summary>
  7804. /// 删除三公其他费用
  7805. /// </summary>
  7806. /// <param name="dto"></param>
  7807. /// <returns></returns>
  7808. [HttpPost]
  7809. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7810. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7811. {
  7812. var jw = JsonView(false, "删除失败!");
  7813. var data = new Grp_DayOtherPrice()
  7814. {
  7815. Id = dto.Id,
  7816. IsDel = 1,
  7817. DeleteUserId = dto.DeleteUserId,
  7818. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7819. };
  7820. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7821. if (del > 0)
  7822. {
  7823. jw.Code = 200;
  7824. jw.Msg = "删除成功!";
  7825. }
  7826. return Ok(jw);
  7827. }
  7828. /// <summary>
  7829. /// 团组模块 - 出入境国家费用标准 List
  7830. /// </summary>
  7831. /// <returns></returns>
  7832. [HttpPost]
  7833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7834. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7835. {
  7836. int provinceId = dto.ProvinceId;
  7837. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7838. var nftData = await _sqlSugar
  7839. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7840. JoinType.Left, ntf.Currency == sd1.Id,
  7841. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7842. JoinType.Left, ntf.ProvinceId == c.Id
  7843. ))
  7844. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7845. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7846. {
  7847. Id = ntf.Id,
  7848. ProvinceId = ntf.ProvinceId,
  7849. ProvinceName = c.Name_CN,
  7850. Continent = ntf.Continent,
  7851. Country = ntf.Country,
  7852. City = ntf.City,
  7853. Currency = ntf.Currency,
  7854. CurrencyCode = sd1.Name,
  7855. CurrencyName = sd1.Remark,
  7856. RoomCost = ntf.RoomCost,
  7857. FoodCost = ntf.FoodCost,
  7858. PublicCost = ntf.PublicCost,
  7859. LastUpdateUserId = ntf.LastUpdateUserId,
  7860. LastUpdateUserName = u.CnName,
  7861. LastUpdateTime = ntf.LastUpdateTime
  7862. })
  7863. .ToListAsync();
  7864. return Ok(JsonView(true, "查询成功!", nftData));
  7865. }
  7866. /// <summary>
  7867. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7868. /// </summary>
  7869. /// <returns></returns>
  7870. [HttpPost]
  7871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7872. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7873. {
  7874. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7875. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7876. List<string> countryData = new List<string>();
  7877. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7878. countryData = countryData.Distinct().ToList();
  7879. List<dynamic> dataSource = new List<dynamic>();
  7880. foreach (var item in countryData)
  7881. {
  7882. var cityData1 = new List<string>();
  7883. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7884. var countryData2 = new
  7885. {
  7886. CountryName = item,
  7887. CityData = cityData1
  7888. };
  7889. if (!dataSource.Contains(countryData2))
  7890. {
  7891. dataSource.Add(countryData2);
  7892. }
  7893. }
  7894. return Ok(JsonView(true, "查询成功!", dataSource));
  7895. }
  7896. /// <summary>
  7897. /// 团组模块 - 出入境国家费用标准 Page List
  7898. /// </summary>
  7899. /// <returns></returns>
  7900. [HttpPost]
  7901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7902. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7903. {
  7904. int portId = dto.PortType,
  7905. pageIndex = dto.PageIndex,
  7906. pageSize = dto.PageSize;
  7907. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7908. if (pageIndex == 0) pageIndex = 1;
  7909. if (pageSize == 0) pageSize = 10;
  7910. RefAsync<int> total = 0;
  7911. var nationalTravelFeeData = await _sqlSugar
  7912. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7913. JoinType.Left, ntf.Currency == sd1.Id,
  7914. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7915. JoinType.Left, ntf.ProvinceId == sd2.Id
  7916. ))
  7917. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7918. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7919. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7920. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7921. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7922. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7923. {
  7924. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7925. Id = ntf.Id,
  7926. ProvinceId = ntf.ProvinceId,
  7927. ProvinceName = sd2.Name_CN,
  7928. Continent = ntf.Continent,
  7929. Country = ntf.Country,
  7930. City = ntf.City,
  7931. Currency = ntf.Currency,
  7932. CurrencyCode = sd1.Name,
  7933. CurrencyName = sd1.Remark,
  7934. RoomCost = ntf.RoomCost,
  7935. FoodCost = ntf.FoodCost,
  7936. PublicCost = ntf.PublicCost,
  7937. LastUpdateUserId = ntf.LastUpdateUserId,
  7938. LastUpdateUserName = u.CnName,
  7939. LastUpdateTime = ntf.LastUpdateTime,
  7940. Remark = ntf.Remark
  7941. })
  7942. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7943. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  7944. }
  7945. /// <summary>
  7946. /// 团组模块 - 出入境国家费用标准 根据城市查询
  7947. /// </summary>
  7948. /// <returns></returns>
  7949. [HttpPost]
  7950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7951. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  7952. {
  7953. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  7954. int portId = dto.PortType;
  7955. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7956. string whereSql = string.Empty;
  7957. if (!string.IsNullOrEmpty(dto.Country))
  7958. {
  7959. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  7960. }
  7961. if (!string.IsNullOrEmpty(dto.City))
  7962. {
  7963. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  7964. }
  7965. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  7966. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  7967. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  7968. From Grp_NationalTravelFee gntf
  7969. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  7970. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  7971. Where gntf.Isdel = 0 {0} ", whereSql);
  7972. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  7973. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  7974. }
  7975. /// <summary>
  7976. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  7977. /// </summary>
  7978. /// <returns></returns>
  7979. [HttpPost]
  7980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7981. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  7982. {
  7983. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  7984. }
  7985. /// <summary>
  7986. /// 团组模块 - 出入境国家费用标准 - Del
  7987. /// </summary>
  7988. /// <returns></returns>
  7989. [HttpPost]
  7990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7991. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7992. {
  7993. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7994. {
  7995. Id = dto.Id,
  7996. DeleteUserId = dto.DeleteUserId,
  7997. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7998. IsDel = 1
  7999. };
  8000. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  8001. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  8002. .WhereColumns(it => new { it.Id })
  8003. .ExecuteCommandAsync();
  8004. if (delStatus <= 0)
  8005. {
  8006. return Ok(JsonView(false, "删除失败!"));
  8007. }
  8008. return Ok(JsonView(true, "操作成功!"));
  8009. }
  8010. /// <summary>
  8011. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  8012. /// 注:Get 请求Headers 加 Token
  8013. /// </summary>
  8014. /// <param name="groupId"></param>
  8015. /// <returns></returns>
  8016. [HttpGet("{groupId}")]
  8017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8018. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  8019. {
  8020. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8021. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  8022. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  8023. data.ForEach(x =>
  8024. {
  8025. x.CreateUserId = _currUserInfo.UserId;
  8026. });
  8027. if (data.Any())
  8028. {
  8029. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  8030. if (add > 0)
  8031. {
  8032. return Ok(JsonView(true, "操作成功!"));
  8033. }
  8034. }
  8035. return Ok(JsonView(false, "未操作!"));
  8036. }
  8037. #endregion
  8038. #region 团组经理模块 出入境费用-草稿
  8039. /// <summary>
  8040. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  8041. /// </summary>
  8042. /// <returns></returns>
  8043. [HttpGet]
  8044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8045. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8046. {
  8047. var provData = await _groupRepository.ProvinceBasicSource();
  8048. return Ok(JsonView(true, "查询成功!", provData));
  8049. }
  8050. /// <summary>
  8051. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8052. /// </summary>
  8053. /// <returns></returns>
  8054. [HttpGet("{provinceId}")]
  8055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8056. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8057. {
  8058. //验证城市归属并给默认值
  8059. if (provinceId < 1) provinceId = 122;
  8060. /*
  8061. * 122 四川
  8062. * 108 贵州
  8063. * 103 重庆
  8064. * 132 云南
  8065. */
  8066. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8067. return Ok(JsonView(true, "查询成功!", new
  8068. {
  8069. WordTypeData = wordTypeData,
  8070. ExcelTypeData = excelTypeData,
  8071. }));
  8072. }
  8073. /// <summary>
  8074. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8075. /// </summary>
  8076. /// <returns></returns>
  8077. [HttpPost]
  8078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8079. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8080. {
  8081. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8082. .Where(x => x.IsDel == 0)
  8083. .OrderByDescending(x => x.CreateTime)
  8084. .Select(x => new { x.Id, x.DraftName })
  8085. .ToListAsync();
  8086. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8087. //SetDataInfoView
  8088. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8089. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8090. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8091. int provinceId = dto.ProvinceId;
  8092. if (provinceId < 1) provinceId = 122;
  8093. /*
  8094. * 122 四川
  8095. * 108 贵州
  8096. * 103 重庆
  8097. * 132 云南
  8098. */
  8099. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8100. //默认币种显示
  8101. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8102. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8103. return Ok(JsonView(true, "查询成功!", new
  8104. {
  8105. DraftNameDatas = draftNameDatas,
  8106. CurrencyData = _CurrencyData,
  8107. WordTypeData = wordTypeData,
  8108. ExcelTypeData = excelTypeData,
  8109. CurrencyInit = _currencyInfos,
  8110. ViewPermissionData = viewPermissionData
  8111. }));
  8112. }
  8113. /// <summary>
  8114. /// 团组模块 - 出入境费用-草稿
  8115. /// 实时汇率 tips
  8116. /// 机票费用 tips
  8117. /// </summary>
  8118. /// <returns></returns>
  8119. [HttpPost]
  8120. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8121. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8122. {
  8123. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8124. return Ok(JsonView(true, "查询成功!", new
  8125. {
  8126. //GroupNameData = groupNameData.Data,
  8127. //visaData = visaData.Data,
  8128. //airData = airData.Data,
  8129. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8130. }));
  8131. }
  8132. /// <summary>
  8133. /// 团组模块 - 出入境费用-草稿
  8134. /// 签证费用 tips
  8135. /// </summary>
  8136. /// <returns></returns>
  8137. [HttpPost]
  8138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8139. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8140. {
  8141. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8142. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8143. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8144. .Select(x => x.NationalTravelFeeId)
  8145. .Distinct()
  8146. .ToListAsync();
  8147. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8148. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8149. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8150. .Select(x => x.Country)
  8151. .Distinct()
  8152. .ToArrayAsync();
  8153. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8154. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8155. return Ok(JsonView(true, "查询成功!", new
  8156. {
  8157. totalAmt = totalAmt,
  8158. remark = remark
  8159. }));
  8160. }
  8161. /// <summary>
  8162. /// 团组模块 - 出入境费用-草稿 - Info
  8163. /// </summary>
  8164. /// <returns></returns>
  8165. [HttpPost]
  8166. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8168. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8169. {
  8170. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8171. }
  8172. /// <summary>
  8173. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8174. /// </summary>
  8175. /// <returns></returns>
  8176. [HttpPost]
  8177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8178. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8179. {
  8180. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8181. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8182. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8183. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8184. foreach (var userId in dto.UserIds)
  8185. {
  8186. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8187. }
  8188. if (permissions.Any())
  8189. {
  8190. _sqlSugar.BeginTran();
  8191. try
  8192. {
  8193. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8194. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8195. if (result < 1)
  8196. {
  8197. _sqlSugar.RollbackTran();
  8198. return Ok(JsonView(false));
  8199. }
  8200. }
  8201. catch (Exception ex)
  8202. {
  8203. _sqlSugar.RollbackTran();
  8204. return Ok(JsonView(false, ex.Message));
  8205. }
  8206. _sqlSugar.CommitTran();
  8207. return Ok(JsonView(true));
  8208. }
  8209. return Ok(JsonView(false));
  8210. }
  8211. /// <summary>
  8212. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8213. /// </summary>
  8214. /// <returns></returns>
  8215. [HttpPost]
  8216. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8218. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8219. {
  8220. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8221. if (data.Code != 0)
  8222. {
  8223. return Ok(JsonView(false, data.Msg));
  8224. }
  8225. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8226. //汇率信息记录
  8227. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8228. return Ok(JsonView(true, data.Msg, data.Data));
  8229. }
  8230. /// <summary>
  8231. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8232. /// </summary>
  8233. /// <param name="dto"></param>
  8234. /// <returns></returns>
  8235. [HttpPost]
  8236. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8238. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8239. {
  8240. try
  8241. {
  8242. var id = dto.Id;
  8243. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8244. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8245. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8246. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8247. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8248. 3 团组成员名单 1 团组成员名单", ""));
  8249. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8250. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8251. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8252. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8253. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8254. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8255. //数据源
  8256. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8257. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8258. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8259. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8260. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8261. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8262. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8263. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8264. .Select((x, a, b) => new
  8265. {
  8266. x.Index,
  8267. itemName = a.Name,
  8268. CurrencyStr = b.Name,
  8269. x.Cost,
  8270. x.SubTotal,
  8271. x.Remark
  8272. })
  8273. .OrderBy((x) => x.Index)
  8274. .ToList(); //其他款项费用
  8275. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8276. var peiceItemCurrencys = new List<string>();
  8277. if (_DayAndCosts.Any())
  8278. {
  8279. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8280. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8281. }
  8282. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8283. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8284. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8285. {
  8286. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8287. }
  8288. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8289. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8290. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8291. if (dto.ExportType == 1) //明细表
  8292. {
  8293. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8294. {
  8295. //获取模板
  8296. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8297. //载入模板
  8298. Document doc = new Document(tempPath);
  8299. DocumentBuilder builder = new DocumentBuilder(doc);
  8300. //利用键值对存放数据
  8301. Dictionary<string, string> dic = new Dictionary<string, string>();
  8302. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8303. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8304. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8305. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8306. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8307. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8308. //境内费用(其他费用)
  8309. if (_EnterExitCosts.ChoiceOne == 1)
  8310. {
  8311. string row1_1 = "";
  8312. if (_EnterExitCosts.Visa > 0)
  8313. {
  8314. //insidePayTotal += _EnterExitCosts.Visa;
  8315. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8316. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8317. //{
  8318. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8319. //}
  8320. }
  8321. string row1_2 = "";
  8322. if (_EnterExitCosts.YiMiao > 0)
  8323. {
  8324. //insidePayTotal += _EnterExitCosts.YiMiao;
  8325. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8326. }
  8327. if (_EnterExitCosts.HeSuan > 0)
  8328. {
  8329. //insidePayTotal += _EnterExitCosts.HeSuan;
  8330. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8331. }
  8332. if (_EnterExitCosts.Service > 0)
  8333. {
  8334. //insidePayTotal += _EnterExitCosts.Service;
  8335. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8336. }
  8337. string row1_3 = "";
  8338. if (_EnterExitCosts.Safe > 0)
  8339. {
  8340. //insidePayTotal += _EnterExitCosts.Safe;
  8341. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8342. }
  8343. if (_EnterExitCosts.Ticket > 0)
  8344. {
  8345. //insidePayTotal += _EnterExitCosts.Ticket;
  8346. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8347. }
  8348. string row1 = "";
  8349. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8350. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8351. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8352. row1 += $"备注:{_EnterExitCosts.Remark}";
  8353. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8354. dic.Add("Row1Str", row1);
  8355. }
  8356. string airTotalStr = string.Empty,
  8357. airPriceStr = string.Empty;
  8358. //经济舱
  8359. if (_EnterExitCosts.SumJJC == 1)
  8360. {
  8361. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8362. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8363. }
  8364. //公务舱
  8365. if (_EnterExitCosts.SumGWC == 1)
  8366. {
  8367. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8368. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8369. }
  8370. //头等舱
  8371. if (_EnterExitCosts.SumTDC == 1)
  8372. {
  8373. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8374. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8375. }
  8376. //汇率描述
  8377. string rateStr = "";
  8378. if (peiceItemCurrencyInfos.Any())
  8379. {
  8380. rateStr = "\r\n汇率描述:";
  8381. foreach (var item in peiceItemCurrencyInfos)
  8382. {
  8383. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8384. }
  8385. }
  8386. string twoItemRemark = "备注:";
  8387. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8388. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8389. dic.Add("AirTotalStr", airTotalStr);
  8390. dic.Add("AirPriceStr", airPriceStr);
  8391. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8392. dic.Add("TwoItemRemark", twoItemRemark);
  8393. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8394. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8395. int table1Row = 0,
  8396. table2Row = 0,
  8397. table3Row = 0,
  8398. table4Row = 0,
  8399. table5Row = 0;
  8400. //住宿费
  8401. if (_EnterExitCosts.ChoiceThree == 1)
  8402. {
  8403. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8404. table1Row = dac1.Count;
  8405. #region 填充word表格内容
  8406. for (int i = 0; i < dac1.Count; i++)
  8407. {
  8408. var dac = dac1[i];
  8409. if (dac == null) continue;
  8410. builder.MoveToCell(0, i, 0, 0);
  8411. builder.Write("第" + dac.Days.ToString() + "晚:");
  8412. builder.MoveToCell(0, i, 1, 0);
  8413. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8414. //builder.Write(dac.Place == null ? "" : dac.Place);
  8415. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8416. builder.MoveToCell(0, i, 2, 0);
  8417. builder.Write("费用标准:");
  8418. string curr = "";
  8419. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8420. if (currData != null)
  8421. {
  8422. curr = currData.Name;
  8423. }
  8424. builder.MoveToCell(0, i, 3, 0);
  8425. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8426. builder.MoveToCell(0, i, 4, 0);
  8427. builder.Write("费用小计:");
  8428. builder.MoveToCell(0, i, 5, 0);
  8429. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8430. }
  8431. #endregion
  8432. }
  8433. else dic.Add("SubZS", "0.00");
  8434. //删除多余行
  8435. while (table1.Rows.Count > table1Row)
  8436. {
  8437. table1.Rows.RemoveAt(table1Row);
  8438. }
  8439. //伙食费
  8440. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8441. if (_EnterExitCosts.ChoiceFour == 1)
  8442. {
  8443. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8444. table2Row = dac2.Count;
  8445. #region 填充word表格内容
  8446. for (int i = 0; i < dac2.Count; i++)
  8447. {
  8448. var dac = dac2[i];
  8449. if (dac == null) continue;
  8450. builder.MoveToCell(1, i, 0, 0);
  8451. builder.Write("第" + dac.Days.ToString() + "天:");
  8452. builder.MoveToCell(1, i, 1, 0);
  8453. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8454. builder.MoveToCell(1, i, 2, 0);
  8455. builder.Write("费用标准:");
  8456. string curr = "";
  8457. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8458. if (currData != null)
  8459. {
  8460. curr = currData.Name;
  8461. }
  8462. builder.MoveToCell(1, i, 3, 0);
  8463. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8464. builder.MoveToCell(1, i, 4, 0);
  8465. builder.Write("费用小计:");
  8466. builder.MoveToCell(1, i, 5, 0);
  8467. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8468. }
  8469. #endregion
  8470. }
  8471. else dic.Add("SubHS", "0.00");
  8472. //删除多余行
  8473. while (table2.Rows.Count > table2Row)
  8474. {
  8475. table2.Rows.RemoveAt(table2Row);
  8476. }
  8477. //公杂费
  8478. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8479. if (_EnterExitCosts.ChoiceFive == 1)
  8480. {
  8481. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8482. table3Row = dac3.Count;
  8483. #region 填充word表格内容
  8484. for (int i = 0; i < dac3.Count; i++)
  8485. {
  8486. var dac = dac3[i];
  8487. if (dac == null) continue;
  8488. builder.MoveToCell(2, i, 0, 0);
  8489. builder.Write("第" + dac.Days.ToString() + "天:");
  8490. builder.MoveToCell(2, i, 1, 0);
  8491. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8492. builder.MoveToCell(2, i, 2, 0);
  8493. builder.Write("费用标准:");
  8494. string curr = "";
  8495. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8496. if (currData != null)
  8497. {
  8498. curr = currData.Name;
  8499. }
  8500. builder.MoveToCell(2, i, 3, 0);
  8501. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8502. builder.MoveToCell(2, i, 4, 0);
  8503. builder.Write("费用小计:");
  8504. builder.MoveToCell(2, i, 5, 0);
  8505. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8506. }
  8507. //删除多余行
  8508. while (table3.Rows.Count > table3Row)
  8509. {
  8510. table3.Rows.RemoveAt(table3Row);
  8511. }
  8512. #endregion
  8513. }
  8514. else dic.Add("SubGZF", "0.00");
  8515. //删除多余行
  8516. while (table3.Rows.Count > table3Row)
  8517. {
  8518. table3.Rows.RemoveAt(table3Row);
  8519. }
  8520. //培训费
  8521. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8522. if (_EnterExitCosts.ChoiceSix == 1)
  8523. {
  8524. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8525. dic.Add("SubPX", pxStr);
  8526. table4Row = dac4.Count;
  8527. #region 填充word表格内容
  8528. for (int i = 0; i < dac4.Count; i++)
  8529. {
  8530. var dac = dac4[i];
  8531. if (dac == null) continue;
  8532. builder.MoveToCell(3, i, 0, 0);
  8533. builder.Write("第" + dac.Days.ToString() + "天:");
  8534. builder.MoveToCell(3, i, 1, 0);
  8535. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8536. builder.MoveToCell(3, i, 2, 0);
  8537. builder.Write("费用标准:");
  8538. string curr = "";
  8539. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8540. if (currData != null)
  8541. {
  8542. curr = currData.Name;
  8543. }
  8544. builder.MoveToCell(3, i, 3, 0);
  8545. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8546. builder.MoveToCell(3, i, 4, 0);
  8547. builder.Write("费用小计:");
  8548. builder.MoveToCell(3, i, 5, 0);
  8549. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8550. }
  8551. #endregion
  8552. }
  8553. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8554. //删除多余行
  8555. while (table4.Rows.Count > table4Row)
  8556. {
  8557. table4.Rows.RemoveAt(table4Row);
  8558. }
  8559. //其他费用
  8560. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8561. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8562. {
  8563. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8564. dic.Add("titleQi", qtStr);
  8565. table5Row = dac5.Count;
  8566. #region 填充word表格内容
  8567. for (int i = 0; i < dac5.Count; i++)
  8568. {
  8569. var dac = dac5[i];
  8570. if (dac == null) continue;
  8571. builder.MoveToCell(4, i, 0, 0);
  8572. builder.Write("第" + dac.Index.ToString() + "项:");
  8573. builder.MoveToCell(4, i, 1, 0);
  8574. builder.Write(dac.itemName);
  8575. builder.MoveToCell(4, i, 2, 0);
  8576. builder.Write("费用标准:");
  8577. builder.MoveToCell(4, i, 3, 0);
  8578. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8579. builder.MoveToCell(4, i, 4, 0);
  8580. builder.Write("费用小计:");
  8581. builder.MoveToCell(4, i, 5, 0);
  8582. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8583. builder.MoveToCell(4, i, 6, 0);
  8584. builder.Write("备注:");
  8585. builder.MoveToCell(4, i, 7, 0);
  8586. builder.Write(dac.Remark);
  8587. }
  8588. #endregion
  8589. }
  8590. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8591. //删除多余行
  8592. while (table5.Rows.Count > table5Row)
  8593. {
  8594. table5.Rows.RemoveAt(table5Row);
  8595. }
  8596. //加上其他费用
  8597. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8598. decimal subJJC = 0.00M,
  8599. subGWC = 0.00M,
  8600. subTDC = 0.00M;
  8601. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8602. string totalLabel = string.Format("全部费用总计:");
  8603. //经济舱
  8604. if (_EnterExitCosts.SumJJC == 1)
  8605. {
  8606. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8607. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8608. }
  8609. //公务舱
  8610. if (_EnterExitCosts.SumGWC == 1)
  8611. {
  8612. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8613. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8614. }
  8615. //头等舱
  8616. if (_EnterExitCosts.SumTDC == 1)
  8617. {
  8618. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8619. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8620. }
  8621. //TotalLabel
  8622. dic.Add("TotalLabel", totalLabel);
  8623. #region 填充word模板书签内容
  8624. foreach (var key in dic.Keys)
  8625. {
  8626. Bookmark bookmark = doc.Range.Bookmarks[key];
  8627. if (bookmark != null)
  8628. {
  8629. builder.MoveToBookmark(key);
  8630. builder.Write(dic[key]);
  8631. }
  8632. }
  8633. #endregion
  8634. //文件名
  8635. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8636. strFileName = CommonFun.ValidFileName(strFileName);
  8637. AsposeHelper.removewatermark_v2180();
  8638. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8639. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8640. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8641. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8642. }
  8643. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8644. {
  8645. //获取模板
  8646. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8647. //载入模板
  8648. Document doc = new Document(tempPath);
  8649. DocumentBuilder builder = new DocumentBuilder(doc);
  8650. Dictionary<string, string> dic = new Dictionary<string, string>();
  8651. string returnCodeLabel = string.Empty;
  8652. if (nationalTravelFeeData.Any())
  8653. {
  8654. List<string> list = new List<string>();
  8655. foreach (var item in nationalTravelFeeData)
  8656. {
  8657. list.Add($"{item.Country}({item.City})");
  8658. }
  8659. list = list.Distinct().ToList();
  8660. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8661. }
  8662. var countryLabel = string.Empty;
  8663. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8664. if (countryData.Any())
  8665. {
  8666. countryLabel = string.Join("、", countryData);
  8667. }
  8668. dic.Add("ReturnCodeAir", returnCodeLabel);
  8669. dic.Add("VisitStartDate", "-");
  8670. dic.Add("VisitEndDate", "-");
  8671. dic.Add("Day", "-");
  8672. dic.Add("VisitCountry", countryLabel);
  8673. dic.Add("ClientUnit", "-");
  8674. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8675. //dic.Add("Names", Names);
  8676. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8677. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8678. decimal dac1totalPrice = 0.00M;
  8679. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8680. foreach (var dac in dac1)
  8681. {
  8682. if (dac.SubTotal == 0.00M)
  8683. {
  8684. continue;
  8685. }
  8686. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8687. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8688. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8689. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8690. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8691. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8692. builder.Write(currency);//币种
  8693. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8694. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8695. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8696. builder.Write("");//人数
  8697. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8698. builder.Write("");//天数
  8699. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8700. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8701. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8702. decimal rate = 0.00M;
  8703. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8704. builder.Write(rate.ToString("#0.0000"));//汇率
  8705. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8706. decimal rbmPrice = dac.SubTotal;
  8707. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8708. accommodationStartIndex++;
  8709. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8710. }
  8711. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8712. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8713. {
  8714. table1.Rows.RemoveAt(i - 1);
  8715. foodandotherStartIndex--;
  8716. }
  8717. if (dac2.Count == dac3.Count)//国家 币种 金额
  8718. {
  8719. for (int i = 0; i < dac2.Count; i++)
  8720. {
  8721. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8722. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8723. }
  8724. }
  8725. decimal dac2totalPrice = 0.00M;
  8726. foreach (var dac in dac2)
  8727. {
  8728. if (dac.SubTotal == 0)
  8729. {
  8730. continue;
  8731. }
  8732. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8733. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8734. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8735. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8736. builder.Write(currency);//币种
  8737. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8738. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8739. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8740. builder.Write("");//人数
  8741. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8742. builder.Write("");//天数
  8743. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8744. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8745. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8746. decimal rate = 0.00M;
  8747. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8748. builder.Write(rate.ToString("#0.0000"));//汇率
  8749. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8750. decimal rbmPrice = dac.SubTotal;
  8751. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8752. foodandotherStartIndex++;
  8753. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8754. }
  8755. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8756. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8757. {
  8758. table1.Rows.RemoveAt(i - 1);
  8759. }
  8760. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8761. string otherFeeStr = "";
  8762. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8763. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8764. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8765. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8766. foreach (var otherInfo in dac5)
  8767. {
  8768. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8769. }
  8770. #endregion
  8771. if (otherFeeStr.Length > 0)
  8772. {
  8773. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8774. otherFeeStr = $"({otherFeeStr})";
  8775. dic.Add("OtherFeeStr", otherFeeStr);
  8776. }
  8777. //总计
  8778. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8779. //国际旅费
  8780. string outsideAir = string.Empty;
  8781. string allPriceAir = string.Empty;
  8782. if (_EnterExitCosts.SumJJC == 1)
  8783. {
  8784. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8785. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8786. }
  8787. if (_EnterExitCosts.SumGWC == 1)
  8788. {
  8789. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8790. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8791. }
  8792. if (_EnterExitCosts.SumTDC == 1)
  8793. {
  8794. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8795. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8796. }
  8797. dic.Add("InTravelPrice", $"({outsideAir})");
  8798. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8799. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8800. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8801. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8802. foreach (var key in dic.Keys)
  8803. {
  8804. builder.MoveToBookmark(key);
  8805. builder.Write(dic[key]);
  8806. }
  8807. //模板文件名
  8808. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8809. strFileName = CommonFun.ValidFileName(strFileName);
  8810. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8811. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8812. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8813. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8814. }
  8815. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8816. {
  8817. //获取模板
  8818. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8819. //载入模板
  8820. WorkbookDesigner designer = new WorkbookDesigner();
  8821. designer.Workbook = new Workbook(tempPath);
  8822. Dictionary<string, string> dic = new Dictionary<string, string>();
  8823. string returnCodeLabel = string.Empty;
  8824. if (nationalTravelFeeData.Any())
  8825. {
  8826. List<string> list = new List<string>();
  8827. foreach (var item in nationalTravelFeeData)
  8828. {
  8829. list.Add($"{item.Country}({item.City})");
  8830. }
  8831. list = list.Distinct().ToList();
  8832. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8833. }
  8834. var countryLabel = string.Empty;
  8835. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8836. if (countryData.Any())
  8837. {
  8838. countryLabel = string.Join("、", countryData);
  8839. }
  8840. dic.Add("ReturnCodeAir", returnCodeLabel);
  8841. dic.Add("VisitStartDate", "-");
  8842. dic.Add("VisitEndDate", "-");
  8843. dic.Add("Day", "0");
  8844. dic.Add("VisitCountry", countryLabel);
  8845. dic.Add("ClientUnit", "-");
  8846. designer.SetDataSource("ClientUnit", "-");
  8847. designer.SetDataSource("VisitCountry", countryLabel);
  8848. designer.SetDataSource("Group", "-");
  8849. designer.SetDataSource("ClientUnitTitle", "-");
  8850. designer.SetDataSource("Name", "-");
  8851. designer.SetDataSource("VisitStartDate", "-");
  8852. designer.SetDataSource("Day", "0");
  8853. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8854. designer.SetDataSource("ReturnCodeAir", "-");
  8855. int startIndex = 10;
  8856. const int startIndexcopy = 10;
  8857. if (dac2.Count == dac3.Count)//国家 币种 金额
  8858. {
  8859. for (int i = 0; i < dac2.Count; i++)
  8860. {
  8861. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8862. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8863. }
  8864. }
  8865. DataTable dtdac1 = new DataTable();
  8866. List<string> place = new List<string>();
  8867. dtdac1.Columns.AddRange(new DataColumn[] {
  8868. new DataColumn(){ ColumnName = "city"},
  8869. new DataColumn(){ ColumnName = "curr"},
  8870. new DataColumn(){ ColumnName = "criterion"},
  8871. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8872. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8873. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8874. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8875. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8876. });
  8877. DataTable dtdac2 = new DataTable();
  8878. dtdac2.Columns.AddRange(new DataColumn[] {
  8879. new DataColumn(){ ColumnName = "city"},
  8880. new DataColumn(){ ColumnName = "curr"},
  8881. new DataColumn(){ ColumnName = "criterion"},
  8882. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8883. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8884. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8885. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8886. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8887. });
  8888. dtdac1.TableName = "tb1";
  8889. dtdac2.TableName = "tb2";
  8890. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8891. foreach (var item in dac1)
  8892. {
  8893. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8894. if (place.Contains(item.Place))
  8895. {
  8896. continue;
  8897. }
  8898. DataRow row = dtdac1.NewRow();
  8899. row["city"] = item.Place;
  8900. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8901. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8902. row["curr"] = currency;
  8903. row["rate"] = rate.ToString("#0.0000");
  8904. row["criterion"] = item.Cost.ToString("#0.00");
  8905. row["number"] = 1;
  8906. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8907. //row["costRMB"] = rbmPrice;
  8908. dtdac1.Rows.Add(row);
  8909. place.Add(item.Place);
  8910. }
  8911. place = new List<string>();
  8912. foreach (var item in dac2)
  8913. {
  8914. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8915. if (place.Contains(item.Place))
  8916. {
  8917. continue;
  8918. }
  8919. DataRow row = dtdac2.NewRow();
  8920. row["city"] = item.Place;
  8921. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8922. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8923. row["curr"] = currency;
  8924. row["rate"] = rate.ToString("#0.0000");
  8925. row["criterion"] = item.Cost.ToString("#0.00");
  8926. row["number"] = 1;
  8927. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8928. //row["cost"] = item.SubTotal;
  8929. //row["costRMB"] = rbmPrice;
  8930. dtdac2.Rows.Add(row);
  8931. place.Add(item.Place);
  8932. //dac2totalPrice += rbmPrice;
  8933. }
  8934. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8935. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8936. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8937. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8938. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8939. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8940. string cell4Str1 = string.Empty;
  8941. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8942. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8943. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8944. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8945. string cellStr = $" 5.其他费用(";
  8946. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8947. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8948. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8949. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8950. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8951. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8952. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8953. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8954. foreach (var otherInfo in dac5)
  8955. {
  8956. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8957. }
  8958. #endregion
  8959. if (cellStr.Length > 8)
  8960. {
  8961. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8962. }
  8963. cellStr += ")";
  8964. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8965. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8966. decimal pxFee = dac4.Sum(it => it.Cost);
  8967. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8968. string celllastStr1 = "";
  8969. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8970. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8971. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8972. celllastStr1 += $",国际旅费 元";
  8973. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8974. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8975. designer.SetDataSource("cell4Str", cell4Str);
  8976. designer.SetDataSource("cellStr", cellStr);
  8977. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8978. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8979. designer.SetDataSource("celllastStr", celllastStr);
  8980. Workbook wb = designer.Workbook;
  8981. var sheet = wb.Worksheets[0];
  8982. //绑定datatable数据集
  8983. designer.SetDataSource(dtdac1);
  8984. designer.SetDataSource(dtdac2);
  8985. designer.Process();
  8986. var rowStart = dtdac1.Rows.Count;
  8987. while (rowStart > 0)
  8988. {
  8989. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8990. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8991. startIndex++;
  8992. rowStart--;
  8993. }
  8994. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8995. startIndex += 1; //总计行
  8996. rowStart = dtdac2.Rows.Count;
  8997. while (rowStart > 0)
  8998. {
  8999. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  9000. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9001. startIndex++;
  9002. rowStart--;
  9003. }
  9004. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  9005. wb.CalculateFormula(true);
  9006. //模板文件名
  9007. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9008. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9009. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9010. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9011. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9012. }
  9013. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  9014. {
  9015. //获取模板
  9016. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  9017. //载入模板
  9018. Document doc = new Document(tempPath);
  9019. DocumentBuilder builder = new DocumentBuilder(doc);
  9020. Dictionary<string, string> dic = new Dictionary<string, string>();
  9021. dic.Add("GroupName", "-");
  9022. dic.Add("ClientUnit", "-");
  9023. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  9024. //string missionLeaderJob = "";//负责人job
  9025. //int groupNumber = 0; //团人数
  9026. dic.Add("MissionLeader", "-"); //团负责人
  9027. dic.Add("MissionLeaderJob", "-"); //团负责人job
  9028. dic.Add("GroupNumber", "0"); //团人数
  9029. dic.Add("Day", "0");
  9030. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  9031. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  9032. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9033. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9034. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  9035. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  9036. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  9037. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  9038. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  9039. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  9040. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  9041. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9042. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9043. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9044. //其他费用
  9045. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9046. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9047. //其他费用合计
  9048. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9049. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9050. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9051. //公务舱合计
  9052. //国际旅费
  9053. //string outsideJJ = "";
  9054. //string allPriceJJ = "";
  9055. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9056. {
  9057. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9058. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9059. }
  9060. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9061. {
  9062. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9063. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9064. }
  9065. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9066. {
  9067. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9068. dic.Add("AirFeeTotal", airFeeTotalStr);
  9069. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9070. dic.Add("FeeTotal", feeTotalStr);
  9071. }
  9072. foreach (var key in dic.Keys)
  9073. {
  9074. builder.MoveToBookmark(key);
  9075. builder.Write(dic[key]);
  9076. }
  9077. //模板文件名
  9078. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9079. strFileName = CommonFun.ValidFileName(strFileName);
  9080. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9081. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9082. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9083. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9084. }
  9085. }
  9086. else if (dto.ExportType == 2) //表格
  9087. {
  9088. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9089. }
  9090. else if (dto.ExportType == 3)
  9091. {
  9092. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9093. }
  9094. return Ok(JsonView(400, "只可导出明细表!", ""));
  9095. }
  9096. catch (Exception ex)
  9097. {
  9098. return Ok(JsonView(400, ex.Message, ""));
  9099. }
  9100. }
  9101. /// <summary>
  9102. /// 获取三公费用标准city
  9103. /// </summary>
  9104. /// <param name="placeData"></param>
  9105. /// <param name="nationalTravelFeeId"></param>
  9106. /// <returns></returns>
  9107. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9108. {
  9109. string _city = string.Empty;
  9110. if (!placeData.Any()) return _city;
  9111. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9112. if (data == null) return _city;
  9113. string country = data.Country;
  9114. string city = data.City;
  9115. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9116. else _city = city;
  9117. return _city;
  9118. }
  9119. /// <summary>
  9120. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9121. /// </summary>
  9122. /// <returns></returns>
  9123. [HttpPost]
  9124. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9126. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9127. {
  9128. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9129. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9130. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9131. if (_view.Code == 0)
  9132. {
  9133. return Ok(JsonView(true, "操作成功"));
  9134. }
  9135. return Ok(JsonView(false, "操作失败"));
  9136. }
  9137. /// <summary>
  9138. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9139. /// </summary>
  9140. /// <returns></returns>
  9141. [HttpPost]
  9142. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9144. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9145. {
  9146. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9147. if (data.Code != 0)
  9148. {
  9149. return Ok(JsonView(false, data.Msg));
  9150. }
  9151. return Ok(JsonView(true, "操作成功!", data.Data));
  9152. }
  9153. /// <summary>
  9154. /// 三公其他费用草稿 删除
  9155. /// </summary>
  9156. /// <param name="dto"></param>
  9157. /// <returns></returns>
  9158. [HttpPost]
  9159. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9160. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9161. {
  9162. var jw = JsonView(false, "删除失败!");
  9163. var data = new Grp_DayOtherPriceDraft()
  9164. {
  9165. Id = dto.Id,
  9166. IsDel = 1,
  9167. DeleteUserId = dto.DeleteUserId,
  9168. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9169. };
  9170. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9171. if (del > 0)
  9172. {
  9173. jw.Code = 200;
  9174. jw.Msg = "删除成功!";
  9175. }
  9176. return Ok(jw);
  9177. }
  9178. /// <summary>
  9179. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9180. /// </summary>
  9181. /// <returns></returns>
  9182. [HttpPost]
  9183. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9184. {
  9185. var jw = JsonView(false);
  9186. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9187. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9188. jw.Code = StatusCodes.Status200OK;
  9189. jw.Msg = "操作成功!";
  9190. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9191. return Ok(jw);
  9192. }
  9193. /// <summary>
  9194. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9195. /// </summary>
  9196. /// <param name="dto"></param>
  9197. /// <returns></returns>
  9198. [HttpPost]
  9199. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9200. {
  9201. int userId = dto.UserId,
  9202. portId = dto.PortType,
  9203. groupId = dto.GroupId,
  9204. draftId = dto.DraftId;
  9205. _portTypeData.Add(1);
  9206. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9207. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9208. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9209. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9210. _sqlSugar.BeginTran();
  9211. try
  9212. {
  9213. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9214. if (draftDatas == null)
  9215. {
  9216. _sqlSugar.RollbackTran();
  9217. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9218. }
  9219. //验证可覆盖已有数据 两边创建人需为同一人;
  9220. int draftCreateUserId = draftDatas.CreateUserId,
  9221. formalCreateUserId = 0;
  9222. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9223. if (formalData != null)
  9224. {
  9225. formalCreateUserId = formalData.CreateUserId;
  9226. if (draftCreateUserId != formalCreateUserId)
  9227. {
  9228. _sqlSugar.RollbackTran();
  9229. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9230. }
  9231. }
  9232. //默认添加查看、编辑权限(创建人、自己)
  9233. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9234. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9235. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9236. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9237. newExterData.DiId = groupId;
  9238. newExterData.CreateUserId = userId;
  9239. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9240. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9241. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9242. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9243. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9244. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9245. //数据如果存在执行删除
  9246. if (enterExitCostInfo != null)
  9247. {
  9248. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9249. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9250. .Where(x => x.Id == enterExitCostInfo.Id)
  9251. .ExecuteCommand();
  9252. _sqlSugar.Updateable<Grp_DayAndCost>()
  9253. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9254. .Where(x => x.DiId == groupId)
  9255. .ExecuteCommand();
  9256. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9257. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9258. .Where(x => x.Diid == groupId)
  9259. .ExecuteCommand();
  9260. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9261. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9262. .Where(x => x.GroupId == groupId)
  9263. .ExecuteCommand();
  9264. }
  9265. //执行insert
  9266. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9267. if (insertId < 1)
  9268. {
  9269. _sqlSugar.RollbackTran();
  9270. return Ok(JsonView(false, "草稿数据导入失败!"));
  9271. }
  9272. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9273. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9274. #region 默认添加权限
  9275. #endregion
  9276. _sqlSugar.CommitTran();
  9277. //执行操作之后
  9278. //生成默认文件pdf并且通知人员
  9279. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9280. {
  9281. DiId = groupId,
  9282. ExportType = 1,
  9283. SubTypeId = 1005
  9284. }, "pdf");
  9285. //发送通知
  9286. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9287. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9288. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9289. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9290. //汇率信息记录
  9291. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9292. return Ok(JsonView(true));
  9293. }
  9294. catch (Exception ex)
  9295. {
  9296. _sqlSugar.RollbackTran();
  9297. return Ok(JsonView(false, ex.Message));
  9298. }
  9299. }
  9300. #endregion
  9301. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9302. /// <summary>
  9303. /// 获取币种基础数据(含逻辑处理)
  9304. /// </summary>
  9305. /// <returns></returns>
  9306. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9307. {
  9308. return await GeneralMethod.EnterExitCostInitRate();
  9309. }
  9310. /// <summary>
  9311. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9312. /// </summary>
  9313. /// <returns></returns>
  9314. [HttpPost]
  9315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9316. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9317. {
  9318. //验证城市归属并给默认值
  9319. int provinceId = dto.ProvinceId;
  9320. if (provinceId < 1) provinceId = 122;
  9321. var dataSource = await _sqlSugar
  9322. .Queryable<Sys_SetData>()
  9323. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9324. .ToListAsync();
  9325. var fileTypes = new List<EecSetDataInfoView>();
  9326. //三公费用-Word明细类型
  9327. var wordTypeData = dataSource
  9328. .Where(it => it.STid == 72)
  9329. .Select(x => new EecSetDataInfoView
  9330. {
  9331. ParentId = 1,
  9332. Id = x.Id,
  9333. Name = x.Name
  9334. })
  9335. .ToArray();
  9336. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9337. var excelTypeData = dataSource
  9338. .Where(it => it.STid == 73)
  9339. .Select(x => new EecSetDataInfoView
  9340. {
  9341. ParentId = 2,
  9342. Id = x.Id,
  9343. Name = x.Name
  9344. })
  9345. .ToArray();
  9346. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9347. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9348. fileTypes.Add(groupNameList);
  9349. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9350. //默认币种显示
  9351. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9352. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9353. return Ok(JsonView(true, "查询成功!", new
  9354. {
  9355. FileTypeData = fileTypes,
  9356. CurrencyInit = _currencyInfos,
  9357. viewPermissionData = viewPermissionData
  9358. }));
  9359. }
  9360. /// <summary>
  9361. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9362. /// </summary>
  9363. /// <returns></returns>
  9364. [HttpPost]
  9365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9366. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9367. {
  9368. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9369. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9370. RefAsync<int> total = 0;
  9371. int diId = 0;
  9372. var status = int.TryParse(dto.GroupName, out diId);
  9373. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9374. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9375. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9376. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9377. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9378. .OrderByDescending(x => x.VisitStartDate)
  9379. .Select(x => new EnterExitCostMobileGroupView()
  9380. {
  9381. Id = x.Id,
  9382. GroupName = x.TeamName,
  9383. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9384. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9385. ProvinceId = x.CityId
  9386. })
  9387. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9388. //处理省份Id
  9389. if (data.Any())
  9390. {
  9391. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9392. if (provCityDatas.Any())
  9393. {
  9394. foreach (var item in data)
  9395. {
  9396. var provinceId = item.ProvinceId;
  9397. var isDefualtVal = true;
  9398. if (provinceId > 0)
  9399. {
  9400. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9401. if (parentId != null)
  9402. {
  9403. isDefualtVal = false;
  9404. item.ProvinceId = (int)parentId;
  9405. }
  9406. }
  9407. if (isDefualtVal)
  9408. {
  9409. item.ProvinceId = 122; //默认四川
  9410. }
  9411. }
  9412. }
  9413. }
  9414. //处理是否显示
  9415. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9416. {
  9417. foreach (var item in data)
  9418. {
  9419. item.IsView = true;
  9420. }
  9421. }
  9422. return Ok(JsonView(true, "查询成功!", data, total));
  9423. }
  9424. /// <summary>
  9425. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9426. /// </summary>
  9427. /// <returns></returns>
  9428. [HttpPost]
  9429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9430. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9431. {
  9432. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9433. RefAsync<int> total = 0;
  9434. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9435. .Where(x => x.IsDel == 0 && x.STid == 66)
  9436. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9437. .Select(x => new
  9438. {
  9439. id = x.Id,
  9440. name = x.Name,
  9441. remark = x.Remark,
  9442. })
  9443. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9444. return Ok(JsonView(true, "查询成功!", data, total));
  9445. }
  9446. /// <summary>
  9447. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9448. /// </summary>
  9449. /// <returns></returns>
  9450. [HttpPost]
  9451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9452. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9453. {
  9454. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9455. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9456. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9457. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9458. var groupOtherRateData = groupRateData.TeamRates;
  9459. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9460. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9461. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9462. groupOtherRateData = groupOtherRateData
  9463. .Select(x => new TeamRateDescAddCurrencyIdView
  9464. {
  9465. CurrencyId = x.CurrencyId,
  9466. CurrencyName = x.CurrencyName,
  9467. CurrencyCode = x.CurrencyCode,
  9468. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9469. }).ToList();
  9470. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9471. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9472. }
  9473. /// <summary>
  9474. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9475. /// </summary>
  9476. /// <returns></returns>
  9477. [HttpPost]
  9478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9479. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9480. {
  9481. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9482. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9483. var tipsData = new List<int>() { 1, 2, 3 };
  9484. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9485. if (dto.TipsType == 1)
  9486. {
  9487. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9488. }
  9489. else if (dto.TipsType == 2)
  9490. {
  9491. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9492. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9493. }
  9494. else if (dto.TipsType == 3)
  9495. {
  9496. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9497. return Ok(JsonView(true, "查询成功!", airData));
  9498. }
  9499. return Ok(JsonView(false));
  9500. }
  9501. /// <summary>
  9502. /// 团组模块 - 出入境国家费用标准-移动端 List
  9503. /// </summary>
  9504. /// <returns></returns>
  9505. [HttpPost]
  9506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9507. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9508. {
  9509. Stopwatch sw = new Stopwatch();
  9510. sw.Start();
  9511. int provinceId = dto.ProvinceId;
  9512. if (provinceId < 1) provinceId = 122; // 默认四川
  9513. RefAsync<int> total = 0;
  9514. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9515. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9516. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9517. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9518. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9519. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9520. .Select((ntf, sd, u, sd1) => new
  9521. {
  9522. Id = ntf.Id,
  9523. Area = $"{ntf.Country}-{ntf.City}",
  9524. Currency = ntf.Currency,
  9525. CurrencyCode = sd.Name,
  9526. CurrencyName = sd.Remark,
  9527. RoomCost = ntf.RoomCost,
  9528. FoodCost = ntf.FoodCost,
  9529. PublicCost = ntf.PublicCost,
  9530. TrainCost = ntf.TrainCost,
  9531. LastUpdateUserId = ntf.LastUpdateUserId,
  9532. LastUpdateUserName = u.CnName,
  9533. LastUpdateTime = ntf.LastUpdateTime
  9534. })
  9535. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9536. sw.Stop();
  9537. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9538. }
  9539. /// <summary>
  9540. /// 团组模块 - 出入境费用-移动端 - Info
  9541. /// </summary>
  9542. /// <returns></returns>
  9543. [HttpPost]
  9544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9545. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9546. {
  9547. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9548. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9549. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9550. return Ok(data);
  9551. }
  9552. /// <summary>
  9553. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9554. /// </summary>
  9555. /// <returns></returns>
  9556. [HttpPost]
  9557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9558. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9559. {
  9560. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9561. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9562. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9563. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9564. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9565. mobileInfo.DiId = dto.DiId;
  9566. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9567. if (eecInfo == null) return Ok(mobileInfo);
  9568. //验证查看权限
  9569. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9570. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9571. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9572. mobileInfo.IsAssignPerm = isSet;
  9573. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9574. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9575. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9576. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9577. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9578. {
  9579. SubId = dac.Id,
  9580. DiId = dac.DiId,
  9581. Type = dac.Type,
  9582. Days = dac.Days,
  9583. NationalTravelFeeId = dac.NationalTravelFeeId,
  9584. Arae = $"{ntf.Country}-{ntf.City}",
  9585. Cost = dac.Cost,
  9586. Currency = dac.Currency,
  9587. CurrencyName = sd.Name,
  9588. SubTotal = dac.SubTotal,
  9589. })
  9590. .ToList();
  9591. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9592. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9593. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9594. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9595. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9596. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9597. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9598. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9599. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9600. //其他款项
  9601. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9602. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9603. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9604. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9605. .OrderBy((dop, sd1, sd2) => dop.Index)
  9606. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9607. {
  9608. SubId = dop.Id,
  9609. DiId = dop.Diid,
  9610. Index = dop.Index,
  9611. SetDataId = dop.SetDataId,
  9612. SetDataName = sd1.Name,
  9613. Cost = dop.Cost,
  9614. Currency = dop.Currency,
  9615. CurrencyName = sd2.Remark,
  9616. SubTotal = dop.SubTotal,
  9617. Remark = dop.Remark,
  9618. })
  9619. .ToArray();
  9620. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9621. return Ok(mobileInfo);
  9622. }
  9623. /// <summary>
  9624. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9625. /// </summary>
  9626. /// <returns></returns>
  9627. [HttpPost]
  9628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9629. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9630. {
  9631. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9632. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9633. //验证查看权限
  9634. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9635. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9636. var userIds = await _sqlSugar
  9637. .Queryable<Grp_EnterExitCostPermission>()
  9638. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9639. .Select(x => x.UserId)
  9640. .ToArrayAsync();
  9641. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9642. var perUsersView = new List<dynamic>();
  9643. foreach (var item in perUsers)
  9644. {
  9645. bool isView1 = false;
  9646. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9647. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9648. }
  9649. return Ok(JsonView(perUsersView));
  9650. }
  9651. /// <summary>
  9652. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9653. /// </summary>
  9654. /// <returns></returns>
  9655. [HttpPost]
  9656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9657. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9658. {
  9659. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9660. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9661. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9662. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9663. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9664. //验证查看权限
  9665. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9666. //if (!isView) return Ok(JsonView(false, msg));
  9667. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9668. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9669. var subType = dto.SubType;
  9670. if (subType == 1) //1:境内费用
  9671. {
  9672. var oneData = new ChoiceOneMobileSubInfoView()
  9673. {
  9674. Id = eecInfo.Id,
  9675. ChoiceOne = eecInfo.ChoiceOne,
  9676. ChoiceOneTotalCost = eecInfo.InsidePay,
  9677. Visa = eecInfo.Visa,
  9678. VisaRemark = eecInfo.VisaRemark,
  9679. YiMiao = eecInfo.YiMiao,
  9680. HeSuan = eecInfo.HeSuan,
  9681. Service = eecInfo.Service,
  9682. Ticket = eecInfo.Ticket,
  9683. Safe = eecInfo.Safe,
  9684. FirstItemRemark = eecInfo.FirstItemRemark
  9685. };
  9686. return Ok(JsonView(oneData));
  9687. }
  9688. else if (subType == 2) //2:国际旅费
  9689. {
  9690. var twoData = new ChoiceTwoMobileSubInfoView()
  9691. {
  9692. Id = eecInfo.Id,
  9693. ChoiceTwoJJ = eecInfo.SumJJC,
  9694. OutsideJJPay = eecInfo.OutsideJJPay,
  9695. ChoiceTwoGW = eecInfo.SumGWC,
  9696. OutsideGWPay = eecInfo.OutsideGWPay,
  9697. ChoiceTwoTD = eecInfo.SumTDC,
  9698. OutsideTDPay = eecInfo.OutsideTDPay,
  9699. AirJJ = eecInfo.AirJJ,
  9700. AirGW = eecInfo.AirGW,
  9701. AirTD = eecInfo.AirTD,
  9702. CityTranffic = eecInfo.CityTranffic,
  9703. TwoItemRemark = eecInfo.TwoItemRemark
  9704. };
  9705. return Ok(JsonView(twoData));
  9706. }
  9707. else if (subType == 3) //3:住宿费
  9708. {
  9709. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9710. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9711. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9712. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9713. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9714. {
  9715. SubId = dac.Id,
  9716. DiId = dac.DiId,
  9717. Type = dac.Type,
  9718. Days = dac.Days,
  9719. NationalTravelFeeId = dac.NationalTravelFeeId,
  9720. Arae = $"{ntf.Country}-{ntf.City}",
  9721. Cost = dac.Cost,
  9722. Currency = dac.Currency,
  9723. CurrencyName = sd.Name,
  9724. SubTotal = dac.SubTotal,
  9725. })
  9726. .ToArray();
  9727. var data = new ChoiceMobileSubInfo3To6View()
  9728. {
  9729. ParentId = eecInfo.Id,
  9730. Choice = eecInfo.ChoiceThree,
  9731. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9732. Details = dayAndCostDatas
  9733. };
  9734. return Ok(JsonView(data));
  9735. }
  9736. else if (subType == 4) //4:伙食费
  9737. {
  9738. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9739. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9740. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9741. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9742. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9743. {
  9744. SubId = dac.Id,
  9745. DiId = dac.DiId,
  9746. Type = dac.Type,
  9747. Days = dac.Days,
  9748. NationalTravelFeeId = dac.NationalTravelFeeId,
  9749. Arae = $"{ntf.Country}-{ntf.City}",
  9750. Cost = dac.Cost,
  9751. Currency = dac.Currency,
  9752. CurrencyName = sd.Name,
  9753. SubTotal = dac.SubTotal,
  9754. })
  9755. .ToArray();
  9756. var data = new ChoiceMobileSubInfo3To6View()
  9757. {
  9758. ParentId = eecInfo.Id,
  9759. Choice = eecInfo.ChoiceFour,
  9760. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9761. Details = dayAndCostDatas
  9762. };
  9763. return Ok(JsonView(data));
  9764. }
  9765. else if (subType == 5) //5:公杂费
  9766. {
  9767. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9768. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9769. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9770. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9771. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9772. {
  9773. SubId = dac.Id,
  9774. DiId = dac.DiId,
  9775. Type = dac.Type,
  9776. Days = dac.Days,
  9777. NationalTravelFeeId = dac.NationalTravelFeeId,
  9778. Arae = $"{ntf.Country}-{ntf.City}",
  9779. Cost = dac.Cost,
  9780. Currency = dac.Currency,
  9781. CurrencyName = sd.Name,
  9782. SubTotal = dac.SubTotal,
  9783. })
  9784. .ToArray();
  9785. var data = new ChoiceMobileSubInfo3To6View()
  9786. {
  9787. ParentId = eecInfo.Id,
  9788. Choice = eecInfo.ChoiceFive,
  9789. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9790. Details = dayAndCostDatas
  9791. };
  9792. return Ok(JsonView(data));
  9793. }
  9794. else if (subType == 6) //6:培训费
  9795. {
  9796. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9797. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9798. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9799. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9800. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9801. {
  9802. SubId = dac.Id,
  9803. DiId = dac.DiId,
  9804. Type = dac.Type,
  9805. Days = dac.Days,
  9806. NationalTravelFeeId = dac.NationalTravelFeeId,
  9807. Arae = $"{ntf.Country}-{ntf.City}",
  9808. Cost = dac.Cost,
  9809. Currency = dac.Currency,
  9810. CurrencyName = sd.Name,
  9811. SubTotal = dac.SubTotal,
  9812. })
  9813. .ToArray();
  9814. var data = new ChoiceMobileSubInfo3To6View()
  9815. {
  9816. ParentId = eecInfo.Id,
  9817. Choice = eecInfo.ChoiceSix,
  9818. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9819. Details = dayAndCostDatas
  9820. };
  9821. return Ok(JsonView(data));
  9822. }
  9823. else if (subType == 7) //7:其他
  9824. {
  9825. //其他款项
  9826. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9827. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9828. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9829. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9830. .OrderBy((dop, sd1, sd2) => dop.Index)
  9831. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9832. {
  9833. SubId = dop.Id,
  9834. DiId = dop.Diid,
  9835. Index = dop.Index,
  9836. SetDataId = dop.SetDataId,
  9837. SetDataName = sd1.Name,
  9838. Cost = dop.Cost,
  9839. Currency = dop.Currency,
  9840. CurrencyName = sd2.Name,
  9841. SubTotal = dop.SubTotal,
  9842. Remark = dop.Remark,
  9843. })
  9844. .ToArray();
  9845. var data = new ChoiceSevenMobileSubInfoView()
  9846. {
  9847. ParentId = eecInfo.Id,
  9848. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9849. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9850. Details = otherData
  9851. };
  9852. return Ok(JsonView(data));
  9853. }
  9854. return Ok(JsonView(false));
  9855. }
  9856. #region op
  9857. ///// <summary>
  9858. ///// 移动端更新费用消息通知
  9859. ///// </summary>
  9860. ///// <param name="diid"></param>
  9861. ///// <param name="id"></param>
  9862. ///// <param name="currUserId"></param>
  9863. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9864. //{
  9865. // try
  9866. // {
  9867. // ////生成默认文件pdf并且通知人员
  9868. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9869. // //{
  9870. // // DiId = diid,
  9871. // // ExportType = 1,
  9872. // // SubTypeId = 1005
  9873. // //}, "pdf");
  9874. // ////发送通知
  9875. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9876. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9877. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9878. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9879. // ////汇率信息记录
  9880. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9881. // }
  9882. // catch (Exception ex)
  9883. // {
  9884. // //记录日志
  9885. // throw;
  9886. // }
  9887. //}
  9888. /// <summary>
  9889. /// 验证出入境费用数据是否存在
  9890. /// 不存在添加
  9891. /// </summary>
  9892. /// <param name="diId"></param>
  9893. /// <param name="currUserId"></param>
  9894. /// <returns></returns>
  9895. /// <exception cref="CustomException"></exception>
  9896. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9897. {
  9898. var parentId = 0;
  9899. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9900. if (info != null)
  9901. {
  9902. parentId = info.Id;
  9903. }
  9904. else
  9905. {
  9906. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9907. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9908. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9909. parentId = addId;
  9910. }
  9911. return parentId;
  9912. }
  9913. /// <summary>
  9914. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9915. /// </summary>
  9916. /// <returns></returns>
  9917. [HttpPost]
  9918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9919. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9920. {
  9921. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9922. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9923. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9924. //验证编辑权限
  9925. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9926. //if (!isEdit) return Ok(JsonView(false, msg));
  9927. var permissions = new List<Grp_EnterExitCostPermission>();
  9928. foreach (var userId in dto.UserIds)
  9929. {
  9930. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  9931. }
  9932. if (permissions.Any())
  9933. {
  9934. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9935. {
  9936. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9937. }
  9938. _sqlSugar.BeginTran();
  9939. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  9940. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9941. if (result < 1)
  9942. {
  9943. _sqlSugar.RollbackTran();
  9944. return Ok(JsonView(false));
  9945. }
  9946. _sqlSugar.CommitTran();
  9947. return Ok(JsonView(true));
  9948. }
  9949. return Ok(JsonView(false));
  9950. }
  9951. /// <summary>
  9952. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9953. /// </summary>
  9954. /// <returns></returns>
  9955. [HttpPost]
  9956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9957. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9958. {
  9959. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9960. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9961. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9962. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9963. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9964. int id = dto.Id;
  9965. if (id <= 0) //add
  9966. {
  9967. //int provinceId = dto.ProvinceId;
  9968. int groupId = dto.DiId;
  9969. //if (provinceId < 1) provinceId = 122;
  9970. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  9971. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  9972. if (add < 1) return Ok(JsonView(false));
  9973. id = add;
  9974. }
  9975. else //update
  9976. {
  9977. ////验证编辑权限
  9978. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9979. //if (!isEdit) return Ok(JsonView(false, msg));
  9980. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9981. if (upd < 1) return Ok(JsonView(false));
  9982. }
  9983. #region 汇率变更时更改币种相关费用
  9984. var opDayCosts = new List<Grp_DayAndCost>();
  9985. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9986. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9987. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9988. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9989. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9990. .Select((dac, sd) => new
  9991. {
  9992. dac.Id,
  9993. dac.DiId,
  9994. CurrencyCode = sd.Name,
  9995. dac.Cost
  9996. })
  9997. .ToList();
  9998. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9999. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10000. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10001. .Select((dop, sd) => new
  10002. {
  10003. dop.Id,
  10004. dop.Diid,
  10005. CurrencyCode = sd.Name,
  10006. dop.Cost
  10007. })
  10008. .ToList();
  10009. if (dayCosts.Count > 0)
  10010. {
  10011. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10012. foreach (var dc in new_dayCosts)
  10013. {
  10014. var thisCurrency = dc.Key.ToUpper();
  10015. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10016. if (thisRate == 0.00M) continue;
  10017. foreach (var dcSub in dc)
  10018. {
  10019. opDayCosts.Add(new Grp_DayAndCost()
  10020. {
  10021. Id = dcSub.Id,
  10022. DiId = dcSub.DiId,
  10023. Cost = dcSub.Cost,
  10024. SubTotal = dcSub.Cost * thisRate,
  10025. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10026. });
  10027. }
  10028. }
  10029. if (opDayCosts.Count > 0)
  10030. {
  10031. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10032. }
  10033. }
  10034. if (dayOtherCosts.Count > 0)
  10035. {
  10036. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10037. foreach (var dc in new_dayOtherCosts)
  10038. {
  10039. var thisCurrency = dc.Key.ToUpper();
  10040. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10041. if (thisRate == 0.00M) continue;
  10042. foreach (var dcSub in dc)
  10043. {
  10044. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10045. {
  10046. Id = dcSub.Id,
  10047. Diid = dcSub.Diid,
  10048. Cost = dcSub.Cost,
  10049. SubTotal = dcSub.Cost * thisRate,
  10050. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10051. });
  10052. }
  10053. }
  10054. if (opDayOtherCosts.Count > 0)
  10055. {
  10056. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10057. }
  10058. }
  10059. #endregion
  10060. //消息通知
  10061. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10062. //汇率信息记录
  10063. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10064. return Ok(JsonView(new { parentId = id }));
  10065. }
  10066. /// <summary>
  10067. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10068. /// </summary>
  10069. /// <returns></returns>
  10070. [HttpPost]
  10071. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10072. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10073. {
  10074. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10075. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10076. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10077. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10078. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10079. int id = dto.Id;
  10080. if (id <= 0) //add
  10081. {
  10082. checkboxInfo.CreateUserId = dto.CurrUserId;
  10083. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10084. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10085. if (add < 1) return Ok(JsonView(false));
  10086. }
  10087. else //update
  10088. {
  10089. ////验证编辑权限
  10090. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10091. //if (!isEdit) return Ok(JsonView(false, msg));
  10092. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10093. .UpdateColumns(x => new
  10094. {
  10095. x.ChoiceOne,
  10096. x.ChoiceTwo,
  10097. x.SumJJC,
  10098. x.SumGWC,
  10099. x.SumTDC,
  10100. x.ChoiceThree,
  10101. x.ChoiceFour,
  10102. x.ChoiceFive,
  10103. x.ChoiceSix,
  10104. x.OtherExpenses_Checked
  10105. })
  10106. .Where(x => x.Id == id)
  10107. .ExecuteCommandAsync();
  10108. if (upd < 1) return Ok(JsonView(false));
  10109. }
  10110. return Ok(JsonView(new { parentId = id }));
  10111. }
  10112. /// <summary>
  10113. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10114. /// </summary>
  10115. /// <returns></returns>
  10116. [HttpPost]
  10117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10118. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10119. {
  10120. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10121. // if (provinceId < 1) provinceId = 122;
  10122. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10123. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10124. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10125. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10126. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10127. var checkboxInfo = new Grp_EnterExitCost()
  10128. {
  10129. Id = id,
  10130. //ProvinceId = provinceId,
  10131. DiId = diId,
  10132. CreateUserId = currUserId
  10133. };
  10134. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10135. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10136. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10137. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10138. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10139. if (id <= 0) //add
  10140. {
  10141. checkboxInfo.CreateUserId = dto.CurrUserId;
  10142. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10143. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10144. if (add < 1) return Ok(JsonView(false));
  10145. }
  10146. else //update
  10147. {
  10148. ////验证编辑权限
  10149. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10150. //if (!isEdit) return Ok(JsonView(false, msg));
  10151. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10152. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10153. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10154. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10155. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10156. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10157. .Where(x => x.Id == id)
  10158. .ExecuteCommandAsync();
  10159. if (upd < 1) return Ok(JsonView(false));
  10160. }
  10161. return Ok(JsonView(new { parentId = id }));
  10162. }
  10163. /// <summary>
  10164. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10165. /// </summary>
  10166. /// <returns></returns>
  10167. [HttpPost]
  10168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10169. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10170. {
  10171. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10172. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10173. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10174. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10175. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10176. info.FirstItemRemark = dto.FirstItemRemark;
  10177. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10178. int id = dto.Id;
  10179. if (id <= 0) //add
  10180. {
  10181. info.CreateUserId = dto.CurrUserId;
  10182. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10183. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10184. if (add < 1) return Ok(JsonView(false));
  10185. id = add;
  10186. }
  10187. else //update
  10188. {
  10189. ////验证编辑权限
  10190. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10191. //if (!isEdit) return Ok(JsonView(false, msg));
  10192. var upd = await _sqlSugar.Updateable(info)
  10193. .UpdateColumns(x => new
  10194. {
  10195. x.ChoiceOne,
  10196. x.InsidePay,
  10197. x.VisaRemark,
  10198. x.Visa,
  10199. x.Service,
  10200. x.Safe,
  10201. x.Ticket,
  10202. x.HeSuan,
  10203. x.YiMiao,
  10204. x.FirstItemRemark
  10205. })
  10206. .Where(x => x.Id == id)
  10207. .ExecuteCommandAsync();
  10208. if (upd < 1) return Ok(JsonView(false));
  10209. }
  10210. //消息通知
  10211. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10212. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10213. }
  10214. /// <summary>
  10215. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10216. /// </summary>
  10217. /// <returns></returns>
  10218. [HttpPost]
  10219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10220. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10221. {
  10222. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10223. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10224. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10225. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10226. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10227. info.DiId = dto.DiId;
  10228. //info.ProvinceId = dto.ProvinceId;
  10229. info.OutsideJJPay = dto.OutsideJJPay;
  10230. info.OutsideGWPay = dto.OutsideGWPay;
  10231. info.OutsideTDPay = dto.OutsideTDPay;
  10232. info.AirJJ = dto.AirJJ;
  10233. info.AirGW = dto.AirGW;
  10234. info.AirTD = dto.AirTD;
  10235. info.CityTranffic = dto.CityTranffic;
  10236. info.TwoItemRemark = dto.TwoItemRemark;
  10237. info.SumJJC = dto.ChoiceTwoJJ;
  10238. info.SumGWC = dto.ChoiceTwoGW;
  10239. info.SumTDC = dto.ChoiceTwoTD;
  10240. int id = dto.Id;
  10241. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10242. if (id <= 0) //add
  10243. {
  10244. info.CreateUserId = dto.CurrUserId;
  10245. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10246. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10247. if (addId <= 0) return Ok(JsonView(false));
  10248. id = addId;
  10249. }
  10250. else //update
  10251. {
  10252. ////验证编辑权限
  10253. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10254. //if (!isEdit) return Ok(JsonView(false, msg));
  10255. var upd = await _sqlSugar.Updateable(info)
  10256. .UpdateColumns(x => new
  10257. {
  10258. x.SumJJC,
  10259. x.OutsideJJPay,
  10260. x.SumGWC,
  10261. x.OutsideGWPay,
  10262. x.SumTDC,
  10263. x.OutsideTDPay,
  10264. x.AirJJ,
  10265. x.AirGW,
  10266. x.AirTD,
  10267. x.CityTranffic,
  10268. x.TwoItemRemark
  10269. })
  10270. .Where(x => x.Id == id)
  10271. .ExecuteCommandAsync();
  10272. if (upd < 1) return Ok(JsonView(false));
  10273. }
  10274. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10275. gwcItemTotal = info.AirGW + info.CityTranffic;
  10276. tdcItemTotal = info.AirTD + info.CityTranffic;
  10277. //消息通知
  10278. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10279. return Ok(JsonView(new
  10280. {
  10281. parentId = id,
  10282. choiceTwoJJ = dto.ChoiceTwoJJ,
  10283. jjcItemTotal = jjcItemTotal,
  10284. choiceTwoGW = dto.ChoiceTwoGW,
  10285. gwcItemTotal = gwcItemTotal,
  10286. choiceTwoTD = dto.ChoiceTwoTD,
  10287. tdcItemTotal = tdcItemTotal
  10288. }));
  10289. }
  10290. /// <summary>
  10291. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10292. /// </summary>
  10293. /// <returns></returns>
  10294. [HttpPost]
  10295. [ApiExplorerSettings(IgnoreApi = true)]
  10296. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10297. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10298. {
  10299. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10300. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10301. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10302. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10303. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10304. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10305. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10306. var infos = infos1.Select(x => new Grp_DayAndCost
  10307. {
  10308. Id = x.Id,
  10309. DiId = dto.DiId,
  10310. Type = dto.FeeType,
  10311. Days = x.Days,
  10312. NationalTravelFeeId = x.NationalTravelFeeId,
  10313. Cost = x.Cost,
  10314. Currency = x.Currency,
  10315. SubTotal = x.SubTotal,
  10316. CreateUserId = dto.CurrUserId
  10317. })
  10318. .ToList();
  10319. var adds = infos.Where(x => x.Id <= 0).ToList();
  10320. var upds = infos.Where(x => x.Id > 0).ToList();
  10321. if (adds.Count > 0)
  10322. {
  10323. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10324. if (add < 1) return Ok(JsonView(false));
  10325. }
  10326. if (upds.Count > 0)
  10327. {
  10328. var upd = await _sqlSugar.Updateable(adds)
  10329. .UpdateColumns(x => new
  10330. {
  10331. x.Days,
  10332. x.NationalTravelFeeId,
  10333. x.Cost,
  10334. x.Currency,
  10335. x.SubTotal
  10336. })
  10337. .WhereColumns(x => new { x.Id })
  10338. .ExecuteCommandAsync();
  10339. if (upd < 1) return Ok(JsonView(false));
  10340. }
  10341. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10342. //消息通知
  10343. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10344. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10345. return Ok(JsonView(new { itemTotal = itemTotal }));
  10346. }
  10347. /// <summary>
  10348. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10349. /// </summary>
  10350. /// <returns></returns>
  10351. [HttpPost]
  10352. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10353. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10354. {
  10355. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10356. int subId = dto.SubId, feeType = dto.FeeType;
  10357. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10358. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10359. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10360. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10361. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10362. subInfo.Id = subId;
  10363. subInfo.DiId = dto.DiId;
  10364. if (feeType == 3) subInfo.Type = 1;
  10365. else if (feeType == 4) subInfo.Type = 2;
  10366. else if (feeType == 5) subInfo.Type = 3;
  10367. else if (feeType == 6) subInfo.Type = 4;
  10368. subInfo.CreateUserId = dto.CurrUserId;
  10369. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10370. if (parentId < 1) return Ok(JsonView(false));
  10371. //子表op
  10372. if (subId < 1)
  10373. {
  10374. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10375. if (subAdd < 1) return Ok(JsonView(false));
  10376. }
  10377. else
  10378. {
  10379. ////验证编辑权限
  10380. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10381. //if (!isEdit) return Ok(JsonView(false, msg));
  10382. var subUpd = await _sqlSugar.Updateable(subInfo)
  10383. .UpdateColumns(x => new
  10384. {
  10385. x.Days,
  10386. x.NationalTravelFeeId,
  10387. x.Cost,
  10388. x.Currency,
  10389. x.SubTotal
  10390. })
  10391. .WhereColumns(x => new { x.Id })
  10392. .ExecuteCommandAsync();
  10393. if (subUpd < 1) return Ok(JsonView(false));
  10394. }
  10395. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10396. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10397. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10398. }
  10399. /// <summary>
  10400. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10401. /// </summary>
  10402. /// <returns></returns>
  10403. [HttpPost]
  10404. [ApiExplorerSettings(IgnoreApi = true)]
  10405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10406. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10407. {
  10408. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10409. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10410. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10411. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10412. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10413. {
  10414. Id = x.Id,
  10415. Diid = dto.DiId,
  10416. SetDataId = x.SetDataId,
  10417. Index = x.Index,
  10418. Cost = x.Cost,
  10419. Currency = x.Currency,
  10420. SubTotal = x.SubTotal,
  10421. CreateUserId = dto.CurrUserId,
  10422. Remark = x.Remark
  10423. }).ToList();
  10424. var adds = infos.Where(x => x.Id <= 0).ToList();
  10425. var upds = infos.Where(x => x.Id > 0).ToList();
  10426. if (adds.Count > 0)
  10427. {
  10428. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10429. if (add < 1) return Ok(JsonView(false));
  10430. }
  10431. if (upds.Count > 0)
  10432. {
  10433. var upd = await _sqlSugar.Updateable(adds)
  10434. .UpdateColumns(x => new
  10435. {
  10436. x.Index,
  10437. x.SetDataId,
  10438. x.Cost,
  10439. x.Currency,
  10440. x.SubTotal,
  10441. x.Remark
  10442. })
  10443. .WhereColumns(x => new { x.Id })
  10444. .ExecuteCommandAsync();
  10445. if (upd < 1) return Ok(JsonView(false));
  10446. }
  10447. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10448. //消息通知
  10449. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10450. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10451. return Ok(JsonView(new { itemTotal = itemTotal }));
  10452. }
  10453. /// <summary>
  10454. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10455. /// </summary>
  10456. /// <returns></returns>
  10457. [HttpPost]
  10458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10459. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10460. {
  10461. int subId = dto.SubId;
  10462. int diId = dto.Diid;
  10463. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10464. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10465. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10466. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10467. subInfo.Id = subId;
  10468. subInfo.Diid = dto.Diid;
  10469. subInfo.CreateUserId = dto.CurrUserId;
  10470. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10471. if (parentId < 1) return Ok(JsonView(false));
  10472. #region 子表op
  10473. if (subId < 1)//add
  10474. {
  10475. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10476. if (subAdd < 1) return Ok(JsonView(false));
  10477. }
  10478. else //upd
  10479. {
  10480. ////验证编辑权限
  10481. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10482. //if (!isEdit) return Ok(JsonView(false, msg));
  10483. var subUpd = await _sqlSugar.Updateable(subInfo)
  10484. .UpdateColumns(x => new
  10485. {
  10486. x.Index,
  10487. x.SetDataId,
  10488. x.Cost,
  10489. x.Currency,
  10490. x.SubTotal,
  10491. x.Remark
  10492. })
  10493. .WhereColumns(x => new { x.Id })
  10494. .ExecuteCommandAsync();
  10495. if (subUpd < 1) return Ok(JsonView(false));
  10496. }
  10497. #endregion
  10498. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10499. //消息通知
  10500. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10501. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10502. }
  10503. /// <summary>
  10504. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10505. /// </summary>
  10506. /// <returns></returns>
  10507. [HttpPost]
  10508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10509. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10510. {
  10511. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10512. if (data.Code != 0)
  10513. {
  10514. return Ok(JsonView(false, data.Msg));
  10515. }
  10516. return Ok(JsonView(true, "操作成功!", data.Data));
  10517. }
  10518. /// <summary>
  10519. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10520. /// </summary>
  10521. /// <param name="dto"></param>
  10522. /// <returns></returns>
  10523. [HttpPost]
  10524. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10525. {
  10526. var data = new Grp_DayOtherPrice()
  10527. {
  10528. Id = dto.Id,
  10529. IsDel = 1,
  10530. DeleteUserId = dto.DeleteUserId,
  10531. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10532. };
  10533. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10534. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10535. return Ok(JsonView(false, "删除失败!"));
  10536. }
  10537. #endregion
  10538. #endregion
  10539. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10540. /// <summary>
  10541. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10542. /// </summary>
  10543. /// <returns></returns>
  10544. [HttpGet]
  10545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10546. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10547. {
  10548. var provData = await _groupRepository.ProvinceBasicSource();
  10549. return Ok(JsonView(true, "查询成功!", provData));
  10550. }
  10551. /// <summary>
  10552. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10553. /// </summary>
  10554. /// <returns></returns>
  10555. [HttpPost]
  10556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10557. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10558. {
  10559. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10560. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10561. RefAsync<int> total = 0;
  10562. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10563. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10564. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10565. .Select(x => new
  10566. {
  10567. Id = x.Id,
  10568. DraftName = x.DraftName,
  10569. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10570. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10571. .Any()
  10572. })
  10573. .OrderByDescending(x => x.Id)
  10574. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10575. return Ok(JsonView(true, "查询成功!", data, total));
  10576. }
  10577. /// <summary>
  10578. /// 出入境费用-草稿 移动端
  10579. /// 获取币种基础数据(含逻辑处理)
  10580. /// </summary>
  10581. /// <returns></returns>
  10582. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10583. {
  10584. return await GeneralMethod.EnterExitCostInitRate();
  10585. }
  10586. /// <summary>
  10587. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10588. /// </summary>
  10589. /// <returns></returns>
  10590. [HttpPost]
  10591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10592. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10593. {
  10594. //验证城市归属并给默认值
  10595. int provinceId = dto.ProvinceId;
  10596. if (provinceId < 1) provinceId = 122;
  10597. var dataSource = await _sqlSugar
  10598. .Queryable<Sys_SetData>()
  10599. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10600. .ToListAsync();
  10601. //三公费用-Word明细类型
  10602. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10603. .Select(x => new SetDataInfoView
  10604. {
  10605. Id = x.Id,
  10606. Name = x.Name,
  10607. Remark = x.Remark
  10608. })
  10609. .ToList();
  10610. //三公费用-Excel明细类型
  10611. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10612. .Select(x => new SetDataInfoView
  10613. {
  10614. Id = x.Id,
  10615. Name = x.Name,
  10616. Remark = x.Remark
  10617. })
  10618. .ToList();
  10619. //默认币种显示
  10620. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10621. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10622. return Ok(JsonView(true, "查询成功!", new
  10623. {
  10624. WordTypeData = wordTypeData,
  10625. ExcelTypeData = excelTypeData,
  10626. CurrencyInit = _currencyInfos,
  10627. viewPermissionData = viewPermissionData
  10628. }));
  10629. }
  10630. /// <summary>
  10631. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10632. /// </summary>
  10633. /// <returns></returns>
  10634. [HttpPost]
  10635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10636. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10637. {
  10638. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10639. RefAsync<int> total = 0;
  10640. int diId = 0;
  10641. var status = int.TryParse(dto.GroupName, out diId);
  10642. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10643. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10644. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10645. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10646. .OrderByDescending(x => x.VisitStartDate)
  10647. .Select(x => new
  10648. {
  10649. Id = x.Id,
  10650. GroupName = x.TeamName
  10651. })
  10652. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10653. return Ok(JsonView(true, "查询成功!", data, total));
  10654. }
  10655. /// <summary>
  10656. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10657. /// </summary>
  10658. /// <returns></returns>
  10659. [HttpPost]
  10660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10661. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10662. {
  10663. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10664. RefAsync<int> total = 0;
  10665. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10666. .Where(x => x.IsDel == 0 && x.STid == 66)
  10667. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10668. .Select(x => new
  10669. {
  10670. id = x.Id,
  10671. name = x.Name,
  10672. remark = x.Remark,
  10673. })
  10674. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10675. return Ok(JsonView(true, "查询成功!", data, total));
  10676. }
  10677. /// <summary>
  10678. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10679. /// </summary>
  10680. /// <returns></returns>
  10681. [HttpPost]
  10682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10683. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10684. {
  10685. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10686. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10687. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10688. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10689. var groupOtherRateData = groupRateData.TeamRates;
  10690. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10691. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10692. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10693. groupOtherRateData = groupOtherRateData
  10694. .Select(x => new TeamRateDescAddCurrencyIdView
  10695. {
  10696. CurrencyId = x.CurrencyId,
  10697. CurrencyName = x.CurrencyName,
  10698. CurrencyCode = x.CurrencyCode,
  10699. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10700. }).ToList();
  10701. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10702. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10703. }
  10704. /// <summary>
  10705. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10706. /// </summary>
  10707. /// <returns></returns>
  10708. [HttpPost]
  10709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10710. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10711. {
  10712. int portType = dto.PortType;
  10713. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10714. var tipsData = new List<int>() { 1, 2, 3 };
  10715. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10716. if (dto.TipsType == 1)
  10717. {
  10718. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10719. }
  10720. else if (dto.TipsType == 2)
  10721. {
  10722. if (portType == 2)
  10723. {
  10724. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10725. }
  10726. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10727. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10728. .Select(x => x.NationalTravelFeeId)
  10729. .Distinct()
  10730. .ToListAsync();
  10731. if (portType == 2)
  10732. {
  10733. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10734. }
  10735. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10736. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10737. .Select(x => x.Country)
  10738. .Distinct()
  10739. .ToArrayAsync();
  10740. if (portType == 2)
  10741. {
  10742. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10743. }
  10744. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10745. return Ok(JsonView(true, "查询成功!", new
  10746. {
  10747. totalAmt = totalAmt,
  10748. remark = remark
  10749. }));
  10750. }
  10751. else if (dto.TipsType == 3)
  10752. {
  10753. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10754. }
  10755. return Ok(JsonView(false));
  10756. }
  10757. /// <summary>
  10758. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10759. /// </summary>
  10760. /// <returns></returns>
  10761. [HttpPost]
  10762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10763. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10764. {
  10765. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10766. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10767. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10768. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10769. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10770. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10771. var info = new Grp_EnterExitCostDraft()
  10772. {
  10773. ProvinceId = dto.ProvinceId,
  10774. DraftName = dto.DraftName,
  10775. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10776. CreateUserId = dto.CurrUserId
  10777. };
  10778. _sqlSugar.BeginTran();
  10779. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10780. if (draftId < 1)
  10781. {
  10782. _sqlSugar.RollbackTran();
  10783. return Ok(JsonView(false, "草稿创建失败!"));
  10784. }
  10785. //添加默认权限
  10786. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10787. _sqlSugar.CommitTran();
  10788. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10789. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10790. mobileInfo.Id = draftId;
  10791. mobileInfo.DraftName = dto.DraftName;
  10792. mobileInfo.Currencys = rateInfos;
  10793. mobileInfo.IsAssignPerm = assignPerm;
  10794. return Ok(JsonView(mobileInfo));
  10795. }
  10796. /// <summary>
  10797. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10798. /// </summary>
  10799. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10800. /// <summary>
  10801. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10802. /// </summary>
  10803. /// <returns></returns>
  10804. [HttpPost]
  10805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10806. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10807. {
  10808. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10809. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10810. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10811. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10812. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10813. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10814. //验证查看编辑权限
  10815. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10816. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10817. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10818. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10819. mobileInfo.IsAssignPerm = assignPerm;
  10820. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10821. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10822. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10823. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10824. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10825. {
  10826. ParentId = dac.ParentId,
  10827. SubId = dac.Id,
  10828. Type = dac.Type,
  10829. Days = dac.Days,
  10830. NationalTravelFeeId = dac.NationalTravelFeeId,
  10831. Arae = $"{ntf.Country}-{ntf.City}",
  10832. Cost = dac.Cost,
  10833. Currency = dac.Currency,
  10834. CurrencyName = sd.Name,
  10835. SubTotal = dac.SubTotal,
  10836. })
  10837. .ToList();
  10838. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10839. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10840. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10841. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10842. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10843. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10844. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10845. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10846. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10847. //其他款项
  10848. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10849. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10850. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10851. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10852. .OrderBy((dop, sd1, sd2) => dop.Index)
  10853. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10854. {
  10855. ParentId = dop.ParentId,
  10856. SubId = dop.Id,
  10857. Index = dop.Index,
  10858. SetDataId = dop.SetDataId,
  10859. SetDataName = sd1.Name,
  10860. Cost = dop.Cost,
  10861. Currency = dop.Currency,
  10862. CurrencyName = sd2.Remark,
  10863. SubTotal = dop.SubTotal,
  10864. Remark = dop.Remark,
  10865. })
  10866. .ToArray();
  10867. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10868. return Ok(mobileInfo);
  10869. }
  10870. /// <summary>
  10871. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10872. /// </summary>
  10873. /// <returns></returns>
  10874. [HttpPost]
  10875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10876. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10877. {
  10878. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10879. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10880. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10881. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10882. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10883. //验证查看编辑权限
  10884. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10885. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10886. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10887. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10888. var subType = dto.SubType;
  10889. if (subType == 1) //1:境内费用
  10890. {
  10891. var oneData = new ChoiceOneMobileSubInfoView()
  10892. {
  10893. Id = eecInfo.Id,
  10894. ChoiceOne = eecInfo.ChoiceOne,
  10895. ChoiceOneTotalCost = eecInfo.InsidePay,
  10896. Visa = eecInfo.Visa,
  10897. VisaRemark = eecInfo.VisaRemark,
  10898. YiMiao = eecInfo.YiMiao,
  10899. HeSuan = eecInfo.HeSuan,
  10900. Service = eecInfo.Service,
  10901. Ticket = eecInfo.Ticket,
  10902. Safe = eecInfo.Safe,
  10903. FirstItemRemark = eecInfo.FirstItemRemark
  10904. };
  10905. return Ok(JsonView(oneData));
  10906. }
  10907. else if (subType == 2) //2:国际旅费
  10908. {
  10909. var twoData = new ChoiceTwoMobileSubInfoView()
  10910. {
  10911. Id = eecInfo.Id,
  10912. ChoiceTwoJJ = eecInfo.SumJJC,
  10913. OutsideJJPay = eecInfo.OutsideJJPay,
  10914. ChoiceTwoGW = eecInfo.SumGWC,
  10915. OutsideGWPay = eecInfo.OutsideGWPay,
  10916. ChoiceTwoTD = eecInfo.SumTDC,
  10917. OutsideTDPay = eecInfo.OutsideTDPay,
  10918. AirJJ = eecInfo.AirJJ,
  10919. AirGW = eecInfo.AirGW,
  10920. AirTD = eecInfo.AirTD,
  10921. CityTranffic = eecInfo.CityTranffic,
  10922. TwoItemRemark = eecInfo.TwoItemRemark
  10923. };
  10924. return Ok(JsonView(twoData));
  10925. }
  10926. else if (subType == 3) //3:住宿费
  10927. {
  10928. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10929. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10930. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10931. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  10932. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10933. {
  10934. ParentId = dac.ParentId,
  10935. SubId = dac.Id,
  10936. Type = dac.Type,
  10937. Days = dac.Days,
  10938. NationalTravelFeeId = dac.NationalTravelFeeId,
  10939. Arae = $"{ntf.Country}-{ntf.City}",
  10940. Cost = dac.Cost,
  10941. Currency = dac.Currency,
  10942. CurrencyName = sd.Name,
  10943. SubTotal = dac.SubTotal,
  10944. })
  10945. .ToArray();
  10946. var data = new ChoiceDraftMobileSubInfo3To6View()
  10947. {
  10948. ParentId = eecInfo.Id,
  10949. Choice = eecInfo.ChoiceThree,
  10950. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10951. Details = dayAndCostDatas
  10952. };
  10953. return Ok(JsonView(data));
  10954. }
  10955. else if (subType == 4) //4:伙食费
  10956. {
  10957. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10958. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10959. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10960. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  10961. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10962. {
  10963. ParentId = dac.ParentId,
  10964. SubId = dac.Id,
  10965. Type = dac.Type,
  10966. Days = dac.Days,
  10967. NationalTravelFeeId = dac.NationalTravelFeeId,
  10968. Arae = $"{ntf.Country}-{ntf.City}",
  10969. Cost = dac.Cost,
  10970. Currency = dac.Currency,
  10971. CurrencyName = sd.Name,
  10972. SubTotal = dac.SubTotal,
  10973. })
  10974. .ToArray();
  10975. var data = new ChoiceDraftMobileSubInfo3To6View()
  10976. {
  10977. ParentId = eecInfo.Id,
  10978. Choice = eecInfo.ChoiceFour,
  10979. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10980. Details = dayAndCostDatas
  10981. };
  10982. return Ok(JsonView(data));
  10983. }
  10984. else if (subType == 5) //5:公杂费
  10985. {
  10986. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10987. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10988. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10989. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10990. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10991. {
  10992. ParentId = dac.ParentId,
  10993. SubId = dac.Id,
  10994. Type = dac.Type,
  10995. Days = dac.Days,
  10996. NationalTravelFeeId = dac.NationalTravelFeeId,
  10997. Arae = $"{ntf.Country}-{ntf.City}",
  10998. Cost = dac.Cost,
  10999. Currency = dac.Currency,
  11000. CurrencyName = sd.Name,
  11001. SubTotal = dac.SubTotal,
  11002. })
  11003. .ToArray();
  11004. var data = new ChoiceDraftMobileSubInfo3To6View()
  11005. {
  11006. ParentId = eecInfo.Id,
  11007. Choice = eecInfo.ChoiceFive,
  11008. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11009. Details = dayAndCostDatas
  11010. };
  11011. return Ok(JsonView(data));
  11012. }
  11013. else if (subType == 6) //6:培训费
  11014. {
  11015. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11016. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11017. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11018. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  11019. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11020. {
  11021. ParentId = dac.ParentId,
  11022. SubId = dac.Id,
  11023. Type = dac.Type,
  11024. Days = dac.Days,
  11025. NationalTravelFeeId = dac.NationalTravelFeeId,
  11026. Arae = $"{ntf.Country}-{ntf.City}",
  11027. Cost = dac.Cost,
  11028. Currency = dac.Currency,
  11029. CurrencyName = sd.Name,
  11030. SubTotal = dac.SubTotal,
  11031. })
  11032. .ToArray();
  11033. var data = new ChoiceDraftMobileSubInfo3To6View()
  11034. {
  11035. ParentId = eecInfo.Id,
  11036. Choice = eecInfo.ChoiceSix,
  11037. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11038. Details = dayAndCostDatas
  11039. };
  11040. return Ok(JsonView(data));
  11041. }
  11042. else if (subType == 7) //7:其他
  11043. {
  11044. //其他款项
  11045. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11046. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11047. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11048. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11049. .OrderBy((dop, sd1, sd2) => dop.Index)
  11050. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11051. {
  11052. ParentId = dop.ParentId,
  11053. SubId = dop.Id,
  11054. Index = dop.Index,
  11055. SetDataId = dop.SetDataId,
  11056. SetDataName = sd1.Name,
  11057. Cost = dop.Cost,
  11058. Currency = dop.Currency,
  11059. CurrencyName = sd2.Name,
  11060. SubTotal = dop.SubTotal,
  11061. Remark = dop.Remark,
  11062. })
  11063. .ToArray();
  11064. var data = new ChoiceSevenDraftMobileSubInfoView()
  11065. {
  11066. ParentId = eecInfo.Id,
  11067. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11068. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11069. Details = otherData
  11070. };
  11071. return Ok(JsonView(data));
  11072. }
  11073. return Ok(JsonView(false));
  11074. }
  11075. #region op
  11076. ///// <summary>
  11077. ///// 移动端更新费用消息通知
  11078. ///// </summary>
  11079. ///// <param name="draftId"></param>
  11080. ///// <param name="id"></param>
  11081. ///// <param name="currUserId"></param>
  11082. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11083. //{
  11084. // try
  11085. // {
  11086. // ////生成默认文件pdf并且通知人员
  11087. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11088. // //{
  11089. // // DiId = draftId,
  11090. // // ExportType = 1,
  11091. // // SubTypeId = 1005
  11092. // //}, "pdf");
  11093. // ////发送通知
  11094. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11095. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11096. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11097. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11098. // ////汇率信息记录
  11099. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11100. // }
  11101. // catch (Exception ex)
  11102. // {
  11103. // //记录日志
  11104. // throw;
  11105. // }
  11106. //}
  11107. /// <summary>
  11108. /// 验证出入境费用数据是否存在
  11109. /// 不存在添加
  11110. /// </summary>
  11111. /// <param name="draftId"></param>
  11112. /// <param name="currUserId"></param>
  11113. /// <returns></returns>
  11114. /// <exception cref="CustomException"></exception>
  11115. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11116. {
  11117. var parentId = 0;
  11118. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11119. if (info != null) parentId = info.Id;
  11120. else
  11121. {
  11122. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11123. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11124. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11125. parentId = addId;
  11126. }
  11127. return parentId;
  11128. }
  11129. /// <summary>
  11130. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11131. /// </summary>
  11132. /// <returns></returns>
  11133. [HttpPost]
  11134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11135. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11136. {
  11137. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11138. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11139. //验证查看权限
  11140. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11141. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11142. var userIds = await _sqlSugar
  11143. .Queryable<Grp_EnterExitCostDraftPermission>()
  11144. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11145. .Select(x => x.UserId)
  11146. .ToArrayAsync();
  11147. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11148. var perUsersView = new List<dynamic>();
  11149. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11150. var viewPermissionData = new List<PermissionViewUserview>();
  11151. if (feeBasePerm.Any())
  11152. {
  11153. foreach (var item in feeBasePerm)
  11154. {
  11155. if (item.Users.Any())
  11156. {
  11157. viewPermissionData.AddRange(item.Users);
  11158. }
  11159. }
  11160. }
  11161. foreach (var item in perUsers)
  11162. {
  11163. bool isView1 = false;
  11164. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11165. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11166. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11167. }
  11168. return Ok(JsonView(perUsersView));
  11169. }
  11170. /// <summary>
  11171. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11172. /// </summary>
  11173. /// <returns></returns>
  11174. [HttpPost]
  11175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11176. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11177. {
  11178. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11179. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11180. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11181. //验证查看编辑权限
  11182. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11183. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11184. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11185. foreach (var userId in dto.UserIds)
  11186. {
  11187. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11188. }
  11189. if (permissions.Any())
  11190. {
  11191. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11192. {
  11193. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11194. }
  11195. _sqlSugar.BeginTran();
  11196. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11197. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11198. if (result < 1)
  11199. {
  11200. _sqlSugar.RollbackTran();
  11201. return Ok(JsonView(false));
  11202. }
  11203. _sqlSugar.CommitTran();
  11204. return Ok(JsonView(true));
  11205. }
  11206. return Ok(JsonView(false));
  11207. }
  11208. /// <summary>
  11209. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11210. /// </summary>
  11211. /// <returns></returns>
  11212. [HttpPost]
  11213. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11214. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11215. {
  11216. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11217. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11218. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11219. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11220. int id = dto.DraftId;
  11221. if (id <= 0) //add
  11222. {
  11223. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11224. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11225. if (add < 1) return Ok(JsonView(false));
  11226. id = add;
  11227. }
  11228. else //update
  11229. {
  11230. //验证查看编辑权限
  11231. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11232. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11233. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11234. if (upd < 1) return Ok(JsonView(false));
  11235. }
  11236. return Ok(JsonView(new { parentId = id }));
  11237. }
  11238. /// <summary>
  11239. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11240. /// </summary>
  11241. /// <returns></returns>
  11242. [HttpPost]
  11243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11244. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11245. {
  11246. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11247. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11248. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11249. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11250. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11251. int id = dto.DraftId;
  11252. if (id <= 0) //add
  11253. {
  11254. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11255. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11256. if (add < 1) return Ok(JsonView(false));
  11257. id = add;
  11258. }
  11259. else //update
  11260. {
  11261. //验证查看编辑权限
  11262. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11263. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11264. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11265. if (upd < 1) return Ok(JsonView(false));
  11266. }
  11267. #region 汇率变更时更改币种相关费用
  11268. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11269. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11270. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11271. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11272. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11273. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11274. .Select((dac, sd) => new
  11275. {
  11276. dac.Id,
  11277. dac.ParentId,
  11278. CurrencyCode = sd.Name,
  11279. dac.Cost
  11280. })
  11281. .ToList();
  11282. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11283. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11284. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11285. .Select((dop, sd) => new
  11286. {
  11287. dop.Id,
  11288. dop.ParentId,
  11289. CurrencyCode = sd.Name,
  11290. dop.Cost
  11291. })
  11292. .ToList();
  11293. if (dayCosts.Count > 0)
  11294. {
  11295. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11296. foreach (var dc in new_dayCosts)
  11297. {
  11298. var thisCurrency = dc.Key.ToUpper();
  11299. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11300. if (thisRate == 0.00M) continue;
  11301. foreach (var dcSub in dc)
  11302. {
  11303. opDayCosts.Add(new Grp_DayAndCostDraft()
  11304. {
  11305. Id = dcSub.Id,
  11306. ParentId = dcSub.ParentId,
  11307. Cost = dcSub.Cost,
  11308. SubTotal = dcSub.Cost * thisRate,
  11309. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11310. });
  11311. }
  11312. }
  11313. if (opDayCosts.Count > 0)
  11314. {
  11315. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11316. }
  11317. }
  11318. if (dayOtherCosts.Count > 0)
  11319. {
  11320. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11321. foreach (var dc in new_dayOtherCosts)
  11322. {
  11323. var thisCurrency = dc.Key.ToUpper();
  11324. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11325. if (thisRate == 0.00M) continue;
  11326. foreach (var dcSub in dc)
  11327. {
  11328. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11329. {
  11330. Id = dcSub.Id,
  11331. ParentId = dcSub.ParentId,
  11332. Cost = dcSub.Cost,
  11333. SubTotal = dcSub.Cost * thisRate,
  11334. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11335. });
  11336. }
  11337. }
  11338. if (opDayOtherCosts.Count > 0)
  11339. {
  11340. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11341. }
  11342. }
  11343. #endregion
  11344. ////消息通知
  11345. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11346. ////汇率信息记录
  11347. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11348. return Ok(JsonView(new { parentId = id }));
  11349. }
  11350. /// <summary>
  11351. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11352. /// </summary>
  11353. /// <returns></returns>
  11354. [HttpPost]
  11355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11356. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11357. {
  11358. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11359. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11360. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11361. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11362. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11363. int id = dto.DraftId;
  11364. if (id <= 0) //add
  11365. {
  11366. checkboxInfo.ProvinceId = dto.ProvinceId;
  11367. checkboxInfo.CreateUserId = dto.CurrUserId;
  11368. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11369. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11370. if (add < 1) return Ok(JsonView(false));
  11371. }
  11372. else //update
  11373. {
  11374. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11375. .UpdateColumns(x => new
  11376. {
  11377. x.ChoiceOne,
  11378. x.ChoiceTwo,
  11379. x.SumJJC,
  11380. x.SumGWC,
  11381. x.SumTDC,
  11382. x.ChoiceThree,
  11383. x.ChoiceFour,
  11384. x.ChoiceFive,
  11385. x.ChoiceSix,
  11386. x.OtherExpenses_Checked
  11387. })
  11388. .Where(x => x.Id == id)
  11389. .ExecuteCommandAsync();
  11390. if (upd < 1) return Ok(JsonView(false));
  11391. }
  11392. return Ok(JsonView(new { parentId = id }));
  11393. }
  11394. /// <summary>
  11395. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11396. /// </summary>
  11397. /// <returns></returns>
  11398. [HttpPost]
  11399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11400. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11401. {
  11402. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11403. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11404. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11405. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11406. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11407. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11408. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11409. var checkboxInfo = new Grp_EnterExitCostDraft()
  11410. {
  11411. Id = draftId,
  11412. ProvinceId = dto.ProvinceId,
  11413. CreateUserId = currUserId
  11414. };
  11415. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11416. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11417. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11418. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11419. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11420. if (draftId <= 0) //add
  11421. {
  11422. checkboxInfo.CreateUserId = dto.CurrUserId;
  11423. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11424. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11425. if (add < 1) return Ok(JsonView(false));
  11426. }
  11427. else //update
  11428. {
  11429. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11430. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11431. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11432. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11433. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11434. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11435. .Where(x => x.Id == draftId)
  11436. .ExecuteCommandAsync();
  11437. if (upd < 1) return Ok(JsonView(false));
  11438. }
  11439. return Ok(JsonView(new { parentId = draftId }));
  11440. }
  11441. /// <summary>
  11442. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11443. /// </summary>
  11444. /// <returns></returns>
  11445. [HttpPost]
  11446. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11447. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11448. {
  11449. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11450. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11451. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11452. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11453. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11454. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11455. info.ProvinceId = dto.ProvinceId;
  11456. info.FirstItemRemark = dto.FirstItemRemark;
  11457. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11458. if (id <= 0) //add
  11459. {
  11460. info.CreateUserId = dto.CurrUserId;
  11461. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11462. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11463. if (add < 1) return Ok(JsonView(false));
  11464. id = add;
  11465. }
  11466. else //update
  11467. {
  11468. var upd = await _sqlSugar.Updateable(info)
  11469. .UpdateColumns(x => new
  11470. {
  11471. x.ChoiceOne,
  11472. x.InsidePay,
  11473. x.VisaRemark,
  11474. x.Visa,
  11475. x.Service,
  11476. x.Safe,
  11477. x.Ticket,
  11478. x.HeSuan,
  11479. x.YiMiao,
  11480. x.FirstItemRemark
  11481. })
  11482. .Where(x => x.Id == id)
  11483. .ExecuteCommandAsync();
  11484. if (upd < 1) return Ok(JsonView(false));
  11485. }
  11486. ////消息通知
  11487. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11488. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11489. }
  11490. /// <summary>
  11491. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11492. /// </summary>
  11493. /// <returns></returns>
  11494. [HttpPost]
  11495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11496. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11497. {
  11498. int id = dto.DraftId;
  11499. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11500. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11501. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11502. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11503. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11504. info.ProvinceId = dto.ProvinceId;
  11505. info.OutsideJJPay = dto.OutsideJJPay;
  11506. info.OutsideGWPay = dto.OutsideGWPay;
  11507. info.OutsideTDPay = dto.OutsideTDPay;
  11508. info.AirJJ = dto.AirJJ;
  11509. info.AirGW = dto.AirGW;
  11510. info.AirTD = dto.AirTD;
  11511. info.CityTranffic = dto.CityTranffic;
  11512. info.TwoItemRemark = dto.TwoItemRemark;
  11513. info.SumJJC = dto.ChoiceTwoJJ;
  11514. info.SumGWC = dto.ChoiceTwoGW;
  11515. info.SumTDC = dto.ChoiceTwoTD;
  11516. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11517. if (id <= 0) //add
  11518. {
  11519. info.CreateUserId = dto.CurrUserId;
  11520. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11521. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11522. if (addId <= 0) return Ok(JsonView(false));
  11523. id = addId;
  11524. }
  11525. else //update
  11526. {
  11527. var upd = await _sqlSugar.Updateable(info)
  11528. .UpdateColumns(x => new
  11529. {
  11530. x.SumJJC,
  11531. x.OutsideJJPay,
  11532. x.SumGWC,
  11533. x.OutsideGWPay,
  11534. x.SumTDC,
  11535. x.OutsideTDPay,
  11536. x.AirJJ,
  11537. x.AirGW,
  11538. x.AirTD,
  11539. x.CityTranffic,
  11540. x.TwoItemRemark
  11541. })
  11542. .Where(x => x.Id == id)
  11543. .ExecuteCommandAsync();
  11544. if (upd < 1) return Ok(JsonView(false));
  11545. }
  11546. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11547. gwcItemTotal = info.AirGW + info.CityTranffic;
  11548. tdcItemTotal = info.AirTD + info.CityTranffic;
  11549. ////消息通知
  11550. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11551. return Ok(JsonView(new
  11552. {
  11553. parentId = id,
  11554. choiceTwoJJ = dto.ChoiceTwoJJ,
  11555. jjcItemTotal = jjcItemTotal,
  11556. choiceTwoGW = dto.ChoiceTwoGW,
  11557. gwcItemTotal = gwcItemTotal,
  11558. choiceTwoTD = dto.ChoiceTwoTD,
  11559. tdcItemTotal = tdcItemTotal
  11560. }));
  11561. }
  11562. /// <summary>
  11563. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11564. /// </summary>
  11565. /// <returns></returns>
  11566. [HttpPost]
  11567. [ApiExplorerSettings(IgnoreApi = true)]
  11568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11569. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11570. {
  11571. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11572. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11573. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11574. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11575. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11576. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11577. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11578. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11579. {
  11580. Id = x.Id,
  11581. ParentId = dto.DraftId,
  11582. Type = dto.FeeType,
  11583. Days = x.Days,
  11584. NationalTravelFeeId = x.NationalTravelFeeId,
  11585. Cost = x.Cost,
  11586. Currency = x.Currency,
  11587. SubTotal = x.SubTotal,
  11588. CreateUserId = dto.CurrUserId
  11589. })
  11590. .ToList();
  11591. var adds = infos.Where(x => x.Id <= 0).ToList();
  11592. var upds = infos.Where(x => x.Id > 0).ToList();
  11593. if (adds.Count > 0)
  11594. {
  11595. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11596. if (add < 1) return Ok(JsonView(false));
  11597. }
  11598. if (upds.Count > 0)
  11599. {
  11600. var upd = await _sqlSugar.Updateable(adds)
  11601. .UpdateColumns(x => new
  11602. {
  11603. x.Days,
  11604. x.NationalTravelFeeId,
  11605. x.Cost,
  11606. x.Currency,
  11607. x.SubTotal
  11608. })
  11609. .WhereColumns(x => new { x.Id })
  11610. .ExecuteCommandAsync();
  11611. if (upd < 1) return Ok(JsonView(false));
  11612. }
  11613. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11614. ////消息通知
  11615. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11616. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11617. return Ok(JsonView(new { itemTotal = itemTotal }));
  11618. }
  11619. /// <summary>
  11620. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11621. /// </summary>
  11622. /// <returns></returns>
  11623. [HttpPost]
  11624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11625. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11626. {
  11627. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11628. int subId = dto.SubId, feeType = dto.FeeType;
  11629. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11630. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11631. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11632. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11633. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11634. subInfo.Id = subId;
  11635. subInfo.ParentId = dto.DraftId;
  11636. if (feeType == 3) subInfo.Type = 1;
  11637. else if (feeType == 4) subInfo.Type = 2;
  11638. else if (feeType == 5) subInfo.Type = 3;
  11639. else if (feeType == 6) subInfo.Type = 4;
  11640. subInfo.CreateUserId = dto.CurrUserId;
  11641. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11642. if (parentId < 1) return Ok(JsonView(false));
  11643. //子表op
  11644. if (subId < 1)
  11645. {
  11646. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11647. if (subAdd < 1) return Ok(JsonView(false));
  11648. }
  11649. else
  11650. {
  11651. var subUpd = await _sqlSugar.Updateable(subInfo)
  11652. .UpdateColumns(x => new
  11653. {
  11654. x.Days,
  11655. x.NationalTravelFeeId,
  11656. x.Cost,
  11657. x.Currency,
  11658. x.SubTotal
  11659. })
  11660. .WhereColumns(x => new { x.Id })
  11661. .ExecuteCommandAsync();
  11662. if (subUpd < 1) return Ok(JsonView(false));
  11663. }
  11664. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11665. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11666. }
  11667. /// <summary>
  11668. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11669. /// </summary>
  11670. /// <returns></returns>
  11671. [HttpPost]
  11672. [ApiExplorerSettings(IgnoreApi = true)]
  11673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11674. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11675. {
  11676. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11677. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11678. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11679. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11680. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11681. {
  11682. Id = x.Id,
  11683. ParentId = dto.DraftId,
  11684. SetDataId = x.SetDataId,
  11685. Index = x.Index,
  11686. Cost = x.Cost,
  11687. Currency = x.Currency,
  11688. SubTotal = x.SubTotal,
  11689. CreateUserId = dto.CurrUserId,
  11690. Remark = x.Remark
  11691. }).ToList();
  11692. var adds = infos.Where(x => x.Id <= 0).ToList();
  11693. var upds = infos.Where(x => x.Id > 0).ToList();
  11694. if (adds.Count > 0)
  11695. {
  11696. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11697. if (add < 1) return Ok(JsonView(false));
  11698. }
  11699. if (upds.Count > 0)
  11700. {
  11701. var upd = await _sqlSugar.Updateable(adds)
  11702. .UpdateColumns(x => new
  11703. {
  11704. x.Index,
  11705. x.SetDataId,
  11706. x.Cost,
  11707. x.Currency,
  11708. x.SubTotal,
  11709. x.Remark
  11710. })
  11711. .WhereColumns(x => new { x.Id })
  11712. .ExecuteCommandAsync();
  11713. if (upd < 1) return Ok(JsonView(false));
  11714. }
  11715. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11716. //消息通知
  11717. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11718. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11719. return Ok(JsonView(new { itemTotal = itemTotal }));
  11720. }
  11721. /// <summary>
  11722. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11723. /// </summary>
  11724. /// <returns></returns>
  11725. [HttpPost]
  11726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11727. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11728. {
  11729. int subId = dto.SubId, id = dto.DraftId;
  11730. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11731. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11732. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11733. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11734. subInfo.Id = subId;
  11735. subInfo.ParentId = id;
  11736. subInfo.CreateUserId = dto.CurrUserId;
  11737. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11738. if (parentId < 1) return Ok(JsonView(false));
  11739. #region 子表op
  11740. if (subId < 1)//add
  11741. {
  11742. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11743. if (subAdd < 1) return Ok(JsonView(false));
  11744. }
  11745. else //upd
  11746. {
  11747. var subUpd = await _sqlSugar.Updateable(subInfo)
  11748. .UpdateColumns(x => new
  11749. {
  11750. x.Index,
  11751. x.SetDataId,
  11752. x.Cost,
  11753. x.Currency,
  11754. x.SubTotal,
  11755. x.Remark
  11756. })
  11757. .WhereColumns(x => new { x.Id })
  11758. .ExecuteCommandAsync();
  11759. if (subUpd < 1) return Ok(JsonView(false));
  11760. }
  11761. #endregion
  11762. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11763. ////消息通知
  11764. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11765. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11766. }
  11767. /// <summary>
  11768. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11769. /// </summary>
  11770. /// <returns></returns>
  11771. [HttpPost]
  11772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11773. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11774. {
  11775. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11776. if (data.Code != 0)
  11777. {
  11778. return Ok(JsonView(false, data.Msg));
  11779. }
  11780. return Ok(JsonView(true, "操作成功!", data.Data));
  11781. }
  11782. /// <summary>
  11783. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11784. /// </summary>
  11785. /// <param name="dto"></param>
  11786. /// <returns></returns>
  11787. [HttpPost]
  11788. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11789. {
  11790. var data = new Grp_DayOtherPriceDraft()
  11791. {
  11792. Id = dto.Id,
  11793. IsDel = 1,
  11794. DeleteUserId = dto.DeleteUserId,
  11795. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11796. };
  11797. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11798. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11799. return Ok(JsonView(false, "删除失败!"));
  11800. }
  11801. #endregion
  11802. #endregion
  11803. #region 团组经理模块 出入境费用报价表
  11804. /// <summary>
  11805. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11806. /// </summary>
  11807. /// <returns></returns>
  11808. [HttpPost]
  11809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11810. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11811. {
  11812. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11813. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11814. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11815. initRates.Insert(0, cnyInfo);
  11816. liveRates.Insert(0, cnyInfo);
  11817. return Ok(JsonView(true, "查询成功!", new
  11818. {
  11819. InitRates = initRates,
  11820. LiveRates = liveRates
  11821. }));
  11822. }
  11823. /// <summary>
  11824. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11825. /// </summary>
  11826. /// <returns></returns>
  11827. [HttpPost]
  11828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11829. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  11830. {
  11831. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11832. }
  11833. /// <summary>
  11834. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11835. /// </summary>
  11836. /// <returns></returns>
  11837. [HttpPost]
  11838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11839. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  11840. {
  11841. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11842. }
  11843. /// <summary>
  11844. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11845. /// </summary>
  11846. /// <returns></returns>
  11847. [HttpPost]
  11848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11849. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11850. {
  11851. int groupId = dto.DiId,
  11852. currUserId = dto.CurrUserId;
  11853. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11854. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11855. //验证报价数据是否存在
  11856. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  11857. if (isNull != null)
  11858. {
  11859. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  11860. if (!info1.Rates.Any())
  11861. {
  11862. var rates = await GeneralMethod.EnterExitCostInitRate();
  11863. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11864. info1.Rates = rates.ToArray();
  11865. }
  11866. return Ok(JsonView(info1));
  11867. }
  11868. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  11869. result.GroupId = groupId;
  11870. //处理报价名称
  11871. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11872. if (groupInfo != null)
  11873. {
  11874. var visitCountry = groupInfo.VisitCountry;
  11875. if (!string.IsNullOrEmpty(visitCountry))
  11876. {
  11877. string quoteName = string.Empty;
  11878. if (visitCountry.Contains("|"))
  11879. {
  11880. var countrys = visitCountry.Split("|");
  11881. quoteName = string.Join("、", countrys);
  11882. }
  11883. else quoteName = visitCountry;
  11884. quoteName += $"团组报价表";
  11885. result.Name = quoteName;
  11886. }
  11887. }
  11888. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11889. if (info.Code != StatusCodes.Status200OK)
  11890. {
  11891. if (!result.Rates.Any())
  11892. {
  11893. var rates = await GeneralMethod.EnterExitCostInitRate();
  11894. result.Rates = rates.ToArray();
  11895. }
  11896. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  11897. }
  11898. var infoView = info.Data as EnterExitCostInfoView;
  11899. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11900. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11901. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11902. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11903. var eecRates = infoView.Currencys;
  11904. //默认添加人名币
  11905. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  11906. {
  11907. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11908. }
  11909. //处理团组人数
  11910. int pplNum = 1;
  11911. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11912. var views = new List<QuoteSubItemInfo>();
  11913. #region 数据填充
  11914. var intTravelCosts = new List<QuoteSubItemInfo>();
  11915. #region 机票费用 1354
  11916. int intTravelIndex = 1;
  11917. if (infoView.SumJJC == 1)
  11918. {
  11919. intTravelCosts.Add(new QuoteSubItemInfo
  11920. {
  11921. ItemId = 1354,
  11922. Index = intTravelIndex,
  11923. FeeName = "经济舱",
  11924. UnitPrice = infoView.AirJJ,
  11925. Currency = "CNY",
  11926. Quantity = 1,
  11927. PplNum = 1,
  11928. TotalAmt = infoView.AirJJ,
  11929. Remark = "",
  11930. });
  11931. intTravelIndex++;
  11932. }
  11933. if (infoView.SumGWC == 1)
  11934. {
  11935. intTravelCosts.Add(new QuoteSubItemInfo
  11936. {
  11937. ItemId = 1354,
  11938. Index = intTravelIndex,
  11939. FeeName = "公务舱",
  11940. UnitPrice = infoView.AirGW,
  11941. Currency = "CNY",
  11942. Quantity = 1,
  11943. PplNum = 1,
  11944. TotalAmt = infoView.AirGW,
  11945. Remark = "",
  11946. });
  11947. intTravelIndex++;
  11948. }
  11949. if (infoView.SumTDC == 1)
  11950. {
  11951. intTravelCosts.Add(new QuoteSubItemInfo
  11952. {
  11953. ItemId = 1354,
  11954. Index = intTravelIndex,
  11955. FeeName = "头等舱",
  11956. UnitPrice = infoView.AirTD,
  11957. Currency = "CNY",
  11958. Quantity = 1,
  11959. PplNum = 1,
  11960. TotalAmt = infoView.AirTD,
  11961. Remark = "",
  11962. });
  11963. intTravelIndex++;
  11964. }
  11965. intTravelCosts.Add(new QuoteSubItemInfo
  11966. {
  11967. ItemId = 1354,
  11968. Index = intTravelIndex,
  11969. FeeName = "城市间交通费用",
  11970. UnitPrice = infoView.CityTranffic,
  11971. Currency = "CNY",
  11972. Quantity = 1,
  11973. PplNum = pplNum,
  11974. TotalAmt = infoView.CityTranffic * pplNum,
  11975. Remark = "",
  11976. });
  11977. views.AddRange(intTravelCosts);
  11978. #endregion
  11979. var accomCosts = new List<QuoteSubItemInfo>();
  11980. #region 住宿费 1355
  11981. if (infoView.QuarterageData.Any())
  11982. {
  11983. int accomIndex = 1;
  11984. int accomItemTypeId = 1355;
  11985. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  11986. foreach (var item in groupData)
  11987. {
  11988. string feeName = string.Empty;
  11989. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11990. if (countryInfo != null)
  11991. {
  11992. feeName = countryInfo.Country;
  11993. var city = countryInfo.City;
  11994. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11995. {
  11996. feeName += $"-{city}";
  11997. }
  11998. }
  11999. var hotelInfo = item.FirstOrDefault();
  12000. if (hotelInfo == null) continue;
  12001. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  12002. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12003. int quantity = item.ToList().Count;
  12004. accomCosts.Add(new QuoteSubItemInfo
  12005. {
  12006. ItemId = accomItemTypeId,
  12007. Index = accomIndex,
  12008. FeeName = feeName,
  12009. UnitPrice = hotelInfo.Cost,
  12010. Currency = thisCurrency,
  12011. Quantity = quantity,
  12012. PplNum = pplNum,
  12013. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  12014. Remark = "",
  12015. });
  12016. accomIndex++;
  12017. }
  12018. views.AddRange(accomCosts);
  12019. }
  12020. #endregion
  12021. var mealCosts = new List<QuoteSubItemInfo>();
  12022. #region 餐饮费 1356
  12023. if (infoView.BoardWagesData.Any())
  12024. {
  12025. var mealIndex = 1;
  12026. int mealItemTypeId = 1356;
  12027. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  12028. foreach (var item in groupData)
  12029. {
  12030. string feeName = string.Empty;
  12031. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12032. if (countryInfo != null)
  12033. {
  12034. feeName = countryInfo.Country;
  12035. var city = countryInfo.City;
  12036. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12037. {
  12038. feeName += $"-{city}";
  12039. }
  12040. }
  12041. var mealInfo = item.FirstOrDefault();
  12042. if (mealInfo == null) continue;
  12043. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12044. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12045. int quantity = item.ToList().Count;
  12046. mealCosts.Add(new QuoteSubItemInfo
  12047. {
  12048. ItemId = mealItemTypeId,
  12049. Index = mealIndex,
  12050. FeeName = feeName,
  12051. UnitPrice = mealInfo.Cost,
  12052. Currency = thisCurrency,
  12053. Quantity = quantity,
  12054. PplNum = pplNum,
  12055. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12056. Remark = "",
  12057. });
  12058. mealIndex++;
  12059. }
  12060. views.AddRange(mealCosts);
  12061. }
  12062. #endregion
  12063. var miscCosts = new List<QuoteSubItemInfo>();
  12064. #region 公杂费 1364
  12065. if (infoView.MiscellaneousFeeData.Any())
  12066. {
  12067. var miscIndex = 1;
  12068. int miscItemTypeId = 1364;
  12069. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12070. foreach (var item in groupData)
  12071. {
  12072. string feeName = string.Empty;
  12073. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12074. if (countryInfo != null)
  12075. {
  12076. feeName = countryInfo.Country;
  12077. var city = countryInfo.City;
  12078. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12079. {
  12080. feeName += $"-{city}";
  12081. }
  12082. }
  12083. var miscInfo = item.FirstOrDefault();
  12084. if (miscInfo == null) continue;
  12085. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12086. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12087. int quantity = item.ToList().Count;
  12088. miscCosts.Add(new QuoteSubItemInfo
  12089. {
  12090. ItemId = miscItemTypeId,
  12091. Index = miscIndex,
  12092. FeeName = feeName,
  12093. UnitPrice = miscInfo.Cost,
  12094. Currency = thisCurrency,
  12095. Quantity = quantity,
  12096. PplNum = pplNum,
  12097. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12098. Remark = "",
  12099. });
  12100. miscIndex++;
  12101. }
  12102. views.AddRange(miscCosts);
  12103. }
  12104. #endregion
  12105. #region 签证+保险 1362
  12106. int visaInsIndex = 1;
  12107. int visaInsItemTypeId = 1362;
  12108. if (infoView.Visa > 0)
  12109. {
  12110. views.Add(new QuoteSubItemInfo()
  12111. {
  12112. ItemId = visaInsItemTypeId,
  12113. Index = visaInsIndex,
  12114. FeeName = $"签证",
  12115. UnitPrice = infoView.Visa,
  12116. Currency = $"CNY",
  12117. Quantity = 1,
  12118. PplNum = pplNum,
  12119. TotalAmt = infoView.Visa * pplNum,
  12120. Remark = "",
  12121. });
  12122. visaInsIndex++;
  12123. }
  12124. if (infoView.Safe > 0)
  12125. {
  12126. views.Add(new QuoteSubItemInfo()
  12127. {
  12128. ItemId = visaInsItemTypeId,
  12129. Index = visaInsIndex,
  12130. FeeName = $"保险",
  12131. UnitPrice = infoView.Safe,
  12132. Currency = $"CNY",
  12133. Quantity = 1,
  12134. PplNum = pplNum,
  12135. TotalAmt = infoView.Safe * pplNum,
  12136. Remark = "",
  12137. });
  12138. }
  12139. #endregion
  12140. #region 服务费 1363
  12141. int serviceFeeIndex = 1;
  12142. int serviceFeeItemTypeId = 1363;
  12143. if (infoView.Service > 0)
  12144. {
  12145. views.Add(new QuoteSubItemInfo()
  12146. {
  12147. ItemId = serviceFeeItemTypeId,
  12148. Index = serviceFeeIndex,
  12149. FeeName = $"服务费",
  12150. UnitPrice = infoView.Service,
  12151. Currency = $"CNY",
  12152. Quantity = 1,
  12153. PplNum = pplNum,
  12154. TotalAmt = infoView.Service * pplNum,
  12155. Remark = "",
  12156. });
  12157. }
  12158. #endregion
  12159. #endregion
  12160. if (result.FeeItems.Any())
  12161. {
  12162. result.FeeItems.Select(x =>
  12163. {
  12164. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12165. if (feeInfos.Any()) x.Infos = feeInfos;
  12166. return x;
  12167. }
  12168. ).OrderBy(x => x.Index)
  12169. .ToList();
  12170. if (!result.Rates.Any())
  12171. {
  12172. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12173. else
  12174. {
  12175. var rates = await GeneralMethod.EnterExitCostInitRate();
  12176. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12177. result.Rates = rates.ToArray();
  12178. }
  12179. }
  12180. }
  12181. return Ok(JsonView(result));
  12182. }
  12183. /// <summary>
  12184. /// 团组模块 - 出入境费用报价表 - Info
  12185. /// </summary>
  12186. /// <returns></returns>
  12187. [HttpPost]
  12188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12189. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12190. {
  12191. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12192. if (!info.Rates.Any())
  12193. {
  12194. var rates = await GeneralMethod.EnterExitCostInitRate();
  12195. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12196. info.Rates = rates.ToArray();
  12197. }
  12198. return Ok(JsonView(info));
  12199. }
  12200. /// <summary>
  12201. /// 团组模块 - 出入境费用报价表 - OP
  12202. /// </summary>
  12203. /// <returns></returns>
  12204. [HttpPost]
  12205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12206. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12207. {
  12208. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12209. }
  12210. /// <summary>
  12211. /// 团组模块 - 出入境费用报价表 - 删除 项
  12212. /// </summary>
  12213. /// <returns></returns>
  12214. [HttpPost]
  12215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12216. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12217. {
  12218. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12219. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12220. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12221. }
  12222. /// <summary>
  12223. /// 团组模块 - 出入境费用报价表 - 导出
  12224. /// </summary>
  12225. /// <returns></returns>
  12226. [HttpPost]
  12227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12228. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12229. {
  12230. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12231. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12232. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12233. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12234. var rates = info.Rates;
  12235. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12236. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12237. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12238. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12239. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12240. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12241. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12242. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12243. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12244. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12245. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12246. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12247. //获取模板
  12248. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12249. var designer = new WorkbookDesigner();
  12250. designer.Workbook = new Workbook(tempPath);
  12251. designer.SetDataSource("QuoteName", info.Name);
  12252. designer.SetDataSource("CompanyTitle", "公司名称");
  12253. designer.SetDataSource("CompanyLabel", "");
  12254. #region 国际旅费
  12255. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12256. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12257. {
  12258. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12259. var label = new StringBuilder();
  12260. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12261. if (infos.Any())
  12262. {
  12263. label.Append(infos.Sum(x => x.PplNum));
  12264. label.Append("人全程机票:");
  12265. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12266. label.AppendLine("元");
  12267. }
  12268. foreach (var item in intTravelCosts.Infos)
  12269. {
  12270. label.Append(item.FeeName);
  12271. label.Append(":");
  12272. label.Append(item.UnitPrice.TruncDecimals(2));
  12273. label.Append("元/人*");
  12274. label.Append(item.PplNum);
  12275. label.AppendLine("人");
  12276. }
  12277. if (label.HasValue())
  12278. {
  12279. label.Append("\r\n以上小计:");
  12280. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12281. label.Append("元");
  12282. }
  12283. designer.SetDataSource("IntTravelLabel", label.ToString());
  12284. }
  12285. #endregion
  12286. #region 住宿费
  12287. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12288. if (accomCosts != null && accomCosts.Infos.Any())
  12289. {
  12290. string currencyName = string.Empty,
  12291. countryName = string.Empty;
  12292. decimal rate = 1.0000M;
  12293. var label = new StringBuilder();
  12294. label.AppendLine("全程五星酒店,每人1间房");
  12295. foreach (var item in accomCosts.Infos)
  12296. {
  12297. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12298. string name = string.Empty, thisCountryName = string.Empty;
  12299. if (item.FeeName.Contains('-'))
  12300. {
  12301. var feeName = item.FeeName.Split('-');
  12302. thisCountryName = feeName[0];
  12303. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12304. name = feeName[1];
  12305. }
  12306. else name = item.FeeName;
  12307. string thisFeeName = string.Empty;
  12308. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12309. else thisFeeName = $"\r\n{name}:";
  12310. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12311. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12312. rate = rateInfo?.Rate ?? 1.0000M;
  12313. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12314. label.AppendLine(subLabel);
  12315. }
  12316. if (label.HasValue())
  12317. {
  12318. //以上小计:52440元(美金汇率:7.5 )
  12319. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12320. label.AppendLine(subLabel);
  12321. }
  12322. designer.SetDataSource("AccomLabel", label.ToString());
  12323. }
  12324. #endregion
  12325. #region 餐饮费
  12326. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12327. if (mealCosts != null && mealCosts.Infos.Any())
  12328. {
  12329. string currencyName = string.Empty;
  12330. decimal rate = 1.0000M;
  12331. var label = new StringBuilder();
  12332. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12333. foreach (var item in mealCosts.Infos)
  12334. {
  12335. string name = string.Empty;
  12336. if (item.FeeName.Contains('-'))
  12337. {
  12338. var feeName = item.FeeName.Split('-');
  12339. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12340. }
  12341. else name = $"\r\n{item.FeeName}:";
  12342. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12343. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12344. rate = rateInfo?.Rate ?? 1.0000M;
  12345. label.Append(name);
  12346. label.Append(item.UnitPrice.TruncDecimals(2));
  12347. label.Append(currencyName);
  12348. label.Append("/天*");
  12349. label.Append(item.Quantity.ToString("#0"));
  12350. label.Append('*');
  12351. label.Append(item.PplNum);
  12352. label.Append("人\r\n");
  12353. }
  12354. if (label.HasValue())
  12355. {
  12356. label.Append("\r\n以上小计:");
  12357. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12358. label.Append("元\r\n(");
  12359. label.Append("汇率:");
  12360. label.Append(rate.TruncDecimals(4));
  12361. label.Append(')');
  12362. }
  12363. designer.SetDataSource("MealLabel", label.ToString());
  12364. }
  12365. #endregion
  12366. #region 车辆安排
  12367. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12368. if (vehArranges != null && vehArranges.Infos.Any())
  12369. {
  12370. string currencyName = string.Empty;
  12371. //decimal rate = 1.0000M;
  12372. var label = new StringBuilder();
  12373. foreach (var item in vehArranges.Infos)
  12374. {
  12375. label.AppendLine();
  12376. label.AppendLine();
  12377. label.Append(item.FeeName);
  12378. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12379. }
  12380. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12381. }
  12382. #endregion
  12383. #region 邀请函发放对象
  12384. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12385. designer.SetDataSource("InviteToContent", "");
  12386. #endregion
  12387. #region 邀请函费
  12388. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12389. var is_label = new StringBuilder();
  12390. if (inviteCosts != null && inviteCosts.Infos.Any())
  12391. {
  12392. string currencyName = string.Empty;
  12393. decimal rate = 1.0000M;
  12394. foreach (var item in inviteCosts.Infos)
  12395. {
  12396. //乌兹别克斯坦:2000美金
  12397. currencyName = item.Currency;
  12398. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12399. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12400. is_label.AppendLine(label);
  12401. }
  12402. if (is_label.HasValue())
  12403. {
  12404. //以上小计:28500元(美金汇率:7.5)
  12405. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12406. is_label.AppendLine(label);
  12407. }
  12408. }
  12409. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12410. #endregion
  12411. #region 邀请函发放时间
  12412. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12413. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12414. #endregion
  12415. #region 公务活动(含翻译)
  12416. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12417. var oa_label = new StringBuilder();
  12418. if (officialActs != null && officialActs.Infos.Any())
  12419. {
  12420. string currencyName = string.Empty;
  12421. decimal rate = 1.0000M;
  12422. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12423. foreach (var item in officialActs.Infos)
  12424. {
  12425. //乌兹别克斯坦:1000美金/场
  12426. currencyName = item.Currency;
  12427. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12428. string label_remark = string.Empty;
  12429. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12430. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12431. }
  12432. label_content += "*总费用中未含超出公务活动价格";
  12433. //8场公务活动(以上小计:60000元)
  12434. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12435. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12436. oa_label.AppendLine(label_title);
  12437. oa_label.AppendLine(label_content);
  12438. }
  12439. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12440. #endregion
  12441. #region 签证+保险
  12442. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12443. var vi_label = new StringBuilder();
  12444. if (visaIns != null && visaIns.Infos.Any())
  12445. {
  12446. foreach (var item in visaIns.Infos)
  12447. {
  12448. //签证:500元/人
  12449. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12450. vi_label.AppendLine(label);
  12451. }
  12452. if (vi_label.HasValue())
  12453. {
  12454. //以上小计:6000元
  12455. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12456. vi_label.AppendLine(label);
  12457. }
  12458. }
  12459. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12460. #endregion
  12461. #region 服务费
  12462. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12463. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12464. #endregion
  12465. #region 公杂费
  12466. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12467. var pm_label = new StringBuilder();
  12468. if (pubMiscs != null && pubMiscs.Infos.Any())
  12469. {
  12470. string currencyName = string.Empty,
  12471. countryName = string.Empty;
  12472. decimal rate = 1.0000M;
  12473. foreach (var item in pubMiscs.Infos)
  12474. {
  12475. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12476. string name = string.Empty, thisCountryName = string.Empty;
  12477. if (item.FeeName.Contains('-'))
  12478. {
  12479. var feeName = item.FeeName.Split('-');
  12480. thisCountryName = feeName[0];
  12481. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12482. name = feeName[1];
  12483. }
  12484. else name = item.FeeName;
  12485. string thisFeeName = string.Empty;
  12486. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12487. else thisFeeName = $"\r\n{name}:";
  12488. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12489. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12490. rate = rateInfo?.Rate ?? 1.0000M;
  12491. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12492. pm_label.AppendLine(label);
  12493. }
  12494. if (pm_label.HasValue())
  12495. {
  12496. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12497. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12498. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12499. pm_label.AppendLine(string.Format("部分发放成员"));
  12500. }
  12501. }
  12502. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12503. #endregion
  12504. #region 税费
  12505. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12506. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12507. #endregion
  12508. #region 合计(单位:元)
  12509. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12510. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12511. #endregion
  12512. #region 汇率 Remark
  12513. var rate_label = new StringBuilder();
  12514. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12515. foreach (var item in rateGroups)
  12516. {
  12517. //美元汇率按\r\n1:7.5
  12518. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12519. rate_label.AppendLine(label);
  12520. }
  12521. designer.SetDataSource("RateLabel", rate_label.ToString());
  12522. #endregion
  12523. designer.Process();
  12524. //文件名
  12525. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  12526. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12527. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12528. return Ok(JsonView(true, "成功", url));
  12529. }
  12530. #endregion
  12531. #region 签证费用录入
  12532. /// <summary>
  12533. /// 根据diid查询签证费用列表
  12534. /// </summary>
  12535. /// <param name="dto"></param>
  12536. /// <returns></returns>
  12537. [HttpPost]
  12538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12539. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12540. {
  12541. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12542. if (groupData.Code != 0)
  12543. {
  12544. return Ok(JsonView(false, groupData.Msg));
  12545. }
  12546. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12547. }
  12548. /// <summary>
  12549. /// 根据签证费用Id查询单条数据及c表数据
  12550. /// </summary>
  12551. /// <param name="dto"></param>
  12552. /// <returns></returns>
  12553. [HttpPost]
  12554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12555. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12556. {
  12557. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12558. if (groupData.Code != 0)
  12559. {
  12560. return Ok(JsonView(false, groupData.Msg));
  12561. }
  12562. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12563. }
  12564. /// <summary>
  12565. /// 签证费用删除
  12566. /// </summary>
  12567. /// <param name="dto"></param>
  12568. /// <returns></returns>
  12569. [HttpPost]
  12570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12571. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12572. {
  12573. _sqlSugar.BeginTran();
  12574. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12575. if (!res)
  12576. {
  12577. _sqlSugar.RollbackTran();
  12578. return Ok(JsonView(false, "删除失败"));
  12579. }
  12580. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12581. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12582. .SetColumns(a => new Grp_CreditCardPayment()
  12583. {
  12584. IsDel = 1,
  12585. DeleteUserId = dto.DeleteUserId,
  12586. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12587. })
  12588. .ExecuteCommand();
  12589. if (resSub < 1)
  12590. {
  12591. _sqlSugar.RollbackTran();
  12592. return Ok(JsonView(false, "删除失败"));
  12593. }
  12594. _sqlSugar.CommitTran();
  12595. return Ok(JsonView(true, "删除成功!"));
  12596. }
  12597. /// <summary>
  12598. /// 签证费用录入下拉框初始化
  12599. /// </summary>
  12600. /// <returns></returns>
  12601. [HttpPost]
  12602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12603. public async Task<IActionResult> VisaPriceAddSelect()
  12604. {
  12605. //支付方式
  12606. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12607. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12608. //币种
  12609. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12610. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12611. //乘客类型
  12612. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12613. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12614. //卡类型
  12615. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12616. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12617. //代办费类型
  12618. var agencyFeeTypeData = new List<dynamic>() {
  12619. new { id = 0 , Text = "未选择" },
  12620. new { id = 1 , Text = "小公务" },
  12621. new { id = 2 , Text = "大公务" },
  12622. };
  12623. //签证费用标准国家Data
  12624. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12625. var data = new
  12626. {
  12627. Payment = _Payment,
  12628. CurrencyList = _CurrencyList,
  12629. PassengerType = _PassengerType,
  12630. BankCard = _BankCard,
  12631. AgencyFeeType = agencyFeeTypeData,
  12632. CountryFeeData = visaCountryFeeData
  12633. };
  12634. return Ok(JsonView(true, "查询成功!", data));
  12635. }
  12636. /// <summary>
  12637. /// 签证费用录入操作(Status:1.新增,2.修改)
  12638. /// </summary>
  12639. /// <param name="dto"></param>
  12640. /// <returns></returns>
  12641. [HttpPost]
  12642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12643. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12644. {
  12645. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12646. if (groupData.Code != 0)
  12647. {
  12648. return Ok(JsonView(false, groupData.Msg));
  12649. }
  12650. #region 应用推送
  12651. try
  12652. {
  12653. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12654. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12655. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12656. //2024-10-21 新增LZ UID
  12657. var userIds = new List<int>() { 21 };
  12658. string title = $"系统通知";
  12659. string content = "";
  12660. var diId = dto.DiId;
  12661. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12662. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12663. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12664. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12665. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12666. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12667. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12668. }
  12669. catch (Exception ex)
  12670. {
  12671. }
  12672. #endregion
  12673. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12674. }
  12675. #endregion
  12676. #region 签证提成录入
  12677. /// <summary>
  12678. /// 签证提成录入
  12679. /// 基础数据
  12680. /// </summary>
  12681. /// <returns></returns>
  12682. [HttpGet]
  12683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12684. public async Task<IActionResult> VisaCommissionInit()
  12685. {
  12686. return Ok(await _visaCommissionRep.Init());
  12687. }
  12688. /// <summary>
  12689. /// 签证提成录入
  12690. /// Item
  12691. /// </summary>
  12692. /// <param name="_dto"></param>
  12693. /// <returns></returns>
  12694. [HttpPost]
  12695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12696. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12697. {
  12698. var validator = new VisaCommissionItemDtoValidator();
  12699. var validatorRes = await validator.ValidateAsync(_dto);
  12700. if (!validatorRes.IsValid)
  12701. {
  12702. var sb = new StringBuilder();
  12703. foreach (var item in validatorRes.Errors)
  12704. {
  12705. sb.AppendLine(item.ErrorMessage);
  12706. }
  12707. return Ok(JsonView(false, sb.ToString()));
  12708. }
  12709. return Ok(await _visaCommissionRep.Item(_dto));
  12710. }
  12711. /// <summary>
  12712. /// 签证提成录入
  12713. /// Save
  12714. /// </summary>
  12715. /// <param name="_dto"></param>
  12716. /// <returns></returns>
  12717. [HttpPost]
  12718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12719. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12720. {
  12721. //参数验证
  12722. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12723. foreach (var item in _dto.Items)
  12724. {
  12725. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12726. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12727. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12728. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12729. }
  12730. return Ok(await _visaCommissionRep.Save(_dto));
  12731. }
  12732. /// <summary>
  12733. /// 签证提成录入
  12734. /// Create
  12735. /// </summary>
  12736. /// <param name="_dto"></param>
  12737. /// <returns></returns>
  12738. [HttpPost]
  12739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12740. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12741. {
  12742. var validator = new VisaCommissionCreateDtoValidator();
  12743. var validatorRes = await validator.ValidateAsync(_dto);
  12744. if (!validatorRes.IsValid)
  12745. {
  12746. var sb = new StringBuilder();
  12747. foreach (var item in validatorRes.Errors)
  12748. {
  12749. sb.AppendLine(item.ErrorMessage);
  12750. }
  12751. return Ok(JsonView(false, sb.ToString()));
  12752. }
  12753. return Ok(await _visaCommissionRep.Create(_dto));
  12754. }
  12755. /// <summary>
  12756. /// 签证提成录入
  12757. /// Put(编辑)
  12758. /// </summary>
  12759. /// <param name="id"></param>
  12760. /// <param name="_dto"></param>
  12761. /// <returns></returns>
  12762. [HttpPut]
  12763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12764. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12765. {
  12766. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12767. var validator = new VisaCommissionCreateDtoValidator();
  12768. var validatorRes = await validator.ValidateAsync(_dto);
  12769. if (!validatorRes.IsValid)
  12770. {
  12771. var sb = new StringBuilder();
  12772. foreach (var item in validatorRes.Errors)
  12773. {
  12774. sb.AppendLine(item.ErrorMessage);
  12775. }
  12776. return Ok(JsonView(false, sb.ToString()));
  12777. }
  12778. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12779. }
  12780. /// <summary>
  12781. /// 签证提成录入
  12782. /// Del
  12783. /// </summary>
  12784. /// <param name="id"></param>
  12785. /// <param name="currUserId"></param>
  12786. /// <returns></returns>
  12787. [HttpPost]
  12788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12789. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12790. {
  12791. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12792. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12793. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12794. }
  12795. #endregion
  12796. #region op费用录入
  12797. /// <summary>
  12798. /// 根据diid查询op费用列表
  12799. /// </summary>
  12800. /// <param name="dto"></param>
  12801. /// <returns></returns>
  12802. [HttpPost]
  12803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12804. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12805. {
  12806. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12807. if (groupData.Code != 0)
  12808. {
  12809. return Ok(JsonView(false, groupData.Msg));
  12810. }
  12811. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12812. }
  12813. /// <summary>
  12814. /// 根据op费用Id查询单条数据及c表数据
  12815. /// </summary>
  12816. /// <param name="dto"></param>
  12817. /// <returns></returns>
  12818. [HttpPost]
  12819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12820. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12821. {
  12822. try
  12823. {
  12824. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12825. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12826. var data = new
  12827. {
  12828. CarTouristGuideGround = _groupData,
  12829. CreditCardPayment = _creditCardPayment
  12830. };
  12831. return Ok(JsonView(true, "查询成功!", data));
  12832. }
  12833. catch (Exception ex)
  12834. {
  12835. return Ok(JsonView(false, "程序错误!"));
  12836. }
  12837. }
  12838. /// <summary>
  12839. /// op费用删除
  12840. /// </summary>
  12841. /// <param name="dto"></param>
  12842. /// <returns></returns>
  12843. [HttpPost]
  12844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12845. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12846. {
  12847. try
  12848. {
  12849. _sqlSugar.BeginTran();
  12850. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12851. if (!res)
  12852. {
  12853. return Ok(JsonView(false, "删除失败"));
  12854. }
  12855. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12856. {
  12857. IsDel = 1,
  12858. DeleteUserId = dto.DeleteUserId,
  12859. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12860. }).ExecuteCommandAsync();
  12861. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12862. {
  12863. IsDel = 1,
  12864. DeleteUserId = dto.DeleteUserId,
  12865. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12866. }).ExecuteCommandAsync();
  12867. #region 删除超支相关数据
  12868. //删除导入的超支数据
  12869. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12870. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12871. {
  12872. IsDel = 1,
  12873. DeleteUserId = dto.DeleteUserId,
  12874. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12875. }).ExecuteCommand();
  12876. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12877. {
  12878. IsDel = 1,
  12879. DeleteUserId = dto.DeleteUserId,
  12880. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12881. }).ExecuteCommand();
  12882. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12883. {
  12884. IsDel = 1,
  12885. DeleteUserId = dto.DeleteUserId,
  12886. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12887. }).ExecuteCommand();
  12888. #endregion
  12889. _sqlSugar.CommitTran();
  12890. return Ok(JsonView(true, "删除成功!"));
  12891. }
  12892. catch (Exception ex)
  12893. {
  12894. _sqlSugar.RollbackTran();
  12895. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12896. }
  12897. }
  12898. /// <summary>
  12899. /// op费用录入操作(Status:1.新增,2.修改)
  12900. /// </summary>
  12901. /// <param name="dto"></param>
  12902. /// <returns></returns>
  12903. [HttpPost]
  12904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12905. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12906. {
  12907. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12908. if (groupData.Code != 0)
  12909. {
  12910. return Ok(JsonView(false, groupData.Msg));
  12911. }
  12912. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12913. }
  12914. /// <summary>
  12915. /// 填写费用详细页面初始化绑定
  12916. /// </summary>
  12917. /// <param name="dto"></param>
  12918. /// <returns></returns>
  12919. [HttpPost]
  12920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12921. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12922. {
  12923. try
  12924. {
  12925. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12926. if (groupData.Code != 0)
  12927. {
  12928. return Ok(JsonView(false, groupData.Msg));
  12929. }
  12930. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12931. }
  12932. catch (Exception ex)
  12933. {
  12934. return Ok(JsonView(false, ex.Message));
  12935. }
  12936. }
  12937. /// <summary>
  12938. /// 根据op费用Id查询详细数据
  12939. /// </summary>
  12940. /// <param name="dto"></param>
  12941. /// <returns></returns>
  12942. [HttpPost]
  12943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12944. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  12945. {
  12946. try
  12947. {
  12948. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  12949. if (groupData.Code != 0)
  12950. {
  12951. return Ok(JsonView(false, groupData.Msg));
  12952. }
  12953. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12954. }
  12955. catch (Exception ex)
  12956. {
  12957. return Ok(JsonView(false, ex.Message));
  12958. }
  12959. }
  12960. /// <summary>
  12961. /// OP费用录入填写详情
  12962. /// </summary>
  12963. /// <param name="dto"></param>
  12964. /// <returns></returns>
  12965. [HttpPost]
  12966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12967. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  12968. {
  12969. try
  12970. {
  12971. #region 参数校验
  12972. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  12973. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  12974. if (di == null) return Ok(JsonView(false, "团组错误!"));
  12975. #endregion
  12976. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  12977. if (groupData.Code != 0)
  12978. {
  12979. return Ok(JsonView(false, groupData.Msg));
  12980. }
  12981. //自动审核
  12982. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  12983. #region 应用推送
  12984. try
  12985. {
  12986. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12987. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12988. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12989. //2024-10-21 新增LZ UID
  12990. var userIds = new List<int>() { 21 };
  12991. string title = $"系统通知";
  12992. var diId = dto.DiId;
  12993. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12994. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12995. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  12996. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12997. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  12998. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12999. }
  13000. catch (Exception ex)
  13001. {
  13002. }
  13003. #endregion
  13004. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13005. }
  13006. catch (Exception ex)
  13007. {
  13008. return Ok(JsonView(false, ex.Message));
  13009. }
  13010. }
  13011. /// <summary>
  13012. /// 获取三公详细所有城市
  13013. /// </summary>
  13014. /// <returns></returns>
  13015. [HttpGet]
  13016. public IActionResult OpCarCityResult()
  13017. {
  13018. var jw = JsonView(false);
  13019. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  13020. {
  13021. x.Id,
  13022. x.Country,
  13023. x.City,
  13024. }).ToList();
  13025. if (data.Count > 0)
  13026. {
  13027. jw = JsonView(true, "获取成功!", data);
  13028. }
  13029. else
  13030. {
  13031. jw.Msg = "城市数据为空!";
  13032. jw.Data = Array.Empty<string>();
  13033. }
  13034. return Ok(jw);
  13035. }
  13036. /// <summary>
  13037. /// 导出地接费用明细
  13038. /// </summary>
  13039. /// <param name="dto"></param>
  13040. /// <returns></returns>
  13041. [HttpPost]
  13042. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13043. {
  13044. var jw = JsonView(false);
  13045. if (dto.Diid < 1)
  13046. {
  13047. jw.Msg = "请输入正确的diid!";
  13048. return Ok(jw);
  13049. }
  13050. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13051. if (group == null)
  13052. {
  13053. jw.Msg = "未找到团组信息!";
  13054. return Ok(jw);
  13055. }
  13056. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13057. if (localGuideArr.Count == 0)
  13058. {
  13059. jw.Msg = "该团组暂无地接信息!";
  13060. return Ok(jw);
  13061. }
  13062. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13063. var overspendSoure = new Dictionary<int, int>
  13064. {
  13065. { 91, 982 }, //车
  13066. { 92 , 1059} ,//导游
  13067. { 994 , 1073}, //翻译
  13068. { 988 , 1074 }, //早餐
  13069. { 93 , 1075 }, //午餐
  13070. { 989 , 1076 }, //晚餐
  13071. };
  13072. var Zips = new Dictionary<string, Stream>();
  13073. foreach (var groupArr in localGroup)
  13074. {
  13075. var keyValue = groupArr.Key;
  13076. if (int.TryParse(keyValue, out int cityid))
  13077. {
  13078. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13079. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13080. }
  13081. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13082. foreach (var item in groupArr)
  13083. {
  13084. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13085. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13086. new Grp_CarTouristGuideGroundReservationsContentExtend
  13087. {
  13088. Count = a.Count,
  13089. CreateTime = a.CreateTime,
  13090. CreateUserId = a.CreateUserId,
  13091. CTGGRId = a.CTGGRId,
  13092. Currency = a.Currency,
  13093. DatePrice = a.DatePrice,
  13094. DeleteTime = a.DeleteTime,
  13095. DeleteUserId = a.DeleteUserId,
  13096. DiId = a.DiId,
  13097. Id = a.Id,
  13098. IsDel = a.IsDel,
  13099. Price = a.Price,
  13100. PriceContent = a.PriceContent,
  13101. Remark = a.Remark,
  13102. SId = a.SId,
  13103. SidName = b.Name,
  13104. Units = a.Units,
  13105. }
  13106. ).ToList();
  13107. if (content.Count > 0)
  13108. {
  13109. contentArr.Add(content);
  13110. }
  13111. }
  13112. //open excel
  13113. //set excel
  13114. //save excel
  13115. try
  13116. {
  13117. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13118. IWorkbook workbook;
  13119. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13120. {
  13121. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13122. }
  13123. else
  13124. {
  13125. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13126. }
  13127. ISheet sheet = workbook.GetSheetAt(0);
  13128. var rowStartIndex = 2;
  13129. var clounmCount = 10;
  13130. var initStyleRow = sheet.GetRow(2);
  13131. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13132. //var overspendArrDetail =
  13133. var existsId = new List<CarCompare>();
  13134. var lastElem = arr.Last();
  13135. var thisSid = -1;
  13136. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13137. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13138. {
  13139. Name = "未知币种!",
  13140. Remark = "未知币种!",
  13141. };
  13142. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13143. Action cloneRowFn = () =>
  13144. {
  13145. rowStartIndex++;
  13146. var cloneRow = sheet.CreateRow(rowStartIndex);
  13147. // 复制样式
  13148. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13149. {
  13150. ICell sourceCell = initStyleRow.GetCell(i);
  13151. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13152. // 确保单元格存在样式
  13153. if (sourceCell.CellStyle != null)
  13154. {
  13155. targetCell.CellStyle = sourceCell.CellStyle;
  13156. }
  13157. }
  13158. };
  13159. var mergeRow = () =>
  13160. {
  13161. for (int i = 2; i < sheet.LastRowNum; i++)
  13162. {
  13163. var row = sheet.GetRow(i);
  13164. var cellFirst = row.GetCell(0);
  13165. var thisIndex = i + 1;
  13166. while (thisIndex < sheet.LastRowNum)
  13167. {
  13168. var nextRow = sheet.GetRow(thisIndex);
  13169. var nextCellFirst = nextRow.GetCell(0);
  13170. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13171. {
  13172. thisIndex++;
  13173. }
  13174. else
  13175. {
  13176. break;
  13177. }
  13178. }
  13179. thisIndex--;
  13180. if (thisIndex != i)
  13181. {
  13182. //合并row
  13183. var cellRangeAddress = new CellRangeAddress(
  13184. i, // 起始行索引(0-based)
  13185. thisIndex, // 结束行索引(0-based)
  13186. 0, // 起始列索引(0-based)
  13187. 0 // 结束列索引(0-based)
  13188. );
  13189. sheet.AddMergedRegion(cellRangeAddress);
  13190. i = thisIndex;
  13191. }
  13192. }
  13193. };
  13194. var chaoshiNumber = 0;
  13195. var totalNumber = 0.00M;
  13196. string lastStr = "";
  13197. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13198. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13199. {
  13200. b.IsAuditGM,
  13201. x.Id,
  13202. x.Area,
  13203. b.PayPercentage,
  13204. b.PayMoney,
  13205. }).ToList();
  13206. string yesPayment = "", noPayment = "";
  13207. foreach (var item in queryCarArrByCityAndDiid)
  13208. {
  13209. if (item.IsAuditGM == 1)
  13210. {
  13211. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13212. }
  13213. else
  13214. {
  13215. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13216. }
  13217. }
  13218. lastStr = yesPayment + noPayment;
  13219. foreach (var item in arr)
  13220. {
  13221. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  13222. {
  13223. if (thisSid != item.SId)
  13224. {
  13225. if (thisSid == -1)
  13226. {
  13227. thisSid = item.SId;
  13228. }
  13229. else
  13230. {
  13231. //合并小计行
  13232. //创建合并区域的实例
  13233. var cellRangeAddress = new CellRangeAddress(
  13234. rowStartIndex, // 起始行索引(0-based)
  13235. rowStartIndex, // 结束行索引(0-based)
  13236. 0, // 起始列索引(0-based)
  13237. 3 // 结束列索引(0-based)
  13238. );
  13239. sheet.AddMergedRegion(cellRangeAddress);
  13240. var CellStyle = workbook.CreateCellStyle();
  13241. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13242. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13243. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13244. for (int i = 0; i <= clounmCount; i++)
  13245. {
  13246. if (i > 6)
  13247. {
  13248. var CellStyle1 = workbook.CreateCellStyle();
  13249. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13250. IFont Font = workbook.CreateFont(); // 创建字体
  13251. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13252. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13253. CellStyle1.SetFont(Font);
  13254. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13255. }
  13256. else
  13257. {
  13258. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13259. }
  13260. }
  13261. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13262. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13263. //超时合计
  13264. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13265. //超时数
  13266. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13267. //超时合计费用
  13268. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13269. thisSid = item.SId;
  13270. cloneRowFn();
  13271. chaoshiNumber = 0;
  13272. totalNumber = 0;
  13273. }
  13274. }
  13275. IRow row = sheet.GetRow(rowStartIndex);
  13276. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13277. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  13278. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13279. if (isOpenOverspendSoure)
  13280. {
  13281. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13282. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13283. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13284. }
  13285. for (int i = 0; i <= clounmCount; i++)
  13286. {
  13287. var cell = row.GetCell(i);
  13288. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13289. if (cell == null)
  13290. {
  13291. cell = row.CreateCell(i);
  13292. }
  13293. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13294. fontRed.CloneStyleFrom(cell.CellStyle);
  13295. IFont Font = workbook.CreateFont(); // 创建字体
  13296. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13297. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13298. fontRed.SetFont(Font);
  13299. byte[] rgb = new byte[3] { 255, 242, 204 };
  13300. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13301. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13302. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13303. if (workbook is XSSFWorkbook)
  13304. {
  13305. BackgroundColor255_242_204.FillForegroundColor = 0;
  13306. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13307. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13308. }
  13309. else
  13310. {
  13311. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13312. }
  13313. if (i == 1 || i > 6)
  13314. {
  13315. if (i > 6)
  13316. {
  13317. fontRed.FillForegroundColor = 0;
  13318. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13319. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13320. }
  13321. cell.CellStyle = fontRed;
  13322. }
  13323. if (i > 2 && i < 7)
  13324. {
  13325. cell.CellStyle = BackgroundColor255_242_204;
  13326. }
  13327. cell.SetCellValue(setCellValue); //写入单元格
  13328. }
  13329. if (overspendSoure.ContainsKey(thisSid))
  13330. {
  13331. var overspendId = overspendSoure[thisSid];
  13332. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13333. }
  13334. cloneRowFn();
  13335. existsId.Add(new CarCompare
  13336. {
  13337. DataPrice = item.DatePrice.ObjToDate(),
  13338. Sid = item.SId
  13339. });
  13340. }
  13341. if (item.Equals(lastElem))
  13342. {
  13343. //合并小计行
  13344. //创建合并区域的实例
  13345. var cellRangeAddress = new CellRangeAddress(
  13346. rowStartIndex, // 起始行索引(0-based)
  13347. rowStartIndex, // 结束行索引(0-based)
  13348. 0, // 起始列索引(0-based)
  13349. 3 // 结束列索引(0-based)
  13350. );
  13351. sheet.AddMergedRegion(cellRangeAddress);
  13352. var CellStyle = workbook.CreateCellStyle();
  13353. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13354. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13355. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13356. for (int i = 0; i <= clounmCount; i++)
  13357. {
  13358. if (i > 6)
  13359. {
  13360. var CellStyle1 = workbook.CreateCellStyle();
  13361. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13362. IFont Font = workbook.CreateFont(); // 创建字体
  13363. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13364. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13365. CellStyle1.SetFont(Font);
  13366. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13367. }
  13368. else
  13369. {
  13370. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13371. }
  13372. }
  13373. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13374. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13375. //超时合计
  13376. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13377. //超时数
  13378. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13379. //超时合计费用
  13380. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13381. cloneRowFn();
  13382. // 创建合并区域的实例
  13383. cellRangeAddress = new CellRangeAddress(
  13384. rowStartIndex, // 起始行索引(0-based)
  13385. rowStartIndex, // 结束行索引(0-based)
  13386. 0, // 起始列索引(0-based)
  13387. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13388. );
  13389. // 添加合并区域
  13390. sheet.AddMergedRegion(cellRangeAddress);
  13391. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13392. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13393. }
  13394. }
  13395. mergeRow();
  13396. // 保存修改后的Excel文件到新文件
  13397. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13398. // new FileStream(newFilePath, FileMode.CreateNew)
  13399. using (var stream = new MemoryStream())
  13400. {
  13401. workbook.Write(stream, true);
  13402. stream.Flush();
  13403. stream.Seek(0, SeekOrigin.Begin);
  13404. var memoryStream = new MemoryStream();
  13405. stream.CopyTo(memoryStream);
  13406. memoryStream.Seek(0, SeekOrigin.Begin);
  13407. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13408. }
  13409. workbook.Close();
  13410. workbook.Dispose();
  13411. }
  13412. catch (Exception ex)
  13413. {
  13414. jw.Msg = "出现异常!" + ex.Message;
  13415. return Ok(jw);
  13416. }
  13417. }
  13418. if (Zips.Count > 0)
  13419. {
  13420. var io = new IOOperatorHelper();
  13421. var byts = io.ConvertZipStream(Zips);
  13422. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13423. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13424. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13425. }
  13426. else
  13427. {
  13428. jw.Msg = "暂无生成文件!";
  13429. }
  13430. return Ok(jw);
  13431. }
  13432. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13433. {
  13434. string outStr = string.Empty;
  13435. switch (i)
  13436. {
  13437. case 0:
  13438. outStr = arr[0].SidName;
  13439. break;
  13440. case 1:
  13441. outStr = arr[0].DataPriceStr;
  13442. break;
  13443. case 2:
  13444. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13445. break;
  13446. case 4:
  13447. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13448. break;
  13449. case 7:
  13450. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13451. {
  13452. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13453. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13454. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13455. }
  13456. break;
  13457. case 8:
  13458. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13459. {
  13460. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13461. }
  13462. break;
  13463. case 9:
  13464. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13465. {
  13466. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13467. }
  13468. break;
  13469. case 10:
  13470. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13471. {
  13472. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13473. }
  13474. break;
  13475. }
  13476. return outStr;
  13477. }
  13478. #region OP行程单
  13479. /// <summary>
  13480. /// OP行程单初始化
  13481. /// </summary>
  13482. /// <param name="dto"></param>
  13483. /// <returns></returns>
  13484. [HttpPost]
  13485. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13486. {
  13487. var jw = JsonView(false);
  13488. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13489. var group = groupList.First();
  13490. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13491. if (group == null)
  13492. {
  13493. jw.Msg = "暂无团组!";
  13494. return Ok(jw);
  13495. }
  13496. group = groupList.Find(x => x.Id == diid);
  13497. if (group == null)
  13498. {
  13499. jw.Msg = "请输入正确的团组ID!";
  13500. return Ok(jw);
  13501. }
  13502. string city = string.Empty;
  13503. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13504. if (blackCode.Count > 0)
  13505. {
  13506. var black = blackCode.First();
  13507. black.BlackCode = black.BlackCode ?? "";
  13508. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13509. if (blackSp.Length > 0)
  13510. {
  13511. try
  13512. {
  13513. var cityArrCode = new List<string>(20);
  13514. foreach (var item in blackSp)
  13515. {
  13516. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13517. var IndexSelect = itemSp[2];
  13518. var cityArrCodeLength = cityArrCode.Count - 1;
  13519. var startCity = IndexSelect.Substring(0, 3);
  13520. if (cityArrCodeLength > 0)
  13521. {
  13522. var arrEndCity = cityArrCode[cityArrCodeLength];
  13523. if (arrEndCity != startCity)
  13524. {
  13525. cityArrCode.Add(startCity.ToUpper());
  13526. }
  13527. }
  13528. else
  13529. {
  13530. cityArrCode.Add(startCity.ToUpper());
  13531. }
  13532. var endCity = IndexSelect.Substring(3, 3);
  13533. cityArrCode.Add(endCity.ToUpper());
  13534. }
  13535. var cityThree = string.Empty;
  13536. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13537. cityThree = cityThree.TrimEnd(',');
  13538. if (string.IsNullOrWhiteSpace(cityThree))
  13539. {
  13540. throw new
  13541. Exception("error");
  13542. }
  13543. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13544. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13545. foreach (var item in cityArrCode)
  13546. {
  13547. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13548. if (find != null)
  13549. {
  13550. city += find.City + "/";
  13551. }
  13552. else
  13553. {
  13554. city += item + "三字码未收入/";
  13555. }
  13556. }
  13557. city = city.TrimEnd('/');
  13558. }
  13559. catch (Exception e)
  13560. {
  13561. city = "黑屏代码格式不正确!";
  13562. }
  13563. }
  13564. }
  13565. else
  13566. {
  13567. city = "未录入黑屏代码";
  13568. }
  13569. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13570. {
  13571. Date = x.Date,
  13572. Days = x.Days,
  13573. Diffgroup = x.Diffgroup,
  13574. Diid = x.Diid,
  13575. Traffic_First = x.Traffic_First,
  13576. Traffic_Second = x.Traffic_Second,
  13577. Trip = x.Trip,
  13578. WeekDay = x.WeekDay,
  13579. Id = x.Id
  13580. }).ToList();
  13581. jw.Data = new
  13582. {
  13583. groupList = groupList.Select(x => new
  13584. {
  13585. x.Id,
  13586. x.TeamName,
  13587. x.TourCode
  13588. }).ToList(),
  13589. groupInfo = new
  13590. {
  13591. group.VisitDays,
  13592. group.TourCode,
  13593. group.VisitPNumber,
  13594. group.TeamName,
  13595. city
  13596. },
  13597. OpTravelList
  13598. };
  13599. jw.Code = 200;
  13600. jw.Msg = "操作成功!";
  13601. return Ok(jw);
  13602. }
  13603. /// <summary>
  13604. /// 删除团组行程单
  13605. /// </summary>
  13606. /// <returns></returns>
  13607. [HttpPost]
  13608. public IActionResult DelTravel(DelOpTravelDto dto)
  13609. {
  13610. var jw = JsonView(false);
  13611. if (dto.UserId <= 0 || dto.Diid <= 0)
  13612. {
  13613. jw.Msg = "请输入正确的参数!";
  13614. return Ok(jw);
  13615. }
  13616. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13617. .SetColumns(x => new Grp_TravelList
  13618. {
  13619. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13620. DeleteUserId = dto.UserId,
  13621. IsDel = 1,
  13622. }).ExecuteCommand();
  13623. jw = JsonView(true);
  13624. return Ok(jw);
  13625. }
  13626. /// <summary>
  13627. /// 行程单保存
  13628. /// </summary>
  13629. /// <returns></returns>
  13630. [HttpPost]
  13631. public IActionResult TravelSave(TravelSaveDto dto)
  13632. {
  13633. var jw = JsonView(false);
  13634. if (dto.Arr.Count > 0)
  13635. {
  13636. try
  13637. {
  13638. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13639. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13640. .ToList();
  13641. _sqlSugar.BeginTran();
  13642. foreach (var item in dto.Arr)
  13643. {
  13644. if (item.Id == 0)
  13645. {
  13646. throw new Exception("请传入正确的Id");
  13647. }
  13648. //比较上一次的差异
  13649. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13650. if (findTravel != null)
  13651. {
  13652. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13653. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13654. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13655. }
  13656. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13657. .SetColumns(x => new Grp_TravelList
  13658. {
  13659. Trip = item.Trip
  13660. }).ExecuteCommand();
  13661. }
  13662. _sqlSugar.CommitTran();
  13663. jw = JsonView(true);
  13664. }
  13665. catch (Exception ex)
  13666. {
  13667. _sqlSugar.RollbackTran();
  13668. jw.Msg = "程序异常!" + ex.Message;
  13669. }
  13670. }
  13671. else
  13672. {
  13673. jw.Msg = "请传入正确的参数!";
  13674. }
  13675. return Ok(jw);
  13676. }
  13677. private static string CheckStr(string original, string changed)
  13678. {
  13679. // 创建diff_match_patch对象
  13680. var dmp = new diff_match_patch();
  13681. // 计算差异
  13682. List<Diff> diffs = dmp.diff_main(original, changed);
  13683. // 清理和合并差异
  13684. dmp.diff_cleanupSemantic(diffs);
  13685. // 使用StringBuilder构建最终的字符串
  13686. var finalString = new StringBuilder();
  13687. // 输出差异结果,并构建变动后的字符串
  13688. foreach (Diff diff in diffs)
  13689. {
  13690. switch (diff.operation)
  13691. {
  13692. case Operation.EQUAL:
  13693. // 相等的部分,直接添加到最终字符串
  13694. finalString.Append(diff.text);
  13695. break;
  13696. case Operation.INSERT:
  13697. // 插入的部分,添加标记并添加到最终字符串
  13698. finalString.Append("[++]" + diff.text + "[++]");
  13699. break;
  13700. case Operation.DELETE:
  13701. // 删除的部分,不添加到最终字符串
  13702. //finalString.Append("[++]" + diff.text + "[++]");
  13703. break;
  13704. }
  13705. }
  13706. // 输出变动后的字符串
  13707. return finalString.ToString();
  13708. }
  13709. private class tagContent
  13710. {
  13711. public DateTime Date { get; set; }
  13712. public string StartTag { get; set; }
  13713. public string EndTag { get; set; }
  13714. public string Content { get; set; }
  13715. public static int tagLength { get { return 3; } }
  13716. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13717. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13718. public bool IsFinally { get; set; }
  13719. }
  13720. private static List<string> ExtractContentBetweenTags(string input, string tag)
  13721. {
  13722. var results = new List<string>();
  13723. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13724. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13725. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13726. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13727. string[] strValueArr = new string[1];
  13728. foreach (System.Text.RegularExpressions.Match match in matches)
  13729. {
  13730. var strValue = match.Groups[1].Value;
  13731. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13732. }
  13733. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13734. return results;
  13735. }
  13736. /// <summary>
  13737. /// 导出行程单
  13738. /// </summary>
  13739. /// <param name="dto"></param>
  13740. /// <returns></returns>
  13741. [HttpPost]
  13742. public IActionResult ExportTravel(ExportTravelDto dto)
  13743. {
  13744. var jw = JsonView(false);
  13745. jw.Data = "";
  13746. int diid = 0;
  13747. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13748. if (Find == null)
  13749. {
  13750. jw.Msg = "请选择正确的团组!";
  13751. return Ok(jw);
  13752. }
  13753. else
  13754. {
  13755. diid = Find.Id;
  13756. }
  13757. //数据源
  13758. var _travelList = new List<Grp_TravelList>();
  13759. DataTable dtBlack = null;
  13760. try
  13761. {
  13762. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13763. }
  13764. catch (Exception)
  13765. {
  13766. jw.Msg = "机票黑屏代码有误!";
  13767. return Ok(jw);
  13768. }
  13769. string CityStr = string.Empty;
  13770. if (dtBlack.Rows.Count == 0)
  13771. {
  13772. jw.Msg = "机票黑屏代码有误!";
  13773. return Ok(jw);
  13774. }
  13775. else
  13776. {
  13777. foreach (DataRow row in dtBlack.Rows)
  13778. {
  13779. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13780. {
  13781. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13782. return Ok(jw);
  13783. }
  13784. }
  13785. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13786. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13787. }
  13788. // 指定的文字
  13789. var targetTextDic = new Dictionary<string, List<string>>();
  13790. //创建数据源Table
  13791. var dtSource = new DataTable();
  13792. dtSource.Columns.Add("Days", typeof(string));
  13793. dtSource.Columns.Add("Date", typeof(string));
  13794. dtSource.Columns.Add("Week", typeof(string));
  13795. dtSource.Columns.Add("Traffic", typeof(string));
  13796. dtSource.Columns.Add("Trip", typeof(string));
  13797. //获取数据,放到datatable
  13798. foreach (var item in _travelList)
  13799. {
  13800. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13801. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13802. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13803. .Replace("[++]", string.Empty);
  13804. DataRow dr = dtSource.NewRow();
  13805. dr["Days"] = item.Days;
  13806. dr["Date"] = item.Date;
  13807. dr["Week"] = item.WeekDay;
  13808. dr["Traffic"] = item.Traffic_First
  13809. + "\r\n"
  13810. + item.Traffic_Second;
  13811. dr["Trip"] = item.Trip;
  13812. dtSource.Rows.Add(dr);
  13813. }
  13814. var dic = new Dictionary<string, string>
  13815. {
  13816. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  13817. { "City", CityStr },
  13818. { "Days", Find.VisitDays.ToString() },
  13819. { "DeleCode", Find.TourCode },
  13820. { "Pnum", Find.VisitPNumber.ToString() }
  13821. };
  13822. //模板路径
  13823. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13824. //载入模板
  13825. Document doc = null;
  13826. DocumentBuilder builder = null;
  13827. try
  13828. {
  13829. //载入模板
  13830. doc = new Document(tempPath);
  13831. builder = new DocumentBuilder(doc);
  13832. }
  13833. catch (Exception)
  13834. {
  13835. jw.Msg = "模板位置不存在!";
  13836. return Ok(jw);
  13837. }
  13838. foreach (var key in dic.Keys)
  13839. {
  13840. Bookmark bookmark = doc.Range.Bookmarks[key];
  13841. if (bookmark != null)
  13842. {
  13843. builder.MoveToBookmark(key);
  13844. builder.Write(dic[key]);
  13845. }
  13846. }
  13847. //获取word里所有表格
  13848. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13849. //获取所填表格的序数
  13850. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13851. try
  13852. {
  13853. //循环赋值
  13854. for (int i = 0; i < dtSource.Rows.Count; i++)
  13855. {
  13856. builder.MoveToCell(0, i + 1, 0, 0);
  13857. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13858. builder.MoveToCell(0, i + 1, 1, 0);
  13859. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13860. builder.MoveToCell(0, i + 1, 2, 0);
  13861. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13862. var trip = dtSource.Rows[i]["Trip"].ToString();
  13863. builder.MoveToCell(0, i + 1, 3, 0);
  13864. builder.Write(trip);
  13865. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13866. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13867. // 获取特定索引的段落
  13868. Paragraph paragraph = (Paragraph)paragraphs[0];
  13869. Run run = paragraph.Runs[0];
  13870. Aspose.Words.Font font = run.Font;
  13871. font.Name = "黑体";
  13872. //设置双休红色
  13873. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13874. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13875. paragraph = (Paragraph)paragraphs[1];
  13876. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13877. {
  13878. run = paragraph.Runs[0];
  13879. font = run.Font;
  13880. font.Color = Color.Red;
  13881. }
  13882. }
  13883. }
  13884. catch (Exception ex)
  13885. {
  13886. }
  13887. //删除多余行
  13888. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13889. {
  13890. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13891. }
  13892. var targetTextList = new List<string>();
  13893. // 遍历文档中的表格
  13894. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13895. {
  13896. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13897. {
  13898. var cellIndex = 0;
  13899. foreach (Cell cell in row.Cells)
  13900. {
  13901. if (cellIndex == 1 && row.Cells.Count == 4)
  13902. {
  13903. foreach (var target in targetTextDic.Keys)
  13904. {
  13905. if (cell.GetText().Contains(target))
  13906. {
  13907. targetTextList = targetTextDic[target];
  13908. break;
  13909. }
  13910. }
  13911. }
  13912. // 遍历单元格中的所有段落
  13913. foreach (Paragraph paragraph in cell.Paragraphs)
  13914. {
  13915. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13916. var runs = new List<Run>();
  13917. foreach (Run run in paragraph.Runs)
  13918. {
  13919. runs.Add(run);
  13920. }
  13921. foreach (Run run in runs)
  13922. {
  13923. foreach (var targetText in targetTextList)
  13924. {
  13925. // 检查文字是否包含指定文字
  13926. if (run.Text.Contains(targetText))
  13927. {
  13928. // 将包含的部分设置为红色
  13929. HighlightText(run, targetText, Color.Red);
  13930. }
  13931. }
  13932. }
  13933. }
  13934. cellIndex++;
  13935. }
  13936. }
  13937. }
  13938. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  13939. if (!Directory.Exists(savePath))
  13940. {
  13941. try
  13942. {
  13943. Directory.CreateDirectory(savePath);
  13944. }
  13945. catch
  13946. {
  13947. }
  13948. }
  13949. string path = savePath + Find.TeamName + "出访日程";
  13950. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  13951. try
  13952. {
  13953. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  13954. string postfix = ".docx";
  13955. if (dto.IsPDF == 1)
  13956. {
  13957. saveFormat = Aspose.Words.SaveFormat.Pdf;
  13958. postfix = ".pdf";
  13959. }
  13960. doc.Save(path + postfix, saveFormat);
  13961. jw = JsonView(true, "导出成功", ftpPath + postfix);
  13962. }
  13963. catch (Exception)
  13964. {
  13965. jw = JsonView(false);
  13966. }
  13967. return Ok(jw);
  13968. }
  13969. /// <summary>
  13970. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  13971. /// </summary>
  13972. /// <param name="num"></param>
  13973. /// <returns></returns>
  13974. static string GetNum(string num)
  13975. {
  13976. string str = "";
  13977. switch (num)
  13978. {
  13979. case "1":
  13980. str = "一";
  13981. break;
  13982. case "2":
  13983. str = "二";
  13984. break;
  13985. case "3":
  13986. str = "三";
  13987. break;
  13988. case "4":
  13989. str = "四";
  13990. break;
  13991. case "5":
  13992. str = "五";
  13993. break;
  13994. case "6":
  13995. str = "六";
  13996. break;
  13997. case "7":
  13998. str = "七";
  13999. break;
  14000. case "8":
  14001. str = "八";
  14002. break;
  14003. case "9":
  14004. str = "九";
  14005. break;
  14006. case "10":
  14007. str = "十";
  14008. break;
  14009. case "11":
  14010. str = "十一";
  14011. break;
  14012. case "12":
  14013. str = "十二";
  14014. break;
  14015. case "一":
  14016. str = "1";
  14017. break;
  14018. case "二":
  14019. str = "2";
  14020. break;
  14021. case "三":
  14022. str = "3";
  14023. break;
  14024. case "四":
  14025. str = "4";
  14026. break;
  14027. case "五":
  14028. str = "5";
  14029. break;
  14030. case "六":
  14031. str = "6";
  14032. break;
  14033. case "七":
  14034. str = "7";
  14035. break;
  14036. case "八":
  14037. str = "8";
  14038. break;
  14039. case "九":
  14040. str = "9";
  14041. break;
  14042. case "十":
  14043. str = "10";
  14044. break;
  14045. case "十一":
  14046. str = "11";
  14047. break;
  14048. case "十二":
  14049. str = "12";
  14050. break;
  14051. }
  14052. return str;
  14053. }
  14054. /// <summary>
  14055. /// 高亮包含指定文字的部分
  14056. /// </summary>
  14057. /// <param name="run"></param>
  14058. /// <param name="targetText"></param>
  14059. /// <param name="color"></param>
  14060. static void HighlightText(Run run, string targetText, Color color)
  14061. {
  14062. string text = run.Text;
  14063. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14064. if (startIndex >= 0)
  14065. {
  14066. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14067. // 前部分
  14068. if (startIndex > 0)
  14069. {
  14070. Run beforeRun = (Run)run.Clone(true);
  14071. beforeRun.Text = text.Substring(0, startIndex);
  14072. parentParagraph.InsertBefore(beforeRun, run);
  14073. }
  14074. // 匹配部分
  14075. Run matchRun = (Run)run.Clone(true);
  14076. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14077. matchRun.Font.Color = color;
  14078. parentParagraph.InsertBefore(matchRun, run);
  14079. // 后部分
  14080. if (startIndex + targetText.Length < text.Length)
  14081. {
  14082. Run afterRun = (Run)run.Clone(true);
  14083. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14084. parentParagraph.InsertBefore(afterRun, run);
  14085. }
  14086. // 删除原始Run
  14087. run.Remove();
  14088. }
  14089. }
  14090. #endregion
  14091. #endregion
  14092. #region 团组成本
  14093. /// <summary>
  14094. /// 团组成本数据初始化
  14095. /// </summary>
  14096. /// <param name="dto"></param>
  14097. /// <returns></returns>
  14098. [HttpPost]
  14099. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14100. {
  14101. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14102. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14103. WHEN COUNT(*) >= 0 THEN 'True'
  14104. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14105. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14106. ").ToList(); //团组列表
  14107. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14108. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14109. var visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14110. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14111. if (groupinfoValue != null)
  14112. {
  14113. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14114. var spArr = new string[1] { countryArr };
  14115. if (countryArr.Contains("|"))
  14116. {
  14117. spArr = countryArr.Split("|");
  14118. }
  14119. else if (countryArr.Contains("、"))
  14120. {
  14121. spArr = countryArr.Split("、");
  14122. }
  14123. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14124. {
  14125. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14126. if (dbQueryCountry != null)
  14127. {
  14128. visaCountryInfoArr.Add(dbQueryCountry);
  14129. }
  14130. }
  14131. }
  14132. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14133. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14134. #region 屏蔽黑屏代码生成
  14135. //var create = _GroupCostRepository.
  14136. // CreateGroupCostByBlackCode(dto.Diid);
  14137. //if (groupCost.Count == 0 && create.Code == 0)
  14138. //{
  14139. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14140. //}
  14141. #endregion
  14142. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14143. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14144. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14145. groupCostMap = groupCostMap.Select(x =>
  14146. {
  14147. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14148. {
  14149. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14150. }
  14151. return x;
  14152. }).ToList();
  14153. //GroupCostParameter.Add(new
  14154. // Grp_GroupCostParameter());
  14155. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14156. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14157. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  14158. return Ok(JsonView(new
  14159. {
  14160. groupList,
  14161. groupInfo,
  14162. groupChecks,
  14163. groupCost = groupCostMap,
  14164. hotelNumber,
  14165. GroupCostParameter = GroupCostParameterMap,
  14166. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14167. {
  14168. x.VisaCountry,
  14169. x.VisaPrice,
  14170. x.Id,
  14171. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  14172. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  14173. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  14174. x.VisaTime, // 一般签证时间
  14175. }).ToList(),
  14176. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14177. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14178. hotelIsTrue,
  14179. groupModuleOperators
  14180. }));
  14181. }
  14182. /// <summary>
  14183. /// 团组成本信息保存
  14184. /// </summary>
  14185. /// <param name="dto"></param>
  14186. /// <returns></returns>
  14187. [HttpPost]
  14188. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14189. {
  14190. if (dto.Diid <= 0 || dto.Userid <= 0)
  14191. {
  14192. return Ok(JsonView(false));
  14193. }
  14194. JsonView jw = null;
  14195. bool isTrue = false;
  14196. #region 复制团组成本
  14197. //if (dto.Diid == 2581)
  14198. //{
  14199. // dto.Diid = 2599;
  14200. // dto.CheckBoxs.ForEach(x =>
  14201. // {
  14202. // x.Diid = 2599;
  14203. // });
  14204. // dto.GroupCosts.ForEach(x =>
  14205. // {
  14206. // x.Diid = 2599;
  14207. // });
  14208. // dto.CostTypeHotelNumbers.ForEach(x =>
  14209. // {
  14210. // x.Diid = 2599;
  14211. // });
  14212. // dto.GroupCostParameters.ForEach(x =>
  14213. // {
  14214. // x.DiId = 2599;
  14215. // });
  14216. //}
  14217. #endregion
  14218. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14219. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14220. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14221. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14222. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14223. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14224. try
  14225. {
  14226. _sqlSugar.BeginTran();
  14227. isTrue = await _GroupCostRepository.
  14228. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14229. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14230. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14231. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14232. _sqlSugar.CommitTran();
  14233. jw = JsonView(true, "保存成功!", isTrue);
  14234. }
  14235. catch (Exception)
  14236. {
  14237. _sqlSugar.RollbackTran();
  14238. jw = JsonView(false);
  14239. }
  14240. return Ok(jw);
  14241. }
  14242. /// <summary>
  14243. /// 复制团组成本信息
  14244. /// </summary>
  14245. /// <param name="dto"></param>
  14246. /// <returns></returns>
  14247. [HttpPost]
  14248. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14249. {
  14250. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14251. {
  14252. return Ok(JsonView(false, "参数有误!"));
  14253. }
  14254. #region 复制团组成本
  14255. dto.Diid = dto.ToGroupId;
  14256. dto.CheckBoxs.ForEach(x =>
  14257. {
  14258. x.Diid = dto.ToGroupId;
  14259. });
  14260. dto.GroupCosts.ForEach(x =>
  14261. {
  14262. x.Diid = dto.ToGroupId;
  14263. });
  14264. dto.CostTypeHotelNumbers.ForEach(x =>
  14265. {
  14266. x.Diid = dto.ToGroupId;
  14267. });
  14268. dto.GroupCostParameters.ForEach(x =>
  14269. {
  14270. x.DiId = dto.ToGroupId;
  14271. });
  14272. #endregion
  14273. JsonView jw = null;
  14274. bool isTrue = false;
  14275. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14276. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14277. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14278. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14279. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14280. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14281. try
  14282. {
  14283. _sqlSugar.BeginTran();
  14284. isTrue = await _GroupCostRepository.
  14285. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14286. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14287. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14288. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14289. _sqlSugar.CommitTran();
  14290. jw = JsonView(true, "保存成功!", isTrue);
  14291. }
  14292. catch (Exception)
  14293. {
  14294. _sqlSugar.RollbackTran();
  14295. jw = JsonView(false);
  14296. }
  14297. return Ok(jw);
  14298. }
  14299. /// <summary>
  14300. /// 司兼导数据
  14301. /// </summary>
  14302. /// <param name="dto"></param>
  14303. /// <returns></returns>
  14304. [HttpPost]
  14305. public IActionResult GetCarGuides(CarGuidesDto dto)
  14306. {
  14307. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14308. return Ok(JsonView(true, "获取成功!", Data));
  14309. }
  14310. /// <summary>
  14311. /// 导游数据
  14312. /// </summary>
  14313. /// <param name="dto"></param>
  14314. /// <returns></returns>
  14315. [HttpPost]
  14316. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14317. {
  14318. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14319. // 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
  14320. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14321. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14322. return Ok(JsonView(true, "获取成功!", Data));
  14323. }
  14324. /// <summary>
  14325. /// 成本车数据
  14326. /// </summary>
  14327. /// <param name="dto"></param>
  14328. /// <returns></returns>
  14329. [HttpPost]
  14330. public IActionResult GetCarInfo(CarGuidesDto dto)
  14331. {
  14332. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14333. return Ok(JsonView(true, "获取成功!", Data));
  14334. }
  14335. /// <summary>
  14336. /// 景点数据
  14337. /// </summary>
  14338. /// <param name="dto"></param>
  14339. /// <returns></returns>
  14340. [HttpPost]
  14341. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14342. {
  14343. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14344. return Ok(JsonView(true, "获取成功!", Data));
  14345. }
  14346. /// <summary>
  14347. /// 成本通知
  14348. /// </summary>
  14349. /// <param name="dto"></param>
  14350. /// <returns></returns>
  14351. [HttpPost]
  14352. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14353. {
  14354. if (dto.Diid < 0)
  14355. {
  14356. return Ok(JsonView(false));
  14357. }
  14358. JsonView jw;
  14359. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14360. if (GroupCostParameter != null)
  14361. {
  14362. int IsShare = 0;
  14363. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14364. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14365. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14366. string msg = string.Empty;
  14367. if (isTrue)
  14368. {
  14369. if (IsShare == 0)
  14370. {
  14371. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14372. }
  14373. else
  14374. {
  14375. #region 企微通知对应岗位用户
  14376. try
  14377. {
  14378. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14379. }
  14380. catch (Exception)
  14381. {
  14382. }
  14383. #endregion
  14384. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14385. }
  14386. jw = JsonView(isTrue, msg, new { IsShare });
  14387. }
  14388. else
  14389. {
  14390. msg = "修改失败!";
  14391. jw = JsonView(isTrue, msg);
  14392. }
  14393. }
  14394. else
  14395. {
  14396. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14397. }
  14398. return Ok(jw);
  14399. }
  14400. /// <summary>
  14401. /// 导出报价单
  14402. /// </summary>
  14403. /// <param name="dto"></param>
  14404. /// <returns></returns>
  14405. [HttpPost]
  14406. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14407. {
  14408. if (dto.Diid == 0)
  14409. {
  14410. return Ok(JsonView(false, "请传递团组id"));
  14411. }
  14412. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14413. if (deleInfo.Code != 0)
  14414. {
  14415. return Ok(JsonView(false, "团组信息查询失败!"));
  14416. }
  14417. var di = deleInfo.Data as DelegationInfoWebView;
  14418. if (di != null)
  14419. {
  14420. di.TeamName = di.TeamName.Replace("|", "、");
  14421. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14422. //文件名
  14423. string strFileName = di.TeamName + "-收款账单.doc";
  14424. //获取模板
  14425. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14426. //载入模板
  14427. Document doc = new Document(tmppath);
  14428. decimal TotalPrice = 0.00M;
  14429. string itemStr = string.Empty;
  14430. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14431. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14432. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14433. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14434. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14435. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14436. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14437. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14438. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14439. foreach (var cost in groupCostType)
  14440. {
  14441. var List = cost.ToList();
  14442. if (cost.Key == "A")
  14443. {
  14444. foreach (var ListItem in List)
  14445. {
  14446. if (ListItem.number > 0)
  14447. {
  14448. if (ListItem.code.Contains("TBR"))
  14449. {
  14450. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14451. }
  14452. else
  14453. {
  14454. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14455. }
  14456. TotalPrice += (ListItem.number * ListItem.price);
  14457. }
  14458. }
  14459. }
  14460. else
  14461. {
  14462. itemStr = itemStr.Insert(0, "A段\r\n");
  14463. itemStr += "B段\r\n";
  14464. foreach (var ListItem in List)
  14465. {
  14466. if (ListItem.number > 0)
  14467. {
  14468. if (ListItem.code.Contains("TBR"))
  14469. {
  14470. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14471. }
  14472. else
  14473. {
  14474. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14475. }
  14476. TotalPrice += (ListItem.number * ListItem.price);
  14477. }
  14478. }
  14479. }
  14480. }
  14481. #region 替换Word模板书签内容
  14482. Dictionary<string, string> marks = new Dictionary<string, string>();
  14483. marks.Add("To", di.ClientUnit);//付款方
  14484. marks.Add("ToTel", di.TellPhone);//付款方电话
  14485. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14486. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14487. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14488. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14489. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14490. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14491. marks.Add("PayItemContent", itemStr);//详细信息
  14492. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14493. #endregion
  14494. ////注
  14495. //if (doc.Range.Bookmarks["Attention"] != null)
  14496. //{
  14497. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14498. // mark.Text = frList[0].Attention;
  14499. //}
  14500. foreach (var item in marks.Keys)
  14501. {
  14502. if (doc.Range.Bookmarks[item] != null)
  14503. {
  14504. Bookmark mark = doc.Range.Bookmarks[item];
  14505. mark.Text = marks[item];
  14506. }
  14507. }
  14508. byte[] bytes = null;
  14509. using (MemoryStream stream = new MemoryStream())
  14510. {
  14511. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14512. bytes = stream.ToArray();
  14513. }
  14514. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14515. return Ok(JsonView(true, "", new
  14516. {
  14517. Data = bytes,
  14518. strFileName,
  14519. }));
  14520. }
  14521. else
  14522. {
  14523. return Ok(JsonView(false, "团组信息不存在!"));
  14524. }
  14525. }
  14526. /// <summary>
  14527. /// 导出团组成本
  14528. /// </summary>
  14529. /// <param name="dto"></param>
  14530. /// <returns></returns>
  14531. [HttpPost]
  14532. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14533. {
  14534. var jw = JsonView(false);
  14535. if (dto.Diid == 0)
  14536. {
  14537. return Ok(JsonView(false, "请传递团组id"));
  14538. }
  14539. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14540. if (deleInfo.Code != 0)
  14541. {
  14542. return Ok(JsonView(false, "团组信息查询失败!"));
  14543. }
  14544. var di = deleInfo.Data as DelegationInfoWebView;
  14545. if (di == null)
  14546. {
  14547. return Ok(JsonView(false, "团组信息查询失败!"));
  14548. }
  14549. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14550. WorkbookDesigner designer = new WorkbookDesigner();
  14551. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14552. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14553. List<int> hideColumnList = new List<int>();
  14554. var ColumnSetting = new[]
  14555. {
  14556. new { tag = "VF", Index = 4, P = "CarCost" },
  14557. new { tag = "VN", Index = 5, P = "CarNumber" },
  14558. new { tag = "VRD", Index = 6, P = "CarTiming" },
  14559. new { tag = "T/G S", Index = 7, P = "TGS" },
  14560. new { tag = "TGWH", Index = 8, P = "TGWH" },
  14561. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  14562. new { tag = "T/G M", Index = 10, P = "TGM" },
  14563. new { tag = "T/G A", Index = 11, P = "TGA" },
  14564. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  14565. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  14566. new { tag = "C/F S", Index = 14, P = "CFS" },
  14567. new { tag = "C/F M", Index = 15, P = "CFM" },
  14568. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  14569. new { tag = "B", Index = 17, P = "B" },
  14570. new { tag = "L", Index = 18, P = "L" },
  14571. new { tag = "D", Index = 19, P = "D" },
  14572. new { tag = "TBR", Index = 20, P = "TBR" },
  14573. new { tag = "SGR", Index = 21, P = "SGR" },
  14574. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  14575. new { tag = "Suite", Index = 23, P = "Suite" },
  14576. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  14577. new { tag = "T/V", Index = 25, P = "TV" },
  14578. new { tag = "1/L", Index = 26, P = "iL" },
  14579. new { tag = "I/F", Index = 27, P = "IF" },
  14580. new { tag = "EF", Index = 28, P = "EF" },
  14581. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  14582. new { tag = "TE", Index = 30, P = "TE" },
  14583. new { tag = "T/G T", Index = 31, P = "TGTips" },
  14584. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  14585. new { tag = "P/C", Index = 33, P = "PC" },
  14586. new { tag = "T/L F", Index = 34, P = "TLF" },
  14587. new { tag = "E/C T", Index = 35, P = "ECT" }
  14588. };
  14589. Func<string, bool> isEmpty = (str) =>
  14590. {
  14591. if (decimal.TryParse(str,out decimal str_De) && str_De == 0)
  14592. {
  14593. return true;
  14594. }
  14595. if (string.IsNullOrWhiteSpace(str))
  14596. {
  14597. return true;
  14598. }
  14599. return false;
  14600. };
  14601. for (int i = 0; i < List_GC.Count; i++)
  14602. {
  14603. GroupCost_Excel gc = new GroupCost_Excel();
  14604. gc.Id = List_GC[i].Id;
  14605. gc.Diid = List_GC[i].Diid.ToString();
  14606. gc.DAY = List_GC[i].DAY;
  14607. string week = "";
  14608. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14609. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14610. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14611. gc.ITIN = List_GC[i].ITIN;
  14612. gc.CarType = List_GC[i].CarType;
  14613. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  14614. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  14615. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  14616. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  14617. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  14618. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  14619. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  14620. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  14621. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  14622. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  14623. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  14624. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  14625. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  14626. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  14627. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  14628. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  14629. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  14630. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  14631. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  14632. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  14633. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  14634. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  14635. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  14636. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  14637. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  14638. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  14639. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  14640. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  14641. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  14642. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  14643. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  14644. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  14645. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  14646. gc.EFR = List_GC[i].EFR;
  14647. List_GC1.Add(gc);
  14648. }
  14649. if (List_GC1.Count > 0)
  14650. {
  14651. var p = List_GC1[0];
  14652. var prs = p.GetType().GetProperties();
  14653. foreach (var item in prs)
  14654. {
  14655. var tp = item.PropertyType;
  14656. if (tp == typeof(int))
  14657. {
  14658. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  14659. if (val == 0)
  14660. {
  14661. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14662. if (columnSetting != null)
  14663. {
  14664. hideColumnList.Add(columnSetting.Index);
  14665. }
  14666. }
  14667. }
  14668. if (tp == typeof(decimal))
  14669. {
  14670. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  14671. if (val == 0)
  14672. {
  14673. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14674. if (columnSetting != null)
  14675. {
  14676. hideColumnList.Add(columnSetting.Index);
  14677. }
  14678. }
  14679. }
  14680. if (tp == typeof(string))
  14681. {
  14682. var val = List_GC1.Sum(x =>
  14683. {
  14684. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  14685. if (decimal.TryParse(str , out decimal str_De))
  14686. {
  14687. return str_De;
  14688. }
  14689. else
  14690. {
  14691. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  14692. }
  14693. });
  14694. if (val == 0)
  14695. {
  14696. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  14697. if (columnSetting != null)
  14698. {
  14699. hideColumnList.Add(columnSetting.Index);
  14700. }
  14701. }
  14702. }
  14703. }
  14704. }
  14705. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14706. dt.TableName = "TB";
  14707. //报表标题等不用dt的值
  14708. designer.SetDataSource("TeamName", dto.title.TeamName);
  14709. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14710. designer.SetDataSource("Tax", dto.title.Tax);
  14711. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14712. designer.SetDataSource("Currency", dto.title.Currency);
  14713. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14714. designer.SetDataSource("Rate", dto.title.Rate);
  14715. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14716. var Aparams = hotels.Find(x => x.Type == "Default");
  14717. if (Aparams == null)
  14718. {
  14719. return Ok(jw);
  14720. }
  14721. //酒店数量
  14722. var txtSGRNumber = Aparams.SGR.ToString();
  14723. var txtTBRNumber = Aparams.TBR.ToString();
  14724. var txtJSESNumber = Aparams.JSES.ToString();
  14725. var txtSUITENumbe = Aparams.SUITE.ToString();
  14726. if (dto.costType == "B")
  14727. {
  14728. Aparams = hotels.Find(x => x.Type == "A");
  14729. var Bparams = hotels.Find(x => x.Type == "B");
  14730. if (Aparams == null || Bparams == null)
  14731. {
  14732. return Ok(jw);
  14733. }
  14734. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14735. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14736. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14737. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14738. }
  14739. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14740. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14741. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14742. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14743. var ws = designer.Workbook.Worksheets[1];
  14744. int Row = List_GC.Count;
  14745. int startIndex = 0;
  14746. int HideRows = 0;
  14747. Row = 0;
  14748. List<int> hideRowsList = new List<int>();
  14749. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14750. #region A段left数据
  14751. var left = dto.leftInfo.Find(x => x.Type == "A");
  14752. if (left == null)
  14753. {
  14754. return Ok(jw);
  14755. }
  14756. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14757. if (leftBindData != null)
  14758. {
  14759. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14760. designer.SetDataSource("VisaRS", leftBindData.rs);
  14761. designer.SetDataSource("VisaXS", leftBindData.xs);
  14762. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14763. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14764. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14765. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14766. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14767. }
  14768. else
  14769. {
  14770. hideRowsList.Add(Row + startIndex + HideRows);
  14771. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14772. }
  14773. HideRows += 2;
  14774. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14775. if (leftBindData != null)
  14776. {
  14777. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14778. designer.SetDataSource("BXRS", leftBindData.rs);
  14779. designer.SetDataSource("BXXS", leftBindData.xs);
  14780. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14781. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14782. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14783. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14784. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14785. }
  14786. else
  14787. {
  14788. hideRowsList.Add(Row + startIndex + HideRows);
  14789. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14790. }
  14791. HideRows += 2;
  14792. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14793. if (leftBindData != null)
  14794. {
  14795. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14796. designer.SetDataSource("HSRS", leftBindData.rs);
  14797. designer.SetDataSource("HSXS", leftBindData.xs);
  14798. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14799. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14800. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14801. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14802. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14803. }
  14804. else
  14805. {
  14806. hideRowsList.Add(Row + startIndex + HideRows);
  14807. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14808. }
  14809. HideRows += 2;
  14810. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14811. if (leftBindData != null)
  14812. {
  14813. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14814. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14815. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14816. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14817. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14818. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14819. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14820. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14821. }
  14822. else
  14823. {
  14824. hideRowsList.Add(Row + startIndex + HideRows);
  14825. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14826. }
  14827. HideRows += 2;
  14828. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14829. if (leftBindData != null)
  14830. {
  14831. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14832. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14833. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14834. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14835. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14836. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14837. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14838. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14839. }
  14840. else
  14841. {
  14842. hideRowsList.Add(Row + startIndex + HideRows);
  14843. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14844. }
  14845. HideRows += 2;
  14846. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14847. if (leftBindData != null)
  14848. {
  14849. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14850. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14851. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14852. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14853. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14854. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14855. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14856. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14857. }
  14858. else
  14859. {
  14860. hideRowsList.Add(Row + startIndex + HideRows);
  14861. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14862. }
  14863. HideRows += 2;
  14864. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14865. if (leftBindData != null)
  14866. {
  14867. ////TBR
  14868. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14869. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14870. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14871. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14872. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14873. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14874. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14875. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14876. }
  14877. else
  14878. {
  14879. hideRowsList.Add(Row + startIndex + HideRows);
  14880. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14881. }
  14882. HideRows += 2;
  14883. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14884. if (leftBindData != null)
  14885. {
  14886. ////SGR
  14887. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14888. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14889. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14890. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14891. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14892. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14893. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14894. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14895. }
  14896. else
  14897. {
  14898. hideRowsList.Add(Row + startIndex + HideRows);
  14899. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14900. }
  14901. HideRows += 2;
  14902. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14903. if (leftBindData != null)
  14904. {
  14905. ////JS/ES
  14906. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14907. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14908. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14909. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14910. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14911. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14912. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14913. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14914. }
  14915. else
  14916. {
  14917. hideRowsList.Add(Row + startIndex + HideRows);
  14918. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14919. }
  14920. HideRows += 2;
  14921. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14922. if (leftBindData != null)
  14923. {
  14924. ////SUITE
  14925. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14926. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14927. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14928. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14929. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14930. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14931. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14932. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14933. }
  14934. else
  14935. {
  14936. hideRowsList.Add(Row + startIndex + HideRows);
  14937. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14938. }
  14939. HideRows += 2;
  14940. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14941. if (leftBindData != null)
  14942. {
  14943. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14944. designer.SetDataSource("DJRS", leftBindData.rs);
  14945. designer.SetDataSource("DJXS", leftBindData.xs);
  14946. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14947. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14948. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14949. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14950. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14951. }
  14952. else
  14953. {
  14954. hideRowsList.Add(Row + startIndex + HideRows);
  14955. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14956. }
  14957. HideRows += 2;
  14958. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14959. if (leftBindData != null)
  14960. {
  14961. designer.SetDataSource("HCPCB", leftBindData.cb);
  14962. designer.SetDataSource("HCPRS", leftBindData.rs);
  14963. designer.SetDataSource("HCPXS", leftBindData.xs);
  14964. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14965. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14966. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14967. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14968. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14969. }
  14970. else
  14971. {
  14972. hideRowsList.Add(Row + startIndex + HideRows);
  14973. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14974. }
  14975. HideRows += 2;
  14976. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14977. if (leftBindData != null)
  14978. {
  14979. designer.SetDataSource("CPCB", leftBindData.cb);
  14980. designer.SetDataSource("CPRS", leftBindData.rs);
  14981. designer.SetDataSource("CPXS", leftBindData.xs);
  14982. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14983. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14984. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14985. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14986. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14987. }
  14988. else
  14989. {
  14990. hideRowsList.Add(Row + startIndex + HideRows);
  14991. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14992. }
  14993. HideRows += 2;
  14994. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14995. if (leftBindData != null)
  14996. {
  14997. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14998. designer.SetDataSource("GWRS", leftBindData.rs);
  14999. designer.SetDataSource("GWXS", leftBindData.xs);
  15000. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15001. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15002. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15003. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15004. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15005. }
  15006. else
  15007. {
  15008. hideRowsList.Add(Row + startIndex + HideRows);
  15009. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15010. }
  15011. HideRows += 2;
  15012. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15013. if (leftBindData != null)
  15014. {
  15015. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  15016. designer.SetDataSource("LYJRS", leftBindData.rs);
  15017. designer.SetDataSource("LYJXS", leftBindData.xs);
  15018. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15019. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15020. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15021. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15022. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15023. }
  15024. else
  15025. {
  15026. hideRowsList.Add(Row + startIndex + HideRows);
  15027. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15028. }
  15029. #endregion
  15030. #region A段Right信息
  15031. var right = dto.rightInfo.Find(x => x.Type == "A");
  15032. if (right == null)
  15033. {
  15034. return Ok(jw);
  15035. }
  15036. HideRows += 4;
  15037. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15038. if (rightBindData != null)
  15039. {
  15040. //经济舱 + 双人间 TBR
  15041. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  15042. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  15043. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15044. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  15045. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15046. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15047. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15048. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15049. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15050. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15051. }
  15052. else
  15053. {
  15054. hideRowsList.Add(Row + startIndex + HideRows);
  15055. }
  15056. HideRows += 2;
  15057. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15058. if (rightBindData != null)
  15059. {
  15060. //经济舱 + 单人间 SGR
  15061. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  15062. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  15063. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15064. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  15065. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15066. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15067. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15068. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15069. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15070. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15071. }
  15072. else
  15073. {
  15074. hideRowsList.Add(Row + startIndex + HideRows);
  15075. }
  15076. HideRows += 2;
  15077. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15078. if (rightBindData != null)
  15079. {
  15080. //公务舱 + 单人间 SGR
  15081. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  15082. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  15083. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15084. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  15085. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15086. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15087. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15088. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15089. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15090. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15091. }
  15092. else
  15093. {
  15094. hideRowsList.Add(Row + startIndex + HideRows);
  15095. }
  15096. HideRows += 2;
  15097. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15098. if (rightBindData != null)
  15099. {
  15100. //公务舱 + 小套房 JSES
  15101. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  15102. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  15103. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15104. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  15105. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15106. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15107. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15108. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15109. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15110. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15111. }
  15112. else
  15113. {
  15114. hideRowsList.Add(Row + startIndex + HideRows);
  15115. }
  15116. HideRows += 2;
  15117. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15118. if (rightBindData != null)
  15119. {
  15120. //公务舱 + 小套房 JSES
  15121. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  15122. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  15123. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15124. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  15125. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15126. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15127. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15128. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15129. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15130. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15131. }
  15132. else
  15133. {
  15134. hideRowsList.Add(Row + startIndex + HideRows);
  15135. }
  15136. HideRows += 2;
  15137. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15138. if (rightBindData != null)
  15139. {
  15140. //经济舱 + 大套房
  15141. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  15142. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  15143. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15144. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  15145. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15146. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15147. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15148. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15149. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15150. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15151. }
  15152. else
  15153. {
  15154. hideRowsList.Add(Row + startIndex + HideRows);
  15155. }
  15156. HideRows += 2;
  15157. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15158. if (rightBindData != null)
  15159. {
  15160. //头等舱 + 小套房 JSES
  15161. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15162. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15163. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15164. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15165. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15166. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15167. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15168. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15169. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15170. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15171. }
  15172. else
  15173. {
  15174. hideRowsList.Add(Row + startIndex + HideRows);
  15175. }
  15176. HideRows += 2;
  15177. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15178. if (rightBindData != null)
  15179. {
  15180. //头等舱 + 大套房
  15181. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15182. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15183. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15184. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15185. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15186. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15187. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15188. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15189. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15190. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15191. }
  15192. else
  15193. {
  15194. hideRowsList.Add(Row + startIndex + HideRows);
  15195. }
  15196. #endregion
  15197. #region B段标题清空
  15198. designer.SetDataSource("CostBDRCB", "");
  15199. designer.SetDataSource("CostBRS", "");
  15200. designer.SetDataSource("CostBXS", "");
  15201. designer.SetDataSource("CostBZCB", "");
  15202. designer.SetDataSource("CostBDRBJ", "");
  15203. designer.SetDataSource("CostBZBJ", "");
  15204. designer.SetDataSource("CostBDRLR", "");
  15205. designer.SetDataSource("CostBZLR", "");
  15206. designer.SetDataSource("CostBDRCBOM", "");
  15207. designer.SetDataSource("CostBRSOM", "");
  15208. designer.SetDataSource("CostBZCBOM", "");
  15209. designer.SetDataSource("CostBDRBJOM", "");
  15210. designer.SetDataSource("CostBZBJOM", "");
  15211. designer.SetDataSource("CostBDRLROM", "");
  15212. designer.SetDataSource("CostBZLROM", "");
  15213. #endregion
  15214. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15215. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15216. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15217. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15218. designer.SetDataSource("DJName", "地接(CNY)");
  15219. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15220. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15221. designer.SetDataSource("GWName", "公务(CNY)");
  15222. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15223. designer.SetDataSource("LYJName", "零用金(CNY)");
  15224. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15225. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15226. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15227. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15228. designer.SetDataSource("BXName", "保险(CNY)");
  15229. designer.SetDataSource("VisaName", "签证(CNY)");
  15230. #region B段基本数据
  15231. if (dto.costType == "B")
  15232. {
  15233. left = dto.leftInfo.Find(x => x.Type == "B");
  15234. if (left == null)
  15235. {
  15236. return Ok(jw);
  15237. }
  15238. #region B段left数据
  15239. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15240. if (leftBindData != null)
  15241. {
  15242. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15243. designer.SetDataSource("BHSRS", leftBindData.rs);
  15244. designer.SetDataSource("BHSXS", leftBindData.xs);
  15245. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15246. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15247. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15248. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15249. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15250. }
  15251. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15252. if (leftBindData != null)
  15253. {
  15254. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15255. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15256. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15257. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15258. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15259. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15260. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15261. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15262. }
  15263. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15264. if (leftBindData != null)
  15265. {
  15266. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15267. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15268. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15269. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15270. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15271. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15272. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15273. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15274. }
  15275. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15276. if (leftBindData != null)
  15277. {
  15278. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15279. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15280. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15281. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15282. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15283. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15284. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15285. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15286. }
  15287. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15288. if (leftBindData != null)
  15289. {
  15290. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15291. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15292. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15293. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15294. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15295. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15296. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15297. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15298. }
  15299. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15300. if (leftBindData != null)
  15301. {
  15302. designer.SetDataSource("BCPCB", leftBindData.cb);
  15303. designer.SetDataSource("BCPRS", leftBindData.rs);
  15304. designer.SetDataSource("BCPXS", leftBindData.xs);
  15305. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15306. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15307. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15308. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15309. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15310. }
  15311. //TBR
  15312. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15313. if (leftBindData != null)
  15314. {
  15315. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15316. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15317. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15318. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15319. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15320. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15321. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15322. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15323. }
  15324. //SGR
  15325. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15326. if (leftBindData != null)
  15327. {
  15328. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15329. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15330. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15331. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15332. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15333. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15334. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15335. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15336. }
  15337. //JS/ES
  15338. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15339. if (leftBindData != null)
  15340. {
  15341. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15342. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15343. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15344. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15345. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15346. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15347. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15348. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15349. }
  15350. //SUITE
  15351. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15352. if (leftBindData != null)
  15353. {
  15354. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15355. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15356. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15357. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15358. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15359. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15360. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15361. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15362. }
  15363. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15364. if (leftBindData != null)
  15365. {
  15366. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15367. designer.SetDataSource("BDJRS", leftBindData.rs);
  15368. designer.SetDataSource("BDJXS", leftBindData.xs);
  15369. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15370. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15371. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15372. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15373. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15374. }
  15375. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15376. if (leftBindData != null)
  15377. {
  15378. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15379. designer.SetDataSource("BGWRS", leftBindData.rs);
  15380. designer.SetDataSource("BGWXS", leftBindData.xs);
  15381. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15382. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15383. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15384. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15385. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15386. }
  15387. #region 优化方案
  15388. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15389. //excelBind.Add("零用金", new {
  15390. //cb="",
  15391. //rs="",
  15392. //xs ="",
  15393. //zcb = "",
  15394. //});
  15395. #endregion
  15396. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15397. if (leftBindData != null)
  15398. {
  15399. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15400. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15401. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15402. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15403. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15404. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15405. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15406. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15407. }
  15408. #endregion
  15409. #region B段Right信息
  15410. right = dto.rightInfo.Find(x => x.Type == "B");
  15411. if (right == null)
  15412. {
  15413. return Ok(jw);
  15414. }
  15415. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15416. if (rightBindData != null)
  15417. {
  15418. //经济舱 + 双人间 TBR
  15419. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15420. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15421. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15422. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15423. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15424. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15425. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15426. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15427. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15428. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15429. }
  15430. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15431. if (rightBindData != null)
  15432. {
  15433. //经济舱 + 单人间 SGR
  15434. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15435. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15436. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15437. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15438. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15439. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15440. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15441. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15442. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15443. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15444. }
  15445. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15446. if (rightBindData != null)
  15447. {
  15448. //公务舱 + 单人间 SGR
  15449. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15450. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15451. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15452. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15453. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15454. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15455. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15456. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15457. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15458. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15459. }
  15460. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15461. if (rightBindData != null)
  15462. {
  15463. //公务舱 + 小套房 JSES
  15464. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15465. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15466. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15467. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15468. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15469. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15470. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15471. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15472. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15473. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15474. }
  15475. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15476. if (rightBindData != null)
  15477. {
  15478. //公务舱 + 小套房 JSES
  15479. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15480. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15481. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15482. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15483. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15484. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15485. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15486. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15487. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15488. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15489. }
  15490. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15491. if (rightBindData != null)
  15492. {
  15493. //经济舱 + 大套房
  15494. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15495. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15496. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15497. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15498. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15499. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15500. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15501. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15502. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15503. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15504. }
  15505. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15506. if (rightBindData != null)
  15507. {
  15508. //头等舱 + 小套房 JSES
  15509. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15510. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15511. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15512. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15513. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15514. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15515. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15516. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15517. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15518. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15519. }
  15520. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15521. if (rightBindData != null)
  15522. {
  15523. //头等舱 + 大套房
  15524. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15525. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15526. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15527. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15528. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15529. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15530. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15531. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15532. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15533. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15534. }
  15535. #endregion
  15536. #region 标题
  15537. designer.SetDataSource("CostBDRCB", "单人成本");
  15538. designer.SetDataSource("CostBRS", "人数");
  15539. designer.SetDataSource("CostBXS", "系数");
  15540. designer.SetDataSource("CostBZCB", "总成本");
  15541. designer.SetDataSource("CostBDRBJ", "单人报价");
  15542. designer.SetDataSource("CostBZBJ", "总报价");
  15543. designer.SetDataSource("CostBDRLR", "单人利润");
  15544. designer.SetDataSource("CostBZLR", "总利润");
  15545. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15546. designer.SetDataSource("CostBRSOM", "人数");
  15547. designer.SetDataSource("CostBZCBOM", "总成本");
  15548. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15549. designer.SetDataSource("CostBZBJOM", "总报价");
  15550. designer.SetDataSource("CostBDRLROM", "单人利润");
  15551. designer.SetDataSource("CostBZLROM", "总利润");
  15552. #endregion
  15553. }
  15554. #endregion
  15555. designer.SetDataSource("TzZCB2", TzZCB2);
  15556. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15557. designer.SetDataSource("TzZLR2", TzZLR2);
  15558. string[] dataSourceKeys = new string[]
  15559. {
  15560. "VF",
  15561. "TGS",
  15562. "TGOF",
  15563. "TGM",
  15564. "TGA",
  15565. "TGTF",
  15566. "TGEF",
  15567. "CFM",
  15568. "CFOF",
  15569. "B",
  15570. "L",
  15571. "D",
  15572. "TBR",
  15573. "SGR",
  15574. "JSES",
  15575. "Suite",
  15576. "TV",
  15577. "1L",
  15578. "IF",
  15579. "EF",
  15580. "BRF",
  15581. "TE",
  15582. "TGT",
  15583. "DRVT",
  15584. "PC",
  15585. "TLF",
  15586. "ECT"
  15587. };
  15588. foreach (var item in dataSourceKeys)
  15589. {
  15590. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  15591. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  15592. var find = dto.titleModel.FirstOrDefault(expr);
  15593. if (find != null)
  15594. {
  15595. designer.SetDataSource(item, find.text);
  15596. }
  15597. else
  15598. {
  15599. designer.SetDataSource(item, 0);
  15600. }
  15601. }
  15602. designer.SetDataSource(dt);
  15603. //根据数据源处理生成报表内容
  15604. designer.Process();
  15605. designer.Workbook.Worksheets[0].Name = "费用明细";
  15606. designer.Workbook.Worksheets[1].Name = "费用总核算";
  15607. Worksheet sheet = designer.Workbook.Worksheets[0];
  15608. foreach (var Rowindex in hideRowsList)
  15609. {
  15610. ws.Cells.HideRows(Rowindex, 2);
  15611. }
  15612. ws = designer.Workbook.Worksheets[0];
  15613. foreach (var Column in hideColumnList)
  15614. {
  15615. ws.Cells.HideColumns(Column, 1);
  15616. }
  15617. byte[] bytes = null;
  15618. string strFileName = di.TeamName + "-团组-成本.xls";
  15619. using (MemoryStream stream = new MemoryStream())
  15620. {
  15621. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15622. bytes = stream.ToArray();
  15623. }
  15624. return Ok(JsonView(true, "", new
  15625. {
  15626. Data = bytes,
  15627. strFileName,
  15628. }));
  15629. }
  15630. /// <summary>
  15631. /// 导出客户报表
  15632. /// </summary>
  15633. /// <returns></returns>
  15634. [HttpPost]
  15635. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15636. {
  15637. var jw = JsonView(false);
  15638. if (dto.Diid == 0)
  15639. {
  15640. return Ok(JsonView(false, "请传递团组id"));
  15641. }
  15642. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15643. if (deleInfo.Code != 0)
  15644. {
  15645. return Ok(JsonView(false, "团组信息查询失败!"));
  15646. }
  15647. var di = deleInfo.Data as DelegationInfoWebView;
  15648. if (di == null)
  15649. {
  15650. return Ok(JsonView(false, "团组信息查询失败!"));
  15651. }
  15652. //文件名
  15653. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15654. //获取模板
  15655. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15656. //载入模板
  15657. Document doc = new Document(tmppath);
  15658. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15659. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15660. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15661. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15662. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15663. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15664. if (AParameter == null)
  15665. {
  15666. return Ok(JsonView(false, "系数不存在!"));
  15667. }
  15668. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15669. , TzAirDesc, TzZCost;
  15670. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15671. = TzAirDesc = TzZCost = string.Empty;
  15672. TzNumber = AParameter.CostTypenumber.ToString();
  15673. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15674. CarGuides1 = dto.CarGuides1;
  15675. Meal = dto.Meal;
  15676. SubsidizedMeals = dto.SubsidizedMeals;
  15677. NightRepair = dto.NightRepair;
  15678. AttractionsTickets = dto.AttractionsTickets;
  15679. MiscellaneousFees = dto.MiscellaneousFees;
  15680. ATip = dto.ATip;
  15681. TzHotelDesc = "";
  15682. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15683. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15684. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15685. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15686. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15687. TzAirDesc = "";
  15688. TzZCost = dto.TzZCost;
  15689. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15690. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15691. var index = 1;
  15692. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15693. foreach (var item in TzHotelDescArr)
  15694. {
  15695. if (AinfoArr != null)
  15696. {
  15697. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15698. if (Ainfo != null)
  15699. {
  15700. if (int.Parse(Ainfo.rs) <= 0)
  15701. {
  15702. continue;
  15703. }
  15704. var hotelText = string.Empty;
  15705. switch (item)
  15706. {
  15707. case "SGR":
  15708. hotelText = "单人间";
  15709. break;
  15710. case "JSES":
  15711. hotelText = "小套房";
  15712. break;
  15713. case "SUITE":
  15714. hotelText = "套房";
  15715. break;
  15716. case "TBR":
  15717. hotelText = "双人间";
  15718. break;
  15719. }
  15720. if (item != "TBR")
  15721. {
  15722. 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";
  15723. }
  15724. else
  15725. {
  15726. 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";
  15727. }
  15728. index++;
  15729. }
  15730. }
  15731. }
  15732. index = 1;
  15733. foreach (var item in TzAirDescArr)
  15734. {
  15735. if (AinfoArr != null)
  15736. {
  15737. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15738. if (Ainfo != null)
  15739. {
  15740. if (int.Parse(Ainfo.rs) <= 0)
  15741. {
  15742. continue;
  15743. }
  15744. 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";
  15745. index++;
  15746. }
  15747. }
  15748. }
  15749. if (dto.costType == "B")
  15750. {
  15751. if (BParameter == null)
  15752. {
  15753. return Ok(JsonView(false, "B段系数不存在!"));
  15754. }
  15755. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15756. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15757. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15758. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15759. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15760. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15761. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15762. foreach (var item in TzHotelDescArr)
  15763. {
  15764. if (AinfoArr != null)
  15765. {
  15766. TzHotelDesc += "B段信息 \r\n";
  15767. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15768. if (Ainfo != null)
  15769. {
  15770. if (int.Parse(Ainfo.rs) <= 0)
  15771. {
  15772. continue;
  15773. }
  15774. var hotelText = string.Empty;
  15775. switch (item)
  15776. {
  15777. case "SGR":
  15778. hotelText = "单人间";
  15779. break;
  15780. case "JSES":
  15781. hotelText = "小套房";
  15782. break;
  15783. case "SUITE":
  15784. hotelText = "套房";
  15785. break;
  15786. case "TBR":
  15787. hotelText = "双人间";
  15788. break;
  15789. }
  15790. if (item != "TBR")
  15791. {
  15792. 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";
  15793. }
  15794. else
  15795. {
  15796. 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";
  15797. }
  15798. index++;
  15799. }
  15800. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15801. }
  15802. }
  15803. index = 1;
  15804. foreach (var item in TzAirDescArr)
  15805. {
  15806. if (AinfoArr != null)
  15807. {
  15808. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15809. if (Ainfo != null)
  15810. {
  15811. if (int.Parse(Ainfo.rs) <= 0)
  15812. {
  15813. continue;
  15814. }
  15815. 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";
  15816. index++;
  15817. }
  15818. }
  15819. }
  15820. }
  15821. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15822. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15823. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15824. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15825. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15826. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15827. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15828. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15829. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15830. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15831. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15832. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15833. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15834. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15835. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15836. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15837. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15838. DickeyValue.Add("TzZCost", TzZCost);
  15839. foreach (var key in DickeyValue.Keys)
  15840. {
  15841. if (doc.Range.Bookmarks[key] != null)
  15842. {
  15843. Bookmark mark = doc.Range.Bookmarks[key];
  15844. mark.Text = DickeyValue[key];
  15845. }
  15846. }
  15847. byte[] bytes = null;
  15848. string strFileName = di.TeamName + "-客户报价.doc";
  15849. using (MemoryStream stream = new MemoryStream())
  15850. {
  15851. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15852. bytes = stream.ToArray();
  15853. }
  15854. return Ok(JsonView(true, "", new
  15855. {
  15856. Data = bytes,
  15857. strFileName,
  15858. }));
  15859. }
  15860. /// <summary>
  15861. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15862. /// </summary>
  15863. /// <param name="dto"></param>
  15864. /// <returns></returns>
  15865. [HttpPost]
  15866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15867. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15868. {
  15869. try
  15870. {
  15871. #region 参数验证
  15872. if (dto.DiId < 0)
  15873. {
  15874. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15875. }
  15876. List<int> cTableIds = new List<int>() {
  15877. 76 ,//酒店预订
  15878. 77 ,//行程
  15879. 79 ,//车/导游地接
  15880. 80 ,//签证
  15881. 81 ,//邀请/公务活
  15882. 82 ,//团组客户保险
  15883. 85 ,//机票预订
  15884. 98 ,//其他款项
  15885. 285 ,//收款退还
  15886. 751 ,//酒店早餐
  15887. 1015 // 超支费用
  15888. };
  15889. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15890. {
  15891. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15892. }
  15893. #endregion
  15894. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15895. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15896. if (_GroupCostParameters.Count <= 0)
  15897. {
  15898. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15899. }
  15900. if (_GroupCostParameters[0].IsShare == 0)
  15901. {
  15902. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15903. }
  15904. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15905. //处理date为空问题
  15906. if (_GroupCosts.Count > 0)
  15907. {
  15908. for (int i = 0; i < _GroupCosts.Count; i++)
  15909. {
  15910. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15911. {
  15912. if (i > 0)
  15913. {
  15914. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15915. }
  15916. }
  15917. }
  15918. }
  15919. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15920. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15921. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15922. string currCode = "";
  15923. #region currCode 验证
  15924. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15925. if (isInt)
  15926. {
  15927. var currData = currDatas.Find(it => it.Id == intCurrency);
  15928. if (currData != null)
  15929. {
  15930. currCode = currData.Name;
  15931. }
  15932. }
  15933. else
  15934. {
  15935. currCode = _GroupCostParameters[0].Currency.Trim();
  15936. }
  15937. #endregion
  15938. //op,酒店单段模式存储
  15939. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15940. {
  15941. CurrencyCode = currCode,
  15942. Rate = _GroupCostParameters[0].Rate,
  15943. CostType = _GroupCostParameters[0].CostType,
  15944. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15945. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15946. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15947. };
  15948. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15949. if (_GroupCostParameters.Count == 2)
  15950. {
  15951. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15952. }
  15953. foreach (var item in _GroupCostParameters)
  15954. {
  15955. decimal _rate = 1;
  15956. decimal _rate1 = item.Rate;
  15957. decimal _scale = 1;
  15958. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15959. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15960. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15961. //if (userInfo != null)
  15962. //{
  15963. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15964. // {
  15965. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15966. // {
  15967. // _scale = 1.00M;
  15968. // }
  15969. // }
  15970. //}
  15971. #endregion
  15972. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15973. {
  15974. CurrencyCode = currCode,
  15975. Rate = _rate1,
  15976. CostType = item.CostType,
  15977. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15978. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15979. CostTypeNumber = item.CostTypenumber
  15980. };
  15981. if (_GroupCostParameters.Count > 1)
  15982. {
  15983. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15984. }
  15985. else
  15986. {
  15987. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15988. }
  15989. if (dto.CTable == 79)//
  15990. {
  15991. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15992. modulePromptInfo.TotalCost = item.DJCB;
  15993. }
  15994. List<string> costTypes = new List<string>() { "A", "B" };
  15995. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15996. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15997. if (_GroupCostsDuplicates.Count() == 1)
  15998. {
  15999. _GroupCostsTypeData = _GroupCosts;
  16000. }
  16001. else
  16002. {
  16003. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  16004. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  16005. }
  16006. /*
  16007. * 76 酒店预订
  16008. * 77 行程
  16009. * 79 车/导游地接
  16010. * 80 签证
  16011. * 81 邀请/公务活动
  16012. * 82 团组客户保险
  16013. * 85 机票预订
  16014. * 98 其他款项
  16015. * 285 收款退还
  16016. * 751 酒店早餐
  16017. * 1015 超支费用
  16018. */
  16019. switch (dto.CTable)
  16020. {
  16021. case 76: // 酒店预订
  16022. _ModuleSubPromptInfo.AddRange(
  16023. _GroupCostsTypeData.Select(it => new
  16024. {
  16025. it.DAY,
  16026. it.Date,
  16027. it.ACCON,
  16028. it.ITIN,
  16029. it.SGR,
  16030. it.TBR,
  16031. it.JS_ES,
  16032. it.Suite
  16033. })
  16034. );
  16035. break;
  16036. case 79: // 车/导游地接
  16037. _ModuleSubPromptInfo.AddRange(
  16038. _GroupCostsTypeData.Select(it => new
  16039. {
  16040. Date = it.Date, //日期
  16041. CarFee = it.CarCost * _rate * _scale, //车费用
  16042. CarType = it.CarType, //车型
  16043. DriverFee = it.CFS * _rate * _scale, //司机工资
  16044. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  16045. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  16046. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  16047. GuideFee = it.TGS * _rate * _scale, //导游费用
  16048. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  16049. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  16050. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  16051. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  16052. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  16053. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  16054. Breakfast = it.B * _rate * _scale, //早餐费
  16055. Lunch = it.L * _rate * _scale, //午餐费
  16056. Dinner = it.D * _rate * _scale, //晚餐费
  16057. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  16058. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  16059. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  16060. TicketFee = it.EF * _rate * _scale, //门票费
  16061. TicketRemark = it.EFR, //门票费描述
  16062. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  16063. TravelSupplies = it.TE * _rate * _scale, //出行物资
  16064. SpentCash = it.PC * _rate * _scale, //零用金
  16065. LeadersFee = it.TLF * _rate * _scale, //领队费
  16066. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  16067. })
  16068. );
  16069. break;
  16070. case 85: // 机票
  16071. List<dynamic> datas = new List<dynamic>();
  16072. datas.Add(
  16073. new
  16074. {
  16075. AirType = "经济舱",
  16076. AirNum = item.JJCRS,
  16077. AirDRCB = item.JJCCB,
  16078. AirZCB = (item.JJCRS * item.JJCCB)
  16079. }
  16080. );
  16081. datas.Add(
  16082. new
  16083. {
  16084. AirType = "公务舱",
  16085. AirNum = item.GWCRS,
  16086. AirDRCB = item.GWCCB,
  16087. AirZCB = (item.GWCRS * item.GWCCB)
  16088. }
  16089. );
  16090. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16091. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  16092. modulePromptInfo.Data = new
  16093. {
  16094. airFeeData = datas,
  16095. airInitData = initDatas
  16096. };
  16097. _ModulePromptInfos.Add(modulePromptInfo);
  16098. break;
  16099. default:
  16100. break;
  16101. }
  16102. }
  16103. if (dto.CTable != 85)
  16104. {
  16105. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  16106. _ModulePromptInfos.Add(_ModulePromptInfo);
  16107. }
  16108. _view.ModulePromptInfos = _ModulePromptInfos;
  16109. return Ok(JsonView(true, "操作成功!", _view));
  16110. }
  16111. catch (Exception ex)
  16112. {
  16113. return Ok(JsonView(false, ex.Message));
  16114. }
  16115. }
  16116. /// <summary>
  16117. /// 根据黑屏代码重新生成行程
  16118. /// </summary>
  16119. /// <param name="dto"></param>
  16120. /// <returns></returns>
  16121. [HttpPost]
  16122. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  16123. {
  16124. var jw = JsonView(false, "Error");
  16125. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  16126. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  16127. .Select(x => new
  16128. {
  16129. x.Id,
  16130. x.Title
  16131. })
  16132. .ToList();
  16133. if (Create.Any())
  16134. {
  16135. jw.Msg = "获取成功!";
  16136. jw.Code = 200;
  16137. jw.Data = new
  16138. {
  16139. BlackCodeListSelect = Create,
  16140. blackCodeIsTrue = true
  16141. };
  16142. }
  16143. else
  16144. {
  16145. jw.Code = 400;
  16146. jw.Data = new
  16147. {
  16148. BlackCodeListSelect = Create,
  16149. blackCodeIsTrue = false,
  16150. };
  16151. }
  16152. return Ok(jw);
  16153. }
  16154. /// <summary>
  16155. /// 根据黑屏代码Id重新生成行程
  16156. /// </summary>
  16157. /// <param name="dto"></param>
  16158. /// <returns></returns>
  16159. [HttpPost]
  16160. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  16161. {
  16162. var jw = JsonView(false, "Error");
  16163. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16164. if (result.Code == 0)
  16165. {
  16166. jw.Msg = "获取成功!";
  16167. jw.Code = 200;
  16168. jw.Data = new
  16169. {
  16170. groupCost = result.Data,
  16171. blackCodeIsTrue = true
  16172. };
  16173. }
  16174. else
  16175. {
  16176. jw.Code = 400;
  16177. jw.Data = new
  16178. {
  16179. groupCost = result.Data,
  16180. blackCodeIsTrue = false,
  16181. };
  16182. }
  16183. return Ok(jw);
  16184. }
  16185. /// <summary>
  16186. /// 成本获取OP历史车费用
  16187. /// </summary>
  16188. /// <param name="dto"></param>
  16189. /// <returns></returns>
  16190. [HttpPost]
  16191. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16192. {
  16193. var jw = JsonView(false);
  16194. try
  16195. {
  16196. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16197. //获取现有所有车的数据
  16198. if (!dto.Param.IsNullOrWhiteSpace())
  16199. {
  16200. string sql = $@"
  16201. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16202. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16203. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16204. 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
  16205. AND gctggr.ServiceEndTime is not NULL
  16206. ORDER by gctggrc.id DESC
  16207. ";
  16208. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16209. var numeberResult = await Task.Run(() =>
  16210. {
  16211. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16212. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16213. return numberArr;
  16214. });
  16215. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16216. foreach (var item in numeberResult)
  16217. {
  16218. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16219. {
  16220. Country = "数据异常!",
  16221. City = string.Empty,
  16222. };
  16223. item.Area = find.Country + " " + find.City;
  16224. }
  16225. dbResult.AddRange(numeberResult);
  16226. if (dto.Param.Contains("、"))
  16227. {
  16228. var sp = dto.Param.Split("、");
  16229. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16230. .Where(x =>
  16231. {
  16232. return System.Array.Exists(sp, e =>
  16233. {
  16234. bool where = false;
  16235. if (x.Area != null)
  16236. {
  16237. where = x.Area.Contains(e);
  16238. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16239. {
  16240. return false;
  16241. }
  16242. }
  16243. if (x.PriceName != null && !where)
  16244. {
  16245. where = x.PriceName.Contains(e);
  16246. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16247. {
  16248. return false;
  16249. }
  16250. }
  16251. return where;
  16252. });
  16253. }).ToList();
  16254. }
  16255. else
  16256. {
  16257. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16258. .Where(x =>
  16259. {
  16260. bool where = false;
  16261. if (x.Area != null)
  16262. {
  16263. where = x.Area.Contains(dto.Param);
  16264. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16265. {
  16266. return false;
  16267. }
  16268. }
  16269. if (x.PriceName != null && !where)
  16270. {
  16271. where = x.PriceName.Contains(dto.Param);
  16272. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16273. {
  16274. return false;
  16275. }
  16276. }
  16277. return where;
  16278. }
  16279. )
  16280. .ToList();
  16281. }
  16282. }
  16283. var view = dbResult.Select(x =>
  16284. {
  16285. decimal dp = 0.00M;
  16286. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16287. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16288. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16289. {
  16290. if (startB && endB)
  16291. {
  16292. var timesp = endD.Subtract(startD);
  16293. if ((timesp.Days + 1) != 0)
  16294. {
  16295. dp = x.Price / (timesp.Days + 1);
  16296. }
  16297. }
  16298. }
  16299. else
  16300. {
  16301. dp = x.Price;
  16302. }
  16303. return new
  16304. {
  16305. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16306. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16307. x.Area,
  16308. x.id,
  16309. price = x.Price.ToString("F2"),
  16310. x.PriceName,
  16311. x.PriceContent,
  16312. x.TeamName,
  16313. x.DatePrice,
  16314. dayPrice = dp.ToString("F2"),
  16315. };
  16316. }).OrderByDescending(x => x.id).ToList();
  16317. jw = JsonView(true, "获取成功!", view);
  16318. }
  16319. catch (Exception e)
  16320. {
  16321. jw = JsonView(false, e.Message);
  16322. }
  16323. return Ok(jw);
  16324. }
  16325. [HttpPost]
  16326. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16327. {
  16328. var jw = JsonView(true);
  16329. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16330. #region SQL语句
  16331. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  16332. //{
  16333. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16334. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16335. // WHEN COUNT(*) >= 0 THEN 'True'
  16336. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16337. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16338. // ")
  16339. // .ToList();
  16340. //}
  16341. //else
  16342. //{
  16343. // string likeKey = string.Empty;
  16344. // foreach (var item in dto.Keyword)
  16345. // {
  16346. // likeKey += "%" + item;
  16347. // }
  16348. // likeKey += "%";
  16349. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16350. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16351. // WHEN COUNT(*) >= 0 THEN 'True'
  16352. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16353. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16354. // ")
  16355. // .ToList();
  16356. //}
  16357. #endregion
  16358. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  16359. {
  16360. @KeyWord = dto.Keyword
  16361. });
  16362. if (table != null && table.Rows.Count > 0)
  16363. {
  16364. foreach (DataRow row in table.Rows)
  16365. {
  16366. matches.Add(new DelegationInfoAndIsTrueView
  16367. {
  16368. Id = row.Field<int>("Id"),
  16369. GroupName = row.Field<string>("GroupName"),
  16370. isTrue = row.Field<string>("isTrue")
  16371. });
  16372. }
  16373. }
  16374. if (matches.Any())
  16375. {
  16376. jw.Data = matches;
  16377. }
  16378. else
  16379. {
  16380. jw.Code = 201;
  16381. jw.Msg = "empty list";
  16382. jw.Data = new List<string>(1);
  16383. }
  16384. return Ok(jw);
  16385. }
  16386. /// <summary>
  16387. /// 报价Word下载
  16388. /// </summary>
  16389. /// <param name="dto"></param>
  16390. /// <returns></returns>
  16391. [HttpPost]
  16392. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16393. {
  16394. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16395. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16396. if (di == null)
  16397. {
  16398. return Ok(JsonView(false, "团组不存在!"));
  16399. }
  16400. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16401. if (mainPrice == null || mainPrice.IsShare == 0)
  16402. {
  16403. return Ok(JsonView(false, "团组成本不存在!"));
  16404. }
  16405. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16406. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16407. if (costTypeHotelNumbers == null)
  16408. {
  16409. return Ok(JsonView(false, "团组成本不存在!"));
  16410. }
  16411. //文件名
  16412. string strFileName = di.TeamName + "-收款账单.doc";
  16413. //获取模板
  16414. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16415. //载入模板
  16416. Document doc = new Document(tmppath);
  16417. decimal allPrice = 0.00M;
  16418. string itemStr = string.Empty;
  16419. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16420. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16421. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16422. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16423. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16424. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16425. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16426. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16427. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16428. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16429. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16430. {
  16431. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16432. ("BXRS", "BXCB", "BXXS", "bx"),
  16433. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16434. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16435. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16436. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16437. ("CPRS", "CPCB", "CPXS", "cp"),
  16438. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16439. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16440. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16441. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16442. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16443. ("DJRS", "DJCB", "DJXS", "dj"),
  16444. ("GWRS", "GWCB", "GWXS", "gw"),
  16445. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16446. };
  16447. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16448. var rightSum = 0.00M;
  16449. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16450. {
  16451. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16452. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16453. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16454. if (prefix == "tbr")
  16455. {
  16456. rsValue *= 2;
  16457. cbValue /= 2;
  16458. }
  16459. if (OtherCostPropertyBJ.Contains(prefix))
  16460. {
  16461. rightSum += cbValue * xsValue;
  16462. }
  16463. }
  16464. var hotelRooms = new Dictionary<string, int>
  16465. {
  16466. { "SGR", costTypeHotelNumbers.SGR },
  16467. { "TBR", costTypeHotelNumbers.TBR },
  16468. { "JSES", costTypeHotelNumbers.JSES },
  16469. { "SUITE", costTypeHotelNumbers.SUITE }
  16470. };
  16471. var flights = new Dictionary<string, int>
  16472. {
  16473. { "经济舱", mainPrice.JJCRS },
  16474. { "公务舱", mainPrice.GWCRS },
  16475. { "头等舱", mainPrice.TDCRS }
  16476. };
  16477. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16478. {
  16479. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16480. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16481. { "头等舱", new[] { "SUITE", "JSES" } }
  16482. };
  16483. var result = new Dictionary<string, int>();
  16484. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16485. foreach (var flight in flights.Keys)
  16486. {
  16487. // 获取当前舱位的匹配规则
  16488. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16489. {
  16490. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16491. }
  16492. }
  16493. #region right计算
  16494. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16495. {
  16496. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16497. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16498. airHotelPriceList.Add(new
  16499. AirHotelPrice
  16500. {
  16501. Name = "经济舱TBR",
  16502. Price = rightSum + air + hotel,
  16503. Count = result["经济舱TBR"] * 2
  16504. });
  16505. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16506. }
  16507. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16508. {
  16509. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16510. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16511. airHotelPriceList.Add(new
  16512. AirHotelPrice
  16513. {
  16514. Name = "经济舱SGR",
  16515. Price = rightSum + air + hotel,
  16516. Count = result["经济舱SGR"]
  16517. });
  16518. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16519. }
  16520. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16521. {
  16522. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16523. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16524. airHotelPriceList.Add(new
  16525. AirHotelPrice
  16526. {
  16527. Name = "公务舱SGR",
  16528. Price = rightSum + air + hotel,
  16529. Count = result["公务舱SGR"]
  16530. });
  16531. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16532. }
  16533. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16534. {
  16535. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16536. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16537. airHotelPriceList.Add(new
  16538. AirHotelPrice
  16539. {
  16540. Name = "公务舱JSES",
  16541. Price = rightSum + air + hotel,
  16542. Count = result["公务舱JSES"]
  16543. });
  16544. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16545. }
  16546. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16547. {
  16548. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16549. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16550. airHotelPriceList.Add(new
  16551. AirHotelPrice
  16552. {
  16553. Name = "公务舱SUITE",
  16554. Price = rightSum + air + hotel,
  16555. Count = result["公务舱SUITE"]
  16556. });
  16557. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16558. }
  16559. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16560. {
  16561. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16562. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16563. airHotelPriceList.Add(new
  16564. AirHotelPrice
  16565. {
  16566. Name = "经济舱SUITE",
  16567. Price = rightSum + air + hotel,
  16568. Count = result["经济舱SUITE"]
  16569. });
  16570. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16571. }
  16572. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16573. {
  16574. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16575. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16576. airHotelPriceList.Add(new
  16577. AirHotelPrice
  16578. {
  16579. Name = "头等舱JSES",
  16580. Price = rightSum + air + hotel,
  16581. Count = result["头等舱JSES"]
  16582. });
  16583. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16584. }
  16585. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16586. {
  16587. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16588. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16589. airHotelPriceList.Add(new
  16590. AirHotelPrice
  16591. {
  16592. Name = "头等舱SUITE",
  16593. Price = rightSum + air + hotel,
  16594. Count = result["头等舱SUITE"]
  16595. });
  16596. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16597. }
  16598. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16599. {
  16600. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16601. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16602. airHotelPriceList.Add(new
  16603. AirHotelPrice
  16604. {
  16605. Name = "经济舱JSES",
  16606. Price = rightSum + air + hotel,
  16607. Count = result["经济舱JSES"]
  16608. });
  16609. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16610. }
  16611. #endregion
  16612. foreach (var item in airSouer.Keys)
  16613. {
  16614. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16615. if (find != null && find.Count > 0)
  16616. {
  16617. if (item.Contains("TBR"))
  16618. {
  16619. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16620. }
  16621. else
  16622. {
  16623. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16624. }
  16625. }
  16626. }
  16627. #region 替换Word模板书签内容
  16628. Dictionary<string, string> marks = new Dictionary<string, string>();
  16629. marks.Add("To", di.ClientUnit);//付款方
  16630. marks.Add("ToTel", di.TellPhone);//付款方电话
  16631. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16632. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16633. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16634. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16635. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16636. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16637. marks.Add("PayItemContent", itemStr);//详细信息
  16638. marks.Add("Total", allPrice.ToString("F2"));//合计
  16639. #endregion
  16640. foreach (var item in marks.Keys)
  16641. {
  16642. if (doc.Range.Bookmarks[item] != null)
  16643. {
  16644. Bookmark mark = doc.Range.Bookmarks[item];
  16645. mark.Text = marks[item];
  16646. }
  16647. }
  16648. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16649. doc.Save(savePaht);
  16650. var jw = new JsonView();
  16651. jw.Msg = "生成成功!";
  16652. jw.Code = 200;
  16653. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16654. return Ok(jw);
  16655. }
  16656. /// <summary>
  16657. /// 详细报价费用Excel下载
  16658. /// </summary>
  16659. /// <param name="dto"></param>
  16660. /// <returns></returns>
  16661. [HttpPost]
  16662. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16663. {
  16664. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16665. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16666. if (di == null)
  16667. {
  16668. return Ok(JsonView(false, "团组不存在!"));
  16669. }
  16670. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16671. if (mainPrice == null || mainPrice.IsShare == 0)
  16672. {
  16673. return Ok(JsonView(false, "团组成本不存在!"));
  16674. }
  16675. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16676. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16677. if (costTypeHotelNumbers == null)
  16678. {
  16679. return Ok(JsonView(false, "团组成本不存在!"));
  16680. }
  16681. WorkbookDesigner designer = new WorkbookDesigner();
  16682. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16683. List<int> hideRowsList = new List<int>();
  16684. int conterStartIndex = 3;
  16685. int rowIndex = conterStartIndex;
  16686. designer.SetDataSource("GroupName", di.TeamName);
  16687. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16688. {
  16689. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16690. ("BXRS", "BXCB", "BXXS", "bx"),
  16691. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16692. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16693. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16694. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16695. ("CPRS", "CPCB", "CPXS", "cp") ,
  16696. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16697. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16698. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16699. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16700. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16701. ("DJRS", "DJCB", "DJXS", "dj") ,
  16702. ("GWRS", "GWCB", "GWXS", "gw") ,
  16703. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16704. };
  16705. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16706. var rightSum = 0.00M;
  16707. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16708. {
  16709. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16710. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16711. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16712. if (prefix == "tbr")
  16713. {
  16714. rsValue *= 2;
  16715. cbValue /= 2;
  16716. }
  16717. if (OtherCostPropertyBJ.Contains(prefix))
  16718. {
  16719. rightSum += cbValue * xsValue;
  16720. }
  16721. if (rsValue == 0)
  16722. {
  16723. hideRowsList.Add(rowIndex);
  16724. }
  16725. else
  16726. {
  16727. designer.SetDataSource($"{prefix}rs", rsValue);
  16728. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16729. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16730. }
  16731. rowIndex += 2;
  16732. }
  16733. var hotelRooms = new Dictionary<string, int>
  16734. {
  16735. { "SGR", costTypeHotelNumbers.SGR },
  16736. { "TBR", costTypeHotelNumbers.TBR },
  16737. { "JSES", costTypeHotelNumbers.JSES },
  16738. { "SUITE", costTypeHotelNumbers.SUITE }
  16739. };
  16740. var flights = new Dictionary<string, int>
  16741. {
  16742. { "经济舱", mainPrice.JJCRS },
  16743. { "公务舱", mainPrice.GWCRS },
  16744. { "头等舱", mainPrice.TDCRS }
  16745. };
  16746. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16747. {
  16748. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16749. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16750. { "头等舱", new[] { "SUITE", "JSES" } }
  16751. };
  16752. var result = new Dictionary<string, int>();
  16753. foreach (var flight in flights.Keys)
  16754. {
  16755. // 获取当前舱位的匹配规则
  16756. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16757. {
  16758. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16759. }
  16760. }
  16761. var allPrice = 0.00M;
  16762. #region right计算
  16763. int airRowIndex = 35;
  16764. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16765. {
  16766. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16767. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16768. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16769. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16770. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16771. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16772. }
  16773. else
  16774. {
  16775. hideRowsList.Add(airRowIndex);
  16776. }
  16777. airRowIndex += 2;
  16778. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16779. {
  16780. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16781. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16782. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16783. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16784. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16785. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16786. }
  16787. else
  16788. {
  16789. hideRowsList.Add(airRowIndex);
  16790. }
  16791. airRowIndex += 2;
  16792. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16793. {
  16794. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16795. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16796. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16797. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16798. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16799. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16800. }
  16801. else
  16802. {
  16803. hideRowsList.Add(airRowIndex);
  16804. }
  16805. airRowIndex += 2;
  16806. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16807. {
  16808. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16809. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16810. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16811. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16812. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16813. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16814. }
  16815. else
  16816. {
  16817. hideRowsList.Add(airRowIndex);
  16818. }
  16819. airRowIndex += 2;
  16820. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16821. {
  16822. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16823. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16824. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16825. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16826. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16827. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16828. }
  16829. else
  16830. {
  16831. hideRowsList.Add(airRowIndex);
  16832. }
  16833. airRowIndex += 2;
  16834. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16835. {
  16836. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16837. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16838. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16839. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16840. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16841. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16842. }
  16843. else
  16844. {
  16845. hideRowsList.Add(airRowIndex);
  16846. }
  16847. airRowIndex += 2;
  16848. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16849. {
  16850. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16851. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16852. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16853. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16854. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16855. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16856. }
  16857. else
  16858. {
  16859. hideRowsList.Add(airRowIndex);
  16860. }
  16861. airRowIndex += 2;
  16862. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16863. {
  16864. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16865. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16866. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  16867. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  16868. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  16869. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16870. }
  16871. else
  16872. {
  16873. hideRowsList.Add(airRowIndex);
  16874. }
  16875. airRowIndex += 2;
  16876. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16877. {
  16878. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16879. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16880. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  16881. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  16882. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  16883. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16884. }
  16885. else
  16886. {
  16887. hideRowsList.Add(airRowIndex);
  16888. }
  16889. #endregion
  16890. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  16891. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  16892. var ws = designer.Workbook.Worksheets[0];
  16893. foreach (var Rowindex in hideRowsList)
  16894. {
  16895. ws.Cells.HideRows(Rowindex, 2);
  16896. }
  16897. designer.Process();
  16898. designer.Workbook.Save(savePaht);
  16899. return Ok(JsonView(true, "生成成功!", new
  16900. {
  16901. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  16902. }));
  16903. }
  16904. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  16905. {
  16906. foreach (var roomType in roomTypes)
  16907. {
  16908. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  16909. {
  16910. hotelRooms[roomType]--;
  16911. flights[flightType]--;
  16912. if (roomType == "TBR")
  16913. {
  16914. flights[flightType]--; // 双人间在减少1
  16915. }
  16916. string key = flightType + roomType;
  16917. if (result.Keys.Contains(key))
  16918. {
  16919. result[key]++;
  16920. }
  16921. else
  16922. {
  16923. result.Add(key, 1);
  16924. }
  16925. }
  16926. }
  16927. }
  16928. private class AirHotelPrice
  16929. {
  16930. public string Name { get; set; }
  16931. public decimal Price { get; set; }
  16932. public int Count { get; set; }
  16933. }
  16934. private class HotelSum
  16935. {
  16936. internal decimal SGR { get; set; }
  16937. internal decimal TBR { get; set; }
  16938. internal decimal JSES { get; set; }
  16939. internal decimal SUITE { get; set; }
  16940. internal decimal AllPrice {
  16941. get { return SGR + TBR + JSES + SUITE; }
  16942. }
  16943. }
  16944. [HttpPost]
  16945. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  16946. {
  16947. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16948. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16949. if (di == null)
  16950. {
  16951. return Ok(JsonView(false, "团组不存在!"));
  16952. }
  16953. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>()
  16954. .Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  16955. .ToList();
  16956. var groupHotelNumber = _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16957. .Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  16958. .ToList();
  16959. var groupHotelNumberDefault = groupHotelNumber.FirstOrDefault(x => x.Type == "Default");
  16960. HotelSum hotelSumP = new ();
  16961. if (groupCost.Any())
  16962. {
  16963. hotelSumP.SGR = groupHotelNumberDefault.SGR > 0 ? groupCost.Sum(x => x.SGR) * groupHotelNumberDefault.SGR : 0 ;
  16964. hotelSumP.TBR = groupHotelNumberDefault.TBR > 0 ? groupCost.Sum(x => x.TBR) * groupHotelNumberDefault.TBR : 0;
  16965. hotelSumP.JSES = groupHotelNumberDefault.JSES > 0 ? groupCost.Sum(x => x.JS_ES) * groupHotelNumberDefault.JSES : 0;
  16966. hotelSumP.SUITE = groupHotelNumberDefault.SUITE > 0 ? groupCost.Sum(x => x.Suite) * groupHotelNumberDefault.SUITE : 0;
  16967. }
  16968. #region 地接系数
  16969. Func<int, decimal> coefficientByDJ = (number) =>
  16970. {
  16971. if (number < 1) return 0.00M;
  16972. return number switch
  16973. {
  16974. < 6 => 2.5M,
  16975. 6 => 2.4M,
  16976. 7 => 1.8M,
  16977. 8 => 2.0M,
  16978. 9 => 3.0M,
  16979. 10 => 1.75M,
  16980. > 10 => 1.9M,
  16981. };
  16982. };
  16983. #endregion
  16984. #region 酒店系数
  16985. #endregion
  16986. return Ok(JsonView(true, "查询成功", new
  16987. {
  16988. HotelSum = hotelSumP,
  16989. CoefficientByDJ = coefficientByDJ(di.VisitPNumber) // 示例调用
  16990. }));
  16991. }
  16992. #endregion
  16993. #region 酒店预订 New 2023-12-28 17:45
  16994. /// <summary>
  16995. /// 酒店预订
  16996. /// 酒店费用列表 根据团组Id查询
  16997. /// </summary>
  16998. /// <param name="_dto"></param>
  16999. /// <returns></returns>
  17000. [HttpPost]
  17001. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17002. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  17003. {
  17004. #region 参数验证
  17005. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17006. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17007. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17008. #region 团组操作权限验证 76 酒店预定模块
  17009. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17010. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17011. #endregion
  17012. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17013. #region 页面操作权限验证
  17014. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17015. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17016. #endregion
  17017. #endregion
  17018. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  17019. }
  17020. /// <summary>
  17021. /// 酒店预订
  17022. /// 基础数据
  17023. /// </summary>
  17024. /// <param name="_dto"></param>
  17025. /// <returns></returns>
  17026. [HttpPost]
  17027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17028. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  17029. {
  17030. #region 参数验证
  17031. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17032. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17033. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17034. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17035. #region 页面操作权限验证
  17036. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17037. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17038. #endregion
  17039. #region 团组操作权限验证 76 酒店预定模块
  17040. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17041. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17042. #endregion
  17043. #endregion
  17044. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  17045. }
  17046. /// <summary>
  17047. /// 酒店预订
  17048. /// 创建 入住卷号码
  17049. /// </summary>
  17050. /// <param name="_dto"></param>
  17051. /// <returns></returns>
  17052. [HttpPost]
  17053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17054. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  17055. {
  17056. #region 参数验证
  17057. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17058. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17059. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17060. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17061. #region 页面操作权限验证
  17062. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17063. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17064. #endregion
  17065. #region 团组操作权限验证 76 酒店预定模块
  17066. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17067. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17068. #endregion
  17069. #endregion
  17070. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  17071. if (data.Code != 0)
  17072. {
  17073. return Ok(JsonView(false, data.Msg));
  17074. }
  17075. return Ok(JsonView(true, data.Msg, data.Data));
  17076. }
  17077. /// <summary>
  17078. /// 酒店预订
  17079. /// 详情
  17080. /// </summary>
  17081. /// <param name="_dto"></param>
  17082. /// <returns></returns>
  17083. [HttpPost]
  17084. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17085. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  17086. {
  17087. #region 参数验证
  17088. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  17089. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17090. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  17091. #region 团组操作权限验证 76 酒店预定模块
  17092. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17093. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17094. #endregion
  17095. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17096. #region 页面操作权限验证
  17097. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17098. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17099. #endregion
  17100. #endregion
  17101. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  17102. }
  17103. /// <summary>
  17104. /// 酒店预订
  17105. /// Add Or Edit
  17106. /// </summary>
  17107. /// <param name="_dto"></param>
  17108. /// <returns></returns>
  17109. [HttpPost]
  17110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17111. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  17112. {
  17113. #region 参数验证
  17114. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17115. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17116. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17117. #region 团组操作权限验证 76 酒店预定模块
  17118. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17119. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17120. #endregion
  17121. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17122. #region 页面操作权限验证
  17123. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17124. if (_dto.Id == 0) // Add
  17125. {
  17126. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17127. }
  17128. else if (_dto.Id > 1) // Edit
  17129. {
  17130. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17131. }
  17132. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  17133. #endregion
  17134. #endregion
  17135. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  17136. if (_view.Code != 200)
  17137. {
  17138. return Ok(_view);
  17139. }
  17140. #region 成本无酒店价格数据进入超支
  17141. _sqlSugar.BeginTran();
  17142. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  17143. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  17144. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  17145. for (int i = 0; i < groupCost.Count; i++)
  17146. {
  17147. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  17148. {
  17149. groupCost[i].Date = groupCost[i - 1].Date;
  17150. }
  17151. }
  17152. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  17153. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  17154. List<Fin_GroupExtraCostDto_OP>();
  17155. if (start_Bool && end_Bool)
  17156. {
  17157. while (start_Time < end_Time)
  17158. {
  17159. foreach (var item in groupCost_Grp)
  17160. {
  17161. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  17162. {
  17163. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  17164. {
  17165. extraCostList.Add(new
  17166. Fin_GroupExtraCostDto_OP
  17167. {
  17168. Area = _dto.AreaId,
  17169. coefficient = 1.5M,
  17170. createUser = _dto.UserId,
  17171. currency = _dto.CardPriceCurrency,
  17172. diId = _dto.DiId,
  17173. ManagerConfirm = 0,
  17174. SupervisorConfirm = 0,
  17175. SYsupervisorConfirm = 0,
  17176. editType = 1,
  17177. PortType = 1,
  17178. price = _dto.CardPrice,
  17179. PriceCount = 1,
  17180. priceType = 1027,
  17181. priceDetailType = 1044,
  17182. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  17183. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  17184. });
  17185. }
  17186. }
  17187. }
  17188. start_Time = start_Time.AddDays(1);
  17189. }
  17190. }
  17191. if (extraCostList.Any())
  17192. {
  17193. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  17194. }
  17195. _sqlSugar.CommitTran();
  17196. #endregion
  17197. #region 应用推送
  17198. try
  17199. {
  17200. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17201. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17202. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17203. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17204. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17205. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17206. var diId = _dto.DiId;
  17207. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17208. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17209. #region 操作记录
  17210. var opInfo = new Crm_TableOperationRecord()
  17211. {
  17212. TableName = "Grp_HotelReservations",
  17213. PortType = _dto.PortType,
  17214. DataId = hotelId,
  17215. CreateUserId = _dto.UserId
  17216. };
  17217. //var opStatus = OperationEnum.NoOperation;
  17218. if (_dto.Id < 1) //添加操作
  17219. {
  17220. opInfo.OperationItem = OperationEnum.Add;
  17221. }
  17222. else if (_dto.Id > 0)
  17223. {
  17224. opInfo.OperationItem = OperationEnum.Edit;
  17225. }
  17226. string opRemark = string.Empty;
  17227. if (ccpInfo != null)
  17228. {
  17229. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  17230. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  17231. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  17232. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  17233. }
  17234. opInfo.Remark = opRemark;
  17235. await _tableorRep.AddAsync(opInfo);
  17236. #endregion
  17237. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  17238. //2024-10-21 新增LZ UID
  17239. var userIds = new List<int>() { 21 };
  17240. string title = $"费用审核";
  17241. string content = "";
  17242. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17243. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17244. try
  17245. {
  17246. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  17247. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  17248. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  17249. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  17250. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  17251. }
  17252. catch (Exception ex)
  17253. {
  17254. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  17255. }
  17256. }
  17257. catch (Exception ex)
  17258. {
  17259. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  17260. }
  17261. try
  17262. {
  17263. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17264. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17265. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17266. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17267. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17268. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17269. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17270. //自动审核
  17271. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  17272. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  17273. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  17274. //2024-10-21 新增LZ UID
  17275. var userIds = new List<int>() { 21 };
  17276. string title = $"系统通知";
  17277. var diId = _dto.DiId;
  17278. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17279. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17280. string content = "";
  17281. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17282. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17283. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17284. }
  17285. catch (Exception ex)
  17286. {
  17287. }
  17288. #endregion
  17289. return Ok(_view);
  17290. }
  17291. /// <summary>
  17292. /// 酒店自动审核测试
  17293. /// Add Or Edit
  17294. /// </summary>
  17295. /// <param name="diid"></param>
  17296. /// <param name="dataId"></param>
  17297. /// <returns></returns>
  17298. [HttpPost]
  17299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17300. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  17301. {
  17302. #region 应用推送
  17303. try
  17304. {
  17305. //自动审核
  17306. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  17307. }
  17308. catch (Exception ex)
  17309. {
  17310. return Ok(JsonView(false, ex.Message));
  17311. }
  17312. #endregion
  17313. return Ok(JsonView(false, "操作成功"));
  17314. }
  17315. /// <summary>
  17316. /// 酒店预订
  17317. /// Del
  17318. /// </summary>
  17319. /// <param name="_dto"></param>
  17320. /// <returns></returns>
  17321. [HttpPost]
  17322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17323. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  17324. {
  17325. #region 参数验证
  17326. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17327. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17328. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17329. #region 团组操作权限验证 76 酒店预定模块
  17330. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17331. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17332. #endregion
  17333. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17334. #region 页面操作权限验证
  17335. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17336. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17337. #endregion
  17338. #endregion
  17339. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  17340. #region 操作记录
  17341. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  17342. {
  17343. TableName = "Grp_HotelReservations",
  17344. PortType = _dto.PortType,
  17345. OperationItem = OperationEnum.Del,
  17346. DataId = _dto.Id,
  17347. CreateUserId = _dto.UserId
  17348. });
  17349. #endregion
  17350. return Ok(data);
  17351. }
  17352. /// <summary>
  17353. /// 酒店预订
  17354. /// 生成VOUCHER
  17355. /// 2024.05.06 之前版本
  17356. /// </summary>
  17357. /// <param name="_dto"></param>
  17358. /// <returns></returns>
  17359. [HttpPost]
  17360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17361. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  17362. {
  17363. try
  17364. {
  17365. #region 参数验证
  17366. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17367. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17368. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17369. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  17370. #region 团组操作权限验证 76 酒店预定模块
  17371. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17372. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17373. #endregion
  17374. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17375. #region 页面操作权限验证
  17376. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17377. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17378. #endregion
  17379. #endregion
  17380. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  17381. //判断数据是否完整
  17382. if (hr != null)
  17383. {
  17384. if (!string.IsNullOrEmpty(hr.DetermineNo))
  17385. {
  17386. string strFileName = "HotelStatement/";
  17387. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17388. if (dele != null)
  17389. strFileName += dele.TourCode;
  17390. //载入模板
  17391. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  17392. Document doc = new Document(sss);
  17393. DocumentBuilder builder = new DocumentBuilder(doc);
  17394. #region 替换Word模板书签内容
  17395. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  17396. //入住卷预定号码
  17397. if (doc.Range.Bookmarks["VNO"] != null)
  17398. {
  17399. Bookmark mark = doc.Range.Bookmarks["VNO"];
  17400. mark.Text = hr.CheckNumber;
  17401. }
  17402. //酒店时间
  17403. if (doc.Range.Bookmarks["Date"] != null)
  17404. {
  17405. Bookmark mark = doc.Range.Bookmarks["Date"];
  17406. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17407. }
  17408. //团号
  17409. if (doc.Range.Bookmarks["TNo"] != null)
  17410. {
  17411. Bookmark mark = doc.Range.Bookmarks["TNo"];
  17412. mark.Text = dele.TourCode;
  17413. }
  17414. //预定号码
  17415. if (doc.Range.Bookmarks["BookingId"] != null)
  17416. {
  17417. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  17418. mark.Text = hr.ReservationsNo;
  17419. }
  17420. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  17421. {
  17422. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  17423. mark.Text = hr.DetermineNo;
  17424. }
  17425. //酒店城市
  17426. if (doc.Range.Bookmarks["City"] != null)
  17427. {
  17428. Bookmark mark = doc.Range.Bookmarks["City"];
  17429. mark.Text = hr.City;
  17430. }
  17431. //酒店名称
  17432. if (doc.Range.Bookmarks["HName"] != null)
  17433. {
  17434. Bookmark mark = doc.Range.Bookmarks["HName"];
  17435. mark.Text = hr.HotelName;
  17436. }
  17437. //酒店地址
  17438. if (doc.Range.Bookmarks["Address"] != null)
  17439. {
  17440. Bookmark mark = doc.Range.Bookmarks["Address"];
  17441. mark.Text = hr.HotelAddress;
  17442. }
  17443. //酒店电话
  17444. if (doc.Range.Bookmarks["Tel"] != null)
  17445. {
  17446. Bookmark mark = doc.Range.Bookmarks["Tel"];
  17447. mark.Text = hr.HotelTel;
  17448. }
  17449. //酒店传真
  17450. if (doc.Range.Bookmarks["Fax"] != null)
  17451. {
  17452. Bookmark mark = doc.Range.Bookmarks["Fax"];
  17453. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  17454. {
  17455. mark.Text = hr.HotelFax;
  17456. }
  17457. }
  17458. //入住时间
  17459. if (doc.Range.Bookmarks["CIn"] != null)
  17460. {
  17461. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17462. Bookmark mark = doc.Range.Bookmarks["CIn"];
  17463. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  17464. }
  17465. //退房时间
  17466. if (doc.Range.Bookmarks["COut"] != null)
  17467. {
  17468. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17469. Bookmark mark = doc.Range.Bookmarks["COut"];
  17470. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17471. }
  17472. //客户名称
  17473. if (doc.Range.Bookmarks["GName"] != null)
  17474. {
  17475. string guestName = "";
  17476. string[] clients = Array.Empty<string>();
  17477. if (hr.GuestName.Contains(","))
  17478. {
  17479. clients = hr.GuestName.Split(",");
  17480. }
  17481. else
  17482. {
  17483. clients = new string[] { hr.GuestName };
  17484. }
  17485. List<int> clientIds_int = new List<int>();
  17486. if (clients.Length > 0)
  17487. {
  17488. foreach (var item in clients)
  17489. {
  17490. if (item.IsNumeric())
  17491. {
  17492. clientIds_int.Add(int.Parse(item));
  17493. }
  17494. }
  17495. }
  17496. if (clientIds_int.Count > 0)
  17497. {
  17498. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  17499. foreach (var client in _clientDatas)
  17500. {
  17501. //男
  17502. if (client.Sex == 0) guestName += $"Mr.";
  17503. //女
  17504. else if (client.Sex == 1) guestName += $"Ms.";
  17505. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  17506. {
  17507. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  17508. }
  17509. //guestName += $"{client.Pinyin},";
  17510. }
  17511. if (guestName.Length > 0)
  17512. {
  17513. guestName = guestName.Substring(0, guestName.Length - 1);
  17514. }
  17515. }
  17516. else
  17517. {
  17518. guestName = hr.GuestName;
  17519. }
  17520. Bookmark mark = doc.Range.Bookmarks["GName"];
  17521. mark.Text = guestName;
  17522. }
  17523. //房间介绍
  17524. if (doc.Range.Bookmarks["ROOM"] != null)
  17525. {
  17526. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  17527. mark.Text = hr.RoomExplanation;
  17528. }
  17529. //报价描述
  17530. if (doc.Range.Bookmarks["NOTE"] != null)
  17531. {
  17532. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  17533. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  17534. if (ss != null)
  17535. mark.Text = ss.Name;
  17536. }
  17537. //入住时间
  17538. if (doc.Range.Bookmarks["CheckIn"] != null)
  17539. {
  17540. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17541. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  17542. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17543. }
  17544. //退房时间
  17545. if (doc.Range.Bookmarks["CheckOut"] != null)
  17546. {
  17547. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17548. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  17549. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17550. }
  17551. //日期
  17552. if (doc.Range.Bookmarks["DT"] != null)
  17553. {
  17554. Bookmark mark = doc.Range.Bookmarks["DT"];
  17555. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17556. }
  17557. //名称
  17558. if (doc.Range.Bookmarks["VName"] != null)
  17559. {
  17560. Bookmark mark = doc.Range.Bookmarks["VName"];
  17561. mark.Text = hr.HotelName;
  17562. }
  17563. //号码
  17564. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  17565. {
  17566. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  17567. mark.Text = hr.CheckNumber;
  17568. }
  17569. #endregion
  17570. strFileName += "VOUCHER.doc";
  17571. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17572. doc.Save(fileDir);
  17573. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17574. return Ok(JsonView(true, "操作成功!", Url));
  17575. }
  17576. else
  17577. {
  17578. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  17579. }
  17580. }
  17581. else
  17582. {
  17583. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  17584. }
  17585. }
  17586. catch (Exception ex)
  17587. {
  17588. return Ok(JsonView(false, ex.Message));
  17589. }
  17590. }
  17591. /// <summary>
  17592. /// 酒店预订
  17593. /// 生成VOUCHER
  17594. /// 2024.05.06 之后版本
  17595. /// </summary>
  17596. /// <param name="_dto"></param>
  17597. /// <returns></returns>
  17598. [HttpPost]
  17599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17600. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  17601. {
  17602. #region 参数验证
  17603. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17604. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17605. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17606. #region 团组操作权限验证 76 酒店预定模块
  17607. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17608. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17609. #endregion
  17610. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17611. #region 页面操作权限验证
  17612. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17613. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17614. #endregion
  17615. #endregion
  17616. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  17617. //判断数据是否完整
  17618. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17619. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17620. string strFileName = "HotelStatement/";
  17621. string guestNames = ""; //格式Mr.xxx Ms.xxx
  17622. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  17623. #region 数据处理
  17624. List<int> guestIds = new List<int>();
  17625. //int index = 0;
  17626. foreach (var item in hrDtas)
  17627. {
  17628. if (item.GuestName.Contains(","))
  17629. {
  17630. string[] guestIdArr = item.GuestName.Split(',');
  17631. foreach (var guestIdStr in guestIdArr)
  17632. {
  17633. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  17634. if (guestBool)
  17635. {
  17636. guestIds.Add(guestId);
  17637. }
  17638. }
  17639. }
  17640. else guestNames += item.GuestName;
  17641. var voucherInfo = new HotelVoucherInfoView()
  17642. {
  17643. HotelName = item.HotelName,
  17644. CheckInDate = item.CheckInDate,
  17645. CheckOutDate = item.CheckOutDate,
  17646. ConfirmationNumber = item.DetermineNo.Trim(),
  17647. RoomType = item.RoomExplanation
  17648. };
  17649. vouchers.Add(voucherInfo);
  17650. }
  17651. if (guestIds.Count > 0)
  17652. {
  17653. guestIds = guestIds.Distinct().ToList();
  17654. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  17655. if (guestDatas.Count > 0)
  17656. {
  17657. guestNames = "";
  17658. foreach (var guest in guestDatas)
  17659. {
  17660. string guestName = "";
  17661. if (guest.Sex == 0) guestName += @"MR.";
  17662. else if (guest.Sex == 1) guestName += @"MS.";
  17663. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17664. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17665. guestNames += @$"{guestName.Trim()}、";
  17666. }
  17667. if (guestNames.Length > 0)
  17668. {
  17669. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17670. }
  17671. }
  17672. }
  17673. #endregion
  17674. //载入模板
  17675. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  17676. Document doc = new Document(sss);
  17677. DocumentBuilder builder = new DocumentBuilder(doc);
  17678. if (doc.Range.Bookmarks["GuestName"] != null)
  17679. {
  17680. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  17681. mark.Text = guestNames;
  17682. }
  17683. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17684. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  17685. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  17686. for (int i = 1; i <= vouchers.Count; i++)
  17687. {
  17688. HotelVoucherInfoView hviv = vouchers[i - 1];
  17689. builder.MoveToCell(0, i, 0, 0);
  17690. builder.Write(hviv.HotelName);
  17691. builder.MoveToCell(0, i, 1, 0);
  17692. builder.Write(hviv.CheckInDate);
  17693. builder.MoveToCell(0, i, 2, 0);
  17694. builder.Write(hviv.CheckOutDate);
  17695. builder.MoveToCell(0, i, 3, 0);
  17696. builder.Write(hviv.RoomType);
  17697. builder.MoveToCell(0, i, 4, 0);
  17698. builder.Write(hviv.ConfirmationNumber);
  17699. }
  17700. //删除多余行
  17701. int currRowIndex = vouchers.Count + 1;
  17702. int delRows = 21 - currRowIndex;
  17703. if (delRows > 0)
  17704. {
  17705. for (int i = 0; i < delRows; i++)
  17706. {
  17707. table.Rows.RemoveAt(currRowIndex);
  17708. //cultivateRowIndex++;
  17709. }
  17710. }
  17711. strFileName += "VOUCHER.docx";
  17712. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17713. doc.Save(fileDir);
  17714. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17715. return Ok(JsonView(true, "操作成功!", Url));
  17716. }
  17717. /// <summary>
  17718. /// 酒店预订
  17719. /// 生成VOUCHER 批量生成
  17720. /// New
  17721. /// </summary>
  17722. /// <param name="_dto"></param>
  17723. /// <returns></returns>
  17724. [HttpPost]
  17725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17726. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  17727. {
  17728. #region 参数验证
  17729. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17730. if (_dto.PageId < 1) _dto.PageId = 28;
  17731. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17732. #region 团组操作权限验证 76 酒店预定模块
  17733. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17734. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17735. #endregion
  17736. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17737. #region 页面操作权限验证
  17738. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17739. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17740. #endregion
  17741. #endregion
  17742. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  17743. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  17744. .OrderBy(x => x.CheckInDate)
  17745. .ToListAsync();
  17746. //判断数据是否完整
  17747. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17748. string strFileName = "HotelStatement/";
  17749. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17750. if (dele != null)
  17751. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  17752. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  17753. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  17754. .Where(it => it.IsDel == 0)
  17755. .ToListAsync();
  17756. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  17757. for (int i = 0; i < hrDtas.Count; i++)
  17758. {
  17759. string guestNames = string.Empty;
  17760. List<int> guestIds = new List<int>();
  17761. var item = hrDtas[i];
  17762. //处理客户姓名
  17763. if (item.GuestName.Contains(","))
  17764. {
  17765. string[] guestIdArr = item.GuestName.Split(',');
  17766. foreach (var guestIdStr in guestIdArr)
  17767. if (int.TryParse(guestIdStr, out int guestId))
  17768. guestIds.Add(guestId);
  17769. }
  17770. else
  17771. {
  17772. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  17773. if (guestIdBool)
  17774. {
  17775. guestIds.Add(guestId);
  17776. }
  17777. //NaN
  17778. if (item.GuestName.Contains("NaN"))
  17779. {
  17780. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  17781. }
  17782. }
  17783. if (guestIds.Count > 0)
  17784. {
  17785. guestIds = guestIds.Distinct().ToList();
  17786. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  17787. if (guestDatas1.Count > 0)
  17788. {
  17789. guestNames = "";
  17790. foreach (var guest in guestDatas1)
  17791. {
  17792. string guestName = "";
  17793. if (guest.Sex == 0) guestName += @"MR.";
  17794. else if (guest.Sex == 1) guestName += @"MS.";
  17795. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17796. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17797. guestNames += @$"{guestName.Trim()}、";
  17798. }
  17799. if (guestNames.Length > 0)
  17800. {
  17801. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17802. }
  17803. }
  17804. }
  17805. //if (!string.IsNullOrEmpty(guestNames))
  17806. //{
  17807. hrDtas[i].GuestName = guestNames;
  17808. //}
  17809. }
  17810. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  17811. Document doc = new Document();
  17812. DocumentBuilder builder = new DocumentBuilder(doc);
  17813. try
  17814. {
  17815. builder.MoveToDocumentStart();
  17816. foreach (var item in hrDtas)
  17817. {
  17818. //标题
  17819. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17820. builder.ParagraphFormat.LineSpacing = 1;
  17821. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17822. builder.ParagraphFormat.Style.Font.Size = 9;
  17823. builder.ParagraphFormat.Style.Font.Bold = true;
  17824. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17825. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  17826. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17827. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17828. builder.ParagraphFormat.LineSpacing = 1;
  17829. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17830. builder.ParagraphFormat.Style.Font.Size = 9;
  17831. builder.ParagraphFormat.Style.Font.Bold = true;
  17832. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  17833. builder.StartTable();
  17834. // 设置边框颜色
  17835. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  17836. //设置边框样式
  17837. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  17838. //表格
  17839. #region 第一行
  17840. builder.InsertCell();
  17841. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17842. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17843. //builder.CellFormat.AllowAutoFit = false;
  17844. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17845. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17846. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17847. builder.CellFormat.WrapText = true; //自动换行
  17848. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17849. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  17850. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17851. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17852. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17853. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17854. builder.Write("TOUR NO:");
  17855. builder.InsertCell();
  17856. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17857. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17858. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17859. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17860. builder.ParagraphFormat.Style.Font.Bold = false;
  17861. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17862. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17863. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17864. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17865. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17866. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17867. builder.Write($"{dele?.TourCode ?? "-"}");
  17868. builder.InsertCell();
  17869. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17870. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17871. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17872. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17873. builder.ParagraphFormat.Style.Font.Bold = false;
  17874. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17875. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17876. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17877. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17878. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17879. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17880. builder.Write($"CITY:");
  17881. builder.InsertCell();
  17882. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17883. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17884. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17885. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17886. builder.ParagraphFormat.Style.Font.Bold = false;
  17887. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17888. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17889. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17890. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17891. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17892. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17893. builder.Write($"{item.City}");
  17894. builder.EndRow();
  17895. #endregion
  17896. #region 第二行
  17897. builder.InsertCell();
  17898. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17899. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17900. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17901. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17902. builder.ParagraphFormat.Style.Font.Bold = false;
  17903. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17904. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17905. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17906. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17907. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17908. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17909. builder.Write("CONFIRMATION NO:");
  17910. builder.InsertCell();
  17911. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17912. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17913. builder.ParagraphFormat.Style.Font.Size = 8;
  17914. builder.ParagraphFormat.Style.Font.Bold = false;
  17915. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17916. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17917. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17918. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17919. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17920. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17921. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17922. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17923. builder.Write($"{item.DetermineNo}");
  17924. builder.InsertCell();
  17925. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17926. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17927. builder.InsertCell();
  17928. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17929. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17930. builder.EndRow();
  17931. #endregion
  17932. #region 第三行
  17933. builder.InsertCell();
  17934. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17935. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17936. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17937. builder.ParagraphFormat.Style.Font.Bold = false;
  17938. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17939. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17940. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17941. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17942. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17943. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17944. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17945. builder.Write($"HOTEL NAME:");
  17946. builder.InsertCell();
  17947. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17948. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17949. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17950. builder.ParagraphFormat.Style.Font.Bold = false;
  17951. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17952. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17953. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17954. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17955. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17956. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17957. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17958. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17959. builder.Write($"{item.HotelName}");
  17960. builder.InsertCell();
  17961. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17962. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17963. builder.InsertCell();
  17964. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17965. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17966. builder.EndRow();
  17967. #endregion
  17968. #region 第四行
  17969. builder.InsertCell();
  17970. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17971. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17972. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17973. builder.ParagraphFormat.Style.Font.Bold = false;
  17974. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17975. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17976. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17977. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17978. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17979. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17980. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17981. builder.Write($"HOTEL ADDRESS:");
  17982. builder.InsertCell();
  17983. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17984. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17985. builder.ParagraphFormat.Style.Font.Size = 8;
  17986. builder.ParagraphFormat.Style.Font.Bold = false;
  17987. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17988. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17989. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17990. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17991. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17992. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17993. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17994. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17995. builder.Write($"{item.HotelAddress}");
  17996. builder.InsertCell();
  17997. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17998. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17999. builder.InsertCell();
  18000. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18001. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18002. builder.EndRow();
  18003. #endregion
  18004. #region 第五行
  18005. builder.InsertCell();
  18006. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18007. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18008. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18009. builder.ParagraphFormat.Style.Font.Bold = false;
  18010. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18011. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18012. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18013. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18014. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18015. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18016. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18017. builder.Write("TEL:");
  18018. builder.InsertCell();
  18019. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18020. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18021. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18022. builder.ParagraphFormat.Style.Font.Bold = false;
  18023. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18024. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18025. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18026. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18027. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18028. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18029. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18030. builder.Write($"{item.HotelTel}");
  18031. builder.InsertCell();
  18032. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18033. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18034. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18035. builder.ParagraphFormat.Style.Font.Bold = false;
  18036. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18037. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18038. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18039. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18040. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18041. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18042. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18043. builder.Write($"FAX:");
  18044. builder.InsertCell();
  18045. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18046. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18047. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18048. builder.ParagraphFormat.Style.Font.Bold = false;
  18049. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18050. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18051. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18052. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18053. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18054. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18055. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18056. builder.Write($"{item.HotelFax}");
  18057. builder.EndRow();
  18058. #endregion
  18059. #region 第六行
  18060. builder.InsertCell();
  18061. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18062. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18063. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18064. builder.ParagraphFormat.Style.Font.Bold = false;
  18065. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18066. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18067. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18068. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18069. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18070. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18071. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18072. builder.Write("CHECK IN:");
  18073. builder.InsertCell();
  18074. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18075. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18076. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18077. builder.ParagraphFormat.Style.Font.Bold = false;
  18078. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18079. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18080. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18081. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18082. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18083. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18084. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18085. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  18086. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18087. builder.Write($"{checkInStr}");
  18088. builder.InsertCell();
  18089. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18090. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18091. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18092. builder.ParagraphFormat.Style.Font.Bold = false;
  18093. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18094. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18095. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18096. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18097. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18098. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18099. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18100. builder.Write($"CHECK OUT:");
  18101. builder.InsertCell();
  18102. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18103. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18104. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18105. builder.ParagraphFormat.Style.Font.Bold = false;
  18106. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18107. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18108. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18109. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18110. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18111. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18112. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18113. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  18114. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  18115. builder.Write($"{checkOutStr}");
  18116. builder.EndRow();
  18117. #endregion
  18118. #region 第七行
  18119. builder.InsertCell();
  18120. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18121. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18122. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18123. builder.ParagraphFormat.Style.Font.Bold = false;
  18124. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18125. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18126. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18127. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18128. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18129. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18130. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18131. builder.Write($"GUEST NAME:");
  18132. builder.InsertCell();
  18133. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18134. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18135. builder.ParagraphFormat.Style.Font.Size = 8;
  18136. builder.ParagraphFormat.Style.Font.Bold = false;
  18137. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18138. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18139. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18140. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18141. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18142. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18143. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18144. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18145. builder.Write($"{item.GuestName.Trim()}");
  18146. builder.InsertCell();
  18147. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18148. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18149. builder.InsertCell();
  18150. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18151. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18152. builder.EndRow();
  18153. #endregion
  18154. #region 第八行
  18155. builder.InsertCell();
  18156. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18157. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18158. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18159. builder.ParagraphFormat.Style.Font.Bold = false;
  18160. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18161. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18162. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18163. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18164. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18165. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18166. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18167. builder.Write($"ROOM TYPE:");
  18168. builder.InsertCell();
  18169. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18170. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18171. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18172. builder.ParagraphFormat.Style.Font.Bold = false;
  18173. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18174. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18175. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18176. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18177. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18178. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18179. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18180. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18181. builder.Write($"{item.RoomExplanation}");
  18182. builder.InsertCell();
  18183. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18184. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18185. builder.InsertCell();
  18186. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18187. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18188. builder.EndRow();
  18189. #endregion
  18190. #region 第九行
  18191. builder.InsertCell();
  18192. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18193. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18194. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18195. builder.ParagraphFormat.Style.Font.Bold = false;
  18196. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18197. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18198. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18199. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18200. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18201. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18202. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18203. builder.Write($"NOTE:");
  18204. builder.InsertCell();
  18205. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18206. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18207. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18208. builder.ParagraphFormat.Style.Font.Bold = false;
  18209. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18210. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18211. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18212. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18213. 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.");
  18214. builder.InsertCell();
  18215. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18216. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18217. builder.InsertCell();
  18218. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18219. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18220. builder.EndRow();
  18221. #endregion
  18222. builder.EndTable();
  18223. //换行
  18224. builder.Writeln("");
  18225. builder.Writeln("");
  18226. }
  18227. #region 获取文档中的所有表格 设置文字自适应
  18228. // 获取文档中的所有表格。
  18229. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  18230. {
  18231. // 遍历表格中的所有行。
  18232. foreach (Aspose.Words.Tables.Row row in table.Rows)
  18233. {
  18234. foreach (Cell cell in row.Cells)
  18235. {
  18236. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  18237. cellFormat.Width = 0;
  18238. }
  18239. }
  18240. }
  18241. #endregion
  18242. #region 设置页眉
  18243. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  18244. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  18245. if (System.IO.File.Exists(voucherHeaderPath))
  18246. {
  18247. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  18248. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  18249. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  18250. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  18251. // 调整图片位置
  18252. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  18253. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  18254. shape.Top = 50; // 将图片距离页眉上边缘的距离
  18255. shape.Left = 0; // 将图片距离页面左边缘的距离
  18256. shape.Width = 81; // 设置图片宽度
  18257. shape.Height = 36; // 设置图片高度
  18258. }
  18259. //靠右
  18260. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18261. //// 设置页脚上下边距
  18262. //builder.PageSetup.HeaderDistance = 42;
  18263. // 添加页眉线
  18264. Aspose.Words.Border borderHeader = null;
  18265. try
  18266. {
  18267. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  18268. }
  18269. catch (Exception e)
  18270. {
  18271. // TODO Auto-generated catch block
  18272. //e.printStackTrace();
  18273. }
  18274. borderHeader.Shadow = true;
  18275. borderHeader.DistanceFromText = 2;
  18276. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  18277. #endregion
  18278. }
  18279. catch (Exception ex)
  18280. {
  18281. }
  18282. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18283. doc.Save(fileDir);
  18284. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18285. return Ok(JsonView(true, "操作成功!", Url));
  18286. }
  18287. /// <summary>
  18288. /// 酒店预订
  18289. /// 生成 预定成本 Excel
  18290. /// </summary>
  18291. /// <param name="_dto"></param>
  18292. /// <returns></returns>
  18293. [HttpPost]
  18294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18295. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  18296. {
  18297. #region 参数验证
  18298. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  18299. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  18300. if (!vadalitorRes.IsValid)
  18301. {
  18302. var errors = new StringBuilder();
  18303. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  18304. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  18305. }
  18306. #region 团组操作权限验证 76 酒店预定模块
  18307. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18308. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18309. #endregion
  18310. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18311. #region 页面操作权限验证
  18312. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18313. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18314. #endregion
  18315. #endregion
  18316. decimal _rate = 1.00M;
  18317. string _currency = string.Empty;
  18318. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  18319. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18320. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  18321. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18322. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  18323. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  18324. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  18325. if (_GroupCostParameter == null)
  18326. {
  18327. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  18328. bool isIntType = int.TryParse(_currency, out int currId);
  18329. if (isIntType)
  18330. {
  18331. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18332. }
  18333. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18334. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18335. if (currInfo == null)
  18336. {
  18337. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18338. }
  18339. else _rate = currInfo.Rate;
  18340. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  18341. {
  18342. _rate = _GroupCostParameter.Rate;
  18343. }
  18344. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18345. //string strFileName = "HotelStatement/";
  18346. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18347. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18348. var rateDatas = new List<dynamic>();
  18349. #region 数据处理
  18350. foreach (var item in hrDtas)
  18351. {
  18352. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18353. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18354. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18355. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18356. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18357. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  18358. {
  18359. continue;
  18360. }
  18361. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18362. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  18363. string singleRoomFeeStr = string.Empty,
  18364. doubleRoomFeeStr = string.Empty,
  18365. suiteRoomFeeStr = string.Empty,
  18366. otherRoomFeeStr = string.Empty,
  18367. payMoneyStr = string.Empty,
  18368. cardPriceStr = string.Empty;
  18369. if (roomCurr.Equals("CNY"))
  18370. {
  18371. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  18372. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18373. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18374. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18375. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18376. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  18377. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  18378. }
  18379. else
  18380. {
  18381. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18382. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18383. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18384. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18385. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18386. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18387. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18388. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18389. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18390. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18391. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  18392. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  18393. if (ccpPaymentCurrency.Equals("CNY"))
  18394. {
  18395. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  18396. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18397. }
  18398. else
  18399. {
  18400. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  18401. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  18402. }
  18403. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  18404. if (hotelcardPriceCurrency.Equals("CNY"))
  18405. {
  18406. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18407. }
  18408. else
  18409. {
  18410. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  18411. }
  18412. }
  18413. string breakfastPriceStr = string.Empty,
  18414. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18415. governmentRentStr = string.Empty,
  18416. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18417. cityTaxStr = string.Empty,
  18418. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18419. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  18420. if (!string.IsNullOrEmpty(breakfastCurrency1))
  18421. {
  18422. if (breakfastCurrency1.Equals("CNY"))
  18423. {
  18424. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18425. }
  18426. else
  18427. {
  18428. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  18429. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  18430. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  18431. }
  18432. }
  18433. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18434. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  18435. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  18436. {
  18437. if (governmentRentCurrency.Equals("CNY"))
  18438. {
  18439. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18440. }
  18441. else
  18442. {
  18443. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  18444. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  18445. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  18446. }
  18447. }
  18448. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18449. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  18450. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  18451. {
  18452. if (cityTaxStrCurrency1.Equals("CNY"))
  18453. {
  18454. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18455. }
  18456. else
  18457. {
  18458. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  18459. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  18460. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  18461. }
  18462. }
  18463. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18464. int payDId = roomInfo?.PayDId ?? 0;
  18465. pcfds.Add(new HotelReservations_PCFD_View()
  18466. {
  18467. City = item.City,
  18468. HotelName = item.HotelName,
  18469. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18470. // SingleRoomCount = item.SingleRoomCount,
  18471. SingleRoomPrice = singleRoomFeeStr,
  18472. // DoubleRoomCount = item.DoubleRoomCount,
  18473. DoubleRoomPrice = doubleRoomFeeStr,
  18474. //SuiteRoomCount = item.SuiteRoomCount,
  18475. SuiteRoomPrice = suiteRoomFeeStr,
  18476. OtherRoomPrice = otherRoomFeeStr,
  18477. //OtherRoomCount = item.OtherRoomCount,
  18478. BreakfastPrice = breakfastPriceStr,
  18479. GovernmentRent = governmentRentStr,
  18480. CityTax = cityTaxStr,
  18481. RoomExplanation = item.RoomExplanation,
  18482. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18483. PayTime = roomInfo?.ConsumptionDate,
  18484. BankNo = roomInfo?.BankNo,
  18485. PayMoney = payMoneyStr,
  18486. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18487. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18488. CardPrice = cardPriceStr,
  18489. Remark = ccpInfo.Remark
  18490. });
  18491. }
  18492. #endregion
  18493. //载入模板
  18494. WorkbookDesigner designer = new WorkbookDesigner();
  18495. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18496. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18497. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18498. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18499. var rateDatas1 = rateDatas.Distinct();
  18500. var rateStr = string.Empty;
  18501. foreach (var item in rateDatas1)
  18502. {
  18503. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  18504. }
  18505. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  18506. designer.SetDataSource("Opertor", userInfo.CnName);
  18507. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18508. dt.TableName = "ViewMyHotelReservations";
  18509. designer.SetDataSource(dt);
  18510. designer.Process();
  18511. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18512. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18513. designer.Workbook.Save(serverPath);
  18514. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18515. #region 删除指定行
  18516. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18517. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18518. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18519. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18520. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18521. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18522. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18523. cssIndex = dt.Columns["CityTax"].Ordinal,
  18524. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18525. remarkIndex = dt.Columns["Remark"].Ordinal;
  18526. //删除指定列
  18527. foreach (DataRow item in dt.Rows)
  18528. {
  18529. string singleStr = item["SingleRoomPrice"].ToString();
  18530. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18531. if (containsDigitButNotZero1) singleDel = false;
  18532. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18533. string doubleStr = item["DoubleRoomPrice"].ToString();
  18534. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18535. if (containsDigitButNotZero2) doubleDel = false;
  18536. string suiteStr = item["SuiteRoomPrice"].ToString();
  18537. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18538. if (containsDigitButNotZero3) suiteDel = false;
  18539. string otherStr = item["OtherRoomPrice"].ToString();
  18540. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18541. if (containsDigitButNotZero4) otherDel = false;
  18542. string zcStr = item["BreakfastPrice"].ToString();
  18543. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18544. if (containsDigitButNotZero5) zcDel = false;
  18545. string dsStr = item["GovernmentRent"].ToString();
  18546. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18547. if (containsDigitButNotZero6) dsDel = false;
  18548. string cssStr = item["CityTax"].ToString();
  18549. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18550. if (containsDigitButNotZero7) cssDel = false;
  18551. string cpStr = item["ConsumptionPatterns"].ToString();
  18552. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18553. string remarkStr = item["Remark"].ToString();
  18554. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18555. }
  18556. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18557. DeleteColumn(serverPath, cpIndex, cpDel);
  18558. DeleteColumn(serverPath, dsIndex, dsDel);
  18559. DeleteColumn(serverPath, cssIndex, cssDel);
  18560. DeleteColumn(serverPath, zcIndex, zcDel);
  18561. DeleteColumn(serverPath, otherIndex, otherDel);
  18562. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18563. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18564. DeleteColumn(serverPath, singleIndex, singleDel);
  18565. #endregion
  18566. //只保留第一个表格
  18567. DeleteSheet(serverPath);
  18568. return Ok(JsonView(true, "操作成功", url = rst));
  18569. }
  18570. else
  18571. {
  18572. _currency = _GroupCostParameter.Currency;
  18573. bool isIntType = int.TryParse(_currency, out int currId);
  18574. if (isIntType)
  18575. {
  18576. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18577. }
  18578. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18579. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18580. if (currInfo == null)
  18581. {
  18582. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18583. }
  18584. if (!_currency.ToUpper().Equals("CNY"))
  18585. {
  18586. _rate = _GroupCostParameter.Rate;
  18587. }
  18588. _rate = currInfo.Rate;
  18589. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18590. //string strFileName = "HotelStatement/";
  18591. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18592. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18593. #region 数据处理
  18594. foreach (var item in hrDtas)
  18595. {
  18596. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18597. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18598. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18599. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18600. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18601. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18602. string singleRoomFeeStr = string.Empty,
  18603. doubleRoomFeeStr = string.Empty,
  18604. suiteRoomFeeStr = string.Empty,
  18605. otherRoomFeeStr = string.Empty,
  18606. payMoneyStr = string.Empty,
  18607. cardPriceStr = string.Empty;
  18608. if (roomCurr.Equals(_currency))
  18609. {
  18610. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  18611. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  18612. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  18613. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  18614. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  18615. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  18616. }
  18617. else
  18618. {
  18619. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18620. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18621. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18622. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18623. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18624. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18625. }
  18626. string breakfastPriceStr = string.Empty,
  18627. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18628. governmentRentStr = string.Empty,
  18629. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18630. cityTaxStrStr = string.Empty,
  18631. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18632. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  18633. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  18634. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  18635. int payDId = roomInfo?.PayDId ?? 0;
  18636. pcfds.Add(new HotelReservations_PCFD_View()
  18637. {
  18638. City = item.City,
  18639. HotelName = item.HotelName,
  18640. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18641. // SingleRoomCount = item.SingleRoomCount,
  18642. SingleRoomPrice = singleRoomFeeStr,
  18643. // DoubleRoomCount = item.DoubleRoomCount,
  18644. DoubleRoomPrice = doubleRoomFeeStr,
  18645. //SuiteRoomCount = item.SuiteRoomCount,
  18646. SuiteRoomPrice = suiteRoomFeeStr,
  18647. OtherRoomPrice = otherRoomFeeStr,
  18648. //OtherRoomCount = item.OtherRoomCount,
  18649. BreakfastPrice = breakfastPriceStr,
  18650. GovernmentRent = governmentRentStr,
  18651. CityTax = cityTaxStrStr,
  18652. RoomExplanation = item.RoomExplanation,
  18653. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18654. PayTime = roomInfo?.ConsumptionDate,
  18655. BankNo = roomInfo?.BankNo,
  18656. PayMoney = payMoneyStr,
  18657. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18658. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18659. CardPrice = cardPriceStr,
  18660. Remark = ccpInfo.Remark
  18661. });
  18662. }
  18663. #endregion
  18664. //载入模板
  18665. WorkbookDesigner designer = new WorkbookDesigner();
  18666. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18667. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18668. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18669. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18670. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  18671. designer.SetDataSource("Opertor", userInfo.CnName);
  18672. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18673. dt.TableName = "ViewMyHotelReservations";
  18674. designer.SetDataSource(dt);
  18675. designer.Process();
  18676. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18677. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18678. designer.Workbook.Save(serverPath);
  18679. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18680. #region 删除指定行
  18681. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18682. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18683. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18684. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18685. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18686. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18687. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18688. cssIndex = dt.Columns["CityTax"].Ordinal,
  18689. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18690. remarkIndex = dt.Columns["Remark"].Ordinal;
  18691. //删除指定列
  18692. foreach (DataRow item in dt.Rows)
  18693. {
  18694. string singleStr = item["SingleRoomPrice"].ToString();
  18695. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18696. if (containsDigitButNotZero1) singleDel = false;
  18697. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18698. string doubleStr = item["DoubleRoomPrice"].ToString();
  18699. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18700. if (containsDigitButNotZero2) doubleDel = false;
  18701. string suiteStr = item["SuiteRoomPrice"].ToString();
  18702. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18703. if (containsDigitButNotZero3) suiteDel = false;
  18704. string otherStr = item["OtherRoomPrice"].ToString();
  18705. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18706. if (containsDigitButNotZero4) otherDel = false;
  18707. string zcStr = item["BreakfastPrice"].ToString();
  18708. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18709. if (containsDigitButNotZero5) zcDel = false;
  18710. string dsStr = item["GovernmentRent"].ToString();
  18711. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18712. if (containsDigitButNotZero6) dsDel = false;
  18713. string cssStr = item["CityTax"].ToString();
  18714. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18715. if (containsDigitButNotZero7) cssDel = false;
  18716. string cpStr = item["ConsumptionPatterns"].ToString();
  18717. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18718. string remarkStr = item["Remark"].ToString();
  18719. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18720. }
  18721. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18722. DeleteColumn(serverPath, cpIndex, cpDel);
  18723. DeleteColumn(serverPath, dsIndex, dsDel);
  18724. DeleteColumn(serverPath, cssIndex, cssDel);
  18725. DeleteColumn(serverPath, zcIndex, zcDel);
  18726. DeleteColumn(serverPath, otherIndex, otherDel);
  18727. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18728. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18729. DeleteColumn(serverPath, singleIndex, singleDel);
  18730. #endregion
  18731. //只保留第一个表格
  18732. DeleteSheet(serverPath);
  18733. return Ok(JsonView(true, "操作成功", url = rst));
  18734. }
  18735. //return Ok(JsonView(false));
  18736. }
  18737. /// <summary>
  18738. /// 删除指定列
  18739. /// </summary>
  18740. /// <param name="file"></param>
  18741. /// <param name="columnIndex"></param>
  18742. /// <param name="isDel"></param>
  18743. private void DeleteColumn(string file, int columnIndex, bool isDel)
  18744. {
  18745. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18746. //wb.Save(file);
  18747. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  18748. if (sheet1 != null)
  18749. {
  18750. if (isDel)
  18751. {
  18752. Cells cells = sheet1.Cells;
  18753. cells.DeleteColumn(columnIndex);
  18754. }
  18755. }
  18756. wb.Save(file);
  18757. }
  18758. /// <summary>
  18759. /// 删除sheet
  18760. /// </summary>
  18761. /// <param name="file"></param>
  18762. private void DeleteSheet(string file)
  18763. {
  18764. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18765. //wb.Save(file);
  18766. List<string> sheets = new List<string>();
  18767. foreach (var item in wb.Worksheets)
  18768. {
  18769. sheets.Add(item.Name);
  18770. }
  18771. if (sheets.Count > 0)
  18772. {
  18773. sheets.RemoveAt(0);//不删除第一个sheet
  18774. foreach (var item in sheets)
  18775. {
  18776. wb.Worksheets.RemoveAt(item);
  18777. }
  18778. }
  18779. wb.Save(file);
  18780. }
  18781. /// <summary>
  18782. /// 酒店预订
  18783. /// 确认单
  18784. /// </summary>
  18785. /// <param name="_dto"></param>
  18786. /// <returns></returns>
  18787. [HttpPost]
  18788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18789. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  18790. {
  18791. try
  18792. {
  18793. #region 参数验证
  18794. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18795. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18796. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18797. #region 团组操作权限验证 76 酒店预定模块
  18798. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18799. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18800. #endregion
  18801. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18802. #region 页面操作权限验证
  18803. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18804. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18805. #endregion
  18806. #endregion
  18807. //团组信息
  18808. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  18809. //酒店数据
  18810. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  18811. if (listhoteldata.Count < 0)
  18812. {
  18813. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  18814. }
  18815. //利datatable存储
  18816. DataTable dt = new DataTable();
  18817. dt.Columns.Add("CheckInDate", typeof(string));
  18818. dt.Columns.Add("City", typeof(string));
  18819. dt.Columns.Add("Hotel", typeof(string));
  18820. dt.Columns.Add("Room", typeof(string));
  18821. for (int i = 0; i < listhoteldata.Count; i++)
  18822. {
  18823. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  18824. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  18825. while (dayStart < dayEnd)
  18826. {
  18827. string temp = "";
  18828. DataRow row = dt.NewRow();
  18829. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  18830. row["City"] = listhoteldata[i].City;
  18831. row["Hotel"] = listhoteldata[i].HotelName;
  18832. if (listhoteldata[i].SingleRoomCount > 0)
  18833. {
  18834. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  18835. }
  18836. if (listhoteldata[i].DoubleRoomCount > 0)
  18837. {
  18838. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  18839. }
  18840. if (listhoteldata[i].SuiteRoomCount > 0)
  18841. {
  18842. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  18843. }
  18844. if (listhoteldata[i].OtherRoomCount > 0)
  18845. {
  18846. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  18847. }
  18848. row["Room"] = temp;
  18849. dt.Rows.Add(row);
  18850. dayStart = dayStart.AddDays(1);
  18851. }
  18852. }
  18853. Dictionary<string, string> dic = new Dictionary<string, string>();
  18854. dic.Add("Dele", di.TeamName);
  18855. dic.Add("City", di.VisitCountry);
  18856. //模板路径
  18857. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  18858. //载入模板
  18859. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  18860. DocumentBuilder builder = new DocumentBuilder(doc);
  18861. foreach (var key in dic.Keys)
  18862. {
  18863. builder.MoveToBookmark(key);
  18864. builder.Write(dic[key]);
  18865. }
  18866. //获取word里所有表格
  18867. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18868. //获取所填表格的序数
  18869. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18870. var rowStart = tableOne.Rows[0]; //获取第1行
  18871. //循环赋值
  18872. for (int i = 0; i < dt.Rows.Count; i++)
  18873. {
  18874. builder.MoveToCell(0, i + 1, 0, 0);
  18875. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  18876. builder.MoveToCell(0, i + 1, 1, 0);
  18877. builder.Write(dt.Rows[i]["City"].ToString());
  18878. builder.MoveToCell(0, i + 1, 2, 0);
  18879. builder.Write(dt.Rows[i]["Hotel"].ToString());
  18880. builder.MoveToCell(0, i + 1, 3, 0);
  18881. builder.Write(dt.Rows[i]["Room"].ToString());
  18882. }
  18883. //删除多余行
  18884. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  18885. {
  18886. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  18887. }
  18888. string strFileName = di.TeamName + "酒店确认单.doc";
  18889. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  18890. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  18891. return Ok(JsonView(true, "成功", url));
  18892. }
  18893. catch (Exception ex)
  18894. {
  18895. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  18896. }
  18897. }
  18898. #endregion
  18899. #region 团组状态
  18900. /// <summary>
  18901. /// 团组状态列表 Page
  18902. /// </summary>
  18903. /// <param name="dto">团组列表请求dto</param>
  18904. /// <returns></returns>
  18905. [HttpPost]
  18906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18907. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  18908. {
  18909. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18910. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  18911. {
  18912. string sqlWhere = string.Empty;
  18913. if (dto.IsSure == 0) //未完成
  18914. {
  18915. sqlWhere += string.Format(@" And IsSure = 0");
  18916. }
  18917. else if (dto.IsSure == 1) //已完成
  18918. {
  18919. sqlWhere += string.Format(@" And IsSure = 1");
  18920. }
  18921. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  18922. {
  18923. string tj = dto.SearchCriteria;
  18924. 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}%')",
  18925. tj, tj, tj, tj, tj);
  18926. }
  18927. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  18928. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  18929. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  18930. From (
  18931. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  18932. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  18933. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  18934. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  18935. From Grp_DelegationInfo gdi
  18936. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  18937. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  18938. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  18939. Where gdi.IsDel = 0 {0}
  18940. ) temp ", sqlWhere);
  18941. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  18942. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  18943. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  18944. }
  18945. else
  18946. {
  18947. return Ok(JsonView(false, "查询失败"));
  18948. }
  18949. }
  18950. /// <summary>
  18951. /// 团组状态
  18952. /// 设置操作完成
  18953. /// </summary>
  18954. /// <param name="dto">团组列表请求dto</param>
  18955. /// <returns></returns>
  18956. [HttpPost]
  18957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18958. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  18959. {
  18960. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18961. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  18962. {
  18963. Id = dto.Id,
  18964. IsSure = 1
  18965. };
  18966. var result = await _sqlSugar.Updateable(_DelegationInfo)
  18967. .UpdateColumns(it => new { it.IsSure })
  18968. .WhereColumns(it => new { it.Id })
  18969. .ExecuteCommandAsync();
  18970. if (result > 0)
  18971. {
  18972. return Ok(JsonView(true, "操作完成!"));
  18973. }
  18974. return Ok(JsonView(false, "操作失败!"));
  18975. }
  18976. #endregion
  18977. #region 保险费用录入
  18978. /// <summary>
  18979. /// 根据团组Id查询保险费用列表
  18980. /// </summary>
  18981. /// <param name="dto"></param>
  18982. /// <returns></returns>
  18983. [HttpPost]
  18984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18985. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  18986. {
  18987. Result groupData = await _customersRep.CustomersByDiId(dto);
  18988. if (groupData.Code != 0)
  18989. {
  18990. return Ok(JsonView(false, groupData.Msg));
  18991. }
  18992. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18993. }
  18994. /// <summary>
  18995. /// 根据保险费用Id查询保险费用详细
  18996. /// </summary>
  18997. /// <param name="dto"></param>
  18998. /// <returns></returns>
  18999. [HttpPost]
  19000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19001. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  19002. {
  19003. try
  19004. {
  19005. Result groupData = await _customersRep.CustomersById(dto);
  19006. if (groupData.Code != 0)
  19007. {
  19008. return Ok(JsonView(false, groupData.Msg));
  19009. }
  19010. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19011. }
  19012. catch (Exception ex)
  19013. {
  19014. return Ok(JsonView(false, ex.Message));
  19015. }
  19016. }
  19017. /// <summary>
  19018. /// 保险费用录入页面初始化绑定
  19019. /// </summary>
  19020. /// <param name="dto"></param>
  19021. /// <returns></returns>
  19022. [HttpPost]
  19023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19024. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  19025. {
  19026. try
  19027. {
  19028. Result groupData = await _customersRep.CustomersInitialize(dto);
  19029. if (groupData.Code != 0)
  19030. {
  19031. return Ok(JsonView(false, groupData.Msg));
  19032. }
  19033. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19034. }
  19035. catch (Exception ex)
  19036. {
  19037. return Ok(JsonView(false, ex.Message));
  19038. }
  19039. }
  19040. /// <summary>
  19041. /// 保险费用操作(Status:1.新增,2.修改)
  19042. /// </summary>
  19043. /// <param name="dto"></param>
  19044. /// <returns></returns>
  19045. [HttpPost]
  19046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19047. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  19048. {
  19049. Result groupData = await _customersRep.OpCustomers(dto);
  19050. if (groupData.Code != 0)
  19051. {
  19052. return Ok(JsonView(false, groupData.Msg));
  19053. }
  19054. #region 应用推送
  19055. try
  19056. {
  19057. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  19058. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  19059. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  19060. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  19061. //自动审核
  19062. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  19063. //2024-10-21 新增LZ UID
  19064. var userIds = new List<int>() { 21 };
  19065. string title = $"系统通知";
  19066. var diId = dto.DiId;
  19067. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  19068. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  19069. string content = "";
  19070. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19071. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19072. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  19073. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  19074. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  19075. }
  19076. catch (Exception ex)
  19077. {
  19078. }
  19079. #endregion
  19080. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19081. }
  19082. /// <summary>
  19083. /// 保险文件上传
  19084. /// </summary>
  19085. /// <param name="file"></param>
  19086. /// <returns></returns>
  19087. [HttpPost]
  19088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19089. public async Task<IActionResult> UploadCus(IFormFile file)
  19090. {
  19091. try
  19092. {
  19093. if (file != null)
  19094. {
  19095. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19096. //文件名称
  19097. string projectFileName = file.FileName;
  19098. //上传的文件的路径
  19099. string filePath = "";
  19100. if (!Directory.Exists(fileDir))
  19101. {
  19102. Directory.CreateDirectory(fileDir);
  19103. }
  19104. //上传的文件的路径
  19105. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  19106. using (FileStream fs = System.IO.File.Create(filePath))
  19107. {
  19108. file.CopyTo(fs);
  19109. fs.Flush();
  19110. }
  19111. return Ok(JsonView(true, "上传成功!", projectFileName));
  19112. }
  19113. else
  19114. {
  19115. return Ok(JsonView(false, "上传失败!"));
  19116. }
  19117. }
  19118. catch (Exception ex)
  19119. {
  19120. return Ok(JsonView(false, ex.Message));
  19121. }
  19122. }
  19123. /// <summary>
  19124. /// 保险删除指定文件
  19125. /// </summary>
  19126. /// <param name="dto"></param>
  19127. /// <returns></returns>
  19128. [HttpPost]
  19129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19130. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  19131. {
  19132. try
  19133. {
  19134. string filePath = "";
  19135. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19136. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  19137. //int id = 0;
  19138. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  19139. // 删除该文件
  19140. try
  19141. {
  19142. System.IO.File.Delete(filePath);
  19143. 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()
  19144. {
  19145. Attachment = "",
  19146. }).ExecuteCommandAsync();
  19147. if (result != 0)
  19148. {
  19149. return Ok(JsonView(true, "成功!"));
  19150. }
  19151. else
  19152. {
  19153. return Ok(JsonView(false, "失败!"));
  19154. }
  19155. }
  19156. catch (Exception)
  19157. {
  19158. 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()
  19159. {
  19160. Attachment = "",
  19161. }).ExecuteCommandAsync();
  19162. if (result != 0)
  19163. {
  19164. return Ok(JsonView(true, "成功!"));
  19165. }
  19166. else
  19167. {
  19168. return Ok(JsonView(false, "失败!"));
  19169. }
  19170. }
  19171. }
  19172. catch (Exception ex)
  19173. {
  19174. return Ok(JsonView(false, "程序错误!"));
  19175. throw;
  19176. }
  19177. }
  19178. /// <summary>
  19179. /// 保险费用操作(删除)
  19180. /// </summary>
  19181. /// <param name="dto"></param>
  19182. /// <returns></returns>
  19183. [HttpPost]
  19184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19185. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  19186. {
  19187. try
  19188. {
  19189. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  19190. if (!res)
  19191. {
  19192. return Ok(JsonView(false, "删除失败"));
  19193. }
  19194. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  19195. {
  19196. IsDel = 1,
  19197. DeleteUserId = dto.DeleteUserId,
  19198. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  19199. }).ExecuteCommandAsync();
  19200. return Ok(JsonView(true, "删除成功!"));
  19201. }
  19202. catch (Exception ex)
  19203. {
  19204. return Ok(JsonView(false, "程序错误!"));
  19205. throw;
  19206. }
  19207. }
  19208. #endregion
  19209. #region 接团客户名单 PageId 104
  19210. /// <summary>
  19211. /// 接团客户名单
  19212. /// 迁移数据(慎用!)
  19213. /// </summary>
  19214. /// <returns></returns>
  19215. [HttpPost]
  19216. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19217. public async Task<IActionResult> PostTourClientListChange()
  19218. {
  19219. try
  19220. {
  19221. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  19222. //var groupClinetData1
  19223. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  19224. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  19225. int updateCount = 0;
  19226. if (oldOAClientList.Count > 0)
  19227. {
  19228. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  19229. _sqlSugar.BeginTran();
  19230. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  19231. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  19232. foreach (var item in oldOAClientList)
  19233. {
  19234. int comId = 0;
  19235. string format = "yyyy-MM-dd HH:mm:ss";
  19236. string data11 = "1990-01-01 00:00";
  19237. var data1 = IsValidDate(item.OPdate, format);
  19238. if (data1) data11 = item.OPdate;
  19239. //客户公司验证
  19240. if (!string.IsNullOrEmpty(item.Company))
  19241. {
  19242. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  19243. if (clientComInfo == null) // add
  19244. {
  19245. var addInfo = new Crm_CustomerCompany()
  19246. {
  19247. CompanyAbbreviation = "",
  19248. CompanyFullName = item.Company,
  19249. Address = "",
  19250. PostCodes = "",
  19251. LastedOpUserId = item.OPer,
  19252. LastedOpDt = Convert.ToDateTime(data11),
  19253. CreateUserId = item.OPer,
  19254. CreateTime = Convert.ToDateTime(data11),
  19255. IsDel = 0
  19256. };
  19257. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  19258. if (comId1 > 0) comId = comId1;
  19259. }
  19260. else comId = clientComInfo.Id;
  19261. }
  19262. //客户人员验证
  19263. int clientId = 0;
  19264. string name = item.LastName + item.Name;
  19265. if (!string.IsNullOrEmpty(name))
  19266. {
  19267. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  19268. if (clientInfo == null)
  19269. {
  19270. DateTime? dateTime = null;
  19271. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  19272. if (isDt) dateTime = birthDayDt;
  19273. var addInfo1 = new Crm_DeleClient()
  19274. {
  19275. CrmCompanyId = comId,
  19276. DiId = -1,
  19277. LastName = item.LastName,
  19278. FirstName = item.Name,
  19279. OldName = "",
  19280. Pinyin = item.Pinyin,
  19281. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  19282. Marriage = 0,
  19283. Phone = item.Phone,
  19284. Job = item.Job,
  19285. BirthDay = dateTime
  19286. };
  19287. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  19288. if (clientId1 > 0) clientId = clientId1;
  19289. }
  19290. else clientId = clientInfo.Id;
  19291. }
  19292. if (clientId < 1)
  19293. {
  19294. continue;
  19295. }
  19296. int airType = 0;
  19297. if (item.AirType == "超经舱") airType = 459;
  19298. else if (item.AirType == "公务舱") airType = 458;
  19299. else if (item.AirType == "经济舱") airType = 460;
  19300. else if (item.AirType == "其他") airType = 565;
  19301. else if (item.AirType == "头等舱") airType = 457;
  19302. var _TourClientListEntity = new Grp_TourClientList()
  19303. {
  19304. DiId = item.Diid,
  19305. ClientId = clientId,
  19306. CreateUserId = item.OPer,
  19307. CreateTime = Convert.ToDateTime(data11),
  19308. Remark = item.Remark,
  19309. IsDel = item.Isdel,
  19310. ShippingSpaceTypeId = airType,
  19311. ShippingSpaceSpecialNeeds = item.AirRemark,
  19312. HotelSpecialNeeds = item.RoomType
  19313. };
  19314. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  19315. if (_TourClientList > 0)
  19316. {
  19317. updateCount++;
  19318. }
  19319. }
  19320. _sqlSugar.CommitTran();
  19321. }
  19322. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  19323. }
  19324. catch (Exception ex)
  19325. {
  19326. _sqlSugar.RollbackTran();
  19327. return Ok(JsonView(false, ex.Message));
  19328. }
  19329. //return Ok(JsonView(true));
  19330. }
  19331. private bool IsValidDate(string dateString, string format)
  19332. {
  19333. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  19334. }
  19335. /// <summary>
  19336. /// 接团客户名单
  19337. /// 根据团组Id查询List
  19338. /// </summary>
  19339. /// <param name="_dto"></param>
  19340. /// <returns></returns>
  19341. [HttpPost]
  19342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19343. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  19344. {
  19345. #region 参数验证
  19346. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  19347. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  19348. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  19349. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19350. #region 页面操作权限验证
  19351. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19352. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19353. #endregion
  19354. #endregion
  19355. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  19356. if (viewData.Code != 0)
  19357. {
  19358. return Ok(JsonView(false, viewData.Msg));
  19359. }
  19360. return Ok(JsonView(viewData.Data));
  19361. }
  19362. /// <summary>
  19363. /// 接团客户名单
  19364. /// 基础数据 Init
  19365. /// </summary>
  19366. /// <param name="_dto"></param>
  19367. /// <returns></returns>
  19368. [HttpPost]
  19369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19370. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  19371. {
  19372. #region 参数验证
  19373. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19374. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19375. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19376. #region 页面操作权限验证
  19377. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19378. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19379. #endregion
  19380. #endregion
  19381. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  19382. }
  19383. /// <summary>
  19384. /// 接团客户名单
  19385. /// 根据 Id查询 Details
  19386. /// </summary>
  19387. /// <param name="_dto"></param>
  19388. /// <returns></returns>
  19389. [HttpPost]
  19390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19391. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  19392. {
  19393. #region 参数验证
  19394. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19395. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19396. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19397. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19398. #region 页面操作权限验证
  19399. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19400. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19401. #endregion
  19402. #endregion
  19403. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  19404. if (viewData.Code != 0)
  19405. {
  19406. return Ok(JsonView(false, viewData.Msg));
  19407. }
  19408. return Ok(JsonView(viewData.Data));
  19409. }
  19410. /// <summary>
  19411. /// 接团客户名单
  19412. /// Add Or Edit
  19413. /// </summary>
  19414. /// <param name="_dto"></param>
  19415. /// <returns></returns>
  19416. [HttpPost]
  19417. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19418. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  19419. {
  19420. #region 参数验证
  19421. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19422. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19423. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19424. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19425. #region 页面操作权限验证
  19426. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19427. if (_dto.Id == 0) //添加
  19428. {
  19429. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19430. }
  19431. else if (_dto.Id >= 0) //修改
  19432. {
  19433. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  19434. }
  19435. #endregion
  19436. #endregion
  19437. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  19438. if (viewData.Code != 0)
  19439. {
  19440. return Ok(JsonView(false, viewData.Msg));
  19441. }
  19442. return Ok(JsonView(true));
  19443. }
  19444. /// <summary>
  19445. /// 接团客户名单
  19446. /// json字符串 AddMultiple(添加多个)
  19447. /// </summary>
  19448. /// <param name="_dto"></param>
  19449. /// <returns></returns>
  19450. [HttpPost]
  19451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19452. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  19453. {
  19454. #region 参数验证
  19455. string jsonLabel = _dto.JsonLabel;
  19456. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19457. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19458. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19459. #region 页面操作权限验证
  19460. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19461. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19462. #endregion
  19463. #endregion
  19464. var request = new TourClientListAddMultipleDto();
  19465. request.DiId = _dto.DiId;
  19466. request.UserId = _dto.UserId;
  19467. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  19468. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  19469. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  19470. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  19471. var infos = new List<TourClientListInfo>();
  19472. foreach (var data in datas)
  19473. {
  19474. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  19475. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  19476. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  19477. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  19478. {
  19479. continue;
  19480. }
  19481. infos.Add(new TourClientListInfo()
  19482. {
  19483. IsAccompany = 1,
  19484. LastName = lastName,
  19485. FirstName = firstName,
  19486. Pinyin = lastNameEn + @"/" + firstNameEn,
  19487. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  19488. CompanyFullName = data.CompanyFullName,
  19489. Job = data.Job
  19490. });
  19491. }
  19492. if (infos.Any())
  19493. {
  19494. var viewData = await _tourClientListRep._AddMultiple(request);
  19495. if (viewData.Code != 0)
  19496. {
  19497. return Ok(JsonView(false, viewData.Msg));
  19498. }
  19499. return Ok(JsonView(true));
  19500. }
  19501. return Ok(JsonView(false));
  19502. }
  19503. /// <summary>
  19504. /// 接团客户名单
  19505. /// AddMultiple(添加多个)
  19506. /// </summary>
  19507. /// <param name="_dto"></param>
  19508. /// <returns></returns>
  19509. [HttpPost]
  19510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19511. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  19512. {
  19513. #region 参数验证
  19514. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19515. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19516. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19517. #region 页面操作权限验证
  19518. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19519. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19520. #endregion
  19521. #endregion
  19522. var viewData = await _tourClientListRep._AddMultiple(_dto);
  19523. if (viewData.Code != 0)
  19524. {
  19525. return Ok(JsonView(false, viewData.Msg));
  19526. }
  19527. return Ok(JsonView(true));
  19528. }
  19529. /// <summary>
  19530. /// 接团客户名单
  19531. /// Del
  19532. /// </summary>
  19533. /// <param name="_dto"></param>
  19534. /// <returns></returns>
  19535. [HttpPost]
  19536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19537. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  19538. {
  19539. #region 参数验证
  19540. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19541. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19542. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19543. #region 页面操作权限验证
  19544. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19545. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  19546. #endregion
  19547. #endregion
  19548. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  19549. if (viewData.Code != 0)
  19550. {
  19551. return Ok(JsonView(false, viewData.Msg));
  19552. }
  19553. return Ok(JsonView(true));
  19554. }
  19555. /// <summary>
  19556. /// 接团客户名单
  19557. /// 文件下载 客户名单
  19558. /// </summary>
  19559. /// <param name="_dto"></param>
  19560. /// <returns></returns>
  19561. [HttpPost]
  19562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19563. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  19564. {
  19565. #region 参数验证
  19566. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19567. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19568. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  19569. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19570. #region 页面操作权限验证
  19571. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19572. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19573. #endregion
  19574. #endregion
  19575. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  19576. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  19577. From Grp_TourClientList tcl
  19578. Left Join
  19579. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  19580. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  19581. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  19582. From Crm_DeleClient dc
  19583. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  19584. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  19585. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  19586. Where dc.IsDel = 0) temp
  19587. On temp.DcId =tcl.ClientId
  19588. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  19589. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  19590. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  19591. //载入模板
  19592. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  19593. if (_dto.Language == 1)
  19594. {
  19595. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  19596. }
  19597. //载入模板
  19598. var doc = new Document(tempPath);
  19599. DocumentBuilder builder = new DocumentBuilder(doc);
  19600. //获取word里所有表格
  19601. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19602. //获取所填表格的序数
  19603. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19604. var rowStart = tableOne.Rows[0]; //获取第1行
  19605. if (_dto.Language == 0)
  19606. {
  19607. //循环赋值
  19608. for (int i = 0; i < DcList.Count; i++)
  19609. {
  19610. EncryptionProcessor.DecryptProperties(DcList[i]);
  19611. builder.MoveToCell(0, i + 1, 0, 0);
  19612. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  19613. builder.MoveToCell(0, i + 1, 1, 0);
  19614. int sex = DcList[i].Sex;
  19615. string sexStr = string.Empty;
  19616. if (sex == 0) sexStr = "男";
  19617. else if (sex == 1) sexStr = "女";
  19618. else sexStr = "未设置";
  19619. builder.Write(sexStr);
  19620. builder.MoveToCell(0, i + 1, 2, 0);
  19621. string birthDay = DcList[i].BirthDay;
  19622. string birthDayStr = string.Empty;
  19623. if (!string.IsNullOrEmpty(birthDay))
  19624. {
  19625. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  19626. }
  19627. builder.Write(birthDayStr);
  19628. builder.MoveToCell(0, i + 1, 3, 0);
  19629. string company = "";
  19630. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19631. {
  19632. company = DcList[i].CompanyFullName.ToString();
  19633. }
  19634. builder.Write(company);
  19635. builder.MoveToCell(0, i + 1, 4, 0);
  19636. builder.Write(DcList[i].Job);
  19637. }
  19638. }
  19639. else if (_dto.Language == 1)
  19640. {
  19641. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  19642. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  19643. List<string> transArrayStr = new List<string>();
  19644. string transStrRes1 = "";
  19645. for (int i = 0; i < DcList.Count; i++)
  19646. {
  19647. var dc = DcList[i];
  19648. EncryptionProcessor.DecryptProperties(dc);
  19649. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  19650. if (dc.Job.Equals("暂无")) dc.Job = "-";
  19651. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  19652. if (DcList.Count - 1 == i) transStrRes1 += str1;
  19653. else transStrRes1 += $"{str1}|";
  19654. }
  19655. #region AI转英文
  19656. string jsonValue = JsonConvert.SerializeObject(DcList);
  19657. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  19658. List<SeedMessages> messages = new List<SeedMessages>()
  19659. {
  19660. new SeedMessages
  19661. {
  19662. Role = KimiRole.user,
  19663. Content = jsonValue + text
  19664. }
  19665. };
  19666. KiMiApiClient client = new KiMiApiClient();
  19667. var kimiApiResult = await client.SeedMessage(messages);
  19668. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19669. string clients = kimiApiResult_JObject["content"].ToString();
  19670. string startStr = "```json", endStr = "```";
  19671. // 判断并清除开头部分
  19672. if (clients.StartsWith(startStr))
  19673. {
  19674. clients = clients.Remove(0, startStr.Length);
  19675. }
  19676. // 判断并清除结尾部分
  19677. if (clients.EndsWith(endStr))
  19678. {
  19679. clients = clients.Remove(clients.Length - endStr.Length);
  19680. }
  19681. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  19682. //循环赋值
  19683. for (int i = 0; i < en_Json.Count; i++)
  19684. {
  19685. var dc = en_Json[i];
  19686. var dc1 = DcList.Find(x => x.Id == dc.Id);
  19687. string PYName = dc.FirstName + " " + dc.LastName;
  19688. builder.MoveToCell(0, i + 1, 0, 0);
  19689. builder.Write(PYName);
  19690. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  19691. builder.MoveToCell(0, i + 1, 1, 0);
  19692. builder.Write(sex);
  19693. DateTime birthDt;
  19694. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  19695. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19696. builder.MoveToCell(0, i + 1, 2, 0);
  19697. builder.Write(birthday);
  19698. string company = string.Empty, job = string.Empty;
  19699. company = dc.CompanyFullName;
  19700. job = dc.Job;
  19701. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  19702. {
  19703. //查询对照表
  19704. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  19705. if (tempCec != null)
  19706. {
  19707. company = tempCec.enName;
  19708. }
  19709. }
  19710. builder.MoveToCell(0, i + 1, 3, 0);
  19711. builder.Write(company);
  19712. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  19713. {
  19714. //查询对照表
  19715. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  19716. if (tempPec != null)
  19717. {
  19718. job = tempPec.enName;
  19719. }
  19720. }
  19721. builder.MoveToCell(0, i + 1, 4, 0);
  19722. builder.Write(job);
  19723. }
  19724. #endregion
  19725. #region 旧翻译英文处理
  19726. ////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";
  19727. //string transStrRes = "";
  19728. //if (transStrRes1.Length > 0)
  19729. //{
  19730. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  19731. //}
  19732. ////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
  19733. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  19734. ////List<string> transArray = new List<string> { };
  19735. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  19736. //if (transStrRes.Contains("|"))
  19737. //{
  19738. // string[] transArray1 = transStrRes.Split('|');
  19739. // if (transArray1.Length > 0)
  19740. // {
  19741. // foreach (var item in transArray1)
  19742. // {
  19743. // if (item.Contains("&"))
  19744. // {
  19745. // string[] transArray2 = item.Split('&');
  19746. // int index = 0;
  19747. // string companyName = "", job = "";
  19748. // if (transArray2.Length > 0)
  19749. // {
  19750. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  19751. // if (1 < transArray2.Length) companyName = transArray2[1];
  19752. // if (2 < transArray2.Length) job = transArray2[2];
  19753. // }
  19754. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  19755. // }
  19756. // }
  19757. // }
  19758. //}
  19759. ////循环赋值
  19760. //for (int i = 0; i < DcList.Count; i++)
  19761. //{
  19762. // string PYName = "";
  19763. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  19764. // {
  19765. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  19766. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  19767. // PYName = PY_First + " " + PY_Last;
  19768. // }
  19769. // else
  19770. // {
  19771. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  19772. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  19773. // PYName = PY_First + " " + PY_Last;
  19774. // }
  19775. // builder.MoveToCell(0, i + 1, 0, 0);
  19776. // builder.Write(PYName);
  19777. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  19778. // builder.MoveToCell(0, i + 1, 1, 0);
  19779. // builder.Write(sex);
  19780. // DateTime birthDt;
  19781. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  19782. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19783. // builder.MoveToCell(0, i + 1, 2, 0);
  19784. // builder.Write(birthday);
  19785. // string company = string.Empty, job = string.Empty;
  19786. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  19787. // if (dcTransInfo != null)
  19788. // {
  19789. // company = dcTransInfo.CompanyName;
  19790. // job = dcTransInfo.Job;
  19791. // }
  19792. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19793. // {
  19794. // //查询对照表
  19795. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  19796. // if (tempCec != null)
  19797. // {
  19798. // company = tempCec.enName;
  19799. // }
  19800. // //翻译
  19801. // else
  19802. // {
  19803. // }
  19804. // }
  19805. // builder.MoveToCell(0, i + 1, 3, 0);
  19806. // builder.Write(company);
  19807. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  19808. // {
  19809. // //查询对照表
  19810. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  19811. // if (tempPec != null)
  19812. // {
  19813. // job = tempPec.enName;
  19814. // }
  19815. // //翻译
  19816. // else
  19817. // {
  19818. // }
  19819. // }
  19820. // builder.MoveToCell(0, i + 1, 4, 0);
  19821. // builder.Write(job);
  19822. //}
  19823. #endregion
  19824. }
  19825. //删除多余行
  19826. while (tableOne.Rows.Count > DcList.Count + 1)
  19827. {
  19828. tableOne.Rows.RemoveAt(DcList.Count + 1);
  19829. }
  19830. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  19831. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  19832. doc.Save(fileDir);
  19833. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  19834. return Ok(JsonView(true, "操作成功!", Url));
  19835. }
  19836. private class TranslateInfo
  19837. {
  19838. public int Index { get; set; }
  19839. public string CompanyName { get; set; }
  19840. public string Job { get; set; }
  19841. }
  19842. [HttpPost]
  19843. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  19844. {
  19845. if (files.Count == 0)
  19846. {
  19847. return Ok(JsonView(false, "文件为空"));
  19848. }
  19849. KiMiApiClient KiMiApi = new KiMiApiClient();
  19850. var seedConter = await KiMiApi.UploadFilesAsync(files);
  19851. if (seedConter.Count == 0)
  19852. {
  19853. return Ok(JsonView(false, "上传结果为空!"));
  19854. }
  19855. var messages = new List<SeedMessages>
  19856. {
  19857. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  19858. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  19859. };
  19860. messages.InsertRange(1, seedConter);
  19861. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  19862. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19863. string clients = kimiApiResult_JObject["content"].ToString();
  19864. string startStr = "```json", endStr = "```";
  19865. // 判断并清除开头部分
  19866. if (clients.StartsWith(startStr))
  19867. {
  19868. clients = clients.Remove(0, startStr.Length);
  19869. }
  19870. // 判断并清除结尾部分
  19871. if (clients.EndsWith(endStr))
  19872. {
  19873. clients = clients.Remove(clients.Length - endStr.Length);
  19874. }
  19875. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  19876. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  19877. {
  19878. {"姓", "LastName" },
  19879. {"名", "FirstName" },
  19880. {"姓名拼音", "Pinyin" },
  19881. {"性别", "Sex" },
  19882. {"单位", "CompanyFullName" },
  19883. {"职务", "Job" },
  19884. {"出生日期", "Birthday" },
  19885. };
  19886. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  19887. foreach (var item in clients_JObject)
  19888. {
  19889. BaiduClientOCRView cdc = new BaiduClientOCRView();
  19890. foreach (var field in clientFieldMap.Keys)
  19891. {
  19892. if (item.TryGetValue(field, out JToken value))
  19893. {
  19894. var getValue = value.ToString();
  19895. System.Type type = cdc.GetType();
  19896. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  19897. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  19898. propertyInfo.SetValue(cdc, propertyValue);
  19899. }
  19900. }
  19901. crmClients.Add(cdc);
  19902. }
  19903. return Ok(JsonView(new
  19904. {
  19905. fileCount = files.Count,
  19906. UploadCount = seedConter.Count,
  19907. ApiResult = clients,
  19908. CrmClients = crmClients
  19909. }));
  19910. }
  19911. #endregion
  19912. #region 团组倒推表
  19913. /// <summary>
  19914. /// 倒推表基础数据
  19915. /// Init
  19916. /// </summary>
  19917. /// <returns></returns>
  19918. [HttpPost]
  19919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19920. public async Task<IActionResult> PostInvertedListInit()
  19921. {
  19922. var viewData = await _invertedListRep._Init();
  19923. if (viewData.Code != 0)
  19924. {
  19925. return Ok(JsonView(false, viewData.Msg));
  19926. }
  19927. return Ok(JsonView(viewData.Data));
  19928. }
  19929. /// <summary>
  19930. /// 倒推表
  19931. /// Info
  19932. /// </summary>
  19933. /// <param name="dto"></param>
  19934. /// <returns></returns>
  19935. [HttpPost]
  19936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19937. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  19938. {
  19939. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  19940. if (viewData.Code != 0)
  19941. {
  19942. return Ok(JsonView(false, viewData.Msg));
  19943. }
  19944. return Ok(JsonView(viewData.Data));
  19945. }
  19946. /// <summary>
  19947. /// 倒推表
  19948. /// Create
  19949. /// </summary>
  19950. /// <param name="dto"></param>
  19951. /// <returns></returns>
  19952. [HttpPost]
  19953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19954. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  19955. {
  19956. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  19957. if (viewData.Code != 0)
  19958. {
  19959. return Ok(JsonView(false, viewData.Msg));
  19960. }
  19961. return Ok(JsonView(viewData.Data));
  19962. }
  19963. /// <summary>
  19964. /// 倒推表
  19965. /// Update
  19966. /// </summary>
  19967. /// <param name="dto"></param>
  19968. /// <returns></returns>
  19969. [HttpPost]
  19970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19971. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  19972. {
  19973. var viewData = await _invertedListRep._Update(dto);
  19974. if (viewData.Code != 0)
  19975. {
  19976. return Ok(JsonView(false, viewData.Msg));
  19977. }
  19978. return Ok(JsonView(viewData.Data));
  19979. }
  19980. /// <summary>
  19981. /// 倒推表
  19982. /// File Download
  19983. /// </summary>
  19984. /// <param name="dto"></param>
  19985. /// <returns></returns>
  19986. [HttpPost]
  19987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19988. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  19989. {
  19990. var info2 = await _invertedListRep._Info(1, dto.DiId);
  19991. if (info2.Code != 0)
  19992. {
  19993. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  19994. }
  19995. var info1 = info2.Data as InvertedListInfoView;
  19996. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  19997. string teamName = "";
  19998. if (info != null) teamName = info.TeamName;
  19999. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  20000. var doc = new Document();
  20001. var builder = new DocumentBuilder(doc);
  20002. #region old insert
  20003. ////载入模板
  20004. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  20005. //Document doc = new Document(tempPath);
  20006. //DocumentBuilder builder = new DocumentBuilder(doc);
  20007. //利用键值对存放数据
  20008. //Dictionary<string, string> dic = new Dictionary<string, string>();
  20009. //dic.Add("TeamName", teamName);
  20010. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  20011. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  20012. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  20013. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  20014. //dic.Add("SQRemark", info1.ApprovalRemark);
  20015. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  20016. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  20017. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  20018. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  20019. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  20020. //dic.Add("QZRemark", info1.VisaInformationRemark);
  20021. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  20022. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  20023. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  20024. //dic.Add("CQRemark", info1.IssueVisaRemark);
  20025. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  20026. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  20027. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  20028. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  20029. //#region 填充word模板书签内容
  20030. //foreach (var key in dic.Keys)
  20031. //{
  20032. // builder.MoveToBookmark(key);
  20033. // builder.Write(dic[key]);
  20034. //}
  20035. //#endregion
  20036. #endregion
  20037. #region New Insert
  20038. string titleFont = $"仿宋",
  20039. contentFont = $"仿宋";
  20040. var fontColor = Color.FromArgb(64, 64, 64);
  20041. //设置标题 团组名称
  20042. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20043. builder.Font.Name = titleFont;
  20044. builder.Font.Color = fontColor;
  20045. builder.Font.Size = 12;
  20046. builder.Font.Bold = true;
  20047. builder.Writeln(teamName);
  20048. //设置副标题 团组出访时间
  20049. builder.Font.Size = 12;
  20050. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  20051. builder.Writeln();
  20052. var backgroundColor = Color.FromArgb(199, 199, 199);
  20053. var table = builder.StartTable();
  20054. builder.InsertCell();
  20055. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  20056. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  20057. builder.CellFormat.Borders.LineWidth = 1;
  20058. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  20059. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  20060. builder.RowFormat.Height = 40;
  20061. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20062. builder.Font.Name = contentFont;
  20063. builder.Font.Size = 12;
  20064. builder.Font.Bold = true;
  20065. builder.Font.Color = fontColor;
  20066. builder.Write("时间");
  20067. builder.InsertCell();
  20068. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  20069. builder.Write("流程");
  20070. builder.InsertCell();
  20071. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  20072. builder.Write("说明");
  20073. builder.EndRow();
  20074. //报批资料准备
  20075. if (info1.IsSelectedAirportd)
  20076. {
  20077. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  20078. }
  20079. //报批/提供送签资料
  20080. if (info1.IsSelectedApprovalData)
  20081. {
  20082. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  20083. }
  20084. //出批件护照办理
  20085. if (info1.IsSelectedIssueApproval)
  20086. {
  20087. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  20088. }
  20089. //签证资料准备
  20090. if (info1.IsSelectedVisaInfo)
  20091. {
  20092. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  20093. }
  20094. //送签
  20095. if (info1.IsSelectedSendVisa)
  20096. {
  20097. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  20098. }
  20099. //出签
  20100. if (info1.IsSelectedIssueVisa)
  20101. {
  20102. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  20103. }
  20104. //机票
  20105. if (info1.IsSelectedAirTicket)
  20106. {
  20107. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  20108. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  20109. }
  20110. //酒店
  20111. if (info1.IsSelectedHotel)
  20112. {
  20113. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  20114. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  20115. }
  20116. //开行前会
  20117. if (info1.IsSelectedPreTripMeeting)
  20118. {
  20119. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  20120. }
  20121. //送机
  20122. if (info1.IsSelectedAirportdDropOff)
  20123. {
  20124. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  20125. }
  20126. builder.EndTable();
  20127. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  20128. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  20129. for (int i = 0; i < table.Rows.Count; i++)
  20130. {
  20131. var row = table.Rows[i];
  20132. //设置宽度
  20133. row.Cells[0].CellFormat.Width = 20.00;
  20134. row.Cells[1].CellFormat.Width = 30.00;
  20135. row.Cells[2].CellFormat.Width = 50.00;
  20136. if (i != 0)
  20137. {
  20138. //边框设置
  20139. InvertedListFileDownloadSetBorders(row.Cells, 0);
  20140. InvertedListFileDownloadSetBorders(row.Cells, 1);
  20141. InvertedListFileDownloadSetBorders(row.Cells, 2);
  20142. }
  20143. }
  20144. #region 页脚插入图片
  20145. // 创建页脚
  20146. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  20147. doc.FirstSection.HeadersFooters.Add(footer);
  20148. Paragraph para = new Paragraph(doc);
  20149. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  20150. footer.AppendChild(para);
  20151. builder.MoveTo(para);
  20152. string imagePath = "./Images/FMGJ_Log.png";
  20153. builder.InsertImage(imagePath);
  20154. #endregion
  20155. #endregion
  20156. var fileDir = AppSettingsHelper.Get("WordBasePath");
  20157. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  20158. string filePath = fileDir + $@"InvertedList/{fileName}";
  20159. doc.Save(filePath);
  20160. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  20161. return Ok(JsonView(true, "操作成功!", Url));
  20162. }
  20163. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  20164. {
  20165. var fontColor = Color.FromArgb(64, 64, 64);
  20166. builder.InsertCell();
  20167. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  20168. builder.RowFormat.Height = 40;
  20169. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20170. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20171. builder.Font.Name = fontName;
  20172. builder.Font.Size = 8;
  20173. builder.Font.Bold = true;
  20174. builder.Font.Color = fontColor;
  20175. builder.Write(dateTime);
  20176. builder.InsertCell();
  20177. builder.Font.Size = 9;
  20178. builder.Font.Bold = true;
  20179. builder.Font.Color = fontColor;
  20180. builder.Write(content);
  20181. builder.InsertCell();
  20182. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20183. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20184. builder.Font.Size = 9;
  20185. builder.Font.Bold = false;
  20186. builder.Font.Color = fontColor;
  20187. builder.Write(reamrk);
  20188. builder.EndRow();
  20189. }
  20190. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  20191. {
  20192. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  20193. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  20194. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  20195. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  20196. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  20197. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  20198. }
  20199. #endregion
  20200. #region 会务倒推表
  20201. /// <summary>
  20202. /// 会务倒推表
  20203. /// Init
  20204. /// </summary>
  20205. /// <returns></returns>
  20206. [HttpPost]
  20207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20208. public async Task<IActionResult> InforRetrogressTableInit()
  20209. {
  20210. var groupData = await _groupRepository.PostShareGroupInfos(1);
  20211. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  20212. return Ok(JsonView(false, groupData.Msg));
  20213. }
  20214. /// <summary>
  20215. /// 会务倒推表
  20216. /// ExcelDownload
  20217. /// </summary>
  20218. /// <param name="dto"></param>
  20219. /// <returns></returns>
  20220. [HttpPost]
  20221. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  20222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20223. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  20224. {
  20225. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  20226. var validatorRes = await validator.ValidateAsync(dto);
  20227. if (!validatorRes.IsValid)
  20228. {
  20229. StringBuilder sb = new StringBuilder();
  20230. foreach (var item in validatorRes.Errors)
  20231. {
  20232. sb.AppendLine(item.ErrorMessage);
  20233. }
  20234. return Ok(JsonView(false, sb.ToString()));
  20235. }
  20236. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20237. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20238. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20239. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20240. #region Excel
  20241. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  20242. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  20243. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  20244. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  20245. var fileNamePrefix = string.Empty;
  20246. if (days >= 30)
  20247. {
  20248. tempPath += $"会务工作倒推进度表(30天).xlsx";
  20249. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  20250. }
  20251. else if (days < 30 && days > 7)
  20252. {
  20253. tempPath += $"会务工作倒推进度表(15天).xlsx";
  20254. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  20255. }
  20256. else if (days <= 7)
  20257. {
  20258. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20259. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20260. }
  20261. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  20262. fileName = CommonFun.ValidFileName(fileName);
  20263. //载入模板
  20264. WorkbookDesigner designer = new WorkbookDesigner();
  20265. designer.Workbook = new Workbook(tempPath);
  20266. designer.Process();
  20267. if (!Directory.Exists(savePath))
  20268. {
  20269. Directory.CreateDirectory(savePath);
  20270. }
  20271. string serverPath = $"{savePath}{fileName}";
  20272. designer.Workbook.Save(serverPath);
  20273. string rst = $"{servicePath}{ftpPath}{fileName}";
  20274. #endregion
  20275. return Ok(JsonView(new { url = rst }));
  20276. }
  20277. #endregion
  20278. #region 三公签证费用(签证费、代办费)
  20279. /// <summary>
  20280. /// 三公签证费用(签证费、代办费)
  20281. /// List
  20282. /// </summary>
  20283. /// <returns></returns>
  20284. [HttpPost]
  20285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20286. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  20287. {
  20288. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  20289. if (_view.Code != 0)
  20290. {
  20291. return Ok(JsonView(false, _view.Msg));
  20292. }
  20293. return Ok(JsonView(true, "操作成功!", _view.Data));
  20294. }
  20295. /// <summary>
  20296. /// 三公签证费用(签证费、代办费)
  20297. /// Add Or Update
  20298. /// </summary>
  20299. /// <returns></returns>
  20300. [HttpPost]
  20301. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20302. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  20303. {
  20304. var _view = await _visaFeeInfoRep._Update(_dto);
  20305. if (_view.Code != 0)
  20306. {
  20307. return Ok(JsonView(false, _view.Msg));
  20308. }
  20309. return Ok(JsonView(true, _view.Msg));
  20310. }
  20311. #endregion
  20312. #region 酒店询价
  20313. /// <summary>
  20314. /// 酒店询价
  20315. /// Init
  20316. /// </summary>
  20317. /// <returns></returns>
  20318. [HttpPost]
  20319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20320. public async Task<IActionResult> PostHotelInquiryInit()
  20321. {
  20322. var res = await _hotelInquiryRep._Init();
  20323. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20324. return Ok(JsonView(true, res.Msg, res.Data));
  20325. }
  20326. /// <summary>
  20327. /// 酒店询价
  20328. /// page Item
  20329. /// </summary>
  20330. /// <param name="_dto"></param>
  20331. /// <returns></returns>
  20332. [HttpPost]
  20333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20334. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  20335. {
  20336. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  20337. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20338. var view = res.Data as PageDataViewBase;
  20339. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  20340. }
  20341. /// <summary>
  20342. /// 酒店询价
  20343. /// info
  20344. /// </summary>
  20345. /// <param name="_dto"></param>
  20346. /// <returns></returns>
  20347. [HttpPost]
  20348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20349. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  20350. {
  20351. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  20352. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20353. return Ok(JsonView(true, res.Msg, res.Data));
  20354. }
  20355. /// <summary>
  20356. /// 酒店询价
  20357. /// Add Or Edit
  20358. /// </summary>
  20359. /// <param name="_dto"></param>
  20360. /// <returns></returns>
  20361. [HttpPost]
  20362. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20363. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  20364. {
  20365. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  20366. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20367. return Ok(JsonView(true, res.Msg, res.Data));
  20368. }
  20369. /// <summary>
  20370. /// 酒店询价
  20371. /// Del
  20372. /// </summary>
  20373. /// <param name="_dto"></param>
  20374. /// <returns></returns>
  20375. [HttpPost]
  20376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20377. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  20378. {
  20379. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  20380. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20381. return Ok(JsonView(true, res.Msg, res.Data));
  20382. }
  20383. #endregion
  20384. #region 下载匹配op行程单
  20385. /// <summary>
  20386. /// 匹配op行程单
  20387. /// Init
  20388. /// </summary>
  20389. /// <param name="dto">团组列表请求dto</param>
  20390. /// <returns></returns>
  20391. [HttpPost]
  20392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20393. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  20394. {
  20395. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20396. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20397. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  20398. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  20399. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  20400. .Where(it => it.IsDel == 0)
  20401. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  20402. .OrderByDescending(it => it.VisitStartDate)
  20403. .ToList();
  20404. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  20405. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20406. var diids = groupInfos.Select(it => it.Id).ToList();
  20407. List<string> countrys = new List<string>();
  20408. foreach (var item in country)
  20409. {
  20410. var data = _groupRepository.FormartTeamName(item);
  20411. var dataArray = _groupRepository.GroupSplitCountry(data);
  20412. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20413. }
  20414. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  20415. List<string> areaArray = new List<string>(); //GetGroupCityLine
  20416. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  20417. foreach (var item in areaItem)
  20418. {
  20419. string areaStr = item.Value;
  20420. if (!string.IsNullOrEmpty(areaStr))
  20421. {
  20422. string[] str1 = areaStr.Split("-");
  20423. if (str1.Length > 0)
  20424. {
  20425. areaArray.AddRange(str1);
  20426. }
  20427. }
  20428. }
  20429. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  20430. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  20431. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  20432. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  20433. .ToList();
  20434. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  20435. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  20436. .Where(it => countriesIds.Contains(it.Id))
  20437. .Select(it => new { it.Id, Name = it.Name_CN })
  20438. .ToList();
  20439. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  20440. .Select(it => it.TeamName).ToList();
  20441. stopwatch.Stop();
  20442. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  20443. }
  20444. ///// <summary>
  20445. ///// 匹配op行程单
  20446. ///// Init 查询区域数据
  20447. ///// </summary>
  20448. ///// <param name="dto">团组列表请求dto</param>
  20449. ///// <returns></returns>
  20450. //[HttpPost]
  20451. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20452. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  20453. //{
  20454. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20455. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  20456. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  20457. // if (string.IsNullOrEmpty(countriesDataStr))
  20458. // {
  20459. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  20460. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  20461. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  20462. // }
  20463. // else
  20464. // {
  20465. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  20466. // }
  20467. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  20468. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  20469. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  20470. // List<dynamic> childList = new List<dynamic>();
  20471. // int parentId = dto.CountriesId;
  20472. // if (provinceData.Count > 1)
  20473. // {
  20474. // foreach (var item1 in provinceData)
  20475. // {
  20476. // List<dynamic> childList1 = new List<dynamic>();
  20477. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  20478. // foreach (var item2 in citiesData1)
  20479. // {
  20480. // List<dynamic> childList2 = new List<dynamic>();
  20481. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20482. // foreach (var item3 in countiesData1)
  20483. // {
  20484. // childList2.Add(new
  20485. // {
  20486. // id = item3.Id,
  20487. // parentId = item2.Id,
  20488. // level = "district",
  20489. // name = item3.Name_CN,
  20490. // });
  20491. // }
  20492. // childList1.Add(new
  20493. // {
  20494. // id = item2.Id,
  20495. // parentId = item1.Id,
  20496. // level = "city",
  20497. // name = item2.Name_CN,
  20498. // childList = childList2
  20499. // });
  20500. // }
  20501. // childList.Add(new
  20502. // {
  20503. // id = item1.Id,
  20504. // parentId = parentId,
  20505. // level = "province",
  20506. // name = item1.Name_CN,
  20507. // childList = childList1
  20508. // });
  20509. // }
  20510. // //城市
  20511. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  20512. // foreach (var item2 in citiesData2)
  20513. // {
  20514. // List<dynamic> childList22 = new List<dynamic>();
  20515. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20516. // foreach (var item3 in countiesData1)
  20517. // {
  20518. // childList22.Add(new
  20519. // {
  20520. // id = item3.Id,
  20521. // parentId = item2.Id,
  20522. // level = "district",
  20523. // name = item3.Name_CN,
  20524. // });
  20525. // }
  20526. // childList.Add(new
  20527. // {
  20528. // id = item2.Id,
  20529. // parentId = parentId,
  20530. // level = "city",
  20531. // name = item2.Name_CN,
  20532. // childList = childList22
  20533. // });
  20534. // }
  20535. // }
  20536. // else
  20537. // {
  20538. // foreach (var item2 in citiesData)
  20539. // {
  20540. // string cname = item2.Name_CN;
  20541. // List<dynamic> childList1 = new List<dynamic>();
  20542. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20543. // foreach (var item3 in countiesData1)
  20544. // {
  20545. // childList1.Add(new
  20546. // {
  20547. // Id = item3.Id,
  20548. // parentId = item2.Id,
  20549. // level = "district",
  20550. // name = item3.Name_CN
  20551. // });
  20552. // }
  20553. // childList.Add(new
  20554. // {
  20555. // id = item2.Id,
  20556. // parentId = parentId,
  20557. // level = "city",
  20558. // name = item2.Name_CN,
  20559. // childList = childList1
  20560. // });
  20561. // }
  20562. // }
  20563. // stopwatch.Stop();
  20564. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  20565. //}
  20566. /// <summary>
  20567. /// 匹配op行程单
  20568. /// 接团信息列表 Page
  20569. /// </summary>
  20570. /// <param name="dto">团组列表请求dto</param>
  20571. /// <returns></returns>
  20572. [HttpPost]
  20573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20574. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  20575. {
  20576. var swatch = new Stopwatch();
  20577. swatch.Start();
  20578. #region 参数验证
  20579. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20580. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20581. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20582. #region 页面操作权限验证
  20583. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20584. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  20585. #endregion
  20586. #endregion
  20587. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20588. {
  20589. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  20590. //string sqlWhere = "";
  20591. if (!string.IsNullOrEmpty(dto.Country))
  20592. {
  20593. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  20594. }
  20595. if (!string.IsNullOrEmpty(dto.Area))
  20596. {
  20597. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  20598. }
  20599. if (!string.IsNullOrEmpty(dto.TeamName))
  20600. {
  20601. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  20602. }
  20603. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  20604. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  20605. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  20606. swatch.Stop();
  20607. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  20608. }
  20609. else
  20610. {
  20611. return Ok(JsonView(false, "查询失败"));
  20612. }
  20613. }
  20614. /// <summary>
  20615. /// 匹配op行程单
  20616. /// 行程单下载
  20617. /// </summary>
  20618. /// <param name="dto">团组列表请求dto</param>
  20619. /// <returns></returns>
  20620. [HttpPost]
  20621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20622. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  20623. {
  20624. #region 参数验证
  20625. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20626. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20627. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20628. #region 页面操作权限验证
  20629. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20630. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  20631. #endregion
  20632. #endregion
  20633. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20634. {
  20635. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  20636. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  20637. }
  20638. else
  20639. {
  20640. return Ok(JsonView(false, "下载失败!"));
  20641. }
  20642. }
  20643. #endregion
  20644. #region 国家信息 数据 注释
  20645. //[HttpPost]
  20646. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  20647. //{
  20648. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  20649. // foreach (var item in dto)
  20650. // {
  20651. // infos.Add(new Grp_GroupsTaskAssignment()
  20652. // {
  20653. // DIId = item,
  20654. // CTId = 82,
  20655. // UId = 248,
  20656. // IsEnable = 1,
  20657. // CreateUserId = 233,
  20658. // CreateTime = DateTime.Now,
  20659. // IsDel = 0
  20660. // });
  20661. // infos.Add(new Grp_GroupsTaskAssignment()
  20662. // {
  20663. // DIId = item,
  20664. // CTId = 82,
  20665. // UId = 286,
  20666. // IsEnable = 1,
  20667. // CreateUserId = 233,
  20668. // CreateTime = DateTime.Now,
  20669. // IsDel = 0
  20670. // });
  20671. // }
  20672. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  20673. // return Ok("操作成功");
  20674. //}
  20675. //public class paramJsonDto
  20676. //{
  20677. // public List<CountriesInfo> str { get; set; }
  20678. //}
  20679. //[HttpPost]
  20680. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  20681. //{
  20682. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  20683. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  20684. // List<Sys_Cities> cities = new List<Sys_Cities>();
  20685. // List<Sys_Cities> districts = new List<Sys_Cities>();
  20686. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20687. // _sqlSugar.BeginTran();
  20688. // int countitiesIndex = 0;
  20689. // foreach (var item in dto.str)
  20690. // {
  20691. // dynamic data = item.c;
  20692. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  20693. // if (data != null)
  20694. // {
  20695. // countitiesIndex++;
  20696. // foreach (var item1 in data)
  20697. // {
  20698. // string cnname = item1.cn;
  20699. // string enname = item1.en;
  20700. // Sys_Cities provinceInfo = new Sys_Cities()
  20701. // {
  20702. // CountriesId = countriesId,
  20703. // Name_CN = cnname,
  20704. // Name_EN = enname,
  20705. // ParentId = 0,
  20706. // IsCapital = 1,
  20707. // CreateUserId = 208,
  20708. // CreateTime = DateTime.Now,
  20709. // IsDel = 0
  20710. // };
  20711. // if (item1.lv == "province") //省份
  20712. // {
  20713. // provinceInfo.Level = 1;
  20714. // int provinceId = 0;
  20715. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  20716. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  20717. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20718. // var data1 = item1.c;
  20719. // foreach (var item2 in data1)
  20720. // {
  20721. // if (item2.lv == "city")
  20722. // {
  20723. // string citycnname = item2.cn;
  20724. // string cityenname = item2.en;
  20725. // Sys_Cities cityInfo = new Sys_Cities()
  20726. // {
  20727. // CountriesId = countriesId,
  20728. // ParentId = provinceId,
  20729. // Level = 2,
  20730. // Name_CN = citycnname,
  20731. // Name_EN = cityenname,
  20732. // IsCapital = 1,
  20733. // CreateUserId = 208,
  20734. // CreateTime = DateTime.Now,
  20735. // IsDel = 0
  20736. // };
  20737. // if (item2.c != null)
  20738. // {
  20739. // int cityId = 0;
  20740. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  20741. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20742. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  20743. // foreach (var item3 in item2.c)
  20744. // {
  20745. // if (item3.lv == "district")
  20746. // {
  20747. // var districtInfo = new Sys_Cities()
  20748. // {
  20749. // CountriesId = countriesId,
  20750. // Name_CN = item3.cn,
  20751. // Name_EN = item3.en,
  20752. // Level = 3,
  20753. // ParentId = cityId,
  20754. // IsCapital = 1,
  20755. // CreateUserId = 208,
  20756. // CreateTime = DateTime.Now,
  20757. // IsDel = 0
  20758. // };
  20759. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20760. // //{
  20761. // districts.Add(districtInfo);
  20762. // //}
  20763. // }
  20764. // }
  20765. // }
  20766. // else
  20767. // {
  20768. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  20769. // //{
  20770. // cities.Add(cityInfo);
  20771. // //}
  20772. // }
  20773. // }
  20774. // }
  20775. // }
  20776. // else if (item1.lv == "city")//城市
  20777. // {
  20778. // provinceInfo.Level = 2;
  20779. // if (item1.c != null)
  20780. // {
  20781. // int cityId = 0;
  20782. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  20783. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20784. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20785. // foreach (var item3 in item1.c)
  20786. // {
  20787. // if (item3.lv == "district")
  20788. // {
  20789. // var districtInfo = new Sys_Cities()
  20790. // {
  20791. // CountriesId = countriesId,
  20792. // Name_CN = item3.cn,
  20793. // Name_EN = item3.en,
  20794. // Level = 3,
  20795. // ParentId = cityId,
  20796. // IsCapital = 1,
  20797. // CreateUserId = 208,
  20798. // CreateTime = DateTime.Now,
  20799. // IsDel = 0
  20800. // };
  20801. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20802. // //{
  20803. // districts.Add(districtInfo);
  20804. // //}
  20805. // }
  20806. // }
  20807. // }
  20808. // else
  20809. // {
  20810. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  20811. // //{
  20812. // cities.Add(provinceInfo);
  20813. // //}
  20814. // }
  20815. // }
  20816. // }
  20817. // }
  20818. // }
  20819. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  20820. // cities = cities.Distinct().ToList();
  20821. // districts = districts.Distinct().ToList();
  20822. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  20823. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  20824. // cities.AddRange(districts);
  20825. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  20826. // //_sqlSugar.RollbackTran();
  20827. // _sqlSugar.CommitTran();
  20828. // return Ok(JsonView(false, "操作成功!"));
  20829. //}
  20830. //[HttpPost]
  20831. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  20832. //{
  20833. // List<CountitiesInfo> infos = dto.MyProperty;
  20834. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  20835. // _sqlSugar.BeginTran();
  20836. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20837. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  20838. // foreach (var item in infos)
  20839. // {
  20840. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  20841. // if (countryInfo != null)
  20842. // {
  20843. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  20844. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  20845. // if (cityInfo1 != null)
  20846. // {
  20847. // cityInfo1.IsCapital = 0;
  20848. // cityInfos.Add(cityInfo1);
  20849. // }
  20850. // }
  20851. // }
  20852. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  20853. // .UpdateColumns(it => it.IsCapital)
  20854. // .WhereColumns(it => it.Id)
  20855. // .ExecuteCommand();
  20856. // //_sqlSugar.RollbackTran();
  20857. // _sqlSugar.CommitTran();
  20858. // return Ok(JsonView(false, "操作成功!"));
  20859. //}
  20860. //public class CounrtiesDto
  20861. //{
  20862. // public List<CountitiesInfo> MyProperty { get; set; }
  20863. //}
  20864. //public class CountitiesInfo
  20865. //{
  20866. // /// <summary>
  20867. // /// 圣约翰
  20868. // /// </summary>
  20869. // public string capital_name_chinese { get; set; }
  20870. // /// <summary>
  20871. // ///
  20872. // /// </summary>
  20873. // public string capital_name { get; set; }
  20874. // /// <summary>
  20875. // ///
  20876. // /// </summary>
  20877. // public string country_type { get; set; }
  20878. // /// <summary>
  20879. // /// 安提瓜和巴布达
  20880. // /// </summary>
  20881. // public string country_name_chinese { get; set; }
  20882. // /// <summary>
  20883. // /// 安提瓜和巴布达
  20884. // /// </summary>
  20885. // public string country_name_chinese_short { get; set; }
  20886. // /// <summary>
  20887. // /// 安提瓜和巴布达
  20888. // /// </summary>
  20889. // public string country_name_chinese_UN { get; set; }
  20890. // /// <summary>
  20891. // ///
  20892. // /// </summary>
  20893. // public string country_name_english_abbreviation { get; set; }
  20894. // /// <summary>
  20895. // ///
  20896. // /// </summary>
  20897. // public string country_name_english_formal { get; set; }
  20898. // /// <summary>
  20899. // ///
  20900. // /// </summary>
  20901. // public string country_name_english_UN { get; set; }
  20902. // /// <summary>
  20903. // ///
  20904. // /// </summary>
  20905. // public string continent_name { get; set; }
  20906. // /// <summary>
  20907. // ///
  20908. // /// </summary>
  20909. // public string subregion_name { get; set; }
  20910. // /// <summary>
  20911. // ///
  20912. // /// </summary>
  20913. // public string country_code2 { get; set; }
  20914. // /// <summary>
  20915. // ///
  20916. // /// </summary>
  20917. // public string country_code3 { get; set; }
  20918. // /// <summary>
  20919. // ///
  20920. // /// </summary>
  20921. // public string phone_code { get; set; }
  20922. //}
  20923. //public class CountriesInfo : BasicInfo
  20924. //{
  20925. // public List<CitiesInfo> c { get; set; }
  20926. //}
  20927. //public class CitiesInfo : BasicInfo
  20928. //{
  20929. // public List<AreaInfo> c { get; set; }
  20930. //}
  20931. //public class AreaInfo : BasicInfo
  20932. //{
  20933. // public List<AreaInfo> c { get; set; }
  20934. //}
  20935. //public class BasicInfo
  20936. //{
  20937. // public string code { get; set; }
  20938. // public string cn { get; set; }
  20939. // public string lv { get; set; }
  20940. // public string en { get; set; }
  20941. //}
  20942. #endregion
  20943. #region 查看邀请方
  20944. /// <summary>
  20945. /// 查看邀请方
  20946. /// 邀请方信息 Init
  20947. /// </summary>
  20948. /// <param name="dto"></param>
  20949. /// <returns></returns>
  20950. [HttpPost]
  20951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20952. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  20953. {
  20954. string sqlWhere = string.Empty;
  20955. if (!string.IsNullOrEmpty(dto.Search))
  20956. {
  20957. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  20958. }
  20959. string sql = string.Format($@"Select
  20960. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  20961. Id,
  20962. UnitName
  20963. From Res_InvitationOfficialActivityData
  20964. Where IsDel = 0
  20965. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  20966. RefAsync<int> total = 0;
  20967. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20968. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  20969. }
  20970. /// <summary>
  20971. /// 查看邀请方
  20972. /// 国家信息 Init
  20973. /// </summary>
  20974. /// <param name="dto"></param>
  20975. /// <returns></returns>
  20976. [HttpPost]
  20977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20978. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  20979. {
  20980. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  20981. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20982. var diids = groupInfos.Select(it => it.Id).ToList();
  20983. List<string> countrys = new List<string>();
  20984. foreach (var item in country)
  20985. {
  20986. var data = _groupRepository.FormartTeamName(item);
  20987. var dataArray = _groupRepository.GroupSplitCountry(data);
  20988. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20989. }
  20990. countrys = countrys.Distinct().ToList();
  20991. for (int i = 0; i < countrys.Count; i++)
  20992. {
  20993. string item = countrys[i];
  20994. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  20995. {
  20996. countrys.Remove(item);
  20997. i--;
  20998. }
  20999. }
  21000. RefAsync<int> total = 0;
  21001. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  21002. .Where(it => countrys.Contains(it.Name_CN))
  21003. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21004. .Select(it => new { id = it.Id, name = it.Name_CN })
  21005. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21006. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21007. }
  21008. /// <summary>
  21009. /// 查看邀请方
  21010. /// 城市信息 Init
  21011. /// </summary>
  21012. /// <param name="dto"></param>
  21013. /// <returns></returns>
  21014. [HttpPost]
  21015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21016. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  21017. {
  21018. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  21019. RefAsync<int> total = 0;
  21020. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  21021. .Where(it => it.CountriesId == dto.CountiesId)
  21022. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21023. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  21024. .Select(it => new { id = it.Id, name = it.Name_CN })
  21025. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21026. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21027. }
  21028. /// <summary>
  21029. /// 查看邀请方
  21030. /// 团组名称 Init
  21031. /// </summary>
  21032. /// <param name="dto"></param>
  21033. /// <returns></returns>
  21034. [HttpPost]
  21035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21036. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  21037. {
  21038. var watch = new Stopwatch();
  21039. watch.Start();
  21040. RefAsync<int> total = 0;
  21041. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  21042. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  21043. .Where((oa, di) => oa.IsDel == 0)
  21044. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  21045. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  21046. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  21047. .Distinct()
  21048. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21049. watch.Stop();
  21050. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  21051. }
  21052. /// <summary>
  21053. /// 查看邀请方
  21054. /// 团组 & 邀请方信息
  21055. /// </summary>
  21056. /// <param name="dto"></param>
  21057. /// <returns></returns>
  21058. [HttpPost]
  21059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21060. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  21061. {
  21062. var watch = new Stopwatch();
  21063. watch.Start();
  21064. RefAsync<int> total = 0;
  21065. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  21066. .AS("Grp_DelegationInfo")
  21067. .Includes(x => x.InvitingInfos)
  21068. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  21069. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  21070. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  21071. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  21072. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  21073. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  21074. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21075. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  21076. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  21077. infos.ForEach(x =>
  21078. {
  21079. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  21080. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  21081. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  21082. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  21083. });
  21084. watch.Stop();
  21085. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  21086. }
  21087. #endregion
  21088. #region 报批行程
  21089. /// <summary>
  21090. /// 报批行程初始化
  21091. /// </summary>
  21092. /// <param name="dto"></param>
  21093. /// <returns></returns>
  21094. [HttpPost]
  21095. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  21096. {
  21097. const int chiNumber = 5;
  21098. var jw = JsonView(false);
  21099. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  21100. var group = groupList.First();
  21101. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  21102. group = groupList.First(x => x.Id == diid);
  21103. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21104. .Where(x => x.DiId == diid && x.IsDel == 0)
  21105. .ToArray();
  21106. var count = 1;
  21107. foreach (var item in blackCodeList)
  21108. {
  21109. if (string.IsNullOrWhiteSpace(item.Title))
  21110. {
  21111. item.Title = "未设置名称数据" + count;
  21112. }
  21113. count++;
  21114. }
  21115. ;
  21116. if (group == null)
  21117. {
  21118. jw.Msg = "暂无团组!";
  21119. return Ok(jw);
  21120. }
  21121. var data = new
  21122. {
  21123. groupList = groupList.Select(x => new
  21124. {
  21125. x.TeamName,
  21126. x.Id
  21127. }),
  21128. content = new ArrayList(),
  21129. groupInfo = new
  21130. {
  21131. group.VisitDays,
  21132. group.TourCode,
  21133. group.VisitPNumber,
  21134. group.TeamName,
  21135. group.Id,
  21136. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  21137. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  21138. group.ClientUnit
  21139. },
  21140. blackCodeList = blackCodeList.Select(x => new
  21141. {
  21142. x.Title,
  21143. x.Id
  21144. }),
  21145. FileTempList = new ArrayList()
  21146. {
  21147. new { Index = 1,FileName = "旧模板" },
  21148. new { Index = 2,FileName = "省外办" },
  21149. new { Index = 3,FileName = "市外办" },
  21150. }
  21151. };
  21152. var resultArr = new ArrayList();
  21153. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  21154. #region 默认不生成行程
  21155. //if (content.Count == 0)
  21156. //{
  21157. // var stay = "-";
  21158. // var cityPath = "-";
  21159. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21160. // .Where(x => x.DiId == diid && x.IsDel == 0)
  21161. // .ToList();
  21162. // //添加城市路径以及住宿地
  21163. // //黑屏代码数据
  21164. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  21165. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21166. // {
  21167. // jw = JsonView(true, "黑屏代码有误!", data);
  21168. // return Ok(jw);
  21169. // }
  21170. // data = data with
  21171. // {
  21172. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  21173. // {
  21174. // x.Title,
  21175. // x.Id,
  21176. // }).ToArray())
  21177. // };
  21178. // foreach (DataRow row in dtBlack.Rows)
  21179. // {
  21180. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21181. // {
  21182. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  21183. // return Ok(jw);
  21184. // }
  21185. // }
  21186. // //黑屏代码获取时间区间
  21187. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21188. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21189. // _sqlSugar.BeginTran();
  21190. // for (int i = 0; i < timeArr.Count; i++)
  21191. // {
  21192. // stay = "-";
  21193. // cityPath = "-";
  21194. // DateTime NewData = DateTime.Parse(timeArr[i]);
  21195. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21196. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21197. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21198. // if (tbSelect.Length > 0)
  21199. // {
  21200. // List<string> threeCodeStr = new List<string>();
  21201. // foreach (var item in tbSelect)
  21202. // {
  21203. // var threeCode = item["Three"].ToString() ?? "";
  21204. // if (threeCode.Length == 6)
  21205. // {
  21206. // var start = threeCode.Substring(0, 3);
  21207. // var end = threeCode.Substring(3, 3);
  21208. // if (threeCodeStr.Count == 0)
  21209. // {
  21210. // threeCodeStr.Add(start);
  21211. // threeCodeStr.Add(end);
  21212. // }
  21213. // else
  21214. // {
  21215. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21216. // {
  21217. // threeCodeStr.Add(end);
  21218. // }
  21219. // else
  21220. // {
  21221. // threeCodeStr.Add(start);
  21222. // threeCodeStr.Add(end);
  21223. // }
  21224. // }
  21225. // }
  21226. // }
  21227. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21228. // var last = threeCodeStr.Last();
  21229. // foreach (var item in threeCodeStr)
  21230. // {
  21231. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21232. // if (item.Equals(last))
  21233. // {
  21234. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21235. // }
  21236. // }
  21237. // cityPath = cityPath.Trim('-');
  21238. // }
  21239. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21240. // appro.Diid = diid ?? -1;
  21241. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21242. // appro.Id = thisId;
  21243. // appro.CreateUserId = dto.UserId;
  21244. // appro.CreateTime = DateTime.Now;
  21245. // content.Add(appro);
  21246. // }
  21247. // _sqlSugar.CommitTran();
  21248. //}
  21249. #endregion
  21250. foreach (var x in content)
  21251. {
  21252. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  21253. if (chiList.Count < chiNumber)
  21254. {
  21255. for (int i = chiList.Count; i < chiNumber; i++)
  21256. {
  21257. chiList.Add(new Grp_ApprovalTravelDetails());
  21258. }
  21259. }
  21260. resultArr.Add(new
  21261. {
  21262. x.Id,
  21263. x.Date,
  21264. x.Diid,
  21265. chiList = chiList.Select(x1 => new
  21266. {
  21267. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21268. x1.Details,
  21269. x1.ParentId,
  21270. x1.Id
  21271. })
  21272. });
  21273. }
  21274. data = data with
  21275. {
  21276. content = resultArr,
  21277. };
  21278. jw = JsonView(true, "获取成功!", data);
  21279. return Ok(jw);
  21280. }
  21281. /// <summary>
  21282. /// 报批行程删除
  21283. /// </summary>
  21284. /// <param name="dto"></param>
  21285. /// <returns></returns>
  21286. [HttpPost]
  21287. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  21288. {
  21289. var jw = JsonView(false);
  21290. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21291. if (group == null)
  21292. {
  21293. jw.Msg = "团组参数有误!";
  21294. return Ok(jw);
  21295. }
  21296. try
  21297. {
  21298. _sqlSugar.BeginTran();
  21299. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  21300. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  21301. {
  21302. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21303. DeleteUserId = dto.uesrId,
  21304. IsDel = 1
  21305. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  21306. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  21307. {
  21308. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21309. DeleteUserId = dto.uesrId,
  21310. IsDel = 1
  21311. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  21312. _sqlSugar.CommitTran();
  21313. jw = JsonView(true, "删除成功");
  21314. }
  21315. catch (Exception ex)
  21316. {
  21317. jw = JsonView(false, ex.Message);
  21318. }
  21319. return Ok(jw);
  21320. }
  21321. /// <summary>
  21322. /// 报批行程保存
  21323. /// </summary>
  21324. /// <param name="dto"></param>
  21325. /// <returns></returns>
  21326. [HttpPost]
  21327. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  21328. {
  21329. var jw = JsonView(false);
  21330. var Find = dto.Arr.Find(x => x.id == 0);
  21331. if (Find != null)
  21332. {
  21333. jw.Msg = "生成的ID为0!";
  21334. return Ok(jw);
  21335. }
  21336. foreach (var item in dto.Arr)
  21337. {
  21338. foreach (var chi in item.chiList)
  21339. {
  21340. if (chi.parentId == 0)
  21341. {
  21342. chi.parentId = item.id;
  21343. }
  21344. }
  21345. }
  21346. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  21347. _sqlSugar.BeginTran();
  21348. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  21349. {
  21350. var parentIds = dto.Arr.Select(x => x.id).ToList();
  21351. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  21352. {
  21353. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21354. DeleteUserId = dto.UserId,
  21355. IsDel = 1
  21356. }).ExecuteCommand();
  21357. }
  21358. try
  21359. {
  21360. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  21361. {
  21362. CreateTime = DateTime.Now,
  21363. CreateUserId = dto.UserId,
  21364. Details = x.details,
  21365. ParentId = x.parentId,
  21366. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21367. Remark = "",
  21368. IsDel = 0
  21369. }).ToList()).ExecuteCommand();
  21370. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  21371. {
  21372. Id = x.id,
  21373. Details = x.details,
  21374. ParentId = x.parentId,
  21375. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21376. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  21377. {
  21378. Details = x.Details,
  21379. ParentId = x.ParentId,
  21380. Time = x.Time
  21381. }).ExecuteCommand();
  21382. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  21383. {
  21384. Id = x.id,
  21385. Date = x.date,
  21386. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  21387. {
  21388. Date = x.Date
  21389. }).ExecuteCommand();
  21390. _sqlSugar.CommitTran();
  21391. jw = JsonView(true, "保存成功!");
  21392. }
  21393. catch (Exception ex)
  21394. {
  21395. _sqlSugar.RollbackTran();
  21396. jw = JsonView(false, "保存失败!" + ex.Message);
  21397. }
  21398. return Ok(jw);
  21399. }
  21400. /// <summary>
  21401. /// 报批行程生成
  21402. /// </summary>
  21403. /// <param name="dto"></param>
  21404. /// <returns></returns>
  21405. [HttpPost]
  21406. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  21407. {
  21408. var jw = JsonView(false);
  21409. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21410. if (group == null)
  21411. {
  21412. jw.Msg = "暂无该团组!";
  21413. return Ok(jw);
  21414. }
  21415. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  21416. //黑屏代码数据
  21417. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  21418. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21419. {
  21420. jw.Msg = "黑屏代码有误!";
  21421. return Ok(jw);
  21422. }
  21423. foreach (DataRow row in dtBlack.Rows)
  21424. {
  21425. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21426. {
  21427. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  21428. return Ok(jw);
  21429. }
  21430. }
  21431. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  21432. var resultArr = new ArrayList();
  21433. //if (officialActivitiesArr.Count == 0)
  21434. //{
  21435. // jw.Msg = "暂无公务出访信息!";
  21436. // return Ok(jw);
  21437. //}
  21438. try
  21439. {
  21440. _sqlSugar.BeginTran();
  21441. DeleteApprovalJourney(new
  21442. Domain.Dtos.Groups.DeleteApprovalJourney
  21443. {
  21444. Diid = dto.Diid,
  21445. uesrId = dto.Userid
  21446. });
  21447. var stay = "-";
  21448. var cityPath = "-";
  21449. var arriveCountry = string.Empty;
  21450. //添加城市路径以及住宿地
  21451. //黑屏代码获取时间区间
  21452. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21453. var empty = "【未收入该三字码!请机票同事录入】";
  21454. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21455. #region 配置公务活动时间
  21456. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  21457. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  21458. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  21459. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  21460. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  21461. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21462. {
  21463. 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" }),
  21464. 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"}),
  21465. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21466. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  21467. };
  21468. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21469. {
  21470. 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" }),
  21471. 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"}),
  21472. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21473. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  21474. };
  21475. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  21476. {
  21477. 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" }),
  21478. 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"}),
  21479. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  21480. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  21481. };
  21482. #endregion
  21483. var nextDayNum = 0;
  21484. for (int i = 0; i < timeArr.Count; i++)
  21485. {
  21486. stay = "-";
  21487. cityPath = "-";
  21488. var chiarr = new List<Grp_ApprovalTravelDetails>();
  21489. DateTime NewData = DateTime.Parse(timeArr[i]);
  21490. //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();
  21491. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21492. if (nextDayNum > 0)
  21493. {
  21494. nextDayNum--;
  21495. }
  21496. if (tbSelect.Length > 0)
  21497. {
  21498. List<string> threeCodeStr = new List<string>();
  21499. bool isTrade = false;
  21500. string trip = string.Empty;
  21501. foreach (var item in tbSelect)
  21502. {
  21503. if (nextDayNum == 0)
  21504. {
  21505. nextDayNum = Convert.ToInt32(item["Sign"]);
  21506. }
  21507. var airStartTime = item["StartTime"].ToString() ?? "0000";
  21508. var airEndTime = item["EndTime"].ToString() ?? "0000";
  21509. var takeOffTime = DateTime.Parse(timeArr[i]);
  21510. var fallToTime = DateTime.Parse(timeArr[i]);
  21511. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  21512. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  21513. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  21514. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  21515. if (nextDayNum > 0)
  21516. {
  21517. fallToTime = fallToTime.AddDays(nextDayNum);
  21518. }
  21519. trip = string.Empty;
  21520. var start = string.Empty;
  21521. var end = string.Empty;
  21522. var threeCode = item["Three"].ToString() ?? "";
  21523. if (threeCode.Length == 6)
  21524. {
  21525. start = threeCode.Substring(0, 3);
  21526. end = threeCode.Substring(3, 3);
  21527. if (threeCodeStr.Count == 0)
  21528. {
  21529. threeCodeStr.Add(start);
  21530. threeCodeStr.Add(end);
  21531. }
  21532. else
  21533. {
  21534. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21535. {
  21536. threeCodeStr.Add(end);
  21537. }
  21538. else
  21539. {
  21540. threeCodeStr.Add(start);
  21541. threeCodeStr.Add(end);
  21542. }
  21543. }
  21544. }
  21545. //处理机票信息
  21546. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  21547. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  21548. if (start_Object == null)
  21549. {
  21550. start_Object = new Res_ThreeCode()
  21551. {
  21552. AirPort = empty,
  21553. AirPort_En = empty,
  21554. City = empty,
  21555. Country = empty,
  21556. Four = empty,
  21557. Three = empty,
  21558. };
  21559. }
  21560. if (end_Object == null)
  21561. {
  21562. end_Object = new Res_ThreeCode()
  21563. {
  21564. AirPort = empty,
  21565. AirPort_En = empty,
  21566. City = empty,
  21567. Country = empty,
  21568. Four = empty,
  21569. Three = empty,
  21570. };
  21571. }
  21572. //机型判断
  21573. string airModel = item["AirModel"].ToString();
  21574. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  21575. string flightTime = item["FlightTime"].ToString();
  21576. flightTime = ParseBlackTime(flightTime);
  21577. //航班号
  21578. string flightcode = item["Fliagtcode"].ToString();
  21579. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  21580. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  21581. if (aircompany == null)
  21582. {
  21583. aircompany = new Res_AirCompany
  21584. {
  21585. CnName = hsEmpty,
  21586. EnName = hsEmpty,
  21587. ShortCode = hsEmpty,
  21588. };
  21589. }
  21590. //航班前公务安排
  21591. if (tbSelect.First().Equals(item) && i != 0)
  21592. {
  21593. foreach (var takeoff in takeoffTimes)
  21594. {
  21595. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  21596. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  21597. {
  21598. foreach (var addTime in takeoff.Item2)
  21599. {
  21600. chiarr.Add(new Grp_ApprovalTravelDetails
  21601. {
  21602. Time = addTime,
  21603. CreateTime = DateTime.Now,
  21604. CreateUserId = dto.Userid,
  21605. ParentId = 0,
  21606. Details = "公务活动"
  21607. });
  21608. }
  21609. break;
  21610. }
  21611. }
  21612. }
  21613. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  21614. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  21615. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  21616. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  21617. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  21618. if (isTrade)
  21619. {
  21620. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  21621. trip += "(转机不出机场)。";
  21622. }
  21623. //else
  21624. //{
  21625. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  21626. //}
  21627. chiarr.Add(new Grp_ApprovalTravelDetails
  21628. {
  21629. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  21630. CreateTime = DateTime.Now,
  21631. CreateUserId = dto.Userid,
  21632. ParentId = 0,
  21633. Details = trip
  21634. });
  21635. //最后一条到达的时间安排公务
  21636. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  21637. {
  21638. bool isCheckCountry = false;
  21639. if (end_Object.Country != arriveCountry)
  21640. {
  21641. arriveCountry = end_Object.Country;
  21642. isCheckCountry = true;
  21643. }
  21644. if (nextDayNum == 0)
  21645. {
  21646. //需要入境的情况
  21647. if (isCheckCountry)
  21648. {
  21649. foreach (var fallTime in fallTimesCheckCountry)
  21650. {
  21651. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21652. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21653. {
  21654. foreach (var addTime in fallTime.Item2)
  21655. {
  21656. chiarr.Add(new Grp_ApprovalTravelDetails
  21657. {
  21658. Time = addTime,
  21659. CreateTime = DateTime.Now,
  21660. CreateUserId = dto.Userid,
  21661. ParentId = 0,
  21662. Details = "公务活动"
  21663. });
  21664. }
  21665. break;
  21666. }
  21667. }
  21668. }
  21669. else
  21670. {
  21671. foreach (var fallTime in fallTimesNotCheckCountry)
  21672. {
  21673. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21674. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21675. {
  21676. foreach (var addTime in fallTime.Item2)
  21677. {
  21678. chiarr.Add(new Grp_ApprovalTravelDetails
  21679. {
  21680. Time = addTime,
  21681. CreateTime = DateTime.Now,
  21682. CreateUserId = dto.Userid,
  21683. ParentId = 0,
  21684. Details = "公务活动"
  21685. });
  21686. }
  21687. break;
  21688. }
  21689. }
  21690. }
  21691. }
  21692. }
  21693. }
  21694. //添加乘车语句
  21695. //chiarr.Add(new Grp_ApprovalTravelDetails
  21696. //{
  21697. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  21698. // CreateTime = DateTime.Now,
  21699. // CreateUserId = dto.Userid,
  21700. // ParentId = 0,
  21701. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  21702. //});
  21703. //if (i != timeArr.Count - 1)
  21704. //{
  21705. // fallToTime = fallToTime.AddHours(2.5);
  21706. // foreach (var item in Times)
  21707. // {
  21708. // //排列公务时间
  21709. // if (fallToTime.Hour < item.Item1)
  21710. // {
  21711. // chiarr.Add(new Grp_ApprovalTravelDetails
  21712. // {
  21713. // Time = $"{item.Item2} - {item.Item3}",
  21714. // CreateTime = DateTime.Now,
  21715. // CreateUserId = dto.Userid,
  21716. // ParentId = 0,
  21717. // Details = "公务活动"
  21718. // });
  21719. // }
  21720. // }
  21721. //}
  21722. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21723. var last = threeCodeStr.Last();
  21724. foreach (var item in threeCodeStr)
  21725. {
  21726. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21727. if (item.Equals(last))
  21728. {
  21729. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21730. }
  21731. }
  21732. cityPath = cityPath.Trim('-');
  21733. }
  21734. else
  21735. {
  21736. foreach (var item in Times)
  21737. {
  21738. chiarr.Add(new Grp_ApprovalTravelDetails
  21739. {
  21740. Time = $"{item.Item2} - {item.Item3}",
  21741. CreateTime = DateTime.Now,
  21742. CreateUserId = dto.Userid,
  21743. ParentId = 0,
  21744. Details = "公务活动"
  21745. });
  21746. }
  21747. }
  21748. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21749. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21750. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  21751. appro.Diid = dto.Diid;
  21752. appro.CreateUserId = dto.Userid;
  21753. appro.CreateTime = DateTime.Now;
  21754. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21755. appro.Id = thisId;
  21756. //foreach (var item in gwinfo)
  21757. //{
  21758. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  21759. // chi.Details = "拜访" + item.Client;
  21760. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  21761. // {
  21762. // chi.Details += "," + item.ReqSample;
  21763. // }
  21764. // chi.ParentId = thisId;
  21765. // chi.Time = item.Time;
  21766. // chiarr.Add(chi);
  21767. //}
  21768. if (chiarr.Count < 6)
  21769. {
  21770. for (int j = chiarr.Count; j < 6; j++)
  21771. {
  21772. chiarr.Add(new
  21773. Grp_ApprovalTravelDetails());
  21774. }
  21775. }
  21776. resultArr.Add(new
  21777. {
  21778. appro.Id,
  21779. appro.Date,
  21780. appro.Diid,
  21781. chiList = chiarr.Select(x1 => new
  21782. {
  21783. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21784. x1.Details,
  21785. x1.ParentId,
  21786. x1.Id
  21787. })
  21788. });
  21789. }
  21790. _sqlSugar.CommitTran();
  21791. jw = JsonView(true, "生成成功!", resultArr);
  21792. }
  21793. catch (Exception ex)
  21794. {
  21795. jw.Code = 400;
  21796. jw.Msg = "生成失败!" + ex.Message;
  21797. }
  21798. return Ok(jw);
  21799. }
  21800. /// <summary>
  21801. /// 报批行程word导出
  21802. /// </summary>
  21803. /// <param name="dto"></param>
  21804. /// <returns></returns>
  21805. [HttpPost]
  21806. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  21807. {
  21808. var jw = JsonView(false);
  21809. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21810. if (group == null)
  21811. {
  21812. jw.Msg = "暂无该团组!";
  21813. return Ok(jw);
  21814. }
  21815. //模板路径
  21816. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  21817. var fileName = string.Empty;
  21818. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  21819. bool bold = false;
  21820. if (dto.FileIndex == 1)
  21821. {
  21822. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  21823. }
  21824. else if (dto.FileIndex == 2)
  21825. {
  21826. fileName = "省外办-报批.docx";
  21827. bold = false;
  21828. titleFont = "方正黑体简体";
  21829. timeFont = "Times New Roman";
  21830. contentFont = "方正仿宋_GBK";
  21831. }
  21832. else if (dto.FileIndex == 3)
  21833. {
  21834. fileName = "市外办-报批.docx";
  21835. titleFont = "方正黑体简体";
  21836. timeFont = "Times New Roman";
  21837. contentFont = "方正仿宋简体";
  21838. }
  21839. tempPath = tempPath + fileName;
  21840. //载入模板
  21841. Document doc = new Document(tempPath);
  21842. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21843. //获取所填表格的序数
  21844. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21845. Aspose.Words.Tables.Row titleRowClone = null;
  21846. Aspose.Words.Tables.Row CenterRowClone = null;
  21847. int index = 0;
  21848. int indexChi = 0;
  21849. int SetIndex = 0;
  21850. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  21851. //获取数据,放到datatable
  21852. foreach (var item in ApprovalTravelArr)
  21853. {
  21854. if (index > 0)
  21855. {
  21856. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  21857. tableOne.AppendChild(titleRowClone);
  21858. }
  21859. var textTime = item.Date;
  21860. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  21861. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  21862. SetIndex++;
  21863. if (ChiRep.Count > 0)
  21864. {
  21865. foreach (var itemChi in ChiRep)
  21866. {
  21867. var txtTime = itemChi.Time;
  21868. var txtDetail = itemChi.Details;
  21869. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  21870. {
  21871. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  21872. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21873. //indexChi++;
  21874. //SetIndex++;
  21875. break;
  21876. }
  21877. if (indexChi > 0)
  21878. {
  21879. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21880. tableOne.AppendChild(CenterRowClone);
  21881. }
  21882. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  21883. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  21884. indexChi++;
  21885. SetIndex++;
  21886. }
  21887. }
  21888. //else
  21889. //{
  21890. // if (indexChi > 0)
  21891. // {
  21892. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21893. // tableOne.AppendChild(CenterRowClone);
  21894. // }
  21895. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  21896. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21897. // indexChi++;
  21898. // SetIndex++;
  21899. //}
  21900. index++;
  21901. }
  21902. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  21903. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21904. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21905. jw.Code = 200;
  21906. jw.Msg = "";
  21907. return Ok(jw);
  21908. }
  21909. private string ParseBlackTime(string time)
  21910. {
  21911. // 匹配可能只有分钟的情况
  21912. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  21913. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  21914. if (match.Success)
  21915. {
  21916. string hours = match.Groups[1].Value;
  21917. string minutes = match.Groups[2].Value;
  21918. // 如果小时部分为空,则只显示分钟
  21919. if (string.IsNullOrEmpty(hours))
  21920. {
  21921. return $"{minutes}分钟";
  21922. }
  21923. // 如果分钟部分为空,则只显示小时
  21924. else if (string.IsNullOrEmpty(minutes))
  21925. {
  21926. return $"{hours}小时";
  21927. }
  21928. // 否则显示完整格式
  21929. else
  21930. {
  21931. return $"{hours}小时{minutes}分钟";
  21932. }
  21933. }
  21934. else
  21935. {
  21936. return "未知时长";
  21937. }
  21938. }
  21939. private string intToString(int numberVal)
  21940. {
  21941. string numberval = numberVal.ToString();
  21942. Dictionary<char, string> Number = new Dictionary<char, string>();
  21943. Number.Add('1', "一");
  21944. Number.Add('2', "二");
  21945. Number.Add('3', "三");
  21946. Number.Add('4', "四");
  21947. Number.Add('5', "五");
  21948. Number.Add('6', "六");
  21949. Number.Add('7', "七");
  21950. Number.Add('8', "八");
  21951. Number.Add('9', "九");
  21952. string stringNumberVal = string.Empty;
  21953. for (int i = 0; i < numberval.Length; i++)
  21954. {
  21955. if (i == 0)
  21956. {
  21957. stringNumberVal += Number[numberval[i]];
  21958. }
  21959. else if (i >= 1)
  21960. {
  21961. if (numberval[i] == '0')
  21962. {
  21963. stringNumberVal = "十";
  21964. }
  21965. else
  21966. {
  21967. stringNumberVal += "十" + Number[numberval[i]];
  21968. }
  21969. }
  21970. }
  21971. return stringNumberVal;
  21972. }
  21973. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  21974. {
  21975. //获取table中的某个单元格,从0开始
  21976. Cell lshCell = table.Rows[rows].Cells[cells];
  21977. //将单元格中段落移除
  21978. foreach (Paragraph item in lshCell.Paragraphs)
  21979. {
  21980. lshCell.Paragraphs.Remove(item);
  21981. }
  21982. if (val.Contains("\r\n"))
  21983. {
  21984. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  21985. foreach (var item in spArr)
  21986. {
  21987. //新建一个段落
  21988. Paragraph p = new Paragraph(doc);
  21989. var r = new Run(doc, item);
  21990. //设置字体
  21991. if (!string.IsNullOrEmpty(font))
  21992. {
  21993. r.Font.Name = font;
  21994. }
  21995. r.Font.Bold = bold;
  21996. //把设置的值赋给之前新建的段落
  21997. p.AppendChild(r);
  21998. //将此段落加到单元格内
  21999. lshCell.AppendChild(p);
  22000. }
  22001. }
  22002. else
  22003. {
  22004. //新建一个段落
  22005. Paragraph p = new Paragraph(doc);
  22006. var r = new Run(doc, val);
  22007. //设置字体
  22008. if (!string.IsNullOrEmpty(font))
  22009. {
  22010. r.Font.Name = font;
  22011. }
  22012. r.Font.Bold = bold;
  22013. //把设置的值赋给之前新建的段落
  22014. p.AppendChild(r);
  22015. //将此段落加到单元格内
  22016. lshCell.AppendChild(p);
  22017. }
  22018. }
  22019. /// <summary>
  22020. /// 报批行程AI续写
  22021. /// </summary>
  22022. /// <returns></returns>
  22023. [HttpPost]
  22024. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  22025. {
  22026. var jw = JsonView(false);
  22027. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  22028. {
  22029. jw.Msg = "参数有误!";
  22030. return Ok(jw);
  22031. }
  22032. KiMiApiClient kiMi = new KiMiApiClient();
  22033. List<SeedMessages> messages = new List<SeedMessages>() {
  22034. new SeedMessages
  22035. {
  22036. Role = KimiRole.system,
  22037. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  22038. },
  22039. new SeedMessages
  22040. {
  22041. Role = KimiRole.user,
  22042. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  22043. }
  22044. };
  22045. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  22046. string data = kimi_result.Choices[0]?.Message.Content;
  22047. if (string.IsNullOrWhiteSpace(data))
  22048. {
  22049. jw.Data = "Ai续写失败!";
  22050. }
  22051. else
  22052. {
  22053. jw = JsonView(true, "success!", data);
  22054. }
  22055. return Ok(jw);
  22056. }
  22057. #endregion
  22058. #region 团组接待意见调查
  22059. /// <summary>
  22060. /// 团组接待意见调查 - 信息管理
  22061. /// 基础数据(团组)
  22062. /// </summary>
  22063. /// <returns></returns>
  22064. [HttpGet]
  22065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22066. public async Task<IActionResult> OpinionaireInit()
  22067. {
  22068. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  22069. .Select(x => new
  22070. {
  22071. x.Id,
  22072. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  22073. })
  22074. .OrderByDescending(x => x.Id)
  22075. .ToListAsync();
  22076. return Ok(JsonView(groupData, groupData.Count));
  22077. }
  22078. /// <summary>
  22079. /// 团组接待意见调查 - 信息管理
  22080. /// 列表
  22081. /// </summary>
  22082. /// <param name="groupId"></param>
  22083. /// <returns></returns>
  22084. [HttpGet("{groupId}")]
  22085. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22086. public async Task<IActionResult> OpinionaireManageList(int groupId)
  22087. {
  22088. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22089. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  22090. .Select(x => new
  22091. {
  22092. x.Id,
  22093. x.TourGuideName,
  22094. x.CityName,
  22095. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  22096. x.CreateTime
  22097. })
  22098. .OrderBy(x => x.Id)
  22099. .ToListAsync();
  22100. return Ok(JsonView(data));
  22101. }
  22102. /// <summary>
  22103. /// 团组接待意见调查 - 信息管理
  22104. /// 保存
  22105. /// </summary>
  22106. /// <param name="dto"></param>
  22107. /// <returns></returns>
  22108. [HttpPost]
  22109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22110. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  22111. {
  22112. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22113. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22114. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22115. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  22116. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  22117. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  22118. _opinionaireRep.BeginTran();
  22119. if (addData != null && addData.Count > 0)
  22120. {
  22121. foreach (var item in addData)
  22122. {
  22123. item.CreateUserId = currUserInfo.UserId;
  22124. item.DiId = dto.DiId;
  22125. }
  22126. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  22127. }
  22128. if (updData != null && updData.Count > 0)
  22129. {
  22130. var upd = await _opinionaireRep._sqlSugar
  22131. .Updateable(updData)
  22132. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  22133. .WhereColumns(x => new { x.Id })
  22134. .ExecuteCommandAsync();
  22135. }
  22136. _opinionaireRep.CommitTran();
  22137. return Ok(JsonView("操作成功!"));
  22138. }
  22139. /// <summary>
  22140. /// 团组接待意见调查 - 信息管理
  22141. /// 删除
  22142. /// </summary>
  22143. /// <param name="id"></param>
  22144. /// <returns></returns>
  22145. [HttpDelete("{id}")]
  22146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22147. public async Task<IActionResult> OpinionaireManageDel(int id)
  22148. {
  22149. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22150. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22151. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  22152. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  22153. if (!del) return Ok(JsonView("操作失败!"));
  22154. return Ok(JsonView("操作成功!"));
  22155. }
  22156. /// <summary>
  22157. /// 团组接待意见调查 - 用户
  22158. /// 列表
  22159. /// </summary>
  22160. /// <param name="diId"></param>
  22161. /// <returns></returns>
  22162. [HttpGet("{diId}")]
  22163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22164. public async Task<IActionResult> OpinionaireUserList(int diId)
  22165. {
  22166. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22167. var sql = string.Format(@"
  22168. SELECT
  22169. o.Id,
  22170. o.DiId,
  22171. di.TeamName AS 'GroupName',
  22172. di.VisitPNumber AS 'PeopleNumber',
  22173. di.ClientName AS 'LeadGroup',
  22174. di.VisitCountry AS 'Travel',
  22175. di.VisitDays AS 'Days',
  22176. o.CityName,
  22177. o.TourGuideName,
  22178. o.Catering,
  22179. o.CateringReason,
  22180. o.Stay,
  22181. o.StayReason,
  22182. o.[Route],
  22183. o.RouteReason,
  22184. o.OfficialActivity,
  22185. o.OfficialActivityReason,
  22186. o.TourGuide,
  22187. o.TourGuideReason,
  22188. o.[Translate],
  22189. o.TranslateReason,
  22190. o.Trip,
  22191. o.TripReason,
  22192. o.ESFileName,
  22193. o.SignatureDate,
  22194. o.Remark
  22195. FROM
  22196. Grp_Opinionaire o
  22197. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  22198. WHERE
  22199. o.IsDel = 0
  22200. AND o.DiId = {0}
  22201. ORDER BY
  22202. o.Id ASC", diId);
  22203. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  22204. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  22205. return Ok(JsonView(data));
  22206. }
  22207. /// <summary>
  22208. /// 团组接待意见调查 - 用户
  22209. /// 保存
  22210. /// </summary>
  22211. /// <param name="dto"></param>
  22212. /// <returns></returns>
  22213. [HttpPost]
  22214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22215. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  22216. {
  22217. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  22218. foreach (var item in dto)
  22219. {
  22220. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  22221. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  22222. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  22223. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  22224. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  22225. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  22226. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  22227. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  22228. }
  22229. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  22230. if (!Directory.Exists(filePathBase))
  22231. {
  22232. Directory.CreateDirectory(filePathBase);
  22233. }
  22234. #region 上传文件
  22235. var filePaths = new List<string>();
  22236. foreach (var item in dto)
  22237. {
  22238. var file = item.File;
  22239. // 将文件保存到指定位置
  22240. var filePath = Path.Combine(filePathBase, file.FileName);
  22241. using (var stream = new FileStream(filePath, FileMode.Create))
  22242. {
  22243. await file.CopyToAsync(stream);
  22244. }
  22245. //验证文件是否上传成功
  22246. if (!System.IO.File.Exists(filePath))
  22247. {
  22248. foreach (var filePathStr in filePaths)
  22249. {
  22250. System.IO.File.Delete(filePathStr);
  22251. }
  22252. return Ok(JsonView(false, "文件上传失败!"));
  22253. }
  22254. item.ESFileName = file.FileName;
  22255. }
  22256. #endregion
  22257. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22258. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22259. .UpdateColumns(x => new
  22260. {
  22261. x.Catering,
  22262. x.CateringReason,
  22263. x.Stay,
  22264. x.StayReason,
  22265. x.Route,
  22266. x.RouteReason,
  22267. x.OfficialActivity,
  22268. x.OfficialActivityReason,
  22269. x.TourGuide,
  22270. x.TourGuideReason,
  22271. x.Translate,
  22272. x.TranslateReason,
  22273. x.Trip,
  22274. x.TripReason,
  22275. x.ESFileName,
  22276. x.SignatureDate,
  22277. x.Remark
  22278. })
  22279. .WhereColumns(x => new { x.Id })
  22280. .ExecuteCommandAsync();
  22281. if (upd < 1)
  22282. {
  22283. foreach (var filePathStr in filePaths)
  22284. {
  22285. System.IO.File.Delete(filePathStr);
  22286. }
  22287. return Ok(JsonView(false));
  22288. }
  22289. return Ok(JsonView(true));
  22290. }
  22291. #endregion
  22292. #region 团组餐厅相关信息
  22293. /// <summary>
  22294. /// 团组相关餐厅信息
  22295. /// 基础数据(团组)
  22296. /// </summary>
  22297. /// <returns></returns>
  22298. [HttpGet]
  22299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22300. public async Task<IActionResult> RestaurantInit()
  22301. {
  22302. return Ok(await _restaurantRep.InitAsync());
  22303. }
  22304. /// <summary>
  22305. /// 团组相关餐厅信息
  22306. /// Item
  22307. /// </summary>
  22308. /// <param name="dto"></param>
  22309. /// <returns></returns>
  22310. [HttpPost]
  22311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22312. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  22313. {
  22314. int portType = dto.PortType,
  22315. groupId = dto.GroupId;
  22316. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22317. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22318. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  22319. }
  22320. /// <summary>
  22321. /// 团组相关餐厅信息
  22322. /// List
  22323. /// </summary>
  22324. /// <param name="dto"></param>
  22325. /// <returns></returns>
  22326. [HttpPost]
  22327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22328. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  22329. {
  22330. int portType = dto.PortType,
  22331. groupId = dto.GroupId;
  22332. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22333. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22334. var sql = string.Format(@" SELECT
  22335. ri.Id,
  22336. ri.GroupId,
  22337. ri.Date,
  22338. ri.StartTime,
  22339. ri.EndTime,
  22340. CASE WHEN ri.Type = 1 THEN '早餐'
  22341. WHEN ri.Type = 2 THEN '午餐'
  22342. WHEN ri.Type = 3 THEN '晚餐'
  22343. ELSE '其他'
  22344. END AS 'Type',
  22345. ri.Name,
  22346. ri.Address,
  22347. ri.Tel,
  22348. ri.Remark,
  22349. ri.CreateTime,
  22350. u.CnName AS CreateUserName
  22351. FROM
  22352. Grp_RestaurantInfo ri
  22353. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  22354. WHERE
  22355. ri.IsDel = 0
  22356. AND ri.GroupId = {0}
  22357. ORDER BY
  22358. ri.Date ASC
  22359. ", groupId);
  22360. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  22361. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  22362. return Ok(JsonView(infos));
  22363. }
  22364. /// <summary>
  22365. /// 团组相关餐厅信息
  22366. /// Info
  22367. /// </summary>
  22368. /// <param name="dto"></param>
  22369. /// <returns></returns>
  22370. [HttpPost]
  22371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22372. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  22373. {
  22374. int portType = dto.PortType,
  22375. id = dto.Id;
  22376. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22377. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22378. return Ok(await _restaurantRep.InfoAsync(portType, id));
  22379. }
  22380. /// <summary>
  22381. /// 团组相关餐厅信息
  22382. /// Op
  22383. /// </summary>
  22384. /// <param name="dto"></param>
  22385. /// <returns></returns>
  22386. [HttpPost]
  22387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22388. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  22389. {
  22390. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22391. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22392. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  22393. return Ok(await _restaurantRep.OpAsync(dto));
  22394. }
  22395. /// <summary>
  22396. /// 团组相关餐厅信息
  22397. /// Del
  22398. /// </summary>
  22399. /// <param name="dto"></param>
  22400. /// <returns></returns>
  22401. [HttpPost]
  22402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22403. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  22404. {
  22405. int userId = dto.DeleteUserId;
  22406. var id = dto.Id;
  22407. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22408. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22409. return Ok(await _restaurantRep.DelAsync(dto));
  22410. }
  22411. #endregion
  22412. /// <summary>
  22413. /// 123132123
  22414. /// </summary>
  22415. /// <param name="_dto"></param>
  22416. /// <returns></returns>
  22417. [HttpPost]
  22418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22419. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  22420. {
  22421. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  22422. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  22423. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  22424. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  22425. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  22426. dicDetail.Add(789, 1034);
  22427. dicDetail.Add(790, 1035);
  22428. dicDetail.Add(791, 1036);
  22429. dicDetail.Add(792, 1037);
  22430. dicDetail.Add(793, 1038);
  22431. dicDetail.Add(794, 1039);
  22432. dicDetail.Add(795, 1040);
  22433. dicDetail.Add(796, 1041);
  22434. dicDetail.Add(797, 1042);
  22435. dicDetail.Add(798, 1043);
  22436. dicDetail.Add(801, 1044);
  22437. dicDetail.Add(802, 1045);
  22438. dicDetail.Add(803, 1046);
  22439. Dictionary<int, int> dic = new Dictionary<int, int>();
  22440. dic.Add(806, 1027);
  22441. dic.Add(807, 1028);
  22442. dic.Add(808, 1029);
  22443. dic.Add(809, 1030);
  22444. dic.Add(810, 1031);
  22445. dic.Add(811, 1032);
  22446. dic.Add(812, 1033);
  22447. foreach (var item in list_visa)
  22448. {
  22449. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  22450. temp.Coefficient = item.coefficient;
  22451. DateTime dtCrt;
  22452. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  22453. if (b1)
  22454. {
  22455. temp.CreateTime = dtCrt;
  22456. }
  22457. else
  22458. {
  22459. temp.CreateTime = DateTime.Now;
  22460. }
  22461. temp.CreateUserId = item.Operators;
  22462. temp.DeleteTime = "";
  22463. temp.DeleteUserId = 0;
  22464. temp.DiId = int.Parse(item.DIID);
  22465. temp.FilePath = item.FilePath;
  22466. temp.IsDel = item.IsDel;
  22467. temp.Price = item.Price;
  22468. temp.PriceCount = 1;
  22469. temp.PriceCurrency = item.Currency;
  22470. int detailId = 0;
  22471. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  22472. {
  22473. detailId = dicDetail[item.PriceTypeDetail];
  22474. }
  22475. temp.PriceDetailType = detailId;
  22476. temp.PriceDt = DateTime.Now;
  22477. temp.PriceName = item.PriceName;
  22478. temp.PriceSum = item.Price;
  22479. int tid = 0;
  22480. if (dic.ContainsKey(item.PriceType))
  22481. {
  22482. tid = dic[item.PriceType];
  22483. }
  22484. temp.PriceType = tid;
  22485. temp.Remark = item.Remark;
  22486. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  22487. }
  22488. return Ok(JsonView(true, "操作成功!"));
  22489. }
  22490. [HttpPost]
  22491. public IActionResult TimeTest()
  22492. {
  22493. var jw = JsonView(false, "error");
  22494. _sqlSugar.BeginTran();
  22495. try
  22496. {
  22497. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  22498. .Select(x => new Crm_NewClientData
  22499. {
  22500. Id = x.Id,
  22501. Client = x.Client,
  22502. Contact = x.Contact,
  22503. Location = x.Location,
  22504. })
  22505. .ToList();
  22506. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  22507. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  22508. Stopwatch stopwatch = new Stopwatch();
  22509. // 开始计时
  22510. stopwatch.Start();
  22511. foreach (var item in clientList)
  22512. {
  22513. EncryptionProcessor.DecryptProperties(item);
  22514. }
  22515. stopwatch.Stop();
  22516. jw.Code = 200;
  22517. jw.Data = stopwatch.ElapsedMilliseconds;
  22518. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  22519. }
  22520. catch (Exception ex)
  22521. {
  22522. jw.Code = 400;
  22523. jw.Msg = ex.Message;
  22524. }
  22525. return Ok(jw);
  22526. }
  22527. }
  22528. }