GroupsController.cs 1.2 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Microsoft.AspNetCore.SignalR;
  7. using NPOI.SS.UserModel;
  8. using NPOI.SS.Util;
  9. using NPOI.XSSF.UserModel;
  10. using OASystem.API.Middlewares;
  11. using OASystem.API.OAMethodLib;
  12. using OASystem.API.OAMethodLib.APNs;
  13. using OASystem.API.OAMethodLib.DeepSeekAPI;
  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.Logging;
  20. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  21. using OASystem.Domain.AesEncryption;
  22. using OASystem.Domain.Attributes;
  23. using OASystem.Domain.Dtos.CRM;
  24. using OASystem.Domain.Dtos.FileDto;
  25. using OASystem.Domain.Dtos.Financial;
  26. using OASystem.Domain.Dtos.Groups;
  27. using OASystem.Domain.Entities.Customer;
  28. using OASystem.Domain.Entities.Financial;
  29. using OASystem.Domain.Entities.Groups;
  30. using OASystem.Domain.ViewModels.CRM;
  31. using OASystem.Domain.ViewModels.Financial;
  32. using OASystem.Domain.ViewModels.Groups;
  33. using OASystem.Domain.ViewModels.OCR;
  34. using OASystem.Infrastructure.Repositories.CRM;
  35. using OASystem.Infrastructure.Repositories.Financial;
  36. using OASystem.Infrastructure.Repositories.Groups;
  37. using Quartz.Util;
  38. using SqlSugar.Extensions;
  39. using System.Collections;
  40. using System.ComponentModel.DataAnnotations;
  41. using System.Data;
  42. using System.Diagnostics;
  43. using System.Globalization;
  44. using System.IO;
  45. using System.IO.Compression;
  46. using System.Text.Json;
  47. using System.Text.RegularExpressions;
  48. using System.Web;
  49. using static OASystem.API.OAMethodLib.JWTHelper;
  50. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  51. using Bookmark = Aspose.Words.Bookmark;
  52. using Cell = Aspose.Words.Tables.Cell;
  53. using Table = Aspose.Words.Tables.Table;
  54. namespace OASystem.API.Controllers
  55. {
  56. /// <summary>
  57. /// 团组相关
  58. /// </summary>
  59. //[Authorize]
  60. [Route("api/[controller]/[action]")]
  61. public class GroupsController : ControllerBase
  62. {
  63. private readonly ILogger<GroupsController> _logger;
  64. private readonly ITextFileLogger _eec_textLogger;
  65. private readonly GrpScheduleRepository _grpScheduleRep;
  66. private readonly IMapper _mapper;
  67. private readonly DelegationInfoRepository _groupRepository;
  68. private readonly TaskAssignmentRepository _taskAssignmentRep;
  69. private readonly AirTicketResRepository _airTicketResRep;
  70. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  71. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  72. private readonly DelegationEnDataRepository _delegationEnDataRep;
  73. private readonly DelegationVisaRepository _delegationVisaRep;
  74. private readonly VisaPriceRepository _visaPriceRep;
  75. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  76. private readonly HotelPriceRepository _hotelPriceRep;
  77. private readonly CustomersRepository _customersRep;
  78. private readonly MessageRepository _message;
  79. private readonly SqlSugarClient _sqlSugar;
  80. private readonly TourClientListRepository _tourClientListRep;
  81. private readonly TeamRateRepository _teamRateRep;
  82. #region 成本相关
  83. private readonly CheckBoxsRepository _checkBoxs;
  84. private readonly GroupCostRepository _GroupCostRepository;
  85. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  86. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  87. #endregion
  88. private readonly SetDataRepository _setDataRep;
  89. private string url;
  90. private string path;
  91. private readonly EnterExitCostRepository _enterExitCostRep;
  92. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  93. private readonly UsersRepository _usersRep;
  94. private readonly IJuHeApiService _juHeApi;
  95. private readonly InvertedListRepository _invertedListRep;
  96. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  97. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  98. private readonly ThreeCodeRepository _threeCodeRepository;
  99. private readonly HotelInquiryRepository _hotelInquiryRep;
  100. private readonly FeeAuditRepository _feeAuditRep;
  101. private readonly VisaCommissionRepository _visaCommissionRep;
  102. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  103. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  104. private readonly List<CurrencyInfo> _currencyInit;
  105. private readonly List<int> _portTypeData;
  106. private readonly TableOperationRecordRepository _tableorRep;
  107. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  108. private readonly RestaurantRepository _restaurantRep;
  109. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  110. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  111. private readonly IDeepSeekService _deepSeekService;
  112. /// <summary>
  113. /// 构造函数
  114. /// </summary>
  115. /// <param name="logger"></param>
  116. /// <param name="eec_textLogger"></param>
  117. /// <param name="mapper"></param>
  118. /// <param name="hubContext"></param>
  119. /// <param name="sqlSugar"></param>
  120. /// <param name="grpScheduleRep"></param>
  121. /// <param name="groupRepository"></param>
  122. /// <param name="taskAssignmentRep"></param>
  123. /// <param name="airTicketResRep"></param>
  124. /// <param name="decreasePaymentsRep"></param>
  125. /// <param name="InvitationOfficialActivitiesRep"></param>
  126. /// <param name="delegationEnDataRep"></param>
  127. /// <param name="enterExitCostRep"></param>
  128. /// <param name="delegationVisaRep"></param>
  129. /// <param name="message"></param>
  130. /// <param name="visaPriceRep"></param>
  131. /// <param name="carTouristGuideGroundRep"></param>
  132. /// <param name="checkBoxs"></param>
  133. /// <param name="GroupCostRepository"></param>
  134. /// <param name="CostTypeHotelNumberRepository"></param>
  135. /// <param name="GroupCostParameterRepository"></param>
  136. /// <param name="hotelPriceRep"></param>
  137. /// <param name="customersRep"></param>
  138. /// <param name="setDataRep"></param>
  139. /// <param name="tourClientListRep"></param>
  140. /// <param name="teamRateRep"></param>
  141. /// <param name="usersRep"></param>
  142. /// <param name="juHeApi"></param>
  143. /// <param name="invertedListRep"></param>
  144. /// <param name="visaFeeInfoRep"></param>
  145. /// <param name="ticketBlackCodeRep"></param>
  146. /// <param name="hotelInquiryRep"></param>
  147. /// <param name="threeCodeRepository"></param>
  148. /// <param name="feeAuditRep"></param>
  149. /// <param name="visaCommissionRep"></param>
  150. /// <param name="ffrRep"></param>
  151. /// <param name="opinionaireRep"></param>
  152. /// <param name="tableorRep"></param>
  153. /// <param name="enterExitCostDraftRep"></param>
  154. /// <param name="restaurantRep"></param>
  155. /// <param name="enterExitCostQuoteRep"></param>
  156. /// <param name="grpOrderPreInfoRep"></param>
  157. public GroupsController(
  158. ILogger<GroupsController> logger,
  159. ITextFileLogger eec_textLogger,
  160. IMapper mapper,
  161. IHubContext<ChatHub, IChatClient> hubContext,
  162. SqlSugarClient sqlSugar,
  163. GrpScheduleRepository grpScheduleRep,
  164. DelegationInfoRepository groupRepository,
  165. TaskAssignmentRepository taskAssignmentRep,
  166. AirTicketResRepository airTicketResRep,
  167. DecreasePaymentsRepository decreasePaymentsRep,
  168. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  169. DelegationEnDataRepository delegationEnDataRep,
  170. EnterExitCostRepository enterExitCostRep,
  171. DelegationVisaRepository delegationVisaRep,
  172. MessageRepository message,
  173. VisaPriceRepository visaPriceRep,
  174. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  175. CheckBoxsRepository checkBoxs,
  176. GroupCostRepository GroupCostRepository,
  177. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  178. GroupCostParameterRepository GroupCostParameterRepository,
  179. HotelPriceRepository hotelPriceRep,
  180. CustomersRepository customersRep,
  181. SetDataRepository setDataRep,
  182. TourClientListRepository tourClientListRep,
  183. TeamRateRepository teamRateRep,
  184. UsersRepository usersRep,
  185. IJuHeApiService juHeApi,
  186. InvertedListRepository invertedListRep,
  187. VisaFeeInfoRepository visaFeeInfoRep,
  188. TicketBlackCodeRepository ticketBlackCodeRep,
  189. HotelInquiryRepository hotelInquiryRep,
  190. ThreeCodeRepository threeCodeRepository,
  191. FeeAuditRepository feeAuditRep,
  192. VisaCommissionRepository visaCommissionRep,
  193. ForeignReceivablesRepository ffrRep,
  194. OpinionaireRepository opinionaireRep,
  195. TableOperationRecordRepository tableorRep,
  196. EnterExitCostDraftRepository enterExitCostDraftRep,
  197. RestaurantRepository restaurantRep,
  198. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  199. GroupOrderPreInfoRepository grpOrderPreInfoRep,
  200. IDeepSeekService deepSeekService
  201. )
  202. {
  203. _logger = logger;
  204. _eec_textLogger = eec_textLogger;
  205. _mapper = mapper;
  206. _grpScheduleRep = grpScheduleRep;
  207. _groupRepository = groupRepository;
  208. _taskAssignmentRep = taskAssignmentRep;
  209. _airTicketResRep = airTicketResRep;
  210. _sqlSugar = sqlSugar;
  211. url = AppSettingsHelper.Get("ExcelBaseUrl");
  212. path = AppSettingsHelper.Get("ExcelBasePath");
  213. if (!System.IO.Directory.Exists(path))
  214. {
  215. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  216. }
  217. _decreasePaymentsRep = decreasePaymentsRep;
  218. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  219. _delegationEnDataRep = delegationEnDataRep;
  220. _enterExitCostRep = enterExitCostRep;
  221. _delegationVisaRep = delegationVisaRep;
  222. _message = message;
  223. _visaPriceRep = visaPriceRep;
  224. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  225. _checkBoxs = checkBoxs;
  226. _GroupCostRepository = GroupCostRepository;
  227. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  228. _GroupCostParameterRepository = GroupCostParameterRepository;
  229. _hotelPriceRep = hotelPriceRep;
  230. _customersRep = customersRep;
  231. _setDataRep = setDataRep;
  232. _tourClientListRep = tourClientListRep;
  233. _teamRateRep = teamRateRep;
  234. _hubContext = hubContext;
  235. _usersRep = usersRep;
  236. _juHeApi = juHeApi;
  237. _invertedListRep = invertedListRep;
  238. _visaFeeInfoRep = visaFeeInfoRep;
  239. _ticketBlackCodeRep = ticketBlackCodeRep;
  240. _hotelInquiryRep = hotelInquiryRep;
  241. _threeCodeRepository = threeCodeRepository;
  242. _feeAuditRep = feeAuditRep;
  243. _visaCommissionRep = visaCommissionRep;
  244. _ffrRep = ffrRep;
  245. _opinionaireRep = opinionaireRep;
  246. _currencyInit = new List<CurrencyInfo>()
  247. {
  248. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  249. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  250. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  251. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  252. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  253. };
  254. _portTypeData = new List<int>() { 2, 3 };
  255. _tableorRep = tableorRep;
  256. _enterExitCostDraftRep = enterExitCostDraftRep;
  257. _restaurantRep = restaurantRep;
  258. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  259. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  260. _deepSeekService = deepSeekService;
  261. }
  262. #region 流程管控
  263. /// <summary>
  264. /// 获取团组流程管控信息
  265. /// </summary>
  266. /// <param name="_jsonDto">查询参数</param>
  267. /// <returns></returns>
  268. [HttpPost]
  269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  270. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  271. {
  272. if (string.IsNullOrEmpty(_jsonDto.Paras))
  273. {
  274. return Ok(JsonView(false, "参数为空"));
  275. }
  276. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  277. if (_ScheduleDto != null)
  278. {
  279. if (_ScheduleDto.SearchType == 2)//获取列表
  280. {
  281. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  282. return Ok(JsonView(_grpScheduleViewList));
  283. }
  284. else//获取对象
  285. {
  286. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  287. if (_grpScheduleView != null)
  288. {
  289. return Ok(JsonView(_grpScheduleView));
  290. }
  291. }
  292. }
  293. else
  294. {
  295. return Ok(JsonView(false, "参数反序列化失败"));
  296. }
  297. return Ok(JsonView(false, "暂无数据!"));
  298. }
  299. /// <summary>
  300. /// 修改团组流程管控详细表数据
  301. /// </summary>
  302. /// <param name="dto"></param>
  303. /// <returns></returns>
  304. [HttpPost]
  305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  306. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  307. {
  308. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  309. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  310. .SetColumns(it => it.Duty == _detail.Duty)
  311. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  312. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  313. .SetColumns(it => it.JobContent == _detail.JobContent)
  314. .SetColumns(it => it.Remark == _detail.Remark)
  315. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  316. .Where(s => s.Id == dto.Id)
  317. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  318. .ExecuteCommandAsync();
  319. if (result > 0)
  320. {
  321. return Ok(JsonView(true, "保存成功!"));
  322. }
  323. return Ok(JsonView(false, "保存失败!"));
  324. }
  325. /// <summary>
  326. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  327. /// </summary>
  328. /// <param name="dto"></param>
  329. /// <returns></returns>
  330. [HttpPost]
  331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  332. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  333. {
  334. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  335. _detail.IsDel = 1;
  336. _detail.DeleteUserId = dto.Duty;
  337. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  338. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  339. .SetColumns(it => it.IsDel == _detail.IsDel)
  340. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  341. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  342. .Where(it => it.Id == dto.Id)
  343. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  344. //.WhereColumns(s => s.Id == dto.Id)
  345. .ExecuteCommandAsync();
  346. if (result > 0)
  347. {
  348. return Ok(JsonView(true, "删除成功!"));
  349. }
  350. return Ok(JsonView(false, "删除失败!"));
  351. }
  352. /// <summary>
  353. /// 增加团组流程管控详细表数据
  354. /// </summary>
  355. /// <param name="dto"></param>
  356. /// <returns></returns>
  357. [HttpPost]
  358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  359. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  360. {
  361. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  362. if (DateTime.Now < _detail.ExpectBeginDt)
  363. {
  364. _detail.StepStatus = 0;
  365. }
  366. else
  367. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  368. _detail.StepStatus = 1;
  369. }
  370. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  371. if (result > 0)
  372. {
  373. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  374. return Ok(JsonView(true, "添加成功!", _result));
  375. }
  376. return Ok(JsonView(false, "添加失败!"));
  377. }
  378. #endregion
  379. #region 团组前期信息
  380. /// <summary>
  381. /// 团组前期信息H5-URL(员工对应地址)
  382. /// </summary>
  383. /// <param name="name">用户名称</param>
  384. /// <returns></returns>
  385. [HttpGet]
  386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  387. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  388. {
  389. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  390. .Where(x => x.IsDel == 0)
  391. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  392. .OrderBy(x => x.Id)
  393. .Select(x => new
  394. {
  395. name = x.CnName,
  396. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  397. })
  398. .ToListAsync();
  399. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  400. }
  401. /// <summary>
  402. /// 团组前期信息 List
  403. /// </summary>
  404. /// <returns></returns>
  405. [HttpPost]
  406. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  407. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  408. {
  409. var search = dto.Search;
  410. int[] nameTempIds = new int[] { 1, 12, 28 },
  411. countryTempIds = new int[] { 2, 13, 29 },
  412. daysTempIds = new int[] { 4, 15, 31 },
  413. ppNumTempIds = new int[] { 6 };
  414. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  415. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  416. .Where((opi, u) => opi.IsDel == 0)
  417. .OrderByDescending((opi, u) => opi.CreateTime)
  418. .Select((opi, u) => new GroupOrderPreInfoListView()
  419. {
  420. Id = opi.Id,
  421. Name = opi.Name,
  422. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  423. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  424. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  425. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  426. Operator = u.CnName,
  427. OperationTime = opi.CreateTime
  428. })
  429. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  430. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  431. .ToListAsync();
  432. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  433. int total = list.Count;
  434. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  435. var listPageData1 = listPageData
  436. .Skip((dto.PageIndex - 1) * dto.PageSize)
  437. .Take(dto.PageSize)
  438. .ToList();
  439. var infoIds = listPageData1.Select(x => x.Id).ToList();
  440. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  441. .Where(x => x.IsDel == 0 && x.STid == 109)
  442. .ToArrayAsync();
  443. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  444. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  445. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  446. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  447. .ToListAsync();
  448. foreach (var item in listPageData1)
  449. {
  450. var typeDatas1 = typeDatas.Select(x => new
  451. {
  452. x.Id,
  453. x.Name,
  454. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  455. }).ToArray();
  456. item.VersionDetails = typeDatas1;
  457. }
  458. return Ok(JsonView(listPageData1, listPageData1.Count));
  459. }
  460. /// <summary>
  461. /// 团组前期信息 Init
  462. /// </summary>
  463. /// <returns></returns>
  464. [HttpGet("{userId}")]
  465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  466. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  467. {
  468. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  469. }
  470. /// <summary>
  471. /// 国家数据源
  472. /// </summary>
  473. /// <param name="pageIndex">当前页码</param>
  474. /// <param name="pageSize">每页条数</param>
  475. /// <param name="search">查询条件</param>
  476. /// <returns></returns>
  477. [HttpGet]
  478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  479. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  480. {
  481. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  482. if (pageIndex == 0 && pageSize == 0)
  483. {
  484. //所有数据
  485. return Ok(JsonView(countrys, countrys.Count));
  486. }
  487. //分页
  488. int skip = (pageIndex - 1) * pageSize;
  489. int take = pageSize;
  490. if (!string.IsNullOrEmpty(search))
  491. {
  492. IEnumerable<char> charSequence = search.Select(c => c);
  493. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  494. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  495. return Ok(JsonView(pageData, pageResult1.Count));
  496. }
  497. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  498. return Ok(JsonView(pageResult2, countrys.Count));
  499. }
  500. /// <summary>
  501. /// 城市数据源
  502. /// </summary>
  503. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  504. /// <param name="pageIndex">当前页码</param>
  505. /// <param name="pageSize">每页条数</param>
  506. /// <param name="search">查询条件</param>
  507. /// <returns></returns>
  508. [HttpGet("{countryLabel}")]
  509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  510. public async Task<IActionResult> CityByCountry(
  511. string countryLabel,
  512. [FromQuery] int pageIndex,
  513. [FromQuery] int pageSize,
  514. [FromQuery] string search)
  515. {
  516. countryLabel = HttpUtility.UrlDecode(countryLabel);
  517. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  518. var citys = Array.Empty<string?>();
  519. if (countryList.Any())
  520. {
  521. var cityDatas = await _sqlSugar
  522. .Queryable<Grp_NationalTravelFee>()
  523. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  524. .ToArrayAsync();
  525. foreach (var item in cityDatas)
  526. {
  527. if (item.City.Contains("城市"))
  528. {
  529. item.City = item.Country + "-所有城市";
  530. }
  531. }
  532. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  533. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  534. }
  535. if (pageIndex == 0 && pageSize == 0)
  536. {
  537. //所有数据
  538. return Ok(JsonView(citys, citys?.Length ?? 0));
  539. }
  540. //分页
  541. int skip = (pageIndex - 1) * pageSize;
  542. int take = pageSize;
  543. if (!string.IsNullOrEmpty(search))
  544. {
  545. IEnumerable<char> charSequence = search.Select(c => c);
  546. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  547. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  548. return Ok(JsonView(pageData, pageResult1.Count));
  549. }
  550. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  551. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  552. }
  553. /// <summary>
  554. /// 团组前期信息 Info
  555. /// </summary>
  556. /// <param name="dto">Id</param>
  557. /// <returns></returns>
  558. [HttpGet("{Id}/{TempId}")]
  559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  560. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  561. {
  562. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  563. }
  564. /// <summary>
  565. /// 团组前期信息 移动端 Info
  566. /// </summary>
  567. /// <param name="dto">Id</param>
  568. /// <returns></returns>
  569. [HttpGet("{Id}/{TempId}")]
  570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  571. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  572. {
  573. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  574. }
  575. /// <summary>
  576. /// 团组前期信息 Save
  577. /// </summary>
  578. /// <param name="dto">Id</param>
  579. /// <returns></returns>
  580. [HttpPost]
  581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  582. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  583. {
  584. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  585. }
  586. /// <summary>
  587. /// 团组前期信息 Del
  588. /// </summary>
  589. /// <param name="dto">Id</param>
  590. /// <returns></returns>
  591. [HttpPost]
  592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  593. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  594. {
  595. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  596. }
  597. /// <summary>
  598. /// 团组前期信息 文件下载
  599. /// </summary>
  600. /// <param name="dto">Id</param>
  601. /// <returns></returns>
  602. [HttpGet("{Id}/{TempId}")]
  603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  604. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  605. {
  606. int id = dto.Id, tempId = dto.TempId;
  607. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  608. var data = view.Data as GrpOrderPreInfoView;
  609. #region Excel
  610. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  611. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  612. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  613. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  614. var fileNamePrefix = string.Empty;
  615. if (tempId == 1405)
  616. {
  617. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  618. fileNamePrefix = $"{data.Name}_无商邀版";
  619. }
  620. else if (tempId == 1406)
  621. {
  622. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  623. fileNamePrefix = $"{data.Name}_有商邀版";
  624. }
  625. else
  626. {
  627. //tempId == 1404 默认下载
  628. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  629. fileNamePrefix = $"{data.Name}_单接送机";
  630. }
  631. foreach (var item in data.Items)
  632. {
  633. var obj = item.NewValue;
  634. if (obj == null) item.OriginVal = "";
  635. else if (obj.Equals("有") || obj.Equals("无"))
  636. {
  637. item.OriginVal = obj.ToString();
  638. }
  639. else if (obj is object[] objArray)
  640. {
  641. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  642. item.OriginVal = string.Join("、", stringArray);
  643. }
  644. else if (obj is string[] stringArray)
  645. {
  646. item.OriginVal = string.Join("、", stringArray);
  647. }
  648. else if (obj.Equals("-"))
  649. {
  650. item.OriginVal = "";
  651. }
  652. }
  653. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  654. fileName = CommonFun.ValidFileName(fileName);
  655. //载入模板
  656. var designer = new WorkbookDesigner
  657. {
  658. Workbook = new Workbook(tempPath)
  659. };
  660. if (tempId == 1406)
  661. {
  662. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  663. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  664. for (int i = 1; i <= view2.Length; i++)
  665. {
  666. view2[i - 1].Index = i;
  667. }
  668. designer.SetDataSource("View1", view1);
  669. designer.SetDataSource("View2", view2);
  670. }
  671. else
  672. {
  673. designer.SetDataSource("View", data.Items);
  674. }
  675. designer.Process();
  676. if (!Directory.Exists(savePath))
  677. {
  678. Directory.CreateDirectory(savePath);
  679. }
  680. string serverPath = $"{savePath}{fileName}";
  681. designer.Workbook.Save(serverPath);
  682. string rst = $"{servicePath}{ftpPath}{fileName}";
  683. #endregion
  684. return Ok(JsonView(new { url = rst }));
  685. }
  686. #endregion
  687. #region 团组基本信息
  688. /// <summary>
  689. /// 接团信息列表
  690. /// </summary>
  691. /// <param name="dto">团组列表请求dto</param>
  692. /// <returns></returns>
  693. [HttpPost]
  694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  695. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  696. {
  697. var groupData = await _groupRepository.GetGroupList(dto);
  698. if (groupData.Code != 0)
  699. {
  700. return Ok(JsonView(false, groupData.Msg));
  701. }
  702. return Ok(JsonView(groupData.Data));
  703. }
  704. /// <summary>
  705. /// 分页查询团组列表
  706. /// </summary>
  707. /// <param name="dto"></param>
  708. /// <returns></returns>
  709. [HttpPost]
  710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  711. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  712. {
  713. var watch = new Stopwatch();
  714. watch.Start();
  715. RefAsync<int> total = 0;
  716. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  717. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  718. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  719. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  720. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  721. .Distinct()
  722. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  723. watch.Stop();
  724. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  725. }
  726. /// <summary>
  727. /// 接团信息列表 Page Init
  728. /// </summary>
  729. /// <returns></returns>
  730. [HttpPost]
  731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  732. public async Task<IActionResult> PostGroupPageListInit()
  733. {
  734. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  735. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  736. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  737. var _view = new
  738. {
  739. depData = depDatas,
  740. rankData = rankDatas
  741. };
  742. return Ok(JsonView(true, "查询成功!", _view));
  743. }
  744. /// <summary>
  745. /// 接团信息列表 Page
  746. /// </summary>
  747. /// <param name="dto">团组列表请求dto</param>
  748. /// <returns></returns>
  749. [HttpPost]
  750. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  751. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  752. {
  753. #region 参数验证
  754. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  755. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  756. #region 页面操作权限验证
  757. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  758. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  759. #endregion
  760. #endregion
  761. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  762. {
  763. string sqlWhere = string.Empty;
  764. if (dto.IsSure == 0) //未完成
  765. {
  766. sqlWhere += string.Format(@" And IsSure = 0");
  767. }
  768. else if (dto.IsSure == 1) //已完成
  769. {
  770. sqlWhere += string.Format(@" And IsSure = 1");
  771. }
  772. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  773. {
  774. string tj = dto.SearchCriteria;
  775. 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}%')",
  776. tj, tj, tj, tj, tj);
  777. }
  778. if (int.TryParse(dto.Rank, out int rankId))
  779. {
  780. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  781. }
  782. string sqlWhere1 = string.Empty;
  783. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  784. {
  785. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  786. }
  787. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  788. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  789. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  790. JietuanOperator,IsSure,CreateTime,IsBid
  791. From (
  792. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  793. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  794. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  795. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  796. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  797. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  798. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  799. From Grp_DelegationInfo gdi
  800. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  801. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  802. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  803. Where gdi.IsDel = 0 {0}
  804. ) temp {1}", sqlWhere, sqlWhere1);
  805. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  806. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  807. //处理 团组模块实际操作人
  808. _DelegationList.ForEach(async x =>
  809. {
  810. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  811. var operatorNames = new StringBuilder();
  812. //operatorNames.AppendLine("各模块实际操作人:");
  813. if (operators.Any())
  814. {
  815. operators.ForEach(y =>
  816. {
  817. string label = string.Empty;
  818. if (y.OperationUsers.Any())
  819. {
  820. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  821. label = string.Join('、', users);
  822. }
  823. else label = "暂未指定";
  824. operatorNames.AppendLine($"{y.CTableName}:{label}");
  825. operatorNames.AppendLine();
  826. });
  827. }
  828. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  829. });
  830. var _view = new
  831. {
  832. PageFuncAuth = pageFunAuthView,
  833. Data = _DelegationList
  834. };
  835. return Ok(JsonView(true, "查询成功!", _view, total));
  836. }
  837. else
  838. {
  839. return Ok(JsonView(false, "查询失败"));
  840. }
  841. }
  842. /// <summary>
  843. /// 团组列表
  844. /// </summary>
  845. /// <returns></returns>
  846. [HttpPost]
  847. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  848. {
  849. #region 参数验证
  850. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  851. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  852. #region 页面操作权限验证
  853. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  854. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  855. #endregion
  856. #endregion
  857. if (dto.PortType != 1 && dto.PortType != 2)
  858. {
  859. return Ok(JsonView(false, "查询失败!"));
  860. }
  861. string orderbyStr = "order by gdi.CreateTime Desc";
  862. string sqlWhere = string.Empty;
  863. if (dto.IsSure == 0) //未完成
  864. {
  865. sqlWhere += string.Format(@" And IsSure = 0");
  866. }
  867. else if (dto.IsSure == 1) //已完成
  868. {
  869. sqlWhere += string.Format(@" And IsSure = 1");
  870. }
  871. //团组类型
  872. if (dto.TeamDid > 0)
  873. {
  874. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  875. }
  876. //团组名称
  877. if (!string.IsNullOrEmpty(dto.TeamName))
  878. {
  879. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  880. }
  881. //客户名称
  882. if (!string.IsNullOrEmpty(dto.ClientName))
  883. {
  884. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  885. }
  886. //客户单位
  887. if (!string.IsNullOrEmpty(dto.ClientUnit))
  888. {
  889. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  890. }
  891. //出访时间
  892. if (!string.IsNullOrEmpty(dto.visitDataTime))
  893. {
  894. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  895. orderbyStr = "order by gdi.VisitDate";
  896. }
  897. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  898. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  899. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  900. JietuanOperator,IsSure,CreateTime
  901. From (
  902. Select row_number() over({0}) as Row_Number,
  903. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  904. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  905. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  906. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  907. From Grp_DelegationInfo gdi
  908. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  909. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  910. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  911. Where gdi.IsDel = 0 {1}
  912. ) temp ", orderbyStr, sqlWhere);
  913. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  914. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  915. #region 处理所属部门
  916. /*
  917. * 1.sq 和 gyy 等显示 市场部
  918. * 2.王鸽和主管及张总还有管理员号统一国交部
  919. * 2-1. 4 管理员 ,21 张海麟
  920. */
  921. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  922. var userIds1 = new List<int>() { 4, 21 };
  923. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  924. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  925. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  926. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  927. .ToList();
  928. foreach (var item in _DelegationList)
  929. {
  930. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  931. }
  932. #endregion
  933. var _view = new
  934. {
  935. PageFuncAuth = pageFunAuthView,
  936. Data = _DelegationList
  937. };
  938. return Ok(JsonView(true, "查询成功!", _view, total));
  939. }
  940. /// <summary>
  941. /// 接团信息详情
  942. /// </summary>
  943. /// <param name="dto">团组info请求dto</param>
  944. /// <returns></returns>
  945. [HttpPost]
  946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  947. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  948. {
  949. var groupData = await _groupRepository.GetGroupInfo(dto);
  950. if (groupData.Code != 0)
  951. {
  952. return Ok(JsonView(false, groupData.Msg));
  953. }
  954. return Ok(JsonView(groupData.Data));
  955. }
  956. /// <summary>
  957. /// 接团信息 编辑添加
  958. /// 基础信息数据源
  959. /// </summary>
  960. /// <param name="dto"></param>
  961. /// <returns></returns>
  962. [HttpPost]
  963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  964. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  965. {
  966. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  967. if (groupData.Code != 0)
  968. {
  969. return Ok(JsonView(false, groupData.Msg));
  970. }
  971. return Ok(JsonView(groupData.Data));
  972. }
  973. /// <summary>
  974. /// 成本修改团组信息
  975. /// </summary>
  976. /// <param name="dto"></param>
  977. /// <returns></returns>
  978. [HttpPost]
  979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  980. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  981. {
  982. var jw = JsonView(false, "操作失败");
  983. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  984. if (di == null)
  985. {
  986. jw.Msg = "参数有误!";
  987. return Ok(jw);
  988. }
  989. #region 添加出访起止时间
  990. var startTime = new DateTime();
  991. var endTime = new DateTime();
  992. if (DateTime.TryParse(dto.VisitDate, out startTime))
  993. {
  994. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  995. }
  996. else
  997. {
  998. jw.Msg = "参数有误!";
  999. return Ok(jw);
  1000. }
  1001. #endregion
  1002. di.VisitDate = startTime;
  1003. di.VisitPNumber = dto.VisitPNumber;
  1004. di.VisitDays = dto.VisitDays;
  1005. di.VisitStartDate = startTime;
  1006. di.VisitEndDate = endTime;
  1007. var count = _sqlSugar.Updateable(di)
  1008. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1009. .ExecuteCommand();
  1010. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1011. }
  1012. /// <summary>
  1013. /// 接团信息 编辑添加
  1014. /// 省份-城市 基础信息数据源
  1015. /// </summary>
  1016. /// <param name="dto"></param>
  1017. /// <returns></returns>
  1018. [HttpPost]
  1019. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1020. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1021. {
  1022. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1023. string search = dto.Search;
  1024. var data = await _groupRepository.CityBasicSource();
  1025. int total = data.Length;
  1026. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1027. .Skip((pageIndex - 1) * pageSize)
  1028. .Take(pageSize)
  1029. .ToArray();
  1030. return Ok(JsonView(data, total));
  1031. }
  1032. /// <summary>
  1033. /// 接团信息 操作(增改)
  1034. /// </summary>
  1035. /// <param name="dto"></param>
  1036. /// <returns></returns>
  1037. [HttpPost]
  1038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1039. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1040. {
  1041. // 创建 Stopwatch 实例
  1042. Stopwatch stopwatch = Stopwatch.StartNew();
  1043. decimal ffrPrice = 0.00M;
  1044. DateTime? visitDt = null;
  1045. if (dto.Status == 2)
  1046. {
  1047. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1048. if (groupInfo != null)
  1049. {
  1050. ffrPrice = groupInfo.PaymentMoney;
  1051. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1052. }
  1053. }
  1054. var groupData = await _groupRepository.GroupOperation(dto);
  1055. if (groupData.Code != 0)
  1056. {
  1057. return Ok(JsonView(false, groupData.Msg));
  1058. }
  1059. int diId = 0;
  1060. try
  1061. {
  1062. //添加时 默认加入团组汇率
  1063. if (dto.Status == 1) //添加
  1064. {
  1065. diId = groupData.Data;
  1066. //添加默认币种
  1067. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1068. //默认分配权限
  1069. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1070. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1071. var _managerIds = new List<int>() { 22, 32, 21 };
  1072. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1073. if (userIds.Count > 0)
  1074. {
  1075. userIds.Add(208);
  1076. //创建团组管控
  1077. GroupStepForDelegation.CreateWorkStep(diId);
  1078. //发送消息
  1079. string groupName = dto.TeamName;
  1080. string createGroupUser = string.Empty;
  1081. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1082. if (userInfo != null) createGroupUser = userInfo.CnName;
  1083. string title = $"系统通知";
  1084. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1085. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1086. }
  1087. //默认创建倒推表
  1088. await _invertedListRep._Create(dto.UserId, diId);
  1089. }
  1090. else if (dto.Status == 2)
  1091. {
  1092. diId = dto.Id;
  1093. }
  1094. #region 签证人员团组时间通知
  1095. #region 计算出访起止时间
  1096. var startTime = new DateTime();
  1097. var endTime = new DateTime();
  1098. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1099. {
  1100. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1101. }
  1102. #endregion
  1103. #endregion
  1104. #region 团组操作默认添加/修改收款账单
  1105. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1106. {
  1107. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1108. .Where(x => x.IsDel == 0 &&
  1109. x.Diid == diId &&
  1110. x.Remark.Equals("预付款")
  1111. )
  1112. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1113. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1114. .FirstAsync();
  1115. ffrInfo = new Fin_ForeignReceivables()
  1116. {
  1117. Diid = diId,
  1118. PriceName = dto.ClientUnit,
  1119. Price = dto.PaymentMoney,
  1120. Count = 1,
  1121. Unit = $"元",
  1122. ItemSumPrice = dto.PaymentMoney,
  1123. Rate = 1.0000M,
  1124. Currency = 836,
  1125. AddingWay = 0,
  1126. CreateUserId = dto.UserId,
  1127. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1128. Remark = $"预付款"
  1129. };
  1130. if (ffrInfo == null) //Add
  1131. {
  1132. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1133. }
  1134. else //修改
  1135. {
  1136. await _sqlSugar.Updateable(ffrInfo)
  1137. .UpdateColumns(x => new
  1138. {
  1139. x.PriceName,
  1140. x.Price,
  1141. x.ItemSumPrice,
  1142. x.CreateTime,
  1143. x.CreateUserId
  1144. })
  1145. .WhereColumns(x => x.Id)
  1146. .ExecuteCommandAsync();
  1147. }
  1148. }
  1149. #endregion
  1150. if (diId > 0)
  1151. {
  1152. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1153. }
  1154. // 停止计时
  1155. stopwatch.Stop();
  1156. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1157. }
  1158. catch (Exception ex)
  1159. {
  1160. // 停止计时
  1161. stopwatch.Stop();
  1162. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1163. Logs(ex.Message);
  1164. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1165. }
  1166. // 停止计时
  1167. stopwatch.Stop();
  1168. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1169. }
  1170. /// <summary>
  1171. /// 接团流程操作(增改)
  1172. /// 安卓端使用 建团时添加客户名单
  1173. /// </summary>
  1174. /// <param name="dto"></param>
  1175. /// <returns></returns>
  1176. [HttpPost]
  1177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1178. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1179. {
  1180. #region 参数验证
  1181. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1182. #region 页面操作权限验证
  1183. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1184. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1185. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1186. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1187. #endregion
  1188. #endregion
  1189. try
  1190. {
  1191. //_sqlSugar.BeginTran();
  1192. decimal ffrPrice = 0.00M;
  1193. DateTime? visitDt = null;
  1194. if (dto.Status == 2)
  1195. {
  1196. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1197. if (groupInfo != null)
  1198. {
  1199. ffrPrice = groupInfo.PaymentMoney;
  1200. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1201. }
  1202. }
  1203. var _dto = new GroupOperationDto();
  1204. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1205. var groupData = await _groupRepository.GroupOperation(_dto);
  1206. if (groupData.Code != 0)
  1207. {
  1208. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1209. }
  1210. int diId = 0;
  1211. //添加时 默认加入团组汇率
  1212. if (dto.Status == 1) //添加
  1213. {
  1214. diId = groupData.Data;
  1215. //添加默认币种
  1216. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1217. //默认分配权限
  1218. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1219. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1220. var _managerIds = new List<int>() { 21, 22, 32 };
  1221. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1222. if (userIds.Count > 0)
  1223. {
  1224. userIds.Add(208);
  1225. //创建团组管控
  1226. GroupStepForDelegation.CreateWorkStep(diId);
  1227. //发送消息
  1228. string groupName = dto.TeamName;
  1229. string createGroupUser = string.Empty;
  1230. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1231. if (userInfo != null) createGroupUser = userInfo.CnName;
  1232. string title = $"系统通知";
  1233. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1234. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1235. }
  1236. #region 应用推送
  1237. try
  1238. {
  1239. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1240. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1241. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1242. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1243. {
  1244. var userList = new List<string>() { users.QiyeChatUserId };
  1245. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1246. }
  1247. }
  1248. catch (Exception ex)
  1249. {
  1250. }
  1251. #endregion
  1252. //默认创建倒推表
  1253. await _invertedListRep._Create(dto.UserId, diId);
  1254. }
  1255. if (dto.Status == 2)
  1256. {
  1257. diId = dto.Id;
  1258. if (diId == 0)
  1259. {
  1260. //_sqlSugar.RollbackTran();
  1261. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1262. }
  1263. }
  1264. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1265. if (viewData.Code != 0)
  1266. {
  1267. //_sqlSugar.RollbackTran();
  1268. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1269. }
  1270. #region 团组操作默认添加/修改收款账单
  1271. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1272. {
  1273. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1274. .Where(x => x.IsDel == 0 &&
  1275. x.Diid == diId &&
  1276. x.Remark.Equals("预付款")
  1277. )
  1278. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1279. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1280. .FirstAsync();
  1281. ffrInfo = new Fin_ForeignReceivables()
  1282. {
  1283. Diid = diId,
  1284. PriceName = dto.ClientUnit,
  1285. Price = dto.PaymentMoney,
  1286. Count = 1,
  1287. Unit = $"元",
  1288. ItemSumPrice = dto.PaymentMoney,
  1289. Rate = 1.0000M,
  1290. Currency = 836,
  1291. AddingWay = 0,
  1292. CreateUserId = dto.UserId,
  1293. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1294. Remark = $"预付款"
  1295. };
  1296. if (ffrInfo == null) //Add
  1297. {
  1298. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1299. }
  1300. else //修改
  1301. {
  1302. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1303. .UpdateColumns(x => new
  1304. {
  1305. x.PriceName,
  1306. x.Price,
  1307. x.ItemSumPrice,
  1308. x.CreateTime,
  1309. x.CreateUserId
  1310. })
  1311. .WhereColumns(x => x.Id)
  1312. .ExecuteCommandAsync();
  1313. }
  1314. }
  1315. #endregion
  1316. #region 签证人员团组时间通知
  1317. #region 计算出访起止时间
  1318. var startTime = new DateTime();
  1319. var endTime = new DateTime();
  1320. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1321. {
  1322. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1323. }
  1324. #endregion
  1325. if (diId > 0)
  1326. {
  1327. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1328. }
  1329. #endregion
  1330. //_sqlSugar.CommitTran();
  1331. return Ok(JsonView(true, "添加成功"));
  1332. }
  1333. catch (Exception ex)
  1334. {
  1335. _sqlSugar.RollbackTran();
  1336. return Ok(JsonView(false, ex.Message));
  1337. }
  1338. }
  1339. /// <summary>
  1340. /// 接团流程操作(增改)
  1341. /// 安卓端使用 建团时添加客户名单
  1342. /// </summary>
  1343. /// <param name="dto"></param>
  1344. /// <returns></returns>
  1345. [HttpPost]
  1346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1347. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1348. {
  1349. #region 参数验证
  1350. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1351. #region 页面操作权限验证
  1352. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1353. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1354. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1355. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1356. #endregion
  1357. #endregion
  1358. _sqlSugar.BeginTran();
  1359. decimal ffrPrice = 0.00M;
  1360. DateTime? visitDt = null;
  1361. if (dto.Status == 2)
  1362. {
  1363. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1364. if (groupInfo != null)
  1365. {
  1366. ffrPrice = groupInfo.PaymentMoney;
  1367. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1368. }
  1369. }
  1370. var _dto = new GroupOperationDto();
  1371. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1372. var groupData = await _groupRepository.GroupOperation(_dto);
  1373. if (groupData.Code != 0)
  1374. {
  1375. _sqlSugar.RollbackTran();
  1376. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1377. }
  1378. try
  1379. {
  1380. int diId = 0;
  1381. //添加时 默认加入团组汇率
  1382. if (dto.Status == 1) //添加
  1383. {
  1384. diId = groupData.Data;
  1385. //添加默认币种
  1386. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1387. //默认分配权限
  1388. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1389. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1390. var _managerIds = new List<int>() { 21, 22, 32 };
  1391. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1392. if (userIds.Count > 0)
  1393. {
  1394. userIds.Add(208);
  1395. //创建团组管控
  1396. GroupStepForDelegation.CreateWorkStep(diId);
  1397. //发送消息
  1398. string groupName = dto.TeamName;
  1399. string createGroupUser = string.Empty;
  1400. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1401. if (userInfo != null) createGroupUser = userInfo.CnName;
  1402. string title = $"系统通知";
  1403. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1404. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1405. }
  1406. #region 应用推送
  1407. try
  1408. {
  1409. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1410. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1411. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1412. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1413. {
  1414. var userList = new List<string>() { users.QiyeChatUserId };
  1415. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1416. }
  1417. }
  1418. catch (Exception ex)
  1419. {
  1420. _sqlSugar.CommitTran();
  1421. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1422. }
  1423. #endregion
  1424. //默认创建倒推表
  1425. await _invertedListRep._Create(dto.UserId, diId);
  1426. }
  1427. else if (dto.Status == 2)
  1428. {
  1429. diId = dto.Id;
  1430. if (diId == 0)
  1431. {
  1432. _sqlSugar.RollbackTran();
  1433. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1434. }
  1435. }
  1436. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1437. if (viewData.Code != 0)
  1438. {
  1439. _sqlSugar.RollbackTran();
  1440. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1441. }
  1442. #region 团组操作默认添加/修改收款账单
  1443. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1444. {
  1445. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1446. .Where(x => x.IsDel == 0 &&
  1447. x.Diid == diId &&
  1448. x.Remark.Equals("预付款")
  1449. )
  1450. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1451. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1452. .FirstAsync();
  1453. ffrInfo = new Fin_ForeignReceivables()
  1454. {
  1455. Diid = diId,
  1456. PriceName = dto.ClientUnit,
  1457. Price = dto.PaymentMoney,
  1458. Count = 1,
  1459. Unit = $"元",
  1460. ItemSumPrice = dto.PaymentMoney,
  1461. Rate = 1.0000M,
  1462. Currency = 836,
  1463. AddingWay = 0,
  1464. CreateUserId = dto.UserId,
  1465. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1466. Remark = $"预付款"
  1467. };
  1468. if (ffrInfo == null) //Add
  1469. {
  1470. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1471. }
  1472. else //修改
  1473. {
  1474. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1475. .UpdateColumns(x => new
  1476. {
  1477. x.PriceName,
  1478. x.Price,
  1479. x.ItemSumPrice,
  1480. x.CreateTime,
  1481. x.CreateUserId
  1482. })
  1483. .WhereColumns(x => x.Id)
  1484. .ExecuteCommandAsync();
  1485. }
  1486. }
  1487. #endregion
  1488. #region 签证人员团组时间通知
  1489. #region 计算出访起止时间
  1490. var startTime = new DateTime();
  1491. var endTime = new DateTime();
  1492. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1493. {
  1494. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1495. }
  1496. #endregion
  1497. if (diId > 0)
  1498. {
  1499. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1500. }
  1501. #endregion
  1502. _sqlSugar.CommitTran();
  1503. return Ok(JsonView(true));
  1504. }
  1505. catch (Exception ex)
  1506. {
  1507. _sqlSugar.RollbackTran();
  1508. return Ok(JsonView(false, ex.Message));
  1509. }
  1510. }
  1511. /// <summary>
  1512. /// 接团信息 操作(删除)
  1513. /// </summary>
  1514. /// <param name="dto"></param>
  1515. /// <returns></returns>
  1516. [HttpPost]
  1517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1518. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1519. {
  1520. var diId = dto.Id;
  1521. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1522. #region 删除 验证
  1523. /*
  1524. * 1、收款账单数据:0 条
  1525. * 2、收款退还数据:0 条
  1526. * 3、机票费用数据:0 条
  1527. * 4、签证费用数据:0 条
  1528. * 5、保险费用数据:0 条
  1529. * 6、酒店费用数据:0 条
  1530. * 7、公务出访数据:1 条
  1531. * 8、邀请公务活动费用数据:1 条
  1532. * 9、OP费用数据:5 条
  1533. * 10、其他费用数据:0 条
  1534. * 11、团组日付报销费用数据:0 条
  1535. *
  1536. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1537. */
  1538. //收款账单
  1539. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1540. //收款退还
  1541. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1542. //机票费用
  1543. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1544. //签证费用
  1545. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1546. //保险费用
  1547. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1548. //酒店费用
  1549. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1550. //公务出访
  1551. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1552. //邀请公务活动费用
  1553. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1554. //OP费用
  1555. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1556. //其他费用
  1557. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1558. //团组日付报销费用
  1559. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1560. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1561. if (feeCount > 0)
  1562. {
  1563. var delMsgTips = new StringBuilder();
  1564. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1565. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1566. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1567. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1568. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1569. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1570. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1571. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1572. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1573. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1574. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1575. delMsgTips.AppendLine($"");
  1576. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1577. return Ok(JsonView(false, delMsgTips.ToString()));
  1578. }
  1579. #endregion
  1580. var groupData = await _groupRepository.GroupDel(dto);
  1581. if (groupData.Code != 0)
  1582. {
  1583. return Ok(JsonView(false, groupData.Msg));
  1584. }
  1585. return Ok(JsonView(true));
  1586. }
  1587. /// <summary>
  1588. /// 获取团组销售报价号
  1589. /// 团组添加时 使用
  1590. /// </summary>
  1591. /// <returns></returns>
  1592. [HttpPost]
  1593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1594. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1595. {
  1596. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1597. if (groupData.Code != 0)
  1598. {
  1599. return Ok(JsonView(false, groupData.Msg));
  1600. }
  1601. object salesQuoteNo = new
  1602. {
  1603. SalesQuoteNo = groupData.Data
  1604. };
  1605. return Ok(JsonView(salesQuoteNo));
  1606. }
  1607. /// <summary>
  1608. /// 设置确认出团
  1609. /// </summary>
  1610. /// <param name="dto"></param>
  1611. /// <returns></returns>
  1612. [HttpPost]
  1613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1614. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1615. {
  1616. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1617. if (groupData.Code != 0)
  1618. {
  1619. return Ok(JsonView(false, groupData.Msg));
  1620. }
  1621. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1622. #region OA消息推送
  1623. try
  1624. {
  1625. string groupName = groupInfo.TeamName;
  1626. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1627. string title = $"系统通知";
  1628. string content = $"团组[{groupName}]已确认出团!";
  1629. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1630. }
  1631. catch (Exception ex)
  1632. {
  1633. }
  1634. #endregion
  1635. #region 应用推送
  1636. try
  1637. {
  1638. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1639. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1640. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1641. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1642. {
  1643. var userList = new List<string>() { users.QiyeChatUserId };
  1644. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1645. }
  1646. }
  1647. catch (Exception ex)
  1648. {
  1649. }
  1650. #endregion
  1651. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1652. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1653. }
  1654. /// <summary>
  1655. /// 获取团组名称data And 签证国别Data
  1656. /// </summary>
  1657. /// <param name="dto"></param>
  1658. /// <returns></returns>
  1659. [HttpPost]
  1660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1661. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1662. {
  1663. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1664. if (groupData.Code != 0)
  1665. {
  1666. return Ok(JsonView(false, groupData.Msg));
  1667. }
  1668. return Ok(JsonView(groupData.Data));
  1669. }
  1670. /// <summary>
  1671. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1672. /// </summary>
  1673. /// <returns></returns>
  1674. [HttpPost]
  1675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1676. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1677. {
  1678. try
  1679. {
  1680. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1681. if (groupData.Code != 0)
  1682. {
  1683. return Ok(JsonView(false, groupData.Msg));
  1684. }
  1685. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1686. }
  1687. catch (Exception ex)
  1688. {
  1689. return Ok(JsonView(false, ex.Message));
  1690. throw;
  1691. }
  1692. }
  1693. /// <summary>
  1694. /// 团组清单 Excel
  1695. /// </summary>
  1696. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1697. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1698. /// <returns></returns>
  1699. [HttpGet]
  1700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1701. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1702. {
  1703. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1704. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1705. if (!beginBool && !endBool)
  1706. {
  1707. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1708. }
  1709. string sql = string.Format(@"
  1710. SELECT
  1711. ROW_NUMBER,
  1712. Id,
  1713. SalesQuoteNo,
  1714. TourCode,
  1715. TeamTypeId,
  1716. TeamType,
  1717. TeamLevId,
  1718. TeamLev,
  1719. TeamName,
  1720. ClientName,
  1721. ClientUnit,
  1722. VisitDate,
  1723. VisitDays,
  1724. VisitPNumber,
  1725. JietuanOperatorId,
  1726. JietuanOperator,
  1727. IsSure,
  1728. CreateUserName,
  1729. IsBid
  1730. FROM
  1731. (
  1732. SELECT
  1733. ROW_NUMBER() OVER(
  1734. ORDER BY
  1735. gdi.VisitDate Desc
  1736. ) AS ROW_NUMBER,
  1737. gdi.Id,
  1738. SalesQuoteNo,
  1739. TourCode,
  1740. ssd.Id TeamTypeId,
  1741. ssd.Name TeamType,
  1742. ssd1.Id TeamLevId,
  1743. ssd1.Name TeamLev,
  1744. TeamName,
  1745. ClientName,
  1746. ClientUnit,
  1747. VisitDate,
  1748. VisitDays,
  1749. VisitPNumber,
  1750. JietuanOperator JietuanOperatorId,
  1751. su.CnName JietuanOperator,
  1752. IsSure,
  1753. gdi.CreateTime,
  1754. su1.CnName As CreateUserName,
  1755. gdi.IsBid
  1756. FROM
  1757. Grp_DelegationInfo gdi
  1758. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1759. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1760. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1761. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1762. WHERE
  1763. gdi.IsDel = 0
  1764. AND gdi.IsBid = 0
  1765. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1766. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1767. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1768. #region 处理所属部门
  1769. /*
  1770. * 1.sq 和 gyy 等显示 市场部
  1771. * 2.王鸽和主管及张总还有管理员号统一国交部
  1772. * 2-1. 4 管理员 ,21 张海麟
  1773. */
  1774. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1775. var userIds1 = new List<int>() { 4, 21 };
  1776. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1777. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1778. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1779. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1780. .ToListAsync();
  1781. var droupIds = groupList.Select(it => it.Id).ToList();
  1782. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1783. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1784. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1785. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1786. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1787. {
  1788. DiId = tcl.DiId,
  1789. LastName = dc.LastName,
  1790. FirstName = dc.FirstName,
  1791. Sex = dc.Sex,
  1792. Birthday = dc.BirthDay,
  1793. Company = cc.CompanyFullName,
  1794. Job = dc.Job,
  1795. CreateTime = tcl.CreateTime,
  1796. })
  1797. .ToList();
  1798. foreach (var item in groupList)
  1799. {
  1800. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1801. string groupFirstName = "";
  1802. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1803. if (currDatas.Any())
  1804. {
  1805. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1806. }
  1807. item.GroupFirst = groupFirstName;
  1808. }
  1809. #endregion
  1810. #region Excel
  1811. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1812. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1813. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1814. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1815. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1816. //载入模板
  1817. var designer = new WorkbookDesigner
  1818. {
  1819. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1820. };
  1821. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1822. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1823. dt.TableName = "GroupList";
  1824. designer.SetDataSource(dt);
  1825. designer.Process();
  1826. if (!Directory.Exists(savePath))
  1827. {
  1828. Directory.CreateDirectory(savePath);
  1829. }
  1830. string serverPath = $"{savePath}{fileName}";
  1831. designer.Workbook.Save(serverPath);
  1832. string rst = $"{servicePath}{ftpPath}{fileName}";
  1833. #endregion
  1834. return Ok(JsonView(true, "操作成功!", rst));
  1835. }
  1836. /// <summary>
  1837. /// 团组合同下载(1.付款80% 2.付全款)
  1838. /// </summary>
  1839. /// <param name="dto"></param>
  1840. /// <returns></returns>
  1841. /// <exception cref="Exception"></exception>
  1842. [HttpPost]
  1843. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1844. {
  1845. var jw = JsonView(false);
  1846. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1847. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1848. if (di == null)
  1849. {
  1850. jw.Msg = "团组Id有误!";
  1851. return Ok(jw);
  1852. }
  1853. #region 权限校验
  1854. var allDownFile = new List<int>() { 21 };
  1855. try
  1856. {
  1857. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1858. .First(x => x.Id == 1418 && x.IsDel == 0);
  1859. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1860. }
  1861. catch (Exception)
  1862. { }
  1863. var guojiaoDownFile = new List<int>() { 330, 383 };
  1864. var shichangDownFile = new List<int>() { 95 };
  1865. if (allDownFile.Contains(dto.UserId))
  1866. {
  1867. }
  1868. else if (guojiaoDownFile.Contains(dto.UserId))
  1869. {
  1870. var guojiaobuDi = new List<int>() { 4, 21 };
  1871. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1872. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1873. .Where((d, u) => u.Id == di.JietuanOperator)
  1874. .Select((d, u) => d.DepName)
  1875. .First();
  1876. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1877. {
  1878. jw.Msg = "暂无下载权限!";
  1879. return Ok(jw);
  1880. }
  1881. }
  1882. else if (shichangDownFile.Contains(dto.UserId))
  1883. {
  1884. var dic = new Dictionary<int, int[]>()
  1885. {
  1886. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1887. };
  1888. try
  1889. {
  1890. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1891. if (sqSetting != null)
  1892. {
  1893. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1894. foreach (var item in result.Keys)
  1895. {
  1896. if (dic.ContainsKey(item))
  1897. {
  1898. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1899. Array.Copy(dic[item], dilatation, dic[item].Length);
  1900. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1901. dic[item] = dilatation;
  1902. }
  1903. else
  1904. {
  1905. dic.Add(item, result[item]);
  1906. }
  1907. }
  1908. }
  1909. if (!dic[95].Contains(di.CreateUserId))
  1910. {
  1911. jw.Msg = "暂无下载权限!";
  1912. return Ok(jw);
  1913. }
  1914. }
  1915. catch (Exception)
  1916. { }
  1917. }
  1918. else if (dto.UserId == di.CreateUserId)
  1919. {
  1920. }
  1921. else
  1922. {
  1923. jw.Msg = "暂无下载权限!";
  1924. return Ok(jw);
  1925. }
  1926. #endregion
  1927. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1928. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1929. .ToListAsync();
  1930. if (!blackCodeList.Any())
  1931. {
  1932. jw.Msg = "该团无机票行程代码!";
  1933. return Ok(jw);
  1934. }
  1935. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1936. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1937. if (groupEnterExitCost == null)
  1938. {
  1939. jw.Msg = "暂无三公费用信息!";
  1940. return Ok(jw);
  1941. }
  1942. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1943. rateList ??= new List<CurrencyInfo>();
  1944. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1945. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1946. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1947. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1948. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1949. .Select((x, a, b) => new
  1950. {
  1951. x.Index,
  1952. itemName = a.Name,
  1953. CurrencyStr = b.Name,
  1954. x.Cost,
  1955. x.SubTotal,
  1956. x.Remark
  1957. })
  1958. .OrderBy((x) => x.Index)
  1959. .ToList();
  1960. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1961. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1962. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1963. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1964. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1965. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1966. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1967. decimal subJJC = 0.00M,
  1968. subGWC = 0.00M,
  1969. subTDC = 0.00M;
  1970. //经济舱
  1971. if (groupEnterExitCost.SumJJC == 1)
  1972. {
  1973. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1974. }
  1975. //公务舱
  1976. if (groupEnterExitCost.SumGWC == 1)
  1977. {
  1978. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1979. }
  1980. //头等舱
  1981. if (groupEnterExitCost.SumTDC == 1)
  1982. {
  1983. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1984. }
  1985. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1986. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1987. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1988. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1989. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1990. .Select((x, s, dc, cc) => new GroupClints
  1991. {
  1992. Id = x.Id,
  1993. Name = s.Name,
  1994. IsAccompany = x.IsAccompany,
  1995. CompanyFullName = cc.CompanyFullName
  1996. })
  1997. .ToListAsync();
  1998. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1999. //获取舱位人数
  2000. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  2001. .GroupBy(x => x.Name)
  2002. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  2003. .ToList();
  2004. string cityPath = string.Empty;
  2005. string startCity = string.Empty;
  2006. string endCity = string.Empty;
  2007. foreach (var item in blackCodeList)
  2008. {
  2009. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2010. cityPath += city + "\r\n";
  2011. if (item.Equals(blackCodeList.First()))
  2012. {
  2013. var sp = city.Split('-');
  2014. startCity = sp[0];
  2015. endCity = sp[^1];
  2016. }
  2017. }
  2018. var bookMarkDic = new Dictionary<string, string>
  2019. {
  2020. { "ClientUnit", di.ClientUnit },
  2021. { "VisitCountry", di.VisitCountry },
  2022. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2023. { "VisitPNumber", di.VisitPNumber.ToString() },
  2024. { "CityPath", cityPath },
  2025. { "StartCity", startCity },
  2026. { "EndCity", endCity },
  2027. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2028. };
  2029. Document doc = null;
  2030. var percentage = 0.8M;
  2031. var fileNameadd = "预付";
  2032. if (dto.FileType == 1)
  2033. {
  2034. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2035. }
  2036. else if (dto.FileType == 2)
  2037. {
  2038. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2039. percentage = 1;
  2040. fileNameadd = "全款";
  2041. }
  2042. else
  2043. {
  2044. throw new Exception("FileType有误!");
  2045. }
  2046. var builder = new DocumentBuilder(doc);
  2047. decimal totalPrice = 0.00M;
  2048. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2049. if (firstTable != null)
  2050. {
  2051. // 遍历表格的行和单元格
  2052. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2053. {
  2054. for (int i = 0; i < row.Cells.Count; i++)
  2055. {
  2056. var cell = row.Cells[i];
  2057. // 读取单元格内容
  2058. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2059. if (cellTextFirst.Contains("舱位"))
  2060. {
  2061. break;
  2062. }
  2063. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2064. {
  2065. if (i == 2)
  2066. {
  2067. if (cellTextFirst == "经济舱")
  2068. {
  2069. // 设置单元格内容
  2070. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2071. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2072. }
  2073. else
  2074. {
  2075. // 设置单元格内容
  2076. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2077. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2078. }
  2079. }
  2080. if (i == 3)
  2081. {
  2082. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2083. if (count != null)
  2084. {
  2085. // 设置单元格内容
  2086. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2087. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2088. }
  2089. }
  2090. if (i == 4)
  2091. {
  2092. var rowPrice = 0.00M;
  2093. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2094. count ??= 0;
  2095. if (cellTextFirst == "经济舱")
  2096. {
  2097. rowPrice = subJJC * (int)count;
  2098. }
  2099. else
  2100. {
  2101. rowPrice = subGWC * (int)count;
  2102. }
  2103. totalPrice += rowPrice;
  2104. // 设置单元格内容
  2105. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2106. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2107. }
  2108. }
  2109. }
  2110. }
  2111. }
  2112. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2113. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2114. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2115. //--合同表格部分
  2116. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2117. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2118. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2119. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2120. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2121. bookMarkDic.Add("CityPath1", cityPath);
  2122. bookMarkDic.Add("CityPath2", cityPath);
  2123. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2124. if (contractTable != null)
  2125. {
  2126. //数据源
  2127. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2128. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2129. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2130. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2131. .Select((it, y, s) => new
  2132. {
  2133. it.Cost,
  2134. it.SubTotal,
  2135. it.Type,
  2136. y.Id,
  2137. y.City,
  2138. s.Name,
  2139. CurrencyCodeCn = s.Remark
  2140. })
  2141. .ToList()
  2142. .Select(x => new
  2143. {
  2144. CurrencyCode = x.Name,
  2145. CityId = x.Id,
  2146. x.City,
  2147. di.VisitPNumber,
  2148. x.Type,
  2149. x.Cost,
  2150. x.SubTotal,
  2151. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2152. x.CurrencyCodeCn,
  2153. });
  2154. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2155. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2156. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2157. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2158. var tableSettings = new List<tableSetting>()
  2159. {
  2160. new(){ Index = 1 , Property = "City"},
  2161. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2162. new(){ Index = 3 , Property = "Cost"},
  2163. new(){ Index = 4 , Property = "VisitPNumber"},
  2164. //new tableSetting{ Index = 5 , Property = ""},
  2165. //new tableSetting{ Index = 6 , Property = ""},
  2166. new(){ Index = 7 , Property = "Rate"},
  2167. //new tableSetting{ Index = 8 , Property = ""},
  2168. };
  2169. //1.住宿费
  2170. int cloneRow = 8;
  2171. int startDayPrice = 8; //写入index
  2172. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2173. foreach (var dac in dac1)
  2174. {
  2175. var first = dac.First();
  2176. var dayCount = dac.Count();
  2177. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2178. for (int i = 1; i < row.Cells.Count; i++)
  2179. {
  2180. var cell = row.Cells[i];
  2181. var findProperty = tableSettings.Find(x => x.Index == i);
  2182. if (findProperty != null)
  2183. {
  2184. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2185. // 设置单元格内容
  2186. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2187. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2188. }
  2189. else
  2190. {
  2191. switch (i)
  2192. {
  2193. case 5:
  2194. cell.FirstParagraph.Runs.Clear();
  2195. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2196. break;
  2197. case 6:
  2198. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2199. cell.FirstParagraph.Runs.Clear();
  2200. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2201. break;
  2202. case 8:
  2203. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2204. cell.FirstParagraph.Runs.Clear();
  2205. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2206. ZSPriceSum += xiaojiRMB;
  2207. break;
  2208. default:
  2209. break;
  2210. }
  2211. }
  2212. }
  2213. startDayPrice++;
  2214. if (!dac1.Last().Equals(dac))
  2215. {
  2216. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2217. // 将克隆的行追加到原行后面
  2218. contractTable.Rows.Insert(startDayPrice, newRow);
  2219. }
  2220. else
  2221. {
  2222. cloneRow += dac1.Count + 1;
  2223. startDayPrice = cloneRow;
  2224. }
  2225. }
  2226. //2.伙食费
  2227. foreach (var dac in dac2)
  2228. {
  2229. var first = dac.First();
  2230. var dayCount = dac.Count();
  2231. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2232. for (int i = 1; i < row.Cells.Count; i++)
  2233. {
  2234. var cell = row.Cells[i];
  2235. var findProperty = tableSettings.Find(x => x.Index == i);
  2236. if (findProperty != null)
  2237. {
  2238. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2239. // 设置单元格内容
  2240. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2241. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2242. }
  2243. else
  2244. {
  2245. switch (i)
  2246. {
  2247. case 5:
  2248. cell.FirstParagraph.Runs.Clear();
  2249. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2250. break;
  2251. case 6:
  2252. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2253. cell.FirstParagraph.Runs.Clear();
  2254. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2255. break;
  2256. case 8:
  2257. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2258. cell.FirstParagraph.Runs.Clear();
  2259. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2260. HSPriceSum += xiaojiRMB;
  2261. break;
  2262. default:
  2263. break;
  2264. }
  2265. }
  2266. }
  2267. startDayPrice++;
  2268. if (!dac2.Last().Equals(dac))
  2269. {
  2270. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2271. // 将克隆的行追加到原行后面
  2272. contractTable.Rows.Insert(startDayPrice, newRow);
  2273. }
  2274. else
  2275. {
  2276. cloneRow += dac2.Count + 1;
  2277. startDayPrice = cloneRow;
  2278. }
  2279. }
  2280. //3.公杂费
  2281. foreach (var dac in dac3)
  2282. {
  2283. var first = dac.First();
  2284. var dayCount = dac.Count();
  2285. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2286. for (int i = 1; i < row.Cells.Count; i++)
  2287. {
  2288. var cell = row.Cells[i];
  2289. var findProperty = tableSettings.Find(x => x.Index == i);
  2290. if (findProperty != null)
  2291. {
  2292. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2293. // 设置单元格内容
  2294. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2295. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2296. }
  2297. else
  2298. {
  2299. switch (i)
  2300. {
  2301. case 5:
  2302. cell.FirstParagraph.Runs.Clear();
  2303. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2304. break;
  2305. case 6:
  2306. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2307. cell.FirstParagraph.Runs.Clear();
  2308. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2309. break;
  2310. case 8:
  2311. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2312. cell.FirstParagraph.Runs.Clear();
  2313. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2314. GZPriceSum += xiaojiRMB;
  2315. break;
  2316. default:
  2317. break;
  2318. }
  2319. }
  2320. }
  2321. startDayPrice++;
  2322. if (!dac3.Last().Equals(dac))
  2323. {
  2324. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2325. // 将克隆的行追加到原行后面
  2326. contractTable.Rows.Insert(startDayPrice, newRow);
  2327. }
  2328. else
  2329. {
  2330. cloneRow += dac3.Count + 1;
  2331. startDayPrice = cloneRow;
  2332. }
  2333. }
  2334. //合并单元格
  2335. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2336. {
  2337. var currentRow = contractTable.Rows[i];
  2338. var nextRow = contractTable.Rows[i + 1];
  2339. // 获取当前行和下一行的第一个单元格
  2340. Cell currentCell = currentRow.Cells[0];
  2341. Cell nextCell = nextRow.Cells[0];
  2342. // 检查单元格内容是否一致(去除尾部的换行符)
  2343. string currentText = currentCell.GetText().Trim();
  2344. string nextText = nextCell.GetText().Trim();
  2345. if (currentText == nextText)
  2346. {
  2347. // 如果当前单元格已经被合并,找到合并的起始单元格
  2348. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2349. {
  2350. // 找到合并的起始单元格
  2351. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2352. // 将下一行的单元格设置为合并的后续单元格
  2353. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2354. }
  2355. else
  2356. {
  2357. // 如果当前单元格是合并的起始单元格
  2358. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2359. // 将下一行的单元格设置为合并的后续单元格
  2360. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2361. }
  2362. }
  2363. else
  2364. {
  2365. // 如果内容不一致,重置当前单元格的合并属性
  2366. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2367. {
  2368. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2369. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2370. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2371. }
  2372. else
  2373. {
  2374. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2375. }
  2376. }
  2377. }
  2378. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2379. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2380. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2381. }
  2382. foreach (var bookmarkName in bookMarkDic.Keys)
  2383. {
  2384. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2385. if (bookmark != null)
  2386. {
  2387. if (bookmarkName == "ClientUnit")
  2388. {
  2389. // 移动到书签位置
  2390. builder.MoveTo(bookmark.BookmarkStart);
  2391. // 设置字体样式为下划线
  2392. builder.Font.Underline = Aspose.Words.Underline.Single;
  2393. // 插入书签值
  2394. builder.Write(bookMarkDic[bookmarkName]);
  2395. // 清除字体格式,避免影响后续文本
  2396. builder.Font.ClearFormatting();
  2397. }
  2398. else
  2399. {
  2400. builder.MoveToBookmark(bookmarkName);
  2401. builder.Write(bookMarkDic[bookmarkName]);
  2402. }
  2403. }
  2404. }
  2405. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2406. doc.Save(savePaht);
  2407. jw.Msg = "生成成功!";
  2408. jw.Code = 200;
  2409. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2410. return Ok(jw);
  2411. }
  2412. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2413. {
  2414. int index = rowIndex;
  2415. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2416. {
  2417. index--;
  2418. }
  2419. return index;
  2420. }
  2421. #endregion
  2422. #region 团组&签证
  2423. #region 团组&签证 New
  2424. /// <summary>
  2425. /// 团组&签证 New
  2426. /// DeepSeek API:测试API连通性
  2427. /// </summary>
  2428. /// <param name="file">请求dto</param>
  2429. /// <returns></returns>
  2430. [HttpPost]
  2431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2432. public async Task<IActionResult> TestDeepSeekApiConnectivityAsync()
  2433. {
  2434. return Ok(JsonView(await _deepSeekService.TestApiConnectivityAsync()));
  2435. }
  2436. /// <summary>
  2437. /// 团组&签证 New
  2438. /// DeepSeek API:检查可用端点
  2439. /// </summary>
  2440. /// <param name="file">请求dto</param>
  2441. /// <returns></returns>
  2442. [HttpPost]
  2443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2444. public async Task<IActionResult> DiscoverAvailableEndpointsAsync()
  2445. {
  2446. return Ok(JsonView(await _deepSeekService.DiscoverAvailableEndpointsAsync()));
  2447. }
  2448. /// <summary>
  2449. /// 团组&签证 New
  2450. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2451. /// </summary>
  2452. /// <param name="file">请求dto</param>
  2453. /// <returns></returns>
  2454. [HttpPost]
  2455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2456. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile visaFile, int fileTypeId)
  2457. {
  2458. //文件验证
  2459. if (visaFile.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2460. //var visaFiles = new VisaUploadFileTypeView();
  2461. var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2462. if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2463. //服务器存储文件
  2464. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2465. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2466. var filePath = Path.Combine(fileServerPath, visaFile.FileName);
  2467. using (var stream = new FileStream(filePath, FileMode.Create))
  2468. {
  2469. await visaFile.CopyToAsync(stream);
  2470. }
  2471. //日志记录-上传文件
  2472. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, visaFile.FileName);
  2473. IFormFile localFile = null;
  2474. //获取项目中的cs文件
  2475. try
  2476. {
  2477. _logger.LogInformation("读取并上传项目文件请求");
  2478. // 1. 读取项目文件
  2479. var readResponse = await _deepSeekService.ReadProjectFilesAsync(new List<string>() { @"OASystem.Domain\ViewModels\VisaFormDetails\AusNewVisaApplicationForm.cs" });
  2480. if (readResponse.SuccessCount == 0)
  2481. {
  2482. return Ok(JsonView(false, "读取项目文件失败"));
  2483. }
  2484. localFile = readResponse.FileInfos.FirstOrDefault().FormFile;
  2485. }
  2486. catch (Exception ex)
  2487. {
  2488. _logger.LogError(ex, "读取项目文件失败");
  2489. return Ok(JsonView(false, "读取项目文件失败"));
  2490. }
  2491. if (localFile == null)
  2492. {
  2493. return Ok(JsonView(false, "读取项目文件失败"));
  2494. }
  2495. var fileReq = new DeepSeekFileUploadRequest() {
  2496. Files = new List<IFormFile> { localFile, visaFile },
  2497. };
  2498. var filesResult = new List<FileUploadResult>();
  2499. #region 上传文件到DeepSeekAPI
  2500. try
  2501. {
  2502. _logger.LogInformation("开始上传 {FileCount} 个文件到DeepSeek API", fileReq.Files.Count);
  2503. filesResult = await _deepSeekService.UploadFilesAsync(fileReq.Files, fileReq.Purpose);
  2504. // 需要等待处理完成
  2505. if (fileReq.WaitForProcessing)
  2506. {
  2507. foreach (var result in filesResult)
  2508. {
  2509. if (result.Success)
  2510. {
  2511. try
  2512. {
  2513. var processedFile = await _deepSeekService.WaitForFileProcessingAsync(result.FileId);
  2514. result.Status = processedFile.Status;
  2515. }
  2516. catch (Exception ex)
  2517. {
  2518. _logger.LogError(ex, "DeepSeek API文件上传失败");
  2519. return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2520. }
  2521. }
  2522. }
  2523. }
  2524. }
  2525. catch (Exception ex)
  2526. {
  2527. _logger.LogError(ex, "DeepSeek API文件上传失败");
  2528. return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2529. }
  2530. #endregion
  2531. if (filesResult == null || filesResult.Count < 1)
  2532. {
  2533. return Ok(JsonView(false, $"DeepSeek API文件上传处理失败"));
  2534. }
  2535. //
  2536. try
  2537. {
  2538. var fileIds = filesResult.Where(x => x.Success).Select(x => x.FileId).ToList();
  2539. _logger.LogInformation("使用 {FileCount} 个文件进行聊天", fileIds.Count);
  2540. string question = string.Format("将上传的文件内容按照识别为JSON格式,并按照 AusNewVisaApplicationForm 指定的实体类结构进行映射。确保字段和值对应、文档中数据的完整性、复选框选择打勾后的文本。第一项从不识别\"比如美国(2024年7月29日)\"相关文字。");
  2541. var response = await _deepSeekService.ChatWithFilesAsync(fileIds,question);
  2542. return Ok(response);
  2543. }
  2544. catch (Exception ex)
  2545. {
  2546. _logger.LogError(ex, "使用文件聊天失败");
  2547. return Ok(JsonView(false, $"聊天失败: {ex.Message}"));
  2548. }
  2549. //加载文件OpCarTouristGuideGroundContent
  2550. ////kimi AI 识别文档返回json结果
  2551. //int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2552. //var KiMiApi = new KiMiApiClient();
  2553. //var files = new List<IFormFile>() { file };
  2554. //var seedConter = await KiMiApi.UploadFilesAsync(files);
  2555. //if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2556. //var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2557. //var messages = new List<SeedMessages>
  2558. //{
  2559. // new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2560. // new() { Role = KimiRole.user, Content = seedMessage }
  2561. //};
  2562. //messages.InsertRange(1, seedConter);
  2563. string jsonString = string.Empty;
  2564. //bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2565. //while (!isJson)
  2566. //{
  2567. // kimiAI_API_Index++;
  2568. // var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2569. // var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2570. // jsonString += kimiApiResult_JObject["content"].ToString();
  2571. // string startStr = "```json", endStr = "```";
  2572. // // 判断并清除开头部分
  2573. // if (jsonString.StartsWith(startStr))
  2574. // {
  2575. // jsonString = jsonString.Replace(startStr, "");
  2576. // }
  2577. // // 判断并清除结尾部分
  2578. // if (jsonString.EndsWith(endStr))
  2579. // {
  2580. // jsonString = jsonString.Replace(endStr, "");
  2581. // }
  2582. // //验证json格式是否正确
  2583. // try
  2584. // {
  2585. // JsonDocument.Parse(jsonString);
  2586. // isJson = true; // 如果解析成功,则是json格式
  2587. // }
  2588. // catch (Exception)
  2589. // {
  2590. // //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2591. // messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2592. // }
  2593. //}
  2594. //var clientInfo = new Crm_DeleClient(); //客户资料表
  2595. //var clientFamily = new Crm_VisaCustomerFamily(); //客户家庭表
  2596. //var clientCompany = new Crm_CustomerCompany(); //客户公司表
  2597. //var clientCert = new Crm_CustomerCert(); //客户证件表
  2598. //var clientSchool = new Crm_VisaCustomerSchool(); //客户学历表
  2599. ////按照表格类型分别进行参数处理
  2600. //switch (fileTypeId)
  2601. //{
  2602. // //澳新签证个人申请表
  2603. // case 1:
  2604. // _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2605. // VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2606. // break;
  2607. // default:
  2608. // break;
  2609. //}
  2610. return Ok(JsonView(true, jsonString));
  2611. }
  2612. private int GetSuccessCount(List<FileUploadResult> results)
  2613. {
  2614. var count = 0;
  2615. foreach (var result in results)
  2616. {
  2617. if (result.Success) count++;
  2618. }
  2619. return count;
  2620. }
  2621. #endregion
  2622. /// <summary>
  2623. /// 根据团组Id获取签证客户信息List
  2624. /// </summary>
  2625. /// <param name="dto">请求dto</param>
  2626. /// <returns></returns>
  2627. [HttpPost]
  2628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2629. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2630. {
  2631. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2632. if (groupData.Code != 0)
  2633. {
  2634. return Ok(JsonView(false, groupData.Msg));
  2635. }
  2636. return Ok(JsonView(groupData.Data));
  2637. }
  2638. /// <summary>
  2639. /// IOS获取团组签证拍照上传进度01(团组列表)
  2640. /// </summary>
  2641. /// <param name="dto">请求dto</param>
  2642. /// <returns></returns>
  2643. [HttpPost]
  2644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2645. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2646. {
  2647. if (dto == null)
  2648. {
  2649. return Ok(JsonView(false, "参数为空"));
  2650. }
  2651. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2652. return Ok(JsonView(visaList));
  2653. }
  2654. /// <summary>
  2655. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2656. /// </summary>
  2657. /// <returns></returns>
  2658. [HttpPost]
  2659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2660. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2661. {
  2662. if (dto == null)
  2663. {
  2664. return Ok(JsonView(false, "请求错误:"));
  2665. }
  2666. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2667. return Ok(JsonView(list));
  2668. }
  2669. /// <summary>
  2670. /// IOS获取团组签证拍照上传进度03(相册)
  2671. /// </summary>
  2672. /// <returns></returns>
  2673. [HttpPost]
  2674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2675. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2676. {
  2677. if (dto == null)
  2678. {
  2679. return Ok(JsonView(false, "请求错误:"));
  2680. }
  2681. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2682. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2683. list.ForEach(s => s.url = url);
  2684. return Ok(JsonView(list));
  2685. }
  2686. /// <summary>
  2687. /// IOS获取团组签证拍照上传进度04(图片上传)
  2688. /// </summary>
  2689. /// <param name="dto"></param>
  2690. /// <returns></returns>
  2691. [HttpPost]
  2692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2693. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2694. {
  2695. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2696. //if (!string.IsNullOrEmpty(result))
  2697. //{
  2698. //}
  2699. //else {
  2700. // return Ok(JsonView(false, "上传失败"));
  2701. //}
  2702. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2703. int sucNum = 0;
  2704. try
  2705. {
  2706. foreach (var item in dto.base64DataList)
  2707. {
  2708. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2709. string result = DecodeBase64ToImage(item, imageName);
  2710. if (!string.IsNullOrEmpty(result))
  2711. {
  2712. var pic = new Grp_VisaProgressCustomerPicture
  2713. {
  2714. CreateUserId = dto.CreateUserId,
  2715. PicName = imageName,
  2716. PicPath = result,
  2717. VisaProgressCustomerId = dto.visaProgressCustomerId
  2718. };
  2719. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2720. if (insertResult > 0)
  2721. {
  2722. sucNum++;
  2723. }
  2724. }
  2725. }
  2726. }
  2727. catch (Exception ex)
  2728. {
  2729. return Ok(JsonView(false, ex.Message));
  2730. }
  2731. string msg = string.Format(@"成功上传{0}张", sucNum);
  2732. return Ok(JsonView(true, msg));
  2733. }
  2734. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2735. {
  2736. string filename = "";//声明一个string类型的相对路径
  2737. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2738. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2739. try//会有异常抛出,try,catch一下
  2740. {
  2741. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2742. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2743. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2744. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2745. //文件名称
  2746. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2747. //上传的文件的路径
  2748. string filePath = "";
  2749. if (!Directory.Exists(fileDir))
  2750. {
  2751. Directory.CreateDirectory(fileDir);
  2752. }
  2753. //上传的文件的路径
  2754. filePath = fileDir + filename;
  2755. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2756. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2757. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2758. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2759. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2760. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2761. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2762. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2763. bitmap.Dispose();
  2764. }
  2765. catch (Exception e)
  2766. {
  2767. string massage = e.Message;
  2768. Logs("IOS图片上传Error:" + massage);
  2769. //filename = e.Message;
  2770. }
  2771. return filename;//返回相对路径
  2772. }
  2773. /// <summary>
  2774. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2775. /// </summary>
  2776. /// <param name="dto"></param>
  2777. /// <returns></returns>
  2778. [HttpPost]
  2779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2780. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2781. {
  2782. if (dto == null)
  2783. {
  2784. return Ok(JsonView(false, "请求错误:"));
  2785. }
  2786. string msg = "参数错误";
  2787. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2788. {
  2789. try
  2790. {
  2791. //_delegationVisaRep.BeginTran();
  2792. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2793. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2794. .Where(s => s.Id == dto.visaProgressCustomerId)
  2795. .ExecuteCommandAsync();
  2796. if (updCount > 0 && dto.publishCode == 1)
  2797. {
  2798. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2799. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2800. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2801. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2802. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2803. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2804. if (groupData == null)
  2805. {
  2806. _delegationVisaRep.RollbackTran();
  2807. }
  2808. string title = string.Format(@"[签证进度更新]");
  2809. string content = string.Format(@"测试文本");
  2810. bool rst = await _message.AddMsg(new MessageDto()
  2811. {
  2812. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2813. IssuerId = dto.publisher,
  2814. Title = title,
  2815. Content = content,
  2816. ReleaseTime = DateTime.Now,
  2817. UIdList = new List<int> {
  2818. 234
  2819. }
  2820. });
  2821. if (rst)
  2822. {
  2823. return Ok(JsonView(true, "发送通知成功"));
  2824. }
  2825. }
  2826. //_delegationVisaRep.CommitTran();
  2827. }
  2828. catch (Exception)
  2829. {
  2830. //_delegationVisaRep.RollbackTran();
  2831. }
  2832. }
  2833. return Ok(JsonView(true, msg));
  2834. }
  2835. #endregion
  2836. #region 团组任务分配
  2837. /// <summary>
  2838. /// 团组任务分配初始化
  2839. /// </summary>
  2840. /// <returns></returns>
  2841. [HttpPost]
  2842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2843. public async Task<IActionResult> GetTaskAssignmen()
  2844. {
  2845. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2846. if (groupData.Code != 0)
  2847. {
  2848. return Ok(JsonView(false, groupData.Msg));
  2849. }
  2850. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2851. }
  2852. /// <summary>
  2853. /// 团组任务分配查询
  2854. /// </summary>
  2855. /// <param name="dto"></param>
  2856. /// <returns></returns>
  2857. [HttpPost]
  2858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2859. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2860. {
  2861. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2862. if (groupData.Code != 0)
  2863. {
  2864. return Ok(JsonView(false, groupData.Msg));
  2865. }
  2866. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2867. }
  2868. /// <summary>
  2869. /// 团组任务分配操作
  2870. /// </summary>
  2871. /// <param name="dto"></param>
  2872. /// <returns></returns>
  2873. [HttpPost]
  2874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2875. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2876. {
  2877. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2878. if (groupData.Code != 0)
  2879. {
  2880. return Ok(JsonView(false, groupData.Msg));
  2881. }
  2882. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2883. }
  2884. /// <summary>
  2885. /// 团组任务分配
  2886. /// 批量分配
  2887. /// 查询团组
  2888. /// </summary>
  2889. /// <param name="dto"></param>
  2890. /// <returns></returns>
  2891. [HttpPost]
  2892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2893. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2894. {
  2895. //参数验证
  2896. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2897. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2898. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2899. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2900. }
  2901. /// <summary>
  2902. /// 团组任务分配
  2903. /// 批量分配
  2904. /// </summary>
  2905. /// <param name="dto"></param>
  2906. /// <returns></returns>
  2907. [HttpPost]
  2908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2909. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2910. {
  2911. //参数验证
  2912. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2913. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2914. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2915. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2916. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2917. }
  2918. #endregion
  2919. #region 团组费用审核
  2920. /// <summary>
  2921. /// 费用审核
  2922. /// 团组列表 Page
  2923. /// </summary>
  2924. /// <param name="_dto">团组列表请求dto</param>
  2925. /// <returns></returns>
  2926. [HttpPost]
  2927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2928. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2929. {
  2930. #region 参数验证
  2931. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2932. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2933. #region 页面操作权限验证
  2934. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2935. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2936. #endregion
  2937. #endregion
  2938. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2939. {
  2940. string sqlWhere = string.Empty;
  2941. if (_dto.IsSure == 0) //未完成
  2942. {
  2943. sqlWhere += string.Format(@" And IsSure = 0");
  2944. }
  2945. else if (_dto.IsSure == 1) //已完成
  2946. {
  2947. sqlWhere += string.Format(@" And IsSure = 1");
  2948. }
  2949. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2950. {
  2951. string tj = _dto.SearchCriteria;
  2952. 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}%')",
  2953. tj, tj, tj, tj, tj);
  2954. }
  2955. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2956. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2957. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2958. From (
  2959. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2960. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2961. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2962. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2963. From Grp_DelegationInfo gdi
  2964. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2965. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2966. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2967. Where gdi.IsDel = 0 {0}
  2968. ) temp ", sqlWhere);
  2969. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2970. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2971. var _view = new
  2972. {
  2973. PageFuncAuth = pageFunAuthView,
  2974. Data = _DelegationList
  2975. };
  2976. return Ok(JsonView(true, "查询成功!", _view, total));
  2977. }
  2978. else
  2979. {
  2980. return Ok(JsonView(false, "查询失败"));
  2981. }
  2982. }
  2983. /// <summary>
  2984. /// 获取团组费用审核
  2985. /// </summary>
  2986. /// <param name="_dto"></param>
  2987. /// <returns></returns>
  2988. [HttpPost]
  2989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2990. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2991. {
  2992. try
  2993. {
  2994. #region 参数验证
  2995. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2996. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2997. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2998. #region 页面操作权限验证
  2999. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3000. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3001. #endregion
  3002. #endregion
  3003. var _view = new Grp_CreditCardPaymentView();
  3004. var clientNameList = GetSimplClientList(_dto.DiId);
  3005. #region 费用清单
  3006. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  3007. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  3008. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  3009. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  3010. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  3011. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  3012. /*
  3013. * 76://酒店预订
  3014. */
  3015. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3016. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3017. /*
  3018. * 79://车/导游地接
  3019. */
  3020. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3021. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3022. /*
  3023. * 80: //签证
  3024. */
  3025. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3026. /*
  3027. *81: //邀请/公务活动
  3028. */
  3029. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3030. /*
  3031. * 82: //团组客户保险
  3032. */
  3033. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3034. /*
  3035. * Lable = 85 机票预订
  3036. */
  3037. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3038. /*
  3039. * 85 机票预定
  3040. */
  3041. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3042. /*
  3043. * 98 其他款项
  3044. */
  3045. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3046. /*
  3047. * 285:收款退还
  3048. */
  3049. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3050. /*
  3051. * 1015: //超支费用
  3052. */
  3053. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3054. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  3055. /*
  3056. * 币种信息
  3057. */
  3058. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  3059. /*
  3060. * 车/导游地接 费用类型
  3061. */
  3062. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  3063. /*
  3064. * 车/导游地接 费用类型
  3065. */
  3066. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  3067. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  3068. /*
  3069. * 用户信息
  3070. */
  3071. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  3072. /*
  3073. * 费用模块
  3074. */
  3075. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  3076. string priceModule = string.Empty;
  3077. if (sdPriceName != null)
  3078. {
  3079. priceModule = sdPriceName.Name;
  3080. }
  3081. /*
  3082. * 成本信息
  3083. */
  3084. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  3085. decimal _groupRate = 0.0000M;
  3086. string _groupCurrencyCode = "-";
  3087. if (groupCost != null)
  3088. {
  3089. _groupRate = groupCost.Rate;
  3090. if (int.TryParse(groupCost.Currency, out int _currency))
  3091. {
  3092. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  3093. }
  3094. else _groupCurrencyCode = groupCost.Currency;
  3095. }
  3096. string costContentSql = $"Select * From Grp_GroupCost";
  3097. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  3098. //处理日期为空的天数
  3099. for (int i = 0; i < groupCostDetails.Count; i++)
  3100. if (i != 0)
  3101. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  3102. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  3103. /*
  3104. * 处理详情数据
  3105. */
  3106. foreach (var entity in entityList)
  3107. {
  3108. var _detail = new Grp_CreditCardPaymentDetailView
  3109. {
  3110. Id = entity.Id,
  3111. PriceName = priceModule,
  3112. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  3113. };
  3114. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3115. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  3116. //处理金额
  3117. if (entity.CTable == 1015)
  3118. {
  3119. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  3120. if (czInfo != null)
  3121. {
  3122. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  3123. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  3124. }
  3125. }
  3126. /*
  3127. * 应付款金额
  3128. */
  3129. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  3130. string PaymentCurrency_WaitPay = "Unknown";
  3131. string hotelCurrncyCode = "Unknown";
  3132. string hotelCurrncyName = "Unknown";
  3133. if (sdPaymentCurrency_WaitPay != null)
  3134. {
  3135. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  3136. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  3137. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  3138. if (hotelCurrncyCode.Equals("CNY"))
  3139. {
  3140. entity.DayRate = 1.0000M;
  3141. }
  3142. }
  3143. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3144. /*
  3145. * 此次付款金额
  3146. */
  3147. decimal CurrPayStr = 0.00M,
  3148. OriginalCurrPay = 0.00M;
  3149. if (entity.PayPercentage == 0)
  3150. {
  3151. if (entity.PayThenMoney != 0)
  3152. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  3153. }
  3154. else
  3155. {
  3156. if (entity.PayMoney != 0)
  3157. {
  3158. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  3159. }
  3160. }
  3161. //if (_dto.Label == 79)
  3162. //{
  3163. // string original = string.Empty;
  3164. // if (hotelCurrncyCode.Equals("CNY"))
  3165. // {
  3166. // OriginalCurrPay = CurrPayStr;
  3167. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3168. // }
  3169. // else
  3170. // {
  3171. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3172. // //760 EUR(7600.00 CNY)
  3173. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  3174. // }
  3175. //}
  3176. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3177. string original = string.Empty;
  3178. if (hotelCurrncyCode.Equals("CNY"))
  3179. {
  3180. OriginalCurrPay = CurrPayStr;
  3181. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3182. }
  3183. else
  3184. {
  3185. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3186. //760 EUR(7600.00 CNY)
  3187. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  3188. }
  3189. /*
  3190. * 剩余尾款
  3191. */
  3192. decimal BalanceStr = 0;
  3193. if (CurrPayStr != 0)
  3194. {
  3195. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3196. BalanceStr = 0;
  3197. else
  3198. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3199. }
  3200. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3201. /*
  3202. * Bus名称
  3203. */
  3204. _detail.BusName = "待增加";
  3205. /*
  3206. *费用所属
  3207. */
  3208. switch (entity.CTable)
  3209. {
  3210. case 76://酒店预订
  3211. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3212. if (hotelReservations != null)
  3213. {
  3214. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3215. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3216. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3217. string roomFeeStr = "", roomFeestr1 = "";
  3218. //是否比较房型价格
  3219. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3220. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3221. roomFeeStr += $"<br/>";
  3222. var roomTotal = 0.00M;
  3223. if (hotelReservations.SingleRoomPrice > 0)
  3224. {
  3225. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3226. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3227. //__isSingle = true;
  3228. roomTotal += fee;
  3229. }
  3230. if (hotelReservations.DoubleRoomPrice > 0)
  3231. {
  3232. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3233. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3234. // __isDouble = true;
  3235. roomTotal += fee;
  3236. }
  3237. if (hotelReservations.SuiteRoomPrice > 0)
  3238. {
  3239. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3240. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3241. //__isSuite = true;
  3242. roomTotal += fee;
  3243. }
  3244. if (hotelReservations.OtherRoomPrice > 0)
  3245. {
  3246. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3247. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3248. //__isOther = true;
  3249. roomTotal += fee;
  3250. }
  3251. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3252. else roomFeeStr += " 0.00 * 0";
  3253. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3254. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3255. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3256. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3257. /*
  3258. * 费用类型
  3259. * 1:房费
  3260. * 2:早餐
  3261. * 3:地税
  3262. * 4:城市税
  3263. * </summary>
  3264. */
  3265. //地税
  3266. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3267. if (governmentRentData != null)
  3268. {
  3269. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3270. governmentRentFee = governmentRentData.Price;
  3271. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3272. if (governmentRentCurrData != null)
  3273. {
  3274. governmentRentCode = governmentRentCurrData.Name;
  3275. governmentRentName = $"({governmentRentCurrData.Remark})";
  3276. }
  3277. }
  3278. //城市税
  3279. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3280. if (cityTaxData != null)
  3281. {
  3282. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3283. cityTaxFee = cityTaxData.Price;
  3284. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3285. if (cityTaxCurrData != null)
  3286. {
  3287. cityTaxCode = cityTaxCurrData.Name;
  3288. cityTaxName = $"({cityTaxCurrData.Remark})";
  3289. }
  3290. }
  3291. //酒店早餐
  3292. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3293. if (breakfastData != null)
  3294. {
  3295. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3296. breakfastFee = breakfastData.Price;
  3297. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3298. if (breakfastCurrData != null)
  3299. {
  3300. breakfastCode = breakfastCurrData.Name;
  3301. breakfastName = $"({breakfastCurrData.Remark})";
  3302. }
  3303. }
  3304. //房间费用
  3305. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3306. if (roomData != null)
  3307. {
  3308. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3309. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3310. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3311. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3312. roomFee = roomData.Price;
  3313. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3314. if (roomCurrData != null)
  3315. {
  3316. roomCode = roomCurrData.Name;
  3317. roomName = $"({roomCurrData.Remark})";
  3318. }
  3319. }
  3320. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3321. string hotelCostStr = "";
  3322. decimal hotelCsotTotal = 0.00M;
  3323. if (groupCost != null)
  3324. {
  3325. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3326. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3327. }
  3328. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3329. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3330. string hotelCost_day = "";
  3331. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3332. foreach (var item in hotelCostDetails1)
  3333. {
  3334. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3335. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3336. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3337. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3338. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3339. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3340. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3341. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3342. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3343. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3344. hotelCost_day += @$"<br/>";
  3345. }
  3346. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3347. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3348. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3349. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3350. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3351. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3352. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3353. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3354. $"房间说明: {hotelReservations.Remark} <br/>" +
  3355. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3356. $"{hotelBreakfastStr}" +
  3357. $"{hotelGovernmentRentStr}" +
  3358. $"{hotelCityTaxStr}";
  3359. _detail.PriceNameContent = hotelReservations.HotelName;
  3360. }
  3361. break;
  3362. case 79://车/导游地接
  3363. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3364. if (touristGuideGroundReservations != null)
  3365. {
  3366. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3367. {
  3368. _detail.BusName = touristGuideGroundReservations.BusName;
  3369. }
  3370. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3371. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3372. //if (isInt)
  3373. //{
  3374. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3375. // if (cityInfo != null)
  3376. // {
  3377. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3378. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3379. // if (carFeeItem != null)
  3380. // {
  3381. // nameContent += $@"({carFeeItem.Name})";
  3382. // }
  3383. // _detail.PriceNameContent = nameContent;
  3384. // }
  3385. //}
  3386. //else
  3387. //{
  3388. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3389. //}
  3390. var touristGuideGroundReservationsContents =
  3391. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3392. var opContent_sb = new StringBuilder();
  3393. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3394. opContent_sb.AppendLine(contetTitle);
  3395. foreach (var item in touristGuideGroundReservationsContents)
  3396. {
  3397. string typeName = "Unknown";
  3398. string carCurrencyCode = "Unknown";
  3399. string carCurrencyName = "Unknown";
  3400. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3401. if (carTypeData != null) typeName = carTypeData.Name;
  3402. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3403. if (currencyData != null)
  3404. {
  3405. carCurrencyCode = currencyData.Name;
  3406. carCurrencyName = currencyData.Remark;
  3407. }
  3408. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3409. bool IsCurrencyAgreement = false;
  3410. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3411. string opCostStr = string.Empty;
  3412. decimal opCostTypePrice = 0.00M;
  3413. #region 处理成本各项费用
  3414. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3415. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3416. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3417. costOPFeeCNY = 0.00M, //团组成本 op费用
  3418. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3419. if (opCost.Count > 0)
  3420. {
  3421. switch (item.SId)
  3422. {
  3423. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3424. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3425. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3426. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3427. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3428. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3429. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3430. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3431. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3432. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3433. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3434. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3435. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3436. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3437. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3438. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3439. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3440. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3441. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3442. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3443. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3444. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3445. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3446. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3447. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3448. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3449. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3450. }
  3451. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3452. costOPFeeCNY = opCostTypePrice * _groupRate;
  3453. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3454. }
  3455. #endregion
  3456. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3457. aduitOPFeeCNY = item.Price * entity.DayRate;
  3458. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3459. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3460. $"{opTypeStr} {opCostStr}<br/>" +
  3461. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3462. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3463. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3464. {
  3465. if (IsCurrencyAgreement)
  3466. {
  3467. if (item.Price > opCostTypePrice)
  3468. {
  3469. opContent_sb.Append("<span style='color:red;'>");
  3470. opContent_sb.Append(opContent);
  3471. opContent_sb.Append("</span>");
  3472. opContent_sb.AppendLine();
  3473. }
  3474. else
  3475. {
  3476. opContent_sb.Append(opContent);
  3477. opContent_sb.AppendLine();
  3478. }
  3479. }
  3480. else
  3481. {
  3482. //验证是否超成本 按付款比例计算
  3483. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3484. {
  3485. opContent_sb.Append("<span style='color:red;'>");
  3486. opContent_sb.Append(opContent);
  3487. opContent_sb.Append("</span>");
  3488. opContent_sb.AppendLine();
  3489. }
  3490. else
  3491. {
  3492. opContent_sb.Append(opContent);
  3493. opContent_sb.AppendLine();
  3494. }
  3495. }
  3496. }
  3497. else
  3498. {
  3499. opContent_sb.Append(opContent);
  3500. opContent_sb.AppendLine();
  3501. }
  3502. }
  3503. _detail.PriceMsgContent = opContent_sb.ToString();
  3504. }
  3505. break;
  3506. case 80: //签证
  3507. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3508. if (visaInfo != null)
  3509. {
  3510. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  3511. _detail.PriceNameContent = visaInfo.VisaDescription;
  3512. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3513. }
  3514. break;
  3515. case 81: //邀请/公务活动
  3516. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3517. if (_ioa != null)
  3518. {
  3519. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3520. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3521. sendCurrName = "Unknown", //快递费用币种 Name
  3522. sendCurrCode = "Unknown", //快递费用币种 Code
  3523. eventsCurrName = "Unknown", //公务活动费币种 Name
  3524. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3525. translateCurrName = "Unknown", //公务翻译费 Name
  3526. translateCurrCode = "Unknown"; //公务翻译费 Code
  3527. #region 处理费用币种
  3528. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3529. if (inviteCurrData != null)
  3530. {
  3531. inviteCurrName = inviteCurrData.Remark;
  3532. inviteCurrCode = inviteCurrData.Name;
  3533. }
  3534. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3535. if (sendCurrData != null)
  3536. {
  3537. sendCurrName = sendCurrData.Remark;
  3538. sendCurrCode = sendCurrData.Name;
  3539. }
  3540. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3541. if (eventsCurrData != null)
  3542. {
  3543. eventsCurrName = eventsCurrData.Remark;
  3544. eventsCurrCode = eventsCurrData.Name;
  3545. }
  3546. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3547. if (translateCurrData != null)
  3548. {
  3549. translateCurrName = translateCurrData.Remark;
  3550. translateCurrCode = translateCurrData.Name;
  3551. }
  3552. #endregion
  3553. _detail.PriceNameContent = _ioa.InviterArea;
  3554. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  3555. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  3556. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  3557. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  3558. $@"备注:" + _ioa.Remark + "<br/>";
  3559. }
  3560. break;
  3561. case 82: //团组客户保险
  3562. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3563. if (customers != null)
  3564. {
  3565. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  3566. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3567. }
  3568. break;
  3569. case 85: //机票预订
  3570. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3571. if (jpRes != null)
  3572. {
  3573. string FlightsDescription = jpRes.FlightsDescription;
  3574. string PriceDescription = jpRes.PriceDescription;
  3575. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3576. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3577. }
  3578. break;
  3579. case 98://其他款项
  3580. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3581. if (gdpRes != null)
  3582. {
  3583. //var urlBase = $"http://132.232.92.186:24/Office/GrpFile/http://132.232.92.186:24/Office/GrpFile/%E5%9B%A2%E7%BB%84%E5%A2%9E%E5%87%8F%E6%AC%BE%E9%A1%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6/";
  3584. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  3585. //{
  3586. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  3587. //}
  3588. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3589. _detail.PriceNameContent = gdpRes.PriceName;
  3590. }
  3591. break;
  3592. case 285://收款退还
  3593. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3594. if (refundAndOtherMoney != null)
  3595. {
  3596. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3597. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3598. }
  3599. break;
  3600. case 751://酒店早餐
  3601. break;
  3602. case 1015://超支费用
  3603. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3604. if (groupExtraCost != null)
  3605. {
  3606. _detail.PriceNameContent = groupExtraCost.PriceName;
  3607. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3608. }
  3609. break;
  3610. default:
  3611. break;
  3612. }
  3613. /*
  3614. * 申请人
  3615. */
  3616. string operatorName = " - ";
  3617. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3618. if (_opUser != null)
  3619. {
  3620. operatorName = _opUser.CnName;
  3621. }
  3622. _detail.OperatorName = operatorName;
  3623. /*
  3624. * 审核人
  3625. */
  3626. string auditOperatorName = " - ";
  3627. if (entity.IsAuditGM != 0)
  3628. {
  3629. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3630. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3631. else
  3632. {
  3633. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3634. if (_adUser != null)
  3635. {
  3636. auditOperatorName = _adUser.CnName;
  3637. }
  3638. }
  3639. }
  3640. _detail.AuditOperatorName = auditOperatorName;
  3641. /*
  3642. * 超预算比例
  3643. */
  3644. string overBudgetStr = "";
  3645. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3646. else if (entity.ExceedBudget == 0)
  3647. {
  3648. if (entity.CTable == 76 || entity.CTable == 79)
  3649. {
  3650. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3651. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3652. }
  3653. else
  3654. {
  3655. overBudgetStr = "未超预算";
  3656. }
  3657. }
  3658. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3659. _detail.OverBudget = overBudgetStr;
  3660. decimal auditFee = 0.00M; //已审核金额 人名币
  3661. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3662. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3663. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3664. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3665. {
  3666. auditedFeeOriginal = entity.PayMoney;
  3667. auditFee = CurrPayStr;
  3668. }
  3669. else if (entity.IsAuditGM == 0)
  3670. {
  3671. unAuditFeeCNY = CurrPayStr;
  3672. unAuditFeeOriginal = OriginalCurrPay;
  3673. OriginalCurrPay = 0.00M;
  3674. }
  3675. /*
  3676. * 费用总计
  3677. */
  3678. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3679. {
  3680. CurrencyId = entity.PaymentCurrency,
  3681. CurrencyName = PaymentCurrency_WaitPay,
  3682. AmountPayable = entity.PayMoney,
  3683. ThisPayment = OriginalCurrPay,
  3684. BalancePayment = BalanceStr,
  3685. AuditedFunds = auditFee,
  3686. AuditedFundsOriginal = auditedFeeOriginal,
  3687. UnAuditFundsCNY = unAuditFeeCNY,
  3688. UnAuditFundsOriginal = unAuditFeeOriginal
  3689. });
  3690. _detail.IsAuditGM = entity.IsAuditGM;
  3691. detailList.Add(_detail);
  3692. }
  3693. #endregion
  3694. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3695. /*
  3696. * 下方描述处理
  3697. */
  3698. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3699. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3700. if (ccpCurrencyPrice != null)
  3701. {
  3702. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3703. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3704. }
  3705. else
  3706. {
  3707. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3708. }
  3709. string amountPayableStr = string.Format(@"应付款总金额: ");
  3710. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3711. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3712. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3713. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3714. foreach (var item in nonDuplicat)
  3715. {
  3716. var currencyName = item.CurrencyName;
  3717. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3718. if (strs.Count > 0)
  3719. {
  3720. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3721. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3722. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3723. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3724. //单独处理此次付款金额
  3725. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3726. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3727. //单独处理已审核费用
  3728. //if (item.CurrencyId == 836) //人民币
  3729. //{
  3730. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3731. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3732. //}
  3733. //else
  3734. //{
  3735. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3736. //}
  3737. if (currencyName.Equals("CNY"))
  3738. {
  3739. //已审核费用
  3740. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3741. //未审核费用
  3742. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3743. }
  3744. else
  3745. {
  3746. //已审核费用
  3747. 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"));
  3748. //未审核费用
  3749. 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"));
  3750. }
  3751. }
  3752. }
  3753. _view.TotalStr1 = amountPayableStr[..^1];
  3754. _view.TotalStr2 = thisPaymentStr[..^1];
  3755. _view.TotalStr3 = balancePaymentStr[..^1];
  3756. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3757. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3758. var _view1 = new
  3759. {
  3760. PageFuncAuth = pageFunAuthView,
  3761. Data = _view
  3762. };
  3763. return Ok(JsonView(_view1));
  3764. }
  3765. catch (Exception ex)
  3766. {
  3767. return Ok(JsonView(false, ex.Message));
  3768. }
  3769. }
  3770. /// <summary>
  3771. /// 费用审核
  3772. /// 修改团组费用审核状态
  3773. /// </summary>
  3774. /// <param name="_dto">参数Json字符串</param>
  3775. /// <returns></returns>
  3776. [HttpPost]
  3777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3778. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3779. {
  3780. #region 参数验证
  3781. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3782. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3783. #endregion
  3784. #region 页面操作权限验证
  3785. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3786. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3787. #endregion
  3788. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3789. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3790. DateTime dtNow = DateTime.Now;
  3791. _groupRepository.BeginTran();
  3792. int rst = 0;
  3793. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3794. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3795. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3796. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3797. var msgDatas = new List<dynamic>();
  3798. var dic_ccp_user = new Dictionary<int, int>() { };
  3799. foreach (var item in idList)
  3800. {
  3801. int CreditId = int.Parse(item);
  3802. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3803. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3804. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3805. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3806. .Where(s => s.Id == CreditId)
  3807. .ExecuteCommandAsync();
  3808. if (result < 1)
  3809. {
  3810. rst = -1;
  3811. _groupRepository.RollbackTran();
  3812. return Ok(JsonView(false, "操作失败并回滚!"));
  3813. }
  3814. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3815. if (creditData != null)
  3816. {
  3817. #region 应用通知配置
  3818. try
  3819. {
  3820. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3821. }
  3822. catch (Exception ex)
  3823. {
  3824. }
  3825. #endregion
  3826. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3827. string groupNameStr = string.Empty;
  3828. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3829. if (groupData != null) groupNameStr = groupData.TeamName;
  3830. string creditTypeStr = string.Empty;
  3831. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3832. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3833. string creditCurrency = string.Empty;
  3834. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3835. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3836. if (creditCurrency.Equals("CNY"))
  3837. {
  3838. creditData.DayRate = 1.0000M;
  3839. }
  3840. if (creditData.PayPercentage == 0.00M)
  3841. {
  3842. creditData.PayPercentage = 100M;
  3843. }
  3844. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3845. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3846. string msgContent = "";
  3847. if (creditCurrency.Equals("CNY"))
  3848. {
  3849. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  3850. }
  3851. else
  3852. {
  3853. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  3854. }
  3855. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3856. }
  3857. }
  3858. if (rst == 0)
  3859. {
  3860. _groupRepository.CommitTran();
  3861. foreach (var item in msgDatas)
  3862. {
  3863. //发送消息
  3864. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3865. }
  3866. #region 应用推送
  3867. try
  3868. {
  3869. foreach (var ccpId in dic_ccp_user.Keys)
  3870. {
  3871. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3872. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3873. }
  3874. }
  3875. catch (Exception)
  3876. {
  3877. }
  3878. #endregion
  3879. return Ok(JsonView(true, "操作成功!"));
  3880. }
  3881. return Ok(JsonView(false, "操作失败!"));
  3882. }
  3883. /// <summary>
  3884. /// 费用审核
  3885. /// 其他款项 文件下载
  3886. /// </summary>
  3887. /// <param name="id">其他款项 主键编号</param>
  3888. /// <returns></returns>
  3889. [HttpGet("{id}")]
  3890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3891. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1, int.MaxValue, ErrorMessage = "请传入有效的ID")] int id)
  3892. {
  3893. //网站域名
  3894. const string baseUrl = "http://132.232.92.186:24/Office/GrpFile/%E5%9B%A2%E7%BB%84%E5%A2%9E%E5%87%8F%E6%AC%BE%E9%A1%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6/";
  3895. var otherInfo = await _decreasePaymentsRep._sqlSugar
  3896. .Queryable<Grp_DecreasePayments>()
  3897. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  3898. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  3899. .Select((x, y) => new
  3900. {
  3901. x.Id,
  3902. x.FilePath
  3903. })
  3904. .FirstAsync();
  3905. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  3906. {
  3907. var url = $"{baseUrl}{otherInfo.FilePath}";
  3908. return Ok(JsonView(true, "操作成功!", url));
  3909. }
  3910. return Ok(JsonView(false, "暂无附件"));
  3911. }
  3912. #endregion
  3913. #region 机票费用录入
  3914. /// <summary>
  3915. /// 机票录入当前登录人可操作团组
  3916. /// </summary>
  3917. /// <param name="dto"></param>
  3918. /// <returns></returns>
  3919. [HttpPost]
  3920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3921. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3922. {
  3923. try
  3924. {
  3925. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3926. if (groupData.Code != 0)
  3927. {
  3928. return Ok(JsonView(false, groupData.Msg));
  3929. }
  3930. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3931. }
  3932. catch (Exception ex)
  3933. {
  3934. return Ok(JsonView(false, ex.Message));
  3935. }
  3936. }
  3937. /// <summary>
  3938. /// 机票费用录入列表
  3939. /// </summary>
  3940. /// <param name="dto"></param>
  3941. /// <returns></returns>
  3942. [HttpPost]
  3943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3944. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3945. {
  3946. try
  3947. {
  3948. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3949. if (groupData.Code != 0)
  3950. {
  3951. return Ok(JsonView(false, groupData.Msg));
  3952. }
  3953. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3954. }
  3955. catch (Exception ex)
  3956. {
  3957. return Ok(JsonView(false, ex.Message));
  3958. throw;
  3959. }
  3960. }
  3961. /// <summary>
  3962. /// 根据id查询费用录入信息
  3963. /// </summary>
  3964. /// <param name="dto"></param>
  3965. /// <returns></returns>
  3966. [HttpPost]
  3967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3968. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3969. {
  3970. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3971. if (groupData.Code != 0)
  3972. {
  3973. return Ok(JsonView(false, groupData.Msg));
  3974. }
  3975. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3976. }
  3977. /// <summary>
  3978. /// 机票费用录入操作(Status:1.新增,2.修改)
  3979. /// </summary>
  3980. /// <param name="dto"></param>
  3981. /// <returns></returns>
  3982. [HttpPost]
  3983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3984. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3985. {
  3986. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3987. if (groupData.Code != 0)
  3988. {
  3989. return Ok(JsonView(false, groupData.Msg));
  3990. }
  3991. #region 应用推送
  3992. try
  3993. {
  3994. var diId = dto.AirTicketResOpData.DiId;
  3995. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3996. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3997. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3998. //自动审核
  3999. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  4000. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  4001. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  4002. $"GroupId:{diId};airId:{dataId};",
  4003. status,
  4004. auditMsg);
  4005. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4006. //2024-10-21 新增LZ UID
  4007. var userIds = new List<int>() { 21 };
  4008. string title = $"系统通知";
  4009. string content = "";
  4010. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4011. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4012. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4013. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4014. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4015. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  4016. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4017. }
  4018. catch (Exception ex)
  4019. {
  4020. }
  4021. #endregion
  4022. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4023. }
  4024. /// <summary>
  4025. /// 机票费用自动审核 AI识别方式
  4026. /// </summary>
  4027. /// <returns></returns>
  4028. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  4029. {
  4030. var ecoTypeIds = new List<int>() {
  4031. 459, //超经舱
  4032. 460, //经济舱
  4033. 1430, //公务舱(实际经济舱)
  4034. 1432, //头等舱(实际经济舱)
  4035. };
  4036. var bizTypeIds = new List<int>() {
  4037. 457, //头等舱
  4038. 458, //公务舱
  4039. 1431, //头等舱(实际公务舱)
  4040. };
  4041. var auditFeeTypeIds = new List<int>() { };
  4042. auditFeeTypeIds.AddRange(ecoTypeIds);
  4043. auditFeeTypeIds.AddRange(bizTypeIds);
  4044. int currModule = 85;
  4045. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  4046. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  4047. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  4048. .Select((x, y) => new
  4049. {
  4050. x.Id,
  4051. CcpId = y.Id,
  4052. x.FlightsDate,
  4053. x.PrePrice,
  4054. x.CType,
  4055. x.ClientNum,
  4056. x.DIId
  4057. })
  4058. .FirstAsync();
  4059. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  4060. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  4061. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  4062. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  4063. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  4064. var groupCostContents = await _sqlSugar
  4065. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  4066. .Where(x => x.IsDel == 0 && x.Diid == diId)
  4067. .ToListAsync();
  4068. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  4069. //处理 成本详细信息日期为空 填装费用信息
  4070. var airFeeLabel = new StringBuilder();
  4071. airFeeLabel.AppendLine("费用成本:");
  4072. for (int i = 0; i < groupCostContents.Count; i++)
  4073. {
  4074. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  4075. {
  4076. int index = i - 1;
  4077. if (index >= 0)
  4078. {
  4079. groupCostContents[i].Date = groupCostContents[index].Date;
  4080. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4081. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4082. }
  4083. }
  4084. else
  4085. {
  4086. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4087. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4088. }
  4089. var item = groupCostContents[i];
  4090. airFeeLabel.AppendLine($"{item.Date}");
  4091. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  4092. }
  4093. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  4094. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  4095. //访问Kimi AI 返回价格结果
  4096. var msgs = new List<SeedMessages>()
  4097. {
  4098. new ()
  4099. {
  4100. Role = KimiRole.user,
  4101. Content = airFeeLabel.ToString()
  4102. }
  4103. };
  4104. var client = new KiMiApiClient();
  4105. var kimiApiResult = await client.SeedMessage(msgs);
  4106. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  4107. string clients = kimiApiResult_JObject["content"].ToString();
  4108. decimal ecoPri_kimiAI = 0.00M,
  4109. bizPri_kimiAI = 0.00M;
  4110. //单个价格: 经济舱价格
  4111. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  4112. //价格文本包含/:/前经济舱价格 /后公务舱价格
  4113. if (clients.Contains('/'))
  4114. {
  4115. var priArray = clients.Split('/');
  4116. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  4117. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  4118. }
  4119. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  4120. var isAutoAudit = false;
  4121. //价格验证处理
  4122. //经济舱
  4123. if (ecoTypeIds.Contains(airInfo.CType))
  4124. {
  4125. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  4126. }
  4127. //公务舱
  4128. else if (bizTypeIds.Contains(airInfo.CType))
  4129. {
  4130. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  4131. }
  4132. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  4133. //是否执行自动审核
  4134. if (isAutoAudit)
  4135. {
  4136. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4137. .SetColumns(x => x.IsAuditGM == 3)
  4138. .SetColumns(x => x.AuditGMOperate == 4)
  4139. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  4140. .Where(x => x.Id == airInfo.CcpId)
  4141. .ExecuteCommandAsync();
  4142. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  4143. }
  4144. return (false, "当前费用超过成本费用,不可自动审核!");
  4145. }
  4146. /// <summary>
  4147. /// 机票费用录入
  4148. /// 自动审核测试 - AI 识别
  4149. /// </summary>
  4150. /// <param name="groupId"></param>
  4151. /// <param name="Id"></param>
  4152. /// <returns></returns>
  4153. [HttpPost]
  4154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4155. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  4156. {
  4157. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4158. return Ok(JsonView(status, msg));
  4159. }
  4160. /// <summary>
  4161. /// 根据舱位类型查询接团客户名单信息
  4162. /// </summary>
  4163. /// <param name="dto"></param>
  4164. /// <returns></returns>
  4165. [HttpPost]
  4166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4167. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4168. {
  4169. try
  4170. {
  4171. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4172. if (crm_Groups.Count != 0)
  4173. {
  4174. var Customer = new List<dynamic>();
  4175. foreach (var item in crm_Groups)
  4176. {
  4177. var data = new
  4178. {
  4179. item.Id,
  4180. item.Pinyin,
  4181. Name = item.LastName + item.FirstName
  4182. };
  4183. Customer.Add(data);
  4184. }
  4185. return Ok(JsonView(true, "查询成功!", Customer));
  4186. }
  4187. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4188. }
  4189. catch (Exception ex)
  4190. {
  4191. return Ok(JsonView(false, "程序错误!"));
  4192. throw;
  4193. }
  4194. }
  4195. /// <summary>
  4196. /// 根据团号获取客户信息
  4197. /// </summary>
  4198. /// <param name="dto"></param>
  4199. /// <returns></returns>
  4200. [HttpPost]
  4201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4202. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  4203. {
  4204. var jw = JsonView(false);
  4205. if (dto.DIID < 1)
  4206. {
  4207. jw.Msg += "请输入正确的diid";
  4208. return Ok(jw);
  4209. }
  4210. var arr = GetSimplClientList(dto.DIID);
  4211. jw = JsonView(true, "获取成功!", arr);
  4212. return Ok(jw);
  4213. }
  4214. private List<SimplClientInfo> GetSimplClientList(int diId)
  4215. {
  4216. 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);
  4217. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  4218. foreach (var item in arr)
  4219. {
  4220. EncryptionProcessor.DecryptProperties(item);
  4221. }
  4222. return arr;
  4223. }
  4224. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  4225. {
  4226. string result = origin;
  4227. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4228. {
  4229. string[] temparr = origin.Split(',');
  4230. string fistrStr = temparr[0];
  4231. int count = temparr.Length;
  4232. bool success = int.TryParse(fistrStr, out int tempId);
  4233. if (success)
  4234. {
  4235. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4236. if (tempInfo != null)
  4237. {
  4238. if (count > 1)
  4239. {
  4240. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4241. }
  4242. else
  4243. {
  4244. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4245. }
  4246. }
  4247. }
  4248. }
  4249. return result;
  4250. }
  4251. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4252. {
  4253. string result = origin;
  4254. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4255. {
  4256. string[] temparr = origin.Split(',');
  4257. result = "";
  4258. foreach (var item in temparr)
  4259. {
  4260. bool success = int.TryParse(item, out int tempId);
  4261. if (success)
  4262. {
  4263. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4264. if (tempInfo != null)
  4265. {
  4266. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4267. }
  4268. }
  4269. }
  4270. }
  4271. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4272. return result;
  4273. }
  4274. /// <summary>
  4275. /// 机票费用录入,删除
  4276. /// </summary>
  4277. /// <param name="dto"></param>
  4278. /// <returns></returns>
  4279. [HttpPost]
  4280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4281. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4282. {
  4283. try
  4284. {
  4285. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4286. if (res)
  4287. {
  4288. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4289. {
  4290. IsDel = 1,
  4291. DeleteUserId = dto.DeleteUserId,
  4292. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4293. }).ExecuteCommandAsync();
  4294. return Ok(JsonView(true, "删除成功!"));
  4295. }
  4296. return Ok(JsonView(false, "删除失败!"));
  4297. }
  4298. catch (Exception ex)
  4299. {
  4300. return Ok(JsonView(false, "程序错误!"));
  4301. throw;
  4302. }
  4303. }
  4304. /// <summary>
  4305. /// 导出机票录入报表
  4306. /// </summary>
  4307. /// <param name="dto"></param>
  4308. /// <returns></returns>
  4309. [HttpPost]
  4310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4311. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4312. {
  4313. try
  4314. {
  4315. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4316. if (groupData.Code != 0)
  4317. {
  4318. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4319. }
  4320. else
  4321. {
  4322. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4323. if (AirTicketReservations.Count != 0)
  4324. {
  4325. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4326. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4327. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4328. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4329. var designer = new WorkbookDesigner
  4330. {
  4331. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  4332. };
  4333. decimal countCost = 0;
  4334. foreach (var item in AirTicketReservations)
  4335. {
  4336. #region 处理客人姓名
  4337. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  4338. item.ClientName = clientNames;
  4339. #endregion
  4340. if (item.BankType == "其他")
  4341. {
  4342. item.BankNo = "--";
  4343. }
  4344. else
  4345. {
  4346. if (!string.IsNullOrEmpty(item.BankType))
  4347. {
  4348. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  4349. }
  4350. }
  4351. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4352. item.Price = System.Decimal.Round(item.Price, 2);
  4353. countCost += Convert.ToDecimal(item.Price);
  4354. }
  4355. designer.SetDataSource("Export", AirTicketReservations);
  4356. designer.SetDataSource("ExportDiCode", diCode);
  4357. designer.SetDataSource("ExportDiName", diName);
  4358. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4359. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4360. designer.Process();
  4361. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4362. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4363. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4364. return Ok(JsonView(true, "成功", url = rst));
  4365. }
  4366. else
  4367. {
  4368. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4369. }
  4370. }
  4371. }
  4372. catch (Exception ex)
  4373. {
  4374. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4375. throw;
  4376. }
  4377. }
  4378. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  4379. /// <summary>
  4380. /// 行程单导出
  4381. /// </summary>
  4382. /// <param name="dto"></param>
  4383. /// <returns></returns>
  4384. [HttpPost]
  4385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4386. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4387. {
  4388. try
  4389. {
  4390. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4391. if (groupData.Code != 0)
  4392. {
  4393. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4394. }
  4395. else
  4396. {
  4397. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4398. if (dto.Language == "CN")
  4399. {
  4400. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4401. var builder = new DocumentBuilder(doc);
  4402. int tableIndex = 0;//表格索引
  4403. //得到文档中的第一个表格
  4404. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4405. foreach (var item in _AirTicketReservations)
  4406. {
  4407. #region 处理固定数据
  4408. string[] FlightsCode = item.FlightsCode.Split('/');
  4409. if (FlightsCode.Length != 0)
  4410. {
  4411. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4412. if (_AirCompany != null)
  4413. {
  4414. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4415. }
  4416. else
  4417. {
  4418. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4419. }
  4420. }
  4421. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4422. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4423. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4424. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4425. string name = "";
  4426. foreach (string clientName in nameArray)
  4427. {
  4428. if (!name.Contains(clientName))
  4429. {
  4430. name += clientName + ",";
  4431. }
  4432. }
  4433. if (!string.IsNullOrWhiteSpace(name))
  4434. {
  4435. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4436. }
  4437. else
  4438. {
  4439. table.Range.Bookmarks["ClientName"].Text = "--";
  4440. }
  4441. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4442. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4443. table.Range.Bookmarks["JointTicket"].Text = "--";
  4444. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4445. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4446. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4447. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4448. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4449. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4450. #endregion
  4451. #region 循环数据处理
  4452. var airs = new List<AirInfo>();
  4453. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4454. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4455. for (int i = 0; i < FlightsCode.Length; i++)
  4456. {
  4457. var air = new AirInfo();
  4458. string[] tempstr = DayArray[i]
  4459. .Replace("\r\n", string.Empty)
  4460. .Replace("\\r\\n", string.Empty)
  4461. .TrimStart().TrimEnd()
  4462. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4463. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4464. string starCity = "";
  4465. if (star_Three != null)
  4466. {
  4467. starCity = star_Three.AirPort;
  4468. }
  4469. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4470. string EndCity = "";
  4471. if (End_Three != null)
  4472. {
  4473. EndCity = End_Three.AirPort;
  4474. }
  4475. air.Destination = starCity + "/" + EndCity;
  4476. air.Flight = FlightsCode[i];
  4477. air.SeatingClass = item.CTypeName;
  4478. string dateTime = tempstr[2];
  4479. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4480. air.FlightDate = DateTemp;
  4481. air.DepartureTime = tempstr[5];
  4482. air.LandingTime = tempstr[6];
  4483. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4484. air.TicketStatus = "--";
  4485. air.Luggage = "--";
  4486. air.DepartureTerminal = "--";
  4487. air.LandingTerminal = "--";
  4488. airs.Add(air);
  4489. }
  4490. int row = 13;
  4491. for (int i = 0; i < airs.Count; i++)
  4492. {
  4493. if (airs.Count > 2)
  4494. {
  4495. for (int j = 0; j < airs.Count - 2; j++)
  4496. {
  4497. var CopyRow = table.Rows[12].Clone(true);
  4498. table.Rows.Add(CopyRow);
  4499. }
  4500. }
  4501. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4502. int index = 0;
  4503. foreach (PropertyInfo property in properties)
  4504. {
  4505. string value = property.GetValue(airs[i]).ToString();
  4506. Cell ishcel0 = table.Rows[row].Cells[index];
  4507. var p = new Paragraph(doc);
  4508. string s = value;
  4509. p.AppendChild(new Run(doc, s));
  4510. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4511. ishcel0.AppendChild(p);
  4512. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4513. index++;
  4514. }
  4515. row++;
  4516. }
  4517. #endregion
  4518. var lastParagraph = new Paragraph(doc);
  4519. //第一个表格末尾加段落
  4520. table.ParentNode.InsertAfter(lastParagraph, table);
  4521. //复制第一个表格
  4522. Table cloneTable = (Table)table.Clone(true);
  4523. //在文档末尾段落后面加入复制的表格
  4524. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4525. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4526. {
  4527. int rownewsIndex = 13;
  4528. for (int i = 0; i < 2; i++)
  4529. {
  4530. var CopyRow = table.Rows[12].Clone(true);
  4531. table.Rows.RemoveAt(13);
  4532. table.Rows.Add(CopyRow);
  4533. rownewsIndex++;
  4534. }
  4535. }
  4536. else
  4537. {
  4538. table.Rows.RemoveAt(12);
  4539. }
  4540. cloneTable.Rows.RemoveAt(12);
  4541. }
  4542. if (_AirTicketReservations.Count != 0)
  4543. {
  4544. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4545. if (FlightsCode.Length != 0)
  4546. {
  4547. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4548. if (_AirCompany != null)
  4549. {
  4550. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4551. }
  4552. else
  4553. {
  4554. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4555. }
  4556. }
  4557. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4558. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4559. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4560. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4561. string name = "";
  4562. foreach (string clientName in nameArray)
  4563. {
  4564. if (!name.Contains(clientName))
  4565. {
  4566. name += clientName + ",";
  4567. }
  4568. }
  4569. if (!string.IsNullOrWhiteSpace(name))
  4570. {
  4571. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4572. }
  4573. else
  4574. {
  4575. table.Range.Bookmarks["ClientName"].Text = "--";
  4576. }
  4577. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4578. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4579. table.Range.Bookmarks["JointTicket"].Text = "--";
  4580. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4581. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4582. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4583. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4584. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4585. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4586. }
  4587. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4588. //保存合并后的文档
  4589. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4590. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4591. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4592. return Ok(JsonView(true, "成功!", rst));
  4593. }
  4594. else
  4595. {
  4596. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4597. var builder = new DocumentBuilder(doc);
  4598. int tableIndex = 0;//表格索引
  4599. //得到文档中的第一个表格
  4600. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4601. var texts = new List<string>();
  4602. foreach (var item in _AirTicketReservations)
  4603. {
  4604. string[] FlightsCode = item.FlightsCode.Split('/');
  4605. if (FlightsCode.Length != 0)
  4606. {
  4607. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4608. if (_AirCompany != null)
  4609. {
  4610. if (!transDic.ContainsKey(_AirCompany.CnName))
  4611. {
  4612. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4613. }
  4614. }
  4615. else
  4616. {
  4617. if (!transDic.ContainsKey("--"))
  4618. {
  4619. transDic.Add("--", "--");
  4620. }
  4621. }
  4622. }
  4623. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4624. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4625. string name = "";
  4626. foreach (string clientName in nameArray)
  4627. {
  4628. name += clientName + ",";
  4629. }
  4630. if (!texts.Contains(name))
  4631. {
  4632. texts.Add(name);
  4633. }
  4634. var airs = new List<AirInfo>();
  4635. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4636. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4637. for (int i = 0; i < FlightsCode.Length; i++)
  4638. {
  4639. var air = new AirInfo();
  4640. string[] tempstr = DayArray[i]
  4641. .Replace("\r\n", string.Empty)
  4642. .Replace("\\r\\n", string.Empty)
  4643. .TrimStart().TrimEnd()
  4644. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4645. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4646. if (star_Three != null)
  4647. {
  4648. if (!transDic.ContainsKey(star_Three.AirPort))
  4649. {
  4650. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4651. }
  4652. }
  4653. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4654. if (End_Three != null)
  4655. {
  4656. if (!transDic.ContainsKey(End_Three.AirPort))
  4657. {
  4658. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4659. }
  4660. }
  4661. if (!texts.Contains(item.CTypeName))
  4662. {
  4663. texts.Add(item.CTypeName);
  4664. }
  4665. }
  4666. }
  4667. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4668. if (transData.Count > 0)
  4669. {
  4670. foreach (TranslateResult item in transData)
  4671. {
  4672. if (!transDic.ContainsKey(item.Query))
  4673. {
  4674. transDic.Add(item.Query, item.Translation);
  4675. }
  4676. }
  4677. }
  4678. foreach (var item in _AirTicketReservations)
  4679. {
  4680. #region 处理固定数据
  4681. string[] FlightsCode = item.FlightsCode.Split('/');
  4682. if (FlightsCode.Length != 0)
  4683. {
  4684. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4685. if (_AirCompany != null)
  4686. {
  4687. string str = "--";
  4688. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4689. if (!string.IsNullOrEmpty(translateResult))
  4690. {
  4691. str = translateResult;
  4692. str = _airTicketResRep.Processing(str);
  4693. }
  4694. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4695. }
  4696. else
  4697. {
  4698. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4699. }
  4700. }
  4701. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4702. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4703. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4704. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4705. string names = "";
  4706. foreach (string clientName in nameArray)
  4707. {
  4708. names += clientName + ",";
  4709. }
  4710. if (!string.IsNullOrWhiteSpace(names))
  4711. {
  4712. string str = "--";
  4713. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4714. if (!string.IsNullOrEmpty(translateResult))
  4715. {
  4716. str = translateResult;
  4717. str = _airTicketResRep.Processing(str);
  4718. }
  4719. table.Range.Bookmarks["ClientName"].Text = str;
  4720. }
  4721. else
  4722. {
  4723. table.Range.Bookmarks["ClientName"].Text = "--";
  4724. }
  4725. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4726. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4727. table.Range.Bookmarks["JointTicket"].Text = "--";
  4728. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4729. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4730. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4731. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4732. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4733. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4734. #endregion
  4735. #region 循环数据处理
  4736. var airs = new List<AirInfo>();
  4737. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4738. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4739. for (int i = 0; i < FlightsCode.Length; i++)
  4740. {
  4741. var air = new AirInfo();
  4742. string[] tempstr = DayArray[i]
  4743. .Replace("\r\n", string.Empty)
  4744. .Replace("\\r\\n", string.Empty)
  4745. .TrimStart().TrimEnd()
  4746. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4747. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4748. string starCity = "";
  4749. if (star_Three != null)
  4750. {
  4751. string str2 = "--";
  4752. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4753. if (!string.IsNullOrEmpty(translateResult2))
  4754. {
  4755. str2 = translateResult2;
  4756. str2 = _airTicketResRep.Processing(str2);
  4757. }
  4758. starCity = str2;
  4759. }
  4760. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4761. string EndCity = "";
  4762. if (End_Three != null)
  4763. {
  4764. string str1 = "--";
  4765. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4766. if (!string.IsNullOrEmpty(translateResult1))
  4767. {
  4768. str1 = translateResult1;
  4769. str1 = _airTicketResRep.Processing(str1);
  4770. }
  4771. EndCity = str1;
  4772. }
  4773. air.Destination = starCity + "/" + EndCity;
  4774. air.Flight = FlightsCode[i];
  4775. string str = "--";
  4776. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4777. if (!string.IsNullOrEmpty(translateResult))
  4778. {
  4779. str = translateResult;
  4780. str = _airTicketResRep.Processing(str);
  4781. }
  4782. air.SeatingClass = str;
  4783. string dateTime = tempstr[2];
  4784. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4785. air.FlightDate = DateTemp;
  4786. air.DepartureTime = tempstr[5];
  4787. air.LandingTime = tempstr[6];
  4788. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4789. air.TicketStatus = "--";
  4790. air.Luggage = "--";
  4791. air.DepartureTerminal = "--";
  4792. air.LandingTerminal = "--";
  4793. airs.Add(air);
  4794. }
  4795. int row = 13;
  4796. for (int i = 0; i < airs.Count; i++)
  4797. {
  4798. if (airs.Count > 2)
  4799. {
  4800. for (int j = 0; j < airs.Count - 2; j++)
  4801. {
  4802. var CopyRow = table.Rows[12].Clone(true);
  4803. table.Rows.Add(CopyRow);
  4804. }
  4805. }
  4806. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4807. int index = 0;
  4808. foreach (PropertyInfo property in properties)
  4809. {
  4810. string value = property.GetValue(airs[i]).ToString();
  4811. Cell ishcel0 = table.Rows[row].Cells[index];
  4812. var p = new Paragraph(doc);
  4813. string s = value;
  4814. p.AppendChild(new Run(doc, s));
  4815. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4816. ishcel0.AppendChild(p);
  4817. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4818. //ishcel0.CellFormat.VerticalAlignment=
  4819. index++;
  4820. }
  4821. row++;
  4822. }
  4823. #endregion
  4824. var lastParagraph = new Paragraph(doc);
  4825. //第一个表格末尾加段落
  4826. table.ParentNode.InsertAfter(lastParagraph, table);
  4827. //复制第一个表格
  4828. Table cloneTable = (Table)table.Clone(true);
  4829. //在文档末尾段落后面加入复制的表格
  4830. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4831. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4832. {
  4833. int rownewsIndex = 13;
  4834. for (int i = 0; i < 2; i++)
  4835. {
  4836. var CopyRow = table.Rows[12].Clone(true);
  4837. table.Rows.RemoveAt(13);
  4838. table.Rows.Add(CopyRow);
  4839. rownewsIndex++;
  4840. }
  4841. }
  4842. else
  4843. {
  4844. table.Rows.RemoveAt(12);
  4845. }
  4846. cloneTable.Rows.RemoveAt(12);
  4847. }
  4848. if (_AirTicketReservations.Count != 0)
  4849. {
  4850. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4851. if (FlightsCode.Length != 0)
  4852. {
  4853. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4854. if (_AirCompany != null)
  4855. {
  4856. string str = "--";
  4857. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4858. if (!string.IsNullOrEmpty(translateResult))
  4859. {
  4860. str = translateResult;
  4861. str = _airTicketResRep.Processing(str);
  4862. }
  4863. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4864. }
  4865. else
  4866. {
  4867. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4868. }
  4869. }
  4870. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4871. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4872. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4873. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4874. string names = "";
  4875. foreach (string clientName in nameArray)
  4876. {
  4877. names += clientName + ",";
  4878. }
  4879. if (!string.IsNullOrWhiteSpace(names))
  4880. {
  4881. string str = "--";
  4882. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4883. if (!string.IsNullOrEmpty(translateResult))
  4884. {
  4885. str = translateResult;
  4886. str = _airTicketResRep.Processing(str);
  4887. }
  4888. table.Range.Bookmarks["ClientName"].Text = str;
  4889. }
  4890. else
  4891. {
  4892. table.Range.Bookmarks["ClientName"].Text = "--";
  4893. }
  4894. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4895. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4896. table.Range.Bookmarks["JointTicket"].Text = "--";
  4897. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4898. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4899. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4900. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4901. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4902. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4903. }
  4904. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4905. //保存合并后的文档
  4906. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4907. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4908. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4909. return Ok(JsonView(true, "成功!", rst));
  4910. }
  4911. }
  4912. }
  4913. catch (Exception ex)
  4914. {
  4915. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4916. throw;
  4917. }
  4918. }
  4919. #endregion
  4920. #region 团组增减款项 --> 其他款项
  4921. /// <summary>
  4922. /// 团组增减款项下拉框绑定
  4923. /// </summary>
  4924. /// <param name="dto"></param>
  4925. /// <returns></returns>
  4926. [HttpPost]
  4927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4928. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4929. {
  4930. #region 参数验证
  4931. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4932. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4933. #endregion
  4934. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4935. }
  4936. /// <summary>
  4937. /// 根据团组Id查询团组增减款项
  4938. /// </summary>
  4939. /// <param name="dto"></param>
  4940. /// <returns></returns>
  4941. [HttpPost]
  4942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4943. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4944. {
  4945. #region 参数验证
  4946. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4947. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4948. #endregion
  4949. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4950. }
  4951. /// <summary>
  4952. /// 团组增减款项操作(Status:1.新增,2.修改)
  4953. /// </summary>
  4954. /// <param name="dto"></param>
  4955. /// <returns></returns>
  4956. [HttpPost]
  4957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4958. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4959. {
  4960. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4961. if (groupData.Code != 200)
  4962. {
  4963. return Ok(JsonView(false, groupData.Msg));
  4964. }
  4965. #region 应用推送
  4966. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4967. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4968. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4969. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4970. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4971. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4972. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  4973. if (recheck)
  4974. {
  4975. //自动审核
  4976. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4977. }
  4978. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4979. //2024-10-21 新增LZ UID
  4980. var userIds = new List<int>() { 21 };
  4981. string title = $"系统通知";
  4982. string content = "";
  4983. var diId = dto.DiId;
  4984. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4985. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4986. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4987. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4988. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4989. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4990. #endregion
  4991. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4992. }
  4993. /// <summary>
  4994. /// 团组增减款项操作 删除
  4995. /// </summary>
  4996. /// <param name="dto"></param>
  4997. /// <returns></returns>
  4998. [HttpPost]
  4999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5000. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  5001. {
  5002. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  5003. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  5004. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  5005. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  5006. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  5007. }
  5008. /// <summary>
  5009. /// 根据团组增减款项Id查询
  5010. /// </summary>
  5011. /// <param name="dto"></param>
  5012. /// <returns></returns>
  5013. [HttpPost]
  5014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5015. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  5016. {
  5017. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  5018. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  5019. }
  5020. /// <summary>
  5021. /// 查询供应商名称
  5022. /// </summary>
  5023. /// <param name="dto"></param>
  5024. /// <returns></returns>
  5025. [HttpPost]
  5026. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  5027. {
  5028. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  5029. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  5030. ?? new List<Grp_DecreasePayments>();
  5031. dbResult = dbResult.Distinct(new
  5032. ProductComparer()).ToList();
  5033. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  5034. {
  5035. x.Id,
  5036. x.SupplierAddress,
  5037. x.SupplierArea,
  5038. x.SupplierContact,
  5039. x.SupplierContactNumber,
  5040. x.SupplierEmail,
  5041. x.SupplierName,
  5042. x.SupplierSocialAccount,
  5043. x.SupplierTypeId,
  5044. }).ToList());
  5045. return Ok(jw);
  5046. }
  5047. /// <summary>
  5048. /// 团组增减款项 OTA匹配
  5049. /// </summary>
  5050. /// <param name="file"></param>
  5051. /// <returns></returns>
  5052. [HttpPost]
  5053. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  5054. {
  5055. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  5056. string fileName = file.FileName;
  5057. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  5058. {
  5059. return Ok(JsonView(false, "请上传Excel文件!"));
  5060. }
  5061. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  5062. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  5063. if (!Directory.Exists(path))
  5064. {
  5065. Directory.CreateDirectory(path);
  5066. }
  5067. var filePath = @$"{path}/{fileName}";
  5068. //保存文件
  5069. using (FileStream fs = System.IO.File.Create(filePath))
  5070. {
  5071. file.CopyTo(fs);
  5072. fs.Flush();
  5073. }
  5074. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  5075. //读取ExcelFile
  5076. DataTable dt = ConvertExcelToDataTable(filePath);
  5077. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  5078. dt.TableName = "TB";
  5079. //修改table列名
  5080. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  5081. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  5082. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  5083. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  5084. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  5085. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  5086. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  5087. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  5088. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  5089. dt.Columns[9].ColumnName = "Quantity"; // 台数
  5090. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  5091. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  5092. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  5093. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  5094. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  5095. var otaOrderNos = new List<string>();
  5096. foreach (DataRow item in dt.Rows)
  5097. {
  5098. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  5099. }
  5100. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  5101. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  5102. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  5103. .Select((dp, di) => new
  5104. {
  5105. dp.PriceName,
  5106. dp.OTAOrderNo,
  5107. dp.FeeTotal,
  5108. di.TeamName,
  5109. })
  5110. .ToListAsync();
  5111. foreach (DataRow item in dt.Rows)
  5112. {
  5113. var otaOrderNo = item["OTAOrderNo"].ToString();
  5114. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  5115. if (oaData == null) continue;
  5116. item["GroupName"] = oaData.TeamName;
  5117. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  5118. }
  5119. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  5120. var pairs = new Dictionary<string, object>();
  5121. var datas = new List<DataTable>
  5122. {
  5123. dt
  5124. };
  5125. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  5126. return Ok(JsonView(true, "操作成功", new { url }));
  5127. }
  5128. #region
  5129. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  5130. {
  5131. // 创建Workbook对象
  5132. var workbook = new Workbook(excelFilePath);
  5133. // 获取第一个工作表
  5134. var worksheet = workbook.Worksheets[0];
  5135. // 将工作表转换为DataTable
  5136. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  5137. return dataTable;
  5138. }
  5139. #endregion
  5140. /// <summary>
  5141. /// 世运会数据
  5142. /// </summary>
  5143. /// <returns></returns>
  5144. [HttpGet]
  5145. public IActionResult WorldGamesData()
  5146. {
  5147. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  5148. var groupMenu = setData.GroupBy(x => x.T0);
  5149. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  5150. foreach (var item in groupMenu)
  5151. {
  5152. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  5153. {
  5154. Data = new SetDataView
  5155. {
  5156. Name = item.Key
  5157. },
  5158. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  5159. });
  5160. }
  5161. return Ok(JsonView(true, "success", resultArr));
  5162. }
  5163. #endregion
  5164. #region 文件上传、删除
  5165. /// <summary>
  5166. /// region 文件上传 可以带参数
  5167. /// </summary>
  5168. /// <param name="file"></param>
  5169. /// <returns></returns>
  5170. [HttpPost]
  5171. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5172. public async Task<IActionResult> UploadProject(IFormFile file)
  5173. {
  5174. //var TypeName = Request.Headers["TypeName"].ToString();
  5175. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5176. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5177. ////文件名称
  5178. //string projectFileName = file.FileName;
  5179. ////上传的文件的路径
  5180. //string filePath = $"{fileDir}/{projectFileName}";
  5181. //if (TypeName == "A")//A代表团组增减款项
  5182. //{
  5183. // filePath = fileDir + $@"\团组增减款项相关文件";
  5184. // if (!Directory.Exists(filePath))
  5185. // {
  5186. // Directory.CreateDirectory(filePath);
  5187. // }
  5188. // //上传的文件的路径
  5189. // filePath += $@"\{projectFileName}";
  5190. //}
  5191. //else if (TypeName == "B")//B代表商邀相关文件
  5192. //{
  5193. // //上传的文件的路径
  5194. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5195. // if (!Directory.Exists(filePath))
  5196. // {
  5197. // Directory.CreateDirectory(filePath);
  5198. // }
  5199. // //上传的文件的路径
  5200. // filePath = $@"\{projectFileName}";
  5201. //}
  5202. //try
  5203. //{
  5204. // using (FileStream fs = System.IO.File.Create(filePath))
  5205. // {
  5206. // file.CopyTo(fs);
  5207. // fs.Flush();
  5208. // }
  5209. //}
  5210. //catch (Exception ex)
  5211. //{
  5212. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  5213. //}
  5214. //return Ok(JsonView(true, "上传成功!", projectFileName));
  5215. try
  5216. {
  5217. var TypeName = Request.Headers["TypeName"].ToString();
  5218. if (file != null)
  5219. {
  5220. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5221. //文件名称
  5222. string projectFileName = file.FileName;
  5223. //上传的文件的路径
  5224. string filePath = $"{fileDir}/{projectFileName}";
  5225. if (TypeName == "A")//A代表团组增减款项
  5226. {
  5227. if (!Directory.Exists(fileDir))
  5228. {
  5229. Directory.CreateDirectory(fileDir);
  5230. }
  5231. //上传的文件的路径
  5232. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5233. }
  5234. else if (TypeName == "B")//B代表商邀相关文件
  5235. {
  5236. if (!Directory.Exists(fileDir))
  5237. {
  5238. Directory.CreateDirectory(fileDir);
  5239. }
  5240. //上传的文件的路径
  5241. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5242. }
  5243. using (FileStream fs = System.IO.File.Create(filePath))
  5244. {
  5245. file.CopyTo(fs);
  5246. fs.Flush();
  5247. }
  5248. return Ok(JsonView(true, "上传成功!", projectFileName));
  5249. }
  5250. else
  5251. {
  5252. return Ok(JsonView(false, "上传失败!"));
  5253. }
  5254. }
  5255. catch (Exception ex)
  5256. {
  5257. return Ok(JsonView(false, ex.Message));
  5258. }
  5259. }
  5260. /// <summary>
  5261. /// 删除指定文件
  5262. /// </summary>
  5263. /// <param name="dto"></param>
  5264. /// <returns></returns>
  5265. [HttpPost]
  5266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5267. public async Task<IActionResult> DelFile(DelFileDto dto)
  5268. {
  5269. try
  5270. {
  5271. var TypeName = Request.Headers["TypeName"].ToString();
  5272. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5273. string filePath = "";
  5274. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5275. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5276. int id = 0;
  5277. if (TypeName == "A")
  5278. {
  5279. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5280. // 删除该文件
  5281. System.IO.File.Delete(filePath);
  5282. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5283. .Where(a => a.Id == dto.Id)
  5284. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5285. .ExecuteCommandAsync();
  5286. }
  5287. else if (TypeName == "B")
  5288. {
  5289. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5290. // 删除该文件
  5291. System.IO.File.Delete(filePath);
  5292. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5293. if (info != null)
  5294. {
  5295. string[] files = Array.Empty<string>();
  5296. if (!string.IsNullOrEmpty(info.Attachment))
  5297. {
  5298. try
  5299. {
  5300. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5301. }
  5302. catch (Exception)
  5303. {
  5304. files = new List<string>() { info.Attachment }.ToArray();
  5305. }
  5306. }
  5307. if (files.Length > 0)
  5308. {
  5309. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5310. string filePath2 = string.Empty;
  5311. if (files1.Length > 0)
  5312. {
  5313. filePath2 = JsonConvert.SerializeObject(files1);
  5314. }
  5315. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5316. .Where(a => a.Id == dto.Id)
  5317. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5318. .ExecuteCommandAsync();
  5319. }
  5320. }
  5321. }
  5322. if (id != 0)
  5323. {
  5324. return Ok(JsonView(true, "成功!"));
  5325. }
  5326. else
  5327. {
  5328. return Ok(JsonView(false, "失败!"));
  5329. }
  5330. }
  5331. catch (Exception ex)
  5332. {
  5333. return Ok(JsonView(false, "程序错误!"));
  5334. throw;
  5335. }
  5336. }
  5337. /// <summary>
  5338. /// 文件上传多个文件 可以带参数
  5339. /// </summary>
  5340. /// <param name="files"></param>
  5341. /// <returns></returns>
  5342. [HttpPost]
  5343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5344. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5345. {
  5346. try
  5347. {
  5348. var TypeName = Request.Headers["TypeName"].ToString();
  5349. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5350. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5351. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5352. var filePahts = new List<string>();
  5353. foreach (var file in files)
  5354. {
  5355. //文件名称
  5356. string projectFileName = file.FileName;
  5357. //上传的文件的路径
  5358. string filePath = $"{fileDir}/{projectFileName}";
  5359. if (TypeName == "A")//A代表团组增减款项
  5360. {
  5361. if (!Directory.Exists(fileDir))
  5362. {
  5363. Directory.CreateDirectory(fileDir);
  5364. }
  5365. //上传的文件的路径
  5366. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5367. }
  5368. else if (TypeName == "B")//B代表商邀相关文件
  5369. {
  5370. if (!Directory.Exists(fileDir))
  5371. {
  5372. Directory.CreateDirectory(fileDir);
  5373. }
  5374. //上传的文件的路径
  5375. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5376. }
  5377. using (FileStream fs = System.IO.File.Create(filePath))
  5378. {
  5379. file.CopyTo(fs);
  5380. fs.Flush();
  5381. }
  5382. filePahts.Add(projectFileName);
  5383. }
  5384. return Ok(JsonView(true, "上传成功!", filePahts));
  5385. }
  5386. catch (Exception ex)
  5387. {
  5388. return Ok(JsonView(false, ex.Message));
  5389. }
  5390. }
  5391. #endregion
  5392. #region 商邀费用录入
  5393. /// <summary>
  5394. /// 根据团组Id查询商邀费用列表
  5395. /// </summary>
  5396. /// <param name="dto"></param>
  5397. /// <returns></returns>
  5398. [HttpPost]
  5399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5400. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5401. {
  5402. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5403. if (groupData.Code != 0)
  5404. {
  5405. return Ok(JsonView(false, groupData.Msg));
  5406. }
  5407. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5408. }
  5409. /// <summary>
  5410. /// 商邀费用列表
  5411. /// 下载文件
  5412. /// </summary>
  5413. /// <param name="id"></param>
  5414. /// <returns></returns>
  5415. [HttpGet("{id}")]
  5416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5417. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5418. {
  5419. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5420. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5421. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5422. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5423. var filePaths = new List<string>();
  5424. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5425. try
  5426. {
  5427. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5428. }
  5429. catch (Exception ex)
  5430. {
  5431. filePaths.Add(info.Attachment);
  5432. }
  5433. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5434. for (int i = 0; i < filePaths.Count; i++)
  5435. {
  5436. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5437. }
  5438. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5439. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5440. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5441. {
  5442. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5443. {
  5444. foreach (string filePath in filePaths)
  5445. {
  5446. if (System.IO.File.Exists(filePath))
  5447. {
  5448. // 获取文件名
  5449. string fileName = Path.GetFileName(filePath);
  5450. // 将文件添加到ZIP归档中
  5451. zipArchive.CreateEntryFromFile(filePath, fileName);
  5452. }
  5453. }
  5454. }
  5455. }
  5456. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5457. }
  5458. /// <summary>
  5459. /// 商邀费用 Info Page 基础数据源
  5460. /// </summary>
  5461. /// <returns></returns>
  5462. [HttpPost]
  5463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5464. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5465. {
  5466. try
  5467. {
  5468. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  5469. if (groupData.Code != 0)
  5470. {
  5471. return Ok(JsonView(false, groupData.Msg));
  5472. }
  5473. return Ok(JsonView(true, "操作成功", groupData.Data));
  5474. }
  5475. catch (Exception ex)
  5476. {
  5477. return Ok(JsonView(false, ex.Message));
  5478. throw;
  5479. }
  5480. }
  5481. /// <summary>
  5482. /// 根据商邀费用ID查询C表和商邀费用数据
  5483. /// </summary>
  5484. /// <param name="dto"></param>
  5485. /// <returns></returns>
  5486. [HttpPost]
  5487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5488. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5489. {
  5490. try
  5491. {
  5492. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5493. if (groupData.Code != 0)
  5494. {
  5495. return Ok(JsonView(false, groupData.Msg));
  5496. }
  5497. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5498. }
  5499. catch (Exception ex)
  5500. {
  5501. return Ok(JsonView(false, ex.Message));
  5502. throw;
  5503. }
  5504. }
  5505. /// <summary>
  5506. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5507. /// </summary>
  5508. /// <param name="dto"></param>
  5509. /// <returns></returns>
  5510. [HttpPost]
  5511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5512. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5513. {
  5514. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5515. if (groupData.Code != 0)
  5516. {
  5517. return Ok(JsonView(false, groupData.Msg));
  5518. }
  5519. #region 应用推送
  5520. try
  5521. {
  5522. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5523. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5524. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5525. //2024-10-21 新增LZ UID
  5526. var userIds = new List<int>() { 21 };
  5527. string title = $"系统通知";
  5528. string content = "";
  5529. var diId = dto.DiId;
  5530. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5531. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5532. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5533. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5534. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5535. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5536. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5537. }
  5538. catch (Exception ex)
  5539. {
  5540. }
  5541. #endregion
  5542. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5543. }
  5544. /// <summary>
  5545. /// 商邀删除
  5546. /// </summary>
  5547. /// <param name="dto"></param>
  5548. /// <returns></returns>
  5549. [HttpPost]
  5550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5551. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5552. {
  5553. try
  5554. {
  5555. _sqlSugar.BeginTran();
  5556. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5557. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5558. {
  5559. IsDel = 1,
  5560. DeleteUserId = dto.DeleteUserId,
  5561. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5562. })
  5563. .Where(it => it.Id == dto.Id)
  5564. .ExecuteCommand();
  5565. if (res1 > 0)
  5566. {
  5567. int _diId = 0;
  5568. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5569. if (_ioaInfo != null)
  5570. {
  5571. _diId = _ioaInfo.DiId;
  5572. }
  5573. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5574. .SetColumns(a => new Grp_CreditCardPayment()
  5575. {
  5576. IsDel = 1,
  5577. DeleteUserId = dto.DeleteUserId,
  5578. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5579. })
  5580. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5581. .ExecuteCommand();
  5582. if (res2 > 0)
  5583. {
  5584. _sqlSugar.CommitTran();
  5585. return Ok(JsonView(true, "删除成功!"));
  5586. }
  5587. }
  5588. _sqlSugar.RollbackTran();
  5589. return Ok(JsonView(false, "删除失败"));
  5590. }
  5591. catch (Exception ex)
  5592. {
  5593. _sqlSugar.RollbackTran();
  5594. return Ok(JsonView(false, ex.Message));
  5595. }
  5596. }
  5597. #endregion
  5598. #region 票据上传
  5599. /// <summary>
  5600. /// 团组模块文件上传
  5601. /// </summary>
  5602. /// <param name="dto"></param>
  5603. /// <returns></returns>
  5604. [HttpPost]
  5605. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5606. {
  5607. var jw = JsonView(false);
  5608. long M = 1024 * 1024;
  5609. if (dto.Files == null || dto.Files.Count == 0)
  5610. {
  5611. jw.Msg = "无文件信息!";
  5612. return Ok(jw);
  5613. }
  5614. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5615. {
  5616. jw.Msg = "文件大小超过20M!";
  5617. return Ok(jw);
  5618. }
  5619. //var nameSp = dto.File.FileName.Split(".");
  5620. //if (nameSp.Length < 2)
  5621. //{
  5622. // jw.Msg = "拓展名称有误!";
  5623. // return Ok(jw);
  5624. //}
  5625. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5626. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5627. //{
  5628. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5629. // return Ok(jw);
  5630. //}
  5631. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5632. if (Ctable == null)
  5633. {
  5634. jw.Msg = "Ctable指向有误!";
  5635. return Ok(jw);
  5636. }
  5637. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5638. if (groupInfo == null)
  5639. {
  5640. jw.Msg = "团组信息不存在!";
  5641. return Ok(jw);
  5642. }
  5643. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5644. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5645. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5646. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5647. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5648. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5649. try
  5650. {
  5651. if (!Directory.Exists(fileBase))
  5652. {
  5653. Directory.CreateDirectory(fileBase);
  5654. }
  5655. var saveArr = new List<Grp_GroupModelFile>();
  5656. foreach (var fileStream in dto.Files)
  5657. {
  5658. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5659. var file = new Grp_GroupModelFile()
  5660. {
  5661. Cid = dto.Cid,
  5662. CreateTime = DateTime.Now,
  5663. CreateUserId = dto.Userid,
  5664. Ctable = dto.Ctable,
  5665. Diid = dto.Diid,
  5666. IsDel = 0,
  5667. FilePath = saveFilePath,
  5668. FileName = fileStream.FileName
  5669. };
  5670. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5671. {
  5672. fileStream.CopyTo(fs);
  5673. fs.Flush();
  5674. }
  5675. saveArr.Add(file);
  5676. }
  5677. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5678. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5679. jw = JsonView(true, "保存成功!", new
  5680. {
  5681. count = addResult,
  5682. filesName = saveArr.Select(x => x.FileName)
  5683. });
  5684. }
  5685. catch (Exception ex)
  5686. {
  5687. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5688. {
  5689. count = 0,
  5690. filesName = Array.Empty<string>(),
  5691. });
  5692. }
  5693. return Ok(jw);
  5694. }
  5695. /// <summary>
  5696. /// 查询各模块已保存文件
  5697. /// </summary>
  5698. /// <param name="dto"></param>
  5699. /// <returns></returns>
  5700. [HttpPost]
  5701. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5702. {
  5703. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5704. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5705. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5706. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5707. {
  5708. expression = Expressionable.Create<Grp_GroupModelFile>()
  5709. .And(x => visaIds.Contains(x.CreateUserId));
  5710. }
  5711. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5712. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5713. .Where(expression.ToExpression())
  5714. .ToList();
  5715. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5716. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5717. {
  5718. x.FileName,
  5719. x.Id,
  5720. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5721. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5722. })));
  5723. }
  5724. /// <summary>
  5725. /// 下载该团组下的所有文件
  5726. /// </summary>
  5727. /// <param name="dto"></param>
  5728. /// <returns></returns>
  5729. [HttpPost]
  5730. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5731. {
  5732. var jw = JsonView(false);
  5733. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5734. if (groupInfo == null)
  5735. {
  5736. jw.Msg = "团组信息不存在!";
  5737. return Ok(jw);
  5738. }
  5739. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5740. var isModule = Convert.ToBoolean(dto.isModule);
  5741. var Zips = new Dictionary<string, Stream>();
  5742. var io = new IOOperatorHelper();
  5743. if (isModule)
  5744. {
  5745. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5746. foreach (var moduleArr in moduleGroup)
  5747. {
  5748. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5749. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5750. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5751. var chiZips = new Dictionary<string, Stream>();
  5752. foreach (var item in moduleArr)
  5753. {
  5754. if (System.IO.File.Exists(item.FilePath))
  5755. {
  5756. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5757. {
  5758. byte[] bytes = new byte[fileStream.Length];
  5759. fileStream.Read(bytes, 0, bytes.Length);
  5760. fileStream.Close();
  5761. Stream stream = new MemoryStream(bytes);
  5762. chiZips.Add(item.FileName, stream);
  5763. }
  5764. }
  5765. }
  5766. if (chiZips.Count > 0)
  5767. {
  5768. var byts = io.ConvertZipStream(chiZips);
  5769. Stream stream = new MemoryStream(byts);
  5770. Zips.Add(key.Name + "_.zip", stream);
  5771. }
  5772. }
  5773. }
  5774. else
  5775. {
  5776. foreach (var item in dbQuery)
  5777. {
  5778. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5779. {
  5780. byte[] bytes = new byte[fileStream.Length];
  5781. fileStream.Read(bytes, 0, bytes.Length);
  5782. fileStream.Close();
  5783. var stream = new MemoryStream(bytes);
  5784. while (Zips.ContainsKey(item.FileName))
  5785. {
  5786. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5787. }
  5788. Zips.Add(item.FileName, stream);
  5789. }
  5790. }
  5791. }
  5792. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5793. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5794. if (Zips.Count > 0)
  5795. {
  5796. var byts = io.ConvertZipStream(Zips);
  5797. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5798. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5799. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5800. }
  5801. else
  5802. {
  5803. jw.Msg = "暂无生成文件!";
  5804. }
  5805. return Ok(jw);
  5806. }
  5807. /// <summary>
  5808. /// 下载该团组下此模块的所有文件
  5809. /// </summary>
  5810. /// <param name="dto"></param>
  5811. /// <returns></returns>
  5812. [HttpPost]
  5813. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5814. {
  5815. var jw = JsonView(false);
  5816. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5817. if (groupInfo == null)
  5818. {
  5819. jw.Msg = "团组信息不存在!";
  5820. return Ok(jw);
  5821. }
  5822. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5823. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5824. && x.IsDel == 0);
  5825. if (key == null)
  5826. {
  5827. jw.Msg = "Ctable指向错误!";
  5828. return Ok(jw);
  5829. }
  5830. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5831. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5832. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5833. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5834. var io = new IOOperatorHelper();
  5835. var Zips = new Dictionary<string, Stream>();
  5836. foreach (var item in dbQuery)
  5837. {
  5838. if (System.IO.File.Exists(item.FilePath))
  5839. {
  5840. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5841. {
  5842. byte[] bytes = new byte[fileStream.Length];
  5843. fileStream.Read(bytes, 0, bytes.Length);
  5844. fileStream.Close();
  5845. var stream = new MemoryStream(bytes);
  5846. while (Zips.ContainsKey(item.FileName))
  5847. {
  5848. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5849. }
  5850. Zips.Add(item.FileName, stream);
  5851. }
  5852. }
  5853. }
  5854. if (Zips.Count > 0)
  5855. {
  5856. var byts = io.ConvertZipStream(Zips);
  5857. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5858. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5859. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5860. }
  5861. else
  5862. {
  5863. jw.Msg = "暂无生成文件!";
  5864. }
  5865. return Ok(jw);
  5866. }
  5867. /// <summary>
  5868. /// 删除该团组下的指定文件
  5869. /// </summary>
  5870. /// <param name="dto"></param>
  5871. /// <returns></returns>
  5872. [HttpPost]
  5873. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5874. {
  5875. var jw = JsonView(false);
  5876. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5877. if (sing == null)
  5878. {
  5879. jw.Msg = "暂无";
  5880. return Ok(jw);
  5881. }
  5882. if (System.IO.File.Exists(sing.FilePath))
  5883. {
  5884. try
  5885. {
  5886. System.IO.File.Delete(sing.FilePath);
  5887. }
  5888. catch (Exception ex)
  5889. {
  5890. jw.Msg = "删除失败!" + ex.Message;
  5891. return Ok(jw);
  5892. }
  5893. }
  5894. sing.IsDel = 1;
  5895. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5896. sing.DeleteUserId = dto.UserId;
  5897. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5898. jw = JsonView(true, "删除成功!");
  5899. return Ok(jw);
  5900. }
  5901. #endregion
  5902. #region 共享文件上传
  5903. /// <summary>
  5904. /// 共享文件数据初始化
  5905. /// </summary>
  5906. /// <returns></returns>
  5907. [HttpGet]
  5908. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5909. {
  5910. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5911. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5912. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5913. .Select(x => x.Id)
  5914. .ToList()
  5915. .Contains(userid);
  5916. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5917. .Where(x => x.STid == 111 && x.IsDel == 0)
  5918. .Select(x => new
  5919. {
  5920. x.Name,
  5921. x.Id,
  5922. }).ToList();
  5923. if (isMarketingDepartment)
  5924. {
  5925. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5926. }
  5927. if (portType == 1)
  5928. {
  5929. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5930. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5931. .Where(x => x.IsDel == 0)
  5932. .OrderByDescending(x => x.VisitDate)
  5933. .Select(x => new
  5934. {
  5935. x.TeamName,
  5936. x.Id,
  5937. x.CityId,
  5938. })
  5939. .ToList()
  5940. .Select(x =>
  5941. {
  5942. var provinceId = x.CityId;
  5943. var isDefualtVal = true;
  5944. if (provinceId > 0)
  5945. {
  5946. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5947. if (parentId != null)
  5948. {
  5949. isDefualtVal = false;
  5950. provinceId = (int)parentId;
  5951. }
  5952. }
  5953. if (isDefualtVal)
  5954. {
  5955. provinceId = 122; //默认四川
  5956. }
  5957. return new
  5958. {
  5959. x.TeamName,
  5960. x.Id,
  5961. provinceId,
  5962. };
  5963. })
  5964. .ToList();
  5965. return Ok(JsonView(true, "SUCCESS!", new
  5966. {
  5967. dropDownType,
  5968. dropDownGroupList,
  5969. isMarketingDepartment
  5970. }));
  5971. }
  5972. else if (portType == 2 || portType == 3)
  5973. {
  5974. return Ok(JsonView(true, "SUCCESS!", new
  5975. {
  5976. dropDownType,
  5977. isMarketingDepartment
  5978. }));
  5979. }
  5980. else
  5981. {
  5982. return Ok(JsonView(false, "portType有误!"));
  5983. }
  5984. }
  5985. /// <summary>
  5986. /// 共享文件上传
  5987. /// </summary>
  5988. /// <param name="dto"></param>
  5989. /// <returns></returns>
  5990. [HttpPost]
  5991. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5992. {
  5993. var isGroup = new List<int> { 1412 };
  5994. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5995. {
  5996. return Ok(JsonView(false, "该文件需要关联团组!"));
  5997. }
  5998. if (dto.Files == null || dto.Files.Count == 0)
  5999. {
  6000. return Ok(JsonView(false, "无文件信息!"));
  6001. }
  6002. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  6003. {
  6004. return Ok(JsonView(false, "文件大小超过20M!"));
  6005. }
  6006. if (dto.Userid < 1)
  6007. {
  6008. return Ok(JsonView(false, "请传入有效的Userid!"));
  6009. }
  6010. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  6011. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  6012. .Select((u, j) => new
  6013. {
  6014. u.CnName,
  6015. UserId = u.Id,
  6016. j.JobName,
  6017. })
  6018. .First();
  6019. if (jobInfo == null)
  6020. {
  6021. return Ok(JsonView(false, "请传入有效的Userid!"));
  6022. }
  6023. var commonFileExtensions = new List<string>
  6024. {
  6025. // 文本文件
  6026. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  6027. // 图片文件
  6028. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  6029. // 视频文件
  6030. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  6031. // 音频文件
  6032. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  6033. // 压缩文件
  6034. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  6035. // 数据文件
  6036. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  6037. };
  6038. try
  6039. {
  6040. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  6041. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  6042. commonFileExtensions.AddRange(settingExtend);
  6043. }
  6044. catch (Exception)
  6045. { }
  6046. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  6047. if (setdata == null)
  6048. {
  6049. return Ok(JsonView(false, "请传入有效的FileType!"));
  6050. }
  6051. var insertList = new List<Grp_GroupShareFile>();
  6052. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  6053. if (!Directory.Exists(winPath))
  6054. {
  6055. Directory.CreateDirectory(winPath);
  6056. }
  6057. foreach (var item in dto.Files)
  6058. {
  6059. var houzui = Path.GetExtension(item.FileName);
  6060. if (!commonFileExtensions.Contains(houzui))
  6061. {
  6062. return Ok(JsonView(false, "未知后缀名称!"));
  6063. }
  6064. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  6065. var saveFilePath = winPath + fileName;
  6066. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6067. {
  6068. item.CopyTo(fs);
  6069. fs.Flush();
  6070. }
  6071. var fileDetail = new Grp_GroupShareFile()
  6072. {
  6073. CreateUserId = dto.Userid,
  6074. CreateTime = DateTime.Now,
  6075. UploadJob = jobInfo.JobName,
  6076. FileName = fileName,
  6077. FileType = dto.FileType,
  6078. Diid = dto.Diid,
  6079. FilePath = winPath + fileName,
  6080. };
  6081. insertList.Add(fileDetail);
  6082. }
  6083. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  6084. return Ok(JsonView(true, "保存成功!"));
  6085. }
  6086. /// <summary>
  6087. /// 查询共享文件列表
  6088. /// </summary>
  6089. /// <param name="dto"></param>
  6090. /// <returns></returns>
  6091. [HttpPost]
  6092. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  6093. {
  6094. var isGroup = new List<int> { 1412 };
  6095. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  6096. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  6097. .And(x => x.Diid == dto.Diid)
  6098. .And(x => x.FileType == dto.FileType)
  6099. .And(x => x.IsDel == 0)
  6100. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  6101. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  6102. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  6103. int totalCount = 0;
  6104. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  6105. .Where(queryExpression.ToExpression())
  6106. .OrderBy(x => x.UploadJob)
  6107. .Select(x => new
  6108. {
  6109. x.Id,
  6110. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  6111. x.FileName,
  6112. x.FileType,
  6113. x.CreateTime,
  6114. })
  6115. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  6116. return Ok(JsonView(true, "SUCCESS!", new
  6117. {
  6118. FileList = dbQuery,
  6119. dto.PageSize,
  6120. dto.PageIndex,
  6121. totalCount
  6122. }));
  6123. }
  6124. /// <summary>
  6125. /// 删除共享文件模块下的指定文件
  6126. /// </summary>
  6127. /// <param name="dto"></param>
  6128. /// <returns></returns>
  6129. [HttpPost]
  6130. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  6131. {
  6132. var jw = JsonView(false);
  6133. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6134. if (sing == null)
  6135. {
  6136. jw.Msg = "暂无文件信息!";
  6137. return Ok(jw);
  6138. }
  6139. if (sing.CreateUserId != dto.UserId)
  6140. {
  6141. jw.Msg = "只能删除自己上传的文件!";
  6142. return Ok(jw);
  6143. }
  6144. if (System.IO.File.Exists(sing.FilePath))
  6145. {
  6146. try
  6147. {
  6148. System.IO.File.Delete(sing.FilePath);
  6149. }
  6150. catch (Exception ex)
  6151. {
  6152. jw.Msg = "删除失败!" + ex.Message;
  6153. return Ok(jw);
  6154. }
  6155. }
  6156. sing.IsDel = 1;
  6157. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6158. sing.DeleteUserId = dto.UserId;
  6159. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  6160. jw = JsonView(true, "删除成功!");
  6161. return Ok(jw);
  6162. }
  6163. #endregion
  6164. #region 团组英文资料
  6165. /// <summary>
  6166. /// 查询团组英文所有资料
  6167. /// </summary>
  6168. /// <param name="dto"></param>
  6169. /// <returns></returns>
  6170. [HttpPost]
  6171. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6172. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6173. {
  6174. try
  6175. {
  6176. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6177. if (groupData.Code != 0)
  6178. {
  6179. return Ok(JsonView(false, groupData.Msg));
  6180. }
  6181. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6182. }
  6183. catch (Exception ex)
  6184. {
  6185. return Ok(JsonView(false, ex.Message));
  6186. throw;
  6187. }
  6188. }
  6189. /// <summary>
  6190. /// 团组英文资料操作(Status:1.新增,2.修改)
  6191. /// </summary>
  6192. /// <param name="dto"></param>
  6193. /// <returns></returns>
  6194. [HttpPost]
  6195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6196. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6197. {
  6198. try
  6199. {
  6200. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  6201. if (groupData.Code != 0)
  6202. {
  6203. return Ok(JsonView(false, groupData.Msg));
  6204. }
  6205. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6206. }
  6207. catch (Exception ex)
  6208. {
  6209. return Ok(JsonView(false, ex.Message));
  6210. throw;
  6211. }
  6212. }
  6213. /// <summary>
  6214. /// 团组英文资料Id查询数据
  6215. /// </summary>
  6216. /// <param name="dto"></param>
  6217. /// <returns></returns>
  6218. [HttpPost]
  6219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6220. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  6221. {
  6222. try
  6223. {
  6224. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  6225. if (_DelegationEnData != null)
  6226. {
  6227. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  6228. }
  6229. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  6230. }
  6231. catch (Exception ex)
  6232. {
  6233. return Ok(JsonView(false, "程序错误!"));
  6234. throw;
  6235. }
  6236. }
  6237. /// <summary>
  6238. /// 团组英文资料删除
  6239. /// </summary>
  6240. /// <param name="dto"></param>
  6241. /// <returns></returns>
  6242. [HttpPost]
  6243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6244. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6245. {
  6246. try
  6247. {
  6248. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6249. if (!res)
  6250. {
  6251. return Ok(JsonView(false, "删除失败"));
  6252. }
  6253. return Ok(JsonView(true, "删除成功!"));
  6254. }
  6255. catch (Exception ex)
  6256. {
  6257. return Ok(JsonView(false, ex.Message));
  6258. throw;
  6259. }
  6260. }
  6261. #endregion
  6262. #region 导出邀请函
  6263. /// <summary>
  6264. /// 导出邀请函页面初始化
  6265. /// </summary>
  6266. /// <param name="dto"></param>
  6267. /// <returns></returns>
  6268. [HttpPost]
  6269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6270. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6271. {
  6272. try
  6273. {
  6274. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6275. var crm_Deles = new List<Crm_DeleClient>();
  6276. if (dto.DiId == 0)
  6277. {
  6278. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6279. }
  6280. else
  6281. {
  6282. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6283. }
  6284. return Ok(JsonView(true, "查询成功!", new
  6285. {
  6286. deleClient = crm_Deles,
  6287. delegations = grp_Delegations
  6288. }));
  6289. }
  6290. catch (Exception ex)
  6291. {
  6292. return Ok(JsonView(false, "程序错误!"));
  6293. throw;
  6294. }
  6295. }
  6296. /// <summary>
  6297. /// 导出邀请函
  6298. /// </summary>
  6299. /// <param name="dto"></param>
  6300. /// <returns></returns>
  6301. [HttpPost]
  6302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6303. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6304. {
  6305. #region 参数验证
  6306. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6307. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6308. #endregion
  6309. try
  6310. {
  6311. var transDic = new Dictionary<string, string>();
  6312. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6313. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6314. From Grp_TourClientList tcl
  6315. Left Join
  6316. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6317. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6318. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6319. From Crm_DeleClient dc
  6320. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6321. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6322. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6323. Where dc.IsDel = 0) temp
  6324. On temp.DcId =tcl.ClientId
  6325. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6326. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6327. var texts = new List<string>();
  6328. if (datas.Count != 0)
  6329. {
  6330. foreach (TourClientListDetailsView item in datas)
  6331. {
  6332. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6333. {
  6334. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6335. }
  6336. else
  6337. {
  6338. string name = item.LastName + item.FirstName;
  6339. texts.Add(name);
  6340. }
  6341. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6342. {
  6343. if (!transDic.ContainsKey(item.Job))
  6344. {
  6345. texts.Add(item.Job);
  6346. }
  6347. }
  6348. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6349. {
  6350. texts.Add(item.CompanyFullName);
  6351. }
  6352. }
  6353. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6354. if (transData.Count > 0)
  6355. {
  6356. foreach (TranslateResult item in transData)
  6357. {
  6358. if (!transDic.ContainsKey(item.Query))
  6359. {
  6360. transDic.Add(item.Query, item.Translation);
  6361. }
  6362. }
  6363. }
  6364. var list = new List<GuestList>();
  6365. foreach (var dele in datas)
  6366. {
  6367. var guestList = new GuestList();
  6368. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6369. {
  6370. guestList.Name = dele.Pinyin;
  6371. }
  6372. else
  6373. {
  6374. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6375. guestList.Name = Name;
  6376. }
  6377. if (dele.Sex == 0)
  6378. {
  6379. guestList.Sex = "Male";
  6380. }
  6381. else if (dele.Sex == 1)
  6382. {
  6383. guestList.Sex = "Female";
  6384. }
  6385. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6386. if (!string.IsNullOrEmpty(dele.Job))
  6387. {
  6388. guestList.Job = dele.Job;
  6389. }
  6390. list.Add(guestList);
  6391. }
  6392. //载入模板
  6393. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6394. var builder = new DocumentBuilder(doc);
  6395. //获取word里所有表格
  6396. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6397. //获取所填表格的序数
  6398. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6399. var rowStart = tableOne.Rows[0]; //获取第1行
  6400. //循环赋值
  6401. for (int i = 0; i < list.Count; i++)
  6402. {
  6403. builder.MoveToCell(0, i + 1, 0, 0);
  6404. builder.Write(list[i].Name.ToString());
  6405. builder.MoveToCell(0, i + 1, 1, 0);
  6406. builder.Write(list[i].Sex.ToString());
  6407. builder.MoveToCell(0, i + 1, 2, 0);
  6408. builder.Write(list[i].DOB.ToString());
  6409. builder.MoveToCell(0, i + 1, 3, 0);
  6410. builder.Write(list[i].Job.ToString());
  6411. }
  6412. //删除多余行
  6413. while (tableOne.Rows.Count > list.Count + 1)
  6414. {
  6415. tableOne.Rows.RemoveAt(list.Count + 1);
  6416. }
  6417. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6418. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6419. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6420. doc.Save(filePath);
  6421. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6422. return Ok(JsonView(true, "操作成功!", Url));
  6423. }
  6424. else
  6425. {
  6426. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6427. }
  6428. }
  6429. catch (Exception ex)
  6430. {
  6431. return Ok(JsonView(false, ex.Message));
  6432. throw;
  6433. }
  6434. }
  6435. #endregion
  6436. #region 团组经理模块 出入境费用
  6437. /// <summary>
  6438. /// 团组模块 - 出入境费用 - 省份基础数据源
  6439. /// </summary>
  6440. /// <returns></returns>
  6441. [HttpGet]
  6442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6443. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6444. {
  6445. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6446. }
  6447. /// <summary>
  6448. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6449. /// </summary>
  6450. /// <param name="dto"></param>
  6451. /// <returns></returns>
  6452. [HttpPost]
  6453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6454. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6455. {
  6456. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6457. var groupNamFirst = groupNameData.FirstOrDefault();
  6458. //SetDataInfoView
  6459. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6460. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6461. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6462. //验证城市归属并给默认值
  6463. int provinceId = 122;
  6464. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6465. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6466. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6467. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6468. return Ok(JsonView(true, "查询成功!", new
  6469. {
  6470. GroupNameData = groupNameData,
  6471. CurrencyData = _CurrencyData,
  6472. WordTypeData = wordTypeData,
  6473. ExcelTypeData = excelTypeData,
  6474. CurrencyInit = _currencyInfos,
  6475. ViewPermissionData = viewPermissionData
  6476. }));
  6477. }
  6478. /// <summary>
  6479. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6480. /// </summary>
  6481. /// <returns></returns>
  6482. [HttpGet("{provinceId}")]
  6483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6484. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6485. {
  6486. //验证城市归属并给默认值
  6487. if (provinceId < 1) provinceId = 122;
  6488. /*
  6489. * 122 四川
  6490. * 108 贵州
  6491. * 103 重庆
  6492. * 132 云南
  6493. */
  6494. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6495. return Ok(JsonView(true, "查询成功!", new
  6496. {
  6497. WordTypeData = wordTypeData,
  6498. ExcelTypeData = excelTypeData,
  6499. }));
  6500. }
  6501. /// <summary>
  6502. /// 团组模块 - 出入境费用
  6503. /// 实时汇率 tips
  6504. /// 签证费用 tips
  6505. /// 机票费用 tips
  6506. /// </summary>
  6507. /// <returns></returns>
  6508. [HttpPost]
  6509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6510. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6511. {
  6512. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6513. //默认币种显示
  6514. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6515. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6516. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6517. return Ok(JsonView(true, "查询成功!", new
  6518. {
  6519. //GroupNameData = groupNameData.Data,
  6520. visaData = visaData.Data,
  6521. airData,
  6522. reteInfos
  6523. }));
  6524. }
  6525. /// <summary>
  6526. /// 团组模块 - 出入境费用 - Info
  6527. /// </summary>
  6528. /// <param name="dto"></param>
  6529. /// <returns></returns>
  6530. [HttpPost]
  6531. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6533. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6534. {
  6535. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6536. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6537. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6538. }
  6539. /// <summary>
  6540. /// 团组模块 - 出入境费用 - 设置view权限
  6541. /// </summary>
  6542. /// <returns></returns>
  6543. [HttpPost]
  6544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6545. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6546. {
  6547. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6548. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6549. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6550. var permissions = new List<Grp_EnterExitCostPermission>();
  6551. foreach (var userId in dto.UserIds)
  6552. {
  6553. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6554. }
  6555. if (permissions.Any())
  6556. {
  6557. _sqlSugar.BeginTran();
  6558. try
  6559. {
  6560. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6561. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6562. if (result < 1)
  6563. {
  6564. _sqlSugar.RollbackTran();
  6565. return Ok(JsonView(false));
  6566. }
  6567. }
  6568. catch (Exception ex)
  6569. {
  6570. _sqlSugar.RollbackTran();
  6571. return Ok(JsonView(false, ex.Message));
  6572. }
  6573. _sqlSugar.CommitTran();
  6574. return Ok(JsonView(true));
  6575. }
  6576. return Ok(JsonView(false));
  6577. }
  6578. /// <summary>
  6579. /// 团组模块 - 出入境费用 - Add And Update
  6580. /// </summary>
  6581. /// <returns></returns>
  6582. [HttpPost]
  6583. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6585. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6586. {
  6587. try
  6588. {
  6589. var rateRecords = new List<RateRecordInfo>();
  6590. #region 汇率保存前存储
  6591. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  6592. if (info != null)
  6593. {
  6594. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  6595. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  6596. {
  6597. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  6598. {
  6599. CurrencyCode = x.CurrencyCode,
  6600. CurrencyName = x.CurrencyName,
  6601. UpdatePreRate = x.Rate,
  6602. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  6603. }).ToList();
  6604. }
  6605. else
  6606. {
  6607. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6608. {
  6609. CurrencyCode = x.CurrencyCode,
  6610. CurrencyName = x.CurrencyName,
  6611. UpdatePreRate = 0.00M,
  6612. UpdateBreRate = x.Rate
  6613. }).ToList();
  6614. }
  6615. }
  6616. else
  6617. {
  6618. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6619. {
  6620. CurrencyCode = x.CurrencyCode,
  6621. CurrencyName = x.CurrencyName,
  6622. UpdatePreRate = 0.00M,
  6623. UpdateBreRate = x.Rate
  6624. }).ToList();
  6625. }
  6626. #endregion
  6627. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6628. if (dto.DayOtherPriceData.Any())
  6629. {
  6630. var inserList = dto.DayOtherPriceData
  6631. .Where(x => x.Id == 0)
  6632. .Select(x => new Grp_DayOtherPrice
  6633. {
  6634. Cost = x.Cost,
  6635. Id = x.Id,
  6636. CreateTime = DateTime.Now,
  6637. CreateUserId = dto.UserId,
  6638. Currency = x.Currency,
  6639. Diid = x.DiId,
  6640. Index = x.Index,
  6641. IsDel = 0,
  6642. SetDataId = x.SetDataId,
  6643. SubTotal = x.SubTotal,
  6644. Remark = x.Remark
  6645. })
  6646. .ToList();
  6647. var updateList = dto.DayOtherPriceData
  6648. .Where(x => x.Id != 0)
  6649. .Select(x => new Grp_DayOtherPrice
  6650. {
  6651. Cost = x.Cost,
  6652. Id = x.Id,
  6653. CreateTime = DateTime.Now,
  6654. CreateUserId = dto.UserId,
  6655. Currency = x.Currency,
  6656. Diid = x.DiId,
  6657. Index = x.Index,
  6658. IsDel = 0,
  6659. SetDataId = x.SetDataId,
  6660. SubTotal = x.SubTotal,
  6661. Remark = x.Remark
  6662. })
  6663. .ToList();
  6664. //添加
  6665. _sqlSugar.BeginTran();
  6666. if (inserList.Any())
  6667. {
  6668. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6669. }
  6670. if (updateList.Any())
  6671. {
  6672. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6673. }
  6674. _sqlSugar.CommitTran();
  6675. }
  6676. if (data.Code != 0)
  6677. {
  6678. return Ok(JsonView(false, data.Msg));
  6679. }
  6680. //生成默认文件pdf并且通知人员
  6681. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6682. {
  6683. DiId = dto.DiId,
  6684. ExportType = 1,
  6685. SubTypeId = 1005
  6686. }, "pdf");
  6687. //发送通知
  6688. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6689. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6690. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6691. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6692. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6693. //汇率信息记录
  6694. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6695. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  6696. //汇率验证、反推
  6697. (bool isSendMsg, string msgContent, List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  6698. if (isSendMsg)
  6699. {
  6700. //消息推送
  6701. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId, dto.UserId, msgContent);
  6702. }
  6703. #region //日志汇率记录
  6704. //按照已使用币种记录
  6705. if (checkCurrencys != null && checkCurrencys.Count > 0)
  6706. {
  6707. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  6708. //汇率记录中加入实时汇率
  6709. if (liveRates != null && liveRates.Count > 0)
  6710. {
  6711. foreach (var item in rateRecords)
  6712. {
  6713. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  6714. }
  6715. }
  6716. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  6717. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  6718. var logContent = new StringBuilder();
  6719. foreach (var item in rateRecords)
  6720. {
  6721. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  6722. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  6723. logContent.AppendLine(msg);
  6724. }
  6725. _eec_textLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】\r\n{logContent}", teamName, dto.DiId, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), logContent.ToString());
  6726. }
  6727. #endregion
  6728. return Ok(JsonView(true, data.Msg, data.Data));
  6729. }
  6730. catch (Exception ex)
  6731. {
  6732. return Ok(JsonView(false, ex.Message));
  6733. }
  6734. }
  6735. /// <summary>
  6736. /// 团组模块 - 出入境费用 - Confirm 费用
  6737. /// </summary>
  6738. /// <returns></returns>
  6739. [HttpPost]
  6740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6741. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6742. {
  6743. //TODO:测试完毕需把对应的用户ID更改
  6744. //1、数据表添加字段
  6745. //2、更改字段接口()
  6746. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6747. //3、确认成功 给财务发送消息
  6748. if (_view.Code == 200)
  6749. {
  6750. if (dto.Type == 1)
  6751. {
  6752. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6753. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6754. }
  6755. }
  6756. return Ok(_view);
  6757. }
  6758. /// <summary>
  6759. /// 团组模块 - 出入境费用 - File download
  6760. /// </summary>
  6761. /// <param name="dto"></param>
  6762. /// <returns></returns>
  6763. [HttpPost]
  6764. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6766. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6767. {
  6768. try
  6769. {
  6770. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6771. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6772. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6773. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6774. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6775. 3 团组成员名单 1 团组成员名单", ""));
  6776. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6777. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6778. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6779. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6780. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6781. //数据源
  6782. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6783. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6784. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6785. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6786. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6787. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6788. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6789. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6790. .Select((x, a, b) => new
  6791. {
  6792. x.Index,
  6793. itemName = a.Name,
  6794. CurrencyStr = b.Name,
  6795. x.Cost,
  6796. x.SubTotal,
  6797. x.Remark
  6798. })
  6799. .OrderBy((x) => x.Index)
  6800. .ToList(); //其他款项费用
  6801. var peiceItemCurrencys = new List<string>();
  6802. if (_DayAndCosts.Any())
  6803. {
  6804. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6805. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6806. }
  6807. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6808. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6809. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6810. {
  6811. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6812. }
  6813. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6814. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6815. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6816. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6817. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6818. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6819. .Select((tcl, dc, cc) => new ClientInfo
  6820. {
  6821. LastName = dc.LastName,
  6822. FirstName = dc.FirstName,
  6823. Sex = dc.Sex,
  6824. Birthday = dc.BirthDay,
  6825. Company = cc.CompanyFullName,
  6826. Job = dc.Job
  6827. })
  6828. .ToList();
  6829. foreach (var item in DeleClientList)
  6830. {
  6831. EncryptionProcessor.DecryptProperties(item);
  6832. }
  6833. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6834. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6835. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6836. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6837. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6838. if (dto.ExportType == 1) //明细表
  6839. {
  6840. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6841. {
  6842. //获取模板
  6843. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6844. //载入模板
  6845. var doc = new Document(tempPath);
  6846. var builder = new DocumentBuilder(doc);
  6847. var dic = new Dictionary<string, string>();
  6848. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6849. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6850. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6851. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6852. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6853. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6854. //境内费用(其他费用)
  6855. if (_EnterExitCosts.ChoiceOne == 1)
  6856. {
  6857. string row1_1 = "";
  6858. if (_EnterExitCosts.Visa > 0)
  6859. {
  6860. //insidePayTotal += _EnterExitCosts.Visa;
  6861. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 元/人";
  6862. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6863. //{
  6864. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6865. //}
  6866. }
  6867. string row1_2 = "";
  6868. if (_EnterExitCosts.YiMiao > 0)
  6869. {
  6870. //insidePayTotal += _EnterExitCosts.YiMiao;
  6871. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 元/人";
  6872. }
  6873. if (_EnterExitCosts.HeSuan > 0)
  6874. {
  6875. //insidePayTotal += _EnterExitCosts.HeSuan;
  6876. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 元/人";
  6877. }
  6878. if (_EnterExitCosts.Service > 0)
  6879. {
  6880. //insidePayTotal += _EnterExitCosts.Service;
  6881. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 元/人";
  6882. }
  6883. string row1_3 = "";
  6884. if (_EnterExitCosts.Safe > 0)
  6885. {
  6886. //insidePayTotal += _EnterExitCosts.Safe;
  6887. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 元/人";
  6888. }
  6889. if (_EnterExitCosts.Ticket > 0)
  6890. {
  6891. //insidePayTotal += _EnterExitCosts.Ticket;
  6892. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 元/人";
  6893. }
  6894. string row1 = "";
  6895. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6896. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6897. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6898. row1 += $"备注:{_EnterExitCosts.Remark}";
  6899. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6900. dic.Add("Row1Str", row1);
  6901. }
  6902. string airTotalStr = string.Empty,
  6903. airPriceStr = string.Empty;
  6904. //经济舱
  6905. if (_EnterExitCosts.SumJJC == 1)
  6906. {
  6907. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  6908. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  6909. }
  6910. //公务舱
  6911. if (_EnterExitCosts.SumGWC == 1)
  6912. {
  6913. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  6914. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  6915. }
  6916. //头等舱
  6917. if (_EnterExitCosts.SumTDC == 1)
  6918. {
  6919. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  6920. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  6921. }
  6922. //汇率描述
  6923. string rateStr = "";
  6924. if (peiceItemCurrencyInfos.Any())
  6925. {
  6926. rateStr = "\r\n汇率描述:";
  6927. foreach (var item in peiceItemCurrencyInfos)
  6928. {
  6929. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  6930. }
  6931. }
  6932. string twoItemRemark = "备注:";
  6933. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6934. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6935. dic.Add("AirTotalStr", airTotalStr);
  6936. dic.Add("AirPriceStr", airPriceStr);
  6937. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6938. dic.Add("TwoItemRemark", twoItemRemark);
  6939. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6940. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6941. int table1Row = 0,
  6942. table2Row = 0,
  6943. table3Row = 0,
  6944. table4Row = 0,
  6945. table5Row = 0;
  6946. //住宿费
  6947. if (_EnterExitCosts.ChoiceThree == 1)
  6948. {
  6949. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6950. table1Row = dac1.Count;
  6951. #region 填充word表格内容
  6952. for (int i = 0; i < dac1.Count; i++)
  6953. {
  6954. Grp_DayAndCost dac = dac1[i];
  6955. if (dac == null) continue;
  6956. builder.MoveToCell(0, i, 0, 0);
  6957. builder.Write("第" + dac.Days.ToString() + "晚:");
  6958. builder.MoveToCell(0, i, 1, 0);
  6959. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6960. //builder.Write(dac.Place == null ? "" : dac.Place);
  6961. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6962. builder.MoveToCell(0, i, 2, 0);
  6963. builder.Write("费用标准:");
  6964. string curr = "";
  6965. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6966. if (currData != null)
  6967. {
  6968. curr = currData.Name;
  6969. }
  6970. builder.MoveToCell(0, i, 3, 0);
  6971. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6972. builder.MoveToCell(0, i, 4, 0);
  6973. builder.Write("费用小计:");
  6974. builder.MoveToCell(0, i, 5, 0);
  6975. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6976. }
  6977. #endregion
  6978. }
  6979. else dic.Add("SubZS", "0.00");
  6980. //删除多余行
  6981. while (table1.Rows.Count > table1Row)
  6982. {
  6983. table1.Rows.RemoveAt(table1Row);
  6984. }
  6985. //伙食费
  6986. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6987. if (_EnterExitCosts.ChoiceFour == 1)
  6988. {
  6989. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6990. table2Row = dac2.Count;
  6991. #region 填充word表格内容
  6992. for (int i = 0; i < dac2.Count; i++)
  6993. {
  6994. Grp_DayAndCost dac = dac2[i];
  6995. if (dac == null) continue;
  6996. builder.MoveToCell(1, i, 0, 0);
  6997. builder.Write("第" + dac.Days.ToString() + "天:");
  6998. builder.MoveToCell(1, i, 1, 0);
  6999. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7000. builder.MoveToCell(1, i, 2, 0);
  7001. builder.Write("费用标准:");
  7002. string curr = "";
  7003. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7004. if (currData != null)
  7005. {
  7006. curr = currData.Name;
  7007. }
  7008. builder.MoveToCell(1, i, 3, 0);
  7009. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7010. builder.MoveToCell(1, i, 4, 0);
  7011. builder.Write("费用小计:");
  7012. builder.MoveToCell(1, i, 5, 0);
  7013. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7014. }
  7015. #endregion
  7016. }
  7017. else dic.Add("SubHS", "0.00");
  7018. //删除多余行
  7019. while (table2.Rows.Count > table2Row)
  7020. {
  7021. table2.Rows.RemoveAt(table2Row);
  7022. }
  7023. //公杂费
  7024. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7025. if (_EnterExitCosts.ChoiceFive == 1)
  7026. {
  7027. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7028. table3Row = dac3.Count;
  7029. #region 填充word表格内容
  7030. for (int i = 0; i < dac3.Count; i++)
  7031. {
  7032. Grp_DayAndCost dac = dac3[i];
  7033. if (dac == null) continue;
  7034. builder.MoveToCell(2, i, 0, 0);
  7035. builder.Write("第" + dac.Days.ToString() + "天:");
  7036. builder.MoveToCell(2, i, 1, 0);
  7037. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7038. builder.MoveToCell(2, i, 2, 0);
  7039. builder.Write("费用标准:");
  7040. string curr = "";
  7041. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7042. if (currData != null)
  7043. {
  7044. curr = currData.Name;
  7045. }
  7046. builder.MoveToCell(2, i, 3, 0);
  7047. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7048. builder.MoveToCell(2, i, 4, 0);
  7049. builder.Write("费用小计:");
  7050. builder.MoveToCell(2, i, 5, 0);
  7051. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7052. }
  7053. //删除多余行
  7054. while (table3.Rows.Count > table3Row)
  7055. {
  7056. table3.Rows.RemoveAt(table3Row);
  7057. }
  7058. #endregion
  7059. }
  7060. else dic.Add("SubGZF", "0.00");
  7061. //删除多余行
  7062. while (table3.Rows.Count > table3Row)
  7063. {
  7064. table3.Rows.RemoveAt(table3Row);
  7065. }
  7066. //培训费
  7067. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7068. if (_EnterExitCosts.ChoiceSix == 1)
  7069. {
  7070. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  7071. dic.Add("SubPX", pxStr);
  7072. table4Row = dac4.Count;
  7073. #region 填充word表格内容
  7074. for (int i = 0; i < dac4.Count; i++)
  7075. {
  7076. Grp_DayAndCost dac = dac4[i];
  7077. if (dac == null) continue;
  7078. builder.MoveToCell(3, i, 0, 0);
  7079. builder.Write("第" + dac.Days.ToString() + "天:");
  7080. builder.MoveToCell(3, i, 1, 0);
  7081. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7082. builder.MoveToCell(3, i, 2, 0);
  7083. builder.Write("费用标准:");
  7084. string curr = "";
  7085. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7086. if (currData != null)
  7087. {
  7088. curr = currData.Name;
  7089. }
  7090. builder.MoveToCell(3, i, 3, 0);
  7091. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7092. builder.MoveToCell(3, i, 4, 0);
  7093. builder.Write("费用小计:");
  7094. builder.MoveToCell(3, i, 5, 0);
  7095. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7096. }
  7097. #endregion
  7098. }
  7099. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  7100. //删除多余行
  7101. while (table4.Rows.Count > table4Row)
  7102. {
  7103. table4.Rows.RemoveAt(table4Row);
  7104. }
  7105. //其他费用
  7106. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7107. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7108. {
  7109. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  7110. dic.Add("titleQi", qtStr);
  7111. table5Row = dac5.Count;
  7112. #region 填充word表格内容
  7113. for (int i = 0; i < dac5.Count; i++)
  7114. {
  7115. var dac = dac5[i];
  7116. if (dac == null) continue;
  7117. builder.MoveToCell(4, i, 0, 0);
  7118. builder.Write("第" + dac.Index.ToString() + "项:");
  7119. builder.MoveToCell(4, i, 1, 0);
  7120. builder.Write(dac.itemName);
  7121. builder.MoveToCell(4, i, 2, 0);
  7122. builder.Write("费用标准:");
  7123. builder.MoveToCell(4, i, 3, 0);
  7124. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7125. builder.MoveToCell(4, i, 4, 0);
  7126. builder.Write("费用小计:");
  7127. builder.MoveToCell(4, i, 5, 0);
  7128. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7129. builder.MoveToCell(4, i, 6, 0);
  7130. builder.Write("备注:");
  7131. builder.MoveToCell(4, i, 7, 0);
  7132. builder.Write(dac.Remark);
  7133. }
  7134. #endregion
  7135. }
  7136. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7137. //删除多余行
  7138. while (table5.Rows.Count > table5Row)
  7139. {
  7140. table5.Rows.RemoveAt(table5Row);
  7141. }
  7142. //加上其他费用
  7143. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7144. decimal subJJC = 0.00M,
  7145. subGWC = 0.00M,
  7146. subTDC = 0.00M;
  7147. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7148. string totalLabel = string.Format("全部费用总计:");
  7149. //经济舱
  7150. if (_EnterExitCosts.SumJJC == 1)
  7151. {
  7152. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7153. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  7154. }
  7155. //公务舱
  7156. if (_EnterExitCosts.SumGWC == 1)
  7157. {
  7158. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7159. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  7160. }
  7161. //头等舱
  7162. if (_EnterExitCosts.SumTDC == 1)
  7163. {
  7164. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7165. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  7166. }
  7167. //TotalLabel
  7168. dic.Add("TotalLabel", totalLabel);
  7169. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7170. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7171. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7172. #region 填充word模板书签内容
  7173. foreach (var key in dic.Keys)
  7174. {
  7175. Bookmark bookmark = doc.Range.Bookmarks[key];
  7176. if (bookmark != null)
  7177. {
  7178. builder.MoveToBookmark(key);
  7179. builder.Write(dic[key]);
  7180. }
  7181. }
  7182. #endregion
  7183. #region 设置页眉
  7184. string userLabel = string.Empty;
  7185. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7186. if (currUserInfo != null)
  7187. {
  7188. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  7189. if (userInfo != null)
  7190. {
  7191. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  7192. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  7193. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  7194. }
  7195. }
  7196. //设置页脚
  7197. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  7198. #endregion
  7199. //文件名
  7200. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  7201. AsposeHelper.removewatermark_v2180();
  7202. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7203. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7204. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7205. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7206. }
  7207. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7208. {
  7209. //获取模板
  7210. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7211. //载入模板
  7212. var doc = new Document(tempPath);
  7213. var builder = new DocumentBuilder(doc);
  7214. var dic = new Dictionary<string, string>();
  7215. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7216. {
  7217. var list = new List<string>();
  7218. try
  7219. {
  7220. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7221. foreach (var item in spilitArr)
  7222. {
  7223. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7224. var depCode = spDotandEmpty[2].Substring(0, 3);
  7225. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7226. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7227. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7228. list.Add(depName);
  7229. list.Add(arrName);
  7230. }
  7231. list = list.Distinct().ToList();
  7232. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7233. }
  7234. catch (Exception)
  7235. {
  7236. dic.Add("ReturnCode", "行程录入不正确!");
  7237. }
  7238. }
  7239. else
  7240. {
  7241. dic.Add("ReturnCode", "未录入行程!");
  7242. }
  7243. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7244. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7245. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7246. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7247. {
  7248. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7249. dic.Add("Day", sp.Days.ToString());
  7250. }
  7251. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7252. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7253. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7254. //dic.Add("Names", Names);
  7255. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7256. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7257. decimal dac1totalPrice = 0.00M;
  7258. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7259. foreach (var dac in dac1)
  7260. {
  7261. if (dac.SubTotal == 0.00M)
  7262. {
  7263. continue;
  7264. }
  7265. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7266. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7267. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7268. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7269. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7270. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7271. builder.Write(currency);//币种
  7272. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7273. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7274. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7275. builder.Write("");//人数
  7276. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7277. builder.Write("");//天数
  7278. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7279. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7280. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7281. decimal rate = 0.00M;
  7282. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7283. builder.Write(rate.ToString("#0.0000"));//汇率
  7284. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7285. decimal rbmPrice = dac.SubTotal;
  7286. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7287. accommodationStartIndex++;
  7288. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7289. }
  7290. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7291. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7292. {
  7293. table1.Rows.RemoveAt(i - 1);
  7294. foodandotherStartIndex--;
  7295. }
  7296. if (dac2.Count == dac3.Count)//国家 币种 金额
  7297. {
  7298. for (int i = 0; i < dac2.Count; i++)
  7299. {
  7300. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7301. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7302. }
  7303. }
  7304. decimal dac2totalPrice = 0.00M;
  7305. foreach (var dac in dac2)
  7306. {
  7307. if (dac.SubTotal == 0)
  7308. {
  7309. continue;
  7310. }
  7311. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7312. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7313. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7314. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7315. builder.Write(currency);//币种
  7316. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7317. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7318. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7319. builder.Write("");//人数
  7320. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7321. builder.Write("");//天数
  7322. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7323. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7324. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7325. decimal rate = 0.00M;
  7326. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7327. builder.Write(rate.ToString("#0.0000"));//汇率
  7328. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7329. decimal rbmPrice = dac.SubTotal;
  7330. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7331. foodandotherStartIndex++;
  7332. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7333. }
  7334. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7335. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7336. {
  7337. table1.Rows.RemoveAt(i - 1);
  7338. }
  7339. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7340. string otherFeeStr = "";
  7341. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  7342. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  7343. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  7344. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7345. foreach (var otherInfo in dac5)
  7346. {
  7347. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7348. }
  7349. #endregion
  7350. if (otherFeeStr.Length > 0)
  7351. {
  7352. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7353. otherFeeStr = $"({otherFeeStr})";
  7354. dic.Add("OtherFeeStr", otherFeeStr);
  7355. }
  7356. //总计
  7357. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7358. //国际旅费
  7359. string outsideAir = string.Empty;
  7360. string allPriceAir = string.Empty;
  7361. if (_EnterExitCosts.SumJJC == 1)
  7362. {
  7363. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7364. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7365. }
  7366. if (_EnterExitCosts.SumGWC == 1)
  7367. {
  7368. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7369. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7370. }
  7371. if (_EnterExitCosts.SumTDC == 1)
  7372. {
  7373. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7374. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7375. }
  7376. dic.Add("InTravelPrice", $"({outsideAir})");
  7377. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7378. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7379. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7380. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7381. foreach (var key in dic.Keys)
  7382. {
  7383. builder.MoveToBookmark(key);
  7384. builder.Write(dic[key]);
  7385. }
  7386. //模板文件名
  7387. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7388. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7389. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7390. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7391. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7392. }
  7393. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7394. {
  7395. //获取模板
  7396. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7397. //载入模板
  7398. var designer = new WorkbookDesigner
  7399. {
  7400. Workbook = new Workbook(tempPath)
  7401. };
  7402. var dic = new Dictionary<string, string>();
  7403. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7404. {
  7405. var list = new List<string>();
  7406. try
  7407. {
  7408. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7409. foreach (var item in spilitArr)
  7410. {
  7411. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7412. var depCode = spDotandEmpty[2].Substring(0, 3);
  7413. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7414. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7415. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7416. list.Add(depName);
  7417. list.Add(arrName);
  7418. }
  7419. list = list.Distinct().ToList();
  7420. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7421. }
  7422. catch (Exception)
  7423. {
  7424. dic.Add("ReturnCode", "行程录入不正确!");
  7425. }
  7426. }
  7427. else
  7428. {
  7429. dic.Add("ReturnCode", "未录入行程!");
  7430. }
  7431. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7432. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7433. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7434. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7435. {
  7436. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7437. dic.Add("Day", sp.Days.ToString());
  7438. }
  7439. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7440. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7441. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7442. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7443. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7444. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7445. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7446. designer.SetDataSource("Name", Names);
  7447. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7448. designer.SetDataSource("Day", dic["Day"] + "天");
  7449. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7450. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7451. int startIndex = 10;
  7452. const int startIndexcopy = 10;
  7453. if (dac2.Count == dac3.Count)//国家 币种 金额
  7454. {
  7455. for (int i = 0; i < dac2.Count; i++)
  7456. {
  7457. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7458. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7459. }
  7460. }
  7461. var dtdac1 = new DataTable();
  7462. var place = new List<string>();
  7463. dtdac1.Columns.AddRange(new DataColumn[] {
  7464. new(){ ColumnName = "city"},
  7465. new(){ ColumnName = "curr"},
  7466. new(){ ColumnName = "criterion"},
  7467. new(){ ColumnName = "number",DataType = typeof(int)},
  7468. new(){ ColumnName = "day",DataType = typeof(int)},
  7469. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7470. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7471. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7472. });
  7473. var dtdac2 = new DataTable();
  7474. dtdac2.Columns.AddRange(new DataColumn[] {
  7475. new(){ ColumnName = "city"},
  7476. new(){ ColumnName = "curr"},
  7477. new(){ ColumnName = "criterion"},
  7478. new(){ ColumnName = "number",DataType = typeof(int)},
  7479. new(){ ColumnName = "day",DataType = typeof(int)},
  7480. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7481. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7482. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7483. });
  7484. dtdac1.TableName = "tb1";
  7485. dtdac2.TableName = "tb2";
  7486. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7487. foreach (var item in dac1)
  7488. {
  7489. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7490. if (place.Contains(item.Place))
  7491. {
  7492. continue;
  7493. }
  7494. DataRow row = dtdac1.NewRow();
  7495. row["city"] = item.Place;
  7496. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7497. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7498. row["curr"] = currency;
  7499. row["rate"] = rate.ToString("#0.0000");
  7500. row["criterion"] = item.Cost.ToString("#0.00");
  7501. row["number"] = 1;
  7502. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7503. //row["costRMB"] = rbmPrice;
  7504. dtdac1.Rows.Add(row);
  7505. place.Add(item.Place);
  7506. }
  7507. place = new List<string>();
  7508. foreach (var item in dac2)
  7509. {
  7510. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7511. if (place.Contains(item.Place))
  7512. {
  7513. continue;
  7514. }
  7515. DataRow row = dtdac2.NewRow();
  7516. row["city"] = item.Place;
  7517. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7518. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7519. row["curr"] = currency;
  7520. row["rate"] = rate.ToString("#0.0000");
  7521. row["criterion"] = item.Cost.ToString("#0.00");
  7522. row["number"] = 1;
  7523. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7524. //row["cost"] = item.SubTotal;
  7525. //row["costRMB"] = rbmPrice;
  7526. dtdac2.Rows.Add(row);
  7527. place.Add(item.Place);
  7528. //dac2totalPrice += rbmPrice;
  7529. }
  7530. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7531. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7532. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7533. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7534. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7535. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7536. string cell4Str1 = string.Empty;
  7537. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7538. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7539. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7540. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7541. string cellStr = $" 5.其他费用(";
  7542. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7543. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7544. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7545. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7546. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7547. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7548. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7549. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7550. foreach (var otherInfo in dac5)
  7551. {
  7552. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7553. }
  7554. #endregion
  7555. if (cellStr.Length > 8)
  7556. {
  7557. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7558. }
  7559. cellStr += ")";
  7560. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7561. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7562. decimal pxFee = dac4.Sum(it => it.Cost);
  7563. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7564. string celllastStr1 = "";
  7565. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7566. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7567. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7568. celllastStr1 += $",国际旅费 元";
  7569. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7570. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7571. designer.SetDataSource("cell4Str", cell4Str);
  7572. designer.SetDataSource("cellStr", cellStr);
  7573. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7574. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7575. designer.SetDataSource("celllastStr", celllastStr);
  7576. Workbook wb = designer.Workbook;
  7577. var sheet = wb.Worksheets[0];
  7578. //绑定datatable数据集
  7579. designer.SetDataSource(dtdac1);
  7580. designer.SetDataSource(dtdac2);
  7581. designer.Process();
  7582. var rowStart = dtdac1.Rows.Count;
  7583. while (rowStart > 0)
  7584. {
  7585. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7586. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7587. startIndex++;
  7588. rowStart--;
  7589. }
  7590. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7591. startIndex += 1; //总计行
  7592. rowStart = dtdac2.Rows.Count;
  7593. while (rowStart > 0)
  7594. {
  7595. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7596. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7597. startIndex++;
  7598. rowStart--;
  7599. }
  7600. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7601. wb.CalculateFormula(true);
  7602. //模板文件名
  7603. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7604. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7605. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7606. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7607. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7608. }
  7609. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7610. {
  7611. //获取模板
  7612. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7613. //载入模板
  7614. var doc = new Document(tempPath);
  7615. var builder = new DocumentBuilder(doc);
  7616. var dic = new Dictionary<string, string>
  7617. {
  7618. { "GroupName", _DelegationInfo.TeamName },
  7619. { "ClientUnit", _DelegationInfo.ClientUnit }
  7620. };
  7621. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7622. string missionLeaderJob = "";//负责人job
  7623. //int groupNumber = 0; //团人数
  7624. if (DeleClientList.Count > 0)
  7625. {
  7626. missionLeader = DeleClientList[0]?.Name ?? "";
  7627. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7628. }
  7629. dic.Add("MissionLeader", missionLeader); //团负责人
  7630. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7631. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7632. #region MyRegion
  7633. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7634. //{
  7635. // List<string> list = new List<string>();
  7636. // try
  7637. // {
  7638. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7639. // foreach (var item in spilitArr)
  7640. // {
  7641. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7642. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7643. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7644. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7645. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7646. // list.Add(depName);
  7647. // list.Add(arrName);
  7648. // }
  7649. // list = list.Distinct().ToList();
  7650. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7651. // }
  7652. // catch (Exception)
  7653. // {
  7654. // dic.Add("ReturnCode", "行程录入不正确!");
  7655. // }
  7656. //}
  7657. //else
  7658. //{
  7659. // dic.Add("ReturnCode", "未录入行程!");
  7660. //}
  7661. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7662. dic.Add("ReturnCode", string.Join("、", countrys));
  7663. #endregion
  7664. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7665. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7666. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7667. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7668. //{
  7669. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7670. // dic.Add("Day", sp.Days.ToString());
  7671. //}
  7672. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7673. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7674. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7675. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7676. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7677. //培训人员名单
  7678. int cultivateRowIndex = 7;
  7679. foreach (var item in DeleClientList)
  7680. {
  7681. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7682. builder.Write(item.Name);
  7683. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7684. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7685. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7686. string birthDay = "";
  7687. if (item.Birthday != null)
  7688. {
  7689. DateTime dt = Convert.ToDateTime(item.Birthday);
  7690. birthDay = $"{dt.Year}.{dt.Month}";
  7691. }
  7692. builder.Write(birthDay);
  7693. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7694. builder.Write(item.Company);
  7695. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7696. builder.Write(item.Job);
  7697. cultivateRowIndex++;
  7698. }
  7699. //删除多余行
  7700. //cultivateRowIndex -= 2;
  7701. int delRows = 10 + 7 - cultivateRowIndex;
  7702. if (delRows > 0)
  7703. {
  7704. for (int i = 0; i < delRows; i++)
  7705. {
  7706. table1.Rows.RemoveAt(cultivateRowIndex);
  7707. //cultivateRowIndex++;
  7708. }
  7709. }
  7710. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7711. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7712. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7713. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7714. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7715. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7716. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7717. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7718. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7719. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7720. //其他费用
  7721. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7722. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7723. //其他费用合计
  7724. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7725. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7726. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7727. //公务舱合计
  7728. //国际旅费
  7729. //string outsideJJ = "";
  7730. //string allPriceJJ = "";
  7731. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7732. {
  7733. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7734. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7735. }
  7736. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7737. {
  7738. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7739. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7740. }
  7741. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7742. {
  7743. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7744. dic.Add("AirFeeTotal", airFeeTotalStr);
  7745. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7746. dic.Add("FeeTotal", feeTotalStr);
  7747. }
  7748. foreach (var key in dic.Keys)
  7749. {
  7750. builder.MoveToBookmark(key);
  7751. builder.Write(dic[key]);
  7752. }
  7753. //模板文件名
  7754. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7755. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7756. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7757. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7758. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7759. }
  7760. }
  7761. else if (dto.ExportType == 2) //表格
  7762. {
  7763. //利用键值对存放数据
  7764. Dictionary<string, string> dic = new Dictionary<string, string>();
  7765. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7766. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7767. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7768. dic.Add("Day", sp.Days.ToString());
  7769. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7770. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7771. {
  7772. //获取模板
  7773. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7774. //载入模板
  7775. var doc = new Document(tempPath);
  7776. var builder = new DocumentBuilder(doc);
  7777. dic.Add("TeamName", _DelegationInfo.TeamName);
  7778. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7779. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7780. string missionLeaderName = "",
  7781. missionLeaderJob = "";
  7782. if (DeleClientList.Count > 0)
  7783. {
  7784. missionLeaderName = DeleClientList[0].Name;
  7785. missionLeaderJob = DeleClientList[0].Job;
  7786. }
  7787. dic.Add("MissionLeaderName", missionLeaderName);
  7788. dic.Add("MissionLeaderJob", missionLeaderJob);
  7789. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7790. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7791. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7792. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7793. int rowCount = 10;//总人数行
  7794. int startRowIndex = 7; //起始行
  7795. for (int i = 0; i < DeleClientList.Count; i++)
  7796. {
  7797. builder.MoveToCell(0, startRowIndex, 0, 0);
  7798. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7799. builder.MoveToCell(0, startRowIndex, 1, 0);
  7800. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7801. builder.Write(sex);//性别
  7802. builder.MoveToCell(0, startRowIndex, 2, 0);
  7803. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7804. builder.MoveToCell(0, startRowIndex, 3, 0);
  7805. builder.Write(DeleClientList[i].Company);//工作单位
  7806. builder.MoveToCell(0, startRowIndex, 4, 0);
  7807. builder.Write(DeleClientList[i].Job);//职务及级别
  7808. builder.MoveToCell(0, startRowIndex, 5, 0);
  7809. builder.Write("");//人员属性
  7810. builder.MoveToCell(0, startRowIndex, 6, 0);
  7811. builder.Write("");//上次出国时间
  7812. startRowIndex++;
  7813. }
  7814. int nullRow = rowCount - DeleClientList.Count;//空行
  7815. for (int i = 0; i < nullRow; i++)
  7816. {
  7817. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7818. }
  7819. foreach (var key in dic.Keys)
  7820. {
  7821. builder.MoveToBookmark(key);
  7822. builder.Write(dic[key]);
  7823. }
  7824. //模板文件名
  7825. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7826. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7827. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7828. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7829. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7830. }
  7831. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7832. {
  7833. //获取模板
  7834. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7835. //载入模板
  7836. var doc = new Document(tempPath);
  7837. var builder = new DocumentBuilder(doc);
  7838. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7839. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7840. dic.Add("Names", Names);
  7841. int accommodationRows = 12;
  7842. //int foodandotherRows = 12;
  7843. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7844. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7845. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7846. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7847. int accommodationStartIndex = 6;
  7848. decimal dac1totalPrice = 0.00M;
  7849. foreach (var dac in dac1)
  7850. {
  7851. if (dac.SubTotal == 0)
  7852. {
  7853. continue;
  7854. }
  7855. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7856. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7857. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7858. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7859. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7860. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7861. builder.Write(currency);//币种
  7862. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7863. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7864. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7865. builder.Write("");//人数
  7866. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7867. builder.Write("");//天数
  7868. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7869. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7870. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7871. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7872. builder.Write(rate.ToString("#0.0000"));//汇率
  7873. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7874. decimal rbmPrice = rate * dac.SubTotal;
  7875. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7876. accommodationStartIndex++;
  7877. dac1totalPrice += rbmPrice;
  7878. }
  7879. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7880. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7881. builder.Write("小计");
  7882. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7883. builder.Write(dac1totalPrice.ToString("#0.00"));
  7884. accommodationStartIndex++;
  7885. int nullRow = accommodationRows - dac1.Count;
  7886. //删除空行
  7887. //if (nullRow > 0)
  7888. //{
  7889. // int rowIndex = accommodationStartIndex;
  7890. // for (int i = 0; i < nullRow; i++)
  7891. // {
  7892. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7893. // row.Remove();
  7894. // rowIndex++;
  7895. // }
  7896. //}
  7897. if (dac2.Count == dac3.Count)//国家 币种 金额
  7898. {
  7899. for (int i = 0; i < dac2.Count; i++)
  7900. {
  7901. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7902. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7903. }
  7904. }
  7905. int foodandotherStartIndex = 19;//
  7906. decimal dac2totalPrice = 0.00M;
  7907. foreach (var dac in dac2)
  7908. {
  7909. if (dac.SubTotal == 0)
  7910. {
  7911. continue;
  7912. }
  7913. //foodandotherStartIndex = 12;
  7914. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7915. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7916. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7917. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7918. builder.Write(currency);//币种
  7919. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7920. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7921. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7922. builder.Write("");//人数
  7923. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7924. builder.Write("");//天数
  7925. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7926. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7927. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7928. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7929. builder.Write(rate.ToString("#0.0000"));//汇率
  7930. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7931. decimal rbmPrice = rate * dac.SubTotal;
  7932. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7933. foodandotherStartIndex++;
  7934. dac2totalPrice += rbmPrice;
  7935. }
  7936. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7937. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7938. //删除空行
  7939. //if (dac2.Count < foodandotherRows)
  7940. //{
  7941. // while (table2.Rows.Count > dac2.Count)
  7942. // {
  7943. // table2.Rows.RemoveAt(dac2.Count);
  7944. // }
  7945. //}
  7946. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7947. string otherFeeStr = "";
  7948. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7949. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7950. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7951. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7952. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7953. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7954. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7955. foreach (var otherInfo in dac5)
  7956. {
  7957. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7958. }
  7959. #endregion
  7960. if (otherFeeStr.Length > 0)
  7961. {
  7962. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7963. otherFeeStr = $"({otherFeeStr})";
  7964. dic.Add("OtherFeeStr", otherFeeStr);
  7965. }
  7966. foreach (var key in dic.Keys)
  7967. {
  7968. builder.MoveToBookmark(key);
  7969. builder.Write(dic[key]);
  7970. }
  7971. //模板文件名
  7972. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7973. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7974. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7975. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7976. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7977. }
  7978. }
  7979. else if (dto.ExportType == 3)
  7980. {
  7981. if (dto.SubTypeId == 1) //团组成员名单
  7982. {
  7983. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7984. //获取模板
  7985. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7986. //载入模板
  7987. var doc = new Document(tempPath);
  7988. var builder = new DocumentBuilder(doc);
  7989. //获取word里所有表格
  7990. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7991. //获取所填表格的序数
  7992. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7993. var rowStart = tableOne.Rows[0]; //获取第1行
  7994. //循环赋值
  7995. for (int i = 0; i < DeleClientList.Count; i++)
  7996. {
  7997. builder.MoveToCell(0, i + 1, 0, 0);
  7998. builder.Write(DeleClientList[i].Name);
  7999. builder.MoveToCell(0, i + 1, 1, 0);
  8000. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8001. builder.Write(sex);
  8002. builder.MoveToCell(0, i + 1, 2, 0);
  8003. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  8004. builder.MoveToCell(0, i + 1, 3, 0);
  8005. builder.Write(DeleClientList[i].Company);
  8006. builder.MoveToCell(0, i + 1, 4, 0);
  8007. builder.Write(DeleClientList[i].Job);
  8008. }
  8009. //删除多余行
  8010. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  8011. {
  8012. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  8013. }
  8014. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  8015. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  8016. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  8017. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8018. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8019. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8020. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8021. }
  8022. }
  8023. return Ok(JsonView(400, "操作失败!", ""));
  8024. }
  8025. catch (Exception ex)
  8026. {
  8027. return Ok(JsonView(400, ex.Message, ""));
  8028. }
  8029. }
  8030. /// <summary>
  8031. /// 获取三公费用标准city
  8032. /// </summary>
  8033. /// <param name="placeData"></param>
  8034. /// <param name="nationalTravelFeeId"></param>
  8035. /// <returns></returns>
  8036. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8037. {
  8038. string _city = string.Empty;
  8039. if (placeData.Count < 1) return _city;
  8040. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8041. if (data == null) return _city;
  8042. string country = data.Country;
  8043. string city = data.City;
  8044. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8045. else _city = city;
  8046. return _city;
  8047. }
  8048. ///// <summary>
  8049. ///// 团组模块 - 出入境费用 - 明细表导出
  8050. ///// </summary>
  8051. ///// <returns></returns>
  8052. //[HttpPost]
  8053. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8054. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  8055. //{
  8056. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  8057. // if (data.Code != 0)
  8058. // {
  8059. // return Ok(JsonView(false, data.Msg));
  8060. // }
  8061. // return Ok(JsonView(true, data.Msg, data.Data));
  8062. //}
  8063. /// <summary>
  8064. /// 团组模块 - 出入境费用 - 一键清空
  8065. /// </summary>
  8066. /// <returns></returns>
  8067. [HttpPost]
  8068. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8070. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  8071. {
  8072. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  8073. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8074. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8075. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  8076. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8077. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  8078. .SetColumns(x => new Grp_DayOtherPrice
  8079. {
  8080. IsDel = 1,
  8081. DeleteUserId = dto.UserId,
  8082. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8083. })
  8084. .ExecuteCommandAsync();
  8085. if (_view.Code == 0)
  8086. {
  8087. return Ok(JsonView(true, "操作成功"));
  8088. }
  8089. return Ok(JsonView(false, "操作失败"));
  8090. }
  8091. /// <summary>
  8092. /// 团组模块 - 出入境费用 - 子项删除
  8093. /// </summary>
  8094. /// <returns></returns>
  8095. [HttpPost]
  8096. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8098. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  8099. {
  8100. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8101. if (data.Code != 0)
  8102. {
  8103. return Ok(JsonView(false, data.Msg));
  8104. }
  8105. return Ok(JsonView(true, "操作成功!", data.Data));
  8106. }
  8107. /// <summary>
  8108. /// 删除三公其他费用
  8109. /// </summary>
  8110. /// <param name="dto"></param>
  8111. /// <returns></returns>
  8112. [HttpPost]
  8113. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8114. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  8115. {
  8116. var jw = JsonView(false, "删除失败!");
  8117. var data = new Grp_DayOtherPrice()
  8118. {
  8119. Id = dto.Id,
  8120. IsDel = 1,
  8121. DeleteUserId = dto.DeleteUserId,
  8122. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8123. };
  8124. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8125. if (del > 0)
  8126. {
  8127. jw.Code = 200;
  8128. jw.Msg = "删除成功!";
  8129. }
  8130. return Ok(jw);
  8131. }
  8132. /// <summary>
  8133. /// 团组模块 - 出入境国家费用标准 List
  8134. /// </summary>
  8135. /// <returns></returns>
  8136. [HttpPost]
  8137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8138. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  8139. {
  8140. int provinceId = dto.ProvinceId;
  8141. if (provinceId < 1) provinceId = 122; //默认四川省数据
  8142. var nftData = await _sqlSugar
  8143. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  8144. JoinType.Left, ntf.Currency == sd1.Id,
  8145. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8146. JoinType.Left, ntf.ProvinceId == c.Id
  8147. ))
  8148. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8149. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  8150. {
  8151. Id = ntf.Id,
  8152. ProvinceId = ntf.ProvinceId,
  8153. ProvinceName = c.Name_CN,
  8154. Continent = ntf.Continent,
  8155. Country = ntf.Country,
  8156. City = ntf.City,
  8157. Currency = ntf.Currency,
  8158. CurrencyCode = sd1.Name,
  8159. CurrencyName = sd1.Remark,
  8160. RoomCost = ntf.RoomCost,
  8161. FoodCost = ntf.FoodCost,
  8162. PublicCost = ntf.PublicCost,
  8163. LastUpdateUserId = ntf.LastUpdateUserId,
  8164. LastUpdateUserName = u.CnName,
  8165. LastUpdateTime = ntf.LastUpdateTime
  8166. })
  8167. .ToListAsync();
  8168. return Ok(JsonView(true, "查询成功!", nftData));
  8169. }
  8170. /// <summary>
  8171. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  8172. /// </summary>
  8173. /// <returns></returns>
  8174. [HttpPost]
  8175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8176. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  8177. {
  8178. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  8179. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  8180. List<string> countryData = new List<string>();
  8181. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  8182. countryData = countryData.Distinct().ToList();
  8183. List<dynamic> dataSource = new List<dynamic>();
  8184. foreach (var item in countryData)
  8185. {
  8186. var cityData1 = new List<string>();
  8187. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  8188. var countryData2 = new
  8189. {
  8190. CountryName = item,
  8191. CityData = cityData1
  8192. };
  8193. if (!dataSource.Contains(countryData2))
  8194. {
  8195. dataSource.Add(countryData2);
  8196. }
  8197. }
  8198. return Ok(JsonView(true, "查询成功!", dataSource));
  8199. }
  8200. /// <summary>
  8201. /// 团组模块 - 出入境国家费用标准 Page List
  8202. /// </summary>
  8203. /// <returns></returns>
  8204. [HttpPost]
  8205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8206. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  8207. {
  8208. int portId = dto.PortType,
  8209. pageIndex = dto.PageIndex,
  8210. pageSize = dto.PageSize;
  8211. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8212. if (pageIndex == 0) pageIndex = 1;
  8213. if (pageSize == 0) pageSize = 10;
  8214. RefAsync<int> total = 0;
  8215. var nationalTravelFeeData = await _sqlSugar
  8216. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  8217. JoinType.Left, ntf.Currency == sd1.Id,
  8218. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8219. JoinType.Left, ntf.ProvinceId == sd2.Id
  8220. ))
  8221. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  8222. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  8223. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  8224. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  8225. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  8226. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  8227. {
  8228. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  8229. Id = ntf.Id,
  8230. ProvinceId = ntf.ProvinceId,
  8231. ProvinceName = sd2.Name_CN,
  8232. Continent = ntf.Continent,
  8233. Country = ntf.Country,
  8234. City = ntf.City,
  8235. Currency = ntf.Currency,
  8236. CurrencyCode = sd1.Name,
  8237. CurrencyName = sd1.Remark,
  8238. RoomCost = ntf.RoomCost,
  8239. FoodCost = ntf.FoodCost,
  8240. PublicCost = ntf.PublicCost,
  8241. LastUpdateUserId = ntf.LastUpdateUserId,
  8242. LastUpdateUserName = u.CnName,
  8243. LastUpdateTime = ntf.LastUpdateTime,
  8244. Remark = ntf.Remark
  8245. })
  8246. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8247. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  8248. }
  8249. /// <summary>
  8250. /// 团组模块 - 出入境国家费用标准 根据城市查询
  8251. /// </summary>
  8252. /// <returns></returns>
  8253. [HttpPost]
  8254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8255. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  8256. {
  8257. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  8258. int portId = dto.PortType;
  8259. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8260. string whereSql = string.Empty;
  8261. if (!string.IsNullOrEmpty(dto.Country))
  8262. {
  8263. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  8264. }
  8265. if (!string.IsNullOrEmpty(dto.City))
  8266. {
  8267. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  8268. }
  8269. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  8270. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  8271. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  8272. From Grp_NationalTravelFee gntf
  8273. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  8274. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  8275. Where gntf.Isdel = 0 {0} ", whereSql);
  8276. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  8277. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  8278. }
  8279. /// <summary>
  8280. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  8281. /// </summary>
  8282. /// <returns></returns>
  8283. [HttpPost]
  8284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8285. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  8286. {
  8287. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  8288. }
  8289. /// <summary>
  8290. /// 团组模块 - 出入境国家费用标准 - Del
  8291. /// </summary>
  8292. /// <returns></returns>
  8293. [HttpPost]
  8294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8295. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  8296. {
  8297. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  8298. {
  8299. Id = dto.Id,
  8300. DeleteUserId = dto.DeleteUserId,
  8301. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8302. IsDel = 1
  8303. };
  8304. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  8305. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  8306. .WhereColumns(it => new { it.Id })
  8307. .ExecuteCommandAsync();
  8308. if (delStatus <= 0)
  8309. {
  8310. return Ok(JsonView(false, "删除失败!"));
  8311. }
  8312. return Ok(JsonView(true, "操作成功!"));
  8313. }
  8314. /// <summary>
  8315. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  8316. /// 注:Get 请求Headers 加 Token
  8317. /// </summary>
  8318. /// <param name="groupId"></param>
  8319. /// <returns></returns>
  8320. [HttpGet("{groupId}")]
  8321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8322. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  8323. {
  8324. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8325. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  8326. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  8327. data.ForEach(x =>
  8328. {
  8329. x.CreateUserId = _currUserInfo.UserId;
  8330. });
  8331. if (data.Any())
  8332. {
  8333. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  8334. if (add > 0)
  8335. {
  8336. return Ok(JsonView(true, "操作成功!"));
  8337. }
  8338. }
  8339. return Ok(JsonView(false, "未操作!"));
  8340. }
  8341. #endregion
  8342. #region 团组经理模块 出入境费用-草稿
  8343. /// <summary>
  8344. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  8345. /// </summary>
  8346. /// <returns></returns>
  8347. [HttpGet]
  8348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8349. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8350. {
  8351. var provData = await _groupRepository.ProvinceBasicSource();
  8352. return Ok(JsonView(true, "查询成功!", provData));
  8353. }
  8354. /// <summary>
  8355. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8356. /// </summary>
  8357. /// <returns></returns>
  8358. [HttpGet("{provinceId}")]
  8359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8360. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8361. {
  8362. //验证城市归属并给默认值
  8363. if (provinceId < 1) provinceId = 122;
  8364. /*
  8365. * 122 四川
  8366. * 108 贵州
  8367. * 103 重庆
  8368. * 132 云南
  8369. */
  8370. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8371. return Ok(JsonView(true, "查询成功!", new
  8372. {
  8373. WordTypeData = wordTypeData,
  8374. ExcelTypeData = excelTypeData,
  8375. }));
  8376. }
  8377. /// <summary>
  8378. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8379. /// </summary>
  8380. /// <returns></returns>
  8381. [HttpPost]
  8382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8383. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8384. {
  8385. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8386. .Where(x => x.IsDel == 0)
  8387. .OrderByDescending(x => x.CreateTime)
  8388. .Select(x => new { x.Id, x.DraftName })
  8389. .ToListAsync();
  8390. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8391. //SetDataInfoView
  8392. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8393. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8394. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8395. int provinceId = dto.ProvinceId;
  8396. if (provinceId < 1) provinceId = 122;
  8397. /*
  8398. * 122 四川
  8399. * 108 贵州
  8400. * 103 重庆
  8401. * 132 云南
  8402. */
  8403. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8404. //默认币种显示
  8405. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8406. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8407. return Ok(JsonView(true, "查询成功!", new
  8408. {
  8409. DraftNameDatas = draftNameDatas,
  8410. CurrencyData = _CurrencyData,
  8411. WordTypeData = wordTypeData,
  8412. ExcelTypeData = excelTypeData,
  8413. CurrencyInit = _currencyInfos,
  8414. ViewPermissionData = viewPermissionData
  8415. }));
  8416. }
  8417. /// <summary>
  8418. /// 团组模块 - 出入境费用-草稿
  8419. /// 实时汇率 tips
  8420. /// 机票费用 tips
  8421. /// </summary>
  8422. /// <returns></returns>
  8423. [HttpPost]
  8424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8425. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8426. {
  8427. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8428. return Ok(JsonView(true, "查询成功!", new
  8429. {
  8430. //GroupNameData = groupNameData.Data,
  8431. //visaData = visaData.Data,
  8432. //airData = airData.Data,
  8433. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8434. }));
  8435. }
  8436. /// <summary>
  8437. /// 团组模块 - 出入境费用-草稿
  8438. /// 签证费用 tips
  8439. /// </summary>
  8440. /// <returns></returns>
  8441. [HttpPost]
  8442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8443. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8444. {
  8445. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8446. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8447. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8448. .Select(x => x.NationalTravelFeeId)
  8449. .Distinct()
  8450. .ToListAsync();
  8451. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8452. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8453. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8454. .Select(x => x.Country)
  8455. .Distinct()
  8456. .ToArrayAsync();
  8457. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8458. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8459. return Ok(JsonView(true, "查询成功!", new
  8460. {
  8461. totalAmt,
  8462. remark
  8463. }));
  8464. }
  8465. /// <summary>
  8466. /// 团组模块 - 出入境费用-草稿 - Info
  8467. /// </summary>
  8468. /// <returns></returns>
  8469. [HttpPost]
  8470. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8472. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8473. {
  8474. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8475. }
  8476. /// <summary>
  8477. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8478. /// </summary>
  8479. /// <returns></returns>
  8480. [HttpPost]
  8481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8482. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8483. {
  8484. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8485. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8486. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8487. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8488. foreach (var userId in dto.UserIds)
  8489. {
  8490. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8491. }
  8492. if (permissions.Any())
  8493. {
  8494. _sqlSugar.BeginTran();
  8495. try
  8496. {
  8497. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8498. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8499. if (result < 1)
  8500. {
  8501. _sqlSugar.RollbackTran();
  8502. return Ok(JsonView(false));
  8503. }
  8504. }
  8505. catch (Exception ex)
  8506. {
  8507. _sqlSugar.RollbackTran();
  8508. return Ok(JsonView(false, ex.Message));
  8509. }
  8510. _sqlSugar.CommitTran();
  8511. return Ok(JsonView(true));
  8512. }
  8513. return Ok(JsonView(false));
  8514. }
  8515. /// <summary>
  8516. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8517. /// </summary>
  8518. /// <returns></returns>
  8519. [HttpPost]
  8520. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8522. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8523. {
  8524. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8525. if (data.Code != 0)
  8526. {
  8527. return Ok(JsonView(false, data.Msg));
  8528. }
  8529. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8530. //汇率信息记录
  8531. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8532. return Ok(JsonView(true, data.Msg, data.Data));
  8533. }
  8534. /// <summary>
  8535. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8536. /// </summary>
  8537. /// <param name="dto"></param>
  8538. /// <returns></returns>
  8539. [HttpPost]
  8540. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8542. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8543. {
  8544. try
  8545. {
  8546. var id = dto.Id;
  8547. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8548. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8549. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8550. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8551. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8552. 3 团组成员名单 1 团组成员名单", ""));
  8553. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8554. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8555. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8556. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8557. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8558. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8559. //数据源
  8560. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8561. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8562. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8563. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8564. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8565. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8566. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8567. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8568. .Select((x, a, b) => new
  8569. {
  8570. x.Index,
  8571. itemName = a.Name,
  8572. CurrencyStr = b.Name,
  8573. x.Cost,
  8574. x.SubTotal,
  8575. x.Remark
  8576. })
  8577. .OrderBy((x) => x.Index)
  8578. .ToList(); //其他款项费用
  8579. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8580. var peiceItemCurrencys = new List<string>();
  8581. if (_DayAndCosts.Any())
  8582. {
  8583. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8584. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8585. }
  8586. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8587. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8588. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8589. {
  8590. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8591. }
  8592. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8593. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8594. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8595. if (dto.ExportType == 1) //明细表
  8596. {
  8597. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8598. {
  8599. //获取模板
  8600. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8601. //载入模板
  8602. Document doc = new Document(tempPath);
  8603. DocumentBuilder builder = new DocumentBuilder(doc);
  8604. //利用键值对存放数据
  8605. Dictionary<string, string> dic = new Dictionary<string, string>();
  8606. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8607. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8608. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8609. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8610. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8611. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8612. //境内费用(其他费用)
  8613. if (_EnterExitCosts.ChoiceOne == 1)
  8614. {
  8615. string row1_1 = "";
  8616. if (_EnterExitCosts.Visa > 0)
  8617. {
  8618. //insidePayTotal += _EnterExitCosts.Visa;
  8619. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8620. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8621. //{
  8622. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8623. //}
  8624. }
  8625. string row1_2 = "";
  8626. if (_EnterExitCosts.YiMiao > 0)
  8627. {
  8628. //insidePayTotal += _EnterExitCosts.YiMiao;
  8629. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8630. }
  8631. if (_EnterExitCosts.HeSuan > 0)
  8632. {
  8633. //insidePayTotal += _EnterExitCosts.HeSuan;
  8634. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8635. }
  8636. if (_EnterExitCosts.Service > 0)
  8637. {
  8638. //insidePayTotal += _EnterExitCosts.Service;
  8639. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8640. }
  8641. string row1_3 = "";
  8642. if (_EnterExitCosts.Safe > 0)
  8643. {
  8644. //insidePayTotal += _EnterExitCosts.Safe;
  8645. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8646. }
  8647. if (_EnterExitCosts.Ticket > 0)
  8648. {
  8649. //insidePayTotal += _EnterExitCosts.Ticket;
  8650. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8651. }
  8652. string row1 = "";
  8653. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8654. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8655. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8656. row1 += $"备注:{_EnterExitCosts.Remark}";
  8657. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8658. dic.Add("Row1Str", row1);
  8659. }
  8660. string airTotalStr = string.Empty,
  8661. airPriceStr = string.Empty;
  8662. //经济舱
  8663. if (_EnterExitCosts.SumJJC == 1)
  8664. {
  8665. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8666. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8667. }
  8668. //公务舱
  8669. if (_EnterExitCosts.SumGWC == 1)
  8670. {
  8671. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8672. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8673. }
  8674. //头等舱
  8675. if (_EnterExitCosts.SumTDC == 1)
  8676. {
  8677. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8678. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8679. }
  8680. //汇率描述
  8681. string rateStr = "";
  8682. if (peiceItemCurrencyInfos.Any())
  8683. {
  8684. rateStr = "\r\n汇率描述:";
  8685. foreach (var item in peiceItemCurrencyInfos)
  8686. {
  8687. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8688. }
  8689. }
  8690. string twoItemRemark = "备注:";
  8691. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8692. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8693. dic.Add("AirTotalStr", airTotalStr);
  8694. dic.Add("AirPriceStr", airPriceStr);
  8695. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8696. dic.Add("TwoItemRemark", twoItemRemark);
  8697. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8698. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8699. int table1Row = 0,
  8700. table2Row = 0,
  8701. table3Row = 0,
  8702. table4Row = 0,
  8703. table5Row = 0;
  8704. //住宿费
  8705. if (_EnterExitCosts.ChoiceThree == 1)
  8706. {
  8707. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8708. table1Row = dac1.Count;
  8709. #region 填充word表格内容
  8710. for (int i = 0; i < dac1.Count; i++)
  8711. {
  8712. var dac = dac1[i];
  8713. if (dac == null) continue;
  8714. builder.MoveToCell(0, i, 0, 0);
  8715. builder.Write("第" + dac.Days.ToString() + "晚:");
  8716. builder.MoveToCell(0, i, 1, 0);
  8717. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8718. //builder.Write(dac.Place == null ? "" : dac.Place);
  8719. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8720. builder.MoveToCell(0, i, 2, 0);
  8721. builder.Write("费用标准:");
  8722. string curr = "";
  8723. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8724. if (currData != null)
  8725. {
  8726. curr = currData.Name;
  8727. }
  8728. builder.MoveToCell(0, i, 3, 0);
  8729. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8730. builder.MoveToCell(0, i, 4, 0);
  8731. builder.Write("费用小计:");
  8732. builder.MoveToCell(0, i, 5, 0);
  8733. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8734. }
  8735. #endregion
  8736. }
  8737. else dic.Add("SubZS", "0.00");
  8738. //删除多余行
  8739. while (table1.Rows.Count > table1Row)
  8740. {
  8741. table1.Rows.RemoveAt(table1Row);
  8742. }
  8743. //伙食费
  8744. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8745. if (_EnterExitCosts.ChoiceFour == 1)
  8746. {
  8747. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8748. table2Row = dac2.Count;
  8749. #region 填充word表格内容
  8750. for (int i = 0; i < dac2.Count; i++)
  8751. {
  8752. var dac = dac2[i];
  8753. if (dac == null) continue;
  8754. builder.MoveToCell(1, i, 0, 0);
  8755. builder.Write("第" + dac.Days.ToString() + "天:");
  8756. builder.MoveToCell(1, i, 1, 0);
  8757. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8758. builder.MoveToCell(1, i, 2, 0);
  8759. builder.Write("费用标准:");
  8760. string curr = "";
  8761. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8762. if (currData != null)
  8763. {
  8764. curr = currData.Name;
  8765. }
  8766. builder.MoveToCell(1, i, 3, 0);
  8767. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8768. builder.MoveToCell(1, i, 4, 0);
  8769. builder.Write("费用小计:");
  8770. builder.MoveToCell(1, i, 5, 0);
  8771. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8772. }
  8773. #endregion
  8774. }
  8775. else dic.Add("SubHS", "0.00");
  8776. //删除多余行
  8777. while (table2.Rows.Count > table2Row)
  8778. {
  8779. table2.Rows.RemoveAt(table2Row);
  8780. }
  8781. //公杂费
  8782. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8783. if (_EnterExitCosts.ChoiceFive == 1)
  8784. {
  8785. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8786. table3Row = dac3.Count;
  8787. #region 填充word表格内容
  8788. for (int i = 0; i < dac3.Count; i++)
  8789. {
  8790. var dac = dac3[i];
  8791. if (dac == null) continue;
  8792. builder.MoveToCell(2, i, 0, 0);
  8793. builder.Write("第" + dac.Days.ToString() + "天:");
  8794. builder.MoveToCell(2, i, 1, 0);
  8795. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8796. builder.MoveToCell(2, i, 2, 0);
  8797. builder.Write("费用标准:");
  8798. string curr = "";
  8799. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8800. if (currData != null)
  8801. {
  8802. curr = currData.Name;
  8803. }
  8804. builder.MoveToCell(2, i, 3, 0);
  8805. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8806. builder.MoveToCell(2, i, 4, 0);
  8807. builder.Write("费用小计:");
  8808. builder.MoveToCell(2, i, 5, 0);
  8809. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8810. }
  8811. //删除多余行
  8812. while (table3.Rows.Count > table3Row)
  8813. {
  8814. table3.Rows.RemoveAt(table3Row);
  8815. }
  8816. #endregion
  8817. }
  8818. else dic.Add("SubGZF", "0.00");
  8819. //删除多余行
  8820. while (table3.Rows.Count > table3Row)
  8821. {
  8822. table3.Rows.RemoveAt(table3Row);
  8823. }
  8824. //培训费
  8825. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8826. if (_EnterExitCosts.ChoiceSix == 1)
  8827. {
  8828. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8829. dic.Add("SubPX", pxStr);
  8830. table4Row = dac4.Count;
  8831. #region 填充word表格内容
  8832. for (int i = 0; i < dac4.Count; i++)
  8833. {
  8834. var dac = dac4[i];
  8835. if (dac == null) continue;
  8836. builder.MoveToCell(3, i, 0, 0);
  8837. builder.Write("第" + dac.Days.ToString() + "天:");
  8838. builder.MoveToCell(3, i, 1, 0);
  8839. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8840. builder.MoveToCell(3, i, 2, 0);
  8841. builder.Write("费用标准:");
  8842. string curr = "";
  8843. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8844. if (currData != null)
  8845. {
  8846. curr = currData.Name;
  8847. }
  8848. builder.MoveToCell(3, i, 3, 0);
  8849. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8850. builder.MoveToCell(3, i, 4, 0);
  8851. builder.Write("费用小计:");
  8852. builder.MoveToCell(3, i, 5, 0);
  8853. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8854. }
  8855. #endregion
  8856. }
  8857. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8858. //删除多余行
  8859. while (table4.Rows.Count > table4Row)
  8860. {
  8861. table4.Rows.RemoveAt(table4Row);
  8862. }
  8863. //其他费用
  8864. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8865. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8866. {
  8867. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8868. dic.Add("titleQi", qtStr);
  8869. table5Row = dac5.Count;
  8870. #region 填充word表格内容
  8871. for (int i = 0; i < dac5.Count; i++)
  8872. {
  8873. var dac = dac5[i];
  8874. if (dac == null) continue;
  8875. builder.MoveToCell(4, i, 0, 0);
  8876. builder.Write("第" + dac.Index.ToString() + "项:");
  8877. builder.MoveToCell(4, i, 1, 0);
  8878. builder.Write(dac.itemName);
  8879. builder.MoveToCell(4, i, 2, 0);
  8880. builder.Write("费用标准:");
  8881. builder.MoveToCell(4, i, 3, 0);
  8882. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8883. builder.MoveToCell(4, i, 4, 0);
  8884. builder.Write("费用小计:");
  8885. builder.MoveToCell(4, i, 5, 0);
  8886. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8887. builder.MoveToCell(4, i, 6, 0);
  8888. builder.Write("备注:");
  8889. builder.MoveToCell(4, i, 7, 0);
  8890. builder.Write(dac.Remark);
  8891. }
  8892. #endregion
  8893. }
  8894. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8895. //删除多余行
  8896. while (table5.Rows.Count > table5Row)
  8897. {
  8898. table5.Rows.RemoveAt(table5Row);
  8899. }
  8900. //加上其他费用
  8901. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8902. decimal subJJC = 0.00M,
  8903. subGWC = 0.00M,
  8904. subTDC = 0.00M;
  8905. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8906. string totalLabel = string.Format("全部费用总计:");
  8907. //经济舱
  8908. if (_EnterExitCosts.SumJJC == 1)
  8909. {
  8910. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8911. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8912. }
  8913. //公务舱
  8914. if (_EnterExitCosts.SumGWC == 1)
  8915. {
  8916. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8917. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8918. }
  8919. //头等舱
  8920. if (_EnterExitCosts.SumTDC == 1)
  8921. {
  8922. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8923. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8924. }
  8925. //TotalLabel
  8926. dic.Add("TotalLabel", totalLabel);
  8927. #region 填充word模板书签内容
  8928. foreach (var key in dic.Keys)
  8929. {
  8930. Bookmark bookmark = doc.Range.Bookmarks[key];
  8931. if (bookmark != null)
  8932. {
  8933. builder.MoveToBookmark(key);
  8934. builder.Write(dic[key]);
  8935. }
  8936. }
  8937. #endregion
  8938. //文件名
  8939. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8940. strFileName = CommonFun.ValidFileName(strFileName);
  8941. AsposeHelper.removewatermark_v2180();
  8942. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8943. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8944. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8945. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8946. }
  8947. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8948. {
  8949. //获取模板
  8950. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8951. //载入模板
  8952. Document doc = new Document(tempPath);
  8953. DocumentBuilder builder = new DocumentBuilder(doc);
  8954. Dictionary<string, string> dic = new Dictionary<string, string>();
  8955. string returnCodeLabel = string.Empty;
  8956. if (nationalTravelFeeData.Any())
  8957. {
  8958. List<string> list = new List<string>();
  8959. foreach (var item in nationalTravelFeeData)
  8960. {
  8961. list.Add($"{item.Country}({item.City})");
  8962. }
  8963. list = list.Distinct().ToList();
  8964. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8965. }
  8966. var countryLabel = string.Empty;
  8967. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8968. if (countryData.Any())
  8969. {
  8970. countryLabel = string.Join("、", countryData);
  8971. }
  8972. dic.Add("ReturnCodeAir", returnCodeLabel);
  8973. dic.Add("VisitStartDate", "-");
  8974. dic.Add("VisitEndDate", "-");
  8975. dic.Add("Day", "-");
  8976. dic.Add("VisitCountry", countryLabel);
  8977. dic.Add("ClientUnit", "-");
  8978. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8979. //dic.Add("Names", Names);
  8980. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8981. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8982. decimal dac1totalPrice = 0.00M;
  8983. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8984. foreach (var dac in dac1)
  8985. {
  8986. if (dac.SubTotal == 0.00M)
  8987. {
  8988. continue;
  8989. }
  8990. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8991. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8992. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8993. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8994. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8995. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8996. builder.Write(currency);//币种
  8997. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8998. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8999. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  9000. builder.Write("");//人数
  9001. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  9002. builder.Write("");//天数
  9003. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  9004. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9005. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  9006. decimal rate = 0.00M;
  9007. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9008. builder.Write(rate.ToString("#0.0000"));//汇率
  9009. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  9010. decimal rbmPrice = dac.SubTotal;
  9011. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9012. accommodationStartIndex++;
  9013. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9014. }
  9015. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9016. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  9017. {
  9018. table1.Rows.RemoveAt(i - 1);
  9019. foodandotherStartIndex--;
  9020. }
  9021. if (dac2.Count == dac3.Count)//国家 币种 金额
  9022. {
  9023. for (int i = 0; i < dac2.Count; i++)
  9024. {
  9025. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9026. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9027. }
  9028. }
  9029. decimal dac2totalPrice = 0.00M;
  9030. foreach (var dac in dac2)
  9031. {
  9032. if (dac.SubTotal == 0)
  9033. {
  9034. continue;
  9035. }
  9036. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  9037. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9038. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  9039. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9040. builder.Write(currency);//币种
  9041. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  9042. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9043. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  9044. builder.Write("");//人数
  9045. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  9046. builder.Write("");//天数
  9047. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  9048. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9049. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  9050. decimal rate = 0.00M;
  9051. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9052. builder.Write(rate.ToString("#0.0000"));//汇率
  9053. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  9054. decimal rbmPrice = dac.SubTotal;
  9055. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9056. foodandotherStartIndex++;
  9057. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9058. }
  9059. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  9060. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  9061. {
  9062. table1.Rows.RemoveAt(i - 1);
  9063. }
  9064. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9065. string otherFeeStr = "";
  9066. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  9067. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  9068. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  9069. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  9070. foreach (var otherInfo in dac5)
  9071. {
  9072. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  9073. }
  9074. #endregion
  9075. if (otherFeeStr.Length > 0)
  9076. {
  9077. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  9078. otherFeeStr = $"({otherFeeStr})";
  9079. dic.Add("OtherFeeStr", otherFeeStr);
  9080. }
  9081. //总计
  9082. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  9083. //国际旅费
  9084. string outsideAir = string.Empty;
  9085. string allPriceAir = string.Empty;
  9086. if (_EnterExitCosts.SumJJC == 1)
  9087. {
  9088. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9089. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  9090. }
  9091. if (_EnterExitCosts.SumGWC == 1)
  9092. {
  9093. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  9094. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9095. }
  9096. if (_EnterExitCosts.SumTDC == 1)
  9097. {
  9098. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  9099. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  9100. }
  9101. dic.Add("InTravelPrice", $"({outsideAir})");
  9102. dic.Add("FinalSumPrice", $"({allPriceAir})");
  9103. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  9104. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  9105. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  9106. foreach (var key in dic.Keys)
  9107. {
  9108. builder.MoveToBookmark(key);
  9109. builder.Write(dic[key]);
  9110. }
  9111. //模板文件名
  9112. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9113. strFileName = CommonFun.ValidFileName(strFileName);
  9114. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9115. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9116. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9117. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9118. }
  9119. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  9120. {
  9121. //获取模板
  9122. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  9123. //载入模板
  9124. WorkbookDesigner designer = new WorkbookDesigner();
  9125. designer.Workbook = new Workbook(tempPath);
  9126. Dictionary<string, string> dic = new Dictionary<string, string>();
  9127. string returnCodeLabel = string.Empty;
  9128. if (nationalTravelFeeData.Any())
  9129. {
  9130. List<string> list = new List<string>();
  9131. foreach (var item in nationalTravelFeeData)
  9132. {
  9133. list.Add($"{item.Country}({item.City})");
  9134. }
  9135. list = list.Distinct().ToList();
  9136. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9137. }
  9138. var countryLabel = string.Empty;
  9139. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9140. if (countryData.Any())
  9141. {
  9142. countryLabel = string.Join("、", countryData);
  9143. }
  9144. dic.Add("ReturnCodeAir", returnCodeLabel);
  9145. dic.Add("VisitStartDate", "-");
  9146. dic.Add("VisitEndDate", "-");
  9147. dic.Add("Day", "0");
  9148. dic.Add("VisitCountry", countryLabel);
  9149. dic.Add("ClientUnit", "-");
  9150. designer.SetDataSource("ClientUnit", "-");
  9151. designer.SetDataSource("VisitCountry", countryLabel);
  9152. designer.SetDataSource("Group", "-");
  9153. designer.SetDataSource("ClientUnitTitle", "-");
  9154. designer.SetDataSource("Name", "-");
  9155. designer.SetDataSource("VisitStartDate", "-");
  9156. designer.SetDataSource("Day", "0");
  9157. designer.SetDataSource("ReturnCode", returnCodeLabel);
  9158. designer.SetDataSource("ReturnCodeAir", "-");
  9159. int startIndex = 10;
  9160. const int startIndexcopy = 10;
  9161. if (dac2.Count == dac3.Count)//国家 币种 金额
  9162. {
  9163. for (int i = 0; i < dac2.Count; i++)
  9164. {
  9165. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9166. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9167. }
  9168. }
  9169. DataTable dtdac1 = new DataTable();
  9170. List<string> place = new List<string>();
  9171. dtdac1.Columns.AddRange(new DataColumn[] {
  9172. new DataColumn(){ ColumnName = "city"},
  9173. new DataColumn(){ ColumnName = "curr"},
  9174. new DataColumn(){ ColumnName = "criterion"},
  9175. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9176. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9177. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9178. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9179. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  9180. });
  9181. DataTable dtdac2 = new DataTable();
  9182. dtdac2.Columns.AddRange(new DataColumn[] {
  9183. new DataColumn(){ ColumnName = "city"},
  9184. new DataColumn(){ ColumnName = "curr"},
  9185. new DataColumn(){ ColumnName = "criterion"},
  9186. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9187. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9188. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9189. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9190. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  9191. });
  9192. dtdac1.TableName = "tb1";
  9193. dtdac2.TableName = "tb2";
  9194. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  9195. foreach (var item in dac1)
  9196. {
  9197. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9198. if (place.Contains(item.Place))
  9199. {
  9200. continue;
  9201. }
  9202. DataRow row = dtdac1.NewRow();
  9203. row["city"] = item.Place;
  9204. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9205. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9206. row["curr"] = currency;
  9207. row["rate"] = rate.ToString("#0.0000");
  9208. row["criterion"] = item.Cost.ToString("#0.00");
  9209. row["number"] = 1;
  9210. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9211. //row["costRMB"] = rbmPrice;
  9212. dtdac1.Rows.Add(row);
  9213. place.Add(item.Place);
  9214. }
  9215. place = new List<string>();
  9216. foreach (var item in dac2)
  9217. {
  9218. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9219. if (place.Contains(item.Place))
  9220. {
  9221. continue;
  9222. }
  9223. DataRow row = dtdac2.NewRow();
  9224. row["city"] = item.Place;
  9225. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9226. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9227. row["curr"] = currency;
  9228. row["rate"] = rate.ToString("#0.0000");
  9229. row["criterion"] = item.Cost.ToString("#0.00");
  9230. row["number"] = 1;
  9231. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9232. //row["cost"] = item.SubTotal;
  9233. //row["costRMB"] = rbmPrice;
  9234. dtdac2.Rows.Add(row);
  9235. place.Add(item.Place);
  9236. //dac2totalPrice += rbmPrice;
  9237. }
  9238. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  9239. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  9240. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9241. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  9242. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  9243. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  9244. string cell4Str1 = string.Empty;
  9245. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  9246. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  9247. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  9248. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  9249. string cellStr = $" 5.其他费用(";
  9250. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9251. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9252. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9253. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9254. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9255. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9256. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  9257. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  9258. foreach (var otherInfo in dac5)
  9259. {
  9260. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9261. }
  9262. #endregion
  9263. if (cellStr.Length > 8)
  9264. {
  9265. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  9266. }
  9267. cellStr += ")";
  9268. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  9269. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  9270. decimal pxFee = dac4.Sum(it => it.Cost);
  9271. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  9272. string celllastStr1 = "";
  9273. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  9274. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  9275. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  9276. celllastStr1 += $",国际旅费 元";
  9277. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  9278. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  9279. designer.SetDataSource("cell4Str", cell4Str);
  9280. designer.SetDataSource("cellStr", cellStr);
  9281. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  9282. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9283. designer.SetDataSource("celllastStr", celllastStr);
  9284. Workbook wb = designer.Workbook;
  9285. var sheet = wb.Worksheets[0];
  9286. //绑定datatable数据集
  9287. designer.SetDataSource(dtdac1);
  9288. designer.SetDataSource(dtdac2);
  9289. designer.Process();
  9290. var rowStart = dtdac1.Rows.Count;
  9291. while (rowStart > 0)
  9292. {
  9293. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  9294. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9295. startIndex++;
  9296. rowStart--;
  9297. }
  9298. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  9299. startIndex += 1; //总计行
  9300. rowStart = dtdac2.Rows.Count;
  9301. while (rowStart > 0)
  9302. {
  9303. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  9304. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9305. startIndex++;
  9306. rowStart--;
  9307. }
  9308. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  9309. wb.CalculateFormula(true);
  9310. //模板文件名
  9311. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9312. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9313. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9314. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9315. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9316. }
  9317. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  9318. {
  9319. //获取模板
  9320. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  9321. //载入模板
  9322. Document doc = new Document(tempPath);
  9323. DocumentBuilder builder = new DocumentBuilder(doc);
  9324. Dictionary<string, string> dic = new Dictionary<string, string>();
  9325. dic.Add("GroupName", "-");
  9326. dic.Add("ClientUnit", "-");
  9327. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  9328. //string missionLeaderJob = "";//负责人job
  9329. //int groupNumber = 0; //团人数
  9330. dic.Add("MissionLeader", "-"); //团负责人
  9331. dic.Add("MissionLeaderJob", "-"); //团负责人job
  9332. dic.Add("GroupNumber", "0"); //团人数
  9333. dic.Add("Day", "0");
  9334. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  9335. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  9336. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9337. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9338. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  9339. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  9340. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  9341. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  9342. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  9343. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  9344. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  9345. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9346. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9347. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9348. //其他费用
  9349. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9350. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9351. //其他费用合计
  9352. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9353. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9354. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9355. //公务舱合计
  9356. //国际旅费
  9357. //string outsideJJ = "";
  9358. //string allPriceJJ = "";
  9359. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9360. {
  9361. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9362. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9363. }
  9364. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9365. {
  9366. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9367. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9368. }
  9369. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9370. {
  9371. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9372. dic.Add("AirFeeTotal", airFeeTotalStr);
  9373. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9374. dic.Add("FeeTotal", feeTotalStr);
  9375. }
  9376. foreach (var key in dic.Keys)
  9377. {
  9378. builder.MoveToBookmark(key);
  9379. builder.Write(dic[key]);
  9380. }
  9381. //模板文件名
  9382. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9383. strFileName = CommonFun.ValidFileName(strFileName);
  9384. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9385. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9386. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9387. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9388. }
  9389. }
  9390. else if (dto.ExportType == 2) //表格
  9391. {
  9392. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9393. }
  9394. else if (dto.ExportType == 3)
  9395. {
  9396. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9397. }
  9398. return Ok(JsonView(400, "只可导出明细表!", ""));
  9399. }
  9400. catch (Exception ex)
  9401. {
  9402. return Ok(JsonView(400, ex.Message, ""));
  9403. }
  9404. }
  9405. /// <summary>
  9406. /// 获取三公费用标准city
  9407. /// </summary>
  9408. /// <param name="placeData"></param>
  9409. /// <param name="nationalTravelFeeId"></param>
  9410. /// <returns></returns>
  9411. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9412. {
  9413. string _city = string.Empty;
  9414. if (!placeData.Any()) return _city;
  9415. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9416. if (data == null) return _city;
  9417. string country = data.Country;
  9418. string city = data.City;
  9419. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9420. else _city = city;
  9421. return _city;
  9422. }
  9423. /// <summary>
  9424. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9425. /// </summary>
  9426. /// <returns></returns>
  9427. [HttpPost]
  9428. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9430. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9431. {
  9432. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9433. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9434. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9435. if (_view.Code == 0)
  9436. {
  9437. return Ok(JsonView(true, "操作成功"));
  9438. }
  9439. return Ok(JsonView(false, "操作失败"));
  9440. }
  9441. /// <summary>
  9442. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9443. /// </summary>
  9444. /// <returns></returns>
  9445. [HttpPost]
  9446. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9448. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9449. {
  9450. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9451. if (data.Code != 0)
  9452. {
  9453. return Ok(JsonView(false, data.Msg));
  9454. }
  9455. return Ok(JsonView(true, "操作成功!", data.Data));
  9456. }
  9457. /// <summary>
  9458. /// 三公其他费用草稿 删除
  9459. /// </summary>
  9460. /// <param name="dto"></param>
  9461. /// <returns></returns>
  9462. [HttpPost]
  9463. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9464. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9465. {
  9466. var jw = JsonView(false, "删除失败!");
  9467. var data = new Grp_DayOtherPriceDraft()
  9468. {
  9469. Id = dto.Id,
  9470. IsDel = 1,
  9471. DeleteUserId = dto.DeleteUserId,
  9472. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9473. };
  9474. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9475. if (del > 0)
  9476. {
  9477. jw.Code = 200;
  9478. jw.Msg = "删除成功!";
  9479. }
  9480. return Ok(jw);
  9481. }
  9482. /// <summary>
  9483. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9484. /// </summary>
  9485. /// <returns></returns>
  9486. [HttpPost]
  9487. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9488. {
  9489. var jw = JsonView(false);
  9490. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9491. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9492. jw.Code = StatusCodes.Status200OK;
  9493. jw.Msg = "操作成功!";
  9494. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9495. return Ok(jw);
  9496. }
  9497. /// <summary>
  9498. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9499. /// </summary>
  9500. /// <param name="dto"></param>
  9501. /// <returns></returns>
  9502. [HttpPost]
  9503. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9504. {
  9505. int userId = dto.UserId,
  9506. portId = dto.PortType,
  9507. groupId = dto.GroupId,
  9508. draftId = dto.DraftId;
  9509. _portTypeData.Add(1);
  9510. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9511. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9512. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9513. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9514. _sqlSugar.BeginTran();
  9515. try
  9516. {
  9517. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9518. if (draftDatas == null)
  9519. {
  9520. _sqlSugar.RollbackTran();
  9521. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9522. }
  9523. //验证可覆盖已有数据 两边创建人需为同一人;
  9524. int draftCreateUserId = draftDatas.CreateUserId,
  9525. formalCreateUserId = 0;
  9526. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9527. if (formalData != null)
  9528. {
  9529. formalCreateUserId = formalData.CreateUserId;
  9530. if (draftCreateUserId != formalCreateUserId)
  9531. {
  9532. _sqlSugar.RollbackTran();
  9533. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9534. }
  9535. }
  9536. //默认添加查看、编辑权限(创建人、自己)
  9537. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9538. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9539. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9540. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9541. newExterData.DiId = groupId;
  9542. newExterData.CreateUserId = userId;
  9543. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9544. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9545. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9546. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9547. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9548. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9549. //数据如果存在执行删除
  9550. if (enterExitCostInfo != null)
  9551. {
  9552. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9553. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9554. .Where(x => x.Id == enterExitCostInfo.Id)
  9555. .ExecuteCommand();
  9556. _sqlSugar.Updateable<Grp_DayAndCost>()
  9557. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9558. .Where(x => x.DiId == groupId)
  9559. .ExecuteCommand();
  9560. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9561. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9562. .Where(x => x.Diid == groupId)
  9563. .ExecuteCommand();
  9564. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9565. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9566. .Where(x => x.GroupId == groupId)
  9567. .ExecuteCommand();
  9568. }
  9569. //执行insert
  9570. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9571. if (insertId < 1)
  9572. {
  9573. _sqlSugar.RollbackTran();
  9574. return Ok(JsonView(false, "草稿数据导入失败!"));
  9575. }
  9576. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9577. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9578. #region 默认添加权限
  9579. #endregion
  9580. _sqlSugar.CommitTran();
  9581. //执行操作之后
  9582. //生成默认文件pdf并且通知人员
  9583. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9584. {
  9585. DiId = groupId,
  9586. ExportType = 1,
  9587. SubTypeId = 1005
  9588. }, "pdf");
  9589. //发送通知
  9590. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9591. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9592. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9593. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9594. //汇率信息记录
  9595. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9596. return Ok(JsonView(true));
  9597. }
  9598. catch (Exception ex)
  9599. {
  9600. _sqlSugar.RollbackTran();
  9601. return Ok(JsonView(false, ex.Message));
  9602. }
  9603. }
  9604. #endregion
  9605. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9606. /// <summary>
  9607. /// 获取币种基础数据(含逻辑处理)
  9608. /// </summary>
  9609. /// <returns></returns>
  9610. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9611. {
  9612. return await GeneralMethod.EnterExitCostInitRate();
  9613. }
  9614. /// <summary>
  9615. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9616. /// </summary>
  9617. /// <returns></returns>
  9618. [HttpPost]
  9619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9620. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9621. {
  9622. //验证城市归属并给默认值
  9623. int provinceId = dto.ProvinceId;
  9624. if (provinceId < 1) provinceId = 122;
  9625. var dataSource = await _sqlSugar
  9626. .Queryable<Sys_SetData>()
  9627. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9628. .ToListAsync();
  9629. var fileTypes = new List<EecSetDataInfoView>();
  9630. //三公费用-Word明细类型
  9631. var wordTypeData = dataSource
  9632. .Where(it => it.STid == 72)
  9633. .Select(x => new EecSetDataInfoView
  9634. {
  9635. ParentId = 1,
  9636. Id = x.Id,
  9637. Name = x.Name
  9638. })
  9639. .ToArray();
  9640. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9641. var excelTypeData = dataSource
  9642. .Where(it => it.STid == 73)
  9643. .Select(x => new EecSetDataInfoView
  9644. {
  9645. ParentId = 2,
  9646. Id = x.Id,
  9647. Name = x.Name
  9648. })
  9649. .ToArray();
  9650. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9651. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9652. fileTypes.Add(groupNameList);
  9653. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9654. //默认币种显示
  9655. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9656. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9657. return Ok(JsonView(true, "查询成功!", new
  9658. {
  9659. FileTypeData = fileTypes,
  9660. CurrencyInit = _currencyInfos,
  9661. viewPermissionData = viewPermissionData
  9662. }));
  9663. }
  9664. /// <summary>
  9665. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9666. /// </summary>
  9667. /// <returns></returns>
  9668. [HttpPost]
  9669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9670. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9671. {
  9672. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9673. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9674. RefAsync<int> total = 0;
  9675. int diId = 0;
  9676. var status = int.TryParse(dto.GroupName, out diId);
  9677. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9678. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9679. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9680. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9681. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9682. .OrderByDescending(x => x.VisitStartDate)
  9683. .Select(x => new EnterExitCostMobileGroupView()
  9684. {
  9685. Id = x.Id,
  9686. GroupName = x.TeamName,
  9687. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9688. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9689. ProvinceId = x.CityId
  9690. })
  9691. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9692. //处理省份Id
  9693. if (data.Any())
  9694. {
  9695. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9696. if (provCityDatas.Any())
  9697. {
  9698. foreach (var item in data)
  9699. {
  9700. var provinceId = item.ProvinceId;
  9701. var isDefualtVal = true;
  9702. if (provinceId > 0)
  9703. {
  9704. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9705. if (parentId != null)
  9706. {
  9707. isDefualtVal = false;
  9708. item.ProvinceId = (int)parentId;
  9709. }
  9710. }
  9711. if (isDefualtVal)
  9712. {
  9713. item.ProvinceId = 122; //默认四川
  9714. }
  9715. }
  9716. }
  9717. }
  9718. //处理是否显示
  9719. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9720. {
  9721. foreach (var item in data)
  9722. {
  9723. item.IsView = true;
  9724. }
  9725. }
  9726. return Ok(JsonView(true, "查询成功!", data, total));
  9727. }
  9728. /// <summary>
  9729. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9730. /// </summary>
  9731. /// <returns></returns>
  9732. [HttpPost]
  9733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9734. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9735. {
  9736. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9737. RefAsync<int> total = 0;
  9738. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9739. .Where(x => x.IsDel == 0 && x.STid == 66)
  9740. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9741. .Select(x => new
  9742. {
  9743. id = x.Id,
  9744. name = x.Name,
  9745. remark = x.Remark,
  9746. })
  9747. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9748. return Ok(JsonView(true, "查询成功!", data, total));
  9749. }
  9750. /// <summary>
  9751. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9752. /// </summary>
  9753. /// <returns></returns>
  9754. [HttpPost]
  9755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9756. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9757. {
  9758. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9759. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9760. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9761. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9762. var groupOtherRateData = groupRateData.TeamRates;
  9763. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9764. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9765. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9766. groupOtherRateData = groupOtherRateData
  9767. .Select(x => new TeamRateDescAddCurrencyIdView
  9768. {
  9769. CurrencyId = x.CurrencyId,
  9770. CurrencyName = x.CurrencyName,
  9771. CurrencyCode = x.CurrencyCode,
  9772. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9773. }).ToList();
  9774. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9775. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9776. }
  9777. /// <summary>
  9778. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9779. /// </summary>
  9780. /// <returns></returns>
  9781. [HttpPost]
  9782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9783. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9784. {
  9785. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9786. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9787. var tipsData = new List<int>() { 1, 2, 3 };
  9788. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9789. if (dto.TipsType == 1)
  9790. {
  9791. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9792. }
  9793. else if (dto.TipsType == 2)
  9794. {
  9795. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9796. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9797. }
  9798. else if (dto.TipsType == 3)
  9799. {
  9800. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9801. return Ok(JsonView(true, "查询成功!", airData));
  9802. }
  9803. return Ok(JsonView(false));
  9804. }
  9805. /// <summary>
  9806. /// 团组模块 - 出入境国家费用标准-移动端 List
  9807. /// </summary>
  9808. /// <returns></returns>
  9809. [HttpPost]
  9810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9811. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9812. {
  9813. Stopwatch sw = new Stopwatch();
  9814. sw.Start();
  9815. int provinceId = dto.ProvinceId;
  9816. if (provinceId < 1) provinceId = 122; // 默认四川
  9817. RefAsync<int> total = 0;
  9818. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9819. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9820. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9821. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9822. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9823. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9824. .Select((ntf, sd, u, sd1) => new
  9825. {
  9826. Id = ntf.Id,
  9827. Area = $"{ntf.Country}-{ntf.City}",
  9828. Currency = ntf.Currency,
  9829. CurrencyCode = sd.Name,
  9830. CurrencyName = sd.Remark,
  9831. RoomCost = ntf.RoomCost,
  9832. FoodCost = ntf.FoodCost,
  9833. PublicCost = ntf.PublicCost,
  9834. TrainCost = ntf.TrainCost,
  9835. LastUpdateUserId = ntf.LastUpdateUserId,
  9836. LastUpdateUserName = u.CnName,
  9837. LastUpdateTime = ntf.LastUpdateTime
  9838. })
  9839. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9840. sw.Stop();
  9841. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9842. }
  9843. /// <summary>
  9844. /// 团组模块 - 出入境费用-移动端 - Info
  9845. /// </summary>
  9846. /// <returns></returns>
  9847. [HttpPost]
  9848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9849. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9850. {
  9851. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9852. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9853. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9854. return Ok(data);
  9855. }
  9856. /// <summary>
  9857. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9858. /// </summary>
  9859. /// <returns></returns>
  9860. [HttpPost]
  9861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9862. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9863. {
  9864. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9865. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9866. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9867. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9868. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9869. mobileInfo.DiId = dto.DiId;
  9870. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9871. if (eecInfo == null) return Ok(mobileInfo);
  9872. //验证查看权限
  9873. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9874. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9875. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9876. mobileInfo.IsAssignPerm = isSet;
  9877. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9878. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9879. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9880. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9881. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9882. {
  9883. SubId = dac.Id,
  9884. DiId = dac.DiId,
  9885. Type = dac.Type,
  9886. Days = dac.Days,
  9887. NationalTravelFeeId = dac.NationalTravelFeeId,
  9888. Arae = $"{ntf.Country}-{ntf.City}",
  9889. Cost = dac.Cost,
  9890. Currency = dac.Currency,
  9891. CurrencyName = sd.Name,
  9892. SubTotal = dac.SubTotal,
  9893. })
  9894. .ToList();
  9895. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9896. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9897. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9898. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9899. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9900. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9901. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9902. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9903. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9904. //其他款项
  9905. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9906. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9907. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9908. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9909. .OrderBy((dop, sd1, sd2) => dop.Index)
  9910. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9911. {
  9912. SubId = dop.Id,
  9913. DiId = dop.Diid,
  9914. Index = dop.Index,
  9915. SetDataId = dop.SetDataId,
  9916. SetDataName = sd1.Name,
  9917. Cost = dop.Cost,
  9918. Currency = dop.Currency,
  9919. CurrencyName = sd2.Remark,
  9920. SubTotal = dop.SubTotal,
  9921. Remark = dop.Remark,
  9922. })
  9923. .ToArray();
  9924. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9925. return Ok(mobileInfo);
  9926. }
  9927. /// <summary>
  9928. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9929. /// </summary>
  9930. /// <returns></returns>
  9931. [HttpPost]
  9932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9933. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9934. {
  9935. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9936. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9937. //验证查看权限
  9938. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9939. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9940. var userIds = await _sqlSugar
  9941. .Queryable<Grp_EnterExitCostPermission>()
  9942. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9943. .Select(x => x.UserId)
  9944. .ToArrayAsync();
  9945. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9946. var perUsersView = new List<dynamic>();
  9947. foreach (var item in perUsers)
  9948. {
  9949. bool isView1 = false;
  9950. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9951. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9952. }
  9953. return Ok(JsonView(perUsersView));
  9954. }
  9955. /// <summary>
  9956. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9957. /// </summary>
  9958. /// <returns></returns>
  9959. [HttpPost]
  9960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9961. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9962. {
  9963. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9964. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9965. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9966. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9967. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9968. //验证查看权限
  9969. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9970. //if (!isView) return Ok(JsonView(false, msg));
  9971. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9972. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9973. var subType = dto.SubType;
  9974. if (subType == 1) //1:境内费用
  9975. {
  9976. var oneData = new ChoiceOneMobileSubInfoView()
  9977. {
  9978. Id = eecInfo.Id,
  9979. ChoiceOne = eecInfo.ChoiceOne,
  9980. ChoiceOneTotalCost = eecInfo.InsidePay,
  9981. Visa = eecInfo.Visa,
  9982. VisaRemark = eecInfo.VisaRemark,
  9983. YiMiao = eecInfo.YiMiao,
  9984. HeSuan = eecInfo.HeSuan,
  9985. Service = eecInfo.Service,
  9986. Ticket = eecInfo.Ticket,
  9987. Safe = eecInfo.Safe,
  9988. FirstItemRemark = eecInfo.FirstItemRemark
  9989. };
  9990. return Ok(JsonView(oneData));
  9991. }
  9992. else if (subType == 2) //2:国际旅费
  9993. {
  9994. var twoData = new ChoiceTwoMobileSubInfoView()
  9995. {
  9996. Id = eecInfo.Id,
  9997. ChoiceTwoJJ = eecInfo.SumJJC,
  9998. OutsideJJPay = eecInfo.OutsideJJPay,
  9999. ChoiceTwoGW = eecInfo.SumGWC,
  10000. OutsideGWPay = eecInfo.OutsideGWPay,
  10001. ChoiceTwoTD = eecInfo.SumTDC,
  10002. OutsideTDPay = eecInfo.OutsideTDPay,
  10003. AirJJ = eecInfo.AirJJ,
  10004. AirGW = eecInfo.AirGW,
  10005. AirTD = eecInfo.AirTD,
  10006. CityTranffic = eecInfo.CityTranffic,
  10007. TwoItemRemark = eecInfo.TwoItemRemark
  10008. };
  10009. return Ok(JsonView(twoData));
  10010. }
  10011. else if (subType == 3) //3:住宿费
  10012. {
  10013. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10014. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10015. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10016. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  10017. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10018. {
  10019. SubId = dac.Id,
  10020. DiId = dac.DiId,
  10021. Type = dac.Type,
  10022. Days = dac.Days,
  10023. NationalTravelFeeId = dac.NationalTravelFeeId,
  10024. Arae = $"{ntf.Country}-{ntf.City}",
  10025. Cost = dac.Cost,
  10026. Currency = dac.Currency,
  10027. CurrencyName = sd.Name,
  10028. SubTotal = dac.SubTotal,
  10029. })
  10030. .ToArray();
  10031. var data = new ChoiceMobileSubInfo3To6View()
  10032. {
  10033. ParentId = eecInfo.Id,
  10034. Choice = eecInfo.ChoiceThree,
  10035. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10036. Details = dayAndCostDatas
  10037. };
  10038. return Ok(JsonView(data));
  10039. }
  10040. else if (subType == 4) //4:伙食费
  10041. {
  10042. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10043. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10044. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10045. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  10046. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10047. {
  10048. SubId = dac.Id,
  10049. DiId = dac.DiId,
  10050. Type = dac.Type,
  10051. Days = dac.Days,
  10052. NationalTravelFeeId = dac.NationalTravelFeeId,
  10053. Arae = $"{ntf.Country}-{ntf.City}",
  10054. Cost = dac.Cost,
  10055. Currency = dac.Currency,
  10056. CurrencyName = sd.Name,
  10057. SubTotal = dac.SubTotal,
  10058. })
  10059. .ToArray();
  10060. var data = new ChoiceMobileSubInfo3To6View()
  10061. {
  10062. ParentId = eecInfo.Id,
  10063. Choice = eecInfo.ChoiceFour,
  10064. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10065. Details = dayAndCostDatas
  10066. };
  10067. return Ok(JsonView(data));
  10068. }
  10069. else if (subType == 5) //5:公杂费
  10070. {
  10071. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10072. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10073. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10074. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  10075. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10076. {
  10077. SubId = dac.Id,
  10078. DiId = dac.DiId,
  10079. Type = dac.Type,
  10080. Days = dac.Days,
  10081. NationalTravelFeeId = dac.NationalTravelFeeId,
  10082. Arae = $"{ntf.Country}-{ntf.City}",
  10083. Cost = dac.Cost,
  10084. Currency = dac.Currency,
  10085. CurrencyName = sd.Name,
  10086. SubTotal = dac.SubTotal,
  10087. })
  10088. .ToArray();
  10089. var data = new ChoiceMobileSubInfo3To6View()
  10090. {
  10091. ParentId = eecInfo.Id,
  10092. Choice = eecInfo.ChoiceFive,
  10093. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10094. Details = dayAndCostDatas
  10095. };
  10096. return Ok(JsonView(data));
  10097. }
  10098. else if (subType == 6) //6:培训费
  10099. {
  10100. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10101. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10102. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10103. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  10104. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10105. {
  10106. SubId = dac.Id,
  10107. DiId = dac.DiId,
  10108. Type = dac.Type,
  10109. Days = dac.Days,
  10110. NationalTravelFeeId = dac.NationalTravelFeeId,
  10111. Arae = $"{ntf.Country}-{ntf.City}",
  10112. Cost = dac.Cost,
  10113. Currency = dac.Currency,
  10114. CurrencyName = sd.Name,
  10115. SubTotal = dac.SubTotal,
  10116. })
  10117. .ToArray();
  10118. var data = new ChoiceMobileSubInfo3To6View()
  10119. {
  10120. ParentId = eecInfo.Id,
  10121. Choice = eecInfo.ChoiceSix,
  10122. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10123. Details = dayAndCostDatas
  10124. };
  10125. return Ok(JsonView(data));
  10126. }
  10127. else if (subType == 7) //7:其他
  10128. {
  10129. //其他款项
  10130. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10131. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10132. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10133. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10134. .OrderBy((dop, sd1, sd2) => dop.Index)
  10135. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10136. {
  10137. SubId = dop.Id,
  10138. DiId = dop.Diid,
  10139. Index = dop.Index,
  10140. SetDataId = dop.SetDataId,
  10141. SetDataName = sd1.Name,
  10142. Cost = dop.Cost,
  10143. Currency = dop.Currency,
  10144. CurrencyName = sd2.Name,
  10145. SubTotal = dop.SubTotal,
  10146. Remark = dop.Remark,
  10147. })
  10148. .ToArray();
  10149. var data = new ChoiceSevenMobileSubInfoView()
  10150. {
  10151. ParentId = eecInfo.Id,
  10152. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10153. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10154. Details = otherData
  10155. };
  10156. return Ok(JsonView(data));
  10157. }
  10158. return Ok(JsonView(false));
  10159. }
  10160. #region op
  10161. ///// <summary>
  10162. ///// 移动端更新费用消息通知
  10163. ///// </summary>
  10164. ///// <param name="diid"></param>
  10165. ///// <param name="id"></param>
  10166. ///// <param name="currUserId"></param>
  10167. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  10168. //{
  10169. // try
  10170. // {
  10171. // ////生成默认文件pdf并且通知人员
  10172. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10173. // //{
  10174. // // DiId = diid,
  10175. // // ExportType = 1,
  10176. // // SubTypeId = 1005
  10177. // //}, "pdf");
  10178. // ////发送通知
  10179. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10180. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10181. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10182. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  10183. // ////汇率信息记录
  10184. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10185. // }
  10186. // catch (Exception ex)
  10187. // {
  10188. // //记录日志
  10189. // throw;
  10190. // }
  10191. //}
  10192. /// <summary>
  10193. /// 验证出入境费用数据是否存在
  10194. /// 不存在添加
  10195. /// </summary>
  10196. /// <param name="diId"></param>
  10197. /// <param name="currUserId"></param>
  10198. /// <returns></returns>
  10199. /// <exception cref="CustomException"></exception>
  10200. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  10201. {
  10202. var parentId = 0;
  10203. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10204. if (info != null)
  10205. {
  10206. parentId = info.Id;
  10207. }
  10208. else
  10209. {
  10210. var currencys = await EnterExitCostMobileGetCurrencyInit();
  10211. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10212. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10213. parentId = addId;
  10214. }
  10215. return parentId;
  10216. }
  10217. /// <summary>
  10218. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  10219. /// </summary>
  10220. /// <returns></returns>
  10221. [HttpPost]
  10222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10223. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  10224. {
  10225. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10226. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10227. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10228. //验证编辑权限
  10229. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10230. //if (!isEdit) return Ok(JsonView(false, msg));
  10231. var permissions = new List<Grp_EnterExitCostPermission>();
  10232. foreach (var userId in dto.UserIds)
  10233. {
  10234. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  10235. }
  10236. if (permissions.Any())
  10237. {
  10238. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10239. {
  10240. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10241. }
  10242. _sqlSugar.BeginTran();
  10243. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  10244. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10245. if (result < 1)
  10246. {
  10247. _sqlSugar.RollbackTran();
  10248. return Ok(JsonView(false));
  10249. }
  10250. _sqlSugar.CommitTran();
  10251. return Ok(JsonView(true));
  10252. }
  10253. return Ok(JsonView(false));
  10254. }
  10255. /// <summary>
  10256. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  10257. /// </summary>
  10258. /// <returns></returns>
  10259. [HttpPost]
  10260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10261. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  10262. {
  10263. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10264. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10265. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10266. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10267. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10268. int id = dto.Id;
  10269. if (id <= 0) //add
  10270. {
  10271. //int provinceId = dto.ProvinceId;
  10272. int groupId = dto.DiId;
  10273. //if (provinceId < 1) provinceId = 122;
  10274. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  10275. info.LastUpdateUserId = dto.CurrUserId;
  10276. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10277. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  10278. if (add < 1) return Ok(JsonView(false));
  10279. id = add;
  10280. }
  10281. else //update
  10282. {
  10283. ////验证编辑权限
  10284. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10285. //if (!isEdit) return Ok(JsonView(false, msg));
  10286. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  10287. {
  10288. CurrencyRemark = currencyStr,
  10289. LastUpdateUserId = dto.CurrUserId,
  10290. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10291. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  10292. if (upd < 1) return Ok(JsonView(false));
  10293. }
  10294. #region 汇率变更时更改币种相关费用
  10295. var opDayCosts = new List<Grp_DayAndCost>();
  10296. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  10297. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10298. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  10299. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10300. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10301. .Select((dac, sd) => new
  10302. {
  10303. dac.Id,
  10304. dac.DiId,
  10305. CurrencyCode = sd.Name,
  10306. dac.Cost
  10307. })
  10308. .ToList();
  10309. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10310. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10311. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10312. .Select((dop, sd) => new
  10313. {
  10314. dop.Id,
  10315. dop.Diid,
  10316. CurrencyCode = sd.Name,
  10317. dop.Cost
  10318. })
  10319. .ToList();
  10320. if (dayCosts.Count > 0)
  10321. {
  10322. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10323. foreach (var dc in new_dayCosts)
  10324. {
  10325. var thisCurrency = dc.Key.ToUpper();
  10326. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10327. if (thisRate == 0.00M) continue;
  10328. foreach (var dcSub in dc)
  10329. {
  10330. opDayCosts.Add(new Grp_DayAndCost()
  10331. {
  10332. Id = dcSub.Id,
  10333. DiId = dcSub.DiId,
  10334. Cost = dcSub.Cost,
  10335. SubTotal = dcSub.Cost * thisRate,
  10336. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10337. });
  10338. }
  10339. }
  10340. if (opDayCosts.Count > 0)
  10341. {
  10342. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10343. }
  10344. }
  10345. if (dayOtherCosts.Count > 0)
  10346. {
  10347. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10348. foreach (var dc in new_dayOtherCosts)
  10349. {
  10350. var thisCurrency = dc.Key.ToUpper();
  10351. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10352. if (thisRate == 0.00M) continue;
  10353. foreach (var dcSub in dc)
  10354. {
  10355. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10356. {
  10357. Id = dcSub.Id,
  10358. Diid = dcSub.Diid,
  10359. Cost = dcSub.Cost,
  10360. SubTotal = dcSub.Cost * thisRate,
  10361. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10362. });
  10363. }
  10364. }
  10365. if (opDayOtherCosts.Count > 0)
  10366. {
  10367. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10368. }
  10369. }
  10370. #endregion
  10371. //消息通知
  10372. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10373. //汇率信息记录
  10374. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10375. return Ok(JsonView(new { parentId = id }));
  10376. }
  10377. /// <summary>
  10378. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10379. /// </summary>
  10380. /// <returns></returns>
  10381. [HttpPost]
  10382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10383. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10384. {
  10385. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10386. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10387. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10388. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10389. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10390. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  10391. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10392. int id = dto.Id;
  10393. if (id <= 0) //add
  10394. {
  10395. checkboxInfo.CreateUserId = dto.CurrUserId;
  10396. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10397. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10398. if (add < 1) return Ok(JsonView(false));
  10399. }
  10400. else //update
  10401. {
  10402. ////验证编辑权限
  10403. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10404. //if (!isEdit) return Ok(JsonView(false, msg));
  10405. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10406. .UpdateColumns(x => new
  10407. {
  10408. x.ChoiceOne,
  10409. x.ChoiceTwo,
  10410. x.SumJJC,
  10411. x.SumGWC,
  10412. x.SumTDC,
  10413. x.ChoiceThree,
  10414. x.ChoiceFour,
  10415. x.ChoiceFive,
  10416. x.ChoiceSix,
  10417. x.OtherExpenses_Checked
  10418. })
  10419. .Where(x => x.Id == id)
  10420. .ExecuteCommandAsync();
  10421. if (upd < 1) return Ok(JsonView(false));
  10422. }
  10423. return Ok(JsonView(new { parentId = id }));
  10424. }
  10425. /// <summary>
  10426. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10427. /// </summary>
  10428. /// <returns></returns>
  10429. [HttpPost]
  10430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10431. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10432. {
  10433. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10434. // if (provinceId < 1) provinceId = 122;
  10435. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10436. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10437. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10438. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10439. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10440. var checkboxInfo = new Grp_EnterExitCost()
  10441. {
  10442. Id = id,
  10443. //ProvinceId = provinceId,
  10444. DiId = diId,
  10445. CreateUserId = currUserId,
  10446. LastUpdateUserId = dto.CurrUserId,
  10447. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10448. };
  10449. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10450. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10451. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10452. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10453. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10454. if (id <= 0) //add
  10455. {
  10456. checkboxInfo.CreateUserId = dto.CurrUserId;
  10457. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10458. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10459. if (add < 1) return Ok(JsonView(false));
  10460. }
  10461. else //update
  10462. {
  10463. ////验证编辑权限
  10464. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10465. //if (!isEdit) return Ok(JsonView(false, msg));
  10466. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10467. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  10468. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  10469. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10470. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10471. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10472. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10473. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10474. .Where(x => x.Id == id)
  10475. .ExecuteCommandAsync();
  10476. if (upd < 1) return Ok(JsonView(false));
  10477. }
  10478. return Ok(JsonView(new { parentId = id }));
  10479. }
  10480. /// <summary>
  10481. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10482. /// </summary>
  10483. /// <returns></returns>
  10484. [HttpPost]
  10485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10486. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10487. {
  10488. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10489. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10490. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10491. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10492. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10493. info.FirstItemRemark = dto.FirstItemRemark;
  10494. info.LastUpdateUserId = dto.CurrUserId;
  10495. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10496. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10497. int id = dto.Id;
  10498. if (id <= 0) //add
  10499. {
  10500. info.CreateUserId = dto.CurrUserId;
  10501. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10502. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10503. if (add < 1) return Ok(JsonView(false));
  10504. id = add;
  10505. }
  10506. else //update
  10507. {
  10508. ////验证编辑权限
  10509. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10510. //if (!isEdit) return Ok(JsonView(false, msg));
  10511. var upd = await _sqlSugar.Updateable(info)
  10512. .UpdateColumns(x => new
  10513. {
  10514. x.ChoiceOne,
  10515. x.InsidePay,
  10516. x.VisaRemark,
  10517. x.Visa,
  10518. x.Service,
  10519. x.Safe,
  10520. x.Ticket,
  10521. x.HeSuan,
  10522. x.YiMiao,
  10523. x.FirstItemRemark,
  10524. x.LastUpdateUserId,
  10525. x.LastUpdateTime
  10526. })
  10527. .Where(x => x.Id == id)
  10528. .ExecuteCommandAsync();
  10529. if (upd < 1) return Ok(JsonView(false));
  10530. }
  10531. //消息通知
  10532. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10533. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10534. }
  10535. /// <summary>
  10536. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10537. /// </summary>
  10538. /// <returns></returns>
  10539. [HttpPost]
  10540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10541. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10542. {
  10543. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10544. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10545. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10546. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10547. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10548. info.DiId = dto.DiId;
  10549. //info.ProvinceId = dto.ProvinceId;
  10550. info.OutsideJJPay = dto.OutsideJJPay;
  10551. info.OutsideGWPay = dto.OutsideGWPay;
  10552. info.OutsideTDPay = dto.OutsideTDPay;
  10553. info.AirJJ = dto.AirJJ;
  10554. info.AirGW = dto.AirGW;
  10555. info.AirTD = dto.AirTD;
  10556. info.CityTranffic = dto.CityTranffic;
  10557. info.TwoItemRemark = dto.TwoItemRemark;
  10558. info.SumJJC = dto.ChoiceTwoJJ;
  10559. info.SumGWC = dto.ChoiceTwoGW;
  10560. info.SumTDC = dto.ChoiceTwoTD;
  10561. info.LastUpdateUserId = dto.CurrUserId;
  10562. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10563. int id = dto.Id;
  10564. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10565. if (id <= 0) //add i
  10566. {
  10567. info.CreateUserId = dto.CurrUserId;
  10568. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10569. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10570. if (addId <= 0) return Ok(JsonView(false));
  10571. id = addId;
  10572. }
  10573. else //update
  10574. {
  10575. ////验证编辑权限
  10576. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10577. //if (!isEdit) return Ok(JsonView(false, msg));
  10578. var upd = await _sqlSugar.Updateable(info)
  10579. .UpdateColumns(x => new
  10580. {
  10581. x.SumJJC,
  10582. x.OutsideJJPay,
  10583. x.SumGWC,
  10584. x.OutsideGWPay,
  10585. x.SumTDC,
  10586. x.OutsideTDPay,
  10587. x.AirJJ,
  10588. x.AirGW,
  10589. x.AirTD,
  10590. x.CityTranffic,
  10591. x.TwoItemRemark,
  10592. x.LastUpdateTime,
  10593. x.LastUpdateUserId
  10594. })
  10595. .Where(x => x.Id == id)
  10596. .ExecuteCommandAsync();
  10597. if (upd < 1) return Ok(JsonView(false));
  10598. }
  10599. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10600. gwcItemTotal = info.AirGW + info.CityTranffic;
  10601. tdcItemTotal = info.AirTD + info.CityTranffic;
  10602. //消息通知
  10603. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10604. return Ok(JsonView(new
  10605. {
  10606. parentId = id,
  10607. choiceTwoJJ = dto.ChoiceTwoJJ,
  10608. jjcItemTotal = jjcItemTotal,
  10609. choiceTwoGW = dto.ChoiceTwoGW,
  10610. gwcItemTotal = gwcItemTotal,
  10611. choiceTwoTD = dto.ChoiceTwoTD,
  10612. tdcItemTotal = tdcItemTotal
  10613. }));
  10614. }
  10615. /// <summary>
  10616. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10617. /// </summary>
  10618. /// <returns></returns>
  10619. [HttpPost]
  10620. [ApiExplorerSettings(IgnoreApi = true)]
  10621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10622. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10623. {
  10624. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10625. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10626. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10627. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10628. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10629. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10630. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10631. var infos = infos1.Select(x => new Grp_DayAndCost
  10632. {
  10633. Id = x.Id,
  10634. DiId = dto.DiId,
  10635. Type = dto.FeeType,
  10636. Days = x.Days,
  10637. NationalTravelFeeId = x.NationalTravelFeeId,
  10638. Cost = x.Cost,
  10639. Currency = x.Currency,
  10640. SubTotal = x.SubTotal,
  10641. CreateUserId = dto.CurrUserId
  10642. })
  10643. .ToList();
  10644. var adds = infos.Where(x => x.Id <= 0).ToList();
  10645. var upds = infos.Where(x => x.Id > 0).ToList();
  10646. if (adds.Count > 0)
  10647. {
  10648. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10649. if (add < 1) return Ok(JsonView(false));
  10650. }
  10651. if (upds.Count > 0)
  10652. {
  10653. var upd = await _sqlSugar.Updateable(adds)
  10654. .UpdateColumns(x => new
  10655. {
  10656. x.Days,
  10657. x.NationalTravelFeeId,
  10658. x.Cost,
  10659. x.Currency,
  10660. x.SubTotal
  10661. })
  10662. .WhereColumns(x => new { x.Id })
  10663. .ExecuteCommandAsync();
  10664. if (upd < 1) return Ok(JsonView(false));
  10665. }
  10666. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10667. //消息通知
  10668. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10669. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10670. return Ok(JsonView(new { itemTotal = itemTotal }));
  10671. }
  10672. /// <summary>
  10673. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10674. /// </summary>
  10675. /// <returns></returns>
  10676. [HttpPost]
  10677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10678. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10679. {
  10680. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10681. int subId = dto.SubId, feeType = dto.FeeType;
  10682. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10683. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10684. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10685. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10686. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10687. subInfo.Id = subId;
  10688. subInfo.DiId = dto.DiId;
  10689. if (feeType == 3) subInfo.Type = 1;
  10690. else if (feeType == 4) subInfo.Type = 2;
  10691. else if (feeType == 5) subInfo.Type = 3;
  10692. else if (feeType == 6) subInfo.Type = 4;
  10693. subInfo.CreateUserId = dto.CurrUserId;
  10694. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10695. if (parentId < 1) return Ok(JsonView(false));
  10696. //子表op
  10697. if (subId < 1)
  10698. {
  10699. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10700. if (subAdd < 1) return Ok(JsonView(false));
  10701. }
  10702. else
  10703. {
  10704. ////验证编辑权限
  10705. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10706. //if (!isEdit) return Ok(JsonView(false, msg));
  10707. var subUpd = await _sqlSugar.Updateable(subInfo)
  10708. .UpdateColumns(x => new
  10709. {
  10710. x.Days,
  10711. x.NationalTravelFeeId,
  10712. x.Cost,
  10713. x.Currency,
  10714. x.SubTotal
  10715. })
  10716. .WhereColumns(x => new { x.Id })
  10717. .ExecuteCommandAsync();
  10718. if (subUpd < 1) return Ok(JsonView(false));
  10719. }
  10720. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10721. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10722. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10723. }
  10724. /// <summary>
  10725. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10726. /// </summary>
  10727. /// <returns></returns>
  10728. [HttpPost]
  10729. [ApiExplorerSettings(IgnoreApi = true)]
  10730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10731. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10732. {
  10733. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10734. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10735. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10736. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10737. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10738. {
  10739. Id = x.Id,
  10740. Diid = dto.DiId,
  10741. SetDataId = x.SetDataId,
  10742. Index = x.Index,
  10743. Cost = x.Cost,
  10744. Currency = x.Currency,
  10745. SubTotal = x.SubTotal,
  10746. CreateUserId = dto.CurrUserId,
  10747. Remark = x.Remark
  10748. }).ToList();
  10749. var adds = infos.Where(x => x.Id <= 0).ToList();
  10750. var upds = infos.Where(x => x.Id > 0).ToList();
  10751. if (adds.Count > 0)
  10752. {
  10753. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10754. if (add < 1) return Ok(JsonView(false));
  10755. }
  10756. if (upds.Count > 0)
  10757. {
  10758. var upd = await _sqlSugar.Updateable(adds)
  10759. .UpdateColumns(x => new
  10760. {
  10761. x.Index,
  10762. x.SetDataId,
  10763. x.Cost,
  10764. x.Currency,
  10765. x.SubTotal,
  10766. x.Remark
  10767. })
  10768. .WhereColumns(x => new { x.Id })
  10769. .ExecuteCommandAsync();
  10770. if (upd < 1) return Ok(JsonView(false));
  10771. }
  10772. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10773. //消息通知
  10774. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10775. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10776. return Ok(JsonView(new { itemTotal = itemTotal }));
  10777. }
  10778. /// <summary>
  10779. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10780. /// </summary>
  10781. /// <returns></returns>
  10782. [HttpPost]
  10783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10784. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10785. {
  10786. int subId = dto.SubId;
  10787. int diId = dto.Diid;
  10788. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10789. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10790. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10791. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10792. subInfo.Id = subId;
  10793. subInfo.Diid = dto.Diid;
  10794. subInfo.CreateUserId = dto.CurrUserId;
  10795. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10796. if (parentId < 1) return Ok(JsonView(false));
  10797. #region 子表op
  10798. if (subId < 1)//add
  10799. {
  10800. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10801. if (subAdd < 1) return Ok(JsonView(false));
  10802. }
  10803. else //upd
  10804. {
  10805. ////验证编辑权限
  10806. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10807. //if (!isEdit) return Ok(JsonView(false, msg));
  10808. var subUpd = await _sqlSugar.Updateable(subInfo)
  10809. .UpdateColumns(x => new
  10810. {
  10811. x.Index,
  10812. x.SetDataId,
  10813. x.Cost,
  10814. x.Currency,
  10815. x.SubTotal,
  10816. x.Remark
  10817. })
  10818. .WhereColumns(x => new { x.Id })
  10819. .ExecuteCommandAsync();
  10820. if (subUpd < 1) return Ok(JsonView(false));
  10821. }
  10822. #endregion
  10823. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10824. //消息通知
  10825. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10826. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10827. }
  10828. /// <summary>
  10829. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10830. /// </summary>
  10831. /// <returns></returns>
  10832. [HttpPost]
  10833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10834. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10835. {
  10836. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10837. if (data.Code != 0)
  10838. {
  10839. return Ok(JsonView(false, data.Msg));
  10840. }
  10841. return Ok(JsonView(true, "操作成功!", data.Data));
  10842. }
  10843. /// <summary>
  10844. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10845. /// </summary>
  10846. /// <param name="dto"></param>
  10847. /// <returns></returns>
  10848. [HttpPost]
  10849. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10850. {
  10851. var data = new Grp_DayOtherPrice()
  10852. {
  10853. Id = dto.Id,
  10854. IsDel = 1,
  10855. DeleteUserId = dto.DeleteUserId,
  10856. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10857. };
  10858. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10859. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10860. return Ok(JsonView(false, "删除失败!"));
  10861. }
  10862. #endregion
  10863. #endregion
  10864. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10865. /// <summary>
  10866. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10867. /// </summary>
  10868. /// <returns></returns>
  10869. [HttpGet]
  10870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10871. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10872. {
  10873. var provData = await _groupRepository.ProvinceBasicSource();
  10874. return Ok(JsonView(true, "查询成功!", provData));
  10875. }
  10876. /// <summary>
  10877. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10878. /// </summary>
  10879. /// <returns></returns>
  10880. [HttpPost]
  10881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10882. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10883. {
  10884. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10885. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10886. RefAsync<int> total = 0;
  10887. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10888. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10889. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10890. .Select(x => new
  10891. {
  10892. Id = x.Id,
  10893. DraftName = x.DraftName,
  10894. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10895. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10896. .Any()
  10897. })
  10898. .OrderByDescending(x => x.Id)
  10899. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10900. return Ok(JsonView(true, "查询成功!", data, total));
  10901. }
  10902. /// <summary>
  10903. /// 出入境费用-草稿 移动端
  10904. /// 获取币种基础数据(含逻辑处理)
  10905. /// </summary>
  10906. /// <returns></returns>
  10907. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10908. {
  10909. return await GeneralMethod.EnterExitCostInitRate();
  10910. }
  10911. /// <summary>
  10912. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10913. /// </summary>
  10914. /// <returns></returns>
  10915. [HttpPost]
  10916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10917. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10918. {
  10919. //验证城市归属并给默认值
  10920. int provinceId = dto.ProvinceId;
  10921. if (provinceId < 1) provinceId = 122;
  10922. var dataSource = await _sqlSugar
  10923. .Queryable<Sys_SetData>()
  10924. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10925. .ToListAsync();
  10926. //三公费用-Word明细类型
  10927. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10928. .Select(x => new SetDataInfoView
  10929. {
  10930. Id = x.Id,
  10931. Name = x.Name,
  10932. Remark = x.Remark
  10933. })
  10934. .ToList();
  10935. //三公费用-Excel明细类型
  10936. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10937. .Select(x => new SetDataInfoView
  10938. {
  10939. Id = x.Id,
  10940. Name = x.Name,
  10941. Remark = x.Remark
  10942. })
  10943. .ToList();
  10944. //默认币种显示
  10945. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10946. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10947. return Ok(JsonView(true, "查询成功!", new
  10948. {
  10949. WordTypeData = wordTypeData,
  10950. ExcelTypeData = excelTypeData,
  10951. CurrencyInit = _currencyInfos,
  10952. viewPermissionData = viewPermissionData
  10953. }));
  10954. }
  10955. /// <summary>
  10956. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10957. /// </summary>
  10958. /// <returns></returns>
  10959. [HttpPost]
  10960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10961. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10962. {
  10963. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10964. RefAsync<int> total = 0;
  10965. int diId = 0;
  10966. var status = int.TryParse(dto.GroupName, out diId);
  10967. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10968. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10969. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10970. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10971. .OrderByDescending(x => x.VisitStartDate)
  10972. .Select(x => new
  10973. {
  10974. Id = x.Id,
  10975. GroupName = x.TeamName
  10976. })
  10977. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10978. return Ok(JsonView(true, "查询成功!", data, total));
  10979. }
  10980. /// <summary>
  10981. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10982. /// </summary>
  10983. /// <returns></returns>
  10984. [HttpPost]
  10985. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10986. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10987. {
  10988. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10989. RefAsync<int> total = 0;
  10990. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10991. .Where(x => x.IsDel == 0 && x.STid == 66)
  10992. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10993. .Select(x => new
  10994. {
  10995. id = x.Id,
  10996. name = x.Name,
  10997. remark = x.Remark,
  10998. })
  10999. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11000. return Ok(JsonView(true, "查询成功!", data, total));
  11001. }
  11002. /// <summary>
  11003. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  11004. /// </summary>
  11005. /// <returns></returns>
  11006. [HttpPost]
  11007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11008. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  11009. {
  11010. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11011. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11012. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  11013. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  11014. var groupOtherRateData = groupRateData.TeamRates;
  11015. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11016. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  11017. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  11018. groupOtherRateData = groupOtherRateData
  11019. .Select(x => new TeamRateDescAddCurrencyIdView
  11020. {
  11021. CurrencyId = x.CurrencyId,
  11022. CurrencyName = x.CurrencyName,
  11023. CurrencyCode = x.CurrencyCode,
  11024. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  11025. }).ToList();
  11026. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  11027. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  11028. }
  11029. /// <summary>
  11030. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  11031. /// </summary>
  11032. /// <returns></returns>
  11033. [HttpPost]
  11034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11035. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  11036. {
  11037. int portType = dto.PortType;
  11038. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11039. var tipsData = new List<int>() { 1, 2, 3 };
  11040. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  11041. if (dto.TipsType == 1)
  11042. {
  11043. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  11044. }
  11045. else if (dto.TipsType == 2)
  11046. {
  11047. if (portType == 2)
  11048. {
  11049. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11050. }
  11051. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11052. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  11053. .Select(x => x.NationalTravelFeeId)
  11054. .Distinct()
  11055. .ToListAsync();
  11056. if (portType == 2)
  11057. {
  11058. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11059. }
  11060. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  11061. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  11062. .Select(x => x.Country)
  11063. .Distinct()
  11064. .ToArrayAsync();
  11065. if (portType == 2)
  11066. {
  11067. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11068. }
  11069. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  11070. return Ok(JsonView(true, "查询成功!", new
  11071. {
  11072. totalAmt = totalAmt,
  11073. remark = remark
  11074. }));
  11075. }
  11076. else if (dto.TipsType == 3)
  11077. {
  11078. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  11079. }
  11080. return Ok(JsonView(false));
  11081. }
  11082. /// <summary>
  11083. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  11084. /// </summary>
  11085. /// <returns></returns>
  11086. [HttpPost]
  11087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11088. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  11089. {
  11090. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  11091. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11092. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11093. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  11094. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  11095. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  11096. var info = new Grp_EnterExitCostDraft()
  11097. {
  11098. ProvinceId = dto.ProvinceId,
  11099. DraftName = dto.DraftName,
  11100. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  11101. CreateUserId = dto.CurrUserId
  11102. };
  11103. _sqlSugar.BeginTran();
  11104. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11105. if (draftId < 1)
  11106. {
  11107. _sqlSugar.RollbackTran();
  11108. return Ok(JsonView(false, "草稿创建失败!"));
  11109. }
  11110. //添加默认权限
  11111. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  11112. _sqlSugar.CommitTran();
  11113. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  11114. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11115. mobileInfo.Id = draftId;
  11116. mobileInfo.DraftName = dto.DraftName;
  11117. mobileInfo.Currencys = rateInfos;
  11118. mobileInfo.IsAssignPerm = assignPerm;
  11119. return Ok(JsonView(mobileInfo));
  11120. }
  11121. /// <summary>
  11122. /// 出入境费用-草稿-移动端 查看编辑提示消息
  11123. /// </summary>
  11124. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  11125. /// <summary>
  11126. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  11127. /// </summary>
  11128. /// <returns></returns>
  11129. [HttpPost]
  11130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11131. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  11132. {
  11133. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11134. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11135. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11136. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11137. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  11138. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  11139. //验证查看编辑权限
  11140. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11141. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11142. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  11143. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  11144. mobileInfo.IsAssignPerm = assignPerm;
  11145. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11146. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11147. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11148. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11149. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11150. {
  11151. ParentId = dac.ParentId,
  11152. SubId = dac.Id,
  11153. Type = dac.Type,
  11154. Days = dac.Days,
  11155. NationalTravelFeeId = dac.NationalTravelFeeId,
  11156. Arae = $"{ntf.Country}-{ntf.City}",
  11157. Cost = dac.Cost,
  11158. Currency = dac.Currency,
  11159. CurrencyName = sd.Name,
  11160. SubTotal = dac.SubTotal,
  11161. })
  11162. .ToList();
  11163. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  11164. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  11165. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  11166. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  11167. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  11168. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  11169. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  11170. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  11171. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  11172. //其他款项
  11173. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11174. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11175. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11176. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11177. .OrderBy((dop, sd1, sd2) => dop.Index)
  11178. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11179. {
  11180. ParentId = dop.ParentId,
  11181. SubId = dop.Id,
  11182. Index = dop.Index,
  11183. SetDataId = dop.SetDataId,
  11184. SetDataName = sd1.Name,
  11185. Cost = dop.Cost,
  11186. Currency = dop.Currency,
  11187. CurrencyName = sd2.Remark,
  11188. SubTotal = dop.SubTotal,
  11189. Remark = dop.Remark,
  11190. })
  11191. .ToArray();
  11192. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  11193. return Ok(mobileInfo);
  11194. }
  11195. /// <summary>
  11196. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  11197. /// </summary>
  11198. /// <returns></returns>
  11199. [HttpPost]
  11200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11201. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  11202. {
  11203. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11204. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11205. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11206. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  11207. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  11208. //验证查看编辑权限
  11209. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11210. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11211. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11212. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  11213. var subType = dto.SubType;
  11214. if (subType == 1) //1:境内费用
  11215. {
  11216. var oneData = new ChoiceOneMobileSubInfoView()
  11217. {
  11218. Id = eecInfo.Id,
  11219. ChoiceOne = eecInfo.ChoiceOne,
  11220. ChoiceOneTotalCost = eecInfo.InsidePay,
  11221. Visa = eecInfo.Visa,
  11222. VisaRemark = eecInfo.VisaRemark,
  11223. YiMiao = eecInfo.YiMiao,
  11224. HeSuan = eecInfo.HeSuan,
  11225. Service = eecInfo.Service,
  11226. Ticket = eecInfo.Ticket,
  11227. Safe = eecInfo.Safe,
  11228. FirstItemRemark = eecInfo.FirstItemRemark
  11229. };
  11230. return Ok(JsonView(oneData));
  11231. }
  11232. else if (subType == 2) //2:国际旅费
  11233. {
  11234. var twoData = new ChoiceTwoMobileSubInfoView()
  11235. {
  11236. Id = eecInfo.Id,
  11237. ChoiceTwoJJ = eecInfo.SumJJC,
  11238. OutsideJJPay = eecInfo.OutsideJJPay,
  11239. ChoiceTwoGW = eecInfo.SumGWC,
  11240. OutsideGWPay = eecInfo.OutsideGWPay,
  11241. ChoiceTwoTD = eecInfo.SumTDC,
  11242. OutsideTDPay = eecInfo.OutsideTDPay,
  11243. AirJJ = eecInfo.AirJJ,
  11244. AirGW = eecInfo.AirGW,
  11245. AirTD = eecInfo.AirTD,
  11246. CityTranffic = eecInfo.CityTranffic,
  11247. TwoItemRemark = eecInfo.TwoItemRemark
  11248. };
  11249. return Ok(JsonView(twoData));
  11250. }
  11251. else if (subType == 3) //3:住宿费
  11252. {
  11253. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11254. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11255. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11256. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  11257. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11258. {
  11259. ParentId = dac.ParentId,
  11260. SubId = dac.Id,
  11261. Type = dac.Type,
  11262. Days = dac.Days,
  11263. NationalTravelFeeId = dac.NationalTravelFeeId,
  11264. Arae = $"{ntf.Country}-{ntf.City}",
  11265. Cost = dac.Cost,
  11266. Currency = dac.Currency,
  11267. CurrencyName = sd.Name,
  11268. SubTotal = dac.SubTotal,
  11269. })
  11270. .ToArray();
  11271. var data = new ChoiceDraftMobileSubInfo3To6View()
  11272. {
  11273. ParentId = eecInfo.Id,
  11274. Choice = eecInfo.ChoiceThree,
  11275. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11276. Details = dayAndCostDatas
  11277. };
  11278. return Ok(JsonView(data));
  11279. }
  11280. else if (subType == 4) //4:伙食费
  11281. {
  11282. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11283. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11284. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11285. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  11286. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11287. {
  11288. ParentId = dac.ParentId,
  11289. SubId = dac.Id,
  11290. Type = dac.Type,
  11291. Days = dac.Days,
  11292. NationalTravelFeeId = dac.NationalTravelFeeId,
  11293. Arae = $"{ntf.Country}-{ntf.City}",
  11294. Cost = dac.Cost,
  11295. Currency = dac.Currency,
  11296. CurrencyName = sd.Name,
  11297. SubTotal = dac.SubTotal,
  11298. })
  11299. .ToArray();
  11300. var data = new ChoiceDraftMobileSubInfo3To6View()
  11301. {
  11302. ParentId = eecInfo.Id,
  11303. Choice = eecInfo.ChoiceFour,
  11304. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11305. Details = dayAndCostDatas
  11306. };
  11307. return Ok(JsonView(data));
  11308. }
  11309. else if (subType == 5) //5:公杂费
  11310. {
  11311. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11312. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11313. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11314. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  11315. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11316. {
  11317. ParentId = dac.ParentId,
  11318. SubId = dac.Id,
  11319. Type = dac.Type,
  11320. Days = dac.Days,
  11321. NationalTravelFeeId = dac.NationalTravelFeeId,
  11322. Arae = $"{ntf.Country}-{ntf.City}",
  11323. Cost = dac.Cost,
  11324. Currency = dac.Currency,
  11325. CurrencyName = sd.Name,
  11326. SubTotal = dac.SubTotal,
  11327. })
  11328. .ToArray();
  11329. var data = new ChoiceDraftMobileSubInfo3To6View()
  11330. {
  11331. ParentId = eecInfo.Id,
  11332. Choice = eecInfo.ChoiceFive,
  11333. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11334. Details = dayAndCostDatas
  11335. };
  11336. return Ok(JsonView(data));
  11337. }
  11338. else if (subType == 6) //6:培训费
  11339. {
  11340. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11341. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11342. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11343. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  11344. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11345. {
  11346. ParentId = dac.ParentId,
  11347. SubId = dac.Id,
  11348. Type = dac.Type,
  11349. Days = dac.Days,
  11350. NationalTravelFeeId = dac.NationalTravelFeeId,
  11351. Arae = $"{ntf.Country}-{ntf.City}",
  11352. Cost = dac.Cost,
  11353. Currency = dac.Currency,
  11354. CurrencyName = sd.Name,
  11355. SubTotal = dac.SubTotal,
  11356. })
  11357. .ToArray();
  11358. var data = new ChoiceDraftMobileSubInfo3To6View()
  11359. {
  11360. ParentId = eecInfo.Id,
  11361. Choice = eecInfo.ChoiceSix,
  11362. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11363. Details = dayAndCostDatas
  11364. };
  11365. return Ok(JsonView(data));
  11366. }
  11367. else if (subType == 7) //7:其他
  11368. {
  11369. //其他款项
  11370. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11371. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11372. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11373. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11374. .OrderBy((dop, sd1, sd2) => dop.Index)
  11375. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11376. {
  11377. ParentId = dop.ParentId,
  11378. SubId = dop.Id,
  11379. Index = dop.Index,
  11380. SetDataId = dop.SetDataId,
  11381. SetDataName = sd1.Name,
  11382. Cost = dop.Cost,
  11383. Currency = dop.Currency,
  11384. CurrencyName = sd2.Name,
  11385. SubTotal = dop.SubTotal,
  11386. Remark = dop.Remark,
  11387. })
  11388. .ToArray();
  11389. var data = new ChoiceSevenDraftMobileSubInfoView()
  11390. {
  11391. ParentId = eecInfo.Id,
  11392. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11393. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11394. Details = otherData
  11395. };
  11396. return Ok(JsonView(data));
  11397. }
  11398. return Ok(JsonView(false));
  11399. }
  11400. #region op
  11401. ///// <summary>
  11402. ///// 移动端更新费用消息通知
  11403. ///// </summary>
  11404. ///// <param name="draftId"></param>
  11405. ///// <param name="id"></param>
  11406. ///// <param name="currUserId"></param>
  11407. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11408. //{
  11409. // try
  11410. // {
  11411. // ////生成默认文件pdf并且通知人员
  11412. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11413. // //{
  11414. // // DiId = draftId,
  11415. // // ExportType = 1,
  11416. // // SubTypeId = 1005
  11417. // //}, "pdf");
  11418. // ////发送通知
  11419. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11420. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11421. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11422. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11423. // ////汇率信息记录
  11424. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11425. // }
  11426. // catch (Exception ex)
  11427. // {
  11428. // //记录日志
  11429. // throw;
  11430. // }
  11431. //}
  11432. /// <summary>
  11433. /// 验证出入境费用数据是否存在
  11434. /// 不存在添加
  11435. /// </summary>
  11436. /// <param name="draftId"></param>
  11437. /// <param name="currUserId"></param>
  11438. /// <returns></returns>
  11439. /// <exception cref="CustomException"></exception>
  11440. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11441. {
  11442. var parentId = 0;
  11443. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11444. if (info != null) parentId = info.Id;
  11445. else
  11446. {
  11447. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11448. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11449. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11450. parentId = addId;
  11451. }
  11452. return parentId;
  11453. }
  11454. /// <summary>
  11455. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11456. /// </summary>
  11457. /// <returns></returns>
  11458. [HttpPost]
  11459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11460. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11461. {
  11462. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11463. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11464. //验证查看权限
  11465. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11466. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11467. var userIds = await _sqlSugar
  11468. .Queryable<Grp_EnterExitCostDraftPermission>()
  11469. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11470. .Select(x => x.UserId)
  11471. .ToArrayAsync();
  11472. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11473. var perUsersView = new List<dynamic>();
  11474. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11475. var viewPermissionData = new List<PermissionViewUserview>();
  11476. if (feeBasePerm.Any())
  11477. {
  11478. foreach (var item in feeBasePerm)
  11479. {
  11480. if (item.Users.Any())
  11481. {
  11482. viewPermissionData.AddRange(item.Users);
  11483. }
  11484. }
  11485. }
  11486. foreach (var item in perUsers)
  11487. {
  11488. bool isView1 = false;
  11489. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11490. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11491. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11492. }
  11493. return Ok(JsonView(perUsersView));
  11494. }
  11495. /// <summary>
  11496. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11497. /// </summary>
  11498. /// <returns></returns>
  11499. [HttpPost]
  11500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11501. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11502. {
  11503. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11504. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11505. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11506. //验证查看编辑权限
  11507. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11508. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11509. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11510. foreach (var userId in dto.UserIds)
  11511. {
  11512. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11513. }
  11514. if (permissions.Any())
  11515. {
  11516. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11517. {
  11518. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11519. }
  11520. _sqlSugar.BeginTran();
  11521. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11522. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11523. if (result < 1)
  11524. {
  11525. _sqlSugar.RollbackTran();
  11526. return Ok(JsonView(false));
  11527. }
  11528. _sqlSugar.CommitTran();
  11529. return Ok(JsonView(true));
  11530. }
  11531. return Ok(JsonView(false));
  11532. }
  11533. /// <summary>
  11534. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11535. /// </summary>
  11536. /// <returns></returns>
  11537. [HttpPost]
  11538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11539. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11540. {
  11541. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11542. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11543. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11544. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11545. int id = dto.DraftId;
  11546. if (id <= 0) //add
  11547. {
  11548. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11549. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11550. if (add < 1) return Ok(JsonView(false));
  11551. id = add;
  11552. }
  11553. else //update
  11554. {
  11555. //验证查看编辑权限
  11556. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11557. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11558. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11559. if (upd < 1) return Ok(JsonView(false));
  11560. }
  11561. return Ok(JsonView(new { parentId = id }));
  11562. }
  11563. /// <summary>
  11564. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11565. /// </summary>
  11566. /// <returns></returns>
  11567. [HttpPost]
  11568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11569. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11570. {
  11571. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11572. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11573. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11574. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11575. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11576. int id = dto.DraftId;
  11577. if (id <= 0) //add
  11578. {
  11579. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11580. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11581. if (add < 1) return Ok(JsonView(false));
  11582. id = add;
  11583. }
  11584. else //update
  11585. {
  11586. //验证查看编辑权限
  11587. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11588. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11589. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11590. if (upd < 1) return Ok(JsonView(false));
  11591. }
  11592. #region 汇率变更时更改币种相关费用
  11593. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11594. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11595. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11596. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11597. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11598. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11599. .Select((dac, sd) => new
  11600. {
  11601. dac.Id,
  11602. dac.ParentId,
  11603. CurrencyCode = sd.Name,
  11604. dac.Cost
  11605. })
  11606. .ToList();
  11607. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11608. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11609. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11610. .Select((dop, sd) => new
  11611. {
  11612. dop.Id,
  11613. dop.ParentId,
  11614. CurrencyCode = sd.Name,
  11615. dop.Cost
  11616. })
  11617. .ToList();
  11618. if (dayCosts.Count > 0)
  11619. {
  11620. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11621. foreach (var dc in new_dayCosts)
  11622. {
  11623. var thisCurrency = dc.Key.ToUpper();
  11624. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11625. if (thisRate == 0.00M) continue;
  11626. foreach (var dcSub in dc)
  11627. {
  11628. opDayCosts.Add(new Grp_DayAndCostDraft()
  11629. {
  11630. Id = dcSub.Id,
  11631. ParentId = dcSub.ParentId,
  11632. Cost = dcSub.Cost,
  11633. SubTotal = dcSub.Cost * thisRate,
  11634. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11635. });
  11636. }
  11637. }
  11638. if (opDayCosts.Count > 0)
  11639. {
  11640. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11641. }
  11642. }
  11643. if (dayOtherCosts.Count > 0)
  11644. {
  11645. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11646. foreach (var dc in new_dayOtherCosts)
  11647. {
  11648. var thisCurrency = dc.Key.ToUpper();
  11649. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11650. if (thisRate == 0.00M) continue;
  11651. foreach (var dcSub in dc)
  11652. {
  11653. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11654. {
  11655. Id = dcSub.Id,
  11656. ParentId = dcSub.ParentId,
  11657. Cost = dcSub.Cost,
  11658. SubTotal = dcSub.Cost * thisRate,
  11659. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11660. });
  11661. }
  11662. }
  11663. if (opDayOtherCosts.Count > 0)
  11664. {
  11665. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11666. }
  11667. }
  11668. #endregion
  11669. ////消息通知
  11670. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11671. ////汇率信息记录
  11672. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11673. return Ok(JsonView(new { parentId = id }));
  11674. }
  11675. /// <summary>
  11676. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11677. /// </summary>
  11678. /// <returns></returns>
  11679. [HttpPost]
  11680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11681. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11682. {
  11683. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11684. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11685. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11686. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11687. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11688. int id = dto.DraftId;
  11689. if (id <= 0) //add
  11690. {
  11691. checkboxInfo.ProvinceId = dto.ProvinceId;
  11692. checkboxInfo.CreateUserId = dto.CurrUserId;
  11693. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11694. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11695. if (add < 1) return Ok(JsonView(false));
  11696. }
  11697. else //update
  11698. {
  11699. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11700. .UpdateColumns(x => new
  11701. {
  11702. x.ChoiceOne,
  11703. x.ChoiceTwo,
  11704. x.SumJJC,
  11705. x.SumGWC,
  11706. x.SumTDC,
  11707. x.ChoiceThree,
  11708. x.ChoiceFour,
  11709. x.ChoiceFive,
  11710. x.ChoiceSix,
  11711. x.OtherExpenses_Checked
  11712. })
  11713. .Where(x => x.Id == id)
  11714. .ExecuteCommandAsync();
  11715. if (upd < 1) return Ok(JsonView(false));
  11716. }
  11717. return Ok(JsonView(new { parentId = id }));
  11718. }
  11719. /// <summary>
  11720. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11721. /// </summary>
  11722. /// <returns></returns>
  11723. [HttpPost]
  11724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11725. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11726. {
  11727. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11728. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11729. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11730. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11731. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11732. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11733. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11734. var checkboxInfo = new Grp_EnterExitCostDraft()
  11735. {
  11736. Id = draftId,
  11737. ProvinceId = dto.ProvinceId,
  11738. CreateUserId = currUserId
  11739. };
  11740. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11741. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11742. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11743. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11744. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11745. if (draftId <= 0) //add
  11746. {
  11747. checkboxInfo.CreateUserId = dto.CurrUserId;
  11748. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11749. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11750. if (add < 1) return Ok(JsonView(false));
  11751. }
  11752. else //update
  11753. {
  11754. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11755. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11756. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11757. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11758. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11759. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11760. .Where(x => x.Id == draftId)
  11761. .ExecuteCommandAsync();
  11762. if (upd < 1) return Ok(JsonView(false));
  11763. }
  11764. return Ok(JsonView(new { parentId = draftId }));
  11765. }
  11766. /// <summary>
  11767. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11768. /// </summary>
  11769. /// <returns></returns>
  11770. [HttpPost]
  11771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11772. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11773. {
  11774. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11775. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11776. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11777. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11778. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11779. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11780. info.ProvinceId = dto.ProvinceId;
  11781. info.FirstItemRemark = dto.FirstItemRemark;
  11782. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11783. if (id <= 0) //add
  11784. {
  11785. info.CreateUserId = dto.CurrUserId;
  11786. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11787. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11788. if (add < 1) return Ok(JsonView(false));
  11789. id = add;
  11790. }
  11791. else //update
  11792. {
  11793. var upd = await _sqlSugar.Updateable(info)
  11794. .UpdateColumns(x => new
  11795. {
  11796. x.ChoiceOne,
  11797. x.InsidePay,
  11798. x.VisaRemark,
  11799. x.Visa,
  11800. x.Service,
  11801. x.Safe,
  11802. x.Ticket,
  11803. x.HeSuan,
  11804. x.YiMiao,
  11805. x.FirstItemRemark
  11806. })
  11807. .Where(x => x.Id == id)
  11808. .ExecuteCommandAsync();
  11809. if (upd < 1) return Ok(JsonView(false));
  11810. }
  11811. ////消息通知
  11812. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11813. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11814. }
  11815. /// <summary>
  11816. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11817. /// </summary>
  11818. /// <returns></returns>
  11819. [HttpPost]
  11820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11821. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11822. {
  11823. int id = dto.DraftId;
  11824. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11825. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11826. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11827. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11828. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11829. info.ProvinceId = dto.ProvinceId;
  11830. info.OutsideJJPay = dto.OutsideJJPay;
  11831. info.OutsideGWPay = dto.OutsideGWPay;
  11832. info.OutsideTDPay = dto.OutsideTDPay;
  11833. info.AirJJ = dto.AirJJ;
  11834. info.AirGW = dto.AirGW;
  11835. info.AirTD = dto.AirTD;
  11836. info.CityTranffic = dto.CityTranffic;
  11837. info.TwoItemRemark = dto.TwoItemRemark;
  11838. info.SumJJC = dto.ChoiceTwoJJ;
  11839. info.SumGWC = dto.ChoiceTwoGW;
  11840. info.SumTDC = dto.ChoiceTwoTD;
  11841. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11842. if (id <= 0) //add
  11843. {
  11844. info.CreateUserId = dto.CurrUserId;
  11845. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11846. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11847. if (addId <= 0) return Ok(JsonView(false));
  11848. id = addId;
  11849. }
  11850. else //update
  11851. {
  11852. var upd = await _sqlSugar.Updateable(info)
  11853. .UpdateColumns(x => new
  11854. {
  11855. x.SumJJC,
  11856. x.OutsideJJPay,
  11857. x.SumGWC,
  11858. x.OutsideGWPay,
  11859. x.SumTDC,
  11860. x.OutsideTDPay,
  11861. x.AirJJ,
  11862. x.AirGW,
  11863. x.AirTD,
  11864. x.CityTranffic,
  11865. x.TwoItemRemark
  11866. })
  11867. .Where(x => x.Id == id)
  11868. .ExecuteCommandAsync();
  11869. if (upd < 1) return Ok(JsonView(false));
  11870. }
  11871. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11872. gwcItemTotal = info.AirGW + info.CityTranffic;
  11873. tdcItemTotal = info.AirTD + info.CityTranffic;
  11874. ////消息通知
  11875. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11876. return Ok(JsonView(new
  11877. {
  11878. parentId = id,
  11879. choiceTwoJJ = dto.ChoiceTwoJJ,
  11880. jjcItemTotal = jjcItemTotal,
  11881. choiceTwoGW = dto.ChoiceTwoGW,
  11882. gwcItemTotal = gwcItemTotal,
  11883. choiceTwoTD = dto.ChoiceTwoTD,
  11884. tdcItemTotal = tdcItemTotal
  11885. }));
  11886. }
  11887. /// <summary>
  11888. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11889. /// </summary>
  11890. /// <returns></returns>
  11891. [HttpPost]
  11892. [ApiExplorerSettings(IgnoreApi = true)]
  11893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11894. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11895. {
  11896. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11897. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11898. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11899. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11900. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11901. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11902. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11903. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11904. {
  11905. Id = x.Id,
  11906. ParentId = dto.DraftId,
  11907. Type = dto.FeeType,
  11908. Days = x.Days,
  11909. NationalTravelFeeId = x.NationalTravelFeeId,
  11910. Cost = x.Cost,
  11911. Currency = x.Currency,
  11912. SubTotal = x.SubTotal,
  11913. CreateUserId = dto.CurrUserId
  11914. })
  11915. .ToList();
  11916. var adds = infos.Where(x => x.Id <= 0).ToList();
  11917. var upds = infos.Where(x => x.Id > 0).ToList();
  11918. if (adds.Count > 0)
  11919. {
  11920. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11921. if (add < 1) return Ok(JsonView(false));
  11922. }
  11923. if (upds.Count > 0)
  11924. {
  11925. var upd = await _sqlSugar.Updateable(adds)
  11926. .UpdateColumns(x => new
  11927. {
  11928. x.Days,
  11929. x.NationalTravelFeeId,
  11930. x.Cost,
  11931. x.Currency,
  11932. x.SubTotal
  11933. })
  11934. .WhereColumns(x => new { x.Id })
  11935. .ExecuteCommandAsync();
  11936. if (upd < 1) return Ok(JsonView(false));
  11937. }
  11938. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11939. ////消息通知
  11940. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11941. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11942. return Ok(JsonView(new { itemTotal = itemTotal }));
  11943. }
  11944. /// <summary>
  11945. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11946. /// </summary>
  11947. /// <returns></returns>
  11948. [HttpPost]
  11949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11950. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11951. {
  11952. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11953. int subId = dto.SubId, feeType = dto.FeeType;
  11954. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11955. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11956. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11957. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11958. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11959. subInfo.Id = subId;
  11960. subInfo.ParentId = dto.DraftId;
  11961. if (feeType == 3) subInfo.Type = 1;
  11962. else if (feeType == 4) subInfo.Type = 2;
  11963. else if (feeType == 5) subInfo.Type = 3;
  11964. else if (feeType == 6) subInfo.Type = 4;
  11965. subInfo.CreateUserId = dto.CurrUserId;
  11966. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11967. if (parentId < 1) return Ok(JsonView(false));
  11968. //子表op
  11969. if (subId < 1)
  11970. {
  11971. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11972. if (subAdd < 1) return Ok(JsonView(false));
  11973. }
  11974. else
  11975. {
  11976. var subUpd = await _sqlSugar.Updateable(subInfo)
  11977. .UpdateColumns(x => new
  11978. {
  11979. x.Days,
  11980. x.NationalTravelFeeId,
  11981. x.Cost,
  11982. x.Currency,
  11983. x.SubTotal
  11984. })
  11985. .WhereColumns(x => new { x.Id })
  11986. .ExecuteCommandAsync();
  11987. if (subUpd < 1) return Ok(JsonView(false));
  11988. }
  11989. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11990. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11991. }
  11992. /// <summary>
  11993. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11994. /// </summary>
  11995. /// <returns></returns>
  11996. [HttpPost]
  11997. [ApiExplorerSettings(IgnoreApi = true)]
  11998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11999. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  12000. {
  12001. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12002. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12003. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12004. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  12005. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  12006. {
  12007. Id = x.Id,
  12008. ParentId = dto.DraftId,
  12009. SetDataId = x.SetDataId,
  12010. Index = x.Index,
  12011. Cost = x.Cost,
  12012. Currency = x.Currency,
  12013. SubTotal = x.SubTotal,
  12014. CreateUserId = dto.CurrUserId,
  12015. Remark = x.Remark
  12016. }).ToList();
  12017. var adds = infos.Where(x => x.Id <= 0).ToList();
  12018. var upds = infos.Where(x => x.Id > 0).ToList();
  12019. if (adds.Count > 0)
  12020. {
  12021. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12022. if (add < 1) return Ok(JsonView(false));
  12023. }
  12024. if (upds.Count > 0)
  12025. {
  12026. var upd = await _sqlSugar.Updateable(adds)
  12027. .UpdateColumns(x => new
  12028. {
  12029. x.Index,
  12030. x.SetDataId,
  12031. x.Cost,
  12032. x.Currency,
  12033. x.SubTotal,
  12034. x.Remark
  12035. })
  12036. .WhereColumns(x => new { x.Id })
  12037. .ExecuteCommandAsync();
  12038. if (upd < 1) return Ok(JsonView(false));
  12039. }
  12040. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  12041. //消息通知
  12042. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  12043. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12044. return Ok(JsonView(new { itemTotal = itemTotal }));
  12045. }
  12046. /// <summary>
  12047. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  12048. /// </summary>
  12049. /// <returns></returns>
  12050. [HttpPost]
  12051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12052. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  12053. {
  12054. int subId = dto.SubId, id = dto.DraftId;
  12055. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12056. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  12057. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12058. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  12059. subInfo.Id = subId;
  12060. subInfo.ParentId = id;
  12061. subInfo.CreateUserId = dto.CurrUserId;
  12062. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  12063. if (parentId < 1) return Ok(JsonView(false));
  12064. #region 子表op
  12065. if (subId < 1)//add
  12066. {
  12067. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12068. if (subAdd < 1) return Ok(JsonView(false));
  12069. }
  12070. else //upd
  12071. {
  12072. var subUpd = await _sqlSugar.Updateable(subInfo)
  12073. .UpdateColumns(x => new
  12074. {
  12075. x.Index,
  12076. x.SetDataId,
  12077. x.Cost,
  12078. x.Currency,
  12079. x.SubTotal,
  12080. x.Remark
  12081. })
  12082. .WhereColumns(x => new { x.Id })
  12083. .ExecuteCommandAsync();
  12084. if (subUpd < 1) return Ok(JsonView(false));
  12085. }
  12086. #endregion
  12087. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  12088. ////消息通知
  12089. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  12090. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12091. }
  12092. /// <summary>
  12093. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  12094. /// </summary>
  12095. /// <returns></returns>
  12096. [HttpPost]
  12097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12098. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  12099. {
  12100. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  12101. if (data.Code != 0)
  12102. {
  12103. return Ok(JsonView(false, data.Msg));
  12104. }
  12105. return Ok(JsonView(true, "操作成功!", data.Data));
  12106. }
  12107. /// <summary>
  12108. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  12109. /// </summary>
  12110. /// <param name="dto"></param>
  12111. /// <returns></returns>
  12112. [HttpPost]
  12113. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  12114. {
  12115. var data = new Grp_DayOtherPriceDraft()
  12116. {
  12117. Id = dto.Id,
  12118. IsDel = 1,
  12119. DeleteUserId = dto.DeleteUserId,
  12120. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  12121. };
  12122. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  12123. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  12124. return Ok(JsonView(false, "删除失败!"));
  12125. }
  12126. #endregion
  12127. #endregion
  12128. #region 团组经理模块 出入境费用报价表
  12129. /// <summary>
  12130. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  12131. /// </summary>
  12132. /// <returns></returns>
  12133. [HttpPost]
  12134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12135. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  12136. {
  12137. var initRates = await GeneralMethod.EnterExitCostInitRate();
  12138. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  12139. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  12140. initRates.Insert(0, cnyInfo);
  12141. liveRates.Insert(0, cnyInfo);
  12142. return Ok(JsonView(true, "查询成功!", new
  12143. {
  12144. InitRates = initRates,
  12145. LiveRates = liveRates
  12146. }));
  12147. }
  12148. /// <summary>
  12149. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  12150. /// </summary>
  12151. /// <returns></returns>
  12152. [HttpPost]
  12153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12154. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  12155. {
  12156. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  12157. }
  12158. /// <summary>
  12159. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  12160. /// </summary>
  12161. /// <returns></returns>
  12162. [HttpPost]
  12163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12164. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  12165. {
  12166. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  12167. }
  12168. /// <summary>
  12169. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  12170. /// </summary>
  12171. /// <returns></returns>
  12172. [HttpPost]
  12173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12174. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  12175. {
  12176. int groupId = dto.DiId,
  12177. currUserId = dto.CurrUserId;
  12178. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  12179. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  12180. //验证报价数据是否存在
  12181. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  12182. if (isNull != null)
  12183. {
  12184. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  12185. if (!info1.Rates.Any())
  12186. {
  12187. var rates = await GeneralMethod.EnterExitCostInitRate();
  12188. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12189. info1.Rates = rates.ToArray();
  12190. }
  12191. return Ok(JsonView(info1));
  12192. }
  12193. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  12194. result.GroupId = groupId;
  12195. //处理报价名称
  12196. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  12197. if (groupInfo != null)
  12198. {
  12199. var visitCountry = groupInfo.VisitCountry;
  12200. if (!string.IsNullOrEmpty(visitCountry))
  12201. {
  12202. string quoteName = string.Empty;
  12203. if (visitCountry.Contains("|"))
  12204. {
  12205. var countrys = visitCountry.Split("|");
  12206. quoteName = string.Join("、", countrys);
  12207. }
  12208. else quoteName = visitCountry;
  12209. quoteName += $"团组报价表";
  12210. result.Name = quoteName;
  12211. }
  12212. }
  12213. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  12214. if (info.Code != StatusCodes.Status200OK)
  12215. {
  12216. if (!result.Rates.Any())
  12217. {
  12218. var rates = await GeneralMethod.EnterExitCostInitRate();
  12219. result.Rates = rates.ToArray();
  12220. }
  12221. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  12222. }
  12223. var infoView = info.Data as EnterExitCostInfoView;
  12224. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  12225. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  12226. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  12227. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  12228. var eecRates = infoView.Currencys;
  12229. //默认添加人名币
  12230. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  12231. {
  12232. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12233. }
  12234. //处理团组人数
  12235. int pplNum = 1;
  12236. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  12237. var views = new List<QuoteSubItemInfo>();
  12238. #region 数据填充
  12239. var intTravelCosts = new List<QuoteSubItemInfo>();
  12240. #region 机票费用 1354
  12241. int intTravelIndex = 1;
  12242. if (infoView.SumJJC == 1)
  12243. {
  12244. intTravelCosts.Add(new QuoteSubItemInfo
  12245. {
  12246. ItemId = 1354,
  12247. Index = intTravelIndex,
  12248. FeeName = "经济舱",
  12249. UnitPrice = infoView.AirJJ,
  12250. Currency = "CNY",
  12251. Quantity = 1,
  12252. PplNum = 1,
  12253. TotalAmt = infoView.AirJJ,
  12254. Remark = "",
  12255. });
  12256. intTravelIndex++;
  12257. }
  12258. if (infoView.SumGWC == 1)
  12259. {
  12260. intTravelCosts.Add(new QuoteSubItemInfo
  12261. {
  12262. ItemId = 1354,
  12263. Index = intTravelIndex,
  12264. FeeName = "公务舱",
  12265. UnitPrice = infoView.AirGW,
  12266. Currency = "CNY",
  12267. Quantity = 1,
  12268. PplNum = 1,
  12269. TotalAmt = infoView.AirGW,
  12270. Remark = "",
  12271. });
  12272. intTravelIndex++;
  12273. }
  12274. if (infoView.SumTDC == 1)
  12275. {
  12276. intTravelCosts.Add(new QuoteSubItemInfo
  12277. {
  12278. ItemId = 1354,
  12279. Index = intTravelIndex,
  12280. FeeName = "头等舱",
  12281. UnitPrice = infoView.AirTD,
  12282. Currency = "CNY",
  12283. Quantity = 1,
  12284. PplNum = 1,
  12285. TotalAmt = infoView.AirTD,
  12286. Remark = "",
  12287. });
  12288. intTravelIndex++;
  12289. }
  12290. intTravelCosts.Add(new QuoteSubItemInfo
  12291. {
  12292. ItemId = 1354,
  12293. Index = intTravelIndex,
  12294. FeeName = "城市间交通费用",
  12295. UnitPrice = infoView.CityTranffic,
  12296. Currency = "CNY",
  12297. Quantity = 1,
  12298. PplNum = pplNum,
  12299. TotalAmt = infoView.CityTranffic * pplNum,
  12300. Remark = "",
  12301. });
  12302. views.AddRange(intTravelCosts);
  12303. #endregion
  12304. var accomCosts = new List<QuoteSubItemInfo>();
  12305. #region 住宿费 1355
  12306. if (infoView.QuarterageData.Any())
  12307. {
  12308. int accomIndex = 1;
  12309. int accomItemTypeId = 1355;
  12310. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  12311. foreach (var item in groupData)
  12312. {
  12313. string feeName = string.Empty;
  12314. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12315. if (countryInfo != null)
  12316. {
  12317. feeName = countryInfo.Country;
  12318. var city = countryInfo.City;
  12319. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12320. {
  12321. feeName += $"-{city}";
  12322. }
  12323. }
  12324. var hotelInfo = item.FirstOrDefault();
  12325. if (hotelInfo == null) continue;
  12326. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  12327. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12328. int quantity = item.ToList().Count;
  12329. accomCosts.Add(new QuoteSubItemInfo
  12330. {
  12331. ItemId = accomItemTypeId,
  12332. Index = accomIndex,
  12333. FeeName = feeName,
  12334. UnitPrice = hotelInfo.Cost,
  12335. Currency = thisCurrency,
  12336. Quantity = quantity,
  12337. PplNum = pplNum,
  12338. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  12339. Remark = "",
  12340. });
  12341. accomIndex++;
  12342. }
  12343. views.AddRange(accomCosts);
  12344. }
  12345. #endregion
  12346. var mealCosts = new List<QuoteSubItemInfo>();
  12347. #region 餐饮费 1356
  12348. if (infoView.BoardWagesData.Any())
  12349. {
  12350. var mealIndex = 1;
  12351. int mealItemTypeId = 1356;
  12352. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  12353. foreach (var item in groupData)
  12354. {
  12355. string feeName = string.Empty;
  12356. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12357. if (countryInfo != null)
  12358. {
  12359. feeName = countryInfo.Country;
  12360. var city = countryInfo.City;
  12361. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12362. {
  12363. feeName += $"-{city}";
  12364. }
  12365. }
  12366. var mealInfo = item.FirstOrDefault();
  12367. if (mealInfo == null) continue;
  12368. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12369. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12370. int quantity = item.ToList().Count;
  12371. mealCosts.Add(new QuoteSubItemInfo
  12372. {
  12373. ItemId = mealItemTypeId,
  12374. Index = mealIndex,
  12375. FeeName = feeName,
  12376. UnitPrice = mealInfo.Cost,
  12377. Currency = thisCurrency,
  12378. Quantity = quantity,
  12379. PplNum = pplNum,
  12380. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12381. Remark = "",
  12382. });
  12383. mealIndex++;
  12384. }
  12385. views.AddRange(mealCosts);
  12386. }
  12387. #endregion
  12388. var miscCosts = new List<QuoteSubItemInfo>();
  12389. #region 公杂费 1364
  12390. if (infoView.MiscellaneousFeeData.Any())
  12391. {
  12392. var miscIndex = 1;
  12393. int miscItemTypeId = 1364;
  12394. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12395. foreach (var item in groupData)
  12396. {
  12397. string feeName = string.Empty;
  12398. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12399. if (countryInfo != null)
  12400. {
  12401. feeName = countryInfo.Country;
  12402. var city = countryInfo.City;
  12403. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12404. {
  12405. feeName += $"-{city}";
  12406. }
  12407. }
  12408. var miscInfo = item.FirstOrDefault();
  12409. if (miscInfo == null) continue;
  12410. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12411. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12412. int quantity = item.ToList().Count;
  12413. miscCosts.Add(new QuoteSubItemInfo
  12414. {
  12415. ItemId = miscItemTypeId,
  12416. Index = miscIndex,
  12417. FeeName = feeName,
  12418. UnitPrice = miscInfo.Cost,
  12419. Currency = thisCurrency,
  12420. Quantity = quantity,
  12421. PplNum = pplNum,
  12422. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12423. Remark = "",
  12424. });
  12425. miscIndex++;
  12426. }
  12427. views.AddRange(miscCosts);
  12428. }
  12429. #endregion
  12430. #region 签证+保险 1362
  12431. int visaInsIndex = 1;
  12432. int visaInsItemTypeId = 1362;
  12433. if (infoView.Visa > 0)
  12434. {
  12435. views.Add(new QuoteSubItemInfo()
  12436. {
  12437. ItemId = visaInsItemTypeId,
  12438. Index = visaInsIndex,
  12439. FeeName = $"签证",
  12440. UnitPrice = infoView.Visa,
  12441. Currency = $"CNY",
  12442. Quantity = 1,
  12443. PplNum = pplNum,
  12444. TotalAmt = infoView.Visa * pplNum,
  12445. Remark = "",
  12446. });
  12447. visaInsIndex++;
  12448. }
  12449. if (infoView.Safe > 0)
  12450. {
  12451. views.Add(new QuoteSubItemInfo()
  12452. {
  12453. ItemId = visaInsItemTypeId,
  12454. Index = visaInsIndex,
  12455. FeeName = $"保险",
  12456. UnitPrice = infoView.Safe,
  12457. Currency = $"CNY",
  12458. Quantity = 1,
  12459. PplNum = pplNum,
  12460. TotalAmt = infoView.Safe * pplNum,
  12461. Remark = "",
  12462. });
  12463. }
  12464. #endregion
  12465. #region 服务费 1363
  12466. int serviceFeeIndex = 1;
  12467. int serviceFeeItemTypeId = 1363;
  12468. if (infoView.Service > 0)
  12469. {
  12470. views.Add(new QuoteSubItemInfo()
  12471. {
  12472. ItemId = serviceFeeItemTypeId,
  12473. Index = serviceFeeIndex,
  12474. FeeName = $"服务费",
  12475. UnitPrice = infoView.Service,
  12476. Currency = $"CNY",
  12477. Quantity = 1,
  12478. PplNum = pplNum,
  12479. TotalAmt = infoView.Service * pplNum,
  12480. Remark = "",
  12481. });
  12482. }
  12483. #endregion
  12484. #endregion
  12485. if (result.FeeItems.Any())
  12486. {
  12487. result.FeeItems.Select(x =>
  12488. {
  12489. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12490. if (feeInfos.Any()) x.Infos = feeInfos;
  12491. return x;
  12492. }
  12493. ).OrderBy(x => x.Index)
  12494. .ToList();
  12495. if (!result.Rates.Any())
  12496. {
  12497. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12498. else
  12499. {
  12500. var rates = await GeneralMethod.EnterExitCostInitRate();
  12501. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12502. result.Rates = rates.ToArray();
  12503. }
  12504. }
  12505. }
  12506. return Ok(JsonView(result));
  12507. }
  12508. /// <summary>
  12509. /// 团组模块 - 出入境费用报价表 - Info
  12510. /// </summary>
  12511. /// <returns></returns>
  12512. [HttpPost]
  12513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12514. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12515. {
  12516. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12517. if (!info.Rates.Any())
  12518. {
  12519. var rates = await GeneralMethod.EnterExitCostInitRate();
  12520. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12521. info.Rates = rates.ToArray();
  12522. }
  12523. return Ok(JsonView(info));
  12524. }
  12525. /// <summary>
  12526. /// 团组模块 - 出入境费用报价表 - OP
  12527. /// </summary>
  12528. /// <returns></returns>
  12529. [HttpPost]
  12530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12531. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12532. {
  12533. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12534. }
  12535. /// <summary>
  12536. /// 团组模块 - 出入境费用报价表 - 删除 项
  12537. /// </summary>
  12538. /// <returns></returns>
  12539. [HttpPost]
  12540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12541. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12542. {
  12543. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12544. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12545. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12546. }
  12547. /// <summary>
  12548. /// 团组模块 - 出入境费用报价表 - 导出
  12549. /// </summary>
  12550. /// <returns></returns>
  12551. [HttpPost]
  12552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12553. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12554. {
  12555. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12556. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12557. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12558. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12559. var rates = info.Rates;
  12560. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12561. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12562. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12563. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12564. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12565. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12566. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12567. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12568. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12569. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12570. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12571. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12572. //获取模板
  12573. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12574. var designer = new WorkbookDesigner();
  12575. designer.Workbook = new Workbook(tempPath);
  12576. designer.SetDataSource("QuoteName", info.Name);
  12577. designer.SetDataSource("CompanyTitle", "公司名称");
  12578. designer.SetDataSource("CompanyLabel", "");
  12579. #region 国际旅费
  12580. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12581. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12582. {
  12583. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12584. var label = new StringBuilder();
  12585. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12586. if (infos.Any())
  12587. {
  12588. label.Append(infos.Sum(x => x.PplNum));
  12589. label.Append("人全程机票:");
  12590. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12591. label.AppendLine("元");
  12592. }
  12593. foreach (var item in intTravelCosts.Infos)
  12594. {
  12595. label.Append(item.FeeName);
  12596. label.Append(":");
  12597. label.Append(item.UnitPrice.TruncDecimals(2));
  12598. label.Append("元/人*");
  12599. label.Append(item.PplNum);
  12600. label.AppendLine("人");
  12601. }
  12602. if (label.HasValue())
  12603. {
  12604. label.Append("\r\n以上小计:");
  12605. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12606. label.Append("元");
  12607. }
  12608. designer.SetDataSource("IntTravelLabel", label.ToString());
  12609. }
  12610. #endregion
  12611. #region 住宿费
  12612. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12613. if (accomCosts != null && accomCosts.Infos.Any())
  12614. {
  12615. string currencyName = string.Empty,
  12616. countryName = string.Empty;
  12617. decimal rate = 1.0000M;
  12618. var label = new StringBuilder();
  12619. label.AppendLine("全程五星酒店,每人1间房");
  12620. foreach (var item in accomCosts.Infos)
  12621. {
  12622. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12623. string name = string.Empty, thisCountryName = string.Empty;
  12624. if (item.FeeName.Contains('-'))
  12625. {
  12626. var feeName = item.FeeName.Split('-');
  12627. thisCountryName = feeName[0];
  12628. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12629. name = feeName[1];
  12630. }
  12631. else name = item.FeeName;
  12632. string thisFeeName = string.Empty;
  12633. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12634. else thisFeeName = $"\r\n{name}:";
  12635. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12636. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12637. rate = rateInfo?.Rate ?? 1.0000M;
  12638. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12639. label.AppendLine(subLabel);
  12640. }
  12641. if (label.HasValue())
  12642. {
  12643. //以上小计:52440元(美金汇率:7.5 )
  12644. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12645. label.AppendLine(subLabel);
  12646. }
  12647. designer.SetDataSource("AccomLabel", label.ToString());
  12648. }
  12649. #endregion
  12650. #region 餐饮费
  12651. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12652. if (mealCosts != null && mealCosts.Infos.Any())
  12653. {
  12654. string currencyName = string.Empty;
  12655. decimal rate = 1.0000M;
  12656. var label = new StringBuilder();
  12657. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12658. foreach (var item in mealCosts.Infos)
  12659. {
  12660. string name = string.Empty;
  12661. if (item.FeeName.Contains('-'))
  12662. {
  12663. var feeName = item.FeeName.Split('-');
  12664. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12665. }
  12666. else name = $"\r\n{item.FeeName}:";
  12667. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12668. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12669. rate = rateInfo?.Rate ?? 1.0000M;
  12670. label.Append(name);
  12671. label.Append(item.UnitPrice.TruncDecimals(2));
  12672. label.Append(currencyName);
  12673. label.Append("/天*");
  12674. label.Append(item.Quantity.ToString("#0"));
  12675. label.Append('*');
  12676. label.Append(item.PplNum);
  12677. label.Append("人\r\n");
  12678. }
  12679. if (label.HasValue())
  12680. {
  12681. label.Append("\r\n以上小计:");
  12682. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12683. label.Append("元\r\n(");
  12684. label.Append("汇率:");
  12685. label.Append(rate.TruncDecimals(4));
  12686. label.Append(')');
  12687. }
  12688. designer.SetDataSource("MealLabel", label.ToString());
  12689. }
  12690. #endregion
  12691. #region 车辆安排
  12692. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12693. if (vehArranges != null && vehArranges.Infos.Any())
  12694. {
  12695. string currencyName = string.Empty;
  12696. //decimal rate = 1.0000M;
  12697. var label = new StringBuilder();
  12698. foreach (var item in vehArranges.Infos)
  12699. {
  12700. label.AppendLine();
  12701. label.AppendLine();
  12702. label.Append(item.FeeName);
  12703. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12704. }
  12705. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12706. }
  12707. #endregion
  12708. #region 邀请函发放对象
  12709. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12710. designer.SetDataSource("InviteToContent", "");
  12711. #endregion
  12712. #region 邀请函费
  12713. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12714. var is_label = new StringBuilder();
  12715. if (inviteCosts != null && inviteCosts.Infos.Any())
  12716. {
  12717. string currencyName = string.Empty;
  12718. decimal rate = 1.0000M;
  12719. foreach (var item in inviteCosts.Infos)
  12720. {
  12721. //乌兹别克斯坦:2000美金
  12722. currencyName = item.Currency;
  12723. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12724. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12725. is_label.AppendLine(label);
  12726. }
  12727. if (is_label.HasValue())
  12728. {
  12729. //以上小计:28500元(美金汇率:7.5)
  12730. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12731. is_label.AppendLine(label);
  12732. }
  12733. }
  12734. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12735. #endregion
  12736. #region 邀请函发放时间
  12737. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12738. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12739. #endregion
  12740. #region 公务活动(含翻译)
  12741. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12742. var oa_label = new StringBuilder();
  12743. if (officialActs != null && officialActs.Infos.Any())
  12744. {
  12745. string currencyName = string.Empty;
  12746. decimal rate = 1.0000M;
  12747. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12748. foreach (var item in officialActs.Infos)
  12749. {
  12750. //乌兹别克斯坦:1000美金/场
  12751. currencyName = item.Currency;
  12752. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12753. string label_remark = string.Empty;
  12754. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12755. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12756. }
  12757. label_content += "*总费用中未含超出公务活动价格";
  12758. //8场公务活动(以上小计:60000元)
  12759. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12760. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12761. oa_label.AppendLine(label_title);
  12762. oa_label.AppendLine(label_content);
  12763. }
  12764. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12765. #endregion
  12766. #region 签证+保险
  12767. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12768. var vi_label = new StringBuilder();
  12769. if (visaIns != null && visaIns.Infos.Any())
  12770. {
  12771. foreach (var item in visaIns.Infos)
  12772. {
  12773. //签证:500元/人
  12774. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12775. vi_label.AppendLine(label);
  12776. }
  12777. if (vi_label.HasValue())
  12778. {
  12779. //以上小计:6000元
  12780. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12781. vi_label.AppendLine(label);
  12782. }
  12783. }
  12784. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12785. #endregion
  12786. #region 服务费
  12787. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12788. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12789. #endregion
  12790. #region 公杂费
  12791. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12792. var pm_label = new StringBuilder();
  12793. if (pubMiscs != null && pubMiscs.Infos.Any())
  12794. {
  12795. string currencyName = string.Empty,
  12796. countryName = string.Empty;
  12797. decimal rate = 1.0000M;
  12798. foreach (var item in pubMiscs.Infos)
  12799. {
  12800. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12801. string name = string.Empty, thisCountryName = string.Empty;
  12802. if (item.FeeName.Contains('-'))
  12803. {
  12804. var feeName = item.FeeName.Split('-');
  12805. thisCountryName = feeName[0];
  12806. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12807. name = feeName[1];
  12808. }
  12809. else name = item.FeeName;
  12810. string thisFeeName = string.Empty;
  12811. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12812. else thisFeeName = $"\r\n{name}:";
  12813. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12814. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12815. rate = rateInfo?.Rate ?? 1.0000M;
  12816. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12817. pm_label.AppendLine(label);
  12818. }
  12819. if (pm_label.HasValue())
  12820. {
  12821. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12822. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12823. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12824. pm_label.AppendLine(string.Format("部分发放成员"));
  12825. }
  12826. }
  12827. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12828. #endregion
  12829. #region 税费
  12830. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12831. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12832. #endregion
  12833. #region 合计(单位:元)
  12834. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12835. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12836. #endregion
  12837. #region 汇率 Remark
  12838. var rate_label = new StringBuilder();
  12839. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12840. foreach (var item in rateGroups)
  12841. {
  12842. //美元汇率按\r\n1:7.5
  12843. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12844. rate_label.AppendLine(label);
  12845. }
  12846. designer.SetDataSource("RateLabel", rate_label.ToString());
  12847. #endregion
  12848. designer.Process();
  12849. //文件名
  12850. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  12851. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12852. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12853. return Ok(JsonView(true, "成功", url));
  12854. }
  12855. #endregion
  12856. #region 签证费用录入
  12857. /// <summary>
  12858. /// 根据diid查询签证费用列表
  12859. /// </summary>
  12860. /// <param name="dto"></param>
  12861. /// <returns></returns>
  12862. [HttpPost]
  12863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12864. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12865. {
  12866. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12867. if (groupData.Code != 0)
  12868. {
  12869. return Ok(JsonView(false, groupData.Msg));
  12870. }
  12871. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12872. }
  12873. /// <summary>
  12874. /// 根据签证费用Id查询单条数据及c表数据
  12875. /// </summary>
  12876. /// <param name="dto"></param>
  12877. /// <returns></returns>
  12878. [HttpPost]
  12879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12880. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12881. {
  12882. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12883. if (groupData.Code != 0)
  12884. {
  12885. return Ok(JsonView(false, groupData.Msg));
  12886. }
  12887. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12888. }
  12889. /// <summary>
  12890. /// 签证费用删除
  12891. /// </summary>
  12892. /// <param name="dto"></param>
  12893. /// <returns></returns>
  12894. [HttpPost]
  12895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12896. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12897. {
  12898. _sqlSugar.BeginTran();
  12899. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12900. if (!res)
  12901. {
  12902. _sqlSugar.RollbackTran();
  12903. return Ok(JsonView(false, "删除失败"));
  12904. }
  12905. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12906. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12907. .SetColumns(a => new Grp_CreditCardPayment()
  12908. {
  12909. IsDel = 1,
  12910. DeleteUserId = dto.DeleteUserId,
  12911. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12912. })
  12913. .ExecuteCommand();
  12914. if (resSub < 1)
  12915. {
  12916. _sqlSugar.RollbackTran();
  12917. return Ok(JsonView(false, "删除失败"));
  12918. }
  12919. _sqlSugar.CommitTran();
  12920. return Ok(JsonView(true, "删除成功!"));
  12921. }
  12922. /// <summary>
  12923. /// 签证费用录入下拉框初始化
  12924. /// </summary>
  12925. /// <returns></returns>
  12926. [HttpPost]
  12927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12928. public async Task<IActionResult> VisaPriceAddSelect()
  12929. {
  12930. //支付方式
  12931. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12932. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12933. //币种
  12934. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12935. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12936. //乘客类型
  12937. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12938. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12939. //卡类型
  12940. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12941. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12942. //代办费类型
  12943. var agencyFeeTypeData = new List<dynamic>() {
  12944. new { id = 0 , Text = "未选择" },
  12945. new { id = 1 , Text = "小公务" },
  12946. new { id = 2 , Text = "大公务" },
  12947. };
  12948. //签证费用标准国家Data
  12949. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12950. var data = new
  12951. {
  12952. Payment = _Payment,
  12953. CurrencyList = _CurrencyList,
  12954. PassengerType = _PassengerType,
  12955. BankCard = _BankCard,
  12956. AgencyFeeType = agencyFeeTypeData,
  12957. CountryFeeData = visaCountryFeeData
  12958. };
  12959. return Ok(JsonView(true, "查询成功!", data));
  12960. }
  12961. /// <summary>
  12962. /// 签证费用录入操作(Status:1.新增,2.修改)
  12963. /// </summary>
  12964. /// <param name="dto"></param>
  12965. /// <returns></returns>
  12966. [HttpPost]
  12967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12968. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12969. {
  12970. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12971. if (groupData.Code != 0)
  12972. {
  12973. return Ok(JsonView(false, groupData.Msg));
  12974. }
  12975. #region 应用推送
  12976. try
  12977. {
  12978. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12979. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12980. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12981. //2024-10-21 新增LZ UID
  12982. var userIds = new List<int>() { 21 };
  12983. string title = $"系统通知";
  12984. string content = "";
  12985. var diId = dto.DiId;
  12986. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12987. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12988. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12989. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12990. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12991. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12992. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12993. }
  12994. catch (Exception ex)
  12995. {
  12996. }
  12997. #endregion
  12998. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12999. }
  13000. #endregion
  13001. #region 签证提成录入
  13002. /// <summary>
  13003. /// 签证提成录入
  13004. /// 基础数据
  13005. /// </summary>
  13006. /// <returns></returns>
  13007. [HttpGet]
  13008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13009. public async Task<IActionResult> VisaCommissionInit()
  13010. {
  13011. return Ok(await _visaCommissionRep.Init());
  13012. }
  13013. /// <summary>
  13014. /// 签证提成录入
  13015. /// Item
  13016. /// </summary>
  13017. /// <param name="_dto"></param>
  13018. /// <returns></returns>
  13019. [HttpPost]
  13020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13021. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  13022. {
  13023. var validator = new VisaCommissionItemDtoValidator();
  13024. var validatorRes = await validator.ValidateAsync(_dto);
  13025. if (!validatorRes.IsValid)
  13026. {
  13027. var sb = new StringBuilder();
  13028. foreach (var item in validatorRes.Errors)
  13029. {
  13030. sb.AppendLine(item.ErrorMessage);
  13031. }
  13032. return Ok(JsonView(false, sb.ToString()));
  13033. }
  13034. return Ok(await _visaCommissionRep.Item(_dto));
  13035. }
  13036. /// <summary>
  13037. /// 签证提成录入
  13038. /// Save
  13039. /// </summary>
  13040. /// <param name="_dto"></param>
  13041. /// <returns></returns>
  13042. [HttpPost]
  13043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13044. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  13045. {
  13046. //参数验证
  13047. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  13048. foreach (var item in _dto.Items)
  13049. {
  13050. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  13051. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  13052. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  13053. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  13054. }
  13055. return Ok(await _visaCommissionRep.Save(_dto));
  13056. }
  13057. /// <summary>
  13058. /// 签证提成录入
  13059. /// Create
  13060. /// </summary>
  13061. /// <param name="_dto"></param>
  13062. /// <returns></returns>
  13063. [HttpPost]
  13064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13065. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  13066. {
  13067. var validator = new VisaCommissionCreateDtoValidator();
  13068. var validatorRes = await validator.ValidateAsync(_dto);
  13069. if (!validatorRes.IsValid)
  13070. {
  13071. var sb = new StringBuilder();
  13072. foreach (var item in validatorRes.Errors)
  13073. {
  13074. sb.AppendLine(item.ErrorMessage);
  13075. }
  13076. return Ok(JsonView(false, sb.ToString()));
  13077. }
  13078. return Ok(await _visaCommissionRep.Create(_dto));
  13079. }
  13080. /// <summary>
  13081. /// 签证提成录入
  13082. /// Put(编辑)
  13083. /// </summary>
  13084. /// <param name="id"></param>
  13085. /// <param name="_dto"></param>
  13086. /// <returns></returns>
  13087. [HttpPut]
  13088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13089. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  13090. {
  13091. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13092. var validator = new VisaCommissionCreateDtoValidator();
  13093. var validatorRes = await validator.ValidateAsync(_dto);
  13094. if (!validatorRes.IsValid)
  13095. {
  13096. var sb = new StringBuilder();
  13097. foreach (var item in validatorRes.Errors)
  13098. {
  13099. sb.AppendLine(item.ErrorMessage);
  13100. }
  13101. return Ok(JsonView(false, sb.ToString()));
  13102. }
  13103. return Ok(await _visaCommissionRep.Edit(id, _dto));
  13104. }
  13105. /// <summary>
  13106. /// 签证提成录入
  13107. /// Del
  13108. /// </summary>
  13109. /// <param name="id"></param>
  13110. /// <param name="currUserId"></param>
  13111. /// <returns></returns>
  13112. [HttpPost]
  13113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13114. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  13115. {
  13116. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13117. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  13118. return Ok(await _visaCommissionRep.Del(id, currUserId));
  13119. }
  13120. #endregion
  13121. #region op费用录入
  13122. /// <summary>
  13123. /// 根据diid查询op费用列表
  13124. /// </summary>
  13125. /// <param name="dto"></param>
  13126. /// <returns></returns>
  13127. [HttpPost]
  13128. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13129. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  13130. {
  13131. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  13132. if (groupData.Code != 0)
  13133. {
  13134. return Ok(JsonView(false, groupData.Msg));
  13135. }
  13136. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13137. }
  13138. /// <summary>
  13139. /// 根据op费用Id查询单条数据及c表数据
  13140. /// </summary>
  13141. /// <param name="dto"></param>
  13142. /// <returns></returns>
  13143. [HttpPost]
  13144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13145. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  13146. {
  13147. try
  13148. {
  13149. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  13150. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  13151. var data = new
  13152. {
  13153. CarTouristGuideGround = _groupData,
  13154. CreditCardPayment = _creditCardPayment
  13155. };
  13156. return Ok(JsonView(true, "查询成功!", data));
  13157. }
  13158. catch (Exception ex)
  13159. {
  13160. return Ok(JsonView(false, "程序错误!"));
  13161. }
  13162. }
  13163. /// <summary>
  13164. /// op费用删除
  13165. /// </summary>
  13166. /// <param name="dto"></param>
  13167. /// <returns></returns>
  13168. [HttpPost]
  13169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13170. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  13171. {
  13172. try
  13173. {
  13174. _sqlSugar.BeginTran();
  13175. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  13176. if (!res)
  13177. {
  13178. return Ok(JsonView(false, "删除失败"));
  13179. }
  13180. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  13181. {
  13182. IsDel = 1,
  13183. DeleteUserId = dto.DeleteUserId,
  13184. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13185. }).ExecuteCommandAsync();
  13186. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  13187. {
  13188. IsDel = 1,
  13189. DeleteUserId = dto.DeleteUserId,
  13190. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13191. }).ExecuteCommandAsync();
  13192. #region 删除超支相关数据
  13193. //删除导入的超支数据
  13194. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  13195. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  13196. {
  13197. IsDel = 1,
  13198. DeleteUserId = dto.DeleteUserId,
  13199. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13200. }).ExecuteCommand();
  13201. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  13202. {
  13203. IsDel = 1,
  13204. DeleteUserId = dto.DeleteUserId,
  13205. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13206. }).ExecuteCommand();
  13207. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  13208. {
  13209. IsDel = 1,
  13210. DeleteUserId = dto.DeleteUserId,
  13211. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13212. }).ExecuteCommand();
  13213. #endregion
  13214. _sqlSugar.CommitTran();
  13215. return Ok(JsonView(true, "删除成功!"));
  13216. }
  13217. catch (Exception ex)
  13218. {
  13219. _sqlSugar.RollbackTran();
  13220. return Ok(JsonView(false, "程序错误!" + ex.Message));
  13221. }
  13222. }
  13223. /// <summary>
  13224. /// op费用录入操作(Status:1.新增,2.修改)
  13225. /// </summary>
  13226. /// <param name="dto"></param>
  13227. /// <returns></returns>
  13228. [HttpPost]
  13229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13230. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  13231. {
  13232. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  13233. if (groupData.Code != 0)
  13234. {
  13235. return Ok(JsonView(false, groupData.Msg));
  13236. }
  13237. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13238. }
  13239. /// <summary>
  13240. /// 填写费用详细页面初始化绑定
  13241. /// </summary>
  13242. /// <param name="dto"></param>
  13243. /// <returns></returns>
  13244. [HttpPost]
  13245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13246. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  13247. {
  13248. try
  13249. {
  13250. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  13251. if (groupData.Code != 0)
  13252. {
  13253. return Ok(JsonView(false, groupData.Msg));
  13254. }
  13255. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13256. }
  13257. catch (Exception ex)
  13258. {
  13259. return Ok(JsonView(false, ex.Message));
  13260. }
  13261. }
  13262. /// <summary>
  13263. /// 根据op费用Id查询详细数据
  13264. /// </summary>
  13265. /// <param name="dto"></param>
  13266. /// <returns></returns>
  13267. [HttpPost]
  13268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13269. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  13270. {
  13271. try
  13272. {
  13273. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  13274. if (groupData.Code != 0)
  13275. {
  13276. return Ok(JsonView(false, groupData.Msg));
  13277. }
  13278. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13279. }
  13280. catch (Exception ex)
  13281. {
  13282. return Ok(JsonView(false, ex.Message));
  13283. }
  13284. }
  13285. /// <summary>
  13286. /// OP费用录入填写详情
  13287. /// </summary>
  13288. /// <param name="dto"></param>
  13289. /// <returns></returns>
  13290. [HttpPost]
  13291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13292. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  13293. {
  13294. try
  13295. {
  13296. #region 参数校验
  13297. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  13298. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  13299. if (di == null) return Ok(JsonView(false, "团组错误!"));
  13300. #endregion
  13301. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  13302. if (groupData.Code != 0)
  13303. {
  13304. return Ok(JsonView(false, groupData.Msg));
  13305. }
  13306. //自动审核
  13307. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  13308. #region 尾款自动审核
  13309. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  13310. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  13311. if (opinfos.PriceType == 1062)
  13312. {
  13313. var isAuto = false;
  13314. //找对应的首付款
  13315. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  13316. .InnerJoin<Grp_CreditCardPayment>((x, a) => a.IsDel == 0 && a.CTable == 79 && a.CId == x.Id && a.DIId == x.DiId && (a.IsAuditGM == 1 || a.IsAuditGM == 3))
  13317. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  13318. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  13319. x.PriceType == 1061 && x.DiId == dto.DiId);
  13320. if (firstPrice != null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  13321. {
  13322. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  13323. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  13324. //合计中排除城市税
  13325. var cityPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  13326. .Where(x => x.SId == 1452 && x.IsDel == 0 && x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId)
  13327. .Sum(x => x.Price * x.Count);
  13328. opinfos.ServiceQuotedPrice = opinfos.ServiceQuotedPrice - cityPrice;
  13329. if (balance >= opinfos.ServiceQuotedPrice)
  13330. {
  13331. isAuto = true;
  13332. }
  13333. }
  13334. if (isAuto)
  13335. {
  13336. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  13337. .SetColumns(a => new Grp_CreditCardPayment
  13338. {
  13339. IsAuditGM = 3, //自动审核通过
  13340. AuditGMOperate = 4,
  13341. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13342. })
  13343. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  13344. .ExecuteCommand();
  13345. }
  13346. }
  13347. #endregion
  13348. #region 应用推送
  13349. try
  13350. {
  13351. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13352. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13353. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13354. //2024-10-21 新增LZ UID
  13355. var userIds = new List<int>() { 21 };
  13356. string title = $"系统通知";
  13357. var diId = dto.DiId;
  13358. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13359. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13360. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  13361. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13362. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  13363. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13364. }
  13365. catch (Exception ex)
  13366. {
  13367. }
  13368. #endregion
  13369. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13370. }
  13371. catch (Exception ex)
  13372. {
  13373. return Ok(JsonView(false, ex.Message));
  13374. }
  13375. }
  13376. /// <summary>
  13377. /// 获取三公详细所有城市
  13378. /// </summary>
  13379. /// <returns></returns>
  13380. [HttpGet]
  13381. public IActionResult OpCarCityResult()
  13382. {
  13383. var jw = JsonView(false);
  13384. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  13385. {
  13386. x.Id,
  13387. x.Country,
  13388. x.City,
  13389. }).ToList();
  13390. if (data.Count > 0)
  13391. {
  13392. jw = JsonView(true, "获取成功!", data);
  13393. }
  13394. else
  13395. {
  13396. jw.Msg = "城市数据为空!";
  13397. jw.Data = Array.Empty<string>();
  13398. }
  13399. return Ok(jw);
  13400. }
  13401. /// <summary>
  13402. /// 导出地接费用明细
  13403. /// </summary>
  13404. /// <param name="dto"></param>
  13405. /// <returns></returns>
  13406. [HttpPost]
  13407. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13408. {
  13409. var jw = JsonView(false);
  13410. if (dto.Diid < 1)
  13411. {
  13412. jw.Msg = "请输入正确的diid!";
  13413. return Ok(jw);
  13414. }
  13415. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13416. if (group == null)
  13417. {
  13418. jw.Msg = "未找到团组信息!";
  13419. return Ok(jw);
  13420. }
  13421. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13422. if (localGuideArr.Count == 0)
  13423. {
  13424. jw.Msg = "该团组暂无地接信息!";
  13425. return Ok(jw);
  13426. }
  13427. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13428. var overspendSoure = new Dictionary<int, int>
  13429. {
  13430. { 91, 982 }, //车
  13431. { 92 , 1059} ,//导游
  13432. { 994 , 1073}, //翻译
  13433. { 988 , 1074 }, //早餐
  13434. { 93 , 1075 }, //午餐
  13435. { 989 , 1076 }, //晚餐
  13436. };
  13437. var Zips = new Dictionary<string, Stream>();
  13438. foreach (var groupArr in localGroup)
  13439. {
  13440. var keyValue = groupArr.Key;
  13441. if (int.TryParse(keyValue, out int cityid))
  13442. {
  13443. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13444. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13445. }
  13446. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13447. foreach (var item in groupArr)
  13448. {
  13449. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13450. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13451. new Grp_CarTouristGuideGroundReservationsContentExtend
  13452. {
  13453. Count = a.Count,
  13454. CreateTime = a.CreateTime,
  13455. CreateUserId = a.CreateUserId,
  13456. CTGGRId = a.CTGGRId,
  13457. Currency = a.Currency,
  13458. DatePrice = a.DatePrice,
  13459. DeleteTime = a.DeleteTime,
  13460. DeleteUserId = a.DeleteUserId,
  13461. DiId = a.DiId,
  13462. Id = a.Id,
  13463. IsDel = a.IsDel,
  13464. Price = a.Price,
  13465. PriceContent = a.PriceContent,
  13466. Remark = a.Remark,
  13467. SId = a.SId,
  13468. SidName = b.Name,
  13469. Units = a.Units,
  13470. }
  13471. ).ToList();
  13472. if (content.Count > 0)
  13473. {
  13474. contentArr.Add(content);
  13475. }
  13476. }
  13477. //open excel
  13478. //set excel
  13479. //save excel
  13480. try
  13481. {
  13482. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13483. IWorkbook workbook;
  13484. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13485. {
  13486. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13487. }
  13488. else
  13489. {
  13490. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13491. }
  13492. ISheet sheet = workbook.GetSheetAt(0);
  13493. var rowStartIndex = 2;
  13494. var clounmCount = 10;
  13495. var initStyleRow = sheet.GetRow(2);
  13496. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13497. //var overspendArrDetail =
  13498. var existsId = new List<CarCompare>();
  13499. var lastElem = arr.Last();
  13500. var thisSid = -1;
  13501. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13502. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13503. {
  13504. Name = "未知币种!",
  13505. Remark = "未知币种!",
  13506. };
  13507. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13508. Action cloneRowFn = () =>
  13509. {
  13510. rowStartIndex++;
  13511. var cloneRow = sheet.CreateRow(rowStartIndex);
  13512. // 复制样式
  13513. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13514. {
  13515. ICell sourceCell = initStyleRow.GetCell(i);
  13516. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13517. // 确保单元格存在样式
  13518. if (sourceCell.CellStyle != null)
  13519. {
  13520. targetCell.CellStyle = sourceCell.CellStyle;
  13521. }
  13522. }
  13523. };
  13524. var mergeRow = () =>
  13525. {
  13526. for (int i = 2; i < sheet.LastRowNum; i++)
  13527. {
  13528. var row = sheet.GetRow(i);
  13529. var cellFirst = row.GetCell(0);
  13530. var thisIndex = i + 1;
  13531. while (thisIndex < sheet.LastRowNum)
  13532. {
  13533. var nextRow = sheet.GetRow(thisIndex);
  13534. var nextCellFirst = nextRow.GetCell(0);
  13535. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13536. {
  13537. thisIndex++;
  13538. }
  13539. else
  13540. {
  13541. break;
  13542. }
  13543. }
  13544. thisIndex--;
  13545. if (thisIndex != i)
  13546. {
  13547. //合并row
  13548. var cellRangeAddress = new CellRangeAddress(
  13549. i, // 起始行索引(0-based)
  13550. thisIndex, // 结束行索引(0-based)
  13551. 0, // 起始列索引(0-based)
  13552. 0 // 结束列索引(0-based)
  13553. );
  13554. sheet.AddMergedRegion(cellRangeAddress);
  13555. i = thisIndex;
  13556. }
  13557. }
  13558. };
  13559. var chaoshiNumber = 0;
  13560. var totalNumber = 0.00M;
  13561. string lastStr = "";
  13562. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13563. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13564. {
  13565. b.IsAuditGM,
  13566. x.Id,
  13567. x.Area,
  13568. b.PayPercentage,
  13569. b.PayMoney,
  13570. }).ToList();
  13571. string yesPayment = "", noPayment = "";
  13572. foreach (var item in queryCarArrByCityAndDiid)
  13573. {
  13574. if (item.IsAuditGM == 1)
  13575. {
  13576. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13577. }
  13578. else
  13579. {
  13580. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13581. }
  13582. }
  13583. lastStr = yesPayment + noPayment;
  13584. foreach (var item in arr)
  13585. {
  13586. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  13587. {
  13588. if (thisSid != item.SId)
  13589. {
  13590. if (thisSid == -1)
  13591. {
  13592. thisSid = item.SId;
  13593. }
  13594. else
  13595. {
  13596. //合并小计行
  13597. //创建合并区域的实例
  13598. var cellRangeAddress = new CellRangeAddress(
  13599. rowStartIndex, // 起始行索引(0-based)
  13600. rowStartIndex, // 结束行索引(0-based)
  13601. 0, // 起始列索引(0-based)
  13602. 3 // 结束列索引(0-based)
  13603. );
  13604. sheet.AddMergedRegion(cellRangeAddress);
  13605. var CellStyle = workbook.CreateCellStyle();
  13606. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13607. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13608. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13609. for (int i = 0; i <= clounmCount; i++)
  13610. {
  13611. if (i > 6)
  13612. {
  13613. var CellStyle1 = workbook.CreateCellStyle();
  13614. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13615. IFont Font = workbook.CreateFont(); // 创建字体
  13616. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13617. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13618. CellStyle1.SetFont(Font);
  13619. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13620. }
  13621. else
  13622. {
  13623. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13624. }
  13625. }
  13626. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13627. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13628. //超时合计
  13629. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13630. //超时数
  13631. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13632. //超时合计费用
  13633. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13634. thisSid = item.SId;
  13635. cloneRowFn();
  13636. chaoshiNumber = 0;
  13637. totalNumber = 0;
  13638. }
  13639. }
  13640. IRow row = sheet.GetRow(rowStartIndex);
  13641. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13642. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  13643. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13644. if (isOpenOverspendSoure)
  13645. {
  13646. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13647. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13648. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13649. }
  13650. for (int i = 0; i <= clounmCount; i++)
  13651. {
  13652. var cell = row.GetCell(i);
  13653. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13654. if (cell == null)
  13655. {
  13656. cell = row.CreateCell(i);
  13657. }
  13658. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13659. fontRed.CloneStyleFrom(cell.CellStyle);
  13660. IFont Font = workbook.CreateFont(); // 创建字体
  13661. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13662. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13663. fontRed.SetFont(Font);
  13664. byte[] rgb = new byte[3] { 255, 242, 204 };
  13665. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13666. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13667. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13668. if (workbook is XSSFWorkbook)
  13669. {
  13670. BackgroundColor255_242_204.FillForegroundColor = 0;
  13671. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13672. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13673. }
  13674. else
  13675. {
  13676. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13677. }
  13678. if (i == 1 || i > 6)
  13679. {
  13680. if (i > 6)
  13681. {
  13682. fontRed.FillForegroundColor = 0;
  13683. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13684. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13685. }
  13686. cell.CellStyle = fontRed;
  13687. }
  13688. if (i > 2 && i < 7)
  13689. {
  13690. cell.CellStyle = BackgroundColor255_242_204;
  13691. }
  13692. cell.SetCellValue(setCellValue); //写入单元格
  13693. }
  13694. if (overspendSoure.ContainsKey(thisSid))
  13695. {
  13696. var overspendId = overspendSoure[thisSid];
  13697. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13698. }
  13699. cloneRowFn();
  13700. existsId.Add(new CarCompare
  13701. {
  13702. DataPrice = item.DatePrice.ObjToDate(),
  13703. Sid = item.SId
  13704. });
  13705. }
  13706. if (item.Equals(lastElem))
  13707. {
  13708. //合并小计行
  13709. //创建合并区域的实例
  13710. var cellRangeAddress = new CellRangeAddress(
  13711. rowStartIndex, // 起始行索引(0-based)
  13712. rowStartIndex, // 结束行索引(0-based)
  13713. 0, // 起始列索引(0-based)
  13714. 3 // 结束列索引(0-based)
  13715. );
  13716. sheet.AddMergedRegion(cellRangeAddress);
  13717. var CellStyle = workbook.CreateCellStyle();
  13718. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13719. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13720. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13721. for (int i = 0; i <= clounmCount; i++)
  13722. {
  13723. if (i > 6)
  13724. {
  13725. var CellStyle1 = workbook.CreateCellStyle();
  13726. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13727. IFont Font = workbook.CreateFont(); // 创建字体
  13728. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13729. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13730. CellStyle1.SetFont(Font);
  13731. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13732. }
  13733. else
  13734. {
  13735. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13736. }
  13737. }
  13738. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13739. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13740. //超时合计
  13741. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13742. //超时数
  13743. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13744. //超时合计费用
  13745. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13746. cloneRowFn();
  13747. // 创建合并区域的实例
  13748. cellRangeAddress = new CellRangeAddress(
  13749. rowStartIndex, // 起始行索引(0-based)
  13750. rowStartIndex, // 结束行索引(0-based)
  13751. 0, // 起始列索引(0-based)
  13752. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13753. );
  13754. // 添加合并区域
  13755. sheet.AddMergedRegion(cellRangeAddress);
  13756. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13757. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13758. }
  13759. }
  13760. mergeRow();
  13761. // 保存修改后的Excel文件到新文件
  13762. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13763. // new FileStream(newFilePath, FileMode.CreateNew)
  13764. using (var stream = new MemoryStream())
  13765. {
  13766. workbook.Write(stream, true);
  13767. stream.Flush();
  13768. stream.Seek(0, SeekOrigin.Begin);
  13769. var memoryStream = new MemoryStream();
  13770. stream.CopyTo(memoryStream);
  13771. memoryStream.Seek(0, SeekOrigin.Begin);
  13772. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13773. }
  13774. workbook.Close();
  13775. workbook.Dispose();
  13776. }
  13777. catch (Exception ex)
  13778. {
  13779. jw.Msg = "出现异常!" + ex.Message;
  13780. return Ok(jw);
  13781. }
  13782. }
  13783. if (Zips.Count > 0)
  13784. {
  13785. var io = new IOOperatorHelper();
  13786. var byts = io.ConvertZipStream(Zips);
  13787. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13788. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13789. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13790. }
  13791. else
  13792. {
  13793. jw.Msg = "暂无生成文件!";
  13794. }
  13795. return Ok(jw);
  13796. }
  13797. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13798. {
  13799. string outStr = string.Empty;
  13800. switch (i)
  13801. {
  13802. case 0:
  13803. outStr = arr[0].SidName;
  13804. break;
  13805. case 1:
  13806. outStr = arr[0].DataPriceStr;
  13807. break;
  13808. case 2:
  13809. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13810. break;
  13811. case 4:
  13812. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13813. break;
  13814. case 7:
  13815. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13816. {
  13817. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13818. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13819. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13820. }
  13821. break;
  13822. case 8:
  13823. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13824. {
  13825. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13826. }
  13827. break;
  13828. case 9:
  13829. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13830. {
  13831. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13832. }
  13833. break;
  13834. case 10:
  13835. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13836. {
  13837. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13838. }
  13839. break;
  13840. }
  13841. return outStr;
  13842. }
  13843. #region OP行程单
  13844. /// <summary>
  13845. /// OP行程单初始化
  13846. /// </summary>
  13847. /// <param name="dto"></param>
  13848. /// <returns></returns>
  13849. [HttpPost]
  13850. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13851. {
  13852. var jw = JsonView(false);
  13853. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13854. var group = groupList.First();
  13855. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13856. if (group == null)
  13857. {
  13858. jw.Msg = "暂无团组!";
  13859. return Ok(jw);
  13860. }
  13861. group = groupList.Find(x => x.Id == diid);
  13862. if (group == null)
  13863. {
  13864. jw.Msg = "请输入正确的团组ID!";
  13865. return Ok(jw);
  13866. }
  13867. string city = string.Empty;
  13868. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13869. if (blackCode.Count > 0)
  13870. {
  13871. var black = blackCode.First();
  13872. black.BlackCode = black.BlackCode ?? "";
  13873. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13874. if (blackSp.Length > 0)
  13875. {
  13876. try
  13877. {
  13878. var cityArrCode = new List<string>(20);
  13879. foreach (var item in blackSp)
  13880. {
  13881. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13882. var IndexSelect = itemSp[2];
  13883. var cityArrCodeLength = cityArrCode.Count - 1;
  13884. var startCity = IndexSelect.Substring(0, 3);
  13885. if (cityArrCodeLength > 0)
  13886. {
  13887. var arrEndCity = cityArrCode[cityArrCodeLength];
  13888. if (arrEndCity != startCity)
  13889. {
  13890. cityArrCode.Add(startCity.ToUpper());
  13891. }
  13892. }
  13893. else
  13894. {
  13895. cityArrCode.Add(startCity.ToUpper());
  13896. }
  13897. var endCity = IndexSelect.Substring(3, 3);
  13898. cityArrCode.Add(endCity.ToUpper());
  13899. }
  13900. var cityThree = string.Empty;
  13901. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13902. cityThree = cityThree.TrimEnd(',');
  13903. if (string.IsNullOrWhiteSpace(cityThree))
  13904. {
  13905. throw new
  13906. Exception("error");
  13907. }
  13908. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13909. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13910. foreach (var item in cityArrCode)
  13911. {
  13912. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13913. if (find != null)
  13914. {
  13915. city += find.City + "/";
  13916. }
  13917. else
  13918. {
  13919. city += item + "三字码未收入/";
  13920. }
  13921. }
  13922. city = city.TrimEnd('/');
  13923. }
  13924. catch (Exception e)
  13925. {
  13926. city = "黑屏代码格式不正确!";
  13927. }
  13928. }
  13929. }
  13930. else
  13931. {
  13932. city = "未录入黑屏代码";
  13933. }
  13934. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13935. {
  13936. Date = x.Date,
  13937. Days = x.Days,
  13938. Diffgroup = x.Diffgroup,
  13939. Diid = x.Diid,
  13940. Traffic_First = x.Traffic_First,
  13941. Traffic_Second = x.Traffic_Second,
  13942. Trip = x.Trip,
  13943. WeekDay = x.WeekDay,
  13944. Id = x.Id
  13945. }).ToList();
  13946. jw.Data = new
  13947. {
  13948. groupList = groupList.Select(x => new
  13949. {
  13950. x.Id,
  13951. x.TeamName,
  13952. x.TourCode
  13953. }).ToList(),
  13954. groupInfo = new
  13955. {
  13956. group.VisitDays,
  13957. group.TourCode,
  13958. group.VisitPNumber,
  13959. group.TeamName,
  13960. city
  13961. },
  13962. OpTravelList
  13963. };
  13964. jw.Code = 200;
  13965. jw.Msg = "操作成功!";
  13966. return Ok(jw);
  13967. }
  13968. /// <summary>
  13969. /// 删除团组行程单
  13970. /// </summary>
  13971. /// <returns></returns>
  13972. [HttpPost]
  13973. public IActionResult DelTravel(DelOpTravelDto dto)
  13974. {
  13975. var jw = JsonView(false);
  13976. if (dto.UserId <= 0 || dto.Diid <= 0)
  13977. {
  13978. jw.Msg = "请输入正确的参数!";
  13979. return Ok(jw);
  13980. }
  13981. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13982. .SetColumns(x => new Grp_TravelList
  13983. {
  13984. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13985. DeleteUserId = dto.UserId,
  13986. IsDel = 1,
  13987. }).ExecuteCommand();
  13988. jw = JsonView(true);
  13989. return Ok(jw);
  13990. }
  13991. /// <summary>
  13992. /// 行程单保存
  13993. /// </summary>
  13994. /// <returns></returns>
  13995. [HttpPost]
  13996. public IActionResult TravelSave(TravelSaveDto dto)
  13997. {
  13998. var jw = JsonView(false);
  13999. if (dto.Arr.Count > 0)
  14000. {
  14001. try
  14002. {
  14003. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  14004. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  14005. .ToList();
  14006. _sqlSugar.BeginTran();
  14007. foreach (var item in dto.Arr)
  14008. {
  14009. if (item.Id == 0)
  14010. {
  14011. throw new Exception("请传入正确的Id");
  14012. }
  14013. //比较上一次的差异
  14014. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  14015. if (findTravel != null)
  14016. {
  14017. item.Trip = item.Trip.Replace("[++]", string.Empty);
  14018. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  14019. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  14020. }
  14021. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  14022. .SetColumns(x => new Grp_TravelList
  14023. {
  14024. Trip = item.Trip
  14025. }).ExecuteCommand();
  14026. }
  14027. _sqlSugar.CommitTran();
  14028. jw = JsonView(true);
  14029. }
  14030. catch (Exception ex)
  14031. {
  14032. _sqlSugar.RollbackTran();
  14033. jw.Msg = "程序异常!" + ex.Message;
  14034. }
  14035. }
  14036. else
  14037. {
  14038. jw.Msg = "请传入正确的参数!";
  14039. }
  14040. return Ok(jw);
  14041. }
  14042. private static string CheckStr(string original, string changed)
  14043. {
  14044. // 创建diff_match_patch对象
  14045. var dmp = new diff_match_patch();
  14046. // 计算差异
  14047. List<Diff> diffs = dmp.diff_main(original, changed);
  14048. // 清理和合并差异
  14049. dmp.diff_cleanupSemantic(diffs);
  14050. // 使用StringBuilder构建最终的字符串
  14051. var finalString = new StringBuilder();
  14052. // 输出差异结果,并构建变动后的字符串
  14053. foreach (Diff diff in diffs)
  14054. {
  14055. switch (diff.operation)
  14056. {
  14057. case Operation.EQUAL:
  14058. // 相等的部分,直接添加到最终字符串
  14059. finalString.Append(diff.text);
  14060. break;
  14061. case Operation.INSERT:
  14062. // 插入的部分,添加标记并添加到最终字符串
  14063. finalString.Append("[++]" + diff.text + "[++]");
  14064. break;
  14065. case Operation.DELETE:
  14066. // 删除的部分,不添加到最终字符串
  14067. //finalString.Append("[++]" + diff.text + "[++]");
  14068. break;
  14069. }
  14070. }
  14071. // 输出变动后的字符串
  14072. return finalString.ToString();
  14073. }
  14074. private class tagContent
  14075. {
  14076. public DateTime Date { get; set; }
  14077. public string StartTag { get; set; }
  14078. public string EndTag { get; set; }
  14079. public string Content { get; set; }
  14080. public static int tagLength { get { return 3; } }
  14081. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  14082. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  14083. public bool IsFinally { get; set; }
  14084. }
  14085. private static List<string> ExtractContentBetweenTags(string input, string tag)
  14086. {
  14087. var results = new List<string>();
  14088. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  14089. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  14090. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  14091. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  14092. string[] strValueArr = new string[1];
  14093. foreach (System.Text.RegularExpressions.Match match in matches)
  14094. {
  14095. var strValue = match.Groups[1].Value;
  14096. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  14097. }
  14098. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  14099. return results;
  14100. }
  14101. /// <summary>
  14102. /// 导出行程单
  14103. /// </summary>
  14104. /// <param name="dto"></param>
  14105. /// <returns></returns>
  14106. [HttpPost]
  14107. public IActionResult ExportTravel(ExportTravelDto dto)
  14108. {
  14109. var jw = JsonView(false);
  14110. jw.Data = "";
  14111. int diid = 0;
  14112. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  14113. if (Find == null)
  14114. {
  14115. jw.Msg = "请选择正确的团组!";
  14116. return Ok(jw);
  14117. }
  14118. else
  14119. {
  14120. diid = Find.Id;
  14121. }
  14122. //数据源
  14123. var _travelList = new List<Grp_TravelList>();
  14124. DataTable dtBlack = null;
  14125. try
  14126. {
  14127. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  14128. }
  14129. catch (Exception)
  14130. {
  14131. jw.Msg = "机票黑屏代码有误!";
  14132. return Ok(jw);
  14133. }
  14134. string CityStr = string.Empty;
  14135. if (dtBlack.Rows.Count == 0)
  14136. {
  14137. jw.Msg = "机票黑屏代码有误!";
  14138. return Ok(jw);
  14139. }
  14140. else
  14141. {
  14142. foreach (DataRow row in dtBlack.Rows)
  14143. {
  14144. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14145. {
  14146. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  14147. return Ok(jw);
  14148. }
  14149. }
  14150. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  14151. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  14152. }
  14153. // 指定的文字
  14154. var targetTextDic = new Dictionary<string, List<string>>();
  14155. //创建数据源Table
  14156. var dtSource = new DataTable();
  14157. dtSource.Columns.Add("Days", typeof(string));
  14158. dtSource.Columns.Add("Date", typeof(string));
  14159. dtSource.Columns.Add("Week", typeof(string));
  14160. dtSource.Columns.Add("Traffic", typeof(string));
  14161. dtSource.Columns.Add("Trip", typeof(string));
  14162. //获取数据,放到datatable
  14163. foreach (var item in _travelList)
  14164. {
  14165. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  14166. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  14167. .Replace(tagContent.TagFormat.Item2, string.Empty)
  14168. .Replace("[++]", string.Empty);
  14169. DataRow dr = dtSource.NewRow();
  14170. dr["Days"] = item.Days;
  14171. dr["Date"] = item.Date;
  14172. dr["Week"] = item.WeekDay;
  14173. dr["Traffic"] = item.Traffic_First
  14174. + "\r\n"
  14175. + item.Traffic_Second;
  14176. dr["Trip"] = item.Trip;
  14177. dtSource.Rows.Add(dr);
  14178. }
  14179. var dic = new Dictionary<string, string>
  14180. {
  14181. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  14182. { "City", CityStr },
  14183. { "Days", Find.VisitDays.ToString() },
  14184. { "DeleCode", Find.TourCode },
  14185. { "Pnum", Find.VisitPNumber.ToString() }
  14186. };
  14187. //模板路径
  14188. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  14189. //载入模板
  14190. Document doc = null;
  14191. DocumentBuilder builder = null;
  14192. try
  14193. {
  14194. //载入模板
  14195. doc = new Document(tempPath);
  14196. builder = new DocumentBuilder(doc);
  14197. }
  14198. catch (Exception)
  14199. {
  14200. jw.Msg = "模板位置不存在!";
  14201. return Ok(jw);
  14202. }
  14203. foreach (var key in dic.Keys)
  14204. {
  14205. Bookmark bookmark = doc.Range.Bookmarks[key];
  14206. if (bookmark != null)
  14207. {
  14208. builder.MoveToBookmark(key);
  14209. builder.Write(dic[key]);
  14210. }
  14211. }
  14212. //获取word里所有表格
  14213. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14214. //获取所填表格的序数
  14215. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14216. try
  14217. {
  14218. //循环赋值
  14219. for (int i = 0; i < dtSource.Rows.Count; i++)
  14220. {
  14221. builder.MoveToCell(0, i + 1, 0, 0);
  14222. builder.Write(dtSource.Rows[i]["Days"].ToString());
  14223. builder.MoveToCell(0, i + 1, 1, 0);
  14224. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  14225. builder.MoveToCell(0, i + 1, 2, 0);
  14226. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  14227. var trip = dtSource.Rows[i]["Trip"].ToString();
  14228. builder.MoveToCell(0, i + 1, 3, 0);
  14229. builder.Write(trip);
  14230. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  14231. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14232. // 获取特定索引的段落
  14233. Paragraph paragraph = (Paragraph)paragraphs[0];
  14234. Run run = paragraph.Runs[0];
  14235. Aspose.Words.Font font = run.Font;
  14236. font.Name = "黑体";
  14237. //设置双休红色
  14238. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  14239. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14240. paragraph = (Paragraph)paragraphs[1];
  14241. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  14242. {
  14243. run = paragraph.Runs[0];
  14244. font = run.Font;
  14245. font.Color = Color.Red;
  14246. }
  14247. }
  14248. }
  14249. catch (Exception ex)
  14250. {
  14251. }
  14252. //删除多余行
  14253. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  14254. {
  14255. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  14256. }
  14257. var targetTextList = new List<string>();
  14258. // 遍历文档中的表格
  14259. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14260. {
  14261. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14262. {
  14263. var cellIndex = 0;
  14264. foreach (Cell cell in row.Cells)
  14265. {
  14266. if (cellIndex == 1 && row.Cells.Count == 4)
  14267. {
  14268. foreach (var target in targetTextDic.Keys)
  14269. {
  14270. if (cell.GetText().Contains(target))
  14271. {
  14272. targetTextList = targetTextDic[target];
  14273. break;
  14274. }
  14275. }
  14276. }
  14277. // 遍历单元格中的所有段落
  14278. foreach (Paragraph paragraph in cell.Paragraphs)
  14279. {
  14280. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  14281. var runs = new List<Run>();
  14282. foreach (Run run in paragraph.Runs)
  14283. {
  14284. runs.Add(run);
  14285. }
  14286. foreach (Run run in runs)
  14287. {
  14288. foreach (var targetText in targetTextList)
  14289. {
  14290. // 检查文字是否包含指定文字
  14291. if (run.Text.Contains(targetText))
  14292. {
  14293. // 将包含的部分设置为红色
  14294. HighlightText(run, targetText, Color.Red);
  14295. }
  14296. }
  14297. }
  14298. }
  14299. cellIndex++;
  14300. }
  14301. }
  14302. }
  14303. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  14304. if (!Directory.Exists(savePath))
  14305. {
  14306. try
  14307. {
  14308. Directory.CreateDirectory(savePath);
  14309. }
  14310. catch
  14311. {
  14312. }
  14313. }
  14314. string path = savePath + Find.TeamName + "出访日程";
  14315. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  14316. try
  14317. {
  14318. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  14319. string postfix = ".docx";
  14320. if (dto.IsPDF == 1)
  14321. {
  14322. saveFormat = Aspose.Words.SaveFormat.Pdf;
  14323. postfix = ".pdf";
  14324. }
  14325. doc.Save(path + postfix, saveFormat);
  14326. jw = JsonView(true, "导出成功", ftpPath + postfix);
  14327. }
  14328. catch (Exception)
  14329. {
  14330. jw = JsonView(false);
  14331. }
  14332. return Ok(jw);
  14333. }
  14334. /// <summary>
  14335. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  14336. /// </summary>
  14337. /// <param name="num"></param>
  14338. /// <returns></returns>
  14339. static string GetNum(string num)
  14340. {
  14341. string str = "";
  14342. switch (num)
  14343. {
  14344. case "1":
  14345. str = "一";
  14346. break;
  14347. case "2":
  14348. str = "二";
  14349. break;
  14350. case "3":
  14351. str = "三";
  14352. break;
  14353. case "4":
  14354. str = "四";
  14355. break;
  14356. case "5":
  14357. str = "五";
  14358. break;
  14359. case "6":
  14360. str = "六";
  14361. break;
  14362. case "7":
  14363. str = "七";
  14364. break;
  14365. case "8":
  14366. str = "八";
  14367. break;
  14368. case "9":
  14369. str = "九";
  14370. break;
  14371. case "10":
  14372. str = "十";
  14373. break;
  14374. case "11":
  14375. str = "十一";
  14376. break;
  14377. case "12":
  14378. str = "十二";
  14379. break;
  14380. case "一":
  14381. str = "1";
  14382. break;
  14383. case "二":
  14384. str = "2";
  14385. break;
  14386. case "三":
  14387. str = "3";
  14388. break;
  14389. case "四":
  14390. str = "4";
  14391. break;
  14392. case "五":
  14393. str = "5";
  14394. break;
  14395. case "六":
  14396. str = "6";
  14397. break;
  14398. case "七":
  14399. str = "7";
  14400. break;
  14401. case "八":
  14402. str = "8";
  14403. break;
  14404. case "九":
  14405. str = "9";
  14406. break;
  14407. case "十":
  14408. str = "10";
  14409. break;
  14410. case "十一":
  14411. str = "11";
  14412. break;
  14413. case "十二":
  14414. str = "12";
  14415. break;
  14416. }
  14417. return str;
  14418. }
  14419. /// <summary>
  14420. /// 高亮包含指定文字的部分
  14421. /// </summary>
  14422. /// <param name="run"></param>
  14423. /// <param name="targetText"></param>
  14424. /// <param name="color"></param>
  14425. static void HighlightText(Run run, string targetText, Color color)
  14426. {
  14427. string text = run.Text;
  14428. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14429. if (startIndex >= 0)
  14430. {
  14431. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14432. // 前部分
  14433. if (startIndex > 0)
  14434. {
  14435. Run beforeRun = (Run)run.Clone(true);
  14436. beforeRun.Text = text.Substring(0, startIndex);
  14437. parentParagraph.InsertBefore(beforeRun, run);
  14438. }
  14439. // 匹配部分
  14440. Run matchRun = (Run)run.Clone(true);
  14441. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14442. matchRun.Font.Color = color;
  14443. parentParagraph.InsertBefore(matchRun, run);
  14444. // 后部分
  14445. if (startIndex + targetText.Length < text.Length)
  14446. {
  14447. Run afterRun = (Run)run.Clone(true);
  14448. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14449. parentParagraph.InsertBefore(afterRun, run);
  14450. }
  14451. // 删除原始Run
  14452. run.Remove();
  14453. }
  14454. }
  14455. #endregion
  14456. #endregion
  14457. #region 团组成本
  14458. /// <summary>
  14459. /// 团组成本数据初始化
  14460. /// </summary>
  14461. /// <param name="dto"></param>
  14462. /// <returns></returns>
  14463. [HttpPost]
  14464. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14465. {
  14466. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14467. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14468. WHEN COUNT(*) >= 0 THEN 'True'
  14469. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14470. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14471. ").ToList(); //团组列表
  14472. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14473. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14474. var visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14475. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14476. if (groupinfoValue != null)
  14477. {
  14478. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14479. var spArr = new string[1] { countryArr };
  14480. if (countryArr.Contains("|"))
  14481. {
  14482. spArr = countryArr.Split("|");
  14483. }
  14484. else if (countryArr.Contains("、"))
  14485. {
  14486. spArr = countryArr.Split("、");
  14487. }
  14488. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14489. {
  14490. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14491. if (dbQueryCountry != null)
  14492. {
  14493. visaCountryInfoArr.Add(dbQueryCountry);
  14494. }
  14495. }
  14496. }
  14497. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14498. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14499. #region 屏蔽黑屏代码生成
  14500. //var create = _GroupCostRepository.
  14501. // CreateGroupCostByBlackCode(dto.Diid);
  14502. //if (groupCost.Count == 0 && create.Code == 0)
  14503. //{
  14504. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14505. //}
  14506. #endregion
  14507. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14508. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14509. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14510. groupCostMap = groupCostMap.Select(x =>
  14511. {
  14512. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14513. {
  14514. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14515. }
  14516. return x;
  14517. }).ToList();
  14518. //GroupCostParameter.Add(new
  14519. // Grp_GroupCostParameter());
  14520. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14521. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14522. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  14523. return Ok(JsonView(new
  14524. {
  14525. groupList,
  14526. groupInfo,
  14527. groupChecks,
  14528. groupCost = groupCostMap,
  14529. hotelNumber,
  14530. GroupCostParameter = GroupCostParameterMap,
  14531. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14532. {
  14533. x.VisaCountry,
  14534. x.VisaPrice,
  14535. x.Id,
  14536. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  14537. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  14538. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  14539. x.VisaTime, // 一般签证时间
  14540. x.PettyBusinessAgencyFee, //小公务代办费
  14541. x.GrandBusinessAgencyFee //大公务代办费
  14542. }).ToList(),
  14543. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14544. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14545. hotelIsTrue,
  14546. groupModuleOperators
  14547. }));
  14548. }
  14549. /// <summary>
  14550. /// 团组成本信息保存
  14551. /// </summary>
  14552. /// <param name="dto"></param>
  14553. /// <returns></returns>
  14554. [HttpPost]
  14555. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14556. {
  14557. if (dto.Diid <= 0 || dto.Userid <= 0)
  14558. {
  14559. return Ok(JsonView(false));
  14560. }
  14561. JsonView jw = null;
  14562. bool isTrue = false;
  14563. #region 复制团组成本
  14564. //if (dto.Diid == 2581)
  14565. //{
  14566. // dto.Diid = 2599;
  14567. // dto.CheckBoxs.ForEach(x =>
  14568. // {
  14569. // x.Diid = 2599;
  14570. // });
  14571. // dto.GroupCosts.ForEach(x =>
  14572. // {
  14573. // x.Diid = 2599;
  14574. // });
  14575. // dto.CostTypeHotelNumbers.ForEach(x =>
  14576. // {
  14577. // x.Diid = 2599;
  14578. // });
  14579. // dto.GroupCostParameters.ForEach(x =>
  14580. // {
  14581. // x.DiId = 2599;
  14582. // });
  14583. //}
  14584. #endregion
  14585. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14586. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14587. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14588. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14589. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14590. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14591. try
  14592. {
  14593. _sqlSugar.BeginTran();
  14594. isTrue = await _GroupCostRepository.
  14595. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14596. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14597. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14598. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14599. _sqlSugar.CommitTran();
  14600. jw = JsonView(true, "保存成功!", isTrue);
  14601. }
  14602. catch (Exception)
  14603. {
  14604. _sqlSugar.RollbackTran();
  14605. jw = JsonView(false);
  14606. }
  14607. return Ok(jw);
  14608. }
  14609. /// <summary>
  14610. /// 复制团组成本信息
  14611. /// </summary>
  14612. /// <param name="dto"></param>
  14613. /// <returns></returns>
  14614. [HttpPost]
  14615. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14616. {
  14617. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14618. {
  14619. return Ok(JsonView(false, "参数有误!"));
  14620. }
  14621. #region 复制团组成本
  14622. dto.Diid = dto.ToGroupId;
  14623. dto.CheckBoxs.ForEach(x =>
  14624. {
  14625. x.Diid = dto.ToGroupId;
  14626. });
  14627. dto.GroupCosts.ForEach(x =>
  14628. {
  14629. x.Diid = dto.ToGroupId;
  14630. });
  14631. dto.CostTypeHotelNumbers.ForEach(x =>
  14632. {
  14633. x.Diid = dto.ToGroupId;
  14634. });
  14635. dto.GroupCostParameters.ForEach(x =>
  14636. {
  14637. x.DiId = dto.ToGroupId;
  14638. });
  14639. #endregion
  14640. JsonView jw = null;
  14641. bool isTrue = false;
  14642. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14643. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14644. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14645. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14646. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14647. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14648. try
  14649. {
  14650. _sqlSugar.BeginTran();
  14651. isTrue = await _GroupCostRepository.
  14652. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14653. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14654. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14655. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14656. _sqlSugar.CommitTran();
  14657. jw = JsonView(true, "保存成功!", isTrue);
  14658. }
  14659. catch (Exception)
  14660. {
  14661. _sqlSugar.RollbackTran();
  14662. jw = JsonView(false);
  14663. }
  14664. return Ok(jw);
  14665. }
  14666. /// <summary>
  14667. /// 司兼导数据
  14668. /// </summary>
  14669. /// <param name="dto"></param>
  14670. /// <returns></returns>
  14671. [HttpPost]
  14672. public IActionResult GetCarGuides(CarGuidesDto dto)
  14673. {
  14674. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14675. return Ok(JsonView(true, "获取成功!", Data));
  14676. }
  14677. /// <summary>
  14678. /// 导游数据
  14679. /// </summary>
  14680. /// <param name="dto"></param>
  14681. /// <returns></returns>
  14682. [HttpPost]
  14683. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14684. {
  14685. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14686. // 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
  14687. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14688. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14689. return Ok(JsonView(true, "获取成功!", Data));
  14690. }
  14691. /// <summary>
  14692. /// 成本车数据
  14693. /// </summary>
  14694. /// <param name="dto"></param>
  14695. /// <returns></returns>
  14696. [HttpPost]
  14697. public IActionResult GetCarInfo(CarGuidesDto dto)
  14698. {
  14699. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14700. return Ok(JsonView(true, "获取成功!", Data));
  14701. }
  14702. /// <summary>
  14703. /// 景点数据
  14704. /// </summary>
  14705. /// <param name="dto"></param>
  14706. /// <returns></returns>
  14707. [HttpPost]
  14708. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14709. {
  14710. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14711. return Ok(JsonView(true, "获取成功!", Data));
  14712. }
  14713. /// <summary>
  14714. /// 成本通知
  14715. /// </summary>
  14716. /// <param name="dto"></param>
  14717. /// <returns></returns>
  14718. [HttpPost]
  14719. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14720. {
  14721. if (dto.Diid < 0)
  14722. {
  14723. return Ok(JsonView(false));
  14724. }
  14725. JsonView jw;
  14726. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14727. if (GroupCostParameter != null)
  14728. {
  14729. int IsShare = 0;
  14730. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14731. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14732. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14733. string msg = string.Empty;
  14734. if (isTrue)
  14735. {
  14736. if (IsShare == 0)
  14737. {
  14738. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14739. }
  14740. else
  14741. {
  14742. #region 企微通知对应岗位用户
  14743. try
  14744. {
  14745. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14746. }
  14747. catch (Exception)
  14748. {
  14749. }
  14750. #endregion
  14751. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14752. }
  14753. jw = JsonView(isTrue, msg, new { IsShare });
  14754. }
  14755. else
  14756. {
  14757. msg = "修改失败!";
  14758. jw = JsonView(isTrue, msg);
  14759. }
  14760. }
  14761. else
  14762. {
  14763. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14764. }
  14765. return Ok(jw);
  14766. }
  14767. /// <summary>
  14768. /// 导出报价单
  14769. /// </summary>
  14770. /// <param name="dto"></param>
  14771. /// <returns></returns>
  14772. [HttpPost]
  14773. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14774. {
  14775. if (dto.Diid == 0)
  14776. {
  14777. return Ok(JsonView(false, "请传递团组id"));
  14778. }
  14779. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14780. if (deleInfo.Code != 0)
  14781. {
  14782. return Ok(JsonView(false, "团组信息查询失败!"));
  14783. }
  14784. var di = deleInfo.Data as DelegationInfoWebView;
  14785. if (di != null)
  14786. {
  14787. di.TeamName = di.TeamName.Replace("|", "、");
  14788. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14789. //文件名
  14790. string strFileName = di.TeamName + "-收款账单.doc";
  14791. //获取模板
  14792. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14793. //载入模板
  14794. Document doc = new Document(tmppath);
  14795. decimal TotalPrice = 0.00M;
  14796. string itemStr = string.Empty;
  14797. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14798. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14799. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14800. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14801. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14802. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14803. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14804. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14805. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14806. foreach (var cost in groupCostType)
  14807. {
  14808. var List = cost.ToList();
  14809. if (cost.Key == "A")
  14810. {
  14811. foreach (var ListItem in List)
  14812. {
  14813. if (ListItem.number > 0)
  14814. {
  14815. if (ListItem.code.Contains("TBR"))
  14816. {
  14817. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14818. }
  14819. else
  14820. {
  14821. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14822. }
  14823. TotalPrice += (ListItem.number * ListItem.price);
  14824. }
  14825. }
  14826. }
  14827. else
  14828. {
  14829. itemStr = itemStr.Insert(0, "A段\r\n");
  14830. itemStr += "B段\r\n";
  14831. foreach (var ListItem in List)
  14832. {
  14833. if (ListItem.number > 0)
  14834. {
  14835. if (ListItem.code.Contains("TBR"))
  14836. {
  14837. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14838. }
  14839. else
  14840. {
  14841. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14842. }
  14843. TotalPrice += (ListItem.number * ListItem.price);
  14844. }
  14845. }
  14846. }
  14847. }
  14848. #region 替换Word模板书签内容
  14849. Dictionary<string, string> marks = new Dictionary<string, string>();
  14850. marks.Add("To", di.ClientUnit);//付款方
  14851. marks.Add("ToTel", di.TellPhone);//付款方电话
  14852. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14853. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14854. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14855. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14856. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14857. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14858. marks.Add("PayItemContent", itemStr);//详细信息
  14859. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14860. #endregion
  14861. ////注
  14862. //if (doc.Range.Bookmarks["Attention"] != null)
  14863. //{
  14864. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14865. // mark.Text = frList[0].Attention;
  14866. //}
  14867. foreach (var item in marks.Keys)
  14868. {
  14869. if (doc.Range.Bookmarks[item] != null)
  14870. {
  14871. Bookmark mark = doc.Range.Bookmarks[item];
  14872. mark.Text = marks[item];
  14873. }
  14874. }
  14875. byte[] bytes = null;
  14876. using (MemoryStream stream = new MemoryStream())
  14877. {
  14878. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14879. bytes = stream.ToArray();
  14880. }
  14881. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14882. return Ok(JsonView(true, "", new
  14883. {
  14884. Data = bytes,
  14885. strFileName,
  14886. }));
  14887. }
  14888. else
  14889. {
  14890. return Ok(JsonView(false, "团组信息不存在!"));
  14891. }
  14892. }
  14893. /// <summary>
  14894. /// 导出团组成本
  14895. /// </summary>
  14896. /// <param name="dto"></param>
  14897. /// <returns></returns>
  14898. [HttpPost]
  14899. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14900. {
  14901. var jw = JsonView(false);
  14902. if (dto.Diid == 0)
  14903. {
  14904. return Ok(JsonView(false, "请传递团组id"));
  14905. }
  14906. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14907. if (deleInfo.Code != 0)
  14908. {
  14909. return Ok(JsonView(false, "团组信息查询失败!"));
  14910. }
  14911. var di = deleInfo.Data as DelegationInfoWebView;
  14912. if (di == null)
  14913. {
  14914. return Ok(JsonView(false, "团组信息查询失败!"));
  14915. }
  14916. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14917. WorkbookDesigner designer = new WorkbookDesigner();
  14918. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14919. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14920. List<int> hideColumnList = new List<int>();
  14921. var ColumnSetting = new[]
  14922. {
  14923. new { tag = "VF", Index = 4, P = "CarCost" },
  14924. new { tag = "VN", Index = 5, P = "CarNumber" },
  14925. new { tag = "VRD", Index = 6, P = "CarTiming" },
  14926. new { tag = "T/G S", Index = 7, P = "TGS" },
  14927. new { tag = "TGWH", Index = 8, P = "TGWH" },
  14928. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  14929. new { tag = "T/G M", Index = 10, P = "TGM" },
  14930. new { tag = "T/G A", Index = 11, P = "TGA" },
  14931. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  14932. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  14933. new { tag = "C/F S", Index = 14, P = "CFS" },
  14934. new { tag = "C/F M", Index = 15, P = "CFM" },
  14935. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  14936. new { tag = "B", Index = 17, P = "B" },
  14937. new { tag = "L", Index = 18, P = "L" },
  14938. new { tag = "D", Index = 19, P = "D" },
  14939. new { tag = "TBR", Index = 20, P = "TBR" },
  14940. new { tag = "SGR", Index = 21, P = "SGR" },
  14941. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  14942. new { tag = "Suite", Index = 23, P = "Suite" },
  14943. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  14944. new { tag = "T/V", Index = 25, P = "TV" },
  14945. new { tag = "1/L", Index = 26, P = "iL" },
  14946. new { tag = "I/F", Index = 27, P = "IF" },
  14947. new { tag = "EF", Index = 28, P = "EF" },
  14948. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  14949. new { tag = "TE", Index = 30, P = "TE" },
  14950. new { tag = "T/G T", Index = 31, P = "TGTips" },
  14951. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  14952. new { tag = "P/C", Index = 33, P = "PC" },
  14953. new { tag = "T/L F", Index = 34, P = "TLF" },
  14954. new { tag = "E/C T", Index = 35, P = "ECT" }
  14955. };
  14956. Func<string, bool> isEmpty = (str) =>
  14957. {
  14958. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  14959. {
  14960. return true;
  14961. }
  14962. if (string.IsNullOrWhiteSpace(str))
  14963. {
  14964. return true;
  14965. }
  14966. return false;
  14967. };
  14968. for (int i = 0; i < List_GC.Count; i++)
  14969. {
  14970. GroupCost_Excel gc = new GroupCost_Excel();
  14971. gc.Id = List_GC[i].Id;
  14972. gc.Diid = List_GC[i].Diid.ToString();
  14973. gc.DAY = List_GC[i].DAY;
  14974. string week = "";
  14975. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14976. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14977. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14978. gc.ITIN = List_GC[i].ITIN;
  14979. gc.CarType = List_GC[i].CarType;
  14980. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  14981. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  14982. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  14983. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  14984. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  14985. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  14986. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  14987. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  14988. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  14989. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  14990. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  14991. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  14992. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  14993. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  14994. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  14995. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  14996. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  14997. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  14998. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  14999. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  15000. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  15001. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  15002. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  15003. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  15004. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  15005. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  15006. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  15007. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  15008. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  15009. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  15010. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  15011. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  15012. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  15013. gc.EFR = List_GC[i].EFR;
  15014. List_GC1.Add(gc);
  15015. }
  15016. if (List_GC1.Count > 0)
  15017. {
  15018. var p = List_GC1[0];
  15019. var prs = p.GetType().GetProperties();
  15020. foreach (var item in prs)
  15021. {
  15022. var tp = item.PropertyType;
  15023. if (tp == typeof(int))
  15024. {
  15025. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  15026. if (val == 0)
  15027. {
  15028. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15029. if (columnSetting != null)
  15030. {
  15031. hideColumnList.Add(columnSetting.Index);
  15032. }
  15033. }
  15034. }
  15035. if (tp == typeof(decimal))
  15036. {
  15037. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  15038. if (val == 0)
  15039. {
  15040. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15041. if (columnSetting != null)
  15042. {
  15043. hideColumnList.Add(columnSetting.Index);
  15044. }
  15045. }
  15046. }
  15047. if (tp == typeof(string))
  15048. {
  15049. var val = List_GC1.Sum(x =>
  15050. {
  15051. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  15052. if (decimal.TryParse(str, out decimal str_De))
  15053. {
  15054. return str_De;
  15055. }
  15056. else
  15057. {
  15058. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  15059. }
  15060. });
  15061. if (val == 0)
  15062. {
  15063. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15064. if (columnSetting != null)
  15065. {
  15066. hideColumnList.Add(columnSetting.Index);
  15067. }
  15068. }
  15069. }
  15070. }
  15071. }
  15072. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  15073. dt.TableName = "TB";
  15074. //报表标题等不用dt的值
  15075. designer.SetDataSource("TeamName", dto.title.TeamName);
  15076. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  15077. designer.SetDataSource("Tax", dto.title.Tax);
  15078. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  15079. designer.SetDataSource("Currency", dto.title.Currency);
  15080. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  15081. designer.SetDataSource("Rate", dto.title.Rate);
  15082. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  15083. var Aparams = hotels.Find(x => x.Type == "Default");
  15084. if (Aparams == null)
  15085. {
  15086. return Ok(jw);
  15087. }
  15088. //酒店数量
  15089. var txtSGRNumber = Aparams.SGR.ToString();
  15090. var txtTBRNumber = Aparams.TBR.ToString();
  15091. var txtJSESNumber = Aparams.JSES.ToString();
  15092. var txtSUITENumbe = Aparams.SUITE.ToString();
  15093. if (dto.costType == "B")
  15094. {
  15095. Aparams = hotels.Find(x => x.Type == "A");
  15096. var Bparams = hotels.Find(x => x.Type == "B");
  15097. if (Aparams == null || Bparams == null)
  15098. {
  15099. return Ok(jw);
  15100. }
  15101. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  15102. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  15103. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  15104. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  15105. }
  15106. designer.SetDataSource("SGRNumber", txtSGRNumber);
  15107. designer.SetDataSource("TBRNumber", txtTBRNumber);
  15108. designer.SetDataSource("JSESNumber", txtJSESNumber);
  15109. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  15110. var ws = designer.Workbook.Worksheets[1];
  15111. int Row = List_GC.Count;
  15112. int startIndex = 0;
  15113. int HideRows = 0;
  15114. Row = 0;
  15115. List<int> hideRowsList = new List<int>();
  15116. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  15117. #region A段left数据
  15118. var left = dto.leftInfo.Find(x => x.Type == "A");
  15119. if (left == null)
  15120. {
  15121. return Ok(jw);
  15122. }
  15123. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  15124. if (leftBindData != null)
  15125. {
  15126. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  15127. designer.SetDataSource("VisaRS", leftBindData.rs);
  15128. designer.SetDataSource("VisaXS", leftBindData.xs);
  15129. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15130. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15131. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15132. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15133. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15134. }
  15135. else
  15136. {
  15137. hideRowsList.Add(Row + startIndex + HideRows);
  15138. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15139. }
  15140. HideRows += 2;
  15141. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  15142. if (leftBindData != null)
  15143. {
  15144. designer.SetDataSource("BXDRCB", leftBindData.cb);
  15145. designer.SetDataSource("BXRS", leftBindData.rs);
  15146. designer.SetDataSource("BXXS", leftBindData.xs);
  15147. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15148. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15149. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15150. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15151. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15152. }
  15153. else
  15154. {
  15155. hideRowsList.Add(Row + startIndex + HideRows);
  15156. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15157. }
  15158. HideRows += 2;
  15159. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15160. if (leftBindData != null)
  15161. {
  15162. designer.SetDataSource("HSDRCB", leftBindData.cb);
  15163. designer.SetDataSource("HSRS", leftBindData.rs);
  15164. designer.SetDataSource("HSXS", leftBindData.xs);
  15165. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15166. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15167. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15168. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15169. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15170. }
  15171. else
  15172. {
  15173. hideRowsList.Add(Row + startIndex + HideRows);
  15174. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15175. }
  15176. HideRows += 2;
  15177. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15178. if (leftBindData != null)
  15179. {
  15180. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  15181. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  15182. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  15183. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15184. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15185. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15186. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15187. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15188. }
  15189. else
  15190. {
  15191. hideRowsList.Add(Row + startIndex + HideRows);
  15192. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15193. }
  15194. HideRows += 2;
  15195. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15196. if (leftBindData != null)
  15197. {
  15198. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  15199. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  15200. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  15201. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15202. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15203. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15204. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15205. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15206. }
  15207. else
  15208. {
  15209. hideRowsList.Add(Row + startIndex + HideRows);
  15210. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15211. }
  15212. HideRows += 2;
  15213. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15214. if (leftBindData != null)
  15215. {
  15216. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  15217. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  15218. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  15219. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15220. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15221. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15222. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15223. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15224. }
  15225. else
  15226. {
  15227. hideRowsList.Add(Row + startIndex + HideRows);
  15228. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15229. }
  15230. HideRows += 2;
  15231. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15232. if (leftBindData != null)
  15233. {
  15234. ////TBR
  15235. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  15236. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  15237. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  15238. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15239. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15240. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15241. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15242. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15243. }
  15244. else
  15245. {
  15246. hideRowsList.Add(Row + startIndex + HideRows);
  15247. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15248. }
  15249. HideRows += 2;
  15250. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15251. if (leftBindData != null)
  15252. {
  15253. ////SGR
  15254. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  15255. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  15256. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  15257. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15258. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15259. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15260. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15261. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15262. }
  15263. else
  15264. {
  15265. hideRowsList.Add(Row + startIndex + HideRows);
  15266. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15267. }
  15268. HideRows += 2;
  15269. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15270. if (leftBindData != null)
  15271. {
  15272. ////JS/ES
  15273. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  15274. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  15275. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  15276. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15277. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15278. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15279. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15280. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15281. }
  15282. else
  15283. {
  15284. hideRowsList.Add(Row + startIndex + HideRows);
  15285. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15286. }
  15287. HideRows += 2;
  15288. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15289. if (leftBindData != null)
  15290. {
  15291. ////SUITE
  15292. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  15293. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  15294. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  15295. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15296. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15297. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15298. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15299. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15300. }
  15301. else
  15302. {
  15303. hideRowsList.Add(Row + startIndex + HideRows);
  15304. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15305. }
  15306. HideRows += 2;
  15307. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15308. if (leftBindData != null)
  15309. {
  15310. designer.SetDataSource("DJDRCB", leftBindData.cb);
  15311. designer.SetDataSource("DJRS", leftBindData.rs);
  15312. designer.SetDataSource("DJXS", leftBindData.xs);
  15313. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15314. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15315. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15316. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15317. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15318. }
  15319. else
  15320. {
  15321. hideRowsList.Add(Row + startIndex + HideRows);
  15322. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15323. }
  15324. HideRows += 2;
  15325. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15326. if (leftBindData != null)
  15327. {
  15328. designer.SetDataSource("HCPCB", leftBindData.cb);
  15329. designer.SetDataSource("HCPRS", leftBindData.rs);
  15330. designer.SetDataSource("HCPXS", leftBindData.xs);
  15331. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15332. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15333. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15334. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15335. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15336. }
  15337. else
  15338. {
  15339. hideRowsList.Add(Row + startIndex + HideRows);
  15340. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15341. }
  15342. HideRows += 2;
  15343. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15344. if (leftBindData != null)
  15345. {
  15346. designer.SetDataSource("CPCB", leftBindData.cb);
  15347. designer.SetDataSource("CPRS", leftBindData.rs);
  15348. designer.SetDataSource("CPXS", leftBindData.xs);
  15349. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15350. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15351. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15352. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15353. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15354. }
  15355. else
  15356. {
  15357. hideRowsList.Add(Row + startIndex + HideRows);
  15358. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15359. }
  15360. HideRows += 2;
  15361. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15362. if (leftBindData != null)
  15363. {
  15364. designer.SetDataSource("GWDRCD", leftBindData.cb);
  15365. designer.SetDataSource("GWRS", leftBindData.rs);
  15366. designer.SetDataSource("GWXS", leftBindData.xs);
  15367. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15368. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15369. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15370. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15371. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15372. }
  15373. else
  15374. {
  15375. hideRowsList.Add(Row + startIndex + HideRows);
  15376. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15377. }
  15378. HideRows += 2;
  15379. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15380. if (leftBindData != null)
  15381. {
  15382. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  15383. designer.SetDataSource("LYJRS", leftBindData.rs);
  15384. designer.SetDataSource("LYJXS", leftBindData.xs);
  15385. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15386. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15387. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15388. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15389. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15390. }
  15391. else
  15392. {
  15393. hideRowsList.Add(Row + startIndex + HideRows);
  15394. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15395. }
  15396. #endregion
  15397. #region A段Right信息
  15398. var right = dto.rightInfo.Find(x => x.Type == "A");
  15399. if (right == null)
  15400. {
  15401. return Ok(jw);
  15402. }
  15403. HideRows += 4;
  15404. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15405. if (rightBindData != null)
  15406. {
  15407. //经济舱 + 双人间 TBR
  15408. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  15409. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  15410. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15411. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  15412. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15413. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15414. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15415. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15416. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15417. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15418. }
  15419. else
  15420. {
  15421. hideRowsList.Add(Row + startIndex + HideRows);
  15422. }
  15423. HideRows += 2;
  15424. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15425. if (rightBindData != null)
  15426. {
  15427. //经济舱 + 单人间 SGR
  15428. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  15429. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  15430. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15431. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  15432. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15433. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15434. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15435. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15436. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15437. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15438. }
  15439. else
  15440. {
  15441. hideRowsList.Add(Row + startIndex + HideRows);
  15442. }
  15443. HideRows += 2;
  15444. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15445. if (rightBindData != null)
  15446. {
  15447. //公务舱 + 单人间 SGR
  15448. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  15449. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  15450. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15451. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  15452. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15453. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15454. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15455. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15456. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15457. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15458. }
  15459. else
  15460. {
  15461. hideRowsList.Add(Row + startIndex + HideRows);
  15462. }
  15463. HideRows += 2;
  15464. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15465. if (rightBindData != null)
  15466. {
  15467. //公务舱 + 小套房 JSES
  15468. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  15469. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  15470. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15471. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  15472. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15473. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15474. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15475. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15476. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15477. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15478. }
  15479. else
  15480. {
  15481. hideRowsList.Add(Row + startIndex + HideRows);
  15482. }
  15483. HideRows += 2;
  15484. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15485. if (rightBindData != null)
  15486. {
  15487. //公务舱 + 小套房 JSES
  15488. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  15489. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  15490. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15491. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  15492. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15493. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15494. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15495. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15496. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15497. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15498. }
  15499. else
  15500. {
  15501. hideRowsList.Add(Row + startIndex + HideRows);
  15502. }
  15503. HideRows += 2;
  15504. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15505. if (rightBindData != null)
  15506. {
  15507. //经济舱 + 大套房
  15508. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  15509. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  15510. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15511. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  15512. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15513. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15514. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15515. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15516. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15517. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15518. }
  15519. else
  15520. {
  15521. hideRowsList.Add(Row + startIndex + HideRows);
  15522. }
  15523. HideRows += 2;
  15524. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15525. if (rightBindData != null)
  15526. {
  15527. //头等舱 + 小套房 JSES
  15528. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15529. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15530. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15531. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15532. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15533. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15534. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15535. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15536. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15537. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15538. }
  15539. else
  15540. {
  15541. hideRowsList.Add(Row + startIndex + HideRows);
  15542. }
  15543. HideRows += 2;
  15544. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15545. if (rightBindData != null)
  15546. {
  15547. //头等舱 + 大套房
  15548. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15549. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15550. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15551. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15552. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15553. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15554. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15555. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15556. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15557. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15558. }
  15559. else
  15560. {
  15561. hideRowsList.Add(Row + startIndex + HideRows);
  15562. }
  15563. #endregion
  15564. #region B段标题清空
  15565. designer.SetDataSource("CostBDRCB", "");
  15566. designer.SetDataSource("CostBRS", "");
  15567. designer.SetDataSource("CostBXS", "");
  15568. designer.SetDataSource("CostBZCB", "");
  15569. designer.SetDataSource("CostBDRBJ", "");
  15570. designer.SetDataSource("CostBZBJ", "");
  15571. designer.SetDataSource("CostBDRLR", "");
  15572. designer.SetDataSource("CostBZLR", "");
  15573. designer.SetDataSource("CostBDRCBOM", "");
  15574. designer.SetDataSource("CostBRSOM", "");
  15575. designer.SetDataSource("CostBZCBOM", "");
  15576. designer.SetDataSource("CostBDRBJOM", "");
  15577. designer.SetDataSource("CostBZBJOM", "");
  15578. designer.SetDataSource("CostBDRLROM", "");
  15579. designer.SetDataSource("CostBZLROM", "");
  15580. #endregion
  15581. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15582. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15583. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15584. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15585. designer.SetDataSource("DJName", "地接(CNY)");
  15586. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15587. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15588. designer.SetDataSource("GWName", "公务(CNY)");
  15589. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15590. designer.SetDataSource("LYJName", "零用金(CNY)");
  15591. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15592. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15593. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15594. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15595. designer.SetDataSource("BXName", "保险(CNY)");
  15596. designer.SetDataSource("VisaName", "签证(CNY)");
  15597. #region B段基本数据
  15598. if (dto.costType == "B")
  15599. {
  15600. left = dto.leftInfo.Find(x => x.Type == "B");
  15601. if (left == null)
  15602. {
  15603. return Ok(jw);
  15604. }
  15605. #region B段left数据
  15606. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15607. if (leftBindData != null)
  15608. {
  15609. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15610. designer.SetDataSource("BHSRS", leftBindData.rs);
  15611. designer.SetDataSource("BHSXS", leftBindData.xs);
  15612. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15613. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15614. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15615. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15616. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15617. }
  15618. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15619. if (leftBindData != null)
  15620. {
  15621. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15622. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15623. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15624. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15625. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15626. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15627. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15628. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15629. }
  15630. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15631. if (leftBindData != null)
  15632. {
  15633. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15634. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15635. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15636. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15637. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15638. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15639. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15640. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15641. }
  15642. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15643. if (leftBindData != null)
  15644. {
  15645. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15646. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15647. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15648. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15649. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15650. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15651. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15652. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15653. }
  15654. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15655. if (leftBindData != null)
  15656. {
  15657. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15658. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15659. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15660. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15661. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15662. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15663. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15664. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15665. }
  15666. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15667. if (leftBindData != null)
  15668. {
  15669. designer.SetDataSource("BCPCB", leftBindData.cb);
  15670. designer.SetDataSource("BCPRS", leftBindData.rs);
  15671. designer.SetDataSource("BCPXS", leftBindData.xs);
  15672. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15673. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15674. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15675. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15676. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15677. }
  15678. //TBR
  15679. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15680. if (leftBindData != null)
  15681. {
  15682. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15683. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15684. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15685. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15686. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15687. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15688. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15689. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15690. }
  15691. //SGR
  15692. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15693. if (leftBindData != null)
  15694. {
  15695. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15696. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15697. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15698. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15699. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15700. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15701. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15702. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15703. }
  15704. //JS/ES
  15705. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15706. if (leftBindData != null)
  15707. {
  15708. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15709. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15710. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15711. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15712. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15713. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15714. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15715. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15716. }
  15717. //SUITE
  15718. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15719. if (leftBindData != null)
  15720. {
  15721. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15722. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15723. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15724. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15725. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15726. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15727. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15728. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15729. }
  15730. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15731. if (leftBindData != null)
  15732. {
  15733. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15734. designer.SetDataSource("BDJRS", leftBindData.rs);
  15735. designer.SetDataSource("BDJXS", leftBindData.xs);
  15736. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15737. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15738. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15739. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15740. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15741. }
  15742. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15743. if (leftBindData != null)
  15744. {
  15745. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15746. designer.SetDataSource("BGWRS", leftBindData.rs);
  15747. designer.SetDataSource("BGWXS", leftBindData.xs);
  15748. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15749. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15750. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15751. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15752. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15753. }
  15754. #region 优化方案
  15755. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15756. //excelBind.Add("零用金", new {
  15757. //cb="",
  15758. //rs="",
  15759. //xs ="",
  15760. //zcb = "",
  15761. //});
  15762. #endregion
  15763. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15764. if (leftBindData != null)
  15765. {
  15766. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15767. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15768. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15769. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15770. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15771. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15772. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15773. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15774. }
  15775. #endregion
  15776. #region B段Right信息
  15777. right = dto.rightInfo.Find(x => x.Type == "B");
  15778. if (right == null)
  15779. {
  15780. return Ok(jw);
  15781. }
  15782. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15783. if (rightBindData != null)
  15784. {
  15785. //经济舱 + 双人间 TBR
  15786. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15787. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15788. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15789. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15790. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15791. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15792. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15793. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15794. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15795. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15796. }
  15797. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15798. if (rightBindData != null)
  15799. {
  15800. //经济舱 + 单人间 SGR
  15801. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15802. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15803. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15804. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15805. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15806. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15807. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15808. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15809. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15810. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15811. }
  15812. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15813. if (rightBindData != null)
  15814. {
  15815. //公务舱 + 单人间 SGR
  15816. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15817. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15818. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15819. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15820. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15821. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15822. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15823. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15824. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15825. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15826. }
  15827. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15828. if (rightBindData != null)
  15829. {
  15830. //公务舱 + 小套房 JSES
  15831. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15832. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15833. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15834. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15835. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15836. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15837. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15838. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15839. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15840. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15841. }
  15842. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15843. if (rightBindData != null)
  15844. {
  15845. //公务舱 + 小套房 JSES
  15846. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15847. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15848. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15849. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15850. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15851. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15852. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15853. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15854. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15855. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15856. }
  15857. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15858. if (rightBindData != null)
  15859. {
  15860. //经济舱 + 大套房
  15861. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15862. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15863. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15864. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15865. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15866. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15867. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15868. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15869. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15870. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15871. }
  15872. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15873. if (rightBindData != null)
  15874. {
  15875. //头等舱 + 小套房 JSES
  15876. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15877. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15878. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15879. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15880. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15881. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15882. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15883. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15884. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15885. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15886. }
  15887. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15888. if (rightBindData != null)
  15889. {
  15890. //头等舱 + 大套房
  15891. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15892. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15893. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15894. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15895. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15896. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15897. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15898. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15899. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15900. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15901. }
  15902. #endregion
  15903. #region 标题
  15904. designer.SetDataSource("CostBDRCB", "单人成本");
  15905. designer.SetDataSource("CostBRS", "人数");
  15906. designer.SetDataSource("CostBXS", "系数");
  15907. designer.SetDataSource("CostBZCB", "总成本");
  15908. designer.SetDataSource("CostBDRBJ", "单人报价");
  15909. designer.SetDataSource("CostBZBJ", "总报价");
  15910. designer.SetDataSource("CostBDRLR", "单人利润");
  15911. designer.SetDataSource("CostBZLR", "总利润");
  15912. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15913. designer.SetDataSource("CostBRSOM", "人数");
  15914. designer.SetDataSource("CostBZCBOM", "总成本");
  15915. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15916. designer.SetDataSource("CostBZBJOM", "总报价");
  15917. designer.SetDataSource("CostBDRLROM", "单人利润");
  15918. designer.SetDataSource("CostBZLROM", "总利润");
  15919. #endregion
  15920. }
  15921. #endregion
  15922. designer.SetDataSource("TzZCB2", TzZCB2);
  15923. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15924. designer.SetDataSource("TzZLR2", TzZLR2);
  15925. string[] dataSourceKeys = new string[]
  15926. {
  15927. "VF",
  15928. "TGS",
  15929. "TGOF",
  15930. "TGM",
  15931. "TGA",
  15932. "TGTF",
  15933. "TGEF",
  15934. "CFM",
  15935. "CFOF",
  15936. "B",
  15937. "L",
  15938. "D",
  15939. "TBR",
  15940. "SGR",
  15941. "JSES",
  15942. "Suite",
  15943. "TV",
  15944. "1L",
  15945. "IF",
  15946. "EF",
  15947. "BRF",
  15948. "TE",
  15949. "TGT",
  15950. "DRVT",
  15951. "PC",
  15952. "TLF",
  15953. "ECT"
  15954. };
  15955. foreach (var item in dataSourceKeys)
  15956. {
  15957. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  15958. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  15959. var find = dto.titleModel.FirstOrDefault(expr);
  15960. if (find != null)
  15961. {
  15962. designer.SetDataSource(item, find.text);
  15963. }
  15964. else
  15965. {
  15966. designer.SetDataSource(item, 0);
  15967. }
  15968. }
  15969. designer.SetDataSource(dt);
  15970. //根据数据源处理生成报表内容
  15971. designer.Process();
  15972. designer.Workbook.Worksheets[0].Name = "费用明细";
  15973. designer.Workbook.Worksheets[1].Name = "费用总核算";
  15974. Worksheet sheet = designer.Workbook.Worksheets[0];
  15975. #region 隐藏舱位
  15976. var settingAir = new[]
  15977. {
  15978. new { key = "经济舱", index = 7 },
  15979. new { key = "公务舱", index = 19 },
  15980. new { key = "头等舱", index = 11 }
  15981. };
  15982. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  15983. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  15984. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  15985. .Select((c, s) => s.Name)
  15986. .ToList()
  15987. .GroupBy(x => x)
  15988. .Select(x => x.Key);
  15989. foreach (var item in settingAir)
  15990. {
  15991. if (!airType.Contains(item.key))
  15992. {
  15993. hideRowsList.Add(item.index);
  15994. }
  15995. }
  15996. #endregion
  15997. foreach (var Rowindex in hideRowsList)
  15998. {
  15999. ws.Cells.HideRows(Rowindex, 2);
  16000. }
  16001. ws = designer.Workbook.Worksheets[0];
  16002. foreach (var Column in hideColumnList)
  16003. {
  16004. ws.Cells.HideColumns(Column, 1);
  16005. }
  16006. byte[] bytes = null;
  16007. string strFileName = di.TeamName + "-团组-成本.xls";
  16008. using (MemoryStream stream = new MemoryStream())
  16009. {
  16010. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  16011. bytes = stream.ToArray();
  16012. }
  16013. return Ok(JsonView(true, "", new
  16014. {
  16015. Data = bytes,
  16016. strFileName,
  16017. }));
  16018. }
  16019. /// <summary>
  16020. /// 导出客户报表
  16021. /// </summary>
  16022. /// <returns></returns>
  16023. [HttpPost]
  16024. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  16025. {
  16026. var jw = JsonView(false);
  16027. if (dto.Diid == 0)
  16028. {
  16029. return Ok(JsonView(false, "请传递团组id"));
  16030. }
  16031. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  16032. if (deleInfo.Code != 0)
  16033. {
  16034. return Ok(JsonView(false, "团组信息查询失败!"));
  16035. }
  16036. var di = deleInfo.Data as DelegationInfoWebView;
  16037. if (di == null)
  16038. {
  16039. return Ok(JsonView(false, "团组信息查询失败!"));
  16040. }
  16041. //文件名
  16042. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  16043. //获取模板
  16044. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  16045. //载入模板
  16046. Document doc = new Document(tmppath);
  16047. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  16048. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  16049. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  16050. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  16051. var AParameter = ParameterList.Find(x => x.CostType == "A");
  16052. var BParameter = ParameterList.Find(x => x.CostType == "B");
  16053. if (AParameter == null)
  16054. {
  16055. return Ok(JsonView(false, "系数不存在!"));
  16056. }
  16057. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  16058. , TzAirDesc, TzZCost;
  16059. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  16060. = TzAirDesc = TzZCost = string.Empty;
  16061. TzNumber = AParameter.CostTypenumber.ToString();
  16062. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  16063. CarGuides1 = dto.CarGuides1;
  16064. Meal = dto.Meal;
  16065. SubsidizedMeals = dto.SubsidizedMeals;
  16066. NightRepair = dto.NightRepair;
  16067. AttractionsTickets = dto.AttractionsTickets;
  16068. MiscellaneousFees = dto.MiscellaneousFees;
  16069. ATip = dto.ATip;
  16070. TzHotelDesc = "";
  16071. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  16072. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  16073. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  16074. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  16075. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  16076. TzAirDesc = "";
  16077. TzZCost = dto.TzZCost;
  16078. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  16079. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  16080. var index = 1;
  16081. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  16082. foreach (var item in TzHotelDescArr)
  16083. {
  16084. if (AinfoArr != null)
  16085. {
  16086. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16087. if (Ainfo != null)
  16088. {
  16089. if (int.Parse(Ainfo.rs) <= 0)
  16090. {
  16091. continue;
  16092. }
  16093. var hotelText = string.Empty;
  16094. switch (item)
  16095. {
  16096. case "SGR":
  16097. hotelText = "单人间";
  16098. break;
  16099. case "JSES":
  16100. hotelText = "小套房";
  16101. break;
  16102. case "SUITE":
  16103. hotelText = "套房";
  16104. break;
  16105. case "TBR":
  16106. hotelText = "双人间";
  16107. break;
  16108. }
  16109. if (item != "TBR")
  16110. {
  16111. 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";
  16112. }
  16113. else
  16114. {
  16115. 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";
  16116. }
  16117. index++;
  16118. }
  16119. }
  16120. }
  16121. index = 1;
  16122. foreach (var item in TzAirDescArr)
  16123. {
  16124. if (AinfoArr != null)
  16125. {
  16126. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16127. if (Ainfo != null)
  16128. {
  16129. if (int.Parse(Ainfo.rs) <= 0)
  16130. {
  16131. continue;
  16132. }
  16133. 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";
  16134. index++;
  16135. }
  16136. }
  16137. }
  16138. if (dto.costType == "B")
  16139. {
  16140. if (BParameter == null)
  16141. {
  16142. return Ok(JsonView(false, "B段系数不存在!"));
  16143. }
  16144. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  16145. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  16146. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  16147. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  16148. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  16149. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  16150. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  16151. foreach (var item in TzHotelDescArr)
  16152. {
  16153. if (AinfoArr != null)
  16154. {
  16155. TzHotelDesc += "B段信息 \r\n";
  16156. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16157. if (Ainfo != null)
  16158. {
  16159. if (int.Parse(Ainfo.rs) <= 0)
  16160. {
  16161. continue;
  16162. }
  16163. var hotelText = string.Empty;
  16164. switch (item)
  16165. {
  16166. case "SGR":
  16167. hotelText = "单人间";
  16168. break;
  16169. case "JSES":
  16170. hotelText = "小套房";
  16171. break;
  16172. case "SUITE":
  16173. hotelText = "套房";
  16174. break;
  16175. case "TBR":
  16176. hotelText = "双人间";
  16177. break;
  16178. }
  16179. if (item != "TBR")
  16180. {
  16181. 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";
  16182. }
  16183. else
  16184. {
  16185. 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";
  16186. }
  16187. index++;
  16188. }
  16189. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  16190. }
  16191. }
  16192. index = 1;
  16193. foreach (var item in TzAirDescArr)
  16194. {
  16195. if (AinfoArr != null)
  16196. {
  16197. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16198. if (Ainfo != null)
  16199. {
  16200. if (int.Parse(Ainfo.rs) <= 0)
  16201. {
  16202. continue;
  16203. }
  16204. 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";
  16205. index++;
  16206. }
  16207. }
  16208. }
  16209. }
  16210. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  16211. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  16212. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  16213. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  16214. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  16215. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  16216. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  16217. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  16218. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  16219. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  16220. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  16221. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  16222. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  16223. DickeyValue.Add("Visa", Visa); // 签证单人报价
  16224. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  16225. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  16226. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  16227. DickeyValue.Add("TzZCost", TzZCost);
  16228. foreach (var key in DickeyValue.Keys)
  16229. {
  16230. if (doc.Range.Bookmarks[key] != null)
  16231. {
  16232. Bookmark mark = doc.Range.Bookmarks[key];
  16233. mark.Text = DickeyValue[key];
  16234. }
  16235. }
  16236. byte[] bytes = null;
  16237. string strFileName = di.TeamName + "-客户报价.doc";
  16238. using (MemoryStream stream = new MemoryStream())
  16239. {
  16240. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  16241. bytes = stream.ToArray();
  16242. }
  16243. return Ok(JsonView(true, "", new
  16244. {
  16245. Data = bytes,
  16246. strFileName,
  16247. }));
  16248. }
  16249. /// <summary>
  16250. /// 团组成本 各模块(酒店,地接,机票)成本提示
  16251. /// </summary>
  16252. /// <param name="dto"></param>
  16253. /// <returns></returns>
  16254. [HttpPost]
  16255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16256. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  16257. {
  16258. try
  16259. {
  16260. #region 参数验证
  16261. if (dto.DiId < 0)
  16262. {
  16263. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  16264. }
  16265. List<int> cTableIds = new List<int>() {
  16266. 76 ,//酒店预订
  16267. 77 ,//行程
  16268. 79 ,//车/导游地接
  16269. 80 ,//签证
  16270. 81 ,//邀请/公务活
  16271. 82 ,//团组客户保险
  16272. 85 ,//机票预订
  16273. 98 ,//其他款项
  16274. 285 ,//收款退还
  16275. 751 ,//酒店早餐
  16276. 1015 // 超支费用
  16277. };
  16278. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  16279. {
  16280. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  16281. }
  16282. #endregion
  16283. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  16284. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  16285. if (_GroupCostParameters.Count <= 0)
  16286. {
  16287. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  16288. }
  16289. if (_GroupCostParameters[0].IsShare == 0)
  16290. {
  16291. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  16292. }
  16293. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16294. //处理date为空问题
  16295. if (_GroupCosts.Count > 0)
  16296. {
  16297. for (int i = 0; i < _GroupCosts.Count; i++)
  16298. {
  16299. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  16300. {
  16301. if (i > 0)
  16302. {
  16303. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  16304. }
  16305. }
  16306. }
  16307. }
  16308. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  16309. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  16310. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  16311. string currCode = "";
  16312. #region currCode 验证
  16313. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  16314. if (isInt)
  16315. {
  16316. var currData = currDatas.Find(it => it.Id == intCurrency);
  16317. if (currData != null)
  16318. {
  16319. currCode = currData.Name;
  16320. }
  16321. }
  16322. else
  16323. {
  16324. currCode = _GroupCostParameters[0].Currency.Trim();
  16325. }
  16326. #endregion
  16327. //op,酒店单段模式存储
  16328. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  16329. {
  16330. CurrencyCode = currCode,
  16331. Rate = _GroupCostParameters[0].Rate,
  16332. CostType = _GroupCostParameters[0].CostType,
  16333. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  16334. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  16335. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  16336. };
  16337. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  16338. if (_GroupCostParameters.Count == 2)
  16339. {
  16340. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  16341. }
  16342. foreach (var item in _GroupCostParameters)
  16343. {
  16344. decimal _rate = 1;
  16345. decimal _rate1 = item.Rate;
  16346. decimal _scale = 1;
  16347. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  16348. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  16349. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  16350. //if (userInfo != null)
  16351. //{
  16352. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  16353. // {
  16354. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  16355. // {
  16356. // _scale = 1.00M;
  16357. // }
  16358. // }
  16359. //}
  16360. #endregion
  16361. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  16362. {
  16363. CurrencyCode = currCode,
  16364. Rate = _rate1,
  16365. CostType = item.CostType,
  16366. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  16367. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  16368. CostTypeNumber = item.CostTypenumber
  16369. };
  16370. if (_GroupCostParameters.Count > 1)
  16371. {
  16372. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  16373. }
  16374. else
  16375. {
  16376. modulePromptInfo.CostTypeNumber = item.LYJRS;
  16377. }
  16378. if (dto.CTable == 79)//
  16379. {
  16380. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  16381. modulePromptInfo.TotalCost = item.DJCB;
  16382. }
  16383. List<string> costTypes = new List<string>() { "A", "B" };
  16384. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  16385. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  16386. if (_GroupCostsDuplicates.Count() == 1)
  16387. {
  16388. _GroupCostsTypeData = _GroupCosts;
  16389. }
  16390. else
  16391. {
  16392. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  16393. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  16394. }
  16395. /*
  16396. * 76 酒店预订
  16397. * 77 行程
  16398. * 79 车/导游地接
  16399. * 80 签证
  16400. * 81 邀请/公务活动
  16401. * 82 团组客户保险
  16402. * 85 机票预订
  16403. * 98 其他款项
  16404. * 285 收款退还
  16405. * 751 酒店早餐
  16406. * 1015 超支费用
  16407. */
  16408. switch (dto.CTable)
  16409. {
  16410. case 76: // 酒店预订
  16411. _ModuleSubPromptInfo.AddRange(
  16412. _GroupCostsTypeData.Select(it => new
  16413. {
  16414. it.DAY,
  16415. it.Date,
  16416. it.ACCON,
  16417. it.ITIN,
  16418. it.SGR,
  16419. it.TBR,
  16420. it.JS_ES,
  16421. it.Suite
  16422. })
  16423. );
  16424. break;
  16425. case 79: // 车/导游地接
  16426. _ModuleSubPromptInfo.AddRange(
  16427. _GroupCostsTypeData.Select(it => new
  16428. {
  16429. Date = it.Date, //日期
  16430. CarFee = it.CarCost * _rate * _scale, //车费用
  16431. CarType = it.CarType, //车型
  16432. DriverFee = it.CFS * _rate * _scale, //司机工资
  16433. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  16434. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  16435. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  16436. GuideFee = it.TGS * _rate * _scale, //导游费用
  16437. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  16438. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  16439. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  16440. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  16441. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  16442. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  16443. Breakfast = it.B * _rate * _scale, //早餐费
  16444. Lunch = it.L * _rate * _scale, //午餐费
  16445. Dinner = it.D * _rate * _scale, //晚餐费
  16446. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  16447. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  16448. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  16449. TicketFee = it.EF * _rate * _scale, //门票费
  16450. TicketRemark = it.EFR, //门票费描述
  16451. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  16452. TravelSupplies = it.TE * _rate * _scale, //出行物资
  16453. SpentCash = it.PC * _rate * _scale, //零用金
  16454. LeadersFee = it.TLF * _rate * _scale, //领队费
  16455. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  16456. })
  16457. );
  16458. break;
  16459. case 85: // 机票
  16460. List<dynamic> datas = new List<dynamic>();
  16461. datas.Add(
  16462. new
  16463. {
  16464. AirType = "经济舱",
  16465. AirNum = item.JJCRS,
  16466. AirDRCB = item.JJCCB,
  16467. AirZCB = (item.JJCRS * item.JJCCB)
  16468. }
  16469. );
  16470. datas.Add(
  16471. new
  16472. {
  16473. AirType = "公务舱",
  16474. AirNum = item.GWCRS,
  16475. AirDRCB = item.GWCCB,
  16476. AirZCB = (item.GWCRS * item.GWCCB)
  16477. }
  16478. );
  16479. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16480. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  16481. modulePromptInfo.Data = new
  16482. {
  16483. airFeeData = datas,
  16484. airInitData = initDatas
  16485. };
  16486. _ModulePromptInfos.Add(modulePromptInfo);
  16487. break;
  16488. default:
  16489. break;
  16490. }
  16491. }
  16492. if (dto.CTable != 85)
  16493. {
  16494. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  16495. _ModulePromptInfos.Add(_ModulePromptInfo);
  16496. }
  16497. _view.ModulePromptInfos = _ModulePromptInfos;
  16498. return Ok(JsonView(true, "操作成功!", _view));
  16499. }
  16500. catch (Exception ex)
  16501. {
  16502. return Ok(JsonView(false, ex.Message));
  16503. }
  16504. }
  16505. /// <summary>
  16506. /// 根据黑屏代码重新生成行程
  16507. /// </summary>
  16508. /// <param name="dto"></param>
  16509. /// <returns></returns>
  16510. [HttpPost]
  16511. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  16512. {
  16513. var jw = JsonView(false, "Error");
  16514. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  16515. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  16516. .Select(x => new
  16517. {
  16518. x.Id,
  16519. x.Title
  16520. })
  16521. .ToList();
  16522. if (Create.Any())
  16523. {
  16524. jw.Msg = "获取成功!";
  16525. jw.Code = 200;
  16526. jw.Data = new
  16527. {
  16528. BlackCodeListSelect = Create,
  16529. blackCodeIsTrue = true
  16530. };
  16531. }
  16532. else
  16533. {
  16534. jw.Code = 400;
  16535. jw.Data = new
  16536. {
  16537. BlackCodeListSelect = Create,
  16538. blackCodeIsTrue = false,
  16539. };
  16540. }
  16541. return Ok(jw);
  16542. }
  16543. /// <summary>
  16544. /// 根据黑屏代码Id重新生成行程
  16545. /// </summary>
  16546. /// <param name="dto"></param>
  16547. /// <returns></returns>
  16548. [HttpPost]
  16549. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  16550. {
  16551. var jw = JsonView(false, "Error");
  16552. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16553. if (result.Code == 0)
  16554. {
  16555. jw.Msg = "获取成功!";
  16556. jw.Code = 200;
  16557. jw.Data = new
  16558. {
  16559. groupCost = result.Data,
  16560. blackCodeIsTrue = true
  16561. };
  16562. }
  16563. else
  16564. {
  16565. jw.Code = 400;
  16566. jw.Data = new
  16567. {
  16568. groupCost = result.Data,
  16569. blackCodeIsTrue = false,
  16570. };
  16571. }
  16572. return Ok(jw);
  16573. }
  16574. /// <summary>
  16575. /// 成本获取OP历史车费用
  16576. /// </summary>
  16577. /// <param name="dto"></param>
  16578. /// <returns></returns>
  16579. [HttpPost]
  16580. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16581. {
  16582. var jw = JsonView(false);
  16583. try
  16584. {
  16585. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16586. //获取现有所有车的数据
  16587. if (!dto.Param.IsNullOrWhiteSpace())
  16588. {
  16589. string sql = $@"
  16590. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16591. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16592. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16593. 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
  16594. AND gctggr.ServiceEndTime is not NULL
  16595. ORDER by gctggrc.id DESC
  16596. ";
  16597. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16598. var numeberResult = await Task.Run(() =>
  16599. {
  16600. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16601. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16602. return numberArr;
  16603. });
  16604. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16605. foreach (var item in numeberResult)
  16606. {
  16607. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16608. {
  16609. Country = "数据异常!",
  16610. City = string.Empty,
  16611. };
  16612. item.Area = find.Country + " " + find.City;
  16613. }
  16614. dbResult.AddRange(numeberResult);
  16615. if (dto.Param.Contains("、"))
  16616. {
  16617. var sp = dto.Param.Split("、");
  16618. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16619. .Where(x =>
  16620. {
  16621. return System.Array.Exists(sp, e =>
  16622. {
  16623. bool where = false;
  16624. if (x.Area != null)
  16625. {
  16626. where = x.Area.Contains(e);
  16627. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16628. {
  16629. return false;
  16630. }
  16631. }
  16632. if (x.PriceName != null && !where)
  16633. {
  16634. where = x.PriceName.Contains(e);
  16635. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16636. {
  16637. return false;
  16638. }
  16639. }
  16640. return where;
  16641. });
  16642. }).ToList();
  16643. }
  16644. else
  16645. {
  16646. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16647. .Where(x =>
  16648. {
  16649. bool where = false;
  16650. if (x.Area != null)
  16651. {
  16652. where = x.Area.Contains(dto.Param);
  16653. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16654. {
  16655. return false;
  16656. }
  16657. }
  16658. if (x.PriceName != null && !where)
  16659. {
  16660. where = x.PriceName.Contains(dto.Param);
  16661. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16662. {
  16663. return false;
  16664. }
  16665. }
  16666. return where;
  16667. }
  16668. )
  16669. .ToList();
  16670. }
  16671. }
  16672. var view = dbResult.Select(x =>
  16673. {
  16674. decimal dp = 0.00M;
  16675. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16676. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16677. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16678. {
  16679. if (startB && endB)
  16680. {
  16681. var timesp = endD.Subtract(startD);
  16682. if ((timesp.Days + 1) != 0)
  16683. {
  16684. dp = x.Price / (timesp.Days + 1);
  16685. }
  16686. }
  16687. }
  16688. else
  16689. {
  16690. dp = x.Price;
  16691. }
  16692. return new
  16693. {
  16694. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16695. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16696. x.Area,
  16697. x.id,
  16698. price = x.Price.ToString("F2"),
  16699. x.PriceName,
  16700. x.PriceContent,
  16701. x.TeamName,
  16702. x.DatePrice,
  16703. dayPrice = dp.ToString("F2"),
  16704. };
  16705. }).OrderByDescending(x => x.id).ToList();
  16706. jw = JsonView(true, "获取成功!", view);
  16707. }
  16708. catch (Exception e)
  16709. {
  16710. jw = JsonView(false, e.Message);
  16711. }
  16712. return Ok(jw);
  16713. }
  16714. [HttpPost]
  16715. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16716. {
  16717. var jw = JsonView(true);
  16718. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16719. #region SQL语句
  16720. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  16721. //{
  16722. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16723. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16724. // WHEN COUNT(*) >= 0 THEN 'True'
  16725. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16726. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16727. // ")
  16728. // .ToList();
  16729. //}
  16730. //else
  16731. //{
  16732. // string likeKey = string.Empty;
  16733. // foreach (var item in dto.Keyword)
  16734. // {
  16735. // likeKey += "%" + item;
  16736. // }
  16737. // likeKey += "%";
  16738. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16739. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16740. // WHEN COUNT(*) >= 0 THEN 'True'
  16741. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16742. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16743. // ")
  16744. // .ToList();
  16745. //}
  16746. #endregion
  16747. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  16748. {
  16749. @KeyWord = dto.Keyword
  16750. });
  16751. if (table != null && table.Rows.Count > 0)
  16752. {
  16753. foreach (DataRow row in table.Rows)
  16754. {
  16755. matches.Add(new DelegationInfoAndIsTrueView
  16756. {
  16757. Id = row.Field<int>("Id"),
  16758. GroupName = row.Field<string>("GroupName"),
  16759. isTrue = row.Field<string>("isTrue")
  16760. });
  16761. }
  16762. }
  16763. if (matches.Any())
  16764. {
  16765. jw.Data = matches;
  16766. }
  16767. else
  16768. {
  16769. jw.Code = 201;
  16770. jw.Msg = "empty list";
  16771. jw.Data = new List<string>(1);
  16772. }
  16773. return Ok(jw);
  16774. }
  16775. /// <summary>
  16776. /// 报价Word下载
  16777. /// </summary>
  16778. /// <param name="dto"></param>
  16779. /// <returns></returns>
  16780. [HttpPost]
  16781. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16782. {
  16783. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16784. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16785. if (di == null)
  16786. {
  16787. return Ok(JsonView(false, "团组不存在!"));
  16788. }
  16789. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16790. if (mainPrice == null || mainPrice.IsShare == 0)
  16791. {
  16792. return Ok(JsonView(false, "团组成本不存在!"));
  16793. }
  16794. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16795. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16796. if (costTypeHotelNumbers == null)
  16797. {
  16798. return Ok(JsonView(false, "团组成本不存在!"));
  16799. }
  16800. //文件名
  16801. string strFileName = di.TeamName + "-收款账单.doc";
  16802. //获取模板
  16803. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16804. //载入模板
  16805. Document doc = new Document(tmppath);
  16806. decimal allPrice = 0.00M;
  16807. string itemStr = string.Empty;
  16808. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16809. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16810. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16811. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16812. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16813. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16814. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16815. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16816. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16817. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16818. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16819. {
  16820. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16821. ("BXRS", "BXCB", "BXXS", "bx"),
  16822. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16823. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16824. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16825. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16826. ("CPRS", "CPCB", "CPXS", "cp"),
  16827. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16828. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16829. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16830. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16831. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16832. ("DJRS", "DJCB", "DJXS", "dj"),
  16833. ("GWRS", "GWCB", "GWXS", "gw"),
  16834. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16835. };
  16836. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16837. var rightSum = 0.00M;
  16838. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16839. {
  16840. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16841. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16842. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16843. if (prefix == "tbr")
  16844. {
  16845. rsValue *= 2;
  16846. cbValue /= 2;
  16847. }
  16848. if (OtherCostPropertyBJ.Contains(prefix))
  16849. {
  16850. rightSum += cbValue * xsValue;
  16851. }
  16852. }
  16853. var hotelRooms = new Dictionary<string, int>
  16854. {
  16855. { "SGR", costTypeHotelNumbers.SGR },
  16856. { "TBR", costTypeHotelNumbers.TBR },
  16857. { "JSES", costTypeHotelNumbers.JSES },
  16858. { "SUITE", costTypeHotelNumbers.SUITE }
  16859. };
  16860. var flights = new Dictionary<string, int>
  16861. {
  16862. { "经济舱", mainPrice.JJCRS },
  16863. { "公务舱", mainPrice.GWCRS },
  16864. { "头等舱", mainPrice.TDCRS }
  16865. };
  16866. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16867. {
  16868. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16869. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16870. { "头等舱", new[] { "SUITE", "JSES" } }
  16871. };
  16872. var result = new Dictionary<string, int>();
  16873. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16874. foreach (var flight in flights.Keys)
  16875. {
  16876. // 获取当前舱位的匹配规则
  16877. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16878. {
  16879. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16880. }
  16881. }
  16882. #region right计算
  16883. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16884. {
  16885. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16886. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16887. airHotelPriceList.Add(new
  16888. AirHotelPrice
  16889. {
  16890. Name = "经济舱TBR",
  16891. Price = rightSum + air + hotel,
  16892. Count = result["经济舱TBR"] * 2
  16893. });
  16894. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16895. }
  16896. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16897. {
  16898. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16899. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16900. airHotelPriceList.Add(new
  16901. AirHotelPrice
  16902. {
  16903. Name = "经济舱SGR",
  16904. Price = rightSum + air + hotel,
  16905. Count = result["经济舱SGR"]
  16906. });
  16907. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16908. }
  16909. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16910. {
  16911. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16912. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16913. airHotelPriceList.Add(new
  16914. AirHotelPrice
  16915. {
  16916. Name = "公务舱SGR",
  16917. Price = rightSum + air + hotel,
  16918. Count = result["公务舱SGR"]
  16919. });
  16920. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16921. }
  16922. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16923. {
  16924. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16925. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16926. airHotelPriceList.Add(new
  16927. AirHotelPrice
  16928. {
  16929. Name = "公务舱JSES",
  16930. Price = rightSum + air + hotel,
  16931. Count = result["公务舱JSES"]
  16932. });
  16933. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16934. }
  16935. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16936. {
  16937. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16938. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16939. airHotelPriceList.Add(new
  16940. AirHotelPrice
  16941. {
  16942. Name = "公务舱SUITE",
  16943. Price = rightSum + air + hotel,
  16944. Count = result["公务舱SUITE"]
  16945. });
  16946. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16947. }
  16948. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16949. {
  16950. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16951. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16952. airHotelPriceList.Add(new
  16953. AirHotelPrice
  16954. {
  16955. Name = "经济舱SUITE",
  16956. Price = rightSum + air + hotel,
  16957. Count = result["经济舱SUITE"]
  16958. });
  16959. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16960. }
  16961. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16962. {
  16963. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16964. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16965. airHotelPriceList.Add(new
  16966. AirHotelPrice
  16967. {
  16968. Name = "头等舱JSES",
  16969. Price = rightSum + air + hotel,
  16970. Count = result["头等舱JSES"]
  16971. });
  16972. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16973. }
  16974. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16975. {
  16976. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16977. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16978. airHotelPriceList.Add(new
  16979. AirHotelPrice
  16980. {
  16981. Name = "头等舱SUITE",
  16982. Price = rightSum + air + hotel,
  16983. Count = result["头等舱SUITE"]
  16984. });
  16985. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16986. }
  16987. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16988. {
  16989. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16990. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16991. airHotelPriceList.Add(new
  16992. AirHotelPrice
  16993. {
  16994. Name = "经济舱JSES",
  16995. Price = rightSum + air + hotel,
  16996. Count = result["经济舱JSES"]
  16997. });
  16998. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16999. }
  17000. #endregion
  17001. foreach (var item in airSouer.Keys)
  17002. {
  17003. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  17004. if (find != null && find.Count > 0)
  17005. {
  17006. if (item.Contains("TBR"))
  17007. {
  17008. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17009. }
  17010. else
  17011. {
  17012. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17013. }
  17014. }
  17015. }
  17016. #region 替换Word模板书签内容
  17017. Dictionary<string, string> marks = new Dictionary<string, string>();
  17018. marks.Add("To", di.ClientUnit);//付款方
  17019. marks.Add("ToTel", di.TellPhone);//付款方电话
  17020. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  17021. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  17022. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  17023. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  17024. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  17025. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  17026. marks.Add("PayItemContent", itemStr);//详细信息
  17027. marks.Add("Total", allPrice.ToString("F2"));//合计
  17028. #endregion
  17029. foreach (var item in marks.Keys)
  17030. {
  17031. if (doc.Range.Bookmarks[item] != null)
  17032. {
  17033. Bookmark mark = doc.Range.Bookmarks[item];
  17034. mark.Text = marks[item];
  17035. }
  17036. }
  17037. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  17038. doc.Save(savePaht);
  17039. var jw = new JsonView();
  17040. jw.Msg = "生成成功!";
  17041. jw.Code = 200;
  17042. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  17043. return Ok(jw);
  17044. }
  17045. /// <summary>
  17046. /// 详细报价费用Excel下载
  17047. /// </summary>
  17048. /// <param name="dto"></param>
  17049. /// <returns></returns>
  17050. [HttpPost]
  17051. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  17052. {
  17053. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17054. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17055. if (di == null)
  17056. {
  17057. return Ok(JsonView(false, "团组不存在!"));
  17058. }
  17059. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17060. if (mainPrice == null || mainPrice.IsShare == 0)
  17061. {
  17062. return Ok(JsonView(false, "团组成本不存在!"));
  17063. }
  17064. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17065. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17066. if (costTypeHotelNumbers == null)
  17067. {
  17068. return Ok(JsonView(false, "团组成本不存在!"));
  17069. }
  17070. WorkbookDesigner designer = new WorkbookDesigner();
  17071. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  17072. List<int> hideRowsList = new List<int>();
  17073. int conterStartIndex = 3;
  17074. int rowIndex = conterStartIndex;
  17075. designer.SetDataSource("GroupName", di.TeamName);
  17076. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17077. {
  17078. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17079. ("BXRS", "BXCB", "BXXS", "bx"),
  17080. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17081. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17082. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  17083. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  17084. ("CPRS", "CPCB", "CPXS", "cp") ,
  17085. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  17086. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  17087. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  17088. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  17089. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  17090. ("DJRS", "DJCB", "DJXS", "dj") ,
  17091. ("GWRS", "GWCB", "GWXS", "gw") ,
  17092. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  17093. };
  17094. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17095. var rightSum = 0.00M;
  17096. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17097. {
  17098. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17099. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17100. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17101. if (prefix == "tbr")
  17102. {
  17103. rsValue *= 2;
  17104. cbValue /= 2;
  17105. }
  17106. if (OtherCostPropertyBJ.Contains(prefix))
  17107. {
  17108. rightSum += cbValue * xsValue;
  17109. }
  17110. if (rsValue == 0)
  17111. {
  17112. hideRowsList.Add(rowIndex);
  17113. }
  17114. else
  17115. {
  17116. designer.SetDataSource($"{prefix}rs", rsValue);
  17117. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  17118. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  17119. }
  17120. rowIndex += 2;
  17121. }
  17122. var hotelRooms = new Dictionary<string, int>
  17123. {
  17124. { "SGR", costTypeHotelNumbers.SGR },
  17125. { "TBR", costTypeHotelNumbers.TBR },
  17126. { "JSES", costTypeHotelNumbers.JSES },
  17127. { "SUITE", costTypeHotelNumbers.SUITE }
  17128. };
  17129. var flights = new Dictionary<string, int>
  17130. {
  17131. { "经济舱", mainPrice.JJCRS },
  17132. { "公务舱", mainPrice.GWCRS },
  17133. { "头等舱", mainPrice.TDCRS }
  17134. };
  17135. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17136. {
  17137. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17138. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17139. { "头等舱", new[] { "SUITE", "JSES" } }
  17140. };
  17141. var result = new Dictionary<string, int>();
  17142. foreach (var flight in flights.Keys)
  17143. {
  17144. // 获取当前舱位的匹配规则
  17145. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17146. {
  17147. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17148. }
  17149. }
  17150. var allPrice = 0.00M;
  17151. #region right计算
  17152. int airRowIndex = 35;
  17153. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17154. {
  17155. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17156. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17157. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  17158. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  17159. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  17160. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17161. }
  17162. else
  17163. {
  17164. hideRowsList.Add(airRowIndex);
  17165. }
  17166. airRowIndex += 2;
  17167. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17168. {
  17169. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17170. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17171. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  17172. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  17173. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  17174. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17175. }
  17176. else
  17177. {
  17178. hideRowsList.Add(airRowIndex);
  17179. }
  17180. airRowIndex += 2;
  17181. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17182. {
  17183. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17184. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17185. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  17186. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  17187. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  17188. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17189. }
  17190. else
  17191. {
  17192. hideRowsList.Add(airRowIndex);
  17193. }
  17194. airRowIndex += 2;
  17195. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17196. {
  17197. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17198. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17199. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  17200. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  17201. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  17202. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17203. }
  17204. else
  17205. {
  17206. hideRowsList.Add(airRowIndex);
  17207. }
  17208. airRowIndex += 2;
  17209. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17210. {
  17211. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17212. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17213. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  17214. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  17215. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  17216. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17217. }
  17218. else
  17219. {
  17220. hideRowsList.Add(airRowIndex);
  17221. }
  17222. airRowIndex += 2;
  17223. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17224. {
  17225. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17226. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17227. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  17228. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  17229. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  17230. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17231. }
  17232. else
  17233. {
  17234. hideRowsList.Add(airRowIndex);
  17235. }
  17236. airRowIndex += 2;
  17237. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17238. {
  17239. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17240. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17241. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  17242. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  17243. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  17244. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17245. }
  17246. else
  17247. {
  17248. hideRowsList.Add(airRowIndex);
  17249. }
  17250. airRowIndex += 2;
  17251. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17252. {
  17253. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17254. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17255. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  17256. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  17257. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  17258. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17259. }
  17260. else
  17261. {
  17262. hideRowsList.Add(airRowIndex);
  17263. }
  17264. airRowIndex += 2;
  17265. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17266. {
  17267. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17268. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17269. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  17270. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  17271. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  17272. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17273. }
  17274. else
  17275. {
  17276. hideRowsList.Add(airRowIndex);
  17277. }
  17278. #endregion
  17279. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  17280. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  17281. var ws = designer.Workbook.Worksheets[0];
  17282. foreach (var Rowindex in hideRowsList)
  17283. {
  17284. ws.Cells.HideRows(Rowindex, 2);
  17285. }
  17286. designer.Process();
  17287. designer.Workbook.Save(savePaht);
  17288. return Ok(JsonView(true, "生成成功!", new
  17289. {
  17290. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  17291. }));
  17292. }
  17293. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  17294. {
  17295. foreach (var roomType in roomTypes)
  17296. {
  17297. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  17298. {
  17299. hotelRooms[roomType]--;
  17300. flights[flightType]--;
  17301. if (roomType == "TBR")
  17302. {
  17303. flights[flightType]--; // 双人间在减少1
  17304. }
  17305. string key = flightType + roomType;
  17306. if (result.Keys.Contains(key))
  17307. {
  17308. result[key]++;
  17309. }
  17310. else
  17311. {
  17312. result.Add(key, 1);
  17313. }
  17314. }
  17315. }
  17316. }
  17317. private class AirHotelPrice
  17318. {
  17319. public string Name { get; set; }
  17320. public decimal Price { get; set; }
  17321. public int Count { get; set; }
  17322. }
  17323. /// <summary>
  17324. /// 团组系数设置
  17325. /// </summary>
  17326. /// <param name="dto"></param>
  17327. /// <returns></returns>
  17328. [HttpPost]
  17329. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  17330. {
  17331. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17332. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17333. if (di == null)
  17334. {
  17335. return Ok(JsonView(false, "团组不存在!"));
  17336. }
  17337. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  17338. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  17339. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  17340. // FirstAsync(firstExpression.ToExpression());
  17341. #region JSON
  17342. string hcpJson = @"
  17343. [
  17344. {
  17345. ""min"": 1,
  17346. ""max"": 500,
  17347. ""value"": 1.50
  17348. },
  17349. {
  17350. ""min"": 501,
  17351. ""max"": 1000,
  17352. ""value"": 1.40
  17353. },
  17354. {
  17355. ""min"": 1001,
  17356. ""max"": 2000,
  17357. ""value"": 1.35
  17358. }
  17359. ]";
  17360. #endregion
  17361. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  17362. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  17363. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  17364. .ToList();
  17365. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  17366. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  17367. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  17368. // new List<(Predicate<decimal>, decimal)>()
  17369. // {
  17370. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  17371. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  17372. // }
  17373. // ));
  17374. #region 签证系数
  17375. var visaXS = 0.00M;
  17376. switch (dto.VisaCB)
  17377. {
  17378. case decimal n when (n > 1 && n < 500):
  17379. switch (dto.VisaRS)
  17380. {
  17381. case 2 or 3:
  17382. visaXS = 1.35M;
  17383. break;
  17384. case 4 or 5:
  17385. visaXS = 1.30M;
  17386. break;
  17387. case 6 or 7:
  17388. visaXS = 1.25M;
  17389. break;
  17390. case 8 or 9 or 10:
  17391. visaXS = 1.20M;
  17392. break;
  17393. case > 10:
  17394. visaXS = 1.15M;
  17395. break;
  17396. default:
  17397. visaXS = 0.00M;
  17398. break;
  17399. }
  17400. break;
  17401. case decimal n when (n >= 500 && n < 1000):
  17402. switch (dto.VisaRS)
  17403. {
  17404. case 2 or 3 or 4:
  17405. visaXS = 1.30M;
  17406. break;
  17407. case 5 or 6 or 7 or 8:
  17408. visaXS = 1.25M;
  17409. break;
  17410. case 9 or 10:
  17411. visaXS = 1.20M;
  17412. break;
  17413. case > 10:
  17414. visaXS = 1.15M;
  17415. break;
  17416. default:
  17417. visaXS = 0.00M;
  17418. break;
  17419. }
  17420. break;
  17421. default:
  17422. switch (dto.VisaRS)
  17423. {
  17424. case 2 or 3 or 4:
  17425. visaXS = 1.30M;
  17426. break;
  17427. case 5 or 6 or 7 or 8:
  17428. visaXS = 1.25M;
  17429. break;
  17430. case 9 or 10:
  17431. visaXS = 1.20M;
  17432. break;
  17433. case > 10:
  17434. visaXS = 1.15M;
  17435. break;
  17436. default:
  17437. visaXS = 0.00M;
  17438. break;
  17439. }
  17440. break;
  17441. }
  17442. #endregion
  17443. #region 火车系数
  17444. var hcpXS = 0.00M;
  17445. foreach (var (condition, result) in hcpSwitchDictionary)
  17446. {
  17447. if (condition(dto.HCPCB))
  17448. {
  17449. hcpXS = result;
  17450. break;
  17451. }
  17452. }
  17453. #endregion
  17454. #region 机票系数
  17455. #region 经济舱系数
  17456. var jjcXS = 0.00M;
  17457. switch (dto.JJCCB)
  17458. {
  17459. case decimal x when (x >= 1000 && x <= 3000):
  17460. jjcXS = 2.6M;
  17461. break;
  17462. case decimal x when (x >= 3001 && x <= 8000):
  17463. jjcXS = 2.3M;
  17464. break;
  17465. case decimal x when (x >= 8001 && x <= 15000):
  17466. jjcXS = 2.1M;
  17467. break;
  17468. case decimal x when (x >= 15001 && x <= 30000):
  17469. jjcXS = 1.95M;
  17470. break;
  17471. case > 30000:
  17472. jjcXS = 1.8M;
  17473. break;
  17474. default:
  17475. break;
  17476. }
  17477. #endregion
  17478. #region 公务舱系数
  17479. var gwcXS = 0.00M;
  17480. switch (dto.GWCCB)
  17481. {
  17482. case decimal x when (x >= 1000 && x <= 3000):
  17483. gwcXS = 2.5M;
  17484. break;
  17485. case decimal x when (x >= 3001 && x <= 8000):
  17486. gwcXS = 2.2M;
  17487. break;
  17488. case decimal x when (x >= 8001 && x <= 15000):
  17489. gwcXS = 2.0M;
  17490. break;
  17491. case decimal x when (x >= 15001 && x <= 30000):
  17492. gwcXS = 1.85M;
  17493. break;
  17494. case > 30000:
  17495. gwcXS = 1.7M;
  17496. break;
  17497. default:
  17498. break;
  17499. }
  17500. #endregion
  17501. #region 头等舱系数
  17502. var tdcXS = 0.00M;
  17503. switch (dto.TDCCB)
  17504. {
  17505. case > 70000:
  17506. tdcXS = 1.5M;
  17507. break;
  17508. default:
  17509. tdcXS = 1.9M;
  17510. break;
  17511. }
  17512. #endregion
  17513. #endregion
  17514. #region 酒店系数
  17515. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  17516. {
  17517. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  17518. {1.5M, new List<string>(){"越南社会主义共和国",
  17519. "老挝",
  17520. "柬埔寨",
  17521. "泰国",
  17522. "缅甸",
  17523. "马来西亚",
  17524. //"新加坡",
  17525. "文莱达鲁萨兰",
  17526. "印度尼西亚",
  17527. "东帝汶"}},
  17528. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  17529. };
  17530. #region SGR
  17531. var sgrXS = 1.25M;
  17532. #endregion
  17533. #region TBR
  17534. var tbrXS = 1.25M;
  17535. #endregion
  17536. #region JSES
  17537. var jsesXS = 1.25M;
  17538. #endregion
  17539. #region SUITE
  17540. var suiteXS = 1.25M;
  17541. #endregion
  17542. var countryArr = di.VisitCountry.Split("|");
  17543. foreach (var item in dic)
  17544. {
  17545. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  17546. .Count();
  17547. if (extsisCount > 0)
  17548. {
  17549. jsesXS = item.Key;
  17550. sgrXS = item.Key;
  17551. tbrXS = item.Key;
  17552. suiteXS = item.Key;
  17553. }
  17554. }
  17555. #endregion
  17556. #region 地接系数
  17557. var djXS = 0.00M;
  17558. switch (dto.DJRS)
  17559. {
  17560. case 2 or 3:
  17561. djXS = 2.65M;
  17562. break;
  17563. case 4:
  17564. djXS = 2.6M;
  17565. break;
  17566. case 5 or 6:
  17567. djXS = 2.5M;
  17568. break;
  17569. case 7 or 8:
  17570. djXS = 2.4M;
  17571. break;
  17572. case 9 or 10:
  17573. djXS = 2.3M;
  17574. break;
  17575. case 11:
  17576. djXS = 2.2M;
  17577. break;
  17578. case 12:
  17579. djXS = 2.1M;
  17580. break;
  17581. case 13 or 14:
  17582. djXS = 2M;
  17583. break;
  17584. case 15:
  17585. djXS = 1.9M;
  17586. break;
  17587. case 16 or 17 or 18:
  17588. djXS = 1.8M;
  17589. break;
  17590. case 19 or 20:
  17591. djXS = 1.7M;
  17592. break;
  17593. }
  17594. #endregion
  17595. #region 零用金系数
  17596. var lyjXS = 0.00M;
  17597. switch (dto.LYJRS)
  17598. {
  17599. case 2:
  17600. lyjXS = 1.25M;
  17601. break;
  17602. case 3 or 4 or 5:
  17603. lyjXS = 1.2M;
  17604. break;
  17605. case int number when (number > 5 && number < 10):
  17606. lyjXS = 1.15M;
  17607. break;
  17608. case > 10:
  17609. lyjXS = 1.1M;
  17610. break;
  17611. default:
  17612. break;
  17613. }
  17614. #endregion
  17615. return Ok(JsonView(true, "查询成功", new ArrayList()
  17616. {
  17617. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  17618. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  17619. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  17620. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  17621. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  17622. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  17623. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  17624. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  17625. new { label = "地接系数", value = djXS, key = "djXS" },
  17626. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  17627. new { label = "公务系数", value = 2M, key = "gwXS" }
  17628. }));
  17629. }
  17630. #endregion
  17631. #region 酒店预订 New 2023-12-28 17:45
  17632. /// <summary>
  17633. /// 酒店预订
  17634. /// 酒店费用列表 根据团组Id查询
  17635. /// </summary>
  17636. /// <param name="_dto"></param>
  17637. /// <returns></returns>
  17638. [HttpPost]
  17639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17640. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  17641. {
  17642. #region 参数验证
  17643. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17644. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17645. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17646. #region 团组操作权限验证 76 酒店预定模块
  17647. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17648. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17649. #endregion
  17650. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17651. #region 页面操作权限验证
  17652. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17653. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17654. #endregion
  17655. #endregion
  17656. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  17657. }
  17658. /// <summary>
  17659. /// 酒店预订
  17660. /// 基础数据
  17661. /// </summary>
  17662. /// <param name="_dto"></param>
  17663. /// <returns></returns>
  17664. [HttpPost]
  17665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17666. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  17667. {
  17668. #region 参数验证
  17669. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17670. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17671. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17672. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17673. #region 页面操作权限验证
  17674. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17675. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17676. #endregion
  17677. #region 团组操作权限验证 76 酒店预定模块
  17678. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17679. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17680. #endregion
  17681. #endregion
  17682. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  17683. }
  17684. /// <summary>
  17685. /// 酒店预订
  17686. /// 创建 入住卷号码
  17687. /// </summary>
  17688. /// <param name="_dto"></param>
  17689. /// <returns></returns>
  17690. [HttpPost]
  17691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17692. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  17693. {
  17694. #region 参数验证
  17695. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17696. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17697. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17698. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17699. #region 页面操作权限验证
  17700. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17701. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17702. #endregion
  17703. #region 团组操作权限验证 76 酒店预定模块
  17704. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17705. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17706. #endregion
  17707. #endregion
  17708. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  17709. if (data.Code != 0)
  17710. {
  17711. return Ok(JsonView(false, data.Msg));
  17712. }
  17713. return Ok(JsonView(true, data.Msg, data.Data));
  17714. }
  17715. /// <summary>
  17716. /// 酒店预订
  17717. /// 详情
  17718. /// </summary>
  17719. /// <param name="_dto"></param>
  17720. /// <returns></returns>
  17721. [HttpPost]
  17722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17723. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  17724. {
  17725. #region 参数验证
  17726. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  17727. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17728. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  17729. #region 团组操作权限验证 76 酒店预定模块
  17730. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17731. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17732. #endregion
  17733. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17734. #region 页面操作权限验证
  17735. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17736. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17737. #endregion
  17738. #endregion
  17739. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  17740. }
  17741. /// <summary>
  17742. /// 酒店预订
  17743. /// Add Or Edit
  17744. /// </summary>
  17745. /// <param name="_dto"></param>
  17746. /// <returns></returns>
  17747. [HttpPost]
  17748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17749. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  17750. {
  17751. #region 参数验证
  17752. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17753. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17754. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17755. #region 团组操作权限验证 76 酒店预定模块
  17756. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17757. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17758. #endregion
  17759. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17760. #region 页面操作权限验证
  17761. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17762. if (_dto.Id == 0) // Add
  17763. {
  17764. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17765. }
  17766. else if (_dto.Id > 1) // Edit
  17767. {
  17768. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17769. }
  17770. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  17771. #endregion
  17772. #endregion
  17773. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  17774. if (_view.Code != 200)
  17775. {
  17776. return Ok(_view);
  17777. }
  17778. #region 成本无酒店价格数据进入超支
  17779. _sqlSugar.BeginTran();
  17780. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  17781. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  17782. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  17783. for (int i = 0; i < groupCost.Count; i++)
  17784. {
  17785. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  17786. {
  17787. groupCost[i].Date = groupCost[i - 1].Date;
  17788. }
  17789. }
  17790. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  17791. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  17792. List<Fin_GroupExtraCostDto_OP>();
  17793. if (start_Bool && end_Bool)
  17794. {
  17795. while (start_Time < end_Time)
  17796. {
  17797. foreach (var item in groupCost_Grp)
  17798. {
  17799. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  17800. {
  17801. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  17802. {
  17803. extraCostList.Add(new
  17804. Fin_GroupExtraCostDto_OP
  17805. {
  17806. Area = _dto.AreaId,
  17807. coefficient = 1.5M,
  17808. createUser = _dto.UserId,
  17809. currency = _dto.CardPriceCurrency,
  17810. diId = _dto.DiId,
  17811. ManagerConfirm = 0,
  17812. SupervisorConfirm = 0,
  17813. SYsupervisorConfirm = 0,
  17814. editType = 1,
  17815. PortType = 1,
  17816. price = _dto.CardPrice,
  17817. PriceCount = 1,
  17818. priceType = 1027,
  17819. priceDetailType = 1044,
  17820. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  17821. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  17822. });
  17823. }
  17824. }
  17825. }
  17826. start_Time = start_Time.AddDays(1);
  17827. }
  17828. }
  17829. if (extraCostList.Any())
  17830. {
  17831. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  17832. }
  17833. _sqlSugar.CommitTran();
  17834. #endregion
  17835. #region 应用推送
  17836. try
  17837. {
  17838. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17839. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17840. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17841. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17842. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17843. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17844. var diId = _dto.DiId;
  17845. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17846. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17847. #region 操作记录
  17848. var opInfo = new Crm_TableOperationRecord()
  17849. {
  17850. TableName = "Grp_HotelReservations",
  17851. PortType = _dto.PortType,
  17852. DataId = hotelId,
  17853. CreateUserId = _dto.UserId
  17854. };
  17855. //var opStatus = OperationEnum.NoOperation;
  17856. if (_dto.Id < 1) //添加操作
  17857. {
  17858. opInfo.OperationItem = OperationEnum.Add;
  17859. }
  17860. else if (_dto.Id > 0)
  17861. {
  17862. opInfo.OperationItem = OperationEnum.Edit;
  17863. }
  17864. string opRemark = string.Empty;
  17865. if (ccpInfo != null)
  17866. {
  17867. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  17868. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  17869. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  17870. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  17871. }
  17872. opInfo.Remark = opRemark;
  17873. await _tableorRep.AddAsync(opInfo);
  17874. #endregion
  17875. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  17876. //2024-10-21 新增LZ UID
  17877. var userIds = new List<int>() { 21 };
  17878. string title = $"费用审核";
  17879. string content = "";
  17880. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17881. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17882. try
  17883. {
  17884. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  17885. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  17886. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  17887. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  17888. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  17889. }
  17890. catch (Exception ex)
  17891. {
  17892. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  17893. }
  17894. }
  17895. catch (Exception ex)
  17896. {
  17897. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  17898. }
  17899. try
  17900. {
  17901. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17902. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17903. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17904. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17905. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17906. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17907. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17908. //自动审核
  17909. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  17910. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  17911. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  17912. //2024-10-21 新增LZ UID
  17913. var userIds = new List<int>() { 21 };
  17914. string title = $"系统通知";
  17915. var diId = _dto.DiId;
  17916. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17917. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17918. string content = "";
  17919. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17920. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17921. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17922. }
  17923. catch (Exception ex)
  17924. {
  17925. }
  17926. #endregion
  17927. return Ok(_view);
  17928. }
  17929. /// <summary>
  17930. /// 酒店自动审核测试
  17931. /// Add Or Edit
  17932. /// </summary>
  17933. /// <param name="diid"></param>
  17934. /// <param name="dataId"></param>
  17935. /// <returns></returns>
  17936. [HttpPost]
  17937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17938. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  17939. {
  17940. #region 应用推送
  17941. try
  17942. {
  17943. //自动审核
  17944. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  17945. }
  17946. catch (Exception ex)
  17947. {
  17948. return Ok(JsonView(false, ex.Message));
  17949. }
  17950. #endregion
  17951. return Ok(JsonView(false, "操作成功"));
  17952. }
  17953. /// <summary>
  17954. /// 酒店预订
  17955. /// Del
  17956. /// </summary>
  17957. /// <param name="_dto"></param>
  17958. /// <returns></returns>
  17959. [HttpPost]
  17960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17961. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  17962. {
  17963. #region 参数验证
  17964. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17965. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17966. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17967. #region 团组操作权限验证 76 酒店预定模块
  17968. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17969. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17970. #endregion
  17971. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17972. #region 页面操作权限验证
  17973. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17974. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17975. #endregion
  17976. #endregion
  17977. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  17978. #region 操作记录
  17979. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  17980. {
  17981. TableName = "Grp_HotelReservations",
  17982. PortType = _dto.PortType,
  17983. OperationItem = OperationEnum.Del,
  17984. DataId = _dto.Id,
  17985. CreateUserId = _dto.UserId
  17986. });
  17987. #endregion
  17988. return Ok(data);
  17989. }
  17990. /// <summary>
  17991. /// 酒店预订
  17992. /// 生成VOUCHER
  17993. /// 2024.05.06 之前版本
  17994. /// </summary>
  17995. /// <param name="_dto"></param>
  17996. /// <returns></returns>
  17997. [HttpPost]
  17998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17999. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  18000. {
  18001. try
  18002. {
  18003. #region 参数验证
  18004. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18005. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18006. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18007. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  18008. #region 团组操作权限验证 76 酒店预定模块
  18009. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18010. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18011. #endregion
  18012. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18013. #region 页面操作权限验证
  18014. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18015. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18016. #endregion
  18017. #endregion
  18018. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  18019. //判断数据是否完整
  18020. if (hr != null)
  18021. {
  18022. if (!string.IsNullOrEmpty(hr.DetermineNo))
  18023. {
  18024. string strFileName = "HotelStatement/";
  18025. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18026. if (dele != null)
  18027. strFileName += dele.TourCode;
  18028. //载入模板
  18029. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  18030. Document doc = new Document(sss);
  18031. DocumentBuilder builder = new DocumentBuilder(doc);
  18032. #region 替换Word模板书签内容
  18033. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  18034. //入住卷预定号码
  18035. if (doc.Range.Bookmarks["VNO"] != null)
  18036. {
  18037. Bookmark mark = doc.Range.Bookmarks["VNO"];
  18038. mark.Text = hr.CheckNumber;
  18039. }
  18040. //酒店时间
  18041. if (doc.Range.Bookmarks["Date"] != null)
  18042. {
  18043. Bookmark mark = doc.Range.Bookmarks["Date"];
  18044. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18045. }
  18046. //团号
  18047. if (doc.Range.Bookmarks["TNo"] != null)
  18048. {
  18049. Bookmark mark = doc.Range.Bookmarks["TNo"];
  18050. mark.Text = dele.TourCode;
  18051. }
  18052. //预定号码
  18053. if (doc.Range.Bookmarks["BookingId"] != null)
  18054. {
  18055. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  18056. mark.Text = hr.ReservationsNo;
  18057. }
  18058. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  18059. {
  18060. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  18061. mark.Text = hr.DetermineNo;
  18062. }
  18063. //酒店城市
  18064. if (doc.Range.Bookmarks["City"] != null)
  18065. {
  18066. Bookmark mark = doc.Range.Bookmarks["City"];
  18067. mark.Text = hr.City;
  18068. }
  18069. //酒店名称
  18070. if (doc.Range.Bookmarks["HName"] != null)
  18071. {
  18072. Bookmark mark = doc.Range.Bookmarks["HName"];
  18073. mark.Text = hr.HotelName;
  18074. }
  18075. //酒店地址
  18076. if (doc.Range.Bookmarks["Address"] != null)
  18077. {
  18078. Bookmark mark = doc.Range.Bookmarks["Address"];
  18079. mark.Text = hr.HotelAddress;
  18080. }
  18081. //酒店电话
  18082. if (doc.Range.Bookmarks["Tel"] != null)
  18083. {
  18084. Bookmark mark = doc.Range.Bookmarks["Tel"];
  18085. mark.Text = hr.HotelTel;
  18086. }
  18087. //酒店传真
  18088. if (doc.Range.Bookmarks["Fax"] != null)
  18089. {
  18090. Bookmark mark = doc.Range.Bookmarks["Fax"];
  18091. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  18092. {
  18093. mark.Text = hr.HotelFax;
  18094. }
  18095. }
  18096. //入住时间
  18097. if (doc.Range.Bookmarks["CIn"] != null)
  18098. {
  18099. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18100. Bookmark mark = doc.Range.Bookmarks["CIn"];
  18101. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  18102. }
  18103. //退房时间
  18104. if (doc.Range.Bookmarks["COut"] != null)
  18105. {
  18106. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18107. Bookmark mark = doc.Range.Bookmarks["COut"];
  18108. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18109. }
  18110. //客户名称
  18111. if (doc.Range.Bookmarks["GName"] != null)
  18112. {
  18113. string guestName = "";
  18114. string[] clients = Array.Empty<string>();
  18115. if (hr.GuestName.Contains(","))
  18116. {
  18117. clients = hr.GuestName.Split(",");
  18118. }
  18119. else
  18120. {
  18121. clients = new string[] { hr.GuestName };
  18122. }
  18123. List<int> clientIds_int = new List<int>();
  18124. if (clients.Length > 0)
  18125. {
  18126. foreach (var item in clients)
  18127. {
  18128. if (item.IsNumeric())
  18129. {
  18130. clientIds_int.Add(int.Parse(item));
  18131. }
  18132. }
  18133. }
  18134. if (clientIds_int.Count > 0)
  18135. {
  18136. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  18137. foreach (var client in _clientDatas)
  18138. {
  18139. //男
  18140. if (client.Sex == 0) guestName += $"Mr.";
  18141. //女
  18142. else if (client.Sex == 1) guestName += $"Ms.";
  18143. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  18144. {
  18145. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  18146. }
  18147. //guestName += $"{client.Pinyin},";
  18148. }
  18149. if (guestName.Length > 0)
  18150. {
  18151. guestName = guestName.Substring(0, guestName.Length - 1);
  18152. }
  18153. }
  18154. else
  18155. {
  18156. guestName = hr.GuestName;
  18157. }
  18158. Bookmark mark = doc.Range.Bookmarks["GName"];
  18159. mark.Text = guestName;
  18160. }
  18161. //房间介绍
  18162. if (doc.Range.Bookmarks["ROOM"] != null)
  18163. {
  18164. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  18165. mark.Text = hr.RoomExplanation;
  18166. }
  18167. //报价描述
  18168. if (doc.Range.Bookmarks["NOTE"] != null)
  18169. {
  18170. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  18171. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  18172. if (ss != null)
  18173. mark.Text = ss.Name;
  18174. }
  18175. //入住时间
  18176. if (doc.Range.Bookmarks["CheckIn"] != null)
  18177. {
  18178. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18179. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  18180. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18181. }
  18182. //退房时间
  18183. if (doc.Range.Bookmarks["CheckOut"] != null)
  18184. {
  18185. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18186. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  18187. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18188. }
  18189. //日期
  18190. if (doc.Range.Bookmarks["DT"] != null)
  18191. {
  18192. Bookmark mark = doc.Range.Bookmarks["DT"];
  18193. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18194. }
  18195. //名称
  18196. if (doc.Range.Bookmarks["VName"] != null)
  18197. {
  18198. Bookmark mark = doc.Range.Bookmarks["VName"];
  18199. mark.Text = hr.HotelName;
  18200. }
  18201. //号码
  18202. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  18203. {
  18204. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  18205. mark.Text = hr.CheckNumber;
  18206. }
  18207. #endregion
  18208. strFileName += "VOUCHER.doc";
  18209. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18210. doc.Save(fileDir);
  18211. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18212. return Ok(JsonView(true, "操作成功!", Url));
  18213. }
  18214. else
  18215. {
  18216. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  18217. }
  18218. }
  18219. else
  18220. {
  18221. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  18222. }
  18223. }
  18224. catch (Exception ex)
  18225. {
  18226. return Ok(JsonView(false, ex.Message));
  18227. }
  18228. }
  18229. /// <summary>
  18230. /// 酒店预订
  18231. /// 生成VOUCHER
  18232. /// 2024.05.06 之后版本
  18233. /// </summary>
  18234. /// <param name="_dto"></param>
  18235. /// <returns></returns>
  18236. [HttpPost]
  18237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18238. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  18239. {
  18240. #region 参数验证
  18241. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18242. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18243. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18244. #region 团组操作权限验证 76 酒店预定模块
  18245. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18246. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18247. #endregion
  18248. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18249. #region 页面操作权限验证
  18250. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18251. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18252. #endregion
  18253. #endregion
  18254. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  18255. //判断数据是否完整
  18256. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18257. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18258. string strFileName = "HotelStatement/";
  18259. string guestNames = ""; //格式Mr.xxx Ms.xxx
  18260. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  18261. #region 数据处理
  18262. List<int> guestIds = new List<int>();
  18263. //int index = 0;
  18264. foreach (var item in hrDtas)
  18265. {
  18266. if (item.GuestName.Contains(","))
  18267. {
  18268. string[] guestIdArr = item.GuestName.Split(',');
  18269. foreach (var guestIdStr in guestIdArr)
  18270. {
  18271. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  18272. if (guestBool)
  18273. {
  18274. guestIds.Add(guestId);
  18275. }
  18276. }
  18277. }
  18278. else guestNames += item.GuestName;
  18279. var voucherInfo = new HotelVoucherInfoView()
  18280. {
  18281. HotelName = item.HotelName,
  18282. CheckInDate = item.CheckInDate,
  18283. CheckOutDate = item.CheckOutDate,
  18284. ConfirmationNumber = item.DetermineNo.Trim(),
  18285. RoomType = item.RoomExplanation
  18286. };
  18287. vouchers.Add(voucherInfo);
  18288. }
  18289. if (guestIds.Count > 0)
  18290. {
  18291. guestIds = guestIds.Distinct().ToList();
  18292. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  18293. if (guestDatas.Count > 0)
  18294. {
  18295. guestNames = "";
  18296. foreach (var guest in guestDatas)
  18297. {
  18298. string guestName = "";
  18299. if (guest.Sex == 0) guestName += @"MR.";
  18300. else if (guest.Sex == 1) guestName += @"MS.";
  18301. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18302. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18303. guestNames += @$"{guestName.Trim()}、";
  18304. }
  18305. if (guestNames.Length > 0)
  18306. {
  18307. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18308. }
  18309. }
  18310. }
  18311. #endregion
  18312. //载入模板
  18313. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  18314. Document doc = new Document(sss);
  18315. DocumentBuilder builder = new DocumentBuilder(doc);
  18316. if (doc.Range.Bookmarks["GuestName"] != null)
  18317. {
  18318. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  18319. mark.Text = guestNames;
  18320. }
  18321. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18322. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  18323. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  18324. for (int i = 1; i <= vouchers.Count; i++)
  18325. {
  18326. HotelVoucherInfoView hviv = vouchers[i - 1];
  18327. builder.MoveToCell(0, i, 0, 0);
  18328. builder.Write(hviv.HotelName);
  18329. builder.MoveToCell(0, i, 1, 0);
  18330. builder.Write(hviv.CheckInDate);
  18331. builder.MoveToCell(0, i, 2, 0);
  18332. builder.Write(hviv.CheckOutDate);
  18333. builder.MoveToCell(0, i, 3, 0);
  18334. builder.Write(hviv.RoomType);
  18335. builder.MoveToCell(0, i, 4, 0);
  18336. builder.Write(hviv.ConfirmationNumber);
  18337. }
  18338. //删除多余行
  18339. int currRowIndex = vouchers.Count + 1;
  18340. int delRows = 21 - currRowIndex;
  18341. if (delRows > 0)
  18342. {
  18343. for (int i = 0; i < delRows; i++)
  18344. {
  18345. table.Rows.RemoveAt(currRowIndex);
  18346. //cultivateRowIndex++;
  18347. }
  18348. }
  18349. strFileName += "VOUCHER.docx";
  18350. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18351. doc.Save(fileDir);
  18352. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18353. return Ok(JsonView(true, "操作成功!", Url));
  18354. }
  18355. /// <summary>
  18356. /// 酒店预订
  18357. /// 生成VOUCHER 批量生成
  18358. /// New
  18359. /// </summary>
  18360. /// <param name="_dto"></param>
  18361. /// <returns></returns>
  18362. [HttpPost]
  18363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18364. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  18365. {
  18366. #region 参数验证
  18367. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18368. if (_dto.PageId < 1) _dto.PageId = 28;
  18369. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18370. #region 团组操作权限验证 76 酒店预定模块
  18371. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18372. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18373. #endregion
  18374. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18375. #region 页面操作权限验证
  18376. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18377. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18378. #endregion
  18379. #endregion
  18380. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  18381. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  18382. .OrderBy(x => x.CheckInDate)
  18383. .ToListAsync();
  18384. //判断数据是否完整
  18385. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18386. string strFileName = "HotelStatement/";
  18387. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18388. if (dele != null)
  18389. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  18390. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  18391. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  18392. .Where(it => it.IsDel == 0)
  18393. .ToListAsync();
  18394. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  18395. for (int i = 0; i < hrDtas.Count; i++)
  18396. {
  18397. string guestNames = string.Empty;
  18398. List<int> guestIds = new List<int>();
  18399. var item = hrDtas[i];
  18400. //处理客户姓名
  18401. if (item.GuestName.Contains(","))
  18402. {
  18403. string[] guestIdArr = item.GuestName.Split(',');
  18404. foreach (var guestIdStr in guestIdArr)
  18405. if (int.TryParse(guestIdStr, out int guestId))
  18406. guestIds.Add(guestId);
  18407. }
  18408. else
  18409. {
  18410. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  18411. if (guestIdBool)
  18412. {
  18413. guestIds.Add(guestId);
  18414. }
  18415. //NaN
  18416. if (item.GuestName.Contains("NaN"))
  18417. {
  18418. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  18419. }
  18420. }
  18421. if (guestIds.Count > 0)
  18422. {
  18423. guestIds = guestIds.Distinct().ToList();
  18424. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  18425. if (guestDatas1.Count > 0)
  18426. {
  18427. guestNames = "";
  18428. foreach (var guest in guestDatas1)
  18429. {
  18430. string guestName = "";
  18431. if (guest.Sex == 0) guestName += @"MR.";
  18432. else if (guest.Sex == 1) guestName += @"MS.";
  18433. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18434. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18435. guestNames += @$"{guestName.Trim()}、";
  18436. }
  18437. if (guestNames.Length > 0)
  18438. {
  18439. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18440. }
  18441. }
  18442. }
  18443. //if (!string.IsNullOrEmpty(guestNames))
  18444. //{
  18445. hrDtas[i].GuestName = guestNames;
  18446. //}
  18447. }
  18448. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  18449. Document doc = new Document();
  18450. DocumentBuilder builder = new DocumentBuilder(doc);
  18451. try
  18452. {
  18453. builder.MoveToDocumentStart();
  18454. foreach (var item in hrDtas)
  18455. {
  18456. //标题
  18457. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18458. builder.ParagraphFormat.LineSpacing = 1;
  18459. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18460. builder.ParagraphFormat.Style.Font.Size = 9;
  18461. builder.ParagraphFormat.Style.Font.Bold = true;
  18462. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18463. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  18464. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18465. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18466. builder.ParagraphFormat.LineSpacing = 1;
  18467. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18468. builder.ParagraphFormat.Style.Font.Size = 9;
  18469. builder.ParagraphFormat.Style.Font.Bold = true;
  18470. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  18471. builder.StartTable();
  18472. // 设置边框颜色
  18473. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  18474. //设置边框样式
  18475. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  18476. //表格
  18477. #region 第一行
  18478. builder.InsertCell();
  18479. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18480. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18481. //builder.CellFormat.AllowAutoFit = false;
  18482. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18483. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18484. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18485. builder.CellFormat.WrapText = true; //自动换行
  18486. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18487. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  18488. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18489. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18490. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18491. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18492. builder.Write("TOUR NO:");
  18493. builder.InsertCell();
  18494. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18495. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18496. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18497. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18498. builder.ParagraphFormat.Style.Font.Bold = false;
  18499. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18500. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18501. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18502. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18503. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18504. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18505. builder.Write($"{dele?.TourCode ?? "-"}");
  18506. builder.InsertCell();
  18507. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18508. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18509. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18510. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18511. builder.ParagraphFormat.Style.Font.Bold = false;
  18512. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18513. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18514. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18515. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18516. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18517. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18518. builder.Write($"CITY:");
  18519. builder.InsertCell();
  18520. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18521. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18522. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18523. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18524. builder.ParagraphFormat.Style.Font.Bold = false;
  18525. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18526. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18527. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18528. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18529. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18530. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18531. builder.Write($"{item.City}");
  18532. builder.EndRow();
  18533. #endregion
  18534. #region 第二行
  18535. builder.InsertCell();
  18536. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18537. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18538. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18539. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18540. builder.ParagraphFormat.Style.Font.Bold = false;
  18541. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18542. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18543. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18544. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18545. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18546. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18547. builder.Write("CONFIRMATION NO:");
  18548. builder.InsertCell();
  18549. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18550. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18551. builder.ParagraphFormat.Style.Font.Size = 8;
  18552. builder.ParagraphFormat.Style.Font.Bold = false;
  18553. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18554. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18555. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18556. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18557. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18558. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18559. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18560. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18561. builder.Write($"{item.DetermineNo}");
  18562. builder.InsertCell();
  18563. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18564. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18565. builder.InsertCell();
  18566. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18567. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18568. builder.EndRow();
  18569. #endregion
  18570. #region 第三行
  18571. builder.InsertCell();
  18572. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18573. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18574. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18575. builder.ParagraphFormat.Style.Font.Bold = false;
  18576. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18577. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18578. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18579. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18580. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18581. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18582. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18583. builder.Write($"HOTEL NAME:");
  18584. builder.InsertCell();
  18585. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18586. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18587. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18588. builder.ParagraphFormat.Style.Font.Bold = false;
  18589. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18590. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18591. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18592. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18593. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18594. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18595. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18596. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18597. builder.Write($"{item.HotelName}");
  18598. builder.InsertCell();
  18599. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18600. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18601. builder.InsertCell();
  18602. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18603. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18604. builder.EndRow();
  18605. #endregion
  18606. #region 第四行
  18607. builder.InsertCell();
  18608. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18609. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18610. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18611. builder.ParagraphFormat.Style.Font.Bold = false;
  18612. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18613. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18614. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18615. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18616. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18617. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18618. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18619. builder.Write($"HOTEL ADDRESS:");
  18620. builder.InsertCell();
  18621. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18622. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18623. builder.ParagraphFormat.Style.Font.Size = 8;
  18624. builder.ParagraphFormat.Style.Font.Bold = false;
  18625. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18626. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18627. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18628. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18629. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18630. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18631. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18632. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18633. builder.Write($"{item.HotelAddress}");
  18634. builder.InsertCell();
  18635. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18636. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18637. builder.InsertCell();
  18638. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18639. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18640. builder.EndRow();
  18641. #endregion
  18642. #region 第五行
  18643. builder.InsertCell();
  18644. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18645. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18646. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18647. builder.ParagraphFormat.Style.Font.Bold = false;
  18648. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18649. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18650. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18651. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18652. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18653. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18654. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18655. builder.Write("TEL:");
  18656. builder.InsertCell();
  18657. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18658. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18659. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18660. builder.ParagraphFormat.Style.Font.Bold = false;
  18661. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18662. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18663. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18664. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18665. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18666. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18667. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18668. builder.Write($"{item.HotelTel}");
  18669. builder.InsertCell();
  18670. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18671. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18672. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18673. builder.ParagraphFormat.Style.Font.Bold = false;
  18674. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18675. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18676. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18677. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18678. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18679. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18680. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18681. builder.Write($"FAX:");
  18682. builder.InsertCell();
  18683. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18684. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18685. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18686. builder.ParagraphFormat.Style.Font.Bold = false;
  18687. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18688. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18689. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18690. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18691. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18692. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18693. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18694. builder.Write($"{item.HotelFax}");
  18695. builder.EndRow();
  18696. #endregion
  18697. #region 第六行
  18698. builder.InsertCell();
  18699. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18700. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18701. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18702. builder.ParagraphFormat.Style.Font.Bold = false;
  18703. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18704. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18705. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18706. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18707. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18708. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18709. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18710. builder.Write("CHECK IN:");
  18711. builder.InsertCell();
  18712. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18713. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18714. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18715. builder.ParagraphFormat.Style.Font.Bold = false;
  18716. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18717. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18718. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18719. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18720. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18721. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18722. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18723. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  18724. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18725. builder.Write($"{checkInStr}");
  18726. builder.InsertCell();
  18727. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18728. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18729. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18730. builder.ParagraphFormat.Style.Font.Bold = false;
  18731. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18732. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18733. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18734. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18735. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18736. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18737. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18738. builder.Write($"CHECK OUT:");
  18739. builder.InsertCell();
  18740. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18741. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18742. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18743. builder.ParagraphFormat.Style.Font.Bold = false;
  18744. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18745. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18746. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18747. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18748. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18749. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18750. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18751. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  18752. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  18753. builder.Write($"{checkOutStr}");
  18754. builder.EndRow();
  18755. #endregion
  18756. #region 第七行
  18757. builder.InsertCell();
  18758. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18759. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18760. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18761. builder.ParagraphFormat.Style.Font.Bold = false;
  18762. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18763. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18764. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18765. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18766. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18767. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18768. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18769. builder.Write($"GUEST NAME:");
  18770. builder.InsertCell();
  18771. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18772. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18773. builder.ParagraphFormat.Style.Font.Size = 8;
  18774. builder.ParagraphFormat.Style.Font.Bold = false;
  18775. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18776. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18777. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18778. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18779. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18780. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18781. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18782. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18783. builder.Write($"{item.GuestName.Trim()}");
  18784. builder.InsertCell();
  18785. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18786. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18787. builder.InsertCell();
  18788. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18789. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18790. builder.EndRow();
  18791. #endregion
  18792. #region 第八行
  18793. builder.InsertCell();
  18794. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18795. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18796. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18797. builder.ParagraphFormat.Style.Font.Bold = false;
  18798. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18799. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18800. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18801. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18802. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18803. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18804. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18805. builder.Write($"ROOM TYPE:");
  18806. builder.InsertCell();
  18807. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18808. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18809. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18810. builder.ParagraphFormat.Style.Font.Bold = false;
  18811. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18812. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18813. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18814. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18815. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18816. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18817. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18818. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18819. builder.Write($"{item.RoomExplanation}");
  18820. builder.InsertCell();
  18821. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18822. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18823. builder.InsertCell();
  18824. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18825. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18826. builder.EndRow();
  18827. #endregion
  18828. #region 第九行
  18829. builder.InsertCell();
  18830. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18831. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18832. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18833. builder.ParagraphFormat.Style.Font.Bold = false;
  18834. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18835. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18836. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18837. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18838. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18839. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18840. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18841. builder.Write($"NOTE:");
  18842. builder.InsertCell();
  18843. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18844. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18845. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18846. builder.ParagraphFormat.Style.Font.Bold = false;
  18847. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18848. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18849. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18850. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18851. 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.");
  18852. builder.InsertCell();
  18853. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18854. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18855. builder.InsertCell();
  18856. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18857. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18858. builder.EndRow();
  18859. #endregion
  18860. builder.EndTable();
  18861. //换行
  18862. builder.Writeln("");
  18863. builder.Writeln("");
  18864. }
  18865. #region 获取文档中的所有表格 设置文字自适应
  18866. // 获取文档中的所有表格。
  18867. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  18868. {
  18869. // 遍历表格中的所有行。
  18870. foreach (Aspose.Words.Tables.Row row in table.Rows)
  18871. {
  18872. foreach (Cell cell in row.Cells)
  18873. {
  18874. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  18875. cellFormat.Width = 0;
  18876. }
  18877. }
  18878. }
  18879. #endregion
  18880. #region 设置页眉
  18881. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  18882. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  18883. if (System.IO.File.Exists(voucherHeaderPath))
  18884. {
  18885. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  18886. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  18887. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  18888. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  18889. // 调整图片位置
  18890. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  18891. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  18892. shape.Top = 50; // 将图片距离页眉上边缘的距离
  18893. shape.Left = 0; // 将图片距离页面左边缘的距离
  18894. shape.Width = 81; // 设置图片宽度
  18895. shape.Height = 36; // 设置图片高度
  18896. }
  18897. //靠右
  18898. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18899. //// 设置页脚上下边距
  18900. //builder.PageSetup.HeaderDistance = 42;
  18901. // 添加页眉线
  18902. Aspose.Words.Border borderHeader = null;
  18903. try
  18904. {
  18905. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  18906. }
  18907. catch (Exception e)
  18908. {
  18909. // TODO Auto-generated catch block
  18910. //e.printStackTrace();
  18911. }
  18912. borderHeader.Shadow = true;
  18913. borderHeader.DistanceFromText = 2;
  18914. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  18915. #endregion
  18916. }
  18917. catch (Exception ex)
  18918. {
  18919. }
  18920. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18921. doc.Save(fileDir);
  18922. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18923. return Ok(JsonView(true, "操作成功!", Url));
  18924. }
  18925. /// <summary>
  18926. /// 酒店预订
  18927. /// 生成 预定成本 Excel
  18928. /// </summary>
  18929. /// <param name="_dto"></param>
  18930. /// <returns></returns>
  18931. [HttpPost]
  18932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18933. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  18934. {
  18935. #region 参数验证
  18936. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  18937. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  18938. if (!vadalitorRes.IsValid)
  18939. {
  18940. var errors = new StringBuilder();
  18941. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  18942. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  18943. }
  18944. #region 团组操作权限验证 76 酒店预定模块
  18945. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18946. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18947. #endregion
  18948. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18949. #region 页面操作权限验证
  18950. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18951. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18952. #endregion
  18953. #endregion
  18954. decimal _rate = 1.00M;
  18955. string _currency = string.Empty;
  18956. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  18957. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18958. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  18959. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18960. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  18961. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  18962. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  18963. if (_GroupCostParameter == null)
  18964. {
  18965. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  18966. bool isIntType = int.TryParse(_currency, out int currId);
  18967. if (isIntType)
  18968. {
  18969. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18970. }
  18971. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18972. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18973. if (currInfo == null)
  18974. {
  18975. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18976. }
  18977. else _rate = currInfo.Rate;
  18978. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  18979. {
  18980. _rate = _GroupCostParameter.Rate;
  18981. }
  18982. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18983. //string strFileName = "HotelStatement/";
  18984. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18985. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18986. var rateDatas = new List<dynamic>();
  18987. #region 数据处理
  18988. foreach (var item in hrDtas)
  18989. {
  18990. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18991. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18992. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18993. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18994. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18995. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  18996. {
  18997. continue;
  18998. }
  18999. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19000. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  19001. string singleRoomFeeStr = string.Empty,
  19002. doubleRoomFeeStr = string.Empty,
  19003. suiteRoomFeeStr = string.Empty,
  19004. otherRoomFeeStr = string.Empty,
  19005. payMoneyStr = string.Empty,
  19006. cardPriceStr = string.Empty;
  19007. if (roomCurr.Equals("CNY"))
  19008. {
  19009. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  19010. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19011. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19012. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19013. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19014. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  19015. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  19016. }
  19017. else
  19018. {
  19019. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19020. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19021. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19022. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19023. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19024. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19025. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19026. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19027. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19028. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19029. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  19030. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  19031. if (ccpPaymentCurrency.Equals("CNY"))
  19032. {
  19033. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  19034. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19035. }
  19036. else
  19037. {
  19038. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  19039. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  19040. }
  19041. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  19042. if (hotelcardPriceCurrency.Equals("CNY"))
  19043. {
  19044. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19045. }
  19046. else
  19047. {
  19048. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  19049. }
  19050. }
  19051. string breakfastPriceStr = string.Empty,
  19052. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19053. governmentRentStr = string.Empty,
  19054. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19055. cityTaxStr = string.Empty,
  19056. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19057. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  19058. if (!string.IsNullOrEmpty(breakfastCurrency1))
  19059. {
  19060. if (breakfastCurrency1.Equals("CNY"))
  19061. {
  19062. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19063. }
  19064. else
  19065. {
  19066. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  19067. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  19068. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  19069. }
  19070. }
  19071. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19072. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  19073. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  19074. {
  19075. if (governmentRentCurrency.Equals("CNY"))
  19076. {
  19077. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19078. }
  19079. else
  19080. {
  19081. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  19082. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  19083. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  19084. }
  19085. }
  19086. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19087. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  19088. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  19089. {
  19090. if (cityTaxStrCurrency1.Equals("CNY"))
  19091. {
  19092. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19093. }
  19094. else
  19095. {
  19096. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  19097. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  19098. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  19099. }
  19100. }
  19101. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19102. int payDId = roomInfo?.PayDId ?? 0;
  19103. pcfds.Add(new HotelReservations_PCFD_View()
  19104. {
  19105. City = item.City,
  19106. HotelName = item.HotelName,
  19107. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19108. // SingleRoomCount = item.SingleRoomCount,
  19109. SingleRoomPrice = singleRoomFeeStr,
  19110. // DoubleRoomCount = item.DoubleRoomCount,
  19111. DoubleRoomPrice = doubleRoomFeeStr,
  19112. //SuiteRoomCount = item.SuiteRoomCount,
  19113. SuiteRoomPrice = suiteRoomFeeStr,
  19114. OtherRoomPrice = otherRoomFeeStr,
  19115. //OtherRoomCount = item.OtherRoomCount,
  19116. BreakfastPrice = breakfastPriceStr,
  19117. GovernmentRent = governmentRentStr,
  19118. CityTax = cityTaxStr,
  19119. RoomExplanation = item.RoomExplanation,
  19120. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19121. PayTime = roomInfo?.ConsumptionDate,
  19122. BankNo = roomInfo?.BankNo,
  19123. PayMoney = payMoneyStr,
  19124. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19125. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19126. CardPrice = cardPriceStr,
  19127. Remark = ccpInfo.Remark
  19128. });
  19129. }
  19130. #endregion
  19131. //载入模板
  19132. WorkbookDesigner designer = new WorkbookDesigner();
  19133. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19134. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19135. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19136. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19137. var rateDatas1 = rateDatas.Distinct();
  19138. var rateStr = string.Empty;
  19139. foreach (var item in rateDatas1)
  19140. {
  19141. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  19142. }
  19143. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  19144. designer.SetDataSource("Opertor", userInfo.CnName);
  19145. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19146. dt.TableName = "ViewMyHotelReservations";
  19147. designer.SetDataSource(dt);
  19148. designer.Process();
  19149. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19150. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19151. designer.Workbook.Save(serverPath);
  19152. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19153. #region 删除指定行
  19154. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19155. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19156. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19157. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19158. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19159. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19160. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19161. cssIndex = dt.Columns["CityTax"].Ordinal,
  19162. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19163. remarkIndex = dt.Columns["Remark"].Ordinal;
  19164. //删除指定列
  19165. foreach (DataRow item in dt.Rows)
  19166. {
  19167. string singleStr = item["SingleRoomPrice"].ToString();
  19168. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19169. if (containsDigitButNotZero1) singleDel = false;
  19170. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19171. string doubleStr = item["DoubleRoomPrice"].ToString();
  19172. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19173. if (containsDigitButNotZero2) doubleDel = false;
  19174. string suiteStr = item["SuiteRoomPrice"].ToString();
  19175. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19176. if (containsDigitButNotZero3) suiteDel = false;
  19177. string otherStr = item["OtherRoomPrice"].ToString();
  19178. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19179. if (containsDigitButNotZero4) otherDel = false;
  19180. string zcStr = item["BreakfastPrice"].ToString();
  19181. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19182. if (containsDigitButNotZero5) zcDel = false;
  19183. string dsStr = item["GovernmentRent"].ToString();
  19184. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19185. if (containsDigitButNotZero6) dsDel = false;
  19186. string cssStr = item["CityTax"].ToString();
  19187. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19188. if (containsDigitButNotZero7) cssDel = false;
  19189. string cpStr = item["ConsumptionPatterns"].ToString();
  19190. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19191. string remarkStr = item["Remark"].ToString();
  19192. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19193. }
  19194. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19195. DeleteColumn(serverPath, cpIndex, cpDel);
  19196. DeleteColumn(serverPath, dsIndex, dsDel);
  19197. DeleteColumn(serverPath, cssIndex, cssDel);
  19198. DeleteColumn(serverPath, zcIndex, zcDel);
  19199. DeleteColumn(serverPath, otherIndex, otherDel);
  19200. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19201. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19202. DeleteColumn(serverPath, singleIndex, singleDel);
  19203. #endregion
  19204. //只保留第一个表格
  19205. DeleteSheet(serverPath);
  19206. return Ok(JsonView(true, "操作成功", url = rst));
  19207. }
  19208. else
  19209. {
  19210. _currency = _GroupCostParameter.Currency;
  19211. bool isIntType = int.TryParse(_currency, out int currId);
  19212. if (isIntType)
  19213. {
  19214. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19215. }
  19216. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19217. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19218. if (currInfo == null)
  19219. {
  19220. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19221. }
  19222. if (!_currency.ToUpper().Equals("CNY"))
  19223. {
  19224. _rate = _GroupCostParameter.Rate;
  19225. }
  19226. _rate = currInfo.Rate;
  19227. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19228. //string strFileName = "HotelStatement/";
  19229. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19230. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19231. #region 数据处理
  19232. foreach (var item in hrDtas)
  19233. {
  19234. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19235. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19236. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19237. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19238. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19239. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19240. string singleRoomFeeStr = string.Empty,
  19241. doubleRoomFeeStr = string.Empty,
  19242. suiteRoomFeeStr = string.Empty,
  19243. otherRoomFeeStr = string.Empty,
  19244. payMoneyStr = string.Empty,
  19245. cardPriceStr = string.Empty;
  19246. if (roomCurr.Equals(_currency))
  19247. {
  19248. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  19249. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  19250. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  19251. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  19252. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  19253. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  19254. }
  19255. else
  19256. {
  19257. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19258. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19259. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19260. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19261. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19262. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19263. }
  19264. string breakfastPriceStr = string.Empty,
  19265. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19266. governmentRentStr = string.Empty,
  19267. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19268. cityTaxStrStr = string.Empty,
  19269. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19270. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  19271. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  19272. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  19273. int payDId = roomInfo?.PayDId ?? 0;
  19274. pcfds.Add(new HotelReservations_PCFD_View()
  19275. {
  19276. City = item.City,
  19277. HotelName = item.HotelName,
  19278. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19279. // SingleRoomCount = item.SingleRoomCount,
  19280. SingleRoomPrice = singleRoomFeeStr,
  19281. // DoubleRoomCount = item.DoubleRoomCount,
  19282. DoubleRoomPrice = doubleRoomFeeStr,
  19283. //SuiteRoomCount = item.SuiteRoomCount,
  19284. SuiteRoomPrice = suiteRoomFeeStr,
  19285. OtherRoomPrice = otherRoomFeeStr,
  19286. //OtherRoomCount = item.OtherRoomCount,
  19287. BreakfastPrice = breakfastPriceStr,
  19288. GovernmentRent = governmentRentStr,
  19289. CityTax = cityTaxStrStr,
  19290. RoomExplanation = item.RoomExplanation,
  19291. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19292. PayTime = roomInfo?.ConsumptionDate,
  19293. BankNo = roomInfo?.BankNo,
  19294. PayMoney = payMoneyStr,
  19295. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19296. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19297. CardPrice = cardPriceStr,
  19298. Remark = ccpInfo.Remark
  19299. });
  19300. }
  19301. #endregion
  19302. //载入模板
  19303. WorkbookDesigner designer = new WorkbookDesigner();
  19304. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19305. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19306. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19307. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19308. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  19309. designer.SetDataSource("Opertor", userInfo.CnName);
  19310. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19311. dt.TableName = "ViewMyHotelReservations";
  19312. designer.SetDataSource(dt);
  19313. designer.Process();
  19314. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19315. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19316. designer.Workbook.Save(serverPath);
  19317. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19318. #region 删除指定行
  19319. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19320. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19321. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19322. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19323. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19324. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19325. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19326. cssIndex = dt.Columns["CityTax"].Ordinal,
  19327. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19328. remarkIndex = dt.Columns["Remark"].Ordinal;
  19329. //删除指定列
  19330. foreach (DataRow item in dt.Rows)
  19331. {
  19332. string singleStr = item["SingleRoomPrice"].ToString();
  19333. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19334. if (containsDigitButNotZero1) singleDel = false;
  19335. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19336. string doubleStr = item["DoubleRoomPrice"].ToString();
  19337. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19338. if (containsDigitButNotZero2) doubleDel = false;
  19339. string suiteStr = item["SuiteRoomPrice"].ToString();
  19340. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19341. if (containsDigitButNotZero3) suiteDel = false;
  19342. string otherStr = item["OtherRoomPrice"].ToString();
  19343. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19344. if (containsDigitButNotZero4) otherDel = false;
  19345. string zcStr = item["BreakfastPrice"].ToString();
  19346. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19347. if (containsDigitButNotZero5) zcDel = false;
  19348. string dsStr = item["GovernmentRent"].ToString();
  19349. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19350. if (containsDigitButNotZero6) dsDel = false;
  19351. string cssStr = item["CityTax"].ToString();
  19352. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19353. if (containsDigitButNotZero7) cssDel = false;
  19354. string cpStr = item["ConsumptionPatterns"].ToString();
  19355. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19356. string remarkStr = item["Remark"].ToString();
  19357. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19358. }
  19359. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19360. DeleteColumn(serverPath, cpIndex, cpDel);
  19361. DeleteColumn(serverPath, dsIndex, dsDel);
  19362. DeleteColumn(serverPath, cssIndex, cssDel);
  19363. DeleteColumn(serverPath, zcIndex, zcDel);
  19364. DeleteColumn(serverPath, otherIndex, otherDel);
  19365. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19366. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19367. DeleteColumn(serverPath, singleIndex, singleDel);
  19368. #endregion
  19369. //只保留第一个表格
  19370. DeleteSheet(serverPath);
  19371. return Ok(JsonView(true, "操作成功", url = rst));
  19372. }
  19373. //return Ok(JsonView(false));
  19374. }
  19375. /// <summary>
  19376. /// 删除指定列
  19377. /// </summary>
  19378. /// <param name="file"></param>
  19379. /// <param name="columnIndex"></param>
  19380. /// <param name="isDel"></param>
  19381. private void DeleteColumn(string file, int columnIndex, bool isDel)
  19382. {
  19383. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19384. //wb.Save(file);
  19385. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  19386. if (sheet1 != null)
  19387. {
  19388. if (isDel)
  19389. {
  19390. Cells cells = sheet1.Cells;
  19391. cells.DeleteColumn(columnIndex);
  19392. }
  19393. }
  19394. wb.Save(file);
  19395. }
  19396. /// <summary>
  19397. /// 删除sheet
  19398. /// </summary>
  19399. /// <param name="file"></param>
  19400. private void DeleteSheet(string file)
  19401. {
  19402. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19403. //wb.Save(file);
  19404. List<string> sheets = new List<string>();
  19405. foreach (var item in wb.Worksheets)
  19406. {
  19407. sheets.Add(item.Name);
  19408. }
  19409. if (sheets.Count > 0)
  19410. {
  19411. sheets.RemoveAt(0);//不删除第一个sheet
  19412. foreach (var item in sheets)
  19413. {
  19414. wb.Worksheets.RemoveAt(item);
  19415. }
  19416. }
  19417. wb.Save(file);
  19418. }
  19419. /// <summary>
  19420. /// 酒店预订
  19421. /// 确认单
  19422. /// </summary>
  19423. /// <param name="_dto"></param>
  19424. /// <returns></returns>
  19425. [HttpPost]
  19426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19427. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  19428. {
  19429. try
  19430. {
  19431. #region 参数验证
  19432. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19433. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19434. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19435. #region 团组操作权限验证 76 酒店预定模块
  19436. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19437. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19438. #endregion
  19439. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19440. #region 页面操作权限验证
  19441. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19442. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19443. #endregion
  19444. #endregion
  19445. //团组信息
  19446. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  19447. //酒店数据
  19448. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  19449. if (listhoteldata.Count < 0)
  19450. {
  19451. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  19452. }
  19453. //利datatable存储
  19454. DataTable dt = new DataTable();
  19455. dt.Columns.Add("CheckInDate", typeof(string));
  19456. dt.Columns.Add("City", typeof(string));
  19457. dt.Columns.Add("Hotel", typeof(string));
  19458. dt.Columns.Add("Room", typeof(string));
  19459. for (int i = 0; i < listhoteldata.Count; i++)
  19460. {
  19461. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  19462. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  19463. while (dayStart < dayEnd)
  19464. {
  19465. string temp = "";
  19466. DataRow row = dt.NewRow();
  19467. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  19468. row["City"] = listhoteldata[i].City;
  19469. row["Hotel"] = listhoteldata[i].HotelName;
  19470. if (listhoteldata[i].SingleRoomCount > 0)
  19471. {
  19472. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  19473. }
  19474. if (listhoteldata[i].DoubleRoomCount > 0)
  19475. {
  19476. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  19477. }
  19478. if (listhoteldata[i].SuiteRoomCount > 0)
  19479. {
  19480. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  19481. }
  19482. if (listhoteldata[i].OtherRoomCount > 0)
  19483. {
  19484. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  19485. }
  19486. row["Room"] = temp;
  19487. dt.Rows.Add(row);
  19488. dayStart = dayStart.AddDays(1);
  19489. }
  19490. }
  19491. Dictionary<string, string> dic = new Dictionary<string, string>();
  19492. dic.Add("Dele", di.TeamName);
  19493. dic.Add("City", di.VisitCountry);
  19494. //模板路径
  19495. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  19496. //载入模板
  19497. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  19498. DocumentBuilder builder = new DocumentBuilder(doc);
  19499. foreach (var key in dic.Keys)
  19500. {
  19501. builder.MoveToBookmark(key);
  19502. builder.Write(dic[key]);
  19503. }
  19504. //获取word里所有表格
  19505. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19506. //获取所填表格的序数
  19507. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19508. var rowStart = tableOne.Rows[0]; //获取第1行
  19509. //循环赋值
  19510. for (int i = 0; i < dt.Rows.Count; i++)
  19511. {
  19512. builder.MoveToCell(0, i + 1, 0, 0);
  19513. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  19514. builder.MoveToCell(0, i + 1, 1, 0);
  19515. builder.Write(dt.Rows[i]["City"].ToString());
  19516. builder.MoveToCell(0, i + 1, 2, 0);
  19517. builder.Write(dt.Rows[i]["Hotel"].ToString());
  19518. builder.MoveToCell(0, i + 1, 3, 0);
  19519. builder.Write(dt.Rows[i]["Room"].ToString());
  19520. }
  19521. //删除多余行
  19522. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  19523. {
  19524. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  19525. }
  19526. string strFileName = di.TeamName + "酒店确认单.doc";
  19527. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  19528. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  19529. return Ok(JsonView(true, "成功", url));
  19530. }
  19531. catch (Exception ex)
  19532. {
  19533. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  19534. }
  19535. }
  19536. #endregion
  19537. #region 团组状态
  19538. /// <summary>
  19539. /// 团组状态列表 Page
  19540. /// </summary>
  19541. /// <param name="dto">团组列表请求dto</param>
  19542. /// <returns></returns>
  19543. [HttpPost]
  19544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19545. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  19546. {
  19547. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19548. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  19549. {
  19550. string sqlWhere = string.Empty;
  19551. if (dto.IsSure == 0) //未完成
  19552. {
  19553. sqlWhere += string.Format(@" And IsSure = 0");
  19554. }
  19555. else if (dto.IsSure == 1) //已完成
  19556. {
  19557. sqlWhere += string.Format(@" And IsSure = 1");
  19558. }
  19559. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  19560. {
  19561. string tj = dto.SearchCriteria;
  19562. 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}%')",
  19563. tj, tj, tj, tj, tj);
  19564. }
  19565. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  19566. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  19567. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  19568. From (
  19569. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  19570. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  19571. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  19572. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  19573. From Grp_DelegationInfo gdi
  19574. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  19575. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  19576. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  19577. Where gdi.IsDel = 0 {0}
  19578. ) temp ", sqlWhere);
  19579. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  19580. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  19581. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  19582. }
  19583. else
  19584. {
  19585. return Ok(JsonView(false, "查询失败"));
  19586. }
  19587. }
  19588. /// <summary>
  19589. /// 团组状态
  19590. /// 设置操作完成
  19591. /// </summary>
  19592. /// <param name="dto">团组列表请求dto</param>
  19593. /// <returns></returns>
  19594. [HttpPost]
  19595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19596. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  19597. {
  19598. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19599. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  19600. {
  19601. Id = dto.Id,
  19602. IsSure = 1
  19603. };
  19604. var result = await _sqlSugar.Updateable(_DelegationInfo)
  19605. .UpdateColumns(it => new { it.IsSure })
  19606. .WhereColumns(it => new { it.Id })
  19607. .ExecuteCommandAsync();
  19608. if (result > 0)
  19609. {
  19610. return Ok(JsonView(true, "操作完成!"));
  19611. }
  19612. return Ok(JsonView(false, "操作失败!"));
  19613. }
  19614. #endregion
  19615. #region 保险费用录入
  19616. /// <summary>
  19617. /// 根据团组Id查询保险费用列表
  19618. /// </summary>
  19619. /// <param name="dto"></param>
  19620. /// <returns></returns>
  19621. [HttpPost]
  19622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19623. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  19624. {
  19625. Result groupData = await _customersRep.CustomersByDiId(dto);
  19626. if (groupData.Code != 0)
  19627. {
  19628. return Ok(JsonView(false, groupData.Msg));
  19629. }
  19630. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19631. }
  19632. /// <summary>
  19633. /// 根据保险费用Id查询保险费用详细
  19634. /// </summary>
  19635. /// <param name="dto"></param>
  19636. /// <returns></returns>
  19637. [HttpPost]
  19638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19639. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  19640. {
  19641. try
  19642. {
  19643. Result groupData = await _customersRep.CustomersById(dto);
  19644. if (groupData.Code != 0)
  19645. {
  19646. return Ok(JsonView(false, groupData.Msg));
  19647. }
  19648. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19649. }
  19650. catch (Exception ex)
  19651. {
  19652. return Ok(JsonView(false, ex.Message));
  19653. }
  19654. }
  19655. /// <summary>
  19656. /// 保险费用录入页面初始化绑定
  19657. /// </summary>
  19658. /// <param name="dto"></param>
  19659. /// <returns></returns>
  19660. [HttpPost]
  19661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19662. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  19663. {
  19664. try
  19665. {
  19666. Result groupData = await _customersRep.CustomersInitialize(dto);
  19667. if (groupData.Code != 0)
  19668. {
  19669. return Ok(JsonView(false, groupData.Msg));
  19670. }
  19671. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19672. }
  19673. catch (Exception ex)
  19674. {
  19675. return Ok(JsonView(false, ex.Message));
  19676. }
  19677. }
  19678. /// <summary>
  19679. /// 保险费用操作(Status:1.新增,2.修改)
  19680. /// </summary>
  19681. /// <param name="dto"></param>
  19682. /// <returns></returns>
  19683. [HttpPost]
  19684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19685. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  19686. {
  19687. Result groupData = await _customersRep.OpCustomers(dto);
  19688. if (groupData.Code != 0)
  19689. {
  19690. return Ok(JsonView(false, groupData.Msg));
  19691. }
  19692. #region 应用推送
  19693. try
  19694. {
  19695. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  19696. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  19697. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  19698. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  19699. //自动审核
  19700. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  19701. //2024-10-21 新增LZ UID
  19702. var userIds = new List<int>() { 21 };
  19703. string title = $"系统通知";
  19704. var diId = dto.DiId;
  19705. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  19706. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  19707. string content = "";
  19708. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19709. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19710. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  19711. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  19712. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  19713. }
  19714. catch (Exception ex)
  19715. {
  19716. }
  19717. #endregion
  19718. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19719. }
  19720. /// <summary>
  19721. /// 保险文件上传
  19722. /// </summary>
  19723. /// <param name="file"></param>
  19724. /// <returns></returns>
  19725. [HttpPost]
  19726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19727. public async Task<IActionResult> UploadCus(IFormFile file)
  19728. {
  19729. try
  19730. {
  19731. if (file != null)
  19732. {
  19733. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19734. //文件名称
  19735. string projectFileName = file.FileName;
  19736. //上传的文件的路径
  19737. string filePath = "";
  19738. if (!Directory.Exists(fileDir))
  19739. {
  19740. Directory.CreateDirectory(fileDir);
  19741. }
  19742. //上传的文件的路径
  19743. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  19744. using (FileStream fs = System.IO.File.Create(filePath))
  19745. {
  19746. file.CopyTo(fs);
  19747. fs.Flush();
  19748. }
  19749. return Ok(JsonView(true, "上传成功!", projectFileName));
  19750. }
  19751. else
  19752. {
  19753. return Ok(JsonView(false, "上传失败!"));
  19754. }
  19755. }
  19756. catch (Exception ex)
  19757. {
  19758. return Ok(JsonView(false, ex.Message));
  19759. }
  19760. }
  19761. /// <summary>
  19762. /// 保险删除指定文件
  19763. /// </summary>
  19764. /// <param name="dto"></param>
  19765. /// <returns></returns>
  19766. [HttpPost]
  19767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19768. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  19769. {
  19770. try
  19771. {
  19772. string filePath = "";
  19773. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19774. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  19775. //int id = 0;
  19776. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  19777. // 删除该文件
  19778. try
  19779. {
  19780. System.IO.File.Delete(filePath);
  19781. 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()
  19782. {
  19783. Attachment = "",
  19784. }).ExecuteCommandAsync();
  19785. if (result != 0)
  19786. {
  19787. return Ok(JsonView(true, "成功!"));
  19788. }
  19789. else
  19790. {
  19791. return Ok(JsonView(false, "失败!"));
  19792. }
  19793. }
  19794. catch (Exception)
  19795. {
  19796. 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()
  19797. {
  19798. Attachment = "",
  19799. }).ExecuteCommandAsync();
  19800. if (result != 0)
  19801. {
  19802. return Ok(JsonView(true, "成功!"));
  19803. }
  19804. else
  19805. {
  19806. return Ok(JsonView(false, "失败!"));
  19807. }
  19808. }
  19809. }
  19810. catch (Exception ex)
  19811. {
  19812. return Ok(JsonView(false, "程序错误!"));
  19813. throw;
  19814. }
  19815. }
  19816. /// <summary>
  19817. /// 保险费用操作(删除)
  19818. /// </summary>
  19819. /// <param name="dto"></param>
  19820. /// <returns></returns>
  19821. [HttpPost]
  19822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19823. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  19824. {
  19825. try
  19826. {
  19827. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  19828. if (!res)
  19829. {
  19830. return Ok(JsonView(false, "删除失败"));
  19831. }
  19832. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  19833. {
  19834. IsDel = 1,
  19835. DeleteUserId = dto.DeleteUserId,
  19836. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  19837. }).ExecuteCommandAsync();
  19838. return Ok(JsonView(true, "删除成功!"));
  19839. }
  19840. catch (Exception ex)
  19841. {
  19842. return Ok(JsonView(false, "程序错误!"));
  19843. throw;
  19844. }
  19845. }
  19846. #endregion
  19847. #region 接团客户名单 PageId 104
  19848. /// <summary>
  19849. /// 接团客户名单
  19850. /// 迁移数据(慎用!)
  19851. /// </summary>
  19852. /// <returns></returns>
  19853. [HttpPost]
  19854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19855. public async Task<IActionResult> PostTourClientListChange()
  19856. {
  19857. try
  19858. {
  19859. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  19860. //var groupClinetData1
  19861. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  19862. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  19863. int updateCount = 0;
  19864. if (oldOAClientList.Count > 0)
  19865. {
  19866. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  19867. _sqlSugar.BeginTran();
  19868. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  19869. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  19870. foreach (var item in oldOAClientList)
  19871. {
  19872. int comId = 0;
  19873. string format = "yyyy-MM-dd HH:mm:ss";
  19874. string data11 = "1990-01-01 00:00";
  19875. var data1 = IsValidDate(item.OPdate, format);
  19876. if (data1) data11 = item.OPdate;
  19877. //客户公司验证
  19878. if (!string.IsNullOrEmpty(item.Company))
  19879. {
  19880. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  19881. if (clientComInfo == null) // add
  19882. {
  19883. var addInfo = new Crm_CustomerCompany()
  19884. {
  19885. CompanyAbbreviation = "",
  19886. CompanyFullName = item.Company,
  19887. Address = "",
  19888. PostCodes = "",
  19889. LastedOpUserId = item.OPer,
  19890. LastedOpDt = Convert.ToDateTime(data11),
  19891. CreateUserId = item.OPer,
  19892. CreateTime = Convert.ToDateTime(data11),
  19893. IsDel = 0
  19894. };
  19895. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  19896. if (comId1 > 0) comId = comId1;
  19897. }
  19898. else comId = clientComInfo.Id;
  19899. }
  19900. //客户人员验证
  19901. int clientId = 0;
  19902. string name = item.LastName + item.Name;
  19903. if (!string.IsNullOrEmpty(name))
  19904. {
  19905. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  19906. if (clientInfo == null)
  19907. {
  19908. DateTime? dateTime = null;
  19909. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  19910. if (isDt) dateTime = birthDayDt;
  19911. var addInfo1 = new Crm_DeleClient()
  19912. {
  19913. CrmCompanyId = comId,
  19914. DiId = -1,
  19915. LastName = item.LastName,
  19916. FirstName = item.Name,
  19917. OldName = "",
  19918. Pinyin = item.Pinyin,
  19919. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  19920. Marriage = 0,
  19921. Phone = item.Phone,
  19922. Job = item.Job,
  19923. BirthDay = dateTime
  19924. };
  19925. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  19926. if (clientId1 > 0) clientId = clientId1;
  19927. }
  19928. else clientId = clientInfo.Id;
  19929. }
  19930. if (clientId < 1)
  19931. {
  19932. continue;
  19933. }
  19934. int airType = 0;
  19935. if (item.AirType == "超经舱") airType = 459;
  19936. else if (item.AirType == "公务舱") airType = 458;
  19937. else if (item.AirType == "经济舱") airType = 460;
  19938. else if (item.AirType == "其他") airType = 565;
  19939. else if (item.AirType == "头等舱") airType = 457;
  19940. var _TourClientListEntity = new Grp_TourClientList()
  19941. {
  19942. DiId = item.Diid,
  19943. ClientId = clientId,
  19944. CreateUserId = item.OPer,
  19945. CreateTime = Convert.ToDateTime(data11),
  19946. Remark = item.Remark,
  19947. IsDel = item.Isdel,
  19948. ShippingSpaceTypeId = airType,
  19949. ShippingSpaceSpecialNeeds = item.AirRemark,
  19950. HotelSpecialNeeds = item.RoomType
  19951. };
  19952. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  19953. if (_TourClientList > 0)
  19954. {
  19955. updateCount++;
  19956. }
  19957. }
  19958. _sqlSugar.CommitTran();
  19959. }
  19960. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  19961. }
  19962. catch (Exception ex)
  19963. {
  19964. _sqlSugar.RollbackTran();
  19965. return Ok(JsonView(false, ex.Message));
  19966. }
  19967. //return Ok(JsonView(true));
  19968. }
  19969. private bool IsValidDate(string dateString, string format)
  19970. {
  19971. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  19972. }
  19973. /// <summary>
  19974. /// 接团客户名单
  19975. /// 根据团组Id查询List
  19976. /// </summary>
  19977. /// <param name="_dto"></param>
  19978. /// <returns></returns>
  19979. [HttpPost]
  19980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19981. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  19982. {
  19983. #region 参数验证
  19984. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  19985. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  19986. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  19987. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19988. #region 页面操作权限验证
  19989. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19990. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19991. #endregion
  19992. #endregion
  19993. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  19994. if (viewData.Code != 0)
  19995. {
  19996. return Ok(JsonView(false, viewData.Msg));
  19997. }
  19998. return Ok(JsonView(viewData.Data));
  19999. }
  20000. /// <summary>
  20001. /// 接团客户名单
  20002. /// 基础数据 Init
  20003. /// </summary>
  20004. /// <param name="_dto"></param>
  20005. /// <returns></returns>
  20006. [HttpPost]
  20007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20008. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  20009. {
  20010. #region 参数验证
  20011. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20012. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20013. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20014. #region 页面操作权限验证
  20015. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20016. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20017. #endregion
  20018. #endregion
  20019. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  20020. }
  20021. /// <summary>
  20022. /// 接团客户名单
  20023. /// 根据 Id查询 Details
  20024. /// </summary>
  20025. /// <param name="_dto"></param>
  20026. /// <returns></returns>
  20027. [HttpPost]
  20028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20029. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  20030. {
  20031. #region 参数验证
  20032. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20033. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20034. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20035. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20036. #region 页面操作权限验证
  20037. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20038. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20039. #endregion
  20040. #endregion
  20041. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  20042. if (viewData.Code != 0)
  20043. {
  20044. return Ok(JsonView(false, viewData.Msg));
  20045. }
  20046. return Ok(JsonView(viewData.Data));
  20047. }
  20048. /// <summary>
  20049. /// 接团客户名单
  20050. /// Add Or Edit
  20051. /// </summary>
  20052. /// <param name="_dto"></param>
  20053. /// <returns></returns>
  20054. [HttpPost]
  20055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20056. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  20057. {
  20058. #region 参数验证
  20059. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20060. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20061. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20062. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20063. #region 页面操作权限验证
  20064. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20065. if (_dto.Id == 0) //添加
  20066. {
  20067. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20068. }
  20069. else if (_dto.Id >= 0) //修改
  20070. {
  20071. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  20072. }
  20073. #endregion
  20074. #endregion
  20075. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  20076. if (viewData.Code != 0)
  20077. {
  20078. return Ok(JsonView(false, viewData.Msg));
  20079. }
  20080. return Ok(JsonView(true));
  20081. }
  20082. /// <summary>
  20083. /// 接团客户名单
  20084. /// json字符串 AddMultiple(添加多个)
  20085. /// </summary>
  20086. /// <param name="_dto"></param>
  20087. /// <returns></returns>
  20088. [HttpPost]
  20089. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20090. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  20091. {
  20092. #region 参数验证
  20093. string jsonLabel = _dto.JsonLabel;
  20094. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20095. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20096. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20097. #region 页面操作权限验证
  20098. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20099. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20100. #endregion
  20101. #endregion
  20102. var request = new TourClientListAddMultipleDto();
  20103. request.DiId = _dto.DiId;
  20104. request.UserId = _dto.UserId;
  20105. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  20106. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  20107. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  20108. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  20109. var infos = new List<TourClientListInfo>();
  20110. foreach (var data in datas)
  20111. {
  20112. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  20113. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  20114. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  20115. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  20116. {
  20117. continue;
  20118. }
  20119. infos.Add(new TourClientListInfo()
  20120. {
  20121. IsAccompany = 1,
  20122. LastName = lastName,
  20123. FirstName = firstName,
  20124. Pinyin = lastNameEn + @"/" + firstNameEn,
  20125. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  20126. CompanyFullName = data.CompanyFullName,
  20127. Job = data.Job
  20128. });
  20129. }
  20130. if (infos.Any())
  20131. {
  20132. var viewData = await _tourClientListRep._AddMultiple(request);
  20133. if (viewData.Code != 0)
  20134. {
  20135. return Ok(JsonView(false, viewData.Msg));
  20136. }
  20137. return Ok(JsonView(true));
  20138. }
  20139. return Ok(JsonView(false));
  20140. }
  20141. /// <summary>
  20142. /// 接团客户名单
  20143. /// AddMultiple(添加多个)
  20144. /// </summary>
  20145. /// <param name="_dto"></param>
  20146. /// <returns></returns>
  20147. [HttpPost]
  20148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20149. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  20150. {
  20151. #region 参数验证
  20152. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20153. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20154. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20155. #region 页面操作权限验证
  20156. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20157. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20158. #endregion
  20159. #endregion
  20160. var viewData = await _tourClientListRep._AddMultiple(_dto);
  20161. if (viewData.Code != 0)
  20162. {
  20163. return Ok(JsonView(false, viewData.Msg));
  20164. }
  20165. return Ok(JsonView(true));
  20166. }
  20167. /// <summary>
  20168. /// 接团客户名单
  20169. /// Del
  20170. /// </summary>
  20171. /// <param name="_dto"></param>
  20172. /// <returns></returns>
  20173. [HttpPost]
  20174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20175. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  20176. {
  20177. #region 参数验证
  20178. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20179. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20180. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20181. #region 页面操作权限验证
  20182. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20183. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  20184. #endregion
  20185. #endregion
  20186. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  20187. if (viewData.Code != 0)
  20188. {
  20189. return Ok(JsonView(false, viewData.Msg));
  20190. }
  20191. return Ok(JsonView(true));
  20192. }
  20193. /// <summary>
  20194. /// 接团客户名单
  20195. /// 文件下载 客户名单
  20196. /// </summary>
  20197. /// <param name="_dto"></param>
  20198. /// <returns></returns>
  20199. [HttpPost]
  20200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20201. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  20202. {
  20203. #region 参数验证
  20204. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20205. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20206. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  20207. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20208. #region 页面操作权限验证
  20209. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20210. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20211. #endregion
  20212. #endregion
  20213. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  20214. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  20215. From Grp_TourClientList tcl
  20216. Left Join
  20217. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  20218. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  20219. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  20220. From Crm_DeleClient dc
  20221. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  20222. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  20223. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  20224. Where dc.IsDel = 0) temp
  20225. On temp.DcId =tcl.ClientId
  20226. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  20227. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  20228. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  20229. //载入模板
  20230. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  20231. if (_dto.Language == 1)
  20232. {
  20233. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  20234. }
  20235. //载入模板
  20236. var doc = new Document(tempPath);
  20237. DocumentBuilder builder = new DocumentBuilder(doc);
  20238. //获取word里所有表格
  20239. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20240. //获取所填表格的序数
  20241. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20242. var rowStart = tableOne.Rows[0]; //获取第1行
  20243. if (_dto.Language == 0)
  20244. {
  20245. //循环赋值
  20246. for (int i = 0; i < DcList.Count; i++)
  20247. {
  20248. EncryptionProcessor.DecryptProperties(DcList[i]);
  20249. builder.MoveToCell(0, i + 1, 0, 0);
  20250. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  20251. builder.MoveToCell(0, i + 1, 1, 0);
  20252. int sex = DcList[i].Sex;
  20253. string sexStr = string.Empty;
  20254. if (sex == 0) sexStr = "男";
  20255. else if (sex == 1) sexStr = "女";
  20256. else sexStr = "未设置";
  20257. builder.Write(sexStr);
  20258. builder.MoveToCell(0, i + 1, 2, 0);
  20259. string birthDay = DcList[i].BirthDay;
  20260. string birthDayStr = string.Empty;
  20261. if (!string.IsNullOrEmpty(birthDay))
  20262. {
  20263. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  20264. }
  20265. builder.Write(birthDayStr);
  20266. builder.MoveToCell(0, i + 1, 3, 0);
  20267. string company = "";
  20268. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20269. {
  20270. company = DcList[i].CompanyFullName.ToString();
  20271. }
  20272. builder.Write(company);
  20273. builder.MoveToCell(0, i + 1, 4, 0);
  20274. builder.Write(DcList[i].Job);
  20275. }
  20276. }
  20277. else if (_dto.Language == 1)
  20278. {
  20279. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  20280. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  20281. List<string> transArrayStr = new List<string>();
  20282. string transStrRes1 = "";
  20283. for (int i = 0; i < DcList.Count; i++)
  20284. {
  20285. var dc = DcList[i];
  20286. EncryptionProcessor.DecryptProperties(dc);
  20287. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  20288. if (dc.Job.Equals("暂无")) dc.Job = "-";
  20289. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  20290. if (DcList.Count - 1 == i) transStrRes1 += str1;
  20291. else transStrRes1 += $"{str1}|";
  20292. }
  20293. #region AI转英文
  20294. string jsonValue = JsonConvert.SerializeObject(DcList);
  20295. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  20296. List<SeedMessages> messages = new List<SeedMessages>()
  20297. {
  20298. new SeedMessages
  20299. {
  20300. Role = KimiRole.user,
  20301. Content = jsonValue + text
  20302. }
  20303. };
  20304. KiMiApiClient client = new KiMiApiClient();
  20305. var kimiApiResult = await client.SeedMessage(messages);
  20306. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20307. string clients = kimiApiResult_JObject["content"].ToString();
  20308. string startStr = "```json", endStr = "```";
  20309. // 判断并清除开头部分
  20310. if (clients.StartsWith(startStr))
  20311. {
  20312. clients = clients.Remove(0, startStr.Length);
  20313. }
  20314. // 判断并清除结尾部分
  20315. if (clients.EndsWith(endStr))
  20316. {
  20317. clients = clients.Remove(clients.Length - endStr.Length);
  20318. }
  20319. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  20320. //循环赋值
  20321. for (int i = 0; i < en_Json.Count; i++)
  20322. {
  20323. var dc = en_Json[i];
  20324. var dc1 = DcList.Find(x => x.Id == dc.Id);
  20325. string PYName = dc.FirstName + " " + dc.LastName;
  20326. builder.MoveToCell(0, i + 1, 0, 0);
  20327. builder.Write(PYName);
  20328. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  20329. builder.MoveToCell(0, i + 1, 1, 0);
  20330. builder.Write(sex);
  20331. DateTime birthDt;
  20332. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  20333. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20334. builder.MoveToCell(0, i + 1, 2, 0);
  20335. builder.Write(birthday);
  20336. string company = string.Empty, job = string.Empty;
  20337. company = dc.CompanyFullName;
  20338. job = dc.Job;
  20339. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  20340. {
  20341. //查询对照表
  20342. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  20343. if (tempCec != null)
  20344. {
  20345. company = tempCec.enName;
  20346. }
  20347. }
  20348. builder.MoveToCell(0, i + 1, 3, 0);
  20349. builder.Write(company);
  20350. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  20351. {
  20352. //查询对照表
  20353. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  20354. if (tempPec != null)
  20355. {
  20356. job = tempPec.enName;
  20357. }
  20358. }
  20359. builder.MoveToCell(0, i + 1, 4, 0);
  20360. builder.Write(job);
  20361. }
  20362. #endregion
  20363. #region 旧翻译英文处理
  20364. ////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";
  20365. //string transStrRes = "";
  20366. //if (transStrRes1.Length > 0)
  20367. //{
  20368. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  20369. //}
  20370. ////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
  20371. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  20372. ////List<string> transArray = new List<string> { };
  20373. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  20374. //if (transStrRes.Contains("|"))
  20375. //{
  20376. // string[] transArray1 = transStrRes.Split('|');
  20377. // if (transArray1.Length > 0)
  20378. // {
  20379. // foreach (var item in transArray1)
  20380. // {
  20381. // if (item.Contains("&"))
  20382. // {
  20383. // string[] transArray2 = item.Split('&');
  20384. // int index = 0;
  20385. // string companyName = "", job = "";
  20386. // if (transArray2.Length > 0)
  20387. // {
  20388. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  20389. // if (1 < transArray2.Length) companyName = transArray2[1];
  20390. // if (2 < transArray2.Length) job = transArray2[2];
  20391. // }
  20392. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  20393. // }
  20394. // }
  20395. // }
  20396. //}
  20397. ////循环赋值
  20398. //for (int i = 0; i < DcList.Count; i++)
  20399. //{
  20400. // string PYName = "";
  20401. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  20402. // {
  20403. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  20404. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  20405. // PYName = PY_First + " " + PY_Last;
  20406. // }
  20407. // else
  20408. // {
  20409. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  20410. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  20411. // PYName = PY_First + " " + PY_Last;
  20412. // }
  20413. // builder.MoveToCell(0, i + 1, 0, 0);
  20414. // builder.Write(PYName);
  20415. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  20416. // builder.MoveToCell(0, i + 1, 1, 0);
  20417. // builder.Write(sex);
  20418. // DateTime birthDt;
  20419. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  20420. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20421. // builder.MoveToCell(0, i + 1, 2, 0);
  20422. // builder.Write(birthday);
  20423. // string company = string.Empty, job = string.Empty;
  20424. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  20425. // if (dcTransInfo != null)
  20426. // {
  20427. // company = dcTransInfo.CompanyName;
  20428. // job = dcTransInfo.Job;
  20429. // }
  20430. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20431. // {
  20432. // //查询对照表
  20433. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  20434. // if (tempCec != null)
  20435. // {
  20436. // company = tempCec.enName;
  20437. // }
  20438. // //翻译
  20439. // else
  20440. // {
  20441. // }
  20442. // }
  20443. // builder.MoveToCell(0, i + 1, 3, 0);
  20444. // builder.Write(company);
  20445. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  20446. // {
  20447. // //查询对照表
  20448. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  20449. // if (tempPec != null)
  20450. // {
  20451. // job = tempPec.enName;
  20452. // }
  20453. // //翻译
  20454. // else
  20455. // {
  20456. // }
  20457. // }
  20458. // builder.MoveToCell(0, i + 1, 4, 0);
  20459. // builder.Write(job);
  20460. //}
  20461. #endregion
  20462. }
  20463. //删除多余行
  20464. while (tableOne.Rows.Count > DcList.Count + 1)
  20465. {
  20466. tableOne.Rows.RemoveAt(DcList.Count + 1);
  20467. }
  20468. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  20469. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  20470. doc.Save(fileDir);
  20471. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  20472. return Ok(JsonView(true, "操作成功!", Url));
  20473. }
  20474. private class TranslateInfo
  20475. {
  20476. public int Index { get; set; }
  20477. public string CompanyName { get; set; }
  20478. public string Job { get; set; }
  20479. }
  20480. [HttpPost]
  20481. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  20482. {
  20483. if (files.Count == 0)
  20484. {
  20485. return Ok(JsonView(false, "文件为空"));
  20486. }
  20487. KiMiApiClient KiMiApi = new KiMiApiClient();
  20488. var seedConter = await KiMiApi.UploadFilesAsync(files);
  20489. if (seedConter.Count == 0)
  20490. {
  20491. return Ok(JsonView(false, "上传结果为空!"));
  20492. }
  20493. var messages = new List<SeedMessages>
  20494. {
  20495. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  20496. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  20497. };
  20498. messages.InsertRange(1, seedConter);
  20499. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  20500. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20501. string clients = kimiApiResult_JObject["content"].ToString();
  20502. string startStr = "```json", endStr = "```";
  20503. // 判断并清除开头部分
  20504. if (clients.StartsWith(startStr))
  20505. {
  20506. clients = clients.Remove(0, startStr.Length);
  20507. }
  20508. // 判断并清除结尾部分
  20509. if (clients.EndsWith(endStr))
  20510. {
  20511. clients = clients.Remove(clients.Length - endStr.Length);
  20512. }
  20513. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  20514. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  20515. {
  20516. {"姓", "LastName" },
  20517. {"名", "FirstName" },
  20518. {"姓名拼音", "Pinyin" },
  20519. {"性别", "Sex" },
  20520. {"单位", "CompanyFullName" },
  20521. {"职务", "Job" },
  20522. {"出生日期", "Birthday" },
  20523. };
  20524. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  20525. foreach (var item in clients_JObject)
  20526. {
  20527. BaiduClientOCRView cdc = new BaiduClientOCRView();
  20528. foreach (var field in clientFieldMap.Keys)
  20529. {
  20530. if (item.TryGetValue(field, out JToken value))
  20531. {
  20532. var getValue = value.ToString();
  20533. System.Type type = cdc.GetType();
  20534. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  20535. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  20536. propertyInfo.SetValue(cdc, propertyValue);
  20537. }
  20538. }
  20539. crmClients.Add(cdc);
  20540. }
  20541. return Ok(JsonView(new
  20542. {
  20543. fileCount = files.Count,
  20544. UploadCount = seedConter.Count,
  20545. ApiResult = clients,
  20546. CrmClients = crmClients
  20547. }));
  20548. }
  20549. #endregion
  20550. #region 团组倒推表
  20551. /// <summary>
  20552. /// 倒推表基础数据
  20553. /// Init
  20554. /// </summary>
  20555. /// <returns></returns>
  20556. [HttpPost]
  20557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20558. public async Task<IActionResult> PostInvertedListInit()
  20559. {
  20560. var viewData = await _invertedListRep._Init();
  20561. if (viewData.Code != 0)
  20562. {
  20563. return Ok(JsonView(false, viewData.Msg));
  20564. }
  20565. return Ok(JsonView(viewData.Data));
  20566. }
  20567. /// <summary>
  20568. /// 倒推表
  20569. /// Info
  20570. /// </summary>
  20571. /// <param name="dto"></param>
  20572. /// <returns></returns>
  20573. [HttpPost]
  20574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20575. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  20576. {
  20577. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  20578. if (viewData.Code != 0)
  20579. {
  20580. return Ok(JsonView(false, viewData.Msg));
  20581. }
  20582. return Ok(JsonView(viewData.Data));
  20583. }
  20584. /// <summary>
  20585. /// 倒推表
  20586. /// Create
  20587. /// </summary>
  20588. /// <param name="dto"></param>
  20589. /// <returns></returns>
  20590. [HttpPost]
  20591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20592. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  20593. {
  20594. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  20595. if (viewData.Code != 0)
  20596. {
  20597. return Ok(JsonView(false, viewData.Msg));
  20598. }
  20599. return Ok(JsonView(viewData.Data));
  20600. }
  20601. /// <summary>
  20602. /// 倒推表
  20603. /// Update
  20604. /// </summary>
  20605. /// <param name="dto"></param>
  20606. /// <returns></returns>
  20607. [HttpPost]
  20608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20609. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  20610. {
  20611. var viewData = await _invertedListRep._Update(dto);
  20612. if (viewData.Code != 0)
  20613. {
  20614. return Ok(JsonView(false, viewData.Msg));
  20615. }
  20616. return Ok(JsonView(viewData.Data));
  20617. }
  20618. /// <summary>
  20619. /// 倒推表
  20620. /// File Download
  20621. /// </summary>
  20622. /// <param name="dto"></param>
  20623. /// <returns></returns>
  20624. [HttpPost]
  20625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20626. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  20627. {
  20628. var info2 = await _invertedListRep._Info(1, dto.DiId);
  20629. if (info2.Code != 0)
  20630. {
  20631. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  20632. }
  20633. var info1 = info2.Data as InvertedListInfoView;
  20634. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  20635. string teamName = "";
  20636. if (info != null) teamName = info.TeamName;
  20637. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  20638. var doc = new Document();
  20639. var builder = new DocumentBuilder(doc);
  20640. #region old insert
  20641. ////载入模板
  20642. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  20643. //Document doc = new Document(tempPath);
  20644. //DocumentBuilder builder = new DocumentBuilder(doc);
  20645. //利用键值对存放数据
  20646. //Dictionary<string, string> dic = new Dictionary<string, string>();
  20647. //dic.Add("TeamName", teamName);
  20648. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  20649. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  20650. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  20651. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  20652. //dic.Add("SQRemark", info1.ApprovalRemark);
  20653. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  20654. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  20655. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  20656. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  20657. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  20658. //dic.Add("QZRemark", info1.VisaInformationRemark);
  20659. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  20660. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  20661. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  20662. //dic.Add("CQRemark", info1.IssueVisaRemark);
  20663. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  20664. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  20665. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  20666. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  20667. //#region 填充word模板书签内容
  20668. //foreach (var key in dic.Keys)
  20669. //{
  20670. // builder.MoveToBookmark(key);
  20671. // builder.Write(dic[key]);
  20672. //}
  20673. //#endregion
  20674. #endregion
  20675. #region New Insert
  20676. string titleFont = $"仿宋",
  20677. contentFont = $"仿宋";
  20678. var fontColor = Color.FromArgb(64, 64, 64);
  20679. //设置标题 团组名称
  20680. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20681. builder.Font.Name = titleFont;
  20682. builder.Font.Color = fontColor;
  20683. builder.Font.Size = 12;
  20684. builder.Font.Bold = true;
  20685. builder.Writeln(teamName);
  20686. //设置副标题 团组出访时间
  20687. builder.Font.Size = 12;
  20688. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  20689. builder.Writeln();
  20690. var backgroundColor = Color.FromArgb(199, 199, 199);
  20691. var table = builder.StartTable();
  20692. builder.InsertCell();
  20693. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  20694. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  20695. builder.CellFormat.Borders.LineWidth = 1;
  20696. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  20697. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  20698. builder.RowFormat.Height = 40;
  20699. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20700. builder.Font.Name = contentFont;
  20701. builder.Font.Size = 12;
  20702. builder.Font.Bold = true;
  20703. builder.Font.Color = fontColor;
  20704. builder.Write("时间");
  20705. builder.InsertCell();
  20706. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  20707. builder.Write("流程");
  20708. builder.InsertCell();
  20709. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  20710. builder.Write("说明");
  20711. builder.EndRow();
  20712. //报批资料准备
  20713. if (info1.IsSelectedAirportd)
  20714. {
  20715. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  20716. }
  20717. //报批/提供送签资料
  20718. if (info1.IsSelectedApprovalData)
  20719. {
  20720. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  20721. }
  20722. //出批件护照办理
  20723. if (info1.IsSelectedIssueApproval)
  20724. {
  20725. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  20726. }
  20727. //签证资料准备
  20728. if (info1.IsSelectedVisaInfo)
  20729. {
  20730. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  20731. }
  20732. //送签
  20733. if (info1.IsSelectedSendVisa)
  20734. {
  20735. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  20736. }
  20737. //出签
  20738. if (info1.IsSelectedIssueVisa)
  20739. {
  20740. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  20741. }
  20742. //机票
  20743. if (info1.IsSelectedAirTicket)
  20744. {
  20745. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  20746. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  20747. }
  20748. //酒店
  20749. if (info1.IsSelectedHotel)
  20750. {
  20751. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  20752. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  20753. }
  20754. //开行前会
  20755. if (info1.IsSelectedPreTripMeeting)
  20756. {
  20757. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  20758. }
  20759. //送机
  20760. if (info1.IsSelectedAirportdDropOff)
  20761. {
  20762. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  20763. }
  20764. builder.EndTable();
  20765. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  20766. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  20767. for (int i = 0; i < table.Rows.Count; i++)
  20768. {
  20769. var row = table.Rows[i];
  20770. //设置宽度
  20771. row.Cells[0].CellFormat.Width = 20.00;
  20772. row.Cells[1].CellFormat.Width = 30.00;
  20773. row.Cells[2].CellFormat.Width = 50.00;
  20774. if (i != 0)
  20775. {
  20776. //边框设置
  20777. InvertedListFileDownloadSetBorders(row.Cells, 0);
  20778. InvertedListFileDownloadSetBorders(row.Cells, 1);
  20779. InvertedListFileDownloadSetBorders(row.Cells, 2);
  20780. }
  20781. }
  20782. #region 页脚插入图片
  20783. // 创建页脚
  20784. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  20785. doc.FirstSection.HeadersFooters.Add(footer);
  20786. Paragraph para = new Paragraph(doc);
  20787. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  20788. footer.AppendChild(para);
  20789. builder.MoveTo(para);
  20790. string imagePath = "./Images/FMGJ_Log.png";
  20791. builder.InsertImage(imagePath);
  20792. #endregion
  20793. #endregion
  20794. var fileDir = AppSettingsHelper.Get("WordBasePath");
  20795. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  20796. string filePath = fileDir + $@"InvertedList/{fileName}";
  20797. doc.Save(filePath);
  20798. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  20799. return Ok(JsonView(true, "操作成功!", Url));
  20800. }
  20801. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  20802. {
  20803. var fontColor = Color.FromArgb(64, 64, 64);
  20804. builder.InsertCell();
  20805. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  20806. builder.RowFormat.Height = 40;
  20807. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20808. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20809. builder.Font.Name = fontName;
  20810. builder.Font.Size = 8;
  20811. builder.Font.Bold = true;
  20812. builder.Font.Color = fontColor;
  20813. builder.Write(dateTime);
  20814. builder.InsertCell();
  20815. builder.Font.Size = 9;
  20816. builder.Font.Bold = true;
  20817. builder.Font.Color = fontColor;
  20818. builder.Write(content);
  20819. builder.InsertCell();
  20820. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20821. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20822. builder.Font.Size = 9;
  20823. builder.Font.Bold = false;
  20824. builder.Font.Color = fontColor;
  20825. builder.Write(reamrk);
  20826. builder.EndRow();
  20827. }
  20828. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  20829. {
  20830. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  20831. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  20832. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  20833. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  20834. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  20835. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  20836. }
  20837. #endregion
  20838. #region 会务倒推表
  20839. /// <summary>
  20840. /// 会务倒推表
  20841. /// Init
  20842. /// </summary>
  20843. /// <returns></returns>
  20844. [HttpPost]
  20845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20846. public async Task<IActionResult> InforRetrogressTableInit()
  20847. {
  20848. var groupData = await _groupRepository.PostShareGroupInfos(1);
  20849. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  20850. return Ok(JsonView(false, groupData.Msg));
  20851. }
  20852. /// <summary>
  20853. /// 会务倒推表
  20854. /// ExcelDownload
  20855. /// </summary>
  20856. /// <param name="dto"></param>
  20857. /// <returns></returns>
  20858. [HttpPost]
  20859. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  20860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20861. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  20862. {
  20863. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  20864. var validatorRes = await validator.ValidateAsync(dto);
  20865. if (!validatorRes.IsValid)
  20866. {
  20867. StringBuilder sb = new StringBuilder();
  20868. foreach (var item in validatorRes.Errors)
  20869. {
  20870. sb.AppendLine(item.ErrorMessage);
  20871. }
  20872. return Ok(JsonView(false, sb.ToString()));
  20873. }
  20874. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20875. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20876. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20877. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20878. #region Excel
  20879. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  20880. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  20881. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  20882. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  20883. var fileNamePrefix = string.Empty;
  20884. if (days >= 30)
  20885. {
  20886. tempPath += $"会务工作倒推进度表(30天).xlsx";
  20887. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  20888. }
  20889. else if (days < 30 && days > 7)
  20890. {
  20891. tempPath += $"会务工作倒推进度表(15天).xlsx";
  20892. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  20893. }
  20894. else if (days <= 7)
  20895. {
  20896. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20897. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20898. }
  20899. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  20900. fileName = CommonFun.ValidFileName(fileName);
  20901. //载入模板
  20902. WorkbookDesigner designer = new WorkbookDesigner();
  20903. designer.Workbook = new Workbook(tempPath);
  20904. designer.Process();
  20905. if (!Directory.Exists(savePath))
  20906. {
  20907. Directory.CreateDirectory(savePath);
  20908. }
  20909. string serverPath = $"{savePath}{fileName}";
  20910. designer.Workbook.Save(serverPath);
  20911. string rst = $"{servicePath}{ftpPath}{fileName}";
  20912. #endregion
  20913. return Ok(JsonView(new { url = rst }));
  20914. }
  20915. #endregion
  20916. #region 三公签证费用(签证费、代办费)
  20917. /// <summary>
  20918. /// 三公签证费用(签证费、代办费)
  20919. /// List
  20920. /// </summary>
  20921. /// <returns></returns>
  20922. [HttpPost]
  20923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20924. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  20925. {
  20926. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  20927. }
  20928. /// <summary>
  20929. /// 三公签证费用(签证费、代办费)
  20930. /// Add Or Update
  20931. /// </summary>
  20932. /// <returns></returns>
  20933. [HttpPost]
  20934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20935. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  20936. {
  20937. var _view = await _visaFeeInfoRep.Update(_dto);
  20938. if (_view.Code != 0)
  20939. {
  20940. return Ok(JsonView(false, _view.Msg));
  20941. }
  20942. return Ok(JsonView(true, _view.Msg));
  20943. }
  20944. #endregion
  20945. #region 酒店询价
  20946. /// <summary>
  20947. /// 酒店询价
  20948. /// Init
  20949. /// </summary>
  20950. /// <returns></returns>
  20951. [HttpPost]
  20952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20953. public async Task<IActionResult> PostHotelInquiryInit()
  20954. {
  20955. var res = await _hotelInquiryRep._Init();
  20956. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20957. return Ok(JsonView(true, res.Msg, res.Data));
  20958. }
  20959. /// <summary>
  20960. /// 酒店询价
  20961. /// page Item
  20962. /// </summary>
  20963. /// <param name="_dto"></param>
  20964. /// <returns></returns>
  20965. [HttpPost]
  20966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20967. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  20968. {
  20969. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  20970. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20971. var view = res.Data as PageDataViewBase;
  20972. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  20973. }
  20974. /// <summary>
  20975. /// 酒店询价
  20976. /// info
  20977. /// </summary>
  20978. /// <param name="_dto"></param>
  20979. /// <returns></returns>
  20980. [HttpPost]
  20981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20982. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  20983. {
  20984. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  20985. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20986. return Ok(JsonView(true, res.Msg, res.Data));
  20987. }
  20988. /// <summary>
  20989. /// 酒店询价
  20990. /// Add Or Edit
  20991. /// </summary>
  20992. /// <param name="_dto"></param>
  20993. /// <returns></returns>
  20994. [HttpPost]
  20995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20996. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  20997. {
  20998. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  20999. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21000. return Ok(JsonView(true, res.Msg, res.Data));
  21001. }
  21002. /// <summary>
  21003. /// 酒店询价
  21004. /// Del
  21005. /// </summary>
  21006. /// <param name="_dto"></param>
  21007. /// <returns></returns>
  21008. [HttpPost]
  21009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21010. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  21011. {
  21012. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  21013. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21014. return Ok(JsonView(true, res.Msg, res.Data));
  21015. }
  21016. #endregion
  21017. #region 下载匹配op行程单
  21018. /// <summary>
  21019. /// 匹配op行程单
  21020. /// Init
  21021. /// </summary>
  21022. /// <param name="dto">团组列表请求dto</param>
  21023. /// <returns></returns>
  21024. [HttpPost]
  21025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21026. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  21027. {
  21028. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21029. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21030. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  21031. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  21032. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  21033. .Where(it => it.IsDel == 0)
  21034. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  21035. .OrderByDescending(it => it.VisitStartDate)
  21036. .ToList();
  21037. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  21038. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21039. var diids = groupInfos.Select(it => it.Id).ToList();
  21040. List<string> countrys = new List<string>();
  21041. foreach (var item in country)
  21042. {
  21043. var data = _groupRepository.FormartTeamName(item);
  21044. var dataArray = _groupRepository.GroupSplitCountry(data);
  21045. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21046. }
  21047. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  21048. List<string> areaArray = new List<string>(); //GetGroupCityLine
  21049. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  21050. foreach (var item in areaItem)
  21051. {
  21052. string areaStr = item.Value;
  21053. if (!string.IsNullOrEmpty(areaStr))
  21054. {
  21055. string[] str1 = areaStr.Split("-");
  21056. if (str1.Length > 0)
  21057. {
  21058. areaArray.AddRange(str1);
  21059. }
  21060. }
  21061. }
  21062. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  21063. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  21064. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  21065. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  21066. .ToList();
  21067. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  21068. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  21069. .Where(it => countriesIds.Contains(it.Id))
  21070. .Select(it => new { it.Id, Name = it.Name_CN })
  21071. .ToList();
  21072. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  21073. .Select(it => it.TeamName).ToList();
  21074. stopwatch.Stop();
  21075. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  21076. }
  21077. ///// <summary>
  21078. ///// 匹配op行程单
  21079. ///// Init 查询区域数据
  21080. ///// </summary>
  21081. ///// <param name="dto">团组列表请求dto</param>
  21082. ///// <returns></returns>
  21083. //[HttpPost]
  21084. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21085. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  21086. //{
  21087. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21088. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  21089. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  21090. // if (string.IsNullOrEmpty(countriesDataStr))
  21091. // {
  21092. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  21093. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  21094. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  21095. // }
  21096. // else
  21097. // {
  21098. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  21099. // }
  21100. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  21101. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  21102. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  21103. // List<dynamic> childList = new List<dynamic>();
  21104. // int parentId = dto.CountriesId;
  21105. // if (provinceData.Count > 1)
  21106. // {
  21107. // foreach (var item1 in provinceData)
  21108. // {
  21109. // List<dynamic> childList1 = new List<dynamic>();
  21110. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  21111. // foreach (var item2 in citiesData1)
  21112. // {
  21113. // List<dynamic> childList2 = new List<dynamic>();
  21114. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21115. // foreach (var item3 in countiesData1)
  21116. // {
  21117. // childList2.Add(new
  21118. // {
  21119. // id = item3.Id,
  21120. // parentId = item2.Id,
  21121. // level = "district",
  21122. // name = item3.Name_CN,
  21123. // });
  21124. // }
  21125. // childList1.Add(new
  21126. // {
  21127. // id = item2.Id,
  21128. // parentId = item1.Id,
  21129. // level = "city",
  21130. // name = item2.Name_CN,
  21131. // childList = childList2
  21132. // });
  21133. // }
  21134. // childList.Add(new
  21135. // {
  21136. // id = item1.Id,
  21137. // parentId = parentId,
  21138. // level = "province",
  21139. // name = item1.Name_CN,
  21140. // childList = childList1
  21141. // });
  21142. // }
  21143. // //城市
  21144. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  21145. // foreach (var item2 in citiesData2)
  21146. // {
  21147. // List<dynamic> childList22 = new List<dynamic>();
  21148. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21149. // foreach (var item3 in countiesData1)
  21150. // {
  21151. // childList22.Add(new
  21152. // {
  21153. // id = item3.Id,
  21154. // parentId = item2.Id,
  21155. // level = "district",
  21156. // name = item3.Name_CN,
  21157. // });
  21158. // }
  21159. // childList.Add(new
  21160. // {
  21161. // id = item2.Id,
  21162. // parentId = parentId,
  21163. // level = "city",
  21164. // name = item2.Name_CN,
  21165. // childList = childList22
  21166. // });
  21167. // }
  21168. // }
  21169. // else
  21170. // {
  21171. // foreach (var item2 in citiesData)
  21172. // {
  21173. // string cname = item2.Name_CN;
  21174. // List<dynamic> childList1 = new List<dynamic>();
  21175. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21176. // foreach (var item3 in countiesData1)
  21177. // {
  21178. // childList1.Add(new
  21179. // {
  21180. // Id = item3.Id,
  21181. // parentId = item2.Id,
  21182. // level = "district",
  21183. // name = item3.Name_CN
  21184. // });
  21185. // }
  21186. // childList.Add(new
  21187. // {
  21188. // id = item2.Id,
  21189. // parentId = parentId,
  21190. // level = "city",
  21191. // name = item2.Name_CN,
  21192. // childList = childList1
  21193. // });
  21194. // }
  21195. // }
  21196. // stopwatch.Stop();
  21197. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  21198. //}
  21199. /// <summary>
  21200. /// 匹配op行程单
  21201. /// 接团信息列表 Page
  21202. /// </summary>
  21203. /// <param name="dto">团组列表请求dto</param>
  21204. /// <returns></returns>
  21205. [HttpPost]
  21206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21207. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  21208. {
  21209. var swatch = new Stopwatch();
  21210. swatch.Start();
  21211. #region 参数验证
  21212. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21213. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21214. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21215. #region 页面操作权限验证
  21216. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21217. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  21218. #endregion
  21219. #endregion
  21220. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21221. {
  21222. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  21223. //string sqlWhere = "";
  21224. if (!string.IsNullOrEmpty(dto.Country))
  21225. {
  21226. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  21227. }
  21228. if (!string.IsNullOrEmpty(dto.Area))
  21229. {
  21230. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  21231. }
  21232. if (!string.IsNullOrEmpty(dto.TeamName))
  21233. {
  21234. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  21235. }
  21236. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  21237. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  21238. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  21239. swatch.Stop();
  21240. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  21241. }
  21242. else
  21243. {
  21244. return Ok(JsonView(false, "查询失败"));
  21245. }
  21246. }
  21247. /// <summary>
  21248. /// 匹配op行程单
  21249. /// 行程单下载
  21250. /// </summary>
  21251. /// <param name="dto">团组列表请求dto</param>
  21252. /// <returns></returns>
  21253. [HttpPost]
  21254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21255. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  21256. {
  21257. #region 参数验证
  21258. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21259. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21260. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21261. #region 页面操作权限验证
  21262. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21263. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  21264. #endregion
  21265. #endregion
  21266. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21267. {
  21268. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  21269. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  21270. }
  21271. else
  21272. {
  21273. return Ok(JsonView(false, "下载失败!"));
  21274. }
  21275. }
  21276. #endregion
  21277. #region 国家信息 数据 注释
  21278. //[HttpPost]
  21279. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  21280. //{
  21281. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  21282. // foreach (var item in dto)
  21283. // {
  21284. // infos.Add(new Grp_GroupsTaskAssignment()
  21285. // {
  21286. // DIId = item,
  21287. // CTId = 82,
  21288. // UId = 248,
  21289. // IsEnable = 1,
  21290. // CreateUserId = 233,
  21291. // CreateTime = DateTime.Now,
  21292. // IsDel = 0
  21293. // });
  21294. // infos.Add(new Grp_GroupsTaskAssignment()
  21295. // {
  21296. // DIId = item,
  21297. // CTId = 82,
  21298. // UId = 286,
  21299. // IsEnable = 1,
  21300. // CreateUserId = 233,
  21301. // CreateTime = DateTime.Now,
  21302. // IsDel = 0
  21303. // });
  21304. // }
  21305. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  21306. // return Ok("操作成功");
  21307. //}
  21308. //public class paramJsonDto
  21309. //{
  21310. // public List<CountriesInfo> str { get; set; }
  21311. //}
  21312. //[HttpPost]
  21313. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  21314. //{
  21315. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  21316. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  21317. // List<Sys_Cities> cities = new List<Sys_Cities>();
  21318. // List<Sys_Cities> districts = new List<Sys_Cities>();
  21319. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21320. // _sqlSugar.BeginTran();
  21321. // int countitiesIndex = 0;
  21322. // foreach (var item in dto.str)
  21323. // {
  21324. // dynamic data = item.c;
  21325. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  21326. // if (data != null)
  21327. // {
  21328. // countitiesIndex++;
  21329. // foreach (var item1 in data)
  21330. // {
  21331. // string cnname = item1.cn;
  21332. // string enname = item1.en;
  21333. // Sys_Cities provinceInfo = new Sys_Cities()
  21334. // {
  21335. // CountriesId = countriesId,
  21336. // Name_CN = cnname,
  21337. // Name_EN = enname,
  21338. // ParentId = 0,
  21339. // IsCapital = 1,
  21340. // CreateUserId = 208,
  21341. // CreateTime = DateTime.Now,
  21342. // IsDel = 0
  21343. // };
  21344. // if (item1.lv == "province") //省份
  21345. // {
  21346. // provinceInfo.Level = 1;
  21347. // int provinceId = 0;
  21348. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  21349. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  21350. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21351. // var data1 = item1.c;
  21352. // foreach (var item2 in data1)
  21353. // {
  21354. // if (item2.lv == "city")
  21355. // {
  21356. // string citycnname = item2.cn;
  21357. // string cityenname = item2.en;
  21358. // Sys_Cities cityInfo = new Sys_Cities()
  21359. // {
  21360. // CountriesId = countriesId,
  21361. // ParentId = provinceId,
  21362. // Level = 2,
  21363. // Name_CN = citycnname,
  21364. // Name_EN = cityenname,
  21365. // IsCapital = 1,
  21366. // CreateUserId = 208,
  21367. // CreateTime = DateTime.Now,
  21368. // IsDel = 0
  21369. // };
  21370. // if (item2.c != null)
  21371. // {
  21372. // int cityId = 0;
  21373. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  21374. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21375. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  21376. // foreach (var item3 in item2.c)
  21377. // {
  21378. // if (item3.lv == "district")
  21379. // {
  21380. // var districtInfo = new Sys_Cities()
  21381. // {
  21382. // CountriesId = countriesId,
  21383. // Name_CN = item3.cn,
  21384. // Name_EN = item3.en,
  21385. // Level = 3,
  21386. // ParentId = cityId,
  21387. // IsCapital = 1,
  21388. // CreateUserId = 208,
  21389. // CreateTime = DateTime.Now,
  21390. // IsDel = 0
  21391. // };
  21392. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21393. // //{
  21394. // districts.Add(districtInfo);
  21395. // //}
  21396. // }
  21397. // }
  21398. // }
  21399. // else
  21400. // {
  21401. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  21402. // //{
  21403. // cities.Add(cityInfo);
  21404. // //}
  21405. // }
  21406. // }
  21407. // }
  21408. // }
  21409. // else if (item1.lv == "city")//城市
  21410. // {
  21411. // provinceInfo.Level = 2;
  21412. // if (item1.c != null)
  21413. // {
  21414. // int cityId = 0;
  21415. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  21416. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21417. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21418. // foreach (var item3 in item1.c)
  21419. // {
  21420. // if (item3.lv == "district")
  21421. // {
  21422. // var districtInfo = new Sys_Cities()
  21423. // {
  21424. // CountriesId = countriesId,
  21425. // Name_CN = item3.cn,
  21426. // Name_EN = item3.en,
  21427. // Level = 3,
  21428. // ParentId = cityId,
  21429. // IsCapital = 1,
  21430. // CreateUserId = 208,
  21431. // CreateTime = DateTime.Now,
  21432. // IsDel = 0
  21433. // };
  21434. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21435. // //{
  21436. // districts.Add(districtInfo);
  21437. // //}
  21438. // }
  21439. // }
  21440. // }
  21441. // else
  21442. // {
  21443. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  21444. // //{
  21445. // cities.Add(provinceInfo);
  21446. // //}
  21447. // }
  21448. // }
  21449. // }
  21450. // }
  21451. // }
  21452. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  21453. // cities = cities.Distinct().ToList();
  21454. // districts = districts.Distinct().ToList();
  21455. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  21456. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  21457. // cities.AddRange(districts);
  21458. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  21459. // //_sqlSugar.RollbackTran();
  21460. // _sqlSugar.CommitTran();
  21461. // return Ok(JsonView(false, "操作成功!"));
  21462. //}
  21463. //[HttpPost]
  21464. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  21465. //{
  21466. // List<CountitiesInfo> infos = dto.MyProperty;
  21467. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  21468. // _sqlSugar.BeginTran();
  21469. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21470. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  21471. // foreach (var item in infos)
  21472. // {
  21473. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  21474. // if (countryInfo != null)
  21475. // {
  21476. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  21477. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  21478. // if (cityInfo1 != null)
  21479. // {
  21480. // cityInfo1.IsCapital = 0;
  21481. // cityInfos.Add(cityInfo1);
  21482. // }
  21483. // }
  21484. // }
  21485. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  21486. // .UpdateColumns(it => it.IsCapital)
  21487. // .WhereColumns(it => it.Id)
  21488. // .ExecuteCommand();
  21489. // //_sqlSugar.RollbackTran();
  21490. // _sqlSugar.CommitTran();
  21491. // return Ok(JsonView(false, "操作成功!"));
  21492. //}
  21493. //public class CounrtiesDto
  21494. //{
  21495. // public List<CountitiesInfo> MyProperty { get; set; }
  21496. //}
  21497. //public class CountitiesInfo
  21498. //{
  21499. // /// <summary>
  21500. // /// 圣约翰
  21501. // /// </summary>
  21502. // public string capital_name_chinese { get; set; }
  21503. // /// <summary>
  21504. // ///
  21505. // /// </summary>
  21506. // public string capital_name { get; set; }
  21507. // /// <summary>
  21508. // ///
  21509. // /// </summary>
  21510. // public string country_type { get; set; }
  21511. // /// <summary>
  21512. // /// 安提瓜和巴布达
  21513. // /// </summary>
  21514. // public string country_name_chinese { get; set; }
  21515. // /// <summary>
  21516. // /// 安提瓜和巴布达
  21517. // /// </summary>
  21518. // public string country_name_chinese_short { get; set; }
  21519. // /// <summary>
  21520. // /// 安提瓜和巴布达
  21521. // /// </summary>
  21522. // public string country_name_chinese_UN { get; set; }
  21523. // /// <summary>
  21524. // ///
  21525. // /// </summary>
  21526. // public string country_name_english_abbreviation { get; set; }
  21527. // /// <summary>
  21528. // ///
  21529. // /// </summary>
  21530. // public string country_name_english_formal { get; set; }
  21531. // /// <summary>
  21532. // ///
  21533. // /// </summary>
  21534. // public string country_name_english_UN { get; set; }
  21535. // /// <summary>
  21536. // ///
  21537. // /// </summary>
  21538. // public string continent_name { get; set; }
  21539. // /// <summary>
  21540. // ///
  21541. // /// </summary>
  21542. // public string subregion_name { get; set; }
  21543. // /// <summary>
  21544. // ///
  21545. // /// </summary>
  21546. // public string country_code2 { get; set; }
  21547. // /// <summary>
  21548. // ///
  21549. // /// </summary>
  21550. // public string country_code3 { get; set; }
  21551. // /// <summary>
  21552. // ///
  21553. // /// </summary>
  21554. // public string phone_code { get; set; }
  21555. //}
  21556. //public class CountriesInfo : BasicInfo
  21557. //{
  21558. // public List<CitiesInfo> c { get; set; }
  21559. //}
  21560. //public class CitiesInfo : BasicInfo
  21561. //{
  21562. // public List<AreaInfo> c { get; set; }
  21563. //}
  21564. //public class AreaInfo : BasicInfo
  21565. //{
  21566. // public List<AreaInfo> c { get; set; }
  21567. //}
  21568. //public class BasicInfo
  21569. //{
  21570. // public string code { get; set; }
  21571. // public string cn { get; set; }
  21572. // public string lv { get; set; }
  21573. // public string en { get; set; }
  21574. //}
  21575. #endregion
  21576. #region 查看邀请方
  21577. /// <summary>
  21578. /// 查看邀请方
  21579. /// 邀请方信息 Init
  21580. /// </summary>
  21581. /// <param name="dto"></param>
  21582. /// <returns></returns>
  21583. [HttpPost]
  21584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21585. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  21586. {
  21587. string sqlWhere = string.Empty;
  21588. if (!string.IsNullOrEmpty(dto.Search))
  21589. {
  21590. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  21591. }
  21592. string sql = string.Format($@"Select
  21593. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  21594. Id,
  21595. UnitName
  21596. From Res_InvitationOfficialActivityData
  21597. Where IsDel = 0
  21598. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  21599. RefAsync<int> total = 0;
  21600. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21601. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  21602. }
  21603. /// <summary>
  21604. /// 查看邀请方
  21605. /// 国家信息 Init
  21606. /// </summary>
  21607. /// <param name="dto"></param>
  21608. /// <returns></returns>
  21609. [HttpPost]
  21610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21611. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  21612. {
  21613. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  21614. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21615. var diids = groupInfos.Select(it => it.Id).ToList();
  21616. List<string> countrys = new List<string>();
  21617. foreach (var item in country)
  21618. {
  21619. var data = _groupRepository.FormartTeamName(item);
  21620. var dataArray = _groupRepository.GroupSplitCountry(data);
  21621. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21622. }
  21623. countrys = countrys.Distinct().ToList();
  21624. for (int i = 0; i < countrys.Count; i++)
  21625. {
  21626. string item = countrys[i];
  21627. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  21628. {
  21629. countrys.Remove(item);
  21630. i--;
  21631. }
  21632. }
  21633. RefAsync<int> total = 0;
  21634. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  21635. .Where(it => countrys.Contains(it.Name_CN))
  21636. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21637. .Select(it => new { id = it.Id, name = it.Name_CN })
  21638. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21639. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21640. }
  21641. /// <summary>
  21642. /// 查看邀请方
  21643. /// 城市信息 Init
  21644. /// </summary>
  21645. /// <param name="dto"></param>
  21646. /// <returns></returns>
  21647. [HttpPost]
  21648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21649. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  21650. {
  21651. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  21652. RefAsync<int> total = 0;
  21653. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  21654. .Where(it => it.CountriesId == dto.CountiesId)
  21655. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21656. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  21657. .Select(it => new { id = it.Id, name = it.Name_CN })
  21658. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21659. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21660. }
  21661. /// <summary>
  21662. /// 查看邀请方
  21663. /// 团组名称 Init
  21664. /// </summary>
  21665. /// <param name="dto"></param>
  21666. /// <returns></returns>
  21667. [HttpPost]
  21668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21669. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  21670. {
  21671. var watch = new Stopwatch();
  21672. watch.Start();
  21673. RefAsync<int> total = 0;
  21674. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  21675. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  21676. .Where((oa, di) => oa.IsDel == 0)
  21677. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  21678. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  21679. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  21680. .Distinct()
  21681. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21682. watch.Stop();
  21683. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  21684. }
  21685. /// <summary>
  21686. /// 查看邀请方
  21687. /// 团组 & 邀请方信息
  21688. /// </summary>
  21689. /// <param name="dto"></param>
  21690. /// <returns></returns>
  21691. [HttpPost]
  21692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21693. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  21694. {
  21695. var watch = new Stopwatch();
  21696. watch.Start();
  21697. RefAsync<int> total = 0;
  21698. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  21699. .AS("Grp_DelegationInfo")
  21700. .Includes(x => x.InvitingInfos)
  21701. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  21702. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  21703. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  21704. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  21705. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  21706. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  21707. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21708. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  21709. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  21710. infos.ForEach(x =>
  21711. {
  21712. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  21713. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  21714. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  21715. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  21716. });
  21717. watch.Stop();
  21718. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  21719. }
  21720. #endregion
  21721. #region 报批行程
  21722. /// <summary>
  21723. /// 报批行程初始化
  21724. /// </summary>
  21725. /// <param name="dto"></param>
  21726. /// <returns></returns>
  21727. [HttpPost]
  21728. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  21729. {
  21730. const int chiNumber = 5;
  21731. var jw = JsonView(false);
  21732. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  21733. var group = groupList.First();
  21734. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  21735. group = groupList.First(x => x.Id == diid);
  21736. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21737. .Where(x => x.DiId == diid && x.IsDel == 0)
  21738. .ToArray();
  21739. var count = 1;
  21740. foreach (var item in blackCodeList)
  21741. {
  21742. if (string.IsNullOrWhiteSpace(item.Title))
  21743. {
  21744. item.Title = "未设置名称数据" + count;
  21745. }
  21746. count++;
  21747. }
  21748. ;
  21749. if (group == null)
  21750. {
  21751. jw.Msg = "暂无团组!";
  21752. return Ok(jw);
  21753. }
  21754. var data = new
  21755. {
  21756. groupList = groupList.Select(x => new
  21757. {
  21758. x.TeamName,
  21759. x.Id
  21760. }),
  21761. content = new ArrayList(),
  21762. groupInfo = new
  21763. {
  21764. group.VisitDays,
  21765. group.TourCode,
  21766. group.VisitPNumber,
  21767. group.TeamName,
  21768. group.Id,
  21769. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  21770. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  21771. group.ClientUnit
  21772. },
  21773. blackCodeList = blackCodeList.Select(x => new
  21774. {
  21775. x.Title,
  21776. x.Id
  21777. }),
  21778. FileTempList = new ArrayList()
  21779. {
  21780. new { Index = 1,FileName = "旧模板" },
  21781. new { Index = 2,FileName = "省外办" },
  21782. new { Index = 3,FileName = "市外办" },
  21783. }
  21784. };
  21785. var resultArr = new ArrayList();
  21786. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  21787. #region 默认不生成行程
  21788. //if (content.Count == 0)
  21789. //{
  21790. // var stay = "-";
  21791. // var cityPath = "-";
  21792. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21793. // .Where(x => x.DiId == diid && x.IsDel == 0)
  21794. // .ToList();
  21795. // //添加城市路径以及住宿地
  21796. // //黑屏代码数据
  21797. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  21798. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21799. // {
  21800. // jw = JsonView(true, "黑屏代码有误!", data);
  21801. // return Ok(jw);
  21802. // }
  21803. // data = data with
  21804. // {
  21805. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  21806. // {
  21807. // x.Title,
  21808. // x.Id,
  21809. // }).ToArray())
  21810. // };
  21811. // foreach (DataRow row in dtBlack.Rows)
  21812. // {
  21813. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21814. // {
  21815. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  21816. // return Ok(jw);
  21817. // }
  21818. // }
  21819. // //黑屏代码获取时间区间
  21820. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21821. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21822. // _sqlSugar.BeginTran();
  21823. // for (int i = 0; i < timeArr.Count; i++)
  21824. // {
  21825. // stay = "-";
  21826. // cityPath = "-";
  21827. // DateTime NewData = DateTime.Parse(timeArr[i]);
  21828. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21829. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21830. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21831. // if (tbSelect.Length > 0)
  21832. // {
  21833. // List<string> threeCodeStr = new List<string>();
  21834. // foreach (var item in tbSelect)
  21835. // {
  21836. // var threeCode = item["Three"].ToString() ?? "";
  21837. // if (threeCode.Length == 6)
  21838. // {
  21839. // var start = threeCode.Substring(0, 3);
  21840. // var end = threeCode.Substring(3, 3);
  21841. // if (threeCodeStr.Count == 0)
  21842. // {
  21843. // threeCodeStr.Add(start);
  21844. // threeCodeStr.Add(end);
  21845. // }
  21846. // else
  21847. // {
  21848. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21849. // {
  21850. // threeCodeStr.Add(end);
  21851. // }
  21852. // else
  21853. // {
  21854. // threeCodeStr.Add(start);
  21855. // threeCodeStr.Add(end);
  21856. // }
  21857. // }
  21858. // }
  21859. // }
  21860. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21861. // var last = threeCodeStr.Last();
  21862. // foreach (var item in threeCodeStr)
  21863. // {
  21864. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21865. // if (item.Equals(last))
  21866. // {
  21867. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21868. // }
  21869. // }
  21870. // cityPath = cityPath.Trim('-');
  21871. // }
  21872. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21873. // appro.Diid = diid ?? -1;
  21874. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21875. // appro.Id = thisId;
  21876. // appro.CreateUserId = dto.UserId;
  21877. // appro.CreateTime = DateTime.Now;
  21878. // content.Add(appro);
  21879. // }
  21880. // _sqlSugar.CommitTran();
  21881. //}
  21882. #endregion
  21883. foreach (var x in content)
  21884. {
  21885. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  21886. if (chiList.Count < chiNumber)
  21887. {
  21888. for (int i = chiList.Count; i < chiNumber; i++)
  21889. {
  21890. chiList.Add(new Grp_ApprovalTravelDetails());
  21891. }
  21892. }
  21893. resultArr.Add(new
  21894. {
  21895. x.Id,
  21896. x.Date,
  21897. x.Diid,
  21898. chiList = chiList.Select(x1 => new
  21899. {
  21900. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21901. x1.Details,
  21902. x1.ParentId,
  21903. x1.Id
  21904. })
  21905. });
  21906. }
  21907. data = data with
  21908. {
  21909. content = resultArr,
  21910. };
  21911. jw = JsonView(true, "获取成功!", data);
  21912. return Ok(jw);
  21913. }
  21914. /// <summary>
  21915. /// 报批行程删除
  21916. /// </summary>
  21917. /// <param name="dto"></param>
  21918. /// <returns></returns>
  21919. [HttpPost]
  21920. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  21921. {
  21922. var jw = JsonView(false);
  21923. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21924. if (group == null)
  21925. {
  21926. jw.Msg = "团组参数有误!";
  21927. return Ok(jw);
  21928. }
  21929. try
  21930. {
  21931. _sqlSugar.BeginTran();
  21932. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  21933. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  21934. {
  21935. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21936. DeleteUserId = dto.uesrId,
  21937. IsDel = 1
  21938. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  21939. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  21940. {
  21941. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21942. DeleteUserId = dto.uesrId,
  21943. IsDel = 1
  21944. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  21945. _sqlSugar.CommitTran();
  21946. jw = JsonView(true, "删除成功");
  21947. }
  21948. catch (Exception ex)
  21949. {
  21950. jw = JsonView(false, ex.Message);
  21951. }
  21952. return Ok(jw);
  21953. }
  21954. /// <summary>
  21955. /// 报批行程保存
  21956. /// </summary>
  21957. /// <param name="dto"></param>
  21958. /// <returns></returns>
  21959. [HttpPost]
  21960. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  21961. {
  21962. var jw = JsonView(false);
  21963. var Find = dto.Arr.Find(x => x.id == 0);
  21964. if (Find != null)
  21965. {
  21966. jw.Msg = "生成的ID为0!";
  21967. return Ok(jw);
  21968. }
  21969. foreach (var item in dto.Arr)
  21970. {
  21971. foreach (var chi in item.chiList)
  21972. {
  21973. if (chi.parentId == 0)
  21974. {
  21975. chi.parentId = item.id;
  21976. }
  21977. }
  21978. }
  21979. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  21980. _sqlSugar.BeginTran();
  21981. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  21982. {
  21983. var parentIds = dto.Arr.Select(x => x.id).ToList();
  21984. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  21985. {
  21986. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21987. DeleteUserId = dto.UserId,
  21988. IsDel = 1
  21989. }).ExecuteCommand();
  21990. }
  21991. try
  21992. {
  21993. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  21994. {
  21995. CreateTime = DateTime.Now,
  21996. CreateUserId = dto.UserId,
  21997. Details = x.details,
  21998. ParentId = x.parentId,
  21999. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22000. Remark = "",
  22001. IsDel = 0
  22002. }).ToList()).ExecuteCommand();
  22003. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  22004. {
  22005. Id = x.id,
  22006. Details = x.details,
  22007. ParentId = x.parentId,
  22008. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22009. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  22010. {
  22011. Details = x.Details,
  22012. ParentId = x.ParentId,
  22013. Time = x.Time
  22014. }).ExecuteCommand();
  22015. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  22016. {
  22017. Id = x.id,
  22018. Date = x.date,
  22019. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  22020. {
  22021. Date = x.Date
  22022. }).ExecuteCommand();
  22023. _sqlSugar.CommitTran();
  22024. jw = JsonView(true, "保存成功!");
  22025. }
  22026. catch (Exception ex)
  22027. {
  22028. _sqlSugar.RollbackTran();
  22029. jw = JsonView(false, "保存失败!" + ex.Message);
  22030. }
  22031. return Ok(jw);
  22032. }
  22033. /// <summary>
  22034. /// 报批行程生成
  22035. /// </summary>
  22036. /// <param name="dto"></param>
  22037. /// <returns></returns>
  22038. [HttpPost]
  22039. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  22040. {
  22041. var jw = JsonView(false);
  22042. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22043. if (group == null)
  22044. {
  22045. jw.Msg = "暂无该团组!";
  22046. return Ok(jw);
  22047. }
  22048. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  22049. //黑屏代码数据
  22050. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  22051. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22052. {
  22053. jw.Msg = "黑屏代码有误!";
  22054. return Ok(jw);
  22055. }
  22056. foreach (DataRow row in dtBlack.Rows)
  22057. {
  22058. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22059. {
  22060. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  22061. return Ok(jw);
  22062. }
  22063. }
  22064. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  22065. var resultArr = new ArrayList();
  22066. //if (officialActivitiesArr.Count == 0)
  22067. //{
  22068. // jw.Msg = "暂无公务出访信息!";
  22069. // return Ok(jw);
  22070. //}
  22071. try
  22072. {
  22073. _sqlSugar.BeginTran();
  22074. DeleteApprovalJourney(new
  22075. Domain.Dtos.Groups.DeleteApprovalJourney
  22076. {
  22077. Diid = dto.Diid,
  22078. uesrId = dto.Userid
  22079. });
  22080. var stay = "-";
  22081. var cityPath = "-";
  22082. var arriveCountry = string.Empty;
  22083. //添加城市路径以及住宿地
  22084. //黑屏代码获取时间区间
  22085. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22086. var empty = "【未收入该三字码!请机票同事录入】";
  22087. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22088. #region 配置公务活动时间
  22089. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  22090. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  22091. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  22092. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  22093. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  22094. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22095. {
  22096. 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" }),
  22097. 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"}),
  22098. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22099. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  22100. };
  22101. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22102. {
  22103. 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" }),
  22104. 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"}),
  22105. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22106. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  22107. };
  22108. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  22109. {
  22110. 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" }),
  22111. 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"}),
  22112. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  22113. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  22114. };
  22115. #endregion
  22116. var nextDayNum = 0;
  22117. for (int i = 0; i < timeArr.Count; i++)
  22118. {
  22119. stay = "-";
  22120. cityPath = "-";
  22121. var chiarr = new List<Grp_ApprovalTravelDetails>();
  22122. DateTime NewData = DateTime.Parse(timeArr[i]);
  22123. //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();
  22124. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22125. if (nextDayNum > 0)
  22126. {
  22127. nextDayNum--;
  22128. }
  22129. if (tbSelect.Length > 0)
  22130. {
  22131. List<string> threeCodeStr = new List<string>();
  22132. bool isTrade = false;
  22133. string trip = string.Empty;
  22134. foreach (var item in tbSelect)
  22135. {
  22136. if (nextDayNum == 0)
  22137. {
  22138. nextDayNum = Convert.ToInt32(item["Sign"]);
  22139. }
  22140. var airStartTime = item["StartTime"].ToString() ?? "0000";
  22141. var airEndTime = item["EndTime"].ToString() ?? "0000";
  22142. var takeOffTime = DateTime.Parse(timeArr[i]);
  22143. var fallToTime = DateTime.Parse(timeArr[i]);
  22144. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  22145. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  22146. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  22147. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  22148. if (nextDayNum > 0)
  22149. {
  22150. fallToTime = fallToTime.AddDays(nextDayNum);
  22151. }
  22152. trip = string.Empty;
  22153. var start = string.Empty;
  22154. var end = string.Empty;
  22155. var threeCode = item["Three"].ToString() ?? "";
  22156. if (threeCode.Length == 6)
  22157. {
  22158. start = threeCode.Substring(0, 3);
  22159. end = threeCode.Substring(3, 3);
  22160. if (threeCodeStr.Count == 0)
  22161. {
  22162. threeCodeStr.Add(start);
  22163. threeCodeStr.Add(end);
  22164. }
  22165. else
  22166. {
  22167. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22168. {
  22169. threeCodeStr.Add(end);
  22170. }
  22171. else
  22172. {
  22173. threeCodeStr.Add(start);
  22174. threeCodeStr.Add(end);
  22175. }
  22176. }
  22177. }
  22178. //处理机票信息
  22179. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  22180. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  22181. if (start_Object == null)
  22182. {
  22183. start_Object = new Res_ThreeCode()
  22184. {
  22185. AirPort = empty,
  22186. AirPort_En = empty,
  22187. City = empty,
  22188. Country = empty,
  22189. Four = empty,
  22190. Three = empty,
  22191. };
  22192. }
  22193. if (end_Object == null)
  22194. {
  22195. end_Object = new Res_ThreeCode()
  22196. {
  22197. AirPort = empty,
  22198. AirPort_En = empty,
  22199. City = empty,
  22200. Country = empty,
  22201. Four = empty,
  22202. Three = empty,
  22203. };
  22204. }
  22205. //机型判断
  22206. string airModel = item["AirModel"].ToString();
  22207. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  22208. string flightTime = item["FlightTime"].ToString();
  22209. flightTime = ParseBlackTime(flightTime);
  22210. //航班号
  22211. string flightcode = item["Fliagtcode"].ToString();
  22212. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  22213. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  22214. if (aircompany == null)
  22215. {
  22216. aircompany = new Res_AirCompany
  22217. {
  22218. CnName = hsEmpty,
  22219. EnName = hsEmpty,
  22220. ShortCode = hsEmpty,
  22221. };
  22222. }
  22223. //航班前公务安排
  22224. if (tbSelect.First().Equals(item) && i != 0)
  22225. {
  22226. foreach (var takeoff in takeoffTimes)
  22227. {
  22228. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  22229. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  22230. {
  22231. foreach (var addTime in takeoff.Item2)
  22232. {
  22233. chiarr.Add(new Grp_ApprovalTravelDetails
  22234. {
  22235. Time = addTime,
  22236. CreateTime = DateTime.Now,
  22237. CreateUserId = dto.Userid,
  22238. ParentId = 0,
  22239. Details = "公务活动"
  22240. });
  22241. }
  22242. break;
  22243. }
  22244. }
  22245. }
  22246. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  22247. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  22248. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  22249. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  22250. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  22251. if (isTrade)
  22252. {
  22253. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  22254. trip += "(转机不出机场)。";
  22255. }
  22256. //else
  22257. //{
  22258. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  22259. //}
  22260. chiarr.Add(new Grp_ApprovalTravelDetails
  22261. {
  22262. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  22263. CreateTime = DateTime.Now,
  22264. CreateUserId = dto.Userid,
  22265. ParentId = 0,
  22266. Details = trip
  22267. });
  22268. //最后一条到达的时间安排公务
  22269. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  22270. {
  22271. bool isCheckCountry = false;
  22272. if (end_Object.Country != arriveCountry)
  22273. {
  22274. arriveCountry = end_Object.Country;
  22275. isCheckCountry = true;
  22276. }
  22277. if (nextDayNum == 0)
  22278. {
  22279. //需要入境的情况
  22280. if (isCheckCountry)
  22281. {
  22282. foreach (var fallTime in fallTimesCheckCountry)
  22283. {
  22284. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22285. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22286. {
  22287. foreach (var addTime in fallTime.Item2)
  22288. {
  22289. chiarr.Add(new Grp_ApprovalTravelDetails
  22290. {
  22291. Time = addTime,
  22292. CreateTime = DateTime.Now,
  22293. CreateUserId = dto.Userid,
  22294. ParentId = 0,
  22295. Details = "公务活动"
  22296. });
  22297. }
  22298. break;
  22299. }
  22300. }
  22301. }
  22302. else
  22303. {
  22304. foreach (var fallTime in fallTimesNotCheckCountry)
  22305. {
  22306. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22307. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22308. {
  22309. foreach (var addTime in fallTime.Item2)
  22310. {
  22311. chiarr.Add(new Grp_ApprovalTravelDetails
  22312. {
  22313. Time = addTime,
  22314. CreateTime = DateTime.Now,
  22315. CreateUserId = dto.Userid,
  22316. ParentId = 0,
  22317. Details = "公务活动"
  22318. });
  22319. }
  22320. break;
  22321. }
  22322. }
  22323. }
  22324. }
  22325. }
  22326. }
  22327. //添加乘车语句
  22328. //chiarr.Add(new Grp_ApprovalTravelDetails
  22329. //{
  22330. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  22331. // CreateTime = DateTime.Now,
  22332. // CreateUserId = dto.Userid,
  22333. // ParentId = 0,
  22334. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  22335. //});
  22336. //if (i != timeArr.Count - 1)
  22337. //{
  22338. // fallToTime = fallToTime.AddHours(2.5);
  22339. // foreach (var item in Times)
  22340. // {
  22341. // //排列公务时间
  22342. // if (fallToTime.Hour < item.Item1)
  22343. // {
  22344. // chiarr.Add(new Grp_ApprovalTravelDetails
  22345. // {
  22346. // Time = $"{item.Item2} - {item.Item3}",
  22347. // CreateTime = DateTime.Now,
  22348. // CreateUserId = dto.Userid,
  22349. // ParentId = 0,
  22350. // Details = "公务活动"
  22351. // });
  22352. // }
  22353. // }
  22354. //}
  22355. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  22356. var last = threeCodeStr.Last();
  22357. foreach (var item in threeCodeStr)
  22358. {
  22359. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  22360. if (item.Equals(last))
  22361. {
  22362. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  22363. }
  22364. }
  22365. cityPath = cityPath.Trim('-');
  22366. }
  22367. else
  22368. {
  22369. foreach (var item in Times)
  22370. {
  22371. chiarr.Add(new Grp_ApprovalTravelDetails
  22372. {
  22373. Time = $"{item.Item2} - {item.Item3}",
  22374. CreateTime = DateTime.Now,
  22375. CreateUserId = dto.Userid,
  22376. ParentId = 0,
  22377. Details = "公务活动"
  22378. });
  22379. }
  22380. }
  22381. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  22382. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  22383. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  22384. appro.Diid = dto.Diid;
  22385. appro.CreateUserId = dto.Userid;
  22386. appro.CreateTime = DateTime.Now;
  22387. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  22388. appro.Id = thisId;
  22389. //foreach (var item in gwinfo)
  22390. //{
  22391. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  22392. // chi.Details = "拜访" + item.Client;
  22393. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  22394. // {
  22395. // chi.Details += "," + item.ReqSample;
  22396. // }
  22397. // chi.ParentId = thisId;
  22398. // chi.Time = item.Time;
  22399. // chiarr.Add(chi);
  22400. //}
  22401. if (chiarr.Count < 6)
  22402. {
  22403. for (int j = chiarr.Count; j < 6; j++)
  22404. {
  22405. chiarr.Add(new
  22406. Grp_ApprovalTravelDetails());
  22407. }
  22408. }
  22409. resultArr.Add(new
  22410. {
  22411. appro.Id,
  22412. appro.Date,
  22413. appro.Diid,
  22414. chiList = chiarr.Select(x1 => new
  22415. {
  22416. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22417. x1.Details,
  22418. x1.ParentId,
  22419. x1.Id
  22420. })
  22421. });
  22422. }
  22423. _sqlSugar.CommitTran();
  22424. jw = JsonView(true, "生成成功!", resultArr);
  22425. }
  22426. catch (Exception ex)
  22427. {
  22428. jw.Code = 400;
  22429. jw.Msg = "生成失败!" + ex.Message;
  22430. }
  22431. return Ok(jw);
  22432. }
  22433. /// <summary>
  22434. /// 报批行程word导出
  22435. /// </summary>
  22436. /// <param name="dto"></param>
  22437. /// <returns></returns>
  22438. [HttpPost]
  22439. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  22440. {
  22441. var jw = JsonView(false);
  22442. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22443. if (group == null)
  22444. {
  22445. jw.Msg = "暂无该团组!";
  22446. return Ok(jw);
  22447. }
  22448. //模板路径
  22449. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  22450. var fileName = string.Empty;
  22451. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  22452. bool bold = false;
  22453. if (dto.FileIndex == 1)
  22454. {
  22455. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  22456. }
  22457. else if (dto.FileIndex == 2)
  22458. {
  22459. fileName = "省外办-报批.docx";
  22460. bold = false;
  22461. titleFont = "方正黑体简体";
  22462. timeFont = "Times New Roman";
  22463. contentFont = "方正仿宋_GBK";
  22464. }
  22465. else if (dto.FileIndex == 3)
  22466. {
  22467. fileName = "市外办-报批.docx";
  22468. titleFont = "方正黑体简体";
  22469. timeFont = "Times New Roman";
  22470. contentFont = "方正仿宋简体";
  22471. }
  22472. tempPath = tempPath + fileName;
  22473. //载入模板
  22474. Document doc = new Document(tempPath);
  22475. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  22476. //获取所填表格的序数
  22477. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  22478. Aspose.Words.Tables.Row titleRowClone = null;
  22479. Aspose.Words.Tables.Row CenterRowClone = null;
  22480. int index = 0;
  22481. int indexChi = 0;
  22482. int SetIndex = 0;
  22483. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  22484. //获取数据,放到datatable
  22485. foreach (var item in ApprovalTravelArr)
  22486. {
  22487. if (index > 0)
  22488. {
  22489. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  22490. tableOne.AppendChild(titleRowClone);
  22491. }
  22492. var textTime = item.Date;
  22493. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  22494. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  22495. SetIndex++;
  22496. if (ChiRep.Count > 0)
  22497. {
  22498. foreach (var itemChi in ChiRep)
  22499. {
  22500. var txtTime = itemChi.Time;
  22501. var txtDetail = itemChi.Details;
  22502. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  22503. {
  22504. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  22505. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22506. //indexChi++;
  22507. //SetIndex++;
  22508. break;
  22509. }
  22510. if (indexChi > 0)
  22511. {
  22512. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22513. tableOne.AppendChild(CenterRowClone);
  22514. }
  22515. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  22516. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  22517. indexChi++;
  22518. SetIndex++;
  22519. }
  22520. }
  22521. //else
  22522. //{
  22523. // if (indexChi > 0)
  22524. // {
  22525. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22526. // tableOne.AppendChild(CenterRowClone);
  22527. // }
  22528. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  22529. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22530. // indexChi++;
  22531. // SetIndex++;
  22532. //}
  22533. index++;
  22534. }
  22535. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  22536. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22537. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22538. jw.Code = 200;
  22539. jw.Msg = "";
  22540. return Ok(jw);
  22541. }
  22542. private string ParseBlackTime(string time)
  22543. {
  22544. // 匹配可能只有分钟的情况
  22545. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  22546. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  22547. if (match.Success)
  22548. {
  22549. string hours = match.Groups[1].Value;
  22550. string minutes = match.Groups[2].Value;
  22551. // 如果小时部分为空,则只显示分钟
  22552. if (string.IsNullOrEmpty(hours))
  22553. {
  22554. return $"{minutes}分钟";
  22555. }
  22556. // 如果分钟部分为空,则只显示小时
  22557. else if (string.IsNullOrEmpty(minutes))
  22558. {
  22559. return $"{hours}小时";
  22560. }
  22561. // 否则显示完整格式
  22562. else
  22563. {
  22564. return $"{hours}小时{minutes}分钟";
  22565. }
  22566. }
  22567. else
  22568. {
  22569. return "未知时长";
  22570. }
  22571. }
  22572. private string intToString(int numberVal)
  22573. {
  22574. string numberval = numberVal.ToString();
  22575. Dictionary<char, string> Number = new Dictionary<char, string>();
  22576. Number.Add('1', "一");
  22577. Number.Add('2', "二");
  22578. Number.Add('3', "三");
  22579. Number.Add('4', "四");
  22580. Number.Add('5', "五");
  22581. Number.Add('6', "六");
  22582. Number.Add('7', "七");
  22583. Number.Add('8', "八");
  22584. Number.Add('9', "九");
  22585. string stringNumberVal = string.Empty;
  22586. for (int i = 0; i < numberval.Length; i++)
  22587. {
  22588. if (i == 0)
  22589. {
  22590. stringNumberVal += Number[numberval[i]];
  22591. }
  22592. else if (i >= 1)
  22593. {
  22594. if (numberval[i] == '0')
  22595. {
  22596. stringNumberVal = "十";
  22597. }
  22598. else
  22599. {
  22600. stringNumberVal += "十" + Number[numberval[i]];
  22601. }
  22602. }
  22603. }
  22604. return stringNumberVal;
  22605. }
  22606. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  22607. {
  22608. //获取table中的某个单元格,从0开始
  22609. Cell lshCell = table.Rows[rows].Cells[cells];
  22610. //将单元格中段落移除
  22611. foreach (Paragraph item in lshCell.Paragraphs)
  22612. {
  22613. lshCell.Paragraphs.Remove(item);
  22614. }
  22615. if (val.Contains("\r\n"))
  22616. {
  22617. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  22618. foreach (var item in spArr)
  22619. {
  22620. //新建一个段落
  22621. Paragraph p = new Paragraph(doc);
  22622. var r = new Run(doc, item);
  22623. //设置字体
  22624. if (!string.IsNullOrEmpty(font))
  22625. {
  22626. r.Font.Name = font;
  22627. }
  22628. r.Font.Bold = bold;
  22629. //把设置的值赋给之前新建的段落
  22630. p.AppendChild(r);
  22631. //将此段落加到单元格内
  22632. lshCell.AppendChild(p);
  22633. }
  22634. }
  22635. else
  22636. {
  22637. //新建一个段落
  22638. Paragraph p = new Paragraph(doc);
  22639. var r = new Run(doc, val);
  22640. //设置字体
  22641. if (!string.IsNullOrEmpty(font))
  22642. {
  22643. r.Font.Name = font;
  22644. }
  22645. r.Font.Bold = bold;
  22646. //把设置的值赋给之前新建的段落
  22647. p.AppendChild(r);
  22648. //将此段落加到单元格内
  22649. lshCell.AppendChild(p);
  22650. }
  22651. }
  22652. /// <summary>
  22653. /// 报批行程AI续写
  22654. /// </summary>
  22655. /// <returns></returns>
  22656. [HttpPost]
  22657. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  22658. {
  22659. var jw = JsonView(false);
  22660. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  22661. {
  22662. jw.Msg = "参数有误!";
  22663. return Ok(jw);
  22664. }
  22665. KiMiApiClient kiMi = new KiMiApiClient();
  22666. List<SeedMessages> messages = new List<SeedMessages>() {
  22667. new SeedMessages
  22668. {
  22669. Role = KimiRole.system,
  22670. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  22671. },
  22672. new SeedMessages
  22673. {
  22674. Role = KimiRole.user,
  22675. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  22676. }
  22677. };
  22678. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  22679. string data = kimi_result.Choices[0]?.Message.Content;
  22680. if (string.IsNullOrWhiteSpace(data))
  22681. {
  22682. jw.Data = "Ai续写失败!";
  22683. }
  22684. else
  22685. {
  22686. jw = JsonView(true, "success!", data);
  22687. }
  22688. return Ok(jw);
  22689. }
  22690. #endregion
  22691. #region 团组接待意见调查
  22692. /// <summary>
  22693. /// 团组接待意见调查 - 信息管理
  22694. /// 基础数据(团组)
  22695. /// </summary>
  22696. /// <returns></returns>
  22697. [HttpGet]
  22698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22699. public async Task<IActionResult> OpinionaireInit()
  22700. {
  22701. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  22702. .Select(x => new
  22703. {
  22704. x.Id,
  22705. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  22706. })
  22707. .OrderByDescending(x => x.Id)
  22708. .ToListAsync();
  22709. return Ok(JsonView(groupData, groupData.Count));
  22710. }
  22711. /// <summary>
  22712. /// 团组接待意见调查 - 信息管理
  22713. /// 列表
  22714. /// </summary>
  22715. /// <param name="groupId"></param>
  22716. /// <returns></returns>
  22717. [HttpGet("{groupId}")]
  22718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22719. public async Task<IActionResult> OpinionaireManageList(int groupId)
  22720. {
  22721. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22722. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  22723. .Select(x => new
  22724. {
  22725. x.Id,
  22726. x.TourGuideName,
  22727. x.CityName,
  22728. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  22729. x.CreateTime
  22730. })
  22731. .OrderBy(x => x.Id)
  22732. .ToListAsync();
  22733. return Ok(JsonView(data));
  22734. }
  22735. /// <summary>
  22736. /// 团组接待意见调查 - 信息管理
  22737. /// 保存
  22738. /// </summary>
  22739. /// <param name="dto"></param>
  22740. /// <returns></returns>
  22741. [HttpPost]
  22742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22743. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  22744. {
  22745. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22746. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22747. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22748. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  22749. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  22750. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  22751. _opinionaireRep.BeginTran();
  22752. if (addData != null && addData.Count > 0)
  22753. {
  22754. foreach (var item in addData)
  22755. {
  22756. item.CreateUserId = currUserInfo.UserId;
  22757. item.DiId = dto.DiId;
  22758. }
  22759. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  22760. }
  22761. if (updData != null && updData.Count > 0)
  22762. {
  22763. var upd = await _opinionaireRep._sqlSugar
  22764. .Updateable(updData)
  22765. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  22766. .WhereColumns(x => new { x.Id })
  22767. .ExecuteCommandAsync();
  22768. }
  22769. _opinionaireRep.CommitTran();
  22770. return Ok(JsonView("操作成功!"));
  22771. }
  22772. /// <summary>
  22773. /// 团组接待意见调查 - 信息管理
  22774. /// 删除
  22775. /// </summary>
  22776. /// <param name="id"></param>
  22777. /// <returns></returns>
  22778. [HttpDelete("{id}")]
  22779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22780. public async Task<IActionResult> OpinionaireManageDel(int id)
  22781. {
  22782. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22783. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22784. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  22785. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  22786. if (!del) return Ok(JsonView("操作失败!"));
  22787. return Ok(JsonView("操作成功!"));
  22788. }
  22789. /// <summary>
  22790. /// 团组接待意见调查 - 用户
  22791. /// 列表
  22792. /// </summary>
  22793. /// <param name="diId"></param>
  22794. /// <returns></returns>
  22795. [HttpGet("{diId}")]
  22796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22797. public async Task<IActionResult> OpinionaireUserList(int diId)
  22798. {
  22799. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22800. var sql = string.Format(@"
  22801. SELECT
  22802. o.Id,
  22803. o.DiId,
  22804. di.TeamName AS 'GroupName',
  22805. di.VisitPNumber AS 'PeopleNumber',
  22806. di.ClientName AS 'LeadGroup',
  22807. di.VisitCountry AS 'Travel',
  22808. di.VisitDays AS 'Days',
  22809. o.CityName,
  22810. o.TourGuideName,
  22811. o.Catering,
  22812. o.CateringReason,
  22813. o.Stay,
  22814. o.StayReason,
  22815. o.[Route],
  22816. o.RouteReason,
  22817. o.OfficialActivity,
  22818. o.OfficialActivityReason,
  22819. o.TourGuide,
  22820. o.TourGuideReason,
  22821. o.[Translate],
  22822. o.TranslateReason,
  22823. o.Trip,
  22824. o.TripReason,
  22825. o.ESFileName,
  22826. o.SignatureDate,
  22827. o.Remark
  22828. FROM
  22829. Grp_Opinionaire o
  22830. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  22831. WHERE
  22832. o.IsDel = 0
  22833. AND o.DiId = {0}
  22834. ORDER BY
  22835. o.Id ASC", diId);
  22836. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  22837. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  22838. return Ok(JsonView(data));
  22839. }
  22840. /// <summary>
  22841. /// 团组接待意见调查 - 用户
  22842. /// 保存
  22843. /// </summary>
  22844. /// <param name="dto"></param>
  22845. /// <returns></returns>
  22846. [HttpPost]
  22847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22848. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  22849. {
  22850. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  22851. foreach (var item in dto)
  22852. {
  22853. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  22854. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  22855. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  22856. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  22857. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  22858. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  22859. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  22860. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  22861. }
  22862. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  22863. if (!Directory.Exists(filePathBase))
  22864. {
  22865. Directory.CreateDirectory(filePathBase);
  22866. }
  22867. #region 上传文件
  22868. var filePaths = new List<string>();
  22869. foreach (var item in dto)
  22870. {
  22871. var file = item.File;
  22872. // 将文件保存到指定位置
  22873. var filePath = Path.Combine(filePathBase, file.FileName);
  22874. using (var stream = new FileStream(filePath, FileMode.Create))
  22875. {
  22876. await file.CopyToAsync(stream);
  22877. }
  22878. //验证文件是否上传成功
  22879. if (!System.IO.File.Exists(filePath))
  22880. {
  22881. foreach (var filePathStr in filePaths)
  22882. {
  22883. System.IO.File.Delete(filePathStr);
  22884. }
  22885. return Ok(JsonView(false, "文件上传失败!"));
  22886. }
  22887. item.ESFileName = file.FileName;
  22888. }
  22889. #endregion
  22890. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22891. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22892. .UpdateColumns(x => new
  22893. {
  22894. x.Catering,
  22895. x.CateringReason,
  22896. x.Stay,
  22897. x.StayReason,
  22898. x.Route,
  22899. x.RouteReason,
  22900. x.OfficialActivity,
  22901. x.OfficialActivityReason,
  22902. x.TourGuide,
  22903. x.TourGuideReason,
  22904. x.Translate,
  22905. x.TranslateReason,
  22906. x.Trip,
  22907. x.TripReason,
  22908. x.ESFileName,
  22909. x.SignatureDate,
  22910. x.Remark
  22911. })
  22912. .WhereColumns(x => new { x.Id })
  22913. .ExecuteCommandAsync();
  22914. if (upd < 1)
  22915. {
  22916. foreach (var filePathStr in filePaths)
  22917. {
  22918. System.IO.File.Delete(filePathStr);
  22919. }
  22920. return Ok(JsonView(false));
  22921. }
  22922. return Ok(JsonView(true));
  22923. }
  22924. #endregion
  22925. #region 团组餐厅相关信息
  22926. /// <summary>
  22927. /// 团组相关餐厅信息
  22928. /// 基础数据(团组)
  22929. /// </summary>
  22930. /// <returns></returns>
  22931. [HttpGet]
  22932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22933. public async Task<IActionResult> RestaurantInit()
  22934. {
  22935. return Ok(await _restaurantRep.InitAsync());
  22936. }
  22937. /// <summary>
  22938. /// 团组相关餐厅信息
  22939. /// Item
  22940. /// </summary>
  22941. /// <param name="dto"></param>
  22942. /// <returns></returns>
  22943. [HttpPost]
  22944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22945. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  22946. {
  22947. int portType = dto.PortType,
  22948. groupId = dto.GroupId;
  22949. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22950. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22951. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  22952. }
  22953. /// <summary>
  22954. /// 团组相关餐厅信息
  22955. /// List
  22956. /// </summary>
  22957. /// <param name="dto"></param>
  22958. /// <returns></returns>
  22959. [HttpPost]
  22960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22961. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  22962. {
  22963. int portType = dto.PortType,
  22964. groupId = dto.GroupId;
  22965. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22966. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22967. var sql = string.Format(@" SELECT
  22968. ri.Id,
  22969. ri.GroupId,
  22970. ri.Date,
  22971. ri.StartTime,
  22972. ri.EndTime,
  22973. CASE WHEN ri.Type = 1 THEN '早餐'
  22974. WHEN ri.Type = 2 THEN '午餐'
  22975. WHEN ri.Type = 3 THEN '晚餐'
  22976. ELSE '其他'
  22977. END AS 'Type',
  22978. ri.Name,
  22979. ri.Address,
  22980. ri.Tel,
  22981. ri.Remark,
  22982. ri.CreateTime,
  22983. u.CnName AS CreateUserName
  22984. FROM
  22985. Grp_RestaurantInfo ri
  22986. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  22987. WHERE
  22988. ri.IsDel = 0
  22989. AND ri.GroupId = {0}
  22990. ORDER BY
  22991. ri.Date ASC
  22992. ", groupId);
  22993. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  22994. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  22995. return Ok(JsonView(infos));
  22996. }
  22997. /// <summary>
  22998. /// 团组相关餐厅信息
  22999. /// Info
  23000. /// </summary>
  23001. /// <param name="dto"></param>
  23002. /// <returns></returns>
  23003. [HttpPost]
  23004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23005. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  23006. {
  23007. int portType = dto.PortType,
  23008. id = dto.Id;
  23009. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23010. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23011. return Ok(await _restaurantRep.InfoAsync(portType, id));
  23012. }
  23013. /// <summary>
  23014. /// 团组相关餐厅信息
  23015. /// Op
  23016. /// </summary>
  23017. /// <param name="dto"></param>
  23018. /// <returns></returns>
  23019. [HttpPost]
  23020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23021. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  23022. {
  23023. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23024. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23025. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  23026. return Ok(await _restaurantRep.OpAsync(dto));
  23027. }
  23028. /// <summary>
  23029. /// 团组相关餐厅信息
  23030. /// Del
  23031. /// </summary>
  23032. /// <param name="dto"></param>
  23033. /// <returns></returns>
  23034. [HttpPost]
  23035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23036. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  23037. {
  23038. int userId = dto.DeleteUserId;
  23039. var id = dto.Id;
  23040. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23041. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23042. return Ok(await _restaurantRep.DelAsync(dto));
  23043. }
  23044. #endregion
  23045. #region 团组会务成本
  23046. /// <summary>
  23047. /// 团组会务成本数据初始化
  23048. /// </summary>
  23049. /// <returns></returns>
  23050. [HttpPost]
  23051. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  23052. {
  23053. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23054. .OrderByDescending(x => x.CreateTime)
  23055. .Where(x => x.IsDel == 0)
  23056. .Select<DelegationEasyView>();
  23057. DelegationEasyView di = Dto.GroupId == 0 ?
  23058. expr.First() :
  23059. expr.First(x => x.Id == Dto.GroupId);
  23060. if (di == null)
  23061. {
  23062. return Ok(JsonView(false, "团组信息不存在!"));
  23063. }
  23064. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  23065. .Where(x => x.IsDel == 0 && x.STid == 21)
  23066. .Select(x => new { x.Id, Text = x.Name })
  23067. .ToListAsync();
  23068. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  23069. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  23070. .Select(x => x.Id)
  23071. .ToList();
  23072. //仅检索会务团组
  23073. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  23074. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  23075. .OrderByDescending(x => x.VisitDate)
  23076. .Select(x => new { x.Id, x.TeamName })
  23077. .ToListAsync();
  23078. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  23079. var userList = await _sqlSugar.Queryable<Sys_Users>()
  23080. .Where(x => x.IsDel == 0)
  23081. .Select(x => new { x.Id, x.CnName })
  23082. .ToListAsync();
  23083. var units = await _sqlSugar.Queryable<Sys_SetData>()
  23084. .Where(x => x.IsDel == 0 && x.STid == 119)
  23085. .Select(x => new { x.Id, Text = x.Name })
  23086. .ToListAsync();
  23087. var FileType = new[]
  23088. {
  23089. new { Id = 0 , Name = "成本下载" },
  23090. new { Id = 1 , Name = "报价下载" },
  23091. new { Id = 2 , Name = "总表下载" },
  23092. };
  23093. var GM = new List<int>();
  23094. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  23095. try
  23096. {
  23097. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  23098. }
  23099. catch (Exception ex)
  23100. {
  23101. GM = new List<int>() { 21 };
  23102. }
  23103. var isReview = Dto.UserId == 21;
  23104. var isGM = GM.Contains(Dto.UserId);
  23105. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23106. .Where(x => x.IsDel == 0)
  23107. .Select<ConferenceAffairsCostView>()
  23108. .First(x => x.Diid == di.Id);
  23109. if (ConferenceAffairsCost == null)
  23110. {
  23111. ConferenceAffairsCost = new ConferenceAffairsCostView();
  23112. ConferenceAffairsCost.Diid = di.Id;
  23113. }
  23114. #region 权限校验
  23115. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  23116. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  23117. .Select(x => x.UserId)
  23118. .Distinct()
  23119. .ToList();
  23120. if (!ids.Contains(Dto.UserId) && !isGM)
  23121. {
  23122. return Ok(JsonView(201, "暂无权限!", new
  23123. {
  23124. typeData,
  23125. groupList,
  23126. currenyList,
  23127. isGM,
  23128. userList,
  23129. units,
  23130. isReview,
  23131. operatorUser = ids,
  23132. di,
  23133. FileType
  23134. }));
  23135. }
  23136. #endregion
  23137. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  23138. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  23139. .Select<ConferenceAffairsCostChildView>()
  23140. .OrderBy(x => x.Index)
  23141. .ToList();
  23142. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  23143. {
  23144. ConferenceAffairsCostChi[i - 1].Index = i;
  23145. }
  23146. var backData = new
  23147. {
  23148. ConferenceAffairsCost,
  23149. ConferenceAffairsCostChi,
  23150. typeData,
  23151. groupList,
  23152. currenyList,
  23153. isGM,
  23154. userList,
  23155. units,
  23156. isReview,
  23157. operatorUser = ids,
  23158. di,
  23159. FileType
  23160. };
  23161. return Ok(JsonView(true, "SUCCESS", backData));
  23162. }
  23163. /// <summary>
  23164. /// 会务成本保存
  23165. /// </summary>
  23166. /// <returns></returns>
  23167. [HttpPost]
  23168. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  23169. {
  23170. _sqlSugar.BeginTran();
  23171. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  23172. var childResult = new
  23173. {
  23174. success = 0,
  23175. error = 0
  23176. };
  23177. try
  23178. {
  23179. if (data.Id == 0)
  23180. {
  23181. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23182. .Where(x => x.Diid == Dto.GroupId)
  23183. .SetColumns(x => new Grp_ConferenceAffairsCost
  23184. {
  23185. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23186. DeleteUserId = Dto.UserId
  23187. })
  23188. .ExecuteCommand();
  23189. data.Diid = Dto.GroupId;
  23190. data.CreateTime = DateTime.Now;
  23191. data.CreateUserId = Dto.UserId;
  23192. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  23193. .ExecuteReturnIdentity();
  23194. }
  23195. else
  23196. {
  23197. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  23198. .ExecuteCommand();
  23199. data.Id = data.Id;
  23200. }
  23201. if (Dto.ConferenceAffairsCostChild.Any())
  23202. {
  23203. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  23204. var insertArr = datas.Where(x => x.Id == 0).ToList();
  23205. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  23206. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  23207. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  23208. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  23209. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  23210. .IgnoreColumns(x => new { x.ConferenceAffairsCostId })
  23211. .ExecuteCommand() : 0;
  23212. childResult = childResult with
  23213. {
  23214. error = notUpdateArr.Count(),
  23215. success = inrsetCount + updateCount
  23216. };
  23217. }
  23218. _sqlSugar.CommitTran();
  23219. }
  23220. catch (Exception ex)
  23221. {
  23222. _sqlSugar.RollbackTran();
  23223. return Ok(JsonView(false, "失败!" + ex.Message));
  23224. }
  23225. return Ok(JsonView(true, "操作成功!", childResult));
  23226. }
  23227. [HttpPost]
  23228. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  23229. {
  23230. var count = 0;
  23231. if (Dto.ConferenceAffairsCostChildids.Any())
  23232. {
  23233. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  23234. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  23235. SetColumns(x => new Grp_ConferenceAffairsCostChild
  23236. {
  23237. ReviewStatus = Dto.ReviewStatus
  23238. }).
  23239. ExecuteCommand();
  23240. }
  23241. return Ok(JsonView(true, "操作成功!", count));
  23242. }
  23243. /// <summary>
  23244. /// 会务成本所有数据清除
  23245. /// </summary>
  23246. /// <param name="Dto"></param>
  23247. /// <returns></returns>
  23248. [HttpPost]
  23249. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  23250. {
  23251. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23252. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  23253. _sqlSugar.BeginTran();
  23254. try
  23255. {
  23256. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23257. .Where(x => x.Diid == Dto.GroupId)
  23258. .SetColumns(x => new Grp_ConferenceAffairsCost
  23259. {
  23260. IsDel = 1,
  23261. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23262. DeleteUserId = Dto.UserId
  23263. })
  23264. .ExecuteCommand();
  23265. if (delCount > 0)
  23266. {
  23267. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23268. .Where(x => x.Diid == Dto.GroupId)
  23269. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23270. {
  23271. IsDel = 1,
  23272. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23273. DeleteUserId = Dto.UserId
  23274. })
  23275. .ExecuteCommand();
  23276. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23277. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23278. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23279. {
  23280. IsDel = 1,
  23281. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23282. DeleteUserId = Dto.UserId
  23283. })
  23284. .ExecuteCommand();
  23285. }
  23286. _sqlSugar.CommitTran();
  23287. }
  23288. catch (Exception ex)
  23289. {
  23290. _sqlSugar.RollbackTran();
  23291. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23292. }
  23293. return Ok(JsonView(true, "操作成功!"));
  23294. }
  23295. /// <summary>
  23296. /// 子项数据删除
  23297. /// </summary>
  23298. /// <param name="Dto"></param>
  23299. /// <returns></returns>
  23300. [HttpPost]
  23301. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  23302. {
  23303. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  23304. .Any(x => x.ReviewStatus == 1);
  23305. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  23306. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23307. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  23308. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23309. {
  23310. IsDel = 1,
  23311. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23312. DeleteUserId = Dto.UserId
  23313. })
  23314. .ExecuteCommand();
  23315. return Ok(JsonView(true, "SUCCESS!", count));
  23316. }
  23317. /// <summary>
  23318. /// 会务成本权限分配
  23319. /// </summary>
  23320. /// <param name="Dto"></param>
  23321. /// <returns></returns>
  23322. [HttpPost]
  23323. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  23324. {
  23325. _sqlSugar.BeginTran();
  23326. var count = 0;
  23327. try
  23328. {
  23329. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23330. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23331. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23332. {
  23333. IsDel = 1,
  23334. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23335. DeleteUserId = Dto.CreateUserId
  23336. })
  23337. .ExecuteCommand();
  23338. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  23339. {
  23340. CreateTime = DateTime.Now,
  23341. CreateUserId = Dto.CreateUserId,
  23342. UserId = x,
  23343. Diid = Dto.GroupId,
  23344. }).ToList()).ExecuteCommand();
  23345. _sqlSugar.CommitTran();
  23346. }
  23347. catch (Exception ex)
  23348. {
  23349. _sqlSugar.RollbackTran();
  23350. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23351. }
  23352. return Ok(JsonView(true, "操作成功!", count));
  23353. }
  23354. /// <summary>
  23355. /// 团组会务成本文件下载
  23356. /// </summary>
  23357. /// <returns></returns>
  23358. [HttpPost]
  23359. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  23360. {
  23361. var FileType = new[]
  23362. {
  23363. new { Id = 0 , Name = "成本下载" },
  23364. new { Id = 1 , Name = "报价下载" },
  23365. new { Id = 2 , Name = "总表下载" },
  23366. };
  23367. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23368. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  23369. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23370. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  23371. .Select<DelegationEasyView>()
  23372. .First();
  23373. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23374. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  23375. if (main == null)
  23376. {
  23377. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  23378. }
  23379. JsonView jw = JsonView(false);
  23380. //总表下载
  23381. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  23382. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  23383. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  23384. var field = string.Empty;
  23385. var fileTypeName = string.Empty;
  23386. field = @$"
  23387. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  23388. b.Name as PriceTypeStr ,
  23389. c.Name as CurrencyStr ,
  23390. d.Name as UnitStr ,
  23391. case a.ReviewStatus
  23392. WHEN 1 THEN '已通过'
  23393. WHEN 0 THEN '未审核'
  23394. WHEN -1 THEN '未通过'
  23395. ELSE '未审核'
  23396. END AS ReviewStatusStr
  23397. ";
  23398. if (Dto.FileTypeId == 0)
  23399. {
  23400. fileTypeName = "会务成本成本表";
  23401. loadPath += $"{fileTypeName}.xlsx";
  23402. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23403. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23404. }
  23405. else if (Dto.FileTypeId == 1)
  23406. {
  23407. fileTypeName = "会务成本报价表";
  23408. loadPath += $"{fileTypeName}.xlsx";
  23409. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23410. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23411. }
  23412. else if (Dto.FileTypeId == 2)
  23413. {
  23414. fileTypeName = "会务成本总表";
  23415. loadPath += $"{fileTypeName}.xlsx";
  23416. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23417. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23418. }
  23419. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  23420. SELECT
  23421. {field}
  23422. FROM Grp_ConferenceAffairsCostChild a
  23423. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  23424. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  23425. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  23426. WHERE a.isdel = 0
  23427. AND a.Diid = {main.Diid}
  23428. AND a.ConferenceAffairsCostId = {main.Id}
  23429. ").ToList();
  23430. var currLists = chiExcelContent.Select(x => new CurrList
  23431. {
  23432. CurrName = x.CurrencyStr,
  23433. CurrRate = x.Rate
  23434. })
  23435. .Distinct()
  23436. .ToList();
  23437. var designer = new WorkbookDesigner
  23438. {
  23439. Workbook = new Workbook(loadPath)
  23440. };
  23441. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == main.MostCurr);
  23442. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  23443. designer.SetDataSource("TeamName", di.TeamName);
  23444. designer.SetDataSource("City", main.City);
  23445. designer.SetDataSource("AllCost", main.CostAll);
  23446. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  23447. designer.SetDataSource("Curr", MostCurr.Name);
  23448. designer.SetDataSource("Curr1", MostCurr.Name);
  23449. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  23450. dt.TableName = "TB";
  23451. designer.SetDataSource(dt);
  23452. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  23453. dt1.TableName = "currTb";
  23454. designer.SetDataSource(dt1);
  23455. designer.Process();
  23456. designer.Workbook.Save(outputPath);
  23457. jw = JsonView(true, "操作成功!", new
  23458. {
  23459. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  23460. FilePath = networkPath
  23461. });
  23462. return Ok(jw);
  23463. }
  23464. [HttpPost]
  23465. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  23466. {
  23467. return Ok(JsonView(true, "SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  23468. .Select(x => x.PriceName).ToList()));
  23469. }
  23470. #endregion
  23471. #region 团组签证流程
  23472. #endregion
  23473. /// <summary>
  23474. /// 123132123
  23475. /// </summary>
  23476. /// <param name="_dto"></param>
  23477. /// <returns></returns>
  23478. [HttpPost]
  23479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23480. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  23481. {
  23482. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  23483. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  23484. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  23485. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  23486. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  23487. dicDetail.Add(789, 1034);
  23488. dicDetail.Add(790, 1035);
  23489. dicDetail.Add(791, 1036);
  23490. dicDetail.Add(792, 1037);
  23491. dicDetail.Add(793, 1038);
  23492. dicDetail.Add(794, 1039);
  23493. dicDetail.Add(795, 1040);
  23494. dicDetail.Add(796, 1041);
  23495. dicDetail.Add(797, 1042);
  23496. dicDetail.Add(798, 1043);
  23497. dicDetail.Add(801, 1044);
  23498. dicDetail.Add(802, 1045);
  23499. dicDetail.Add(803, 1046);
  23500. Dictionary<int, int> dic = new Dictionary<int, int>();
  23501. dic.Add(806, 1027);
  23502. dic.Add(807, 1028);
  23503. dic.Add(808, 1029);
  23504. dic.Add(809, 1030);
  23505. dic.Add(810, 1031);
  23506. dic.Add(811, 1032);
  23507. dic.Add(812, 1033);
  23508. foreach (var item in list_visa)
  23509. {
  23510. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  23511. temp.Coefficient = item.coefficient;
  23512. DateTime dtCrt;
  23513. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  23514. if (b1)
  23515. {
  23516. temp.CreateTime = dtCrt;
  23517. }
  23518. else
  23519. {
  23520. temp.CreateTime = DateTime.Now;
  23521. }
  23522. temp.CreateUserId = item.Operators;
  23523. temp.DeleteTime = "";
  23524. temp.DeleteUserId = 0;
  23525. temp.DiId = int.Parse(item.DIID);
  23526. temp.FilePath = item.FilePath;
  23527. temp.IsDel = item.IsDel;
  23528. temp.Price = item.Price;
  23529. temp.PriceCount = 1;
  23530. temp.PriceCurrency = item.Currency;
  23531. int detailId = 0;
  23532. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  23533. {
  23534. detailId = dicDetail[item.PriceTypeDetail];
  23535. }
  23536. temp.PriceDetailType = detailId;
  23537. temp.PriceDt = DateTime.Now;
  23538. temp.PriceName = item.PriceName;
  23539. temp.PriceSum = item.Price;
  23540. int tid = 0;
  23541. if (dic.ContainsKey(item.PriceType))
  23542. {
  23543. tid = dic[item.PriceType];
  23544. }
  23545. temp.PriceType = tid;
  23546. temp.Remark = item.Remark;
  23547. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  23548. }
  23549. return Ok(JsonView(true, "操作成功!"));
  23550. }
  23551. [HttpPost]
  23552. public IActionResult TimeTest()
  23553. {
  23554. var jw = JsonView(false, "error");
  23555. _sqlSugar.BeginTran();
  23556. try
  23557. {
  23558. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  23559. .Select(x => new Crm_NewClientData
  23560. {
  23561. Id = x.Id,
  23562. Client = x.Client,
  23563. Contact = x.Contact,
  23564. Location = x.Location,
  23565. })
  23566. .ToList();
  23567. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  23568. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  23569. Stopwatch stopwatch = new Stopwatch();
  23570. // 开始计时
  23571. stopwatch.Start();
  23572. foreach (var item in clientList)
  23573. {
  23574. EncryptionProcessor.DecryptProperties(item);
  23575. }
  23576. stopwatch.Stop();
  23577. jw.Code = 200;
  23578. jw.Data = stopwatch.ElapsedMilliseconds;
  23579. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  23580. }
  23581. catch (Exception ex)
  23582. {
  23583. jw.Code = 400;
  23584. jw.Msg = ex.Message;
  23585. }
  23586. return Ok(jw);
  23587. }
  23588. }
  23589. }