GroupsController.cs 1.2 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290
  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. //2025-09-08 商邀费用名称更改:单项费用不等于0,则在名称后面最加费用类型名称。
  3555. List<string> priceExpNames = new List<string>();
  3556. if (_ioa.InviteCost != 0.00M) priceExpNames.Add("邀请费");
  3557. if (_ioa.SendCost != 0.00M) priceExpNames.Add("快递费");
  3558. if (_ioa.EventsCost != 0.00M) priceExpNames.Add("公务活动费");
  3559. if (_ioa.TranslateCost != 0.00M) priceExpNames.Add("公务翻译费");
  3560. if (priceExpNames != null && priceExpNames.Count > 0)
  3561. {
  3562. _detail.PriceNameContent += $"({string.Join("+",priceExpNames)})";
  3563. }
  3564. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  3565. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  3566. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  3567. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  3568. $@"备注:" + _ioa.Remark + "<br/>";
  3569. }
  3570. break;
  3571. case 82: //团组客户保险
  3572. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3573. if (customers != null)
  3574. {
  3575. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  3576. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3577. }
  3578. break;
  3579. case 85: //机票预订
  3580. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3581. if (jpRes != null)
  3582. {
  3583. string FlightsDescription = jpRes.FlightsDescription;
  3584. string PriceDescription = jpRes.PriceDescription;
  3585. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3586. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3587. }
  3588. break;
  3589. case 98://其他款项
  3590. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3591. if (gdpRes != null)
  3592. {
  3593. //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/";
  3594. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  3595. //{
  3596. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  3597. //}
  3598. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3599. _detail.PriceNameContent = gdpRes.PriceName;
  3600. }
  3601. break;
  3602. case 285://收款退还
  3603. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3604. if (refundAndOtherMoney != null)
  3605. {
  3606. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3607. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3608. }
  3609. break;
  3610. case 751://酒店早餐
  3611. break;
  3612. case 1015://超支费用
  3613. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3614. if (groupExtraCost != null)
  3615. {
  3616. _detail.PriceNameContent = groupExtraCost.PriceName;
  3617. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3618. }
  3619. break;
  3620. default:
  3621. break;
  3622. }
  3623. /*
  3624. * 申请人
  3625. */
  3626. string operatorName = " - ";
  3627. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3628. if (_opUser != null)
  3629. {
  3630. operatorName = _opUser.CnName;
  3631. }
  3632. _detail.OperatorName = operatorName;
  3633. /*
  3634. * 审核人
  3635. */
  3636. string auditOperatorName = " - ";
  3637. if (entity.IsAuditGM != 0)
  3638. {
  3639. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3640. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3641. else
  3642. {
  3643. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3644. if (_adUser != null)
  3645. {
  3646. auditOperatorName = _adUser.CnName;
  3647. }
  3648. }
  3649. }
  3650. _detail.AuditOperatorName = auditOperatorName;
  3651. /*
  3652. * 超预算比例
  3653. */
  3654. string overBudgetStr = "";
  3655. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3656. else if (entity.ExceedBudget == 0)
  3657. {
  3658. if (entity.CTable == 76 || entity.CTable == 79)
  3659. {
  3660. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3661. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3662. }
  3663. else
  3664. {
  3665. overBudgetStr = "未超预算";
  3666. }
  3667. }
  3668. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3669. _detail.OverBudget = overBudgetStr;
  3670. decimal auditFee = 0.00M; //已审核金额 人名币
  3671. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3672. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3673. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3674. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3675. {
  3676. auditedFeeOriginal = entity.PayMoney;
  3677. auditFee = CurrPayStr;
  3678. }
  3679. else if (entity.IsAuditGM == 0)
  3680. {
  3681. unAuditFeeCNY = CurrPayStr;
  3682. unAuditFeeOriginal = OriginalCurrPay;
  3683. OriginalCurrPay = 0.00M;
  3684. }
  3685. /*
  3686. * 费用总计
  3687. */
  3688. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3689. {
  3690. CurrencyId = entity.PaymentCurrency,
  3691. CurrencyName = PaymentCurrency_WaitPay,
  3692. AmountPayable = entity.PayMoney,
  3693. ThisPayment = OriginalCurrPay,
  3694. BalancePayment = BalanceStr,
  3695. AuditedFunds = auditFee,
  3696. AuditedFundsOriginal = auditedFeeOriginal,
  3697. UnAuditFundsCNY = unAuditFeeCNY,
  3698. UnAuditFundsOriginal = unAuditFeeOriginal
  3699. });
  3700. _detail.IsAuditGM = entity.IsAuditGM;
  3701. detailList.Add(_detail);
  3702. }
  3703. #endregion
  3704. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3705. /*
  3706. * 下方描述处理
  3707. */
  3708. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3709. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3710. if (ccpCurrencyPrice != null)
  3711. {
  3712. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3713. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3714. }
  3715. else
  3716. {
  3717. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3718. }
  3719. string amountPayableStr = string.Format(@"应付款总金额: ");
  3720. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3721. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3722. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3723. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3724. foreach (var item in nonDuplicat)
  3725. {
  3726. var currencyName = item.CurrencyName;
  3727. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3728. if (strs.Count > 0)
  3729. {
  3730. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3731. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3732. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3733. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3734. //单独处理此次付款金额
  3735. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3736. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3737. //单独处理已审核费用
  3738. //if (item.CurrencyId == 836) //人民币
  3739. //{
  3740. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3741. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3742. //}
  3743. //else
  3744. //{
  3745. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3746. //}
  3747. if (currencyName.Equals("CNY"))
  3748. {
  3749. //已审核费用
  3750. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3751. //未审核费用
  3752. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3753. }
  3754. else
  3755. {
  3756. //已审核费用
  3757. 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"));
  3758. //未审核费用
  3759. 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"));
  3760. }
  3761. }
  3762. }
  3763. _view.TotalStr1 = amountPayableStr[..^1];
  3764. _view.TotalStr2 = thisPaymentStr[..^1];
  3765. _view.TotalStr3 = balancePaymentStr[..^1];
  3766. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3767. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3768. var _view1 = new
  3769. {
  3770. PageFuncAuth = pageFunAuthView,
  3771. Data = _view
  3772. };
  3773. return Ok(JsonView(_view1));
  3774. }
  3775. catch (Exception ex)
  3776. {
  3777. return Ok(JsonView(false, ex.Message));
  3778. }
  3779. }
  3780. /// <summary>
  3781. /// 费用审核
  3782. /// 修改团组费用审核状态
  3783. /// </summary>
  3784. /// <param name="_dto">参数Json字符串</param>
  3785. /// <returns></returns>
  3786. [HttpPost]
  3787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3788. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3789. {
  3790. #region 参数验证
  3791. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3792. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3793. #endregion
  3794. #region 页面操作权限验证
  3795. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3796. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3797. #endregion
  3798. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3799. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3800. DateTime dtNow = DateTime.Now;
  3801. _groupRepository.BeginTran();
  3802. int rst = 0;
  3803. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3804. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3805. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3806. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3807. var msgDatas = new List<dynamic>();
  3808. var dic_ccp_user = new Dictionary<int, int>() { };
  3809. foreach (var item in idList)
  3810. {
  3811. int CreditId = int.Parse(item);
  3812. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3813. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3814. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3815. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3816. .Where(s => s.Id == CreditId)
  3817. .ExecuteCommandAsync();
  3818. if (result < 1)
  3819. {
  3820. rst = -1;
  3821. _groupRepository.RollbackTran();
  3822. return Ok(JsonView(false, "操作失败并回滚!"));
  3823. }
  3824. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3825. if (creditData != null)
  3826. {
  3827. #region 应用通知配置
  3828. try
  3829. {
  3830. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3831. }
  3832. catch (Exception ex)
  3833. {
  3834. }
  3835. #endregion
  3836. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3837. string groupNameStr = string.Empty;
  3838. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3839. if (groupData != null) groupNameStr = groupData.TeamName;
  3840. string creditTypeStr = string.Empty;
  3841. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3842. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3843. string creditCurrency = string.Empty;
  3844. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3845. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3846. if (creditCurrency.Equals("CNY"))
  3847. {
  3848. creditData.DayRate = 1.0000M;
  3849. }
  3850. if (creditData.PayPercentage == 0.00M)
  3851. {
  3852. creditData.PayPercentage = 100M;
  3853. }
  3854. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3855. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3856. string msgContent = "";
  3857. if (creditCurrency.Equals("CNY"))
  3858. {
  3859. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  3860. }
  3861. else
  3862. {
  3863. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  3864. }
  3865. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3866. }
  3867. }
  3868. if (rst == 0)
  3869. {
  3870. _groupRepository.CommitTran();
  3871. foreach (var item in msgDatas)
  3872. {
  3873. //发送消息
  3874. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3875. }
  3876. #region 应用推送
  3877. try
  3878. {
  3879. foreach (var ccpId in dic_ccp_user.Keys)
  3880. {
  3881. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3882. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3883. }
  3884. }
  3885. catch (Exception)
  3886. {
  3887. }
  3888. #endregion
  3889. return Ok(JsonView(true, "操作成功!"));
  3890. }
  3891. return Ok(JsonView(false, "操作失败!"));
  3892. }
  3893. /// <summary>
  3894. /// 费用审核
  3895. /// 其他款项 文件下载
  3896. /// </summary>
  3897. /// <param name="id">其他款项 主键编号</param>
  3898. /// <returns></returns>
  3899. [HttpGet("{id}")]
  3900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3901. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1, int.MaxValue, ErrorMessage = "请传入有效的ID")] int id)
  3902. {
  3903. //网站域名
  3904. 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/";
  3905. var otherInfo = await _decreasePaymentsRep._sqlSugar
  3906. .Queryable<Grp_DecreasePayments>()
  3907. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  3908. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  3909. .Select((x, y) => new
  3910. {
  3911. x.Id,
  3912. x.FilePath
  3913. })
  3914. .FirstAsync();
  3915. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  3916. {
  3917. var url = $"{baseUrl}{otherInfo.FilePath}";
  3918. return Ok(JsonView(true, "操作成功!", url));
  3919. }
  3920. return Ok(JsonView(false, "暂无附件"));
  3921. }
  3922. #endregion
  3923. #region 机票费用录入
  3924. /// <summary>
  3925. /// 机票录入当前登录人可操作团组
  3926. /// </summary>
  3927. /// <param name="dto"></param>
  3928. /// <returns></returns>
  3929. [HttpPost]
  3930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3931. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3932. {
  3933. try
  3934. {
  3935. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3936. if (groupData.Code != 0)
  3937. {
  3938. return Ok(JsonView(false, groupData.Msg));
  3939. }
  3940. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3941. }
  3942. catch (Exception ex)
  3943. {
  3944. return Ok(JsonView(false, ex.Message));
  3945. }
  3946. }
  3947. /// <summary>
  3948. /// 机票费用录入列表
  3949. /// </summary>
  3950. /// <param name="dto"></param>
  3951. /// <returns></returns>
  3952. [HttpPost]
  3953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3954. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3955. {
  3956. try
  3957. {
  3958. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3959. if (groupData.Code != 0)
  3960. {
  3961. return Ok(JsonView(false, groupData.Msg));
  3962. }
  3963. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3964. }
  3965. catch (Exception ex)
  3966. {
  3967. return Ok(JsonView(false, ex.Message));
  3968. throw;
  3969. }
  3970. }
  3971. /// <summary>
  3972. /// 根据id查询费用录入信息
  3973. /// </summary>
  3974. /// <param name="dto"></param>
  3975. /// <returns></returns>
  3976. [HttpPost]
  3977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3978. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3979. {
  3980. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3981. if (groupData.Code != 0)
  3982. {
  3983. return Ok(JsonView(false, groupData.Msg));
  3984. }
  3985. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3986. }
  3987. /// <summary>
  3988. /// 机票费用录入操作(Status:1.新增,2.修改)
  3989. /// </summary>
  3990. /// <param name="dto"></param>
  3991. /// <returns></returns>
  3992. [HttpPost]
  3993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3994. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3995. {
  3996. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3997. if (groupData.Code != 0)
  3998. {
  3999. return Ok(JsonView(false, groupData.Msg));
  4000. }
  4001. #region 应用推送
  4002. try
  4003. {
  4004. var diId = dto.AirTicketResOpData.DiId;
  4005. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4006. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4007. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4008. //自动审核
  4009. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  4010. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  4011. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  4012. $"GroupId:{diId};airId:{dataId};",
  4013. status,
  4014. auditMsg);
  4015. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4016. //2024-10-21 新增LZ UID
  4017. var userIds = new List<int>() { 21 };
  4018. string title = $"系统通知";
  4019. string content = "";
  4020. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4021. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4022. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4023. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4024. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4025. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  4026. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4027. }
  4028. catch (Exception ex)
  4029. {
  4030. }
  4031. #endregion
  4032. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4033. }
  4034. /// <summary>
  4035. /// 机票费用自动审核 AI识别方式
  4036. /// </summary>
  4037. /// <returns></returns>
  4038. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  4039. {
  4040. var ecoTypeIds = new List<int>() {
  4041. 459, //超经舱
  4042. 460, //经济舱
  4043. 1430, //公务舱(实际经济舱)
  4044. 1432, //头等舱(实际经济舱)
  4045. };
  4046. var bizTypeIds = new List<int>() {
  4047. 457, //头等舱
  4048. 458, //公务舱
  4049. 1431, //头等舱(实际公务舱)
  4050. };
  4051. var auditFeeTypeIds = new List<int>() { };
  4052. auditFeeTypeIds.AddRange(ecoTypeIds);
  4053. auditFeeTypeIds.AddRange(bizTypeIds);
  4054. int currModule = 85;
  4055. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  4056. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  4057. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  4058. .Select((x, y) => new
  4059. {
  4060. x.Id,
  4061. CcpId = y.Id,
  4062. x.FlightsDate,
  4063. x.PrePrice,
  4064. x.CType,
  4065. x.ClientNum,
  4066. x.DIId
  4067. })
  4068. .FirstAsync();
  4069. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  4070. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  4071. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  4072. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  4073. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  4074. var groupCostContents = await _sqlSugar
  4075. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  4076. .Where(x => x.IsDel == 0 && x.Diid == diId)
  4077. .ToListAsync();
  4078. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  4079. //处理 成本详细信息日期为空 填装费用信息
  4080. var airFeeLabel = new StringBuilder();
  4081. airFeeLabel.AppendLine("费用成本:");
  4082. for (int i = 0; i < groupCostContents.Count; i++)
  4083. {
  4084. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  4085. {
  4086. int index = i - 1;
  4087. if (index >= 0)
  4088. {
  4089. groupCostContents[i].Date = groupCostContents[index].Date;
  4090. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4091. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4092. }
  4093. }
  4094. else
  4095. {
  4096. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4097. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4098. }
  4099. var item = groupCostContents[i];
  4100. airFeeLabel.AppendLine($"{item.Date}");
  4101. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  4102. }
  4103. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  4104. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  4105. //访问Kimi AI 返回价格结果
  4106. var msgs = new List<SeedMessages>()
  4107. {
  4108. new ()
  4109. {
  4110. Role = KimiRole.user,
  4111. Content = airFeeLabel.ToString()
  4112. }
  4113. };
  4114. var client = new KiMiApiClient();
  4115. var kimiApiResult = await client.SeedMessage(msgs);
  4116. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  4117. string clients = kimiApiResult_JObject["content"].ToString();
  4118. decimal ecoPri_kimiAI = 0.00M,
  4119. bizPri_kimiAI = 0.00M;
  4120. //单个价格: 经济舱价格
  4121. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  4122. //价格文本包含/:/前经济舱价格 /后公务舱价格
  4123. if (clients.Contains('/'))
  4124. {
  4125. var priArray = clients.Split('/');
  4126. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  4127. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  4128. }
  4129. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  4130. var isAutoAudit = false;
  4131. //价格验证处理
  4132. //经济舱
  4133. if (ecoTypeIds.Contains(airInfo.CType))
  4134. {
  4135. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  4136. }
  4137. //公务舱
  4138. else if (bizTypeIds.Contains(airInfo.CType))
  4139. {
  4140. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  4141. }
  4142. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  4143. //是否执行自动审核
  4144. if (isAutoAudit)
  4145. {
  4146. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4147. .SetColumns(x => x.IsAuditGM == 3)
  4148. .SetColumns(x => x.AuditGMOperate == 4)
  4149. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  4150. .Where(x => x.Id == airInfo.CcpId)
  4151. .ExecuteCommandAsync();
  4152. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  4153. }
  4154. return (false, "当前费用超过成本费用,不可自动审核!");
  4155. }
  4156. /// <summary>
  4157. /// 机票费用录入
  4158. /// 自动审核测试 - AI 识别
  4159. /// </summary>
  4160. /// <param name="groupId"></param>
  4161. /// <param name="Id"></param>
  4162. /// <returns></returns>
  4163. [HttpPost]
  4164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4165. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  4166. {
  4167. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4168. return Ok(JsonView(status, msg));
  4169. }
  4170. /// <summary>
  4171. /// 根据舱位类型查询接团客户名单信息
  4172. /// </summary>
  4173. /// <param name="dto"></param>
  4174. /// <returns></returns>
  4175. [HttpPost]
  4176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4177. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4178. {
  4179. try
  4180. {
  4181. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4182. if (crm_Groups.Count != 0)
  4183. {
  4184. var Customer = new List<dynamic>();
  4185. foreach (var item in crm_Groups)
  4186. {
  4187. var data = new
  4188. {
  4189. item.Id,
  4190. item.Pinyin,
  4191. Name = item.LastName + item.FirstName
  4192. };
  4193. Customer.Add(data);
  4194. }
  4195. return Ok(JsonView(true, "查询成功!", Customer));
  4196. }
  4197. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4198. }
  4199. catch (Exception ex)
  4200. {
  4201. return Ok(JsonView(false, "程序错误!"));
  4202. throw;
  4203. }
  4204. }
  4205. /// <summary>
  4206. /// 根据团号获取客户信息
  4207. /// </summary>
  4208. /// <param name="dto"></param>
  4209. /// <returns></returns>
  4210. [HttpPost]
  4211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4212. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  4213. {
  4214. var jw = JsonView(false);
  4215. if (dto.DIID < 1)
  4216. {
  4217. jw.Msg += "请输入正确的diid";
  4218. return Ok(jw);
  4219. }
  4220. var arr = GetSimplClientList(dto.DIID);
  4221. jw = JsonView(true, "获取成功!", arr);
  4222. return Ok(jw);
  4223. }
  4224. private List<SimplClientInfo> GetSimplClientList(int diId)
  4225. {
  4226. 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);
  4227. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  4228. foreach (var item in arr)
  4229. {
  4230. EncryptionProcessor.DecryptProperties(item);
  4231. }
  4232. return arr;
  4233. }
  4234. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  4235. {
  4236. string result = origin;
  4237. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4238. {
  4239. string[] temparr = origin.Split(',');
  4240. string fistrStr = temparr[0];
  4241. int count = temparr.Length;
  4242. bool success = int.TryParse(fistrStr, out int tempId);
  4243. if (success)
  4244. {
  4245. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4246. if (tempInfo != null)
  4247. {
  4248. if (count > 1)
  4249. {
  4250. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4251. }
  4252. else
  4253. {
  4254. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4255. }
  4256. }
  4257. }
  4258. }
  4259. return result;
  4260. }
  4261. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4262. {
  4263. string result = origin;
  4264. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4265. {
  4266. string[] temparr = origin.Split(',');
  4267. result = "";
  4268. foreach (var item in temparr)
  4269. {
  4270. bool success = int.TryParse(item, out int tempId);
  4271. if (success)
  4272. {
  4273. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4274. if (tempInfo != null)
  4275. {
  4276. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4277. }
  4278. }
  4279. }
  4280. }
  4281. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4282. return result;
  4283. }
  4284. /// <summary>
  4285. /// 机票费用录入,删除
  4286. /// </summary>
  4287. /// <param name="dto"></param>
  4288. /// <returns></returns>
  4289. [HttpPost]
  4290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4291. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4292. {
  4293. try
  4294. {
  4295. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4296. if (res)
  4297. {
  4298. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4299. {
  4300. IsDel = 1,
  4301. DeleteUserId = dto.DeleteUserId,
  4302. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4303. }).ExecuteCommandAsync();
  4304. return Ok(JsonView(true, "删除成功!"));
  4305. }
  4306. return Ok(JsonView(false, "删除失败!"));
  4307. }
  4308. catch (Exception ex)
  4309. {
  4310. return Ok(JsonView(false, "程序错误!"));
  4311. throw;
  4312. }
  4313. }
  4314. /// <summary>
  4315. /// 导出机票录入报表
  4316. /// </summary>
  4317. /// <param name="dto"></param>
  4318. /// <returns></returns>
  4319. [HttpPost]
  4320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4321. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4322. {
  4323. try
  4324. {
  4325. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4326. if (groupData.Code != 0)
  4327. {
  4328. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4329. }
  4330. else
  4331. {
  4332. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4333. if (AirTicketReservations.Count != 0)
  4334. {
  4335. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4336. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4337. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4338. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4339. var designer = new WorkbookDesigner
  4340. {
  4341. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  4342. };
  4343. decimal countCost = 0;
  4344. foreach (var item in AirTicketReservations)
  4345. {
  4346. #region 处理客人姓名
  4347. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  4348. item.ClientName = clientNames;
  4349. #endregion
  4350. if (item.BankType == "其他")
  4351. {
  4352. item.BankNo = "--";
  4353. }
  4354. else
  4355. {
  4356. if (!string.IsNullOrEmpty(item.BankType))
  4357. {
  4358. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  4359. }
  4360. }
  4361. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4362. item.Price = System.Decimal.Round(item.Price, 2);
  4363. countCost += Convert.ToDecimal(item.Price);
  4364. }
  4365. designer.SetDataSource("Export", AirTicketReservations);
  4366. designer.SetDataSource("ExportDiCode", diCode);
  4367. designer.SetDataSource("ExportDiName", diName);
  4368. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4369. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4370. designer.Process();
  4371. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4372. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4373. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4374. return Ok(JsonView(true, "成功", url = rst));
  4375. }
  4376. else
  4377. {
  4378. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4379. }
  4380. }
  4381. }
  4382. catch (Exception ex)
  4383. {
  4384. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4385. throw;
  4386. }
  4387. }
  4388. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  4389. /// <summary>
  4390. /// 行程单导出
  4391. /// </summary>
  4392. /// <param name="dto"></param>
  4393. /// <returns></returns>
  4394. [HttpPost]
  4395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4396. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4397. {
  4398. try
  4399. {
  4400. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4401. if (groupData.Code != 0)
  4402. {
  4403. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4404. }
  4405. else
  4406. {
  4407. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4408. if (dto.Language == "CN")
  4409. {
  4410. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4411. var builder = new DocumentBuilder(doc);
  4412. int tableIndex = 0;//表格索引
  4413. //得到文档中的第一个表格
  4414. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4415. foreach (var item in _AirTicketReservations)
  4416. {
  4417. #region 处理固定数据
  4418. string[] FlightsCode = item.FlightsCode.Split('/');
  4419. if (FlightsCode.Length != 0)
  4420. {
  4421. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4422. if (_AirCompany != null)
  4423. {
  4424. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4425. }
  4426. else
  4427. {
  4428. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4429. }
  4430. }
  4431. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4432. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4433. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4434. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4435. string name = "";
  4436. foreach (string clientName in nameArray)
  4437. {
  4438. if (!name.Contains(clientName))
  4439. {
  4440. name += clientName + ",";
  4441. }
  4442. }
  4443. if (!string.IsNullOrWhiteSpace(name))
  4444. {
  4445. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4446. }
  4447. else
  4448. {
  4449. table.Range.Bookmarks["ClientName"].Text = "--";
  4450. }
  4451. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4452. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4453. table.Range.Bookmarks["JointTicket"].Text = "--";
  4454. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4455. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4456. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4457. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4458. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4459. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4460. #endregion
  4461. #region 循环数据处理
  4462. var airs = new List<AirInfo>();
  4463. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4464. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4465. for (int i = 0; i < FlightsCode.Length; i++)
  4466. {
  4467. var air = new AirInfo();
  4468. string[] tempstr = DayArray[i]
  4469. .Replace("\r\n", string.Empty)
  4470. .Replace("\\r\\n", string.Empty)
  4471. .TrimStart().TrimEnd()
  4472. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4473. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4474. string starCity = "";
  4475. if (star_Three != null)
  4476. {
  4477. starCity = star_Three.AirPort;
  4478. }
  4479. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4480. string EndCity = "";
  4481. if (End_Three != null)
  4482. {
  4483. EndCity = End_Three.AirPort;
  4484. }
  4485. air.Destination = starCity + "/" + EndCity;
  4486. air.Flight = FlightsCode[i];
  4487. air.SeatingClass = item.CTypeName;
  4488. string dateTime = tempstr[2];
  4489. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4490. air.FlightDate = DateTemp;
  4491. air.DepartureTime = tempstr[5];
  4492. air.LandingTime = tempstr[6];
  4493. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4494. air.TicketStatus = "--";
  4495. air.Luggage = "--";
  4496. air.DepartureTerminal = "--";
  4497. air.LandingTerminal = "--";
  4498. airs.Add(air);
  4499. }
  4500. int row = 13;
  4501. for (int i = 0; i < airs.Count; i++)
  4502. {
  4503. if (airs.Count > 2)
  4504. {
  4505. for (int j = 0; j < airs.Count - 2; j++)
  4506. {
  4507. var CopyRow = table.Rows[12].Clone(true);
  4508. table.Rows.Add(CopyRow);
  4509. }
  4510. }
  4511. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4512. int index = 0;
  4513. foreach (PropertyInfo property in properties)
  4514. {
  4515. string value = property.GetValue(airs[i]).ToString();
  4516. Cell ishcel0 = table.Rows[row].Cells[index];
  4517. var p = new Paragraph(doc);
  4518. string s = value;
  4519. p.AppendChild(new Run(doc, s));
  4520. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4521. ishcel0.AppendChild(p);
  4522. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4523. index++;
  4524. }
  4525. row++;
  4526. }
  4527. #endregion
  4528. var lastParagraph = new Paragraph(doc);
  4529. //第一个表格末尾加段落
  4530. table.ParentNode.InsertAfter(lastParagraph, table);
  4531. //复制第一个表格
  4532. Table cloneTable = (Table)table.Clone(true);
  4533. //在文档末尾段落后面加入复制的表格
  4534. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4535. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4536. {
  4537. int rownewsIndex = 13;
  4538. for (int i = 0; i < 2; i++)
  4539. {
  4540. var CopyRow = table.Rows[12].Clone(true);
  4541. table.Rows.RemoveAt(13);
  4542. table.Rows.Add(CopyRow);
  4543. rownewsIndex++;
  4544. }
  4545. }
  4546. else
  4547. {
  4548. table.Rows.RemoveAt(12);
  4549. }
  4550. cloneTable.Rows.RemoveAt(12);
  4551. }
  4552. if (_AirTicketReservations.Count != 0)
  4553. {
  4554. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4555. if (FlightsCode.Length != 0)
  4556. {
  4557. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4558. if (_AirCompany != null)
  4559. {
  4560. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4561. }
  4562. else
  4563. {
  4564. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4565. }
  4566. }
  4567. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4568. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4569. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4570. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4571. string name = "";
  4572. foreach (string clientName in nameArray)
  4573. {
  4574. if (!name.Contains(clientName))
  4575. {
  4576. name += clientName + ",";
  4577. }
  4578. }
  4579. if (!string.IsNullOrWhiteSpace(name))
  4580. {
  4581. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4582. }
  4583. else
  4584. {
  4585. table.Range.Bookmarks["ClientName"].Text = "--";
  4586. }
  4587. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4588. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4589. table.Range.Bookmarks["JointTicket"].Text = "--";
  4590. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4591. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4592. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4593. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4594. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4595. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4596. }
  4597. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4598. //保存合并后的文档
  4599. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4600. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4601. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4602. return Ok(JsonView(true, "成功!", rst));
  4603. }
  4604. else
  4605. {
  4606. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4607. var builder = new DocumentBuilder(doc);
  4608. int tableIndex = 0;//表格索引
  4609. //得到文档中的第一个表格
  4610. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4611. var texts = new List<string>();
  4612. foreach (var item in _AirTicketReservations)
  4613. {
  4614. string[] FlightsCode = item.FlightsCode.Split('/');
  4615. if (FlightsCode.Length != 0)
  4616. {
  4617. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4618. if (_AirCompany != null)
  4619. {
  4620. if (!transDic.ContainsKey(_AirCompany.CnName))
  4621. {
  4622. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4623. }
  4624. }
  4625. else
  4626. {
  4627. if (!transDic.ContainsKey("--"))
  4628. {
  4629. transDic.Add("--", "--");
  4630. }
  4631. }
  4632. }
  4633. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4634. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4635. string name = "";
  4636. foreach (string clientName in nameArray)
  4637. {
  4638. name += clientName + ",";
  4639. }
  4640. if (!texts.Contains(name))
  4641. {
  4642. texts.Add(name);
  4643. }
  4644. var airs = new List<AirInfo>();
  4645. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4646. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4647. for (int i = 0; i < FlightsCode.Length; i++)
  4648. {
  4649. var air = new AirInfo();
  4650. string[] tempstr = DayArray[i]
  4651. .Replace("\r\n", string.Empty)
  4652. .Replace("\\r\\n", string.Empty)
  4653. .TrimStart().TrimEnd()
  4654. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4655. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4656. if (star_Three != null)
  4657. {
  4658. if (!transDic.ContainsKey(star_Three.AirPort))
  4659. {
  4660. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4661. }
  4662. }
  4663. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4664. if (End_Three != null)
  4665. {
  4666. if (!transDic.ContainsKey(End_Three.AirPort))
  4667. {
  4668. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4669. }
  4670. }
  4671. if (!texts.Contains(item.CTypeName))
  4672. {
  4673. texts.Add(item.CTypeName);
  4674. }
  4675. }
  4676. }
  4677. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4678. if (transData.Count > 0)
  4679. {
  4680. foreach (TranslateResult item in transData)
  4681. {
  4682. if (!transDic.ContainsKey(item.Query))
  4683. {
  4684. transDic.Add(item.Query, item.Translation);
  4685. }
  4686. }
  4687. }
  4688. foreach (var item in _AirTicketReservations)
  4689. {
  4690. #region 处理固定数据
  4691. string[] FlightsCode = item.FlightsCode.Split('/');
  4692. if (FlightsCode.Length != 0)
  4693. {
  4694. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4695. if (_AirCompany != null)
  4696. {
  4697. string str = "--";
  4698. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4699. if (!string.IsNullOrEmpty(translateResult))
  4700. {
  4701. str = translateResult;
  4702. str = _airTicketResRep.Processing(str);
  4703. }
  4704. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4705. }
  4706. else
  4707. {
  4708. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4709. }
  4710. }
  4711. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4712. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4713. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4714. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4715. string names = "";
  4716. foreach (string clientName in nameArray)
  4717. {
  4718. names += clientName + ",";
  4719. }
  4720. if (!string.IsNullOrWhiteSpace(names))
  4721. {
  4722. string str = "--";
  4723. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4724. if (!string.IsNullOrEmpty(translateResult))
  4725. {
  4726. str = translateResult;
  4727. str = _airTicketResRep.Processing(str);
  4728. }
  4729. table.Range.Bookmarks["ClientName"].Text = str;
  4730. }
  4731. else
  4732. {
  4733. table.Range.Bookmarks["ClientName"].Text = "--";
  4734. }
  4735. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4736. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4737. table.Range.Bookmarks["JointTicket"].Text = "--";
  4738. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4739. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4740. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4741. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4742. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4743. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4744. #endregion
  4745. #region 循环数据处理
  4746. var airs = new List<AirInfo>();
  4747. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4748. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4749. for (int i = 0; i < FlightsCode.Length; i++)
  4750. {
  4751. var air = new AirInfo();
  4752. string[] tempstr = DayArray[i]
  4753. .Replace("\r\n", string.Empty)
  4754. .Replace("\\r\\n", string.Empty)
  4755. .TrimStart().TrimEnd()
  4756. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4757. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4758. string starCity = "";
  4759. if (star_Three != null)
  4760. {
  4761. string str2 = "--";
  4762. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4763. if (!string.IsNullOrEmpty(translateResult2))
  4764. {
  4765. str2 = translateResult2;
  4766. str2 = _airTicketResRep.Processing(str2);
  4767. }
  4768. starCity = str2;
  4769. }
  4770. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4771. string EndCity = "";
  4772. if (End_Three != null)
  4773. {
  4774. string str1 = "--";
  4775. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4776. if (!string.IsNullOrEmpty(translateResult1))
  4777. {
  4778. str1 = translateResult1;
  4779. str1 = _airTicketResRep.Processing(str1);
  4780. }
  4781. EndCity = str1;
  4782. }
  4783. air.Destination = starCity + "/" + EndCity;
  4784. air.Flight = FlightsCode[i];
  4785. string str = "--";
  4786. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4787. if (!string.IsNullOrEmpty(translateResult))
  4788. {
  4789. str = translateResult;
  4790. str = _airTicketResRep.Processing(str);
  4791. }
  4792. air.SeatingClass = str;
  4793. string dateTime = tempstr[2];
  4794. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4795. air.FlightDate = DateTemp;
  4796. air.DepartureTime = tempstr[5];
  4797. air.LandingTime = tempstr[6];
  4798. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4799. air.TicketStatus = "--";
  4800. air.Luggage = "--";
  4801. air.DepartureTerminal = "--";
  4802. air.LandingTerminal = "--";
  4803. airs.Add(air);
  4804. }
  4805. int row = 13;
  4806. for (int i = 0; i < airs.Count; i++)
  4807. {
  4808. if (airs.Count > 2)
  4809. {
  4810. for (int j = 0; j < airs.Count - 2; j++)
  4811. {
  4812. var CopyRow = table.Rows[12].Clone(true);
  4813. table.Rows.Add(CopyRow);
  4814. }
  4815. }
  4816. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4817. int index = 0;
  4818. foreach (PropertyInfo property in properties)
  4819. {
  4820. string value = property.GetValue(airs[i]).ToString();
  4821. Cell ishcel0 = table.Rows[row].Cells[index];
  4822. var p = new Paragraph(doc);
  4823. string s = value;
  4824. p.AppendChild(new Run(doc, s));
  4825. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4826. ishcel0.AppendChild(p);
  4827. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4828. //ishcel0.CellFormat.VerticalAlignment=
  4829. index++;
  4830. }
  4831. row++;
  4832. }
  4833. #endregion
  4834. var lastParagraph = new Paragraph(doc);
  4835. //第一个表格末尾加段落
  4836. table.ParentNode.InsertAfter(lastParagraph, table);
  4837. //复制第一个表格
  4838. Table cloneTable = (Table)table.Clone(true);
  4839. //在文档末尾段落后面加入复制的表格
  4840. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4841. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4842. {
  4843. int rownewsIndex = 13;
  4844. for (int i = 0; i < 2; i++)
  4845. {
  4846. var CopyRow = table.Rows[12].Clone(true);
  4847. table.Rows.RemoveAt(13);
  4848. table.Rows.Add(CopyRow);
  4849. rownewsIndex++;
  4850. }
  4851. }
  4852. else
  4853. {
  4854. table.Rows.RemoveAt(12);
  4855. }
  4856. cloneTable.Rows.RemoveAt(12);
  4857. }
  4858. if (_AirTicketReservations.Count != 0)
  4859. {
  4860. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4861. if (FlightsCode.Length != 0)
  4862. {
  4863. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4864. if (_AirCompany != null)
  4865. {
  4866. string str = "--";
  4867. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4868. if (!string.IsNullOrEmpty(translateResult))
  4869. {
  4870. str = translateResult;
  4871. str = _airTicketResRep.Processing(str);
  4872. }
  4873. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4874. }
  4875. else
  4876. {
  4877. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4878. }
  4879. }
  4880. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4881. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4882. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4883. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4884. string names = "";
  4885. foreach (string clientName in nameArray)
  4886. {
  4887. names += clientName + ",";
  4888. }
  4889. if (!string.IsNullOrWhiteSpace(names))
  4890. {
  4891. string str = "--";
  4892. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4893. if (!string.IsNullOrEmpty(translateResult))
  4894. {
  4895. str = translateResult;
  4896. str = _airTicketResRep.Processing(str);
  4897. }
  4898. table.Range.Bookmarks["ClientName"].Text = str;
  4899. }
  4900. else
  4901. {
  4902. table.Range.Bookmarks["ClientName"].Text = "--";
  4903. }
  4904. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4905. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4906. table.Range.Bookmarks["JointTicket"].Text = "--";
  4907. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4908. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4909. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4910. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4911. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4912. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4913. }
  4914. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4915. //保存合并后的文档
  4916. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4917. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4918. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4919. return Ok(JsonView(true, "成功!", rst));
  4920. }
  4921. }
  4922. }
  4923. catch (Exception ex)
  4924. {
  4925. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4926. throw;
  4927. }
  4928. }
  4929. #endregion
  4930. #region 团组增减款项 --> 其他款项
  4931. /// <summary>
  4932. /// 团组增减款项下拉框绑定
  4933. /// </summary>
  4934. /// <param name="dto"></param>
  4935. /// <returns></returns>
  4936. [HttpPost]
  4937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4938. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4939. {
  4940. #region 参数验证
  4941. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4942. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4943. #endregion
  4944. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4945. }
  4946. /// <summary>
  4947. /// 根据团组Id查询团组增减款项
  4948. /// </summary>
  4949. /// <param name="dto"></param>
  4950. /// <returns></returns>
  4951. [HttpPost]
  4952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4953. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4954. {
  4955. #region 参数验证
  4956. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4957. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4958. #endregion
  4959. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4960. }
  4961. /// <summary>
  4962. /// 团组增减款项操作(Status:1.新增,2.修改)
  4963. /// </summary>
  4964. /// <param name="dto"></param>
  4965. /// <returns></returns>
  4966. [HttpPost]
  4967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4968. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4969. {
  4970. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4971. if (groupData.Code != 200)
  4972. {
  4973. return Ok(JsonView(false, groupData.Msg));
  4974. }
  4975. #region 应用推送
  4976. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4977. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4978. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4979. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4980. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4981. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4982. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  4983. if (recheck)
  4984. {
  4985. //自动审核
  4986. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4987. }
  4988. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4989. //2024-10-21 新增LZ UID
  4990. var userIds = new List<int>() { 21 };
  4991. string title = $"系统通知";
  4992. string content = "";
  4993. var diId = dto.DiId;
  4994. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4995. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4996. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4997. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4998. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4999. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  5000. #endregion
  5001. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5002. }
  5003. /// <summary>
  5004. /// 团组增减款项操作 删除
  5005. /// </summary>
  5006. /// <param name="dto"></param>
  5007. /// <returns></returns>
  5008. [HttpPost]
  5009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5010. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  5011. {
  5012. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  5013. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  5014. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  5015. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  5016. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  5017. }
  5018. /// <summary>
  5019. /// 根据团组增减款项Id查询
  5020. /// </summary>
  5021. /// <param name="dto"></param>
  5022. /// <returns></returns>
  5023. [HttpPost]
  5024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5025. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  5026. {
  5027. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  5028. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  5029. }
  5030. /// <summary>
  5031. /// 查询供应商名称
  5032. /// </summary>
  5033. /// <param name="dto"></param>
  5034. /// <returns></returns>
  5035. [HttpPost]
  5036. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  5037. {
  5038. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  5039. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  5040. ?? new List<Grp_DecreasePayments>();
  5041. dbResult = dbResult.Distinct(new
  5042. ProductComparer()).ToList();
  5043. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  5044. {
  5045. x.Id,
  5046. x.SupplierAddress,
  5047. x.SupplierArea,
  5048. x.SupplierContact,
  5049. x.SupplierContactNumber,
  5050. x.SupplierEmail,
  5051. x.SupplierName,
  5052. x.SupplierSocialAccount,
  5053. x.SupplierTypeId,
  5054. }).ToList());
  5055. return Ok(jw);
  5056. }
  5057. /// <summary>
  5058. /// 团组增减款项 OTA匹配
  5059. /// </summary>
  5060. /// <param name="file"></param>
  5061. /// <returns></returns>
  5062. [HttpPost]
  5063. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  5064. {
  5065. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  5066. string fileName = file.FileName;
  5067. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  5068. {
  5069. return Ok(JsonView(false, "请上传Excel文件!"));
  5070. }
  5071. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  5072. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  5073. if (!Directory.Exists(path))
  5074. {
  5075. Directory.CreateDirectory(path);
  5076. }
  5077. var filePath = @$"{path}/{fileName}";
  5078. //保存文件
  5079. using (FileStream fs = System.IO.File.Create(filePath))
  5080. {
  5081. file.CopyTo(fs);
  5082. fs.Flush();
  5083. }
  5084. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  5085. //读取ExcelFile
  5086. DataTable dt = ConvertExcelToDataTable(filePath);
  5087. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  5088. dt.TableName = "TB";
  5089. //修改table列名
  5090. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  5091. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  5092. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  5093. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  5094. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  5095. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  5096. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  5097. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  5098. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  5099. dt.Columns[9].ColumnName = "Quantity"; // 台数
  5100. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  5101. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  5102. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  5103. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  5104. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  5105. var otaOrderNos = new List<string>();
  5106. foreach (DataRow item in dt.Rows)
  5107. {
  5108. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  5109. }
  5110. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  5111. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  5112. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  5113. .Select((dp, di) => new
  5114. {
  5115. dp.PriceName,
  5116. dp.OTAOrderNo,
  5117. dp.FeeTotal,
  5118. di.TeamName,
  5119. })
  5120. .ToListAsync();
  5121. foreach (DataRow item in dt.Rows)
  5122. {
  5123. var otaOrderNo = item["OTAOrderNo"].ToString();
  5124. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  5125. if (oaData == null) continue;
  5126. item["GroupName"] = oaData.TeamName;
  5127. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  5128. }
  5129. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  5130. var pairs = new Dictionary<string, object>();
  5131. var datas = new List<DataTable>
  5132. {
  5133. dt
  5134. };
  5135. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  5136. return Ok(JsonView(true, "操作成功", new { url }));
  5137. }
  5138. #region
  5139. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  5140. {
  5141. // 创建Workbook对象
  5142. var workbook = new Workbook(excelFilePath);
  5143. // 获取第一个工作表
  5144. var worksheet = workbook.Worksheets[0];
  5145. // 将工作表转换为DataTable
  5146. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  5147. return dataTable;
  5148. }
  5149. #endregion
  5150. /// <summary>
  5151. /// 世运会数据
  5152. /// </summary>
  5153. /// <returns></returns>
  5154. [HttpGet]
  5155. public IActionResult WorldGamesData()
  5156. {
  5157. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  5158. var groupMenu = setData.GroupBy(x => x.T0);
  5159. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  5160. foreach (var item in groupMenu)
  5161. {
  5162. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  5163. {
  5164. Data = new SetDataView
  5165. {
  5166. Name = item.Key
  5167. },
  5168. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  5169. });
  5170. }
  5171. return Ok(JsonView(true, "success", resultArr));
  5172. }
  5173. #endregion
  5174. #region 文件上传、删除
  5175. /// <summary>
  5176. /// region 文件上传 可以带参数
  5177. /// </summary>
  5178. /// <param name="file"></param>
  5179. /// <returns></returns>
  5180. [HttpPost]
  5181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5182. public async Task<IActionResult> UploadProject(IFormFile file)
  5183. {
  5184. //var TypeName = Request.Headers["TypeName"].ToString();
  5185. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5186. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5187. ////文件名称
  5188. //string projectFileName = file.FileName;
  5189. ////上传的文件的路径
  5190. //string filePath = $"{fileDir}/{projectFileName}";
  5191. //if (TypeName == "A")//A代表团组增减款项
  5192. //{
  5193. // filePath = fileDir + $@"\团组增减款项相关文件";
  5194. // if (!Directory.Exists(filePath))
  5195. // {
  5196. // Directory.CreateDirectory(filePath);
  5197. // }
  5198. // //上传的文件的路径
  5199. // filePath += $@"\{projectFileName}";
  5200. //}
  5201. //else if (TypeName == "B")//B代表商邀相关文件
  5202. //{
  5203. // //上传的文件的路径
  5204. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5205. // if (!Directory.Exists(filePath))
  5206. // {
  5207. // Directory.CreateDirectory(filePath);
  5208. // }
  5209. // //上传的文件的路径
  5210. // filePath = $@"\{projectFileName}";
  5211. //}
  5212. //try
  5213. //{
  5214. // using (FileStream fs = System.IO.File.Create(filePath))
  5215. // {
  5216. // file.CopyTo(fs);
  5217. // fs.Flush();
  5218. // }
  5219. //}
  5220. //catch (Exception ex)
  5221. //{
  5222. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  5223. //}
  5224. //return Ok(JsonView(true, "上传成功!", projectFileName));
  5225. try
  5226. {
  5227. var TypeName = Request.Headers["TypeName"].ToString();
  5228. if (file != null)
  5229. {
  5230. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5231. //文件名称
  5232. string projectFileName = file.FileName;
  5233. //上传的文件的路径
  5234. string filePath = $"{fileDir}/{projectFileName}";
  5235. if (TypeName == "A")//A代表团组增减款项
  5236. {
  5237. if (!Directory.Exists(fileDir))
  5238. {
  5239. Directory.CreateDirectory(fileDir);
  5240. }
  5241. //上传的文件的路径
  5242. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5243. }
  5244. else if (TypeName == "B")//B代表商邀相关文件
  5245. {
  5246. if (!Directory.Exists(fileDir))
  5247. {
  5248. Directory.CreateDirectory(fileDir);
  5249. }
  5250. //上传的文件的路径
  5251. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5252. }
  5253. using (FileStream fs = System.IO.File.Create(filePath))
  5254. {
  5255. file.CopyTo(fs);
  5256. fs.Flush();
  5257. }
  5258. return Ok(JsonView(true, "上传成功!", projectFileName));
  5259. }
  5260. else
  5261. {
  5262. return Ok(JsonView(false, "上传失败!"));
  5263. }
  5264. }
  5265. catch (Exception ex)
  5266. {
  5267. return Ok(JsonView(false, ex.Message));
  5268. }
  5269. }
  5270. /// <summary>
  5271. /// 删除指定文件
  5272. /// </summary>
  5273. /// <param name="dto"></param>
  5274. /// <returns></returns>
  5275. [HttpPost]
  5276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5277. public async Task<IActionResult> DelFile(DelFileDto dto)
  5278. {
  5279. try
  5280. {
  5281. var TypeName = Request.Headers["TypeName"].ToString();
  5282. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5283. string filePath = "";
  5284. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5285. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5286. int id = 0;
  5287. if (TypeName == "A")
  5288. {
  5289. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5290. // 删除该文件
  5291. System.IO.File.Delete(filePath);
  5292. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5293. .Where(a => a.Id == dto.Id)
  5294. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5295. .ExecuteCommandAsync();
  5296. }
  5297. else if (TypeName == "B")
  5298. {
  5299. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5300. // 删除该文件
  5301. System.IO.File.Delete(filePath);
  5302. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5303. if (info != null)
  5304. {
  5305. string[] files = Array.Empty<string>();
  5306. if (!string.IsNullOrEmpty(info.Attachment))
  5307. {
  5308. try
  5309. {
  5310. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5311. }
  5312. catch (Exception)
  5313. {
  5314. files = new List<string>() { info.Attachment }.ToArray();
  5315. }
  5316. }
  5317. if (files.Length > 0)
  5318. {
  5319. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5320. string filePath2 = string.Empty;
  5321. if (files1.Length > 0)
  5322. {
  5323. filePath2 = JsonConvert.SerializeObject(files1);
  5324. }
  5325. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5326. .Where(a => a.Id == dto.Id)
  5327. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5328. .ExecuteCommandAsync();
  5329. }
  5330. }
  5331. }
  5332. if (id != 0)
  5333. {
  5334. return Ok(JsonView(true, "成功!"));
  5335. }
  5336. else
  5337. {
  5338. return Ok(JsonView(false, "失败!"));
  5339. }
  5340. }
  5341. catch (Exception ex)
  5342. {
  5343. return Ok(JsonView(false, "程序错误!"));
  5344. throw;
  5345. }
  5346. }
  5347. /// <summary>
  5348. /// 文件上传多个文件 可以带参数
  5349. /// </summary>
  5350. /// <param name="files"></param>
  5351. /// <returns></returns>
  5352. [HttpPost]
  5353. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5354. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5355. {
  5356. try
  5357. {
  5358. var TypeName = Request.Headers["TypeName"].ToString();
  5359. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5360. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5361. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5362. var filePahts = new List<string>();
  5363. foreach (var file in files)
  5364. {
  5365. //文件名称
  5366. string projectFileName = file.FileName;
  5367. //上传的文件的路径
  5368. string filePath = $"{fileDir}/{projectFileName}";
  5369. if (TypeName == "A")//A代表团组增减款项
  5370. {
  5371. if (!Directory.Exists(fileDir))
  5372. {
  5373. Directory.CreateDirectory(fileDir);
  5374. }
  5375. //上传的文件的路径
  5376. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5377. }
  5378. else if (TypeName == "B")//B代表商邀相关文件
  5379. {
  5380. if (!Directory.Exists(fileDir))
  5381. {
  5382. Directory.CreateDirectory(fileDir);
  5383. }
  5384. //上传的文件的路径
  5385. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5386. }
  5387. using (FileStream fs = System.IO.File.Create(filePath))
  5388. {
  5389. file.CopyTo(fs);
  5390. fs.Flush();
  5391. }
  5392. filePahts.Add(projectFileName);
  5393. }
  5394. return Ok(JsonView(true, "上传成功!", filePahts));
  5395. }
  5396. catch (Exception ex)
  5397. {
  5398. return Ok(JsonView(false, ex.Message));
  5399. }
  5400. }
  5401. #endregion
  5402. #region 商邀费用录入
  5403. /// <summary>
  5404. /// 根据团组Id查询商邀费用列表
  5405. /// </summary>
  5406. /// <param name="dto"></param>
  5407. /// <returns></returns>
  5408. [HttpPost]
  5409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5410. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5411. {
  5412. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5413. if (groupData.Code != 0)
  5414. {
  5415. return Ok(JsonView(false, groupData.Msg));
  5416. }
  5417. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5418. }
  5419. /// <summary>
  5420. /// 商邀费用列表
  5421. /// 下载文件
  5422. /// </summary>
  5423. /// <param name="id"></param>
  5424. /// <returns></returns>
  5425. [HttpGet("{id}")]
  5426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5427. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5428. {
  5429. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5430. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5431. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5432. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5433. var filePaths = new List<string>();
  5434. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5435. try
  5436. {
  5437. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5438. }
  5439. catch (Exception ex)
  5440. {
  5441. filePaths.Add(info.Attachment);
  5442. }
  5443. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5444. for (int i = 0; i < filePaths.Count; i++)
  5445. {
  5446. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5447. }
  5448. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5449. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5450. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5451. {
  5452. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5453. {
  5454. foreach (string filePath in filePaths)
  5455. {
  5456. if (System.IO.File.Exists(filePath))
  5457. {
  5458. // 获取文件名
  5459. string fileName = Path.GetFileName(filePath);
  5460. // 将文件添加到ZIP归档中
  5461. zipArchive.CreateEntryFromFile(filePath, fileName);
  5462. }
  5463. }
  5464. }
  5465. }
  5466. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5467. }
  5468. /// <summary>
  5469. /// 商邀费用 Info Page 基础数据源
  5470. /// </summary>
  5471. /// <returns></returns>
  5472. [HttpPost]
  5473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5474. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5475. {
  5476. try
  5477. {
  5478. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  5479. if (groupData.Code != 0)
  5480. {
  5481. return Ok(JsonView(false, groupData.Msg));
  5482. }
  5483. return Ok(JsonView(true, "操作成功", groupData.Data));
  5484. }
  5485. catch (Exception ex)
  5486. {
  5487. return Ok(JsonView(false, ex.Message));
  5488. throw;
  5489. }
  5490. }
  5491. /// <summary>
  5492. /// 根据商邀费用ID查询C表和商邀费用数据
  5493. /// </summary>
  5494. /// <param name="dto"></param>
  5495. /// <returns></returns>
  5496. [HttpPost]
  5497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5498. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5499. {
  5500. try
  5501. {
  5502. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5503. if (groupData.Code != 0)
  5504. {
  5505. return Ok(JsonView(false, groupData.Msg));
  5506. }
  5507. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5508. }
  5509. catch (Exception ex)
  5510. {
  5511. return Ok(JsonView(false, ex.Message));
  5512. throw;
  5513. }
  5514. }
  5515. /// <summary>
  5516. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5517. /// </summary>
  5518. /// <param name="dto"></param>
  5519. /// <returns></returns>
  5520. [HttpPost]
  5521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5522. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5523. {
  5524. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5525. if (groupData.Code != 0)
  5526. {
  5527. return Ok(JsonView(false, groupData.Msg));
  5528. }
  5529. #region 应用推送
  5530. try
  5531. {
  5532. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5533. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5534. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5535. //2024-10-21 新增LZ UID
  5536. var userIds = new List<int>() { 21 };
  5537. string title = $"系统通知";
  5538. string content = "";
  5539. var diId = dto.DiId;
  5540. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5541. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5542. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5543. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5544. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5545. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5546. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5547. }
  5548. catch (Exception ex)
  5549. {
  5550. }
  5551. #endregion
  5552. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5553. }
  5554. /// <summary>
  5555. /// 商邀删除
  5556. /// </summary>
  5557. /// <param name="dto"></param>
  5558. /// <returns></returns>
  5559. [HttpPost]
  5560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5561. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5562. {
  5563. try
  5564. {
  5565. _sqlSugar.BeginTran();
  5566. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5567. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5568. {
  5569. IsDel = 1,
  5570. DeleteUserId = dto.DeleteUserId,
  5571. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5572. })
  5573. .Where(it => it.Id == dto.Id)
  5574. .ExecuteCommand();
  5575. if (res1 > 0)
  5576. {
  5577. int _diId = 0;
  5578. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5579. if (_ioaInfo != null)
  5580. {
  5581. _diId = _ioaInfo.DiId;
  5582. }
  5583. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5584. .SetColumns(a => new Grp_CreditCardPayment()
  5585. {
  5586. IsDel = 1,
  5587. DeleteUserId = dto.DeleteUserId,
  5588. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5589. })
  5590. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5591. .ExecuteCommand();
  5592. if (res2 > 0)
  5593. {
  5594. _sqlSugar.CommitTran();
  5595. return Ok(JsonView(true, "删除成功!"));
  5596. }
  5597. }
  5598. _sqlSugar.RollbackTran();
  5599. return Ok(JsonView(false, "删除失败"));
  5600. }
  5601. catch (Exception ex)
  5602. {
  5603. _sqlSugar.RollbackTran();
  5604. return Ok(JsonView(false, ex.Message));
  5605. }
  5606. }
  5607. #endregion
  5608. #region 票据上传
  5609. /// <summary>
  5610. /// 团组模块文件上传
  5611. /// </summary>
  5612. /// <param name="dto"></param>
  5613. /// <returns></returns>
  5614. [HttpPost]
  5615. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5616. {
  5617. var jw = JsonView(false);
  5618. long M = 1024 * 1024;
  5619. if (dto.Files == null || dto.Files.Count == 0)
  5620. {
  5621. jw.Msg = "无文件信息!";
  5622. return Ok(jw);
  5623. }
  5624. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5625. {
  5626. jw.Msg = "文件大小超过20M!";
  5627. return Ok(jw);
  5628. }
  5629. //var nameSp = dto.File.FileName.Split(".");
  5630. //if (nameSp.Length < 2)
  5631. //{
  5632. // jw.Msg = "拓展名称有误!";
  5633. // return Ok(jw);
  5634. //}
  5635. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5636. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5637. //{
  5638. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5639. // return Ok(jw);
  5640. //}
  5641. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5642. if (Ctable == null)
  5643. {
  5644. jw.Msg = "Ctable指向有误!";
  5645. return Ok(jw);
  5646. }
  5647. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5648. if (groupInfo == null)
  5649. {
  5650. jw.Msg = "团组信息不存在!";
  5651. return Ok(jw);
  5652. }
  5653. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5654. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5655. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5656. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5657. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5658. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5659. try
  5660. {
  5661. if (!Directory.Exists(fileBase))
  5662. {
  5663. Directory.CreateDirectory(fileBase);
  5664. }
  5665. var saveArr = new List<Grp_GroupModelFile>();
  5666. foreach (var fileStream in dto.Files)
  5667. {
  5668. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5669. var file = new Grp_GroupModelFile()
  5670. {
  5671. Cid = dto.Cid,
  5672. CreateTime = DateTime.Now,
  5673. CreateUserId = dto.Userid,
  5674. Ctable = dto.Ctable,
  5675. Diid = dto.Diid,
  5676. IsDel = 0,
  5677. FilePath = saveFilePath,
  5678. FileName = fileStream.FileName
  5679. };
  5680. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5681. {
  5682. fileStream.CopyTo(fs);
  5683. fs.Flush();
  5684. }
  5685. saveArr.Add(file);
  5686. }
  5687. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5688. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5689. jw = JsonView(true, "保存成功!", new
  5690. {
  5691. count = addResult,
  5692. filesName = saveArr.Select(x => x.FileName)
  5693. });
  5694. }
  5695. catch (Exception ex)
  5696. {
  5697. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5698. {
  5699. count = 0,
  5700. filesName = Array.Empty<string>(),
  5701. });
  5702. }
  5703. return Ok(jw);
  5704. }
  5705. /// <summary>
  5706. /// 查询各模块已保存文件
  5707. /// </summary>
  5708. /// <param name="dto"></param>
  5709. /// <returns></returns>
  5710. [HttpPost]
  5711. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5712. {
  5713. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5714. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5715. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5716. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5717. {
  5718. expression = Expressionable.Create<Grp_GroupModelFile>()
  5719. .And(x => visaIds.Contains(x.CreateUserId));
  5720. }
  5721. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5722. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5723. .Where(expression.ToExpression())
  5724. .ToList();
  5725. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5726. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5727. {
  5728. x.FileName,
  5729. x.Id,
  5730. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5731. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5732. })));
  5733. }
  5734. /// <summary>
  5735. /// 下载该团组下的所有文件
  5736. /// </summary>
  5737. /// <param name="dto"></param>
  5738. /// <returns></returns>
  5739. [HttpPost]
  5740. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5741. {
  5742. var jw = JsonView(false);
  5743. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5744. if (groupInfo == null)
  5745. {
  5746. jw.Msg = "团组信息不存在!";
  5747. return Ok(jw);
  5748. }
  5749. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5750. var isModule = Convert.ToBoolean(dto.isModule);
  5751. var Zips = new Dictionary<string, Stream>();
  5752. var io = new IOOperatorHelper();
  5753. if (isModule)
  5754. {
  5755. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5756. foreach (var moduleArr in moduleGroup)
  5757. {
  5758. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5759. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5760. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5761. var chiZips = new Dictionary<string, Stream>();
  5762. foreach (var item in moduleArr)
  5763. {
  5764. if (System.IO.File.Exists(item.FilePath))
  5765. {
  5766. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5767. {
  5768. byte[] bytes = new byte[fileStream.Length];
  5769. fileStream.Read(bytes, 0, bytes.Length);
  5770. fileStream.Close();
  5771. Stream stream = new MemoryStream(bytes);
  5772. chiZips.Add(item.FileName, stream);
  5773. }
  5774. }
  5775. }
  5776. if (chiZips.Count > 0)
  5777. {
  5778. var byts = io.ConvertZipStream(chiZips);
  5779. Stream stream = new MemoryStream(byts);
  5780. Zips.Add(key.Name + "_.zip", stream);
  5781. }
  5782. }
  5783. }
  5784. else
  5785. {
  5786. foreach (var item in dbQuery)
  5787. {
  5788. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5789. {
  5790. byte[] bytes = new byte[fileStream.Length];
  5791. fileStream.Read(bytes, 0, bytes.Length);
  5792. fileStream.Close();
  5793. var stream = new MemoryStream(bytes);
  5794. while (Zips.ContainsKey(item.FileName))
  5795. {
  5796. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5797. }
  5798. Zips.Add(item.FileName, stream);
  5799. }
  5800. }
  5801. }
  5802. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5803. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5804. if (Zips.Count > 0)
  5805. {
  5806. var byts = io.ConvertZipStream(Zips);
  5807. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5808. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5809. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5810. }
  5811. else
  5812. {
  5813. jw.Msg = "暂无生成文件!";
  5814. }
  5815. return Ok(jw);
  5816. }
  5817. /// <summary>
  5818. /// 下载该团组下此模块的所有文件
  5819. /// </summary>
  5820. /// <param name="dto"></param>
  5821. /// <returns></returns>
  5822. [HttpPost]
  5823. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5824. {
  5825. var jw = JsonView(false);
  5826. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5827. if (groupInfo == null)
  5828. {
  5829. jw.Msg = "团组信息不存在!";
  5830. return Ok(jw);
  5831. }
  5832. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5833. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5834. && x.IsDel == 0);
  5835. if (key == null)
  5836. {
  5837. jw.Msg = "Ctable指向错误!";
  5838. return Ok(jw);
  5839. }
  5840. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5841. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5842. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5843. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5844. var io = new IOOperatorHelper();
  5845. var Zips = new Dictionary<string, Stream>();
  5846. foreach (var item in dbQuery)
  5847. {
  5848. if (System.IO.File.Exists(item.FilePath))
  5849. {
  5850. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5851. {
  5852. byte[] bytes = new byte[fileStream.Length];
  5853. fileStream.Read(bytes, 0, bytes.Length);
  5854. fileStream.Close();
  5855. var stream = new MemoryStream(bytes);
  5856. while (Zips.ContainsKey(item.FileName))
  5857. {
  5858. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5859. }
  5860. Zips.Add(item.FileName, stream);
  5861. }
  5862. }
  5863. }
  5864. if (Zips.Count > 0)
  5865. {
  5866. var byts = io.ConvertZipStream(Zips);
  5867. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5868. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5869. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5870. }
  5871. else
  5872. {
  5873. jw.Msg = "暂无生成文件!";
  5874. }
  5875. return Ok(jw);
  5876. }
  5877. /// <summary>
  5878. /// 删除该团组下的指定文件
  5879. /// </summary>
  5880. /// <param name="dto"></param>
  5881. /// <returns></returns>
  5882. [HttpPost]
  5883. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5884. {
  5885. var jw = JsonView(false);
  5886. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5887. if (sing == null)
  5888. {
  5889. jw.Msg = "暂无";
  5890. return Ok(jw);
  5891. }
  5892. if (System.IO.File.Exists(sing.FilePath))
  5893. {
  5894. try
  5895. {
  5896. System.IO.File.Delete(sing.FilePath);
  5897. }
  5898. catch (Exception ex)
  5899. {
  5900. jw.Msg = "删除失败!" + ex.Message;
  5901. return Ok(jw);
  5902. }
  5903. }
  5904. sing.IsDel = 1;
  5905. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5906. sing.DeleteUserId = dto.UserId;
  5907. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5908. jw = JsonView(true, "删除成功!");
  5909. return Ok(jw);
  5910. }
  5911. #endregion
  5912. #region 共享文件上传
  5913. /// <summary>
  5914. /// 共享文件数据初始化
  5915. /// </summary>
  5916. /// <returns></returns>
  5917. [HttpGet]
  5918. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5919. {
  5920. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5921. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5922. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5923. .Select(x => x.Id)
  5924. .ToList()
  5925. .Contains(userid);
  5926. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5927. .Where(x => x.STid == 111 && x.IsDel == 0)
  5928. .Select(x => new
  5929. {
  5930. x.Name,
  5931. x.Id,
  5932. }).ToList();
  5933. if (isMarketingDepartment)
  5934. {
  5935. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5936. }
  5937. if (portType == 1)
  5938. {
  5939. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5940. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5941. .Where(x => x.IsDel == 0)
  5942. .OrderByDescending(x => x.VisitDate)
  5943. .Select(x => new
  5944. {
  5945. x.TeamName,
  5946. x.Id,
  5947. x.CityId,
  5948. })
  5949. .ToList()
  5950. .Select(x =>
  5951. {
  5952. var provinceId = x.CityId;
  5953. var isDefualtVal = true;
  5954. if (provinceId > 0)
  5955. {
  5956. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5957. if (parentId != null)
  5958. {
  5959. isDefualtVal = false;
  5960. provinceId = (int)parentId;
  5961. }
  5962. }
  5963. if (isDefualtVal)
  5964. {
  5965. provinceId = 122; //默认四川
  5966. }
  5967. return new
  5968. {
  5969. x.TeamName,
  5970. x.Id,
  5971. provinceId,
  5972. };
  5973. })
  5974. .ToList();
  5975. return Ok(JsonView(true, "SUCCESS!", new
  5976. {
  5977. dropDownType,
  5978. dropDownGroupList,
  5979. isMarketingDepartment
  5980. }));
  5981. }
  5982. else if (portType == 2 || portType == 3)
  5983. {
  5984. return Ok(JsonView(true, "SUCCESS!", new
  5985. {
  5986. dropDownType,
  5987. isMarketingDepartment
  5988. }));
  5989. }
  5990. else
  5991. {
  5992. return Ok(JsonView(false, "portType有误!"));
  5993. }
  5994. }
  5995. /// <summary>
  5996. /// 共享文件上传
  5997. /// </summary>
  5998. /// <param name="dto"></param>
  5999. /// <returns></returns>
  6000. [HttpPost]
  6001. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  6002. {
  6003. var isGroup = new List<int> { 1412 };
  6004. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  6005. {
  6006. return Ok(JsonView(false, "该文件需要关联团组!"));
  6007. }
  6008. if (dto.Files == null || dto.Files.Count == 0)
  6009. {
  6010. return Ok(JsonView(false, "无文件信息!"));
  6011. }
  6012. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  6013. {
  6014. return Ok(JsonView(false, "文件大小超过20M!"));
  6015. }
  6016. if (dto.Userid < 1)
  6017. {
  6018. return Ok(JsonView(false, "请传入有效的Userid!"));
  6019. }
  6020. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  6021. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  6022. .Select((u, j) => new
  6023. {
  6024. u.CnName,
  6025. UserId = u.Id,
  6026. j.JobName,
  6027. })
  6028. .First();
  6029. if (jobInfo == null)
  6030. {
  6031. return Ok(JsonView(false, "请传入有效的Userid!"));
  6032. }
  6033. var commonFileExtensions = new List<string>
  6034. {
  6035. // 文本文件
  6036. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  6037. // 图片文件
  6038. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  6039. // 视频文件
  6040. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  6041. // 音频文件
  6042. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  6043. // 压缩文件
  6044. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  6045. // 数据文件
  6046. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  6047. };
  6048. try
  6049. {
  6050. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  6051. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  6052. commonFileExtensions.AddRange(settingExtend);
  6053. }
  6054. catch (Exception)
  6055. { }
  6056. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  6057. if (setdata == null)
  6058. {
  6059. return Ok(JsonView(false, "请传入有效的FileType!"));
  6060. }
  6061. var insertList = new List<Grp_GroupShareFile>();
  6062. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  6063. if (!Directory.Exists(winPath))
  6064. {
  6065. Directory.CreateDirectory(winPath);
  6066. }
  6067. foreach (var item in dto.Files)
  6068. {
  6069. var houzui = Path.GetExtension(item.FileName);
  6070. if (!commonFileExtensions.Contains(houzui))
  6071. {
  6072. return Ok(JsonView(false, "未知后缀名称!"));
  6073. }
  6074. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  6075. var saveFilePath = winPath + fileName;
  6076. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6077. {
  6078. item.CopyTo(fs);
  6079. fs.Flush();
  6080. }
  6081. var fileDetail = new Grp_GroupShareFile()
  6082. {
  6083. CreateUserId = dto.Userid,
  6084. CreateTime = DateTime.Now,
  6085. UploadJob = jobInfo.JobName,
  6086. FileName = fileName,
  6087. FileType = dto.FileType,
  6088. Diid = dto.Diid,
  6089. FilePath = winPath + fileName,
  6090. };
  6091. insertList.Add(fileDetail);
  6092. }
  6093. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  6094. return Ok(JsonView(true, "保存成功!"));
  6095. }
  6096. /// <summary>
  6097. /// 查询共享文件列表
  6098. /// </summary>
  6099. /// <param name="dto"></param>
  6100. /// <returns></returns>
  6101. [HttpPost]
  6102. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  6103. {
  6104. var isGroup = new List<int> { 1412 };
  6105. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  6106. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  6107. .And(x => x.Diid == dto.Diid)
  6108. .And(x => x.FileType == dto.FileType)
  6109. .And(x => x.IsDel == 0)
  6110. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  6111. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  6112. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  6113. int totalCount = 0;
  6114. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  6115. .Where(queryExpression.ToExpression())
  6116. .OrderBy(x => x.UploadJob)
  6117. .Select(x => new
  6118. {
  6119. x.Id,
  6120. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  6121. x.FileName,
  6122. x.FileType,
  6123. x.CreateTime,
  6124. })
  6125. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  6126. return Ok(JsonView(true, "SUCCESS!", new
  6127. {
  6128. FileList = dbQuery,
  6129. dto.PageSize,
  6130. dto.PageIndex,
  6131. totalCount
  6132. }));
  6133. }
  6134. /// <summary>
  6135. /// 删除共享文件模块下的指定文件
  6136. /// </summary>
  6137. /// <param name="dto"></param>
  6138. /// <returns></returns>
  6139. [HttpPost]
  6140. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  6141. {
  6142. var jw = JsonView(false);
  6143. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6144. if (sing == null)
  6145. {
  6146. jw.Msg = "暂无文件信息!";
  6147. return Ok(jw);
  6148. }
  6149. if (sing.CreateUserId != dto.UserId)
  6150. {
  6151. jw.Msg = "只能删除自己上传的文件!";
  6152. return Ok(jw);
  6153. }
  6154. if (System.IO.File.Exists(sing.FilePath))
  6155. {
  6156. try
  6157. {
  6158. System.IO.File.Delete(sing.FilePath);
  6159. }
  6160. catch (Exception ex)
  6161. {
  6162. jw.Msg = "删除失败!" + ex.Message;
  6163. return Ok(jw);
  6164. }
  6165. }
  6166. sing.IsDel = 1;
  6167. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6168. sing.DeleteUserId = dto.UserId;
  6169. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  6170. jw = JsonView(true, "删除成功!");
  6171. return Ok(jw);
  6172. }
  6173. #endregion
  6174. #region 团组英文资料
  6175. /// <summary>
  6176. /// 查询团组英文所有资料
  6177. /// </summary>
  6178. /// <param name="dto"></param>
  6179. /// <returns></returns>
  6180. [HttpPost]
  6181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6182. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6183. {
  6184. try
  6185. {
  6186. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6187. if (groupData.Code != 0)
  6188. {
  6189. return Ok(JsonView(false, groupData.Msg));
  6190. }
  6191. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6192. }
  6193. catch (Exception ex)
  6194. {
  6195. return Ok(JsonView(false, ex.Message));
  6196. throw;
  6197. }
  6198. }
  6199. /// <summary>
  6200. /// 团组英文资料操作(Status:1.新增,2.修改)
  6201. /// </summary>
  6202. /// <param name="dto"></param>
  6203. /// <returns></returns>
  6204. [HttpPost]
  6205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6206. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6207. {
  6208. try
  6209. {
  6210. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  6211. if (groupData.Code != 0)
  6212. {
  6213. return Ok(JsonView(false, groupData.Msg));
  6214. }
  6215. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6216. }
  6217. catch (Exception ex)
  6218. {
  6219. return Ok(JsonView(false, ex.Message));
  6220. throw;
  6221. }
  6222. }
  6223. /// <summary>
  6224. /// 团组英文资料Id查询数据
  6225. /// </summary>
  6226. /// <param name="dto"></param>
  6227. /// <returns></returns>
  6228. [HttpPost]
  6229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6230. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  6231. {
  6232. try
  6233. {
  6234. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  6235. if (_DelegationEnData != null)
  6236. {
  6237. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  6238. }
  6239. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  6240. }
  6241. catch (Exception ex)
  6242. {
  6243. return Ok(JsonView(false, "程序错误!"));
  6244. throw;
  6245. }
  6246. }
  6247. /// <summary>
  6248. /// 团组英文资料删除
  6249. /// </summary>
  6250. /// <param name="dto"></param>
  6251. /// <returns></returns>
  6252. [HttpPost]
  6253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6254. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6255. {
  6256. try
  6257. {
  6258. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6259. if (!res)
  6260. {
  6261. return Ok(JsonView(false, "删除失败"));
  6262. }
  6263. return Ok(JsonView(true, "删除成功!"));
  6264. }
  6265. catch (Exception ex)
  6266. {
  6267. return Ok(JsonView(false, ex.Message));
  6268. throw;
  6269. }
  6270. }
  6271. #endregion
  6272. #region 导出邀请函
  6273. /// <summary>
  6274. /// 导出邀请函页面初始化
  6275. /// </summary>
  6276. /// <param name="dto"></param>
  6277. /// <returns></returns>
  6278. [HttpPost]
  6279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6280. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6281. {
  6282. try
  6283. {
  6284. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6285. var crm_Deles = new List<Crm_DeleClient>();
  6286. if (dto.DiId == 0)
  6287. {
  6288. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6289. }
  6290. else
  6291. {
  6292. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6293. }
  6294. return Ok(JsonView(true, "查询成功!", new
  6295. {
  6296. deleClient = crm_Deles,
  6297. delegations = grp_Delegations
  6298. }));
  6299. }
  6300. catch (Exception ex)
  6301. {
  6302. return Ok(JsonView(false, "程序错误!"));
  6303. throw;
  6304. }
  6305. }
  6306. /// <summary>
  6307. /// 导出邀请函
  6308. /// </summary>
  6309. /// <param name="dto"></param>
  6310. /// <returns></returns>
  6311. [HttpPost]
  6312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6313. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6314. {
  6315. #region 参数验证
  6316. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6317. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6318. #endregion
  6319. try
  6320. {
  6321. var transDic = new Dictionary<string, string>();
  6322. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6323. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6324. From Grp_TourClientList tcl
  6325. Left Join
  6326. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6327. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6328. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6329. From Crm_DeleClient dc
  6330. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6331. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6332. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6333. Where dc.IsDel = 0) temp
  6334. On temp.DcId =tcl.ClientId
  6335. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6336. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6337. var texts = new List<string>();
  6338. if (datas.Count != 0)
  6339. {
  6340. foreach (TourClientListDetailsView item in datas)
  6341. {
  6342. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6343. {
  6344. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6345. }
  6346. else
  6347. {
  6348. string name = item.LastName + item.FirstName;
  6349. texts.Add(name);
  6350. }
  6351. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6352. {
  6353. if (!transDic.ContainsKey(item.Job))
  6354. {
  6355. texts.Add(item.Job);
  6356. }
  6357. }
  6358. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6359. {
  6360. texts.Add(item.CompanyFullName);
  6361. }
  6362. }
  6363. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6364. if (transData.Count > 0)
  6365. {
  6366. foreach (TranslateResult item in transData)
  6367. {
  6368. if (!transDic.ContainsKey(item.Query))
  6369. {
  6370. transDic.Add(item.Query, item.Translation);
  6371. }
  6372. }
  6373. }
  6374. var list = new List<GuestList>();
  6375. foreach (var dele in datas)
  6376. {
  6377. var guestList = new GuestList();
  6378. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6379. {
  6380. guestList.Name = dele.Pinyin;
  6381. }
  6382. else
  6383. {
  6384. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6385. guestList.Name = Name;
  6386. }
  6387. if (dele.Sex == 0)
  6388. {
  6389. guestList.Sex = "Male";
  6390. }
  6391. else if (dele.Sex == 1)
  6392. {
  6393. guestList.Sex = "Female";
  6394. }
  6395. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6396. if (!string.IsNullOrEmpty(dele.Job))
  6397. {
  6398. guestList.Job = dele.Job;
  6399. }
  6400. list.Add(guestList);
  6401. }
  6402. //载入模板
  6403. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6404. var builder = new DocumentBuilder(doc);
  6405. //获取word里所有表格
  6406. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6407. //获取所填表格的序数
  6408. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6409. var rowStart = tableOne.Rows[0]; //获取第1行
  6410. //循环赋值
  6411. for (int i = 0; i < list.Count; i++)
  6412. {
  6413. builder.MoveToCell(0, i + 1, 0, 0);
  6414. builder.Write(list[i].Name.ToString());
  6415. builder.MoveToCell(0, i + 1, 1, 0);
  6416. builder.Write(list[i].Sex.ToString());
  6417. builder.MoveToCell(0, i + 1, 2, 0);
  6418. builder.Write(list[i].DOB.ToString());
  6419. builder.MoveToCell(0, i + 1, 3, 0);
  6420. builder.Write(list[i].Job.ToString());
  6421. }
  6422. //删除多余行
  6423. while (tableOne.Rows.Count > list.Count + 1)
  6424. {
  6425. tableOne.Rows.RemoveAt(list.Count + 1);
  6426. }
  6427. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6428. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6429. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6430. doc.Save(filePath);
  6431. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6432. return Ok(JsonView(true, "操作成功!", Url));
  6433. }
  6434. else
  6435. {
  6436. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6437. }
  6438. }
  6439. catch (Exception ex)
  6440. {
  6441. return Ok(JsonView(false, ex.Message));
  6442. throw;
  6443. }
  6444. }
  6445. #endregion
  6446. #region 团组经理模块 出入境费用
  6447. /// <summary>
  6448. /// 团组模块 - 出入境费用 - 省份基础数据源
  6449. /// </summary>
  6450. /// <returns></returns>
  6451. [HttpGet]
  6452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6453. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6454. {
  6455. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6456. }
  6457. /// <summary>
  6458. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6459. /// </summary>
  6460. /// <param name="dto"></param>
  6461. /// <returns></returns>
  6462. [HttpPost]
  6463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6464. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6465. {
  6466. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6467. var groupNamFirst = groupNameData.FirstOrDefault();
  6468. //SetDataInfoView
  6469. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6470. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6471. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6472. //验证城市归属并给默认值
  6473. int provinceId = 122;
  6474. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6475. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6476. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6477. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6478. return Ok(JsonView(true, "查询成功!", new
  6479. {
  6480. GroupNameData = groupNameData,
  6481. CurrencyData = _CurrencyData,
  6482. WordTypeData = wordTypeData,
  6483. ExcelTypeData = excelTypeData,
  6484. CurrencyInit = _currencyInfos,
  6485. ViewPermissionData = viewPermissionData
  6486. }));
  6487. }
  6488. /// <summary>
  6489. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6490. /// </summary>
  6491. /// <returns></returns>
  6492. [HttpGet("{provinceId}")]
  6493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6494. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6495. {
  6496. //验证城市归属并给默认值
  6497. if (provinceId < 1) provinceId = 122;
  6498. /*
  6499. * 122 四川
  6500. * 108 贵州
  6501. * 103 重庆
  6502. * 132 云南
  6503. */
  6504. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6505. return Ok(JsonView(true, "查询成功!", new
  6506. {
  6507. WordTypeData = wordTypeData,
  6508. ExcelTypeData = excelTypeData,
  6509. }));
  6510. }
  6511. /// <summary>
  6512. /// 团组模块 - 出入境费用
  6513. /// 实时汇率 tips
  6514. /// 签证费用 tips
  6515. /// 机票费用 tips
  6516. /// </summary>
  6517. /// <returns></returns>
  6518. [HttpPost]
  6519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6520. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6521. {
  6522. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6523. //默认币种显示
  6524. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6525. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6526. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6527. return Ok(JsonView(true, "查询成功!", new
  6528. {
  6529. //GroupNameData = groupNameData.Data,
  6530. visaData = visaData.Data,
  6531. airData,
  6532. reteInfos
  6533. }));
  6534. }
  6535. /// <summary>
  6536. /// 团组模块 - 出入境费用 - Info
  6537. /// </summary>
  6538. /// <param name="dto"></param>
  6539. /// <returns></returns>
  6540. [HttpPost]
  6541. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6543. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6544. {
  6545. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6546. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6547. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6548. }
  6549. /// <summary>
  6550. /// 团组模块 - 出入境费用 - 设置view权限
  6551. /// </summary>
  6552. /// <returns></returns>
  6553. [HttpPost]
  6554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6555. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6556. {
  6557. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6558. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6559. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6560. var permissions = new List<Grp_EnterExitCostPermission>();
  6561. foreach (var userId in dto.UserIds)
  6562. {
  6563. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6564. }
  6565. if (permissions.Any())
  6566. {
  6567. _sqlSugar.BeginTran();
  6568. try
  6569. {
  6570. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6571. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6572. if (result < 1)
  6573. {
  6574. _sqlSugar.RollbackTran();
  6575. return Ok(JsonView(false));
  6576. }
  6577. }
  6578. catch (Exception ex)
  6579. {
  6580. _sqlSugar.RollbackTran();
  6581. return Ok(JsonView(false, ex.Message));
  6582. }
  6583. _sqlSugar.CommitTran();
  6584. return Ok(JsonView(true));
  6585. }
  6586. return Ok(JsonView(false));
  6587. }
  6588. /// <summary>
  6589. /// 团组模块 - 出入境费用 - Add And Update
  6590. /// </summary>
  6591. /// <returns></returns>
  6592. [HttpPost]
  6593. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6595. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6596. {
  6597. try
  6598. {
  6599. var rateRecords = new List<RateRecordInfo>();
  6600. #region 汇率保存前存储
  6601. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  6602. if (info != null)
  6603. {
  6604. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  6605. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  6606. {
  6607. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  6608. {
  6609. CurrencyCode = x.CurrencyCode,
  6610. CurrencyName = x.CurrencyName,
  6611. UpdatePreRate = x.Rate,
  6612. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  6613. }).ToList();
  6614. }
  6615. else
  6616. {
  6617. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6618. {
  6619. CurrencyCode = x.CurrencyCode,
  6620. CurrencyName = x.CurrencyName,
  6621. UpdatePreRate = 0.00M,
  6622. UpdateBreRate = x.Rate
  6623. }).ToList();
  6624. }
  6625. }
  6626. else
  6627. {
  6628. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6629. {
  6630. CurrencyCode = x.CurrencyCode,
  6631. CurrencyName = x.CurrencyName,
  6632. UpdatePreRate = 0.00M,
  6633. UpdateBreRate = x.Rate
  6634. }).ToList();
  6635. }
  6636. #endregion
  6637. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6638. if (dto.DayOtherPriceData.Any())
  6639. {
  6640. var inserList = dto.DayOtherPriceData
  6641. .Where(x => x.Id == 0)
  6642. .Select(x => new Grp_DayOtherPrice
  6643. {
  6644. Cost = x.Cost,
  6645. Id = x.Id,
  6646. CreateTime = DateTime.Now,
  6647. CreateUserId = dto.UserId,
  6648. Currency = x.Currency,
  6649. Diid = x.DiId,
  6650. Index = x.Index,
  6651. IsDel = 0,
  6652. SetDataId = x.SetDataId,
  6653. SubTotal = x.SubTotal,
  6654. Remark = x.Remark
  6655. })
  6656. .ToList();
  6657. var updateList = dto.DayOtherPriceData
  6658. .Where(x => x.Id != 0)
  6659. .Select(x => new Grp_DayOtherPrice
  6660. {
  6661. Cost = x.Cost,
  6662. Id = x.Id,
  6663. CreateTime = DateTime.Now,
  6664. CreateUserId = dto.UserId,
  6665. Currency = x.Currency,
  6666. Diid = x.DiId,
  6667. Index = x.Index,
  6668. IsDel = 0,
  6669. SetDataId = x.SetDataId,
  6670. SubTotal = x.SubTotal,
  6671. Remark = x.Remark
  6672. })
  6673. .ToList();
  6674. //添加
  6675. _sqlSugar.BeginTran();
  6676. if (inserList.Any())
  6677. {
  6678. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6679. }
  6680. if (updateList.Any())
  6681. {
  6682. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6683. }
  6684. _sqlSugar.CommitTran();
  6685. }
  6686. if (data.Code != 0)
  6687. {
  6688. return Ok(JsonView(false, data.Msg));
  6689. }
  6690. //生成默认文件pdf并且通知人员
  6691. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6692. {
  6693. DiId = dto.DiId,
  6694. ExportType = 1,
  6695. SubTypeId = 1005
  6696. }, "pdf");
  6697. //发送通知
  6698. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6699. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6700. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6701. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6702. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6703. //汇率信息记录
  6704. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6705. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  6706. //汇率验证、反推
  6707. (bool isSendMsg, string msgContent, List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  6708. if (isSendMsg)
  6709. {
  6710. //消息推送
  6711. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId, dto.UserId, msgContent);
  6712. }
  6713. #region //日志汇率记录
  6714. //按照已使用币种记录
  6715. if (checkCurrencys != null && checkCurrencys.Count > 0)
  6716. {
  6717. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  6718. //汇率记录中加入实时汇率
  6719. if (liveRates != null && liveRates.Count > 0)
  6720. {
  6721. foreach (var item in rateRecords)
  6722. {
  6723. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  6724. }
  6725. }
  6726. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  6727. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  6728. var logContent = new StringBuilder();
  6729. foreach (var item in rateRecords)
  6730. {
  6731. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  6732. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  6733. logContent.AppendLine(msg);
  6734. }
  6735. _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());
  6736. }
  6737. #endregion
  6738. return Ok(JsonView(true, data.Msg, data.Data));
  6739. }
  6740. catch (Exception ex)
  6741. {
  6742. return Ok(JsonView(false, ex.Message));
  6743. }
  6744. }
  6745. /// <summary>
  6746. /// 团组模块 - 出入境费用 - Confirm 费用
  6747. /// </summary>
  6748. /// <returns></returns>
  6749. [HttpPost]
  6750. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6751. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6752. {
  6753. //TODO:测试完毕需把对应的用户ID更改
  6754. //1、数据表添加字段
  6755. //2、更改字段接口()
  6756. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6757. //3、确认成功 给财务发送消息
  6758. if (_view.Code == 200)
  6759. {
  6760. if (dto.Type == 1)
  6761. {
  6762. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6763. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6764. }
  6765. }
  6766. return Ok(_view);
  6767. }
  6768. /// <summary>
  6769. /// 团组模块 - 出入境费用 - File download
  6770. /// </summary>
  6771. /// <param name="dto"></param>
  6772. /// <returns></returns>
  6773. [HttpPost]
  6774. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6776. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6777. {
  6778. try
  6779. {
  6780. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6781. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6782. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6783. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6784. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6785. 3 团组成员名单 1 团组成员名单", ""));
  6786. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6787. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6788. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6789. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6790. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6791. //数据源
  6792. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6793. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6794. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6795. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6796. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6797. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6798. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6799. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6800. .Select((x, a, b) => new
  6801. {
  6802. x.Index,
  6803. itemName = a.Name,
  6804. CurrencyStr = b.Name,
  6805. x.Cost,
  6806. x.SubTotal,
  6807. x.Remark
  6808. })
  6809. .OrderBy((x) => x.Index)
  6810. .ToList(); //其他款项费用
  6811. var peiceItemCurrencys = new List<string>();
  6812. if (_DayAndCosts.Any())
  6813. {
  6814. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6815. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6816. }
  6817. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6818. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6819. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6820. {
  6821. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6822. }
  6823. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6824. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6825. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6826. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6827. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6828. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6829. .Select((tcl, dc, cc) => new ClientInfo
  6830. {
  6831. LastName = dc.LastName,
  6832. FirstName = dc.FirstName,
  6833. Sex = dc.Sex,
  6834. Birthday = dc.BirthDay,
  6835. Company = cc.CompanyFullName,
  6836. Job = dc.Job
  6837. })
  6838. .ToList();
  6839. foreach (var item in DeleClientList)
  6840. {
  6841. EncryptionProcessor.DecryptProperties(item);
  6842. }
  6843. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6844. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6845. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6846. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6847. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6848. if (dto.ExportType == 1) //明细表
  6849. {
  6850. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6851. {
  6852. //获取模板
  6853. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6854. //载入模板
  6855. var doc = new Document(tempPath);
  6856. var builder = new DocumentBuilder(doc);
  6857. var dic = new Dictionary<string, string>();
  6858. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6859. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6860. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6861. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6862. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6863. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6864. //境内费用(其他费用)
  6865. if (_EnterExitCosts.ChoiceOne == 1)
  6866. {
  6867. string row1_1 = "";
  6868. if (_EnterExitCosts.Visa > 0)
  6869. {
  6870. //insidePayTotal += _EnterExitCosts.Visa;
  6871. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 元/人";
  6872. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6873. //{
  6874. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6875. //}
  6876. }
  6877. string row1_2 = "";
  6878. if (_EnterExitCosts.YiMiao > 0)
  6879. {
  6880. //insidePayTotal += _EnterExitCosts.YiMiao;
  6881. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 元/人";
  6882. }
  6883. if (_EnterExitCosts.HeSuan > 0)
  6884. {
  6885. //insidePayTotal += _EnterExitCosts.HeSuan;
  6886. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 元/人";
  6887. }
  6888. if (_EnterExitCosts.Service > 0)
  6889. {
  6890. //insidePayTotal += _EnterExitCosts.Service;
  6891. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 元/人";
  6892. }
  6893. string row1_3 = "";
  6894. if (_EnterExitCosts.Safe > 0)
  6895. {
  6896. //insidePayTotal += _EnterExitCosts.Safe;
  6897. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 元/人";
  6898. }
  6899. if (_EnterExitCosts.Ticket > 0)
  6900. {
  6901. //insidePayTotal += _EnterExitCosts.Ticket;
  6902. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 元/人";
  6903. }
  6904. string row1 = "";
  6905. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6906. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6907. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6908. row1 += $"备注:{_EnterExitCosts.Remark}";
  6909. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6910. dic.Add("Row1Str", row1);
  6911. }
  6912. string airTotalStr = string.Empty,
  6913. airPriceStr = string.Empty;
  6914. //经济舱
  6915. if (_EnterExitCosts.SumJJC == 1)
  6916. {
  6917. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  6918. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  6919. }
  6920. //公务舱
  6921. if (_EnterExitCosts.SumGWC == 1)
  6922. {
  6923. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  6924. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  6925. }
  6926. //头等舱
  6927. if (_EnterExitCosts.SumTDC == 1)
  6928. {
  6929. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  6930. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  6931. }
  6932. //汇率描述
  6933. string rateStr = "";
  6934. if (peiceItemCurrencyInfos.Any())
  6935. {
  6936. rateStr = "\r\n汇率描述:";
  6937. foreach (var item in peiceItemCurrencyInfos)
  6938. {
  6939. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  6940. }
  6941. }
  6942. string twoItemRemark = "备注:";
  6943. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6944. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6945. dic.Add("AirTotalStr", airTotalStr);
  6946. dic.Add("AirPriceStr", airPriceStr);
  6947. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6948. dic.Add("TwoItemRemark", twoItemRemark);
  6949. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6950. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6951. int table1Row = 0,
  6952. table2Row = 0,
  6953. table3Row = 0,
  6954. table4Row = 0,
  6955. table5Row = 0;
  6956. //住宿费
  6957. if (_EnterExitCosts.ChoiceThree == 1)
  6958. {
  6959. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6960. table1Row = dac1.Count;
  6961. #region 填充word表格内容
  6962. for (int i = 0; i < dac1.Count; i++)
  6963. {
  6964. Grp_DayAndCost dac = dac1[i];
  6965. if (dac == null) continue;
  6966. builder.MoveToCell(0, i, 0, 0);
  6967. builder.Write("第" + dac.Days.ToString() + "晚:");
  6968. builder.MoveToCell(0, i, 1, 0);
  6969. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6970. //builder.Write(dac.Place == null ? "" : dac.Place);
  6971. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6972. builder.MoveToCell(0, i, 2, 0);
  6973. builder.Write("费用标准:");
  6974. string curr = "";
  6975. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6976. if (currData != null)
  6977. {
  6978. curr = currData.Name;
  6979. }
  6980. builder.MoveToCell(0, i, 3, 0);
  6981. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6982. builder.MoveToCell(0, i, 4, 0);
  6983. builder.Write("费用小计:");
  6984. builder.MoveToCell(0, i, 5, 0);
  6985. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6986. }
  6987. #endregion
  6988. }
  6989. else dic.Add("SubZS", "0.00");
  6990. //删除多余行
  6991. while (table1.Rows.Count > table1Row)
  6992. {
  6993. table1.Rows.RemoveAt(table1Row);
  6994. }
  6995. //伙食费
  6996. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6997. if (_EnterExitCosts.ChoiceFour == 1)
  6998. {
  6999. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7000. table2Row = dac2.Count;
  7001. #region 填充word表格内容
  7002. for (int i = 0; i < dac2.Count; i++)
  7003. {
  7004. Grp_DayAndCost dac = dac2[i];
  7005. if (dac == null) continue;
  7006. builder.MoveToCell(1, i, 0, 0);
  7007. builder.Write("第" + dac.Days.ToString() + "天:");
  7008. builder.MoveToCell(1, i, 1, 0);
  7009. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7010. builder.MoveToCell(1, i, 2, 0);
  7011. builder.Write("费用标准:");
  7012. string curr = "";
  7013. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7014. if (currData != null)
  7015. {
  7016. curr = currData.Name;
  7017. }
  7018. builder.MoveToCell(1, i, 3, 0);
  7019. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7020. builder.MoveToCell(1, i, 4, 0);
  7021. builder.Write("费用小计:");
  7022. builder.MoveToCell(1, i, 5, 0);
  7023. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7024. }
  7025. #endregion
  7026. }
  7027. else dic.Add("SubHS", "0.00");
  7028. //删除多余行
  7029. while (table2.Rows.Count > table2Row)
  7030. {
  7031. table2.Rows.RemoveAt(table2Row);
  7032. }
  7033. //公杂费
  7034. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7035. if (_EnterExitCosts.ChoiceFive == 1)
  7036. {
  7037. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7038. table3Row = dac3.Count;
  7039. #region 填充word表格内容
  7040. for (int i = 0; i < dac3.Count; i++)
  7041. {
  7042. Grp_DayAndCost dac = dac3[i];
  7043. if (dac == null) continue;
  7044. builder.MoveToCell(2, i, 0, 0);
  7045. builder.Write("第" + dac.Days.ToString() + "天:");
  7046. builder.MoveToCell(2, i, 1, 0);
  7047. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7048. builder.MoveToCell(2, i, 2, 0);
  7049. builder.Write("费用标准:");
  7050. string curr = "";
  7051. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7052. if (currData != null)
  7053. {
  7054. curr = currData.Name;
  7055. }
  7056. builder.MoveToCell(2, i, 3, 0);
  7057. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7058. builder.MoveToCell(2, i, 4, 0);
  7059. builder.Write("费用小计:");
  7060. builder.MoveToCell(2, i, 5, 0);
  7061. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7062. }
  7063. //删除多余行
  7064. while (table3.Rows.Count > table3Row)
  7065. {
  7066. table3.Rows.RemoveAt(table3Row);
  7067. }
  7068. #endregion
  7069. }
  7070. else dic.Add("SubGZF", "0.00");
  7071. //删除多余行
  7072. while (table3.Rows.Count > table3Row)
  7073. {
  7074. table3.Rows.RemoveAt(table3Row);
  7075. }
  7076. //培训费
  7077. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7078. if (_EnterExitCosts.ChoiceSix == 1)
  7079. {
  7080. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  7081. dic.Add("SubPX", pxStr);
  7082. table4Row = dac4.Count;
  7083. #region 填充word表格内容
  7084. for (int i = 0; i < dac4.Count; i++)
  7085. {
  7086. Grp_DayAndCost dac = dac4[i];
  7087. if (dac == null) continue;
  7088. builder.MoveToCell(3, i, 0, 0);
  7089. builder.Write("第" + dac.Days.ToString() + "天:");
  7090. builder.MoveToCell(3, i, 1, 0);
  7091. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7092. builder.MoveToCell(3, i, 2, 0);
  7093. builder.Write("费用标准:");
  7094. string curr = "";
  7095. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7096. if (currData != null)
  7097. {
  7098. curr = currData.Name;
  7099. }
  7100. builder.MoveToCell(3, i, 3, 0);
  7101. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7102. builder.MoveToCell(3, i, 4, 0);
  7103. builder.Write("费用小计:");
  7104. builder.MoveToCell(3, i, 5, 0);
  7105. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7106. }
  7107. #endregion
  7108. }
  7109. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  7110. //删除多余行
  7111. while (table4.Rows.Count > table4Row)
  7112. {
  7113. table4.Rows.RemoveAt(table4Row);
  7114. }
  7115. //其他费用
  7116. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7117. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7118. {
  7119. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  7120. dic.Add("titleQi", qtStr);
  7121. table5Row = dac5.Count;
  7122. #region 填充word表格内容
  7123. for (int i = 0; i < dac5.Count; i++)
  7124. {
  7125. var dac = dac5[i];
  7126. if (dac == null) continue;
  7127. builder.MoveToCell(4, i, 0, 0);
  7128. builder.Write("第" + dac.Index.ToString() + "项:");
  7129. builder.MoveToCell(4, i, 1, 0);
  7130. builder.Write(dac.itemName);
  7131. builder.MoveToCell(4, i, 2, 0);
  7132. builder.Write("费用标准:");
  7133. builder.MoveToCell(4, i, 3, 0);
  7134. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7135. builder.MoveToCell(4, i, 4, 0);
  7136. builder.Write("费用小计:");
  7137. builder.MoveToCell(4, i, 5, 0);
  7138. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7139. builder.MoveToCell(4, i, 6, 0);
  7140. builder.Write("备注:");
  7141. builder.MoveToCell(4, i, 7, 0);
  7142. builder.Write(dac.Remark);
  7143. }
  7144. #endregion
  7145. }
  7146. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7147. //删除多余行
  7148. while (table5.Rows.Count > table5Row)
  7149. {
  7150. table5.Rows.RemoveAt(table5Row);
  7151. }
  7152. //加上其他费用
  7153. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7154. decimal subJJC = 0.00M,
  7155. subGWC = 0.00M,
  7156. subTDC = 0.00M;
  7157. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7158. string totalLabel = string.Format("全部费用总计:");
  7159. //经济舱
  7160. if (_EnterExitCosts.SumJJC == 1)
  7161. {
  7162. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7163. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  7164. }
  7165. //公务舱
  7166. if (_EnterExitCosts.SumGWC == 1)
  7167. {
  7168. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7169. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  7170. }
  7171. //头等舱
  7172. if (_EnterExitCosts.SumTDC == 1)
  7173. {
  7174. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7175. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  7176. }
  7177. //TotalLabel
  7178. dic.Add("TotalLabel", totalLabel);
  7179. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7180. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7181. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7182. #region 填充word模板书签内容
  7183. foreach (var key in dic.Keys)
  7184. {
  7185. Bookmark bookmark = doc.Range.Bookmarks[key];
  7186. if (bookmark != null)
  7187. {
  7188. builder.MoveToBookmark(key);
  7189. builder.Write(dic[key]);
  7190. }
  7191. }
  7192. #endregion
  7193. #region 设置页眉
  7194. string userLabel = string.Empty;
  7195. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7196. if (currUserInfo != null)
  7197. {
  7198. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  7199. if (userInfo != null)
  7200. {
  7201. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  7202. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  7203. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  7204. }
  7205. }
  7206. //设置页脚
  7207. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  7208. #endregion
  7209. //文件名
  7210. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  7211. AsposeHelper.removewatermark_v2180();
  7212. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7213. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7214. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7215. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7216. }
  7217. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7218. {
  7219. //获取模板
  7220. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7221. //载入模板
  7222. var doc = new Document(tempPath);
  7223. var builder = new DocumentBuilder(doc);
  7224. var dic = new Dictionary<string, string>();
  7225. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7226. {
  7227. var list = new List<string>();
  7228. try
  7229. {
  7230. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7231. foreach (var item in spilitArr)
  7232. {
  7233. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7234. var depCode = spDotandEmpty[2].Substring(0, 3);
  7235. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7236. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7237. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7238. list.Add(depName);
  7239. list.Add(arrName);
  7240. }
  7241. list = list.Distinct().ToList();
  7242. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7243. }
  7244. catch (Exception)
  7245. {
  7246. dic.Add("ReturnCode", "行程录入不正确!");
  7247. }
  7248. }
  7249. else
  7250. {
  7251. dic.Add("ReturnCode", "未录入行程!");
  7252. }
  7253. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7254. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7255. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7256. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7257. {
  7258. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7259. dic.Add("Day", sp.Days.ToString());
  7260. }
  7261. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7262. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7263. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7264. //dic.Add("Names", Names);
  7265. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7266. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7267. decimal dac1totalPrice = 0.00M;
  7268. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7269. foreach (var dac in dac1)
  7270. {
  7271. if (dac.SubTotal == 0.00M)
  7272. {
  7273. continue;
  7274. }
  7275. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7276. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7277. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7278. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7279. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7280. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7281. builder.Write(currency);//币种
  7282. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7283. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7284. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7285. builder.Write("");//人数
  7286. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7287. builder.Write("");//天数
  7288. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7289. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7290. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7291. decimal rate = 0.00M;
  7292. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7293. builder.Write(rate.ToString("#0.0000"));//汇率
  7294. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7295. decimal rbmPrice = dac.SubTotal;
  7296. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7297. accommodationStartIndex++;
  7298. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7299. }
  7300. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7301. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7302. {
  7303. table1.Rows.RemoveAt(i - 1);
  7304. foodandotherStartIndex--;
  7305. }
  7306. if (dac2.Count == dac3.Count)//国家 币种 金额
  7307. {
  7308. for (int i = 0; i < dac2.Count; i++)
  7309. {
  7310. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7311. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7312. }
  7313. }
  7314. decimal dac2totalPrice = 0.00M;
  7315. foreach (var dac in dac2)
  7316. {
  7317. if (dac.SubTotal == 0)
  7318. {
  7319. continue;
  7320. }
  7321. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7322. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7323. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7324. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7325. builder.Write(currency);//币种
  7326. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7327. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7328. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7329. builder.Write("");//人数
  7330. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7331. builder.Write("");//天数
  7332. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7333. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7334. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7335. decimal rate = 0.00M;
  7336. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7337. builder.Write(rate.ToString("#0.0000"));//汇率
  7338. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7339. decimal rbmPrice = dac.SubTotal;
  7340. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7341. foodandotherStartIndex++;
  7342. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7343. }
  7344. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7345. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7346. {
  7347. table1.Rows.RemoveAt(i - 1);
  7348. }
  7349. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7350. string otherFeeStr = "";
  7351. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  7352. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  7353. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  7354. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7355. foreach (var otherInfo in dac5)
  7356. {
  7357. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7358. }
  7359. #endregion
  7360. if (otherFeeStr.Length > 0)
  7361. {
  7362. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7363. otherFeeStr = $"({otherFeeStr})";
  7364. dic.Add("OtherFeeStr", otherFeeStr);
  7365. }
  7366. //总计
  7367. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7368. //国际旅费
  7369. string outsideAir = string.Empty;
  7370. string allPriceAir = string.Empty;
  7371. if (_EnterExitCosts.SumJJC == 1)
  7372. {
  7373. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7374. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7375. }
  7376. if (_EnterExitCosts.SumGWC == 1)
  7377. {
  7378. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7379. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7380. }
  7381. if (_EnterExitCosts.SumTDC == 1)
  7382. {
  7383. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7384. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7385. }
  7386. dic.Add("InTravelPrice", $"({outsideAir})");
  7387. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7388. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7389. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7390. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7391. foreach (var key in dic.Keys)
  7392. {
  7393. builder.MoveToBookmark(key);
  7394. builder.Write(dic[key]);
  7395. }
  7396. //模板文件名
  7397. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7398. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7399. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7400. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7401. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7402. }
  7403. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7404. {
  7405. //获取模板
  7406. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7407. //载入模板
  7408. var designer = new WorkbookDesigner
  7409. {
  7410. Workbook = new Workbook(tempPath)
  7411. };
  7412. var dic = new Dictionary<string, string>();
  7413. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7414. {
  7415. var list = new List<string>();
  7416. try
  7417. {
  7418. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7419. foreach (var item in spilitArr)
  7420. {
  7421. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7422. var depCode = spDotandEmpty[2].Substring(0, 3);
  7423. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7424. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7425. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7426. list.Add(depName);
  7427. list.Add(arrName);
  7428. }
  7429. list = list.Distinct().ToList();
  7430. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7431. }
  7432. catch (Exception)
  7433. {
  7434. dic.Add("ReturnCode", "行程录入不正确!");
  7435. }
  7436. }
  7437. else
  7438. {
  7439. dic.Add("ReturnCode", "未录入行程!");
  7440. }
  7441. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7442. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7443. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7444. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7445. {
  7446. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7447. dic.Add("Day", sp.Days.ToString());
  7448. }
  7449. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7450. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7451. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7452. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7453. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7454. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7455. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7456. designer.SetDataSource("Name", Names);
  7457. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7458. designer.SetDataSource("Day", dic["Day"] + "天");
  7459. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7460. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7461. int startIndex = 10;
  7462. const int startIndexcopy = 10;
  7463. if (dac2.Count == dac3.Count)//国家 币种 金额
  7464. {
  7465. for (int i = 0; i < dac2.Count; i++)
  7466. {
  7467. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7468. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7469. }
  7470. }
  7471. var dtdac1 = new DataTable();
  7472. var place = new List<string>();
  7473. dtdac1.Columns.AddRange(new DataColumn[] {
  7474. new(){ ColumnName = "city"},
  7475. new(){ ColumnName = "curr"},
  7476. new(){ ColumnName = "criterion"},
  7477. new(){ ColumnName = "number",DataType = typeof(int)},
  7478. new(){ ColumnName = "day",DataType = typeof(int)},
  7479. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7480. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7481. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7482. });
  7483. var dtdac2 = new DataTable();
  7484. dtdac2.Columns.AddRange(new DataColumn[] {
  7485. new(){ ColumnName = "city"},
  7486. new(){ ColumnName = "curr"},
  7487. new(){ ColumnName = "criterion"},
  7488. new(){ ColumnName = "number",DataType = typeof(int)},
  7489. new(){ ColumnName = "day",DataType = typeof(int)},
  7490. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7491. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7492. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7493. });
  7494. dtdac1.TableName = "tb1";
  7495. dtdac2.TableName = "tb2";
  7496. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7497. foreach (var item in dac1)
  7498. {
  7499. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7500. if (place.Contains(item.Place))
  7501. {
  7502. continue;
  7503. }
  7504. DataRow row = dtdac1.NewRow();
  7505. row["city"] = item.Place;
  7506. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7507. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7508. row["curr"] = currency;
  7509. row["rate"] = rate.ToString("#0.0000");
  7510. row["criterion"] = item.Cost.ToString("#0.00");
  7511. row["number"] = 1;
  7512. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7513. //row["costRMB"] = rbmPrice;
  7514. dtdac1.Rows.Add(row);
  7515. place.Add(item.Place);
  7516. }
  7517. place = new List<string>();
  7518. foreach (var item in dac2)
  7519. {
  7520. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7521. if (place.Contains(item.Place))
  7522. {
  7523. continue;
  7524. }
  7525. DataRow row = dtdac2.NewRow();
  7526. row["city"] = item.Place;
  7527. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7528. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7529. row["curr"] = currency;
  7530. row["rate"] = rate.ToString("#0.0000");
  7531. row["criterion"] = item.Cost.ToString("#0.00");
  7532. row["number"] = 1;
  7533. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7534. //row["cost"] = item.SubTotal;
  7535. //row["costRMB"] = rbmPrice;
  7536. dtdac2.Rows.Add(row);
  7537. place.Add(item.Place);
  7538. //dac2totalPrice += rbmPrice;
  7539. }
  7540. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7541. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7542. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7543. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7544. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7545. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7546. string cell4Str1 = string.Empty;
  7547. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7548. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7549. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7550. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7551. string cellStr = $" 5.其他费用(";
  7552. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7553. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7554. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7555. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7556. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7557. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7558. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7559. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7560. foreach (var otherInfo in dac5)
  7561. {
  7562. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7563. }
  7564. #endregion
  7565. if (cellStr.Length > 8)
  7566. {
  7567. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7568. }
  7569. cellStr += ")";
  7570. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7571. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7572. decimal pxFee = dac4.Sum(it => it.Cost);
  7573. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7574. string celllastStr1 = "";
  7575. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7576. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7577. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7578. celllastStr1 += $",国际旅费 元";
  7579. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7580. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7581. designer.SetDataSource("cell4Str", cell4Str);
  7582. designer.SetDataSource("cellStr", cellStr);
  7583. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7584. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7585. designer.SetDataSource("celllastStr", celllastStr);
  7586. Workbook wb = designer.Workbook;
  7587. var sheet = wb.Worksheets[0];
  7588. //绑定datatable数据集
  7589. designer.SetDataSource(dtdac1);
  7590. designer.SetDataSource(dtdac2);
  7591. designer.Process();
  7592. var rowStart = dtdac1.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 + 1}: I{startIndex})";
  7601. startIndex += 1; //总计行
  7602. rowStart = dtdac2.Rows.Count;
  7603. while (rowStart > 0)
  7604. {
  7605. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7606. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7607. startIndex++;
  7608. rowStart--;
  7609. }
  7610. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7611. wb.CalculateFormula(true);
  7612. //模板文件名
  7613. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7614. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7615. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7616. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7617. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7618. }
  7619. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7620. {
  7621. //获取模板
  7622. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7623. //载入模板
  7624. var doc = new Document(tempPath);
  7625. var builder = new DocumentBuilder(doc);
  7626. var dic = new Dictionary<string, string>
  7627. {
  7628. { "GroupName", _DelegationInfo.TeamName },
  7629. { "ClientUnit", _DelegationInfo.ClientUnit }
  7630. };
  7631. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7632. string missionLeaderJob = "";//负责人job
  7633. //int groupNumber = 0; //团人数
  7634. if (DeleClientList.Count > 0)
  7635. {
  7636. missionLeader = DeleClientList[0]?.Name ?? "";
  7637. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7638. }
  7639. dic.Add("MissionLeader", missionLeader); //团负责人
  7640. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7641. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7642. #region MyRegion
  7643. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7644. //{
  7645. // List<string> list = new List<string>();
  7646. // try
  7647. // {
  7648. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7649. // foreach (var item in spilitArr)
  7650. // {
  7651. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7652. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7653. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7654. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7655. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7656. // list.Add(depName);
  7657. // list.Add(arrName);
  7658. // }
  7659. // list = list.Distinct().ToList();
  7660. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7661. // }
  7662. // catch (Exception)
  7663. // {
  7664. // dic.Add("ReturnCode", "行程录入不正确!");
  7665. // }
  7666. //}
  7667. //else
  7668. //{
  7669. // dic.Add("ReturnCode", "未录入行程!");
  7670. //}
  7671. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7672. dic.Add("ReturnCode", string.Join("、", countrys));
  7673. #endregion
  7674. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7675. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7676. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7677. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7678. //{
  7679. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7680. // dic.Add("Day", sp.Days.ToString());
  7681. //}
  7682. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7683. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7684. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7685. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7686. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7687. //培训人员名单
  7688. int cultivateRowIndex = 7;
  7689. foreach (var item in DeleClientList)
  7690. {
  7691. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7692. builder.Write(item.Name);
  7693. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7694. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7695. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7696. string birthDay = "";
  7697. if (item.Birthday != null)
  7698. {
  7699. DateTime dt = Convert.ToDateTime(item.Birthday);
  7700. birthDay = $"{dt.Year}.{dt.Month}";
  7701. }
  7702. builder.Write(birthDay);
  7703. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7704. builder.Write(item.Company);
  7705. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7706. builder.Write(item.Job);
  7707. cultivateRowIndex++;
  7708. }
  7709. //删除多余行
  7710. //cultivateRowIndex -= 2;
  7711. int delRows = 10 + 7 - cultivateRowIndex;
  7712. if (delRows > 0)
  7713. {
  7714. for (int i = 0; i < delRows; i++)
  7715. {
  7716. table1.Rows.RemoveAt(cultivateRowIndex);
  7717. //cultivateRowIndex++;
  7718. }
  7719. }
  7720. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7721. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7722. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7723. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7724. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7725. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7726. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7727. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7728. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7729. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7730. //其他费用
  7731. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7732. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7733. //其他费用合计
  7734. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7735. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7736. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7737. //公务舱合计
  7738. //国际旅费
  7739. //string outsideJJ = "";
  7740. //string allPriceJJ = "";
  7741. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7742. {
  7743. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7744. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7745. }
  7746. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7747. {
  7748. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7749. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7750. }
  7751. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7752. {
  7753. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7754. dic.Add("AirFeeTotal", airFeeTotalStr);
  7755. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7756. dic.Add("FeeTotal", feeTotalStr);
  7757. }
  7758. foreach (var key in dic.Keys)
  7759. {
  7760. builder.MoveToBookmark(key);
  7761. builder.Write(dic[key]);
  7762. }
  7763. //模板文件名
  7764. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7765. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7766. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7767. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7768. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7769. }
  7770. }
  7771. else if (dto.ExportType == 2) //表格
  7772. {
  7773. //利用键值对存放数据
  7774. Dictionary<string, string> dic = new Dictionary<string, string>();
  7775. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7776. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7777. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7778. dic.Add("Day", sp.Days.ToString());
  7779. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7780. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7781. {
  7782. //获取模板
  7783. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7784. //载入模板
  7785. var doc = new Document(tempPath);
  7786. var builder = new DocumentBuilder(doc);
  7787. dic.Add("TeamName", _DelegationInfo.TeamName);
  7788. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7789. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7790. string missionLeaderName = "",
  7791. missionLeaderJob = "";
  7792. if (DeleClientList.Count > 0)
  7793. {
  7794. missionLeaderName = DeleClientList[0].Name;
  7795. missionLeaderJob = DeleClientList[0].Job;
  7796. }
  7797. dic.Add("MissionLeaderName", missionLeaderName);
  7798. dic.Add("MissionLeaderJob", missionLeaderJob);
  7799. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7800. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7801. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7802. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7803. int rowCount = 10;//总人数行
  7804. int startRowIndex = 7; //起始行
  7805. for (int i = 0; i < DeleClientList.Count; i++)
  7806. {
  7807. builder.MoveToCell(0, startRowIndex, 0, 0);
  7808. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7809. builder.MoveToCell(0, startRowIndex, 1, 0);
  7810. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7811. builder.Write(sex);//性别
  7812. builder.MoveToCell(0, startRowIndex, 2, 0);
  7813. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7814. builder.MoveToCell(0, startRowIndex, 3, 0);
  7815. builder.Write(DeleClientList[i].Company);//工作单位
  7816. builder.MoveToCell(0, startRowIndex, 4, 0);
  7817. builder.Write(DeleClientList[i].Job);//职务及级别
  7818. builder.MoveToCell(0, startRowIndex, 5, 0);
  7819. builder.Write("");//人员属性
  7820. builder.MoveToCell(0, startRowIndex, 6, 0);
  7821. builder.Write("");//上次出国时间
  7822. startRowIndex++;
  7823. }
  7824. int nullRow = rowCount - DeleClientList.Count;//空行
  7825. for (int i = 0; i < nullRow; i++)
  7826. {
  7827. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7828. }
  7829. foreach (var key in dic.Keys)
  7830. {
  7831. builder.MoveToBookmark(key);
  7832. builder.Write(dic[key]);
  7833. }
  7834. //模板文件名
  7835. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7836. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7837. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7838. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7839. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7840. }
  7841. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7842. {
  7843. //获取模板
  7844. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7845. //载入模板
  7846. var doc = new Document(tempPath);
  7847. var builder = new DocumentBuilder(doc);
  7848. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7849. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7850. dic.Add("Names", Names);
  7851. int accommodationRows = 12;
  7852. //int foodandotherRows = 12;
  7853. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7854. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7855. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7856. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7857. int accommodationStartIndex = 6;
  7858. decimal dac1totalPrice = 0.00M;
  7859. foreach (var dac in dac1)
  7860. {
  7861. if (dac.SubTotal == 0)
  7862. {
  7863. continue;
  7864. }
  7865. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7866. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7867. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7868. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7869. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7870. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7871. builder.Write(currency);//币种
  7872. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7873. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7874. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7875. builder.Write("");//人数
  7876. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7877. builder.Write("");//天数
  7878. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7879. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7880. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7881. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7882. builder.Write(rate.ToString("#0.0000"));//汇率
  7883. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7884. decimal rbmPrice = rate * dac.SubTotal;
  7885. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7886. accommodationStartIndex++;
  7887. dac1totalPrice += rbmPrice;
  7888. }
  7889. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7890. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7891. builder.Write("小计");
  7892. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7893. builder.Write(dac1totalPrice.ToString("#0.00"));
  7894. accommodationStartIndex++;
  7895. int nullRow = accommodationRows - dac1.Count;
  7896. //删除空行
  7897. //if (nullRow > 0)
  7898. //{
  7899. // int rowIndex = accommodationStartIndex;
  7900. // for (int i = 0; i < nullRow; i++)
  7901. // {
  7902. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7903. // row.Remove();
  7904. // rowIndex++;
  7905. // }
  7906. //}
  7907. if (dac2.Count == dac3.Count)//国家 币种 金额
  7908. {
  7909. for (int i = 0; i < dac2.Count; i++)
  7910. {
  7911. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7912. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7913. }
  7914. }
  7915. int foodandotherStartIndex = 19;//
  7916. decimal dac2totalPrice = 0.00M;
  7917. foreach (var dac in dac2)
  7918. {
  7919. if (dac.SubTotal == 0)
  7920. {
  7921. continue;
  7922. }
  7923. //foodandotherStartIndex = 12;
  7924. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7925. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7926. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7927. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7928. builder.Write(currency);//币种
  7929. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7930. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7931. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7932. builder.Write("");//人数
  7933. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7934. builder.Write("");//天数
  7935. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7936. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7937. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7938. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7939. builder.Write(rate.ToString("#0.0000"));//汇率
  7940. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7941. decimal rbmPrice = rate * dac.SubTotal;
  7942. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7943. foodandotherStartIndex++;
  7944. dac2totalPrice += rbmPrice;
  7945. }
  7946. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7947. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7948. //删除空行
  7949. //if (dac2.Count < foodandotherRows)
  7950. //{
  7951. // while (table2.Rows.Count > dac2.Count)
  7952. // {
  7953. // table2.Rows.RemoveAt(dac2.Count);
  7954. // }
  7955. //}
  7956. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7957. string otherFeeStr = "";
  7958. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7959. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7960. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7961. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7962. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7963. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7964. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7965. foreach (var otherInfo in dac5)
  7966. {
  7967. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7968. }
  7969. #endregion
  7970. if (otherFeeStr.Length > 0)
  7971. {
  7972. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7973. otherFeeStr = $"({otherFeeStr})";
  7974. dic.Add("OtherFeeStr", otherFeeStr);
  7975. }
  7976. foreach (var key in dic.Keys)
  7977. {
  7978. builder.MoveToBookmark(key);
  7979. builder.Write(dic[key]);
  7980. }
  7981. //模板文件名
  7982. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7983. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7984. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7985. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7986. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7987. }
  7988. }
  7989. else if (dto.ExportType == 3)
  7990. {
  7991. if (dto.SubTypeId == 1) //团组成员名单
  7992. {
  7993. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7994. //获取模板
  7995. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7996. //载入模板
  7997. var doc = new Document(tempPath);
  7998. var builder = new DocumentBuilder(doc);
  7999. //获取word里所有表格
  8000. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8001. //获取所填表格的序数
  8002. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8003. var rowStart = tableOne.Rows[0]; //获取第1行
  8004. //循环赋值
  8005. for (int i = 0; i < DeleClientList.Count; i++)
  8006. {
  8007. builder.MoveToCell(0, i + 1, 0, 0);
  8008. builder.Write(DeleClientList[i].Name);
  8009. builder.MoveToCell(0, i + 1, 1, 0);
  8010. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8011. builder.Write(sex);
  8012. builder.MoveToCell(0, i + 1, 2, 0);
  8013. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  8014. builder.MoveToCell(0, i + 1, 3, 0);
  8015. builder.Write(DeleClientList[i].Company);
  8016. builder.MoveToCell(0, i + 1, 4, 0);
  8017. builder.Write(DeleClientList[i].Job);
  8018. }
  8019. //删除多余行
  8020. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  8021. {
  8022. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  8023. }
  8024. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  8025. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  8026. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  8027. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8028. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8029. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8030. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8031. }
  8032. }
  8033. return Ok(JsonView(400, "操作失败!", ""));
  8034. }
  8035. catch (Exception ex)
  8036. {
  8037. return Ok(JsonView(400, ex.Message, ""));
  8038. }
  8039. }
  8040. /// <summary>
  8041. /// 获取三公费用标准city
  8042. /// </summary>
  8043. /// <param name="placeData"></param>
  8044. /// <param name="nationalTravelFeeId"></param>
  8045. /// <returns></returns>
  8046. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8047. {
  8048. string _city = string.Empty;
  8049. if (placeData.Count < 1) return _city;
  8050. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8051. if (data == null) return _city;
  8052. string country = data.Country;
  8053. string city = data.City;
  8054. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8055. else _city = city;
  8056. return _city;
  8057. }
  8058. ///// <summary>
  8059. ///// 团组模块 - 出入境费用 - 明细表导出
  8060. ///// </summary>
  8061. ///// <returns></returns>
  8062. //[HttpPost]
  8063. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8064. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  8065. //{
  8066. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  8067. // if (data.Code != 0)
  8068. // {
  8069. // return Ok(JsonView(false, data.Msg));
  8070. // }
  8071. // return Ok(JsonView(true, data.Msg, data.Data));
  8072. //}
  8073. /// <summary>
  8074. /// 团组模块 - 出入境费用 - 一键清空
  8075. /// </summary>
  8076. /// <returns></returns>
  8077. [HttpPost]
  8078. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8080. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  8081. {
  8082. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  8083. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8084. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8085. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  8086. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8087. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  8088. .SetColumns(x => new Grp_DayOtherPrice
  8089. {
  8090. IsDel = 1,
  8091. DeleteUserId = dto.UserId,
  8092. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8093. })
  8094. .ExecuteCommandAsync();
  8095. if (_view.Code == 0)
  8096. {
  8097. return Ok(JsonView(true, "操作成功"));
  8098. }
  8099. return Ok(JsonView(false, "操作失败"));
  8100. }
  8101. /// <summary>
  8102. /// 团组模块 - 出入境费用 - 子项删除
  8103. /// </summary>
  8104. /// <returns></returns>
  8105. [HttpPost]
  8106. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8108. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  8109. {
  8110. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8111. if (data.Code != 0)
  8112. {
  8113. return Ok(JsonView(false, data.Msg));
  8114. }
  8115. return Ok(JsonView(true, "操作成功!", data.Data));
  8116. }
  8117. /// <summary>
  8118. /// 删除三公其他费用
  8119. /// </summary>
  8120. /// <param name="dto"></param>
  8121. /// <returns></returns>
  8122. [HttpPost]
  8123. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8124. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  8125. {
  8126. var jw = JsonView(false, "删除失败!");
  8127. var data = new Grp_DayOtherPrice()
  8128. {
  8129. Id = dto.Id,
  8130. IsDel = 1,
  8131. DeleteUserId = dto.DeleteUserId,
  8132. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8133. };
  8134. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8135. if (del > 0)
  8136. {
  8137. jw.Code = 200;
  8138. jw.Msg = "删除成功!";
  8139. }
  8140. return Ok(jw);
  8141. }
  8142. /// <summary>
  8143. /// 团组模块 - 出入境国家费用标准 List
  8144. /// </summary>
  8145. /// <returns></returns>
  8146. [HttpPost]
  8147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8148. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  8149. {
  8150. int provinceId = dto.ProvinceId;
  8151. if (provinceId < 1) provinceId = 122; //默认四川省数据
  8152. var nftData = await _sqlSugar
  8153. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  8154. JoinType.Left, ntf.Currency == sd1.Id,
  8155. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8156. JoinType.Left, ntf.ProvinceId == c.Id
  8157. ))
  8158. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8159. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  8160. {
  8161. Id = ntf.Id,
  8162. ProvinceId = ntf.ProvinceId,
  8163. ProvinceName = c.Name_CN,
  8164. Continent = ntf.Continent,
  8165. Country = ntf.Country,
  8166. City = ntf.City,
  8167. Currency = ntf.Currency,
  8168. CurrencyCode = sd1.Name,
  8169. CurrencyName = sd1.Remark,
  8170. RoomCost = ntf.RoomCost,
  8171. FoodCost = ntf.FoodCost,
  8172. PublicCost = ntf.PublicCost,
  8173. LastUpdateUserId = ntf.LastUpdateUserId,
  8174. LastUpdateUserName = u.CnName,
  8175. LastUpdateTime = ntf.LastUpdateTime
  8176. })
  8177. .ToListAsync();
  8178. return Ok(JsonView(true, "查询成功!", nftData));
  8179. }
  8180. /// <summary>
  8181. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  8182. /// </summary>
  8183. /// <returns></returns>
  8184. [HttpPost]
  8185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8186. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  8187. {
  8188. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  8189. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  8190. List<string> countryData = new List<string>();
  8191. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  8192. countryData = countryData.Distinct().ToList();
  8193. List<dynamic> dataSource = new List<dynamic>();
  8194. foreach (var item in countryData)
  8195. {
  8196. var cityData1 = new List<string>();
  8197. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  8198. var countryData2 = new
  8199. {
  8200. CountryName = item,
  8201. CityData = cityData1
  8202. };
  8203. if (!dataSource.Contains(countryData2))
  8204. {
  8205. dataSource.Add(countryData2);
  8206. }
  8207. }
  8208. return Ok(JsonView(true, "查询成功!", dataSource));
  8209. }
  8210. /// <summary>
  8211. /// 团组模块 - 出入境国家费用标准 Page List
  8212. /// </summary>
  8213. /// <returns></returns>
  8214. [HttpPost]
  8215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8216. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  8217. {
  8218. int portId = dto.PortType,
  8219. pageIndex = dto.PageIndex,
  8220. pageSize = dto.PageSize;
  8221. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8222. if (pageIndex == 0) pageIndex = 1;
  8223. if (pageSize == 0) pageSize = 10;
  8224. RefAsync<int> total = 0;
  8225. var nationalTravelFeeData = await _sqlSugar
  8226. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  8227. JoinType.Left, ntf.Currency == sd1.Id,
  8228. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8229. JoinType.Left, ntf.ProvinceId == sd2.Id
  8230. ))
  8231. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  8232. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  8233. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  8234. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  8235. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  8236. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  8237. {
  8238. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  8239. Id = ntf.Id,
  8240. ProvinceId = ntf.ProvinceId,
  8241. ProvinceName = sd2.Name_CN,
  8242. Continent = ntf.Continent,
  8243. Country = ntf.Country,
  8244. City = ntf.City,
  8245. Currency = ntf.Currency,
  8246. CurrencyCode = sd1.Name,
  8247. CurrencyName = sd1.Remark,
  8248. RoomCost = ntf.RoomCost,
  8249. FoodCost = ntf.FoodCost,
  8250. PublicCost = ntf.PublicCost,
  8251. LastUpdateUserId = ntf.LastUpdateUserId,
  8252. LastUpdateUserName = u.CnName,
  8253. LastUpdateTime = ntf.LastUpdateTime,
  8254. Remark = ntf.Remark
  8255. })
  8256. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8257. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  8258. }
  8259. /// <summary>
  8260. /// 团组模块 - 出入境国家费用标准 根据城市查询
  8261. /// </summary>
  8262. /// <returns></returns>
  8263. [HttpPost]
  8264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8265. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  8266. {
  8267. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  8268. int portId = dto.PortType;
  8269. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8270. string whereSql = string.Empty;
  8271. if (!string.IsNullOrEmpty(dto.Country))
  8272. {
  8273. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  8274. }
  8275. if (!string.IsNullOrEmpty(dto.City))
  8276. {
  8277. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  8278. }
  8279. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  8280. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  8281. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  8282. From Grp_NationalTravelFee gntf
  8283. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  8284. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  8285. Where gntf.Isdel = 0 {0} ", whereSql);
  8286. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  8287. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  8288. }
  8289. /// <summary>
  8290. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  8291. /// </summary>
  8292. /// <returns></returns>
  8293. [HttpPost]
  8294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8295. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  8296. {
  8297. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  8298. }
  8299. /// <summary>
  8300. /// 团组模块 - 出入境国家费用标准 - Del
  8301. /// </summary>
  8302. /// <returns></returns>
  8303. [HttpPost]
  8304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8305. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  8306. {
  8307. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  8308. {
  8309. Id = dto.Id,
  8310. DeleteUserId = dto.DeleteUserId,
  8311. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8312. IsDel = 1
  8313. };
  8314. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  8315. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  8316. .WhereColumns(it => new { it.Id })
  8317. .ExecuteCommandAsync();
  8318. if (delStatus <= 0)
  8319. {
  8320. return Ok(JsonView(false, "删除失败!"));
  8321. }
  8322. return Ok(JsonView(true, "操作成功!"));
  8323. }
  8324. /// <summary>
  8325. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  8326. /// 注:Get 请求Headers 加 Token
  8327. /// </summary>
  8328. /// <param name="groupId"></param>
  8329. /// <returns></returns>
  8330. [HttpGet("{groupId}")]
  8331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8332. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  8333. {
  8334. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8335. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  8336. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  8337. data.ForEach(x =>
  8338. {
  8339. x.CreateUserId = _currUserInfo.UserId;
  8340. });
  8341. if (data.Any())
  8342. {
  8343. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  8344. if (add > 0)
  8345. {
  8346. return Ok(JsonView(true, "操作成功!"));
  8347. }
  8348. }
  8349. return Ok(JsonView(false, "未操作!"));
  8350. }
  8351. #endregion
  8352. #region 团组经理模块 出入境费用-草稿
  8353. /// <summary>
  8354. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  8355. /// </summary>
  8356. /// <returns></returns>
  8357. [HttpGet]
  8358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8359. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8360. {
  8361. var provData = await _groupRepository.ProvinceBasicSource();
  8362. return Ok(JsonView(true, "查询成功!", provData));
  8363. }
  8364. /// <summary>
  8365. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8366. /// </summary>
  8367. /// <returns></returns>
  8368. [HttpGet("{provinceId}")]
  8369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8370. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8371. {
  8372. //验证城市归属并给默认值
  8373. if (provinceId < 1) provinceId = 122;
  8374. /*
  8375. * 122 四川
  8376. * 108 贵州
  8377. * 103 重庆
  8378. * 132 云南
  8379. */
  8380. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8381. return Ok(JsonView(true, "查询成功!", new
  8382. {
  8383. WordTypeData = wordTypeData,
  8384. ExcelTypeData = excelTypeData,
  8385. }));
  8386. }
  8387. /// <summary>
  8388. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8389. /// </summary>
  8390. /// <returns></returns>
  8391. [HttpPost]
  8392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8393. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8394. {
  8395. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8396. .Where(x => x.IsDel == 0)
  8397. .OrderByDescending(x => x.CreateTime)
  8398. .Select(x => new { x.Id, x.DraftName })
  8399. .ToListAsync();
  8400. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8401. //SetDataInfoView
  8402. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8403. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8404. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8405. int provinceId = dto.ProvinceId;
  8406. if (provinceId < 1) provinceId = 122;
  8407. /*
  8408. * 122 四川
  8409. * 108 贵州
  8410. * 103 重庆
  8411. * 132 云南
  8412. */
  8413. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8414. //默认币种显示
  8415. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8416. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8417. return Ok(JsonView(true, "查询成功!", new
  8418. {
  8419. DraftNameDatas = draftNameDatas,
  8420. CurrencyData = _CurrencyData,
  8421. WordTypeData = wordTypeData,
  8422. ExcelTypeData = excelTypeData,
  8423. CurrencyInit = _currencyInfos,
  8424. ViewPermissionData = viewPermissionData
  8425. }));
  8426. }
  8427. /// <summary>
  8428. /// 团组模块 - 出入境费用-草稿
  8429. /// 实时汇率 tips
  8430. /// 机票费用 tips
  8431. /// </summary>
  8432. /// <returns></returns>
  8433. [HttpPost]
  8434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8435. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8436. {
  8437. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8438. return Ok(JsonView(true, "查询成功!", new
  8439. {
  8440. //GroupNameData = groupNameData.Data,
  8441. //visaData = visaData.Data,
  8442. //airData = airData.Data,
  8443. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8444. }));
  8445. }
  8446. /// <summary>
  8447. /// 团组模块 - 出入境费用-草稿
  8448. /// 签证费用 tips
  8449. /// </summary>
  8450. /// <returns></returns>
  8451. [HttpPost]
  8452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8453. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8454. {
  8455. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8456. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8457. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8458. .Select(x => x.NationalTravelFeeId)
  8459. .Distinct()
  8460. .ToListAsync();
  8461. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8462. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8463. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8464. .Select(x => x.Country)
  8465. .Distinct()
  8466. .ToArrayAsync();
  8467. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8468. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8469. return Ok(JsonView(true, "查询成功!", new
  8470. {
  8471. totalAmt,
  8472. remark
  8473. }));
  8474. }
  8475. /// <summary>
  8476. /// 团组模块 - 出入境费用-草稿 - Info
  8477. /// </summary>
  8478. /// <returns></returns>
  8479. [HttpPost]
  8480. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8482. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8483. {
  8484. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8485. }
  8486. /// <summary>
  8487. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8488. /// </summary>
  8489. /// <returns></returns>
  8490. [HttpPost]
  8491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8492. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8493. {
  8494. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8495. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8496. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8497. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8498. foreach (var userId in dto.UserIds)
  8499. {
  8500. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8501. }
  8502. if (permissions.Any())
  8503. {
  8504. _sqlSugar.BeginTran();
  8505. try
  8506. {
  8507. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8508. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8509. if (result < 1)
  8510. {
  8511. _sqlSugar.RollbackTran();
  8512. return Ok(JsonView(false));
  8513. }
  8514. }
  8515. catch (Exception ex)
  8516. {
  8517. _sqlSugar.RollbackTran();
  8518. return Ok(JsonView(false, ex.Message));
  8519. }
  8520. _sqlSugar.CommitTran();
  8521. return Ok(JsonView(true));
  8522. }
  8523. return Ok(JsonView(false));
  8524. }
  8525. /// <summary>
  8526. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8527. /// </summary>
  8528. /// <returns></returns>
  8529. [HttpPost]
  8530. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8532. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8533. {
  8534. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8535. if (data.Code != 0)
  8536. {
  8537. return Ok(JsonView(false, data.Msg));
  8538. }
  8539. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8540. //汇率信息记录
  8541. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8542. return Ok(JsonView(true, data.Msg, data.Data));
  8543. }
  8544. /// <summary>
  8545. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8546. /// </summary>
  8547. /// <param name="dto"></param>
  8548. /// <returns></returns>
  8549. [HttpPost]
  8550. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8552. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8553. {
  8554. try
  8555. {
  8556. var id = dto.Id;
  8557. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8558. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8559. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8560. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8561. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8562. 3 团组成员名单 1 团组成员名单", ""));
  8563. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8564. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8565. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8566. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8567. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8568. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8569. //数据源
  8570. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8571. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8572. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8573. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8574. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8575. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8576. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8577. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8578. .Select((x, a, b) => new
  8579. {
  8580. x.Index,
  8581. itemName = a.Name,
  8582. CurrencyStr = b.Name,
  8583. x.Cost,
  8584. x.SubTotal,
  8585. x.Remark
  8586. })
  8587. .OrderBy((x) => x.Index)
  8588. .ToList(); //其他款项费用
  8589. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8590. var peiceItemCurrencys = new List<string>();
  8591. if (_DayAndCosts.Any())
  8592. {
  8593. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8594. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8595. }
  8596. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8597. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8598. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8599. {
  8600. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8601. }
  8602. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8603. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8604. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8605. if (dto.ExportType == 1) //明细表
  8606. {
  8607. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8608. {
  8609. //获取模板
  8610. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8611. //载入模板
  8612. Document doc = new Document(tempPath);
  8613. DocumentBuilder builder = new DocumentBuilder(doc);
  8614. //利用键值对存放数据
  8615. Dictionary<string, string> dic = new Dictionary<string, string>();
  8616. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8617. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8618. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8619. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8620. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8621. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8622. //境内费用(其他费用)
  8623. if (_EnterExitCosts.ChoiceOne == 1)
  8624. {
  8625. string row1_1 = "";
  8626. if (_EnterExitCosts.Visa > 0)
  8627. {
  8628. //insidePayTotal += _EnterExitCosts.Visa;
  8629. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8630. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8631. //{
  8632. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8633. //}
  8634. }
  8635. string row1_2 = "";
  8636. if (_EnterExitCosts.YiMiao > 0)
  8637. {
  8638. //insidePayTotal += _EnterExitCosts.YiMiao;
  8639. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8640. }
  8641. if (_EnterExitCosts.HeSuan > 0)
  8642. {
  8643. //insidePayTotal += _EnterExitCosts.HeSuan;
  8644. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8645. }
  8646. if (_EnterExitCosts.Service > 0)
  8647. {
  8648. //insidePayTotal += _EnterExitCosts.Service;
  8649. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8650. }
  8651. string row1_3 = "";
  8652. if (_EnterExitCosts.Safe > 0)
  8653. {
  8654. //insidePayTotal += _EnterExitCosts.Safe;
  8655. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8656. }
  8657. if (_EnterExitCosts.Ticket > 0)
  8658. {
  8659. //insidePayTotal += _EnterExitCosts.Ticket;
  8660. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8661. }
  8662. string row1 = "";
  8663. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8664. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8665. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8666. row1 += $"备注:{_EnterExitCosts.Remark}";
  8667. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8668. dic.Add("Row1Str", row1);
  8669. }
  8670. string airTotalStr = string.Empty,
  8671. airPriceStr = string.Empty;
  8672. //经济舱
  8673. if (_EnterExitCosts.SumJJC == 1)
  8674. {
  8675. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8676. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8677. }
  8678. //公务舱
  8679. if (_EnterExitCosts.SumGWC == 1)
  8680. {
  8681. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8682. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8683. }
  8684. //头等舱
  8685. if (_EnterExitCosts.SumTDC == 1)
  8686. {
  8687. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8688. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8689. }
  8690. //汇率描述
  8691. string rateStr = "";
  8692. if (peiceItemCurrencyInfos.Any())
  8693. {
  8694. rateStr = "\r\n汇率描述:";
  8695. foreach (var item in peiceItemCurrencyInfos)
  8696. {
  8697. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8698. }
  8699. }
  8700. string twoItemRemark = "备注:";
  8701. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8702. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8703. dic.Add("AirTotalStr", airTotalStr);
  8704. dic.Add("AirPriceStr", airPriceStr);
  8705. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8706. dic.Add("TwoItemRemark", twoItemRemark);
  8707. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8708. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8709. int table1Row = 0,
  8710. table2Row = 0,
  8711. table3Row = 0,
  8712. table4Row = 0,
  8713. table5Row = 0;
  8714. //住宿费
  8715. if (_EnterExitCosts.ChoiceThree == 1)
  8716. {
  8717. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8718. table1Row = dac1.Count;
  8719. #region 填充word表格内容
  8720. for (int i = 0; i < dac1.Count; i++)
  8721. {
  8722. var dac = dac1[i];
  8723. if (dac == null) continue;
  8724. builder.MoveToCell(0, i, 0, 0);
  8725. builder.Write("第" + dac.Days.ToString() + "晚:");
  8726. builder.MoveToCell(0, i, 1, 0);
  8727. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8728. //builder.Write(dac.Place == null ? "" : dac.Place);
  8729. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8730. builder.MoveToCell(0, i, 2, 0);
  8731. builder.Write("费用标准:");
  8732. string curr = "";
  8733. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8734. if (currData != null)
  8735. {
  8736. curr = currData.Name;
  8737. }
  8738. builder.MoveToCell(0, i, 3, 0);
  8739. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8740. builder.MoveToCell(0, i, 4, 0);
  8741. builder.Write("费用小计:");
  8742. builder.MoveToCell(0, i, 5, 0);
  8743. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8744. }
  8745. #endregion
  8746. }
  8747. else dic.Add("SubZS", "0.00");
  8748. //删除多余行
  8749. while (table1.Rows.Count > table1Row)
  8750. {
  8751. table1.Rows.RemoveAt(table1Row);
  8752. }
  8753. //伙食费
  8754. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8755. if (_EnterExitCosts.ChoiceFour == 1)
  8756. {
  8757. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8758. table2Row = dac2.Count;
  8759. #region 填充word表格内容
  8760. for (int i = 0; i < dac2.Count; i++)
  8761. {
  8762. var dac = dac2[i];
  8763. if (dac == null) continue;
  8764. builder.MoveToCell(1, i, 0, 0);
  8765. builder.Write("第" + dac.Days.ToString() + "天:");
  8766. builder.MoveToCell(1, i, 1, 0);
  8767. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8768. builder.MoveToCell(1, i, 2, 0);
  8769. builder.Write("费用标准:");
  8770. string curr = "";
  8771. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8772. if (currData != null)
  8773. {
  8774. curr = currData.Name;
  8775. }
  8776. builder.MoveToCell(1, i, 3, 0);
  8777. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8778. builder.MoveToCell(1, i, 4, 0);
  8779. builder.Write("费用小计:");
  8780. builder.MoveToCell(1, i, 5, 0);
  8781. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8782. }
  8783. #endregion
  8784. }
  8785. else dic.Add("SubHS", "0.00");
  8786. //删除多余行
  8787. while (table2.Rows.Count > table2Row)
  8788. {
  8789. table2.Rows.RemoveAt(table2Row);
  8790. }
  8791. //公杂费
  8792. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8793. if (_EnterExitCosts.ChoiceFive == 1)
  8794. {
  8795. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8796. table3Row = dac3.Count;
  8797. #region 填充word表格内容
  8798. for (int i = 0; i < dac3.Count; i++)
  8799. {
  8800. var dac = dac3[i];
  8801. if (dac == null) continue;
  8802. builder.MoveToCell(2, i, 0, 0);
  8803. builder.Write("第" + dac.Days.ToString() + "天:");
  8804. builder.MoveToCell(2, i, 1, 0);
  8805. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8806. builder.MoveToCell(2, i, 2, 0);
  8807. builder.Write("费用标准:");
  8808. string curr = "";
  8809. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8810. if (currData != null)
  8811. {
  8812. curr = currData.Name;
  8813. }
  8814. builder.MoveToCell(2, i, 3, 0);
  8815. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8816. builder.MoveToCell(2, i, 4, 0);
  8817. builder.Write("费用小计:");
  8818. builder.MoveToCell(2, i, 5, 0);
  8819. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8820. }
  8821. //删除多余行
  8822. while (table3.Rows.Count > table3Row)
  8823. {
  8824. table3.Rows.RemoveAt(table3Row);
  8825. }
  8826. #endregion
  8827. }
  8828. else dic.Add("SubGZF", "0.00");
  8829. //删除多余行
  8830. while (table3.Rows.Count > table3Row)
  8831. {
  8832. table3.Rows.RemoveAt(table3Row);
  8833. }
  8834. //培训费
  8835. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8836. if (_EnterExitCosts.ChoiceSix == 1)
  8837. {
  8838. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8839. dic.Add("SubPX", pxStr);
  8840. table4Row = dac4.Count;
  8841. #region 填充word表格内容
  8842. for (int i = 0; i < dac4.Count; i++)
  8843. {
  8844. var dac = dac4[i];
  8845. if (dac == null) continue;
  8846. builder.MoveToCell(3, i, 0, 0);
  8847. builder.Write("第" + dac.Days.ToString() + "天:");
  8848. builder.MoveToCell(3, i, 1, 0);
  8849. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8850. builder.MoveToCell(3, i, 2, 0);
  8851. builder.Write("费用标准:");
  8852. string curr = "";
  8853. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8854. if (currData != null)
  8855. {
  8856. curr = currData.Name;
  8857. }
  8858. builder.MoveToCell(3, i, 3, 0);
  8859. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8860. builder.MoveToCell(3, i, 4, 0);
  8861. builder.Write("费用小计:");
  8862. builder.MoveToCell(3, i, 5, 0);
  8863. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8864. }
  8865. #endregion
  8866. }
  8867. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8868. //删除多余行
  8869. while (table4.Rows.Count > table4Row)
  8870. {
  8871. table4.Rows.RemoveAt(table4Row);
  8872. }
  8873. //其他费用
  8874. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8875. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8876. {
  8877. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8878. dic.Add("titleQi", qtStr);
  8879. table5Row = dac5.Count;
  8880. #region 填充word表格内容
  8881. for (int i = 0; i < dac5.Count; i++)
  8882. {
  8883. var dac = dac5[i];
  8884. if (dac == null) continue;
  8885. builder.MoveToCell(4, i, 0, 0);
  8886. builder.Write("第" + dac.Index.ToString() + "项:");
  8887. builder.MoveToCell(4, i, 1, 0);
  8888. builder.Write(dac.itemName);
  8889. builder.MoveToCell(4, i, 2, 0);
  8890. builder.Write("费用标准:");
  8891. builder.MoveToCell(4, i, 3, 0);
  8892. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8893. builder.MoveToCell(4, i, 4, 0);
  8894. builder.Write("费用小计:");
  8895. builder.MoveToCell(4, i, 5, 0);
  8896. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8897. builder.MoveToCell(4, i, 6, 0);
  8898. builder.Write("备注:");
  8899. builder.MoveToCell(4, i, 7, 0);
  8900. builder.Write(dac.Remark);
  8901. }
  8902. #endregion
  8903. }
  8904. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8905. //删除多余行
  8906. while (table5.Rows.Count > table5Row)
  8907. {
  8908. table5.Rows.RemoveAt(table5Row);
  8909. }
  8910. //加上其他费用
  8911. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8912. decimal subJJC = 0.00M,
  8913. subGWC = 0.00M,
  8914. subTDC = 0.00M;
  8915. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8916. string totalLabel = string.Format("全部费用总计:");
  8917. //经济舱
  8918. if (_EnterExitCosts.SumJJC == 1)
  8919. {
  8920. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8921. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8922. }
  8923. //公务舱
  8924. if (_EnterExitCosts.SumGWC == 1)
  8925. {
  8926. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8927. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8928. }
  8929. //头等舱
  8930. if (_EnterExitCosts.SumTDC == 1)
  8931. {
  8932. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8933. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8934. }
  8935. //TotalLabel
  8936. dic.Add("TotalLabel", totalLabel);
  8937. #region 填充word模板书签内容
  8938. foreach (var key in dic.Keys)
  8939. {
  8940. Bookmark bookmark = doc.Range.Bookmarks[key];
  8941. if (bookmark != null)
  8942. {
  8943. builder.MoveToBookmark(key);
  8944. builder.Write(dic[key]);
  8945. }
  8946. }
  8947. #endregion
  8948. //文件名
  8949. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8950. strFileName = CommonFun.ValidFileName(strFileName);
  8951. AsposeHelper.removewatermark_v2180();
  8952. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8953. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8954. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8955. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8956. }
  8957. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8958. {
  8959. //获取模板
  8960. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8961. //载入模板
  8962. Document doc = new Document(tempPath);
  8963. DocumentBuilder builder = new DocumentBuilder(doc);
  8964. Dictionary<string, string> dic = new Dictionary<string, string>();
  8965. string returnCodeLabel = string.Empty;
  8966. if (nationalTravelFeeData.Any())
  8967. {
  8968. List<string> list = new List<string>();
  8969. foreach (var item in nationalTravelFeeData)
  8970. {
  8971. list.Add($"{item.Country}({item.City})");
  8972. }
  8973. list = list.Distinct().ToList();
  8974. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8975. }
  8976. var countryLabel = string.Empty;
  8977. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8978. if (countryData.Any())
  8979. {
  8980. countryLabel = string.Join("、", countryData);
  8981. }
  8982. dic.Add("ReturnCodeAir", returnCodeLabel);
  8983. dic.Add("VisitStartDate", "-");
  8984. dic.Add("VisitEndDate", "-");
  8985. dic.Add("Day", "-");
  8986. dic.Add("VisitCountry", countryLabel);
  8987. dic.Add("ClientUnit", "-");
  8988. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8989. //dic.Add("Names", Names);
  8990. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8991. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8992. decimal dac1totalPrice = 0.00M;
  8993. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8994. foreach (var dac in dac1)
  8995. {
  8996. if (dac.SubTotal == 0.00M)
  8997. {
  8998. continue;
  8999. }
  9000. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  9001. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  9002. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  9003. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9004. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  9005. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9006. builder.Write(currency);//币种
  9007. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  9008. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9009. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  9010. builder.Write("");//人数
  9011. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  9012. builder.Write("");//天数
  9013. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  9014. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9015. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  9016. decimal rate = 0.00M;
  9017. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9018. builder.Write(rate.ToString("#0.0000"));//汇率
  9019. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  9020. decimal rbmPrice = dac.SubTotal;
  9021. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9022. accommodationStartIndex++;
  9023. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9024. }
  9025. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9026. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  9027. {
  9028. table1.Rows.RemoveAt(i - 1);
  9029. foodandotherStartIndex--;
  9030. }
  9031. if (dac2.Count == dac3.Count)//国家 币种 金额
  9032. {
  9033. for (int i = 0; i < dac2.Count; i++)
  9034. {
  9035. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9036. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9037. }
  9038. }
  9039. decimal dac2totalPrice = 0.00M;
  9040. foreach (var dac in dac2)
  9041. {
  9042. if (dac.SubTotal == 0)
  9043. {
  9044. continue;
  9045. }
  9046. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  9047. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9048. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  9049. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9050. builder.Write(currency);//币种
  9051. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  9052. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9053. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  9054. builder.Write("");//人数
  9055. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  9056. builder.Write("");//天数
  9057. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  9058. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9059. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  9060. decimal rate = 0.00M;
  9061. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9062. builder.Write(rate.ToString("#0.0000"));//汇率
  9063. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  9064. decimal rbmPrice = dac.SubTotal;
  9065. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9066. foodandotherStartIndex++;
  9067. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9068. }
  9069. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  9070. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  9071. {
  9072. table1.Rows.RemoveAt(i - 1);
  9073. }
  9074. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9075. string otherFeeStr = "";
  9076. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  9077. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  9078. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  9079. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  9080. foreach (var otherInfo in dac5)
  9081. {
  9082. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  9083. }
  9084. #endregion
  9085. if (otherFeeStr.Length > 0)
  9086. {
  9087. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  9088. otherFeeStr = $"({otherFeeStr})";
  9089. dic.Add("OtherFeeStr", otherFeeStr);
  9090. }
  9091. //总计
  9092. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  9093. //国际旅费
  9094. string outsideAir = string.Empty;
  9095. string allPriceAir = string.Empty;
  9096. if (_EnterExitCosts.SumJJC == 1)
  9097. {
  9098. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9099. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  9100. }
  9101. if (_EnterExitCosts.SumGWC == 1)
  9102. {
  9103. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  9104. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9105. }
  9106. if (_EnterExitCosts.SumTDC == 1)
  9107. {
  9108. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  9109. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  9110. }
  9111. dic.Add("InTravelPrice", $"({outsideAir})");
  9112. dic.Add("FinalSumPrice", $"({allPriceAir})");
  9113. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  9114. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  9115. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  9116. foreach (var key in dic.Keys)
  9117. {
  9118. builder.MoveToBookmark(key);
  9119. builder.Write(dic[key]);
  9120. }
  9121. //模板文件名
  9122. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9123. strFileName = CommonFun.ValidFileName(strFileName);
  9124. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9125. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9126. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9127. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9128. }
  9129. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  9130. {
  9131. //获取模板
  9132. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  9133. //载入模板
  9134. WorkbookDesigner designer = new WorkbookDesigner();
  9135. designer.Workbook = new Workbook(tempPath);
  9136. Dictionary<string, string> dic = new Dictionary<string, string>();
  9137. string returnCodeLabel = string.Empty;
  9138. if (nationalTravelFeeData.Any())
  9139. {
  9140. List<string> list = new List<string>();
  9141. foreach (var item in nationalTravelFeeData)
  9142. {
  9143. list.Add($"{item.Country}({item.City})");
  9144. }
  9145. list = list.Distinct().ToList();
  9146. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9147. }
  9148. var countryLabel = string.Empty;
  9149. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9150. if (countryData.Any())
  9151. {
  9152. countryLabel = string.Join("、", countryData);
  9153. }
  9154. dic.Add("ReturnCodeAir", returnCodeLabel);
  9155. dic.Add("VisitStartDate", "-");
  9156. dic.Add("VisitEndDate", "-");
  9157. dic.Add("Day", "0");
  9158. dic.Add("VisitCountry", countryLabel);
  9159. dic.Add("ClientUnit", "-");
  9160. designer.SetDataSource("ClientUnit", "-");
  9161. designer.SetDataSource("VisitCountry", countryLabel);
  9162. designer.SetDataSource("Group", "-");
  9163. designer.SetDataSource("ClientUnitTitle", "-");
  9164. designer.SetDataSource("Name", "-");
  9165. designer.SetDataSource("VisitStartDate", "-");
  9166. designer.SetDataSource("Day", "0");
  9167. designer.SetDataSource("ReturnCode", returnCodeLabel);
  9168. designer.SetDataSource("ReturnCodeAir", "-");
  9169. int startIndex = 10;
  9170. const int startIndexcopy = 10;
  9171. if (dac2.Count == dac3.Count)//国家 币种 金额
  9172. {
  9173. for (int i = 0; i < dac2.Count; i++)
  9174. {
  9175. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9176. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9177. }
  9178. }
  9179. DataTable dtdac1 = new DataTable();
  9180. List<string> place = new List<string>();
  9181. dtdac1.Columns.AddRange(new DataColumn[] {
  9182. new DataColumn(){ ColumnName = "city"},
  9183. new DataColumn(){ ColumnName = "curr"},
  9184. new DataColumn(){ ColumnName = "criterion"},
  9185. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9186. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9187. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9188. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9189. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  9190. });
  9191. DataTable dtdac2 = new DataTable();
  9192. dtdac2.Columns.AddRange(new DataColumn[] {
  9193. new DataColumn(){ ColumnName = "city"},
  9194. new DataColumn(){ ColumnName = "curr"},
  9195. new DataColumn(){ ColumnName = "criterion"},
  9196. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9197. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9198. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9199. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9200. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  9201. });
  9202. dtdac1.TableName = "tb1";
  9203. dtdac2.TableName = "tb2";
  9204. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  9205. foreach (var item in dac1)
  9206. {
  9207. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9208. if (place.Contains(item.Place))
  9209. {
  9210. continue;
  9211. }
  9212. DataRow row = dtdac1.NewRow();
  9213. row["city"] = item.Place;
  9214. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9215. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9216. row["curr"] = currency;
  9217. row["rate"] = rate.ToString("#0.0000");
  9218. row["criterion"] = item.Cost.ToString("#0.00");
  9219. row["number"] = 1;
  9220. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9221. //row["costRMB"] = rbmPrice;
  9222. dtdac1.Rows.Add(row);
  9223. place.Add(item.Place);
  9224. }
  9225. place = new List<string>();
  9226. foreach (var item in dac2)
  9227. {
  9228. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9229. if (place.Contains(item.Place))
  9230. {
  9231. continue;
  9232. }
  9233. DataRow row = dtdac2.NewRow();
  9234. row["city"] = item.Place;
  9235. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9236. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9237. row["curr"] = currency;
  9238. row["rate"] = rate.ToString("#0.0000");
  9239. row["criterion"] = item.Cost.ToString("#0.00");
  9240. row["number"] = 1;
  9241. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9242. //row["cost"] = item.SubTotal;
  9243. //row["costRMB"] = rbmPrice;
  9244. dtdac2.Rows.Add(row);
  9245. place.Add(item.Place);
  9246. //dac2totalPrice += rbmPrice;
  9247. }
  9248. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  9249. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  9250. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9251. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  9252. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  9253. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  9254. string cell4Str1 = string.Empty;
  9255. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  9256. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  9257. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  9258. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  9259. string cellStr = $" 5.其他费用(";
  9260. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9261. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9262. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9263. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9264. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9265. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9266. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  9267. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  9268. foreach (var otherInfo in dac5)
  9269. {
  9270. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9271. }
  9272. #endregion
  9273. if (cellStr.Length > 8)
  9274. {
  9275. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  9276. }
  9277. cellStr += ")";
  9278. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  9279. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  9280. decimal pxFee = dac4.Sum(it => it.Cost);
  9281. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  9282. string celllastStr1 = "";
  9283. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  9284. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  9285. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  9286. celllastStr1 += $",国际旅费 元";
  9287. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  9288. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  9289. designer.SetDataSource("cell4Str", cell4Str);
  9290. designer.SetDataSource("cellStr", cellStr);
  9291. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  9292. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9293. designer.SetDataSource("celllastStr", celllastStr);
  9294. Workbook wb = designer.Workbook;
  9295. var sheet = wb.Worksheets[0];
  9296. //绑定datatable数据集
  9297. designer.SetDataSource(dtdac1);
  9298. designer.SetDataSource(dtdac2);
  9299. designer.Process();
  9300. var rowStart = dtdac1.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 + 1}: I{startIndex})";
  9309. startIndex += 1; //总计行
  9310. rowStart = dtdac2.Rows.Count;
  9311. while (rowStart > 0)
  9312. {
  9313. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  9314. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9315. startIndex++;
  9316. rowStart--;
  9317. }
  9318. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  9319. wb.CalculateFormula(true);
  9320. //模板文件名
  9321. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9322. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9323. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9324. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9325. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9326. }
  9327. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  9328. {
  9329. //获取模板
  9330. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  9331. //载入模板
  9332. Document doc = new Document(tempPath);
  9333. DocumentBuilder builder = new DocumentBuilder(doc);
  9334. Dictionary<string, string> dic = new Dictionary<string, string>();
  9335. dic.Add("GroupName", "-");
  9336. dic.Add("ClientUnit", "-");
  9337. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  9338. //string missionLeaderJob = "";//负责人job
  9339. //int groupNumber = 0; //团人数
  9340. dic.Add("MissionLeader", "-"); //团负责人
  9341. dic.Add("MissionLeaderJob", "-"); //团负责人job
  9342. dic.Add("GroupNumber", "0"); //团人数
  9343. dic.Add("Day", "0");
  9344. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  9345. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  9346. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9347. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9348. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  9349. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  9350. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  9351. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  9352. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  9353. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  9354. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  9355. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9356. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9357. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9358. //其他费用
  9359. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9360. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9361. //其他费用合计
  9362. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9363. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9364. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9365. //公务舱合计
  9366. //国际旅费
  9367. //string outsideJJ = "";
  9368. //string allPriceJJ = "";
  9369. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9370. {
  9371. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9372. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9373. }
  9374. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9375. {
  9376. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9377. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9378. }
  9379. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9380. {
  9381. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9382. dic.Add("AirFeeTotal", airFeeTotalStr);
  9383. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9384. dic.Add("FeeTotal", feeTotalStr);
  9385. }
  9386. foreach (var key in dic.Keys)
  9387. {
  9388. builder.MoveToBookmark(key);
  9389. builder.Write(dic[key]);
  9390. }
  9391. //模板文件名
  9392. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9393. strFileName = CommonFun.ValidFileName(strFileName);
  9394. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9395. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9396. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9397. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9398. }
  9399. }
  9400. else if (dto.ExportType == 2) //表格
  9401. {
  9402. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9403. }
  9404. else if (dto.ExportType == 3)
  9405. {
  9406. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9407. }
  9408. return Ok(JsonView(400, "只可导出明细表!", ""));
  9409. }
  9410. catch (Exception ex)
  9411. {
  9412. return Ok(JsonView(400, ex.Message, ""));
  9413. }
  9414. }
  9415. /// <summary>
  9416. /// 获取三公费用标准city
  9417. /// </summary>
  9418. /// <param name="placeData"></param>
  9419. /// <param name="nationalTravelFeeId"></param>
  9420. /// <returns></returns>
  9421. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9422. {
  9423. string _city = string.Empty;
  9424. if (!placeData.Any()) return _city;
  9425. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9426. if (data == null) return _city;
  9427. string country = data.Country;
  9428. string city = data.City;
  9429. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9430. else _city = city;
  9431. return _city;
  9432. }
  9433. /// <summary>
  9434. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9435. /// </summary>
  9436. /// <returns></returns>
  9437. [HttpPost]
  9438. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9440. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9441. {
  9442. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9443. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9444. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9445. if (_view.Code == 0)
  9446. {
  9447. return Ok(JsonView(true, "操作成功"));
  9448. }
  9449. return Ok(JsonView(false, "操作失败"));
  9450. }
  9451. /// <summary>
  9452. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9453. /// </summary>
  9454. /// <returns></returns>
  9455. [HttpPost]
  9456. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9458. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9459. {
  9460. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9461. if (data.Code != 0)
  9462. {
  9463. return Ok(JsonView(false, data.Msg));
  9464. }
  9465. return Ok(JsonView(true, "操作成功!", data.Data));
  9466. }
  9467. /// <summary>
  9468. /// 三公其他费用草稿 删除
  9469. /// </summary>
  9470. /// <param name="dto"></param>
  9471. /// <returns></returns>
  9472. [HttpPost]
  9473. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9474. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9475. {
  9476. var jw = JsonView(false, "删除失败!");
  9477. var data = new Grp_DayOtherPriceDraft()
  9478. {
  9479. Id = dto.Id,
  9480. IsDel = 1,
  9481. DeleteUserId = dto.DeleteUserId,
  9482. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9483. };
  9484. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9485. if (del > 0)
  9486. {
  9487. jw.Code = 200;
  9488. jw.Msg = "删除成功!";
  9489. }
  9490. return Ok(jw);
  9491. }
  9492. /// <summary>
  9493. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9494. /// </summary>
  9495. /// <returns></returns>
  9496. [HttpPost]
  9497. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9498. {
  9499. var jw = JsonView(false);
  9500. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9501. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9502. jw.Code = StatusCodes.Status200OK;
  9503. jw.Msg = "操作成功!";
  9504. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9505. return Ok(jw);
  9506. }
  9507. /// <summary>
  9508. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9509. /// </summary>
  9510. /// <param name="dto"></param>
  9511. /// <returns></returns>
  9512. [HttpPost]
  9513. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9514. {
  9515. int userId = dto.UserId,
  9516. portId = dto.PortType,
  9517. groupId = dto.GroupId,
  9518. draftId = dto.DraftId;
  9519. _portTypeData.Add(1);
  9520. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9521. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9522. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9523. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9524. _sqlSugar.BeginTran();
  9525. try
  9526. {
  9527. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9528. if (draftDatas == null)
  9529. {
  9530. _sqlSugar.RollbackTran();
  9531. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9532. }
  9533. //验证可覆盖已有数据 两边创建人需为同一人;
  9534. int draftCreateUserId = draftDatas.CreateUserId,
  9535. formalCreateUserId = 0;
  9536. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9537. if (formalData != null)
  9538. {
  9539. formalCreateUserId = formalData.CreateUserId;
  9540. if (draftCreateUserId != formalCreateUserId)
  9541. {
  9542. _sqlSugar.RollbackTran();
  9543. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9544. }
  9545. }
  9546. //默认添加查看、编辑权限(创建人、自己)
  9547. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9548. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9549. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9550. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9551. newExterData.DiId = groupId;
  9552. newExterData.CreateUserId = userId;
  9553. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9554. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9555. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9556. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9557. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9558. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9559. //数据如果存在执行删除
  9560. if (enterExitCostInfo != null)
  9561. {
  9562. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9563. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9564. .Where(x => x.Id == enterExitCostInfo.Id)
  9565. .ExecuteCommand();
  9566. _sqlSugar.Updateable<Grp_DayAndCost>()
  9567. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9568. .Where(x => x.DiId == groupId)
  9569. .ExecuteCommand();
  9570. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9571. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9572. .Where(x => x.Diid == groupId)
  9573. .ExecuteCommand();
  9574. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9575. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9576. .Where(x => x.GroupId == groupId)
  9577. .ExecuteCommand();
  9578. }
  9579. //执行insert
  9580. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9581. if (insertId < 1)
  9582. {
  9583. _sqlSugar.RollbackTran();
  9584. return Ok(JsonView(false, "草稿数据导入失败!"));
  9585. }
  9586. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9587. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9588. #region 默认添加权限
  9589. #endregion
  9590. _sqlSugar.CommitTran();
  9591. //执行操作之后
  9592. //生成默认文件pdf并且通知人员
  9593. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9594. {
  9595. DiId = groupId,
  9596. ExportType = 1,
  9597. SubTypeId = 1005
  9598. }, "pdf");
  9599. //发送通知
  9600. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9601. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9602. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9603. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9604. //汇率信息记录
  9605. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9606. return Ok(JsonView(true));
  9607. }
  9608. catch (Exception ex)
  9609. {
  9610. _sqlSugar.RollbackTran();
  9611. return Ok(JsonView(false, ex.Message));
  9612. }
  9613. }
  9614. #endregion
  9615. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9616. /// <summary>
  9617. /// 获取币种基础数据(含逻辑处理)
  9618. /// </summary>
  9619. /// <returns></returns>
  9620. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9621. {
  9622. return await GeneralMethod.EnterExitCostInitRate();
  9623. }
  9624. /// <summary>
  9625. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9626. /// </summary>
  9627. /// <returns></returns>
  9628. [HttpPost]
  9629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9630. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9631. {
  9632. //验证城市归属并给默认值
  9633. int provinceId = dto.ProvinceId;
  9634. if (provinceId < 1) provinceId = 122;
  9635. var dataSource = await _sqlSugar
  9636. .Queryable<Sys_SetData>()
  9637. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9638. .ToListAsync();
  9639. var fileTypes = new List<EecSetDataInfoView>();
  9640. //三公费用-Word明细类型
  9641. var wordTypeData = dataSource
  9642. .Where(it => it.STid == 72)
  9643. .Select(x => new EecSetDataInfoView
  9644. {
  9645. ParentId = 1,
  9646. Id = x.Id,
  9647. Name = x.Name
  9648. })
  9649. .ToArray();
  9650. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9651. var excelTypeData = dataSource
  9652. .Where(it => it.STid == 73)
  9653. .Select(x => new EecSetDataInfoView
  9654. {
  9655. ParentId = 2,
  9656. Id = x.Id,
  9657. Name = x.Name
  9658. })
  9659. .ToArray();
  9660. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9661. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9662. fileTypes.Add(groupNameList);
  9663. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9664. //默认币种显示
  9665. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9666. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9667. return Ok(JsonView(true, "查询成功!", new
  9668. {
  9669. FileTypeData = fileTypes,
  9670. CurrencyInit = _currencyInfos,
  9671. viewPermissionData = viewPermissionData
  9672. }));
  9673. }
  9674. /// <summary>
  9675. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9676. /// </summary>
  9677. /// <returns></returns>
  9678. [HttpPost]
  9679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9680. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9681. {
  9682. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9683. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9684. RefAsync<int> total = 0;
  9685. int diId = 0;
  9686. var status = int.TryParse(dto.GroupName, out diId);
  9687. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9688. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9689. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9690. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9691. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9692. .OrderByDescending(x => x.VisitStartDate)
  9693. .Select(x => new EnterExitCostMobileGroupView()
  9694. {
  9695. Id = x.Id,
  9696. GroupName = x.TeamName,
  9697. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9698. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9699. ProvinceId = x.CityId
  9700. })
  9701. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9702. //处理省份Id
  9703. if (data.Any())
  9704. {
  9705. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9706. if (provCityDatas.Any())
  9707. {
  9708. foreach (var item in data)
  9709. {
  9710. var provinceId = item.ProvinceId;
  9711. var isDefualtVal = true;
  9712. if (provinceId > 0)
  9713. {
  9714. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9715. if (parentId != null)
  9716. {
  9717. isDefualtVal = false;
  9718. item.ProvinceId = (int)parentId;
  9719. }
  9720. }
  9721. if (isDefualtVal)
  9722. {
  9723. item.ProvinceId = 122; //默认四川
  9724. }
  9725. }
  9726. }
  9727. }
  9728. //处理是否显示
  9729. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9730. {
  9731. foreach (var item in data)
  9732. {
  9733. item.IsView = true;
  9734. }
  9735. }
  9736. return Ok(JsonView(true, "查询成功!", data, total));
  9737. }
  9738. /// <summary>
  9739. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9740. /// </summary>
  9741. /// <returns></returns>
  9742. [HttpPost]
  9743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9744. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9745. {
  9746. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9747. RefAsync<int> total = 0;
  9748. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9749. .Where(x => x.IsDel == 0 && x.STid == 66)
  9750. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9751. .Select(x => new
  9752. {
  9753. id = x.Id,
  9754. name = x.Name,
  9755. remark = x.Remark,
  9756. })
  9757. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9758. return Ok(JsonView(true, "查询成功!", data, total));
  9759. }
  9760. /// <summary>
  9761. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9762. /// </summary>
  9763. /// <returns></returns>
  9764. [HttpPost]
  9765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9766. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9767. {
  9768. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9769. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9770. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9771. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9772. var groupOtherRateData = groupRateData.TeamRates;
  9773. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9774. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9775. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9776. groupOtherRateData = groupOtherRateData
  9777. .Select(x => new TeamRateDescAddCurrencyIdView
  9778. {
  9779. CurrencyId = x.CurrencyId,
  9780. CurrencyName = x.CurrencyName,
  9781. CurrencyCode = x.CurrencyCode,
  9782. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9783. }).ToList();
  9784. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9785. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9786. }
  9787. /// <summary>
  9788. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9789. /// </summary>
  9790. /// <returns></returns>
  9791. [HttpPost]
  9792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9793. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9794. {
  9795. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9796. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9797. var tipsData = new List<int>() { 1, 2, 3 };
  9798. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9799. if (dto.TipsType == 1)
  9800. {
  9801. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9802. }
  9803. else if (dto.TipsType == 2)
  9804. {
  9805. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9806. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9807. }
  9808. else if (dto.TipsType == 3)
  9809. {
  9810. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9811. return Ok(JsonView(true, "查询成功!", airData));
  9812. }
  9813. return Ok(JsonView(false));
  9814. }
  9815. /// <summary>
  9816. /// 团组模块 - 出入境国家费用标准-移动端 List
  9817. /// </summary>
  9818. /// <returns></returns>
  9819. [HttpPost]
  9820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9821. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9822. {
  9823. Stopwatch sw = new Stopwatch();
  9824. sw.Start();
  9825. int provinceId = dto.ProvinceId;
  9826. if (provinceId < 1) provinceId = 122; // 默认四川
  9827. RefAsync<int> total = 0;
  9828. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9829. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9830. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9831. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9832. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9833. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9834. .Select((ntf, sd, u, sd1) => new
  9835. {
  9836. Id = ntf.Id,
  9837. Area = $"{ntf.Country}-{ntf.City}",
  9838. Currency = ntf.Currency,
  9839. CurrencyCode = sd.Name,
  9840. CurrencyName = sd.Remark,
  9841. RoomCost = ntf.RoomCost,
  9842. FoodCost = ntf.FoodCost,
  9843. PublicCost = ntf.PublicCost,
  9844. TrainCost = ntf.TrainCost,
  9845. LastUpdateUserId = ntf.LastUpdateUserId,
  9846. LastUpdateUserName = u.CnName,
  9847. LastUpdateTime = ntf.LastUpdateTime
  9848. })
  9849. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9850. sw.Stop();
  9851. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9852. }
  9853. /// <summary>
  9854. /// 团组模块 - 出入境费用-移动端 - Info
  9855. /// </summary>
  9856. /// <returns></returns>
  9857. [HttpPost]
  9858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9859. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9860. {
  9861. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9862. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9863. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9864. return Ok(data);
  9865. }
  9866. /// <summary>
  9867. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9868. /// </summary>
  9869. /// <returns></returns>
  9870. [HttpPost]
  9871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9872. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9873. {
  9874. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9875. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9876. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9877. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9878. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9879. mobileInfo.DiId = dto.DiId;
  9880. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9881. if (eecInfo == null) return Ok(mobileInfo);
  9882. //验证查看权限
  9883. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9884. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9885. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9886. mobileInfo.IsAssignPerm = isSet;
  9887. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9888. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9889. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9890. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9891. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9892. {
  9893. SubId = dac.Id,
  9894. DiId = dac.DiId,
  9895. Type = dac.Type,
  9896. Days = dac.Days,
  9897. NationalTravelFeeId = dac.NationalTravelFeeId,
  9898. Arae = $"{ntf.Country}-{ntf.City}",
  9899. Cost = dac.Cost,
  9900. Currency = dac.Currency,
  9901. CurrencyName = sd.Name,
  9902. SubTotal = dac.SubTotal,
  9903. })
  9904. .ToList();
  9905. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9906. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9907. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9908. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9909. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9910. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9911. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9912. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9913. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9914. //其他款项
  9915. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9916. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9917. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9918. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9919. .OrderBy((dop, sd1, sd2) => dop.Index)
  9920. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9921. {
  9922. SubId = dop.Id,
  9923. DiId = dop.Diid,
  9924. Index = dop.Index,
  9925. SetDataId = dop.SetDataId,
  9926. SetDataName = sd1.Name,
  9927. Cost = dop.Cost,
  9928. Currency = dop.Currency,
  9929. CurrencyName = sd2.Remark,
  9930. SubTotal = dop.SubTotal,
  9931. Remark = dop.Remark,
  9932. })
  9933. .ToArray();
  9934. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9935. return Ok(mobileInfo);
  9936. }
  9937. /// <summary>
  9938. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9939. /// </summary>
  9940. /// <returns></returns>
  9941. [HttpPost]
  9942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9943. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9944. {
  9945. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9946. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9947. //验证查看权限
  9948. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9949. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9950. var userIds = await _sqlSugar
  9951. .Queryable<Grp_EnterExitCostPermission>()
  9952. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9953. .Select(x => x.UserId)
  9954. .ToArrayAsync();
  9955. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9956. var perUsersView = new List<dynamic>();
  9957. foreach (var item in perUsers)
  9958. {
  9959. bool isView1 = false;
  9960. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9961. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9962. }
  9963. return Ok(JsonView(perUsersView));
  9964. }
  9965. /// <summary>
  9966. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9967. /// </summary>
  9968. /// <returns></returns>
  9969. [HttpPost]
  9970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9971. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9972. {
  9973. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9974. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9975. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9976. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9977. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9978. //验证查看权限
  9979. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9980. //if (!isView) return Ok(JsonView(false, msg));
  9981. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9982. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9983. var subType = dto.SubType;
  9984. if (subType == 1) //1:境内费用
  9985. {
  9986. var oneData = new ChoiceOneMobileSubInfoView()
  9987. {
  9988. Id = eecInfo.Id,
  9989. ChoiceOne = eecInfo.ChoiceOne,
  9990. ChoiceOneTotalCost = eecInfo.InsidePay,
  9991. Visa = eecInfo.Visa,
  9992. VisaRemark = eecInfo.VisaRemark,
  9993. YiMiao = eecInfo.YiMiao,
  9994. HeSuan = eecInfo.HeSuan,
  9995. Service = eecInfo.Service,
  9996. Ticket = eecInfo.Ticket,
  9997. Safe = eecInfo.Safe,
  9998. FirstItemRemark = eecInfo.FirstItemRemark
  9999. };
  10000. return Ok(JsonView(oneData));
  10001. }
  10002. else if (subType == 2) //2:国际旅费
  10003. {
  10004. var twoData = new ChoiceTwoMobileSubInfoView()
  10005. {
  10006. Id = eecInfo.Id,
  10007. ChoiceTwoJJ = eecInfo.SumJJC,
  10008. OutsideJJPay = eecInfo.OutsideJJPay,
  10009. ChoiceTwoGW = eecInfo.SumGWC,
  10010. OutsideGWPay = eecInfo.OutsideGWPay,
  10011. ChoiceTwoTD = eecInfo.SumTDC,
  10012. OutsideTDPay = eecInfo.OutsideTDPay,
  10013. AirJJ = eecInfo.AirJJ,
  10014. AirGW = eecInfo.AirGW,
  10015. AirTD = eecInfo.AirTD,
  10016. CityTranffic = eecInfo.CityTranffic,
  10017. TwoItemRemark = eecInfo.TwoItemRemark
  10018. };
  10019. return Ok(JsonView(twoData));
  10020. }
  10021. else if (subType == 3) //3:住宿费
  10022. {
  10023. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10024. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10025. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10026. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  10027. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10028. {
  10029. SubId = dac.Id,
  10030. DiId = dac.DiId,
  10031. Type = dac.Type,
  10032. Days = dac.Days,
  10033. NationalTravelFeeId = dac.NationalTravelFeeId,
  10034. Arae = $"{ntf.Country}-{ntf.City}",
  10035. Cost = dac.Cost,
  10036. Currency = dac.Currency,
  10037. CurrencyName = sd.Name,
  10038. SubTotal = dac.SubTotal,
  10039. })
  10040. .ToArray();
  10041. var data = new ChoiceMobileSubInfo3To6View()
  10042. {
  10043. ParentId = eecInfo.Id,
  10044. Choice = eecInfo.ChoiceThree,
  10045. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10046. Details = dayAndCostDatas
  10047. };
  10048. return Ok(JsonView(data));
  10049. }
  10050. else if (subType == 4) //4:伙食费
  10051. {
  10052. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10053. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10054. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10055. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  10056. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10057. {
  10058. SubId = dac.Id,
  10059. DiId = dac.DiId,
  10060. Type = dac.Type,
  10061. Days = dac.Days,
  10062. NationalTravelFeeId = dac.NationalTravelFeeId,
  10063. Arae = $"{ntf.Country}-{ntf.City}",
  10064. Cost = dac.Cost,
  10065. Currency = dac.Currency,
  10066. CurrencyName = sd.Name,
  10067. SubTotal = dac.SubTotal,
  10068. })
  10069. .ToArray();
  10070. var data = new ChoiceMobileSubInfo3To6View()
  10071. {
  10072. ParentId = eecInfo.Id,
  10073. Choice = eecInfo.ChoiceFour,
  10074. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10075. Details = dayAndCostDatas
  10076. };
  10077. return Ok(JsonView(data));
  10078. }
  10079. else if (subType == 5) //5:公杂费
  10080. {
  10081. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10082. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10083. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10084. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  10085. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10086. {
  10087. SubId = dac.Id,
  10088. DiId = dac.DiId,
  10089. Type = dac.Type,
  10090. Days = dac.Days,
  10091. NationalTravelFeeId = dac.NationalTravelFeeId,
  10092. Arae = $"{ntf.Country}-{ntf.City}",
  10093. Cost = dac.Cost,
  10094. Currency = dac.Currency,
  10095. CurrencyName = sd.Name,
  10096. SubTotal = dac.SubTotal,
  10097. })
  10098. .ToArray();
  10099. var data = new ChoiceMobileSubInfo3To6View()
  10100. {
  10101. ParentId = eecInfo.Id,
  10102. Choice = eecInfo.ChoiceFive,
  10103. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10104. Details = dayAndCostDatas
  10105. };
  10106. return Ok(JsonView(data));
  10107. }
  10108. else if (subType == 6) //6:培训费
  10109. {
  10110. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10111. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10112. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10113. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  10114. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10115. {
  10116. SubId = dac.Id,
  10117. DiId = dac.DiId,
  10118. Type = dac.Type,
  10119. Days = dac.Days,
  10120. NationalTravelFeeId = dac.NationalTravelFeeId,
  10121. Arae = $"{ntf.Country}-{ntf.City}",
  10122. Cost = dac.Cost,
  10123. Currency = dac.Currency,
  10124. CurrencyName = sd.Name,
  10125. SubTotal = dac.SubTotal,
  10126. })
  10127. .ToArray();
  10128. var data = new ChoiceMobileSubInfo3To6View()
  10129. {
  10130. ParentId = eecInfo.Id,
  10131. Choice = eecInfo.ChoiceSix,
  10132. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10133. Details = dayAndCostDatas
  10134. };
  10135. return Ok(JsonView(data));
  10136. }
  10137. else if (subType == 7) //7:其他
  10138. {
  10139. //其他款项
  10140. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10141. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10142. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10143. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10144. .OrderBy((dop, sd1, sd2) => dop.Index)
  10145. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10146. {
  10147. SubId = dop.Id,
  10148. DiId = dop.Diid,
  10149. Index = dop.Index,
  10150. SetDataId = dop.SetDataId,
  10151. SetDataName = sd1.Name,
  10152. Cost = dop.Cost,
  10153. Currency = dop.Currency,
  10154. CurrencyName = sd2.Name,
  10155. SubTotal = dop.SubTotal,
  10156. Remark = dop.Remark,
  10157. })
  10158. .ToArray();
  10159. var data = new ChoiceSevenMobileSubInfoView()
  10160. {
  10161. ParentId = eecInfo.Id,
  10162. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10163. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10164. Details = otherData
  10165. };
  10166. return Ok(JsonView(data));
  10167. }
  10168. return Ok(JsonView(false));
  10169. }
  10170. #region op
  10171. ///// <summary>
  10172. ///// 移动端更新费用消息通知
  10173. ///// </summary>
  10174. ///// <param name="diid"></param>
  10175. ///// <param name="id"></param>
  10176. ///// <param name="currUserId"></param>
  10177. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  10178. //{
  10179. // try
  10180. // {
  10181. // ////生成默认文件pdf并且通知人员
  10182. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10183. // //{
  10184. // // DiId = diid,
  10185. // // ExportType = 1,
  10186. // // SubTypeId = 1005
  10187. // //}, "pdf");
  10188. // ////发送通知
  10189. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10190. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10191. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10192. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  10193. // ////汇率信息记录
  10194. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10195. // }
  10196. // catch (Exception ex)
  10197. // {
  10198. // //记录日志
  10199. // throw;
  10200. // }
  10201. //}
  10202. /// <summary>
  10203. /// 验证出入境费用数据是否存在
  10204. /// 不存在添加
  10205. /// </summary>
  10206. /// <param name="diId"></param>
  10207. /// <param name="currUserId"></param>
  10208. /// <returns></returns>
  10209. /// <exception cref="CustomException"></exception>
  10210. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  10211. {
  10212. var parentId = 0;
  10213. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10214. if (info != null)
  10215. {
  10216. parentId = info.Id;
  10217. }
  10218. else
  10219. {
  10220. var currencys = await EnterExitCostMobileGetCurrencyInit();
  10221. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10222. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10223. parentId = addId;
  10224. }
  10225. return parentId;
  10226. }
  10227. /// <summary>
  10228. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  10229. /// </summary>
  10230. /// <returns></returns>
  10231. [HttpPost]
  10232. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10233. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  10234. {
  10235. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10236. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10237. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10238. //验证编辑权限
  10239. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10240. //if (!isEdit) return Ok(JsonView(false, msg));
  10241. var permissions = new List<Grp_EnterExitCostPermission>();
  10242. foreach (var userId in dto.UserIds)
  10243. {
  10244. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  10245. }
  10246. if (permissions.Any())
  10247. {
  10248. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10249. {
  10250. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10251. }
  10252. _sqlSugar.BeginTran();
  10253. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  10254. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10255. if (result < 1)
  10256. {
  10257. _sqlSugar.RollbackTran();
  10258. return Ok(JsonView(false));
  10259. }
  10260. _sqlSugar.CommitTran();
  10261. return Ok(JsonView(true));
  10262. }
  10263. return Ok(JsonView(false));
  10264. }
  10265. /// <summary>
  10266. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  10267. /// </summary>
  10268. /// <returns></returns>
  10269. [HttpPost]
  10270. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10271. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  10272. {
  10273. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10274. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10275. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10276. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10277. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10278. int id = dto.Id;
  10279. if (id <= 0) //add
  10280. {
  10281. //int provinceId = dto.ProvinceId;
  10282. int groupId = dto.DiId;
  10283. //if (provinceId < 1) provinceId = 122;
  10284. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  10285. info.LastUpdateUserId = dto.CurrUserId;
  10286. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10287. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  10288. if (add < 1) return Ok(JsonView(false));
  10289. id = add;
  10290. }
  10291. else //update
  10292. {
  10293. ////验证编辑权限
  10294. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10295. //if (!isEdit) return Ok(JsonView(false, msg));
  10296. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  10297. {
  10298. CurrencyRemark = currencyStr,
  10299. LastUpdateUserId = dto.CurrUserId,
  10300. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10301. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  10302. if (upd < 1) return Ok(JsonView(false));
  10303. }
  10304. #region 汇率变更时更改币种相关费用
  10305. var opDayCosts = new List<Grp_DayAndCost>();
  10306. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  10307. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10308. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  10309. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10310. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10311. .Select((dac, sd) => new
  10312. {
  10313. dac.Id,
  10314. dac.DiId,
  10315. CurrencyCode = sd.Name,
  10316. dac.Cost
  10317. })
  10318. .ToList();
  10319. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10320. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10321. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10322. .Select((dop, sd) => new
  10323. {
  10324. dop.Id,
  10325. dop.Diid,
  10326. CurrencyCode = sd.Name,
  10327. dop.Cost
  10328. })
  10329. .ToList();
  10330. if (dayCosts.Count > 0)
  10331. {
  10332. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10333. foreach (var dc in new_dayCosts)
  10334. {
  10335. var thisCurrency = dc.Key.ToUpper();
  10336. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10337. if (thisRate == 0.00M) continue;
  10338. foreach (var dcSub in dc)
  10339. {
  10340. opDayCosts.Add(new Grp_DayAndCost()
  10341. {
  10342. Id = dcSub.Id,
  10343. DiId = dcSub.DiId,
  10344. Cost = dcSub.Cost,
  10345. SubTotal = dcSub.Cost * thisRate,
  10346. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10347. });
  10348. }
  10349. }
  10350. if (opDayCosts.Count > 0)
  10351. {
  10352. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10353. }
  10354. }
  10355. if (dayOtherCosts.Count > 0)
  10356. {
  10357. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10358. foreach (var dc in new_dayOtherCosts)
  10359. {
  10360. var thisCurrency = dc.Key.ToUpper();
  10361. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10362. if (thisRate == 0.00M) continue;
  10363. foreach (var dcSub in dc)
  10364. {
  10365. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10366. {
  10367. Id = dcSub.Id,
  10368. Diid = dcSub.Diid,
  10369. Cost = dcSub.Cost,
  10370. SubTotal = dcSub.Cost * thisRate,
  10371. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10372. });
  10373. }
  10374. }
  10375. if (opDayOtherCosts.Count > 0)
  10376. {
  10377. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10378. }
  10379. }
  10380. #endregion
  10381. //消息通知
  10382. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10383. //汇率信息记录
  10384. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10385. return Ok(JsonView(new { parentId = id }));
  10386. }
  10387. /// <summary>
  10388. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10389. /// </summary>
  10390. /// <returns></returns>
  10391. [HttpPost]
  10392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10393. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10394. {
  10395. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10396. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10397. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10398. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10399. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10400. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  10401. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10402. int id = dto.Id;
  10403. if (id <= 0) //add
  10404. {
  10405. checkboxInfo.CreateUserId = dto.CurrUserId;
  10406. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10407. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10408. if (add < 1) return Ok(JsonView(false));
  10409. }
  10410. else //update
  10411. {
  10412. ////验证编辑权限
  10413. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10414. //if (!isEdit) return Ok(JsonView(false, msg));
  10415. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10416. .UpdateColumns(x => new
  10417. {
  10418. x.ChoiceOne,
  10419. x.ChoiceTwo,
  10420. x.SumJJC,
  10421. x.SumGWC,
  10422. x.SumTDC,
  10423. x.ChoiceThree,
  10424. x.ChoiceFour,
  10425. x.ChoiceFive,
  10426. x.ChoiceSix,
  10427. x.OtherExpenses_Checked
  10428. })
  10429. .Where(x => x.Id == id)
  10430. .ExecuteCommandAsync();
  10431. if (upd < 1) return Ok(JsonView(false));
  10432. }
  10433. return Ok(JsonView(new { parentId = id }));
  10434. }
  10435. /// <summary>
  10436. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10437. /// </summary>
  10438. /// <returns></returns>
  10439. [HttpPost]
  10440. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10441. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10442. {
  10443. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10444. // if (provinceId < 1) provinceId = 122;
  10445. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10446. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10447. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10448. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10449. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10450. var checkboxInfo = new Grp_EnterExitCost()
  10451. {
  10452. Id = id,
  10453. //ProvinceId = provinceId,
  10454. DiId = diId,
  10455. CreateUserId = currUserId,
  10456. LastUpdateUserId = dto.CurrUserId,
  10457. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10458. };
  10459. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10460. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10461. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10462. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10463. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10464. if (id <= 0) //add
  10465. {
  10466. checkboxInfo.CreateUserId = dto.CurrUserId;
  10467. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10468. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10469. if (add < 1) return Ok(JsonView(false));
  10470. }
  10471. else //update
  10472. {
  10473. ////验证编辑权限
  10474. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10475. //if (!isEdit) return Ok(JsonView(false, msg));
  10476. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10477. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  10478. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  10479. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10480. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10481. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10482. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10483. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10484. .Where(x => x.Id == id)
  10485. .ExecuteCommandAsync();
  10486. if (upd < 1) return Ok(JsonView(false));
  10487. }
  10488. return Ok(JsonView(new { parentId = id }));
  10489. }
  10490. /// <summary>
  10491. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10492. /// </summary>
  10493. /// <returns></returns>
  10494. [HttpPost]
  10495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10496. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10497. {
  10498. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10499. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10500. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10501. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10502. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10503. info.FirstItemRemark = dto.FirstItemRemark;
  10504. info.LastUpdateUserId = dto.CurrUserId;
  10505. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10506. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10507. int id = dto.Id;
  10508. if (id <= 0) //add
  10509. {
  10510. info.CreateUserId = dto.CurrUserId;
  10511. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10512. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10513. if (add < 1) return Ok(JsonView(false));
  10514. id = add;
  10515. }
  10516. else //update
  10517. {
  10518. ////验证编辑权限
  10519. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10520. //if (!isEdit) return Ok(JsonView(false, msg));
  10521. var upd = await _sqlSugar.Updateable(info)
  10522. .UpdateColumns(x => new
  10523. {
  10524. x.ChoiceOne,
  10525. x.InsidePay,
  10526. x.VisaRemark,
  10527. x.Visa,
  10528. x.Service,
  10529. x.Safe,
  10530. x.Ticket,
  10531. x.HeSuan,
  10532. x.YiMiao,
  10533. x.FirstItemRemark,
  10534. x.LastUpdateUserId,
  10535. x.LastUpdateTime
  10536. })
  10537. .Where(x => x.Id == id)
  10538. .ExecuteCommandAsync();
  10539. if (upd < 1) return Ok(JsonView(false));
  10540. }
  10541. //消息通知
  10542. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10543. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10544. }
  10545. /// <summary>
  10546. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10547. /// </summary>
  10548. /// <returns></returns>
  10549. [HttpPost]
  10550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10551. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10552. {
  10553. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10554. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10555. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10556. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10557. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10558. info.DiId = dto.DiId;
  10559. //info.ProvinceId = dto.ProvinceId;
  10560. info.OutsideJJPay = dto.OutsideJJPay;
  10561. info.OutsideGWPay = dto.OutsideGWPay;
  10562. info.OutsideTDPay = dto.OutsideTDPay;
  10563. info.AirJJ = dto.AirJJ;
  10564. info.AirGW = dto.AirGW;
  10565. info.AirTD = dto.AirTD;
  10566. info.CityTranffic = dto.CityTranffic;
  10567. info.TwoItemRemark = dto.TwoItemRemark;
  10568. info.SumJJC = dto.ChoiceTwoJJ;
  10569. info.SumGWC = dto.ChoiceTwoGW;
  10570. info.SumTDC = dto.ChoiceTwoTD;
  10571. info.LastUpdateUserId = dto.CurrUserId;
  10572. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10573. int id = dto.Id;
  10574. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10575. if (id <= 0) //add i
  10576. {
  10577. info.CreateUserId = dto.CurrUserId;
  10578. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10579. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10580. if (addId <= 0) return Ok(JsonView(false));
  10581. id = addId;
  10582. }
  10583. else //update
  10584. {
  10585. ////验证编辑权限
  10586. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10587. //if (!isEdit) return Ok(JsonView(false, msg));
  10588. var upd = await _sqlSugar.Updateable(info)
  10589. .UpdateColumns(x => new
  10590. {
  10591. x.SumJJC,
  10592. x.OutsideJJPay,
  10593. x.SumGWC,
  10594. x.OutsideGWPay,
  10595. x.SumTDC,
  10596. x.OutsideTDPay,
  10597. x.AirJJ,
  10598. x.AirGW,
  10599. x.AirTD,
  10600. x.CityTranffic,
  10601. x.TwoItemRemark,
  10602. x.LastUpdateTime,
  10603. x.LastUpdateUserId
  10604. })
  10605. .Where(x => x.Id == id)
  10606. .ExecuteCommandAsync();
  10607. if (upd < 1) return Ok(JsonView(false));
  10608. }
  10609. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10610. gwcItemTotal = info.AirGW + info.CityTranffic;
  10611. tdcItemTotal = info.AirTD + info.CityTranffic;
  10612. //消息通知
  10613. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10614. return Ok(JsonView(new
  10615. {
  10616. parentId = id,
  10617. choiceTwoJJ = dto.ChoiceTwoJJ,
  10618. jjcItemTotal = jjcItemTotal,
  10619. choiceTwoGW = dto.ChoiceTwoGW,
  10620. gwcItemTotal = gwcItemTotal,
  10621. choiceTwoTD = dto.ChoiceTwoTD,
  10622. tdcItemTotal = tdcItemTotal
  10623. }));
  10624. }
  10625. /// <summary>
  10626. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10627. /// </summary>
  10628. /// <returns></returns>
  10629. [HttpPost]
  10630. [ApiExplorerSettings(IgnoreApi = true)]
  10631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10632. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10633. {
  10634. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10635. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10636. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10637. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10638. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10639. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10640. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10641. var infos = infos1.Select(x => new Grp_DayAndCost
  10642. {
  10643. Id = x.Id,
  10644. DiId = dto.DiId,
  10645. Type = dto.FeeType,
  10646. Days = x.Days,
  10647. NationalTravelFeeId = x.NationalTravelFeeId,
  10648. Cost = x.Cost,
  10649. Currency = x.Currency,
  10650. SubTotal = x.SubTotal,
  10651. CreateUserId = dto.CurrUserId
  10652. })
  10653. .ToList();
  10654. var adds = infos.Where(x => x.Id <= 0).ToList();
  10655. var upds = infos.Where(x => x.Id > 0).ToList();
  10656. if (adds.Count > 0)
  10657. {
  10658. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10659. if (add < 1) return Ok(JsonView(false));
  10660. }
  10661. if (upds.Count > 0)
  10662. {
  10663. var upd = await _sqlSugar.Updateable(adds)
  10664. .UpdateColumns(x => new
  10665. {
  10666. x.Days,
  10667. x.NationalTravelFeeId,
  10668. x.Cost,
  10669. x.Currency,
  10670. x.SubTotal
  10671. })
  10672. .WhereColumns(x => new { x.Id })
  10673. .ExecuteCommandAsync();
  10674. if (upd < 1) return Ok(JsonView(false));
  10675. }
  10676. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10677. //消息通知
  10678. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10679. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10680. return Ok(JsonView(new { itemTotal = itemTotal }));
  10681. }
  10682. /// <summary>
  10683. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10684. /// </summary>
  10685. /// <returns></returns>
  10686. [HttpPost]
  10687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10688. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10689. {
  10690. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10691. int subId = dto.SubId, feeType = dto.FeeType;
  10692. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10693. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10694. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10695. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10696. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10697. subInfo.Id = subId;
  10698. subInfo.DiId = dto.DiId;
  10699. if (feeType == 3) subInfo.Type = 1;
  10700. else if (feeType == 4) subInfo.Type = 2;
  10701. else if (feeType == 5) subInfo.Type = 3;
  10702. else if (feeType == 6) subInfo.Type = 4;
  10703. subInfo.CreateUserId = dto.CurrUserId;
  10704. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10705. if (parentId < 1) return Ok(JsonView(false));
  10706. //子表op
  10707. if (subId < 1)
  10708. {
  10709. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10710. if (subAdd < 1) return Ok(JsonView(false));
  10711. }
  10712. else
  10713. {
  10714. ////验证编辑权限
  10715. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10716. //if (!isEdit) return Ok(JsonView(false, msg));
  10717. var subUpd = await _sqlSugar.Updateable(subInfo)
  10718. .UpdateColumns(x => new
  10719. {
  10720. x.Days,
  10721. x.NationalTravelFeeId,
  10722. x.Cost,
  10723. x.Currency,
  10724. x.SubTotal
  10725. })
  10726. .WhereColumns(x => new { x.Id })
  10727. .ExecuteCommandAsync();
  10728. if (subUpd < 1) return Ok(JsonView(false));
  10729. }
  10730. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10731. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10732. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10733. }
  10734. /// <summary>
  10735. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10736. /// </summary>
  10737. /// <returns></returns>
  10738. [HttpPost]
  10739. [ApiExplorerSettings(IgnoreApi = true)]
  10740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10741. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10742. {
  10743. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10744. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10745. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10746. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10747. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10748. {
  10749. Id = x.Id,
  10750. Diid = dto.DiId,
  10751. SetDataId = x.SetDataId,
  10752. Index = x.Index,
  10753. Cost = x.Cost,
  10754. Currency = x.Currency,
  10755. SubTotal = x.SubTotal,
  10756. CreateUserId = dto.CurrUserId,
  10757. Remark = x.Remark
  10758. }).ToList();
  10759. var adds = infos.Where(x => x.Id <= 0).ToList();
  10760. var upds = infos.Where(x => x.Id > 0).ToList();
  10761. if (adds.Count > 0)
  10762. {
  10763. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10764. if (add < 1) return Ok(JsonView(false));
  10765. }
  10766. if (upds.Count > 0)
  10767. {
  10768. var upd = await _sqlSugar.Updateable(adds)
  10769. .UpdateColumns(x => new
  10770. {
  10771. x.Index,
  10772. x.SetDataId,
  10773. x.Cost,
  10774. x.Currency,
  10775. x.SubTotal,
  10776. x.Remark
  10777. })
  10778. .WhereColumns(x => new { x.Id })
  10779. .ExecuteCommandAsync();
  10780. if (upd < 1) return Ok(JsonView(false));
  10781. }
  10782. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10783. //消息通知
  10784. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10785. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10786. return Ok(JsonView(new { itemTotal = itemTotal }));
  10787. }
  10788. /// <summary>
  10789. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10790. /// </summary>
  10791. /// <returns></returns>
  10792. [HttpPost]
  10793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10794. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10795. {
  10796. int subId = dto.SubId;
  10797. int diId = dto.Diid;
  10798. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10799. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10800. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10801. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10802. subInfo.Id = subId;
  10803. subInfo.Diid = dto.Diid;
  10804. subInfo.CreateUserId = dto.CurrUserId;
  10805. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10806. if (parentId < 1) return Ok(JsonView(false));
  10807. #region 子表op
  10808. if (subId < 1)//add
  10809. {
  10810. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10811. if (subAdd < 1) return Ok(JsonView(false));
  10812. }
  10813. else //upd
  10814. {
  10815. ////验证编辑权限
  10816. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10817. //if (!isEdit) return Ok(JsonView(false, msg));
  10818. var subUpd = await _sqlSugar.Updateable(subInfo)
  10819. .UpdateColumns(x => new
  10820. {
  10821. x.Index,
  10822. x.SetDataId,
  10823. x.Cost,
  10824. x.Currency,
  10825. x.SubTotal,
  10826. x.Remark
  10827. })
  10828. .WhereColumns(x => new { x.Id })
  10829. .ExecuteCommandAsync();
  10830. if (subUpd < 1) return Ok(JsonView(false));
  10831. }
  10832. #endregion
  10833. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10834. //消息通知
  10835. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10836. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10837. }
  10838. /// <summary>
  10839. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10840. /// </summary>
  10841. /// <returns></returns>
  10842. [HttpPost]
  10843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10844. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10845. {
  10846. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10847. if (data.Code != 0)
  10848. {
  10849. return Ok(JsonView(false, data.Msg));
  10850. }
  10851. return Ok(JsonView(true, "操作成功!", data.Data));
  10852. }
  10853. /// <summary>
  10854. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10855. /// </summary>
  10856. /// <param name="dto"></param>
  10857. /// <returns></returns>
  10858. [HttpPost]
  10859. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10860. {
  10861. var data = new Grp_DayOtherPrice()
  10862. {
  10863. Id = dto.Id,
  10864. IsDel = 1,
  10865. DeleteUserId = dto.DeleteUserId,
  10866. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10867. };
  10868. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10869. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10870. return Ok(JsonView(false, "删除失败!"));
  10871. }
  10872. #endregion
  10873. #endregion
  10874. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10875. /// <summary>
  10876. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10877. /// </summary>
  10878. /// <returns></returns>
  10879. [HttpGet]
  10880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10881. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10882. {
  10883. var provData = await _groupRepository.ProvinceBasicSource();
  10884. return Ok(JsonView(true, "查询成功!", provData));
  10885. }
  10886. /// <summary>
  10887. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10888. /// </summary>
  10889. /// <returns></returns>
  10890. [HttpPost]
  10891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10892. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10893. {
  10894. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10895. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10896. RefAsync<int> total = 0;
  10897. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10898. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10899. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10900. .Select(x => new
  10901. {
  10902. Id = x.Id,
  10903. DraftName = x.DraftName,
  10904. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10905. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10906. .Any()
  10907. })
  10908. .OrderByDescending(x => x.Id)
  10909. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10910. return Ok(JsonView(true, "查询成功!", data, total));
  10911. }
  10912. /// <summary>
  10913. /// 出入境费用-草稿 移动端
  10914. /// 获取币种基础数据(含逻辑处理)
  10915. /// </summary>
  10916. /// <returns></returns>
  10917. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10918. {
  10919. return await GeneralMethod.EnterExitCostInitRate();
  10920. }
  10921. /// <summary>
  10922. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10923. /// </summary>
  10924. /// <returns></returns>
  10925. [HttpPost]
  10926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10927. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10928. {
  10929. //验证城市归属并给默认值
  10930. int provinceId = dto.ProvinceId;
  10931. if (provinceId < 1) provinceId = 122;
  10932. var dataSource = await _sqlSugar
  10933. .Queryable<Sys_SetData>()
  10934. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10935. .ToListAsync();
  10936. //三公费用-Word明细类型
  10937. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10938. .Select(x => new SetDataInfoView
  10939. {
  10940. Id = x.Id,
  10941. Name = x.Name,
  10942. Remark = x.Remark
  10943. })
  10944. .ToList();
  10945. //三公费用-Excel明细类型
  10946. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10947. .Select(x => new SetDataInfoView
  10948. {
  10949. Id = x.Id,
  10950. Name = x.Name,
  10951. Remark = x.Remark
  10952. })
  10953. .ToList();
  10954. //默认币种显示
  10955. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10956. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10957. return Ok(JsonView(true, "查询成功!", new
  10958. {
  10959. WordTypeData = wordTypeData,
  10960. ExcelTypeData = excelTypeData,
  10961. CurrencyInit = _currencyInfos,
  10962. viewPermissionData = viewPermissionData
  10963. }));
  10964. }
  10965. /// <summary>
  10966. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10967. /// </summary>
  10968. /// <returns></returns>
  10969. [HttpPost]
  10970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10971. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10972. {
  10973. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10974. RefAsync<int> total = 0;
  10975. int diId = 0;
  10976. var status = int.TryParse(dto.GroupName, out diId);
  10977. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10978. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10979. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10980. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10981. .OrderByDescending(x => x.VisitStartDate)
  10982. .Select(x => new
  10983. {
  10984. Id = x.Id,
  10985. GroupName = x.TeamName
  10986. })
  10987. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10988. return Ok(JsonView(true, "查询成功!", data, total));
  10989. }
  10990. /// <summary>
  10991. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10992. /// </summary>
  10993. /// <returns></returns>
  10994. [HttpPost]
  10995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10996. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10997. {
  10998. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10999. RefAsync<int> total = 0;
  11000. var data = await _sqlSugar.Queryable<Sys_SetData>()
  11001. .Where(x => x.IsDel == 0 && x.STid == 66)
  11002. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  11003. .Select(x => new
  11004. {
  11005. id = x.Id,
  11006. name = x.Name,
  11007. remark = x.Remark,
  11008. })
  11009. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11010. return Ok(JsonView(true, "查询成功!", data, total));
  11011. }
  11012. /// <summary>
  11013. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  11014. /// </summary>
  11015. /// <returns></returns>
  11016. [HttpPost]
  11017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11018. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  11019. {
  11020. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11021. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11022. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  11023. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  11024. var groupOtherRateData = groupRateData.TeamRates;
  11025. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11026. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  11027. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  11028. groupOtherRateData = groupOtherRateData
  11029. .Select(x => new TeamRateDescAddCurrencyIdView
  11030. {
  11031. CurrencyId = x.CurrencyId,
  11032. CurrencyName = x.CurrencyName,
  11033. CurrencyCode = x.CurrencyCode,
  11034. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  11035. }).ToList();
  11036. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  11037. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  11038. }
  11039. /// <summary>
  11040. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  11041. /// </summary>
  11042. /// <returns></returns>
  11043. [HttpPost]
  11044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11045. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  11046. {
  11047. int portType = dto.PortType;
  11048. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11049. var tipsData = new List<int>() { 1, 2, 3 };
  11050. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  11051. if (dto.TipsType == 1)
  11052. {
  11053. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  11054. }
  11055. else if (dto.TipsType == 2)
  11056. {
  11057. if (portType == 2)
  11058. {
  11059. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11060. }
  11061. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11062. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  11063. .Select(x => x.NationalTravelFeeId)
  11064. .Distinct()
  11065. .ToListAsync();
  11066. if (portType == 2)
  11067. {
  11068. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11069. }
  11070. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  11071. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  11072. .Select(x => x.Country)
  11073. .Distinct()
  11074. .ToArrayAsync();
  11075. if (portType == 2)
  11076. {
  11077. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11078. }
  11079. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  11080. return Ok(JsonView(true, "查询成功!", new
  11081. {
  11082. totalAmt = totalAmt,
  11083. remark = remark
  11084. }));
  11085. }
  11086. else if (dto.TipsType == 3)
  11087. {
  11088. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  11089. }
  11090. return Ok(JsonView(false));
  11091. }
  11092. /// <summary>
  11093. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  11094. /// </summary>
  11095. /// <returns></returns>
  11096. [HttpPost]
  11097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11098. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  11099. {
  11100. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  11101. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11102. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11103. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  11104. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  11105. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  11106. var info = new Grp_EnterExitCostDraft()
  11107. {
  11108. ProvinceId = dto.ProvinceId,
  11109. DraftName = dto.DraftName,
  11110. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  11111. CreateUserId = dto.CurrUserId
  11112. };
  11113. _sqlSugar.BeginTran();
  11114. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11115. if (draftId < 1)
  11116. {
  11117. _sqlSugar.RollbackTran();
  11118. return Ok(JsonView(false, "草稿创建失败!"));
  11119. }
  11120. //添加默认权限
  11121. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  11122. _sqlSugar.CommitTran();
  11123. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  11124. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11125. mobileInfo.Id = draftId;
  11126. mobileInfo.DraftName = dto.DraftName;
  11127. mobileInfo.Currencys = rateInfos;
  11128. mobileInfo.IsAssignPerm = assignPerm;
  11129. return Ok(JsonView(mobileInfo));
  11130. }
  11131. /// <summary>
  11132. /// 出入境费用-草稿-移动端 查看编辑提示消息
  11133. /// </summary>
  11134. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  11135. /// <summary>
  11136. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  11137. /// </summary>
  11138. /// <returns></returns>
  11139. [HttpPost]
  11140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11141. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  11142. {
  11143. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11144. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11145. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11146. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11147. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  11148. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  11149. //验证查看编辑权限
  11150. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11151. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11152. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  11153. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  11154. mobileInfo.IsAssignPerm = assignPerm;
  11155. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11156. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11157. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11158. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11159. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11160. {
  11161. ParentId = dac.ParentId,
  11162. SubId = dac.Id,
  11163. Type = dac.Type,
  11164. Days = dac.Days,
  11165. NationalTravelFeeId = dac.NationalTravelFeeId,
  11166. Arae = $"{ntf.Country}-{ntf.City}",
  11167. Cost = dac.Cost,
  11168. Currency = dac.Currency,
  11169. CurrencyName = sd.Name,
  11170. SubTotal = dac.SubTotal,
  11171. })
  11172. .ToList();
  11173. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  11174. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  11175. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  11176. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  11177. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  11178. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  11179. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  11180. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  11181. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  11182. //其他款项
  11183. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11184. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11185. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11186. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11187. .OrderBy((dop, sd1, sd2) => dop.Index)
  11188. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11189. {
  11190. ParentId = dop.ParentId,
  11191. SubId = dop.Id,
  11192. Index = dop.Index,
  11193. SetDataId = dop.SetDataId,
  11194. SetDataName = sd1.Name,
  11195. Cost = dop.Cost,
  11196. Currency = dop.Currency,
  11197. CurrencyName = sd2.Remark,
  11198. SubTotal = dop.SubTotal,
  11199. Remark = dop.Remark,
  11200. })
  11201. .ToArray();
  11202. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  11203. return Ok(mobileInfo);
  11204. }
  11205. /// <summary>
  11206. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  11207. /// </summary>
  11208. /// <returns></returns>
  11209. [HttpPost]
  11210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11211. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  11212. {
  11213. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11214. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11215. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11216. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  11217. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  11218. //验证查看编辑权限
  11219. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11220. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11221. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11222. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  11223. var subType = dto.SubType;
  11224. if (subType == 1) //1:境内费用
  11225. {
  11226. var oneData = new ChoiceOneMobileSubInfoView()
  11227. {
  11228. Id = eecInfo.Id,
  11229. ChoiceOne = eecInfo.ChoiceOne,
  11230. ChoiceOneTotalCost = eecInfo.InsidePay,
  11231. Visa = eecInfo.Visa,
  11232. VisaRemark = eecInfo.VisaRemark,
  11233. YiMiao = eecInfo.YiMiao,
  11234. HeSuan = eecInfo.HeSuan,
  11235. Service = eecInfo.Service,
  11236. Ticket = eecInfo.Ticket,
  11237. Safe = eecInfo.Safe,
  11238. FirstItemRemark = eecInfo.FirstItemRemark
  11239. };
  11240. return Ok(JsonView(oneData));
  11241. }
  11242. else if (subType == 2) //2:国际旅费
  11243. {
  11244. var twoData = new ChoiceTwoMobileSubInfoView()
  11245. {
  11246. Id = eecInfo.Id,
  11247. ChoiceTwoJJ = eecInfo.SumJJC,
  11248. OutsideJJPay = eecInfo.OutsideJJPay,
  11249. ChoiceTwoGW = eecInfo.SumGWC,
  11250. OutsideGWPay = eecInfo.OutsideGWPay,
  11251. ChoiceTwoTD = eecInfo.SumTDC,
  11252. OutsideTDPay = eecInfo.OutsideTDPay,
  11253. AirJJ = eecInfo.AirJJ,
  11254. AirGW = eecInfo.AirGW,
  11255. AirTD = eecInfo.AirTD,
  11256. CityTranffic = eecInfo.CityTranffic,
  11257. TwoItemRemark = eecInfo.TwoItemRemark
  11258. };
  11259. return Ok(JsonView(twoData));
  11260. }
  11261. else if (subType == 3) //3:住宿费
  11262. {
  11263. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11264. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11265. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11266. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  11267. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11268. {
  11269. ParentId = dac.ParentId,
  11270. SubId = dac.Id,
  11271. Type = dac.Type,
  11272. Days = dac.Days,
  11273. NationalTravelFeeId = dac.NationalTravelFeeId,
  11274. Arae = $"{ntf.Country}-{ntf.City}",
  11275. Cost = dac.Cost,
  11276. Currency = dac.Currency,
  11277. CurrencyName = sd.Name,
  11278. SubTotal = dac.SubTotal,
  11279. })
  11280. .ToArray();
  11281. var data = new ChoiceDraftMobileSubInfo3To6View()
  11282. {
  11283. ParentId = eecInfo.Id,
  11284. Choice = eecInfo.ChoiceThree,
  11285. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11286. Details = dayAndCostDatas
  11287. };
  11288. return Ok(JsonView(data));
  11289. }
  11290. else if (subType == 4) //4:伙食费
  11291. {
  11292. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11293. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11294. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11295. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  11296. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11297. {
  11298. ParentId = dac.ParentId,
  11299. SubId = dac.Id,
  11300. Type = dac.Type,
  11301. Days = dac.Days,
  11302. NationalTravelFeeId = dac.NationalTravelFeeId,
  11303. Arae = $"{ntf.Country}-{ntf.City}",
  11304. Cost = dac.Cost,
  11305. Currency = dac.Currency,
  11306. CurrencyName = sd.Name,
  11307. SubTotal = dac.SubTotal,
  11308. })
  11309. .ToArray();
  11310. var data = new ChoiceDraftMobileSubInfo3To6View()
  11311. {
  11312. ParentId = eecInfo.Id,
  11313. Choice = eecInfo.ChoiceFour,
  11314. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11315. Details = dayAndCostDatas
  11316. };
  11317. return Ok(JsonView(data));
  11318. }
  11319. else if (subType == 5) //5:公杂费
  11320. {
  11321. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11322. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11323. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11324. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  11325. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11326. {
  11327. ParentId = dac.ParentId,
  11328. SubId = dac.Id,
  11329. Type = dac.Type,
  11330. Days = dac.Days,
  11331. NationalTravelFeeId = dac.NationalTravelFeeId,
  11332. Arae = $"{ntf.Country}-{ntf.City}",
  11333. Cost = dac.Cost,
  11334. Currency = dac.Currency,
  11335. CurrencyName = sd.Name,
  11336. SubTotal = dac.SubTotal,
  11337. })
  11338. .ToArray();
  11339. var data = new ChoiceDraftMobileSubInfo3To6View()
  11340. {
  11341. ParentId = eecInfo.Id,
  11342. Choice = eecInfo.ChoiceFive,
  11343. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11344. Details = dayAndCostDatas
  11345. };
  11346. return Ok(JsonView(data));
  11347. }
  11348. else if (subType == 6) //6:培训费
  11349. {
  11350. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11351. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11352. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11353. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  11354. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11355. {
  11356. ParentId = dac.ParentId,
  11357. SubId = dac.Id,
  11358. Type = dac.Type,
  11359. Days = dac.Days,
  11360. NationalTravelFeeId = dac.NationalTravelFeeId,
  11361. Arae = $"{ntf.Country}-{ntf.City}",
  11362. Cost = dac.Cost,
  11363. Currency = dac.Currency,
  11364. CurrencyName = sd.Name,
  11365. SubTotal = dac.SubTotal,
  11366. })
  11367. .ToArray();
  11368. var data = new ChoiceDraftMobileSubInfo3To6View()
  11369. {
  11370. ParentId = eecInfo.Id,
  11371. Choice = eecInfo.ChoiceSix,
  11372. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11373. Details = dayAndCostDatas
  11374. };
  11375. return Ok(JsonView(data));
  11376. }
  11377. else if (subType == 7) //7:其他
  11378. {
  11379. //其他款项
  11380. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11381. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11382. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11383. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11384. .OrderBy((dop, sd1, sd2) => dop.Index)
  11385. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11386. {
  11387. ParentId = dop.ParentId,
  11388. SubId = dop.Id,
  11389. Index = dop.Index,
  11390. SetDataId = dop.SetDataId,
  11391. SetDataName = sd1.Name,
  11392. Cost = dop.Cost,
  11393. Currency = dop.Currency,
  11394. CurrencyName = sd2.Name,
  11395. SubTotal = dop.SubTotal,
  11396. Remark = dop.Remark,
  11397. })
  11398. .ToArray();
  11399. var data = new ChoiceSevenDraftMobileSubInfoView()
  11400. {
  11401. ParentId = eecInfo.Id,
  11402. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11403. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11404. Details = otherData
  11405. };
  11406. return Ok(JsonView(data));
  11407. }
  11408. return Ok(JsonView(false));
  11409. }
  11410. #region op
  11411. ///// <summary>
  11412. ///// 移动端更新费用消息通知
  11413. ///// </summary>
  11414. ///// <param name="draftId"></param>
  11415. ///// <param name="id"></param>
  11416. ///// <param name="currUserId"></param>
  11417. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11418. //{
  11419. // try
  11420. // {
  11421. // ////生成默认文件pdf并且通知人员
  11422. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11423. // //{
  11424. // // DiId = draftId,
  11425. // // ExportType = 1,
  11426. // // SubTypeId = 1005
  11427. // //}, "pdf");
  11428. // ////发送通知
  11429. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11430. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11431. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11432. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11433. // ////汇率信息记录
  11434. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11435. // }
  11436. // catch (Exception ex)
  11437. // {
  11438. // //记录日志
  11439. // throw;
  11440. // }
  11441. //}
  11442. /// <summary>
  11443. /// 验证出入境费用数据是否存在
  11444. /// 不存在添加
  11445. /// </summary>
  11446. /// <param name="draftId"></param>
  11447. /// <param name="currUserId"></param>
  11448. /// <returns></returns>
  11449. /// <exception cref="CustomException"></exception>
  11450. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11451. {
  11452. var parentId = 0;
  11453. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11454. if (info != null) parentId = info.Id;
  11455. else
  11456. {
  11457. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11458. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11459. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11460. parentId = addId;
  11461. }
  11462. return parentId;
  11463. }
  11464. /// <summary>
  11465. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11466. /// </summary>
  11467. /// <returns></returns>
  11468. [HttpPost]
  11469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11470. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11471. {
  11472. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11473. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11474. //验证查看权限
  11475. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11476. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11477. var userIds = await _sqlSugar
  11478. .Queryable<Grp_EnterExitCostDraftPermission>()
  11479. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11480. .Select(x => x.UserId)
  11481. .ToArrayAsync();
  11482. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11483. var perUsersView = new List<dynamic>();
  11484. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11485. var viewPermissionData = new List<PermissionViewUserview>();
  11486. if (feeBasePerm.Any())
  11487. {
  11488. foreach (var item in feeBasePerm)
  11489. {
  11490. if (item.Users.Any())
  11491. {
  11492. viewPermissionData.AddRange(item.Users);
  11493. }
  11494. }
  11495. }
  11496. foreach (var item in perUsers)
  11497. {
  11498. bool isView1 = false;
  11499. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11500. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11501. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11502. }
  11503. return Ok(JsonView(perUsersView));
  11504. }
  11505. /// <summary>
  11506. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11507. /// </summary>
  11508. /// <returns></returns>
  11509. [HttpPost]
  11510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11511. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11512. {
  11513. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11514. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11515. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11516. //验证查看编辑权限
  11517. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11518. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11519. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11520. foreach (var userId in dto.UserIds)
  11521. {
  11522. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11523. }
  11524. if (permissions.Any())
  11525. {
  11526. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11527. {
  11528. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11529. }
  11530. _sqlSugar.BeginTran();
  11531. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11532. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11533. if (result < 1)
  11534. {
  11535. _sqlSugar.RollbackTran();
  11536. return Ok(JsonView(false));
  11537. }
  11538. _sqlSugar.CommitTran();
  11539. return Ok(JsonView(true));
  11540. }
  11541. return Ok(JsonView(false));
  11542. }
  11543. /// <summary>
  11544. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11545. /// </summary>
  11546. /// <returns></returns>
  11547. [HttpPost]
  11548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11549. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11550. {
  11551. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11552. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11553. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11554. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11555. int id = dto.DraftId;
  11556. if (id <= 0) //add
  11557. {
  11558. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11559. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11560. if (add < 1) return Ok(JsonView(false));
  11561. id = add;
  11562. }
  11563. else //update
  11564. {
  11565. //验证查看编辑权限
  11566. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11567. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11568. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11569. if (upd < 1) return Ok(JsonView(false));
  11570. }
  11571. return Ok(JsonView(new { parentId = id }));
  11572. }
  11573. /// <summary>
  11574. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11575. /// </summary>
  11576. /// <returns></returns>
  11577. [HttpPost]
  11578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11579. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11580. {
  11581. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11582. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11583. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11584. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11585. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11586. int id = dto.DraftId;
  11587. if (id <= 0) //add
  11588. {
  11589. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11590. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11591. if (add < 1) return Ok(JsonView(false));
  11592. id = add;
  11593. }
  11594. else //update
  11595. {
  11596. //验证查看编辑权限
  11597. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11598. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11599. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11600. if (upd < 1) return Ok(JsonView(false));
  11601. }
  11602. #region 汇率变更时更改币种相关费用
  11603. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11604. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11605. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11606. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11607. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11608. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11609. .Select((dac, sd) => new
  11610. {
  11611. dac.Id,
  11612. dac.ParentId,
  11613. CurrencyCode = sd.Name,
  11614. dac.Cost
  11615. })
  11616. .ToList();
  11617. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11618. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11619. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11620. .Select((dop, sd) => new
  11621. {
  11622. dop.Id,
  11623. dop.ParentId,
  11624. CurrencyCode = sd.Name,
  11625. dop.Cost
  11626. })
  11627. .ToList();
  11628. if (dayCosts.Count > 0)
  11629. {
  11630. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11631. foreach (var dc in new_dayCosts)
  11632. {
  11633. var thisCurrency = dc.Key.ToUpper();
  11634. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11635. if (thisRate == 0.00M) continue;
  11636. foreach (var dcSub in dc)
  11637. {
  11638. opDayCosts.Add(new Grp_DayAndCostDraft()
  11639. {
  11640. Id = dcSub.Id,
  11641. ParentId = dcSub.ParentId,
  11642. Cost = dcSub.Cost,
  11643. SubTotal = dcSub.Cost * thisRate,
  11644. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11645. });
  11646. }
  11647. }
  11648. if (opDayCosts.Count > 0)
  11649. {
  11650. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11651. }
  11652. }
  11653. if (dayOtherCosts.Count > 0)
  11654. {
  11655. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11656. foreach (var dc in new_dayOtherCosts)
  11657. {
  11658. var thisCurrency = dc.Key.ToUpper();
  11659. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11660. if (thisRate == 0.00M) continue;
  11661. foreach (var dcSub in dc)
  11662. {
  11663. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11664. {
  11665. Id = dcSub.Id,
  11666. ParentId = dcSub.ParentId,
  11667. Cost = dcSub.Cost,
  11668. SubTotal = dcSub.Cost * thisRate,
  11669. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11670. });
  11671. }
  11672. }
  11673. if (opDayOtherCosts.Count > 0)
  11674. {
  11675. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11676. }
  11677. }
  11678. #endregion
  11679. ////消息通知
  11680. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11681. ////汇率信息记录
  11682. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11683. return Ok(JsonView(new { parentId = id }));
  11684. }
  11685. /// <summary>
  11686. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11687. /// </summary>
  11688. /// <returns></returns>
  11689. [HttpPost]
  11690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11691. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11692. {
  11693. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11694. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11695. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11696. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11697. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11698. int id = dto.DraftId;
  11699. if (id <= 0) //add
  11700. {
  11701. checkboxInfo.ProvinceId = dto.ProvinceId;
  11702. checkboxInfo.CreateUserId = dto.CurrUserId;
  11703. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11704. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11705. if (add < 1) return Ok(JsonView(false));
  11706. }
  11707. else //update
  11708. {
  11709. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11710. .UpdateColumns(x => new
  11711. {
  11712. x.ChoiceOne,
  11713. x.ChoiceTwo,
  11714. x.SumJJC,
  11715. x.SumGWC,
  11716. x.SumTDC,
  11717. x.ChoiceThree,
  11718. x.ChoiceFour,
  11719. x.ChoiceFive,
  11720. x.ChoiceSix,
  11721. x.OtherExpenses_Checked
  11722. })
  11723. .Where(x => x.Id == id)
  11724. .ExecuteCommandAsync();
  11725. if (upd < 1) return Ok(JsonView(false));
  11726. }
  11727. return Ok(JsonView(new { parentId = id }));
  11728. }
  11729. /// <summary>
  11730. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11731. /// </summary>
  11732. /// <returns></returns>
  11733. [HttpPost]
  11734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11735. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11736. {
  11737. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11738. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11739. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11740. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11741. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11742. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11743. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11744. var checkboxInfo = new Grp_EnterExitCostDraft()
  11745. {
  11746. Id = draftId,
  11747. ProvinceId = dto.ProvinceId,
  11748. CreateUserId = currUserId
  11749. };
  11750. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11751. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11752. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11753. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11754. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11755. if (draftId <= 0) //add
  11756. {
  11757. checkboxInfo.CreateUserId = dto.CurrUserId;
  11758. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11759. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11760. if (add < 1) return Ok(JsonView(false));
  11761. }
  11762. else //update
  11763. {
  11764. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11765. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11766. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11767. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11768. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11769. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11770. .Where(x => x.Id == draftId)
  11771. .ExecuteCommandAsync();
  11772. if (upd < 1) return Ok(JsonView(false));
  11773. }
  11774. return Ok(JsonView(new { parentId = draftId }));
  11775. }
  11776. /// <summary>
  11777. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11778. /// </summary>
  11779. /// <returns></returns>
  11780. [HttpPost]
  11781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11782. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11783. {
  11784. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11785. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11786. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11787. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11788. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11789. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11790. info.ProvinceId = dto.ProvinceId;
  11791. info.FirstItemRemark = dto.FirstItemRemark;
  11792. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11793. if (id <= 0) //add
  11794. {
  11795. info.CreateUserId = dto.CurrUserId;
  11796. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11797. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11798. if (add < 1) return Ok(JsonView(false));
  11799. id = add;
  11800. }
  11801. else //update
  11802. {
  11803. var upd = await _sqlSugar.Updateable(info)
  11804. .UpdateColumns(x => new
  11805. {
  11806. x.ChoiceOne,
  11807. x.InsidePay,
  11808. x.VisaRemark,
  11809. x.Visa,
  11810. x.Service,
  11811. x.Safe,
  11812. x.Ticket,
  11813. x.HeSuan,
  11814. x.YiMiao,
  11815. x.FirstItemRemark
  11816. })
  11817. .Where(x => x.Id == id)
  11818. .ExecuteCommandAsync();
  11819. if (upd < 1) return Ok(JsonView(false));
  11820. }
  11821. ////消息通知
  11822. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11823. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11824. }
  11825. /// <summary>
  11826. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11827. /// </summary>
  11828. /// <returns></returns>
  11829. [HttpPost]
  11830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11831. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11832. {
  11833. int id = dto.DraftId;
  11834. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11835. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11836. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11837. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11838. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11839. info.ProvinceId = dto.ProvinceId;
  11840. info.OutsideJJPay = dto.OutsideJJPay;
  11841. info.OutsideGWPay = dto.OutsideGWPay;
  11842. info.OutsideTDPay = dto.OutsideTDPay;
  11843. info.AirJJ = dto.AirJJ;
  11844. info.AirGW = dto.AirGW;
  11845. info.AirTD = dto.AirTD;
  11846. info.CityTranffic = dto.CityTranffic;
  11847. info.TwoItemRemark = dto.TwoItemRemark;
  11848. info.SumJJC = dto.ChoiceTwoJJ;
  11849. info.SumGWC = dto.ChoiceTwoGW;
  11850. info.SumTDC = dto.ChoiceTwoTD;
  11851. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11852. if (id <= 0) //add
  11853. {
  11854. info.CreateUserId = dto.CurrUserId;
  11855. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11856. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11857. if (addId <= 0) return Ok(JsonView(false));
  11858. id = addId;
  11859. }
  11860. else //update
  11861. {
  11862. var upd = await _sqlSugar.Updateable(info)
  11863. .UpdateColumns(x => new
  11864. {
  11865. x.SumJJC,
  11866. x.OutsideJJPay,
  11867. x.SumGWC,
  11868. x.OutsideGWPay,
  11869. x.SumTDC,
  11870. x.OutsideTDPay,
  11871. x.AirJJ,
  11872. x.AirGW,
  11873. x.AirTD,
  11874. x.CityTranffic,
  11875. x.TwoItemRemark
  11876. })
  11877. .Where(x => x.Id == id)
  11878. .ExecuteCommandAsync();
  11879. if (upd < 1) return Ok(JsonView(false));
  11880. }
  11881. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11882. gwcItemTotal = info.AirGW + info.CityTranffic;
  11883. tdcItemTotal = info.AirTD + info.CityTranffic;
  11884. ////消息通知
  11885. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11886. return Ok(JsonView(new
  11887. {
  11888. parentId = id,
  11889. choiceTwoJJ = dto.ChoiceTwoJJ,
  11890. jjcItemTotal = jjcItemTotal,
  11891. choiceTwoGW = dto.ChoiceTwoGW,
  11892. gwcItemTotal = gwcItemTotal,
  11893. choiceTwoTD = dto.ChoiceTwoTD,
  11894. tdcItemTotal = tdcItemTotal
  11895. }));
  11896. }
  11897. /// <summary>
  11898. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11899. /// </summary>
  11900. /// <returns></returns>
  11901. [HttpPost]
  11902. [ApiExplorerSettings(IgnoreApi = true)]
  11903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11904. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11905. {
  11906. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11907. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11908. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11909. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11910. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11911. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11912. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11913. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11914. {
  11915. Id = x.Id,
  11916. ParentId = dto.DraftId,
  11917. Type = dto.FeeType,
  11918. Days = x.Days,
  11919. NationalTravelFeeId = x.NationalTravelFeeId,
  11920. Cost = x.Cost,
  11921. Currency = x.Currency,
  11922. SubTotal = x.SubTotal,
  11923. CreateUserId = dto.CurrUserId
  11924. })
  11925. .ToList();
  11926. var adds = infos.Where(x => x.Id <= 0).ToList();
  11927. var upds = infos.Where(x => x.Id > 0).ToList();
  11928. if (adds.Count > 0)
  11929. {
  11930. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11931. if (add < 1) return Ok(JsonView(false));
  11932. }
  11933. if (upds.Count > 0)
  11934. {
  11935. var upd = await _sqlSugar.Updateable(adds)
  11936. .UpdateColumns(x => new
  11937. {
  11938. x.Days,
  11939. x.NationalTravelFeeId,
  11940. x.Cost,
  11941. x.Currency,
  11942. x.SubTotal
  11943. })
  11944. .WhereColumns(x => new { x.Id })
  11945. .ExecuteCommandAsync();
  11946. if (upd < 1) return Ok(JsonView(false));
  11947. }
  11948. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11949. ////消息通知
  11950. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11951. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11952. return Ok(JsonView(new { itemTotal = itemTotal }));
  11953. }
  11954. /// <summary>
  11955. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11956. /// </summary>
  11957. /// <returns></returns>
  11958. [HttpPost]
  11959. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11960. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11961. {
  11962. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11963. int subId = dto.SubId, feeType = dto.FeeType;
  11964. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11965. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11966. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11967. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11968. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11969. subInfo.Id = subId;
  11970. subInfo.ParentId = dto.DraftId;
  11971. if (feeType == 3) subInfo.Type = 1;
  11972. else if (feeType == 4) subInfo.Type = 2;
  11973. else if (feeType == 5) subInfo.Type = 3;
  11974. else if (feeType == 6) subInfo.Type = 4;
  11975. subInfo.CreateUserId = dto.CurrUserId;
  11976. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11977. if (parentId < 1) return Ok(JsonView(false));
  11978. //子表op
  11979. if (subId < 1)
  11980. {
  11981. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11982. if (subAdd < 1) return Ok(JsonView(false));
  11983. }
  11984. else
  11985. {
  11986. var subUpd = await _sqlSugar.Updateable(subInfo)
  11987. .UpdateColumns(x => new
  11988. {
  11989. x.Days,
  11990. x.NationalTravelFeeId,
  11991. x.Cost,
  11992. x.Currency,
  11993. x.SubTotal
  11994. })
  11995. .WhereColumns(x => new { x.Id })
  11996. .ExecuteCommandAsync();
  11997. if (subUpd < 1) return Ok(JsonView(false));
  11998. }
  11999. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  12000. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12001. }
  12002. /// <summary>
  12003. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  12004. /// </summary>
  12005. /// <returns></returns>
  12006. [HttpPost]
  12007. [ApiExplorerSettings(IgnoreApi = true)]
  12008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12009. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  12010. {
  12011. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12012. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12013. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12014. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  12015. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  12016. {
  12017. Id = x.Id,
  12018. ParentId = dto.DraftId,
  12019. SetDataId = x.SetDataId,
  12020. Index = x.Index,
  12021. Cost = x.Cost,
  12022. Currency = x.Currency,
  12023. SubTotal = x.SubTotal,
  12024. CreateUserId = dto.CurrUserId,
  12025. Remark = x.Remark
  12026. }).ToList();
  12027. var adds = infos.Where(x => x.Id <= 0).ToList();
  12028. var upds = infos.Where(x => x.Id > 0).ToList();
  12029. if (adds.Count > 0)
  12030. {
  12031. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12032. if (add < 1) return Ok(JsonView(false));
  12033. }
  12034. if (upds.Count > 0)
  12035. {
  12036. var upd = await _sqlSugar.Updateable(adds)
  12037. .UpdateColumns(x => new
  12038. {
  12039. x.Index,
  12040. x.SetDataId,
  12041. x.Cost,
  12042. x.Currency,
  12043. x.SubTotal,
  12044. x.Remark
  12045. })
  12046. .WhereColumns(x => new { x.Id })
  12047. .ExecuteCommandAsync();
  12048. if (upd < 1) return Ok(JsonView(false));
  12049. }
  12050. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  12051. //消息通知
  12052. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  12053. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12054. return Ok(JsonView(new { itemTotal = itemTotal }));
  12055. }
  12056. /// <summary>
  12057. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  12058. /// </summary>
  12059. /// <returns></returns>
  12060. [HttpPost]
  12061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12062. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  12063. {
  12064. int subId = dto.SubId, id = dto.DraftId;
  12065. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12066. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  12067. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12068. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  12069. subInfo.Id = subId;
  12070. subInfo.ParentId = id;
  12071. subInfo.CreateUserId = dto.CurrUserId;
  12072. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  12073. if (parentId < 1) return Ok(JsonView(false));
  12074. #region 子表op
  12075. if (subId < 1)//add
  12076. {
  12077. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12078. if (subAdd < 1) return Ok(JsonView(false));
  12079. }
  12080. else //upd
  12081. {
  12082. var subUpd = await _sqlSugar.Updateable(subInfo)
  12083. .UpdateColumns(x => new
  12084. {
  12085. x.Index,
  12086. x.SetDataId,
  12087. x.Cost,
  12088. x.Currency,
  12089. x.SubTotal,
  12090. x.Remark
  12091. })
  12092. .WhereColumns(x => new { x.Id })
  12093. .ExecuteCommandAsync();
  12094. if (subUpd < 1) return Ok(JsonView(false));
  12095. }
  12096. #endregion
  12097. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  12098. ////消息通知
  12099. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  12100. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12101. }
  12102. /// <summary>
  12103. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  12104. /// </summary>
  12105. /// <returns></returns>
  12106. [HttpPost]
  12107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12108. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  12109. {
  12110. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  12111. if (data.Code != 0)
  12112. {
  12113. return Ok(JsonView(false, data.Msg));
  12114. }
  12115. return Ok(JsonView(true, "操作成功!", data.Data));
  12116. }
  12117. /// <summary>
  12118. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  12119. /// </summary>
  12120. /// <param name="dto"></param>
  12121. /// <returns></returns>
  12122. [HttpPost]
  12123. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  12124. {
  12125. var data = new Grp_DayOtherPriceDraft()
  12126. {
  12127. Id = dto.Id,
  12128. IsDel = 1,
  12129. DeleteUserId = dto.DeleteUserId,
  12130. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  12131. };
  12132. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  12133. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  12134. return Ok(JsonView(false, "删除失败!"));
  12135. }
  12136. #endregion
  12137. #endregion
  12138. #region 团组经理模块 出入境费用报价表
  12139. /// <summary>
  12140. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  12141. /// </summary>
  12142. /// <returns></returns>
  12143. [HttpPost]
  12144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12145. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  12146. {
  12147. var initRates = await GeneralMethod.EnterExitCostInitRate();
  12148. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  12149. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  12150. initRates.Insert(0, cnyInfo);
  12151. liveRates.Insert(0, cnyInfo);
  12152. return Ok(JsonView(true, "查询成功!", new
  12153. {
  12154. InitRates = initRates,
  12155. LiveRates = liveRates
  12156. }));
  12157. }
  12158. /// <summary>
  12159. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  12160. /// </summary>
  12161. /// <returns></returns>
  12162. [HttpPost]
  12163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12164. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  12165. {
  12166. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  12167. }
  12168. /// <summary>
  12169. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  12170. /// </summary>
  12171. /// <returns></returns>
  12172. [HttpPost]
  12173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12174. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  12175. {
  12176. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  12177. }
  12178. /// <summary>
  12179. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  12180. /// </summary>
  12181. /// <returns></returns>
  12182. [HttpPost]
  12183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12184. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  12185. {
  12186. int groupId = dto.DiId,
  12187. currUserId = dto.CurrUserId;
  12188. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  12189. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  12190. //验证报价数据是否存在
  12191. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  12192. if (isNull != null)
  12193. {
  12194. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  12195. if (!info1.Rates.Any())
  12196. {
  12197. var rates = await GeneralMethod.EnterExitCostInitRate();
  12198. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12199. info1.Rates = rates.ToArray();
  12200. }
  12201. return Ok(JsonView(info1));
  12202. }
  12203. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  12204. result.GroupId = groupId;
  12205. //处理报价名称
  12206. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  12207. if (groupInfo != null)
  12208. {
  12209. var visitCountry = groupInfo.VisitCountry;
  12210. if (!string.IsNullOrEmpty(visitCountry))
  12211. {
  12212. string quoteName = string.Empty;
  12213. if (visitCountry.Contains("|"))
  12214. {
  12215. var countrys = visitCountry.Split("|");
  12216. quoteName = string.Join("、", countrys);
  12217. }
  12218. else quoteName = visitCountry;
  12219. quoteName += $"团组报价表";
  12220. result.Name = quoteName;
  12221. }
  12222. }
  12223. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  12224. if (info.Code != StatusCodes.Status200OK)
  12225. {
  12226. if (!result.Rates.Any())
  12227. {
  12228. var rates = await GeneralMethod.EnterExitCostInitRate();
  12229. result.Rates = rates.ToArray();
  12230. }
  12231. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  12232. }
  12233. var infoView = info.Data as EnterExitCostInfoView;
  12234. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  12235. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  12236. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  12237. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  12238. var eecRates = infoView.Currencys;
  12239. //默认添加人名币
  12240. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  12241. {
  12242. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12243. }
  12244. //处理团组人数
  12245. int pplNum = 1;
  12246. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  12247. var views = new List<QuoteSubItemInfo>();
  12248. #region 数据填充
  12249. var intTravelCosts = new List<QuoteSubItemInfo>();
  12250. #region 机票费用 1354
  12251. int intTravelIndex = 1;
  12252. if (infoView.SumJJC == 1)
  12253. {
  12254. intTravelCosts.Add(new QuoteSubItemInfo
  12255. {
  12256. ItemId = 1354,
  12257. Index = intTravelIndex,
  12258. FeeName = "经济舱",
  12259. UnitPrice = infoView.AirJJ,
  12260. Currency = "CNY",
  12261. Quantity = 1,
  12262. PplNum = 1,
  12263. TotalAmt = infoView.AirJJ,
  12264. Remark = "",
  12265. });
  12266. intTravelIndex++;
  12267. }
  12268. if (infoView.SumGWC == 1)
  12269. {
  12270. intTravelCosts.Add(new QuoteSubItemInfo
  12271. {
  12272. ItemId = 1354,
  12273. Index = intTravelIndex,
  12274. FeeName = "公务舱",
  12275. UnitPrice = infoView.AirGW,
  12276. Currency = "CNY",
  12277. Quantity = 1,
  12278. PplNum = 1,
  12279. TotalAmt = infoView.AirGW,
  12280. Remark = "",
  12281. });
  12282. intTravelIndex++;
  12283. }
  12284. if (infoView.SumTDC == 1)
  12285. {
  12286. intTravelCosts.Add(new QuoteSubItemInfo
  12287. {
  12288. ItemId = 1354,
  12289. Index = intTravelIndex,
  12290. FeeName = "头等舱",
  12291. UnitPrice = infoView.AirTD,
  12292. Currency = "CNY",
  12293. Quantity = 1,
  12294. PplNum = 1,
  12295. TotalAmt = infoView.AirTD,
  12296. Remark = "",
  12297. });
  12298. intTravelIndex++;
  12299. }
  12300. intTravelCosts.Add(new QuoteSubItemInfo
  12301. {
  12302. ItemId = 1354,
  12303. Index = intTravelIndex,
  12304. FeeName = "城市间交通费用",
  12305. UnitPrice = infoView.CityTranffic,
  12306. Currency = "CNY",
  12307. Quantity = 1,
  12308. PplNum = pplNum,
  12309. TotalAmt = infoView.CityTranffic * pplNum,
  12310. Remark = "",
  12311. });
  12312. views.AddRange(intTravelCosts);
  12313. #endregion
  12314. var accomCosts = new List<QuoteSubItemInfo>();
  12315. #region 住宿费 1355
  12316. if (infoView.QuarterageData.Any())
  12317. {
  12318. int accomIndex = 1;
  12319. int accomItemTypeId = 1355;
  12320. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  12321. foreach (var item in groupData)
  12322. {
  12323. string feeName = string.Empty;
  12324. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12325. if (countryInfo != null)
  12326. {
  12327. feeName = countryInfo.Country;
  12328. var city = countryInfo.City;
  12329. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12330. {
  12331. feeName += $"-{city}";
  12332. }
  12333. }
  12334. var hotelInfo = item.FirstOrDefault();
  12335. if (hotelInfo == null) continue;
  12336. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  12337. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12338. int quantity = item.ToList().Count;
  12339. accomCosts.Add(new QuoteSubItemInfo
  12340. {
  12341. ItemId = accomItemTypeId,
  12342. Index = accomIndex,
  12343. FeeName = feeName,
  12344. UnitPrice = hotelInfo.Cost,
  12345. Currency = thisCurrency,
  12346. Quantity = quantity,
  12347. PplNum = pplNum,
  12348. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  12349. Remark = "",
  12350. });
  12351. accomIndex++;
  12352. }
  12353. views.AddRange(accomCosts);
  12354. }
  12355. #endregion
  12356. var mealCosts = new List<QuoteSubItemInfo>();
  12357. #region 餐饮费 1356
  12358. if (infoView.BoardWagesData.Any())
  12359. {
  12360. var mealIndex = 1;
  12361. int mealItemTypeId = 1356;
  12362. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  12363. foreach (var item in groupData)
  12364. {
  12365. string feeName = string.Empty;
  12366. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12367. if (countryInfo != null)
  12368. {
  12369. feeName = countryInfo.Country;
  12370. var city = countryInfo.City;
  12371. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12372. {
  12373. feeName += $"-{city}";
  12374. }
  12375. }
  12376. var mealInfo = item.FirstOrDefault();
  12377. if (mealInfo == null) continue;
  12378. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12379. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12380. int quantity = item.ToList().Count;
  12381. mealCosts.Add(new QuoteSubItemInfo
  12382. {
  12383. ItemId = mealItemTypeId,
  12384. Index = mealIndex,
  12385. FeeName = feeName,
  12386. UnitPrice = mealInfo.Cost,
  12387. Currency = thisCurrency,
  12388. Quantity = quantity,
  12389. PplNum = pplNum,
  12390. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12391. Remark = "",
  12392. });
  12393. mealIndex++;
  12394. }
  12395. views.AddRange(mealCosts);
  12396. }
  12397. #endregion
  12398. var miscCosts = new List<QuoteSubItemInfo>();
  12399. #region 公杂费 1364
  12400. if (infoView.MiscellaneousFeeData.Any())
  12401. {
  12402. var miscIndex = 1;
  12403. int miscItemTypeId = 1364;
  12404. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12405. foreach (var item in groupData)
  12406. {
  12407. string feeName = string.Empty;
  12408. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12409. if (countryInfo != null)
  12410. {
  12411. feeName = countryInfo.Country;
  12412. var city = countryInfo.City;
  12413. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12414. {
  12415. feeName += $"-{city}";
  12416. }
  12417. }
  12418. var miscInfo = item.FirstOrDefault();
  12419. if (miscInfo == null) continue;
  12420. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12421. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12422. int quantity = item.ToList().Count;
  12423. miscCosts.Add(new QuoteSubItemInfo
  12424. {
  12425. ItemId = miscItemTypeId,
  12426. Index = miscIndex,
  12427. FeeName = feeName,
  12428. UnitPrice = miscInfo.Cost,
  12429. Currency = thisCurrency,
  12430. Quantity = quantity,
  12431. PplNum = pplNum,
  12432. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12433. Remark = "",
  12434. });
  12435. miscIndex++;
  12436. }
  12437. views.AddRange(miscCosts);
  12438. }
  12439. #endregion
  12440. #region 签证+保险 1362
  12441. int visaInsIndex = 1;
  12442. int visaInsItemTypeId = 1362;
  12443. if (infoView.Visa > 0)
  12444. {
  12445. views.Add(new QuoteSubItemInfo()
  12446. {
  12447. ItemId = visaInsItemTypeId,
  12448. Index = visaInsIndex,
  12449. FeeName = $"签证",
  12450. UnitPrice = infoView.Visa,
  12451. Currency = $"CNY",
  12452. Quantity = 1,
  12453. PplNum = pplNum,
  12454. TotalAmt = infoView.Visa * pplNum,
  12455. Remark = "",
  12456. });
  12457. visaInsIndex++;
  12458. }
  12459. if (infoView.Safe > 0)
  12460. {
  12461. views.Add(new QuoteSubItemInfo()
  12462. {
  12463. ItemId = visaInsItemTypeId,
  12464. Index = visaInsIndex,
  12465. FeeName = $"保险",
  12466. UnitPrice = infoView.Safe,
  12467. Currency = $"CNY",
  12468. Quantity = 1,
  12469. PplNum = pplNum,
  12470. TotalAmt = infoView.Safe * pplNum,
  12471. Remark = "",
  12472. });
  12473. }
  12474. #endregion
  12475. #region 服务费 1363
  12476. int serviceFeeIndex = 1;
  12477. int serviceFeeItemTypeId = 1363;
  12478. if (infoView.Service > 0)
  12479. {
  12480. views.Add(new QuoteSubItemInfo()
  12481. {
  12482. ItemId = serviceFeeItemTypeId,
  12483. Index = serviceFeeIndex,
  12484. FeeName = $"服务费",
  12485. UnitPrice = infoView.Service,
  12486. Currency = $"CNY",
  12487. Quantity = 1,
  12488. PplNum = pplNum,
  12489. TotalAmt = infoView.Service * pplNum,
  12490. Remark = "",
  12491. });
  12492. }
  12493. #endregion
  12494. #endregion
  12495. if (result.FeeItems.Any())
  12496. {
  12497. result.FeeItems.Select(x =>
  12498. {
  12499. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12500. if (feeInfos.Any()) x.Infos = feeInfos;
  12501. return x;
  12502. }
  12503. ).OrderBy(x => x.Index)
  12504. .ToList();
  12505. if (!result.Rates.Any())
  12506. {
  12507. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12508. else
  12509. {
  12510. var rates = await GeneralMethod.EnterExitCostInitRate();
  12511. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12512. result.Rates = rates.ToArray();
  12513. }
  12514. }
  12515. }
  12516. return Ok(JsonView(result));
  12517. }
  12518. /// <summary>
  12519. /// 团组模块 - 出入境费用报价表 - Info
  12520. /// </summary>
  12521. /// <returns></returns>
  12522. [HttpPost]
  12523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12524. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12525. {
  12526. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12527. if (!info.Rates.Any())
  12528. {
  12529. var rates = await GeneralMethod.EnterExitCostInitRate();
  12530. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12531. info.Rates = rates.ToArray();
  12532. }
  12533. return Ok(JsonView(info));
  12534. }
  12535. /// <summary>
  12536. /// 团组模块 - 出入境费用报价表 - OP
  12537. /// </summary>
  12538. /// <returns></returns>
  12539. [HttpPost]
  12540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12541. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12542. {
  12543. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12544. }
  12545. /// <summary>
  12546. /// 团组模块 - 出入境费用报价表 - 删除 项
  12547. /// </summary>
  12548. /// <returns></returns>
  12549. [HttpPost]
  12550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12551. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12552. {
  12553. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12554. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12555. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12556. }
  12557. /// <summary>
  12558. /// 团组模块 - 出入境费用报价表 - 导出
  12559. /// </summary>
  12560. /// <returns></returns>
  12561. [HttpPost]
  12562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12563. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12564. {
  12565. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12566. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12567. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12568. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12569. var rates = info.Rates;
  12570. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12571. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12572. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12573. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12574. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12575. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12576. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12577. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12578. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12579. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12580. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12581. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12582. //获取模板
  12583. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12584. var designer = new WorkbookDesigner();
  12585. designer.Workbook = new Workbook(tempPath);
  12586. designer.SetDataSource("QuoteName", info.Name);
  12587. designer.SetDataSource("CompanyTitle", "公司名称");
  12588. designer.SetDataSource("CompanyLabel", "");
  12589. #region 国际旅费
  12590. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12591. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12592. {
  12593. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12594. var label = new StringBuilder();
  12595. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12596. if (infos.Any())
  12597. {
  12598. label.Append(infos.Sum(x => x.PplNum));
  12599. label.Append("人全程机票:");
  12600. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12601. label.AppendLine("元");
  12602. }
  12603. foreach (var item in intTravelCosts.Infos)
  12604. {
  12605. label.Append(item.FeeName);
  12606. label.Append(":");
  12607. label.Append(item.UnitPrice.TruncDecimals(2));
  12608. label.Append("元/人*");
  12609. label.Append(item.PplNum);
  12610. label.AppendLine("人");
  12611. }
  12612. if (label.HasValue())
  12613. {
  12614. label.Append("\r\n以上小计:");
  12615. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12616. label.Append("元");
  12617. }
  12618. designer.SetDataSource("IntTravelLabel", label.ToString());
  12619. }
  12620. #endregion
  12621. #region 住宿费
  12622. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12623. if (accomCosts != null && accomCosts.Infos.Any())
  12624. {
  12625. string currencyName = string.Empty,
  12626. countryName = string.Empty;
  12627. decimal rate = 1.0000M;
  12628. var label = new StringBuilder();
  12629. label.AppendLine("全程五星酒店,每人1间房");
  12630. foreach (var item in accomCosts.Infos)
  12631. {
  12632. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12633. string name = string.Empty, thisCountryName = string.Empty;
  12634. if (item.FeeName.Contains('-'))
  12635. {
  12636. var feeName = item.FeeName.Split('-');
  12637. thisCountryName = feeName[0];
  12638. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12639. name = feeName[1];
  12640. }
  12641. else name = item.FeeName;
  12642. string thisFeeName = string.Empty;
  12643. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12644. else thisFeeName = $"\r\n{name}:";
  12645. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12646. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12647. rate = rateInfo?.Rate ?? 1.0000M;
  12648. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12649. label.AppendLine(subLabel);
  12650. }
  12651. if (label.HasValue())
  12652. {
  12653. //以上小计:52440元(美金汇率:7.5 )
  12654. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12655. label.AppendLine(subLabel);
  12656. }
  12657. designer.SetDataSource("AccomLabel", label.ToString());
  12658. }
  12659. #endregion
  12660. #region 餐饮费
  12661. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12662. if (mealCosts != null && mealCosts.Infos.Any())
  12663. {
  12664. string currencyName = string.Empty;
  12665. decimal rate = 1.0000M;
  12666. var label = new StringBuilder();
  12667. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12668. foreach (var item in mealCosts.Infos)
  12669. {
  12670. string name = string.Empty;
  12671. if (item.FeeName.Contains('-'))
  12672. {
  12673. var feeName = item.FeeName.Split('-');
  12674. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12675. }
  12676. else name = $"\r\n{item.FeeName}:";
  12677. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12678. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12679. rate = rateInfo?.Rate ?? 1.0000M;
  12680. label.Append(name);
  12681. label.Append(item.UnitPrice.TruncDecimals(2));
  12682. label.Append(currencyName);
  12683. label.Append("/天*");
  12684. label.Append(item.Quantity.ToString("#0"));
  12685. label.Append('*');
  12686. label.Append(item.PplNum);
  12687. label.Append("人\r\n");
  12688. }
  12689. if (label.HasValue())
  12690. {
  12691. label.Append("\r\n以上小计:");
  12692. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12693. label.Append("元\r\n(");
  12694. label.Append("汇率:");
  12695. label.Append(rate.TruncDecimals(4));
  12696. label.Append(')');
  12697. }
  12698. designer.SetDataSource("MealLabel", label.ToString());
  12699. }
  12700. #endregion
  12701. #region 车辆安排
  12702. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12703. if (vehArranges != null && vehArranges.Infos.Any())
  12704. {
  12705. string currencyName = string.Empty;
  12706. //decimal rate = 1.0000M;
  12707. var label = new StringBuilder();
  12708. foreach (var item in vehArranges.Infos)
  12709. {
  12710. label.AppendLine();
  12711. label.AppendLine();
  12712. label.Append(item.FeeName);
  12713. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12714. }
  12715. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12716. }
  12717. #endregion
  12718. #region 邀请函发放对象
  12719. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12720. designer.SetDataSource("InviteToContent", "");
  12721. #endregion
  12722. #region 邀请函费
  12723. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12724. var is_label = new StringBuilder();
  12725. if (inviteCosts != null && inviteCosts.Infos.Any())
  12726. {
  12727. string currencyName = string.Empty;
  12728. decimal rate = 1.0000M;
  12729. foreach (var item in inviteCosts.Infos)
  12730. {
  12731. //乌兹别克斯坦:2000美金
  12732. currencyName = item.Currency;
  12733. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12734. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12735. is_label.AppendLine(label);
  12736. }
  12737. if (is_label.HasValue())
  12738. {
  12739. //以上小计:28500元(美金汇率:7.5)
  12740. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12741. is_label.AppendLine(label);
  12742. }
  12743. }
  12744. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12745. #endregion
  12746. #region 邀请函发放时间
  12747. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12748. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12749. #endregion
  12750. #region 公务活动(含翻译)
  12751. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12752. var oa_label = new StringBuilder();
  12753. if (officialActs != null && officialActs.Infos.Any())
  12754. {
  12755. string currencyName = string.Empty;
  12756. decimal rate = 1.0000M;
  12757. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12758. foreach (var item in officialActs.Infos)
  12759. {
  12760. //乌兹别克斯坦:1000美金/场
  12761. currencyName = item.Currency;
  12762. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12763. string label_remark = string.Empty;
  12764. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12765. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12766. }
  12767. label_content += "*总费用中未含超出公务活动价格";
  12768. //8场公务活动(以上小计:60000元)
  12769. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12770. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12771. oa_label.AppendLine(label_title);
  12772. oa_label.AppendLine(label_content);
  12773. }
  12774. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12775. #endregion
  12776. #region 签证+保险
  12777. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12778. var vi_label = new StringBuilder();
  12779. if (visaIns != null && visaIns.Infos.Any())
  12780. {
  12781. foreach (var item in visaIns.Infos)
  12782. {
  12783. //签证:500元/人
  12784. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12785. vi_label.AppendLine(label);
  12786. }
  12787. if (vi_label.HasValue())
  12788. {
  12789. //以上小计:6000元
  12790. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12791. vi_label.AppendLine(label);
  12792. }
  12793. }
  12794. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12795. #endregion
  12796. #region 服务费
  12797. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12798. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12799. #endregion
  12800. #region 公杂费
  12801. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12802. var pm_label = new StringBuilder();
  12803. if (pubMiscs != null && pubMiscs.Infos.Any())
  12804. {
  12805. string currencyName = string.Empty,
  12806. countryName = string.Empty;
  12807. decimal rate = 1.0000M;
  12808. foreach (var item in pubMiscs.Infos)
  12809. {
  12810. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12811. string name = string.Empty, thisCountryName = string.Empty;
  12812. if (item.FeeName.Contains('-'))
  12813. {
  12814. var feeName = item.FeeName.Split('-');
  12815. thisCountryName = feeName[0];
  12816. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12817. name = feeName[1];
  12818. }
  12819. else name = item.FeeName;
  12820. string thisFeeName = string.Empty;
  12821. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12822. else thisFeeName = $"\r\n{name}:";
  12823. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12824. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12825. rate = rateInfo?.Rate ?? 1.0000M;
  12826. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12827. pm_label.AppendLine(label);
  12828. }
  12829. if (pm_label.HasValue())
  12830. {
  12831. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12832. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12833. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12834. pm_label.AppendLine(string.Format("部分发放成员"));
  12835. }
  12836. }
  12837. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12838. #endregion
  12839. #region 税费
  12840. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12841. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12842. #endregion
  12843. #region 合计(单位:元)
  12844. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12845. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12846. #endregion
  12847. #region 汇率 Remark
  12848. var rate_label = new StringBuilder();
  12849. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12850. foreach (var item in rateGroups)
  12851. {
  12852. //美元汇率按\r\n1:7.5
  12853. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12854. rate_label.AppendLine(label);
  12855. }
  12856. designer.SetDataSource("RateLabel", rate_label.ToString());
  12857. #endregion
  12858. designer.Process();
  12859. //文件名
  12860. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  12861. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12862. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12863. return Ok(JsonView(true, "成功", url));
  12864. }
  12865. #endregion
  12866. #region 签证费用录入
  12867. /// <summary>
  12868. /// 根据diid查询签证费用列表
  12869. /// </summary>
  12870. /// <param name="dto"></param>
  12871. /// <returns></returns>
  12872. [HttpPost]
  12873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12874. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12875. {
  12876. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12877. if (groupData.Code != 0)
  12878. {
  12879. return Ok(JsonView(false, groupData.Msg));
  12880. }
  12881. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12882. }
  12883. /// <summary>
  12884. /// 根据签证费用Id查询单条数据及c表数据
  12885. /// </summary>
  12886. /// <param name="dto"></param>
  12887. /// <returns></returns>
  12888. [HttpPost]
  12889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12890. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12891. {
  12892. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12893. if (groupData.Code != 0)
  12894. {
  12895. return Ok(JsonView(false, groupData.Msg));
  12896. }
  12897. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12898. }
  12899. /// <summary>
  12900. /// 签证费用删除
  12901. /// </summary>
  12902. /// <param name="dto"></param>
  12903. /// <returns></returns>
  12904. [HttpPost]
  12905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12906. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12907. {
  12908. _sqlSugar.BeginTran();
  12909. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12910. if (!res)
  12911. {
  12912. _sqlSugar.RollbackTran();
  12913. return Ok(JsonView(false, "删除失败"));
  12914. }
  12915. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12916. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12917. .SetColumns(a => new Grp_CreditCardPayment()
  12918. {
  12919. IsDel = 1,
  12920. DeleteUserId = dto.DeleteUserId,
  12921. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12922. })
  12923. .ExecuteCommand();
  12924. if (resSub < 1)
  12925. {
  12926. _sqlSugar.RollbackTran();
  12927. return Ok(JsonView(false, "删除失败"));
  12928. }
  12929. _sqlSugar.CommitTran();
  12930. return Ok(JsonView(true, "删除成功!"));
  12931. }
  12932. /// <summary>
  12933. /// 签证费用录入下拉框初始化
  12934. /// </summary>
  12935. /// <returns></returns>
  12936. [HttpPost]
  12937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12938. public async Task<IActionResult> VisaPriceAddSelect()
  12939. {
  12940. //支付方式
  12941. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12942. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12943. //币种
  12944. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12945. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12946. //乘客类型
  12947. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12948. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12949. //卡类型
  12950. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12951. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12952. //代办费类型
  12953. var agencyFeeTypeData = new List<dynamic>() {
  12954. new { id = 0 , Text = "未选择" },
  12955. new { id = 1 , Text = "小公务" },
  12956. new { id = 2 , Text = "大公务" },
  12957. };
  12958. //签证费用标准国家Data
  12959. var visaSql = string.Format(@"select
  12960. id,
  12961. case
  12962. when FeeType = 0 then Country+'(因公)'
  12963. when FeeType = 1 then Country+'(因私)'
  12964. else Country+'(未设置)'
  12965. end as 'country'
  12966. from Res_VisaFeeStandard where isdel = 0");
  12967. var visaCountryFeeData = _sqlSugar.SqlQueryable<dynamic>(visaSql).ToList();
  12968. var data = new
  12969. {
  12970. Payment = _Payment,
  12971. CurrencyList = _CurrencyList,
  12972. PassengerType = _PassengerType,
  12973. BankCard = _BankCard,
  12974. AgencyFeeType = agencyFeeTypeData,
  12975. CountryFeeData = visaCountryFeeData
  12976. };
  12977. return Ok(JsonView(true, "查询成功!", data));
  12978. }
  12979. /// <summary>
  12980. /// 签证费用录入操作(Status:1.新增,2.修改)
  12981. /// </summary>
  12982. /// <param name="dto"></param>
  12983. /// <returns></returns>
  12984. [HttpPost]
  12985. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12986. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12987. {
  12988. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12989. if (groupData.Code != 0)
  12990. {
  12991. return Ok(JsonView(false, groupData.Msg));
  12992. }
  12993. #region 应用推送
  12994. try
  12995. {
  12996. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12997. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12998. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12999. //2024-10-21 新增LZ UID
  13000. var userIds = new List<int>() { 21 };
  13001. string title = $"系统通知";
  13002. string content = "";
  13003. var diId = dto.DiId;
  13004. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13005. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13006. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13007. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13008. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13009. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  13010. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13011. }
  13012. catch (Exception ex)
  13013. {
  13014. }
  13015. #endregion
  13016. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13017. }
  13018. #endregion
  13019. #region 签证提成录入
  13020. /// <summary>
  13021. /// 签证提成录入
  13022. /// 基础数据
  13023. /// </summary>
  13024. /// <returns></returns>
  13025. [HttpGet]
  13026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13027. public async Task<IActionResult> VisaCommissionInit()
  13028. {
  13029. return Ok(await _visaCommissionRep.Init());
  13030. }
  13031. /// <summary>
  13032. /// 签证提成录入
  13033. /// Item
  13034. /// </summary>
  13035. /// <param name="_dto"></param>
  13036. /// <returns></returns>
  13037. [HttpPost]
  13038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13039. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  13040. {
  13041. var validator = new VisaCommissionItemDtoValidator();
  13042. var validatorRes = await validator.ValidateAsync(_dto);
  13043. if (!validatorRes.IsValid)
  13044. {
  13045. var sb = new StringBuilder();
  13046. foreach (var item in validatorRes.Errors)
  13047. {
  13048. sb.AppendLine(item.ErrorMessage);
  13049. }
  13050. return Ok(JsonView(false, sb.ToString()));
  13051. }
  13052. return Ok(await _visaCommissionRep.Item(_dto));
  13053. }
  13054. /// <summary>
  13055. /// 签证提成录入
  13056. /// Save
  13057. /// </summary>
  13058. /// <param name="_dto"></param>
  13059. /// <returns></returns>
  13060. [HttpPost]
  13061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13062. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  13063. {
  13064. //参数验证
  13065. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  13066. foreach (var item in _dto.Items)
  13067. {
  13068. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  13069. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  13070. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  13071. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  13072. }
  13073. return Ok(await _visaCommissionRep.Save(_dto));
  13074. }
  13075. /// <summary>
  13076. /// 签证提成录入
  13077. /// Create
  13078. /// </summary>
  13079. /// <param name="_dto"></param>
  13080. /// <returns></returns>
  13081. [HttpPost]
  13082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13083. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  13084. {
  13085. var validator = new VisaCommissionCreateDtoValidator();
  13086. var validatorRes = await validator.ValidateAsync(_dto);
  13087. if (!validatorRes.IsValid)
  13088. {
  13089. var sb = new StringBuilder();
  13090. foreach (var item in validatorRes.Errors)
  13091. {
  13092. sb.AppendLine(item.ErrorMessage);
  13093. }
  13094. return Ok(JsonView(false, sb.ToString()));
  13095. }
  13096. return Ok(await _visaCommissionRep.Create(_dto));
  13097. }
  13098. /// <summary>
  13099. /// 签证提成录入
  13100. /// Put(编辑)
  13101. /// </summary>
  13102. /// <param name="id"></param>
  13103. /// <param name="_dto"></param>
  13104. /// <returns></returns>
  13105. [HttpPut]
  13106. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13107. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  13108. {
  13109. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13110. var validator = new VisaCommissionCreateDtoValidator();
  13111. var validatorRes = await validator.ValidateAsync(_dto);
  13112. if (!validatorRes.IsValid)
  13113. {
  13114. var sb = new StringBuilder();
  13115. foreach (var item in validatorRes.Errors)
  13116. {
  13117. sb.AppendLine(item.ErrorMessage);
  13118. }
  13119. return Ok(JsonView(false, sb.ToString()));
  13120. }
  13121. return Ok(await _visaCommissionRep.Edit(id, _dto));
  13122. }
  13123. /// <summary>
  13124. /// 签证提成录入
  13125. /// Del
  13126. /// </summary>
  13127. /// <param name="id"></param>
  13128. /// <param name="currUserId"></param>
  13129. /// <returns></returns>
  13130. [HttpPost]
  13131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13132. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  13133. {
  13134. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13135. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  13136. return Ok(await _visaCommissionRep.Del(id, currUserId));
  13137. }
  13138. #endregion
  13139. #region op费用录入
  13140. /// <summary>
  13141. /// 根据diid查询op费用列表
  13142. /// </summary>
  13143. /// <param name="dto"></param>
  13144. /// <returns></returns>
  13145. [HttpPost]
  13146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13147. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  13148. {
  13149. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  13150. if (groupData.Code != 0)
  13151. {
  13152. return Ok(JsonView(false, groupData.Msg));
  13153. }
  13154. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13155. }
  13156. /// <summary>
  13157. /// 根据op费用Id查询单条数据及c表数据
  13158. /// </summary>
  13159. /// <param name="dto"></param>
  13160. /// <returns></returns>
  13161. [HttpPost]
  13162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13163. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  13164. {
  13165. try
  13166. {
  13167. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  13168. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  13169. var data = new
  13170. {
  13171. CarTouristGuideGround = _groupData,
  13172. CreditCardPayment = _creditCardPayment
  13173. };
  13174. return Ok(JsonView(true, "查询成功!", data));
  13175. }
  13176. catch (Exception ex)
  13177. {
  13178. return Ok(JsonView(false, "程序错误!"));
  13179. }
  13180. }
  13181. /// <summary>
  13182. /// op费用删除
  13183. /// </summary>
  13184. /// <param name="dto"></param>
  13185. /// <returns></returns>
  13186. [HttpPost]
  13187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13188. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  13189. {
  13190. try
  13191. {
  13192. _sqlSugar.BeginTran();
  13193. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  13194. if (!res)
  13195. {
  13196. return Ok(JsonView(false, "删除失败"));
  13197. }
  13198. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  13199. {
  13200. IsDel = 1,
  13201. DeleteUserId = dto.DeleteUserId,
  13202. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13203. }).ExecuteCommandAsync();
  13204. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  13205. {
  13206. IsDel = 1,
  13207. DeleteUserId = dto.DeleteUserId,
  13208. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13209. }).ExecuteCommandAsync();
  13210. #region 删除超支相关数据
  13211. //删除导入的超支数据
  13212. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  13213. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  13214. {
  13215. IsDel = 1,
  13216. DeleteUserId = dto.DeleteUserId,
  13217. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13218. }).ExecuteCommand();
  13219. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  13220. {
  13221. IsDel = 1,
  13222. DeleteUserId = dto.DeleteUserId,
  13223. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13224. }).ExecuteCommand();
  13225. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  13226. {
  13227. IsDel = 1,
  13228. DeleteUserId = dto.DeleteUserId,
  13229. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13230. }).ExecuteCommand();
  13231. #endregion
  13232. _sqlSugar.CommitTran();
  13233. return Ok(JsonView(true, "删除成功!"));
  13234. }
  13235. catch (Exception ex)
  13236. {
  13237. _sqlSugar.RollbackTran();
  13238. return Ok(JsonView(false, "程序错误!" + ex.Message));
  13239. }
  13240. }
  13241. /// <summary>
  13242. /// op费用录入操作(Status:1.新增,2.修改)
  13243. /// </summary>
  13244. /// <param name="dto"></param>
  13245. /// <returns></returns>
  13246. [HttpPost]
  13247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13248. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  13249. {
  13250. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(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. /// <summary>
  13258. /// 填写费用详细页面初始化绑定
  13259. /// </summary>
  13260. /// <param name="dto"></param>
  13261. /// <returns></returns>
  13262. [HttpPost]
  13263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13264. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  13265. {
  13266. try
  13267. {
  13268. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  13269. if (groupData.Code != 0)
  13270. {
  13271. return Ok(JsonView(false, groupData.Msg));
  13272. }
  13273. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13274. }
  13275. catch (Exception ex)
  13276. {
  13277. return Ok(JsonView(false, ex.Message));
  13278. }
  13279. }
  13280. /// <summary>
  13281. /// 根据op费用Id查询详细数据
  13282. /// </summary>
  13283. /// <param name="dto"></param>
  13284. /// <returns></returns>
  13285. [HttpPost]
  13286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13287. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  13288. {
  13289. try
  13290. {
  13291. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  13292. if (groupData.Code != 0)
  13293. {
  13294. return Ok(JsonView(false, groupData.Msg));
  13295. }
  13296. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13297. }
  13298. catch (Exception ex)
  13299. {
  13300. return Ok(JsonView(false, ex.Message));
  13301. }
  13302. }
  13303. /// <summary>
  13304. /// OP费用录入填写详情
  13305. /// </summary>
  13306. /// <param name="dto"></param>
  13307. /// <returns></returns>
  13308. [HttpPost]
  13309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13310. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  13311. {
  13312. try
  13313. {
  13314. #region 参数校验
  13315. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  13316. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  13317. if (di == null) return Ok(JsonView(false, "团组错误!"));
  13318. #endregion
  13319. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  13320. if (groupData.Code != 0)
  13321. {
  13322. return Ok(JsonView(false, groupData.Msg));
  13323. }
  13324. //自动审核
  13325. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  13326. #region 尾款自动审核
  13327. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  13328. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  13329. if (opinfos.PriceType == 1062)
  13330. {
  13331. var isAuto = false;
  13332. //找对应的首付款
  13333. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  13334. .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))
  13335. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  13336. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  13337. x.PriceType == 1061 && x.DiId == dto.DiId);
  13338. if (firstPrice != null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  13339. {
  13340. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  13341. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  13342. //合计中排除城市税
  13343. var cityPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  13344. .Where(x => x.SId == 1452 && x.IsDel == 0 && x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId)
  13345. .Sum(x => x.Price * x.Count);
  13346. opinfos.ServiceQuotedPrice = opinfos.ServiceQuotedPrice - cityPrice;
  13347. if (balance >= opinfos.ServiceQuotedPrice)
  13348. {
  13349. isAuto = true;
  13350. }
  13351. }
  13352. if (isAuto)
  13353. {
  13354. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  13355. .SetColumns(a => new Grp_CreditCardPayment
  13356. {
  13357. IsAuditGM = 3, //自动审核通过
  13358. AuditGMOperate = 4,
  13359. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13360. })
  13361. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  13362. .ExecuteCommand();
  13363. }
  13364. }
  13365. #endregion
  13366. #region 应用推送
  13367. try
  13368. {
  13369. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13370. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13371. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13372. //2024-10-21 新增LZ UID
  13373. var userIds = new List<int>() { 21 };
  13374. string title = $"系统通知";
  13375. var diId = dto.DiId;
  13376. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13377. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13378. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  13379. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13380. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  13381. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13382. }
  13383. catch (Exception ex)
  13384. {
  13385. }
  13386. #endregion
  13387. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13388. }
  13389. catch (Exception ex)
  13390. {
  13391. return Ok(JsonView(false, ex.Message));
  13392. }
  13393. }
  13394. /// <summary>
  13395. /// 获取三公详细所有城市
  13396. /// </summary>
  13397. /// <returns></returns>
  13398. [HttpGet]
  13399. public IActionResult OpCarCityResult()
  13400. {
  13401. var jw = JsonView(false);
  13402. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  13403. {
  13404. x.Id,
  13405. x.Country,
  13406. x.City,
  13407. }).ToList();
  13408. if (data.Count > 0)
  13409. {
  13410. jw = JsonView(true, "获取成功!", data);
  13411. }
  13412. else
  13413. {
  13414. jw.Msg = "城市数据为空!";
  13415. jw.Data = Array.Empty<string>();
  13416. }
  13417. return Ok(jw);
  13418. }
  13419. /// <summary>
  13420. /// 导出地接费用明细
  13421. /// </summary>
  13422. /// <param name="dto"></param>
  13423. /// <returns></returns>
  13424. [HttpPost]
  13425. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13426. {
  13427. var jw = JsonView(false);
  13428. if (dto.Diid < 1)
  13429. {
  13430. jw.Msg = "请输入正确的diid!";
  13431. return Ok(jw);
  13432. }
  13433. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13434. if (group == null)
  13435. {
  13436. jw.Msg = "未找到团组信息!";
  13437. return Ok(jw);
  13438. }
  13439. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13440. if (localGuideArr.Count == 0)
  13441. {
  13442. jw.Msg = "该团组暂无地接信息!";
  13443. return Ok(jw);
  13444. }
  13445. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13446. var overspendSoure = new Dictionary<int, int>
  13447. {
  13448. { 91, 982 }, //车
  13449. { 92 , 1059} ,//导游
  13450. { 994 , 1073}, //翻译
  13451. { 988 , 1074 }, //早餐
  13452. { 93 , 1075 }, //午餐
  13453. { 989 , 1076 }, //晚餐
  13454. };
  13455. var Zips = new Dictionary<string, Stream>();
  13456. foreach (var groupArr in localGroup)
  13457. {
  13458. var keyValue = groupArr.Key;
  13459. if (int.TryParse(keyValue, out int cityid))
  13460. {
  13461. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13462. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13463. }
  13464. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13465. foreach (var item in groupArr)
  13466. {
  13467. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13468. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13469. new Grp_CarTouristGuideGroundReservationsContentExtend
  13470. {
  13471. Count = a.Count,
  13472. CreateTime = a.CreateTime,
  13473. CreateUserId = a.CreateUserId,
  13474. CTGGRId = a.CTGGRId,
  13475. Currency = a.Currency,
  13476. DatePrice = a.DatePrice,
  13477. DeleteTime = a.DeleteTime,
  13478. DeleteUserId = a.DeleteUserId,
  13479. DiId = a.DiId,
  13480. Id = a.Id,
  13481. IsDel = a.IsDel,
  13482. Price = a.Price,
  13483. PriceContent = a.PriceContent,
  13484. Remark = a.Remark,
  13485. SId = a.SId,
  13486. SidName = b.Name,
  13487. Units = a.Units,
  13488. }
  13489. ).ToList();
  13490. if (content.Count > 0)
  13491. {
  13492. contentArr.Add(content);
  13493. }
  13494. }
  13495. //open excel
  13496. //set excel
  13497. //save excel
  13498. try
  13499. {
  13500. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13501. IWorkbook workbook;
  13502. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13503. {
  13504. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13505. }
  13506. else
  13507. {
  13508. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13509. }
  13510. ISheet sheet = workbook.GetSheetAt(0);
  13511. var rowStartIndex = 2;
  13512. var clounmCount = 10;
  13513. var initStyleRow = sheet.GetRow(2);
  13514. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13515. //var overspendArrDetail =
  13516. var existsId = new List<CarCompare>();
  13517. var lastElem = arr.Last();
  13518. var thisSid = -1;
  13519. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13520. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13521. {
  13522. Name = "未知币种!",
  13523. Remark = "未知币种!",
  13524. };
  13525. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13526. Action cloneRowFn = () =>
  13527. {
  13528. rowStartIndex++;
  13529. var cloneRow = sheet.CreateRow(rowStartIndex);
  13530. // 复制样式
  13531. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13532. {
  13533. ICell sourceCell = initStyleRow.GetCell(i);
  13534. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13535. // 确保单元格存在样式
  13536. if (sourceCell.CellStyle != null)
  13537. {
  13538. targetCell.CellStyle = sourceCell.CellStyle;
  13539. }
  13540. }
  13541. };
  13542. var mergeRow = () =>
  13543. {
  13544. for (int i = 2; i < sheet.LastRowNum; i++)
  13545. {
  13546. var row = sheet.GetRow(i);
  13547. var cellFirst = row.GetCell(0);
  13548. var thisIndex = i + 1;
  13549. while (thisIndex < sheet.LastRowNum)
  13550. {
  13551. var nextRow = sheet.GetRow(thisIndex);
  13552. var nextCellFirst = nextRow.GetCell(0);
  13553. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13554. {
  13555. thisIndex++;
  13556. }
  13557. else
  13558. {
  13559. break;
  13560. }
  13561. }
  13562. thisIndex--;
  13563. if (thisIndex != i)
  13564. {
  13565. //合并row
  13566. var cellRangeAddress = new CellRangeAddress(
  13567. i, // 起始行索引(0-based)
  13568. thisIndex, // 结束行索引(0-based)
  13569. 0, // 起始列索引(0-based)
  13570. 0 // 结束列索引(0-based)
  13571. );
  13572. sheet.AddMergedRegion(cellRangeAddress);
  13573. i = thisIndex;
  13574. }
  13575. }
  13576. };
  13577. var chaoshiNumber = 0;
  13578. var totalNumber = 0.00M;
  13579. string lastStr = "";
  13580. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13581. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13582. {
  13583. b.IsAuditGM,
  13584. x.Id,
  13585. x.Area,
  13586. b.PayPercentage,
  13587. b.PayMoney,
  13588. }).ToList();
  13589. string yesPayment = "", noPayment = "";
  13590. foreach (var item in queryCarArrByCityAndDiid)
  13591. {
  13592. if (item.IsAuditGM == 1)
  13593. {
  13594. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13595. }
  13596. else
  13597. {
  13598. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13599. }
  13600. }
  13601. lastStr = yesPayment + noPayment;
  13602. foreach (var item in arr)
  13603. {
  13604. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  13605. {
  13606. if (thisSid != item.SId)
  13607. {
  13608. if (thisSid == -1)
  13609. {
  13610. thisSid = item.SId;
  13611. }
  13612. else
  13613. {
  13614. //合并小计行
  13615. //创建合并区域的实例
  13616. var cellRangeAddress = new CellRangeAddress(
  13617. rowStartIndex, // 起始行索引(0-based)
  13618. rowStartIndex, // 结束行索引(0-based)
  13619. 0, // 起始列索引(0-based)
  13620. 3 // 结束列索引(0-based)
  13621. );
  13622. sheet.AddMergedRegion(cellRangeAddress);
  13623. var CellStyle = workbook.CreateCellStyle();
  13624. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13625. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13626. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13627. for (int i = 0; i <= clounmCount; i++)
  13628. {
  13629. if (i > 6)
  13630. {
  13631. var CellStyle1 = workbook.CreateCellStyle();
  13632. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13633. IFont Font = workbook.CreateFont(); // 创建字体
  13634. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13635. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13636. CellStyle1.SetFont(Font);
  13637. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13638. }
  13639. else
  13640. {
  13641. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13642. }
  13643. }
  13644. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13645. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13646. //超时合计
  13647. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13648. //超时数
  13649. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13650. //超时合计费用
  13651. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13652. thisSid = item.SId;
  13653. cloneRowFn();
  13654. chaoshiNumber = 0;
  13655. totalNumber = 0;
  13656. }
  13657. }
  13658. IRow row = sheet.GetRow(rowStartIndex);
  13659. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13660. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  13661. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13662. if (isOpenOverspendSoure)
  13663. {
  13664. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13665. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13666. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13667. }
  13668. for (int i = 0; i <= clounmCount; i++)
  13669. {
  13670. var cell = row.GetCell(i);
  13671. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13672. if (cell == null)
  13673. {
  13674. cell = row.CreateCell(i);
  13675. }
  13676. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13677. fontRed.CloneStyleFrom(cell.CellStyle);
  13678. IFont Font = workbook.CreateFont(); // 创建字体
  13679. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13680. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13681. fontRed.SetFont(Font);
  13682. byte[] rgb = new byte[3] { 255, 242, 204 };
  13683. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13684. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13685. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13686. if (workbook is XSSFWorkbook)
  13687. {
  13688. BackgroundColor255_242_204.FillForegroundColor = 0;
  13689. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13690. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13691. }
  13692. else
  13693. {
  13694. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13695. }
  13696. if (i == 1 || i > 6)
  13697. {
  13698. if (i > 6)
  13699. {
  13700. fontRed.FillForegroundColor = 0;
  13701. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13702. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13703. }
  13704. cell.CellStyle = fontRed;
  13705. }
  13706. if (i > 2 && i < 7)
  13707. {
  13708. cell.CellStyle = BackgroundColor255_242_204;
  13709. }
  13710. cell.SetCellValue(setCellValue); //写入单元格
  13711. }
  13712. if (overspendSoure.ContainsKey(thisSid))
  13713. {
  13714. var overspendId = overspendSoure[thisSid];
  13715. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13716. }
  13717. cloneRowFn();
  13718. existsId.Add(new CarCompare
  13719. {
  13720. DataPrice = item.DatePrice.ObjToDate(),
  13721. Sid = item.SId
  13722. });
  13723. }
  13724. if (item.Equals(lastElem))
  13725. {
  13726. //合并小计行
  13727. //创建合并区域的实例
  13728. var cellRangeAddress = new CellRangeAddress(
  13729. rowStartIndex, // 起始行索引(0-based)
  13730. rowStartIndex, // 结束行索引(0-based)
  13731. 0, // 起始列索引(0-based)
  13732. 3 // 结束列索引(0-based)
  13733. );
  13734. sheet.AddMergedRegion(cellRangeAddress);
  13735. var CellStyle = workbook.CreateCellStyle();
  13736. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13737. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13738. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13739. for (int i = 0; i <= clounmCount; i++)
  13740. {
  13741. if (i > 6)
  13742. {
  13743. var CellStyle1 = workbook.CreateCellStyle();
  13744. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13745. IFont Font = workbook.CreateFont(); // 创建字体
  13746. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13747. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13748. CellStyle1.SetFont(Font);
  13749. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13750. }
  13751. else
  13752. {
  13753. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13754. }
  13755. }
  13756. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13757. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13758. //超时合计
  13759. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13760. //超时数
  13761. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13762. //超时合计费用
  13763. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13764. cloneRowFn();
  13765. // 创建合并区域的实例
  13766. cellRangeAddress = new CellRangeAddress(
  13767. rowStartIndex, // 起始行索引(0-based)
  13768. rowStartIndex, // 结束行索引(0-based)
  13769. 0, // 起始列索引(0-based)
  13770. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13771. );
  13772. // 添加合并区域
  13773. sheet.AddMergedRegion(cellRangeAddress);
  13774. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13775. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13776. }
  13777. }
  13778. mergeRow();
  13779. // 保存修改后的Excel文件到新文件
  13780. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13781. // new FileStream(newFilePath, FileMode.CreateNew)
  13782. using (var stream = new MemoryStream())
  13783. {
  13784. workbook.Write(stream, true);
  13785. stream.Flush();
  13786. stream.Seek(0, SeekOrigin.Begin);
  13787. var memoryStream = new MemoryStream();
  13788. stream.CopyTo(memoryStream);
  13789. memoryStream.Seek(0, SeekOrigin.Begin);
  13790. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13791. }
  13792. workbook.Close();
  13793. workbook.Dispose();
  13794. }
  13795. catch (Exception ex)
  13796. {
  13797. jw.Msg = "出现异常!" + ex.Message;
  13798. return Ok(jw);
  13799. }
  13800. }
  13801. if (Zips.Count > 0)
  13802. {
  13803. var io = new IOOperatorHelper();
  13804. var byts = io.ConvertZipStream(Zips);
  13805. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13806. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13807. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13808. }
  13809. else
  13810. {
  13811. jw.Msg = "暂无生成文件!";
  13812. }
  13813. return Ok(jw);
  13814. }
  13815. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13816. {
  13817. string outStr = string.Empty;
  13818. switch (i)
  13819. {
  13820. case 0:
  13821. outStr = arr[0].SidName;
  13822. break;
  13823. case 1:
  13824. outStr = arr[0].DataPriceStr;
  13825. break;
  13826. case 2:
  13827. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13828. break;
  13829. case 4:
  13830. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13831. break;
  13832. case 7:
  13833. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13834. {
  13835. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13836. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13837. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13838. }
  13839. break;
  13840. case 8:
  13841. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13842. {
  13843. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13844. }
  13845. break;
  13846. case 9:
  13847. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13848. {
  13849. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13850. }
  13851. break;
  13852. case 10:
  13853. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13854. {
  13855. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13856. }
  13857. break;
  13858. }
  13859. return outStr;
  13860. }
  13861. #region OP行程单
  13862. /// <summary>
  13863. /// OP行程单初始化
  13864. /// </summary>
  13865. /// <param name="dto"></param>
  13866. /// <returns></returns>
  13867. [HttpPost]
  13868. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13869. {
  13870. var jw = JsonView(false);
  13871. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13872. var group = groupList.First();
  13873. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13874. if (group == null)
  13875. {
  13876. jw.Msg = "暂无团组!";
  13877. return Ok(jw);
  13878. }
  13879. group = groupList.Find(x => x.Id == diid);
  13880. if (group == null)
  13881. {
  13882. jw.Msg = "请输入正确的团组ID!";
  13883. return Ok(jw);
  13884. }
  13885. string city = string.Empty;
  13886. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13887. if (blackCode.Count > 0)
  13888. {
  13889. var black = blackCode.First();
  13890. black.BlackCode = black.BlackCode ?? "";
  13891. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13892. if (blackSp.Length > 0)
  13893. {
  13894. try
  13895. {
  13896. var cityArrCode = new List<string>(20);
  13897. foreach (var item in blackSp)
  13898. {
  13899. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13900. var IndexSelect = itemSp[2];
  13901. var cityArrCodeLength = cityArrCode.Count - 1;
  13902. var startCity = IndexSelect.Substring(0, 3);
  13903. if (cityArrCodeLength > 0)
  13904. {
  13905. var arrEndCity = cityArrCode[cityArrCodeLength];
  13906. if (arrEndCity != startCity)
  13907. {
  13908. cityArrCode.Add(startCity.ToUpper());
  13909. }
  13910. }
  13911. else
  13912. {
  13913. cityArrCode.Add(startCity.ToUpper());
  13914. }
  13915. var endCity = IndexSelect.Substring(3, 3);
  13916. cityArrCode.Add(endCity.ToUpper());
  13917. }
  13918. var cityThree = string.Empty;
  13919. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13920. cityThree = cityThree.TrimEnd(',');
  13921. if (string.IsNullOrWhiteSpace(cityThree))
  13922. {
  13923. throw new
  13924. Exception("error");
  13925. }
  13926. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13927. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13928. foreach (var item in cityArrCode)
  13929. {
  13930. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13931. if (find != null)
  13932. {
  13933. city += find.City + "/";
  13934. }
  13935. else
  13936. {
  13937. city += item + "三字码未收入/";
  13938. }
  13939. }
  13940. city = city.TrimEnd('/');
  13941. }
  13942. catch (Exception e)
  13943. {
  13944. city = "黑屏代码格式不正确!";
  13945. }
  13946. }
  13947. }
  13948. else
  13949. {
  13950. city = "未录入黑屏代码";
  13951. }
  13952. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13953. {
  13954. Date = x.Date,
  13955. Days = x.Days,
  13956. Diffgroup = x.Diffgroup,
  13957. Diid = x.Diid,
  13958. Traffic_First = x.Traffic_First,
  13959. Traffic_Second = x.Traffic_Second,
  13960. Trip = x.Trip,
  13961. WeekDay = x.WeekDay,
  13962. Id = x.Id
  13963. }).ToList();
  13964. jw.Data = new
  13965. {
  13966. groupList = groupList.Select(x => new
  13967. {
  13968. x.Id,
  13969. x.TeamName,
  13970. x.TourCode
  13971. }).ToList(),
  13972. groupInfo = new
  13973. {
  13974. group.VisitDays,
  13975. group.TourCode,
  13976. group.VisitPNumber,
  13977. group.TeamName,
  13978. city
  13979. },
  13980. OpTravelList
  13981. };
  13982. jw.Code = 200;
  13983. jw.Msg = "操作成功!";
  13984. return Ok(jw);
  13985. }
  13986. /// <summary>
  13987. /// 删除团组行程单
  13988. /// </summary>
  13989. /// <returns></returns>
  13990. [HttpPost]
  13991. public IActionResult DelTravel(DelOpTravelDto dto)
  13992. {
  13993. var jw = JsonView(false);
  13994. if (dto.UserId <= 0 || dto.Diid <= 0)
  13995. {
  13996. jw.Msg = "请输入正确的参数!";
  13997. return Ok(jw);
  13998. }
  13999. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  14000. .SetColumns(x => new Grp_TravelList
  14001. {
  14002. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  14003. DeleteUserId = dto.UserId,
  14004. IsDel = 1,
  14005. }).ExecuteCommand();
  14006. jw = JsonView(true);
  14007. return Ok(jw);
  14008. }
  14009. /// <summary>
  14010. /// 行程单保存
  14011. /// </summary>
  14012. /// <returns></returns>
  14013. [HttpPost]
  14014. public IActionResult TravelSave(TravelSaveDto dto)
  14015. {
  14016. var jw = JsonView(false);
  14017. if (dto.Arr.Count > 0)
  14018. {
  14019. try
  14020. {
  14021. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  14022. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  14023. .ToList();
  14024. _sqlSugar.BeginTran();
  14025. foreach (var item in dto.Arr)
  14026. {
  14027. if (item.Id == 0)
  14028. {
  14029. throw new Exception("请传入正确的Id");
  14030. }
  14031. //比较上一次的差异
  14032. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  14033. if (findTravel != null)
  14034. {
  14035. item.Trip = item.Trip.Replace("[++]", string.Empty);
  14036. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  14037. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  14038. }
  14039. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  14040. .SetColumns(x => new Grp_TravelList
  14041. {
  14042. Trip = item.Trip
  14043. }).ExecuteCommand();
  14044. }
  14045. _sqlSugar.CommitTran();
  14046. jw = JsonView(true);
  14047. }
  14048. catch (Exception ex)
  14049. {
  14050. _sqlSugar.RollbackTran();
  14051. jw.Msg = "程序异常!" + ex.Message;
  14052. }
  14053. }
  14054. else
  14055. {
  14056. jw.Msg = "请传入正确的参数!";
  14057. }
  14058. return Ok(jw);
  14059. }
  14060. private static string CheckStr(string original, string changed)
  14061. {
  14062. // 创建diff_match_patch对象
  14063. var dmp = new diff_match_patch();
  14064. // 计算差异
  14065. List<Diff> diffs = dmp.diff_main(original, changed);
  14066. // 清理和合并差异
  14067. dmp.diff_cleanupSemantic(diffs);
  14068. // 使用StringBuilder构建最终的字符串
  14069. var finalString = new StringBuilder();
  14070. // 输出差异结果,并构建变动后的字符串
  14071. foreach (Diff diff in diffs)
  14072. {
  14073. switch (diff.operation)
  14074. {
  14075. case Operation.EQUAL:
  14076. // 相等的部分,直接添加到最终字符串
  14077. finalString.Append(diff.text);
  14078. break;
  14079. case Operation.INSERT:
  14080. // 插入的部分,添加标记并添加到最终字符串
  14081. finalString.Append("[++]" + diff.text + "[++]");
  14082. break;
  14083. case Operation.DELETE:
  14084. // 删除的部分,不添加到最终字符串
  14085. //finalString.Append("[++]" + diff.text + "[++]");
  14086. break;
  14087. }
  14088. }
  14089. // 输出变动后的字符串
  14090. return finalString.ToString();
  14091. }
  14092. private class tagContent
  14093. {
  14094. public DateTime Date { get; set; }
  14095. public string StartTag { get; set; }
  14096. public string EndTag { get; set; }
  14097. public string Content { get; set; }
  14098. public static int tagLength { get { return 3; } }
  14099. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  14100. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  14101. public bool IsFinally { get; set; }
  14102. }
  14103. private static List<string> ExtractContentBetweenTags(string input, string tag)
  14104. {
  14105. var results = new List<string>();
  14106. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  14107. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  14108. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  14109. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  14110. string[] strValueArr = new string[1];
  14111. foreach (System.Text.RegularExpressions.Match match in matches)
  14112. {
  14113. var strValue = match.Groups[1].Value;
  14114. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  14115. }
  14116. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  14117. return results;
  14118. }
  14119. /// <summary>
  14120. /// 导出行程单
  14121. /// </summary>
  14122. /// <param name="dto"></param>
  14123. /// <returns></returns>
  14124. [HttpPost]
  14125. public IActionResult ExportTravel(ExportTravelDto dto)
  14126. {
  14127. var jw = JsonView(false);
  14128. jw.Data = "";
  14129. int diid = 0;
  14130. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  14131. if (Find == null)
  14132. {
  14133. jw.Msg = "请选择正确的团组!";
  14134. return Ok(jw);
  14135. }
  14136. else
  14137. {
  14138. diid = Find.Id;
  14139. }
  14140. //数据源
  14141. var _travelList = new List<Grp_TravelList>();
  14142. DataTable dtBlack = null;
  14143. try
  14144. {
  14145. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  14146. }
  14147. catch (Exception)
  14148. {
  14149. jw.Msg = "机票黑屏代码有误!";
  14150. return Ok(jw);
  14151. }
  14152. string CityStr = string.Empty;
  14153. if (dtBlack.Rows.Count == 0)
  14154. {
  14155. jw.Msg = "机票黑屏代码有误!";
  14156. return Ok(jw);
  14157. }
  14158. else
  14159. {
  14160. foreach (DataRow row in dtBlack.Rows)
  14161. {
  14162. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14163. {
  14164. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  14165. return Ok(jw);
  14166. }
  14167. }
  14168. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  14169. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  14170. }
  14171. // 指定的文字
  14172. var targetTextDic = new Dictionary<string, List<string>>();
  14173. //创建数据源Table
  14174. var dtSource = new DataTable();
  14175. dtSource.Columns.Add("Days", typeof(string));
  14176. dtSource.Columns.Add("Date", typeof(string));
  14177. dtSource.Columns.Add("Week", typeof(string));
  14178. dtSource.Columns.Add("Traffic", typeof(string));
  14179. dtSource.Columns.Add("Trip", typeof(string));
  14180. //获取数据,放到datatable
  14181. foreach (var item in _travelList)
  14182. {
  14183. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  14184. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  14185. .Replace(tagContent.TagFormat.Item2, string.Empty)
  14186. .Replace("[++]", string.Empty);
  14187. DataRow dr = dtSource.NewRow();
  14188. dr["Days"] = item.Days;
  14189. dr["Date"] = item.Date;
  14190. dr["Week"] = item.WeekDay;
  14191. dr["Traffic"] = item.Traffic_First
  14192. + "\r\n"
  14193. + item.Traffic_Second;
  14194. dr["Trip"] = item.Trip;
  14195. dtSource.Rows.Add(dr);
  14196. }
  14197. var dic = new Dictionary<string, string>
  14198. {
  14199. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  14200. { "City", CityStr },
  14201. { "Days", Find.VisitDays.ToString() },
  14202. { "DeleCode", Find.TourCode },
  14203. { "Pnum", Find.VisitPNumber.ToString() }
  14204. };
  14205. //模板路径
  14206. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  14207. //载入模板
  14208. Document doc = null;
  14209. DocumentBuilder builder = null;
  14210. try
  14211. {
  14212. //载入模板
  14213. doc = new Document(tempPath);
  14214. builder = new DocumentBuilder(doc);
  14215. }
  14216. catch (Exception)
  14217. {
  14218. jw.Msg = "模板位置不存在!";
  14219. return Ok(jw);
  14220. }
  14221. foreach (var key in dic.Keys)
  14222. {
  14223. Bookmark bookmark = doc.Range.Bookmarks[key];
  14224. if (bookmark != null)
  14225. {
  14226. builder.MoveToBookmark(key);
  14227. builder.Write(dic[key]);
  14228. }
  14229. }
  14230. //获取word里所有表格
  14231. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14232. //获取所填表格的序数
  14233. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14234. try
  14235. {
  14236. //循环赋值
  14237. for (int i = 0; i < dtSource.Rows.Count; i++)
  14238. {
  14239. builder.MoveToCell(0, i + 1, 0, 0);
  14240. builder.Write(dtSource.Rows[i]["Days"].ToString());
  14241. builder.MoveToCell(0, i + 1, 1, 0);
  14242. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  14243. builder.MoveToCell(0, i + 1, 2, 0);
  14244. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  14245. var trip = dtSource.Rows[i]["Trip"].ToString();
  14246. builder.MoveToCell(0, i + 1, 3, 0);
  14247. builder.Write(trip);
  14248. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  14249. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14250. // 获取特定索引的段落
  14251. Paragraph paragraph = (Paragraph)paragraphs[0];
  14252. Run run = paragraph.Runs[0];
  14253. Aspose.Words.Font font = run.Font;
  14254. font.Name = "黑体";
  14255. //设置双休红色
  14256. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  14257. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14258. paragraph = (Paragraph)paragraphs[1];
  14259. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  14260. {
  14261. run = paragraph.Runs[0];
  14262. font = run.Font;
  14263. font.Color = Color.Red;
  14264. }
  14265. }
  14266. }
  14267. catch (Exception ex)
  14268. {
  14269. }
  14270. //删除多余行
  14271. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  14272. {
  14273. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  14274. }
  14275. var targetTextList = new List<string>();
  14276. // 遍历文档中的表格
  14277. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14278. {
  14279. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14280. {
  14281. var cellIndex = 0;
  14282. foreach (Cell cell in row.Cells)
  14283. {
  14284. if (cellIndex == 1 && row.Cells.Count == 4)
  14285. {
  14286. foreach (var target in targetTextDic.Keys)
  14287. {
  14288. if (cell.GetText().Contains(target))
  14289. {
  14290. targetTextList = targetTextDic[target];
  14291. break;
  14292. }
  14293. }
  14294. }
  14295. // 遍历单元格中的所有段落
  14296. foreach (Paragraph paragraph in cell.Paragraphs)
  14297. {
  14298. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  14299. var runs = new List<Run>();
  14300. foreach (Run run in paragraph.Runs)
  14301. {
  14302. runs.Add(run);
  14303. }
  14304. foreach (Run run in runs)
  14305. {
  14306. foreach (var targetText in targetTextList)
  14307. {
  14308. // 检查文字是否包含指定文字
  14309. if (run.Text.Contains(targetText))
  14310. {
  14311. // 将包含的部分设置为红色
  14312. HighlightText(run, targetText, Color.Red);
  14313. }
  14314. }
  14315. }
  14316. }
  14317. cellIndex++;
  14318. }
  14319. }
  14320. }
  14321. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  14322. if (!Directory.Exists(savePath))
  14323. {
  14324. try
  14325. {
  14326. Directory.CreateDirectory(savePath);
  14327. }
  14328. catch
  14329. {
  14330. }
  14331. }
  14332. string path = savePath + Find.TeamName + "出访日程";
  14333. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  14334. try
  14335. {
  14336. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  14337. string postfix = ".docx";
  14338. if (dto.IsPDF == 1)
  14339. {
  14340. saveFormat = Aspose.Words.SaveFormat.Pdf;
  14341. postfix = ".pdf";
  14342. }
  14343. doc.Save(path + postfix, saveFormat);
  14344. jw = JsonView(true, "导出成功", ftpPath + postfix);
  14345. }
  14346. catch (Exception)
  14347. {
  14348. jw = JsonView(false);
  14349. }
  14350. return Ok(jw);
  14351. }
  14352. /// <summary>
  14353. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  14354. /// </summary>
  14355. /// <param name="num"></param>
  14356. /// <returns></returns>
  14357. static string GetNum(string num)
  14358. {
  14359. string str = "";
  14360. switch (num)
  14361. {
  14362. case "1":
  14363. str = "一";
  14364. break;
  14365. case "2":
  14366. str = "二";
  14367. break;
  14368. case "3":
  14369. str = "三";
  14370. break;
  14371. case "4":
  14372. str = "四";
  14373. break;
  14374. case "5":
  14375. str = "五";
  14376. break;
  14377. case "6":
  14378. str = "六";
  14379. break;
  14380. case "7":
  14381. str = "七";
  14382. break;
  14383. case "8":
  14384. str = "八";
  14385. break;
  14386. case "9":
  14387. str = "九";
  14388. break;
  14389. case "10":
  14390. str = "十";
  14391. break;
  14392. case "11":
  14393. str = "十一";
  14394. break;
  14395. case "12":
  14396. str = "十二";
  14397. break;
  14398. case "一":
  14399. str = "1";
  14400. break;
  14401. case "二":
  14402. str = "2";
  14403. break;
  14404. case "三":
  14405. str = "3";
  14406. break;
  14407. case "四":
  14408. str = "4";
  14409. break;
  14410. case "五":
  14411. str = "5";
  14412. break;
  14413. case "六":
  14414. str = "6";
  14415. break;
  14416. case "七":
  14417. str = "7";
  14418. break;
  14419. case "八":
  14420. str = "8";
  14421. break;
  14422. case "九":
  14423. str = "9";
  14424. break;
  14425. case "十":
  14426. str = "10";
  14427. break;
  14428. case "十一":
  14429. str = "11";
  14430. break;
  14431. case "十二":
  14432. str = "12";
  14433. break;
  14434. }
  14435. return str;
  14436. }
  14437. /// <summary>
  14438. /// 高亮包含指定文字的部分
  14439. /// </summary>
  14440. /// <param name="run"></param>
  14441. /// <param name="targetText"></param>
  14442. /// <param name="color"></param>
  14443. static void HighlightText(Run run, string targetText, Color color)
  14444. {
  14445. string text = run.Text;
  14446. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14447. if (startIndex >= 0)
  14448. {
  14449. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14450. // 前部分
  14451. if (startIndex > 0)
  14452. {
  14453. Run beforeRun = (Run)run.Clone(true);
  14454. beforeRun.Text = text.Substring(0, startIndex);
  14455. parentParagraph.InsertBefore(beforeRun, run);
  14456. }
  14457. // 匹配部分
  14458. Run matchRun = (Run)run.Clone(true);
  14459. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14460. matchRun.Font.Color = color;
  14461. parentParagraph.InsertBefore(matchRun, run);
  14462. // 后部分
  14463. if (startIndex + targetText.Length < text.Length)
  14464. {
  14465. Run afterRun = (Run)run.Clone(true);
  14466. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14467. parentParagraph.InsertBefore(afterRun, run);
  14468. }
  14469. // 删除原始Run
  14470. run.Remove();
  14471. }
  14472. }
  14473. #endregion
  14474. #endregion
  14475. #region 团组成本
  14476. /// <summary>
  14477. /// 团组成本数据初始化
  14478. /// </summary>
  14479. /// <param name="dto"></param>
  14480. /// <returns></returns>
  14481. [HttpPost]
  14482. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14483. {
  14484. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14485. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14486. WHEN COUNT(*) >= 0 THEN 'True'
  14487. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14488. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14489. ").ToList(); //团组列表
  14490. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14491. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14492. var visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14493. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14494. if (groupinfoValue != null)
  14495. {
  14496. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14497. var spArr = new string[1] { countryArr };
  14498. if (countryArr.Contains("|"))
  14499. {
  14500. spArr = countryArr.Split("|");
  14501. }
  14502. else if (countryArr.Contains("、"))
  14503. {
  14504. spArr = countryArr.Split("、");
  14505. }
  14506. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14507. {
  14508. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14509. if (dbQueryCountry != null)
  14510. {
  14511. visaCountryInfoArr.Add(dbQueryCountry);
  14512. }
  14513. }
  14514. }
  14515. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14516. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14517. #region 屏蔽黑屏代码生成
  14518. //var create = _GroupCostRepository.
  14519. // CreateGroupCostByBlackCode(dto.Diid);
  14520. //if (groupCost.Count == 0 && create.Code == 0)
  14521. //{
  14522. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14523. //}
  14524. #endregion
  14525. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14526. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14527. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14528. groupCostMap = groupCostMap.Select(x =>
  14529. {
  14530. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14531. {
  14532. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14533. }
  14534. return x;
  14535. }).ToList();
  14536. //GroupCostParameter.Add(new
  14537. // Grp_GroupCostParameter());
  14538. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14539. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14540. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  14541. return Ok(JsonView(new
  14542. {
  14543. groupList,
  14544. groupInfo,
  14545. groupChecks,
  14546. groupCost = groupCostMap,
  14547. hotelNumber,
  14548. GroupCostParameter = GroupCostParameterMap,
  14549. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14550. {
  14551. x.VisaCountry,
  14552. x.VisaPrice,
  14553. x.Id,
  14554. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  14555. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  14556. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  14557. x.VisaTime, // 一般签证时间
  14558. x.PettyBusinessAgencyFee, //小公务代办费
  14559. x.GrandBusinessAgencyFee //大公务代办费
  14560. }).ToList(),
  14561. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14562. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14563. hotelIsTrue,
  14564. groupModuleOperators
  14565. }));
  14566. }
  14567. /// <summary>
  14568. /// 团组成本信息保存
  14569. /// </summary>
  14570. /// <param name="dto"></param>
  14571. /// <returns></returns>
  14572. [HttpPost]
  14573. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14574. {
  14575. if (dto.Diid <= 0 || dto.Userid <= 0)
  14576. {
  14577. return Ok(JsonView(false));
  14578. }
  14579. JsonView jw = null;
  14580. bool isTrue = false;
  14581. #region 复制团组成本
  14582. //if (dto.Diid == 2581)
  14583. //{
  14584. // dto.Diid = 2599;
  14585. // dto.CheckBoxs.ForEach(x =>
  14586. // {
  14587. // x.Diid = 2599;
  14588. // });
  14589. // dto.GroupCosts.ForEach(x =>
  14590. // {
  14591. // x.Diid = 2599;
  14592. // });
  14593. // dto.CostTypeHotelNumbers.ForEach(x =>
  14594. // {
  14595. // x.Diid = 2599;
  14596. // });
  14597. // dto.GroupCostParameters.ForEach(x =>
  14598. // {
  14599. // x.DiId = 2599;
  14600. // });
  14601. //}
  14602. #endregion
  14603. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14604. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14605. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14606. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14607. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14608. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14609. try
  14610. {
  14611. _sqlSugar.BeginTran();
  14612. isTrue = await _GroupCostRepository.
  14613. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14614. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14615. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14616. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14617. _sqlSugar.CommitTran();
  14618. jw = JsonView(true, "保存成功!", isTrue);
  14619. }
  14620. catch (Exception)
  14621. {
  14622. _sqlSugar.RollbackTran();
  14623. jw = JsonView(false);
  14624. }
  14625. return Ok(jw);
  14626. }
  14627. /// <summary>
  14628. /// 复制团组成本信息
  14629. /// </summary>
  14630. /// <param name="dto"></param>
  14631. /// <returns></returns>
  14632. [HttpPost]
  14633. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14634. {
  14635. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14636. {
  14637. return Ok(JsonView(false, "参数有误!"));
  14638. }
  14639. #region 复制团组成本
  14640. dto.Diid = dto.ToGroupId;
  14641. dto.CheckBoxs.ForEach(x =>
  14642. {
  14643. x.Diid = dto.ToGroupId;
  14644. });
  14645. dto.GroupCosts.ForEach(x =>
  14646. {
  14647. x.Diid = dto.ToGroupId;
  14648. });
  14649. dto.CostTypeHotelNumbers.ForEach(x =>
  14650. {
  14651. x.Diid = dto.ToGroupId;
  14652. });
  14653. dto.GroupCostParameters.ForEach(x =>
  14654. {
  14655. x.DiId = dto.ToGroupId;
  14656. });
  14657. #endregion
  14658. JsonView jw = null;
  14659. bool isTrue = false;
  14660. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14661. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14662. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14663. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14664. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14665. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14666. try
  14667. {
  14668. _sqlSugar.BeginTran();
  14669. isTrue = await _GroupCostRepository.
  14670. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14671. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14672. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14673. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14674. _sqlSugar.CommitTran();
  14675. jw = JsonView(true, "保存成功!", isTrue);
  14676. }
  14677. catch (Exception)
  14678. {
  14679. _sqlSugar.RollbackTran();
  14680. jw = JsonView(false);
  14681. }
  14682. return Ok(jw);
  14683. }
  14684. /// <summary>
  14685. /// 司兼导数据
  14686. /// </summary>
  14687. /// <param name="dto"></param>
  14688. /// <returns></returns>
  14689. [HttpPost]
  14690. public IActionResult GetCarGuides(CarGuidesDto dto)
  14691. {
  14692. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14693. return Ok(JsonView(true, "获取成功!", Data));
  14694. }
  14695. /// <summary>
  14696. /// 导游数据
  14697. /// </summary>
  14698. /// <param name="dto"></param>
  14699. /// <returns></returns>
  14700. [HttpPost]
  14701. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14702. {
  14703. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14704. // 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
  14705. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14706. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14707. return Ok(JsonView(true, "获取成功!", Data));
  14708. }
  14709. /// <summary>
  14710. /// 成本车数据
  14711. /// </summary>
  14712. /// <param name="dto"></param>
  14713. /// <returns></returns>
  14714. [HttpPost]
  14715. public IActionResult GetCarInfo(CarGuidesDto dto)
  14716. {
  14717. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14718. return Ok(JsonView(true, "获取成功!", Data));
  14719. }
  14720. /// <summary>
  14721. /// 景点数据
  14722. /// </summary>
  14723. /// <param name="dto"></param>
  14724. /// <returns></returns>
  14725. [HttpPost]
  14726. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14727. {
  14728. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14729. return Ok(JsonView(true, "获取成功!", Data));
  14730. }
  14731. /// <summary>
  14732. /// 成本通知
  14733. /// </summary>
  14734. /// <param name="dto"></param>
  14735. /// <returns></returns>
  14736. [HttpPost]
  14737. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14738. {
  14739. if (dto.Diid < 0)
  14740. {
  14741. return Ok(JsonView(false));
  14742. }
  14743. JsonView jw;
  14744. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14745. if (GroupCostParameter != null)
  14746. {
  14747. int IsShare = 0;
  14748. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14749. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14750. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14751. string msg = string.Empty;
  14752. if (isTrue)
  14753. {
  14754. if (IsShare == 0)
  14755. {
  14756. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14757. }
  14758. else
  14759. {
  14760. #region 企微通知对应岗位用户
  14761. try
  14762. {
  14763. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14764. }
  14765. catch (Exception)
  14766. {
  14767. }
  14768. #endregion
  14769. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14770. }
  14771. jw = JsonView(isTrue, msg, new { IsShare });
  14772. }
  14773. else
  14774. {
  14775. msg = "修改失败!";
  14776. jw = JsonView(isTrue, msg);
  14777. }
  14778. }
  14779. else
  14780. {
  14781. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14782. }
  14783. return Ok(jw);
  14784. }
  14785. /// <summary>
  14786. /// 导出报价单
  14787. /// </summary>
  14788. /// <param name="dto"></param>
  14789. /// <returns></returns>
  14790. [HttpPost]
  14791. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14792. {
  14793. if (dto.Diid == 0)
  14794. {
  14795. return Ok(JsonView(false, "请传递团组id"));
  14796. }
  14797. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14798. if (deleInfo.Code != 0)
  14799. {
  14800. return Ok(JsonView(false, "团组信息查询失败!"));
  14801. }
  14802. var di = deleInfo.Data as DelegationInfoWebView;
  14803. if (di != null)
  14804. {
  14805. di.TeamName = di.TeamName.Replace("|", "、");
  14806. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14807. //文件名
  14808. string strFileName = di.TeamName + "-收款账单.doc";
  14809. //获取模板
  14810. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14811. //载入模板
  14812. Document doc = new Document(tmppath);
  14813. decimal TotalPrice = 0.00M;
  14814. string itemStr = string.Empty;
  14815. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14816. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14817. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14818. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14819. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14820. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14821. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14822. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14823. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14824. foreach (var cost in groupCostType)
  14825. {
  14826. var List = cost.ToList();
  14827. if (cost.Key == "A")
  14828. {
  14829. foreach (var ListItem in List)
  14830. {
  14831. if (ListItem.number > 0)
  14832. {
  14833. if (ListItem.code.Contains("TBR"))
  14834. {
  14835. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14836. }
  14837. else
  14838. {
  14839. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14840. }
  14841. TotalPrice += (ListItem.number * ListItem.price);
  14842. }
  14843. }
  14844. }
  14845. else
  14846. {
  14847. itemStr = itemStr.Insert(0, "A段\r\n");
  14848. itemStr += "B段\r\n";
  14849. foreach (var ListItem in List)
  14850. {
  14851. if (ListItem.number > 0)
  14852. {
  14853. if (ListItem.code.Contains("TBR"))
  14854. {
  14855. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14856. }
  14857. else
  14858. {
  14859. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14860. }
  14861. TotalPrice += (ListItem.number * ListItem.price);
  14862. }
  14863. }
  14864. }
  14865. }
  14866. #region 替换Word模板书签内容
  14867. Dictionary<string, string> marks = new Dictionary<string, string>();
  14868. marks.Add("To", di.ClientUnit);//付款方
  14869. marks.Add("ToTel", di.TellPhone);//付款方电话
  14870. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14871. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14872. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14873. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14874. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14875. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14876. marks.Add("PayItemContent", itemStr);//详细信息
  14877. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14878. #endregion
  14879. ////注
  14880. //if (doc.Range.Bookmarks["Attention"] != null)
  14881. //{
  14882. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14883. // mark.Text = frList[0].Attention;
  14884. //}
  14885. foreach (var item in marks.Keys)
  14886. {
  14887. if (doc.Range.Bookmarks[item] != null)
  14888. {
  14889. Bookmark mark = doc.Range.Bookmarks[item];
  14890. mark.Text = marks[item];
  14891. }
  14892. }
  14893. byte[] bytes = null;
  14894. using (MemoryStream stream = new MemoryStream())
  14895. {
  14896. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14897. bytes = stream.ToArray();
  14898. }
  14899. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14900. return Ok(JsonView(true, "", new
  14901. {
  14902. Data = bytes,
  14903. strFileName,
  14904. }));
  14905. }
  14906. else
  14907. {
  14908. return Ok(JsonView(false, "团组信息不存在!"));
  14909. }
  14910. }
  14911. /// <summary>
  14912. /// 导出团组成本
  14913. /// </summary>
  14914. /// <param name="dto"></param>
  14915. /// <returns></returns>
  14916. [HttpPost]
  14917. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14918. {
  14919. var jw = JsonView(false);
  14920. if (dto.Diid == 0)
  14921. {
  14922. return Ok(JsonView(false, "请传递团组id"));
  14923. }
  14924. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14925. if (deleInfo.Code != 0)
  14926. {
  14927. return Ok(JsonView(false, "团组信息查询失败!"));
  14928. }
  14929. var di = deleInfo.Data as DelegationInfoWebView;
  14930. if (di == null)
  14931. {
  14932. return Ok(JsonView(false, "团组信息查询失败!"));
  14933. }
  14934. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14935. WorkbookDesigner designer = new WorkbookDesigner();
  14936. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14937. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14938. List<int> hideColumnList = new List<int>();
  14939. var ColumnSetting = new[]
  14940. {
  14941. new { tag = "VF", Index = 4, P = "CarCost" },
  14942. new { tag = "VN", Index = 5, P = "CarNumber" },
  14943. new { tag = "VRD", Index = 6, P = "CarTiming" },
  14944. new { tag = "T/G S", Index = 7, P = "TGS" },
  14945. new { tag = "TGWH", Index = 8, P = "TGWH" },
  14946. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  14947. new { tag = "T/G M", Index = 10, P = "TGM" },
  14948. new { tag = "T/G A", Index = 11, P = "TGA" },
  14949. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  14950. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  14951. new { tag = "C/F S", Index = 14, P = "CFS" },
  14952. new { tag = "C/F M", Index = 15, P = "CFM" },
  14953. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  14954. new { tag = "B", Index = 17, P = "B" },
  14955. new { tag = "L", Index = 18, P = "L" },
  14956. new { tag = "D", Index = 19, P = "D" },
  14957. new { tag = "TBR", Index = 20, P = "TBR" },
  14958. new { tag = "SGR", Index = 21, P = "SGR" },
  14959. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  14960. new { tag = "Suite", Index = 23, P = "Suite" },
  14961. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  14962. new { tag = "T/V", Index = 25, P = "TV" },
  14963. new { tag = "1/L", Index = 26, P = "iL" },
  14964. new { tag = "I/F", Index = 27, P = "IF" },
  14965. new { tag = "EF", Index = 28, P = "EF" },
  14966. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  14967. new { tag = "TE", Index = 30, P = "TE" },
  14968. new { tag = "T/G T", Index = 31, P = "TGTips" },
  14969. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  14970. new { tag = "P/C", Index = 33, P = "PC" },
  14971. new { tag = "T/L F", Index = 34, P = "TLF" },
  14972. new { tag = "E/C T", Index = 35, P = "ECT" }
  14973. };
  14974. Func<string, bool> isEmpty = (str) =>
  14975. {
  14976. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  14977. {
  14978. return true;
  14979. }
  14980. if (string.IsNullOrWhiteSpace(str))
  14981. {
  14982. return true;
  14983. }
  14984. return false;
  14985. };
  14986. for (int i = 0; i < List_GC.Count; i++)
  14987. {
  14988. GroupCost_Excel gc = new GroupCost_Excel();
  14989. gc.Id = List_GC[i].Id;
  14990. gc.Diid = List_GC[i].Diid.ToString();
  14991. gc.DAY = List_GC[i].DAY;
  14992. string week = "";
  14993. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14994. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14995. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14996. gc.ITIN = List_GC[i].ITIN;
  14997. gc.CarType = List_GC[i].CarType;
  14998. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  14999. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  15000. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  15001. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  15002. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  15003. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  15004. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  15005. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  15006. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  15007. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  15008. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  15009. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  15010. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  15011. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  15012. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  15013. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  15014. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  15015. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  15016. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  15017. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  15018. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  15019. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  15020. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  15021. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  15022. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  15023. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  15024. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  15025. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  15026. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  15027. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  15028. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  15029. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  15030. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  15031. gc.EFR = List_GC[i].EFR;
  15032. List_GC1.Add(gc);
  15033. }
  15034. if (List_GC1.Count > 0)
  15035. {
  15036. var p = List_GC1[0];
  15037. var prs = p.GetType().GetProperties();
  15038. foreach (var item in prs)
  15039. {
  15040. var tp = item.PropertyType;
  15041. if (tp == typeof(int))
  15042. {
  15043. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  15044. if (val == 0)
  15045. {
  15046. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15047. if (columnSetting != null)
  15048. {
  15049. hideColumnList.Add(columnSetting.Index);
  15050. }
  15051. }
  15052. }
  15053. if (tp == typeof(decimal))
  15054. {
  15055. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  15056. if (val == 0)
  15057. {
  15058. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15059. if (columnSetting != null)
  15060. {
  15061. hideColumnList.Add(columnSetting.Index);
  15062. }
  15063. }
  15064. }
  15065. if (tp == typeof(string))
  15066. {
  15067. var val = List_GC1.Sum(x =>
  15068. {
  15069. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  15070. if (decimal.TryParse(str, out decimal str_De))
  15071. {
  15072. return str_De;
  15073. }
  15074. else
  15075. {
  15076. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  15077. }
  15078. });
  15079. if (val == 0)
  15080. {
  15081. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15082. if (columnSetting != null)
  15083. {
  15084. hideColumnList.Add(columnSetting.Index);
  15085. }
  15086. }
  15087. }
  15088. }
  15089. }
  15090. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  15091. dt.TableName = "TB";
  15092. //报表标题等不用dt的值
  15093. designer.SetDataSource("TeamName", dto.title.TeamName);
  15094. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  15095. designer.SetDataSource("Tax", dto.title.Tax);
  15096. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  15097. designer.SetDataSource("Currency", dto.title.Currency);
  15098. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  15099. designer.SetDataSource("Rate", dto.title.Rate);
  15100. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  15101. var Aparams = hotels.Find(x => x.Type == "Default");
  15102. if (Aparams == null)
  15103. {
  15104. return Ok(jw);
  15105. }
  15106. //酒店数量
  15107. var txtSGRNumber = Aparams.SGR.ToString();
  15108. var txtTBRNumber = Aparams.TBR.ToString();
  15109. var txtJSESNumber = Aparams.JSES.ToString();
  15110. var txtSUITENumbe = Aparams.SUITE.ToString();
  15111. if (dto.costType == "B")
  15112. {
  15113. Aparams = hotels.Find(x => x.Type == "A");
  15114. var Bparams = hotels.Find(x => x.Type == "B");
  15115. if (Aparams == null || Bparams == null)
  15116. {
  15117. return Ok(jw);
  15118. }
  15119. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  15120. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  15121. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  15122. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  15123. }
  15124. designer.SetDataSource("SGRNumber", txtSGRNumber);
  15125. designer.SetDataSource("TBRNumber", txtTBRNumber);
  15126. designer.SetDataSource("JSESNumber", txtJSESNumber);
  15127. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  15128. var ws = designer.Workbook.Worksheets[1];
  15129. int Row = List_GC.Count;
  15130. int startIndex = 0;
  15131. int HideRows = 0;
  15132. Row = 0;
  15133. List<int> hideRowsList = new List<int>();
  15134. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  15135. #region A段left数据
  15136. var left = dto.leftInfo.Find(x => x.Type == "A");
  15137. if (left == null)
  15138. {
  15139. return Ok(jw);
  15140. }
  15141. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  15142. if (leftBindData != null)
  15143. {
  15144. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  15145. designer.SetDataSource("VisaRS", leftBindData.rs);
  15146. designer.SetDataSource("VisaXS", leftBindData.xs);
  15147. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15148. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15149. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15150. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15151. designer.SetDataSource("VisaZLR", ((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("BXDRCB", leftBindData.cb);
  15163. designer.SetDataSource("BXRS", leftBindData.rs);
  15164. designer.SetDataSource("BXXS", leftBindData.xs);
  15165. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15166. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15167. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15168. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15169. designer.SetDataSource("BXZLR", ((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("HSDRCB", leftBindData.cb);
  15181. designer.SetDataSource("HSRS", leftBindData.rs);
  15182. designer.SetDataSource("HSXS", leftBindData.xs);
  15183. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15184. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15185. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15186. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15187. designer.SetDataSource("HSZLR", ((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("JPJJCCB", leftBindData.cb);
  15199. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  15200. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  15201. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15202. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15203. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15204. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15205. designer.SetDataSource("JPJJCZLR", ((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("JPGWCCB", leftBindData.cb);
  15217. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  15218. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  15219. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15220. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15221. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15222. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15223. designer.SetDataSource("JPGWCZLR", ((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("头等舱"));
  15232. if (leftBindData != null)
  15233. {
  15234. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  15235. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  15236. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  15237. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15238. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15239. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15240. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15241. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15242. }
  15243. else
  15244. {
  15245. hideRowsList.Add(Row + startIndex + HideRows);
  15246. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15247. }
  15248. HideRows += 2;
  15249. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15250. if (leftBindData != null)
  15251. {
  15252. ////TBR
  15253. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  15254. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  15255. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  15256. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15257. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15258. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15259. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15260. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15261. }
  15262. else
  15263. {
  15264. hideRowsList.Add(Row + startIndex + HideRows);
  15265. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15266. }
  15267. HideRows += 2;
  15268. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15269. if (leftBindData != null)
  15270. {
  15271. ////SGR
  15272. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  15273. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  15274. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  15275. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15276. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15277. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15278. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15279. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15280. }
  15281. else
  15282. {
  15283. hideRowsList.Add(Row + startIndex + HideRows);
  15284. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15285. }
  15286. HideRows += 2;
  15287. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15288. if (leftBindData != null)
  15289. {
  15290. ////JS/ES
  15291. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  15292. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  15293. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  15294. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15295. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15296. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15297. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15298. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15299. }
  15300. else
  15301. {
  15302. hideRowsList.Add(Row + startIndex + HideRows);
  15303. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15304. }
  15305. HideRows += 2;
  15306. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15307. if (leftBindData != null)
  15308. {
  15309. ////SUITE
  15310. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  15311. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  15312. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  15313. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15314. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15315. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15316. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15317. designer.SetDataSource("HotelSUITEZLR", ((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("DJDRCB", leftBindData.cb);
  15329. designer.SetDataSource("DJRS", leftBindData.rs);
  15330. designer.SetDataSource("DJXS", leftBindData.xs);
  15331. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15332. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15333. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15334. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15335. designer.SetDataSource("DJZLR", ((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("HCPCB", leftBindData.cb);
  15347. designer.SetDataSource("HCPRS", leftBindData.rs);
  15348. designer.SetDataSource("HCPXS", leftBindData.xs);
  15349. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15350. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15351. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15352. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15353. designer.SetDataSource("HCPZLR", ((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("CPCB", leftBindData.cb);
  15365. designer.SetDataSource("CPRS", leftBindData.rs);
  15366. designer.SetDataSource("CPXS", leftBindData.xs);
  15367. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15368. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15369. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15370. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15371. designer.SetDataSource("CPZLR", ((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("GWDRCD", leftBindData.cb);
  15383. designer.SetDataSource("GWRS", leftBindData.rs);
  15384. designer.SetDataSource("GWXS", leftBindData.xs);
  15385. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15386. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15387. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15388. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15389. designer.SetDataSource("GWZLR", ((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. HideRows += 2;
  15397. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15398. if (leftBindData != null)
  15399. {
  15400. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  15401. designer.SetDataSource("LYJRS", leftBindData.rs);
  15402. designer.SetDataSource("LYJXS", leftBindData.xs);
  15403. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15404. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15405. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15406. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15407. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15408. }
  15409. else
  15410. {
  15411. hideRowsList.Add(Row + startIndex + HideRows);
  15412. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15413. }
  15414. #endregion
  15415. #region A段Right信息
  15416. var right = dto.rightInfo.Find(x => x.Type == "A");
  15417. if (right == null)
  15418. {
  15419. return Ok(jw);
  15420. }
  15421. HideRows += 4;
  15422. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15423. if (rightBindData != null)
  15424. {
  15425. //经济舱 + 双人间 TBR
  15426. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  15427. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  15428. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15429. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  15430. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15431. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15432. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15433. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15434. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15435. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15436. }
  15437. else
  15438. {
  15439. hideRowsList.Add(Row + startIndex + HideRows);
  15440. }
  15441. HideRows += 2;
  15442. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15443. if (rightBindData != null)
  15444. {
  15445. //经济舱 + 单人间 SGR
  15446. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  15447. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  15448. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15449. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  15450. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15451. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15452. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15453. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15454. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15455. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15456. }
  15457. else
  15458. {
  15459. hideRowsList.Add(Row + startIndex + HideRows);
  15460. }
  15461. HideRows += 2;
  15462. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15463. if (rightBindData != null)
  15464. {
  15465. //公务舱 + 单人间 SGR
  15466. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  15467. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  15468. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15469. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  15470. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15471. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15472. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15473. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15474. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15475. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15476. }
  15477. else
  15478. {
  15479. hideRowsList.Add(Row + startIndex + HideRows);
  15480. }
  15481. HideRows += 2;
  15482. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15483. if (rightBindData != null)
  15484. {
  15485. //公务舱 + 小套房 JSES
  15486. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  15487. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  15488. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15489. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  15490. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15491. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15492. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15493. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15494. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15495. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15496. }
  15497. else
  15498. {
  15499. hideRowsList.Add(Row + startIndex + HideRows);
  15500. }
  15501. HideRows += 2;
  15502. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15503. if (rightBindData != null)
  15504. {
  15505. //公务舱 + 小套房 JSES
  15506. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  15507. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  15508. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15509. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  15510. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15511. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15512. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15513. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15514. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15515. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15516. }
  15517. else
  15518. {
  15519. hideRowsList.Add(Row + startIndex + HideRows);
  15520. }
  15521. HideRows += 2;
  15522. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15523. if (rightBindData != null)
  15524. {
  15525. //经济舱 + 大套房
  15526. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  15527. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  15528. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15529. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  15530. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15531. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15532. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15533. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15534. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15535. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15536. }
  15537. else
  15538. {
  15539. hideRowsList.Add(Row + startIndex + HideRows);
  15540. }
  15541. HideRows += 2;
  15542. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15543. if (rightBindData != null)
  15544. {
  15545. //头等舱 + 小套房 JSES
  15546. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15547. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15548. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15549. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15550. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15551. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15552. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15553. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15554. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15555. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15556. }
  15557. else
  15558. {
  15559. hideRowsList.Add(Row + startIndex + HideRows);
  15560. }
  15561. HideRows += 2;
  15562. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15563. if (rightBindData != null)
  15564. {
  15565. //头等舱 + 大套房
  15566. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15567. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15568. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15569. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15570. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15571. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15572. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15573. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15574. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15575. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15576. }
  15577. else
  15578. {
  15579. hideRowsList.Add(Row + startIndex + HideRows);
  15580. }
  15581. #endregion
  15582. #region B段标题清空
  15583. designer.SetDataSource("CostBDRCB", "");
  15584. designer.SetDataSource("CostBRS", "");
  15585. designer.SetDataSource("CostBXS", "");
  15586. designer.SetDataSource("CostBZCB", "");
  15587. designer.SetDataSource("CostBDRBJ", "");
  15588. designer.SetDataSource("CostBZBJ", "");
  15589. designer.SetDataSource("CostBDRLR", "");
  15590. designer.SetDataSource("CostBZLR", "");
  15591. designer.SetDataSource("CostBDRCBOM", "");
  15592. designer.SetDataSource("CostBRSOM", "");
  15593. designer.SetDataSource("CostBZCBOM", "");
  15594. designer.SetDataSource("CostBDRBJOM", "");
  15595. designer.SetDataSource("CostBZBJOM", "");
  15596. designer.SetDataSource("CostBDRLROM", "");
  15597. designer.SetDataSource("CostBZLROM", "");
  15598. #endregion
  15599. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15600. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15601. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15602. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15603. designer.SetDataSource("DJName", "地接(CNY)");
  15604. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15605. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15606. designer.SetDataSource("GWName", "公务(CNY)");
  15607. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15608. designer.SetDataSource("LYJName", "零用金(CNY)");
  15609. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15610. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15611. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15612. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15613. designer.SetDataSource("BXName", "保险(CNY)");
  15614. designer.SetDataSource("VisaName", "签证(CNY)");
  15615. #region B段基本数据
  15616. if (dto.costType == "B")
  15617. {
  15618. left = dto.leftInfo.Find(x => x.Type == "B");
  15619. if (left == null)
  15620. {
  15621. return Ok(jw);
  15622. }
  15623. #region B段left数据
  15624. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15625. if (leftBindData != null)
  15626. {
  15627. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15628. designer.SetDataSource("BHSRS", leftBindData.rs);
  15629. designer.SetDataSource("BHSXS", leftBindData.xs);
  15630. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15631. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15632. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15633. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15634. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15635. }
  15636. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15637. if (leftBindData != null)
  15638. {
  15639. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15640. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15641. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15642. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15643. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15644. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15645. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15646. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15647. }
  15648. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15649. if (leftBindData != null)
  15650. {
  15651. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15652. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15653. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15654. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15655. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15656. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15657. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15658. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15659. }
  15660. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15661. if (leftBindData != null)
  15662. {
  15663. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15664. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15665. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15666. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15667. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15668. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15669. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15670. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15671. }
  15672. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15673. if (leftBindData != null)
  15674. {
  15675. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15676. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15677. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15678. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15679. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15680. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15681. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15682. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15683. }
  15684. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15685. if (leftBindData != null)
  15686. {
  15687. designer.SetDataSource("BCPCB", leftBindData.cb);
  15688. designer.SetDataSource("BCPRS", leftBindData.rs);
  15689. designer.SetDataSource("BCPXS", leftBindData.xs);
  15690. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15691. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15692. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15693. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15694. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15695. }
  15696. //TBR
  15697. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15698. if (leftBindData != null)
  15699. {
  15700. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15701. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15702. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15703. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15704. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15705. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15706. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15707. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15708. }
  15709. //SGR
  15710. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15711. if (leftBindData != null)
  15712. {
  15713. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15714. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15715. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15716. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15717. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15718. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15719. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15720. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15721. }
  15722. //JS/ES
  15723. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15724. if (leftBindData != null)
  15725. {
  15726. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15727. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15728. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15729. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15730. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15731. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15732. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15733. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15734. }
  15735. //SUITE
  15736. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15737. if (leftBindData != null)
  15738. {
  15739. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15740. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15741. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15742. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15743. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15744. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15745. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15746. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15747. }
  15748. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15749. if (leftBindData != null)
  15750. {
  15751. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15752. designer.SetDataSource("BDJRS", leftBindData.rs);
  15753. designer.SetDataSource("BDJXS", leftBindData.xs);
  15754. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15755. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15756. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15757. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15758. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15759. }
  15760. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15761. if (leftBindData != null)
  15762. {
  15763. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15764. designer.SetDataSource("BGWRS", leftBindData.rs);
  15765. designer.SetDataSource("BGWXS", leftBindData.xs);
  15766. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15767. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15768. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15769. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15770. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15771. }
  15772. #region 优化方案
  15773. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15774. //excelBind.Add("零用金", new {
  15775. //cb="",
  15776. //rs="",
  15777. //xs ="",
  15778. //zcb = "",
  15779. //});
  15780. #endregion
  15781. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15782. if (leftBindData != null)
  15783. {
  15784. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15785. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15786. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15787. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15788. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15789. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15790. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15791. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15792. }
  15793. #endregion
  15794. #region B段Right信息
  15795. right = dto.rightInfo.Find(x => x.Type == "B");
  15796. if (right == null)
  15797. {
  15798. return Ok(jw);
  15799. }
  15800. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15801. if (rightBindData != null)
  15802. {
  15803. //经济舱 + 双人间 TBR
  15804. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15805. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15806. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15807. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15808. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15809. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15810. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15811. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15812. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15813. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15814. }
  15815. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15816. if (rightBindData != null)
  15817. {
  15818. //经济舱 + 单人间 SGR
  15819. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15820. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15821. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15822. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15823. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15824. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15825. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15826. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15827. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15828. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15829. }
  15830. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15831. if (rightBindData != null)
  15832. {
  15833. //公务舱 + 单人间 SGR
  15834. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15835. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15836. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15837. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15838. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15839. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15840. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15841. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15842. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15843. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15844. }
  15845. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15846. if (rightBindData != null)
  15847. {
  15848. //公务舱 + 小套房 JSES
  15849. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15850. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15851. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15852. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15853. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15854. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15855. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15856. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15857. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15858. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15859. }
  15860. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15861. if (rightBindData != null)
  15862. {
  15863. //公务舱 + 小套房 JSES
  15864. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15865. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15866. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15867. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15868. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15869. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15870. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15871. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15872. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15873. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15874. }
  15875. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15876. if (rightBindData != null)
  15877. {
  15878. //经济舱 + 大套房
  15879. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15880. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15881. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15882. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15883. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15884. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15885. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15886. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15887. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15888. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15889. }
  15890. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15891. if (rightBindData != null)
  15892. {
  15893. //头等舱 + 小套房 JSES
  15894. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15895. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15896. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15897. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15898. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15899. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15900. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15901. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15902. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15903. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15904. }
  15905. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15906. if (rightBindData != null)
  15907. {
  15908. //头等舱 + 大套房
  15909. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15910. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15911. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15912. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15913. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15914. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15915. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15916. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15917. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15918. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15919. }
  15920. #endregion
  15921. #region 标题
  15922. designer.SetDataSource("CostBDRCB", "单人成本");
  15923. designer.SetDataSource("CostBRS", "人数");
  15924. designer.SetDataSource("CostBXS", "系数");
  15925. designer.SetDataSource("CostBZCB", "总成本");
  15926. designer.SetDataSource("CostBDRBJ", "单人报价");
  15927. designer.SetDataSource("CostBZBJ", "总报价");
  15928. designer.SetDataSource("CostBDRLR", "单人利润");
  15929. designer.SetDataSource("CostBZLR", "总利润");
  15930. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15931. designer.SetDataSource("CostBRSOM", "人数");
  15932. designer.SetDataSource("CostBZCBOM", "总成本");
  15933. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15934. designer.SetDataSource("CostBZBJOM", "总报价");
  15935. designer.SetDataSource("CostBDRLROM", "单人利润");
  15936. designer.SetDataSource("CostBZLROM", "总利润");
  15937. #endregion
  15938. }
  15939. #endregion
  15940. designer.SetDataSource("TzZCB2", TzZCB2);
  15941. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15942. designer.SetDataSource("TzZLR2", TzZLR2);
  15943. string[] dataSourceKeys = new string[]
  15944. {
  15945. "VF",
  15946. "TGS",
  15947. "TGOF",
  15948. "TGM",
  15949. "TGA",
  15950. "TGTF",
  15951. "TGEF",
  15952. "CFM",
  15953. "CFOF",
  15954. "B",
  15955. "L",
  15956. "D",
  15957. "TBR",
  15958. "SGR",
  15959. "JSES",
  15960. "Suite",
  15961. "TV",
  15962. "1L",
  15963. "IF",
  15964. "EF",
  15965. "BRF",
  15966. "TE",
  15967. "TGT",
  15968. "DRVT",
  15969. "PC",
  15970. "TLF",
  15971. "ECT"
  15972. };
  15973. foreach (var item in dataSourceKeys)
  15974. {
  15975. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  15976. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  15977. var find = dto.titleModel.FirstOrDefault(expr);
  15978. if (find != null)
  15979. {
  15980. designer.SetDataSource(item, find.text);
  15981. }
  15982. else
  15983. {
  15984. designer.SetDataSource(item, 0);
  15985. }
  15986. }
  15987. designer.SetDataSource(dt);
  15988. //根据数据源处理生成报表内容
  15989. designer.Process();
  15990. designer.Workbook.Worksheets[0].Name = "费用明细";
  15991. designer.Workbook.Worksheets[1].Name = "费用总核算";
  15992. Worksheet sheet = designer.Workbook.Worksheets[0];
  15993. #region 隐藏舱位
  15994. var settingAir = new[]
  15995. {
  15996. new { key = "经济舱", index = 7 },
  15997. new { key = "公务舱", index = 19 },
  15998. new { key = "头等舱", index = 11 }
  15999. };
  16000. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  16001. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  16002. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  16003. .Select((c, s) => s.Name)
  16004. .ToList()
  16005. .GroupBy(x => x)
  16006. .Select(x => x.Key);
  16007. foreach (var item in settingAir)
  16008. {
  16009. if (!airType.Contains(item.key))
  16010. {
  16011. hideRowsList.Add(item.index);
  16012. }
  16013. }
  16014. #endregion
  16015. foreach (var Rowindex in hideRowsList)
  16016. {
  16017. ws.Cells.HideRows(Rowindex, 2);
  16018. }
  16019. ws = designer.Workbook.Worksheets[0];
  16020. foreach (var Column in hideColumnList)
  16021. {
  16022. ws.Cells.HideColumns(Column, 1);
  16023. }
  16024. byte[] bytes = null;
  16025. string strFileName = di.TeamName + "-团组-成本.xls";
  16026. using (MemoryStream stream = new MemoryStream())
  16027. {
  16028. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  16029. bytes = stream.ToArray();
  16030. }
  16031. return Ok(JsonView(true, "", new
  16032. {
  16033. Data = bytes,
  16034. strFileName,
  16035. }));
  16036. }
  16037. /// <summary>
  16038. /// 导出客户报表
  16039. /// </summary>
  16040. /// <returns></returns>
  16041. [HttpPost]
  16042. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  16043. {
  16044. var jw = JsonView(false);
  16045. if (dto.Diid == 0)
  16046. {
  16047. return Ok(JsonView(false, "请传递团组id"));
  16048. }
  16049. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  16050. if (deleInfo.Code != 0)
  16051. {
  16052. return Ok(JsonView(false, "团组信息查询失败!"));
  16053. }
  16054. var di = deleInfo.Data as DelegationInfoWebView;
  16055. if (di == null)
  16056. {
  16057. return Ok(JsonView(false, "团组信息查询失败!"));
  16058. }
  16059. //文件名
  16060. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  16061. //获取模板
  16062. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  16063. //载入模板
  16064. Document doc = new Document(tmppath);
  16065. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  16066. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  16067. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  16068. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  16069. var AParameter = ParameterList.Find(x => x.CostType == "A");
  16070. var BParameter = ParameterList.Find(x => x.CostType == "B");
  16071. if (AParameter == null)
  16072. {
  16073. return Ok(JsonView(false, "系数不存在!"));
  16074. }
  16075. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  16076. , TzAirDesc, TzZCost;
  16077. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  16078. = TzAirDesc = TzZCost = string.Empty;
  16079. TzNumber = AParameter.CostTypenumber.ToString();
  16080. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  16081. CarGuides1 = dto.CarGuides1;
  16082. Meal = dto.Meal;
  16083. SubsidizedMeals = dto.SubsidizedMeals;
  16084. NightRepair = dto.NightRepair;
  16085. AttractionsTickets = dto.AttractionsTickets;
  16086. MiscellaneousFees = dto.MiscellaneousFees;
  16087. ATip = dto.ATip;
  16088. TzHotelDesc = "";
  16089. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  16090. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  16091. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  16092. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  16093. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  16094. TzAirDesc = "";
  16095. TzZCost = dto.TzZCost;
  16096. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  16097. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  16098. var index = 1;
  16099. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  16100. foreach (var item in TzHotelDescArr)
  16101. {
  16102. if (AinfoArr != null)
  16103. {
  16104. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16105. if (Ainfo != null)
  16106. {
  16107. if (int.Parse(Ainfo.rs) <= 0)
  16108. {
  16109. continue;
  16110. }
  16111. var hotelText = string.Empty;
  16112. switch (item)
  16113. {
  16114. case "SGR":
  16115. hotelText = "单人间";
  16116. break;
  16117. case "JSES":
  16118. hotelText = "小套房";
  16119. break;
  16120. case "SUITE":
  16121. hotelText = "套房";
  16122. break;
  16123. case "TBR":
  16124. hotelText = "双人间";
  16125. break;
  16126. }
  16127. if (item != "TBR")
  16128. {
  16129. 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";
  16130. }
  16131. else
  16132. {
  16133. 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";
  16134. }
  16135. index++;
  16136. }
  16137. }
  16138. }
  16139. index = 1;
  16140. foreach (var item in TzAirDescArr)
  16141. {
  16142. if (AinfoArr != null)
  16143. {
  16144. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16145. if (Ainfo != null)
  16146. {
  16147. if (int.Parse(Ainfo.rs) <= 0)
  16148. {
  16149. continue;
  16150. }
  16151. 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";
  16152. index++;
  16153. }
  16154. }
  16155. }
  16156. if (dto.costType == "B")
  16157. {
  16158. if (BParameter == null)
  16159. {
  16160. return Ok(JsonView(false, "B段系数不存在!"));
  16161. }
  16162. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  16163. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  16164. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  16165. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  16166. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  16167. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  16168. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  16169. foreach (var item in TzHotelDescArr)
  16170. {
  16171. if (AinfoArr != null)
  16172. {
  16173. TzHotelDesc += "B段信息 \r\n";
  16174. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16175. if (Ainfo != null)
  16176. {
  16177. if (int.Parse(Ainfo.rs) <= 0)
  16178. {
  16179. continue;
  16180. }
  16181. var hotelText = string.Empty;
  16182. switch (item)
  16183. {
  16184. case "SGR":
  16185. hotelText = "单人间";
  16186. break;
  16187. case "JSES":
  16188. hotelText = "小套房";
  16189. break;
  16190. case "SUITE":
  16191. hotelText = "套房";
  16192. break;
  16193. case "TBR":
  16194. hotelText = "双人间";
  16195. break;
  16196. }
  16197. if (item != "TBR")
  16198. {
  16199. 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";
  16200. }
  16201. else
  16202. {
  16203. 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";
  16204. }
  16205. index++;
  16206. }
  16207. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  16208. }
  16209. }
  16210. index = 1;
  16211. foreach (var item in TzAirDescArr)
  16212. {
  16213. if (AinfoArr != null)
  16214. {
  16215. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16216. if (Ainfo != null)
  16217. {
  16218. if (int.Parse(Ainfo.rs) <= 0)
  16219. {
  16220. continue;
  16221. }
  16222. 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";
  16223. index++;
  16224. }
  16225. }
  16226. }
  16227. }
  16228. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  16229. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  16230. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  16231. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  16232. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  16233. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  16234. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  16235. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  16236. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  16237. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  16238. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  16239. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  16240. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  16241. DickeyValue.Add("Visa", Visa); // 签证单人报价
  16242. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  16243. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  16244. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  16245. DickeyValue.Add("TzZCost", TzZCost);
  16246. foreach (var key in DickeyValue.Keys)
  16247. {
  16248. if (doc.Range.Bookmarks[key] != null)
  16249. {
  16250. Bookmark mark = doc.Range.Bookmarks[key];
  16251. mark.Text = DickeyValue[key];
  16252. }
  16253. }
  16254. byte[] bytes = null;
  16255. string strFileName = di.TeamName + "-客户报价.doc";
  16256. using (MemoryStream stream = new MemoryStream())
  16257. {
  16258. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  16259. bytes = stream.ToArray();
  16260. }
  16261. return Ok(JsonView(true, "", new
  16262. {
  16263. Data = bytes,
  16264. strFileName,
  16265. }));
  16266. }
  16267. /// <summary>
  16268. /// 团组成本 各模块(酒店,地接,机票)成本提示
  16269. /// </summary>
  16270. /// <param name="dto"></param>
  16271. /// <returns></returns>
  16272. [HttpPost]
  16273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16274. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  16275. {
  16276. try
  16277. {
  16278. #region 参数验证
  16279. if (dto.DiId < 0)
  16280. {
  16281. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  16282. }
  16283. List<int> cTableIds = new List<int>() {
  16284. 76 ,//酒店预订
  16285. 77 ,//行程
  16286. 79 ,//车/导游地接
  16287. 80 ,//签证
  16288. 81 ,//邀请/公务活
  16289. 82 ,//团组客户保险
  16290. 85 ,//机票预订
  16291. 98 ,//其他款项
  16292. 285 ,//收款退还
  16293. 751 ,//酒店早餐
  16294. 1015 // 超支费用
  16295. };
  16296. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  16297. {
  16298. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  16299. }
  16300. #endregion
  16301. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  16302. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  16303. if (_GroupCostParameters.Count <= 0)
  16304. {
  16305. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  16306. }
  16307. if (_GroupCostParameters[0].IsShare == 0)
  16308. {
  16309. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  16310. }
  16311. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16312. //处理date为空问题
  16313. if (_GroupCosts.Count > 0)
  16314. {
  16315. for (int i = 0; i < _GroupCosts.Count; i++)
  16316. {
  16317. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  16318. {
  16319. if (i > 0)
  16320. {
  16321. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  16322. }
  16323. }
  16324. }
  16325. }
  16326. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  16327. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  16328. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  16329. string currCode = "";
  16330. #region currCode 验证
  16331. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  16332. if (isInt)
  16333. {
  16334. var currData = currDatas.Find(it => it.Id == intCurrency);
  16335. if (currData != null)
  16336. {
  16337. currCode = currData.Name;
  16338. }
  16339. }
  16340. else
  16341. {
  16342. currCode = _GroupCostParameters[0].Currency.Trim();
  16343. }
  16344. #endregion
  16345. //op,酒店单段模式存储
  16346. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  16347. {
  16348. CurrencyCode = currCode,
  16349. Rate = _GroupCostParameters[0].Rate,
  16350. CostType = _GroupCostParameters[0].CostType,
  16351. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  16352. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  16353. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  16354. };
  16355. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  16356. if (_GroupCostParameters.Count == 2)
  16357. {
  16358. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  16359. }
  16360. foreach (var item in _GroupCostParameters)
  16361. {
  16362. decimal _rate = 1;
  16363. decimal _rate1 = item.Rate;
  16364. decimal _scale = 1;
  16365. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  16366. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  16367. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  16368. //if (userInfo != null)
  16369. //{
  16370. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  16371. // {
  16372. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  16373. // {
  16374. // _scale = 1.00M;
  16375. // }
  16376. // }
  16377. //}
  16378. #endregion
  16379. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  16380. {
  16381. CurrencyCode = currCode,
  16382. Rate = _rate1,
  16383. CostType = item.CostType,
  16384. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  16385. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  16386. CostTypeNumber = item.CostTypenumber
  16387. };
  16388. if (_GroupCostParameters.Count > 1)
  16389. {
  16390. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  16391. }
  16392. else
  16393. {
  16394. modulePromptInfo.CostTypeNumber = item.LYJRS;
  16395. }
  16396. if (dto.CTable == 79)//
  16397. {
  16398. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  16399. modulePromptInfo.TotalCost = item.DJCB;
  16400. }
  16401. List<string> costTypes = new List<string>() { "A", "B" };
  16402. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  16403. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  16404. if (_GroupCostsDuplicates.Count() == 1)
  16405. {
  16406. _GroupCostsTypeData = _GroupCosts;
  16407. }
  16408. else
  16409. {
  16410. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  16411. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  16412. }
  16413. /*
  16414. * 76 酒店预订
  16415. * 77 行程
  16416. * 79 车/导游地接
  16417. * 80 签证
  16418. * 81 邀请/公务活动
  16419. * 82 团组客户保险
  16420. * 85 机票预订
  16421. * 98 其他款项
  16422. * 285 收款退还
  16423. * 751 酒店早餐
  16424. * 1015 超支费用
  16425. */
  16426. switch (dto.CTable)
  16427. {
  16428. case 76: // 酒店预订
  16429. _ModuleSubPromptInfo.AddRange(
  16430. _GroupCostsTypeData.Select(it => new
  16431. {
  16432. it.DAY,
  16433. it.Date,
  16434. it.ACCON,
  16435. it.ITIN,
  16436. it.SGR,
  16437. it.TBR,
  16438. it.JS_ES,
  16439. it.Suite
  16440. })
  16441. );
  16442. break;
  16443. case 79: // 车/导游地接
  16444. _ModuleSubPromptInfo.AddRange(
  16445. _GroupCostsTypeData.Select(it => new
  16446. {
  16447. Date = it.Date, //日期
  16448. CarFee = it.CarCost * _rate * _scale, //车费用
  16449. CarType = it.CarType, //车型
  16450. DriverFee = it.CFS * _rate * _scale, //司机工资
  16451. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  16452. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  16453. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  16454. GuideFee = it.TGS * _rate * _scale, //导游费用
  16455. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  16456. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  16457. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  16458. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  16459. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  16460. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  16461. Breakfast = it.B * _rate * _scale, //早餐费
  16462. Lunch = it.L * _rate * _scale, //午餐费
  16463. Dinner = it.D * _rate * _scale, //晚餐费
  16464. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  16465. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  16466. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  16467. TicketFee = it.EF * _rate * _scale, //门票费
  16468. TicketRemark = it.EFR, //门票费描述
  16469. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  16470. TravelSupplies = it.TE * _rate * _scale, //出行物资
  16471. SpentCash = it.PC * _rate * _scale, //零用金
  16472. LeadersFee = it.TLF * _rate * _scale, //领队费
  16473. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  16474. })
  16475. );
  16476. break;
  16477. case 85: // 机票
  16478. List<dynamic> datas = new List<dynamic>();
  16479. datas.Add(
  16480. new
  16481. {
  16482. AirType = "经济舱",
  16483. AirNum = item.JJCRS,
  16484. AirDRCB = item.JJCCB,
  16485. AirZCB = (item.JJCRS * item.JJCCB)
  16486. }
  16487. );
  16488. datas.Add(
  16489. new
  16490. {
  16491. AirType = "公务舱",
  16492. AirNum = item.GWCRS,
  16493. AirDRCB = item.GWCCB,
  16494. AirZCB = (item.GWCRS * item.GWCCB)
  16495. }
  16496. );
  16497. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16498. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  16499. modulePromptInfo.Data = new
  16500. {
  16501. airFeeData = datas,
  16502. airInitData = initDatas
  16503. };
  16504. _ModulePromptInfos.Add(modulePromptInfo);
  16505. break;
  16506. default:
  16507. break;
  16508. }
  16509. }
  16510. if (dto.CTable != 85)
  16511. {
  16512. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  16513. _ModulePromptInfos.Add(_ModulePromptInfo);
  16514. }
  16515. _view.ModulePromptInfos = _ModulePromptInfos;
  16516. return Ok(JsonView(true, "操作成功!", _view));
  16517. }
  16518. catch (Exception ex)
  16519. {
  16520. return Ok(JsonView(false, ex.Message));
  16521. }
  16522. }
  16523. /// <summary>
  16524. /// 根据黑屏代码重新生成行程
  16525. /// </summary>
  16526. /// <param name="dto"></param>
  16527. /// <returns></returns>
  16528. [HttpPost]
  16529. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  16530. {
  16531. var jw = JsonView(false, "Error");
  16532. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  16533. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  16534. .Select(x => new
  16535. {
  16536. x.Id,
  16537. x.Title
  16538. })
  16539. .ToList();
  16540. if (Create.Any())
  16541. {
  16542. jw.Msg = "获取成功!";
  16543. jw.Code = 200;
  16544. jw.Data = new
  16545. {
  16546. BlackCodeListSelect = Create,
  16547. blackCodeIsTrue = true
  16548. };
  16549. }
  16550. else
  16551. {
  16552. jw.Code = 400;
  16553. jw.Data = new
  16554. {
  16555. BlackCodeListSelect = Create,
  16556. blackCodeIsTrue = false,
  16557. };
  16558. }
  16559. return Ok(jw);
  16560. }
  16561. /// <summary>
  16562. /// 根据黑屏代码Id重新生成行程
  16563. /// </summary>
  16564. /// <param name="dto"></param>
  16565. /// <returns></returns>
  16566. [HttpPost]
  16567. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  16568. {
  16569. var jw = JsonView(false, "Error");
  16570. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16571. if (result.Code == 0)
  16572. {
  16573. jw.Msg = "获取成功!";
  16574. jw.Code = 200;
  16575. jw.Data = new
  16576. {
  16577. groupCost = result.Data,
  16578. blackCodeIsTrue = true
  16579. };
  16580. }
  16581. else
  16582. {
  16583. jw.Code = 400;
  16584. jw.Data = new
  16585. {
  16586. groupCost = result.Data,
  16587. blackCodeIsTrue = false,
  16588. };
  16589. }
  16590. return Ok(jw);
  16591. }
  16592. /// <summary>
  16593. /// 成本获取OP历史车费用
  16594. /// </summary>
  16595. /// <param name="dto"></param>
  16596. /// <returns></returns>
  16597. [HttpPost]
  16598. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16599. {
  16600. var jw = JsonView(false);
  16601. try
  16602. {
  16603. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16604. //获取现有所有车的数据
  16605. if (!dto.Param.IsNullOrWhiteSpace())
  16606. {
  16607. string sql = $@"
  16608. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16609. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16610. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16611. 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
  16612. AND gctggr.ServiceEndTime is not NULL
  16613. ORDER by gctggrc.id DESC
  16614. ";
  16615. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16616. var numeberResult = await Task.Run(() =>
  16617. {
  16618. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16619. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16620. return numberArr;
  16621. });
  16622. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16623. foreach (var item in numeberResult)
  16624. {
  16625. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16626. {
  16627. Country = "数据异常!",
  16628. City = string.Empty,
  16629. };
  16630. item.Area = find.Country + " " + find.City;
  16631. }
  16632. dbResult.AddRange(numeberResult);
  16633. if (dto.Param.Contains("、"))
  16634. {
  16635. var sp = dto.Param.Split("、");
  16636. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16637. .Where(x =>
  16638. {
  16639. return System.Array.Exists(sp, e =>
  16640. {
  16641. bool where = false;
  16642. if (x.Area != null)
  16643. {
  16644. where = x.Area.Contains(e);
  16645. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16646. {
  16647. return false;
  16648. }
  16649. }
  16650. if (x.PriceName != null && !where)
  16651. {
  16652. where = x.PriceName.Contains(e);
  16653. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16654. {
  16655. return false;
  16656. }
  16657. }
  16658. return where;
  16659. });
  16660. }).ToList();
  16661. }
  16662. else
  16663. {
  16664. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16665. .Where(x =>
  16666. {
  16667. bool where = false;
  16668. if (x.Area != null)
  16669. {
  16670. where = x.Area.Contains(dto.Param);
  16671. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16672. {
  16673. return false;
  16674. }
  16675. }
  16676. if (x.PriceName != null && !where)
  16677. {
  16678. where = x.PriceName.Contains(dto.Param);
  16679. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16680. {
  16681. return false;
  16682. }
  16683. }
  16684. return where;
  16685. }
  16686. )
  16687. .ToList();
  16688. }
  16689. }
  16690. var view = dbResult.Select(x =>
  16691. {
  16692. decimal dp = 0.00M;
  16693. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16694. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16695. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16696. {
  16697. if (startB && endB)
  16698. {
  16699. var timesp = endD.Subtract(startD);
  16700. if ((timesp.Days + 1) != 0)
  16701. {
  16702. dp = x.Price / (timesp.Days + 1);
  16703. }
  16704. }
  16705. }
  16706. else
  16707. {
  16708. dp = x.Price;
  16709. }
  16710. return new
  16711. {
  16712. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16713. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16714. x.Area,
  16715. x.id,
  16716. price = x.Price.ToString("F2"),
  16717. x.PriceName,
  16718. x.PriceContent,
  16719. x.TeamName,
  16720. x.DatePrice,
  16721. dayPrice = dp.ToString("F2"),
  16722. };
  16723. }).OrderByDescending(x => x.id).ToList();
  16724. jw = JsonView(true, "获取成功!", view);
  16725. }
  16726. catch (Exception e)
  16727. {
  16728. jw = JsonView(false, e.Message);
  16729. }
  16730. return Ok(jw);
  16731. }
  16732. [HttpPost]
  16733. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16734. {
  16735. var jw = JsonView(true);
  16736. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16737. #region SQL语句
  16738. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  16739. //{
  16740. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16741. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16742. // WHEN COUNT(*) >= 0 THEN 'True'
  16743. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16744. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16745. // ")
  16746. // .ToList();
  16747. //}
  16748. //else
  16749. //{
  16750. // string likeKey = string.Empty;
  16751. // foreach (var item in dto.Keyword)
  16752. // {
  16753. // likeKey += "%" + item;
  16754. // }
  16755. // likeKey += "%";
  16756. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16757. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16758. // WHEN COUNT(*) >= 0 THEN 'True'
  16759. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16760. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16761. // ")
  16762. // .ToList();
  16763. //}
  16764. #endregion
  16765. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  16766. {
  16767. @KeyWord = dto.Keyword
  16768. });
  16769. if (table != null && table.Rows.Count > 0)
  16770. {
  16771. foreach (DataRow row in table.Rows)
  16772. {
  16773. matches.Add(new DelegationInfoAndIsTrueView
  16774. {
  16775. Id = row.Field<int>("Id"),
  16776. GroupName = row.Field<string>("GroupName"),
  16777. isTrue = row.Field<string>("isTrue")
  16778. });
  16779. }
  16780. }
  16781. if (matches.Any())
  16782. {
  16783. jw.Data = matches;
  16784. }
  16785. else
  16786. {
  16787. jw.Code = 201;
  16788. jw.Msg = "empty list";
  16789. jw.Data = new List<string>(1);
  16790. }
  16791. return Ok(jw);
  16792. }
  16793. /// <summary>
  16794. /// 报价Word下载
  16795. /// </summary>
  16796. /// <param name="dto"></param>
  16797. /// <returns></returns>
  16798. [HttpPost]
  16799. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16800. {
  16801. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16802. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16803. if (di == null)
  16804. {
  16805. return Ok(JsonView(false, "团组不存在!"));
  16806. }
  16807. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16808. if (mainPrice == null || mainPrice.IsShare == 0)
  16809. {
  16810. return Ok(JsonView(false, "团组成本不存在!"));
  16811. }
  16812. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16813. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16814. if (costTypeHotelNumbers == null)
  16815. {
  16816. return Ok(JsonView(false, "团组成本不存在!"));
  16817. }
  16818. //文件名
  16819. string strFileName = di.TeamName + "-收款账单.doc";
  16820. //获取模板
  16821. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16822. //载入模板
  16823. Document doc = new Document(tmppath);
  16824. decimal allPrice = 0.00M;
  16825. string itemStr = string.Empty;
  16826. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16827. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16828. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16829. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16830. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16831. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16832. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16833. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16834. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16835. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16836. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16837. {
  16838. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16839. ("BXRS", "BXCB", "BXXS", "bx"),
  16840. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16841. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16842. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16843. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16844. ("CPRS", "CPCB", "CPXS", "cp"),
  16845. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16846. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16847. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16848. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16849. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16850. ("DJRS", "DJCB", "DJXS", "dj"),
  16851. ("GWRS", "GWCB", "GWXS", "gw"),
  16852. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16853. };
  16854. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16855. var rightSum = 0.00M;
  16856. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16857. {
  16858. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16859. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16860. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16861. if (prefix == "tbr")
  16862. {
  16863. rsValue *= 2;
  16864. cbValue /= 2;
  16865. }
  16866. if (OtherCostPropertyBJ.Contains(prefix))
  16867. {
  16868. rightSum += cbValue * xsValue;
  16869. }
  16870. }
  16871. var hotelRooms = new Dictionary<string, int>
  16872. {
  16873. { "SGR", costTypeHotelNumbers.SGR },
  16874. { "TBR", costTypeHotelNumbers.TBR },
  16875. { "JSES", costTypeHotelNumbers.JSES },
  16876. { "SUITE", costTypeHotelNumbers.SUITE }
  16877. };
  16878. var flights = new Dictionary<string, int>
  16879. {
  16880. { "经济舱", mainPrice.JJCRS },
  16881. { "公务舱", mainPrice.GWCRS },
  16882. { "头等舱", mainPrice.TDCRS }
  16883. };
  16884. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16885. {
  16886. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16887. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16888. { "头等舱", new[] { "SUITE", "JSES" } }
  16889. };
  16890. var result = new Dictionary<string, int>();
  16891. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16892. foreach (var flight in flights.Keys)
  16893. {
  16894. // 获取当前舱位的匹配规则
  16895. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16896. {
  16897. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16898. }
  16899. }
  16900. #region right计算
  16901. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16902. {
  16903. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16904. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16905. airHotelPriceList.Add(new
  16906. AirHotelPrice
  16907. {
  16908. Name = "经济舱TBR",
  16909. Price = rightSum + air + hotel,
  16910. Count = result["经济舱TBR"] * 2
  16911. });
  16912. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16913. }
  16914. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16915. {
  16916. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16917. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16918. airHotelPriceList.Add(new
  16919. AirHotelPrice
  16920. {
  16921. Name = "经济舱SGR",
  16922. Price = rightSum + air + hotel,
  16923. Count = result["经济舱SGR"]
  16924. });
  16925. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16926. }
  16927. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16928. {
  16929. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16930. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16931. airHotelPriceList.Add(new
  16932. AirHotelPrice
  16933. {
  16934. Name = "公务舱SGR",
  16935. Price = rightSum + air + hotel,
  16936. Count = result["公务舱SGR"]
  16937. });
  16938. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16939. }
  16940. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16941. {
  16942. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16943. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16944. airHotelPriceList.Add(new
  16945. AirHotelPrice
  16946. {
  16947. Name = "公务舱JSES",
  16948. Price = rightSum + air + hotel,
  16949. Count = result["公务舱JSES"]
  16950. });
  16951. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16952. }
  16953. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16954. {
  16955. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16956. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16957. airHotelPriceList.Add(new
  16958. AirHotelPrice
  16959. {
  16960. Name = "公务舱SUITE",
  16961. Price = rightSum + air + hotel,
  16962. Count = result["公务舱SUITE"]
  16963. });
  16964. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16965. }
  16966. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16967. {
  16968. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16969. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16970. airHotelPriceList.Add(new
  16971. AirHotelPrice
  16972. {
  16973. Name = "经济舱SUITE",
  16974. Price = rightSum + air + hotel,
  16975. Count = result["经济舱SUITE"]
  16976. });
  16977. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16978. }
  16979. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16980. {
  16981. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16982. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16983. airHotelPriceList.Add(new
  16984. AirHotelPrice
  16985. {
  16986. Name = "头等舱JSES",
  16987. Price = rightSum + air + hotel,
  16988. Count = result["头等舱JSES"]
  16989. });
  16990. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16991. }
  16992. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16993. {
  16994. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16995. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16996. airHotelPriceList.Add(new
  16997. AirHotelPrice
  16998. {
  16999. Name = "头等舱SUITE",
  17000. Price = rightSum + air + hotel,
  17001. Count = result["头等舱SUITE"]
  17002. });
  17003. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17004. }
  17005. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17006. {
  17007. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17008. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17009. airHotelPriceList.Add(new
  17010. AirHotelPrice
  17011. {
  17012. Name = "经济舱JSES",
  17013. Price = rightSum + air + hotel,
  17014. Count = result["经济舱JSES"]
  17015. });
  17016. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17017. }
  17018. #endregion
  17019. foreach (var item in airSouer.Keys)
  17020. {
  17021. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  17022. if (find != null && find.Count > 0)
  17023. {
  17024. if (item.Contains("TBR"))
  17025. {
  17026. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17027. }
  17028. else
  17029. {
  17030. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17031. }
  17032. }
  17033. }
  17034. #region 替换Word模板书签内容
  17035. Dictionary<string, string> marks = new Dictionary<string, string>();
  17036. marks.Add("To", di.ClientUnit);//付款方
  17037. marks.Add("ToTel", di.TellPhone);//付款方电话
  17038. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  17039. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  17040. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  17041. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  17042. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  17043. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  17044. marks.Add("PayItemContent", itemStr);//详细信息
  17045. marks.Add("Total", allPrice.ToString("F2"));//合计
  17046. #endregion
  17047. foreach (var item in marks.Keys)
  17048. {
  17049. if (doc.Range.Bookmarks[item] != null)
  17050. {
  17051. Bookmark mark = doc.Range.Bookmarks[item];
  17052. mark.Text = marks[item];
  17053. }
  17054. }
  17055. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  17056. doc.Save(savePaht);
  17057. var jw = new JsonView();
  17058. jw.Msg = "生成成功!";
  17059. jw.Code = 200;
  17060. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  17061. return Ok(jw);
  17062. }
  17063. /// <summary>
  17064. /// 详细报价费用Excel下载
  17065. /// </summary>
  17066. /// <param name="dto"></param>
  17067. /// <returns></returns>
  17068. [HttpPost]
  17069. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  17070. {
  17071. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17072. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17073. if (di == null)
  17074. {
  17075. return Ok(JsonView(false, "团组不存在!"));
  17076. }
  17077. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17078. if (mainPrice == null || mainPrice.IsShare == 0)
  17079. {
  17080. return Ok(JsonView(false, "团组成本不存在!"));
  17081. }
  17082. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17083. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17084. if (costTypeHotelNumbers == null)
  17085. {
  17086. return Ok(JsonView(false, "团组成本不存在!"));
  17087. }
  17088. WorkbookDesigner designer = new WorkbookDesigner();
  17089. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  17090. List<int> hideRowsList = new List<int>();
  17091. int conterStartIndex = 3;
  17092. int rowIndex = conterStartIndex;
  17093. designer.SetDataSource("GroupName", di.TeamName);
  17094. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17095. {
  17096. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17097. ("BXRS", "BXCB", "BXXS", "bx"),
  17098. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17099. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17100. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  17101. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  17102. ("CPRS", "CPCB", "CPXS", "cp") ,
  17103. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  17104. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  17105. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  17106. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  17107. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  17108. ("DJRS", "DJCB", "DJXS", "dj") ,
  17109. ("GWRS", "GWCB", "GWXS", "gw") ,
  17110. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  17111. };
  17112. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17113. var rightSum = 0.00M;
  17114. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17115. {
  17116. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17117. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17118. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17119. if (prefix == "tbr")
  17120. {
  17121. rsValue *= 2;
  17122. cbValue /= 2;
  17123. }
  17124. if (OtherCostPropertyBJ.Contains(prefix))
  17125. {
  17126. rightSum += cbValue * xsValue;
  17127. }
  17128. if (rsValue == 0)
  17129. {
  17130. hideRowsList.Add(rowIndex);
  17131. }
  17132. else
  17133. {
  17134. designer.SetDataSource($"{prefix}rs", rsValue);
  17135. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  17136. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  17137. }
  17138. rowIndex += 2;
  17139. }
  17140. var hotelRooms = new Dictionary<string, int>
  17141. {
  17142. { "SGR", costTypeHotelNumbers.SGR },
  17143. { "TBR", costTypeHotelNumbers.TBR },
  17144. { "JSES", costTypeHotelNumbers.JSES },
  17145. { "SUITE", costTypeHotelNumbers.SUITE }
  17146. };
  17147. var flights = new Dictionary<string, int>
  17148. {
  17149. { "经济舱", mainPrice.JJCRS },
  17150. { "公务舱", mainPrice.GWCRS },
  17151. { "头等舱", mainPrice.TDCRS }
  17152. };
  17153. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17154. {
  17155. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17156. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17157. { "头等舱", new[] { "SUITE", "JSES" } }
  17158. };
  17159. var result = new Dictionary<string, int>();
  17160. foreach (var flight in flights.Keys)
  17161. {
  17162. // 获取当前舱位的匹配规则
  17163. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17164. {
  17165. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17166. }
  17167. }
  17168. var allPrice = 0.00M;
  17169. #region right计算
  17170. int airRowIndex = 35;
  17171. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17172. {
  17173. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17174. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17175. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  17176. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  17177. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  17178. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17179. }
  17180. else
  17181. {
  17182. hideRowsList.Add(airRowIndex);
  17183. }
  17184. airRowIndex += 2;
  17185. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17186. {
  17187. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17188. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17189. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  17190. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  17191. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  17192. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17193. }
  17194. else
  17195. {
  17196. hideRowsList.Add(airRowIndex);
  17197. }
  17198. airRowIndex += 2;
  17199. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17200. {
  17201. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17202. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17203. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  17204. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  17205. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  17206. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17207. }
  17208. else
  17209. {
  17210. hideRowsList.Add(airRowIndex);
  17211. }
  17212. airRowIndex += 2;
  17213. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17214. {
  17215. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17216. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17217. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  17218. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  17219. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  17220. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17221. }
  17222. else
  17223. {
  17224. hideRowsList.Add(airRowIndex);
  17225. }
  17226. airRowIndex += 2;
  17227. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17228. {
  17229. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17230. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17231. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  17232. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  17233. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  17234. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17235. }
  17236. else
  17237. {
  17238. hideRowsList.Add(airRowIndex);
  17239. }
  17240. airRowIndex += 2;
  17241. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17242. {
  17243. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17244. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17245. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  17246. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  17247. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  17248. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17249. }
  17250. else
  17251. {
  17252. hideRowsList.Add(airRowIndex);
  17253. }
  17254. airRowIndex += 2;
  17255. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17256. {
  17257. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17258. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17259. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  17260. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  17261. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  17262. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17263. }
  17264. else
  17265. {
  17266. hideRowsList.Add(airRowIndex);
  17267. }
  17268. airRowIndex += 2;
  17269. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17270. {
  17271. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17272. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17273. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  17274. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  17275. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  17276. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17277. }
  17278. else
  17279. {
  17280. hideRowsList.Add(airRowIndex);
  17281. }
  17282. airRowIndex += 2;
  17283. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17284. {
  17285. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17286. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17287. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  17288. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  17289. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  17290. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17291. }
  17292. else
  17293. {
  17294. hideRowsList.Add(airRowIndex);
  17295. }
  17296. #endregion
  17297. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  17298. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  17299. var ws = designer.Workbook.Worksheets[0];
  17300. foreach (var Rowindex in hideRowsList)
  17301. {
  17302. ws.Cells.HideRows(Rowindex, 2);
  17303. }
  17304. designer.Process();
  17305. designer.Workbook.Save(savePaht);
  17306. return Ok(JsonView(true, "生成成功!", new
  17307. {
  17308. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  17309. }));
  17310. }
  17311. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  17312. {
  17313. foreach (var roomType in roomTypes)
  17314. {
  17315. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  17316. {
  17317. hotelRooms[roomType]--;
  17318. flights[flightType]--;
  17319. if (roomType == "TBR")
  17320. {
  17321. flights[flightType]--; // 双人间在减少1
  17322. }
  17323. string key = flightType + roomType;
  17324. if (result.Keys.Contains(key))
  17325. {
  17326. result[key]++;
  17327. }
  17328. else
  17329. {
  17330. result.Add(key, 1);
  17331. }
  17332. }
  17333. }
  17334. }
  17335. private class AirHotelPrice
  17336. {
  17337. public string Name { get; set; }
  17338. public decimal Price { get; set; }
  17339. public int Count { get; set; }
  17340. }
  17341. /// <summary>
  17342. /// 团组系数设置
  17343. /// </summary>
  17344. /// <param name="dto"></param>
  17345. /// <returns></returns>
  17346. [HttpPost]
  17347. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  17348. {
  17349. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17350. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17351. if (di == null)
  17352. {
  17353. return Ok(JsonView(false, "团组不存在!"));
  17354. }
  17355. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  17356. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  17357. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  17358. // FirstAsync(firstExpression.ToExpression());
  17359. #region JSON
  17360. string hcpJson = @"
  17361. [
  17362. {
  17363. ""min"": 1,
  17364. ""max"": 500,
  17365. ""value"": 1.50
  17366. },
  17367. {
  17368. ""min"": 501,
  17369. ""max"": 1000,
  17370. ""value"": 1.40
  17371. },
  17372. {
  17373. ""min"": 1001,
  17374. ""max"": 2000,
  17375. ""value"": 1.35
  17376. }
  17377. ]";
  17378. #endregion
  17379. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  17380. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  17381. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  17382. .ToList();
  17383. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  17384. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  17385. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  17386. // new List<(Predicate<decimal>, decimal)>()
  17387. // {
  17388. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  17389. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  17390. // }
  17391. // ));
  17392. #region 签证系数
  17393. var visaXS = 0.00M;
  17394. switch (dto.VisaCB)
  17395. {
  17396. case decimal n when (n > 1 && n < 500):
  17397. switch (dto.VisaRS)
  17398. {
  17399. case 2 or 3:
  17400. visaXS = 1.35M;
  17401. break;
  17402. case 4 or 5:
  17403. visaXS = 1.30M;
  17404. break;
  17405. case 6 or 7:
  17406. visaXS = 1.25M;
  17407. break;
  17408. case 8 or 9 or 10:
  17409. visaXS = 1.20M;
  17410. break;
  17411. case > 10:
  17412. visaXS = 1.15M;
  17413. break;
  17414. default:
  17415. visaXS = 0.00M;
  17416. break;
  17417. }
  17418. break;
  17419. case decimal n when (n >= 500 && n < 1000):
  17420. switch (dto.VisaRS)
  17421. {
  17422. case 2 or 3 or 4:
  17423. visaXS = 1.30M;
  17424. break;
  17425. case 5 or 6 or 7 or 8:
  17426. visaXS = 1.25M;
  17427. break;
  17428. case 9 or 10:
  17429. visaXS = 1.20M;
  17430. break;
  17431. case > 10:
  17432. visaXS = 1.15M;
  17433. break;
  17434. default:
  17435. visaXS = 0.00M;
  17436. break;
  17437. }
  17438. break;
  17439. default:
  17440. switch (dto.VisaRS)
  17441. {
  17442. case 2 or 3 or 4:
  17443. visaXS = 1.30M;
  17444. break;
  17445. case 5 or 6 or 7 or 8:
  17446. visaXS = 1.25M;
  17447. break;
  17448. case 9 or 10:
  17449. visaXS = 1.20M;
  17450. break;
  17451. case > 10:
  17452. visaXS = 1.15M;
  17453. break;
  17454. default:
  17455. visaXS = 0.00M;
  17456. break;
  17457. }
  17458. break;
  17459. }
  17460. #endregion
  17461. #region 火车系数
  17462. var hcpXS = 0.00M;
  17463. foreach (var (condition, result) in hcpSwitchDictionary)
  17464. {
  17465. if (condition(dto.HCPCB))
  17466. {
  17467. hcpXS = result;
  17468. break;
  17469. }
  17470. }
  17471. #endregion
  17472. #region 机票系数
  17473. #region 经济舱系数
  17474. var jjcXS = 0.00M;
  17475. switch (dto.JJCCB)
  17476. {
  17477. case decimal x when (x >= 1000 && x <= 3000):
  17478. jjcXS = 2.6M;
  17479. break;
  17480. case decimal x when (x >= 3001 && x <= 8000):
  17481. jjcXS = 2.3M;
  17482. break;
  17483. case decimal x when (x >= 8001 && x <= 15000):
  17484. jjcXS = 2.1M;
  17485. break;
  17486. case decimal x when (x >= 15001 && x <= 30000):
  17487. jjcXS = 1.95M;
  17488. break;
  17489. case > 30000:
  17490. jjcXS = 1.8M;
  17491. break;
  17492. default:
  17493. break;
  17494. }
  17495. #endregion
  17496. #region 公务舱系数
  17497. var gwcXS = 0.00M;
  17498. switch (dto.GWCCB)
  17499. {
  17500. case decimal x when (x >= 1000 && x <= 3000):
  17501. gwcXS = 2.5M;
  17502. break;
  17503. case decimal x when (x >= 3001 && x <= 8000):
  17504. gwcXS = 2.2M;
  17505. break;
  17506. case decimal x when (x >= 8001 && x <= 15000):
  17507. gwcXS = 2.0M;
  17508. break;
  17509. case decimal x when (x >= 15001 && x <= 30000):
  17510. gwcXS = 1.85M;
  17511. break;
  17512. case > 30000:
  17513. gwcXS = 1.7M;
  17514. break;
  17515. default:
  17516. break;
  17517. }
  17518. #endregion
  17519. #region 头等舱系数
  17520. var tdcXS = 0.00M;
  17521. switch (dto.TDCCB)
  17522. {
  17523. case > 70000:
  17524. tdcXS = 1.5M;
  17525. break;
  17526. default:
  17527. tdcXS = 1.9M;
  17528. break;
  17529. }
  17530. #endregion
  17531. #endregion
  17532. #region 酒店系数
  17533. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  17534. {
  17535. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  17536. {1.5M, new List<string>(){"越南社会主义共和国",
  17537. "老挝",
  17538. "柬埔寨",
  17539. "泰国",
  17540. "缅甸",
  17541. "马来西亚",
  17542. //"新加坡",
  17543. "文莱达鲁萨兰",
  17544. "印度尼西亚",
  17545. "东帝汶"}},
  17546. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  17547. };
  17548. #region SGR
  17549. var sgrXS = 1.25M;
  17550. #endregion
  17551. #region TBR
  17552. var tbrXS = 1.25M;
  17553. #endregion
  17554. #region JSES
  17555. var jsesXS = 1.25M;
  17556. #endregion
  17557. #region SUITE
  17558. var suiteXS = 1.25M;
  17559. #endregion
  17560. var countryArr = di.VisitCountry.Split("|");
  17561. foreach (var item in dic)
  17562. {
  17563. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  17564. .Count();
  17565. if (extsisCount > 0)
  17566. {
  17567. jsesXS = item.Key;
  17568. sgrXS = item.Key;
  17569. tbrXS = item.Key;
  17570. suiteXS = item.Key;
  17571. }
  17572. }
  17573. #endregion
  17574. #region 地接系数
  17575. var djXS = 0.00M;
  17576. switch (dto.DJRS)
  17577. {
  17578. case 2 or 3:
  17579. djXS = 2.65M;
  17580. break;
  17581. case 4:
  17582. djXS = 2.6M;
  17583. break;
  17584. case 5 or 6:
  17585. djXS = 2.5M;
  17586. break;
  17587. case 7 or 8:
  17588. djXS = 2.4M;
  17589. break;
  17590. case 9 or 10:
  17591. djXS = 2.3M;
  17592. break;
  17593. case 11:
  17594. djXS = 2.2M;
  17595. break;
  17596. case 12:
  17597. djXS = 2.1M;
  17598. break;
  17599. case 13 or 14:
  17600. djXS = 2M;
  17601. break;
  17602. case 15:
  17603. djXS = 1.9M;
  17604. break;
  17605. case 16 or 17 or 18:
  17606. djXS = 1.8M;
  17607. break;
  17608. case 19 or 20:
  17609. djXS = 1.7M;
  17610. break;
  17611. }
  17612. #endregion
  17613. #region 零用金系数
  17614. var lyjXS = 0.00M;
  17615. switch (dto.LYJRS)
  17616. {
  17617. case 2:
  17618. lyjXS = 1.25M;
  17619. break;
  17620. case 3 or 4 or 5:
  17621. lyjXS = 1.2M;
  17622. break;
  17623. case int number when (number > 5 && number < 10):
  17624. lyjXS = 1.15M;
  17625. break;
  17626. case > 10:
  17627. lyjXS = 1.1M;
  17628. break;
  17629. default:
  17630. break;
  17631. }
  17632. #endregion
  17633. return Ok(JsonView(true, "查询成功", new ArrayList()
  17634. {
  17635. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  17636. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  17637. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  17638. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  17639. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  17640. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  17641. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  17642. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  17643. new { label = "地接系数", value = djXS, key = "djXS" },
  17644. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  17645. new { label = "公务系数", value = 2M, key = "gwXS" }
  17646. }));
  17647. }
  17648. #endregion
  17649. #region 酒店预订 New 2023-12-28 17:45
  17650. /// <summary>
  17651. /// 酒店预订
  17652. /// 酒店费用列表 根据团组Id查询
  17653. /// </summary>
  17654. /// <param name="_dto"></param>
  17655. /// <returns></returns>
  17656. [HttpPost]
  17657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17658. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  17659. {
  17660. #region 参数验证
  17661. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17662. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17663. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17664. #region 团组操作权限验证 76 酒店预定模块
  17665. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17666. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17667. #endregion
  17668. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17669. #region 页面操作权限验证
  17670. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17671. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17672. #endregion
  17673. #endregion
  17674. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  17675. }
  17676. /// <summary>
  17677. /// 酒店预订
  17678. /// 基础数据
  17679. /// </summary>
  17680. /// <param name="_dto"></param>
  17681. /// <returns></returns>
  17682. [HttpPost]
  17683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17684. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  17685. {
  17686. #region 参数验证
  17687. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17688. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17689. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17690. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17691. #region 页面操作权限验证
  17692. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17693. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17694. #endregion
  17695. #region 团组操作权限验证 76 酒店预定模块
  17696. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17697. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17698. #endregion
  17699. #endregion
  17700. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  17701. }
  17702. /// <summary>
  17703. /// 酒店预订
  17704. /// 创建 入住卷号码
  17705. /// </summary>
  17706. /// <param name="_dto"></param>
  17707. /// <returns></returns>
  17708. [HttpPost]
  17709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17710. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  17711. {
  17712. #region 参数验证
  17713. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17714. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17715. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17716. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17717. #region 页面操作权限验证
  17718. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17719. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17720. #endregion
  17721. #region 团组操作权限验证 76 酒店预定模块
  17722. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17723. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17724. #endregion
  17725. #endregion
  17726. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  17727. if (data.Code != 0)
  17728. {
  17729. return Ok(JsonView(false, data.Msg));
  17730. }
  17731. return Ok(JsonView(true, data.Msg, data.Data));
  17732. }
  17733. /// <summary>
  17734. /// 酒店预订
  17735. /// 详情
  17736. /// </summary>
  17737. /// <param name="_dto"></param>
  17738. /// <returns></returns>
  17739. [HttpPost]
  17740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17741. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  17742. {
  17743. #region 参数验证
  17744. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  17745. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17746. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  17747. #region 团组操作权限验证 76 酒店预定模块
  17748. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17749. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17750. #endregion
  17751. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17752. #region 页面操作权限验证
  17753. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17754. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17755. #endregion
  17756. #endregion
  17757. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  17758. }
  17759. /// <summary>
  17760. /// 酒店预订
  17761. /// Add Or Edit
  17762. /// </summary>
  17763. /// <param name="_dto"></param>
  17764. /// <returns></returns>
  17765. [HttpPost]
  17766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17767. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  17768. {
  17769. #region 参数验证
  17770. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17771. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17772. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17773. #region 团组操作权限验证 76 酒店预定模块
  17774. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17775. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17776. #endregion
  17777. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17778. #region 页面操作权限验证
  17779. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17780. if (_dto.Id == 0) // Add
  17781. {
  17782. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17783. }
  17784. else if (_dto.Id > 1) // Edit
  17785. {
  17786. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17787. }
  17788. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  17789. #endregion
  17790. #endregion
  17791. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  17792. if (_view.Code != 200)
  17793. {
  17794. return Ok(_view);
  17795. }
  17796. #region 成本无酒店价格数据进入超支
  17797. _sqlSugar.BeginTran();
  17798. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  17799. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  17800. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  17801. for (int i = 0; i < groupCost.Count; i++)
  17802. {
  17803. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  17804. {
  17805. groupCost[i].Date = groupCost[i - 1].Date;
  17806. }
  17807. }
  17808. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  17809. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  17810. List<Fin_GroupExtraCostDto_OP>();
  17811. if (start_Bool && end_Bool)
  17812. {
  17813. while (start_Time < end_Time)
  17814. {
  17815. foreach (var item in groupCost_Grp)
  17816. {
  17817. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  17818. {
  17819. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  17820. {
  17821. extraCostList.Add(new
  17822. Fin_GroupExtraCostDto_OP
  17823. {
  17824. Area = _dto.AreaId,
  17825. coefficient = 1.5M,
  17826. createUser = _dto.UserId,
  17827. currency = _dto.CardPriceCurrency,
  17828. diId = _dto.DiId,
  17829. ManagerConfirm = 0,
  17830. SupervisorConfirm = 0,
  17831. SYsupervisorConfirm = 0,
  17832. editType = 1,
  17833. PortType = 1,
  17834. price = _dto.CardPrice,
  17835. PriceCount = 1,
  17836. priceType = 1027,
  17837. priceDetailType = 1044,
  17838. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  17839. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  17840. });
  17841. }
  17842. }
  17843. }
  17844. start_Time = start_Time.AddDays(1);
  17845. }
  17846. }
  17847. if (extraCostList.Any())
  17848. {
  17849. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  17850. }
  17851. _sqlSugar.CommitTran();
  17852. #endregion
  17853. #region 应用推送
  17854. try
  17855. {
  17856. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17857. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17858. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17859. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17860. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17861. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17862. var diId = _dto.DiId;
  17863. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17864. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17865. #region 操作记录
  17866. var opInfo = new Crm_TableOperationRecord()
  17867. {
  17868. TableName = "Grp_HotelReservations",
  17869. PortType = _dto.PortType,
  17870. DataId = hotelId,
  17871. CreateUserId = _dto.UserId
  17872. };
  17873. //var opStatus = OperationEnum.NoOperation;
  17874. if (_dto.Id < 1) //添加操作
  17875. {
  17876. opInfo.OperationItem = OperationEnum.Add;
  17877. }
  17878. else if (_dto.Id > 0)
  17879. {
  17880. opInfo.OperationItem = OperationEnum.Edit;
  17881. }
  17882. string opRemark = string.Empty;
  17883. if (ccpInfo != null)
  17884. {
  17885. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  17886. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  17887. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  17888. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  17889. }
  17890. opInfo.Remark = opRemark;
  17891. await _tableorRep.AddAsync(opInfo);
  17892. #endregion
  17893. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  17894. //2024-10-21 新增LZ UID
  17895. var userIds = new List<int>() { 21 };
  17896. string title = $"费用审核";
  17897. string content = "";
  17898. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17899. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17900. try
  17901. {
  17902. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  17903. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  17904. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  17905. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  17906. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  17907. }
  17908. catch (Exception ex)
  17909. {
  17910. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  17911. }
  17912. }
  17913. catch (Exception ex)
  17914. {
  17915. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  17916. }
  17917. try
  17918. {
  17919. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17920. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17921. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17922. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17923. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17924. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17925. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17926. //自动审核
  17927. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  17928. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  17929. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  17930. //2024-10-21 新增LZ UID
  17931. var userIds = new List<int>() { 21 };
  17932. string title = $"系统通知";
  17933. var diId = _dto.DiId;
  17934. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17935. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17936. string content = "";
  17937. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17938. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17939. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17940. }
  17941. catch (Exception ex)
  17942. {
  17943. }
  17944. #endregion
  17945. return Ok(_view);
  17946. }
  17947. /// <summary>
  17948. /// 酒店自动审核测试
  17949. /// Add Or Edit
  17950. /// </summary>
  17951. /// <param name="diid"></param>
  17952. /// <param name="dataId"></param>
  17953. /// <returns></returns>
  17954. [HttpPost]
  17955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17956. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  17957. {
  17958. #region 应用推送
  17959. try
  17960. {
  17961. //自动审核
  17962. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  17963. }
  17964. catch (Exception ex)
  17965. {
  17966. return Ok(JsonView(false, ex.Message));
  17967. }
  17968. #endregion
  17969. return Ok(JsonView(false, "操作成功"));
  17970. }
  17971. /// <summary>
  17972. /// 酒店预订
  17973. /// Del
  17974. /// </summary>
  17975. /// <param name="_dto"></param>
  17976. /// <returns></returns>
  17977. [HttpPost]
  17978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17979. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  17980. {
  17981. #region 参数验证
  17982. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17983. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17984. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17985. #region 团组操作权限验证 76 酒店预定模块
  17986. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17987. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17988. #endregion
  17989. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17990. #region 页面操作权限验证
  17991. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17992. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17993. #endregion
  17994. #endregion
  17995. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  17996. #region 操作记录
  17997. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  17998. {
  17999. TableName = "Grp_HotelReservations",
  18000. PortType = _dto.PortType,
  18001. OperationItem = OperationEnum.Del,
  18002. DataId = _dto.Id,
  18003. CreateUserId = _dto.UserId
  18004. });
  18005. #endregion
  18006. return Ok(data);
  18007. }
  18008. /// <summary>
  18009. /// 酒店预订
  18010. /// 生成VOUCHER
  18011. /// 2024.05.06 之前版本
  18012. /// </summary>
  18013. /// <param name="_dto"></param>
  18014. /// <returns></returns>
  18015. [HttpPost]
  18016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18017. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  18018. {
  18019. try
  18020. {
  18021. #region 参数验证
  18022. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18023. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18024. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18025. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  18026. #region 团组操作权限验证 76 酒店预定模块
  18027. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18028. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18029. #endregion
  18030. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18031. #region 页面操作权限验证
  18032. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18033. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18034. #endregion
  18035. #endregion
  18036. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  18037. //判断数据是否完整
  18038. if (hr != null)
  18039. {
  18040. if (!string.IsNullOrEmpty(hr.DetermineNo))
  18041. {
  18042. string strFileName = "HotelStatement/";
  18043. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18044. if (dele != null)
  18045. strFileName += dele.TourCode;
  18046. //载入模板
  18047. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  18048. Document doc = new Document(sss);
  18049. DocumentBuilder builder = new DocumentBuilder(doc);
  18050. #region 替换Word模板书签内容
  18051. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  18052. //入住卷预定号码
  18053. if (doc.Range.Bookmarks["VNO"] != null)
  18054. {
  18055. Bookmark mark = doc.Range.Bookmarks["VNO"];
  18056. mark.Text = hr.CheckNumber;
  18057. }
  18058. //酒店时间
  18059. if (doc.Range.Bookmarks["Date"] != null)
  18060. {
  18061. Bookmark mark = doc.Range.Bookmarks["Date"];
  18062. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18063. }
  18064. //团号
  18065. if (doc.Range.Bookmarks["TNo"] != null)
  18066. {
  18067. Bookmark mark = doc.Range.Bookmarks["TNo"];
  18068. mark.Text = dele.TourCode;
  18069. }
  18070. //预定号码
  18071. if (doc.Range.Bookmarks["BookingId"] != null)
  18072. {
  18073. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  18074. mark.Text = hr.ReservationsNo;
  18075. }
  18076. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  18077. {
  18078. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  18079. mark.Text = hr.DetermineNo;
  18080. }
  18081. //酒店城市
  18082. if (doc.Range.Bookmarks["City"] != null)
  18083. {
  18084. Bookmark mark = doc.Range.Bookmarks["City"];
  18085. mark.Text = hr.City;
  18086. }
  18087. //酒店名称
  18088. if (doc.Range.Bookmarks["HName"] != null)
  18089. {
  18090. Bookmark mark = doc.Range.Bookmarks["HName"];
  18091. mark.Text = hr.HotelName;
  18092. }
  18093. //酒店地址
  18094. if (doc.Range.Bookmarks["Address"] != null)
  18095. {
  18096. Bookmark mark = doc.Range.Bookmarks["Address"];
  18097. mark.Text = hr.HotelAddress;
  18098. }
  18099. //酒店电话
  18100. if (doc.Range.Bookmarks["Tel"] != null)
  18101. {
  18102. Bookmark mark = doc.Range.Bookmarks["Tel"];
  18103. mark.Text = hr.HotelTel;
  18104. }
  18105. //酒店传真
  18106. if (doc.Range.Bookmarks["Fax"] != null)
  18107. {
  18108. Bookmark mark = doc.Range.Bookmarks["Fax"];
  18109. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  18110. {
  18111. mark.Text = hr.HotelFax;
  18112. }
  18113. }
  18114. //入住时间
  18115. if (doc.Range.Bookmarks["CIn"] != null)
  18116. {
  18117. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18118. Bookmark mark = doc.Range.Bookmarks["CIn"];
  18119. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  18120. }
  18121. //退房时间
  18122. if (doc.Range.Bookmarks["COut"] != null)
  18123. {
  18124. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18125. Bookmark mark = doc.Range.Bookmarks["COut"];
  18126. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18127. }
  18128. //客户名称
  18129. if (doc.Range.Bookmarks["GName"] != null)
  18130. {
  18131. string guestName = "";
  18132. string[] clients = Array.Empty<string>();
  18133. if (hr.GuestName.Contains(","))
  18134. {
  18135. clients = hr.GuestName.Split(",");
  18136. }
  18137. else
  18138. {
  18139. clients = new string[] { hr.GuestName };
  18140. }
  18141. List<int> clientIds_int = new List<int>();
  18142. if (clients.Length > 0)
  18143. {
  18144. foreach (var item in clients)
  18145. {
  18146. if (item.IsNumeric())
  18147. {
  18148. clientIds_int.Add(int.Parse(item));
  18149. }
  18150. }
  18151. }
  18152. if (clientIds_int.Count > 0)
  18153. {
  18154. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  18155. foreach (var client in _clientDatas)
  18156. {
  18157. //男
  18158. if (client.Sex == 0) guestName += $"Mr.";
  18159. //女
  18160. else if (client.Sex == 1) guestName += $"Ms.";
  18161. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  18162. {
  18163. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  18164. }
  18165. //guestName += $"{client.Pinyin},";
  18166. }
  18167. if (guestName.Length > 0)
  18168. {
  18169. guestName = guestName.Substring(0, guestName.Length - 1);
  18170. }
  18171. }
  18172. else
  18173. {
  18174. guestName = hr.GuestName;
  18175. }
  18176. Bookmark mark = doc.Range.Bookmarks["GName"];
  18177. mark.Text = guestName;
  18178. }
  18179. //房间介绍
  18180. if (doc.Range.Bookmarks["ROOM"] != null)
  18181. {
  18182. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  18183. mark.Text = hr.RoomExplanation;
  18184. }
  18185. //报价描述
  18186. if (doc.Range.Bookmarks["NOTE"] != null)
  18187. {
  18188. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  18189. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  18190. if (ss != null)
  18191. mark.Text = ss.Name;
  18192. }
  18193. //入住时间
  18194. if (doc.Range.Bookmarks["CheckIn"] != null)
  18195. {
  18196. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18197. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  18198. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18199. }
  18200. //退房时间
  18201. if (doc.Range.Bookmarks["CheckOut"] != null)
  18202. {
  18203. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18204. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  18205. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18206. }
  18207. //日期
  18208. if (doc.Range.Bookmarks["DT"] != null)
  18209. {
  18210. Bookmark mark = doc.Range.Bookmarks["DT"];
  18211. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18212. }
  18213. //名称
  18214. if (doc.Range.Bookmarks["VName"] != null)
  18215. {
  18216. Bookmark mark = doc.Range.Bookmarks["VName"];
  18217. mark.Text = hr.HotelName;
  18218. }
  18219. //号码
  18220. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  18221. {
  18222. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  18223. mark.Text = hr.CheckNumber;
  18224. }
  18225. #endregion
  18226. strFileName += "VOUCHER.doc";
  18227. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18228. doc.Save(fileDir);
  18229. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18230. return Ok(JsonView(true, "操作成功!", Url));
  18231. }
  18232. else
  18233. {
  18234. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  18235. }
  18236. }
  18237. else
  18238. {
  18239. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  18240. }
  18241. }
  18242. catch (Exception ex)
  18243. {
  18244. return Ok(JsonView(false, ex.Message));
  18245. }
  18246. }
  18247. /// <summary>
  18248. /// 酒店预订
  18249. /// 生成VOUCHER
  18250. /// 2024.05.06 之后版本
  18251. /// </summary>
  18252. /// <param name="_dto"></param>
  18253. /// <returns></returns>
  18254. [HttpPost]
  18255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18256. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  18257. {
  18258. #region 参数验证
  18259. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18260. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18261. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18262. #region 团组操作权限验证 76 酒店预定模块
  18263. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18264. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18265. #endregion
  18266. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18267. #region 页面操作权限验证
  18268. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18269. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18270. #endregion
  18271. #endregion
  18272. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  18273. //判断数据是否完整
  18274. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18275. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18276. string strFileName = "HotelStatement/";
  18277. string guestNames = ""; //格式Mr.xxx Ms.xxx
  18278. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  18279. #region 数据处理
  18280. List<int> guestIds = new List<int>();
  18281. //int index = 0;
  18282. foreach (var item in hrDtas)
  18283. {
  18284. if (item.GuestName.Contains(","))
  18285. {
  18286. string[] guestIdArr = item.GuestName.Split(',');
  18287. foreach (var guestIdStr in guestIdArr)
  18288. {
  18289. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  18290. if (guestBool)
  18291. {
  18292. guestIds.Add(guestId);
  18293. }
  18294. }
  18295. }
  18296. else guestNames += item.GuestName;
  18297. var voucherInfo = new HotelVoucherInfoView()
  18298. {
  18299. HotelName = item.HotelName,
  18300. CheckInDate = item.CheckInDate,
  18301. CheckOutDate = item.CheckOutDate,
  18302. ConfirmationNumber = item.DetermineNo.Trim(),
  18303. RoomType = item.RoomExplanation
  18304. };
  18305. vouchers.Add(voucherInfo);
  18306. }
  18307. if (guestIds.Count > 0)
  18308. {
  18309. guestIds = guestIds.Distinct().ToList();
  18310. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  18311. if (guestDatas.Count > 0)
  18312. {
  18313. guestNames = "";
  18314. foreach (var guest in guestDatas)
  18315. {
  18316. string guestName = "";
  18317. if (guest.Sex == 0) guestName += @"MR.";
  18318. else if (guest.Sex == 1) guestName += @"MS.";
  18319. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18320. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18321. guestNames += @$"{guestName.Trim()}、";
  18322. }
  18323. if (guestNames.Length > 0)
  18324. {
  18325. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18326. }
  18327. }
  18328. }
  18329. #endregion
  18330. //载入模板
  18331. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  18332. Document doc = new Document(sss);
  18333. DocumentBuilder builder = new DocumentBuilder(doc);
  18334. if (doc.Range.Bookmarks["GuestName"] != null)
  18335. {
  18336. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  18337. mark.Text = guestNames;
  18338. }
  18339. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18340. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  18341. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  18342. for (int i = 1; i <= vouchers.Count; i++)
  18343. {
  18344. HotelVoucherInfoView hviv = vouchers[i - 1];
  18345. builder.MoveToCell(0, i, 0, 0);
  18346. builder.Write(hviv.HotelName);
  18347. builder.MoveToCell(0, i, 1, 0);
  18348. builder.Write(hviv.CheckInDate);
  18349. builder.MoveToCell(0, i, 2, 0);
  18350. builder.Write(hviv.CheckOutDate);
  18351. builder.MoveToCell(0, i, 3, 0);
  18352. builder.Write(hviv.RoomType);
  18353. builder.MoveToCell(0, i, 4, 0);
  18354. builder.Write(hviv.ConfirmationNumber);
  18355. }
  18356. //删除多余行
  18357. int currRowIndex = vouchers.Count + 1;
  18358. int delRows = 21 - currRowIndex;
  18359. if (delRows > 0)
  18360. {
  18361. for (int i = 0; i < delRows; i++)
  18362. {
  18363. table.Rows.RemoveAt(currRowIndex);
  18364. //cultivateRowIndex++;
  18365. }
  18366. }
  18367. strFileName += "VOUCHER.docx";
  18368. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18369. doc.Save(fileDir);
  18370. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18371. return Ok(JsonView(true, "操作成功!", Url));
  18372. }
  18373. /// <summary>
  18374. /// 酒店预订
  18375. /// 生成VOUCHER 批量生成
  18376. /// New
  18377. /// </summary>
  18378. /// <param name="_dto"></param>
  18379. /// <returns></returns>
  18380. [HttpPost]
  18381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18382. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  18383. {
  18384. #region 参数验证
  18385. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18386. if (_dto.PageId < 1) _dto.PageId = 28;
  18387. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18388. #region 团组操作权限验证 76 酒店预定模块
  18389. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18390. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18391. #endregion
  18392. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18393. #region 页面操作权限验证
  18394. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18395. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18396. #endregion
  18397. #endregion
  18398. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  18399. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  18400. .OrderBy(x => x.CheckInDate)
  18401. .ToListAsync();
  18402. //判断数据是否完整
  18403. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18404. string strFileName = "HotelStatement/";
  18405. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18406. if (dele != null)
  18407. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  18408. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  18409. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  18410. .Where(it => it.IsDel == 0)
  18411. .ToListAsync();
  18412. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  18413. for (int i = 0; i < hrDtas.Count; i++)
  18414. {
  18415. string guestNames = string.Empty;
  18416. List<int> guestIds = new List<int>();
  18417. var item = hrDtas[i];
  18418. //处理客户姓名
  18419. if (item.GuestName.Contains(","))
  18420. {
  18421. string[] guestIdArr = item.GuestName.Split(',');
  18422. foreach (var guestIdStr in guestIdArr)
  18423. if (int.TryParse(guestIdStr, out int guestId))
  18424. guestIds.Add(guestId);
  18425. }
  18426. else
  18427. {
  18428. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  18429. if (guestIdBool)
  18430. {
  18431. guestIds.Add(guestId);
  18432. }
  18433. //NaN
  18434. if (item.GuestName.Contains("NaN"))
  18435. {
  18436. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  18437. }
  18438. }
  18439. if (guestIds.Count > 0)
  18440. {
  18441. guestIds = guestIds.Distinct().ToList();
  18442. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  18443. if (guestDatas1.Count > 0)
  18444. {
  18445. guestNames = "";
  18446. foreach (var guest in guestDatas1)
  18447. {
  18448. string guestName = "";
  18449. if (guest.Sex == 0) guestName += @"MR.";
  18450. else if (guest.Sex == 1) guestName += @"MS.";
  18451. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18452. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18453. guestNames += @$"{guestName.Trim()}、";
  18454. }
  18455. if (guestNames.Length > 0)
  18456. {
  18457. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18458. }
  18459. }
  18460. }
  18461. //if (!string.IsNullOrEmpty(guestNames))
  18462. //{
  18463. hrDtas[i].GuestName = guestNames;
  18464. //}
  18465. }
  18466. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  18467. Document doc = new Document();
  18468. DocumentBuilder builder = new DocumentBuilder(doc);
  18469. try
  18470. {
  18471. builder.MoveToDocumentStart();
  18472. foreach (var item in hrDtas)
  18473. {
  18474. //标题
  18475. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18476. builder.ParagraphFormat.LineSpacing = 1;
  18477. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18478. builder.ParagraphFormat.Style.Font.Size = 9;
  18479. builder.ParagraphFormat.Style.Font.Bold = true;
  18480. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18481. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  18482. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18483. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18484. builder.ParagraphFormat.LineSpacing = 1;
  18485. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18486. builder.ParagraphFormat.Style.Font.Size = 9;
  18487. builder.ParagraphFormat.Style.Font.Bold = true;
  18488. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  18489. builder.StartTable();
  18490. // 设置边框颜色
  18491. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  18492. //设置边框样式
  18493. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  18494. //表格
  18495. #region 第一行
  18496. builder.InsertCell();
  18497. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18498. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18499. //builder.CellFormat.AllowAutoFit = false;
  18500. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18501. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18502. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18503. builder.CellFormat.WrapText = true; //自动换行
  18504. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18505. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  18506. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18507. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18508. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18509. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18510. builder.Write("TOUR NO:");
  18511. builder.InsertCell();
  18512. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18513. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18514. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18515. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18516. builder.ParagraphFormat.Style.Font.Bold = false;
  18517. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18518. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18519. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18520. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18521. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18522. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18523. builder.Write($"{dele?.TourCode ?? "-"}");
  18524. builder.InsertCell();
  18525. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18526. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18527. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18528. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18529. builder.ParagraphFormat.Style.Font.Bold = false;
  18530. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18531. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18532. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18533. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18534. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18535. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18536. builder.Write($"CITY:");
  18537. builder.InsertCell();
  18538. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18539. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18540. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18541. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18542. builder.ParagraphFormat.Style.Font.Bold = false;
  18543. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18544. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18545. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18546. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18547. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18548. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18549. builder.Write($"{item.City}");
  18550. builder.EndRow();
  18551. #endregion
  18552. #region 第二行
  18553. builder.InsertCell();
  18554. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18555. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18556. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18557. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18558. builder.ParagraphFormat.Style.Font.Bold = false;
  18559. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18560. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18561. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18562. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18563. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18564. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18565. builder.Write("CONFIRMATION NO:");
  18566. builder.InsertCell();
  18567. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18568. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18569. builder.ParagraphFormat.Style.Font.Size = 8;
  18570. builder.ParagraphFormat.Style.Font.Bold = false;
  18571. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18572. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18573. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18574. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18575. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18576. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18577. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18578. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18579. builder.Write($"{item.DetermineNo}");
  18580. builder.InsertCell();
  18581. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18582. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18583. builder.InsertCell();
  18584. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18585. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18586. builder.EndRow();
  18587. #endregion
  18588. #region 第三行
  18589. builder.InsertCell();
  18590. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18591. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18592. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18593. builder.ParagraphFormat.Style.Font.Bold = false;
  18594. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18595. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18596. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18597. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18598. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18599. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18600. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18601. builder.Write($"HOTEL NAME:");
  18602. builder.InsertCell();
  18603. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18604. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18605. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18606. builder.ParagraphFormat.Style.Font.Bold = false;
  18607. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18608. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18609. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18610. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18611. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18612. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18613. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18614. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18615. builder.Write($"{item.HotelName}");
  18616. builder.InsertCell();
  18617. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18618. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18619. builder.InsertCell();
  18620. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18621. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18622. builder.EndRow();
  18623. #endregion
  18624. #region 第四行
  18625. builder.InsertCell();
  18626. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18627. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18628. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18629. builder.ParagraphFormat.Style.Font.Bold = false;
  18630. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18631. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18632. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18633. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18634. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18635. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18636. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18637. builder.Write($"HOTEL ADDRESS:");
  18638. builder.InsertCell();
  18639. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18640. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18641. builder.ParagraphFormat.Style.Font.Size = 8;
  18642. builder.ParagraphFormat.Style.Font.Bold = false;
  18643. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18644. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18645. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18646. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18647. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18648. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18649. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18650. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18651. builder.Write($"{item.HotelAddress}");
  18652. builder.InsertCell();
  18653. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18654. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18655. builder.InsertCell();
  18656. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18657. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18658. builder.EndRow();
  18659. #endregion
  18660. #region 第五行
  18661. builder.InsertCell();
  18662. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18663. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18664. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18665. builder.ParagraphFormat.Style.Font.Bold = false;
  18666. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18667. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18668. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18669. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18670. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18671. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18672. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18673. builder.Write("TEL:");
  18674. builder.InsertCell();
  18675. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18676. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18677. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18678. builder.ParagraphFormat.Style.Font.Bold = false;
  18679. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18680. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18681. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18682. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18683. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18684. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18685. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18686. builder.Write($"{item.HotelTel}");
  18687. builder.InsertCell();
  18688. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18689. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18690. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18691. builder.ParagraphFormat.Style.Font.Bold = false;
  18692. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18693. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18694. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18695. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18696. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18697. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18698. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18699. builder.Write($"FAX:");
  18700. builder.InsertCell();
  18701. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18702. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18703. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18704. builder.ParagraphFormat.Style.Font.Bold = false;
  18705. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18706. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18707. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18708. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18709. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18710. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18711. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18712. builder.Write($"{item.HotelFax}");
  18713. builder.EndRow();
  18714. #endregion
  18715. #region 第六行
  18716. builder.InsertCell();
  18717. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18718. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18719. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18720. builder.ParagraphFormat.Style.Font.Bold = false;
  18721. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18722. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18723. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18724. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18725. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18726. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18727. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18728. builder.Write("CHECK IN:");
  18729. builder.InsertCell();
  18730. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18731. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18732. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18733. builder.ParagraphFormat.Style.Font.Bold = false;
  18734. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18735. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18736. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18737. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18738. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18739. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18740. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18741. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  18742. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18743. builder.Write($"{checkInStr}");
  18744. builder.InsertCell();
  18745. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18746. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18747. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18748. builder.ParagraphFormat.Style.Font.Bold = false;
  18749. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18750. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18751. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18752. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18753. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18754. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18755. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18756. builder.Write($"CHECK OUT:");
  18757. builder.InsertCell();
  18758. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  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.Left;//对齐
  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. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  18770. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  18771. builder.Write($"{checkOutStr}");
  18772. builder.EndRow();
  18773. #endregion
  18774. #region 第七行
  18775. builder.InsertCell();
  18776. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18777. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18778. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18779. builder.ParagraphFormat.Style.Font.Bold = false;
  18780. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18781. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18782. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18783. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18784. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18785. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18786. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18787. builder.Write($"GUEST NAME:");
  18788. builder.InsertCell();
  18789. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18790. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18791. builder.ParagraphFormat.Style.Font.Size = 8;
  18792. builder.ParagraphFormat.Style.Font.Bold = false;
  18793. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18794. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18795. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18796. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18797. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18798. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18799. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18800. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18801. builder.Write($"{item.GuestName.Trim()}");
  18802. builder.InsertCell();
  18803. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18804. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18805. builder.InsertCell();
  18806. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18807. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18808. builder.EndRow();
  18809. #endregion
  18810. #region 第八行
  18811. builder.InsertCell();
  18812. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18813. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18814. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18815. builder.ParagraphFormat.Style.Font.Bold = false;
  18816. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18817. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18818. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18819. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18820. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18821. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18822. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18823. builder.Write($"ROOM TYPE:");
  18824. builder.InsertCell();
  18825. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18826. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18827. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18828. builder.ParagraphFormat.Style.Font.Bold = false;
  18829. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18830. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18831. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18832. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18833. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18834. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18835. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18836. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18837. builder.Write($"{item.RoomExplanation}");
  18838. builder.InsertCell();
  18839. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18840. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18841. builder.InsertCell();
  18842. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18843. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18844. builder.EndRow();
  18845. #endregion
  18846. #region 第九行
  18847. builder.InsertCell();
  18848. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18849. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18850. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18851. builder.ParagraphFormat.Style.Font.Bold = false;
  18852. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18853. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18854. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18855. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18856. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18857. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18858. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18859. builder.Write($"NOTE:");
  18860. builder.InsertCell();
  18861. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18862. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18863. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18864. builder.ParagraphFormat.Style.Font.Bold = false;
  18865. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18866. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18867. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18868. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18869. 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.");
  18870. builder.InsertCell();
  18871. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18872. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18873. builder.InsertCell();
  18874. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18875. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18876. builder.EndRow();
  18877. #endregion
  18878. builder.EndTable();
  18879. //换行
  18880. builder.Writeln("");
  18881. builder.Writeln("");
  18882. }
  18883. #region 获取文档中的所有表格 设置文字自适应
  18884. // 获取文档中的所有表格。
  18885. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  18886. {
  18887. // 遍历表格中的所有行。
  18888. foreach (Aspose.Words.Tables.Row row in table.Rows)
  18889. {
  18890. foreach (Cell cell in row.Cells)
  18891. {
  18892. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  18893. cellFormat.Width = 0;
  18894. }
  18895. }
  18896. }
  18897. #endregion
  18898. #region 设置页眉
  18899. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  18900. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  18901. if (System.IO.File.Exists(voucherHeaderPath))
  18902. {
  18903. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  18904. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  18905. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  18906. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  18907. // 调整图片位置
  18908. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  18909. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  18910. shape.Top = 50; // 将图片距离页眉上边缘的距离
  18911. shape.Left = 0; // 将图片距离页面左边缘的距离
  18912. shape.Width = 81; // 设置图片宽度
  18913. shape.Height = 36; // 设置图片高度
  18914. }
  18915. //靠右
  18916. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18917. //// 设置页脚上下边距
  18918. //builder.PageSetup.HeaderDistance = 42;
  18919. // 添加页眉线
  18920. Aspose.Words.Border borderHeader = null;
  18921. try
  18922. {
  18923. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  18924. }
  18925. catch (Exception e)
  18926. {
  18927. // TODO Auto-generated catch block
  18928. //e.printStackTrace();
  18929. }
  18930. borderHeader.Shadow = true;
  18931. borderHeader.DistanceFromText = 2;
  18932. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  18933. #endregion
  18934. }
  18935. catch (Exception ex)
  18936. {
  18937. }
  18938. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18939. doc.Save(fileDir);
  18940. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18941. return Ok(JsonView(true, "操作成功!", Url));
  18942. }
  18943. /// <summary>
  18944. /// 酒店预订
  18945. /// 生成 预定成本 Excel
  18946. /// </summary>
  18947. /// <param name="_dto"></param>
  18948. /// <returns></returns>
  18949. [HttpPost]
  18950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18951. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  18952. {
  18953. #region 参数验证
  18954. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  18955. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  18956. if (!vadalitorRes.IsValid)
  18957. {
  18958. var errors = new StringBuilder();
  18959. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  18960. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  18961. }
  18962. #region 团组操作权限验证 76 酒店预定模块
  18963. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18964. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18965. #endregion
  18966. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18967. #region 页面操作权限验证
  18968. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18969. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18970. #endregion
  18971. #endregion
  18972. decimal _rate = 1.00M;
  18973. string _currency = string.Empty;
  18974. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  18975. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18976. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  18977. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18978. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  18979. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  18980. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  18981. if (_GroupCostParameter == null)
  18982. {
  18983. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  18984. bool isIntType = int.TryParse(_currency, out int currId);
  18985. if (isIntType)
  18986. {
  18987. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18988. }
  18989. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18990. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18991. if (currInfo == null)
  18992. {
  18993. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18994. }
  18995. else _rate = currInfo.Rate;
  18996. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  18997. {
  18998. _rate = _GroupCostParameter.Rate;
  18999. }
  19000. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19001. //string strFileName = "HotelStatement/";
  19002. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19003. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19004. var rateDatas = new List<dynamic>();
  19005. #region 数据处理
  19006. foreach (var item in hrDtas)
  19007. {
  19008. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19009. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19010. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19011. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19012. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19013. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  19014. {
  19015. continue;
  19016. }
  19017. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19018. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  19019. string singleRoomFeeStr = string.Empty,
  19020. doubleRoomFeeStr = string.Empty,
  19021. suiteRoomFeeStr = string.Empty,
  19022. otherRoomFeeStr = string.Empty,
  19023. payMoneyStr = string.Empty,
  19024. cardPriceStr = string.Empty;
  19025. if (roomCurr.Equals("CNY"))
  19026. {
  19027. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  19028. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19029. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19030. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19031. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19032. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  19033. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  19034. }
  19035. else
  19036. {
  19037. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19038. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19039. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19040. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19041. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19042. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19043. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19044. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19045. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19046. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19047. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  19048. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  19049. if (ccpPaymentCurrency.Equals("CNY"))
  19050. {
  19051. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  19052. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19053. }
  19054. else
  19055. {
  19056. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  19057. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  19058. }
  19059. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  19060. if (hotelcardPriceCurrency.Equals("CNY"))
  19061. {
  19062. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19063. }
  19064. else
  19065. {
  19066. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  19067. }
  19068. }
  19069. string breakfastPriceStr = string.Empty,
  19070. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19071. governmentRentStr = string.Empty,
  19072. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19073. cityTaxStr = string.Empty,
  19074. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19075. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  19076. if (!string.IsNullOrEmpty(breakfastCurrency1))
  19077. {
  19078. if (breakfastCurrency1.Equals("CNY"))
  19079. {
  19080. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19081. }
  19082. else
  19083. {
  19084. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  19085. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  19086. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  19087. }
  19088. }
  19089. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19090. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  19091. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  19092. {
  19093. if (governmentRentCurrency.Equals("CNY"))
  19094. {
  19095. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19096. }
  19097. else
  19098. {
  19099. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  19100. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  19101. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  19102. }
  19103. }
  19104. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19105. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  19106. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  19107. {
  19108. if (cityTaxStrCurrency1.Equals("CNY"))
  19109. {
  19110. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19111. }
  19112. else
  19113. {
  19114. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  19115. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  19116. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  19117. }
  19118. }
  19119. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19120. int payDId = roomInfo?.PayDId ?? 0;
  19121. pcfds.Add(new HotelReservations_PCFD_View()
  19122. {
  19123. City = item.City,
  19124. HotelName = item.HotelName,
  19125. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19126. // SingleRoomCount = item.SingleRoomCount,
  19127. SingleRoomPrice = singleRoomFeeStr,
  19128. // DoubleRoomCount = item.DoubleRoomCount,
  19129. DoubleRoomPrice = doubleRoomFeeStr,
  19130. //SuiteRoomCount = item.SuiteRoomCount,
  19131. SuiteRoomPrice = suiteRoomFeeStr,
  19132. OtherRoomPrice = otherRoomFeeStr,
  19133. //OtherRoomCount = item.OtherRoomCount,
  19134. BreakfastPrice = breakfastPriceStr,
  19135. GovernmentRent = governmentRentStr,
  19136. CityTax = cityTaxStr,
  19137. RoomExplanation = item.RoomExplanation,
  19138. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19139. PayTime = roomInfo?.ConsumptionDate,
  19140. BankNo = roomInfo?.BankNo,
  19141. PayMoney = payMoneyStr,
  19142. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19143. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19144. CardPrice = cardPriceStr,
  19145. Remark = ccpInfo.Remark
  19146. });
  19147. }
  19148. #endregion
  19149. //载入模板
  19150. WorkbookDesigner designer = new WorkbookDesigner();
  19151. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19152. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19153. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19154. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19155. var rateDatas1 = rateDatas.Distinct();
  19156. var rateStr = string.Empty;
  19157. foreach (var item in rateDatas1)
  19158. {
  19159. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  19160. }
  19161. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  19162. designer.SetDataSource("Opertor", userInfo.CnName);
  19163. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19164. dt.TableName = "ViewMyHotelReservations";
  19165. designer.SetDataSource(dt);
  19166. designer.Process();
  19167. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19168. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19169. designer.Workbook.Save(serverPath);
  19170. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19171. #region 删除指定行
  19172. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19173. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19174. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19175. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19176. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19177. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19178. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19179. cssIndex = dt.Columns["CityTax"].Ordinal,
  19180. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19181. remarkIndex = dt.Columns["Remark"].Ordinal;
  19182. //删除指定列
  19183. foreach (DataRow item in dt.Rows)
  19184. {
  19185. string singleStr = item["SingleRoomPrice"].ToString();
  19186. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19187. if (containsDigitButNotZero1) singleDel = false;
  19188. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19189. string doubleStr = item["DoubleRoomPrice"].ToString();
  19190. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19191. if (containsDigitButNotZero2) doubleDel = false;
  19192. string suiteStr = item["SuiteRoomPrice"].ToString();
  19193. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19194. if (containsDigitButNotZero3) suiteDel = false;
  19195. string otherStr = item["OtherRoomPrice"].ToString();
  19196. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19197. if (containsDigitButNotZero4) otherDel = false;
  19198. string zcStr = item["BreakfastPrice"].ToString();
  19199. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19200. if (containsDigitButNotZero5) zcDel = false;
  19201. string dsStr = item["GovernmentRent"].ToString();
  19202. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19203. if (containsDigitButNotZero6) dsDel = false;
  19204. string cssStr = item["CityTax"].ToString();
  19205. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19206. if (containsDigitButNotZero7) cssDel = false;
  19207. string cpStr = item["ConsumptionPatterns"].ToString();
  19208. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19209. string remarkStr = item["Remark"].ToString();
  19210. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19211. }
  19212. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19213. DeleteColumn(serverPath, cpIndex, cpDel);
  19214. DeleteColumn(serverPath, dsIndex, dsDel);
  19215. DeleteColumn(serverPath, cssIndex, cssDel);
  19216. DeleteColumn(serverPath, zcIndex, zcDel);
  19217. DeleteColumn(serverPath, otherIndex, otherDel);
  19218. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19219. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19220. DeleteColumn(serverPath, singleIndex, singleDel);
  19221. #endregion
  19222. //只保留第一个表格
  19223. DeleteSheet(serverPath);
  19224. return Ok(JsonView(true, "操作成功", url = rst));
  19225. }
  19226. else
  19227. {
  19228. _currency = _GroupCostParameter.Currency;
  19229. bool isIntType = int.TryParse(_currency, out int currId);
  19230. if (isIntType)
  19231. {
  19232. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19233. }
  19234. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19235. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19236. if (currInfo == null)
  19237. {
  19238. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19239. }
  19240. if (!_currency.ToUpper().Equals("CNY"))
  19241. {
  19242. _rate = _GroupCostParameter.Rate;
  19243. }
  19244. _rate = currInfo.Rate;
  19245. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19246. //string strFileName = "HotelStatement/";
  19247. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19248. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19249. #region 数据处理
  19250. foreach (var item in hrDtas)
  19251. {
  19252. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19253. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19254. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19255. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19256. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19257. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19258. string singleRoomFeeStr = string.Empty,
  19259. doubleRoomFeeStr = string.Empty,
  19260. suiteRoomFeeStr = string.Empty,
  19261. otherRoomFeeStr = string.Empty,
  19262. payMoneyStr = string.Empty,
  19263. cardPriceStr = string.Empty;
  19264. if (roomCurr.Equals(_currency))
  19265. {
  19266. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  19267. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  19268. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  19269. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  19270. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  19271. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  19272. }
  19273. else
  19274. {
  19275. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19276. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19277. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19278. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19279. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19280. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19281. }
  19282. string breakfastPriceStr = string.Empty,
  19283. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19284. governmentRentStr = string.Empty,
  19285. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19286. cityTaxStrStr = string.Empty,
  19287. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19288. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  19289. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  19290. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  19291. int payDId = roomInfo?.PayDId ?? 0;
  19292. pcfds.Add(new HotelReservations_PCFD_View()
  19293. {
  19294. City = item.City,
  19295. HotelName = item.HotelName,
  19296. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19297. // SingleRoomCount = item.SingleRoomCount,
  19298. SingleRoomPrice = singleRoomFeeStr,
  19299. // DoubleRoomCount = item.DoubleRoomCount,
  19300. DoubleRoomPrice = doubleRoomFeeStr,
  19301. //SuiteRoomCount = item.SuiteRoomCount,
  19302. SuiteRoomPrice = suiteRoomFeeStr,
  19303. OtherRoomPrice = otherRoomFeeStr,
  19304. //OtherRoomCount = item.OtherRoomCount,
  19305. BreakfastPrice = breakfastPriceStr,
  19306. GovernmentRent = governmentRentStr,
  19307. CityTax = cityTaxStrStr,
  19308. RoomExplanation = item.RoomExplanation,
  19309. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19310. PayTime = roomInfo?.ConsumptionDate,
  19311. BankNo = roomInfo?.BankNo,
  19312. PayMoney = payMoneyStr,
  19313. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19314. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19315. CardPrice = cardPriceStr,
  19316. Remark = ccpInfo.Remark
  19317. });
  19318. }
  19319. #endregion
  19320. //载入模板
  19321. WorkbookDesigner designer = new WorkbookDesigner();
  19322. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19323. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19324. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19325. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19326. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  19327. designer.SetDataSource("Opertor", userInfo.CnName);
  19328. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19329. dt.TableName = "ViewMyHotelReservations";
  19330. designer.SetDataSource(dt);
  19331. designer.Process();
  19332. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19333. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19334. designer.Workbook.Save(serverPath);
  19335. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19336. #region 删除指定行
  19337. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19338. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19339. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19340. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19341. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19342. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19343. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19344. cssIndex = dt.Columns["CityTax"].Ordinal,
  19345. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19346. remarkIndex = dt.Columns["Remark"].Ordinal;
  19347. //删除指定列
  19348. foreach (DataRow item in dt.Rows)
  19349. {
  19350. string singleStr = item["SingleRoomPrice"].ToString();
  19351. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19352. if (containsDigitButNotZero1) singleDel = false;
  19353. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19354. string doubleStr = item["DoubleRoomPrice"].ToString();
  19355. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19356. if (containsDigitButNotZero2) doubleDel = false;
  19357. string suiteStr = item["SuiteRoomPrice"].ToString();
  19358. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19359. if (containsDigitButNotZero3) suiteDel = false;
  19360. string otherStr = item["OtherRoomPrice"].ToString();
  19361. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19362. if (containsDigitButNotZero4) otherDel = false;
  19363. string zcStr = item["BreakfastPrice"].ToString();
  19364. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19365. if (containsDigitButNotZero5) zcDel = false;
  19366. string dsStr = item["GovernmentRent"].ToString();
  19367. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19368. if (containsDigitButNotZero6) dsDel = false;
  19369. string cssStr = item["CityTax"].ToString();
  19370. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19371. if (containsDigitButNotZero7) cssDel = false;
  19372. string cpStr = item["ConsumptionPatterns"].ToString();
  19373. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19374. string remarkStr = item["Remark"].ToString();
  19375. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19376. }
  19377. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19378. DeleteColumn(serverPath, cpIndex, cpDel);
  19379. DeleteColumn(serverPath, dsIndex, dsDel);
  19380. DeleteColumn(serverPath, cssIndex, cssDel);
  19381. DeleteColumn(serverPath, zcIndex, zcDel);
  19382. DeleteColumn(serverPath, otherIndex, otherDel);
  19383. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19384. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19385. DeleteColumn(serverPath, singleIndex, singleDel);
  19386. #endregion
  19387. //只保留第一个表格
  19388. DeleteSheet(serverPath);
  19389. return Ok(JsonView(true, "操作成功", url = rst));
  19390. }
  19391. //return Ok(JsonView(false));
  19392. }
  19393. /// <summary>
  19394. /// 删除指定列
  19395. /// </summary>
  19396. /// <param name="file"></param>
  19397. /// <param name="columnIndex"></param>
  19398. /// <param name="isDel"></param>
  19399. private void DeleteColumn(string file, int columnIndex, bool isDel)
  19400. {
  19401. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19402. //wb.Save(file);
  19403. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  19404. if (sheet1 != null)
  19405. {
  19406. if (isDel)
  19407. {
  19408. Cells cells = sheet1.Cells;
  19409. cells.DeleteColumn(columnIndex);
  19410. }
  19411. }
  19412. wb.Save(file);
  19413. }
  19414. /// <summary>
  19415. /// 删除sheet
  19416. /// </summary>
  19417. /// <param name="file"></param>
  19418. private void DeleteSheet(string file)
  19419. {
  19420. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19421. //wb.Save(file);
  19422. List<string> sheets = new List<string>();
  19423. foreach (var item in wb.Worksheets)
  19424. {
  19425. sheets.Add(item.Name);
  19426. }
  19427. if (sheets.Count > 0)
  19428. {
  19429. sheets.RemoveAt(0);//不删除第一个sheet
  19430. foreach (var item in sheets)
  19431. {
  19432. wb.Worksheets.RemoveAt(item);
  19433. }
  19434. }
  19435. wb.Save(file);
  19436. }
  19437. /// <summary>
  19438. /// 酒店预订
  19439. /// 确认单
  19440. /// </summary>
  19441. /// <param name="_dto"></param>
  19442. /// <returns></returns>
  19443. [HttpPost]
  19444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19445. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  19446. {
  19447. try
  19448. {
  19449. #region 参数验证
  19450. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19451. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19452. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19453. #region 团组操作权限验证 76 酒店预定模块
  19454. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19455. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19456. #endregion
  19457. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19458. #region 页面操作权限验证
  19459. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19460. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19461. #endregion
  19462. #endregion
  19463. //团组信息
  19464. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  19465. //酒店数据
  19466. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  19467. if (listhoteldata.Count < 0)
  19468. {
  19469. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  19470. }
  19471. //利datatable存储
  19472. DataTable dt = new DataTable();
  19473. dt.Columns.Add("CheckInDate", typeof(string));
  19474. dt.Columns.Add("City", typeof(string));
  19475. dt.Columns.Add("Hotel", typeof(string));
  19476. dt.Columns.Add("Room", typeof(string));
  19477. for (int i = 0; i < listhoteldata.Count; i++)
  19478. {
  19479. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  19480. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  19481. while (dayStart < dayEnd)
  19482. {
  19483. string temp = "";
  19484. DataRow row = dt.NewRow();
  19485. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  19486. row["City"] = listhoteldata[i].City;
  19487. row["Hotel"] = listhoteldata[i].HotelName;
  19488. if (listhoteldata[i].SingleRoomCount > 0)
  19489. {
  19490. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  19491. }
  19492. if (listhoteldata[i].DoubleRoomCount > 0)
  19493. {
  19494. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  19495. }
  19496. if (listhoteldata[i].SuiteRoomCount > 0)
  19497. {
  19498. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  19499. }
  19500. if (listhoteldata[i].OtherRoomCount > 0)
  19501. {
  19502. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  19503. }
  19504. row["Room"] = temp;
  19505. dt.Rows.Add(row);
  19506. dayStart = dayStart.AddDays(1);
  19507. }
  19508. }
  19509. Dictionary<string, string> dic = new Dictionary<string, string>();
  19510. dic.Add("Dele", di.TeamName);
  19511. dic.Add("City", di.VisitCountry);
  19512. //模板路径
  19513. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  19514. //载入模板
  19515. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  19516. DocumentBuilder builder = new DocumentBuilder(doc);
  19517. foreach (var key in dic.Keys)
  19518. {
  19519. builder.MoveToBookmark(key);
  19520. builder.Write(dic[key]);
  19521. }
  19522. //获取word里所有表格
  19523. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19524. //获取所填表格的序数
  19525. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19526. var rowStart = tableOne.Rows[0]; //获取第1行
  19527. //循环赋值
  19528. for (int i = 0; i < dt.Rows.Count; i++)
  19529. {
  19530. builder.MoveToCell(0, i + 1, 0, 0);
  19531. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  19532. builder.MoveToCell(0, i + 1, 1, 0);
  19533. builder.Write(dt.Rows[i]["City"].ToString());
  19534. builder.MoveToCell(0, i + 1, 2, 0);
  19535. builder.Write(dt.Rows[i]["Hotel"].ToString());
  19536. builder.MoveToCell(0, i + 1, 3, 0);
  19537. builder.Write(dt.Rows[i]["Room"].ToString());
  19538. }
  19539. //删除多余行
  19540. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  19541. {
  19542. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  19543. }
  19544. string strFileName = di.TeamName + "酒店确认单.doc";
  19545. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  19546. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  19547. return Ok(JsonView(true, "成功", url));
  19548. }
  19549. catch (Exception ex)
  19550. {
  19551. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  19552. }
  19553. }
  19554. #endregion
  19555. #region 团组状态
  19556. /// <summary>
  19557. /// 团组状态列表 Page
  19558. /// </summary>
  19559. /// <param name="dto">团组列表请求dto</param>
  19560. /// <returns></returns>
  19561. [HttpPost]
  19562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19563. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  19564. {
  19565. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19566. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  19567. {
  19568. string sqlWhere = string.Empty;
  19569. if (dto.IsSure == 0) //未完成
  19570. {
  19571. sqlWhere += string.Format(@" And IsSure = 0");
  19572. }
  19573. else if (dto.IsSure == 1) //已完成
  19574. {
  19575. sqlWhere += string.Format(@" And IsSure = 1");
  19576. }
  19577. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  19578. {
  19579. string tj = dto.SearchCriteria;
  19580. 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}%')",
  19581. tj, tj, tj, tj, tj);
  19582. }
  19583. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  19584. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  19585. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  19586. From (
  19587. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  19588. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  19589. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  19590. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  19591. From Grp_DelegationInfo gdi
  19592. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  19593. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  19594. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  19595. Where gdi.IsDel = 0 {0}
  19596. ) temp ", sqlWhere);
  19597. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  19598. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  19599. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  19600. }
  19601. else
  19602. {
  19603. return Ok(JsonView(false, "查询失败"));
  19604. }
  19605. }
  19606. /// <summary>
  19607. /// 团组状态
  19608. /// 设置操作完成
  19609. /// </summary>
  19610. /// <param name="dto">团组列表请求dto</param>
  19611. /// <returns></returns>
  19612. [HttpPost]
  19613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19614. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  19615. {
  19616. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19617. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  19618. {
  19619. Id = dto.Id,
  19620. IsSure = 1
  19621. };
  19622. var result = await _sqlSugar.Updateable(_DelegationInfo)
  19623. .UpdateColumns(it => new { it.IsSure })
  19624. .WhereColumns(it => new { it.Id })
  19625. .ExecuteCommandAsync();
  19626. if (result > 0)
  19627. {
  19628. return Ok(JsonView(true, "操作完成!"));
  19629. }
  19630. return Ok(JsonView(false, "操作失败!"));
  19631. }
  19632. #endregion
  19633. #region 保险费用录入
  19634. /// <summary>
  19635. /// 根据团组Id查询保险费用列表
  19636. /// </summary>
  19637. /// <param name="dto"></param>
  19638. /// <returns></returns>
  19639. [HttpPost]
  19640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19641. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  19642. {
  19643. Result groupData = await _customersRep.CustomersByDiId(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. /// <summary>
  19651. /// 根据保险费用Id查询保险费用详细
  19652. /// </summary>
  19653. /// <param name="dto"></param>
  19654. /// <returns></returns>
  19655. [HttpPost]
  19656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19657. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  19658. {
  19659. try
  19660. {
  19661. Result groupData = await _customersRep.CustomersById(dto);
  19662. if (groupData.Code != 0)
  19663. {
  19664. return Ok(JsonView(false, groupData.Msg));
  19665. }
  19666. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19667. }
  19668. catch (Exception ex)
  19669. {
  19670. return Ok(JsonView(false, ex.Message));
  19671. }
  19672. }
  19673. /// <summary>
  19674. /// 保险费用录入页面初始化绑定
  19675. /// </summary>
  19676. /// <param name="dto"></param>
  19677. /// <returns></returns>
  19678. [HttpPost]
  19679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19680. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  19681. {
  19682. try
  19683. {
  19684. Result groupData = await _customersRep.CustomersInitialize(dto);
  19685. if (groupData.Code != 0)
  19686. {
  19687. return Ok(JsonView(false, groupData.Msg));
  19688. }
  19689. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19690. }
  19691. catch (Exception ex)
  19692. {
  19693. return Ok(JsonView(false, ex.Message));
  19694. }
  19695. }
  19696. /// <summary>
  19697. /// 保险费用操作(Status:1.新增,2.修改)
  19698. /// </summary>
  19699. /// <param name="dto"></param>
  19700. /// <returns></returns>
  19701. [HttpPost]
  19702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19703. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  19704. {
  19705. Result groupData = await _customersRep.OpCustomers(dto);
  19706. if (groupData.Code != 0)
  19707. {
  19708. return Ok(JsonView(false, groupData.Msg));
  19709. }
  19710. #region 应用推送
  19711. try
  19712. {
  19713. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  19714. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  19715. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  19716. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  19717. //自动审核
  19718. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  19719. //2024-10-21 新增LZ UID
  19720. var userIds = new List<int>() { 21 };
  19721. string title = $"系统通知";
  19722. var diId = dto.DiId;
  19723. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  19724. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  19725. string content = "";
  19726. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19727. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19728. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  19729. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  19730. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  19731. }
  19732. catch (Exception ex)
  19733. {
  19734. }
  19735. #endregion
  19736. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19737. }
  19738. /// <summary>
  19739. /// 保险文件上传
  19740. /// </summary>
  19741. /// <param name="file"></param>
  19742. /// <returns></returns>
  19743. [HttpPost]
  19744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19745. public async Task<IActionResult> UploadCus(IFormFile file)
  19746. {
  19747. try
  19748. {
  19749. if (file != null)
  19750. {
  19751. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19752. //文件名称
  19753. string projectFileName = file.FileName;
  19754. //上传的文件的路径
  19755. string filePath = "";
  19756. if (!Directory.Exists(fileDir))
  19757. {
  19758. Directory.CreateDirectory(fileDir);
  19759. }
  19760. //上传的文件的路径
  19761. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  19762. using (FileStream fs = System.IO.File.Create(filePath))
  19763. {
  19764. file.CopyTo(fs);
  19765. fs.Flush();
  19766. }
  19767. return Ok(JsonView(true, "上传成功!", projectFileName));
  19768. }
  19769. else
  19770. {
  19771. return Ok(JsonView(false, "上传失败!"));
  19772. }
  19773. }
  19774. catch (Exception ex)
  19775. {
  19776. return Ok(JsonView(false, ex.Message));
  19777. }
  19778. }
  19779. /// <summary>
  19780. /// 保险删除指定文件
  19781. /// </summary>
  19782. /// <param name="dto"></param>
  19783. /// <returns></returns>
  19784. [HttpPost]
  19785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19786. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  19787. {
  19788. try
  19789. {
  19790. string filePath = "";
  19791. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19792. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  19793. //int id = 0;
  19794. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  19795. // 删除该文件
  19796. try
  19797. {
  19798. System.IO.File.Delete(filePath);
  19799. 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()
  19800. {
  19801. Attachment = "",
  19802. }).ExecuteCommandAsync();
  19803. if (result != 0)
  19804. {
  19805. return Ok(JsonView(true, "成功!"));
  19806. }
  19807. else
  19808. {
  19809. return Ok(JsonView(false, "失败!"));
  19810. }
  19811. }
  19812. catch (Exception)
  19813. {
  19814. 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()
  19815. {
  19816. Attachment = "",
  19817. }).ExecuteCommandAsync();
  19818. if (result != 0)
  19819. {
  19820. return Ok(JsonView(true, "成功!"));
  19821. }
  19822. else
  19823. {
  19824. return Ok(JsonView(false, "失败!"));
  19825. }
  19826. }
  19827. }
  19828. catch (Exception ex)
  19829. {
  19830. return Ok(JsonView(false, "程序错误!"));
  19831. throw;
  19832. }
  19833. }
  19834. /// <summary>
  19835. /// 保险费用操作(删除)
  19836. /// </summary>
  19837. /// <param name="dto"></param>
  19838. /// <returns></returns>
  19839. [HttpPost]
  19840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19841. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  19842. {
  19843. try
  19844. {
  19845. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  19846. if (!res)
  19847. {
  19848. return Ok(JsonView(false, "删除失败"));
  19849. }
  19850. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  19851. {
  19852. IsDel = 1,
  19853. DeleteUserId = dto.DeleteUserId,
  19854. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  19855. }).ExecuteCommandAsync();
  19856. return Ok(JsonView(true, "删除成功!"));
  19857. }
  19858. catch (Exception ex)
  19859. {
  19860. return Ok(JsonView(false, "程序错误!"));
  19861. throw;
  19862. }
  19863. }
  19864. #endregion
  19865. #region 接团客户名单 PageId 104
  19866. /// <summary>
  19867. /// 接团客户名单
  19868. /// 迁移数据(慎用!)
  19869. /// </summary>
  19870. /// <returns></returns>
  19871. [HttpPost]
  19872. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19873. public async Task<IActionResult> PostTourClientListChange()
  19874. {
  19875. try
  19876. {
  19877. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  19878. //var groupClinetData1
  19879. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  19880. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  19881. int updateCount = 0;
  19882. if (oldOAClientList.Count > 0)
  19883. {
  19884. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  19885. _sqlSugar.BeginTran();
  19886. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  19887. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  19888. foreach (var item in oldOAClientList)
  19889. {
  19890. int comId = 0;
  19891. string format = "yyyy-MM-dd HH:mm:ss";
  19892. string data11 = "1990-01-01 00:00";
  19893. var data1 = IsValidDate(item.OPdate, format);
  19894. if (data1) data11 = item.OPdate;
  19895. //客户公司验证
  19896. if (!string.IsNullOrEmpty(item.Company))
  19897. {
  19898. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  19899. if (clientComInfo == null) // add
  19900. {
  19901. var addInfo = new Crm_CustomerCompany()
  19902. {
  19903. CompanyAbbreviation = "",
  19904. CompanyFullName = item.Company,
  19905. Address = "",
  19906. PostCodes = "",
  19907. LastedOpUserId = item.OPer,
  19908. LastedOpDt = Convert.ToDateTime(data11),
  19909. CreateUserId = item.OPer,
  19910. CreateTime = Convert.ToDateTime(data11),
  19911. IsDel = 0
  19912. };
  19913. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  19914. if (comId1 > 0) comId = comId1;
  19915. }
  19916. else comId = clientComInfo.Id;
  19917. }
  19918. //客户人员验证
  19919. int clientId = 0;
  19920. string name = item.LastName + item.Name;
  19921. if (!string.IsNullOrEmpty(name))
  19922. {
  19923. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  19924. if (clientInfo == null)
  19925. {
  19926. DateTime? dateTime = null;
  19927. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  19928. if (isDt) dateTime = birthDayDt;
  19929. var addInfo1 = new Crm_DeleClient()
  19930. {
  19931. CrmCompanyId = comId,
  19932. DiId = -1,
  19933. LastName = item.LastName,
  19934. FirstName = item.Name,
  19935. OldName = "",
  19936. Pinyin = item.Pinyin,
  19937. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  19938. Marriage = 0,
  19939. Phone = item.Phone,
  19940. Job = item.Job,
  19941. BirthDay = dateTime
  19942. };
  19943. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  19944. if (clientId1 > 0) clientId = clientId1;
  19945. }
  19946. else clientId = clientInfo.Id;
  19947. }
  19948. if (clientId < 1)
  19949. {
  19950. continue;
  19951. }
  19952. int airType = 0;
  19953. if (item.AirType == "超经舱") airType = 459;
  19954. else if (item.AirType == "公务舱") airType = 458;
  19955. else if (item.AirType == "经济舱") airType = 460;
  19956. else if (item.AirType == "其他") airType = 565;
  19957. else if (item.AirType == "头等舱") airType = 457;
  19958. var _TourClientListEntity = new Grp_TourClientList()
  19959. {
  19960. DiId = item.Diid,
  19961. ClientId = clientId,
  19962. CreateUserId = item.OPer,
  19963. CreateTime = Convert.ToDateTime(data11),
  19964. Remark = item.Remark,
  19965. IsDel = item.Isdel,
  19966. ShippingSpaceTypeId = airType,
  19967. ShippingSpaceSpecialNeeds = item.AirRemark,
  19968. HotelSpecialNeeds = item.RoomType
  19969. };
  19970. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  19971. if (_TourClientList > 0)
  19972. {
  19973. updateCount++;
  19974. }
  19975. }
  19976. _sqlSugar.CommitTran();
  19977. }
  19978. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  19979. }
  19980. catch (Exception ex)
  19981. {
  19982. _sqlSugar.RollbackTran();
  19983. return Ok(JsonView(false, ex.Message));
  19984. }
  19985. //return Ok(JsonView(true));
  19986. }
  19987. private bool IsValidDate(string dateString, string format)
  19988. {
  19989. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  19990. }
  19991. /// <summary>
  19992. /// 接团客户名单
  19993. /// 根据团组Id查询List
  19994. /// </summary>
  19995. /// <param name="_dto"></param>
  19996. /// <returns></returns>
  19997. [HttpPost]
  19998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19999. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  20000. {
  20001. #region 参数验证
  20002. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  20003. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  20004. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  20005. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20006. #region 页面操作权限验证
  20007. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20008. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20009. #endregion
  20010. #endregion
  20011. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  20012. if (viewData.Code != 0)
  20013. {
  20014. return Ok(JsonView(false, viewData.Msg));
  20015. }
  20016. return Ok(JsonView(viewData.Data));
  20017. }
  20018. /// <summary>
  20019. /// 接团客户名单
  20020. /// 基础数据 Init
  20021. /// </summary>
  20022. /// <param name="_dto"></param>
  20023. /// <returns></returns>
  20024. [HttpPost]
  20025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20026. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  20027. {
  20028. #region 参数验证
  20029. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20030. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20031. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20032. #region 页面操作权限验证
  20033. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20034. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20035. #endregion
  20036. #endregion
  20037. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  20038. }
  20039. /// <summary>
  20040. /// 接团客户名单
  20041. /// 根据 Id查询 Details
  20042. /// </summary>
  20043. /// <param name="_dto"></param>
  20044. /// <returns></returns>
  20045. [HttpPost]
  20046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20047. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  20048. {
  20049. #region 参数验证
  20050. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20051. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20052. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20053. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20054. #region 页面操作权限验证
  20055. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20056. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20057. #endregion
  20058. #endregion
  20059. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  20060. if (viewData.Code != 0)
  20061. {
  20062. return Ok(JsonView(false, viewData.Msg));
  20063. }
  20064. return Ok(JsonView(viewData.Data));
  20065. }
  20066. /// <summary>
  20067. /// 接团客户名单
  20068. /// Add Or Edit
  20069. /// </summary>
  20070. /// <param name="_dto"></param>
  20071. /// <returns></returns>
  20072. [HttpPost]
  20073. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20074. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  20075. {
  20076. #region 参数验证
  20077. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20078. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20079. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20080. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20081. #region 页面操作权限验证
  20082. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20083. if (_dto.Id == 0) //添加
  20084. {
  20085. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20086. }
  20087. else if (_dto.Id >= 0) //修改
  20088. {
  20089. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  20090. }
  20091. #endregion
  20092. #endregion
  20093. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  20094. if (viewData.Code != 0)
  20095. {
  20096. return Ok(JsonView(false, viewData.Msg));
  20097. }
  20098. return Ok(JsonView(true));
  20099. }
  20100. /// <summary>
  20101. /// 接团客户名单
  20102. /// json字符串 AddMultiple(添加多个)
  20103. /// </summary>
  20104. /// <param name="_dto"></param>
  20105. /// <returns></returns>
  20106. [HttpPost]
  20107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20108. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  20109. {
  20110. #region 参数验证
  20111. string jsonLabel = _dto.JsonLabel;
  20112. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20113. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20114. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20115. #region 页面操作权限验证
  20116. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20117. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20118. #endregion
  20119. #endregion
  20120. var request = new TourClientListAddMultipleDto();
  20121. request.DiId = _dto.DiId;
  20122. request.UserId = _dto.UserId;
  20123. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  20124. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  20125. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  20126. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  20127. var infos = new List<TourClientListInfo>();
  20128. foreach (var data in datas)
  20129. {
  20130. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  20131. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  20132. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  20133. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  20134. {
  20135. continue;
  20136. }
  20137. infos.Add(new TourClientListInfo()
  20138. {
  20139. IsAccompany = 1,
  20140. LastName = lastName,
  20141. FirstName = firstName,
  20142. Pinyin = lastNameEn + @"/" + firstNameEn,
  20143. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  20144. CompanyFullName = data.CompanyFullName,
  20145. Job = data.Job
  20146. });
  20147. }
  20148. if (infos.Any())
  20149. {
  20150. var viewData = await _tourClientListRep._AddMultiple(request);
  20151. if (viewData.Code != 0)
  20152. {
  20153. return Ok(JsonView(false, viewData.Msg));
  20154. }
  20155. return Ok(JsonView(true));
  20156. }
  20157. return Ok(JsonView(false));
  20158. }
  20159. /// <summary>
  20160. /// 接团客户名单
  20161. /// AddMultiple(添加多个)
  20162. /// </summary>
  20163. /// <param name="_dto"></param>
  20164. /// <returns></returns>
  20165. [HttpPost]
  20166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20167. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  20168. {
  20169. #region 参数验证
  20170. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20171. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20172. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20173. #region 页面操作权限验证
  20174. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20175. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20176. #endregion
  20177. #endregion
  20178. var viewData = await _tourClientListRep._AddMultiple(_dto);
  20179. if (viewData.Code != 0)
  20180. {
  20181. return Ok(JsonView(false, viewData.Msg));
  20182. }
  20183. return Ok(JsonView(true));
  20184. }
  20185. /// <summary>
  20186. /// 接团客户名单
  20187. /// Del
  20188. /// </summary>
  20189. /// <param name="_dto"></param>
  20190. /// <returns></returns>
  20191. [HttpPost]
  20192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20193. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  20194. {
  20195. #region 参数验证
  20196. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20197. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20198. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20199. #region 页面操作权限验证
  20200. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20201. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  20202. #endregion
  20203. #endregion
  20204. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  20205. if (viewData.Code != 0)
  20206. {
  20207. return Ok(JsonView(false, viewData.Msg));
  20208. }
  20209. return Ok(JsonView(true));
  20210. }
  20211. /// <summary>
  20212. /// 接团客户名单
  20213. /// 文件下载 客户名单
  20214. /// </summary>
  20215. /// <param name="_dto"></param>
  20216. /// <returns></returns>
  20217. [HttpPost]
  20218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20219. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  20220. {
  20221. #region 参数验证
  20222. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20223. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20224. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  20225. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20226. #region 页面操作权限验证
  20227. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20228. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20229. #endregion
  20230. #endregion
  20231. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  20232. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  20233. From Grp_TourClientList tcl
  20234. Left Join
  20235. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  20236. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  20237. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  20238. From Crm_DeleClient dc
  20239. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  20240. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  20241. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  20242. Where dc.IsDel = 0) temp
  20243. On temp.DcId =tcl.ClientId
  20244. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  20245. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  20246. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  20247. //载入模板
  20248. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  20249. if (_dto.Language == 1)
  20250. {
  20251. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  20252. }
  20253. //载入模板
  20254. var doc = new Document(tempPath);
  20255. DocumentBuilder builder = new DocumentBuilder(doc);
  20256. //获取word里所有表格
  20257. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20258. //获取所填表格的序数
  20259. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20260. var rowStart = tableOne.Rows[0]; //获取第1行
  20261. if (_dto.Language == 0)
  20262. {
  20263. //循环赋值
  20264. for (int i = 0; i < DcList.Count; i++)
  20265. {
  20266. EncryptionProcessor.DecryptProperties(DcList[i]);
  20267. builder.MoveToCell(0, i + 1, 0, 0);
  20268. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  20269. builder.MoveToCell(0, i + 1, 1, 0);
  20270. int sex = DcList[i].Sex;
  20271. string sexStr = string.Empty;
  20272. if (sex == 0) sexStr = "男";
  20273. else if (sex == 1) sexStr = "女";
  20274. else sexStr = "未设置";
  20275. builder.Write(sexStr);
  20276. builder.MoveToCell(0, i + 1, 2, 0);
  20277. string birthDay = DcList[i].BirthDay;
  20278. string birthDayStr = string.Empty;
  20279. if (!string.IsNullOrEmpty(birthDay))
  20280. {
  20281. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  20282. }
  20283. builder.Write(birthDayStr);
  20284. builder.MoveToCell(0, i + 1, 3, 0);
  20285. string company = "";
  20286. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20287. {
  20288. company = DcList[i].CompanyFullName.ToString();
  20289. }
  20290. builder.Write(company);
  20291. builder.MoveToCell(0, i + 1, 4, 0);
  20292. builder.Write(DcList[i].Job);
  20293. }
  20294. }
  20295. else if (_dto.Language == 1)
  20296. {
  20297. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  20298. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  20299. List<string> transArrayStr = new List<string>();
  20300. string transStrRes1 = "";
  20301. for (int i = 0; i < DcList.Count; i++)
  20302. {
  20303. var dc = DcList[i];
  20304. EncryptionProcessor.DecryptProperties(dc);
  20305. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  20306. if (dc.Job.Equals("暂无")) dc.Job = "-";
  20307. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  20308. if (DcList.Count - 1 == i) transStrRes1 += str1;
  20309. else transStrRes1 += $"{str1}|";
  20310. }
  20311. #region AI转英文
  20312. string jsonValue = JsonConvert.SerializeObject(DcList);
  20313. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  20314. List<SeedMessages> messages = new List<SeedMessages>()
  20315. {
  20316. new SeedMessages
  20317. {
  20318. Role = KimiRole.user,
  20319. Content = jsonValue + text
  20320. }
  20321. };
  20322. KiMiApiClient client = new KiMiApiClient();
  20323. var kimiApiResult = await client.SeedMessage(messages);
  20324. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20325. string clients = kimiApiResult_JObject["content"].ToString();
  20326. string startStr = "```json", endStr = "```";
  20327. // 判断并清除开头部分
  20328. if (clients.StartsWith(startStr))
  20329. {
  20330. clients = clients.Remove(0, startStr.Length);
  20331. }
  20332. // 判断并清除结尾部分
  20333. if (clients.EndsWith(endStr))
  20334. {
  20335. clients = clients.Remove(clients.Length - endStr.Length);
  20336. }
  20337. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  20338. //循环赋值
  20339. for (int i = 0; i < en_Json.Count; i++)
  20340. {
  20341. var dc = en_Json[i];
  20342. var dc1 = DcList.Find(x => x.Id == dc.Id);
  20343. string PYName = dc.FirstName + " " + dc.LastName;
  20344. builder.MoveToCell(0, i + 1, 0, 0);
  20345. builder.Write(PYName);
  20346. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  20347. builder.MoveToCell(0, i + 1, 1, 0);
  20348. builder.Write(sex);
  20349. DateTime birthDt;
  20350. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  20351. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20352. builder.MoveToCell(0, i + 1, 2, 0);
  20353. builder.Write(birthday);
  20354. string company = string.Empty, job = string.Empty;
  20355. company = dc.CompanyFullName;
  20356. job = dc.Job;
  20357. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  20358. {
  20359. //查询对照表
  20360. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  20361. if (tempCec != null)
  20362. {
  20363. company = tempCec.enName;
  20364. }
  20365. }
  20366. builder.MoveToCell(0, i + 1, 3, 0);
  20367. builder.Write(company);
  20368. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  20369. {
  20370. //查询对照表
  20371. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  20372. if (tempPec != null)
  20373. {
  20374. job = tempPec.enName;
  20375. }
  20376. }
  20377. builder.MoveToCell(0, i + 1, 4, 0);
  20378. builder.Write(job);
  20379. }
  20380. #endregion
  20381. #region 旧翻译英文处理
  20382. ////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";
  20383. //string transStrRes = "";
  20384. //if (transStrRes1.Length > 0)
  20385. //{
  20386. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  20387. //}
  20388. ////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
  20389. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  20390. ////List<string> transArray = new List<string> { };
  20391. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  20392. //if (transStrRes.Contains("|"))
  20393. //{
  20394. // string[] transArray1 = transStrRes.Split('|');
  20395. // if (transArray1.Length > 0)
  20396. // {
  20397. // foreach (var item in transArray1)
  20398. // {
  20399. // if (item.Contains("&"))
  20400. // {
  20401. // string[] transArray2 = item.Split('&');
  20402. // int index = 0;
  20403. // string companyName = "", job = "";
  20404. // if (transArray2.Length > 0)
  20405. // {
  20406. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  20407. // if (1 < transArray2.Length) companyName = transArray2[1];
  20408. // if (2 < transArray2.Length) job = transArray2[2];
  20409. // }
  20410. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  20411. // }
  20412. // }
  20413. // }
  20414. //}
  20415. ////循环赋值
  20416. //for (int i = 0; i < DcList.Count; i++)
  20417. //{
  20418. // string PYName = "";
  20419. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  20420. // {
  20421. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  20422. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  20423. // PYName = PY_First + " " + PY_Last;
  20424. // }
  20425. // else
  20426. // {
  20427. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  20428. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  20429. // PYName = PY_First + " " + PY_Last;
  20430. // }
  20431. // builder.MoveToCell(0, i + 1, 0, 0);
  20432. // builder.Write(PYName);
  20433. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  20434. // builder.MoveToCell(0, i + 1, 1, 0);
  20435. // builder.Write(sex);
  20436. // DateTime birthDt;
  20437. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  20438. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20439. // builder.MoveToCell(0, i + 1, 2, 0);
  20440. // builder.Write(birthday);
  20441. // string company = string.Empty, job = string.Empty;
  20442. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  20443. // if (dcTransInfo != null)
  20444. // {
  20445. // company = dcTransInfo.CompanyName;
  20446. // job = dcTransInfo.Job;
  20447. // }
  20448. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20449. // {
  20450. // //查询对照表
  20451. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  20452. // if (tempCec != null)
  20453. // {
  20454. // company = tempCec.enName;
  20455. // }
  20456. // //翻译
  20457. // else
  20458. // {
  20459. // }
  20460. // }
  20461. // builder.MoveToCell(0, i + 1, 3, 0);
  20462. // builder.Write(company);
  20463. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  20464. // {
  20465. // //查询对照表
  20466. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  20467. // if (tempPec != null)
  20468. // {
  20469. // job = tempPec.enName;
  20470. // }
  20471. // //翻译
  20472. // else
  20473. // {
  20474. // }
  20475. // }
  20476. // builder.MoveToCell(0, i + 1, 4, 0);
  20477. // builder.Write(job);
  20478. //}
  20479. #endregion
  20480. }
  20481. //删除多余行
  20482. while (tableOne.Rows.Count > DcList.Count + 1)
  20483. {
  20484. tableOne.Rows.RemoveAt(DcList.Count + 1);
  20485. }
  20486. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  20487. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  20488. doc.Save(fileDir);
  20489. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  20490. return Ok(JsonView(true, "操作成功!", Url));
  20491. }
  20492. private class TranslateInfo
  20493. {
  20494. public int Index { get; set; }
  20495. public string CompanyName { get; set; }
  20496. public string Job { get; set; }
  20497. }
  20498. [HttpPost]
  20499. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  20500. {
  20501. if (files.Count == 0)
  20502. {
  20503. return Ok(JsonView(false, "文件为空"));
  20504. }
  20505. KiMiApiClient KiMiApi = new KiMiApiClient();
  20506. var seedConter = await KiMiApi.UploadFilesAsync(files);
  20507. if (seedConter.Count == 0)
  20508. {
  20509. return Ok(JsonView(false, "上传结果为空!"));
  20510. }
  20511. var messages = new List<SeedMessages>
  20512. {
  20513. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  20514. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  20515. };
  20516. messages.InsertRange(1, seedConter);
  20517. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  20518. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20519. string clients = kimiApiResult_JObject["content"].ToString();
  20520. string startStr = "```json", endStr = "```";
  20521. // 判断并清除开头部分
  20522. if (clients.StartsWith(startStr))
  20523. {
  20524. clients = clients.Remove(0, startStr.Length);
  20525. }
  20526. // 判断并清除结尾部分
  20527. if (clients.EndsWith(endStr))
  20528. {
  20529. clients = clients.Remove(clients.Length - endStr.Length);
  20530. }
  20531. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  20532. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  20533. {
  20534. {"姓", "LastName" },
  20535. {"名", "FirstName" },
  20536. {"姓名拼音", "Pinyin" },
  20537. {"性别", "Sex" },
  20538. {"单位", "CompanyFullName" },
  20539. {"职务", "Job" },
  20540. {"出生日期", "Birthday" },
  20541. };
  20542. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  20543. foreach (var item in clients_JObject)
  20544. {
  20545. BaiduClientOCRView cdc = new BaiduClientOCRView();
  20546. foreach (var field in clientFieldMap.Keys)
  20547. {
  20548. if (item.TryGetValue(field, out JToken value))
  20549. {
  20550. var getValue = value.ToString();
  20551. System.Type type = cdc.GetType();
  20552. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  20553. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  20554. propertyInfo.SetValue(cdc, propertyValue);
  20555. }
  20556. }
  20557. crmClients.Add(cdc);
  20558. }
  20559. return Ok(JsonView(new
  20560. {
  20561. fileCount = files.Count,
  20562. UploadCount = seedConter.Count,
  20563. ApiResult = clients,
  20564. CrmClients = crmClients
  20565. }));
  20566. }
  20567. #endregion
  20568. #region 团组倒推表
  20569. /// <summary>
  20570. /// 倒推表基础数据
  20571. /// Init
  20572. /// </summary>
  20573. /// <returns></returns>
  20574. [HttpPost]
  20575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20576. public async Task<IActionResult> PostInvertedListInit()
  20577. {
  20578. var viewData = await _invertedListRep._Init();
  20579. if (viewData.Code != 0)
  20580. {
  20581. return Ok(JsonView(false, viewData.Msg));
  20582. }
  20583. return Ok(JsonView(viewData.Data));
  20584. }
  20585. /// <summary>
  20586. /// 倒推表
  20587. /// Info
  20588. /// </summary>
  20589. /// <param name="dto"></param>
  20590. /// <returns></returns>
  20591. [HttpPost]
  20592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20593. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  20594. {
  20595. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  20596. if (viewData.Code != 0)
  20597. {
  20598. return Ok(JsonView(false, viewData.Msg));
  20599. }
  20600. return Ok(JsonView(viewData.Data));
  20601. }
  20602. /// <summary>
  20603. /// 倒推表
  20604. /// Create
  20605. /// </summary>
  20606. /// <param name="dto"></param>
  20607. /// <returns></returns>
  20608. [HttpPost]
  20609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20610. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  20611. {
  20612. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  20613. if (viewData.Code != 0)
  20614. {
  20615. return Ok(JsonView(false, viewData.Msg));
  20616. }
  20617. return Ok(JsonView(viewData.Data));
  20618. }
  20619. /// <summary>
  20620. /// 倒推表
  20621. /// Update
  20622. /// </summary>
  20623. /// <param name="dto"></param>
  20624. /// <returns></returns>
  20625. [HttpPost]
  20626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20627. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  20628. {
  20629. var viewData = await _invertedListRep._Update(dto);
  20630. if (viewData.Code != 0)
  20631. {
  20632. return Ok(JsonView(false, viewData.Msg));
  20633. }
  20634. return Ok(JsonView(viewData.Data));
  20635. }
  20636. /// <summary>
  20637. /// 倒推表
  20638. /// File Download
  20639. /// </summary>
  20640. /// <param name="dto"></param>
  20641. /// <returns></returns>
  20642. [HttpPost]
  20643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20644. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  20645. {
  20646. var info2 = await _invertedListRep._Info(1, dto.DiId);
  20647. if (info2.Code != 0)
  20648. {
  20649. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  20650. }
  20651. var info1 = info2.Data as InvertedListInfoView;
  20652. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  20653. string teamName = "";
  20654. if (info != null) teamName = info.TeamName;
  20655. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  20656. var doc = new Document();
  20657. var builder = new DocumentBuilder(doc);
  20658. #region old insert
  20659. ////载入模板
  20660. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  20661. //Document doc = new Document(tempPath);
  20662. //DocumentBuilder builder = new DocumentBuilder(doc);
  20663. //利用键值对存放数据
  20664. //Dictionary<string, string> dic = new Dictionary<string, string>();
  20665. //dic.Add("TeamName", teamName);
  20666. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  20667. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  20668. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  20669. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  20670. //dic.Add("SQRemark", info1.ApprovalRemark);
  20671. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  20672. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  20673. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  20674. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  20675. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  20676. //dic.Add("QZRemark", info1.VisaInformationRemark);
  20677. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  20678. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  20679. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  20680. //dic.Add("CQRemark", info1.IssueVisaRemark);
  20681. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  20682. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  20683. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  20684. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  20685. //#region 填充word模板书签内容
  20686. //foreach (var key in dic.Keys)
  20687. //{
  20688. // builder.MoveToBookmark(key);
  20689. // builder.Write(dic[key]);
  20690. //}
  20691. //#endregion
  20692. #endregion
  20693. #region New Insert
  20694. string titleFont = $"仿宋",
  20695. contentFont = $"仿宋";
  20696. var fontColor = Color.FromArgb(64, 64, 64);
  20697. //设置标题 团组名称
  20698. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20699. builder.Font.Name = titleFont;
  20700. builder.Font.Color = fontColor;
  20701. builder.Font.Size = 12;
  20702. builder.Font.Bold = true;
  20703. builder.Writeln(teamName);
  20704. //设置副标题 团组出访时间
  20705. builder.Font.Size = 12;
  20706. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  20707. builder.Writeln();
  20708. var backgroundColor = Color.FromArgb(199, 199, 199);
  20709. var table = builder.StartTable();
  20710. builder.InsertCell();
  20711. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  20712. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  20713. builder.CellFormat.Borders.LineWidth = 1;
  20714. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  20715. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  20716. builder.RowFormat.Height = 40;
  20717. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20718. builder.Font.Name = contentFont;
  20719. builder.Font.Size = 12;
  20720. builder.Font.Bold = true;
  20721. builder.Font.Color = fontColor;
  20722. builder.Write("时间");
  20723. builder.InsertCell();
  20724. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  20725. builder.Write("流程");
  20726. builder.InsertCell();
  20727. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  20728. builder.Write("说明");
  20729. builder.EndRow();
  20730. //报批资料准备
  20731. if (info1.IsSelectedAirportd)
  20732. {
  20733. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  20734. }
  20735. //报批/提供送签资料
  20736. if (info1.IsSelectedApprovalData)
  20737. {
  20738. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  20739. }
  20740. //出批件护照办理
  20741. if (info1.IsSelectedIssueApproval)
  20742. {
  20743. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  20744. }
  20745. //签证资料准备
  20746. if (info1.IsSelectedVisaInfo)
  20747. {
  20748. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  20749. }
  20750. //送签
  20751. if (info1.IsSelectedSendVisa)
  20752. {
  20753. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  20754. }
  20755. //出签
  20756. if (info1.IsSelectedIssueVisa)
  20757. {
  20758. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  20759. }
  20760. //机票
  20761. if (info1.IsSelectedAirTicket)
  20762. {
  20763. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  20764. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  20765. }
  20766. //酒店
  20767. if (info1.IsSelectedHotel)
  20768. {
  20769. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  20770. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  20771. }
  20772. //开行前会
  20773. if (info1.IsSelectedPreTripMeeting)
  20774. {
  20775. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  20776. }
  20777. //送机
  20778. if (info1.IsSelectedAirportdDropOff)
  20779. {
  20780. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  20781. }
  20782. builder.EndTable();
  20783. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  20784. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  20785. for (int i = 0; i < table.Rows.Count; i++)
  20786. {
  20787. var row = table.Rows[i];
  20788. //设置宽度
  20789. row.Cells[0].CellFormat.Width = 20.00;
  20790. row.Cells[1].CellFormat.Width = 30.00;
  20791. row.Cells[2].CellFormat.Width = 50.00;
  20792. if (i != 0)
  20793. {
  20794. //边框设置
  20795. InvertedListFileDownloadSetBorders(row.Cells, 0);
  20796. InvertedListFileDownloadSetBorders(row.Cells, 1);
  20797. InvertedListFileDownloadSetBorders(row.Cells, 2);
  20798. }
  20799. }
  20800. #region 页脚插入图片
  20801. // 创建页脚
  20802. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  20803. doc.FirstSection.HeadersFooters.Add(footer);
  20804. Paragraph para = new Paragraph(doc);
  20805. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  20806. footer.AppendChild(para);
  20807. builder.MoveTo(para);
  20808. string imagePath = "./Images/FMGJ_Log.png";
  20809. builder.InsertImage(imagePath);
  20810. #endregion
  20811. #endregion
  20812. var fileDir = AppSettingsHelper.Get("WordBasePath");
  20813. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  20814. string filePath = fileDir + $@"InvertedList/{fileName}";
  20815. doc.Save(filePath);
  20816. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  20817. return Ok(JsonView(true, "操作成功!", Url));
  20818. }
  20819. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  20820. {
  20821. var fontColor = Color.FromArgb(64, 64, 64);
  20822. builder.InsertCell();
  20823. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  20824. builder.RowFormat.Height = 40;
  20825. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20826. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20827. builder.Font.Name = fontName;
  20828. builder.Font.Size = 8;
  20829. builder.Font.Bold = true;
  20830. builder.Font.Color = fontColor;
  20831. builder.Write(dateTime);
  20832. builder.InsertCell();
  20833. builder.Font.Size = 9;
  20834. builder.Font.Bold = true;
  20835. builder.Font.Color = fontColor;
  20836. builder.Write(content);
  20837. builder.InsertCell();
  20838. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20839. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20840. builder.Font.Size = 9;
  20841. builder.Font.Bold = false;
  20842. builder.Font.Color = fontColor;
  20843. builder.Write(reamrk);
  20844. builder.EndRow();
  20845. }
  20846. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  20847. {
  20848. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  20849. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  20850. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  20851. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  20852. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  20853. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  20854. }
  20855. #endregion
  20856. #region 会务倒推表
  20857. /// <summary>
  20858. /// 会务倒推表
  20859. /// Init
  20860. /// </summary>
  20861. /// <returns></returns>
  20862. [HttpPost]
  20863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20864. public async Task<IActionResult> InforRetrogressTableInit()
  20865. {
  20866. var groupData = await _groupRepository.PostShareGroupInfos(1);
  20867. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  20868. return Ok(JsonView(false, groupData.Msg));
  20869. }
  20870. /// <summary>
  20871. /// 会务倒推表
  20872. /// ExcelDownload
  20873. /// </summary>
  20874. /// <param name="dto"></param>
  20875. /// <returns></returns>
  20876. [HttpPost]
  20877. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  20878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20879. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  20880. {
  20881. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  20882. var validatorRes = await validator.ValidateAsync(dto);
  20883. if (!validatorRes.IsValid)
  20884. {
  20885. StringBuilder sb = new StringBuilder();
  20886. foreach (var item in validatorRes.Errors)
  20887. {
  20888. sb.AppendLine(item.ErrorMessage);
  20889. }
  20890. return Ok(JsonView(false, sb.ToString()));
  20891. }
  20892. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20893. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20894. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20895. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20896. #region Excel
  20897. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  20898. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  20899. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  20900. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  20901. var fileNamePrefix = string.Empty;
  20902. if (days >= 30)
  20903. {
  20904. tempPath += $"会务工作倒推进度表(30天).xlsx";
  20905. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  20906. }
  20907. else if (days < 30 && days > 7)
  20908. {
  20909. tempPath += $"会务工作倒推进度表(15天).xlsx";
  20910. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  20911. }
  20912. else if (days <= 7)
  20913. {
  20914. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20915. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20916. }
  20917. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  20918. fileName = CommonFun.ValidFileName(fileName);
  20919. //载入模板
  20920. WorkbookDesigner designer = new WorkbookDesigner();
  20921. designer.Workbook = new Workbook(tempPath);
  20922. designer.Process();
  20923. if (!Directory.Exists(savePath))
  20924. {
  20925. Directory.CreateDirectory(savePath);
  20926. }
  20927. string serverPath = $"{savePath}{fileName}";
  20928. designer.Workbook.Save(serverPath);
  20929. string rst = $"{servicePath}{ftpPath}{fileName}";
  20930. #endregion
  20931. return Ok(JsonView(new { url = rst }));
  20932. }
  20933. #endregion
  20934. #region 三公签证费用(签证费、代办费)
  20935. /// <summary>
  20936. /// 三公签证费用(签证费、代办费)
  20937. /// List
  20938. /// </summary>
  20939. /// <returns></returns>
  20940. [HttpPost]
  20941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20942. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  20943. {
  20944. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  20945. }
  20946. /// <summary>
  20947. /// 三公签证费用(签证费、代办费)
  20948. /// Add Or Update
  20949. /// </summary>
  20950. /// <returns></returns>
  20951. [HttpPost]
  20952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20953. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  20954. {
  20955. var _view = await _visaFeeInfoRep.Update(_dto);
  20956. if (_view.Code != 0)
  20957. {
  20958. return Ok(JsonView(false, _view.Msg));
  20959. }
  20960. return Ok(JsonView(true, _view.Msg));
  20961. }
  20962. #endregion
  20963. #region 酒店询价
  20964. /// <summary>
  20965. /// 酒店询价
  20966. /// Init
  20967. /// </summary>
  20968. /// <returns></returns>
  20969. [HttpPost]
  20970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20971. public async Task<IActionResult> PostHotelInquiryInit()
  20972. {
  20973. var res = await _hotelInquiryRep._Init();
  20974. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20975. return Ok(JsonView(true, res.Msg, res.Data));
  20976. }
  20977. /// <summary>
  20978. /// 酒店询价
  20979. /// page Item
  20980. /// </summary>
  20981. /// <param name="_dto"></param>
  20982. /// <returns></returns>
  20983. [HttpPost]
  20984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20985. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  20986. {
  20987. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  20988. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20989. var view = res.Data as PageDataViewBase;
  20990. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  20991. }
  20992. /// <summary>
  20993. /// 酒店询价
  20994. /// info
  20995. /// </summary>
  20996. /// <param name="_dto"></param>
  20997. /// <returns></returns>
  20998. [HttpPost]
  20999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21000. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  21001. {
  21002. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  21003. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21004. return Ok(JsonView(true, res.Msg, res.Data));
  21005. }
  21006. /// <summary>
  21007. /// 酒店询价
  21008. /// Add Or Edit
  21009. /// </summary>
  21010. /// <param name="_dto"></param>
  21011. /// <returns></returns>
  21012. [HttpPost]
  21013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21014. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  21015. {
  21016. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  21017. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21018. return Ok(JsonView(true, res.Msg, res.Data));
  21019. }
  21020. /// <summary>
  21021. /// 酒店询价
  21022. /// Del
  21023. /// </summary>
  21024. /// <param name="_dto"></param>
  21025. /// <returns></returns>
  21026. [HttpPost]
  21027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21028. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  21029. {
  21030. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  21031. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21032. return Ok(JsonView(true, res.Msg, res.Data));
  21033. }
  21034. #endregion
  21035. #region 下载匹配op行程单
  21036. /// <summary>
  21037. /// 匹配op行程单
  21038. /// Init
  21039. /// </summary>
  21040. /// <param name="dto">团组列表请求dto</param>
  21041. /// <returns></returns>
  21042. [HttpPost]
  21043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21044. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  21045. {
  21046. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21047. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21048. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  21049. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  21050. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  21051. .Where(it => it.IsDel == 0)
  21052. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  21053. .OrderByDescending(it => it.VisitStartDate)
  21054. .ToList();
  21055. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  21056. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21057. var diids = groupInfos.Select(it => it.Id).ToList();
  21058. List<string> countrys = new List<string>();
  21059. foreach (var item in country)
  21060. {
  21061. var data = _groupRepository.FormartTeamName(item);
  21062. var dataArray = _groupRepository.GroupSplitCountry(data);
  21063. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21064. }
  21065. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  21066. List<string> areaArray = new List<string>(); //GetGroupCityLine
  21067. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  21068. foreach (var item in areaItem)
  21069. {
  21070. string areaStr = item.Value;
  21071. if (!string.IsNullOrEmpty(areaStr))
  21072. {
  21073. string[] str1 = areaStr.Split("-");
  21074. if (str1.Length > 0)
  21075. {
  21076. areaArray.AddRange(str1);
  21077. }
  21078. }
  21079. }
  21080. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  21081. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  21082. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  21083. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  21084. .ToList();
  21085. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  21086. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  21087. .Where(it => countriesIds.Contains(it.Id))
  21088. .Select(it => new { it.Id, Name = it.Name_CN })
  21089. .ToList();
  21090. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  21091. .Select(it => it.TeamName).ToList();
  21092. stopwatch.Stop();
  21093. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  21094. }
  21095. ///// <summary>
  21096. ///// 匹配op行程单
  21097. ///// Init 查询区域数据
  21098. ///// </summary>
  21099. ///// <param name="dto">团组列表请求dto</param>
  21100. ///// <returns></returns>
  21101. //[HttpPost]
  21102. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21103. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  21104. //{
  21105. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21106. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  21107. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  21108. // if (string.IsNullOrEmpty(countriesDataStr))
  21109. // {
  21110. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  21111. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  21112. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  21113. // }
  21114. // else
  21115. // {
  21116. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  21117. // }
  21118. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  21119. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  21120. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  21121. // List<dynamic> childList = new List<dynamic>();
  21122. // int parentId = dto.CountriesId;
  21123. // if (provinceData.Count > 1)
  21124. // {
  21125. // foreach (var item1 in provinceData)
  21126. // {
  21127. // List<dynamic> childList1 = new List<dynamic>();
  21128. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  21129. // foreach (var item2 in citiesData1)
  21130. // {
  21131. // List<dynamic> childList2 = new List<dynamic>();
  21132. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21133. // foreach (var item3 in countiesData1)
  21134. // {
  21135. // childList2.Add(new
  21136. // {
  21137. // id = item3.Id,
  21138. // parentId = item2.Id,
  21139. // level = "district",
  21140. // name = item3.Name_CN,
  21141. // });
  21142. // }
  21143. // childList1.Add(new
  21144. // {
  21145. // id = item2.Id,
  21146. // parentId = item1.Id,
  21147. // level = "city",
  21148. // name = item2.Name_CN,
  21149. // childList = childList2
  21150. // });
  21151. // }
  21152. // childList.Add(new
  21153. // {
  21154. // id = item1.Id,
  21155. // parentId = parentId,
  21156. // level = "province",
  21157. // name = item1.Name_CN,
  21158. // childList = childList1
  21159. // });
  21160. // }
  21161. // //城市
  21162. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  21163. // foreach (var item2 in citiesData2)
  21164. // {
  21165. // List<dynamic> childList22 = new List<dynamic>();
  21166. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21167. // foreach (var item3 in countiesData1)
  21168. // {
  21169. // childList22.Add(new
  21170. // {
  21171. // id = item3.Id,
  21172. // parentId = item2.Id,
  21173. // level = "district",
  21174. // name = item3.Name_CN,
  21175. // });
  21176. // }
  21177. // childList.Add(new
  21178. // {
  21179. // id = item2.Id,
  21180. // parentId = parentId,
  21181. // level = "city",
  21182. // name = item2.Name_CN,
  21183. // childList = childList22
  21184. // });
  21185. // }
  21186. // }
  21187. // else
  21188. // {
  21189. // foreach (var item2 in citiesData)
  21190. // {
  21191. // string cname = item2.Name_CN;
  21192. // List<dynamic> childList1 = new List<dynamic>();
  21193. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21194. // foreach (var item3 in countiesData1)
  21195. // {
  21196. // childList1.Add(new
  21197. // {
  21198. // Id = item3.Id,
  21199. // parentId = item2.Id,
  21200. // level = "district",
  21201. // name = item3.Name_CN
  21202. // });
  21203. // }
  21204. // childList.Add(new
  21205. // {
  21206. // id = item2.Id,
  21207. // parentId = parentId,
  21208. // level = "city",
  21209. // name = item2.Name_CN,
  21210. // childList = childList1
  21211. // });
  21212. // }
  21213. // }
  21214. // stopwatch.Stop();
  21215. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  21216. //}
  21217. /// <summary>
  21218. /// 匹配op行程单
  21219. /// 接团信息列表 Page
  21220. /// </summary>
  21221. /// <param name="dto">团组列表请求dto</param>
  21222. /// <returns></returns>
  21223. [HttpPost]
  21224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21225. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  21226. {
  21227. var swatch = new Stopwatch();
  21228. swatch.Start();
  21229. #region 参数验证
  21230. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21231. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21232. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21233. #region 页面操作权限验证
  21234. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21235. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  21236. #endregion
  21237. #endregion
  21238. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21239. {
  21240. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  21241. //string sqlWhere = "";
  21242. if (!string.IsNullOrEmpty(dto.Country))
  21243. {
  21244. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  21245. }
  21246. if (!string.IsNullOrEmpty(dto.Area))
  21247. {
  21248. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  21249. }
  21250. if (!string.IsNullOrEmpty(dto.TeamName))
  21251. {
  21252. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  21253. }
  21254. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  21255. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  21256. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  21257. swatch.Stop();
  21258. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  21259. }
  21260. else
  21261. {
  21262. return Ok(JsonView(false, "查询失败"));
  21263. }
  21264. }
  21265. /// <summary>
  21266. /// 匹配op行程单
  21267. /// 行程单下载
  21268. /// </summary>
  21269. /// <param name="dto">团组列表请求dto</param>
  21270. /// <returns></returns>
  21271. [HttpPost]
  21272. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21273. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  21274. {
  21275. #region 参数验证
  21276. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21277. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21278. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21279. #region 页面操作权限验证
  21280. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21281. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  21282. #endregion
  21283. #endregion
  21284. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21285. {
  21286. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  21287. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  21288. }
  21289. else
  21290. {
  21291. return Ok(JsonView(false, "下载失败!"));
  21292. }
  21293. }
  21294. #endregion
  21295. #region 国家信息 数据 注释
  21296. //[HttpPost]
  21297. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  21298. //{
  21299. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  21300. // foreach (var item in dto)
  21301. // {
  21302. // infos.Add(new Grp_GroupsTaskAssignment()
  21303. // {
  21304. // DIId = item,
  21305. // CTId = 82,
  21306. // UId = 248,
  21307. // IsEnable = 1,
  21308. // CreateUserId = 233,
  21309. // CreateTime = DateTime.Now,
  21310. // IsDel = 0
  21311. // });
  21312. // infos.Add(new Grp_GroupsTaskAssignment()
  21313. // {
  21314. // DIId = item,
  21315. // CTId = 82,
  21316. // UId = 286,
  21317. // IsEnable = 1,
  21318. // CreateUserId = 233,
  21319. // CreateTime = DateTime.Now,
  21320. // IsDel = 0
  21321. // });
  21322. // }
  21323. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  21324. // return Ok("操作成功");
  21325. //}
  21326. //public class paramJsonDto
  21327. //{
  21328. // public List<CountriesInfo> str { get; set; }
  21329. //}
  21330. //[HttpPost]
  21331. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  21332. //{
  21333. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  21334. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  21335. // List<Sys_Cities> cities = new List<Sys_Cities>();
  21336. // List<Sys_Cities> districts = new List<Sys_Cities>();
  21337. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21338. // _sqlSugar.BeginTran();
  21339. // int countitiesIndex = 0;
  21340. // foreach (var item in dto.str)
  21341. // {
  21342. // dynamic data = item.c;
  21343. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  21344. // if (data != null)
  21345. // {
  21346. // countitiesIndex++;
  21347. // foreach (var item1 in data)
  21348. // {
  21349. // string cnname = item1.cn;
  21350. // string enname = item1.en;
  21351. // Sys_Cities provinceInfo = new Sys_Cities()
  21352. // {
  21353. // CountriesId = countriesId,
  21354. // Name_CN = cnname,
  21355. // Name_EN = enname,
  21356. // ParentId = 0,
  21357. // IsCapital = 1,
  21358. // CreateUserId = 208,
  21359. // CreateTime = DateTime.Now,
  21360. // IsDel = 0
  21361. // };
  21362. // if (item1.lv == "province") //省份
  21363. // {
  21364. // provinceInfo.Level = 1;
  21365. // int provinceId = 0;
  21366. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  21367. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  21368. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21369. // var data1 = item1.c;
  21370. // foreach (var item2 in data1)
  21371. // {
  21372. // if (item2.lv == "city")
  21373. // {
  21374. // string citycnname = item2.cn;
  21375. // string cityenname = item2.en;
  21376. // Sys_Cities cityInfo = new Sys_Cities()
  21377. // {
  21378. // CountriesId = countriesId,
  21379. // ParentId = provinceId,
  21380. // Level = 2,
  21381. // Name_CN = citycnname,
  21382. // Name_EN = cityenname,
  21383. // IsCapital = 1,
  21384. // CreateUserId = 208,
  21385. // CreateTime = DateTime.Now,
  21386. // IsDel = 0
  21387. // };
  21388. // if (item2.c != null)
  21389. // {
  21390. // int cityId = 0;
  21391. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  21392. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21393. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  21394. // foreach (var item3 in item2.c)
  21395. // {
  21396. // if (item3.lv == "district")
  21397. // {
  21398. // var districtInfo = new Sys_Cities()
  21399. // {
  21400. // CountriesId = countriesId,
  21401. // Name_CN = item3.cn,
  21402. // Name_EN = item3.en,
  21403. // Level = 3,
  21404. // ParentId = cityId,
  21405. // IsCapital = 1,
  21406. // CreateUserId = 208,
  21407. // CreateTime = DateTime.Now,
  21408. // IsDel = 0
  21409. // };
  21410. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21411. // //{
  21412. // districts.Add(districtInfo);
  21413. // //}
  21414. // }
  21415. // }
  21416. // }
  21417. // else
  21418. // {
  21419. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  21420. // //{
  21421. // cities.Add(cityInfo);
  21422. // //}
  21423. // }
  21424. // }
  21425. // }
  21426. // }
  21427. // else if (item1.lv == "city")//城市
  21428. // {
  21429. // provinceInfo.Level = 2;
  21430. // if (item1.c != null)
  21431. // {
  21432. // int cityId = 0;
  21433. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  21434. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21435. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21436. // foreach (var item3 in item1.c)
  21437. // {
  21438. // if (item3.lv == "district")
  21439. // {
  21440. // var districtInfo = new Sys_Cities()
  21441. // {
  21442. // CountriesId = countriesId,
  21443. // Name_CN = item3.cn,
  21444. // Name_EN = item3.en,
  21445. // Level = 3,
  21446. // ParentId = cityId,
  21447. // IsCapital = 1,
  21448. // CreateUserId = 208,
  21449. // CreateTime = DateTime.Now,
  21450. // IsDel = 0
  21451. // };
  21452. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21453. // //{
  21454. // districts.Add(districtInfo);
  21455. // //}
  21456. // }
  21457. // }
  21458. // }
  21459. // else
  21460. // {
  21461. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  21462. // //{
  21463. // cities.Add(provinceInfo);
  21464. // //}
  21465. // }
  21466. // }
  21467. // }
  21468. // }
  21469. // }
  21470. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  21471. // cities = cities.Distinct().ToList();
  21472. // districts = districts.Distinct().ToList();
  21473. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  21474. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  21475. // cities.AddRange(districts);
  21476. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  21477. // //_sqlSugar.RollbackTran();
  21478. // _sqlSugar.CommitTran();
  21479. // return Ok(JsonView(false, "操作成功!"));
  21480. //}
  21481. //[HttpPost]
  21482. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  21483. //{
  21484. // List<CountitiesInfo> infos = dto.MyProperty;
  21485. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  21486. // _sqlSugar.BeginTran();
  21487. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21488. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  21489. // foreach (var item in infos)
  21490. // {
  21491. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  21492. // if (countryInfo != null)
  21493. // {
  21494. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  21495. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  21496. // if (cityInfo1 != null)
  21497. // {
  21498. // cityInfo1.IsCapital = 0;
  21499. // cityInfos.Add(cityInfo1);
  21500. // }
  21501. // }
  21502. // }
  21503. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  21504. // .UpdateColumns(it => it.IsCapital)
  21505. // .WhereColumns(it => it.Id)
  21506. // .ExecuteCommand();
  21507. // //_sqlSugar.RollbackTran();
  21508. // _sqlSugar.CommitTran();
  21509. // return Ok(JsonView(false, "操作成功!"));
  21510. //}
  21511. //public class CounrtiesDto
  21512. //{
  21513. // public List<CountitiesInfo> MyProperty { get; set; }
  21514. //}
  21515. //public class CountitiesInfo
  21516. //{
  21517. // /// <summary>
  21518. // /// 圣约翰
  21519. // /// </summary>
  21520. // public string capital_name_chinese { get; set; }
  21521. // /// <summary>
  21522. // ///
  21523. // /// </summary>
  21524. // public string capital_name { get; set; }
  21525. // /// <summary>
  21526. // ///
  21527. // /// </summary>
  21528. // public string country_type { get; set; }
  21529. // /// <summary>
  21530. // /// 安提瓜和巴布达
  21531. // /// </summary>
  21532. // public string country_name_chinese { get; set; }
  21533. // /// <summary>
  21534. // /// 安提瓜和巴布达
  21535. // /// </summary>
  21536. // public string country_name_chinese_short { get; set; }
  21537. // /// <summary>
  21538. // /// 安提瓜和巴布达
  21539. // /// </summary>
  21540. // public string country_name_chinese_UN { get; set; }
  21541. // /// <summary>
  21542. // ///
  21543. // /// </summary>
  21544. // public string country_name_english_abbreviation { get; set; }
  21545. // /// <summary>
  21546. // ///
  21547. // /// </summary>
  21548. // public string country_name_english_formal { get; set; }
  21549. // /// <summary>
  21550. // ///
  21551. // /// </summary>
  21552. // public string country_name_english_UN { get; set; }
  21553. // /// <summary>
  21554. // ///
  21555. // /// </summary>
  21556. // public string continent_name { get; set; }
  21557. // /// <summary>
  21558. // ///
  21559. // /// </summary>
  21560. // public string subregion_name { get; set; }
  21561. // /// <summary>
  21562. // ///
  21563. // /// </summary>
  21564. // public string country_code2 { get; set; }
  21565. // /// <summary>
  21566. // ///
  21567. // /// </summary>
  21568. // public string country_code3 { get; set; }
  21569. // /// <summary>
  21570. // ///
  21571. // /// </summary>
  21572. // public string phone_code { get; set; }
  21573. //}
  21574. //public class CountriesInfo : BasicInfo
  21575. //{
  21576. // public List<CitiesInfo> c { get; set; }
  21577. //}
  21578. //public class CitiesInfo : BasicInfo
  21579. //{
  21580. // public List<AreaInfo> c { get; set; }
  21581. //}
  21582. //public class AreaInfo : BasicInfo
  21583. //{
  21584. // public List<AreaInfo> c { get; set; }
  21585. //}
  21586. //public class BasicInfo
  21587. //{
  21588. // public string code { get; set; }
  21589. // public string cn { get; set; }
  21590. // public string lv { get; set; }
  21591. // public string en { get; set; }
  21592. //}
  21593. #endregion
  21594. #region 查看邀请方
  21595. /// <summary>
  21596. /// 查看邀请方
  21597. /// 邀请方信息 Init
  21598. /// </summary>
  21599. /// <param name="dto"></param>
  21600. /// <returns></returns>
  21601. [HttpPost]
  21602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21603. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  21604. {
  21605. string sqlWhere = string.Empty;
  21606. if (!string.IsNullOrEmpty(dto.Search))
  21607. {
  21608. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  21609. }
  21610. string sql = string.Format($@"Select
  21611. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  21612. Id,
  21613. UnitName
  21614. From Res_InvitationOfficialActivityData
  21615. Where IsDel = 0
  21616. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  21617. RefAsync<int> total = 0;
  21618. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21619. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  21620. }
  21621. /// <summary>
  21622. /// 查看邀请方
  21623. /// 国家信息 Init
  21624. /// </summary>
  21625. /// <param name="dto"></param>
  21626. /// <returns></returns>
  21627. [HttpPost]
  21628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21629. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  21630. {
  21631. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  21632. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21633. var diids = groupInfos.Select(it => it.Id).ToList();
  21634. List<string> countrys = new List<string>();
  21635. foreach (var item in country)
  21636. {
  21637. var data = _groupRepository.FormartTeamName(item);
  21638. var dataArray = _groupRepository.GroupSplitCountry(data);
  21639. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21640. }
  21641. countrys = countrys.Distinct().ToList();
  21642. for (int i = 0; i < countrys.Count; i++)
  21643. {
  21644. string item = countrys[i];
  21645. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  21646. {
  21647. countrys.Remove(item);
  21648. i--;
  21649. }
  21650. }
  21651. RefAsync<int> total = 0;
  21652. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  21653. .Where(it => countrys.Contains(it.Name_CN))
  21654. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21655. .Select(it => new { id = it.Id, name = it.Name_CN })
  21656. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21657. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21658. }
  21659. /// <summary>
  21660. /// 查看邀请方
  21661. /// 城市信息 Init
  21662. /// </summary>
  21663. /// <param name="dto"></param>
  21664. /// <returns></returns>
  21665. [HttpPost]
  21666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21667. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  21668. {
  21669. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  21670. RefAsync<int> total = 0;
  21671. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  21672. .Where(it => it.CountriesId == dto.CountiesId)
  21673. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21674. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  21675. .Select(it => new { id = it.Id, name = it.Name_CN })
  21676. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21677. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21678. }
  21679. /// <summary>
  21680. /// 查看邀请方
  21681. /// 团组名称 Init
  21682. /// </summary>
  21683. /// <param name="dto"></param>
  21684. /// <returns></returns>
  21685. [HttpPost]
  21686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21687. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  21688. {
  21689. var watch = new Stopwatch();
  21690. watch.Start();
  21691. RefAsync<int> total = 0;
  21692. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  21693. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  21694. .Where((oa, di) => oa.IsDel == 0)
  21695. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  21696. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  21697. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  21698. .Distinct()
  21699. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21700. watch.Stop();
  21701. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  21702. }
  21703. /// <summary>
  21704. /// 查看邀请方
  21705. /// 团组 & 邀请方信息
  21706. /// </summary>
  21707. /// <param name="dto"></param>
  21708. /// <returns></returns>
  21709. [HttpPost]
  21710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21711. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  21712. {
  21713. var watch = new Stopwatch();
  21714. watch.Start();
  21715. RefAsync<int> total = 0;
  21716. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  21717. .AS("Grp_DelegationInfo")
  21718. .Includes(x => x.InvitingInfos)
  21719. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  21720. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  21721. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  21722. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  21723. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  21724. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  21725. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21726. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  21727. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  21728. infos.ForEach(x =>
  21729. {
  21730. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  21731. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  21732. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  21733. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  21734. });
  21735. watch.Stop();
  21736. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  21737. }
  21738. #endregion
  21739. #region 报批行程
  21740. /// <summary>
  21741. /// 报批行程初始化
  21742. /// </summary>
  21743. /// <param name="dto"></param>
  21744. /// <returns></returns>
  21745. [HttpPost]
  21746. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  21747. {
  21748. const int chiNumber = 5;
  21749. var jw = JsonView(false);
  21750. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  21751. var group = groupList.First();
  21752. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  21753. group = groupList.First(x => x.Id == diid);
  21754. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21755. .Where(x => x.DiId == diid && x.IsDel == 0)
  21756. .ToArray();
  21757. var count = 1;
  21758. foreach (var item in blackCodeList)
  21759. {
  21760. if (string.IsNullOrWhiteSpace(item.Title))
  21761. {
  21762. item.Title = "未设置名称数据" + count;
  21763. }
  21764. count++;
  21765. }
  21766. ;
  21767. if (group == null)
  21768. {
  21769. jw.Msg = "暂无团组!";
  21770. return Ok(jw);
  21771. }
  21772. var data = new
  21773. {
  21774. groupList = groupList.Select(x => new
  21775. {
  21776. x.TeamName,
  21777. x.Id
  21778. }),
  21779. content = new ArrayList(),
  21780. groupInfo = new
  21781. {
  21782. group.VisitDays,
  21783. group.TourCode,
  21784. group.VisitPNumber,
  21785. group.TeamName,
  21786. group.Id,
  21787. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  21788. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  21789. group.ClientUnit
  21790. },
  21791. blackCodeList = blackCodeList.Select(x => new
  21792. {
  21793. x.Title,
  21794. x.Id
  21795. }),
  21796. FileTempList = new ArrayList()
  21797. {
  21798. new { Index = 1,FileName = "旧模板" },
  21799. new { Index = 2,FileName = "省外办" },
  21800. new { Index = 3,FileName = "市外办" },
  21801. }
  21802. };
  21803. var resultArr = new ArrayList();
  21804. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  21805. #region 默认不生成行程
  21806. //if (content.Count == 0)
  21807. //{
  21808. // var stay = "-";
  21809. // var cityPath = "-";
  21810. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21811. // .Where(x => x.DiId == diid && x.IsDel == 0)
  21812. // .ToList();
  21813. // //添加城市路径以及住宿地
  21814. // //黑屏代码数据
  21815. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  21816. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21817. // {
  21818. // jw = JsonView(true, "黑屏代码有误!", data);
  21819. // return Ok(jw);
  21820. // }
  21821. // data = data with
  21822. // {
  21823. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  21824. // {
  21825. // x.Title,
  21826. // x.Id,
  21827. // }).ToArray())
  21828. // };
  21829. // foreach (DataRow row in dtBlack.Rows)
  21830. // {
  21831. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21832. // {
  21833. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  21834. // return Ok(jw);
  21835. // }
  21836. // }
  21837. // //黑屏代码获取时间区间
  21838. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21839. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21840. // _sqlSugar.BeginTran();
  21841. // for (int i = 0; i < timeArr.Count; i++)
  21842. // {
  21843. // stay = "-";
  21844. // cityPath = "-";
  21845. // DateTime NewData = DateTime.Parse(timeArr[i]);
  21846. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21847. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21848. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21849. // if (tbSelect.Length > 0)
  21850. // {
  21851. // List<string> threeCodeStr = new List<string>();
  21852. // foreach (var item in tbSelect)
  21853. // {
  21854. // var threeCode = item["Three"].ToString() ?? "";
  21855. // if (threeCode.Length == 6)
  21856. // {
  21857. // var start = threeCode.Substring(0, 3);
  21858. // var end = threeCode.Substring(3, 3);
  21859. // if (threeCodeStr.Count == 0)
  21860. // {
  21861. // threeCodeStr.Add(start);
  21862. // threeCodeStr.Add(end);
  21863. // }
  21864. // else
  21865. // {
  21866. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21867. // {
  21868. // threeCodeStr.Add(end);
  21869. // }
  21870. // else
  21871. // {
  21872. // threeCodeStr.Add(start);
  21873. // threeCodeStr.Add(end);
  21874. // }
  21875. // }
  21876. // }
  21877. // }
  21878. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21879. // var last = threeCodeStr.Last();
  21880. // foreach (var item in threeCodeStr)
  21881. // {
  21882. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21883. // if (item.Equals(last))
  21884. // {
  21885. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21886. // }
  21887. // }
  21888. // cityPath = cityPath.Trim('-');
  21889. // }
  21890. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21891. // appro.Diid = diid ?? -1;
  21892. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21893. // appro.Id = thisId;
  21894. // appro.CreateUserId = dto.UserId;
  21895. // appro.CreateTime = DateTime.Now;
  21896. // content.Add(appro);
  21897. // }
  21898. // _sqlSugar.CommitTran();
  21899. //}
  21900. #endregion
  21901. foreach (var x in content)
  21902. {
  21903. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  21904. if (chiList.Count < chiNumber)
  21905. {
  21906. for (int i = chiList.Count; i < chiNumber; i++)
  21907. {
  21908. chiList.Add(new Grp_ApprovalTravelDetails());
  21909. }
  21910. }
  21911. resultArr.Add(new
  21912. {
  21913. x.Id,
  21914. x.Date,
  21915. x.Diid,
  21916. chiList = chiList.Select(x1 => new
  21917. {
  21918. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21919. x1.Details,
  21920. x1.ParentId,
  21921. x1.Id
  21922. })
  21923. });
  21924. }
  21925. data = data with
  21926. {
  21927. content = resultArr,
  21928. };
  21929. jw = JsonView(true, "获取成功!", data);
  21930. return Ok(jw);
  21931. }
  21932. /// <summary>
  21933. /// 报批行程删除
  21934. /// </summary>
  21935. /// <param name="dto"></param>
  21936. /// <returns></returns>
  21937. [HttpPost]
  21938. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  21939. {
  21940. var jw = JsonView(false);
  21941. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21942. if (group == null)
  21943. {
  21944. jw.Msg = "团组参数有误!";
  21945. return Ok(jw);
  21946. }
  21947. try
  21948. {
  21949. _sqlSugar.BeginTran();
  21950. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  21951. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  21952. {
  21953. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21954. DeleteUserId = dto.uesrId,
  21955. IsDel = 1
  21956. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  21957. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  21958. {
  21959. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21960. DeleteUserId = dto.uesrId,
  21961. IsDel = 1
  21962. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  21963. _sqlSugar.CommitTran();
  21964. jw = JsonView(true, "删除成功");
  21965. }
  21966. catch (Exception ex)
  21967. {
  21968. jw = JsonView(false, ex.Message);
  21969. }
  21970. return Ok(jw);
  21971. }
  21972. /// <summary>
  21973. /// 报批行程保存
  21974. /// </summary>
  21975. /// <param name="dto"></param>
  21976. /// <returns></returns>
  21977. [HttpPost]
  21978. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  21979. {
  21980. var jw = JsonView(false);
  21981. var Find = dto.Arr.Find(x => x.id == 0);
  21982. if (Find != null)
  21983. {
  21984. jw.Msg = "生成的ID为0!";
  21985. return Ok(jw);
  21986. }
  21987. foreach (var item in dto.Arr)
  21988. {
  21989. foreach (var chi in item.chiList)
  21990. {
  21991. if (chi.parentId == 0)
  21992. {
  21993. chi.parentId = item.id;
  21994. }
  21995. }
  21996. }
  21997. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  21998. _sqlSugar.BeginTran();
  21999. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  22000. {
  22001. var parentIds = dto.Arr.Select(x => x.id).ToList();
  22002. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  22003. {
  22004. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22005. DeleteUserId = dto.UserId,
  22006. IsDel = 1
  22007. }).ExecuteCommand();
  22008. }
  22009. try
  22010. {
  22011. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  22012. {
  22013. CreateTime = DateTime.Now,
  22014. CreateUserId = dto.UserId,
  22015. Details = x.details,
  22016. ParentId = x.parentId,
  22017. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22018. Remark = "",
  22019. IsDel = 0
  22020. }).ToList()).ExecuteCommand();
  22021. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  22022. {
  22023. Id = x.id,
  22024. Details = x.details,
  22025. ParentId = x.parentId,
  22026. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22027. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  22028. {
  22029. Details = x.Details,
  22030. ParentId = x.ParentId,
  22031. Time = x.Time
  22032. }).ExecuteCommand();
  22033. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  22034. {
  22035. Id = x.id,
  22036. Date = x.date,
  22037. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  22038. {
  22039. Date = x.Date
  22040. }).ExecuteCommand();
  22041. _sqlSugar.CommitTran();
  22042. jw = JsonView(true, "保存成功!");
  22043. }
  22044. catch (Exception ex)
  22045. {
  22046. _sqlSugar.RollbackTran();
  22047. jw = JsonView(false, "保存失败!" + ex.Message);
  22048. }
  22049. return Ok(jw);
  22050. }
  22051. /// <summary>
  22052. /// 报批行程生成
  22053. /// </summary>
  22054. /// <param name="dto"></param>
  22055. /// <returns></returns>
  22056. [HttpPost]
  22057. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  22058. {
  22059. var jw = JsonView(false);
  22060. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22061. if (group == null)
  22062. {
  22063. jw.Msg = "暂无该团组!";
  22064. return Ok(jw);
  22065. }
  22066. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  22067. //黑屏代码数据
  22068. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  22069. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22070. {
  22071. jw.Msg = "黑屏代码有误!";
  22072. return Ok(jw);
  22073. }
  22074. foreach (DataRow row in dtBlack.Rows)
  22075. {
  22076. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22077. {
  22078. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  22079. return Ok(jw);
  22080. }
  22081. }
  22082. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  22083. var resultArr = new ArrayList();
  22084. //if (officialActivitiesArr.Count == 0)
  22085. //{
  22086. // jw.Msg = "暂无公务出访信息!";
  22087. // return Ok(jw);
  22088. //}
  22089. try
  22090. {
  22091. _sqlSugar.BeginTran();
  22092. DeleteApprovalJourney(new
  22093. Domain.Dtos.Groups.DeleteApprovalJourney
  22094. {
  22095. Diid = dto.Diid,
  22096. uesrId = dto.Userid
  22097. });
  22098. var stay = "-";
  22099. var cityPath = "-";
  22100. var arriveCountry = string.Empty;
  22101. //添加城市路径以及住宿地
  22102. //黑屏代码获取时间区间
  22103. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22104. var empty = "【未收入该三字码!请机票同事录入】";
  22105. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22106. #region 配置公务活动时间
  22107. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  22108. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  22109. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  22110. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  22111. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  22112. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22113. {
  22114. 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" }),
  22115. 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"}),
  22116. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22117. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  22118. };
  22119. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22120. {
  22121. 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" }),
  22122. 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"}),
  22123. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22124. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  22125. };
  22126. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  22127. {
  22128. 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" }),
  22129. 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"}),
  22130. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  22131. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  22132. };
  22133. #endregion
  22134. var nextDayNum = 0;
  22135. for (int i = 0; i < timeArr.Count; i++)
  22136. {
  22137. stay = "-";
  22138. cityPath = "-";
  22139. var chiarr = new List<Grp_ApprovalTravelDetails>();
  22140. DateTime NewData = DateTime.Parse(timeArr[i]);
  22141. //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();
  22142. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22143. if (nextDayNum > 0)
  22144. {
  22145. nextDayNum--;
  22146. }
  22147. if (tbSelect.Length > 0)
  22148. {
  22149. List<string> threeCodeStr = new List<string>();
  22150. bool isTrade = false;
  22151. string trip = string.Empty;
  22152. foreach (var item in tbSelect)
  22153. {
  22154. if (nextDayNum == 0)
  22155. {
  22156. nextDayNum = Convert.ToInt32(item["Sign"]);
  22157. }
  22158. var airStartTime = item["StartTime"].ToString() ?? "0000";
  22159. var airEndTime = item["EndTime"].ToString() ?? "0000";
  22160. var takeOffTime = DateTime.Parse(timeArr[i]);
  22161. var fallToTime = DateTime.Parse(timeArr[i]);
  22162. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  22163. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  22164. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  22165. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  22166. if (nextDayNum > 0)
  22167. {
  22168. fallToTime = fallToTime.AddDays(nextDayNum);
  22169. }
  22170. trip = string.Empty;
  22171. var start = string.Empty;
  22172. var end = string.Empty;
  22173. var threeCode = item["Three"].ToString() ?? "";
  22174. if (threeCode.Length == 6)
  22175. {
  22176. start = threeCode.Substring(0, 3);
  22177. end = threeCode.Substring(3, 3);
  22178. if (threeCodeStr.Count == 0)
  22179. {
  22180. threeCodeStr.Add(start);
  22181. threeCodeStr.Add(end);
  22182. }
  22183. else
  22184. {
  22185. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22186. {
  22187. threeCodeStr.Add(end);
  22188. }
  22189. else
  22190. {
  22191. threeCodeStr.Add(start);
  22192. threeCodeStr.Add(end);
  22193. }
  22194. }
  22195. }
  22196. //处理机票信息
  22197. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  22198. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  22199. if (start_Object == null)
  22200. {
  22201. start_Object = new Res_ThreeCode()
  22202. {
  22203. AirPort = empty,
  22204. AirPort_En = empty,
  22205. City = empty,
  22206. Country = empty,
  22207. Four = empty,
  22208. Three = empty,
  22209. };
  22210. }
  22211. if (end_Object == null)
  22212. {
  22213. end_Object = new Res_ThreeCode()
  22214. {
  22215. AirPort = empty,
  22216. AirPort_En = empty,
  22217. City = empty,
  22218. Country = empty,
  22219. Four = empty,
  22220. Three = empty,
  22221. };
  22222. }
  22223. //机型判断
  22224. string airModel = item["AirModel"].ToString();
  22225. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  22226. string flightTime = item["FlightTime"].ToString();
  22227. flightTime = ParseBlackTime(flightTime);
  22228. //航班号
  22229. string flightcode = item["Fliagtcode"].ToString();
  22230. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  22231. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  22232. if (aircompany == null)
  22233. {
  22234. aircompany = new Res_AirCompany
  22235. {
  22236. CnName = hsEmpty,
  22237. EnName = hsEmpty,
  22238. ShortCode = hsEmpty,
  22239. };
  22240. }
  22241. //航班前公务安排
  22242. if (tbSelect.First().Equals(item) && i != 0)
  22243. {
  22244. foreach (var takeoff in takeoffTimes)
  22245. {
  22246. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  22247. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  22248. {
  22249. foreach (var addTime in takeoff.Item2)
  22250. {
  22251. chiarr.Add(new Grp_ApprovalTravelDetails
  22252. {
  22253. Time = addTime,
  22254. CreateTime = DateTime.Now,
  22255. CreateUserId = dto.Userid,
  22256. ParentId = 0,
  22257. Details = "公务活动"
  22258. });
  22259. }
  22260. break;
  22261. }
  22262. }
  22263. }
  22264. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  22265. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  22266. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  22267. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  22268. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  22269. if (isTrade)
  22270. {
  22271. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  22272. trip += "(转机不出机场)。";
  22273. }
  22274. //else
  22275. //{
  22276. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  22277. //}
  22278. chiarr.Add(new Grp_ApprovalTravelDetails
  22279. {
  22280. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  22281. CreateTime = DateTime.Now,
  22282. CreateUserId = dto.Userid,
  22283. ParentId = 0,
  22284. Details = trip
  22285. });
  22286. //最后一条到达的时间安排公务
  22287. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  22288. {
  22289. bool isCheckCountry = false;
  22290. if (end_Object.Country != arriveCountry)
  22291. {
  22292. arriveCountry = end_Object.Country;
  22293. isCheckCountry = true;
  22294. }
  22295. if (nextDayNum == 0)
  22296. {
  22297. //需要入境的情况
  22298. if (isCheckCountry)
  22299. {
  22300. foreach (var fallTime in fallTimesCheckCountry)
  22301. {
  22302. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22303. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22304. {
  22305. foreach (var addTime in fallTime.Item2)
  22306. {
  22307. chiarr.Add(new Grp_ApprovalTravelDetails
  22308. {
  22309. Time = addTime,
  22310. CreateTime = DateTime.Now,
  22311. CreateUserId = dto.Userid,
  22312. ParentId = 0,
  22313. Details = "公务活动"
  22314. });
  22315. }
  22316. break;
  22317. }
  22318. }
  22319. }
  22320. else
  22321. {
  22322. foreach (var fallTime in fallTimesNotCheckCountry)
  22323. {
  22324. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22325. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22326. {
  22327. foreach (var addTime in fallTime.Item2)
  22328. {
  22329. chiarr.Add(new Grp_ApprovalTravelDetails
  22330. {
  22331. Time = addTime,
  22332. CreateTime = DateTime.Now,
  22333. CreateUserId = dto.Userid,
  22334. ParentId = 0,
  22335. Details = "公务活动"
  22336. });
  22337. }
  22338. break;
  22339. }
  22340. }
  22341. }
  22342. }
  22343. }
  22344. }
  22345. //添加乘车语句
  22346. //chiarr.Add(new Grp_ApprovalTravelDetails
  22347. //{
  22348. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  22349. // CreateTime = DateTime.Now,
  22350. // CreateUserId = dto.Userid,
  22351. // ParentId = 0,
  22352. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  22353. //});
  22354. //if (i != timeArr.Count - 1)
  22355. //{
  22356. // fallToTime = fallToTime.AddHours(2.5);
  22357. // foreach (var item in Times)
  22358. // {
  22359. // //排列公务时间
  22360. // if (fallToTime.Hour < item.Item1)
  22361. // {
  22362. // chiarr.Add(new Grp_ApprovalTravelDetails
  22363. // {
  22364. // Time = $"{item.Item2} - {item.Item3}",
  22365. // CreateTime = DateTime.Now,
  22366. // CreateUserId = dto.Userid,
  22367. // ParentId = 0,
  22368. // Details = "公务活动"
  22369. // });
  22370. // }
  22371. // }
  22372. //}
  22373. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  22374. var last = threeCodeStr.Last();
  22375. foreach (var item in threeCodeStr)
  22376. {
  22377. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  22378. if (item.Equals(last))
  22379. {
  22380. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  22381. }
  22382. }
  22383. cityPath = cityPath.Trim('-');
  22384. }
  22385. else
  22386. {
  22387. foreach (var item in Times)
  22388. {
  22389. chiarr.Add(new Grp_ApprovalTravelDetails
  22390. {
  22391. Time = $"{item.Item2} - {item.Item3}",
  22392. CreateTime = DateTime.Now,
  22393. CreateUserId = dto.Userid,
  22394. ParentId = 0,
  22395. Details = "公务活动"
  22396. });
  22397. }
  22398. }
  22399. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  22400. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  22401. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  22402. appro.Diid = dto.Diid;
  22403. appro.CreateUserId = dto.Userid;
  22404. appro.CreateTime = DateTime.Now;
  22405. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  22406. appro.Id = thisId;
  22407. //foreach (var item in gwinfo)
  22408. //{
  22409. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  22410. // chi.Details = "拜访" + item.Client;
  22411. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  22412. // {
  22413. // chi.Details += "," + item.ReqSample;
  22414. // }
  22415. // chi.ParentId = thisId;
  22416. // chi.Time = item.Time;
  22417. // chiarr.Add(chi);
  22418. //}
  22419. if (chiarr.Count < 6)
  22420. {
  22421. for (int j = chiarr.Count; j < 6; j++)
  22422. {
  22423. chiarr.Add(new
  22424. Grp_ApprovalTravelDetails());
  22425. }
  22426. }
  22427. resultArr.Add(new
  22428. {
  22429. appro.Id,
  22430. appro.Date,
  22431. appro.Diid,
  22432. chiList = chiarr.Select(x1 => new
  22433. {
  22434. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22435. x1.Details,
  22436. x1.ParentId,
  22437. x1.Id
  22438. })
  22439. });
  22440. }
  22441. _sqlSugar.CommitTran();
  22442. jw = JsonView(true, "生成成功!", resultArr);
  22443. }
  22444. catch (Exception ex)
  22445. {
  22446. jw.Code = 400;
  22447. jw.Msg = "生成失败!" + ex.Message;
  22448. }
  22449. return Ok(jw);
  22450. }
  22451. /// <summary>
  22452. /// 报批行程word导出
  22453. /// </summary>
  22454. /// <param name="dto"></param>
  22455. /// <returns></returns>
  22456. [HttpPost]
  22457. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  22458. {
  22459. var jw = JsonView(false);
  22460. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22461. if (group == null)
  22462. {
  22463. jw.Msg = "暂无该团组!";
  22464. return Ok(jw);
  22465. }
  22466. //模板路径
  22467. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  22468. var fileName = string.Empty;
  22469. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  22470. bool bold = false;
  22471. if (dto.FileIndex == 1)
  22472. {
  22473. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  22474. }
  22475. else if (dto.FileIndex == 2)
  22476. {
  22477. fileName = "省外办-报批.docx";
  22478. bold = false;
  22479. titleFont = "方正黑体简体";
  22480. timeFont = "Times New Roman";
  22481. contentFont = "方正仿宋_GBK";
  22482. }
  22483. else if (dto.FileIndex == 3)
  22484. {
  22485. fileName = "市外办-报批.docx";
  22486. titleFont = "方正黑体简体";
  22487. timeFont = "Times New Roman";
  22488. contentFont = "方正仿宋简体";
  22489. }
  22490. tempPath = tempPath + fileName;
  22491. //载入模板
  22492. Document doc = new Document(tempPath);
  22493. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  22494. //获取所填表格的序数
  22495. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  22496. Aspose.Words.Tables.Row titleRowClone = null;
  22497. Aspose.Words.Tables.Row CenterRowClone = null;
  22498. int index = 0;
  22499. int indexChi = 0;
  22500. int SetIndex = 0;
  22501. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  22502. //获取数据,放到datatable
  22503. foreach (var item in ApprovalTravelArr)
  22504. {
  22505. if (index > 0)
  22506. {
  22507. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  22508. tableOne.AppendChild(titleRowClone);
  22509. }
  22510. var textTime = item.Date;
  22511. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  22512. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  22513. SetIndex++;
  22514. if (ChiRep.Count > 0)
  22515. {
  22516. foreach (var itemChi in ChiRep)
  22517. {
  22518. var txtTime = itemChi.Time;
  22519. var txtDetail = itemChi.Details;
  22520. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  22521. {
  22522. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  22523. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22524. //indexChi++;
  22525. //SetIndex++;
  22526. break;
  22527. }
  22528. if (indexChi > 0)
  22529. {
  22530. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22531. tableOne.AppendChild(CenterRowClone);
  22532. }
  22533. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  22534. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  22535. indexChi++;
  22536. SetIndex++;
  22537. }
  22538. }
  22539. //else
  22540. //{
  22541. // if (indexChi > 0)
  22542. // {
  22543. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22544. // tableOne.AppendChild(CenterRowClone);
  22545. // }
  22546. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  22547. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22548. // indexChi++;
  22549. // SetIndex++;
  22550. //}
  22551. index++;
  22552. }
  22553. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  22554. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22555. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22556. jw.Code = 200;
  22557. jw.Msg = "";
  22558. return Ok(jw);
  22559. }
  22560. private string ParseBlackTime(string time)
  22561. {
  22562. // 匹配可能只有分钟的情况
  22563. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  22564. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  22565. if (match.Success)
  22566. {
  22567. string hours = match.Groups[1].Value;
  22568. string minutes = match.Groups[2].Value;
  22569. // 如果小时部分为空,则只显示分钟
  22570. if (string.IsNullOrEmpty(hours))
  22571. {
  22572. return $"{minutes}分钟";
  22573. }
  22574. // 如果分钟部分为空,则只显示小时
  22575. else if (string.IsNullOrEmpty(minutes))
  22576. {
  22577. return $"{hours}小时";
  22578. }
  22579. // 否则显示完整格式
  22580. else
  22581. {
  22582. return $"{hours}小时{minutes}分钟";
  22583. }
  22584. }
  22585. else
  22586. {
  22587. return "未知时长";
  22588. }
  22589. }
  22590. private string intToString(int numberVal)
  22591. {
  22592. string numberval = numberVal.ToString();
  22593. Dictionary<char, string> Number = new Dictionary<char, string>();
  22594. Number.Add('1', "一");
  22595. Number.Add('2', "二");
  22596. Number.Add('3', "三");
  22597. Number.Add('4', "四");
  22598. Number.Add('5', "五");
  22599. Number.Add('6', "六");
  22600. Number.Add('7', "七");
  22601. Number.Add('8', "八");
  22602. Number.Add('9', "九");
  22603. string stringNumberVal = string.Empty;
  22604. for (int i = 0; i < numberval.Length; i++)
  22605. {
  22606. if (i == 0)
  22607. {
  22608. stringNumberVal += Number[numberval[i]];
  22609. }
  22610. else if (i >= 1)
  22611. {
  22612. if (numberval[i] == '0')
  22613. {
  22614. stringNumberVal = "十";
  22615. }
  22616. else
  22617. {
  22618. stringNumberVal += "十" + Number[numberval[i]];
  22619. }
  22620. }
  22621. }
  22622. return stringNumberVal;
  22623. }
  22624. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  22625. {
  22626. //获取table中的某个单元格,从0开始
  22627. Cell lshCell = table.Rows[rows].Cells[cells];
  22628. //将单元格中段落移除
  22629. foreach (Paragraph item in lshCell.Paragraphs)
  22630. {
  22631. lshCell.Paragraphs.Remove(item);
  22632. }
  22633. if (val.Contains("\r\n"))
  22634. {
  22635. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  22636. foreach (var item in spArr)
  22637. {
  22638. //新建一个段落
  22639. Paragraph p = new Paragraph(doc);
  22640. var r = new Run(doc, item);
  22641. //设置字体
  22642. if (!string.IsNullOrEmpty(font))
  22643. {
  22644. r.Font.Name = font;
  22645. }
  22646. r.Font.Bold = bold;
  22647. //把设置的值赋给之前新建的段落
  22648. p.AppendChild(r);
  22649. //将此段落加到单元格内
  22650. lshCell.AppendChild(p);
  22651. }
  22652. }
  22653. else
  22654. {
  22655. //新建一个段落
  22656. Paragraph p = new Paragraph(doc);
  22657. var r = new Run(doc, val);
  22658. //设置字体
  22659. if (!string.IsNullOrEmpty(font))
  22660. {
  22661. r.Font.Name = font;
  22662. }
  22663. r.Font.Bold = bold;
  22664. //把设置的值赋给之前新建的段落
  22665. p.AppendChild(r);
  22666. //将此段落加到单元格内
  22667. lshCell.AppendChild(p);
  22668. }
  22669. }
  22670. /// <summary>
  22671. /// 报批行程AI续写
  22672. /// </summary>
  22673. /// <returns></returns>
  22674. [HttpPost]
  22675. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  22676. {
  22677. var jw = JsonView(false);
  22678. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  22679. {
  22680. jw.Msg = "参数有误!";
  22681. return Ok(jw);
  22682. }
  22683. KiMiApiClient kiMi = new KiMiApiClient();
  22684. List<SeedMessages> messages = new List<SeedMessages>() {
  22685. new SeedMessages
  22686. {
  22687. Role = KimiRole.system,
  22688. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  22689. },
  22690. new SeedMessages
  22691. {
  22692. Role = KimiRole.user,
  22693. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  22694. }
  22695. };
  22696. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  22697. string data = kimi_result.Choices[0]?.Message.Content;
  22698. if (string.IsNullOrWhiteSpace(data))
  22699. {
  22700. jw.Data = "Ai续写失败!";
  22701. }
  22702. else
  22703. {
  22704. jw = JsonView(true, "success!", data);
  22705. }
  22706. return Ok(jw);
  22707. }
  22708. #endregion
  22709. #region 团组接待意见调查
  22710. /// <summary>
  22711. /// 团组接待意见调查 - 信息管理
  22712. /// 基础数据(团组)
  22713. /// </summary>
  22714. /// <returns></returns>
  22715. [HttpGet]
  22716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22717. public async Task<IActionResult> OpinionaireInit()
  22718. {
  22719. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  22720. .Select(x => new
  22721. {
  22722. x.Id,
  22723. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  22724. })
  22725. .OrderByDescending(x => x.Id)
  22726. .ToListAsync();
  22727. return Ok(JsonView(groupData, groupData.Count));
  22728. }
  22729. /// <summary>
  22730. /// 团组接待意见调查 - 信息管理
  22731. /// 列表
  22732. /// </summary>
  22733. /// <param name="groupId"></param>
  22734. /// <returns></returns>
  22735. [HttpGet("{groupId}")]
  22736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22737. public async Task<IActionResult> OpinionaireManageList(int groupId)
  22738. {
  22739. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22740. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  22741. .Select(x => new
  22742. {
  22743. x.Id,
  22744. x.TourGuideName,
  22745. x.CityName,
  22746. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  22747. x.CreateTime
  22748. })
  22749. .OrderBy(x => x.Id)
  22750. .ToListAsync();
  22751. return Ok(JsonView(data));
  22752. }
  22753. /// <summary>
  22754. /// 团组接待意见调查 - 信息管理
  22755. /// 保存
  22756. /// </summary>
  22757. /// <param name="dto"></param>
  22758. /// <returns></returns>
  22759. [HttpPost]
  22760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22761. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  22762. {
  22763. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22764. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22765. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22766. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  22767. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  22768. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  22769. _opinionaireRep.BeginTran();
  22770. if (addData != null && addData.Count > 0)
  22771. {
  22772. foreach (var item in addData)
  22773. {
  22774. item.CreateUserId = currUserInfo.UserId;
  22775. item.DiId = dto.DiId;
  22776. }
  22777. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  22778. }
  22779. if (updData != null && updData.Count > 0)
  22780. {
  22781. var upd = await _opinionaireRep._sqlSugar
  22782. .Updateable(updData)
  22783. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  22784. .WhereColumns(x => new { x.Id })
  22785. .ExecuteCommandAsync();
  22786. }
  22787. _opinionaireRep.CommitTran();
  22788. return Ok(JsonView("操作成功!"));
  22789. }
  22790. /// <summary>
  22791. /// 团组接待意见调查 - 信息管理
  22792. /// 删除
  22793. /// </summary>
  22794. /// <param name="id"></param>
  22795. /// <returns></returns>
  22796. [HttpDelete("{id}")]
  22797. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22798. public async Task<IActionResult> OpinionaireManageDel(int id)
  22799. {
  22800. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22801. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22802. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  22803. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  22804. if (!del) return Ok(JsonView("操作失败!"));
  22805. return Ok(JsonView("操作成功!"));
  22806. }
  22807. /// <summary>
  22808. /// 团组接待意见调查 - 用户
  22809. /// 列表
  22810. /// </summary>
  22811. /// <param name="diId"></param>
  22812. /// <returns></returns>
  22813. [HttpGet("{diId}")]
  22814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22815. public async Task<IActionResult> OpinionaireUserList(int diId)
  22816. {
  22817. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22818. var sql = string.Format(@"
  22819. SELECT
  22820. o.Id,
  22821. o.DiId,
  22822. di.TeamName AS 'GroupName',
  22823. di.VisitPNumber AS 'PeopleNumber',
  22824. di.ClientName AS 'LeadGroup',
  22825. di.VisitCountry AS 'Travel',
  22826. di.VisitDays AS 'Days',
  22827. o.CityName,
  22828. o.TourGuideName,
  22829. o.Catering,
  22830. o.CateringReason,
  22831. o.Stay,
  22832. o.StayReason,
  22833. o.[Route],
  22834. o.RouteReason,
  22835. o.OfficialActivity,
  22836. o.OfficialActivityReason,
  22837. o.TourGuide,
  22838. o.TourGuideReason,
  22839. o.[Translate],
  22840. o.TranslateReason,
  22841. o.Trip,
  22842. o.TripReason,
  22843. o.ESFileName,
  22844. o.SignatureDate,
  22845. o.Remark
  22846. FROM
  22847. Grp_Opinionaire o
  22848. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  22849. WHERE
  22850. o.IsDel = 0
  22851. AND o.DiId = {0}
  22852. ORDER BY
  22853. o.Id ASC", diId);
  22854. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  22855. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  22856. return Ok(JsonView(data));
  22857. }
  22858. /// <summary>
  22859. /// 团组接待意见调查 - 用户
  22860. /// 保存
  22861. /// </summary>
  22862. /// <param name="dto"></param>
  22863. /// <returns></returns>
  22864. [HttpPost]
  22865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22866. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  22867. {
  22868. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  22869. foreach (var item in dto)
  22870. {
  22871. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  22872. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  22873. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  22874. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  22875. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  22876. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  22877. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  22878. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  22879. }
  22880. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  22881. if (!Directory.Exists(filePathBase))
  22882. {
  22883. Directory.CreateDirectory(filePathBase);
  22884. }
  22885. #region 上传文件
  22886. var filePaths = new List<string>();
  22887. foreach (var item in dto)
  22888. {
  22889. var file = item.File;
  22890. // 将文件保存到指定位置
  22891. var filePath = Path.Combine(filePathBase, file.FileName);
  22892. using (var stream = new FileStream(filePath, FileMode.Create))
  22893. {
  22894. await file.CopyToAsync(stream);
  22895. }
  22896. //验证文件是否上传成功
  22897. if (!System.IO.File.Exists(filePath))
  22898. {
  22899. foreach (var filePathStr in filePaths)
  22900. {
  22901. System.IO.File.Delete(filePathStr);
  22902. }
  22903. return Ok(JsonView(false, "文件上传失败!"));
  22904. }
  22905. item.ESFileName = file.FileName;
  22906. }
  22907. #endregion
  22908. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22909. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22910. .UpdateColumns(x => new
  22911. {
  22912. x.Catering,
  22913. x.CateringReason,
  22914. x.Stay,
  22915. x.StayReason,
  22916. x.Route,
  22917. x.RouteReason,
  22918. x.OfficialActivity,
  22919. x.OfficialActivityReason,
  22920. x.TourGuide,
  22921. x.TourGuideReason,
  22922. x.Translate,
  22923. x.TranslateReason,
  22924. x.Trip,
  22925. x.TripReason,
  22926. x.ESFileName,
  22927. x.SignatureDate,
  22928. x.Remark
  22929. })
  22930. .WhereColumns(x => new { x.Id })
  22931. .ExecuteCommandAsync();
  22932. if (upd < 1)
  22933. {
  22934. foreach (var filePathStr in filePaths)
  22935. {
  22936. System.IO.File.Delete(filePathStr);
  22937. }
  22938. return Ok(JsonView(false));
  22939. }
  22940. return Ok(JsonView(true));
  22941. }
  22942. #endregion
  22943. #region 团组餐厅相关信息
  22944. /// <summary>
  22945. /// 团组相关餐厅信息
  22946. /// 基础数据(团组)
  22947. /// </summary>
  22948. /// <returns></returns>
  22949. [HttpGet]
  22950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22951. public async Task<IActionResult> RestaurantInit()
  22952. {
  22953. return Ok(await _restaurantRep.InitAsync());
  22954. }
  22955. /// <summary>
  22956. /// 团组相关餐厅信息
  22957. /// Item
  22958. /// </summary>
  22959. /// <param name="dto"></param>
  22960. /// <returns></returns>
  22961. [HttpPost]
  22962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22963. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  22964. {
  22965. int portType = dto.PortType,
  22966. groupId = dto.GroupId;
  22967. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22968. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22969. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  22970. }
  22971. /// <summary>
  22972. /// 团组相关餐厅信息
  22973. /// List
  22974. /// </summary>
  22975. /// <param name="dto"></param>
  22976. /// <returns></returns>
  22977. [HttpPost]
  22978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22979. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  22980. {
  22981. int portType = dto.PortType,
  22982. groupId = dto.GroupId;
  22983. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22984. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22985. var sql = string.Format(@" SELECT
  22986. ri.Id,
  22987. ri.GroupId,
  22988. ri.Date,
  22989. ri.StartTime,
  22990. ri.EndTime,
  22991. CASE WHEN ri.Type = 1 THEN '早餐'
  22992. WHEN ri.Type = 2 THEN '午餐'
  22993. WHEN ri.Type = 3 THEN '晚餐'
  22994. ELSE '其他'
  22995. END AS 'Type',
  22996. ri.Name,
  22997. ri.Address,
  22998. ri.Tel,
  22999. ri.Remark,
  23000. ri.CreateTime,
  23001. u.CnName AS CreateUserName
  23002. FROM
  23003. Grp_RestaurantInfo ri
  23004. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  23005. WHERE
  23006. ri.IsDel = 0
  23007. AND ri.GroupId = {0}
  23008. ORDER BY
  23009. ri.Date ASC
  23010. ", groupId);
  23011. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  23012. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  23013. return Ok(JsonView(infos));
  23014. }
  23015. /// <summary>
  23016. /// 团组相关餐厅信息
  23017. /// Info
  23018. /// </summary>
  23019. /// <param name="dto"></param>
  23020. /// <returns></returns>
  23021. [HttpPost]
  23022. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23023. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  23024. {
  23025. int portType = dto.PortType,
  23026. id = dto.Id;
  23027. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23028. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23029. return Ok(await _restaurantRep.InfoAsync(portType, id));
  23030. }
  23031. /// <summary>
  23032. /// 团组相关餐厅信息
  23033. /// Op
  23034. /// </summary>
  23035. /// <param name="dto"></param>
  23036. /// <returns></returns>
  23037. [HttpPost]
  23038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23039. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  23040. {
  23041. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23042. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23043. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  23044. return Ok(await _restaurantRep.OpAsync(dto));
  23045. }
  23046. /// <summary>
  23047. /// 团组相关餐厅信息
  23048. /// Del
  23049. /// </summary>
  23050. /// <param name="dto"></param>
  23051. /// <returns></returns>
  23052. [HttpPost]
  23053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23054. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  23055. {
  23056. int userId = dto.DeleteUserId;
  23057. var id = dto.Id;
  23058. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23059. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23060. return Ok(await _restaurantRep.DelAsync(dto));
  23061. }
  23062. #endregion
  23063. #region 团组会务成本
  23064. /// <summary>
  23065. /// 团组会务成本数据初始化
  23066. /// </summary>
  23067. /// <returns></returns>
  23068. [HttpPost]
  23069. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  23070. {
  23071. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23072. .OrderByDescending(x => x.CreateTime)
  23073. .Where(x => x.IsDel == 0)
  23074. .Select<DelegationEasyView>();
  23075. DelegationEasyView di = Dto.GroupId == 0 ?
  23076. expr.First() :
  23077. expr.First(x => x.Id == Dto.GroupId);
  23078. if (di == null)
  23079. {
  23080. return Ok(JsonView(false, "团组信息不存在!"));
  23081. }
  23082. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  23083. .Where(x => x.IsDel == 0 && x.STid == 21)
  23084. .Select(x => new { x.Id, Text = x.Name })
  23085. .ToListAsync();
  23086. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  23087. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  23088. .Select(x => x.Id)
  23089. .ToList();
  23090. //仅检索会务团组
  23091. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  23092. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  23093. .OrderByDescending(x => x.VisitDate)
  23094. .Select(x => new { x.Id, x.TeamName })
  23095. .ToListAsync();
  23096. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  23097. var userList = await _sqlSugar.Queryable<Sys_Users>()
  23098. .Where(x => x.IsDel == 0)
  23099. .Select(x => new { x.Id, x.CnName })
  23100. .ToListAsync();
  23101. var units = await _sqlSugar.Queryable<Sys_SetData>()
  23102. .Where(x => x.IsDel == 0 && x.STid == 119)
  23103. .Select(x => new { x.Id, Text = x.Name })
  23104. .ToListAsync();
  23105. var FileType = new[]
  23106. {
  23107. new { Id = 0 , Name = "成本下载" },
  23108. new { Id = 1 , Name = "报价下载" },
  23109. new { Id = 2 , Name = "总表下载" },
  23110. };
  23111. var GM = new List<int>();
  23112. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  23113. try
  23114. {
  23115. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  23116. }
  23117. catch (Exception ex)
  23118. {
  23119. GM = new List<int>() { 21 };
  23120. }
  23121. var isReview = Dto.UserId == 21;
  23122. var isGM = GM.Contains(Dto.UserId);
  23123. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23124. .Where(x => x.IsDel == 0)
  23125. .Select<ConferenceAffairsCostView>()
  23126. .First(x => x.Diid == di.Id);
  23127. if (ConferenceAffairsCost == null)
  23128. {
  23129. ConferenceAffairsCost = new ConferenceAffairsCostView();
  23130. ConferenceAffairsCost.Diid = di.Id;
  23131. }
  23132. #region 权限校验
  23133. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  23134. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  23135. .Select(x => x.UserId)
  23136. .Distinct()
  23137. .ToList();
  23138. if (!ids.Contains(Dto.UserId) && !isGM)
  23139. {
  23140. return Ok(JsonView(201, "暂无权限!", new
  23141. {
  23142. typeData,
  23143. groupList,
  23144. currenyList,
  23145. isGM,
  23146. userList,
  23147. units,
  23148. isReview,
  23149. operatorUser = ids,
  23150. di,
  23151. FileType
  23152. }));
  23153. }
  23154. #endregion
  23155. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  23156. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  23157. .Select<ConferenceAffairsCostChildView>()
  23158. .OrderBy(x => x.Index)
  23159. .ToList();
  23160. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  23161. {
  23162. ConferenceAffairsCostChi[i - 1].Index = i;
  23163. }
  23164. var backData = new
  23165. {
  23166. ConferenceAffairsCost,
  23167. ConferenceAffairsCostChi,
  23168. typeData,
  23169. groupList,
  23170. currenyList,
  23171. isGM,
  23172. userList,
  23173. units,
  23174. isReview,
  23175. operatorUser = ids,
  23176. di,
  23177. FileType
  23178. };
  23179. return Ok(JsonView(true, "SUCCESS", backData));
  23180. }
  23181. /// <summary>
  23182. /// 会务成本保存
  23183. /// </summary>
  23184. /// <returns></returns>
  23185. [HttpPost]
  23186. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  23187. {
  23188. _sqlSugar.BeginTran();
  23189. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  23190. var childResult = new
  23191. {
  23192. success = 0,
  23193. error = 0
  23194. };
  23195. try
  23196. {
  23197. if (data.Id == 0)
  23198. {
  23199. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23200. .Where(x => x.Diid == Dto.GroupId)
  23201. .SetColumns(x => new Grp_ConferenceAffairsCost
  23202. {
  23203. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23204. DeleteUserId = Dto.UserId
  23205. })
  23206. .ExecuteCommand();
  23207. data.Diid = Dto.GroupId;
  23208. data.CreateTime = DateTime.Now;
  23209. data.CreateUserId = Dto.UserId;
  23210. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  23211. .ExecuteReturnIdentity();
  23212. }
  23213. else
  23214. {
  23215. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  23216. .ExecuteCommand();
  23217. data.Id = data.Id;
  23218. }
  23219. if (Dto.ConferenceAffairsCostChild.Any())
  23220. {
  23221. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  23222. var insertArr = datas.Where(x => x.Id == 0).ToList();
  23223. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  23224. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  23225. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  23226. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  23227. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  23228. .IgnoreColumns(x => new { x.ConferenceAffairsCostId })
  23229. .ExecuteCommand() : 0;
  23230. childResult = childResult with
  23231. {
  23232. error = notUpdateArr.Count(),
  23233. success = inrsetCount + updateCount
  23234. };
  23235. }
  23236. _sqlSugar.CommitTran();
  23237. }
  23238. catch (Exception ex)
  23239. {
  23240. _sqlSugar.RollbackTran();
  23241. return Ok(JsonView(false, "失败!" + ex.Message));
  23242. }
  23243. return Ok(JsonView(true, "操作成功!", childResult));
  23244. }
  23245. [HttpPost]
  23246. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  23247. {
  23248. var count = 0;
  23249. if (Dto.ConferenceAffairsCostChildids.Any())
  23250. {
  23251. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  23252. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  23253. SetColumns(x => new Grp_ConferenceAffairsCostChild
  23254. {
  23255. ReviewStatus = Dto.ReviewStatus
  23256. }).
  23257. ExecuteCommand();
  23258. }
  23259. return Ok(JsonView(true, "操作成功!", count));
  23260. }
  23261. /// <summary>
  23262. /// 会务成本所有数据清除
  23263. /// </summary>
  23264. /// <param name="Dto"></param>
  23265. /// <returns></returns>
  23266. [HttpPost]
  23267. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  23268. {
  23269. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23270. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  23271. _sqlSugar.BeginTran();
  23272. try
  23273. {
  23274. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23275. .Where(x => x.Diid == Dto.GroupId)
  23276. .SetColumns(x => new Grp_ConferenceAffairsCost
  23277. {
  23278. IsDel = 1,
  23279. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23280. DeleteUserId = Dto.UserId
  23281. })
  23282. .ExecuteCommand();
  23283. if (delCount > 0)
  23284. {
  23285. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23286. .Where(x => x.Diid == Dto.GroupId)
  23287. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23288. {
  23289. IsDel = 1,
  23290. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23291. DeleteUserId = Dto.UserId
  23292. })
  23293. .ExecuteCommand();
  23294. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23295. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23296. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23297. {
  23298. IsDel = 1,
  23299. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23300. DeleteUserId = Dto.UserId
  23301. })
  23302. .ExecuteCommand();
  23303. }
  23304. _sqlSugar.CommitTran();
  23305. }
  23306. catch (Exception ex)
  23307. {
  23308. _sqlSugar.RollbackTran();
  23309. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23310. }
  23311. return Ok(JsonView(true, "操作成功!"));
  23312. }
  23313. /// <summary>
  23314. /// 子项数据删除
  23315. /// </summary>
  23316. /// <param name="Dto"></param>
  23317. /// <returns></returns>
  23318. [HttpPost]
  23319. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  23320. {
  23321. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  23322. .Any(x => x.ReviewStatus == 1);
  23323. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  23324. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23325. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  23326. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23327. {
  23328. IsDel = 1,
  23329. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23330. DeleteUserId = Dto.UserId
  23331. })
  23332. .ExecuteCommand();
  23333. return Ok(JsonView(true, "SUCCESS!", count));
  23334. }
  23335. /// <summary>
  23336. /// 会务成本权限分配
  23337. /// </summary>
  23338. /// <param name="Dto"></param>
  23339. /// <returns></returns>
  23340. [HttpPost]
  23341. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  23342. {
  23343. _sqlSugar.BeginTran();
  23344. var count = 0;
  23345. try
  23346. {
  23347. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23348. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23349. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23350. {
  23351. IsDel = 1,
  23352. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23353. DeleteUserId = Dto.CreateUserId
  23354. })
  23355. .ExecuteCommand();
  23356. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  23357. {
  23358. CreateTime = DateTime.Now,
  23359. CreateUserId = Dto.CreateUserId,
  23360. UserId = x,
  23361. Diid = Dto.GroupId,
  23362. }).ToList()).ExecuteCommand();
  23363. _sqlSugar.CommitTran();
  23364. }
  23365. catch (Exception ex)
  23366. {
  23367. _sqlSugar.RollbackTran();
  23368. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23369. }
  23370. return Ok(JsonView(true, "操作成功!", count));
  23371. }
  23372. /// <summary>
  23373. /// 团组会务成本文件下载
  23374. /// </summary>
  23375. /// <returns></returns>
  23376. [HttpPost]
  23377. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  23378. {
  23379. var FileType = new[]
  23380. {
  23381. new { Id = 0 , Name = "成本下载" },
  23382. new { Id = 1 , Name = "报价下载" },
  23383. new { Id = 2 , Name = "总表下载" },
  23384. };
  23385. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23386. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  23387. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23388. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  23389. .Select<DelegationEasyView>()
  23390. .First();
  23391. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23392. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  23393. if (main == null)
  23394. {
  23395. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  23396. }
  23397. JsonView jw = JsonView(false);
  23398. //总表下载
  23399. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  23400. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  23401. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  23402. var field = string.Empty;
  23403. var fileTypeName = string.Empty;
  23404. field = @$"
  23405. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  23406. b.Name as PriceTypeStr ,
  23407. c.Name as CurrencyStr ,
  23408. d.Name as UnitStr ,
  23409. case a.ReviewStatus
  23410. WHEN 1 THEN '已通过'
  23411. WHEN 0 THEN '未审核'
  23412. WHEN -1 THEN '未通过'
  23413. ELSE '未审核'
  23414. END AS ReviewStatusStr
  23415. ";
  23416. if (Dto.FileTypeId == 0)
  23417. {
  23418. fileTypeName = "会务成本成本表";
  23419. loadPath += $"{fileTypeName}.xlsx";
  23420. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23421. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23422. }
  23423. else if (Dto.FileTypeId == 1)
  23424. {
  23425. fileTypeName = "会务成本报价表";
  23426. loadPath += $"{fileTypeName}.xlsx";
  23427. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23428. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23429. }
  23430. else if (Dto.FileTypeId == 2)
  23431. {
  23432. fileTypeName = "会务成本总表";
  23433. loadPath += $"{fileTypeName}.xlsx";
  23434. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23435. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23436. }
  23437. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  23438. SELECT
  23439. {field}
  23440. FROM Grp_ConferenceAffairsCostChild a
  23441. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  23442. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  23443. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  23444. WHERE a.isdel = 0
  23445. AND a.Diid = {main.Diid}
  23446. AND a.ConferenceAffairsCostId = {main.Id}
  23447. ").ToList();
  23448. var currLists = chiExcelContent.Select(x => new CurrList
  23449. {
  23450. CurrName = x.CurrencyStr,
  23451. CurrRate = x.Rate
  23452. })
  23453. .Distinct()
  23454. .ToList();
  23455. var designer = new WorkbookDesigner
  23456. {
  23457. Workbook = new Workbook(loadPath)
  23458. };
  23459. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == main.MostCurr);
  23460. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  23461. designer.SetDataSource("TeamName", di.TeamName);
  23462. designer.SetDataSource("City", main.City);
  23463. designer.SetDataSource("AllCost", main.CostAll);
  23464. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  23465. designer.SetDataSource("Curr", MostCurr.Name);
  23466. designer.SetDataSource("Curr1", MostCurr.Name);
  23467. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  23468. dt.TableName = "TB";
  23469. designer.SetDataSource(dt);
  23470. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  23471. dt1.TableName = "currTb";
  23472. designer.SetDataSource(dt1);
  23473. designer.Process();
  23474. designer.Workbook.Save(outputPath);
  23475. jw = JsonView(true, "操作成功!", new
  23476. {
  23477. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  23478. FilePath = networkPath
  23479. });
  23480. return Ok(jw);
  23481. }
  23482. [HttpPost]
  23483. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  23484. {
  23485. return Ok(JsonView(true, "SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  23486. .Select(x => x.PriceName).ToList()));
  23487. }
  23488. #endregion
  23489. #region 团组签证流程
  23490. #endregion
  23491. /// <summary>
  23492. /// 123132123
  23493. /// </summary>
  23494. /// <param name="_dto"></param>
  23495. /// <returns></returns>
  23496. [HttpPost]
  23497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23498. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  23499. {
  23500. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  23501. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  23502. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  23503. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  23504. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  23505. dicDetail.Add(789, 1034);
  23506. dicDetail.Add(790, 1035);
  23507. dicDetail.Add(791, 1036);
  23508. dicDetail.Add(792, 1037);
  23509. dicDetail.Add(793, 1038);
  23510. dicDetail.Add(794, 1039);
  23511. dicDetail.Add(795, 1040);
  23512. dicDetail.Add(796, 1041);
  23513. dicDetail.Add(797, 1042);
  23514. dicDetail.Add(798, 1043);
  23515. dicDetail.Add(801, 1044);
  23516. dicDetail.Add(802, 1045);
  23517. dicDetail.Add(803, 1046);
  23518. Dictionary<int, int> dic = new Dictionary<int, int>();
  23519. dic.Add(806, 1027);
  23520. dic.Add(807, 1028);
  23521. dic.Add(808, 1029);
  23522. dic.Add(809, 1030);
  23523. dic.Add(810, 1031);
  23524. dic.Add(811, 1032);
  23525. dic.Add(812, 1033);
  23526. foreach (var item in list_visa)
  23527. {
  23528. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  23529. temp.Coefficient = item.coefficient;
  23530. DateTime dtCrt;
  23531. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  23532. if (b1)
  23533. {
  23534. temp.CreateTime = dtCrt;
  23535. }
  23536. else
  23537. {
  23538. temp.CreateTime = DateTime.Now;
  23539. }
  23540. temp.CreateUserId = item.Operators;
  23541. temp.DeleteTime = "";
  23542. temp.DeleteUserId = 0;
  23543. temp.DiId = int.Parse(item.DIID);
  23544. temp.FilePath = item.FilePath;
  23545. temp.IsDel = item.IsDel;
  23546. temp.Price = item.Price;
  23547. temp.PriceCount = 1;
  23548. temp.PriceCurrency = item.Currency;
  23549. int detailId = 0;
  23550. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  23551. {
  23552. detailId = dicDetail[item.PriceTypeDetail];
  23553. }
  23554. temp.PriceDetailType = detailId;
  23555. temp.PriceDt = DateTime.Now;
  23556. temp.PriceName = item.PriceName;
  23557. temp.PriceSum = item.Price;
  23558. int tid = 0;
  23559. if (dic.ContainsKey(item.PriceType))
  23560. {
  23561. tid = dic[item.PriceType];
  23562. }
  23563. temp.PriceType = tid;
  23564. temp.Remark = item.Remark;
  23565. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  23566. }
  23567. return Ok(JsonView(true, "操作成功!"));
  23568. }
  23569. [HttpPost]
  23570. public IActionResult TimeTest()
  23571. {
  23572. var jw = JsonView(false, "error");
  23573. _sqlSugar.BeginTran();
  23574. try
  23575. {
  23576. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  23577. .Select(x => new Crm_NewClientData
  23578. {
  23579. Id = x.Id,
  23580. Client = x.Client,
  23581. Contact = x.Contact,
  23582. Location = x.Location,
  23583. })
  23584. .ToList();
  23585. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  23586. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  23587. Stopwatch stopwatch = new Stopwatch();
  23588. // 开始计时
  23589. stopwatch.Start();
  23590. foreach (var item in clientList)
  23591. {
  23592. EncryptionProcessor.DecryptProperties(item);
  23593. }
  23594. stopwatch.Stop();
  23595. jw.Code = 200;
  23596. jw.Data = stopwatch.ElapsedMilliseconds;
  23597. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  23598. }
  23599. catch (Exception ex)
  23600. {
  23601. jw.Code = 400;
  23602. jw.Msg = ex.Message;
  23603. }
  23604. return Ok(jw);
  23605. }
  23606. }
  23607. }