GroupsController.cs 1.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638
  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.Formula.Functions;
  8. using NPOI.SS.UserModel;
  9. using NPOI.SS.Util;
  10. using NPOI.XSSF.UserModel;
  11. using OASystem.API.Middlewares;
  12. using OASystem.API.OAMethodLib;
  13. using OASystem.API.OAMethodLib.APNs;
  14. using OASystem.API.OAMethodLib.DeepSeekAPI;
  15. using OASystem.API.OAMethodLib.File;
  16. using OASystem.API.OAMethodLib.Hub.HubClients;
  17. using OASystem.API.OAMethodLib.Hub.Hubs;
  18. using OASystem.API.OAMethodLib.JuHeAPI;
  19. using OASystem.API.OAMethodLib.KiMiApi;
  20. using OASystem.API.OAMethodLib.Logging;
  21. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  22. using OASystem.Domain.AesEncryption;
  23. using OASystem.Domain.Attributes;
  24. using OASystem.Domain.Dtos.CRM;
  25. using OASystem.Domain.Dtos.FileDto;
  26. using OASystem.Domain.Dtos.Financial;
  27. using OASystem.Domain.Dtos.Groups;
  28. using OASystem.Domain.Entities.Customer;
  29. using OASystem.Domain.Entities.Financial;
  30. using OASystem.Domain.Entities.Groups;
  31. using OASystem.Domain.ViewModels.CRM;
  32. using OASystem.Domain.ViewModels.Financial;
  33. using OASystem.Domain.ViewModels.Groups;
  34. using OASystem.Domain.ViewModels.OCR;
  35. using OASystem.Infrastructure.Repositories.CRM;
  36. using OASystem.Infrastructure.Repositories.Financial;
  37. using OASystem.Infrastructure.Repositories.Groups;
  38. using Quartz.Logging;
  39. using Quartz.Util;
  40. using SQLitePCL;
  41. using SqlSugar.Extensions;
  42. using System.Collections;
  43. using System.ComponentModel.DataAnnotations;
  44. using System.Data;
  45. using System.Diagnostics;
  46. using System.Globalization;
  47. using System.IO;
  48. using System.IO.Compression;
  49. using System.Linq.Expressions;
  50. using System.Text.Json;
  51. using System.Text.RegularExpressions;
  52. using System.Threading.Tasks;
  53. using System.Web;
  54. using static OASystem.API.OAMethodLib.JWTHelper;
  55. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  56. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  57. using Bookmark = Aspose.Words.Bookmark;
  58. using Cell = Aspose.Words.Tables.Cell;
  59. using Table = Aspose.Words.Tables.Table;
  60. namespace OASystem.API.Controllers
  61. {
  62. /// <summary>
  63. /// 团组相关
  64. /// </summary>
  65. //[Authorize]
  66. [Route("api/[controller]/[action]")]
  67. public class GroupsController : ControllerBase
  68. {
  69. private readonly ILogger<GroupsController> _logger;
  70. private readonly ITextFileLogger _eec_textLogger;
  71. private readonly IGroupTextFileLogger _groupTextLogger;
  72. private readonly GrpScheduleRepository _grpScheduleRep;
  73. private readonly IMapper _mapper;
  74. private readonly DelegationInfoRepository _groupRepository;
  75. private readonly TaskAssignmentRepository _taskAssignmentRep;
  76. private readonly AirTicketResRepository _airTicketResRep;
  77. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  78. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  79. private readonly DelegationEnDataRepository _delegationEnDataRep;
  80. private readonly DelegationVisaRepository _delegationVisaRep;
  81. private readonly VisaPriceRepository _visaPriceRep;
  82. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  83. private readonly HotelPriceRepository _hotelPriceRep;
  84. private readonly CustomersRepository _customersRep;
  85. private readonly MessageRepository _message;
  86. private readonly SqlSugarClient _sqlSugar;
  87. private readonly TourClientListRepository _tourClientListRep;
  88. private readonly TeamRateRepository _teamRateRep;
  89. #region 成本相关
  90. private readonly CheckBoxsRepository _checkBoxs;
  91. private readonly GroupCostRepository _GroupCostRepository;
  92. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  93. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  94. #endregion
  95. private readonly SetDataRepository _setDataRep;
  96. private string url;
  97. private string path;
  98. private readonly EnterExitCostRepository _enterExitCostRep;
  99. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  100. private readonly UsersRepository _usersRep;
  101. private readonly IJuHeApiService _juHeApi;
  102. private readonly InvertedListRepository _invertedListRep;
  103. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  104. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  105. private readonly ThreeCodeRepository _threeCodeRepository;
  106. private readonly HotelInquiryRepository _hotelInquiryRep;
  107. private readonly FeeAuditRepository _feeAuditRep;
  108. private readonly VisaCommissionRepository _visaCommissionRep;
  109. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  110. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  111. private readonly List<CurrencyInfo> _currencyInit;
  112. private readonly List<int> _portTypeData;
  113. private readonly TableOperationRecordRepository _tableorRep;
  114. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  115. private readonly RestaurantRepository _restaurantRep;
  116. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  117. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  118. private readonly VisaProcessRepository _visaProcessRep;
  119. private readonly ProcessOverviewRepository _processOverviewRep;
  120. private readonly IDeepSeekService _deepSeekService;
  121. /// <summary>
  122. /// 构造函数
  123. /// </summary>
  124. /// <param name="logger"></param>
  125. /// <param name="eec_textLogger"></param>
  126. /// <param name="groupTextLogger"></param>
  127. /// <param name="mapper"></param>
  128. /// <param name="hubContext"></param>
  129. /// <param name="sqlSugar"></param>
  130. /// <param name="grpScheduleRep"></param>
  131. /// <param name="groupRepository"></param>
  132. /// <param name="taskAssignmentRep"></param>
  133. /// <param name="airTicketResRep"></param>
  134. /// <param name="decreasePaymentsRep"></param>
  135. /// <param name="InvitationOfficialActivitiesRep"></param>
  136. /// <param name="delegationEnDataRep"></param>
  137. /// <param name="enterExitCostRep"></param>
  138. /// <param name="delegationVisaRep"></param>
  139. /// <param name="message"></param>
  140. /// <param name="visaPriceRep"></param>
  141. /// <param name="carTouristGuideGroundRep"></param>
  142. /// <param name="checkBoxs"></param>
  143. /// <param name="GroupCostRepository"></param>
  144. /// <param name="CostTypeHotelNumberRepository"></param>
  145. /// <param name="GroupCostParameterRepository"></param>
  146. /// <param name="hotelPriceRep"></param>
  147. /// <param name="customersRep"></param>
  148. /// <param name="setDataRep"></param>
  149. /// <param name="tourClientListRep"></param>
  150. /// <param name="teamRateRep"></param>
  151. /// <param name="usersRep"></param>
  152. /// <param name="juHeApi"></param>
  153. /// <param name="invertedListRep"></param>
  154. /// <param name="visaFeeInfoRep"></param>
  155. /// <param name="ticketBlackCodeRep"></param>
  156. /// <param name="hotelInquiryRep"></param>
  157. /// <param name="threeCodeRepository"></param>
  158. /// <param name="feeAuditRep"></param>
  159. /// <param name="visaCommissionRep"></param>
  160. /// <param name="ffrRep"></param>
  161. /// <param name="opinionaireRep"></param>
  162. /// <param name="tableorRep"></param>
  163. /// <param name="enterExitCostDraftRep"></param>
  164. /// <param name="restaurantRep"></param>
  165. /// <param name="enterExitCostQuoteRep"></param>
  166. /// <param name="grpOrderPreInfoRep"></param>
  167. /// <param name="visaProcessRep"></param>
  168. /// <param name="processOverviewRep"></param>
  169. public GroupsController(
  170. ILogger<GroupsController> logger,
  171. ITextFileLogger eec_textLogger,
  172. IGroupTextFileLogger groupTextLogger,
  173. IMapper mapper,
  174. IHubContext<ChatHub, IChatClient> hubContext,
  175. SqlSugarClient sqlSugar,
  176. GrpScheduleRepository grpScheduleRep,
  177. DelegationInfoRepository groupRepository,
  178. TaskAssignmentRepository taskAssignmentRep,
  179. AirTicketResRepository airTicketResRep,
  180. DecreasePaymentsRepository decreasePaymentsRep,
  181. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  182. DelegationEnDataRepository delegationEnDataRep,
  183. EnterExitCostRepository enterExitCostRep,
  184. DelegationVisaRepository delegationVisaRep,
  185. MessageRepository message,
  186. VisaPriceRepository visaPriceRep,
  187. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  188. CheckBoxsRepository checkBoxs,
  189. GroupCostRepository GroupCostRepository,
  190. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  191. GroupCostParameterRepository GroupCostParameterRepository,
  192. HotelPriceRepository hotelPriceRep,
  193. CustomersRepository customersRep,
  194. SetDataRepository setDataRep,
  195. TourClientListRepository tourClientListRep,
  196. TeamRateRepository teamRateRep,
  197. UsersRepository usersRep,
  198. IJuHeApiService juHeApi,
  199. InvertedListRepository invertedListRep,
  200. VisaFeeInfoRepository visaFeeInfoRep,
  201. TicketBlackCodeRepository ticketBlackCodeRep,
  202. HotelInquiryRepository hotelInquiryRep,
  203. ThreeCodeRepository threeCodeRepository,
  204. FeeAuditRepository feeAuditRep,
  205. VisaCommissionRepository visaCommissionRep,
  206. ForeignReceivablesRepository ffrRep,
  207. OpinionaireRepository opinionaireRep,
  208. TableOperationRecordRepository tableorRep,
  209. EnterExitCostDraftRepository enterExitCostDraftRep,
  210. RestaurantRepository restaurantRep,
  211. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  212. GroupOrderPreInfoRepository grpOrderPreInfoRep,
  213. VisaProcessRepository visaProcessRep,
  214. ProcessOverviewRepository processOverviewRep
  215. )
  216. {
  217. _logger = logger;
  218. _eec_textLogger = eec_textLogger;
  219. _groupTextLogger = groupTextLogger;
  220. _mapper = mapper;
  221. _grpScheduleRep = grpScheduleRep;
  222. _groupRepository = groupRepository;
  223. _taskAssignmentRep = taskAssignmentRep;
  224. _airTicketResRep = airTicketResRep;
  225. _sqlSugar = sqlSugar;
  226. url = AppSettingsHelper.Get("ExcelBaseUrl");
  227. path = AppSettingsHelper.Get("ExcelBasePath");
  228. if (!System.IO.Directory.Exists(path))
  229. {
  230. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  231. }
  232. _decreasePaymentsRep = decreasePaymentsRep;
  233. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  234. _delegationEnDataRep = delegationEnDataRep;
  235. _enterExitCostRep = enterExitCostRep;
  236. _delegationVisaRep = delegationVisaRep;
  237. _message = message;
  238. _visaPriceRep = visaPriceRep;
  239. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  240. _checkBoxs = checkBoxs;
  241. _GroupCostRepository = GroupCostRepository;
  242. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  243. _GroupCostParameterRepository = GroupCostParameterRepository;
  244. _hotelPriceRep = hotelPriceRep;
  245. _customersRep = customersRep;
  246. _setDataRep = setDataRep;
  247. _tourClientListRep = tourClientListRep;
  248. _teamRateRep = teamRateRep;
  249. _hubContext = hubContext;
  250. _usersRep = usersRep;
  251. _juHeApi = juHeApi;
  252. _invertedListRep = invertedListRep;
  253. _visaFeeInfoRep = visaFeeInfoRep;
  254. _ticketBlackCodeRep = ticketBlackCodeRep;
  255. _hotelInquiryRep = hotelInquiryRep;
  256. _threeCodeRepository = threeCodeRepository;
  257. _feeAuditRep = feeAuditRep;
  258. _visaCommissionRep = visaCommissionRep;
  259. _ffrRep = ffrRep;
  260. _opinionaireRep = opinionaireRep;
  261. _currencyInit = new List<CurrencyInfo>()
  262. {
  263. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  264. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  265. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  266. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  267. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  268. };
  269. _portTypeData = new List<int>() { 2, 3 };
  270. _tableorRep = tableorRep;
  271. _enterExitCostDraftRep = enterExitCostDraftRep;
  272. _restaurantRep = restaurantRep;
  273. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  274. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  275. _visaProcessRep = visaProcessRep;
  276. _processOverviewRep = processOverviewRep;
  277. }
  278. #region 流程管控
  279. /// <summary>
  280. /// 获取团组流程管控信息
  281. /// </summary>
  282. /// <param name="_jsonDto">查询参数</param>
  283. /// <returns></returns>
  284. [HttpPost]
  285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  286. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  287. {
  288. if (string.IsNullOrEmpty(_jsonDto.Paras))
  289. {
  290. return Ok(JsonView(false, "参数为空"));
  291. }
  292. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  293. if (_ScheduleDto != null)
  294. {
  295. if (_ScheduleDto.SearchType == 2)//获取列表
  296. {
  297. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  298. return Ok(JsonView(_grpScheduleViewList));
  299. }
  300. else//获取对象
  301. {
  302. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  303. if (_grpScheduleView != null)
  304. {
  305. return Ok(JsonView(_grpScheduleView));
  306. }
  307. }
  308. }
  309. else
  310. {
  311. return Ok(JsonView(false, "参数反序列化失败"));
  312. }
  313. return Ok(JsonView(false, "暂无数据!"));
  314. }
  315. /// <summary>
  316. /// 修改团组流程管控详细表数据
  317. /// </summary>
  318. /// <param name="dto"></param>
  319. /// <returns></returns>
  320. [HttpPost]
  321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  322. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  323. {
  324. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  325. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  326. .SetColumns(it => it.Duty == _detail.Duty)
  327. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  328. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  329. .SetColumns(it => it.JobContent == _detail.JobContent)
  330. .SetColumns(it => it.Remark == _detail.Remark)
  331. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  332. .Where(s => s.Id == dto.Id)
  333. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  334. .ExecuteCommandAsync();
  335. if (result > 0)
  336. {
  337. return Ok(JsonView(true, "保存成功!"));
  338. }
  339. return Ok(JsonView(false, "保存失败!"));
  340. }
  341. /// <summary>
  342. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  343. /// </summary>
  344. /// <param name="dto"></param>
  345. /// <returns></returns>
  346. [HttpPost]
  347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  348. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  349. {
  350. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  351. _detail.IsDel = 1;
  352. _detail.DeleteUserId = dto.Duty;
  353. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  354. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  355. .SetColumns(it => it.IsDel == _detail.IsDel)
  356. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  357. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  358. .Where(it => it.Id == dto.Id)
  359. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  360. //.WhereColumns(s => s.Id == dto.Id)
  361. .ExecuteCommandAsync();
  362. if (result > 0)
  363. {
  364. return Ok(JsonView(true, "删除成功!"));
  365. }
  366. return Ok(JsonView(false, "删除失败!"));
  367. }
  368. /// <summary>
  369. /// 增加团组流程管控详细表数据
  370. /// </summary>
  371. /// <param name="dto"></param>
  372. /// <returns></returns>
  373. [HttpPost]
  374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  375. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  376. {
  377. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  378. if (DateTime.Now < _detail.ExpectBeginDt)
  379. {
  380. _detail.StepStatus = 0;
  381. }
  382. else
  383. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  384. _detail.StepStatus = 1;
  385. }
  386. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  387. if (result > 0)
  388. {
  389. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  390. return Ok(JsonView(true, "添加成功!", _result));
  391. }
  392. return Ok(JsonView(false, "添加失败!"));
  393. }
  394. #endregion
  395. #region 团组前期信息
  396. /// <summary>
  397. /// 团组前期信息H5-URL(员工对应地址)
  398. /// </summary>
  399. /// <param name="name">用户名称</param>
  400. /// <returns></returns>
  401. [HttpGet]
  402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  403. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  404. {
  405. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  406. .Where(x => x.IsDel == 0)
  407. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  408. .OrderBy(x => x.Id)
  409. .Select(x => new
  410. {
  411. name = x.CnName,
  412. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  413. })
  414. .ToListAsync();
  415. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  416. }
  417. /// <summary>
  418. /// 团组前期信息 List
  419. /// </summary>
  420. /// <returns></returns>
  421. [HttpPost]
  422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  423. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  424. {
  425. var search = dto.Search;
  426. int[] nameTempIds = new int[] { 1, 12, 28 },
  427. countryTempIds = new int[] { 2, 13, 29 },
  428. daysTempIds = new int[] { 4, 15, 31 },
  429. ppNumTempIds = new int[] { 6 };
  430. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  431. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  432. .Where((opi, u) => opi.IsDel == 0)
  433. .OrderByDescending((opi, u) => opi.CreateTime)
  434. .Select((opi, u) => new GroupOrderPreInfoListView()
  435. {
  436. Id = opi.Id,
  437. Name = opi.Name,
  438. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  439. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  440. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  441. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  442. Operator = u.CnName,
  443. OperationTime = opi.CreateTime
  444. })
  445. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  446. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  447. .ToListAsync();
  448. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  449. int total = list.Count;
  450. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  451. var listPageData1 = listPageData
  452. .Skip((dto.PageIndex - 1) * dto.PageSize)
  453. .Take(dto.PageSize)
  454. .ToList();
  455. var infoIds = listPageData1.Select(x => x.Id).ToList();
  456. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  457. .Where(x => x.IsDel == 0 && x.STid == 109)
  458. .ToArrayAsync();
  459. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  460. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  461. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  462. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  463. .ToListAsync();
  464. foreach (var item in listPageData1)
  465. {
  466. var typeDatas1 = typeDatas.Select(x => new
  467. {
  468. x.Id,
  469. x.Name,
  470. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  471. }).ToArray();
  472. item.VersionDetails = typeDatas1;
  473. }
  474. return Ok(JsonView(listPageData1, listPageData1.Count));
  475. }
  476. /// <summary>
  477. /// 团组前期信息 Init
  478. /// </summary>
  479. /// <returns></returns>
  480. [HttpGet("{userId}")]
  481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  482. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  483. {
  484. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  485. }
  486. /// <summary>
  487. /// 国家数据源
  488. /// </summary>
  489. /// <param name="pageIndex">当前页码</param>
  490. /// <param name="pageSize">每页条数</param>
  491. /// <param name="search">查询条件</param>
  492. /// <returns></returns>
  493. [HttpGet]
  494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  495. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  496. {
  497. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  498. if (pageIndex == 0 && pageSize == 0)
  499. {
  500. //所有数据
  501. return Ok(JsonView(countrys, countrys.Count));
  502. }
  503. //分页
  504. int skip = (pageIndex - 1) * pageSize;
  505. int take = pageSize;
  506. if (!string.IsNullOrEmpty(search))
  507. {
  508. IEnumerable<char> charSequence = search.Select(c => c);
  509. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  510. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  511. return Ok(JsonView(pageData, pageResult1.Count));
  512. }
  513. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  514. return Ok(JsonView(pageResult2, countrys.Count));
  515. }
  516. /// <summary>
  517. /// 城市数据源
  518. /// </summary>
  519. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  520. /// <param name="pageIndex">当前页码</param>
  521. /// <param name="pageSize">每页条数</param>
  522. /// <param name="search">查询条件</param>
  523. /// <returns></returns>
  524. [HttpGet("{countryLabel}")]
  525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  526. public async Task<IActionResult> CityByCountry(
  527. string countryLabel,
  528. [FromQuery] int pageIndex,
  529. [FromQuery] int pageSize,
  530. [FromQuery] string search)
  531. {
  532. countryLabel = HttpUtility.UrlDecode(countryLabel);
  533. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  534. var citys = Array.Empty<string?>();
  535. if (countryList.Any())
  536. {
  537. var cityDatas = await _sqlSugar
  538. .Queryable<Grp_NationalTravelFee>()
  539. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  540. .ToArrayAsync();
  541. foreach (var item in cityDatas)
  542. {
  543. if (item.City.Contains("城市"))
  544. {
  545. item.City = item.Country + "-所有城市";
  546. }
  547. }
  548. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  549. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  550. }
  551. if (pageIndex == 0 && pageSize == 0)
  552. {
  553. //所有数据
  554. return Ok(JsonView(citys, citys?.Length ?? 0));
  555. }
  556. //分页
  557. int skip = (pageIndex - 1) * pageSize;
  558. int take = pageSize;
  559. if (!string.IsNullOrEmpty(search))
  560. {
  561. IEnumerable<char> charSequence = search.Select(c => c);
  562. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  563. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  564. return Ok(JsonView(pageData, pageResult1.Count));
  565. }
  566. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  567. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  568. }
  569. /// <summary>
  570. /// 团组前期信息 Info
  571. /// </summary>
  572. /// <param name="dto">Id</param>
  573. /// <returns></returns>
  574. [HttpGet("{Id}/{TempId}")]
  575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  576. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  577. {
  578. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  579. }
  580. /// <summary>
  581. /// 团组前期信息 移动端 Info
  582. /// </summary>
  583. /// <param name="dto">Id</param>
  584. /// <returns></returns>
  585. [HttpGet("{Id}/{TempId}")]
  586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  587. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  588. {
  589. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  590. }
  591. /// <summary>
  592. /// 团组前期信息 Save
  593. /// </summary>
  594. /// <param name="dto">Id</param>
  595. /// <returns></returns>
  596. [HttpPost]
  597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  598. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  599. {
  600. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  601. }
  602. /// <summary>
  603. /// 团组前期信息 Del
  604. /// </summary>
  605. /// <param name="dto">Id</param>
  606. /// <returns></returns>
  607. [HttpPost]
  608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  609. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  610. {
  611. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  612. }
  613. /// <summary>
  614. /// 团组前期信息 文件下载
  615. /// </summary>
  616. /// <param name="dto">Id</param>
  617. /// <returns></returns>
  618. [HttpGet("{Id}/{TempId}")]
  619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  620. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  621. {
  622. int id = dto.Id, tempId = dto.TempId;
  623. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  624. var data = view.Data as GrpOrderPreInfoView;
  625. #region Excel
  626. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  627. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  628. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  629. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  630. var fileNamePrefix = string.Empty;
  631. if (tempId == 1405)
  632. {
  633. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  634. fileNamePrefix = $"{data.Name}_无商邀版";
  635. }
  636. else if (tempId == 1406)
  637. {
  638. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  639. fileNamePrefix = $"{data.Name}_有商邀版";
  640. }
  641. else
  642. {
  643. //tempId == 1404 默认下载
  644. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  645. fileNamePrefix = $"{data.Name}_单接送机";
  646. }
  647. foreach (var item in data.Items)
  648. {
  649. var obj = item.NewValue;
  650. if (obj == null) item.OriginVal = "";
  651. else if (obj.Equals("有") || obj.Equals("无"))
  652. {
  653. item.OriginVal = obj.ToString();
  654. }
  655. else if (obj is object[] objArray)
  656. {
  657. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  658. item.OriginVal = string.Join("、", stringArray);
  659. }
  660. else if (obj is string[] stringArray)
  661. {
  662. item.OriginVal = string.Join("、", stringArray);
  663. }
  664. else if (obj.Equals("-"))
  665. {
  666. item.OriginVal = "";
  667. }
  668. }
  669. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  670. fileName = CommonFun.ValidFileName(fileName);
  671. //载入模板
  672. var designer = new WorkbookDesigner
  673. {
  674. Workbook = new Workbook(tempPath)
  675. };
  676. if (tempId == 1406)
  677. {
  678. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  679. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  680. for (int i = 1; i <= view2.Length; i++)
  681. {
  682. view2[i - 1].Index = i;
  683. }
  684. designer.SetDataSource("View1", view1);
  685. designer.SetDataSource("View2", view2);
  686. }
  687. else
  688. {
  689. designer.SetDataSource("View", data.Items);
  690. }
  691. designer.Process();
  692. if (!Directory.Exists(savePath))
  693. {
  694. Directory.CreateDirectory(savePath);
  695. }
  696. string serverPath = $"{savePath}{fileName}";
  697. designer.Workbook.Save(serverPath);
  698. string rst = $"{servicePath}{ftpPath}{fileName}";
  699. #endregion
  700. return Ok(JsonView(new { url = rst }));
  701. }
  702. #endregion
  703. #region 团组基本信息
  704. /// <summary>
  705. /// 接团信息列表
  706. /// </summary>
  707. /// <param name="dto">团组列表请求dto</param>
  708. /// <returns></returns>
  709. [HttpPost]
  710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  711. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  712. {
  713. var groupData = await _groupRepository.GetGroupList(dto);
  714. if (groupData.Code != 0)
  715. {
  716. return Ok(JsonView(false, groupData.Msg));
  717. }
  718. return Ok(JsonView(groupData.Data));
  719. }
  720. /// <summary>
  721. /// 分页查询团组列表
  722. /// </summary>
  723. /// <param name="dto"></param>
  724. /// <returns></returns>
  725. [HttpPost]
  726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  727. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  728. {
  729. var watch = new Stopwatch();
  730. watch.Start();
  731. RefAsync<int> total = 0;
  732. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  733. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  734. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  735. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  736. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  737. .Distinct()
  738. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  739. watch.Stop();
  740. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  741. }
  742. /// <summary>
  743. /// 接团信息列表 Page Init
  744. /// </summary>
  745. /// <returns></returns>
  746. [HttpPost]
  747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  748. public async Task<IActionResult> PostGroupPageListInit()
  749. {
  750. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  751. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  752. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  753. var _view = new
  754. {
  755. depData = depDatas,
  756. rankData = rankDatas
  757. };
  758. return Ok(JsonView(true, "查询成功!", _view));
  759. }
  760. /// <summary>
  761. /// 接团信息列表 Page
  762. /// </summary>
  763. /// <param name="dto">团组列表请求dto</param>
  764. /// <returns></returns>
  765. [HttpPost]
  766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  767. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  768. {
  769. #region 参数验证
  770. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  771. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  772. #region 页面操作权限验证
  773. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  774. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  775. #endregion
  776. #endregion
  777. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  778. {
  779. string sqlWhere = string.Empty;
  780. if (dto.IsSure == 0) //未完成
  781. {
  782. sqlWhere += string.Format(@" And IsSure = 0");
  783. }
  784. else if (dto.IsSure == 1) //已完成
  785. {
  786. sqlWhere += string.Format(@" And IsSure = 1");
  787. }
  788. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  789. {
  790. string tj = dto.SearchCriteria;
  791. 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}%')",
  792. tj, tj, tj, tj, tj);
  793. }
  794. if (int.TryParse(dto.Rank, out int rankId))
  795. {
  796. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  797. }
  798. string sqlWhere1 = string.Empty;
  799. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  800. {
  801. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  802. }
  803. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  804. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  805. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  806. JietuanOperator,IsSure,CreateTime,IsBid,Step
  807. From (
  808. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  809. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  810. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  811. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,gdi.Step,
  812. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  813. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  814. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  815. From Grp_DelegationInfo gdi
  816. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  817. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  818. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  819. Where gdi.IsDel = 0 {0}
  820. ) temp {1}", sqlWhere, sqlWhere1);
  821. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  822. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  823. //处理 团组模块实际操作人
  824. _DelegationList.ForEach(async x =>
  825. {
  826. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  827. var operatorNames = new StringBuilder();
  828. //operatorNames.AppendLine("各模块实际操作人:");
  829. if (operators.Any())
  830. {
  831. operators.ForEach(y =>
  832. {
  833. string label = string.Empty;
  834. if (y.OperationUsers.Any())
  835. {
  836. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  837. label = string.Join('、', users);
  838. }
  839. else label = "暂未指定";
  840. operatorNames.AppendLine($"{y.CTableName}:{label}");
  841. operatorNames.AppendLine();
  842. });
  843. }
  844. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  845. });
  846. var _view = new
  847. {
  848. PageFuncAuth = pageFunAuthView,
  849. Data = _DelegationList
  850. };
  851. return Ok(JsonView(true, "查询成功!", _view, total));
  852. }
  853. else
  854. {
  855. return Ok(JsonView(false, "查询失败"));
  856. }
  857. }
  858. /// <summary>
  859. /// 团组列表
  860. /// </summary>
  861. /// <returns></returns>
  862. [HttpPost]
  863. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  864. {
  865. #region 参数验证
  866. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  867. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  868. #region 页面操作权限验证
  869. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  870. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  871. #endregion
  872. #endregion
  873. if (dto.PortType != 1 && dto.PortType != 2)
  874. {
  875. return Ok(JsonView(false, "查询失败!"));
  876. }
  877. string orderbyStr = "order by gdi.CreateTime Desc";
  878. string sqlWhere = string.Empty;
  879. if (dto.IsSure == 0) //未完成
  880. {
  881. sqlWhere += string.Format(@" And IsSure = 0");
  882. }
  883. else if (dto.IsSure == 1) //已完成
  884. {
  885. sqlWhere += string.Format(@" And IsSure = 1");
  886. }
  887. //团组类型
  888. if (dto.TeamDid > 0)
  889. {
  890. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  891. }
  892. //团组名称
  893. if (!string.IsNullOrEmpty(dto.TeamName))
  894. {
  895. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  896. }
  897. //客户名称
  898. if (!string.IsNullOrEmpty(dto.ClientName))
  899. {
  900. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  901. }
  902. //客户单位
  903. if (!string.IsNullOrEmpty(dto.ClientUnit))
  904. {
  905. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  906. }
  907. //出访时间
  908. if (!string.IsNullOrEmpty(dto.visitDataTime))
  909. {
  910. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  911. orderbyStr = "order by gdi.VisitDate";
  912. }
  913. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  914. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  915. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  916. JietuanOperator,IsSure,CreateTime
  917. From (
  918. Select row_number() over({0}) as Row_Number,
  919. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  920. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  921. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  922. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  923. From Grp_DelegationInfo gdi
  924. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  925. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  926. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  927. Where gdi.IsDel = 0 {1}
  928. ) temp ", orderbyStr, sqlWhere);
  929. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  930. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  931. #region 处理所属部门
  932. /*
  933. * 1.sq 和 gyy 等显示 市场部
  934. * 2.王鸽和主管及张总还有管理员号统一国交部
  935. * 2-1. 4 管理员 ,21 张海麟
  936. */
  937. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  938. var userIds1 = new List<int>() { 4, 21 };
  939. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  940. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  941. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  942. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  943. .ToList();
  944. foreach (var item in _DelegationList)
  945. {
  946. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  947. }
  948. #endregion
  949. var _view = new
  950. {
  951. PageFuncAuth = pageFunAuthView,
  952. Data = _DelegationList
  953. };
  954. return Ok(JsonView(true, "查询成功!", _view, total));
  955. }
  956. /// <summary>
  957. /// 接团信息详情
  958. /// </summary>
  959. /// <param name="dto">团组info请求dto</param>
  960. /// <returns></returns>
  961. [HttpPost]
  962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  963. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  964. {
  965. var groupData = await _groupRepository.GetGroupInfo(dto);
  966. if (groupData.Code != 0)
  967. {
  968. return Ok(JsonView(false, groupData.Msg));
  969. }
  970. return Ok(JsonView(groupData.Data));
  971. }
  972. /// <summary>
  973. /// 接团信息 编辑添加
  974. /// 基础信息数据源
  975. /// </summary>
  976. /// <param name="dto"></param>
  977. /// <returns></returns>
  978. [HttpPost]
  979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  980. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  981. {
  982. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  983. if (groupData.Code != 0)
  984. {
  985. return Ok(JsonView(false, groupData.Msg));
  986. }
  987. return Ok(JsonView(groupData.Data));
  988. }
  989. /// <summary>
  990. /// 成本修改团组信息
  991. /// </summary>
  992. /// <param name="dto"></param>
  993. /// <returns></returns>
  994. [HttpPost]
  995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  996. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  997. {
  998. var jw = JsonView(false, "操作失败");
  999. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  1000. if (di == null)
  1001. {
  1002. jw.Msg = "参数有误!";
  1003. return Ok(jw);
  1004. }
  1005. #region 添加出访起止时间
  1006. var startTime = new DateTime();
  1007. var endTime = new DateTime();
  1008. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1009. {
  1010. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1011. }
  1012. else
  1013. {
  1014. jw.Msg = "参数有误!";
  1015. return Ok(jw);
  1016. }
  1017. #endregion
  1018. di.VisitDate = startTime;
  1019. di.VisitPNumber = dto.VisitPNumber;
  1020. di.VisitDays = dto.VisitDays;
  1021. di.VisitStartDate = startTime;
  1022. di.VisitEndDate = endTime;
  1023. var count = _sqlSugar.Updateable(di)
  1024. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1025. .ExecuteCommand();
  1026. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1027. }
  1028. /// <summary>
  1029. /// 接团信息 编辑添加
  1030. /// 省份-城市 基础信息数据源
  1031. /// </summary>
  1032. /// <param name="dto"></param>
  1033. /// <returns></returns>
  1034. [HttpPost]
  1035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1036. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1037. {
  1038. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1039. string search = dto.Search;
  1040. var data = await _groupRepository.CityBasicSource();
  1041. int total = data.Length;
  1042. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1043. .Skip((pageIndex - 1) * pageSize)
  1044. .Take(pageSize)
  1045. .ToArray();
  1046. return Ok(JsonView(data, total));
  1047. }
  1048. /// <summary>
  1049. /// 接团信息 操作(增改)
  1050. /// </summary>
  1051. /// <param name="dto"></param>
  1052. /// <returns></returns>
  1053. [HttpPost]
  1054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1055. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1056. {
  1057. // 创建 Stopwatch 实例
  1058. Stopwatch stopwatch = Stopwatch.StartNew();
  1059. decimal ffrPrice = 0.00M;
  1060. DateTime? visitDt = null;
  1061. if (dto.Status == 2)
  1062. {
  1063. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1064. if (groupInfo != null)
  1065. {
  1066. ffrPrice = groupInfo.PaymentMoney;
  1067. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1068. }
  1069. }
  1070. var groupData = await _groupRepository.GroupOperation(dto);
  1071. if (groupData.Code != 0)
  1072. {
  1073. return Ok(JsonView(false, groupData.Msg));
  1074. }
  1075. int diId = 0;
  1076. try
  1077. {
  1078. //添加时 默认加入团组汇率
  1079. if (dto.Status == 1) //添加
  1080. {
  1081. diId = groupData.Data;
  1082. //添加默认币种
  1083. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1084. //默认分配权限
  1085. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1086. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1087. var _managerIds = new List<int>() { 22, 32, 21 };
  1088. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1089. if (userIds.Count > 0)
  1090. {
  1091. userIds.Add(208);
  1092. //创建团组管控
  1093. GroupStepForDelegation.CreateWorkStep(diId);
  1094. //发送消息
  1095. string groupName = dto.TeamName;
  1096. string createGroupUser = string.Empty;
  1097. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1098. if (userInfo != null) createGroupUser = userInfo.CnName;
  1099. string title = $"系统通知";
  1100. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1101. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1102. }
  1103. //默认创建倒推表
  1104. await _invertedListRep._Create(dto.UserId, diId);
  1105. //默认创建签证流程
  1106. await _visaProcessRep.Create(dto.UserId, diId);
  1107. //默认创建团组流程总览信息
  1108. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1109. }
  1110. else if (dto.Status == 2)
  1111. {
  1112. diId = dto.Id;
  1113. }
  1114. #region 签证人员团组时间通知
  1115. #region 计算出访起止时间
  1116. var startTime = new DateTime();
  1117. var endTime = new DateTime();
  1118. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1119. {
  1120. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1121. }
  1122. #endregion
  1123. #endregion
  1124. #region 团组操作默认添加/修改收款账单
  1125. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1126. {
  1127. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1128. .Where(x => x.IsDel == 0 &&
  1129. x.Diid == diId &&
  1130. x.Remark.Equals("预付款")
  1131. )
  1132. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1133. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1134. .FirstAsync();
  1135. ffrInfo = new Fin_ForeignReceivables()
  1136. {
  1137. Diid = diId,
  1138. PriceName = dto.ClientUnit,
  1139. Price = dto.PaymentMoney,
  1140. Count = 1,
  1141. Unit = $"元",
  1142. ItemSumPrice = dto.PaymentMoney,
  1143. Rate = 1.0000M,
  1144. Currency = 836,
  1145. AddingWay = 0,
  1146. CreateUserId = dto.UserId,
  1147. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1148. Remark = $"预付款"
  1149. };
  1150. if (ffrInfo == null) //Add
  1151. {
  1152. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1153. }
  1154. else //修改
  1155. {
  1156. await _sqlSugar.Updateable(ffrInfo)
  1157. .UpdateColumns(x => new
  1158. {
  1159. x.PriceName,
  1160. x.Price,
  1161. x.ItemSumPrice,
  1162. x.CreateTime,
  1163. x.CreateUserId
  1164. })
  1165. .WhereColumns(x => x.Id)
  1166. .ExecuteCommandAsync();
  1167. }
  1168. }
  1169. #endregion
  1170. if (diId > 0)
  1171. {
  1172. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1173. }
  1174. // 停止计时
  1175. stopwatch.Stop();
  1176. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1177. }
  1178. catch (Exception ex)
  1179. {
  1180. // 停止计时
  1181. stopwatch.Stop();
  1182. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1183. Logs(ex.Message);
  1184. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1185. }
  1186. // 停止计时
  1187. stopwatch.Stop();
  1188. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1189. }
  1190. /// <summary>
  1191. /// 接团流程操作(增改)
  1192. /// 安卓端使用 建团时添加客户名单
  1193. /// </summary>
  1194. /// <param name="dto"></param>
  1195. /// <returns></returns>
  1196. [HttpPost]
  1197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1198. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1199. {
  1200. #region 参数验证
  1201. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1202. #region 页面操作权限验证
  1203. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1204. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1205. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1206. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1207. #endregion
  1208. #endregion
  1209. try
  1210. {
  1211. //_sqlSugar.BeginTran();
  1212. decimal ffrPrice = 0.00M;
  1213. DateTime? visitDt = null;
  1214. if (dto.Status == 2)
  1215. {
  1216. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1217. if (groupInfo != null)
  1218. {
  1219. ffrPrice = groupInfo.PaymentMoney;
  1220. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1221. }
  1222. }
  1223. var _dto = new GroupOperationDto();
  1224. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1225. var groupData = await _groupRepository.GroupOperation(_dto);
  1226. if (groupData.Code != 0)
  1227. {
  1228. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1229. }
  1230. int diId = 0;
  1231. //添加时 默认加入团组汇率
  1232. if (dto.Status == 1) //添加
  1233. {
  1234. diId = groupData.Data;
  1235. //添加默认币种
  1236. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1237. //默认分配权限
  1238. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1239. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1240. var _managerIds = new List<int>() { 21, 22, 32 };
  1241. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1242. if (userIds.Count > 0)
  1243. {
  1244. userIds.Add(208);
  1245. //创建团组管控
  1246. GroupStepForDelegation.CreateWorkStep(diId);
  1247. //发送消息
  1248. string groupName = dto.TeamName;
  1249. string createGroupUser = string.Empty;
  1250. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1251. if (userInfo != null) createGroupUser = userInfo.CnName;
  1252. string title = $"系统通知";
  1253. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1254. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1255. }
  1256. #region 应用推送
  1257. try
  1258. {
  1259. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1260. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1261. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1262. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1263. {
  1264. var userList = new List<string>() { users.QiyeChatUserId };
  1265. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1266. }
  1267. }
  1268. catch (Exception ex)
  1269. {
  1270. }
  1271. #endregion
  1272. //默认创建倒推表
  1273. await _invertedListRep._Create(dto.UserId, diId);
  1274. //默认创建签证流程
  1275. await _visaProcessRep.Create(dto.UserId, diId);
  1276. //默认创建团组流程总览信息
  1277. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1278. }
  1279. if (dto.Status == 2)
  1280. {
  1281. diId = dto.Id;
  1282. if (diId == 0)
  1283. {
  1284. //_sqlSugar.RollbackTran();
  1285. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1286. }
  1287. }
  1288. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1289. if (viewData.Code != 0)
  1290. {
  1291. //_sqlSugar.RollbackTran();
  1292. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1293. }
  1294. #region 团组操作默认添加/修改收款账单
  1295. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1296. {
  1297. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1298. .Where(x => x.IsDel == 0 &&
  1299. x.Diid == diId &&
  1300. x.Remark.Equals("预付款")
  1301. )
  1302. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1303. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1304. .FirstAsync();
  1305. ffrInfo = new Fin_ForeignReceivables()
  1306. {
  1307. Diid = diId,
  1308. PriceName = dto.ClientUnit,
  1309. Price = dto.PaymentMoney,
  1310. Count = 1,
  1311. Unit = $"元",
  1312. ItemSumPrice = dto.PaymentMoney,
  1313. Rate = 1.0000M,
  1314. Currency = 836,
  1315. AddingWay = 0,
  1316. CreateUserId = dto.UserId,
  1317. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1318. Remark = $"预付款"
  1319. };
  1320. if (ffrInfo == null) //Add
  1321. {
  1322. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1323. }
  1324. else //修改
  1325. {
  1326. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1327. .UpdateColumns(x => new
  1328. {
  1329. x.PriceName,
  1330. x.Price,
  1331. x.ItemSumPrice,
  1332. x.CreateTime,
  1333. x.CreateUserId
  1334. })
  1335. .WhereColumns(x => x.Id)
  1336. .ExecuteCommandAsync();
  1337. }
  1338. }
  1339. #endregion
  1340. #region 签证人员团组时间通知
  1341. #region 计算出访起止时间
  1342. var startTime = new DateTime();
  1343. var endTime = new DateTime();
  1344. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1345. {
  1346. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1347. }
  1348. #endregion
  1349. if (diId > 0)
  1350. {
  1351. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1352. }
  1353. #endregion
  1354. //_sqlSugar.CommitTran();
  1355. return Ok(JsonView(true, "添加成功"));
  1356. }
  1357. catch (Exception ex)
  1358. {
  1359. _sqlSugar.RollbackTran();
  1360. return Ok(JsonView(false, ex.Message));
  1361. }
  1362. }
  1363. /// <summary>
  1364. /// 接团流程操作(增改)
  1365. /// 安卓端使用 建团时添加客户名单
  1366. /// </summary>
  1367. /// <param name="dto"></param>
  1368. /// <returns></returns>
  1369. [HttpPost]
  1370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1371. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1372. {
  1373. #region 参数验证
  1374. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1375. #region 页面操作权限验证
  1376. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1377. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1378. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1379. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1380. #endregion
  1381. #endregion
  1382. _sqlSugar.BeginTran();
  1383. decimal ffrPrice = 0.00M;
  1384. DateTime? visitDt = null;
  1385. if (dto.Status == 2)
  1386. {
  1387. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1388. if (groupInfo != null)
  1389. {
  1390. ffrPrice = groupInfo.PaymentMoney;
  1391. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1392. }
  1393. }
  1394. var _dto = new GroupOperationDto();
  1395. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1396. var groupData = await _groupRepository.GroupOperation(_dto);
  1397. if (groupData.Code != 0)
  1398. {
  1399. _sqlSugar.RollbackTran();
  1400. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1401. }
  1402. try
  1403. {
  1404. int diId = 0;
  1405. //添加时 默认加入团组汇率
  1406. if (dto.Status == 1) //添加
  1407. {
  1408. diId = groupData.Data;
  1409. //添加默认币种
  1410. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1411. //默认分配权限
  1412. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1413. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1414. var _managerIds = new List<int>() { 21, 22, 32 };
  1415. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1416. if (userIds.Count > 0)
  1417. {
  1418. userIds.Add(208);
  1419. //创建团组管控
  1420. GroupStepForDelegation.CreateWorkStep(diId);
  1421. //发送消息
  1422. string groupName = dto.TeamName;
  1423. string createGroupUser = string.Empty;
  1424. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1425. if (userInfo != null) createGroupUser = userInfo.CnName;
  1426. string title = $"系统通知";
  1427. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1428. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1429. }
  1430. #region 应用推送
  1431. try
  1432. {
  1433. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1434. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1435. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1436. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1437. {
  1438. var userList = new List<string>() { users.QiyeChatUserId };
  1439. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1440. }
  1441. }
  1442. catch (Exception ex)
  1443. {
  1444. _sqlSugar.CommitTran();
  1445. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1446. }
  1447. #endregion
  1448. //默认创建倒推表
  1449. await _invertedListRep._Create(dto.UserId, diId);
  1450. }
  1451. else if (dto.Status == 2)
  1452. {
  1453. diId = dto.Id;
  1454. if (diId == 0)
  1455. {
  1456. _sqlSugar.RollbackTran();
  1457. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1458. }
  1459. }
  1460. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1461. if (viewData.Code != 0)
  1462. {
  1463. _sqlSugar.RollbackTran();
  1464. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1465. }
  1466. #region 团组操作默认添加/修改收款账单
  1467. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1468. {
  1469. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1470. .Where(x => x.IsDel == 0 &&
  1471. x.Diid == diId &&
  1472. x.Remark.Equals("预付款")
  1473. )
  1474. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1475. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1476. .FirstAsync();
  1477. ffrInfo = new Fin_ForeignReceivables()
  1478. {
  1479. Diid = diId,
  1480. PriceName = dto.ClientUnit,
  1481. Price = dto.PaymentMoney,
  1482. Count = 1,
  1483. Unit = $"元",
  1484. ItemSumPrice = dto.PaymentMoney,
  1485. Rate = 1.0000M,
  1486. Currency = 836,
  1487. AddingWay = 0,
  1488. CreateUserId = dto.UserId,
  1489. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1490. Remark = $"预付款"
  1491. };
  1492. if (ffrInfo == null) //Add
  1493. {
  1494. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1495. }
  1496. else //修改
  1497. {
  1498. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1499. .UpdateColumns(x => new
  1500. {
  1501. x.PriceName,
  1502. x.Price,
  1503. x.ItemSumPrice,
  1504. x.CreateTime,
  1505. x.CreateUserId
  1506. })
  1507. .WhereColumns(x => x.Id)
  1508. .ExecuteCommandAsync();
  1509. }
  1510. }
  1511. #endregion
  1512. #region 签证人员团组时间通知
  1513. #region 计算出访起止时间
  1514. var startTime = new DateTime();
  1515. var endTime = new DateTime();
  1516. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1517. {
  1518. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1519. }
  1520. #endregion
  1521. if (diId > 0)
  1522. {
  1523. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1524. }
  1525. #endregion
  1526. _sqlSugar.CommitTran();
  1527. return Ok(JsonView(true));
  1528. }
  1529. catch (Exception ex)
  1530. {
  1531. _sqlSugar.RollbackTran();
  1532. return Ok(JsonView(false, ex.Message));
  1533. }
  1534. }
  1535. /// <summary>
  1536. /// 接团信息 操作(删除)
  1537. /// </summary>
  1538. /// <param name="dto"></param>
  1539. /// <returns></returns>
  1540. [HttpPost]
  1541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1542. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1543. {
  1544. var diId = dto.Id;
  1545. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1546. #region 删除 验证
  1547. /*
  1548. * 1、收款账单数据:0 条
  1549. * 2、收款退还数据:0 条
  1550. * 3、机票费用数据:0 条
  1551. * 4、签证费用数据:0 条
  1552. * 5、保险费用数据:0 条
  1553. * 6、酒店费用数据:0 条
  1554. * 7、公务出访数据:1 条
  1555. * 8、邀请公务活动费用数据:1 条
  1556. * 9、OP费用数据:5 条
  1557. * 10、其他费用数据:0 条
  1558. * 11、团组日付报销费用数据:0 条
  1559. *
  1560. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1561. */
  1562. //收款账单
  1563. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1564. //收款退还
  1565. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1566. //机票费用
  1567. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1568. //签证费用
  1569. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1570. //保险费用
  1571. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1572. //酒店费用
  1573. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1574. //公务出访
  1575. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1576. //邀请公务活动费用
  1577. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1578. //OP费用
  1579. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1580. //其他费用
  1581. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1582. //团组日付报销费用
  1583. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1584. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1585. if (feeCount > 0)
  1586. {
  1587. var delMsgTips = new StringBuilder();
  1588. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1589. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1590. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1591. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1592. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1593. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1594. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1595. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1596. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1597. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1598. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1599. delMsgTips.AppendLine($"");
  1600. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1601. return Ok(JsonView(false, delMsgTips.ToString()));
  1602. }
  1603. #endregion
  1604. var groupData = await _groupRepository.GroupDel(dto);
  1605. if (groupData.Code != 0)
  1606. {
  1607. return Ok(JsonView(false, groupData.Msg));
  1608. }
  1609. return Ok(JsonView(true));
  1610. }
  1611. /// <summary>
  1612. /// 获取团组销售报价号
  1613. /// 团组添加时 使用
  1614. /// </summary>
  1615. /// <returns></returns>
  1616. [HttpPost]
  1617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1618. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1619. {
  1620. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1621. if (groupData.Code != 0)
  1622. {
  1623. return Ok(JsonView(false, groupData.Msg));
  1624. }
  1625. object salesQuoteNo = new
  1626. {
  1627. SalesQuoteNo = groupData.Data
  1628. };
  1629. return Ok(JsonView(salesQuoteNo));
  1630. }
  1631. /// <summary>
  1632. /// 设置确认出团
  1633. /// </summary>
  1634. /// <param name="dto"></param>
  1635. /// <returns></returns>
  1636. [HttpPost]
  1637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1638. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1639. {
  1640. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1641. if (groupData.Code != 0)
  1642. {
  1643. return Ok(JsonView(false, groupData.Msg));
  1644. }
  1645. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1646. #region OA消息推送
  1647. try
  1648. {
  1649. string groupName = groupInfo.TeamName;
  1650. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1651. string title = $"系统通知";
  1652. string content = $"团组[{groupName}]已确认出团!";
  1653. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1654. }
  1655. catch (Exception ex)
  1656. {
  1657. }
  1658. #endregion
  1659. #region 应用推送
  1660. try
  1661. {
  1662. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1663. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1664. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1665. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1666. {
  1667. var userList = new List<string>() { users.QiyeChatUserId };
  1668. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1669. }
  1670. }
  1671. catch (Exception ex)
  1672. {
  1673. }
  1674. #endregion
  1675. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1676. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1677. }
  1678. /// <summary>
  1679. /// 获取团组名称data And 签证国别Data
  1680. /// </summary>
  1681. /// <param name="dto"></param>
  1682. /// <returns></returns>
  1683. [HttpPost]
  1684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1685. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1686. {
  1687. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1688. if (groupData.Code != 0)
  1689. {
  1690. return Ok(JsonView(false, groupData.Msg));
  1691. }
  1692. return Ok(JsonView(groupData.Data));
  1693. }
  1694. /// <summary>
  1695. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1696. /// </summary>
  1697. /// <returns></returns>
  1698. [HttpPost]
  1699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1700. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1701. {
  1702. try
  1703. {
  1704. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1705. if (groupData.Code != 0)
  1706. {
  1707. return Ok(JsonView(false, groupData.Msg));
  1708. }
  1709. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1710. }
  1711. catch (Exception ex)
  1712. {
  1713. return Ok(JsonView(false, ex.Message));
  1714. throw;
  1715. }
  1716. }
  1717. /// <summary>
  1718. /// 团组清单 Excel
  1719. /// </summary>
  1720. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1721. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1722. /// <returns></returns>
  1723. [HttpGet]
  1724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1725. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1726. {
  1727. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1728. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1729. if (!beginBool && !endBool)
  1730. {
  1731. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1732. }
  1733. string sql = string.Format(@"
  1734. SELECT
  1735. ROW_NUMBER,
  1736. Id,
  1737. SalesQuoteNo,
  1738. TourCode,
  1739. TeamTypeId,
  1740. TeamType,
  1741. TeamLevId,
  1742. TeamLev,
  1743. TeamName,
  1744. ClientName,
  1745. ClientUnit,
  1746. VisitDate,
  1747. VisitDays,
  1748. VisitPNumber,
  1749. JietuanOperatorId,
  1750. JietuanOperator,
  1751. IsSure,
  1752. CreateUserName,
  1753. IsBid
  1754. FROM
  1755. (
  1756. SELECT
  1757. ROW_NUMBER() OVER(
  1758. ORDER BY
  1759. gdi.VisitDate Desc
  1760. ) AS ROW_NUMBER,
  1761. gdi.Id,
  1762. SalesQuoteNo,
  1763. TourCode,
  1764. ssd.Id TeamTypeId,
  1765. ssd.Name TeamType,
  1766. ssd1.Id TeamLevId,
  1767. ssd1.Name TeamLev,
  1768. TeamName,
  1769. ClientName,
  1770. ClientUnit,
  1771. VisitDate,
  1772. VisitDays,
  1773. VisitPNumber,
  1774. JietuanOperator JietuanOperatorId,
  1775. su.CnName JietuanOperator,
  1776. IsSure,
  1777. gdi.CreateTime,
  1778. su1.CnName As CreateUserName,
  1779. gdi.IsBid
  1780. FROM
  1781. Grp_DelegationInfo gdi
  1782. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1783. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1784. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1785. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1786. WHERE
  1787. gdi.IsDel = 0
  1788. AND gdi.IsBid = 0
  1789. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1790. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1791. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1792. #region 处理所属部门
  1793. /*
  1794. * 1.sq 和 gyy 等显示 市场部
  1795. * 2.王鸽和主管及张总还有管理员号统一国交部
  1796. * 2-1. 4 管理员 ,21 张海麟
  1797. */
  1798. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1799. var userIds1 = new List<int>() { 4, 21 };
  1800. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1801. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1802. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1803. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1804. .ToListAsync();
  1805. var droupIds = groupList.Select(it => it.Id).ToList();
  1806. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1807. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1808. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1809. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1810. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1811. {
  1812. DiId = tcl.DiId,
  1813. LastName = dc.LastName,
  1814. FirstName = dc.FirstName,
  1815. Sex = dc.Sex,
  1816. Birthday = dc.BirthDay,
  1817. Company = cc.CompanyFullName,
  1818. Job = dc.Job,
  1819. CreateTime = tcl.CreateTime,
  1820. })
  1821. .ToList();
  1822. foreach (var item in groupList)
  1823. {
  1824. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1825. string groupFirstName = "";
  1826. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1827. if (currDatas.Any())
  1828. {
  1829. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1830. }
  1831. item.GroupFirst = groupFirstName;
  1832. }
  1833. #endregion
  1834. #region Excel
  1835. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1836. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1837. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1838. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1839. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1840. //载入模板
  1841. var designer = new WorkbookDesigner
  1842. {
  1843. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1844. };
  1845. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1846. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1847. dt.TableName = "GroupList";
  1848. designer.SetDataSource(dt);
  1849. designer.Process();
  1850. if (!Directory.Exists(savePath))
  1851. {
  1852. Directory.CreateDirectory(savePath);
  1853. }
  1854. string serverPath = $"{savePath}{fileName}";
  1855. designer.Workbook.Save(serverPath);
  1856. string rst = $"{servicePath}{ftpPath}{fileName}";
  1857. #endregion
  1858. return Ok(JsonView(true, "操作成功!", rst));
  1859. }
  1860. /// <summary>
  1861. /// 团组合同下载(1.付款80% 2.付全款)
  1862. /// </summary>
  1863. /// <param name="dto"></param>
  1864. /// <returns></returns>
  1865. /// <exception cref="Exception"></exception>
  1866. [HttpPost]
  1867. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1868. {
  1869. var jw = JsonView(false);
  1870. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1871. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1872. if (di == null)
  1873. {
  1874. jw.Msg = "团组Id有误!";
  1875. return Ok(jw);
  1876. }
  1877. #region 权限校验
  1878. var allDownFile = new List<int>() { 21 };
  1879. try
  1880. {
  1881. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1882. .First(x => x.Id == 1418 && x.IsDel == 0);
  1883. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1884. }
  1885. catch (Exception)
  1886. { }
  1887. var guojiaoDownFile = new List<int>() { 330, 383 };
  1888. var shichangDownFile = new List<int>() { 95 };
  1889. if (allDownFile.Contains(dto.UserId))
  1890. {
  1891. }
  1892. else if (guojiaoDownFile.Contains(dto.UserId))
  1893. {
  1894. var guojiaobuDi = new List<int>() { 4, 21 };
  1895. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1896. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1897. .Where((d, u) => u.Id == di.JietuanOperator)
  1898. .Select((d, u) => d.DepName)
  1899. .First();
  1900. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1901. {
  1902. jw.Msg = "暂无下载权限!";
  1903. return Ok(jw);
  1904. }
  1905. }
  1906. else if (shichangDownFile.Contains(dto.UserId))
  1907. {
  1908. var dic = new Dictionary<int, int[]>()
  1909. {
  1910. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1911. };
  1912. try
  1913. {
  1914. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1915. if (sqSetting != null)
  1916. {
  1917. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1918. foreach (var item in result.Keys)
  1919. {
  1920. if (dic.ContainsKey(item))
  1921. {
  1922. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1923. Array.Copy(dic[item], dilatation, dic[item].Length);
  1924. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1925. dic[item] = dilatation;
  1926. }
  1927. else
  1928. {
  1929. dic.Add(item, result[item]);
  1930. }
  1931. }
  1932. }
  1933. if (!dic[95].Contains(di.CreateUserId))
  1934. {
  1935. jw.Msg = "暂无下载权限!";
  1936. return Ok(jw);
  1937. }
  1938. }
  1939. catch (Exception)
  1940. { }
  1941. }
  1942. else if (dto.UserId == di.CreateUserId)
  1943. {
  1944. }
  1945. else
  1946. {
  1947. jw.Msg = "暂无下载权限!";
  1948. return Ok(jw);
  1949. }
  1950. #endregion
  1951. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1952. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1953. .ToListAsync();
  1954. if (!blackCodeList.Any())
  1955. {
  1956. jw.Msg = "该团无机票行程代码!";
  1957. return Ok(jw);
  1958. }
  1959. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1960. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1961. if (groupEnterExitCost == null)
  1962. {
  1963. jw.Msg = "暂无三公费用信息!";
  1964. return Ok(jw);
  1965. }
  1966. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1967. rateList ??= new List<CurrencyInfo>();
  1968. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1969. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1970. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1971. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1972. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1973. .Select((x, a, b) => new
  1974. {
  1975. x.Index,
  1976. itemName = a.Name,
  1977. CurrencyStr = b.Name,
  1978. x.Cost,
  1979. x.SubTotal,
  1980. x.Remark
  1981. })
  1982. .OrderBy((x) => x.Index)
  1983. .ToList();
  1984. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1985. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1986. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1987. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1988. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1989. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1990. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1991. decimal subJJC = 0.00M,
  1992. subGWC = 0.00M,
  1993. subTDC = 0.00M;
  1994. //经济舱
  1995. if (groupEnterExitCost.SumJJC == 1)
  1996. {
  1997. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1998. }
  1999. //公务舱
  2000. if (groupEnterExitCost.SumGWC == 1)
  2001. {
  2002. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  2003. }
  2004. //头等舱
  2005. if (groupEnterExitCost.SumTDC == 1)
  2006. {
  2007. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  2008. }
  2009. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  2010. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  2011. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  2012. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  2013. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  2014. .Select((x, s, dc, cc) => new GroupClints
  2015. {
  2016. Id = x.Id,
  2017. Name = s.Name,
  2018. IsAccompany = x.IsAccompany,
  2019. CompanyFullName = cc.CompanyFullName
  2020. })
  2021. .ToListAsync();
  2022. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  2023. //获取舱位人数
  2024. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  2025. .GroupBy(x => x.Name)
  2026. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  2027. .ToList();
  2028. string cityPath = string.Empty;
  2029. string startCity = string.Empty;
  2030. string endCity = string.Empty;
  2031. foreach (var item in blackCodeList)
  2032. {
  2033. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2034. cityPath += city + "\r\n";
  2035. if (item.Equals(blackCodeList.First()))
  2036. {
  2037. var sp = city.Split('-');
  2038. startCity = sp[0];
  2039. endCity = sp[^1];
  2040. }
  2041. }
  2042. di.VisitCountry = Regex.Replace(di.VisitCountry, @"[|-]", "、");
  2043. var bookMarkDic = new Dictionary<string, string>
  2044. {
  2045. { "ClientUnit", di.ClientUnit },
  2046. { "VisitCountry", di.VisitCountry },
  2047. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2048. { "VisitPNumber", di.VisitPNumber.ToString() },
  2049. { "CityPath", cityPath },
  2050. { "StartCity", startCity },
  2051. { "EndCity", endCity },
  2052. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2053. };
  2054. Document doc = null;
  2055. var percentage = 0.8M;
  2056. var fileNameadd = "预付";
  2057. if (dto.FileType == 1)
  2058. {
  2059. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2060. }
  2061. else if (dto.FileType == 2)
  2062. {
  2063. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2064. percentage = 1;
  2065. fileNameadd = "全款";
  2066. }
  2067. else
  2068. {
  2069. throw new Exception("FileType有误!");
  2070. }
  2071. var builder = new DocumentBuilder(doc);
  2072. decimal totalPrice = 0.00M;
  2073. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2074. if (firstTable != null)
  2075. {
  2076. // 遍历表格的行和单元格
  2077. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2078. {
  2079. for (int i = 0; i < row.Cells.Count; i++)
  2080. {
  2081. var cell = row.Cells[i];
  2082. // 读取单元格内容
  2083. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2084. if (cellTextFirst.Contains("舱位"))
  2085. {
  2086. break;
  2087. }
  2088. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2089. {
  2090. if (i == 2)
  2091. {
  2092. if (cellTextFirst == "经济舱")
  2093. {
  2094. // 设置单元格内容
  2095. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2096. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2097. }
  2098. else
  2099. {
  2100. // 设置单元格内容
  2101. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2102. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2103. }
  2104. }
  2105. if (i == 3)
  2106. {
  2107. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2108. if (count != null)
  2109. {
  2110. // 设置单元格内容
  2111. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2112. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2113. }
  2114. }
  2115. if (i == 4)
  2116. {
  2117. var rowPrice = 0.00M;
  2118. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2119. count ??= 0;
  2120. if (cellTextFirst == "经济舱")
  2121. {
  2122. rowPrice = subJJC * (int)count;
  2123. }
  2124. else
  2125. {
  2126. rowPrice = subGWC * (int)count;
  2127. }
  2128. totalPrice += rowPrice;
  2129. // 设置单元格内容
  2130. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2131. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2132. }
  2133. }
  2134. }
  2135. }
  2136. }
  2137. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2138. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2139. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2140. //--合同表格部分
  2141. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2142. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2143. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2144. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2145. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2146. bookMarkDic.Add("CityPath1", cityPath);
  2147. bookMarkDic.Add("CityPath2", cityPath);
  2148. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2149. if (contractTable != null)
  2150. {
  2151. //数据源
  2152. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2153. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2154. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2155. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2156. .Select((it, y, s) => new
  2157. {
  2158. it.Cost,
  2159. it.SubTotal,
  2160. it.Type,
  2161. y.Id,
  2162. y.City,
  2163. s.Name,
  2164. CurrencyCodeCn = s.Remark
  2165. })
  2166. .ToList()
  2167. .Select(x => new
  2168. {
  2169. CurrencyCode = x.Name,
  2170. CityId = x.Id,
  2171. x.City,
  2172. di.VisitPNumber,
  2173. x.Type,
  2174. x.Cost,
  2175. x.SubTotal,
  2176. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2177. x.CurrencyCodeCn,
  2178. });
  2179. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2180. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2181. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2182. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2183. var tableSettings = new List<tableSetting>()
  2184. {
  2185. new(){ Index = 1 , Property = "City"},
  2186. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2187. new(){ Index = 3 , Property = "Cost"},
  2188. new(){ Index = 4 , Property = "VisitPNumber"},
  2189. //new tableSetting{ Index = 5 , Property = ""},
  2190. //new tableSetting{ Index = 6 , Property = ""},
  2191. new(){ Index = 7 , Property = "Rate"},
  2192. //new tableSetting{ Index = 8 , Property = ""},
  2193. };
  2194. //1.住宿费
  2195. int cloneRow = 8;
  2196. int startDayPrice = 8; //写入index
  2197. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2198. foreach (var dac in dac1)
  2199. {
  2200. var first = dac.First();
  2201. var dayCount = dac.Count();
  2202. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2203. for (int i = 1; i < row.Cells.Count; i++)
  2204. {
  2205. var cell = row.Cells[i];
  2206. var findProperty = tableSettings.Find(x => x.Index == i);
  2207. if (findProperty != null)
  2208. {
  2209. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2210. // 设置单元格内容
  2211. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2212. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2213. }
  2214. else
  2215. {
  2216. switch (i)
  2217. {
  2218. case 5:
  2219. cell.FirstParagraph.Runs.Clear();
  2220. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2221. break;
  2222. case 6:
  2223. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2224. cell.FirstParagraph.Runs.Clear();
  2225. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2226. break;
  2227. case 8:
  2228. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2229. cell.FirstParagraph.Runs.Clear();
  2230. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2231. ZSPriceSum += xiaojiRMB;
  2232. break;
  2233. default:
  2234. break;
  2235. }
  2236. }
  2237. }
  2238. startDayPrice++;
  2239. if (!dac1.Last().Equals(dac))
  2240. {
  2241. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2242. // 将克隆的行追加到原行后面
  2243. contractTable.Rows.Insert(startDayPrice, newRow);
  2244. }
  2245. else
  2246. {
  2247. cloneRow += dac1.Count + 1;
  2248. startDayPrice = cloneRow;
  2249. }
  2250. }
  2251. //2.伙食费
  2252. foreach (var dac in dac2)
  2253. {
  2254. var first = dac.First();
  2255. var dayCount = dac.Count();
  2256. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2257. for (int i = 1; i < row.Cells.Count; i++)
  2258. {
  2259. var cell = row.Cells[i];
  2260. var findProperty = tableSettings.Find(x => x.Index == i);
  2261. if (findProperty != null)
  2262. {
  2263. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2264. // 设置单元格内容
  2265. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2266. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2267. }
  2268. else
  2269. {
  2270. switch (i)
  2271. {
  2272. case 5:
  2273. cell.FirstParagraph.Runs.Clear();
  2274. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2275. break;
  2276. case 6:
  2277. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2278. cell.FirstParagraph.Runs.Clear();
  2279. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2280. break;
  2281. case 8:
  2282. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2283. cell.FirstParagraph.Runs.Clear();
  2284. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2285. HSPriceSum += xiaojiRMB;
  2286. break;
  2287. default:
  2288. break;
  2289. }
  2290. }
  2291. }
  2292. startDayPrice++;
  2293. if (!dac2.Last().Equals(dac))
  2294. {
  2295. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2296. // 将克隆的行追加到原行后面
  2297. contractTable.Rows.Insert(startDayPrice, newRow);
  2298. }
  2299. else
  2300. {
  2301. cloneRow += dac2.Count + 1;
  2302. startDayPrice = cloneRow;
  2303. }
  2304. }
  2305. //3.公杂费
  2306. foreach (var dac in dac3)
  2307. {
  2308. var first = dac.First();
  2309. var dayCount = dac.Count();
  2310. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2311. for (int i = 1; i < row.Cells.Count; i++)
  2312. {
  2313. var cell = row.Cells[i];
  2314. var findProperty = tableSettings.Find(x => x.Index == i);
  2315. if (findProperty != null)
  2316. {
  2317. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2318. // 设置单元格内容
  2319. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2320. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2321. }
  2322. else
  2323. {
  2324. switch (i)
  2325. {
  2326. case 5:
  2327. cell.FirstParagraph.Runs.Clear();
  2328. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2329. break;
  2330. case 6:
  2331. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2332. cell.FirstParagraph.Runs.Clear();
  2333. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2334. break;
  2335. case 8:
  2336. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2337. cell.FirstParagraph.Runs.Clear();
  2338. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2339. GZPriceSum += xiaojiRMB;
  2340. break;
  2341. default:
  2342. break;
  2343. }
  2344. }
  2345. }
  2346. startDayPrice++;
  2347. if (!dac3.Last().Equals(dac))
  2348. {
  2349. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2350. // 将克隆的行追加到原行后面
  2351. contractTable.Rows.Insert(startDayPrice, newRow);
  2352. }
  2353. else
  2354. {
  2355. cloneRow += dac3.Count + 1;
  2356. startDayPrice = cloneRow;
  2357. }
  2358. }
  2359. //合并单元格
  2360. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2361. {
  2362. var currentRow = contractTable.Rows[i];
  2363. var nextRow = contractTable.Rows[i + 1];
  2364. // 获取当前行和下一行的第一个单元格
  2365. Cell currentCell = currentRow.Cells[0];
  2366. Cell nextCell = nextRow.Cells[0];
  2367. // 检查单元格内容是否一致(去除尾部的换行符)
  2368. string currentText = currentCell.GetText().Trim();
  2369. string nextText = nextCell.GetText().Trim();
  2370. if (currentText == nextText)
  2371. {
  2372. // 如果当前单元格已经被合并,找到合并的起始单元格
  2373. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2374. {
  2375. // 找到合并的起始单元格
  2376. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2377. // 将下一行的单元格设置为合并的后续单元格
  2378. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2379. }
  2380. else
  2381. {
  2382. // 如果当前单元格是合并的起始单元格
  2383. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2384. // 将下一行的单元格设置为合并的后续单元格
  2385. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2386. }
  2387. }
  2388. else
  2389. {
  2390. // 如果内容不一致,重置当前单元格的合并属性
  2391. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2392. {
  2393. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2394. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2395. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2396. }
  2397. else
  2398. {
  2399. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2400. }
  2401. }
  2402. }
  2403. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2404. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2405. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2406. }
  2407. foreach (var bookmarkName in bookMarkDic.Keys)
  2408. {
  2409. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2410. if (bookmark != null)
  2411. {
  2412. if (bookmarkName == "ClientUnit")
  2413. {
  2414. // 移动到书签位置
  2415. builder.MoveTo(bookmark.BookmarkStart);
  2416. // 设置字体样式为下划线
  2417. builder.Font.Underline = Aspose.Words.Underline.Single;
  2418. // 插入书签值
  2419. builder.Write(bookMarkDic[bookmarkName]);
  2420. // 清除字体格式,避免影响后续文本
  2421. builder.Font.ClearFormatting();
  2422. }
  2423. else
  2424. {
  2425. builder.MoveToBookmark(bookmarkName);
  2426. builder.Write(bookMarkDic[bookmarkName]);
  2427. }
  2428. }
  2429. }
  2430. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2431. doc.Save(savePaht);
  2432. jw.Msg = "生成成功!";
  2433. jw.Code = 200;
  2434. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2435. return Ok(jw);
  2436. }
  2437. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2438. {
  2439. int index = rowIndex;
  2440. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2441. {
  2442. index--;
  2443. }
  2444. return index;
  2445. }
  2446. /// <summary>
  2447. /// 报批完成企微通知
  2448. /// </summary>
  2449. /// <param name="dto"></param>
  2450. /// <returns></returns>
  2451. [HttpPost]
  2452. public async Task<IActionResult> EnterpriseWeChatNotificationAsyncBaoPi(EnterpriseWeChatNotificationAsyncBaoPiDto dto)
  2453. {
  2454. int currUserId = dto.currUserId;
  2455. int diid = dto.diid;
  2456. var jw = JsonView(true);
  2457. var users = new List<string>();
  2458. var ssd = _sqlSugar.Queryable<Sys_SetData>()
  2459. .First(x => x.Id == 1460);
  2460. try
  2461. {
  2462. users = JsonConvert.DeserializeObject<List<string>>(ssd.Remark);
  2463. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(dto.diid);
  2464. //添加分配人员
  2465. // 79 车/导游地接
  2466. // 80 签证
  2467. // 81 邀请/公务活动
  2468. var setdataids = new List<int>() { 79, 81 };
  2469. foreach (var groupModule in groupModuleOperators)
  2470. {
  2471. if (setdataids.Contains(groupModule.CTableId))
  2472. {
  2473. users.AddRange(groupModule.OperationUsers.Select(x => x.UserId.ToString()));
  2474. }
  2475. }
  2476. var res = await AppNoticeLibrary.SendUserMsg_BaoPi_ToUser(users, diid);
  2477. //消息通知成功 更改团组step、记录日志
  2478. if (res)
  2479. {
  2480. var groupStep = 0; //0-新建 1-企微消息通知
  2481. //更改团组step
  2482. var updStatus = await _sqlSugar.Updateable<Grp_DelegationInfo>()
  2483. .SetColumns(x => new Grp_DelegationInfo()
  2484. {
  2485. Step = 2
  2486. })
  2487. .Where(x => x.Id == diid && x.IsDel == 0)
  2488. .ExecuteCommandAsync();
  2489. if (updStatus > 0) groupStep = 2;
  2490. string groupStepLabel = groupStep switch
  2491. {
  2492. 1 => "新建",
  2493. 2 => "企微消息通知(报批)",
  2494. _ => "未设置"
  2495. };
  2496. //记录日志
  2497. var teamName = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2498. .Where(x => x.Id == diid && x.IsDel == 0)
  2499. .Select(x => x.TeamName)
  2500. .First() ?? "-";
  2501. var operationName = _sqlSugar.Queryable<Sys_Users>()
  2502. .Where(x => x.Id == currUserId && x.IsDel == 0)
  2503. .Select(x => x.CnName)
  2504. .First() ?? "-";
  2505. _groupTextLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】{logContent}", teamName, diid, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), groupStepLabel);
  2506. //设置 签证流程初始值
  2507. await _visaProcessRep.UpdateBatchTop4Step(dto.diid, dto.currUserId);
  2508. }
  2509. }
  2510. catch (Exception ex)
  2511. {
  2512. return Ok(JsonView(false, ex.Message));
  2513. }
  2514. return Ok(jw);
  2515. }
  2516. #endregion
  2517. #region 团组&签证
  2518. #region 团组&签证 New
  2519. /// <summary>
  2520. /// 团组&签证 New
  2521. /// DeepSeek API:测试API连通性
  2522. /// </summary>
  2523. /// <param name="file">请求dto</param>
  2524. /// <returns></returns>
  2525. [HttpPost]
  2526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2527. public async Task<IActionResult> TestDeepSeekApiConnectivityAsync()
  2528. {
  2529. return Ok(JsonView(await _deepSeekService.TestApiConnectivityAsync()));
  2530. }
  2531. /// <summary>
  2532. /// 团组&签证 New
  2533. /// DeepSeek API:检查可用端点
  2534. /// </summary>
  2535. /// <param name="file">请求dto</param>
  2536. /// <returns></returns>
  2537. [HttpPost]
  2538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2539. public async Task<IActionResult> DiscoverAvailableEndpointsAsync()
  2540. {
  2541. return Ok(JsonView(await _deepSeekService.DiscoverAvailableEndpointsAsync()));
  2542. }
  2543. /// <summary>
  2544. /// 团组&签证 New
  2545. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2546. /// </summary>
  2547. /// <param name="visaFile">文件</param>
  2548. /// <param name="fileTypeId">
  2549. /// 1. 澳新签证个人申请表
  2550. /// 2. 出国个人申请表
  2551. /// 3. 美国签证个人申请表格
  2552. /// 4. 沙特个人信息表格
  2553. /// 5. 申根签证个人资料表
  2554. /// 6. 中文个人简历模板
  2555. /// </param>
  2556. /// <returns></returns>
  2557. [HttpPost]
  2558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2559. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile visaFile, int fileTypeId)
  2560. {
  2561. //文件验证
  2562. if (visaFile.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2563. //var visaFiles = new VisaUploadFileTypeView();
  2564. //var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2565. //if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2566. //服务器存储文件
  2567. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2568. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2569. var filePath = Path.Combine(fileServerPath, visaFile.FileName);
  2570. using (var stream = new FileStream(filePath, FileMode.Create))
  2571. {
  2572. await visaFile.CopyToAsync(stream);
  2573. }
  2574. //日志记录-上传文件
  2575. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, visaFile.FileName);
  2576. #region 上传文件到DeepSeekAPI
  2577. //IFormFile localFile = null;
  2578. ////获取项目中的cs文件
  2579. //try
  2580. //{
  2581. // _logger.LogInformation("读取并上传项目文件请求");
  2582. // // 1. 读取项目文件
  2583. // var readResponse = await _deepSeekService.ReadProjectFilesAsync(new List<string>() { @"OASystem.Domain\ViewModels\VisaFormDetails\AusNewVisaApplicationForm.cs" });
  2584. // if (readResponse.SuccessCount == 0)
  2585. // {
  2586. // return Ok(JsonView(false, "读取项目文件失败"));
  2587. // }
  2588. // localFile = readResponse.FileInfos.FirstOrDefault().FormFile;
  2589. //}
  2590. //catch (Exception ex)
  2591. //{
  2592. // _logger.LogError(ex, "读取项目文件失败");
  2593. // return Ok(JsonView(false, "读取项目文件失败"));
  2594. //}
  2595. //if (localFile == null)
  2596. //{
  2597. // return Ok(JsonView(false, "读取项目文件失败"));
  2598. //}
  2599. //var fileReq = new DeepSeekFileUploadRequest()
  2600. //{
  2601. // Files = new List<IFormFile> { localFile, visaFile },
  2602. //};
  2603. //var filesResult = new List<FileUploadResult>();
  2604. //try
  2605. //{
  2606. // _logger.LogInformation("开始上传 {FileCount} 个文件到DeepSeek API", fileReq.Files.Count);
  2607. // filesResult = await _deepSeekService.UploadFilesAsync(fileReq.Files, fileReq.Purpose);
  2608. // // 需要等待处理完成
  2609. // if (fileReq.WaitForProcessing)
  2610. // {
  2611. // foreach (var result in filesResult)
  2612. // {
  2613. // if (result.Success)
  2614. // {
  2615. // try
  2616. // {
  2617. // var processedFile = await _deepSeekService.WaitForFileProcessingAsync(result.FileId);
  2618. // result.Status = processedFile.Status;
  2619. // }
  2620. // catch (Exception ex)
  2621. // {
  2622. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  2623. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2624. // }
  2625. // }
  2626. // }
  2627. // }
  2628. //}
  2629. //catch (Exception ex)
  2630. //{
  2631. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  2632. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2633. //}
  2634. //#endregion
  2635. //if (filesResult == null || filesResult.Count < 1)
  2636. //{
  2637. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败"));
  2638. //}
  2639. ////
  2640. //try
  2641. //{
  2642. // var fileIds = filesResult.Where(x => x.Success).Select(x => x.FileId).ToList();
  2643. // _logger.LogInformation("使用 {FileCount} 个文件进行聊天", fileIds.Count);
  2644. // string question = string.Format("将上传的文件内容按照识别为JSON格式,并按照 AusNewVisaApplicationForm 指定的实体类结构进行映射。确保字段和值对应、文档中数据的完整性、复选框选择打勾后的文本。第一项从不识别\"比如美国(2024年7月29日)\"相关文字。");
  2645. // var response = await _deepSeekService.ChatWithFilesAsync(fileIds, question);
  2646. // return Ok(response);
  2647. //}
  2648. //catch (Exception ex)
  2649. //{
  2650. // _logger.LogError(ex, "使用文件聊天失败");
  2651. // return Ok(JsonView(false, $"聊天失败: {ex.Message}"));
  2652. //}
  2653. #endregion
  2654. #region kimi API
  2655. //加载文件OpCarTouristGuideGroundContent
  2656. //kimi AI 识别文档返回json结果
  2657. int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2658. var KiMiApi = new KiMiApiClient();
  2659. var files = new List<IFormFile>() { visaFile };
  2660. var seedConter = await KiMiApi.UploadFilesAsync(files);
  2661. if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2662. //var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2663. var seedMessage = string.Format(@"你是领事馆电子材料审核员,只关注 Word 里的表格,正文、页眉页脚、水印、批注全部忽略。
  2664. 任务:把表格里的每个可填字段转换成“标题:值”的键值对,标题用原文,值用原文,不翻译。
  2665. 规则如下:
  2666. 1. 行列对齐:先按视觉补齐所有合并单元格——纵向合并则重复上方单元格内容,横向合并则留空字符串;无线表按对齐虚拟列线。
  2667. 2. 单格内出现多个“□”时,把被勾选(☑、√、×、■)的选项原文输出;若没有任何勾选,该字段输出 null。
  2668. 3. 所有日期统一转 yyyy-mm-dd,原格式“1990年1月1日”→1990-01-01;若缺日/月,用-01补位。
  2669. 4. 电话、传真、手机号:输出连续数字,遇到“(0 )”或“-”一律删除,只保留 7~15 位数字;若缺区号,原样保留。
  2670. 5. 金额:保留原数字,如“3000”。
  2671. 6. 地址:省、市、区、街道、门牌、邮编用空格分隔,不省略。
  2672. 7. 若同一张表出现“现住址”“家庭地址”“单位地址”等多列,依次编号 address_home / address_unit / address_legal。
  2673. 8. 输出顺序:按表格从左到右、从上到下逐行扫描,字段名重复时加序号,如 child_name_1、child_name_2。
  2674. 9. 结果格式:每行一个键值对,字段名与值之间用英文冒号+空格分隔,不要表格 Markdown,不要多余说明。
  2675. 10. 文件命名空间:每份表的最前面加一行 filename 作为起始标记(例:出国个人申请表.doc)。
  2676. 11. 内容为空的字段,显示标题,记空值。
  2677. 12. 只返回json结果,不需要其他内容;json内容去掉换行。");
  2678. var messages = new List<SeedMessages>
  2679. {
  2680. new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2681. new() { Role = KimiRole.user, Content = seedMessage }
  2682. };
  2683. messages.InsertRange(1, seedConter);
  2684. string jsonString = string.Empty;
  2685. object jsonData = null;
  2686. bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2687. while (!isJson)
  2688. {
  2689. kimiAI_API_Index++;
  2690. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2691. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2692. jsonString += kimiApiResult_JObject["content"].ToString();
  2693. string startStr = "```json", endStr = "```";
  2694. // 判断并清除开头部分
  2695. if (jsonString.StartsWith(startStr))
  2696. {
  2697. jsonString = jsonString.Replace(startStr, "");
  2698. }
  2699. // 判断并清除结尾部分
  2700. if (jsonString.EndsWith(endStr))
  2701. {
  2702. jsonString = jsonString.Replace(endStr, "");
  2703. }
  2704. //验证json格式是否正确
  2705. try
  2706. {
  2707. jsonData = JsonDocument.Parse(jsonString);
  2708. isJson = true; // 如果解析成功,则是json格式
  2709. }
  2710. catch (Exception)
  2711. {
  2712. //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2713. messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2714. }
  2715. }
  2716. if (jsonData == null)
  2717. {
  2718. return Ok(JsonView(false, "kimi识别json转换失败。"));
  2719. }
  2720. var visaDetails = new VisaDetailsView();
  2721. //按照表格类型分别进行参数处理
  2722. // 1. 澳新签证个人申请表
  2723. // 2. 出国个人申请表
  2724. // 3. 美国签证个人申请表格
  2725. // 4. 沙特个人信息表格
  2726. // 5. 申根签证个人资料表
  2727. // 6. 中文个人简历模板
  2728. switch (fileTypeId)
  2729. {
  2730. //澳新签证个人申请表
  2731. case 1:
  2732. _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2733. VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2734. break;
  2735. //美国签证个人申请表格
  2736. case 3:
  2737. _logger.LogInformation("【签证上传文件操作信息】【美国签证个人申请表格】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2738. string name = (string)jsonData.GetType().GetProperty("姓名")!.GetValue(jsonData)!;
  2739. string passportNo = (string)jsonData.GetType().GetProperty("护照号码")!.GetValue(jsonData)!;
  2740. string passportPlace = (string)jsonData.GetType().GetProperty("护照签发地")!.GetValue(jsonData)!;
  2741. string idNo = (string)jsonData.GetType().GetProperty("身份证号码")!.GetValue(jsonData)!;
  2742. string maritalStatusText = (string)jsonData.GetType().GetProperty("婚姻状况")!.GetValue(jsonData)!;
  2743. int maritalStatus = maritalStatusText switch
  2744. {
  2745. "未设置" => 0,
  2746. "未婚" => 1,
  2747. "已婚" => 2,
  2748. "离异" => 3,
  2749. "丧偶" => 4,
  2750. _ => -1
  2751. };
  2752. string birthDay = (string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!;
  2753. DateTime.TryParse(birthDay, out DateTime birthDayDt);
  2754. string birthPlace = (string)jsonData.GetType().GetProperty("出生地点")!.GetValue(jsonData)!;
  2755. var birthDay1 = CommonFun.SplitProvinceCity(birthPlace);
  2756. string birthDay_mate = (string)jsonData.GetType().GetProperty("配偶出生日期")!.GetValue(jsonData)!;
  2757. DateTime.TryParse(birthDay_mate, out DateTime birthDayDt_mate);
  2758. string birthPlace_mate = (string)jsonData.GetType().GetProperty("配偶出生地")!.GetValue(jsonData)!;
  2759. var birthDay1_mate = CommonFun.SplitProvinceCity(birthPlace_mate);
  2760. var addressText = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  2761. var address = SplitAddressZip(addressText);
  2762. //美国驾照信息
  2763. string driveText = (string)jsonData.GetType().GetProperty("是否有美国驾照")!.GetValue(jsonData)!;
  2764. var driveInfo = LicenseParser(driveText);
  2765. //美国社会安全号或者纳税ID号
  2766. string ssnText = (string)jsonData.GetType().GetProperty("是否有美国社会安全号或者纳税ID号")!.GetValue(jsonData)!;
  2767. //单位信息
  2768. string clientName = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校")!.GetValue(jsonData)!;
  2769. string clientAddr = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校地址")!.GetValue(jsonData)!;//
  2770. var (hasSsnItin, number) = SsnItinParser(ssnText);
  2771. //婚姻相关
  2772. var WeddingText = (string)jsonData.GetType().GetProperty("若离婚,婚姻起止时间")!.GetValue(jsonData)!;
  2773. var (f, t) = WeddingParser(WeddingText);
  2774. //美国联系人电话和邮箱
  2775. var peText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  2776. var usa_phone = Regex.Match(peText ?? "", @"[\d-]+").Value; // 数字和中横线
  2777. var usa_email = Regex.Match(peText ?? "", @"[^@\s]+@[^@\s]+\.[^@\s]+").Value;
  2778. //赴美时间、停留时间处理
  2779. var usa_dateText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  2780. var (usa_d, usa_days) = TravelParser(usa_dateText);
  2781. //赴美同行人
  2782. string usaCmpNameText = (string)jsonData.GetType().GetProperty("赴美同行人")!.GetValue(jsonData)!;
  2783. string usaCmpName = string.Empty;
  2784. if (usaCmpNameText.Contains("是"))
  2785. {
  2786. var usaCmpNameTextSplit = usaCmpNameText.Replace(":", "-").Replace("", "-").Split("-");
  2787. if (usaCmpNameTextSplit.Length > 1)
  2788. {
  2789. usaCmpName = usaCmpNameTextSplit[1];
  2790. }
  2791. }
  2792. //是否丢失过护照
  2793. string loseCodeText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  2794. string loseCode = string.Empty;
  2795. if (loseCodeText.Contains("是"))
  2796. {
  2797. var loseCodeTextSplit = loseCodeText.Replace(":", "-").Replace("", "-").Split("-");
  2798. if (loseCodeTextSplit.Length > 1)
  2799. {
  2800. usaCmpName = loseCodeTextSplit[1];
  2801. }
  2802. }
  2803. //是否获得过美国签证
  2804. string usaVisaText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  2805. string usaVisaDateText = (string)jsonData.GetType().GetProperty("获得日期")!.GetValue(jsonData)!;
  2806. //DateTime usaVisaDate;
  2807. if (!string.IsNullOrEmpty(usaVisaDateText))
  2808. {
  2809. if (DateTime.TryParse(usaVisaDateText, out DateTime usaVisaDate))
  2810. {
  2811. visaDetails.ClientInfo.GetUSAVisaDate = usaVisaDate;
  2812. }
  2813. }
  2814. string usaFingerText = (string)jsonData.GetType().GetProperty("是否留过十指指纹")!.GetValue(jsonData)!;
  2815. int usaFinger = 0;
  2816. if (usaFingerText.Contains('是')) usaFinger = 1;
  2817. string usaLoseText = (string)jsonData.GetType().GetProperty("签证是否曾遗失")!.GetValue(jsonData)!;
  2818. int usaLose = 0;
  2819. if (usaLoseText.Contains("是")) usaLose = 1;
  2820. //是否曾抵达过美国
  2821. string usaHadArrival‌Text = (string)jsonData.GetType().GetProperty("是否曾抵达过美国")!.GetValue(jsonData)!;
  2822. var (usaHadArrivalf, usaHadArrivalD, usaHadArrivalDays) = TravelHadFlagParser(usaHadArrival‌Text);
  2823. //是否有被美国拒发签证的经历
  2824. string usaRejecteVisaTest = (string)jsonData.GetType().GetProperty("是否有被美国拒发签证的经历")!.GetValue(jsonData)!;
  2825. var (denied, rejectedDate, rejectedPlace, rejectedType) = VisaDenialParser(usaRejecteVisaTest);
  2826. if (denied)
  2827. {
  2828. visaDetails.ClientInfo.RejectedDate = rejectedDate;
  2829. visaDetails.ClientInfo.RejectedPlace = rejectedPlace;
  2830. visaDetails.ClientInfo.RejectedVisa = rejectedType;
  2831. }
  2832. //是否在申请或曾经申请过美国移民签证
  2833. string usaImmVisaText‌ = (string)jsonData.GetType().GetProperty("是否在申请或曾经申请过美国移民签证")!.GetValue(jsonData)!;
  2834. var (immDenied, immDate, immPlace, immType) = VisaDenialParser(usaImmVisaText‌);
  2835. if (immDenied)
  2836. {
  2837. visaDetails.ClientInfo.USAImmVisa‌Date = immDate;
  2838. visaDetails.ClientInfo.USAImmVisa‌Place = immPlace;
  2839. visaDetails.ClientInfo.USAImmVisa‌ = immType;
  2840. }
  2841. //在美直系
  2842. string usaImmedText‌ = (string)jsonData.GetType().GetProperty("是否有直系亲属在美国")!.GetValue(jsonData)!;
  2843. var (immedDenied, immedName, immedRel, immedStat) = FourFieldParser(usaImmedText‌);
  2844. if (immedDenied)
  2845. {
  2846. visaDetails.ClientInfo.USAImmedFamName = immedName;
  2847. visaDetails.ClientInfo.USAImmedFamRel = immedRel;
  2848. visaDetails.ClientInfo.USAImmedFamStat = immedStat;
  2849. }
  2850. //在美旁系
  2851. string usaUncleText‌ = (string)jsonData.GetType().GetProperty("是否有旁系亲属在美国")!.GetValue(jsonData)!;
  2852. var (uncleDenied, uncleName, uncleRel, uncleStat) = FourFieldParser(usaUncleText‌);
  2853. if (immedDenied)
  2854. {
  2855. visaDetails.ClientInfo.USAUncleFamName = uncleName;
  2856. visaDetails.ClientInfo.USAUncleFamRel = uncleName;
  2857. visaDetails.ClientInfo.USAUncleFamStat = uncleStat;
  2858. }
  2859. //服役时间 MilitaryParser
  2860. string militaryText‌ = (string)jsonData.GetType().GetProperty("是否曾参过军")!.GetValue(jsonData)!;
  2861. var (militaryH, militaryB, militaryR, militaryS, (militaryStart, militaryEnd)) = MilitaryParser(militaryText‌);
  2862. var militarys = new List<MilitaryInfo>();
  2863. if (militaryH)
  2864. {
  2865. militarys.Add(new()
  2866. {
  2867. MilBranch = militaryB,
  2868. MilRank = militaryR,
  2869. MilSkill = militaryS,
  2870. ServeTimeBegin = militaryStart,
  2871. ServeTimeEnd = militaryEnd,
  2872. });
  2873. }
  2874. //申请人父母信息 ParentParser
  2875. string fthMthText‌ = (string)jsonData.GetType().GetProperty("申请人父母信息")!.GetValue(jsonData)!;
  2876. if (!string.IsNullOrEmpty(fthMthText‌))
  2877. {
  2878. var (fName, fDob, mName, mDob) = ParentParser(fthMthText‌);
  2879. visaDetails.ClientInfo.FthName = fName;
  2880. visaDetails.ClientInfo.FthBirth = fDob;
  2881. visaDetails.ClientInfo.MthName = mName;
  2882. visaDetails.ClientInfo.MthBirth = mDob;
  2883. }
  2884. visaDetails.ClientInfo = new()
  2885. {
  2886. LastName = name.GetLastName(),
  2887. FirstName = name.GetFirstName(),
  2888. Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1,
  2889. OldName = (string)jsonData.GetType().GetProperty("曾用名")!.GetValue(jsonData)!,
  2890. BirthDay = birthDayDt,
  2891. BirthProvince = birthDay1.province,
  2892. BirthCity = birthDay1.city,
  2893. Address = address.address,
  2894. PostCodes = address.zipCode,
  2895. Marriage = maritalStatus,
  2896. MateName = (string)jsonData.GetType().GetProperty("配偶姓名")!.GetValue(jsonData)!,
  2897. MateBirthDay = birthDayDt_mate,
  2898. MateBirthCountry = birthDay1_mate.province,
  2899. MateBirthCity = birthDay1_mate.city,
  2900. USA_DLNo = driveInfo.number,
  2901. USA_DLPlace = driveInfo.place,
  2902. USA_SSNOrITIN = number,
  2903. Resident = CleanPrefix((string)jsonData.GetType().GetProperty("是否是其他国家的永久居民")!.GetValue(jsonData)!),
  2904. HasSocialAcc‌ = CleanPrefix((string)jsonData.GetType().GetProperty("近五年内是否使用过任何社交账号")!.GetValue(jsonData)!),
  2905. WeddingDate = f,
  2906. DivorceDate = t,
  2907. DivorceRsn = (string)jsonData.GetType().GetProperty("离婚原因")!.GetValue(jsonData)!,
  2908. Job = (string)jsonData.GetType().GetProperty("职务")!.GetValue(jsonData)!,
  2909. Wage = (string)jsonData.GetType().GetProperty("月薪")!.GetValue(jsonData)!,
  2910. WorkState = (string)jsonData.GetType().GetProperty("工作职责")!.GetValue(jsonData)!,
  2911. WorkDate = (string)jsonData.GetType().GetProperty("入职/入学时间(详细到月)")!.GetValue(jsonData)!,
  2912. USAAddress = (string)jsonData.GetType().GetProperty("请提供美国详细住址")!.GetValue(jsonData)!,
  2913. USAPurpose = (string)jsonData.GetType().GetProperty("赴美目的")!.GetValue(jsonData)!,
  2914. CostBearers = (string)jsonData.GetType().GetProperty("费用谁付")!.GetValue(jsonData)!,
  2915. USAContact = (string)jsonData.GetType().GetProperty("美国联系人或组织")!.GetValue(jsonData)!,
  2916. USAContactTel = usa_phone,
  2917. USAContactEmail = usa_email,
  2918. USADate = usa_d,
  2919. USADays = usa_days,
  2920. USAArrivalCity‌ = (string)jsonData.GetType().GetProperty("赴美的到达城市")!.GetValue(jsonData)!,
  2921. USADepartCity‌ = (string)jsonData.GetType().GetProperty("赴美的离开城市")!.GetValue(jsonData)!,
  2922. USAVisitSites‌ = (string)jsonData.GetType().GetProperty("计划在美国访问的景点")!.GetValue(jsonData)!,
  2923. USACmpName = usaCmpName,
  2924. USACmpRelation = (string)jsonData.GetType().GetProperty("同行人关系")!.GetValue(jsonData)!,
  2925. Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!,
  2926. ClientPhone = (string)jsonData.GetType().GetProperty("单位电话")!.GetValue(jsonData)!,
  2927. Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!,
  2928. Cntry5Y‌ = (string)jsonData.GetType().GetProperty("过去5年内到过的国家")!.GetValue(jsonData)!,
  2929. LangSkill‌ = (string)jsonData.GetType().GetProperty("面签时能流利交流的语言")!.GetValue(jsonData)!,
  2930. LoseCode = loseCode,
  2931. DenyNationRsn = (string)jsonData.GetType().GetProperty("曾被哪些国家拒签/拒签原因")!.GetValue(jsonData)!,
  2932. USAVisaCode = (string)jsonData.GetType().GetProperty("签证号码")!.GetValue(jsonData)!,
  2933. USAVisaCate = (string)jsonData.GetType().GetProperty("获签类型")!.GetValue(jsonData)!,
  2934. //GetUSAVisaDate = usaVisaDate,
  2935. USAFinger = usaFinger,
  2936. IsLose = usaLose,
  2937. USAHadArrival = usaHadArrivalD,
  2938. USAHadDays = usaHadArrivalDays,
  2939. ArmyState = JsonConvert.SerializeObject(militarys)
  2940. };
  2941. visaDetails.ClientCerts = new() {
  2942. new(){ SdId = 74,CertNo = passportNo,IDCardAddress = passportPlace },
  2943. new(){ SdId = 73,CertNo = idNo},
  2944. };
  2945. visaDetails.ClientCompany = new() { CompanyFullName = clientName, Address = clientAddr };
  2946. break;
  2947. //中文个人简历模板
  2948. case 6:
  2949. _logger.LogInformation("【签证上传文件操作信息】【中文个人简历模板】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2950. visaDetails.ClientInfo.LastName = (string)jsonData.GetType().GetProperty("姓名(中英文拼音)")!.GetValue(jsonData)!;
  2951. visaDetails.ClientInfo.Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1;
  2952. DateTime.TryParse((string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!, out DateTime birthDay11);
  2953. visaDetails.ClientInfo.BirthDay = birthDay11;
  2954. visaDetails.ClientInfo.BirthProvince = (string)jsonData.GetType().GetProperty("出生地")!.GetValue(jsonData)!;
  2955. visaDetails.ClientInfo.Address = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  2956. visaDetails.ClientInfo.Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!;
  2957. visaDetails.ClientInfo.TableOpTel = (string)jsonData.GetType().GetProperty("工作电话")!.GetValue(jsonData)!;
  2958. visaDetails.ClientInfo.Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!;
  2959. visaDetails.ClientInfo.Email = (string)jsonData.GetType().GetProperty("电子邮件")!.GetValue(jsonData)!;
  2960. //学校信息
  2961. visaDetails.ClientSchools.Add(new()
  2962. {
  2963. School = (string)jsonData.GetType().GetProperty("教育学校名称")!.GetValue(jsonData)!,
  2964. Education = (string)jsonData.GetType().GetProperty("教育学位")!.GetValue(jsonData)!,
  2965. Subject = (string)jsonData.GetType().GetProperty("教育专业")!.GetValue(jsonData)!,
  2966. Remark = (string)jsonData.GetType().GetProperty("教育论文题目/研究重点(硕士、博士)")!.GetValue(jsonData)!,
  2967. });
  2968. //工作信息
  2969. visaDetails.ClientCompany = new()
  2970. {
  2971. CompanyFullName = (string)jsonData.GetType().GetProperty("工作经历雇主")!.GetValue(jsonData)!,
  2972. };
  2973. visaDetails.ClientInfo.Job = (string)jsonData.GetType().GetProperty("工作经历职位或头衔职责")!.GetValue(jsonData)!;
  2974. break;
  2975. default:
  2976. break;
  2977. }
  2978. //数据提交
  2979. #region 数据提交
  2980. _sqlSugar.BeginTran();
  2981. // 客户公司表
  2982. var compId = UpsertReturnId<Crm_CustomerCompany>(visaDetails.ClientCompany, o => o.CompanyFullName);
  2983. if (compId < 1)
  2984. {
  2985. _sqlSugar.RollbackTran();
  2986. return Ok(JsonView(false, "公司信息更新失败!"));
  2987. }
  2988. visaDetails.ClientInfo.CrmCompanyId = compId;
  2989. // 客户资料表
  2990. var clientId = UpsertReturnId<Crm_DeleClient>(visaDetails.ClientInfo, o => new { o.LastName, o.FirstName });
  2991. if (clientId < 1)
  2992. {
  2993. _sqlSugar.RollbackTran();
  2994. return Ok(JsonView(false, "客户信息更新失败!"));
  2995. }
  2996. for (int i = 0; i < visaDetails.ClientFamilys.Count(); i++)
  2997. {
  2998. visaDetails.ClientFamilys[i].DcId = clientId;
  2999. }
  3000. for (int i = 0; i < visaDetails.ClientCerts.Count(); i++)
  3001. {
  3002. visaDetails.ClientCerts[i].DcId = clientId;
  3003. }
  3004. for (int i = 0; i < visaDetails.ClientSchools.Count(); i++)
  3005. {
  3006. visaDetails.ClientSchools[i].DcId = clientId;
  3007. }
  3008. // 客户家庭表
  3009. foreach (var item in visaDetails.ClientFamilys)
  3010. {
  3011. var famId = UpsertReturnId<Crm_VisaCustomerFamily>(item, o => o.Name);
  3012. if (famId < 1)
  3013. {
  3014. _sqlSugar.RollbackTran();
  3015. return Ok(JsonView(false, "客户家庭信息更新失败!"));
  3016. }
  3017. }
  3018. // 客户证件表
  3019. foreach (var item in visaDetails.ClientCerts)
  3020. {
  3021. var certId = UpsertReturnId<Crm_CustomerCert>(item, o => o.CertNo);
  3022. if (certId < 1)
  3023. {
  3024. _sqlSugar.RollbackTran();
  3025. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3026. }
  3027. }
  3028. // 客户学历表
  3029. foreach (var item in visaDetails.ClientSchools)
  3030. {
  3031. var schoolId = UpsertReturnId<Crm_VisaCustomerSchool>(item, o => o.School);
  3032. if (schoolId < 1)
  3033. {
  3034. _sqlSugar.RollbackTran();
  3035. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3036. }
  3037. }
  3038. _sqlSugar.CommitTran();
  3039. #endregion
  3040. #endregion
  3041. return Ok(JsonView(true, jsonString));
  3042. }
  3043. #region 扩展处理
  3044. // 从 Expression<Func<T,object>> 里取出属性名
  3045. static string GetPropName<T>(Expression<Func<T, object>> expr)
  3046. {
  3047. if (expr.Body is UnaryExpression ue) expr = Expression.Lambda<Func<T, object>>(ue.Operand, expr.Parameters);
  3048. return ((MemberExpression)expr.Body).Member.Name;
  3049. }
  3050. /// <summary>
  3051. /// 5.1.4.193 可用:存在更新(非NULL非空串),不存在插入,返回主键ID
  3052. /// </summary>
  3053. public int UpsertReturnId<T>(T entity, Expression<Func<T, object>> whereExpr) where T : class, new()
  3054. {
  3055. // 1. 空字符串→NULL,让后续忽略
  3056. foreach (var pi in typeof(T).GetProperties())
  3057. if (pi.PropertyType == typeof(string) &&
  3058. pi.GetValue(entity) is string s &&
  3059. string.IsNullOrWhiteSpace(s))
  3060. pi.SetValue(entity, null);
  3061. // 2. 从表达式里拿属性名
  3062. string propName = GetPropName(whereExpr);
  3063. var propValue = typeof(T).GetProperty(propName)?.GetValue(entity);
  3064. // 3. 判断存在
  3065. bool exists = _sqlSugar.Queryable<T>().Where(propName, propValue).Any();
  3066. // 4. 执行 Upsert
  3067. if (exists)
  3068. {
  3069. _sqlSugar.Updateable(entity)
  3070. .WhereColumns(propName) // 指定条件列
  3071. .IgnoreColumns(ignoreAllNullColumns: true) // 忽略 NULL
  3072. .ExecuteCommand();
  3073. }
  3074. else
  3075. {
  3076. _sqlSugar.Insertable(entity).ExecuteReturnIdentity();
  3077. }
  3078. // 5. 返回主键值(自增/雪花已回填)
  3079. var idProp = typeof(T).GetProperties()
  3080. .First(p => p.GetCustomAttributes<SugarColumn>()
  3081. .Any(a => a.IsPrimaryKey));
  3082. return (int)idProp.GetValue(entity)!;
  3083. }
  3084. /// <summary>
  3085. /// 地址喊邮编 相关处理
  3086. /// </summary>
  3087. public static (string address, string zipCode) SplitAddressZip(string? s)
  3088. {
  3089. if (string.IsNullOrWhiteSpace(s))
  3090. return ("", "");
  3091. ReadOnlySpan<char> src = s.AsSpan();
  3092. int i = src.IndexOf("邮编".AsSpan());
  3093. if (i < 0) // 没有“邮编”字样
  3094. return (src.Trim().ToString(), "");
  3095. ReadOnlySpan<char> addr = src[..i].TrimEnd();
  3096. ReadOnlySpan<char> zip = src[(i + 3)..].Trim(); // 跳过“邮编:”
  3097. // 可能只有“邮编:”而没有数字
  3098. return (addr.IsEmpty ? "" : addr.ToString(),
  3099. zip.IsEmpty ? "" : zip.ToString());
  3100. }
  3101. /// <summary>
  3102. /// 驾照相 关处理
  3103. /// </summary>
  3104. /// <param name="raw"></param>
  3105. /// <returns></returns>
  3106. public static (bool hasLicense, string number, string place) LicenseParser(string? raw)
  3107. {
  3108. if (string.IsNullOrWhiteSpace(raw))
  3109. return (false, "", "");
  3110. // 1. 是否持有
  3111. bool has = raw.StartsWith("是", System.StringComparison.OrdinalIgnoreCase) ||
  3112. raw.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3113. // 2. 去掉前缀,按空格切
  3114. ReadOnlySpan<char> s = raw.AsSpan();
  3115. int colon = s.IndexOf(':');
  3116. ReadOnlySpan<char> after = colon < 0 ? s : s[(colon + 1)..];
  3117. after = after.Trim();
  3118. int space = after.IndexOf(' ');
  3119. ReadOnlySpan<char> num = space < 0 ? after : after[..space];
  3120. ReadOnlySpan<char> st = space < 0 ? ReadOnlySpan<char>.Empty : after[(space + 1)..];
  3121. return (has, num.ToString().Trim(), st.ToString().Trim());
  3122. }
  3123. /// <summary>
  3124. /// 美国社会安全号或者纳税ID号 相关处理
  3125. /// </summary>
  3126. /// <param name="raw"></param>
  3127. /// <returns></returns>
  3128. public static (bool hasSsnItin, string number) SsnItinParser(string? raw)
  3129. {
  3130. if (string.IsNullOrWhiteSpace(raw))
  3131. return (false, "");
  3132. ReadOnlySpan<char> s = raw.AsSpan();
  3133. // 1. 是否持有
  3134. bool has = s.StartsWith("是", System.StringComparison.Ordinal) ||
  3135. s.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3136. // 2. 取号码(去掉前缀和空格)
  3137. int colon = s.IndexOf(':');
  3138. ReadOnlySpan<char> num = colon < 0
  3139. ? ReadOnlySpan<char>.Empty
  3140. : s[(colon + 1)..].Trim();
  3141. return (has, num.ToString());
  3142. }
  3143. /// <summary>
  3144. /// 取消开始的“是:”或者“是”或者“ :”
  3145. /// </summary>
  3146. /// <param name="raw"></param>
  3147. /// <returns></returns>
  3148. public static string CleanPrefix(string? raw)
  3149. {
  3150. if (string.IsNullOrWhiteSpace(raw)) return "";
  3151. // 跳过第一个“是”或“Y”
  3152. ReadOnlySpan<char> s = raw.AsSpan();
  3153. int start = 0;
  3154. if (s.StartsWith("是") || s.StartsWith("Y", StringComparison.OrdinalIgnoreCase))
  3155. start = 1;
  3156. // 跳过连续 : 或空格
  3157. while (start < s.Length && (s[start] == ':' || s[start] == ' '))
  3158. start++;
  3159. return s[start..].Trim().ToString();
  3160. }
  3161. /// <summary>
  3162. /// 婚姻起止时间处理
  3163. /// </summary>
  3164. /// <param name="raw"></param>
  3165. /// <returns></returns>
  3166. public static (DateTime? fromDate, DateTime? toDate) WeddingParser(string? raw)
  3167. {
  3168. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3169. Regex _clean = new(@"[\s~至]+", RegexOptions.Compiled);
  3170. // 1. 把所有“空格~至”统一成 '-'
  3171. string normalized = _clean.Replace(raw, "-");
  3172. // 2. 切两段
  3173. string[] parts = normalized.Split('-', StringSplitOptions.RemoveEmptyEntries);
  3174. if (parts.Length != 2) return (null, null);
  3175. // 3. 解析
  3176. bool ff = DateTime.TryParse(parts[0].Trim(), out var from);
  3177. bool tf = DateTime.TryParse(parts[1].Trim(), out var to);
  3178. return (tf ? from : null, tf ? to : null);
  3179. }
  3180. /// <summary>
  3181. /// 出行日期和天数处理
  3182. /// </summary>
  3183. /// <param name="raw"></param>
  3184. /// <returns></returns>
  3185. public static (DateTime? travelDate, int? days) TravelParser(string? raw)
  3186. {
  3187. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3188. // 切成两段:第一段日期,第二段天数
  3189. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3190. string[] parts = sep.Split(raw.Trim());
  3191. if (parts.Length < 2) return (null, null);
  3192. bool okDate = DateTime.TryParse(parts[0], out DateTime date);
  3193. bool okDays = int.TryParse(parts[1], out int days) && days > 0;
  3194. return (okDate ? date : null, okDays ? days : null);
  3195. }
  3196. /// <summary>
  3197. /// 是否曾抵达过美国
  3198. /// </summary>
  3199. /// <param name="raw"></param>
  3200. /// <returns></returns>
  3201. public static (bool hasTravel, string date, string days) TravelHadFlagParser(string? raw)
  3202. {
  3203. if (string.IsNullOrWhiteSpace(raw)) return (false, string.Empty, string.Empty);
  3204. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3205. // 1. 是否持有
  3206. bool has = raw.AsSpan().TrimStart().StartsWith("是") ||
  3207. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3208. // 2. 用非数字分隔符切成三段:第一段空,第二段日期,第三段天数
  3209. string[] parts = sep.Split(raw.Trim());
  3210. if (parts.Length < 3) return (has, string.Empty, string.Empty);
  3211. return (has, parts[1], parts[2]);
  3212. }
  3213. /// <summary>
  3214. /// 是否有被美国拒发签证的经历
  3215. /// </summary>
  3216. /// <param name="raw"></param>
  3217. /// <returns></returns>
  3218. public static (bool wasDenied, DateTime? date, string place, string visaType) VisaDenialParser(string? raw)
  3219. {
  3220. if (string.IsNullOrWhiteSpace(raw)) return (false, null, "", "");
  3221. bool denied = raw.AsSpan().TrimStart().StartsWith("有") ||
  3222. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3223. var parts = Regex.Split(raw.Trim(), @"[^0-9A-Za-z-]+");
  3224. if (parts.Length < 4) return (denied, null, "", "");
  3225. DateTime.TryParse(parts[1], out var dt); // ← 这里改为 DateTime
  3226. return (denied, dt, parts[2], parts[3]);
  3227. }
  3228. /// <summary>
  3229. /// 在美直系、旁系 处理
  3230. /// </summary>
  3231. /// <param name="raw"></param>
  3232. /// <returns></returns>
  3233. public static (bool flag, string name, string rel, string stat) FourFieldParser(string? raw)
  3234. {
  3235. if (string.IsNullOrWhiteSpace(raw)) return (false, "", "", "");
  3236. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3237. if (parts.Length < 4) return (false, "", "", "");
  3238. bool flag = parts[0] is "有" or "是" or "Y" or "Yes";
  3239. string name = parts[1];
  3240. string rel = parts[2];
  3241. string stat = parts[3];
  3242. return (flag, name, rel, stat);
  3243. }
  3244. /// <summary>
  3245. /// 服役时间处理
  3246. /// </summary>
  3247. /// <param name="raw"></param>
  3248. /// <returns></returns>
  3249. public static (bool hasService, string branch, string rank, string specialty, (DateTime? start, DateTime? end) period) MilitaryParser(string? raw)
  3250. {
  3251. const string fmt = "yyyy年MM月dd日";
  3252. if (string.IsNullOrWhiteSpace(raw))
  3253. return (false, "", "", "", (null, null));
  3254. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3255. if (parts.Length < 5) return (false, "", "", "", (null, null));
  3256. bool has = parts[0] is "是" or "Y" or "Yes";
  3257. string branch = parts[1];
  3258. string rank = parts[2];
  3259. string specialty = parts[3];
  3260. // 拼回时间字符串
  3261. string periodRaw = string.Join(" ", parts[4..]);
  3262. var span = periodRaw.AsSpan();
  3263. int zhi = span.IndexOf("至");
  3264. if (zhi < 0) return (has, branch, rank, specialty, (null, null));
  3265. var startStr = span.Slice(0, zhi).Trim();
  3266. var endStr = span.Slice(zhi + 1).Trim();
  3267. bool okStart = DateTime.TryParseExact(startStr.ToString(), fmt, null, DateTimeStyles.None, out var start);
  3268. bool okEnd = DateTime.TryParseExact(endStr.ToString(), fmt, null, DateTimeStyles.None, out var end);
  3269. return (has, branch, rank, specialty, (okStart ? start : null, okEnd ? end : null));
  3270. }
  3271. /// <summary>
  3272. /// 申请人父母信息
  3273. /// </summary>
  3274. /// <param name="raw"></param>
  3275. /// <returns></returns>
  3276. public static (string fatherName, DateTime? fatherDob, string motherName, DateTime? motherDob) ParentParser(string? raw)
  3277. {
  3278. const string fmt = "yyyy年MM月dd日";
  3279. if (string.IsNullOrWhiteSpace(raw)) return ("", null, "", null);
  3280. // 按空格切,去掉空元素
  3281. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3282. if (parts.Length < 4) return ("", null, "", null);
  3283. // 父亲
  3284. string fName = parts[0];
  3285. DateTime.TryParseExact(parts[1], fmt, null, DateTimeStyles.None, out var fDob);
  3286. // 母亲
  3287. string mName = parts[2];
  3288. DateTime.TryParseExact(parts[3], fmt, null, DateTimeStyles.None, out var mDob);
  3289. return (fName, fDob, mName, mDob);
  3290. }
  3291. public class VisaDetailsView
  3292. {
  3293. /// <summary>
  3294. /// 客户资料表
  3295. /// </summary>
  3296. public Crm_DeleClient ClientInfo { get; set; }
  3297. /// <summary>
  3298. /// 客户家庭表
  3299. /// </summary>
  3300. public List<Crm_VisaCustomerFamily> ClientFamilys { get; set; }
  3301. /// <summary>
  3302. /// 客户公司表
  3303. /// </summary>
  3304. public Crm_CustomerCompany ClientCompany { get; set; }
  3305. /// <summary>
  3306. /// 客户证件表
  3307. /// </summary>
  3308. public List<Crm_CustomerCert> ClientCerts { get; set; }
  3309. /// <summary>
  3310. /// 客户学历表
  3311. /// </summary>
  3312. public List<Crm_VisaCustomerSchool> ClientSchools { get; set; }
  3313. }
  3314. private int GetSuccessCount(List<FileUploadResult> results)
  3315. {
  3316. var count = 0;
  3317. foreach (var result in results)
  3318. {
  3319. if (result.Success) count++;
  3320. }
  3321. return count;
  3322. }
  3323. #endregion
  3324. /// <summary>
  3325. /// 根据团组Id获取签证客户信息List
  3326. /// </summary>
  3327. /// <param name="dto">请求dto</param>
  3328. /// <returns></returns>
  3329. [HttpPost]
  3330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3331. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  3332. {
  3333. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  3334. if (groupData.Code != 0)
  3335. {
  3336. return Ok(JsonView(false, groupData.Msg));
  3337. }
  3338. return Ok(JsonView(groupData.Data));
  3339. }
  3340. /// <summary>
  3341. /// IOS获取团组签证拍照上传进度01(团组列表)
  3342. /// </summary>
  3343. /// <param name="dto">请求dto</param>
  3344. /// <returns></returns>
  3345. [HttpPost]
  3346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3347. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  3348. {
  3349. if (dto == null)
  3350. {
  3351. return Ok(JsonView(false, "参数为空"));
  3352. }
  3353. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  3354. return Ok(JsonView(visaList));
  3355. }
  3356. /// <summary>
  3357. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  3358. /// </summary>
  3359. /// <returns></returns>
  3360. [HttpPost]
  3361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3362. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  3363. {
  3364. if (dto == null)
  3365. {
  3366. return Ok(JsonView(false, "请求错误:"));
  3367. }
  3368. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  3369. return Ok(JsonView(list));
  3370. }
  3371. /// <summary>
  3372. /// IOS获取团组签证拍照上传进度03(相册)
  3373. /// </summary>
  3374. /// <returns></returns>
  3375. [HttpPost]
  3376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3377. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  3378. {
  3379. if (dto == null)
  3380. {
  3381. return Ok(JsonView(false, "请求错误:"));
  3382. }
  3383. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  3384. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  3385. list.ForEach(s => s.url = url);
  3386. return Ok(JsonView(list));
  3387. }
  3388. /// <summary>
  3389. /// IOS获取团组签证拍照上传进度04(图片上传)
  3390. /// </summary>
  3391. /// <param name="dto"></param>
  3392. /// <returns></returns>
  3393. [HttpPost]
  3394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3395. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  3396. {
  3397. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  3398. //if (!string.IsNullOrEmpty(result))
  3399. //{
  3400. //}
  3401. //else {
  3402. // return Ok(JsonView(false, "上传失败"));
  3403. //}
  3404. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  3405. int sucNum = 0;
  3406. try
  3407. {
  3408. foreach (var item in dto.base64DataList)
  3409. {
  3410. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  3411. string result = DecodeBase64ToImage(item, imageName);
  3412. if (!string.IsNullOrEmpty(result))
  3413. {
  3414. var pic = new Grp_VisaProgressCustomerPicture
  3415. {
  3416. CreateUserId = dto.CreateUserId,
  3417. PicName = imageName,
  3418. PicPath = result,
  3419. VisaProgressCustomerId = dto.visaProgressCustomerId
  3420. };
  3421. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  3422. if (insertResult > 0)
  3423. {
  3424. sucNum++;
  3425. }
  3426. }
  3427. }
  3428. }
  3429. catch (Exception ex)
  3430. {
  3431. return Ok(JsonView(false, ex.Message));
  3432. }
  3433. string msg = string.Format(@"成功上传{0}张", sucNum);
  3434. return Ok(JsonView(true, msg));
  3435. }
  3436. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  3437. {
  3438. string filename = "";//声明一个string类型的相对路径
  3439. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  3440. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  3441. try//会有异常抛出,try,catch一下
  3442. {
  3443. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  3444. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  3445. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  3446. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  3447. //文件名称
  3448. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  3449. //上传的文件的路径
  3450. string filePath = "";
  3451. if (!Directory.Exists(fileDir))
  3452. {
  3453. Directory.CreateDirectory(fileDir);
  3454. }
  3455. //上传的文件的路径
  3456. filePath = fileDir + filename;
  3457. //string url = HttpRuntime.AppDomainAppPath.ToString();
  3458. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  3459. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  3460. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  3461. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  3462. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  3463. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  3464. ms.Close();//关闭当前流,并释放所有与之关联的资源
  3465. bitmap.Dispose();
  3466. }
  3467. catch (Exception e)
  3468. {
  3469. string massage = e.Message;
  3470. Logs("IOS图片上传Error:" + massage);
  3471. //filename = e.Message;
  3472. }
  3473. return filename;//返回相对路径
  3474. }
  3475. /// <summary>
  3476. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  3477. /// </summary>
  3478. /// <param name="dto"></param>
  3479. /// <returns></returns>
  3480. [HttpPost]
  3481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3482. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  3483. {
  3484. if (dto == null)
  3485. {
  3486. return Ok(JsonView(false, "请求错误:"));
  3487. }
  3488. string msg = "参数错误";
  3489. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  3490. {
  3491. try
  3492. {
  3493. //_delegationVisaRep.BeginTran();
  3494. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  3495. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  3496. .Where(s => s.Id == dto.visaProgressCustomerId)
  3497. .ExecuteCommandAsync();
  3498. if (updCount > 0 && dto.publishCode == 1)
  3499. {
  3500. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  3501. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  3502. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  3503. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  3504. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  3505. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  3506. if (groupData == null)
  3507. {
  3508. _delegationVisaRep.RollbackTran();
  3509. }
  3510. string title = string.Format(@"[签证进度更新]");
  3511. string content = string.Format(@"测试文本");
  3512. bool rst = await _message.AddMsg(new MessageDto()
  3513. {
  3514. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  3515. IssuerId = dto.publisher,
  3516. Title = title,
  3517. Content = content,
  3518. ReleaseTime = DateTime.Now,
  3519. UIdList = new List<int> {
  3520. 234
  3521. }
  3522. });
  3523. if (rst)
  3524. {
  3525. return Ok(JsonView(true, "发送通知成功"));
  3526. }
  3527. }
  3528. //_delegationVisaRep.CommitTran();
  3529. }
  3530. catch (Exception)
  3531. {
  3532. //_delegationVisaRep.RollbackTran();
  3533. }
  3534. }
  3535. return Ok(JsonView(true, msg));
  3536. }
  3537. #endregion
  3538. #endregion
  3539. #region 团组任务分配
  3540. /// <summary>
  3541. /// 团组任务分配初始化
  3542. /// </summary>
  3543. /// <returns></returns>
  3544. [HttpPost]
  3545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3546. public async Task<IActionResult> GetTaskAssignmen()
  3547. {
  3548. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  3549. if (groupData.Code != 0)
  3550. {
  3551. return Ok(JsonView(false, groupData.Msg));
  3552. }
  3553. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3554. }
  3555. /// <summary>
  3556. /// 团组任务分配查询
  3557. /// </summary>
  3558. /// <param name="dto"></param>
  3559. /// <returns></returns>
  3560. [HttpPost]
  3561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3562. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  3563. {
  3564. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  3565. if (groupData.Code != 0)
  3566. {
  3567. return Ok(JsonView(false, groupData.Msg));
  3568. }
  3569. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3570. }
  3571. /// <summary>
  3572. /// 团组任务分配操作
  3573. /// </summary>
  3574. /// <param name="dto"></param>
  3575. /// <returns></returns>
  3576. [HttpPost]
  3577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3578. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  3579. {
  3580. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  3581. if (groupData.Code != 0)
  3582. {
  3583. return Ok(JsonView(false, groupData.Msg));
  3584. }
  3585. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3586. }
  3587. /// <summary>
  3588. /// 团组任务分配
  3589. /// 批量分配
  3590. /// 查询团组
  3591. /// </summary>
  3592. /// <param name="dto"></param>
  3593. /// <returns></returns>
  3594. [HttpPost]
  3595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3596. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  3597. {
  3598. //参数验证
  3599. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  3600. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  3601. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  3602. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  3603. }
  3604. /// <summary>
  3605. /// 团组任务分配
  3606. /// 批量分配
  3607. /// </summary>
  3608. /// <param name="dto"></param>
  3609. /// <returns></returns>
  3610. [HttpPost]
  3611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3612. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  3613. {
  3614. //参数验证
  3615. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  3616. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  3617. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  3618. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  3619. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  3620. }
  3621. #endregion
  3622. #region 团组费用审核
  3623. /// <summary>
  3624. /// 费用审核
  3625. /// 团组列表 Page
  3626. /// </summary>
  3627. /// <param name="_dto">团组列表请求dto</param>
  3628. /// <returns></returns>
  3629. [HttpPost]
  3630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3631. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  3632. {
  3633. #region 参数验证
  3634. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3635. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3636. #region 页面操作权限验证
  3637. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3638. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3639. #endregion
  3640. #endregion
  3641. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  3642. {
  3643. string sqlWhere = string.Empty;
  3644. if (_dto.IsSure == 0) //未完成
  3645. {
  3646. sqlWhere += string.Format(@" And IsSure = 0");
  3647. }
  3648. else if (_dto.IsSure == 1) //已完成
  3649. {
  3650. sqlWhere += string.Format(@" And IsSure = 1");
  3651. }
  3652. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  3653. {
  3654. string tj = _dto.SearchCriteria;
  3655. 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}%')",
  3656. tj, tj, tj, tj, tj);
  3657. }
  3658. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  3659. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  3660. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  3661. From (
  3662. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  3663. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  3664. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  3665. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  3666. From Grp_DelegationInfo gdi
  3667. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  3668. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  3669. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  3670. Where gdi.IsDel = 0 {0}
  3671. ) temp ", sqlWhere);
  3672. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  3673. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  3674. var _view = new
  3675. {
  3676. PageFuncAuth = pageFunAuthView,
  3677. Data = _DelegationList
  3678. };
  3679. return Ok(JsonView(true, "查询成功!", _view, total));
  3680. }
  3681. else
  3682. {
  3683. return Ok(JsonView(false, "查询失败"));
  3684. }
  3685. }
  3686. /// <summary>
  3687. /// 获取团组费用审核
  3688. /// </summary>
  3689. /// <param name="_dto"></param>
  3690. /// <returns></returns>
  3691. [HttpPost]
  3692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3693. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  3694. {
  3695. try
  3696. {
  3697. #region 参数验证
  3698. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3699. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3700. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  3701. #region 页面操作权限验证
  3702. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3703. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3704. #endregion
  3705. #endregion
  3706. var _view = new Grp_CreditCardPaymentView();
  3707. var clientNameList = GetSimplClientList(_dto.DiId);
  3708. #region 费用清单
  3709. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  3710. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  3711. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  3712. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  3713. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  3714. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  3715. /*
  3716. * 76://酒店预订
  3717. */
  3718. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3719. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3720. /*
  3721. * 79://车/导游地接
  3722. */
  3723. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3724. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3725. /*
  3726. * 80: //签证
  3727. */
  3728. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3729. /*
  3730. *81: //邀请/公务活动
  3731. */
  3732. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3733. /*
  3734. * 82: //团组客户保险
  3735. */
  3736. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3737. /*
  3738. * Lable = 85 机票预订
  3739. */
  3740. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3741. /*
  3742. * 85 机票预定
  3743. */
  3744. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3745. /*
  3746. * 98 其他款项
  3747. */
  3748. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3749. /*
  3750. * 285:收款退还
  3751. */
  3752. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3753. /*
  3754. * 1015: //超支费用
  3755. */
  3756. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3757. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  3758. /*
  3759. * 币种信息
  3760. */
  3761. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  3762. /*
  3763. * 车/导游地接 费用类型
  3764. */
  3765. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  3766. /*
  3767. * 车/导游地接 费用类型
  3768. */
  3769. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  3770. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  3771. /*
  3772. * 用户信息
  3773. */
  3774. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  3775. /*
  3776. * 费用模块
  3777. */
  3778. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  3779. string priceModule = string.Empty;
  3780. if (sdPriceName != null)
  3781. {
  3782. priceModule = sdPriceName.Name;
  3783. }
  3784. /*
  3785. * 成本信息
  3786. */
  3787. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  3788. decimal _groupRate = 0.0000M;
  3789. string _groupCurrencyCode = "-";
  3790. if (groupCost != null)
  3791. {
  3792. _groupRate = groupCost.Rate;
  3793. if (int.TryParse(groupCost.Currency, out int _currency))
  3794. {
  3795. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  3796. }
  3797. else _groupCurrencyCode = groupCost.Currency;
  3798. }
  3799. string costContentSql = $"Select * From Grp_GroupCost";
  3800. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  3801. //处理日期为空的天数
  3802. for (int i = 0; i < groupCostDetails.Count; i++)
  3803. if (i != 0)
  3804. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  3805. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  3806. /*
  3807. * 处理详情数据
  3808. */
  3809. foreach (var entity in entityList)
  3810. {
  3811. var _detail = new Grp_CreditCardPaymentDetailView
  3812. {
  3813. Id = entity.Id,
  3814. PriceName = priceModule,
  3815. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  3816. };
  3817. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3818. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  3819. //处理金额
  3820. if (entity.CTable == 1015)
  3821. {
  3822. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  3823. if (czInfo != null)
  3824. {
  3825. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  3826. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  3827. }
  3828. }
  3829. /*
  3830. * 应付款金额
  3831. */
  3832. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  3833. string PaymentCurrency_WaitPay = "Unknown";
  3834. string hotelCurrncyCode = "Unknown";
  3835. string hotelCurrncyName = "Unknown";
  3836. if (sdPaymentCurrency_WaitPay != null)
  3837. {
  3838. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  3839. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  3840. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  3841. if (hotelCurrncyCode.Equals("CNY"))
  3842. {
  3843. entity.DayRate = 1.0000M;
  3844. }
  3845. }
  3846. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3847. /*
  3848. * 此次付款金额
  3849. */
  3850. decimal CurrPayStr = 0.00M,
  3851. OriginalCurrPay = 0.00M;
  3852. if (entity.PayPercentage == 0)
  3853. {
  3854. if (entity.PayThenMoney != 0)
  3855. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  3856. }
  3857. else
  3858. {
  3859. if (entity.PayMoney != 0)
  3860. {
  3861. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  3862. }
  3863. }
  3864. //if (_dto.Label == 79)
  3865. //{
  3866. // string original = string.Empty;
  3867. // if (hotelCurrncyCode.Equals("CNY"))
  3868. // {
  3869. // OriginalCurrPay = CurrPayStr;
  3870. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3871. // }
  3872. // else
  3873. // {
  3874. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3875. // //760 EUR(7600.00 CNY)
  3876. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  3877. // }
  3878. //}
  3879. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3880. string original = string.Empty;
  3881. if (hotelCurrncyCode.Equals("CNY"))
  3882. {
  3883. OriginalCurrPay = CurrPayStr;
  3884. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3885. }
  3886. else
  3887. {
  3888. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3889. //760 EUR(7600.00 CNY)
  3890. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  3891. }
  3892. /*
  3893. * 剩余尾款
  3894. */
  3895. decimal BalanceStr = 0;
  3896. if (CurrPayStr != 0)
  3897. {
  3898. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3899. BalanceStr = 0;
  3900. else
  3901. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3902. }
  3903. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3904. /*
  3905. * Bus名称
  3906. */
  3907. _detail.BusName = "待增加";
  3908. /*
  3909. *费用所属
  3910. */
  3911. switch (entity.CTable)
  3912. {
  3913. case 76://酒店预订
  3914. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3915. if (hotelReservations != null)
  3916. {
  3917. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3918. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3919. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3920. string roomFeeStr = "", roomFeestr1 = "";
  3921. //是否比较房型价格
  3922. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3923. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3924. roomFeeStr += $"<br/>";
  3925. var roomTotal = 0.00M;
  3926. if (hotelReservations.SingleRoomPrice > 0)
  3927. {
  3928. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3929. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3930. //__isSingle = true;
  3931. roomTotal += fee;
  3932. }
  3933. if (hotelReservations.DoubleRoomPrice > 0)
  3934. {
  3935. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3936. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3937. // __isDouble = true;
  3938. roomTotal += fee;
  3939. }
  3940. if (hotelReservations.SuiteRoomPrice > 0)
  3941. {
  3942. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3943. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3944. //__isSuite = true;
  3945. roomTotal += fee;
  3946. }
  3947. if (hotelReservations.OtherRoomPrice > 0)
  3948. {
  3949. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3950. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3951. //__isOther = true;
  3952. roomTotal += fee;
  3953. }
  3954. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3955. else roomFeeStr += " 0.00 * 0";
  3956. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3957. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3958. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3959. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3960. /*
  3961. * 费用类型
  3962. * 1:房费
  3963. * 2:早餐
  3964. * 3:地税
  3965. * 4:城市税
  3966. * </summary>
  3967. */
  3968. //地税
  3969. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3970. if (governmentRentData != null)
  3971. {
  3972. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3973. governmentRentFee = governmentRentData.Price;
  3974. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3975. if (governmentRentCurrData != null)
  3976. {
  3977. governmentRentCode = governmentRentCurrData.Name;
  3978. governmentRentName = $"({governmentRentCurrData.Remark})";
  3979. }
  3980. }
  3981. //城市税
  3982. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3983. if (cityTaxData != null)
  3984. {
  3985. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3986. cityTaxFee = cityTaxData.Price;
  3987. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3988. if (cityTaxCurrData != null)
  3989. {
  3990. cityTaxCode = cityTaxCurrData.Name;
  3991. cityTaxName = $"({cityTaxCurrData.Remark})";
  3992. }
  3993. }
  3994. //酒店早餐
  3995. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3996. if (breakfastData != null)
  3997. {
  3998. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3999. breakfastFee = breakfastData.Price;
  4000. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  4001. if (breakfastCurrData != null)
  4002. {
  4003. breakfastCode = breakfastCurrData.Name;
  4004. breakfastName = $"({breakfastCurrData.Remark})";
  4005. }
  4006. }
  4007. //房间费用
  4008. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  4009. if (roomData != null)
  4010. {
  4011. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  4012. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  4013. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  4014. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  4015. roomFee = roomData.Price;
  4016. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  4017. if (roomCurrData != null)
  4018. {
  4019. roomCode = roomCurrData.Name;
  4020. roomName = $"({roomCurrData.Remark})";
  4021. }
  4022. }
  4023. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  4024. string hotelCostStr = "";
  4025. decimal hotelCsotTotal = 0.00M;
  4026. if (groupCost != null)
  4027. {
  4028. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  4029. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  4030. }
  4031. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  4032. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  4033. string hotelCost_day = "";
  4034. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  4035. foreach (var item in hotelCostDetails1)
  4036. {
  4037. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  4038. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  4039. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  4040. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  4041. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  4042. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  4043. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  4044. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  4045. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  4046. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  4047. hotelCost_day += @$"<br/>";
  4048. }
  4049. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  4050. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  4051. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  4052. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  4053. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  4054. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  4055. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  4056. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  4057. $"房间说明: {hotelReservations.Remark} <br/>" +
  4058. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  4059. $"{hotelBreakfastStr}" +
  4060. $"{hotelGovernmentRentStr}" +
  4061. $"{hotelCityTaxStr}";
  4062. _detail.PriceNameContent = hotelReservations.HotelName;
  4063. }
  4064. break;
  4065. case 79://车/导游地接
  4066. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  4067. if (touristGuideGroundReservations != null)
  4068. {
  4069. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  4070. {
  4071. _detail.BusName = touristGuideGroundReservations.BusName;
  4072. }
  4073. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  4074. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  4075. //if (isInt)
  4076. //{
  4077. // var cityInfo = cityData.Find(it => it.Id == cityId);
  4078. // if (cityInfo != null)
  4079. // {
  4080. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  4081. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  4082. // if (carFeeItem != null)
  4083. // {
  4084. // nameContent += $@"({carFeeItem.Name})";
  4085. // }
  4086. // _detail.PriceNameContent = nameContent;
  4087. // }
  4088. //}
  4089. //else
  4090. //{
  4091. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  4092. //}
  4093. var touristGuideGroundReservationsContents =
  4094. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  4095. var opContent_sb = new StringBuilder();
  4096. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  4097. opContent_sb.AppendLine(contetTitle);
  4098. foreach (var item in touristGuideGroundReservationsContents)
  4099. {
  4100. string typeName = "Unknown";
  4101. string carCurrencyCode = "Unknown";
  4102. string carCurrencyName = "Unknown";
  4103. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  4104. if (carTypeData != null) typeName = carTypeData.Name;
  4105. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  4106. if (currencyData != null)
  4107. {
  4108. carCurrencyCode = currencyData.Name;
  4109. carCurrencyName = currencyData.Remark;
  4110. }
  4111. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  4112. bool IsCurrencyAgreement = false;
  4113. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  4114. string opCostStr = string.Empty;
  4115. decimal opCostTypePrice = 0.00M;
  4116. #region 处理成本各项费用
  4117. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  4118. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  4119. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  4120. costOPFeeCNY = 0.00M, //团组成本 op费用
  4121. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  4122. if (opCost.Count > 0)
  4123. {
  4124. switch (item.SId)
  4125. {
  4126. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  4127. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  4128. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  4129. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  4130. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  4131. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  4132. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  4133. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  4134. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  4135. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  4136. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  4137. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  4138. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  4139. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  4140. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  4141. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  4142. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  4143. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  4144. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  4145. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  4146. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  4147. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  4148. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  4149. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  4150. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  4151. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  4152. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  4153. }
  4154. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  4155. costOPFeeCNY = opCostTypePrice * _groupRate;
  4156. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  4157. }
  4158. #endregion
  4159. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  4160. aduitOPFeeCNY = item.Price * entity.DayRate;
  4161. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  4162. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  4163. $"{opTypeStr} {opCostStr}<br/>" +
  4164. $"明细:{item.PriceContent ?? "-"}<br/>" +
  4165. $"备注:{item.Remark ?? "-"}<br/><br/>";
  4166. if (entity.IsAuditGM != 3) //状态 != 自动审核
  4167. {
  4168. if (IsCurrencyAgreement)
  4169. {
  4170. if (item.Price > opCostTypePrice)
  4171. {
  4172. opContent_sb.Append("<span style='color:red;'>");
  4173. opContent_sb.Append(opContent);
  4174. opContent_sb.Append("</span>");
  4175. opContent_sb.AppendLine();
  4176. }
  4177. else
  4178. {
  4179. opContent_sb.Append(opContent);
  4180. opContent_sb.AppendLine();
  4181. }
  4182. }
  4183. else
  4184. {
  4185. //验证是否超成本 按付款比例计算
  4186. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  4187. {
  4188. opContent_sb.Append("<span style='color:red;'>");
  4189. opContent_sb.Append(opContent);
  4190. opContent_sb.Append("</span>");
  4191. opContent_sb.AppendLine();
  4192. }
  4193. else
  4194. {
  4195. opContent_sb.Append(opContent);
  4196. opContent_sb.AppendLine();
  4197. }
  4198. }
  4199. }
  4200. else
  4201. {
  4202. opContent_sb.Append(opContent);
  4203. opContent_sb.AppendLine();
  4204. }
  4205. }
  4206. _detail.PriceMsgContent = opContent_sb.ToString();
  4207. }
  4208. break;
  4209. case 80: //签证
  4210. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  4211. if (visaInfo != null)
  4212. {
  4213. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  4214. _detail.PriceNameContent = visaInfo.VisaDescription;
  4215. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  4216. }
  4217. break;
  4218. case 81: //邀请/公务活动
  4219. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  4220. if (_ioa != null)
  4221. {
  4222. string inviteCurrName = "Unknown", //邀请费用币种 Name
  4223. inviteCurrCode = "Unknown", //邀请费用币种 Code
  4224. sendCurrName = "Unknown", //快递费用币种 Name
  4225. sendCurrCode = "Unknown", //快递费用币种 Code
  4226. eventsCurrName = "Unknown", //公务活动费币种 Name
  4227. eventsCurrCode = "Unknown", //公务活动费币种 Code
  4228. translateCurrName = "Unknown", //公务翻译费 Name
  4229. translateCurrCode = "Unknown"; //公务翻译费 Code
  4230. #region 处理费用币种
  4231. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  4232. if (inviteCurrData != null)
  4233. {
  4234. inviteCurrName = inviteCurrData.Remark;
  4235. inviteCurrCode = inviteCurrData.Name;
  4236. }
  4237. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  4238. if (sendCurrData != null)
  4239. {
  4240. sendCurrName = sendCurrData.Remark;
  4241. sendCurrCode = sendCurrData.Name;
  4242. }
  4243. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  4244. if (eventsCurrData != null)
  4245. {
  4246. eventsCurrName = eventsCurrData.Remark;
  4247. eventsCurrCode = eventsCurrData.Name;
  4248. }
  4249. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  4250. if (translateCurrData != null)
  4251. {
  4252. translateCurrName = translateCurrData.Remark;
  4253. translateCurrCode = translateCurrData.Name;
  4254. }
  4255. #endregion
  4256. _detail.PriceNameContent = _ioa.InviterArea;
  4257. //2025-09-08 商邀费用名称更改:单项费用不等于0,则在名称后面最加费用类型名称。
  4258. List<string> priceExpNames = new List<string>();
  4259. if (_ioa.InviteCost != 0.00M) priceExpNames.Add("邀请费");
  4260. if (_ioa.SendCost != 0.00M) priceExpNames.Add("快递费");
  4261. if (_ioa.EventsCost != 0.00M) priceExpNames.Add("公务活动费");
  4262. if (_ioa.TranslateCost != 0.00M) priceExpNames.Add("公务翻译费");
  4263. if (priceExpNames != null && priceExpNames.Count > 0)
  4264. {
  4265. _detail.PriceNameContent += $"({string.Join("+", priceExpNames)})";
  4266. }
  4267. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  4268. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  4269. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  4270. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  4271. $@"备注:" + _ioa.Remark + "<br/>";
  4272. }
  4273. break;
  4274. case 82: //团组客户保险
  4275. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  4276. if (customers != null)
  4277. {
  4278. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  4279. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  4280. }
  4281. break;
  4282. case 85: //机票预订
  4283. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  4284. if (jpRes != null)
  4285. {
  4286. string FlightsDescription = jpRes.FlightsDescription;
  4287. string PriceDescription = jpRes.PriceDescription;
  4288. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  4289. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  4290. }
  4291. break;
  4292. case 98://其他款项
  4293. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  4294. if (gdpRes != null)
  4295. {
  4296. //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/";
  4297. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  4298. //{
  4299. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  4300. //}
  4301. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  4302. _detail.PriceNameContent = gdpRes.PriceName;
  4303. }
  4304. break;
  4305. case 285://收款退还
  4306. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  4307. if (refundAndOtherMoney != null)
  4308. {
  4309. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  4310. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  4311. }
  4312. break;
  4313. case 751://酒店早餐
  4314. break;
  4315. case 1015://超支费用
  4316. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  4317. if (groupExtraCost != null)
  4318. {
  4319. _detail.PriceNameContent = groupExtraCost.PriceName;
  4320. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  4321. }
  4322. break;
  4323. default:
  4324. break;
  4325. }
  4326. /*
  4327. * 申请人
  4328. */
  4329. string operatorName = " - ";
  4330. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  4331. if (_opUser != null)
  4332. {
  4333. operatorName = _opUser.CnName;
  4334. }
  4335. _detail.OperatorName = operatorName;
  4336. /*
  4337. * 审核人
  4338. */
  4339. string auditOperatorName = " - ";
  4340. if (entity.IsAuditGM != 0)
  4341. {
  4342. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  4343. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  4344. else
  4345. {
  4346. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  4347. if (_adUser != null)
  4348. {
  4349. auditOperatorName = _adUser.CnName;
  4350. }
  4351. }
  4352. }
  4353. _detail.AuditOperatorName = auditOperatorName;
  4354. /*
  4355. * 超预算比例
  4356. */
  4357. string overBudgetStr = "";
  4358. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  4359. else if (entity.ExceedBudget == 0)
  4360. {
  4361. if (entity.CTable == 76 || entity.CTable == 79)
  4362. {
  4363. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  4364. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  4365. }
  4366. else
  4367. {
  4368. overBudgetStr = "未超预算";
  4369. }
  4370. }
  4371. else overBudgetStr = entity.ExceedBudget.ToString("P");
  4372. _detail.OverBudget = overBudgetStr;
  4373. decimal auditFee = 0.00M; //已审核金额 人名币
  4374. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  4375. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  4376. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  4377. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  4378. {
  4379. auditedFeeOriginal = entity.PayMoney;
  4380. auditFee = CurrPayStr;
  4381. }
  4382. else if (entity.IsAuditGM == 0)
  4383. {
  4384. unAuditFeeCNY = CurrPayStr;
  4385. unAuditFeeOriginal = OriginalCurrPay;
  4386. OriginalCurrPay = 0.00M;
  4387. }
  4388. /*
  4389. * 费用总计
  4390. */
  4391. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  4392. {
  4393. CurrencyId = entity.PaymentCurrency,
  4394. CurrencyName = PaymentCurrency_WaitPay,
  4395. AmountPayable = entity.PayMoney,
  4396. ThisPayment = OriginalCurrPay,
  4397. BalancePayment = BalanceStr,
  4398. AuditedFunds = auditFee,
  4399. AuditedFundsOriginal = auditedFeeOriginal,
  4400. UnAuditFundsCNY = unAuditFeeCNY,
  4401. UnAuditFundsOriginal = unAuditFeeOriginal
  4402. });
  4403. _detail.IsAuditGM = entity.IsAuditGM;
  4404. detailList.Add(_detail);
  4405. }
  4406. #endregion
  4407. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  4408. /*
  4409. * 下方描述处理
  4410. */
  4411. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  4412. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  4413. if (ccpCurrencyPrice != null)
  4414. {
  4415. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  4416. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  4417. }
  4418. else
  4419. {
  4420. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  4421. }
  4422. string amountPayableStr = string.Format(@"应付款总金额: ");
  4423. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  4424. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  4425. string auditedFundsStr = string.Format(@"已审费用总额: ");
  4426. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  4427. foreach (var item in nonDuplicat)
  4428. {
  4429. var currencyName = item.CurrencyName;
  4430. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  4431. if (strs.Count > 0)
  4432. {
  4433. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  4434. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  4435. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  4436. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  4437. //单独处理此次付款金额
  4438. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  4439. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  4440. //单独处理已审核费用
  4441. //if (item.CurrencyId == 836) //人民币
  4442. //{
  4443. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  4444. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  4445. //}
  4446. //else
  4447. //{
  4448. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  4449. //}
  4450. if (currencyName.Equals("CNY"))
  4451. {
  4452. //已审核费用
  4453. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  4454. //未审核费用
  4455. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  4456. }
  4457. else
  4458. {
  4459. //已审核费用
  4460. 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"));
  4461. //未审核费用
  4462. 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"));
  4463. }
  4464. }
  4465. }
  4466. _view.TotalStr1 = amountPayableStr[..^1];
  4467. _view.TotalStr2 = thisPaymentStr[..^1];
  4468. _view.TotalStr3 = balancePaymentStr[..^1];
  4469. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  4470. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  4471. var _view1 = new
  4472. {
  4473. PageFuncAuth = pageFunAuthView,
  4474. Data = _view
  4475. };
  4476. return Ok(JsonView(_view1));
  4477. }
  4478. catch (Exception ex)
  4479. {
  4480. return Ok(JsonView(false, ex.Message));
  4481. }
  4482. }
  4483. /// <summary>
  4484. /// 费用审核
  4485. /// 修改团组费用审核状态
  4486. /// </summary>
  4487. /// <param name="_dto">参数Json字符串</param>
  4488. /// <returns></returns>
  4489. [HttpPost]
  4490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4491. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  4492. {
  4493. #region 参数验证
  4494. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  4495. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  4496. #endregion
  4497. #region 页面操作权限验证
  4498. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4499. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  4500. #endregion
  4501. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  4502. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  4503. DateTime dtNow = DateTime.Now;
  4504. _groupRepository.BeginTran();
  4505. int rst = 0;
  4506. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  4507. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  4508. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4509. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  4510. var msgDatas = new List<dynamic>();
  4511. var dic_ccp_user = new Dictionary<int, int>() { };
  4512. foreach (var item in idList)
  4513. {
  4514. int CreditId = int.Parse(item);
  4515. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  4516. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  4517. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  4518. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  4519. .Where(s => s.Id == CreditId)
  4520. .ExecuteCommandAsync();
  4521. if (result < 1)
  4522. {
  4523. rst = -1;
  4524. _groupRepository.RollbackTran();
  4525. return Ok(JsonView(false, "操作失败并回滚!"));
  4526. }
  4527. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  4528. if (creditData != null)
  4529. {
  4530. #region 应用通知配置
  4531. try
  4532. {
  4533. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  4534. }
  4535. catch (Exception ex)
  4536. {
  4537. }
  4538. #endregion
  4539. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  4540. string groupNameStr = string.Empty;
  4541. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  4542. if (groupData != null) groupNameStr = groupData.TeamName;
  4543. string creditTypeStr = string.Empty;
  4544. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  4545. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  4546. string creditCurrency = string.Empty;
  4547. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  4548. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  4549. if (creditCurrency.Equals("CNY"))
  4550. {
  4551. creditData.DayRate = 1.0000M;
  4552. }
  4553. if (creditData.PayPercentage == 0.00M)
  4554. {
  4555. creditData.PayPercentage = 100M;
  4556. }
  4557. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  4558. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  4559. string msgContent = "";
  4560. if (creditCurrency.Equals("CNY"))
  4561. {
  4562. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  4563. }
  4564. else
  4565. {
  4566. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  4567. }
  4568. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  4569. }
  4570. }
  4571. if (rst == 0)
  4572. {
  4573. _groupRepository.CommitTran();
  4574. foreach (var item in msgDatas)
  4575. {
  4576. //发送消息
  4577. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  4578. }
  4579. #region 应用推送
  4580. try
  4581. {
  4582. foreach (var ccpId in dic_ccp_user.Keys)
  4583. {
  4584. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  4585. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  4586. }
  4587. }
  4588. catch (Exception)
  4589. {
  4590. }
  4591. #endregion
  4592. return Ok(JsonView(true, "操作成功!"));
  4593. }
  4594. return Ok(JsonView(false, "操作失败!"));
  4595. }
  4596. /// <summary>
  4597. /// 费用审核
  4598. /// 其他款项 文件下载
  4599. /// </summary>
  4600. /// <param name="id">其他款项 主键编号</param>
  4601. /// <returns></returns>
  4602. [HttpGet("{id}")]
  4603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4604. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1, int.MaxValue, ErrorMessage = "请传入有效的ID")] int id)
  4605. {
  4606. //网站域名
  4607. 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/";
  4608. var otherInfo = await _decreasePaymentsRep._sqlSugar
  4609. .Queryable<Grp_DecreasePayments>()
  4610. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  4611. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  4612. .Select((x, y) => new
  4613. {
  4614. x.Id,
  4615. x.FilePath
  4616. })
  4617. .FirstAsync();
  4618. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  4619. {
  4620. var url = $"{baseUrl}{otherInfo.FilePath}";
  4621. return Ok(JsonView(true, "操作成功!", url));
  4622. }
  4623. return Ok(JsonView(false, "暂无附件"));
  4624. }
  4625. #endregion
  4626. #region 机票费用录入
  4627. /// <summary>
  4628. /// 机票录入当前登录人可操作团组
  4629. /// </summary>
  4630. /// <param name="dto"></param>
  4631. /// <returns></returns>
  4632. [HttpPost]
  4633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4634. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  4635. {
  4636. try
  4637. {
  4638. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  4639. if (groupData.Code != 0)
  4640. {
  4641. return Ok(JsonView(false, groupData.Msg));
  4642. }
  4643. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4644. }
  4645. catch (Exception ex)
  4646. {
  4647. return Ok(JsonView(false, ex.Message));
  4648. }
  4649. }
  4650. /// <summary>
  4651. /// 机票费用录入列表
  4652. /// </summary>
  4653. /// <param name="dto"></param>
  4654. /// <returns></returns>
  4655. [HttpPost]
  4656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4657. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  4658. {
  4659. try
  4660. {
  4661. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  4662. if (groupData.Code != 0)
  4663. {
  4664. return Ok(JsonView(false, groupData.Msg));
  4665. }
  4666. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4667. }
  4668. catch (Exception ex)
  4669. {
  4670. return Ok(JsonView(false, ex.Message));
  4671. throw;
  4672. }
  4673. }
  4674. /// <summary>
  4675. /// 根据id查询费用录入信息
  4676. /// </summary>
  4677. /// <param name="dto"></param>
  4678. /// <returns></returns>
  4679. [HttpPost]
  4680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4681. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  4682. {
  4683. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  4684. if (groupData.Code != 0)
  4685. {
  4686. return Ok(JsonView(false, groupData.Msg));
  4687. }
  4688. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4689. }
  4690. /// <summary>
  4691. /// 机票费用录入操作(Status:1.新增,2.修改)
  4692. /// </summary>
  4693. /// <param name="dto"></param>
  4694. /// <returns></returns>
  4695. [HttpPost]
  4696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4697. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  4698. {
  4699. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  4700. if (groupData.Code != 0)
  4701. {
  4702. return Ok(JsonView(false, groupData.Msg));
  4703. }
  4704. #region 应用推送
  4705. try
  4706. {
  4707. var diId = dto.AirTicketResOpData.DiId;
  4708. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4709. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4710. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4711. //自动审核
  4712. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  4713. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  4714. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  4715. $"GroupId:{diId};airId:{dataId};",
  4716. status,
  4717. auditMsg);
  4718. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4719. //2024-10-21 新增LZ UID
  4720. var userIds = new List<int>() { 21 };
  4721. string title = $"系统通知";
  4722. string content = "";
  4723. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4724. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4725. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4726. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4727. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4728. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  4729. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4730. }
  4731. catch (Exception ex)
  4732. {
  4733. }
  4734. #endregion
  4735. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4736. }
  4737. /// <summary>
  4738. /// 机票费用自动审核 AI识别方式
  4739. /// </summary>
  4740. /// <returns></returns>
  4741. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  4742. {
  4743. var ecoTypeIds = new List<int>() {
  4744. 459, //超经舱
  4745. 460, //经济舱
  4746. 1430, //公务舱(实际经济舱)
  4747. 1432, //头等舱(实际经济舱)
  4748. };
  4749. var bizTypeIds = new List<int>() {
  4750. 457, //头等舱
  4751. 458, //公务舱
  4752. 1431, //头等舱(实际公务舱)
  4753. };
  4754. var auditFeeTypeIds = new List<int>() { };
  4755. auditFeeTypeIds.AddRange(ecoTypeIds);
  4756. auditFeeTypeIds.AddRange(bizTypeIds);
  4757. int currModule = 85;
  4758. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  4759. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  4760. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  4761. .Select((x, y) => new
  4762. {
  4763. x.Id,
  4764. CcpId = y.Id,
  4765. x.FlightsDate,
  4766. x.PrePrice,
  4767. x.CType,
  4768. x.ClientNum,
  4769. x.DIId
  4770. })
  4771. .FirstAsync();
  4772. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  4773. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  4774. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  4775. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  4776. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  4777. var groupCostContents = await _sqlSugar
  4778. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  4779. .Where(x => x.IsDel == 0 && x.Diid == diId)
  4780. .ToListAsync();
  4781. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  4782. //处理 成本详细信息日期为空 填装费用信息
  4783. var airFeeLabel = new StringBuilder();
  4784. airFeeLabel.AppendLine("费用成本:");
  4785. for (int i = 0; i < groupCostContents.Count; i++)
  4786. {
  4787. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  4788. {
  4789. int index = i - 1;
  4790. if (index >= 0)
  4791. {
  4792. groupCostContents[i].Date = groupCostContents[index].Date;
  4793. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4794. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4795. }
  4796. }
  4797. else
  4798. {
  4799. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4800. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4801. }
  4802. var item = groupCostContents[i];
  4803. airFeeLabel.AppendLine($"{item.Date}");
  4804. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  4805. }
  4806. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  4807. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  4808. //访问Kimi AI 返回价格结果
  4809. var msgs = new List<SeedMessages>()
  4810. {
  4811. new ()
  4812. {
  4813. Role = KimiRole.user,
  4814. Content = airFeeLabel.ToString()
  4815. }
  4816. };
  4817. var client = new KiMiApiClient();
  4818. var kimiApiResult = await client.SeedMessage(msgs);
  4819. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  4820. string clients = kimiApiResult_JObject["content"].ToString();
  4821. decimal ecoPri_kimiAI = 0.00M,
  4822. bizPri_kimiAI = 0.00M;
  4823. //单个价格: 经济舱价格
  4824. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  4825. //价格文本包含/:/前经济舱价格 /后公务舱价格
  4826. if (clients.Contains('/'))
  4827. {
  4828. var priArray = clients.Split('/');
  4829. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  4830. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  4831. }
  4832. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  4833. var isAutoAudit = false;
  4834. //价格验证处理
  4835. //经济舱
  4836. if (ecoTypeIds.Contains(airInfo.CType))
  4837. {
  4838. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  4839. }
  4840. //公务舱
  4841. else if (bizTypeIds.Contains(airInfo.CType))
  4842. {
  4843. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  4844. }
  4845. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  4846. //是否执行自动审核
  4847. if (isAutoAudit)
  4848. {
  4849. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4850. .SetColumns(x => x.IsAuditGM == 3)
  4851. .SetColumns(x => x.AuditGMOperate == 4)
  4852. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  4853. .Where(x => x.Id == airInfo.CcpId)
  4854. .ExecuteCommandAsync();
  4855. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  4856. }
  4857. return (false, "当前费用超过成本费用,不可自动审核!");
  4858. }
  4859. /// <summary>
  4860. /// 机票费用录入
  4861. /// 自动审核测试 - AI 识别
  4862. /// </summary>
  4863. /// <param name="groupId"></param>
  4864. /// <param name="Id"></param>
  4865. /// <returns></returns>
  4866. [HttpPost]
  4867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4868. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  4869. {
  4870. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4871. return Ok(JsonView(status, msg));
  4872. }
  4873. /// <summary>
  4874. /// 根据舱位类型查询接团客户名单信息
  4875. /// </summary>
  4876. /// <param name="dto"></param>
  4877. /// <returns></returns>
  4878. [HttpPost]
  4879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4880. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4881. {
  4882. try
  4883. {
  4884. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4885. if (crm_Groups.Count != 0)
  4886. {
  4887. var Customer = new List<dynamic>();
  4888. foreach (var item in crm_Groups)
  4889. {
  4890. var data = new
  4891. {
  4892. item.Id,
  4893. item.Pinyin,
  4894. Name = item.LastName + item.FirstName
  4895. };
  4896. Customer.Add(data);
  4897. }
  4898. return Ok(JsonView(true, "查询成功!", Customer));
  4899. }
  4900. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4901. }
  4902. catch (Exception ex)
  4903. {
  4904. return Ok(JsonView(false, "程序错误!"));
  4905. throw;
  4906. }
  4907. }
  4908. /// <summary>
  4909. /// 根据团号获取客户信息
  4910. /// </summary>
  4911. /// <param name="dto"></param>
  4912. /// <returns></returns>
  4913. [HttpPost]
  4914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4915. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  4916. {
  4917. var jw = JsonView(false);
  4918. if (dto.DIID < 1)
  4919. {
  4920. jw.Msg += "请输入正确的diid";
  4921. return Ok(jw);
  4922. }
  4923. var arr = GetSimplClientList(dto.DIID);
  4924. jw = JsonView(true, "获取成功!", arr);
  4925. return Ok(jw);
  4926. }
  4927. private List<SimplClientInfo> GetSimplClientList(int diId)
  4928. {
  4929. 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);
  4930. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  4931. foreach (var item in arr)
  4932. {
  4933. EncryptionProcessor.DecryptProperties(item);
  4934. }
  4935. return arr;
  4936. }
  4937. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  4938. {
  4939. string result = origin;
  4940. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4941. {
  4942. string[] temparr = origin.Split(',');
  4943. string fistrStr = temparr[0];
  4944. int count = temparr.Length;
  4945. bool success = int.TryParse(fistrStr, out int tempId);
  4946. if (success)
  4947. {
  4948. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4949. if (tempInfo != null)
  4950. {
  4951. if (count > 1)
  4952. {
  4953. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4954. }
  4955. else
  4956. {
  4957. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4958. }
  4959. }
  4960. }
  4961. }
  4962. return result;
  4963. }
  4964. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4965. {
  4966. string result = origin;
  4967. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4968. {
  4969. string[] temparr = origin.Split(',');
  4970. result = "";
  4971. foreach (var item in temparr)
  4972. {
  4973. bool success = int.TryParse(item, out int tempId);
  4974. if (success)
  4975. {
  4976. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4977. if (tempInfo != null)
  4978. {
  4979. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4980. }
  4981. }
  4982. }
  4983. }
  4984. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4985. return result;
  4986. }
  4987. /// <summary>
  4988. /// 机票费用录入,删除
  4989. /// </summary>
  4990. /// <param name="dto"></param>
  4991. /// <returns></returns>
  4992. [HttpPost]
  4993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4994. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4995. {
  4996. try
  4997. {
  4998. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4999. if (res)
  5000. {
  5001. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  5002. {
  5003. IsDel = 1,
  5004. DeleteUserId = dto.DeleteUserId,
  5005. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5006. }).ExecuteCommandAsync();
  5007. return Ok(JsonView(true, "删除成功!"));
  5008. }
  5009. return Ok(JsonView(false, "删除失败!"));
  5010. }
  5011. catch (Exception ex)
  5012. {
  5013. return Ok(JsonView(false, "程序错误!"));
  5014. throw;
  5015. }
  5016. }
  5017. /// <summary>
  5018. /// 导出机票录入报表
  5019. /// </summary>
  5020. /// <param name="dto"></param>
  5021. /// <returns></returns>
  5022. [HttpPost]
  5023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5024. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  5025. {
  5026. try
  5027. {
  5028. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  5029. if (groupData.Code != 0)
  5030. {
  5031. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  5032. }
  5033. else
  5034. {
  5035. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  5036. if (AirTicketReservations.Count != 0)
  5037. {
  5038. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  5039. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  5040. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  5041. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  5042. var designer = new WorkbookDesigner
  5043. {
  5044. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  5045. };
  5046. decimal countCost = 0;
  5047. foreach (var item in AirTicketReservations)
  5048. {
  5049. #region 处理客人姓名
  5050. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  5051. item.ClientName = clientNames;
  5052. #endregion
  5053. if (item.BankType == "其他")
  5054. {
  5055. item.BankNo = "--";
  5056. }
  5057. else
  5058. {
  5059. if (!string.IsNullOrEmpty(item.BankType))
  5060. {
  5061. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  5062. }
  5063. }
  5064. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  5065. item.Price = System.Decimal.Round(item.Price, 2);
  5066. countCost += Convert.ToDecimal(item.Price);
  5067. }
  5068. designer.SetDataSource("Export", AirTicketReservations);
  5069. designer.SetDataSource("ExportDiCode", diCode);
  5070. designer.SetDataSource("ExportDiName", diName);
  5071. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  5072. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  5073. designer.Process();
  5074. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  5075. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  5076. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  5077. return Ok(JsonView(true, "成功", url = rst));
  5078. }
  5079. else
  5080. {
  5081. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  5082. }
  5083. }
  5084. }
  5085. catch (Exception ex)
  5086. {
  5087. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  5088. throw;
  5089. }
  5090. }
  5091. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  5092. /// <summary>
  5093. /// 行程单导出
  5094. /// </summary>
  5095. /// <param name="dto"></param>
  5096. /// <returns></returns>
  5097. [HttpPost]
  5098. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5099. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  5100. {
  5101. try
  5102. {
  5103. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  5104. if (groupData.Code != 0)
  5105. {
  5106. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  5107. }
  5108. else
  5109. {
  5110. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  5111. if (dto.Language == "CN")
  5112. {
  5113. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  5114. var builder = new DocumentBuilder(doc);
  5115. int tableIndex = 0;//表格索引
  5116. //得到文档中的第一个表格
  5117. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  5118. foreach (var item in _AirTicketReservations)
  5119. {
  5120. #region 处理固定数据
  5121. string[] FlightsCode = item.FlightsCode.Split('/');
  5122. if (FlightsCode.Length != 0)
  5123. {
  5124. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5125. if (_AirCompany != null)
  5126. {
  5127. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  5128. }
  5129. else
  5130. {
  5131. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5132. }
  5133. }
  5134. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5135. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5136. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5137. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5138. string name = "";
  5139. foreach (string clientName in nameArray)
  5140. {
  5141. if (!name.Contains(clientName))
  5142. {
  5143. name += clientName + ",";
  5144. }
  5145. }
  5146. if (!string.IsNullOrWhiteSpace(name))
  5147. {
  5148. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  5149. }
  5150. else
  5151. {
  5152. table.Range.Bookmarks["ClientName"].Text = "--";
  5153. }
  5154. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5155. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5156. table.Range.Bookmarks["JointTicket"].Text = "--";
  5157. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5158. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5159. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5160. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5161. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5162. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5163. #endregion
  5164. #region 循环数据处理
  5165. var airs = new List<AirInfo>();
  5166. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5167. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5168. for (int i = 0; i < FlightsCode.Length; i++)
  5169. {
  5170. var air = new AirInfo();
  5171. string[] tempstr = DayArray[i]
  5172. .Replace("\r\n", string.Empty)
  5173. .Replace("\\r\\n", string.Empty)
  5174. .TrimStart().TrimEnd()
  5175. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5176. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5177. string starCity = "";
  5178. if (star_Three != null)
  5179. {
  5180. starCity = star_Three.AirPort;
  5181. }
  5182. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5183. string EndCity = "";
  5184. if (End_Three != null)
  5185. {
  5186. EndCity = End_Three.AirPort;
  5187. }
  5188. air.Destination = starCity + "/" + EndCity;
  5189. air.Flight = FlightsCode[i];
  5190. air.SeatingClass = item.CTypeName;
  5191. string dateTime = tempstr[2];
  5192. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  5193. air.FlightDate = DateTemp;
  5194. air.DepartureTime = tempstr[5];
  5195. air.LandingTime = tempstr[6];
  5196. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  5197. air.TicketStatus = "--";
  5198. air.Luggage = "--";
  5199. air.DepartureTerminal = "--";
  5200. air.LandingTerminal = "--";
  5201. airs.Add(air);
  5202. }
  5203. int row = 13;
  5204. for (int i = 0; i < airs.Count; i++)
  5205. {
  5206. if (airs.Count > 2)
  5207. {
  5208. for (int j = 0; j < airs.Count - 2; j++)
  5209. {
  5210. var CopyRow = table.Rows[12].Clone(true);
  5211. table.Rows.Add(CopyRow);
  5212. }
  5213. }
  5214. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  5215. int index = 0;
  5216. foreach (PropertyInfo property in properties)
  5217. {
  5218. string value = property.GetValue(airs[i]).ToString();
  5219. Cell ishcel0 = table.Rows[row].Cells[index];
  5220. var p = new Paragraph(doc);
  5221. string s = value;
  5222. p.AppendChild(new Run(doc, s));
  5223. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  5224. ishcel0.AppendChild(p);
  5225. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  5226. index++;
  5227. }
  5228. row++;
  5229. }
  5230. #endregion
  5231. var lastParagraph = new Paragraph(doc);
  5232. //第一个表格末尾加段落
  5233. table.ParentNode.InsertAfter(lastParagraph, table);
  5234. //复制第一个表格
  5235. Table cloneTable = (Table)table.Clone(true);
  5236. //在文档末尾段落后面加入复制的表格
  5237. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  5238. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  5239. {
  5240. int rownewsIndex = 13;
  5241. for (int i = 0; i < 2; i++)
  5242. {
  5243. var CopyRow = table.Rows[12].Clone(true);
  5244. table.Rows.RemoveAt(13);
  5245. table.Rows.Add(CopyRow);
  5246. rownewsIndex++;
  5247. }
  5248. }
  5249. else
  5250. {
  5251. table.Rows.RemoveAt(12);
  5252. }
  5253. cloneTable.Rows.RemoveAt(12);
  5254. }
  5255. if (_AirTicketReservations.Count != 0)
  5256. {
  5257. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  5258. if (FlightsCode.Length != 0)
  5259. {
  5260. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5261. if (_AirCompany != null)
  5262. {
  5263. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  5264. }
  5265. else
  5266. {
  5267. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5268. }
  5269. }
  5270. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5271. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5272. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5273. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5274. string name = "";
  5275. foreach (string clientName in nameArray)
  5276. {
  5277. if (!name.Contains(clientName))
  5278. {
  5279. name += clientName + ",";
  5280. }
  5281. }
  5282. if (!string.IsNullOrWhiteSpace(name))
  5283. {
  5284. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  5285. }
  5286. else
  5287. {
  5288. table.Range.Bookmarks["ClientName"].Text = "--";
  5289. }
  5290. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5291. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5292. table.Range.Bookmarks["JointTicket"].Text = "--";
  5293. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5294. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5295. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5296. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5297. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5298. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5299. }
  5300. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  5301. //保存合并后的文档
  5302. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  5303. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  5304. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  5305. return Ok(JsonView(true, "成功!", rst));
  5306. }
  5307. else
  5308. {
  5309. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  5310. var builder = new DocumentBuilder(doc);
  5311. int tableIndex = 0;//表格索引
  5312. //得到文档中的第一个表格
  5313. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  5314. var texts = new List<string>();
  5315. foreach (var item in _AirTicketReservations)
  5316. {
  5317. string[] FlightsCode = item.FlightsCode.Split('/');
  5318. if (FlightsCode.Length != 0)
  5319. {
  5320. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5321. if (_AirCompany != null)
  5322. {
  5323. if (!transDic.ContainsKey(_AirCompany.CnName))
  5324. {
  5325. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  5326. }
  5327. }
  5328. else
  5329. {
  5330. if (!transDic.ContainsKey("--"))
  5331. {
  5332. transDic.Add("--", "--");
  5333. }
  5334. }
  5335. }
  5336. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5337. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5338. string name = "";
  5339. foreach (string clientName in nameArray)
  5340. {
  5341. name += clientName + ",";
  5342. }
  5343. if (!texts.Contains(name))
  5344. {
  5345. texts.Add(name);
  5346. }
  5347. var airs = new List<AirInfo>();
  5348. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5349. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5350. for (int i = 0; i < FlightsCode.Length; i++)
  5351. {
  5352. var air = new AirInfo();
  5353. string[] tempstr = DayArray[i]
  5354. .Replace("\r\n", string.Empty)
  5355. .Replace("\\r\\n", string.Empty)
  5356. .TrimStart().TrimEnd()
  5357. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5358. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5359. if (star_Three != null)
  5360. {
  5361. if (!transDic.ContainsKey(star_Three.AirPort))
  5362. {
  5363. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  5364. }
  5365. }
  5366. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5367. if (End_Three != null)
  5368. {
  5369. if (!transDic.ContainsKey(End_Three.AirPort))
  5370. {
  5371. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  5372. }
  5373. }
  5374. if (!texts.Contains(item.CTypeName))
  5375. {
  5376. texts.Add(item.CTypeName);
  5377. }
  5378. }
  5379. }
  5380. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5381. if (transData.Count > 0)
  5382. {
  5383. foreach (TranslateResult item in transData)
  5384. {
  5385. if (!transDic.ContainsKey(item.Query))
  5386. {
  5387. transDic.Add(item.Query, item.Translation);
  5388. }
  5389. }
  5390. }
  5391. foreach (var item in _AirTicketReservations)
  5392. {
  5393. #region 处理固定数据
  5394. string[] FlightsCode = item.FlightsCode.Split('/');
  5395. if (FlightsCode.Length != 0)
  5396. {
  5397. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5398. if (_AirCompany != null)
  5399. {
  5400. string str = "--";
  5401. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  5402. if (!string.IsNullOrEmpty(translateResult))
  5403. {
  5404. str = translateResult;
  5405. str = _airTicketResRep.Processing(str);
  5406. }
  5407. table.Range.Bookmarks["AirlineCompany"].Text = str;
  5408. }
  5409. else
  5410. {
  5411. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5412. }
  5413. }
  5414. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5415. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5416. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5417. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5418. string names = "";
  5419. foreach (string clientName in nameArray)
  5420. {
  5421. names += clientName + ",";
  5422. }
  5423. if (!string.IsNullOrWhiteSpace(names))
  5424. {
  5425. string str = "--";
  5426. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  5427. if (!string.IsNullOrEmpty(translateResult))
  5428. {
  5429. str = translateResult;
  5430. str = _airTicketResRep.Processing(str);
  5431. }
  5432. table.Range.Bookmarks["ClientName"].Text = str;
  5433. }
  5434. else
  5435. {
  5436. table.Range.Bookmarks["ClientName"].Text = "--";
  5437. }
  5438. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5439. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5440. table.Range.Bookmarks["JointTicket"].Text = "--";
  5441. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5442. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5443. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5444. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5445. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5446. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5447. #endregion
  5448. #region 循环数据处理
  5449. var airs = new List<AirInfo>();
  5450. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5451. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5452. for (int i = 0; i < FlightsCode.Length; i++)
  5453. {
  5454. var air = new AirInfo();
  5455. string[] tempstr = DayArray[i]
  5456. .Replace("\r\n", string.Empty)
  5457. .Replace("\\r\\n", string.Empty)
  5458. .TrimStart().TrimEnd()
  5459. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5460. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5461. string starCity = "";
  5462. if (star_Three != null)
  5463. {
  5464. string str2 = "--";
  5465. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  5466. if (!string.IsNullOrEmpty(translateResult2))
  5467. {
  5468. str2 = translateResult2;
  5469. str2 = _airTicketResRep.Processing(str2);
  5470. }
  5471. starCity = str2;
  5472. }
  5473. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5474. string EndCity = "";
  5475. if (End_Three != null)
  5476. {
  5477. string str1 = "--";
  5478. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  5479. if (!string.IsNullOrEmpty(translateResult1))
  5480. {
  5481. str1 = translateResult1;
  5482. str1 = _airTicketResRep.Processing(str1);
  5483. }
  5484. EndCity = str1;
  5485. }
  5486. air.Destination = starCity + "/" + EndCity;
  5487. air.Flight = FlightsCode[i];
  5488. string str = "--";
  5489. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  5490. if (!string.IsNullOrEmpty(translateResult))
  5491. {
  5492. str = translateResult;
  5493. str = _airTicketResRep.Processing(str);
  5494. }
  5495. air.SeatingClass = str;
  5496. string dateTime = tempstr[2];
  5497. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  5498. air.FlightDate = DateTemp;
  5499. air.DepartureTime = tempstr[5];
  5500. air.LandingTime = tempstr[6];
  5501. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  5502. air.TicketStatus = "--";
  5503. air.Luggage = "--";
  5504. air.DepartureTerminal = "--";
  5505. air.LandingTerminal = "--";
  5506. airs.Add(air);
  5507. }
  5508. int row = 13;
  5509. for (int i = 0; i < airs.Count; i++)
  5510. {
  5511. if (airs.Count > 2)
  5512. {
  5513. for (int j = 0; j < airs.Count - 2; j++)
  5514. {
  5515. var CopyRow = table.Rows[12].Clone(true);
  5516. table.Rows.Add(CopyRow);
  5517. }
  5518. }
  5519. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  5520. int index = 0;
  5521. foreach (PropertyInfo property in properties)
  5522. {
  5523. string value = property.GetValue(airs[i]).ToString();
  5524. Cell ishcel0 = table.Rows[row].Cells[index];
  5525. var p = new Paragraph(doc);
  5526. string s = value;
  5527. p.AppendChild(new Run(doc, s));
  5528. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  5529. ishcel0.AppendChild(p);
  5530. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  5531. //ishcel0.CellFormat.VerticalAlignment=
  5532. index++;
  5533. }
  5534. row++;
  5535. }
  5536. #endregion
  5537. var lastParagraph = new Paragraph(doc);
  5538. //第一个表格末尾加段落
  5539. table.ParentNode.InsertAfter(lastParagraph, table);
  5540. //复制第一个表格
  5541. Table cloneTable = (Table)table.Clone(true);
  5542. //在文档末尾段落后面加入复制的表格
  5543. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  5544. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  5545. {
  5546. int rownewsIndex = 13;
  5547. for (int i = 0; i < 2; i++)
  5548. {
  5549. var CopyRow = table.Rows[12].Clone(true);
  5550. table.Rows.RemoveAt(13);
  5551. table.Rows.Add(CopyRow);
  5552. rownewsIndex++;
  5553. }
  5554. }
  5555. else
  5556. {
  5557. table.Rows.RemoveAt(12);
  5558. }
  5559. cloneTable.Rows.RemoveAt(12);
  5560. }
  5561. if (_AirTicketReservations.Count != 0)
  5562. {
  5563. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  5564. if (FlightsCode.Length != 0)
  5565. {
  5566. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5567. if (_AirCompany != null)
  5568. {
  5569. string str = "--";
  5570. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  5571. if (!string.IsNullOrEmpty(translateResult))
  5572. {
  5573. str = translateResult;
  5574. str = _airTicketResRep.Processing(str);
  5575. }
  5576. table.Range.Bookmarks["AirlineCompany"].Text = str;
  5577. }
  5578. else
  5579. {
  5580. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5581. }
  5582. }
  5583. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5584. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5585. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5586. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5587. string names = "";
  5588. foreach (string clientName in nameArray)
  5589. {
  5590. names += clientName + ",";
  5591. }
  5592. if (!string.IsNullOrWhiteSpace(names))
  5593. {
  5594. string str = "--";
  5595. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  5596. if (!string.IsNullOrEmpty(translateResult))
  5597. {
  5598. str = translateResult;
  5599. str = _airTicketResRep.Processing(str);
  5600. }
  5601. table.Range.Bookmarks["ClientName"].Text = str;
  5602. }
  5603. else
  5604. {
  5605. table.Range.Bookmarks["ClientName"].Text = "--";
  5606. }
  5607. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5608. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5609. table.Range.Bookmarks["JointTicket"].Text = "--";
  5610. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5611. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5612. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5613. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5614. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5615. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5616. }
  5617. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  5618. //保存合并后的文档
  5619. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  5620. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  5621. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  5622. return Ok(JsonView(true, "成功!", rst));
  5623. }
  5624. }
  5625. }
  5626. catch (Exception ex)
  5627. {
  5628. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  5629. throw;
  5630. }
  5631. }
  5632. #endregion
  5633. #region 团组增减款项 --> 其他款项
  5634. /// <summary>
  5635. /// 团组增减款项下拉框绑定
  5636. /// </summary>
  5637. /// <param name="dto"></param>
  5638. /// <returns></returns>
  5639. [HttpPost]
  5640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5641. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  5642. {
  5643. #region 参数验证
  5644. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5645. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  5646. #endregion
  5647. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  5648. }
  5649. /// <summary>
  5650. /// 根据团组Id查询团组增减款项
  5651. /// </summary>
  5652. /// <param name="dto"></param>
  5653. /// <returns></returns>
  5654. [HttpPost]
  5655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5656. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  5657. {
  5658. #region 参数验证
  5659. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5660. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5661. #endregion
  5662. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  5663. }
  5664. /// <summary>
  5665. /// 团组增减款项操作(Status:1.新增,2.修改)
  5666. /// </summary>
  5667. /// <param name="dto"></param>
  5668. /// <returns></returns>
  5669. [HttpPost]
  5670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5671. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  5672. {
  5673. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  5674. if (groupData.Code != 200)
  5675. {
  5676. return Ok(JsonView(false, groupData.Msg));
  5677. }
  5678. #region 应用推送
  5679. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  5680. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5681. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5682. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  5683. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  5684. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  5685. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  5686. if (recheck)
  5687. {
  5688. //自动审核
  5689. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  5690. }
  5691. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5692. //2024-10-21 新增LZ UID
  5693. var userIds = new List<int>() { 21 };
  5694. string title = $"系统通知";
  5695. string content = "";
  5696. var diId = dto.DiId;
  5697. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5698. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5699. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5700. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5701. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5702. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  5703. #endregion
  5704. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5705. }
  5706. /// <summary>
  5707. /// 团组增减款项操作 删除
  5708. /// </summary>
  5709. /// <param name="dto"></param>
  5710. /// <returns></returns>
  5711. [HttpPost]
  5712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5713. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  5714. {
  5715. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  5716. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  5717. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  5718. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  5719. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  5720. }
  5721. /// <summary>
  5722. /// 根据团组增减款项Id查询
  5723. /// </summary>
  5724. /// <param name="dto"></param>
  5725. /// <returns></returns>
  5726. [HttpPost]
  5727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5728. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  5729. {
  5730. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  5731. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  5732. }
  5733. /// <summary>
  5734. /// 查询供应商名称
  5735. /// </summary>
  5736. /// <param name="dto"></param>
  5737. /// <returns></returns>
  5738. [HttpPost]
  5739. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  5740. {
  5741. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  5742. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  5743. ?? new List<Grp_DecreasePayments>();
  5744. dbResult = dbResult.Distinct(new
  5745. ProductComparer()).ToList();
  5746. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  5747. {
  5748. x.Id,
  5749. x.SupplierAddress,
  5750. x.SupplierArea,
  5751. x.SupplierContact,
  5752. x.SupplierContactNumber,
  5753. x.SupplierEmail,
  5754. x.SupplierName,
  5755. x.SupplierSocialAccount,
  5756. x.SupplierTypeId,
  5757. }).ToList());
  5758. return Ok(jw);
  5759. }
  5760. /// <summary>
  5761. /// 团组增减款项 OTA匹配
  5762. /// </summary>
  5763. /// <param name="file"></param>
  5764. /// <returns></returns>
  5765. [HttpPost]
  5766. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  5767. {
  5768. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  5769. string fileName = file.FileName;
  5770. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  5771. {
  5772. return Ok(JsonView(false, "请上传Excel文件!"));
  5773. }
  5774. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  5775. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  5776. if (!Directory.Exists(path))
  5777. {
  5778. Directory.CreateDirectory(path);
  5779. }
  5780. var filePath = @$"{path}/{fileName}";
  5781. //保存文件
  5782. using (FileStream fs = System.IO.File.Create(filePath))
  5783. {
  5784. file.CopyTo(fs);
  5785. fs.Flush();
  5786. }
  5787. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  5788. //读取ExcelFile
  5789. DataTable dt = ConvertExcelToDataTable(filePath);
  5790. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  5791. dt.TableName = "TB";
  5792. //修改table列名
  5793. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  5794. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  5795. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  5796. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  5797. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  5798. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  5799. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  5800. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  5801. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  5802. dt.Columns[9].ColumnName = "Quantity"; // 台数
  5803. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  5804. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  5805. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  5806. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  5807. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  5808. var otaOrderNos = new List<string>();
  5809. foreach (DataRow item in dt.Rows)
  5810. {
  5811. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  5812. }
  5813. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  5814. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  5815. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  5816. .Select((dp, di) => new
  5817. {
  5818. dp.PriceName,
  5819. dp.OTAOrderNo,
  5820. dp.FeeTotal,
  5821. di.TeamName,
  5822. })
  5823. .ToListAsync();
  5824. foreach (DataRow item in dt.Rows)
  5825. {
  5826. var otaOrderNo = item["OTAOrderNo"].ToString();
  5827. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  5828. if (oaData == null) continue;
  5829. item["GroupName"] = oaData.TeamName;
  5830. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  5831. }
  5832. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  5833. var pairs = new Dictionary<string, object>();
  5834. var datas = new List<DataTable>
  5835. {
  5836. dt
  5837. };
  5838. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  5839. return Ok(JsonView(true, "操作成功", new { url }));
  5840. }
  5841. #region
  5842. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  5843. {
  5844. // 创建Workbook对象
  5845. var workbook = new Workbook(excelFilePath);
  5846. // 获取第一个工作表
  5847. var worksheet = workbook.Worksheets[0];
  5848. // 将工作表转换为DataTable
  5849. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  5850. return dataTable;
  5851. }
  5852. #endregion
  5853. /// <summary>
  5854. /// 世运会数据
  5855. /// </summary>
  5856. /// <returns></returns>
  5857. [HttpGet]
  5858. public IActionResult WorldGamesData()
  5859. {
  5860. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  5861. var groupMenu = setData.GroupBy(x => x.T0);
  5862. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  5863. foreach (var item in groupMenu)
  5864. {
  5865. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  5866. {
  5867. Data = new SetDataView
  5868. {
  5869. Name = item.Key
  5870. },
  5871. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  5872. });
  5873. }
  5874. return Ok(JsonView(true, "success", resultArr));
  5875. }
  5876. #endregion
  5877. #region 文件上传、删除
  5878. /// <summary>
  5879. /// region 文件上传 可以带参数
  5880. /// </summary>
  5881. /// <param name="file"></param>
  5882. /// <returns></returns>
  5883. [HttpPost]
  5884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5885. public async Task<IActionResult> UploadProject(IFormFile file)
  5886. {
  5887. //var TypeName = Request.Headers["TypeName"].ToString();
  5888. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5889. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5890. ////文件名称
  5891. //string projectFileName = file.FileName;
  5892. ////上传的文件的路径
  5893. //string filePath = $"{fileDir}/{projectFileName}";
  5894. //if (TypeName == "A")//A代表团组增减款项
  5895. //{
  5896. // filePath = fileDir + $@"\团组增减款项相关文件";
  5897. // if (!Directory.Exists(filePath))
  5898. // {
  5899. // Directory.CreateDirectory(filePath);
  5900. // }
  5901. // //上传的文件的路径
  5902. // filePath += $@"\{projectFileName}";
  5903. //}
  5904. //else if (TypeName == "B")//B代表商邀相关文件
  5905. //{
  5906. // //上传的文件的路径
  5907. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5908. // if (!Directory.Exists(filePath))
  5909. // {
  5910. // Directory.CreateDirectory(filePath);
  5911. // }
  5912. // //上传的文件的路径
  5913. // filePath = $@"\{projectFileName}";
  5914. //}
  5915. //try
  5916. //{
  5917. // using (FileStream fs = System.IO.File.Create(filePath))
  5918. // {
  5919. // file.CopyTo(fs);
  5920. // fs.Flush();
  5921. // }
  5922. //}
  5923. //catch (Exception ex)
  5924. //{
  5925. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  5926. //}
  5927. //return Ok(JsonView(true, "上传成功!", projectFileName));
  5928. try
  5929. {
  5930. var TypeName = Request.Headers["TypeName"].ToString();
  5931. if (file != null)
  5932. {
  5933. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5934. //文件名称
  5935. string projectFileName = file.FileName;
  5936. //上传的文件的路径
  5937. string filePath = $"{fileDir}/{projectFileName}";
  5938. if (TypeName == "A")//A代表团组增减款项
  5939. {
  5940. if (!Directory.Exists(fileDir))
  5941. {
  5942. Directory.CreateDirectory(fileDir);
  5943. }
  5944. //上传的文件的路径
  5945. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5946. }
  5947. else if (TypeName == "B")//B代表商邀相关文件
  5948. {
  5949. if (!Directory.Exists(fileDir))
  5950. {
  5951. Directory.CreateDirectory(fileDir);
  5952. }
  5953. //上传的文件的路径
  5954. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5955. }
  5956. using (FileStream fs = System.IO.File.Create(filePath))
  5957. {
  5958. file.CopyTo(fs);
  5959. fs.Flush();
  5960. }
  5961. return Ok(JsonView(true, "上传成功!", projectFileName));
  5962. }
  5963. else
  5964. {
  5965. return Ok(JsonView(false, "上传失败!"));
  5966. }
  5967. }
  5968. catch (Exception ex)
  5969. {
  5970. return Ok(JsonView(false, ex.Message));
  5971. }
  5972. }
  5973. /// <summary>
  5974. /// 删除指定文件
  5975. /// </summary>
  5976. /// <param name="dto"></param>
  5977. /// <returns></returns>
  5978. [HttpPost]
  5979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5980. public async Task<IActionResult> DelFile(DelFileDto dto)
  5981. {
  5982. try
  5983. {
  5984. var TypeName = Request.Headers["TypeName"].ToString();
  5985. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5986. string filePath = "";
  5987. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5988. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5989. int id = 0;
  5990. if (TypeName == "A")
  5991. {
  5992. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5993. // 删除该文件
  5994. System.IO.File.Delete(filePath);
  5995. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5996. .Where(a => a.Id == dto.Id)
  5997. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5998. .ExecuteCommandAsync();
  5999. }
  6000. else if (TypeName == "B")
  6001. {
  6002. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  6003. // 删除该文件
  6004. System.IO.File.Delete(filePath);
  6005. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  6006. if (info != null)
  6007. {
  6008. string[] files = Array.Empty<string>();
  6009. if (!string.IsNullOrEmpty(info.Attachment))
  6010. {
  6011. try
  6012. {
  6013. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  6014. }
  6015. catch (Exception)
  6016. {
  6017. files = new List<string>() { info.Attachment }.ToArray();
  6018. }
  6019. }
  6020. if (files.Length > 0)
  6021. {
  6022. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  6023. string filePath2 = string.Empty;
  6024. if (files1.Length > 0)
  6025. {
  6026. filePath2 = JsonConvert.SerializeObject(files1);
  6027. }
  6028. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  6029. .Where(a => a.Id == dto.Id)
  6030. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  6031. .ExecuteCommandAsync();
  6032. }
  6033. }
  6034. }
  6035. if (id != 0)
  6036. {
  6037. return Ok(JsonView(true, "成功!"));
  6038. }
  6039. else
  6040. {
  6041. return Ok(JsonView(false, "失败!"));
  6042. }
  6043. }
  6044. catch (Exception ex)
  6045. {
  6046. return Ok(JsonView(false, "程序错误!"));
  6047. throw;
  6048. }
  6049. }
  6050. /// <summary>
  6051. /// 文件上传多个文件 可以带参数
  6052. /// </summary>
  6053. /// <param name="files"></param>
  6054. /// <returns></returns>
  6055. [HttpPost]
  6056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6057. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  6058. {
  6059. try
  6060. {
  6061. var TypeName = Request.Headers["TypeName"].ToString();
  6062. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  6063. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  6064. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6065. var filePahts = new List<string>();
  6066. foreach (var file in files)
  6067. {
  6068. //文件名称
  6069. string projectFileName = file.FileName;
  6070. //上传的文件的路径
  6071. string filePath = $"{fileDir}/{projectFileName}";
  6072. if (TypeName == "A")//A代表团组增减款项
  6073. {
  6074. if (!Directory.Exists(fileDir))
  6075. {
  6076. Directory.CreateDirectory(fileDir);
  6077. }
  6078. //上传的文件的路径
  6079. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  6080. }
  6081. else if (TypeName == "B")//B代表商邀相关文件
  6082. {
  6083. if (!Directory.Exists(fileDir))
  6084. {
  6085. Directory.CreateDirectory(fileDir);
  6086. }
  6087. //上传的文件的路径
  6088. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  6089. }
  6090. using (FileStream fs = System.IO.File.Create(filePath))
  6091. {
  6092. file.CopyTo(fs);
  6093. fs.Flush();
  6094. }
  6095. filePahts.Add(projectFileName);
  6096. }
  6097. return Ok(JsonView(true, "上传成功!", filePahts));
  6098. }
  6099. catch (Exception ex)
  6100. {
  6101. return Ok(JsonView(false, ex.Message));
  6102. }
  6103. }
  6104. #endregion
  6105. #region 商邀费用录入
  6106. /// <summary>
  6107. /// 根据团组Id查询商邀费用列表
  6108. /// </summary>
  6109. /// <param name="dto"></param>
  6110. /// <returns></returns>
  6111. [HttpPost]
  6112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6113. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  6114. {
  6115. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  6116. if (groupData.Code != 0)
  6117. {
  6118. return Ok(JsonView(false, groupData.Msg));
  6119. }
  6120. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6121. }
  6122. /// <summary>
  6123. /// 商邀费用列表
  6124. /// 下载文件
  6125. /// </summary>
  6126. /// <param name="id"></param>
  6127. /// <returns></returns>
  6128. [HttpGet("{id}")]
  6129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6130. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  6131. {
  6132. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  6133. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  6134. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  6135. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  6136. var filePaths = new List<string>();
  6137. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  6138. try
  6139. {
  6140. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  6141. }
  6142. catch (Exception ex)
  6143. {
  6144. filePaths.Add(info.Attachment);
  6145. }
  6146. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  6147. for (int i = 0; i < filePaths.Count; i++)
  6148. {
  6149. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  6150. }
  6151. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  6152. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  6153. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  6154. {
  6155. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  6156. {
  6157. foreach (string filePath in filePaths)
  6158. {
  6159. if (System.IO.File.Exists(filePath))
  6160. {
  6161. // 获取文件名
  6162. string fileName = Path.GetFileName(filePath);
  6163. // 将文件添加到ZIP归档中
  6164. zipArchive.CreateEntryFromFile(filePath, fileName);
  6165. }
  6166. }
  6167. }
  6168. }
  6169. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  6170. }
  6171. /// <summary>
  6172. /// 商邀费用 Info Page 基础数据源
  6173. /// </summary>
  6174. /// <returns></returns>
  6175. [HttpPost]
  6176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6177. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  6178. {
  6179. try
  6180. {
  6181. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  6182. if (groupData.Code != 0)
  6183. {
  6184. return Ok(JsonView(false, groupData.Msg));
  6185. }
  6186. return Ok(JsonView(true, "操作成功", groupData.Data));
  6187. }
  6188. catch (Exception ex)
  6189. {
  6190. return Ok(JsonView(false, ex.Message));
  6191. throw;
  6192. }
  6193. }
  6194. /// <summary>
  6195. /// 根据商邀费用ID查询C表和商邀费用数据
  6196. /// </summary>
  6197. /// <param name="dto"></param>
  6198. /// <returns></returns>
  6199. [HttpPost]
  6200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6201. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  6202. {
  6203. try
  6204. {
  6205. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  6206. if (groupData.Code != 0)
  6207. {
  6208. return Ok(JsonView(false, groupData.Msg));
  6209. }
  6210. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6211. }
  6212. catch (Exception ex)
  6213. {
  6214. return Ok(JsonView(false, ex.Message));
  6215. throw;
  6216. }
  6217. }
  6218. /// <summary>
  6219. /// 商邀费用录入操作(Status:1.新增,2.修改)
  6220. /// </summary>
  6221. /// <param name="dto"></param>
  6222. /// <returns></returns>
  6223. [HttpPost]
  6224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6225. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  6226. {
  6227. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  6228. if (groupData.Code != 0)
  6229. {
  6230. return Ok(JsonView(false, groupData.Msg));
  6231. }
  6232. #region 应用推送
  6233. try
  6234. {
  6235. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6236. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6237. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6238. //2024-10-21 新增LZ UID
  6239. var userIds = new List<int>() { 21 };
  6240. string title = $"系统通知";
  6241. string content = "";
  6242. var diId = dto.DiId;
  6243. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6244. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6245. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6246. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6247. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6248. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  6249. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  6250. }
  6251. catch (Exception ex)
  6252. {
  6253. }
  6254. #endregion
  6255. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6256. }
  6257. /// <summary>
  6258. /// 商邀删除
  6259. /// </summary>
  6260. /// <param name="dto"></param>
  6261. /// <returns></returns>
  6262. [HttpPost]
  6263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6264. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  6265. {
  6266. try
  6267. {
  6268. _sqlSugar.BeginTran();
  6269. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  6270. .SetColumns(it => new Grp_InvitationOfficialActivities()
  6271. {
  6272. IsDel = 1,
  6273. DeleteUserId = dto.DeleteUserId,
  6274. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6275. })
  6276. .Where(it => it.Id == dto.Id)
  6277. .ExecuteCommand();
  6278. if (res1 > 0)
  6279. {
  6280. int _diId = 0;
  6281. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  6282. if (_ioaInfo != null)
  6283. {
  6284. _diId = _ioaInfo.DiId;
  6285. }
  6286. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6287. .SetColumns(a => new Grp_CreditCardPayment()
  6288. {
  6289. IsDel = 1,
  6290. DeleteUserId = dto.DeleteUserId,
  6291. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6292. })
  6293. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  6294. .ExecuteCommand();
  6295. if (res2 > 0)
  6296. {
  6297. _sqlSugar.CommitTran();
  6298. return Ok(JsonView(true, "删除成功!"));
  6299. }
  6300. }
  6301. _sqlSugar.RollbackTran();
  6302. return Ok(JsonView(false, "删除失败"));
  6303. }
  6304. catch (Exception ex)
  6305. {
  6306. _sqlSugar.RollbackTran();
  6307. return Ok(JsonView(false, ex.Message));
  6308. }
  6309. }
  6310. #endregion
  6311. #region 票据上传
  6312. /// <summary>
  6313. /// 团组模块文件上传
  6314. /// </summary>
  6315. /// <param name="dto"></param>
  6316. /// <returns></returns>
  6317. [HttpPost]
  6318. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  6319. {
  6320. var jw = JsonView(false);
  6321. long M = 1024 * 1024;
  6322. if (dto.Files == null || dto.Files.Count == 0)
  6323. {
  6324. jw.Msg = "无文件信息!";
  6325. return Ok(jw);
  6326. }
  6327. if (dto.Files.Sum(x => x.Length) > 20 * M)
  6328. {
  6329. jw.Msg = "文件大小超过20M!";
  6330. return Ok(jw);
  6331. }
  6332. //var nameSp = dto.File.FileName.Split(".");
  6333. //if (nameSp.Length < 2)
  6334. //{
  6335. // jw.Msg = "拓展名称有误!";
  6336. // return Ok(jw);
  6337. //}
  6338. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  6339. //if (!existsName.Contains(nameSp[1].ToUpper()))
  6340. //{
  6341. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  6342. // return Ok(jw);
  6343. //}
  6344. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  6345. if (Ctable == null)
  6346. {
  6347. jw.Msg = "Ctable指向有误!";
  6348. return Ok(jw);
  6349. }
  6350. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6351. if (groupInfo == null)
  6352. {
  6353. jw.Msg = "团组信息不存在!";
  6354. return Ok(jw);
  6355. }
  6356. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  6357. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6358. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6359. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6360. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  6361. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  6362. try
  6363. {
  6364. if (!Directory.Exists(fileBase))
  6365. {
  6366. Directory.CreateDirectory(fileBase);
  6367. }
  6368. var saveArr = new List<Grp_GroupModelFile>();
  6369. foreach (var fileStream in dto.Files)
  6370. {
  6371. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  6372. var file = new Grp_GroupModelFile()
  6373. {
  6374. Cid = dto.Cid,
  6375. CreateTime = DateTime.Now,
  6376. CreateUserId = dto.Userid,
  6377. Ctable = dto.Ctable,
  6378. Diid = dto.Diid,
  6379. IsDel = 0,
  6380. FilePath = saveFilePath,
  6381. FileName = fileStream.FileName
  6382. };
  6383. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6384. {
  6385. fileStream.CopyTo(fs);
  6386. fs.Flush();
  6387. }
  6388. saveArr.Add(file);
  6389. }
  6390. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  6391. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  6392. jw = JsonView(true, "保存成功!", new
  6393. {
  6394. count = addResult,
  6395. filesName = saveArr.Select(x => x.FileName)
  6396. });
  6397. }
  6398. catch (Exception ex)
  6399. {
  6400. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  6401. {
  6402. count = 0,
  6403. filesName = Array.Empty<string>(),
  6404. });
  6405. }
  6406. return Ok(jw);
  6407. }
  6408. /// <summary>
  6409. /// 查询各模块已保存文件
  6410. /// </summary>
  6411. /// <param name="dto"></param>
  6412. /// <returns></returns>
  6413. [HttpPost]
  6414. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  6415. {
  6416. var expression = Expressionable.Create<Grp_GroupModelFile>()
  6417. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  6418. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  6419. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  6420. {
  6421. expression = Expressionable.Create<Grp_GroupModelFile>()
  6422. .And(x => visaIds.Contains(x.CreateUserId));
  6423. }
  6424. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  6425. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  6426. .Where(expression.ToExpression())
  6427. .ToList();
  6428. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  6429. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  6430. {
  6431. x.FileName,
  6432. x.Id,
  6433. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  6434. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  6435. })));
  6436. }
  6437. /// <summary>
  6438. /// 下载该团组下的所有文件
  6439. /// </summary>
  6440. /// <param name="dto"></param>
  6441. /// <returns></returns>
  6442. [HttpPost]
  6443. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  6444. {
  6445. var jw = JsonView(false);
  6446. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  6447. if (groupInfo == null)
  6448. {
  6449. jw.Msg = "团组信息不存在!";
  6450. return Ok(jw);
  6451. }
  6452. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  6453. var isModule = Convert.ToBoolean(dto.isModule);
  6454. var Zips = new Dictionary<string, Stream>();
  6455. var io = new IOOperatorHelper();
  6456. if (isModule)
  6457. {
  6458. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  6459. foreach (var moduleArr in moduleGroup)
  6460. {
  6461. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  6462. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  6463. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6464. var chiZips = new Dictionary<string, Stream>();
  6465. foreach (var item in moduleArr)
  6466. {
  6467. if (System.IO.File.Exists(item.FilePath))
  6468. {
  6469. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6470. {
  6471. byte[] bytes = new byte[fileStream.Length];
  6472. fileStream.Read(bytes, 0, bytes.Length);
  6473. fileStream.Close();
  6474. Stream stream = new MemoryStream(bytes);
  6475. chiZips.Add(item.FileName, stream);
  6476. }
  6477. }
  6478. }
  6479. if (chiZips.Count > 0)
  6480. {
  6481. var byts = io.ConvertZipStream(chiZips);
  6482. Stream stream = new MemoryStream(byts);
  6483. Zips.Add(key.Name + "_.zip", stream);
  6484. }
  6485. }
  6486. }
  6487. else
  6488. {
  6489. foreach (var item in dbQuery)
  6490. {
  6491. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6492. {
  6493. byte[] bytes = new byte[fileStream.Length];
  6494. fileStream.Read(bytes, 0, bytes.Length);
  6495. fileStream.Close();
  6496. var stream = new MemoryStream(bytes);
  6497. while (Zips.ContainsKey(item.FileName))
  6498. {
  6499. item.FileName = new Random().Next(100) + "_" + item.FileName;
  6500. }
  6501. Zips.Add(item.FileName, stream);
  6502. }
  6503. }
  6504. }
  6505. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6506. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6507. if (Zips.Count > 0)
  6508. {
  6509. var byts = io.ConvertZipStream(Zips);
  6510. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  6511. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  6512. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  6513. }
  6514. else
  6515. {
  6516. jw.Msg = "暂无生成文件!";
  6517. }
  6518. return Ok(jw);
  6519. }
  6520. /// <summary>
  6521. /// 下载该团组下此模块的所有文件
  6522. /// </summary>
  6523. /// <param name="dto"></param>
  6524. /// <returns></returns>
  6525. [HttpPost]
  6526. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  6527. {
  6528. var jw = JsonView(false);
  6529. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  6530. if (groupInfo == null)
  6531. {
  6532. jw.Msg = "团组信息不存在!";
  6533. return Ok(jw);
  6534. }
  6535. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  6536. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  6537. && x.IsDel == 0);
  6538. if (key == null)
  6539. {
  6540. jw.Msg = "Ctable指向错误!";
  6541. return Ok(jw);
  6542. }
  6543. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  6544. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6545. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6546. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6547. var io = new IOOperatorHelper();
  6548. var Zips = new Dictionary<string, Stream>();
  6549. foreach (var item in dbQuery)
  6550. {
  6551. if (System.IO.File.Exists(item.FilePath))
  6552. {
  6553. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6554. {
  6555. byte[] bytes = new byte[fileStream.Length];
  6556. fileStream.Read(bytes, 0, bytes.Length);
  6557. fileStream.Close();
  6558. var stream = new MemoryStream(bytes);
  6559. while (Zips.ContainsKey(item.FileName))
  6560. {
  6561. item.FileName = new Random().Next(100) + "_" + item.FileName;
  6562. }
  6563. Zips.Add(item.FileName, stream);
  6564. }
  6565. }
  6566. }
  6567. if (Zips.Count > 0)
  6568. {
  6569. var byts = io.ConvertZipStream(Zips);
  6570. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  6571. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  6572. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  6573. }
  6574. else
  6575. {
  6576. jw.Msg = "暂无生成文件!";
  6577. }
  6578. return Ok(jw);
  6579. }
  6580. /// <summary>
  6581. /// 删除该团组下的指定文件
  6582. /// </summary>
  6583. /// <param name="dto"></param>
  6584. /// <returns></returns>
  6585. [HttpPost]
  6586. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  6587. {
  6588. var jw = JsonView(false);
  6589. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6590. if (sing == null)
  6591. {
  6592. jw.Msg = "暂无";
  6593. return Ok(jw);
  6594. }
  6595. if (System.IO.File.Exists(sing.FilePath))
  6596. {
  6597. try
  6598. {
  6599. System.IO.File.Delete(sing.FilePath);
  6600. }
  6601. catch (Exception ex)
  6602. {
  6603. jw.Msg = "删除失败!" + ex.Message;
  6604. return Ok(jw);
  6605. }
  6606. }
  6607. sing.IsDel = 1;
  6608. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6609. sing.DeleteUserId = dto.UserId;
  6610. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  6611. jw = JsonView(true, "删除成功!");
  6612. return Ok(jw);
  6613. }
  6614. #endregion
  6615. #region 共享文件上传
  6616. /// <summary>
  6617. /// 共享文件数据初始化
  6618. /// </summary>
  6619. /// <returns></returns>
  6620. [HttpGet]
  6621. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  6622. {
  6623. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  6624. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  6625. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  6626. .Select(x => x.Id)
  6627. .ToList()
  6628. .Contains(userid);
  6629. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  6630. .Where(x => x.STid == 111 && x.IsDel == 0)
  6631. .Select(x => new
  6632. {
  6633. x.Name,
  6634. x.Id,
  6635. }).ToList();
  6636. if (isMarketingDepartment)
  6637. {
  6638. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  6639. }
  6640. if (portType == 1)
  6641. {
  6642. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  6643. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  6644. .Where(x => x.IsDel == 0)
  6645. .OrderByDescending(x => x.VisitDate)
  6646. .Select(x => new
  6647. {
  6648. x.TeamName,
  6649. x.Id,
  6650. x.CityId,
  6651. })
  6652. .ToList()
  6653. .Select(x =>
  6654. {
  6655. var provinceId = x.CityId;
  6656. var isDefualtVal = true;
  6657. if (provinceId > 0)
  6658. {
  6659. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  6660. if (parentId != null)
  6661. {
  6662. isDefualtVal = false;
  6663. provinceId = (int)parentId;
  6664. }
  6665. }
  6666. if (isDefualtVal)
  6667. {
  6668. provinceId = 122; //默认四川
  6669. }
  6670. return new
  6671. {
  6672. x.TeamName,
  6673. x.Id,
  6674. provinceId,
  6675. };
  6676. })
  6677. .ToList();
  6678. return Ok(JsonView(true, "SUCCESS!", new
  6679. {
  6680. dropDownType,
  6681. dropDownGroupList,
  6682. isMarketingDepartment
  6683. }));
  6684. }
  6685. else if (portType == 2 || portType == 3)
  6686. {
  6687. return Ok(JsonView(true, "SUCCESS!", new
  6688. {
  6689. dropDownType,
  6690. isMarketingDepartment
  6691. }));
  6692. }
  6693. else
  6694. {
  6695. return Ok(JsonView(false, "portType有误!"));
  6696. }
  6697. }
  6698. /// <summary>
  6699. /// 共享文件上传
  6700. /// </summary>
  6701. /// <param name="dto"></param>
  6702. /// <returns></returns>
  6703. [HttpPost]
  6704. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  6705. {
  6706. var isGroup = new List<int> { 1412 };
  6707. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  6708. {
  6709. return Ok(JsonView(false, "该文件需要关联团组!"));
  6710. }
  6711. if (dto.Files == null || dto.Files.Count == 0)
  6712. {
  6713. return Ok(JsonView(false, "无文件信息!"));
  6714. }
  6715. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  6716. {
  6717. return Ok(JsonView(false, "文件大小超过20M!"));
  6718. }
  6719. if (dto.Userid < 1)
  6720. {
  6721. return Ok(JsonView(false, "请传入有效的Userid!"));
  6722. }
  6723. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  6724. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  6725. .Select((u, j) => new
  6726. {
  6727. u.CnName,
  6728. UserId = u.Id,
  6729. j.JobName,
  6730. })
  6731. .First();
  6732. if (jobInfo == null)
  6733. {
  6734. return Ok(JsonView(false, "请传入有效的Userid!"));
  6735. }
  6736. var commonFileExtensions = new List<string>
  6737. {
  6738. // 文本文件
  6739. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  6740. // 图片文件
  6741. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  6742. // 视频文件
  6743. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  6744. // 音频文件
  6745. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  6746. // 压缩文件
  6747. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  6748. // 数据文件
  6749. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  6750. };
  6751. try
  6752. {
  6753. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  6754. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  6755. commonFileExtensions.AddRange(settingExtend);
  6756. }
  6757. catch (Exception)
  6758. { }
  6759. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  6760. if (setdata == null)
  6761. {
  6762. return Ok(JsonView(false, "请传入有效的FileType!"));
  6763. }
  6764. var insertList = new List<Grp_GroupShareFile>();
  6765. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  6766. if (!Directory.Exists(winPath))
  6767. {
  6768. Directory.CreateDirectory(winPath);
  6769. }
  6770. foreach (var item in dto.Files)
  6771. {
  6772. var houzui = Path.GetExtension(item.FileName);
  6773. if (!commonFileExtensions.Contains(houzui))
  6774. {
  6775. return Ok(JsonView(false, "未知后缀名称!"));
  6776. }
  6777. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  6778. var saveFilePath = winPath + fileName;
  6779. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6780. {
  6781. item.CopyTo(fs);
  6782. fs.Flush();
  6783. }
  6784. var fileDetail = new Grp_GroupShareFile()
  6785. {
  6786. CreateUserId = dto.Userid,
  6787. CreateTime = DateTime.Now,
  6788. UploadJob = jobInfo.JobName,
  6789. FileName = fileName,
  6790. FileType = dto.FileType,
  6791. Diid = dto.Diid,
  6792. FilePath = winPath + fileName,
  6793. };
  6794. insertList.Add(fileDetail);
  6795. }
  6796. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  6797. return Ok(JsonView(true, "保存成功!"));
  6798. }
  6799. /// <summary>
  6800. /// 查询共享文件列表
  6801. /// </summary>
  6802. /// <param name="dto"></param>
  6803. /// <returns></returns>
  6804. [HttpPost]
  6805. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  6806. {
  6807. var isGroup = new List<int> { 1412 };
  6808. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  6809. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  6810. .And(x => x.Diid == dto.Diid)
  6811. .And(x => x.FileType == dto.FileType)
  6812. .And(x => x.IsDel == 0)
  6813. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  6814. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  6815. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  6816. int totalCount = 0;
  6817. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  6818. .Where(queryExpression.ToExpression())
  6819. .OrderBy(x => x.UploadJob)
  6820. .Select(x => new
  6821. {
  6822. x.Id,
  6823. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  6824. x.FileName,
  6825. x.FileType,
  6826. x.CreateTime,
  6827. })
  6828. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  6829. return Ok(JsonView(true, "SUCCESS!", new
  6830. {
  6831. FileList = dbQuery,
  6832. dto.PageSize,
  6833. dto.PageIndex,
  6834. totalCount
  6835. }));
  6836. }
  6837. /// <summary>
  6838. /// 删除共享文件模块下的指定文件
  6839. /// </summary>
  6840. /// <param name="dto"></param>
  6841. /// <returns></returns>
  6842. [HttpPost]
  6843. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  6844. {
  6845. var jw = JsonView(false);
  6846. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6847. if (sing == null)
  6848. {
  6849. jw.Msg = "暂无文件信息!";
  6850. return Ok(jw);
  6851. }
  6852. if (sing.CreateUserId != dto.UserId)
  6853. {
  6854. jw.Msg = "只能删除自己上传的文件!";
  6855. return Ok(jw);
  6856. }
  6857. if (System.IO.File.Exists(sing.FilePath))
  6858. {
  6859. try
  6860. {
  6861. System.IO.File.Delete(sing.FilePath);
  6862. }
  6863. catch (Exception ex)
  6864. {
  6865. jw.Msg = "删除失败!" + ex.Message;
  6866. return Ok(jw);
  6867. }
  6868. }
  6869. sing.IsDel = 1;
  6870. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6871. sing.DeleteUserId = dto.UserId;
  6872. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  6873. jw = JsonView(true, "删除成功!");
  6874. return Ok(jw);
  6875. }
  6876. #endregion
  6877. #region 团组英文资料
  6878. /// <summary>
  6879. /// 查询团组英文所有资料
  6880. /// </summary>
  6881. /// <param name="dto"></param>
  6882. /// <returns></returns>
  6883. [HttpPost]
  6884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6885. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6886. {
  6887. try
  6888. {
  6889. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6890. if (groupData.Code != 0)
  6891. {
  6892. return Ok(JsonView(false, groupData.Msg));
  6893. }
  6894. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6895. }
  6896. catch (Exception ex)
  6897. {
  6898. return Ok(JsonView(false, ex.Message));
  6899. throw;
  6900. }
  6901. }
  6902. /// <summary>
  6903. /// 团组英文资料操作(Status:1.新增,2.修改)
  6904. /// </summary>
  6905. /// <param name="dto"></param>
  6906. /// <returns></returns>
  6907. [HttpPost]
  6908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6909. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6910. {
  6911. try
  6912. {
  6913. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  6914. if (groupData.Code != 0)
  6915. {
  6916. return Ok(JsonView(false, groupData.Msg));
  6917. }
  6918. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6919. }
  6920. catch (Exception ex)
  6921. {
  6922. return Ok(JsonView(false, ex.Message));
  6923. throw;
  6924. }
  6925. }
  6926. /// <summary>
  6927. /// 团组英文资料Id查询数据
  6928. /// </summary>
  6929. /// <param name="dto"></param>
  6930. /// <returns></returns>
  6931. [HttpPost]
  6932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6933. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  6934. {
  6935. try
  6936. {
  6937. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  6938. if (_DelegationEnData != null)
  6939. {
  6940. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  6941. }
  6942. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  6943. }
  6944. catch (Exception ex)
  6945. {
  6946. return Ok(JsonView(false, "程序错误!"));
  6947. throw;
  6948. }
  6949. }
  6950. /// <summary>
  6951. /// 团组英文资料删除
  6952. /// </summary>
  6953. /// <param name="dto"></param>
  6954. /// <returns></returns>
  6955. [HttpPost]
  6956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6957. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6958. {
  6959. try
  6960. {
  6961. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6962. if (!res)
  6963. {
  6964. return Ok(JsonView(false, "删除失败"));
  6965. }
  6966. return Ok(JsonView(true, "删除成功!"));
  6967. }
  6968. catch (Exception ex)
  6969. {
  6970. return Ok(JsonView(false, ex.Message));
  6971. throw;
  6972. }
  6973. }
  6974. #endregion
  6975. #region 导出邀请函
  6976. /// <summary>
  6977. /// 导出邀请函页面初始化
  6978. /// </summary>
  6979. /// <param name="dto"></param>
  6980. /// <returns></returns>
  6981. [HttpPost]
  6982. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6983. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6984. {
  6985. try
  6986. {
  6987. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6988. var crm_Deles = new List<Crm_DeleClient>();
  6989. if (dto.DiId == 0)
  6990. {
  6991. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6992. }
  6993. else
  6994. {
  6995. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6996. }
  6997. return Ok(JsonView(true, "查询成功!", new
  6998. {
  6999. deleClient = crm_Deles,
  7000. delegations = grp_Delegations
  7001. }));
  7002. }
  7003. catch (Exception ex)
  7004. {
  7005. return Ok(JsonView(false, "程序错误!"));
  7006. throw;
  7007. }
  7008. }
  7009. /// <summary>
  7010. /// 导出邀请函
  7011. /// </summary>
  7012. /// <param name="dto"></param>
  7013. /// <returns></returns>
  7014. [HttpPost]
  7015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7016. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  7017. {
  7018. #region 参数验证
  7019. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  7020. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7021. #endregion
  7022. try
  7023. {
  7024. var transDic = new Dictionary<string, string>();
  7025. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  7026. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  7027. From Grp_TourClientList tcl
  7028. Left Join
  7029. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  7030. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  7031. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  7032. From Crm_DeleClient dc
  7033. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  7034. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  7035. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  7036. Where dc.IsDel = 0) temp
  7037. On temp.DcId =tcl.ClientId
  7038. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  7039. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  7040. var texts = new List<string>();
  7041. if (datas.Count != 0)
  7042. {
  7043. foreach (TourClientListDetailsView item in datas)
  7044. {
  7045. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  7046. {
  7047. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  7048. }
  7049. else
  7050. {
  7051. string name = item.LastName + item.FirstName;
  7052. texts.Add(name);
  7053. }
  7054. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  7055. {
  7056. if (!transDic.ContainsKey(item.Job))
  7057. {
  7058. texts.Add(item.Job);
  7059. }
  7060. }
  7061. if (!string.IsNullOrEmpty(item.CompanyFullName))
  7062. {
  7063. texts.Add(item.CompanyFullName);
  7064. }
  7065. }
  7066. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  7067. if (transData.Count > 0)
  7068. {
  7069. foreach (TranslateResult item in transData)
  7070. {
  7071. if (!transDic.ContainsKey(item.Query))
  7072. {
  7073. transDic.Add(item.Query, item.Translation);
  7074. }
  7075. }
  7076. }
  7077. var list = new List<GuestList>();
  7078. foreach (var dele in datas)
  7079. {
  7080. var guestList = new GuestList();
  7081. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  7082. {
  7083. guestList.Name = dele.Pinyin;
  7084. }
  7085. else
  7086. {
  7087. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  7088. guestList.Name = Name;
  7089. }
  7090. if (dele.Sex == 0)
  7091. {
  7092. guestList.Sex = "Male";
  7093. }
  7094. else if (dele.Sex == 1)
  7095. {
  7096. guestList.Sex = "Female";
  7097. }
  7098. guestList.DOB = dele.BirthDay.Replace('-', '.');
  7099. if (!string.IsNullOrEmpty(dele.Job))
  7100. {
  7101. guestList.Job = dele.Job;
  7102. }
  7103. list.Add(guestList);
  7104. }
  7105. //载入模板
  7106. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  7107. var builder = new DocumentBuilder(doc);
  7108. //获取word里所有表格
  7109. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7110. //获取所填表格的序数
  7111. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7112. var rowStart = tableOne.Rows[0]; //获取第1行
  7113. //循环赋值
  7114. for (int i = 0; i < list.Count; i++)
  7115. {
  7116. builder.MoveToCell(0, i + 1, 0, 0);
  7117. builder.Write(list[i].Name.ToString());
  7118. builder.MoveToCell(0, i + 1, 1, 0);
  7119. builder.Write(list[i].Sex.ToString());
  7120. builder.MoveToCell(0, i + 1, 2, 0);
  7121. builder.Write(list[i].DOB.ToString());
  7122. builder.MoveToCell(0, i + 1, 3, 0);
  7123. builder.Write(list[i].Job.ToString());
  7124. }
  7125. //删除多余行
  7126. while (tableOne.Rows.Count > list.Count + 1)
  7127. {
  7128. tableOne.Rows.RemoveAt(list.Count + 1);
  7129. }
  7130. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7131. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  7132. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  7133. doc.Save(filePath);
  7134. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  7135. return Ok(JsonView(true, "操作成功!", Url));
  7136. }
  7137. else
  7138. {
  7139. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  7140. }
  7141. }
  7142. catch (Exception ex)
  7143. {
  7144. return Ok(JsonView(false, ex.Message));
  7145. throw;
  7146. }
  7147. }
  7148. #endregion
  7149. #region 团组经理模块 出入境费用
  7150. /// <summary>
  7151. /// 团组模块 - 出入境费用 - 省份基础数据源
  7152. /// </summary>
  7153. /// <returns></returns>
  7154. [HttpGet]
  7155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7156. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  7157. {
  7158. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  7159. }
  7160. /// <summary>
  7161. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  7162. /// </summary>
  7163. /// <param name="dto"></param>
  7164. /// <returns></returns>
  7165. [HttpPost]
  7166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7167. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  7168. {
  7169. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  7170. var groupNamFirst = groupNameData.FirstOrDefault();
  7171. //SetDataInfoView
  7172. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7173. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7174. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7175. //验证城市归属并给默认值
  7176. int provinceId = 122;
  7177. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  7178. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7179. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7180. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7181. return Ok(JsonView(true, "查询成功!", new
  7182. {
  7183. GroupNameData = groupNameData,
  7184. CurrencyData = _CurrencyData,
  7185. WordTypeData = wordTypeData,
  7186. ExcelTypeData = excelTypeData,
  7187. CurrencyInit = _currencyInfos,
  7188. ViewPermissionData = viewPermissionData
  7189. }));
  7190. }
  7191. /// <summary>
  7192. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  7193. /// </summary>
  7194. /// <returns></returns>
  7195. [HttpGet("{provinceId}")]
  7196. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7197. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  7198. {
  7199. //验证城市归属并给默认值
  7200. if (provinceId < 1) provinceId = 122;
  7201. /*
  7202. * 122 四川
  7203. * 108 贵州
  7204. * 103 重庆
  7205. * 132 云南
  7206. */
  7207. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7208. return Ok(JsonView(true, "查询成功!", new
  7209. {
  7210. WordTypeData = wordTypeData,
  7211. ExcelTypeData = excelTypeData,
  7212. }));
  7213. }
  7214. /// <summary>
  7215. /// 团组模块 - 出入境费用
  7216. /// 实时汇率 tips
  7217. /// 签证费用 tips
  7218. /// 机票费用 tips
  7219. /// </summary>
  7220. /// <returns></returns>
  7221. [HttpPost]
  7222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7223. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  7224. {
  7225. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  7226. //默认币种显示
  7227. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  7228. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  7229. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  7230. return Ok(JsonView(true, "查询成功!", new
  7231. {
  7232. //GroupNameData = groupNameData.Data,
  7233. visaData = visaData.Data,
  7234. airData,
  7235. reteInfos
  7236. }));
  7237. }
  7238. /// <summary>
  7239. /// 团组模块 - 出入境费用 - Info
  7240. /// </summary>
  7241. /// <param name="dto"></param>
  7242. /// <returns></returns>
  7243. [HttpPost]
  7244. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  7245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7246. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  7247. {
  7248. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7249. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7250. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  7251. }
  7252. /// <summary>
  7253. /// 团组模块 - 出入境费用 - 设置view权限
  7254. /// </summary>
  7255. /// <returns></returns>
  7256. [HttpPost]
  7257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7258. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  7259. {
  7260. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7261. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7262. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7263. var permissions = new List<Grp_EnterExitCostPermission>();
  7264. foreach (var userId in dto.UserIds)
  7265. {
  7266. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  7267. }
  7268. if (permissions.Any())
  7269. {
  7270. _sqlSugar.BeginTran();
  7271. try
  7272. {
  7273. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  7274. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7275. if (result < 1)
  7276. {
  7277. _sqlSugar.RollbackTran();
  7278. return Ok(JsonView(false));
  7279. }
  7280. }
  7281. catch (Exception ex)
  7282. {
  7283. _sqlSugar.RollbackTran();
  7284. return Ok(JsonView(false, ex.Message));
  7285. }
  7286. _sqlSugar.CommitTran();
  7287. return Ok(JsonView(true));
  7288. }
  7289. return Ok(JsonView(false));
  7290. }
  7291. /// <summary>
  7292. /// 团组模块 - 出入境费用 - Add And Update
  7293. /// </summary>
  7294. /// <returns></returns>
  7295. [HttpPost]
  7296. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  7297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7298. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  7299. {
  7300. try
  7301. {
  7302. var rateRecords = new List<RateRecordInfo>();
  7303. #region 汇率保存前存储
  7304. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  7305. if (info != null)
  7306. {
  7307. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  7308. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  7309. {
  7310. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  7311. {
  7312. CurrencyCode = x.CurrencyCode,
  7313. CurrencyName = x.CurrencyName,
  7314. UpdatePreRate = x.Rate,
  7315. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  7316. }).ToList();
  7317. }
  7318. else
  7319. {
  7320. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  7321. {
  7322. CurrencyCode = x.CurrencyCode,
  7323. CurrencyName = x.CurrencyName,
  7324. UpdatePreRate = 0.00M,
  7325. UpdateBreRate = x.Rate
  7326. }).ToList();
  7327. }
  7328. }
  7329. else
  7330. {
  7331. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  7332. {
  7333. CurrencyCode = x.CurrencyCode,
  7334. CurrencyName = x.CurrencyName,
  7335. UpdatePreRate = 0.00M,
  7336. UpdateBreRate = x.Rate
  7337. }).ToList();
  7338. }
  7339. #endregion
  7340. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7341. if (dto.DayOtherPriceData.Any())
  7342. {
  7343. var inserList = dto.DayOtherPriceData
  7344. .Where(x => x.Id == 0)
  7345. .Select(x => new Grp_DayOtherPrice
  7346. {
  7347. Cost = x.Cost,
  7348. Id = x.Id,
  7349. CreateTime = DateTime.Now,
  7350. CreateUserId = dto.UserId,
  7351. Currency = x.Currency,
  7352. Diid = x.DiId,
  7353. Index = x.Index,
  7354. IsDel = 0,
  7355. SetDataId = x.SetDataId,
  7356. SubTotal = x.SubTotal,
  7357. Remark = x.Remark
  7358. })
  7359. .ToList();
  7360. var updateList = dto.DayOtherPriceData
  7361. .Where(x => x.Id != 0)
  7362. .Select(x => new Grp_DayOtherPrice
  7363. {
  7364. Cost = x.Cost,
  7365. Id = x.Id,
  7366. CreateTime = DateTime.Now,
  7367. CreateUserId = dto.UserId,
  7368. Currency = x.Currency,
  7369. Diid = x.DiId,
  7370. Index = x.Index,
  7371. IsDel = 0,
  7372. SetDataId = x.SetDataId,
  7373. SubTotal = x.SubTotal,
  7374. Remark = x.Remark
  7375. })
  7376. .ToList();
  7377. //添加
  7378. _sqlSugar.BeginTran();
  7379. if (inserList.Any())
  7380. {
  7381. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  7382. }
  7383. if (updateList.Any())
  7384. {
  7385. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  7386. }
  7387. _sqlSugar.CommitTran();
  7388. }
  7389. if (data.Code != 0)
  7390. {
  7391. return Ok(JsonView(false, data.Msg));
  7392. }
  7393. //生成默认文件pdf并且通知人员
  7394. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7395. {
  7396. DiId = dto.DiId,
  7397. ExportType = 1,
  7398. SubTypeId = 1005
  7399. }, "pdf");
  7400. //发送通知
  7401. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7402. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7403. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  7404. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  7405. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7406. //汇率信息记录
  7407. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7408. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  7409. //汇率验证、反推
  7410. (bool isSendMsg, string msgContent, List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  7411. if (isSendMsg)
  7412. {
  7413. //消息推送
  7414. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId, dto.UserId, msgContent);
  7415. }
  7416. #region //日志汇率记录
  7417. //按照已使用币种记录
  7418. if (checkCurrencys != null && checkCurrencys.Count > 0)
  7419. {
  7420. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  7421. //汇率记录中加入实时汇率
  7422. if (liveRates != null && liveRates.Count > 0)
  7423. {
  7424. foreach (var item in rateRecords)
  7425. {
  7426. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  7427. }
  7428. }
  7429. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  7430. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  7431. var logContent = new StringBuilder();
  7432. foreach (var item in rateRecords)
  7433. {
  7434. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  7435. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  7436. logContent.AppendLine(msg);
  7437. }
  7438. _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());
  7439. }
  7440. #endregion
  7441. return Ok(JsonView(true, data.Msg, data.Data));
  7442. }
  7443. catch (Exception ex)
  7444. {
  7445. return Ok(JsonView(false, ex.Message));
  7446. }
  7447. }
  7448. /// <summary>
  7449. /// 团组模块 - 出入境费用 - Confirm 费用
  7450. /// </summary>
  7451. /// <returns></returns>
  7452. [HttpPost]
  7453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7454. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  7455. {
  7456. //TODO:测试完毕需把对应的用户ID更改
  7457. //1、数据表添加字段
  7458. //2、更改字段接口()
  7459. var _view = await _enterExitCostRep.ConfirmCost(dto);
  7460. //3、确认成功 给财务发送消息
  7461. if (_view.Code == 200)
  7462. {
  7463. if (dto.Type == 1)
  7464. {
  7465. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  7466. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  7467. }
  7468. }
  7469. return Ok(_view);
  7470. }
  7471. /// <summary>
  7472. /// 团组模块 - 出入境费用 - File download
  7473. /// </summary>
  7474. /// <param name="dto"></param>
  7475. /// <returns></returns>
  7476. [HttpPost]
  7477. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  7478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7479. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  7480. {
  7481. try
  7482. {
  7483. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7484. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7485. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7486. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7487. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7488. 3 团组成员名单 1 团组成员名单", ""));
  7489. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  7490. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  7491. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  7492. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  7493. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7494. //数据源
  7495. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  7496. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  7497. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  7498. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  7499. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  7500. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  7501. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  7502. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  7503. .Select((x, a, b) => new
  7504. {
  7505. x.Index,
  7506. itemName = a.Name,
  7507. CurrencyStr = b.Name,
  7508. x.Cost,
  7509. x.SubTotal,
  7510. x.Remark
  7511. })
  7512. .OrderBy((x) => x.Index)
  7513. .ToList(); //其他款项费用
  7514. var peiceItemCurrencys = new List<string>();
  7515. if (_DayAndCosts.Any())
  7516. {
  7517. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7518. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7519. }
  7520. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7521. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7522. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7523. {
  7524. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7525. }
  7526. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7527. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  7528. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  7529. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  7530. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  7531. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  7532. .Select((tcl, dc, cc) => new ClientInfo
  7533. {
  7534. LastName = dc.LastName,
  7535. FirstName = dc.FirstName,
  7536. Sex = dc.Sex,
  7537. Birthday = dc.BirthDay,
  7538. Company = cc.CompanyFullName,
  7539. Job = dc.Job
  7540. })
  7541. .ToList();
  7542. foreach (var item in DeleClientList)
  7543. {
  7544. EncryptionProcessor.DecryptProperties(item);
  7545. }
  7546. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  7547. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7548. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7549. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7550. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  7551. if (dto.ExportType == 1) //明细表
  7552. {
  7553. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7554. {
  7555. //获取模板
  7556. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  7557. //载入模板
  7558. var doc = new Document(tempPath);
  7559. var builder = new DocumentBuilder(doc);
  7560. var dic = new Dictionary<string, string>();
  7561. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  7562. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  7563. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  7564. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  7565. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  7566. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  7567. //境内费用(其他费用)
  7568. if (_EnterExitCosts.ChoiceOne == 1)
  7569. {
  7570. string row1_1 = "";
  7571. if (_EnterExitCosts.Visa > 0)
  7572. {
  7573. //insidePayTotal += _EnterExitCosts.Visa;
  7574. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 元/人";
  7575. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  7576. //{
  7577. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  7578. //}
  7579. }
  7580. string row1_2 = "";
  7581. if (_EnterExitCosts.YiMiao > 0)
  7582. {
  7583. //insidePayTotal += _EnterExitCosts.YiMiao;
  7584. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 元/人";
  7585. }
  7586. if (_EnterExitCosts.HeSuan > 0)
  7587. {
  7588. //insidePayTotal += _EnterExitCosts.HeSuan;
  7589. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 元/人";
  7590. }
  7591. if (_EnterExitCosts.Service > 0)
  7592. {
  7593. //insidePayTotal += _EnterExitCosts.Service;
  7594. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 元/人";
  7595. }
  7596. string row1_3 = "";
  7597. if (_EnterExitCosts.Safe > 0)
  7598. {
  7599. //insidePayTotal += _EnterExitCosts.Safe;
  7600. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 元/人";
  7601. }
  7602. if (_EnterExitCosts.Ticket > 0)
  7603. {
  7604. //insidePayTotal += _EnterExitCosts.Ticket;
  7605. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 元/人";
  7606. }
  7607. string row1 = "";
  7608. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  7609. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  7610. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  7611. row1 += $"备注:{_EnterExitCosts.Remark}";
  7612. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  7613. dic.Add("Row1Str", row1);
  7614. }
  7615. string airTotalStr = string.Empty,
  7616. airPriceStr = string.Empty;
  7617. //经济舱
  7618. if (_EnterExitCosts.SumJJC == 1)
  7619. {
  7620. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  7621. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  7622. }
  7623. //公务舱
  7624. if (_EnterExitCosts.SumGWC == 1)
  7625. {
  7626. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  7627. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  7628. }
  7629. //头等舱
  7630. if (_EnterExitCosts.SumTDC == 1)
  7631. {
  7632. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  7633. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  7634. }
  7635. //汇率描述
  7636. string rateStr = "";
  7637. if (peiceItemCurrencyInfos.Any())
  7638. {
  7639. rateStr = "\r\n汇率描述:";
  7640. foreach (var item in peiceItemCurrencyInfos)
  7641. {
  7642. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  7643. }
  7644. }
  7645. string twoItemRemark = "备注:";
  7646. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7647. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7648. dic.Add("AirTotalStr", airTotalStr);
  7649. dic.Add("AirPriceStr", airPriceStr);
  7650. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7651. dic.Add("TwoItemRemark", twoItemRemark);
  7652. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7653. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7654. int table1Row = 0,
  7655. table2Row = 0,
  7656. table3Row = 0,
  7657. table4Row = 0,
  7658. table5Row = 0;
  7659. //住宿费
  7660. if (_EnterExitCosts.ChoiceThree == 1)
  7661. {
  7662. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7663. table1Row = dac1.Count;
  7664. #region 填充word表格内容
  7665. for (int i = 0; i < dac1.Count; i++)
  7666. {
  7667. Grp_DayAndCost dac = dac1[i];
  7668. if (dac == null) continue;
  7669. builder.MoveToCell(0, i, 0, 0);
  7670. builder.Write("第" + dac.Days.ToString() + "晚:");
  7671. builder.MoveToCell(0, i, 1, 0);
  7672. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7673. //builder.Write(dac.Place == null ? "" : dac.Place);
  7674. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7675. builder.MoveToCell(0, i, 2, 0);
  7676. builder.Write("费用标准:");
  7677. string curr = "";
  7678. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7679. if (currData != null)
  7680. {
  7681. curr = currData.Name;
  7682. }
  7683. builder.MoveToCell(0, i, 3, 0);
  7684. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7685. builder.MoveToCell(0, i, 4, 0);
  7686. builder.Write("费用小计:");
  7687. builder.MoveToCell(0, i, 5, 0);
  7688. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7689. }
  7690. #endregion
  7691. }
  7692. else dic.Add("SubZS", "0.00");
  7693. //删除多余行
  7694. while (table1.Rows.Count > table1Row)
  7695. {
  7696. table1.Rows.RemoveAt(table1Row);
  7697. }
  7698. //伙食费
  7699. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7700. if (_EnterExitCosts.ChoiceFour == 1)
  7701. {
  7702. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7703. table2Row = dac2.Count;
  7704. #region 填充word表格内容
  7705. for (int i = 0; i < dac2.Count; i++)
  7706. {
  7707. Grp_DayAndCost dac = dac2[i];
  7708. if (dac == null) continue;
  7709. builder.MoveToCell(1, i, 0, 0);
  7710. builder.Write("第" + dac.Days.ToString() + "天:");
  7711. builder.MoveToCell(1, i, 1, 0);
  7712. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7713. builder.MoveToCell(1, i, 2, 0);
  7714. builder.Write("费用标准:");
  7715. string curr = "";
  7716. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7717. if (currData != null)
  7718. {
  7719. curr = currData.Name;
  7720. }
  7721. builder.MoveToCell(1, i, 3, 0);
  7722. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7723. builder.MoveToCell(1, i, 4, 0);
  7724. builder.Write("费用小计:");
  7725. builder.MoveToCell(1, i, 5, 0);
  7726. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7727. }
  7728. #endregion
  7729. }
  7730. else dic.Add("SubHS", "0.00");
  7731. //删除多余行
  7732. while (table2.Rows.Count > table2Row)
  7733. {
  7734. table2.Rows.RemoveAt(table2Row);
  7735. }
  7736. //公杂费
  7737. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7738. if (_EnterExitCosts.ChoiceFive == 1)
  7739. {
  7740. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7741. table3Row = dac3.Count;
  7742. #region 填充word表格内容
  7743. for (int i = 0; i < dac3.Count; i++)
  7744. {
  7745. Grp_DayAndCost dac = dac3[i];
  7746. if (dac == null) continue;
  7747. builder.MoveToCell(2, i, 0, 0);
  7748. builder.Write("第" + dac.Days.ToString() + "天:");
  7749. builder.MoveToCell(2, i, 1, 0);
  7750. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7751. builder.MoveToCell(2, i, 2, 0);
  7752. builder.Write("费用标准:");
  7753. string curr = "";
  7754. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7755. if (currData != null)
  7756. {
  7757. curr = currData.Name;
  7758. }
  7759. builder.MoveToCell(2, i, 3, 0);
  7760. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7761. builder.MoveToCell(2, i, 4, 0);
  7762. builder.Write("费用小计:");
  7763. builder.MoveToCell(2, i, 5, 0);
  7764. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7765. }
  7766. //删除多余行
  7767. while (table3.Rows.Count > table3Row)
  7768. {
  7769. table3.Rows.RemoveAt(table3Row);
  7770. }
  7771. #endregion
  7772. }
  7773. else dic.Add("SubGZF", "0.00");
  7774. //删除多余行
  7775. while (table3.Rows.Count > table3Row)
  7776. {
  7777. table3.Rows.RemoveAt(table3Row);
  7778. }
  7779. //培训费
  7780. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7781. if (_EnterExitCosts.ChoiceSix == 1)
  7782. {
  7783. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  7784. dic.Add("SubPX", pxStr);
  7785. table4Row = dac4.Count;
  7786. #region 填充word表格内容
  7787. for (int i = 0; i < dac4.Count; i++)
  7788. {
  7789. Grp_DayAndCost dac = dac4[i];
  7790. if (dac == null) continue;
  7791. builder.MoveToCell(3, i, 0, 0);
  7792. builder.Write("第" + dac.Days.ToString() + "天:");
  7793. builder.MoveToCell(3, i, 1, 0);
  7794. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7795. builder.MoveToCell(3, i, 2, 0);
  7796. builder.Write("费用标准:");
  7797. string curr = "";
  7798. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7799. if (currData != null)
  7800. {
  7801. curr = currData.Name;
  7802. }
  7803. builder.MoveToCell(3, i, 3, 0);
  7804. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7805. builder.MoveToCell(3, i, 4, 0);
  7806. builder.Write("费用小计:");
  7807. builder.MoveToCell(3, i, 5, 0);
  7808. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7809. }
  7810. #endregion
  7811. }
  7812. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  7813. //删除多余行
  7814. while (table4.Rows.Count > table4Row)
  7815. {
  7816. table4.Rows.RemoveAt(table4Row);
  7817. }
  7818. //其他费用
  7819. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7820. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7821. {
  7822. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  7823. dic.Add("titleQi", qtStr);
  7824. table5Row = dac5.Count;
  7825. #region 填充word表格内容
  7826. for (int i = 0; i < dac5.Count; i++)
  7827. {
  7828. var dac = dac5[i];
  7829. if (dac == null) continue;
  7830. builder.MoveToCell(4, i, 0, 0);
  7831. builder.Write("第" + dac.Index.ToString() + "项:");
  7832. builder.MoveToCell(4, i, 1, 0);
  7833. builder.Write(dac.itemName);
  7834. builder.MoveToCell(4, i, 2, 0);
  7835. builder.Write("费用标准:");
  7836. builder.MoveToCell(4, i, 3, 0);
  7837. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7838. builder.MoveToCell(4, i, 4, 0);
  7839. builder.Write("费用小计:");
  7840. builder.MoveToCell(4, i, 5, 0);
  7841. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7842. builder.MoveToCell(4, i, 6, 0);
  7843. builder.Write("备注:");
  7844. builder.MoveToCell(4, i, 7, 0);
  7845. builder.Write(dac.Remark);
  7846. }
  7847. #endregion
  7848. }
  7849. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7850. //删除多余行
  7851. while (table5.Rows.Count > table5Row)
  7852. {
  7853. table5.Rows.RemoveAt(table5Row);
  7854. }
  7855. //加上其他费用
  7856. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7857. decimal subJJC = 0.00M,
  7858. subGWC = 0.00M,
  7859. subTDC = 0.00M;
  7860. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7861. string totalLabel = string.Format("全部费用总计:");
  7862. //经济舱
  7863. if (_EnterExitCosts.SumJJC == 1)
  7864. {
  7865. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7866. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  7867. }
  7868. //公务舱
  7869. if (_EnterExitCosts.SumGWC == 1)
  7870. {
  7871. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7872. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  7873. }
  7874. //头等舱
  7875. if (_EnterExitCosts.SumTDC == 1)
  7876. {
  7877. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7878. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  7879. }
  7880. //TotalLabel
  7881. dic.Add("TotalLabel", totalLabel);
  7882. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7883. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7884. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7885. #region 填充word模板书签内容
  7886. foreach (var key in dic.Keys)
  7887. {
  7888. Bookmark bookmark = doc.Range.Bookmarks[key];
  7889. if (bookmark != null)
  7890. {
  7891. builder.MoveToBookmark(key);
  7892. builder.Write(dic[key]);
  7893. }
  7894. }
  7895. #endregion
  7896. #region 设置页眉
  7897. string userLabel = string.Empty;
  7898. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7899. if (currUserInfo != null)
  7900. {
  7901. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  7902. if (userInfo != null)
  7903. {
  7904. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  7905. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  7906. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  7907. }
  7908. }
  7909. //设置页脚
  7910. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  7911. #endregion
  7912. var guid = CommonFun.GUID.Substring(0, 8);
  7913. //文件名
  7914. string strFileName = CommonFun.ValidFileName($"{_DelegationInfo.TeamName}出入境费用{guid}.docx");
  7915. AsposeHelper.removewatermark_v2180();
  7916. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7917. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7918. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7919. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7920. }
  7921. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7922. {
  7923. //获取模板
  7924. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7925. //载入模板
  7926. var doc = new Document(tempPath);
  7927. var builder = new DocumentBuilder(doc);
  7928. var dic = new Dictionary<string, string>();
  7929. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7930. {
  7931. var list = new List<string>();
  7932. try
  7933. {
  7934. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7935. foreach (var item in spilitArr)
  7936. {
  7937. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7938. var depCode = spDotandEmpty[2].Substring(0, 3);
  7939. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7940. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7941. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7942. list.Add(depName);
  7943. list.Add(arrName);
  7944. }
  7945. list = list.Distinct().ToList();
  7946. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7947. }
  7948. catch (Exception)
  7949. {
  7950. dic.Add("ReturnCode", "行程录入不正确!");
  7951. }
  7952. }
  7953. else
  7954. {
  7955. dic.Add("ReturnCode", "未录入行程!");
  7956. }
  7957. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7958. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7959. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7960. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7961. {
  7962. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7963. dic.Add("Day", sp.Days.ToString());
  7964. }
  7965. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7966. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7967. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7968. //dic.Add("Names", Names);
  7969. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7970. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7971. decimal dac1totalPrice = 0.00M;
  7972. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7973. foreach (var dac in dac1)
  7974. {
  7975. if (dac.SubTotal == 0.00M)
  7976. {
  7977. continue;
  7978. }
  7979. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7980. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7981. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7982. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7983. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7984. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7985. builder.Write(currency);//币种
  7986. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7987. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7988. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7989. builder.Write("");//人数
  7990. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7991. builder.Write("");//天数
  7992. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7993. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7994. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7995. decimal rate = 0.00M;
  7996. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7997. builder.Write(rate.ToString("#0.0000"));//汇率
  7998. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7999. decimal rbmPrice = dac.SubTotal;
  8000. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8001. accommodationStartIndex++;
  8002. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8003. }
  8004. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8005. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8006. {
  8007. table1.Rows.RemoveAt(i - 1);
  8008. foodandotherStartIndex--;
  8009. }
  8010. if (dac2.Count == dac3.Count)//国家 币种 金额
  8011. {
  8012. for (int i = 0; i < dac2.Count; i++)
  8013. {
  8014. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8015. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8016. }
  8017. }
  8018. decimal dac2totalPrice = 0.00M;
  8019. foreach (var dac in dac2)
  8020. {
  8021. if (dac.SubTotal == 0)
  8022. {
  8023. continue;
  8024. }
  8025. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8026. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8027. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8028. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8029. builder.Write(currency);//币种
  8030. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8031. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8032. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8033. builder.Write("");//人数
  8034. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8035. builder.Write("");//天数
  8036. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8037. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8038. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8039. decimal rate = 0.00M;
  8040. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8041. builder.Write(rate.ToString("#0.0000"));//汇率
  8042. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8043. decimal rbmPrice = dac.SubTotal;
  8044. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8045. foodandotherStartIndex++;
  8046. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8047. }
  8048. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8049. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8050. {
  8051. table1.Rows.RemoveAt(i - 1);
  8052. }
  8053. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8054. string otherFeeStr = "";
  8055. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  8056. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  8057. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  8058. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8059. foreach (var otherInfo in dac5)
  8060. {
  8061. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8062. }
  8063. #endregion
  8064. if (otherFeeStr.Length > 0)
  8065. {
  8066. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8067. otherFeeStr = $"({otherFeeStr})";
  8068. dic.Add("OtherFeeStr", otherFeeStr);
  8069. }
  8070. //总计
  8071. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8072. //国际旅费
  8073. string outsideAir = string.Empty;
  8074. string allPriceAir = string.Empty;
  8075. if (_EnterExitCosts.SumJJC == 1)
  8076. {
  8077. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8078. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8079. }
  8080. if (_EnterExitCosts.SumGWC == 1)
  8081. {
  8082. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8083. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8084. }
  8085. if (_EnterExitCosts.SumTDC == 1)
  8086. {
  8087. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8088. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8089. }
  8090. dic.Add("InTravelPrice", $"({outsideAir})");
  8091. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8092. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8093. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8094. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8095. foreach (var key in dic.Keys)
  8096. {
  8097. builder.MoveToBookmark(key);
  8098. builder.Write(dic[key]);
  8099. }
  8100. //模板文件名
  8101. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8102. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8103. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8104. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8105. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8106. }
  8107. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8108. {
  8109. //获取模板
  8110. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8111. //载入模板
  8112. var designer = new WorkbookDesigner
  8113. {
  8114. Workbook = new Workbook(tempPath)
  8115. };
  8116. var dic = new Dictionary<string, string>();
  8117. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  8118. {
  8119. var list = new List<string>();
  8120. try
  8121. {
  8122. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  8123. foreach (var item in spilitArr)
  8124. {
  8125. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  8126. var depCode = spDotandEmpty[2].Substring(0, 3);
  8127. var arrCode = spDotandEmpty[2].Substring(3, 3);
  8128. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  8129. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  8130. list.Add(depName);
  8131. list.Add(arrName);
  8132. }
  8133. list = list.Distinct().ToList();
  8134. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  8135. }
  8136. catch (Exception)
  8137. {
  8138. dic.Add("ReturnCode", "行程录入不正确!");
  8139. }
  8140. }
  8141. else
  8142. {
  8143. dic.Add("ReturnCode", "未录入行程!");
  8144. }
  8145. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  8146. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8147. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8148. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  8149. {
  8150. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8151. dic.Add("Day", sp.Days.ToString());
  8152. }
  8153. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8154. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  8155. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8156. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  8157. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  8158. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  8159. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  8160. designer.SetDataSource("Name", Names);
  8161. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  8162. designer.SetDataSource("Day", dic["Day"] + "天");
  8163. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  8164. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  8165. int startIndex = 10;
  8166. const int startIndexcopy = 10;
  8167. if (dac2.Count == dac3.Count)//国家 币种 金额
  8168. {
  8169. for (int i = 0; i < dac2.Count; i++)
  8170. {
  8171. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8172. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8173. }
  8174. }
  8175. var dtdac1 = new DataTable();
  8176. var place = new List<string>();
  8177. dtdac1.Columns.AddRange(new DataColumn[] {
  8178. new(){ ColumnName = "city"},
  8179. new(){ ColumnName = "curr"},
  8180. new(){ ColumnName = "criterion"},
  8181. new(){ ColumnName = "number",DataType = typeof(int)},
  8182. new(){ ColumnName = "day",DataType = typeof(int)},
  8183. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  8184. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  8185. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8186. });
  8187. var dtdac2 = new DataTable();
  8188. dtdac2.Columns.AddRange(new DataColumn[] {
  8189. new(){ ColumnName = "city"},
  8190. new(){ ColumnName = "curr"},
  8191. new(){ ColumnName = "criterion"},
  8192. new(){ ColumnName = "number",DataType = typeof(int)},
  8193. new(){ ColumnName = "day",DataType = typeof(int)},
  8194. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  8195. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  8196. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8197. });
  8198. dtdac1.TableName = "tb1";
  8199. dtdac2.TableName = "tb2";
  8200. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8201. foreach (var item in dac1)
  8202. {
  8203. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  8204. if (place.Contains(item.Place))
  8205. {
  8206. continue;
  8207. }
  8208. DataRow row = dtdac1.NewRow();
  8209. row["city"] = item.Place;
  8210. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8211. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8212. row["curr"] = currency;
  8213. row["rate"] = rate.ToString("#0.0000");
  8214. row["criterion"] = item.Cost.ToString("#0.00");
  8215. row["number"] = 1;
  8216. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8217. //row["costRMB"] = rbmPrice;
  8218. dtdac1.Rows.Add(row);
  8219. place.Add(item.Place);
  8220. }
  8221. place = new List<string>();
  8222. foreach (var item in dac2)
  8223. {
  8224. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  8225. if (place.Contains(item.Place))
  8226. {
  8227. continue;
  8228. }
  8229. DataRow row = dtdac2.NewRow();
  8230. row["city"] = item.Place;
  8231. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8232. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8233. row["curr"] = currency;
  8234. row["rate"] = rate.ToString("#0.0000");
  8235. row["criterion"] = item.Cost.ToString("#0.00");
  8236. row["number"] = 1;
  8237. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8238. //row["cost"] = item.SubTotal;
  8239. //row["costRMB"] = rbmPrice;
  8240. dtdac2.Rows.Add(row);
  8241. place.Add(item.Place);
  8242. //dac2totalPrice += rbmPrice;
  8243. }
  8244. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8245. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8246. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8247. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8248. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8249. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8250. string cell4Str1 = string.Empty;
  8251. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8252. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8253. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8254. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8255. string cellStr = $" 5.其他费用(";
  8256. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8257. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8258. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8259. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8260. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8261. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8262. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8263. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8264. foreach (var otherInfo in dac5)
  8265. {
  8266. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8267. }
  8268. #endregion
  8269. if (cellStr.Length > 8)
  8270. {
  8271. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8272. }
  8273. cellStr += ")";
  8274. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8275. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8276. decimal pxFee = dac4.Sum(it => it.Cost);
  8277. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8278. string celllastStr1 = "";
  8279. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8280. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8281. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8282. celllastStr1 += $",国际旅费 元";
  8283. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8284. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8285. designer.SetDataSource("cell4Str", cell4Str);
  8286. designer.SetDataSource("cellStr", cellStr);
  8287. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8288. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8289. designer.SetDataSource("celllastStr", celllastStr);
  8290. Workbook wb = designer.Workbook;
  8291. var sheet = wb.Worksheets[0];
  8292. //绑定datatable数据集
  8293. designer.SetDataSource(dtdac1);
  8294. designer.SetDataSource(dtdac2);
  8295. designer.Process();
  8296. var rowStart = dtdac1.Rows.Count;
  8297. while (rowStart > 0)
  8298. {
  8299. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8300. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8301. startIndex++;
  8302. rowStart--;
  8303. }
  8304. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8305. startIndex += 1; //总计行
  8306. rowStart = dtdac2.Rows.Count;
  8307. while (rowStart > 0)
  8308. {
  8309. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8310. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8311. startIndex++;
  8312. rowStart--;
  8313. }
  8314. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8315. wb.CalculateFormula(true);
  8316. //模板文件名
  8317. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8318. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8319. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8320. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8321. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8322. }
  8323. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8324. {
  8325. //获取模板
  8326. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8327. //载入模板
  8328. var doc = new Document(tempPath);
  8329. var builder = new DocumentBuilder(doc);
  8330. var dic = new Dictionary<string, string>
  8331. {
  8332. { "GroupName", _DelegationInfo.TeamName },
  8333. { "ClientUnit", _DelegationInfo.ClientUnit }
  8334. };
  8335. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8336. string missionLeaderJob = "";//负责人job
  8337. //int groupNumber = 0; //团人数
  8338. if (DeleClientList.Count > 0)
  8339. {
  8340. missionLeader = DeleClientList[0]?.Name ?? "";
  8341. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  8342. }
  8343. dic.Add("MissionLeader", missionLeader); //团负责人
  8344. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  8345. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  8346. #region MyRegion
  8347. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  8348. //{
  8349. // List<string> list = new List<string>();
  8350. // try
  8351. // {
  8352. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  8353. // foreach (var item in spilitArr)
  8354. // {
  8355. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  8356. // var depCode = spDotandEmpty[2].Substring(0, 3);
  8357. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  8358. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  8359. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  8360. // list.Add(depName);
  8361. // list.Add(arrName);
  8362. // }
  8363. // list = list.Distinct().ToList();
  8364. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  8365. // }
  8366. // catch (Exception)
  8367. // {
  8368. // dic.Add("ReturnCode", "行程录入不正确!");
  8369. // }
  8370. //}
  8371. //else
  8372. //{
  8373. // dic.Add("ReturnCode", "未录入行程!");
  8374. //}
  8375. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  8376. dic.Add("ReturnCode", string.Join("、", countrys));
  8377. #endregion
  8378. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  8379. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8380. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8381. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  8382. //{
  8383. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8384. // dic.Add("Day", sp.Days.ToString());
  8385. //}
  8386. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  8387. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8388. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8389. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8390. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8391. //培训人员名单
  8392. int cultivateRowIndex = 7;
  8393. foreach (var item in DeleClientList)
  8394. {
  8395. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  8396. builder.Write(item.Name);
  8397. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  8398. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  8399. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  8400. string birthDay = "";
  8401. if (item.Birthday != null)
  8402. {
  8403. DateTime dt = Convert.ToDateTime(item.Birthday);
  8404. birthDay = $"{dt.Year}.{dt.Month}";
  8405. }
  8406. builder.Write(birthDay);
  8407. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  8408. builder.Write(item.Company);
  8409. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  8410. builder.Write(item.Job);
  8411. cultivateRowIndex++;
  8412. }
  8413. //删除多余行
  8414. //cultivateRowIndex -= 2;
  8415. int delRows = 10 + 7 - cultivateRowIndex;
  8416. if (delRows > 0)
  8417. {
  8418. for (int i = 0; i < delRows; i++)
  8419. {
  8420. table1.Rows.RemoveAt(cultivateRowIndex);
  8421. //cultivateRowIndex++;
  8422. }
  8423. }
  8424. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8425. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8426. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8427. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8428. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8429. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8430. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8431. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8432. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8433. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8434. //其他费用
  8435. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8436. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8437. //其他费用合计
  8438. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8439. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8440. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8441. //公务舱合计
  8442. //国际旅费
  8443. //string outsideJJ = "";
  8444. //string allPriceJJ = "";
  8445. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8446. {
  8447. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8448. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8449. }
  8450. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8451. {
  8452. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8453. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8454. }
  8455. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8456. {
  8457. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8458. dic.Add("AirFeeTotal", airFeeTotalStr);
  8459. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8460. dic.Add("FeeTotal", feeTotalStr);
  8461. }
  8462. foreach (var key in dic.Keys)
  8463. {
  8464. builder.MoveToBookmark(key);
  8465. builder.Write(dic[key]);
  8466. }
  8467. //模板文件名
  8468. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8469. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8470. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8471. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8472. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8473. }
  8474. }
  8475. else if (dto.ExportType == 2) //表格
  8476. {
  8477. //利用键值对存放数据
  8478. Dictionary<string, string> dic = new Dictionary<string, string>();
  8479. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8480. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8481. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8482. dic.Add("Day", sp.Days.ToString());
  8483. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8484. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  8485. {
  8486. //获取模板
  8487. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  8488. //载入模板
  8489. var doc = new Document(tempPath);
  8490. var builder = new DocumentBuilder(doc);
  8491. dic.Add("TeamName", _DelegationInfo.TeamName);
  8492. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  8493. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  8494. string missionLeaderName = "",
  8495. missionLeaderJob = "";
  8496. if (DeleClientList.Count > 0)
  8497. {
  8498. missionLeaderName = DeleClientList[0].Name;
  8499. missionLeaderJob = DeleClientList[0].Job;
  8500. }
  8501. dic.Add("MissionLeaderName", missionLeaderName);
  8502. dic.Add("MissionLeaderJob", missionLeaderJob);
  8503. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  8504. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  8505. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8506. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8507. int rowCount = 10;//总人数行
  8508. int startRowIndex = 7; //起始行
  8509. for (int i = 0; i < DeleClientList.Count; i++)
  8510. {
  8511. builder.MoveToCell(0, startRowIndex, 0, 0);
  8512. builder.Write(DeleClientList[i].Name); //出国人员姓名
  8513. builder.MoveToCell(0, startRowIndex, 1, 0);
  8514. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8515. builder.Write(sex);//性别
  8516. builder.MoveToCell(0, startRowIndex, 2, 0);
  8517. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  8518. builder.MoveToCell(0, startRowIndex, 3, 0);
  8519. builder.Write(DeleClientList[i].Company);//工作单位
  8520. builder.MoveToCell(0, startRowIndex, 4, 0);
  8521. builder.Write(DeleClientList[i].Job);//职务及级别
  8522. builder.MoveToCell(0, startRowIndex, 5, 0);
  8523. builder.Write("");//人员属性
  8524. builder.MoveToCell(0, startRowIndex, 6, 0);
  8525. builder.Write("");//上次出国时间
  8526. startRowIndex++;
  8527. }
  8528. int nullRow = rowCount - DeleClientList.Count;//空行
  8529. for (int i = 0; i < nullRow; i++)
  8530. {
  8531. table1.Rows.Remove(table1.Rows[startRowIndex]);
  8532. }
  8533. foreach (var key in dic.Keys)
  8534. {
  8535. builder.MoveToBookmark(key);
  8536. builder.Write(dic[key]);
  8537. }
  8538. //模板文件名
  8539. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  8540. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8541. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8542. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  8543. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  8544. }
  8545. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  8546. {
  8547. //获取模板
  8548. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  8549. //载入模板
  8550. var doc = new Document(tempPath);
  8551. var builder = new DocumentBuilder(doc);
  8552. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  8553. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  8554. dic.Add("Names", Names);
  8555. int accommodationRows = 12;
  8556. //int foodandotherRows = 12;
  8557. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  8558. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  8559. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8560. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8561. int accommodationStartIndex = 6;
  8562. decimal dac1totalPrice = 0.00M;
  8563. foreach (var dac in dac1)
  8564. {
  8565. if (dac.SubTotal == 0)
  8566. {
  8567. continue;
  8568. }
  8569. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8570. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8571. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8572. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  8573. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8574. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  8575. builder.Write(currency);//币种
  8576. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8577. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8578. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8579. builder.Write("");//人数
  8580. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8581. builder.Write("");//天数
  8582. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8583. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8584. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8585. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8586. builder.Write(rate.ToString("#0.0000"));//汇率
  8587. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8588. decimal rbmPrice = rate * dac.SubTotal;
  8589. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8590. accommodationStartIndex++;
  8591. dac1totalPrice += rbmPrice;
  8592. }
  8593. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8594. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8595. builder.Write("小计");
  8596. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8597. builder.Write(dac1totalPrice.ToString("#0.00"));
  8598. accommodationStartIndex++;
  8599. int nullRow = accommodationRows - dac1.Count;
  8600. //删除空行
  8601. //if (nullRow > 0)
  8602. //{
  8603. // int rowIndex = accommodationStartIndex;
  8604. // for (int i = 0; i < nullRow; i++)
  8605. // {
  8606. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  8607. // row.Remove();
  8608. // rowIndex++;
  8609. // }
  8610. //}
  8611. if (dac2.Count == dac3.Count)//国家 币种 金额
  8612. {
  8613. for (int i = 0; i < dac2.Count; i++)
  8614. {
  8615. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8616. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8617. }
  8618. }
  8619. int foodandotherStartIndex = 19;//
  8620. decimal dac2totalPrice = 0.00M;
  8621. foreach (var dac in dac2)
  8622. {
  8623. if (dac.SubTotal == 0)
  8624. {
  8625. continue;
  8626. }
  8627. //foodandotherStartIndex = 12;
  8628. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8629. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  8630. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8631. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  8632. builder.Write(currency);//币种
  8633. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8634. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8635. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8636. builder.Write("");//人数
  8637. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8638. builder.Write("");//天数
  8639. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8640. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8641. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8642. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8643. builder.Write(rate.ToString("#0.0000"));//汇率
  8644. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8645. decimal rbmPrice = rate * dac.SubTotal;
  8646. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8647. foodandotherStartIndex++;
  8648. dac2totalPrice += rbmPrice;
  8649. }
  8650. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8651. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8652. //删除空行
  8653. //if (dac2.Count < foodandotherRows)
  8654. //{
  8655. // while (table2.Rows.Count > dac2.Count)
  8656. // {
  8657. // table2.Rows.RemoveAt(dac2.Count);
  8658. // }
  8659. //}
  8660. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8661. string otherFeeStr = "";
  8662. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8663. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8664. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8665. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8666. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8667. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8668. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8669. foreach (var otherInfo in dac5)
  8670. {
  8671. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8672. }
  8673. #endregion
  8674. if (otherFeeStr.Length > 0)
  8675. {
  8676. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8677. otherFeeStr = $"({otherFeeStr})";
  8678. dic.Add("OtherFeeStr", otherFeeStr);
  8679. }
  8680. foreach (var key in dic.Keys)
  8681. {
  8682. builder.MoveToBookmark(key);
  8683. builder.Write(dic[key]);
  8684. }
  8685. //模板文件名
  8686. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8687. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8688. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8689. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8690. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8691. }
  8692. }
  8693. else if (dto.ExportType == 3)
  8694. {
  8695. if (dto.SubTypeId == 1) //团组成员名单
  8696. {
  8697. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  8698. //获取模板
  8699. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  8700. //载入模板
  8701. var doc = new Document(tempPath);
  8702. var builder = new DocumentBuilder(doc);
  8703. //获取word里所有表格
  8704. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8705. //获取所填表格的序数
  8706. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8707. var rowStart = tableOne.Rows[0]; //获取第1行
  8708. //循环赋值
  8709. for (int i = 0; i < DeleClientList.Count; i++)
  8710. {
  8711. builder.MoveToCell(0, i + 1, 0, 0);
  8712. builder.Write(DeleClientList[i].Name);
  8713. builder.MoveToCell(0, i + 1, 1, 0);
  8714. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8715. builder.Write(sex);
  8716. builder.MoveToCell(0, i + 1, 2, 0);
  8717. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  8718. builder.MoveToCell(0, i + 1, 3, 0);
  8719. builder.Write(DeleClientList[i].Company);
  8720. builder.MoveToCell(0, i + 1, 4, 0);
  8721. builder.Write(DeleClientList[i].Job);
  8722. }
  8723. //删除多余行
  8724. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  8725. {
  8726. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  8727. }
  8728. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  8729. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  8730. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  8731. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8732. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8733. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8734. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8735. }
  8736. }
  8737. return Ok(JsonView(400, "操作失败!", ""));
  8738. }
  8739. catch (Exception ex)
  8740. {
  8741. return Ok(JsonView(400, ex.Message, ""));
  8742. }
  8743. }
  8744. /// <summary>
  8745. /// 获取三公费用标准city
  8746. /// </summary>
  8747. /// <param name="placeData"></param>
  8748. /// <param name="nationalTravelFeeId"></param>
  8749. /// <returns></returns>
  8750. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8751. {
  8752. string _city = string.Empty;
  8753. if (placeData.Count < 1) return _city;
  8754. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8755. if (data == null) return _city;
  8756. string country = data.Country;
  8757. string city = data.City;
  8758. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8759. else _city = city;
  8760. return _city;
  8761. }
  8762. ///// <summary>
  8763. ///// 团组模块 - 出入境费用 - 明细表导出
  8764. ///// </summary>
  8765. ///// <returns></returns>
  8766. //[HttpPost]
  8767. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8768. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  8769. //{
  8770. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  8771. // if (data.Code != 0)
  8772. // {
  8773. // return Ok(JsonView(false, data.Msg));
  8774. // }
  8775. // return Ok(JsonView(true, data.Msg, data.Data));
  8776. //}
  8777. /// <summary>
  8778. /// 团组模块 - 出入境费用 - 一键清空
  8779. /// </summary>
  8780. /// <returns></returns>
  8781. [HttpPost]
  8782. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8784. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  8785. {
  8786. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  8787. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8788. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8789. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  8790. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8791. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  8792. .SetColumns(x => new Grp_DayOtherPrice
  8793. {
  8794. IsDel = 1,
  8795. DeleteUserId = dto.UserId,
  8796. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8797. })
  8798. .ExecuteCommandAsync();
  8799. if (_view.Code == 0)
  8800. {
  8801. return Ok(JsonView(true, "操作成功"));
  8802. }
  8803. return Ok(JsonView(false, "操作失败"));
  8804. }
  8805. /// <summary>
  8806. /// 团组模块 - 出入境费用 - 子项删除
  8807. /// </summary>
  8808. /// <returns></returns>
  8809. [HttpPost]
  8810. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8812. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  8813. {
  8814. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8815. if (data.Code != 0)
  8816. {
  8817. return Ok(JsonView(false, data.Msg));
  8818. }
  8819. return Ok(JsonView(true, "操作成功!", data.Data));
  8820. }
  8821. /// <summary>
  8822. /// 删除三公其他费用
  8823. /// </summary>
  8824. /// <param name="dto"></param>
  8825. /// <returns></returns>
  8826. [HttpPost]
  8827. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8828. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  8829. {
  8830. var jw = JsonView(false, "删除失败!");
  8831. var data = new Grp_DayOtherPrice()
  8832. {
  8833. Id = dto.Id,
  8834. IsDel = 1,
  8835. DeleteUserId = dto.DeleteUserId,
  8836. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8837. };
  8838. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8839. if (del > 0)
  8840. {
  8841. jw.Code = 200;
  8842. jw.Msg = "删除成功!";
  8843. }
  8844. return Ok(jw);
  8845. }
  8846. /// <summary>
  8847. /// 团组模块 - 出入境国家费用标准 List
  8848. /// </summary>
  8849. /// <returns></returns>
  8850. [HttpPost]
  8851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8852. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  8853. {
  8854. int provinceId = dto.ProvinceId;
  8855. if (provinceId < 1) provinceId = 122; //默认四川省数据
  8856. var nftData = await _sqlSugar
  8857. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  8858. JoinType.Left, ntf.Currency == sd1.Id,
  8859. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8860. JoinType.Left, ntf.ProvinceId == c.Id
  8861. ))
  8862. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8863. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  8864. {
  8865. Id = ntf.Id,
  8866. ProvinceId = ntf.ProvinceId,
  8867. ProvinceName = c.Name_CN,
  8868. Continent = ntf.Continent,
  8869. Country = ntf.Country,
  8870. City = ntf.City,
  8871. Currency = ntf.Currency,
  8872. CurrencyCode = sd1.Name,
  8873. CurrencyName = sd1.Remark,
  8874. RoomCost = ntf.RoomCost,
  8875. FoodCost = ntf.FoodCost,
  8876. PublicCost = ntf.PublicCost,
  8877. LastUpdateUserId = ntf.LastUpdateUserId,
  8878. LastUpdateUserName = u.CnName,
  8879. LastUpdateTime = ntf.LastUpdateTime
  8880. })
  8881. .ToListAsync();
  8882. return Ok(JsonView(true, "查询成功!", nftData));
  8883. }
  8884. /// <summary>
  8885. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  8886. /// </summary>
  8887. /// <returns></returns>
  8888. [HttpPost]
  8889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8890. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  8891. {
  8892. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  8893. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  8894. List<string> countryData = new List<string>();
  8895. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  8896. countryData = countryData.Distinct().ToList();
  8897. List<dynamic> dataSource = new List<dynamic>();
  8898. foreach (var item in countryData)
  8899. {
  8900. var cityData1 = new List<string>();
  8901. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  8902. var countryData2 = new
  8903. {
  8904. CountryName = item,
  8905. CityData = cityData1
  8906. };
  8907. if (!dataSource.Contains(countryData2))
  8908. {
  8909. dataSource.Add(countryData2);
  8910. }
  8911. }
  8912. return Ok(JsonView(true, "查询成功!", dataSource));
  8913. }
  8914. /// <summary>
  8915. /// 团组模块 - 出入境国家费用标准 Page List
  8916. /// </summary>
  8917. /// <returns></returns>
  8918. [HttpPost]
  8919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8920. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  8921. {
  8922. int portId = dto.PortType,
  8923. pageIndex = dto.PageIndex,
  8924. pageSize = dto.PageSize;
  8925. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8926. if (pageIndex == 0) pageIndex = 1;
  8927. if (pageSize == 0) pageSize = 10;
  8928. RefAsync<int> total = 0;
  8929. var nationalTravelFeeData = await _sqlSugar
  8930. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  8931. JoinType.Left, ntf.Currency == sd1.Id,
  8932. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8933. JoinType.Left, ntf.ProvinceId == sd2.Id
  8934. ))
  8935. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  8936. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  8937. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  8938. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  8939. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  8940. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  8941. {
  8942. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  8943. Id = ntf.Id,
  8944. ProvinceId = ntf.ProvinceId,
  8945. ProvinceName = sd2.Name_CN,
  8946. Continent = ntf.Continent,
  8947. Country = ntf.Country,
  8948. City = ntf.City,
  8949. Currency = ntf.Currency,
  8950. CurrencyCode = sd1.Name,
  8951. CurrencyName = sd1.Remark,
  8952. RoomCost = ntf.RoomCost,
  8953. FoodCost = ntf.FoodCost,
  8954. PublicCost = ntf.PublicCost,
  8955. LastUpdateUserId = ntf.LastUpdateUserId,
  8956. LastUpdateUserName = u.CnName,
  8957. LastUpdateTime = ntf.LastUpdateTime,
  8958. Remark = ntf.Remark
  8959. })
  8960. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8961. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  8962. }
  8963. /// <summary>
  8964. /// 团组模块 - 出入境国家费用标准 根据城市查询
  8965. /// </summary>
  8966. /// <returns></returns>
  8967. [HttpPost]
  8968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8969. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  8970. {
  8971. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  8972. int portId = dto.PortType;
  8973. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8974. string whereSql = string.Empty;
  8975. if (!string.IsNullOrEmpty(dto.Country))
  8976. {
  8977. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  8978. }
  8979. if (!string.IsNullOrEmpty(dto.City))
  8980. {
  8981. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  8982. }
  8983. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  8984. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  8985. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  8986. From Grp_NationalTravelFee gntf
  8987. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  8988. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  8989. Where gntf.Isdel = 0 {0} ", whereSql);
  8990. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  8991. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  8992. }
  8993. /// <summary>
  8994. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  8995. /// </summary>
  8996. /// <returns></returns>
  8997. [HttpPost]
  8998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8999. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  9000. {
  9001. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  9002. }
  9003. /// <summary>
  9004. /// 团组模块 - 出入境国家费用标准 - Del
  9005. /// </summary>
  9006. /// <returns></returns>
  9007. [HttpPost]
  9008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9009. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  9010. {
  9011. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  9012. {
  9013. Id = dto.Id,
  9014. DeleteUserId = dto.DeleteUserId,
  9015. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  9016. IsDel = 1
  9017. };
  9018. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  9019. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  9020. .WhereColumns(it => new { it.Id })
  9021. .ExecuteCommandAsync();
  9022. if (delStatus <= 0)
  9023. {
  9024. return Ok(JsonView(false, "删除失败!"));
  9025. }
  9026. return Ok(JsonView(true, "操作成功!"));
  9027. }
  9028. /// <summary>
  9029. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  9030. /// 注:Get 请求Headers 加 Token
  9031. /// </summary>
  9032. /// <param name="groupId"></param>
  9033. /// <returns></returns>
  9034. [HttpGet("{groupId}")]
  9035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9036. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  9037. {
  9038. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  9039. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  9040. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  9041. data.ForEach(x =>
  9042. {
  9043. x.CreateUserId = _currUserInfo.UserId;
  9044. });
  9045. if (data.Any())
  9046. {
  9047. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  9048. if (add > 0)
  9049. {
  9050. return Ok(JsonView(true, "操作成功!"));
  9051. }
  9052. }
  9053. return Ok(JsonView(false, "未操作!"));
  9054. }
  9055. #endregion
  9056. #region 团组经理模块 出入境费用-草稿
  9057. /// <summary>
  9058. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  9059. /// </summary>
  9060. /// <returns></returns>
  9061. [HttpGet]
  9062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9063. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  9064. {
  9065. var provData = await _groupRepository.ProvinceBasicSource();
  9066. return Ok(JsonView(true, "查询成功!", provData));
  9067. }
  9068. /// <summary>
  9069. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  9070. /// </summary>
  9071. /// <returns></returns>
  9072. [HttpGet("{provinceId}")]
  9073. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9074. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  9075. {
  9076. //验证城市归属并给默认值
  9077. if (provinceId < 1) provinceId = 122;
  9078. /*
  9079. * 122 四川
  9080. * 108 贵州
  9081. * 103 重庆
  9082. * 132 云南
  9083. */
  9084. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  9085. return Ok(JsonView(true, "查询成功!", new
  9086. {
  9087. WordTypeData = wordTypeData,
  9088. ExcelTypeData = excelTypeData,
  9089. }));
  9090. }
  9091. /// <summary>
  9092. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  9093. /// </summary>
  9094. /// <returns></returns>
  9095. [HttpPost]
  9096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9097. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  9098. {
  9099. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9100. .Where(x => x.IsDel == 0)
  9101. .OrderByDescending(x => x.CreateTime)
  9102. .Select(x => new { x.Id, x.DraftName })
  9103. .ToListAsync();
  9104. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9105. //SetDataInfoView
  9106. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  9107. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  9108. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  9109. int provinceId = dto.ProvinceId;
  9110. if (provinceId < 1) provinceId = 122;
  9111. /*
  9112. * 122 四川
  9113. * 108 贵州
  9114. * 103 重庆
  9115. * 132 云南
  9116. */
  9117. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  9118. //默认币种显示
  9119. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  9120. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  9121. return Ok(JsonView(true, "查询成功!", new
  9122. {
  9123. DraftNameDatas = draftNameDatas,
  9124. CurrencyData = _CurrencyData,
  9125. WordTypeData = wordTypeData,
  9126. ExcelTypeData = excelTypeData,
  9127. CurrencyInit = _currencyInfos,
  9128. ViewPermissionData = viewPermissionData
  9129. }));
  9130. }
  9131. /// <summary>
  9132. /// 团组模块 - 出入境费用-草稿
  9133. /// 实时汇率 tips
  9134. /// 机票费用 tips
  9135. /// </summary>
  9136. /// <returns></returns>
  9137. [HttpPost]
  9138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9139. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  9140. {
  9141. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  9142. return Ok(JsonView(true, "查询成功!", new
  9143. {
  9144. //GroupNameData = groupNameData.Data,
  9145. //visaData = visaData.Data,
  9146. //airData = airData.Data,
  9147. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  9148. }));
  9149. }
  9150. /// <summary>
  9151. /// 团组模块 - 出入境费用-草稿
  9152. /// 签证费用 tips
  9153. /// </summary>
  9154. /// <returns></returns>
  9155. [HttpPost]
  9156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9157. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  9158. {
  9159. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  9160. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9161. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9162. .Select(x => x.NationalTravelFeeId)
  9163. .Distinct()
  9164. .ToListAsync();
  9165. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9166. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9167. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9168. .Select(x => x.Country)
  9169. .Distinct()
  9170. .ToArrayAsync();
  9171. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9172. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9173. return Ok(JsonView(true, "查询成功!", new
  9174. {
  9175. totalAmt,
  9176. remark
  9177. }));
  9178. }
  9179. /// <summary>
  9180. /// 团组模块 - 出入境费用-草稿 - Info
  9181. /// </summary>
  9182. /// <returns></returns>
  9183. [HttpPost]
  9184. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  9185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9186. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  9187. {
  9188. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  9189. }
  9190. /// <summary>
  9191. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  9192. /// </summary>
  9193. /// <returns></returns>
  9194. [HttpPost]
  9195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9196. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  9197. {
  9198. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9199. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  9200. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9201. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9202. foreach (var userId in dto.UserIds)
  9203. {
  9204. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9205. }
  9206. if (permissions.Any())
  9207. {
  9208. _sqlSugar.BeginTran();
  9209. try
  9210. {
  9211. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9212. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9213. if (result < 1)
  9214. {
  9215. _sqlSugar.RollbackTran();
  9216. return Ok(JsonView(false));
  9217. }
  9218. }
  9219. catch (Exception ex)
  9220. {
  9221. _sqlSugar.RollbackTran();
  9222. return Ok(JsonView(false, ex.Message));
  9223. }
  9224. _sqlSugar.CommitTran();
  9225. return Ok(JsonView(true));
  9226. }
  9227. return Ok(JsonView(false));
  9228. }
  9229. /// <summary>
  9230. /// 团组模块 - 出入境费用-草稿 - Add And Update
  9231. /// </summary>
  9232. /// <returns></returns>
  9233. [HttpPost]
  9234. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  9235. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9236. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  9237. {
  9238. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  9239. if (data.Code != 0)
  9240. {
  9241. return Ok(JsonView(false, data.Msg));
  9242. }
  9243. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  9244. //汇率信息记录
  9245. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  9246. return Ok(JsonView(true, data.Msg, data.Data));
  9247. }
  9248. /// <summary>
  9249. /// 团组模块 - 出入境费用-草稿 - File downlaod
  9250. /// </summary>
  9251. /// <param name="dto"></param>
  9252. /// <returns></returns>
  9253. [HttpPost]
  9254. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  9255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9256. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  9257. {
  9258. try
  9259. {
  9260. var id = dto.Id;
  9261. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  9262. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  9263. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  9264. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  9265. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  9266. 3 团组成员名单 1 团组成员名单", ""));
  9267. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  9268. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  9269. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  9270. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  9271. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  9272. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  9273. //数据源
  9274. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  9275. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  9276. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  9277. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  9278. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9279. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  9280. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  9281. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  9282. .Select((x, a, b) => new
  9283. {
  9284. x.Index,
  9285. itemName = a.Name,
  9286. CurrencyStr = b.Name,
  9287. x.Cost,
  9288. x.SubTotal,
  9289. x.Remark
  9290. })
  9291. .OrderBy((x) => x.Index)
  9292. .ToList(); //其他款项费用
  9293. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9294. var peiceItemCurrencys = new List<string>();
  9295. if (_DayAndCosts.Any())
  9296. {
  9297. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  9298. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  9299. }
  9300. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  9301. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  9302. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  9303. {
  9304. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  9305. }
  9306. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  9307. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  9308. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  9309. if (dto.ExportType == 1) //明细表
  9310. {
  9311. if (dto.SubTypeId == 1005) //1005(默认明细表)
  9312. {
  9313. //获取模板
  9314. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  9315. //载入模板
  9316. Document doc = new Document(tempPath);
  9317. DocumentBuilder builder = new DocumentBuilder(doc);
  9318. //利用键值对存放数据
  9319. Dictionary<string, string> dic = new Dictionary<string, string>();
  9320. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  9321. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  9322. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  9323. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  9324. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  9325. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  9326. //境内费用(其他费用)
  9327. if (_EnterExitCosts.ChoiceOne == 1)
  9328. {
  9329. string row1_1 = "";
  9330. if (_EnterExitCosts.Visa > 0)
  9331. {
  9332. //insidePayTotal += _EnterExitCosts.Visa;
  9333. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  9334. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  9335. //{
  9336. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  9337. //}
  9338. }
  9339. string row1_2 = "";
  9340. if (_EnterExitCosts.YiMiao > 0)
  9341. {
  9342. //insidePayTotal += _EnterExitCosts.YiMiao;
  9343. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  9344. }
  9345. if (_EnterExitCosts.HeSuan > 0)
  9346. {
  9347. //insidePayTotal += _EnterExitCosts.HeSuan;
  9348. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  9349. }
  9350. if (_EnterExitCosts.Service > 0)
  9351. {
  9352. //insidePayTotal += _EnterExitCosts.Service;
  9353. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  9354. }
  9355. string row1_3 = "";
  9356. if (_EnterExitCosts.Safe > 0)
  9357. {
  9358. //insidePayTotal += _EnterExitCosts.Safe;
  9359. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  9360. }
  9361. if (_EnterExitCosts.Ticket > 0)
  9362. {
  9363. //insidePayTotal += _EnterExitCosts.Ticket;
  9364. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  9365. }
  9366. string row1 = "";
  9367. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  9368. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  9369. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  9370. row1 += $"备注:{_EnterExitCosts.Remark}";
  9371. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  9372. dic.Add("Row1Str", row1);
  9373. }
  9374. string airTotalStr = string.Empty,
  9375. airPriceStr = string.Empty;
  9376. //经济舱
  9377. if (_EnterExitCosts.SumJJC == 1)
  9378. {
  9379. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  9380. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  9381. }
  9382. //公务舱
  9383. if (_EnterExitCosts.SumGWC == 1)
  9384. {
  9385. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  9386. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  9387. }
  9388. //头等舱
  9389. if (_EnterExitCosts.SumTDC == 1)
  9390. {
  9391. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  9392. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  9393. }
  9394. //汇率描述
  9395. string rateStr = "";
  9396. if (peiceItemCurrencyInfos.Any())
  9397. {
  9398. rateStr = "\r\n汇率描述:";
  9399. foreach (var item in peiceItemCurrencyInfos)
  9400. {
  9401. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  9402. }
  9403. }
  9404. string twoItemRemark = "备注:";
  9405. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  9406. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  9407. dic.Add("AirTotalStr", airTotalStr);
  9408. dic.Add("AirPriceStr", airPriceStr);
  9409. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9410. dic.Add("TwoItemRemark", twoItemRemark);
  9411. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9412. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9413. int table1Row = 0,
  9414. table2Row = 0,
  9415. table3Row = 0,
  9416. table4Row = 0,
  9417. table5Row = 0;
  9418. //住宿费
  9419. if (_EnterExitCosts.ChoiceThree == 1)
  9420. {
  9421. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  9422. table1Row = dac1.Count;
  9423. #region 填充word表格内容
  9424. for (int i = 0; i < dac1.Count; i++)
  9425. {
  9426. var dac = dac1[i];
  9427. if (dac == null) continue;
  9428. builder.MoveToCell(0, i, 0, 0);
  9429. builder.Write("第" + dac.Days.ToString() + "晚:");
  9430. builder.MoveToCell(0, i, 1, 0);
  9431. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  9432. //builder.Write(dac.Place == null ? "" : dac.Place);
  9433. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9434. builder.MoveToCell(0, i, 2, 0);
  9435. builder.Write("费用标准:");
  9436. string curr = "";
  9437. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9438. if (currData != null)
  9439. {
  9440. curr = currData.Name;
  9441. }
  9442. builder.MoveToCell(0, i, 3, 0);
  9443. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9444. builder.MoveToCell(0, i, 4, 0);
  9445. builder.Write("费用小计:");
  9446. builder.MoveToCell(0, i, 5, 0);
  9447. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9448. }
  9449. #endregion
  9450. }
  9451. else dic.Add("SubZS", "0.00");
  9452. //删除多余行
  9453. while (table1.Rows.Count > table1Row)
  9454. {
  9455. table1.Rows.RemoveAt(table1Row);
  9456. }
  9457. //伙食费
  9458. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  9459. if (_EnterExitCosts.ChoiceFour == 1)
  9460. {
  9461. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  9462. table2Row = dac2.Count;
  9463. #region 填充word表格内容
  9464. for (int i = 0; i < dac2.Count; i++)
  9465. {
  9466. var dac = dac2[i];
  9467. if (dac == null) continue;
  9468. builder.MoveToCell(1, i, 0, 0);
  9469. builder.Write("第" + dac.Days.ToString() + "天:");
  9470. builder.MoveToCell(1, i, 1, 0);
  9471. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9472. builder.MoveToCell(1, i, 2, 0);
  9473. builder.Write("费用标准:");
  9474. string curr = "";
  9475. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9476. if (currData != null)
  9477. {
  9478. curr = currData.Name;
  9479. }
  9480. builder.MoveToCell(1, i, 3, 0);
  9481. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9482. builder.MoveToCell(1, i, 4, 0);
  9483. builder.Write("费用小计:");
  9484. builder.MoveToCell(1, i, 5, 0);
  9485. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9486. }
  9487. #endregion
  9488. }
  9489. else dic.Add("SubHS", "0.00");
  9490. //删除多余行
  9491. while (table2.Rows.Count > table2Row)
  9492. {
  9493. table2.Rows.RemoveAt(table2Row);
  9494. }
  9495. //公杂费
  9496. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  9497. if (_EnterExitCosts.ChoiceFive == 1)
  9498. {
  9499. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  9500. table3Row = dac3.Count;
  9501. #region 填充word表格内容
  9502. for (int i = 0; i < dac3.Count; i++)
  9503. {
  9504. var dac = dac3[i];
  9505. if (dac == null) continue;
  9506. builder.MoveToCell(2, i, 0, 0);
  9507. builder.Write("第" + dac.Days.ToString() + "天:");
  9508. builder.MoveToCell(2, i, 1, 0);
  9509. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9510. builder.MoveToCell(2, i, 2, 0);
  9511. builder.Write("费用标准:");
  9512. string curr = "";
  9513. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9514. if (currData != null)
  9515. {
  9516. curr = currData.Name;
  9517. }
  9518. builder.MoveToCell(2, i, 3, 0);
  9519. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9520. builder.MoveToCell(2, i, 4, 0);
  9521. builder.Write("费用小计:");
  9522. builder.MoveToCell(2, i, 5, 0);
  9523. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9524. }
  9525. //删除多余行
  9526. while (table3.Rows.Count > table3Row)
  9527. {
  9528. table3.Rows.RemoveAt(table3Row);
  9529. }
  9530. #endregion
  9531. }
  9532. else dic.Add("SubGZF", "0.00");
  9533. //删除多余行
  9534. while (table3.Rows.Count > table3Row)
  9535. {
  9536. table3.Rows.RemoveAt(table3Row);
  9537. }
  9538. //培训费
  9539. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  9540. if (_EnterExitCosts.ChoiceSix == 1)
  9541. {
  9542. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  9543. dic.Add("SubPX", pxStr);
  9544. table4Row = dac4.Count;
  9545. #region 填充word表格内容
  9546. for (int i = 0; i < dac4.Count; i++)
  9547. {
  9548. var dac = dac4[i];
  9549. if (dac == null) continue;
  9550. builder.MoveToCell(3, i, 0, 0);
  9551. builder.Write("第" + dac.Days.ToString() + "天:");
  9552. builder.MoveToCell(3, i, 1, 0);
  9553. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9554. builder.MoveToCell(3, i, 2, 0);
  9555. builder.Write("费用标准:");
  9556. string curr = "";
  9557. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9558. if (currData != null)
  9559. {
  9560. curr = currData.Name;
  9561. }
  9562. builder.MoveToCell(3, i, 3, 0);
  9563. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9564. builder.MoveToCell(3, i, 4, 0);
  9565. builder.Write("费用小计:");
  9566. builder.MoveToCell(3, i, 5, 0);
  9567. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9568. }
  9569. #endregion
  9570. }
  9571. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  9572. //删除多余行
  9573. while (table4.Rows.Count > table4Row)
  9574. {
  9575. table4.Rows.RemoveAt(table4Row);
  9576. }
  9577. //其他费用
  9578. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  9579. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  9580. {
  9581. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  9582. dic.Add("titleQi", qtStr);
  9583. table5Row = dac5.Count;
  9584. #region 填充word表格内容
  9585. for (int i = 0; i < dac5.Count; i++)
  9586. {
  9587. var dac = dac5[i];
  9588. if (dac == null) continue;
  9589. builder.MoveToCell(4, i, 0, 0);
  9590. builder.Write("第" + dac.Index.ToString() + "项:");
  9591. builder.MoveToCell(4, i, 1, 0);
  9592. builder.Write(dac.itemName);
  9593. builder.MoveToCell(4, i, 2, 0);
  9594. builder.Write("费用标准:");
  9595. builder.MoveToCell(4, i, 3, 0);
  9596. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  9597. builder.MoveToCell(4, i, 4, 0);
  9598. builder.Write("费用小计:");
  9599. builder.MoveToCell(4, i, 5, 0);
  9600. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9601. builder.MoveToCell(4, i, 6, 0);
  9602. builder.Write("备注:");
  9603. builder.MoveToCell(4, i, 7, 0);
  9604. builder.Write(dac.Remark);
  9605. }
  9606. #endregion
  9607. }
  9608. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  9609. //删除多余行
  9610. while (table5.Rows.Count > table5Row)
  9611. {
  9612. table5.Rows.RemoveAt(table5Row);
  9613. }
  9614. //加上其他费用
  9615. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  9616. decimal subJJC = 0.00M,
  9617. subGWC = 0.00M,
  9618. subTDC = 0.00M;
  9619. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  9620. string totalLabel = string.Format("全部费用总计:");
  9621. //经济舱
  9622. if (_EnterExitCosts.SumJJC == 1)
  9623. {
  9624. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  9625. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  9626. }
  9627. //公务舱
  9628. if (_EnterExitCosts.SumGWC == 1)
  9629. {
  9630. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  9631. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  9632. }
  9633. //头等舱
  9634. if (_EnterExitCosts.SumTDC == 1)
  9635. {
  9636. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  9637. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  9638. }
  9639. //TotalLabel
  9640. dic.Add("TotalLabel", totalLabel);
  9641. #region 填充word模板书签内容
  9642. foreach (var key in dic.Keys)
  9643. {
  9644. Bookmark bookmark = doc.Range.Bookmarks[key];
  9645. if (bookmark != null)
  9646. {
  9647. builder.MoveToBookmark(key);
  9648. builder.Write(dic[key]);
  9649. }
  9650. }
  9651. #endregion
  9652. //文件名
  9653. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  9654. strFileName = CommonFun.ValidFileName(strFileName);
  9655. AsposeHelper.removewatermark_v2180();
  9656. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9657. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9658. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9659. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9660. }
  9661. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  9662. {
  9663. //获取模板
  9664. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  9665. //载入模板
  9666. Document doc = new Document(tempPath);
  9667. DocumentBuilder builder = new DocumentBuilder(doc);
  9668. Dictionary<string, string> dic = new Dictionary<string, string>();
  9669. string returnCodeLabel = string.Empty;
  9670. if (nationalTravelFeeData.Any())
  9671. {
  9672. List<string> list = new List<string>();
  9673. foreach (var item in nationalTravelFeeData)
  9674. {
  9675. list.Add($"{item.Country}({item.City})");
  9676. }
  9677. list = list.Distinct().ToList();
  9678. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9679. }
  9680. var countryLabel = string.Empty;
  9681. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9682. if (countryData.Any())
  9683. {
  9684. countryLabel = string.Join("、", countryData);
  9685. }
  9686. dic.Add("ReturnCodeAir", returnCodeLabel);
  9687. dic.Add("VisitStartDate", "-");
  9688. dic.Add("VisitEndDate", "-");
  9689. dic.Add("Day", "-");
  9690. dic.Add("VisitCountry", countryLabel);
  9691. dic.Add("ClientUnit", "-");
  9692. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  9693. //dic.Add("Names", Names);
  9694. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9695. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9696. decimal dac1totalPrice = 0.00M;
  9697. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  9698. foreach (var dac in dac1)
  9699. {
  9700. if (dac.SubTotal == 0.00M)
  9701. {
  9702. continue;
  9703. }
  9704. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  9705. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  9706. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  9707. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9708. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  9709. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9710. builder.Write(currency);//币种
  9711. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  9712. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9713. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  9714. builder.Write("");//人数
  9715. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  9716. builder.Write("");//天数
  9717. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  9718. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9719. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  9720. decimal rate = 0.00M;
  9721. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9722. builder.Write(rate.ToString("#0.0000"));//汇率
  9723. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  9724. decimal rbmPrice = dac.SubTotal;
  9725. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9726. accommodationStartIndex++;
  9727. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9728. }
  9729. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9730. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  9731. {
  9732. table1.Rows.RemoveAt(i - 1);
  9733. foodandotherStartIndex--;
  9734. }
  9735. if (dac2.Count == dac3.Count)//国家 币种 金额
  9736. {
  9737. for (int i = 0; i < dac2.Count; i++)
  9738. {
  9739. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9740. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9741. }
  9742. }
  9743. decimal dac2totalPrice = 0.00M;
  9744. foreach (var dac in dac2)
  9745. {
  9746. if (dac.SubTotal == 0)
  9747. {
  9748. continue;
  9749. }
  9750. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  9751. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9752. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  9753. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9754. builder.Write(currency);//币种
  9755. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  9756. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9757. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  9758. builder.Write("");//人数
  9759. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  9760. builder.Write("");//天数
  9761. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  9762. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9763. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  9764. decimal rate = 0.00M;
  9765. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9766. builder.Write(rate.ToString("#0.0000"));//汇率
  9767. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  9768. decimal rbmPrice = dac.SubTotal;
  9769. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9770. foodandotherStartIndex++;
  9771. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9772. }
  9773. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  9774. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  9775. {
  9776. table1.Rows.RemoveAt(i - 1);
  9777. }
  9778. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9779. string otherFeeStr = "";
  9780. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  9781. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  9782. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  9783. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  9784. foreach (var otherInfo in dac5)
  9785. {
  9786. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  9787. }
  9788. #endregion
  9789. if (otherFeeStr.Length > 0)
  9790. {
  9791. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  9792. otherFeeStr = $"({otherFeeStr})";
  9793. dic.Add("OtherFeeStr", otherFeeStr);
  9794. }
  9795. //总计
  9796. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  9797. //国际旅费
  9798. string outsideAir = string.Empty;
  9799. string allPriceAir = string.Empty;
  9800. if (_EnterExitCosts.SumJJC == 1)
  9801. {
  9802. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9803. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  9804. }
  9805. if (_EnterExitCosts.SumGWC == 1)
  9806. {
  9807. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  9808. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9809. }
  9810. if (_EnterExitCosts.SumTDC == 1)
  9811. {
  9812. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  9813. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  9814. }
  9815. dic.Add("InTravelPrice", $"({outsideAir})");
  9816. dic.Add("FinalSumPrice", $"({allPriceAir})");
  9817. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  9818. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  9819. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  9820. foreach (var key in dic.Keys)
  9821. {
  9822. builder.MoveToBookmark(key);
  9823. builder.Write(dic[key]);
  9824. }
  9825. //模板文件名
  9826. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9827. strFileName = CommonFun.ValidFileName(strFileName);
  9828. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9829. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9830. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9831. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9832. }
  9833. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  9834. {
  9835. //获取模板
  9836. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  9837. //载入模板
  9838. WorkbookDesigner designer = new WorkbookDesigner();
  9839. designer.Workbook = new Workbook(tempPath);
  9840. Dictionary<string, string> dic = new Dictionary<string, string>();
  9841. string returnCodeLabel = string.Empty;
  9842. if (nationalTravelFeeData.Any())
  9843. {
  9844. List<string> list = new List<string>();
  9845. foreach (var item in nationalTravelFeeData)
  9846. {
  9847. list.Add($"{item.Country}({item.City})");
  9848. }
  9849. list = list.Distinct().ToList();
  9850. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9851. }
  9852. var countryLabel = string.Empty;
  9853. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9854. if (countryData.Any())
  9855. {
  9856. countryLabel = string.Join("、", countryData);
  9857. }
  9858. dic.Add("ReturnCodeAir", returnCodeLabel);
  9859. dic.Add("VisitStartDate", "-");
  9860. dic.Add("VisitEndDate", "-");
  9861. dic.Add("Day", "0");
  9862. dic.Add("VisitCountry", countryLabel);
  9863. dic.Add("ClientUnit", "-");
  9864. designer.SetDataSource("ClientUnit", "-");
  9865. designer.SetDataSource("VisitCountry", countryLabel);
  9866. designer.SetDataSource("Group", "-");
  9867. designer.SetDataSource("ClientUnitTitle", "-");
  9868. designer.SetDataSource("Name", "-");
  9869. designer.SetDataSource("VisitStartDate", "-");
  9870. designer.SetDataSource("Day", "0");
  9871. designer.SetDataSource("ReturnCode", returnCodeLabel);
  9872. designer.SetDataSource("ReturnCodeAir", "-");
  9873. int startIndex = 10;
  9874. const int startIndexcopy = 10;
  9875. if (dac2.Count == dac3.Count)//国家 币种 金额
  9876. {
  9877. for (int i = 0; i < dac2.Count; i++)
  9878. {
  9879. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9880. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9881. }
  9882. }
  9883. DataTable dtdac1 = new DataTable();
  9884. List<string> place = new List<string>();
  9885. dtdac1.Columns.AddRange(new DataColumn[] {
  9886. new DataColumn(){ ColumnName = "city"},
  9887. new DataColumn(){ ColumnName = "curr"},
  9888. new DataColumn(){ ColumnName = "criterion"},
  9889. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9890. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9891. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9892. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9893. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  9894. });
  9895. DataTable dtdac2 = new DataTable();
  9896. dtdac2.Columns.AddRange(new DataColumn[] {
  9897. new DataColumn(){ ColumnName = "city"},
  9898. new DataColumn(){ ColumnName = "curr"},
  9899. new DataColumn(){ ColumnName = "criterion"},
  9900. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9901. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9902. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9903. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9904. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  9905. });
  9906. dtdac1.TableName = "tb1";
  9907. dtdac2.TableName = "tb2";
  9908. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  9909. foreach (var item in dac1)
  9910. {
  9911. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9912. if (place.Contains(item.Place))
  9913. {
  9914. continue;
  9915. }
  9916. DataRow row = dtdac1.NewRow();
  9917. row["city"] = item.Place;
  9918. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9919. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9920. row["curr"] = currency;
  9921. row["rate"] = rate.ToString("#0.0000");
  9922. row["criterion"] = item.Cost.ToString("#0.00");
  9923. row["number"] = 1;
  9924. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9925. //row["costRMB"] = rbmPrice;
  9926. dtdac1.Rows.Add(row);
  9927. place.Add(item.Place);
  9928. }
  9929. place = new List<string>();
  9930. foreach (var item in dac2)
  9931. {
  9932. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9933. if (place.Contains(item.Place))
  9934. {
  9935. continue;
  9936. }
  9937. DataRow row = dtdac2.NewRow();
  9938. row["city"] = item.Place;
  9939. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9940. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9941. row["curr"] = currency;
  9942. row["rate"] = rate.ToString("#0.0000");
  9943. row["criterion"] = item.Cost.ToString("#0.00");
  9944. row["number"] = 1;
  9945. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9946. //row["cost"] = item.SubTotal;
  9947. //row["costRMB"] = rbmPrice;
  9948. dtdac2.Rows.Add(row);
  9949. place.Add(item.Place);
  9950. //dac2totalPrice += rbmPrice;
  9951. }
  9952. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  9953. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  9954. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9955. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  9956. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  9957. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  9958. string cell4Str1 = string.Empty;
  9959. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  9960. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  9961. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  9962. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  9963. string cellStr = $" 5.其他费用(";
  9964. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9965. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9966. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9967. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9968. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9969. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9970. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  9971. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  9972. foreach (var otherInfo in dac5)
  9973. {
  9974. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9975. }
  9976. #endregion
  9977. if (cellStr.Length > 8)
  9978. {
  9979. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  9980. }
  9981. cellStr += ")";
  9982. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  9983. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  9984. decimal pxFee = dac4.Sum(it => it.Cost);
  9985. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  9986. string celllastStr1 = "";
  9987. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  9988. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  9989. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  9990. celllastStr1 += $",国际旅费 元";
  9991. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  9992. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  9993. designer.SetDataSource("cell4Str", cell4Str);
  9994. designer.SetDataSource("cellStr", cellStr);
  9995. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  9996. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9997. designer.SetDataSource("celllastStr", celllastStr);
  9998. Workbook wb = designer.Workbook;
  9999. var sheet = wb.Worksheets[0];
  10000. //绑定datatable数据集
  10001. designer.SetDataSource(dtdac1);
  10002. designer.SetDataSource(dtdac2);
  10003. designer.Process();
  10004. var rowStart = dtdac1.Rows.Count;
  10005. while (rowStart > 0)
  10006. {
  10007. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  10008. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10009. startIndex++;
  10010. rowStart--;
  10011. }
  10012. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  10013. startIndex += 1; //总计行
  10014. rowStart = dtdac2.Rows.Count;
  10015. while (rowStart > 0)
  10016. {
  10017. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  10018. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10019. startIndex++;
  10020. rowStart--;
  10021. }
  10022. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  10023. wb.CalculateFormula(true);
  10024. //模板文件名
  10025. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10026. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10027. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10028. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10029. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10030. }
  10031. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  10032. {
  10033. //获取模板
  10034. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  10035. //载入模板
  10036. Document doc = new Document(tempPath);
  10037. DocumentBuilder builder = new DocumentBuilder(doc);
  10038. Dictionary<string, string> dic = new Dictionary<string, string>();
  10039. dic.Add("GroupName", "-");
  10040. dic.Add("ClientUnit", "-");
  10041. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  10042. //string missionLeaderJob = "";//负责人job
  10043. //int groupNumber = 0; //团人数
  10044. dic.Add("MissionLeader", "-"); //团负责人
  10045. dic.Add("MissionLeaderJob", "-"); //团负责人job
  10046. dic.Add("GroupNumber", "0"); //团人数
  10047. dic.Add("Day", "0");
  10048. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  10049. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10050. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10051. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10052. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  10053. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  10054. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  10055. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  10056. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  10057. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  10058. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  10059. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  10060. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  10061. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  10062. //其他费用
  10063. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  10064. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  10065. //其他费用合计
  10066. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  10067. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  10068. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  10069. //公务舱合计
  10070. //国际旅费
  10071. //string outsideJJ = "";
  10072. //string allPriceJJ = "";
  10073. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  10074. {
  10075. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  10076. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  10077. }
  10078. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  10079. {
  10080. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  10081. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  10082. }
  10083. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  10084. {
  10085. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  10086. dic.Add("AirFeeTotal", airFeeTotalStr);
  10087. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  10088. dic.Add("FeeTotal", feeTotalStr);
  10089. }
  10090. foreach (var key in dic.Keys)
  10091. {
  10092. builder.MoveToBookmark(key);
  10093. builder.Write(dic[key]);
  10094. }
  10095. //模板文件名
  10096. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  10097. strFileName = CommonFun.ValidFileName(strFileName);
  10098. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10099. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10100. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10101. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10102. }
  10103. }
  10104. else if (dto.ExportType == 2) //表格
  10105. {
  10106. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  10107. }
  10108. else if (dto.ExportType == 3)
  10109. {
  10110. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  10111. }
  10112. return Ok(JsonView(400, "只可导出明细表!", ""));
  10113. }
  10114. catch (Exception ex)
  10115. {
  10116. return Ok(JsonView(400, ex.Message, ""));
  10117. }
  10118. }
  10119. /// <summary>
  10120. /// 获取三公费用标准city
  10121. /// </summary>
  10122. /// <param name="placeData"></param>
  10123. /// <param name="nationalTravelFeeId"></param>
  10124. /// <returns></returns>
  10125. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  10126. {
  10127. string _city = string.Empty;
  10128. if (!placeData.Any()) return _city;
  10129. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  10130. if (data == null) return _city;
  10131. string country = data.Country;
  10132. string city = data.City;
  10133. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  10134. else _city = city;
  10135. return _city;
  10136. }
  10137. /// <summary>
  10138. /// 团组模块 - 出入境费用-草稿 - 一键清空
  10139. /// </summary>
  10140. /// <returns></returns>
  10141. [HttpPost]
  10142. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10144. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  10145. {
  10146. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  10147. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  10148. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  10149. if (_view.Code == 0)
  10150. {
  10151. return Ok(JsonView(true, "操作成功"));
  10152. }
  10153. return Ok(JsonView(false, "操作失败"));
  10154. }
  10155. /// <summary>
  10156. /// 团组模块 - 出入境费用-草稿 - 子项删除
  10157. /// </summary>
  10158. /// <returns></returns>
  10159. [HttpPost]
  10160. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10162. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10163. {
  10164. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10165. if (data.Code != 0)
  10166. {
  10167. return Ok(JsonView(false, data.Msg));
  10168. }
  10169. return Ok(JsonView(true, "操作成功!", data.Data));
  10170. }
  10171. /// <summary>
  10172. /// 三公其他费用草稿 删除
  10173. /// </summary>
  10174. /// <param name="dto"></param>
  10175. /// <returns></returns>
  10176. [HttpPost]
  10177. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10178. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  10179. {
  10180. var jw = JsonView(false, "删除失败!");
  10181. var data = new Grp_DayOtherPriceDraft()
  10182. {
  10183. Id = dto.Id,
  10184. IsDel = 1,
  10185. DeleteUserId = dto.DeleteUserId,
  10186. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10187. };
  10188. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10189. if (del > 0)
  10190. {
  10191. jw.Code = 200;
  10192. jw.Msg = "删除成功!";
  10193. }
  10194. return Ok(jw);
  10195. }
  10196. /// <summary>
  10197. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  10198. /// </summary>
  10199. /// <returns></returns>
  10200. [HttpPost]
  10201. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  10202. {
  10203. var jw = JsonView(false);
  10204. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  10205. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  10206. jw.Code = StatusCodes.Status200OK;
  10207. jw.Msg = "操作成功!";
  10208. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  10209. return Ok(jw);
  10210. }
  10211. /// <summary>
  10212. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  10213. /// </summary>
  10214. /// <param name="dto"></param>
  10215. /// <returns></returns>
  10216. [HttpPost]
  10217. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  10218. {
  10219. int userId = dto.UserId,
  10220. portId = dto.PortType,
  10221. groupId = dto.GroupId,
  10222. draftId = dto.DraftId;
  10223. _portTypeData.Add(1);
  10224. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10225. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  10226. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  10227. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  10228. _sqlSugar.BeginTran();
  10229. try
  10230. {
  10231. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  10232. if (draftDatas == null)
  10233. {
  10234. _sqlSugar.RollbackTran();
  10235. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  10236. }
  10237. //验证可覆盖已有数据 两边创建人需为同一人;
  10238. int draftCreateUserId = draftDatas.CreateUserId,
  10239. formalCreateUserId = 0;
  10240. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  10241. if (formalData != null)
  10242. {
  10243. formalCreateUserId = formalData.CreateUserId;
  10244. if (draftCreateUserId != formalCreateUserId)
  10245. {
  10246. _sqlSugar.RollbackTran();
  10247. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  10248. }
  10249. }
  10250. //默认添加查看、编辑权限(创建人、自己)
  10251. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  10252. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  10253. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  10254. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  10255. newExterData.DiId = groupId;
  10256. newExterData.CreateUserId = userId;
  10257. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  10258. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  10259. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  10260. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  10261. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  10262. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  10263. //数据如果存在执行删除
  10264. if (enterExitCostInfo != null)
  10265. {
  10266. _sqlSugar.Updateable<Grp_EnterExitCost>()
  10267. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  10268. .Where(x => x.Id == enterExitCostInfo.Id)
  10269. .ExecuteCommand();
  10270. _sqlSugar.Updateable<Grp_DayAndCost>()
  10271. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10272. .Where(x => x.DiId == groupId)
  10273. .ExecuteCommand();
  10274. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  10275. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10276. .Where(x => x.Diid == groupId)
  10277. .ExecuteCommand();
  10278. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  10279. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10280. .Where(x => x.GroupId == groupId)
  10281. .ExecuteCommand();
  10282. }
  10283. //执行insert
  10284. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  10285. if (insertId < 1)
  10286. {
  10287. _sqlSugar.RollbackTran();
  10288. return Ok(JsonView(false, "草稿数据导入失败!"));
  10289. }
  10290. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  10291. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  10292. #region 默认添加权限
  10293. #endregion
  10294. _sqlSugar.CommitTran();
  10295. //执行操作之后
  10296. //生成默认文件pdf并且通知人员
  10297. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10298. {
  10299. DiId = groupId,
  10300. ExportType = 1,
  10301. SubTypeId = 1005
  10302. }, "pdf");
  10303. //发送通知
  10304. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10305. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  10306. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  10307. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  10308. //汇率信息记录
  10309. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  10310. return Ok(JsonView(true));
  10311. }
  10312. catch (Exception ex)
  10313. {
  10314. _sqlSugar.RollbackTran();
  10315. return Ok(JsonView(false, ex.Message));
  10316. }
  10317. }
  10318. #endregion
  10319. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  10320. /// <summary>
  10321. /// 获取币种基础数据(含逻辑处理)
  10322. /// </summary>
  10323. /// <returns></returns>
  10324. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  10325. {
  10326. return await GeneralMethod.EnterExitCostInitRate();
  10327. }
  10328. /// <summary>
  10329. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10330. /// </summary>
  10331. /// <returns></returns>
  10332. [HttpPost]
  10333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10334. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  10335. {
  10336. //验证城市归属并给默认值
  10337. int provinceId = dto.ProvinceId;
  10338. if (provinceId < 1) provinceId = 122;
  10339. var dataSource = await _sqlSugar
  10340. .Queryable<Sys_SetData>()
  10341. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10342. .ToListAsync();
  10343. var fileTypes = new List<EecSetDataInfoView>();
  10344. //三公费用-Word明细类型
  10345. var wordTypeData = dataSource
  10346. .Where(it => it.STid == 72)
  10347. .Select(x => new EecSetDataInfoView
  10348. {
  10349. ParentId = 1,
  10350. Id = x.Id,
  10351. Name = x.Name
  10352. })
  10353. .ToArray();
  10354. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  10355. var excelTypeData = dataSource
  10356. .Where(it => it.STid == 73)
  10357. .Select(x => new EecSetDataInfoView
  10358. {
  10359. ParentId = 2,
  10360. Id = x.Id,
  10361. Name = x.Name
  10362. })
  10363. .ToArray();
  10364. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  10365. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  10366. fileTypes.Add(groupNameList);
  10367. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  10368. //默认币种显示
  10369. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10370. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10371. return Ok(JsonView(true, "查询成功!", new
  10372. {
  10373. FileTypeData = fileTypes,
  10374. CurrencyInit = _currencyInfos,
  10375. viewPermissionData = viewPermissionData
  10376. }));
  10377. }
  10378. /// <summary>
  10379. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  10380. /// </summary>
  10381. /// <returns></returns>
  10382. [HttpPost]
  10383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10384. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  10385. {
  10386. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10387. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10388. RefAsync<int> total = 0;
  10389. int diId = 0;
  10390. var status = int.TryParse(dto.GroupName, out diId);
  10391. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  10392. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10393. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10394. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10395. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10396. .OrderByDescending(x => x.VisitStartDate)
  10397. .Select(x => new EnterExitCostMobileGroupView()
  10398. {
  10399. Id = x.Id,
  10400. GroupName = x.TeamName,
  10401. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  10402. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  10403. ProvinceId = x.CityId
  10404. })
  10405. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10406. //处理省份Id
  10407. if (data.Any())
  10408. {
  10409. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  10410. if (provCityDatas.Any())
  10411. {
  10412. foreach (var item in data)
  10413. {
  10414. var provinceId = item.ProvinceId;
  10415. var isDefualtVal = true;
  10416. if (provinceId > 0)
  10417. {
  10418. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  10419. if (parentId != null)
  10420. {
  10421. isDefualtVal = false;
  10422. item.ProvinceId = (int)parentId;
  10423. }
  10424. }
  10425. if (isDefualtVal)
  10426. {
  10427. item.ProvinceId = 122; //默认四川
  10428. }
  10429. }
  10430. }
  10431. }
  10432. //处理是否显示
  10433. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  10434. {
  10435. foreach (var item in data)
  10436. {
  10437. item.IsView = true;
  10438. }
  10439. }
  10440. return Ok(JsonView(true, "查询成功!", data, total));
  10441. }
  10442. /// <summary>
  10443. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  10444. /// </summary>
  10445. /// <returns></returns>
  10446. [HttpPost]
  10447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10448. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  10449. {
  10450. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10451. RefAsync<int> total = 0;
  10452. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10453. .Where(x => x.IsDel == 0 && x.STid == 66)
  10454. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10455. .Select(x => new
  10456. {
  10457. id = x.Id,
  10458. name = x.Name,
  10459. remark = x.Remark,
  10460. })
  10461. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10462. return Ok(JsonView(true, "查询成功!", data, total));
  10463. }
  10464. /// <summary>
  10465. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10466. /// </summary>
  10467. /// <returns></returns>
  10468. [HttpPost]
  10469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10470. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  10471. {
  10472. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10473. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10474. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  10475. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10476. var groupOtherRateData = groupRateData.TeamRates;
  10477. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10478. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10479. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10480. groupOtherRateData = groupOtherRateData
  10481. .Select(x => new TeamRateDescAddCurrencyIdView
  10482. {
  10483. CurrencyId = x.CurrencyId,
  10484. CurrencyName = x.CurrencyName,
  10485. CurrencyCode = x.CurrencyCode,
  10486. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10487. }).ToList();
  10488. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10489. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10490. }
  10491. /// <summary>
  10492. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  10493. /// </summary>
  10494. /// <returns></returns>
  10495. [HttpPost]
  10496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10497. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  10498. {
  10499. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10500. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10501. var tipsData = new List<int>() { 1, 2, 3 };
  10502. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10503. if (dto.TipsType == 1)
  10504. {
  10505. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10506. }
  10507. else if (dto.TipsType == 2)
  10508. {
  10509. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  10510. return Ok(JsonView(true, "查询成功!", visaData.Data));
  10511. }
  10512. else if (dto.TipsType == 3)
  10513. {
  10514. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  10515. return Ok(JsonView(true, "查询成功!", airData));
  10516. }
  10517. return Ok(JsonView(false));
  10518. }
  10519. /// <summary>
  10520. /// 团组模块 - 出入境国家费用标准-移动端 List
  10521. /// </summary>
  10522. /// <returns></returns>
  10523. [HttpPost]
  10524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10525. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  10526. {
  10527. Stopwatch sw = new Stopwatch();
  10528. sw.Start();
  10529. int provinceId = dto.ProvinceId;
  10530. if (provinceId < 1) provinceId = 122; // 默认四川
  10531. RefAsync<int> total = 0;
  10532. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10533. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  10534. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  10535. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  10536. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  10537. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  10538. .Select((ntf, sd, u, sd1) => new
  10539. {
  10540. Id = ntf.Id,
  10541. Area = $"{ntf.Country}-{ntf.City}",
  10542. Currency = ntf.Currency,
  10543. CurrencyCode = sd.Name,
  10544. CurrencyName = sd.Remark,
  10545. RoomCost = ntf.RoomCost,
  10546. FoodCost = ntf.FoodCost,
  10547. PublicCost = ntf.PublicCost,
  10548. TrainCost = ntf.TrainCost,
  10549. LastUpdateUserId = ntf.LastUpdateUserId,
  10550. LastUpdateUserName = u.CnName,
  10551. LastUpdateTime = ntf.LastUpdateTime
  10552. })
  10553. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10554. sw.Stop();
  10555. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  10556. }
  10557. /// <summary>
  10558. /// 团组模块 - 出入境费用-移动端 - Info
  10559. /// </summary>
  10560. /// <returns></returns>
  10561. [HttpPost]
  10562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10563. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  10564. {
  10565. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10566. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10567. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10568. return Ok(data);
  10569. }
  10570. /// <summary>
  10571. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  10572. /// </summary>
  10573. /// <returns></returns>
  10574. [HttpPost]
  10575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10576. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  10577. {
  10578. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10579. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10580. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10581. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10582. var mobileInfo = new EnterExitCostMobileParentInfoView();
  10583. mobileInfo.DiId = dto.DiId;
  10584. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10585. if (eecInfo == null) return Ok(mobileInfo);
  10586. //验证查看权限
  10587. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  10588. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  10589. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  10590. mobileInfo.IsAssignPerm = isSet;
  10591. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  10592. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10593. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10594. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10595. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10596. {
  10597. SubId = dac.Id,
  10598. DiId = dac.DiId,
  10599. Type = dac.Type,
  10600. Days = dac.Days,
  10601. NationalTravelFeeId = dac.NationalTravelFeeId,
  10602. Arae = $"{ntf.Country}-{ntf.City}",
  10603. Cost = dac.Cost,
  10604. Currency = dac.Currency,
  10605. CurrencyName = sd.Name,
  10606. SubTotal = dac.SubTotal,
  10607. })
  10608. .ToList();
  10609. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10610. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10611. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10612. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10613. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10614. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10615. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10616. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10617. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10618. //其他款项
  10619. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10620. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10621. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10622. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10623. .OrderBy((dop, sd1, sd2) => dop.Index)
  10624. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10625. {
  10626. SubId = dop.Id,
  10627. DiId = dop.Diid,
  10628. Index = dop.Index,
  10629. SetDataId = dop.SetDataId,
  10630. SetDataName = sd1.Name,
  10631. Cost = dop.Cost,
  10632. Currency = dop.Currency,
  10633. CurrencyName = sd2.Remark,
  10634. SubTotal = dop.SubTotal,
  10635. Remark = dop.Remark,
  10636. })
  10637. .ToArray();
  10638. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10639. return Ok(mobileInfo);
  10640. }
  10641. /// <summary>
  10642. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  10643. /// </summary>
  10644. /// <returns></returns>
  10645. [HttpPost]
  10646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10647. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  10648. {
  10649. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10650. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10651. //验证查看权限
  10652. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  10653. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  10654. var userIds = await _sqlSugar
  10655. .Queryable<Grp_EnterExitCostPermission>()
  10656. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  10657. .Select(x => x.UserId)
  10658. .ToArrayAsync();
  10659. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  10660. var perUsersView = new List<dynamic>();
  10661. foreach (var item in perUsers)
  10662. {
  10663. bool isView1 = false;
  10664. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10665. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10666. }
  10667. return Ok(JsonView(perUsersView));
  10668. }
  10669. /// <summary>
  10670. /// 团组模块 - 出入境费用-移动端 - SubInfo
  10671. /// </summary>
  10672. /// <returns></returns>
  10673. [HttpPost]
  10674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10675. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  10676. {
  10677. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10678. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10679. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10680. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10681. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10682. //验证查看权限
  10683. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  10684. //if (!isView) return Ok(JsonView(false, msg));
  10685. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10686. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10687. var subType = dto.SubType;
  10688. if (subType == 1) //1:境内费用
  10689. {
  10690. var oneData = new ChoiceOneMobileSubInfoView()
  10691. {
  10692. Id = eecInfo.Id,
  10693. ChoiceOne = eecInfo.ChoiceOne,
  10694. ChoiceOneTotalCost = eecInfo.InsidePay,
  10695. Visa = eecInfo.Visa,
  10696. VisaRemark = eecInfo.VisaRemark,
  10697. YiMiao = eecInfo.YiMiao,
  10698. HeSuan = eecInfo.HeSuan,
  10699. Service = eecInfo.Service,
  10700. Ticket = eecInfo.Ticket,
  10701. Safe = eecInfo.Safe,
  10702. FirstItemRemark = eecInfo.FirstItemRemark
  10703. };
  10704. return Ok(JsonView(oneData));
  10705. }
  10706. else if (subType == 2) //2:国际旅费
  10707. {
  10708. var twoData = new ChoiceTwoMobileSubInfoView()
  10709. {
  10710. Id = eecInfo.Id,
  10711. ChoiceTwoJJ = eecInfo.SumJJC,
  10712. OutsideJJPay = eecInfo.OutsideJJPay,
  10713. ChoiceTwoGW = eecInfo.SumGWC,
  10714. OutsideGWPay = eecInfo.OutsideGWPay,
  10715. ChoiceTwoTD = eecInfo.SumTDC,
  10716. OutsideTDPay = eecInfo.OutsideTDPay,
  10717. AirJJ = eecInfo.AirJJ,
  10718. AirGW = eecInfo.AirGW,
  10719. AirTD = eecInfo.AirTD,
  10720. CityTranffic = eecInfo.CityTranffic,
  10721. TwoItemRemark = eecInfo.TwoItemRemark
  10722. };
  10723. return Ok(JsonView(twoData));
  10724. }
  10725. else if (subType == 3) //3:住宿费
  10726. {
  10727. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10728. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10729. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10730. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  10731. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10732. {
  10733. SubId = dac.Id,
  10734. DiId = dac.DiId,
  10735. Type = dac.Type,
  10736. Days = dac.Days,
  10737. NationalTravelFeeId = dac.NationalTravelFeeId,
  10738. Arae = $"{ntf.Country}-{ntf.City}",
  10739. Cost = dac.Cost,
  10740. Currency = dac.Currency,
  10741. CurrencyName = sd.Name,
  10742. SubTotal = dac.SubTotal,
  10743. })
  10744. .ToArray();
  10745. var data = new ChoiceMobileSubInfo3To6View()
  10746. {
  10747. ParentId = eecInfo.Id,
  10748. Choice = eecInfo.ChoiceThree,
  10749. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10750. Details = dayAndCostDatas
  10751. };
  10752. return Ok(JsonView(data));
  10753. }
  10754. else if (subType == 4) //4:伙食费
  10755. {
  10756. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10757. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10758. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10759. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  10760. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10761. {
  10762. SubId = dac.Id,
  10763. DiId = dac.DiId,
  10764. Type = dac.Type,
  10765. Days = dac.Days,
  10766. NationalTravelFeeId = dac.NationalTravelFeeId,
  10767. Arae = $"{ntf.Country}-{ntf.City}",
  10768. Cost = dac.Cost,
  10769. Currency = dac.Currency,
  10770. CurrencyName = sd.Name,
  10771. SubTotal = dac.SubTotal,
  10772. })
  10773. .ToArray();
  10774. var data = new ChoiceMobileSubInfo3To6View()
  10775. {
  10776. ParentId = eecInfo.Id,
  10777. Choice = eecInfo.ChoiceFour,
  10778. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10779. Details = dayAndCostDatas
  10780. };
  10781. return Ok(JsonView(data));
  10782. }
  10783. else if (subType == 5) //5:公杂费
  10784. {
  10785. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10786. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10787. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10788. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  10789. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10790. {
  10791. SubId = dac.Id,
  10792. DiId = dac.DiId,
  10793. Type = dac.Type,
  10794. Days = dac.Days,
  10795. NationalTravelFeeId = dac.NationalTravelFeeId,
  10796. Arae = $"{ntf.Country}-{ntf.City}",
  10797. Cost = dac.Cost,
  10798. Currency = dac.Currency,
  10799. CurrencyName = sd.Name,
  10800. SubTotal = dac.SubTotal,
  10801. })
  10802. .ToArray();
  10803. var data = new ChoiceMobileSubInfo3To6View()
  10804. {
  10805. ParentId = eecInfo.Id,
  10806. Choice = eecInfo.ChoiceFive,
  10807. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10808. Details = dayAndCostDatas
  10809. };
  10810. return Ok(JsonView(data));
  10811. }
  10812. else if (subType == 6) //6:培训费
  10813. {
  10814. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10815. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10816. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10817. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  10818. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10819. {
  10820. SubId = dac.Id,
  10821. DiId = dac.DiId,
  10822. Type = dac.Type,
  10823. Days = dac.Days,
  10824. NationalTravelFeeId = dac.NationalTravelFeeId,
  10825. Arae = $"{ntf.Country}-{ntf.City}",
  10826. Cost = dac.Cost,
  10827. Currency = dac.Currency,
  10828. CurrencyName = sd.Name,
  10829. SubTotal = dac.SubTotal,
  10830. })
  10831. .ToArray();
  10832. var data = new ChoiceMobileSubInfo3To6View()
  10833. {
  10834. ParentId = eecInfo.Id,
  10835. Choice = eecInfo.ChoiceSix,
  10836. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10837. Details = dayAndCostDatas
  10838. };
  10839. return Ok(JsonView(data));
  10840. }
  10841. else if (subType == 7) //7:其他
  10842. {
  10843. //其他款项
  10844. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10845. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10846. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10847. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10848. .OrderBy((dop, sd1, sd2) => dop.Index)
  10849. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10850. {
  10851. SubId = dop.Id,
  10852. DiId = dop.Diid,
  10853. Index = dop.Index,
  10854. SetDataId = dop.SetDataId,
  10855. SetDataName = sd1.Name,
  10856. Cost = dop.Cost,
  10857. Currency = dop.Currency,
  10858. CurrencyName = sd2.Name,
  10859. SubTotal = dop.SubTotal,
  10860. Remark = dop.Remark,
  10861. })
  10862. .ToArray();
  10863. var data = new ChoiceSevenMobileSubInfoView()
  10864. {
  10865. ParentId = eecInfo.Id,
  10866. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10867. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10868. Details = otherData
  10869. };
  10870. return Ok(JsonView(data));
  10871. }
  10872. return Ok(JsonView(false));
  10873. }
  10874. #region op
  10875. ///// <summary>
  10876. ///// 移动端更新费用消息通知
  10877. ///// </summary>
  10878. ///// <param name="diid"></param>
  10879. ///// <param name="id"></param>
  10880. ///// <param name="currUserId"></param>
  10881. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  10882. //{
  10883. // try
  10884. // {
  10885. // ////生成默认文件pdf并且通知人员
  10886. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10887. // //{
  10888. // // DiId = diid,
  10889. // // ExportType = 1,
  10890. // // SubTypeId = 1005
  10891. // //}, "pdf");
  10892. // ////发送通知
  10893. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10894. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10895. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10896. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  10897. // ////汇率信息记录
  10898. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10899. // }
  10900. // catch (Exception ex)
  10901. // {
  10902. // //记录日志
  10903. // throw;
  10904. // }
  10905. //}
  10906. /// <summary>
  10907. /// 验证出入境费用数据是否存在
  10908. /// 不存在添加
  10909. /// </summary>
  10910. /// <param name="diId"></param>
  10911. /// <param name="currUserId"></param>
  10912. /// <returns></returns>
  10913. /// <exception cref="CustomException"></exception>
  10914. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  10915. {
  10916. var parentId = 0;
  10917. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10918. if (info != null)
  10919. {
  10920. parentId = info.Id;
  10921. }
  10922. else
  10923. {
  10924. var currencys = await EnterExitCostMobileGetCurrencyInit();
  10925. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10926. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10927. parentId = addId;
  10928. }
  10929. return parentId;
  10930. }
  10931. /// <summary>
  10932. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  10933. /// </summary>
  10934. /// <returns></returns>
  10935. [HttpPost]
  10936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10937. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  10938. {
  10939. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10940. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10941. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10942. //验证编辑权限
  10943. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10944. //if (!isEdit) return Ok(JsonView(false, msg));
  10945. var permissions = new List<Grp_EnterExitCostPermission>();
  10946. foreach (var userId in dto.UserIds)
  10947. {
  10948. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  10949. }
  10950. if (permissions.Any())
  10951. {
  10952. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10953. {
  10954. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10955. }
  10956. _sqlSugar.BeginTran();
  10957. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  10958. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10959. if (result < 1)
  10960. {
  10961. _sqlSugar.RollbackTran();
  10962. return Ok(JsonView(false));
  10963. }
  10964. _sqlSugar.CommitTran();
  10965. return Ok(JsonView(true));
  10966. }
  10967. return Ok(JsonView(false));
  10968. }
  10969. /// <summary>
  10970. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  10971. /// </summary>
  10972. /// <returns></returns>
  10973. [HttpPost]
  10974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10975. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  10976. {
  10977. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10978. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10979. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10980. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10981. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10982. int id = dto.Id;
  10983. if (id <= 0) //add
  10984. {
  10985. //int provinceId = dto.ProvinceId;
  10986. int groupId = dto.DiId;
  10987. //if (provinceId < 1) provinceId = 122;
  10988. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  10989. info.LastUpdateUserId = dto.CurrUserId;
  10990. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10991. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  10992. if (add < 1) return Ok(JsonView(false));
  10993. id = add;
  10994. }
  10995. else //update
  10996. {
  10997. ////验证编辑权限
  10998. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10999. //if (!isEdit) return Ok(JsonView(false, msg));
  11000. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  11001. {
  11002. CurrencyRemark = currencyStr,
  11003. LastUpdateUserId = dto.CurrUserId,
  11004. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11005. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  11006. if (upd < 1) return Ok(JsonView(false));
  11007. }
  11008. #region 汇率变更时更改币种相关费用
  11009. var opDayCosts = new List<Grp_DayAndCost>();
  11010. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  11011. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11012. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  11013. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11014. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  11015. .Select((dac, sd) => new
  11016. {
  11017. dac.Id,
  11018. dac.DiId,
  11019. CurrencyCode = sd.Name,
  11020. dac.Cost
  11021. })
  11022. .ToList();
  11023. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  11024. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11025. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  11026. .Select((dop, sd) => new
  11027. {
  11028. dop.Id,
  11029. dop.Diid,
  11030. CurrencyCode = sd.Name,
  11031. dop.Cost
  11032. })
  11033. .ToList();
  11034. if (dayCosts.Count > 0)
  11035. {
  11036. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11037. foreach (var dc in new_dayCosts)
  11038. {
  11039. var thisCurrency = dc.Key.ToUpper();
  11040. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11041. if (thisRate == 0.00M) continue;
  11042. foreach (var dcSub in dc)
  11043. {
  11044. opDayCosts.Add(new Grp_DayAndCost()
  11045. {
  11046. Id = dcSub.Id,
  11047. DiId = dcSub.DiId,
  11048. Cost = dcSub.Cost,
  11049. SubTotal = dcSub.Cost * thisRate,
  11050. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11051. });
  11052. }
  11053. }
  11054. if (opDayCosts.Count > 0)
  11055. {
  11056. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11057. }
  11058. }
  11059. if (dayOtherCosts.Count > 0)
  11060. {
  11061. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11062. foreach (var dc in new_dayOtherCosts)
  11063. {
  11064. var thisCurrency = dc.Key.ToUpper();
  11065. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11066. if (thisRate == 0.00M) continue;
  11067. foreach (var dcSub in dc)
  11068. {
  11069. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  11070. {
  11071. Id = dcSub.Id,
  11072. Diid = dcSub.Diid,
  11073. Cost = dcSub.Cost,
  11074. SubTotal = dcSub.Cost * thisRate,
  11075. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11076. });
  11077. }
  11078. }
  11079. if (opDayOtherCosts.Count > 0)
  11080. {
  11081. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11082. }
  11083. }
  11084. #endregion
  11085. //消息通知
  11086. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11087. //汇率信息记录
  11088. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11089. return Ok(JsonView(new { parentId = id }));
  11090. }
  11091. /// <summary>
  11092. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  11093. /// </summary>
  11094. /// <returns></returns>
  11095. [HttpPost]
  11096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11097. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  11098. {
  11099. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11100. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11101. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11102. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11103. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  11104. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  11105. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11106. int id = dto.Id;
  11107. if (id <= 0) //add
  11108. {
  11109. checkboxInfo.CreateUserId = dto.CurrUserId;
  11110. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11111. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11112. if (add < 1) return Ok(JsonView(false));
  11113. }
  11114. else //update
  11115. {
  11116. ////验证编辑权限
  11117. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11118. //if (!isEdit) return Ok(JsonView(false, msg));
  11119. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11120. .UpdateColumns(x => new
  11121. {
  11122. x.ChoiceOne,
  11123. x.ChoiceTwo,
  11124. x.SumJJC,
  11125. x.SumGWC,
  11126. x.SumTDC,
  11127. x.ChoiceThree,
  11128. x.ChoiceFour,
  11129. x.ChoiceFive,
  11130. x.ChoiceSix,
  11131. x.OtherExpenses_Checked
  11132. })
  11133. .Where(x => x.Id == id)
  11134. .ExecuteCommandAsync();
  11135. if (upd < 1) return Ok(JsonView(false));
  11136. }
  11137. return Ok(JsonView(new { parentId = id }));
  11138. }
  11139. /// <summary>
  11140. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  11141. /// </summary>
  11142. /// <returns></returns>
  11143. [HttpPost]
  11144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11145. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  11146. {
  11147. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  11148. // if (provinceId < 1) provinceId = 122;
  11149. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11150. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11151. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11152. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11153. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11154. var checkboxInfo = new Grp_EnterExitCost()
  11155. {
  11156. Id = id,
  11157. //ProvinceId = provinceId,
  11158. DiId = diId,
  11159. CreateUserId = currUserId,
  11160. LastUpdateUserId = dto.CurrUserId,
  11161. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11162. };
  11163. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11164. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11165. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11166. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11167. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11168. if (id <= 0) //add
  11169. {
  11170. checkboxInfo.CreateUserId = dto.CurrUserId;
  11171. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11172. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11173. if (add < 1) return Ok(JsonView(false));
  11174. }
  11175. else //update
  11176. {
  11177. ////验证编辑权限
  11178. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11179. //if (!isEdit) return Ok(JsonView(false, msg));
  11180. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  11181. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  11182. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  11183. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11184. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11185. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11186. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11187. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11188. .Where(x => x.Id == id)
  11189. .ExecuteCommandAsync();
  11190. if (upd < 1) return Ok(JsonView(false));
  11191. }
  11192. return Ok(JsonView(new { parentId = id }));
  11193. }
  11194. /// <summary>
  11195. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  11196. /// </summary>
  11197. /// <returns></returns>
  11198. [HttpPost]
  11199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11200. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  11201. {
  11202. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11203. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11204. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11205. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11206. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  11207. info.FirstItemRemark = dto.FirstItemRemark;
  11208. info.LastUpdateUserId = dto.CurrUserId;
  11209. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11210. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11211. int id = dto.Id;
  11212. if (id <= 0) //add
  11213. {
  11214. info.CreateUserId = dto.CurrUserId;
  11215. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11216. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11217. if (add < 1) return Ok(JsonView(false));
  11218. id = add;
  11219. }
  11220. else //update
  11221. {
  11222. ////验证编辑权限
  11223. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11224. //if (!isEdit) return Ok(JsonView(false, msg));
  11225. var upd = await _sqlSugar.Updateable(info)
  11226. .UpdateColumns(x => new
  11227. {
  11228. x.ChoiceOne,
  11229. x.InsidePay,
  11230. x.VisaRemark,
  11231. x.Visa,
  11232. x.Service,
  11233. x.Safe,
  11234. x.Ticket,
  11235. x.HeSuan,
  11236. x.YiMiao,
  11237. x.FirstItemRemark,
  11238. x.LastUpdateUserId,
  11239. x.LastUpdateTime
  11240. })
  11241. .Where(x => x.Id == id)
  11242. .ExecuteCommandAsync();
  11243. if (upd < 1) return Ok(JsonView(false));
  11244. }
  11245. //消息通知
  11246. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11247. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11248. }
  11249. /// <summary>
  11250. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  11251. /// </summary>
  11252. /// <returns></returns>
  11253. [HttpPost]
  11254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11255. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  11256. {
  11257. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11258. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11259. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11260. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11261. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  11262. info.DiId = dto.DiId;
  11263. //info.ProvinceId = dto.ProvinceId;
  11264. info.OutsideJJPay = dto.OutsideJJPay;
  11265. info.OutsideGWPay = dto.OutsideGWPay;
  11266. info.OutsideTDPay = dto.OutsideTDPay;
  11267. info.AirJJ = dto.AirJJ;
  11268. info.AirGW = dto.AirGW;
  11269. info.AirTD = dto.AirTD;
  11270. info.CityTranffic = dto.CityTranffic;
  11271. info.TwoItemRemark = dto.TwoItemRemark;
  11272. info.SumJJC = dto.ChoiceTwoJJ;
  11273. info.SumGWC = dto.ChoiceTwoGW;
  11274. info.SumTDC = dto.ChoiceTwoTD;
  11275. info.LastUpdateUserId = dto.CurrUserId;
  11276. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11277. int id = dto.Id;
  11278. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11279. if (id <= 0) //add i
  11280. {
  11281. info.CreateUserId = dto.CurrUserId;
  11282. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11283. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11284. if (addId <= 0) return Ok(JsonView(false));
  11285. id = addId;
  11286. }
  11287. else //update
  11288. {
  11289. ////验证编辑权限
  11290. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11291. //if (!isEdit) return Ok(JsonView(false, msg));
  11292. var upd = await _sqlSugar.Updateable(info)
  11293. .UpdateColumns(x => new
  11294. {
  11295. x.SumJJC,
  11296. x.OutsideJJPay,
  11297. x.SumGWC,
  11298. x.OutsideGWPay,
  11299. x.SumTDC,
  11300. x.OutsideTDPay,
  11301. x.AirJJ,
  11302. x.AirGW,
  11303. x.AirTD,
  11304. x.CityTranffic,
  11305. x.TwoItemRemark,
  11306. x.LastUpdateTime,
  11307. x.LastUpdateUserId
  11308. })
  11309. .Where(x => x.Id == id)
  11310. .ExecuteCommandAsync();
  11311. if (upd < 1) return Ok(JsonView(false));
  11312. }
  11313. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11314. gwcItemTotal = info.AirGW + info.CityTranffic;
  11315. tdcItemTotal = info.AirTD + info.CityTranffic;
  11316. //消息通知
  11317. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11318. return Ok(JsonView(new
  11319. {
  11320. parentId = id,
  11321. choiceTwoJJ = dto.ChoiceTwoJJ,
  11322. jjcItemTotal = jjcItemTotal,
  11323. choiceTwoGW = dto.ChoiceTwoGW,
  11324. gwcItemTotal = gwcItemTotal,
  11325. choiceTwoTD = dto.ChoiceTwoTD,
  11326. tdcItemTotal = tdcItemTotal
  11327. }));
  11328. }
  11329. /// <summary>
  11330. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11331. /// </summary>
  11332. /// <returns></returns>
  11333. [HttpPost]
  11334. [ApiExplorerSettings(IgnoreApi = true)]
  11335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11336. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  11337. {
  11338. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11339. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11340. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11341. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11342. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11343. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11344. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  11345. var infos = infos1.Select(x => new Grp_DayAndCost
  11346. {
  11347. Id = x.Id,
  11348. DiId = dto.DiId,
  11349. Type = dto.FeeType,
  11350. Days = x.Days,
  11351. NationalTravelFeeId = x.NationalTravelFeeId,
  11352. Cost = x.Cost,
  11353. Currency = x.Currency,
  11354. SubTotal = x.SubTotal,
  11355. CreateUserId = dto.CurrUserId
  11356. })
  11357. .ToList();
  11358. var adds = infos.Where(x => x.Id <= 0).ToList();
  11359. var upds = infos.Where(x => x.Id > 0).ToList();
  11360. if (adds.Count > 0)
  11361. {
  11362. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11363. if (add < 1) return Ok(JsonView(false));
  11364. }
  11365. if (upds.Count > 0)
  11366. {
  11367. var upd = await _sqlSugar.Updateable(adds)
  11368. .UpdateColumns(x => new
  11369. {
  11370. x.Days,
  11371. x.NationalTravelFeeId,
  11372. x.Cost,
  11373. x.Currency,
  11374. x.SubTotal
  11375. })
  11376. .WhereColumns(x => new { x.Id })
  11377. .ExecuteCommandAsync();
  11378. if (upd < 1) return Ok(JsonView(false));
  11379. }
  11380. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11381. //消息通知
  11382. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  11383. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11384. return Ok(JsonView(new { itemTotal = itemTotal }));
  11385. }
  11386. /// <summary>
  11387. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11388. /// </summary>
  11389. /// <returns></returns>
  11390. [HttpPost]
  11391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11392. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  11393. {
  11394. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11395. int subId = dto.SubId, feeType = dto.FeeType;
  11396. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11397. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11398. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11399. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11400. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  11401. subInfo.Id = subId;
  11402. subInfo.DiId = dto.DiId;
  11403. if (feeType == 3) subInfo.Type = 1;
  11404. else if (feeType == 4) subInfo.Type = 2;
  11405. else if (feeType == 5) subInfo.Type = 3;
  11406. else if (feeType == 6) subInfo.Type = 4;
  11407. subInfo.CreateUserId = dto.CurrUserId;
  11408. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  11409. if (parentId < 1) return Ok(JsonView(false));
  11410. //子表op
  11411. if (subId < 1)
  11412. {
  11413. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11414. if (subAdd < 1) return Ok(JsonView(false));
  11415. }
  11416. else
  11417. {
  11418. ////验证编辑权限
  11419. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11420. //if (!isEdit) return Ok(JsonView(false, msg));
  11421. var subUpd = await _sqlSugar.Updateable(subInfo)
  11422. .UpdateColumns(x => new
  11423. {
  11424. x.Days,
  11425. x.NationalTravelFeeId,
  11426. x.Cost,
  11427. x.Currency,
  11428. x.SubTotal
  11429. })
  11430. .WhereColumns(x => new { x.Id })
  11431. .ExecuteCommandAsync();
  11432. if (subUpd < 1) return Ok(JsonView(false));
  11433. }
  11434. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  11435. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  11436. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11437. }
  11438. /// <summary>
  11439. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  11440. /// </summary>
  11441. /// <returns></returns>
  11442. [HttpPost]
  11443. [ApiExplorerSettings(IgnoreApi = true)]
  11444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11445. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  11446. {
  11447. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11448. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11449. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11450. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  11451. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  11452. {
  11453. Id = x.Id,
  11454. Diid = dto.DiId,
  11455. SetDataId = x.SetDataId,
  11456. Index = x.Index,
  11457. Cost = x.Cost,
  11458. Currency = x.Currency,
  11459. SubTotal = x.SubTotal,
  11460. CreateUserId = dto.CurrUserId,
  11461. Remark = x.Remark
  11462. }).ToList();
  11463. var adds = infos.Where(x => x.Id <= 0).ToList();
  11464. var upds = infos.Where(x => x.Id > 0).ToList();
  11465. if (adds.Count > 0)
  11466. {
  11467. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11468. if (add < 1) return Ok(JsonView(false));
  11469. }
  11470. if (upds.Count > 0)
  11471. {
  11472. var upd = await _sqlSugar.Updateable(adds)
  11473. .UpdateColumns(x => new
  11474. {
  11475. x.Index,
  11476. x.SetDataId,
  11477. x.Cost,
  11478. x.Currency,
  11479. x.SubTotal,
  11480. x.Remark
  11481. })
  11482. .WhereColumns(x => new { x.Id })
  11483. .ExecuteCommandAsync();
  11484. if (upd < 1) return Ok(JsonView(false));
  11485. }
  11486. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  11487. //消息通知
  11488. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  11489. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11490. return Ok(JsonView(new { itemTotal = itemTotal }));
  11491. }
  11492. /// <summary>
  11493. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  11494. /// </summary>
  11495. /// <returns></returns>
  11496. [HttpPost]
  11497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11498. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  11499. {
  11500. int subId = dto.SubId;
  11501. int diId = dto.Diid;
  11502. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11503. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11504. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11505. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  11506. subInfo.Id = subId;
  11507. subInfo.Diid = dto.Diid;
  11508. subInfo.CreateUserId = dto.CurrUserId;
  11509. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  11510. if (parentId < 1) return Ok(JsonView(false));
  11511. #region 子表op
  11512. if (subId < 1)//add
  11513. {
  11514. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11515. if (subAdd < 1) return Ok(JsonView(false));
  11516. }
  11517. else //upd
  11518. {
  11519. ////验证编辑权限
  11520. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  11521. //if (!isEdit) return Ok(JsonView(false, msg));
  11522. var subUpd = await _sqlSugar.Updateable(subInfo)
  11523. .UpdateColumns(x => new
  11524. {
  11525. x.Index,
  11526. x.SetDataId,
  11527. x.Cost,
  11528. x.Currency,
  11529. x.SubTotal,
  11530. x.Remark
  11531. })
  11532. .WhereColumns(x => new { x.Id })
  11533. .ExecuteCommandAsync();
  11534. if (subUpd < 1) return Ok(JsonView(false));
  11535. }
  11536. #endregion
  11537. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  11538. //消息通知
  11539. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11540. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11541. }
  11542. /// <summary>
  11543. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  11544. /// </summary>
  11545. /// <returns></returns>
  11546. [HttpPost]
  11547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11548. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  11549. {
  11550. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  11551. if (data.Code != 0)
  11552. {
  11553. return Ok(JsonView(false, data.Msg));
  11554. }
  11555. return Ok(JsonView(true, "操作成功!", data.Data));
  11556. }
  11557. /// <summary>
  11558. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  11559. /// </summary>
  11560. /// <param name="dto"></param>
  11561. /// <returns></returns>
  11562. [HttpPost]
  11563. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  11564. {
  11565. var data = new Grp_DayOtherPrice()
  11566. {
  11567. Id = dto.Id,
  11568. IsDel = 1,
  11569. DeleteUserId = dto.DeleteUserId,
  11570. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11571. };
  11572. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11573. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11574. return Ok(JsonView(false, "删除失败!"));
  11575. }
  11576. #endregion
  11577. #endregion
  11578. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  11579. /// <summary>
  11580. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  11581. /// </summary>
  11582. /// <returns></returns>
  11583. [HttpGet]
  11584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11585. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  11586. {
  11587. var provData = await _groupRepository.ProvinceBasicSource();
  11588. return Ok(JsonView(true, "查询成功!", provData));
  11589. }
  11590. /// <summary>
  11591. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  11592. /// </summary>
  11593. /// <returns></returns>
  11594. [HttpPost]
  11595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11596. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  11597. {
  11598. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11599. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11600. RefAsync<int> total = 0;
  11601. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  11602. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  11603. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  11604. .Select(x => new
  11605. {
  11606. Id = x.Id,
  11607. DraftName = x.DraftName,
  11608. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  11609. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  11610. .Any()
  11611. })
  11612. .OrderByDescending(x => x.Id)
  11613. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11614. return Ok(JsonView(true, "查询成功!", data, total));
  11615. }
  11616. /// <summary>
  11617. /// 出入境费用-草稿 移动端
  11618. /// 获取币种基础数据(含逻辑处理)
  11619. /// </summary>
  11620. /// <returns></returns>
  11621. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  11622. {
  11623. return await GeneralMethod.EnterExitCostInitRate();
  11624. }
  11625. /// <summary>
  11626. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  11627. /// </summary>
  11628. /// <returns></returns>
  11629. [HttpPost]
  11630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11631. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  11632. {
  11633. //验证城市归属并给默认值
  11634. int provinceId = dto.ProvinceId;
  11635. if (provinceId < 1) provinceId = 122;
  11636. var dataSource = await _sqlSugar
  11637. .Queryable<Sys_SetData>()
  11638. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  11639. .ToListAsync();
  11640. //三公费用-Word明细类型
  11641. var wordTypeData = dataSource.Where(it => it.STid == 72)
  11642. .Select(x => new SetDataInfoView
  11643. {
  11644. Id = x.Id,
  11645. Name = x.Name,
  11646. Remark = x.Remark
  11647. })
  11648. .ToList();
  11649. //三公费用-Excel明细类型
  11650. var excelTypeData = dataSource.Where(it => it.STid == 73)
  11651. .Select(x => new SetDataInfoView
  11652. {
  11653. Id = x.Id,
  11654. Name = x.Name,
  11655. Remark = x.Remark
  11656. })
  11657. .ToList();
  11658. //默认币种显示
  11659. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  11660. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  11661. return Ok(JsonView(true, "查询成功!", new
  11662. {
  11663. WordTypeData = wordTypeData,
  11664. ExcelTypeData = excelTypeData,
  11665. CurrencyInit = _currencyInfos,
  11666. viewPermissionData = viewPermissionData
  11667. }));
  11668. }
  11669. /// <summary>
  11670. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  11671. /// </summary>
  11672. /// <returns></returns>
  11673. [HttpPost]
  11674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11675. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  11676. {
  11677. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11678. RefAsync<int> total = 0;
  11679. int diId = 0;
  11680. var status = int.TryParse(dto.GroupName, out diId);
  11681. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  11682. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  11683. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  11684. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  11685. .OrderByDescending(x => x.VisitStartDate)
  11686. .Select(x => new
  11687. {
  11688. Id = x.Id,
  11689. GroupName = x.TeamName
  11690. })
  11691. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11692. return Ok(JsonView(true, "查询成功!", data, total));
  11693. }
  11694. /// <summary>
  11695. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  11696. /// </summary>
  11697. /// <returns></returns>
  11698. [HttpPost]
  11699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11700. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  11701. {
  11702. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11703. RefAsync<int> total = 0;
  11704. var data = await _sqlSugar.Queryable<Sys_SetData>()
  11705. .Where(x => x.IsDel == 0 && x.STid == 66)
  11706. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  11707. .Select(x => new
  11708. {
  11709. id = x.Id,
  11710. name = x.Name,
  11711. remark = x.Remark,
  11712. })
  11713. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11714. return Ok(JsonView(true, "查询成功!", data, total));
  11715. }
  11716. /// <summary>
  11717. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  11718. /// </summary>
  11719. /// <returns></returns>
  11720. [HttpPost]
  11721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11722. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  11723. {
  11724. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11725. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11726. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  11727. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  11728. var groupOtherRateData = groupRateData.TeamRates;
  11729. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11730. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  11731. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  11732. groupOtherRateData = groupOtherRateData
  11733. .Select(x => new TeamRateDescAddCurrencyIdView
  11734. {
  11735. CurrencyId = x.CurrencyId,
  11736. CurrencyName = x.CurrencyName,
  11737. CurrencyCode = x.CurrencyCode,
  11738. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  11739. }).ToList();
  11740. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  11741. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  11742. }
  11743. /// <summary>
  11744. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  11745. /// </summary>
  11746. /// <returns></returns>
  11747. [HttpPost]
  11748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11749. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  11750. {
  11751. int portType = dto.PortType;
  11752. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11753. var tipsData = new List<int>() { 1, 2, 3 };
  11754. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  11755. if (dto.TipsType == 1)
  11756. {
  11757. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  11758. }
  11759. else if (dto.TipsType == 2)
  11760. {
  11761. if (portType == 2)
  11762. {
  11763. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11764. }
  11765. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11766. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  11767. .Select(x => x.NationalTravelFeeId)
  11768. .Distinct()
  11769. .ToListAsync();
  11770. if (portType == 2)
  11771. {
  11772. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11773. }
  11774. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  11775. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  11776. .Select(x => x.Country)
  11777. .Distinct()
  11778. .ToArrayAsync();
  11779. if (portType == 2)
  11780. {
  11781. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11782. }
  11783. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  11784. return Ok(JsonView(true, "查询成功!", new
  11785. {
  11786. totalAmt = totalAmt,
  11787. remark = remark
  11788. }));
  11789. }
  11790. else if (dto.TipsType == 3)
  11791. {
  11792. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  11793. }
  11794. return Ok(JsonView(false));
  11795. }
  11796. /// <summary>
  11797. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  11798. /// </summary>
  11799. /// <returns></returns>
  11800. [HttpPost]
  11801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11802. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  11803. {
  11804. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  11805. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11806. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11807. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  11808. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  11809. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  11810. var info = new Grp_EnterExitCostDraft()
  11811. {
  11812. ProvinceId = dto.ProvinceId,
  11813. DraftName = dto.DraftName,
  11814. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  11815. CreateUserId = dto.CurrUserId
  11816. };
  11817. _sqlSugar.BeginTran();
  11818. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11819. if (draftId < 1)
  11820. {
  11821. _sqlSugar.RollbackTran();
  11822. return Ok(JsonView(false, "草稿创建失败!"));
  11823. }
  11824. //添加默认权限
  11825. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  11826. _sqlSugar.CommitTran();
  11827. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  11828. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11829. mobileInfo.Id = draftId;
  11830. mobileInfo.DraftName = dto.DraftName;
  11831. mobileInfo.Currencys = rateInfos;
  11832. mobileInfo.IsAssignPerm = assignPerm;
  11833. return Ok(JsonView(mobileInfo));
  11834. }
  11835. /// <summary>
  11836. /// 出入境费用-草稿-移动端 查看编辑提示消息
  11837. /// </summary>
  11838. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  11839. /// <summary>
  11840. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  11841. /// </summary>
  11842. /// <returns></returns>
  11843. [HttpPost]
  11844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11845. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  11846. {
  11847. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11848. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11849. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11850. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11851. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  11852. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  11853. //验证查看编辑权限
  11854. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11855. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11856. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  11857. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  11858. mobileInfo.IsAssignPerm = assignPerm;
  11859. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11860. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11861. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11862. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11863. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11864. {
  11865. ParentId = dac.ParentId,
  11866. SubId = dac.Id,
  11867. Type = dac.Type,
  11868. Days = dac.Days,
  11869. NationalTravelFeeId = dac.NationalTravelFeeId,
  11870. Arae = $"{ntf.Country}-{ntf.City}",
  11871. Cost = dac.Cost,
  11872. Currency = dac.Currency,
  11873. CurrencyName = sd.Name,
  11874. SubTotal = dac.SubTotal,
  11875. })
  11876. .ToList();
  11877. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  11878. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  11879. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  11880. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  11881. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  11882. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  11883. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  11884. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  11885. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  11886. //其他款项
  11887. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11888. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11889. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11890. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11891. .OrderBy((dop, sd1, sd2) => dop.Index)
  11892. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11893. {
  11894. ParentId = dop.ParentId,
  11895. SubId = dop.Id,
  11896. Index = dop.Index,
  11897. SetDataId = dop.SetDataId,
  11898. SetDataName = sd1.Name,
  11899. Cost = dop.Cost,
  11900. Currency = dop.Currency,
  11901. CurrencyName = sd2.Remark,
  11902. SubTotal = dop.SubTotal,
  11903. Remark = dop.Remark,
  11904. })
  11905. .ToArray();
  11906. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  11907. return Ok(mobileInfo);
  11908. }
  11909. /// <summary>
  11910. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  11911. /// </summary>
  11912. /// <returns></returns>
  11913. [HttpPost]
  11914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11915. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  11916. {
  11917. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11918. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11919. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11920. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  11921. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  11922. //验证查看编辑权限
  11923. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11924. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11925. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11926. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  11927. var subType = dto.SubType;
  11928. if (subType == 1) //1:境内费用
  11929. {
  11930. var oneData = new ChoiceOneMobileSubInfoView()
  11931. {
  11932. Id = eecInfo.Id,
  11933. ChoiceOne = eecInfo.ChoiceOne,
  11934. ChoiceOneTotalCost = eecInfo.InsidePay,
  11935. Visa = eecInfo.Visa,
  11936. VisaRemark = eecInfo.VisaRemark,
  11937. YiMiao = eecInfo.YiMiao,
  11938. HeSuan = eecInfo.HeSuan,
  11939. Service = eecInfo.Service,
  11940. Ticket = eecInfo.Ticket,
  11941. Safe = eecInfo.Safe,
  11942. FirstItemRemark = eecInfo.FirstItemRemark
  11943. };
  11944. return Ok(JsonView(oneData));
  11945. }
  11946. else if (subType == 2) //2:国际旅费
  11947. {
  11948. var twoData = new ChoiceTwoMobileSubInfoView()
  11949. {
  11950. Id = eecInfo.Id,
  11951. ChoiceTwoJJ = eecInfo.SumJJC,
  11952. OutsideJJPay = eecInfo.OutsideJJPay,
  11953. ChoiceTwoGW = eecInfo.SumGWC,
  11954. OutsideGWPay = eecInfo.OutsideGWPay,
  11955. ChoiceTwoTD = eecInfo.SumTDC,
  11956. OutsideTDPay = eecInfo.OutsideTDPay,
  11957. AirJJ = eecInfo.AirJJ,
  11958. AirGW = eecInfo.AirGW,
  11959. AirTD = eecInfo.AirTD,
  11960. CityTranffic = eecInfo.CityTranffic,
  11961. TwoItemRemark = eecInfo.TwoItemRemark
  11962. };
  11963. return Ok(JsonView(twoData));
  11964. }
  11965. else if (subType == 3) //3:住宿费
  11966. {
  11967. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11968. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11969. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11970. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  11971. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11972. {
  11973. ParentId = dac.ParentId,
  11974. SubId = dac.Id,
  11975. Type = dac.Type,
  11976. Days = dac.Days,
  11977. NationalTravelFeeId = dac.NationalTravelFeeId,
  11978. Arae = $"{ntf.Country}-{ntf.City}",
  11979. Cost = dac.Cost,
  11980. Currency = dac.Currency,
  11981. CurrencyName = sd.Name,
  11982. SubTotal = dac.SubTotal,
  11983. })
  11984. .ToArray();
  11985. var data = new ChoiceDraftMobileSubInfo3To6View()
  11986. {
  11987. ParentId = eecInfo.Id,
  11988. Choice = eecInfo.ChoiceThree,
  11989. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11990. Details = dayAndCostDatas
  11991. };
  11992. return Ok(JsonView(data));
  11993. }
  11994. else if (subType == 4) //4:伙食费
  11995. {
  11996. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11997. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11998. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11999. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  12000. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12001. {
  12002. ParentId = dac.ParentId,
  12003. SubId = dac.Id,
  12004. Type = dac.Type,
  12005. Days = dac.Days,
  12006. NationalTravelFeeId = dac.NationalTravelFeeId,
  12007. Arae = $"{ntf.Country}-{ntf.City}",
  12008. Cost = dac.Cost,
  12009. Currency = dac.Currency,
  12010. CurrencyName = sd.Name,
  12011. SubTotal = dac.SubTotal,
  12012. })
  12013. .ToArray();
  12014. var data = new ChoiceDraftMobileSubInfo3To6View()
  12015. {
  12016. ParentId = eecInfo.Id,
  12017. Choice = eecInfo.ChoiceFour,
  12018. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12019. Details = dayAndCostDatas
  12020. };
  12021. return Ok(JsonView(data));
  12022. }
  12023. else if (subType == 5) //5:公杂费
  12024. {
  12025. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12026. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12027. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12028. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  12029. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12030. {
  12031. ParentId = dac.ParentId,
  12032. SubId = dac.Id,
  12033. Type = dac.Type,
  12034. Days = dac.Days,
  12035. NationalTravelFeeId = dac.NationalTravelFeeId,
  12036. Arae = $"{ntf.Country}-{ntf.City}",
  12037. Cost = dac.Cost,
  12038. Currency = dac.Currency,
  12039. CurrencyName = sd.Name,
  12040. SubTotal = dac.SubTotal,
  12041. })
  12042. .ToArray();
  12043. var data = new ChoiceDraftMobileSubInfo3To6View()
  12044. {
  12045. ParentId = eecInfo.Id,
  12046. Choice = eecInfo.ChoiceFive,
  12047. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12048. Details = dayAndCostDatas
  12049. };
  12050. return Ok(JsonView(data));
  12051. }
  12052. else if (subType == 6) //6:培训费
  12053. {
  12054. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12055. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12056. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12057. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  12058. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12059. {
  12060. ParentId = dac.ParentId,
  12061. SubId = dac.Id,
  12062. Type = dac.Type,
  12063. Days = dac.Days,
  12064. NationalTravelFeeId = dac.NationalTravelFeeId,
  12065. Arae = $"{ntf.Country}-{ntf.City}",
  12066. Cost = dac.Cost,
  12067. Currency = dac.Currency,
  12068. CurrencyName = sd.Name,
  12069. SubTotal = dac.SubTotal,
  12070. })
  12071. .ToArray();
  12072. var data = new ChoiceDraftMobileSubInfo3To6View()
  12073. {
  12074. ParentId = eecInfo.Id,
  12075. Choice = eecInfo.ChoiceSix,
  12076. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12077. Details = dayAndCostDatas
  12078. };
  12079. return Ok(JsonView(data));
  12080. }
  12081. else if (subType == 7) //7:其他
  12082. {
  12083. //其他款项
  12084. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  12085. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  12086. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  12087. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  12088. .OrderBy((dop, sd1, sd2) => dop.Index)
  12089. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  12090. {
  12091. ParentId = dop.ParentId,
  12092. SubId = dop.Id,
  12093. Index = dop.Index,
  12094. SetDataId = dop.SetDataId,
  12095. SetDataName = sd1.Name,
  12096. Cost = dop.Cost,
  12097. Currency = dop.Currency,
  12098. CurrencyName = sd2.Name,
  12099. SubTotal = dop.SubTotal,
  12100. Remark = dop.Remark,
  12101. })
  12102. .ToArray();
  12103. var data = new ChoiceSevenDraftMobileSubInfoView()
  12104. {
  12105. ParentId = eecInfo.Id,
  12106. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  12107. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  12108. Details = otherData
  12109. };
  12110. return Ok(JsonView(data));
  12111. }
  12112. return Ok(JsonView(false));
  12113. }
  12114. #region op
  12115. ///// <summary>
  12116. ///// 移动端更新费用消息通知
  12117. ///// </summary>
  12118. ///// <param name="draftId"></param>
  12119. ///// <param name="id"></param>
  12120. ///// <param name="currUserId"></param>
  12121. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  12122. //{
  12123. // try
  12124. // {
  12125. // ////生成默认文件pdf并且通知人员
  12126. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  12127. // //{
  12128. // // DiId = draftId,
  12129. // // ExportType = 1,
  12130. // // SubTypeId = 1005
  12131. // //}, "pdf");
  12132. // ////发送通知
  12133. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  12134. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  12135. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  12136. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  12137. // ////汇率信息记录
  12138. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  12139. // }
  12140. // catch (Exception ex)
  12141. // {
  12142. // //记录日志
  12143. // throw;
  12144. // }
  12145. //}
  12146. /// <summary>
  12147. /// 验证出入境费用数据是否存在
  12148. /// 不存在添加
  12149. /// </summary>
  12150. /// <param name="draftId"></param>
  12151. /// <param name="currUserId"></param>
  12152. /// <returns></returns>
  12153. /// <exception cref="CustomException"></exception>
  12154. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  12155. {
  12156. var parentId = 0;
  12157. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  12158. if (info != null) parentId = info.Id;
  12159. else
  12160. {
  12161. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  12162. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  12163. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  12164. parentId = addId;
  12165. }
  12166. return parentId;
  12167. }
  12168. /// <summary>
  12169. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  12170. /// </summary>
  12171. /// <returns></returns>
  12172. [HttpPost]
  12173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12174. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  12175. {
  12176. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12177. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12178. //验证查看权限
  12179. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12180. if (!isView) return Ok(JsonView(false, _viewPermStr));
  12181. var userIds = await _sqlSugar
  12182. .Queryable<Grp_EnterExitCostDraftPermission>()
  12183. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  12184. .Select(x => x.UserId)
  12185. .ToArrayAsync();
  12186. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  12187. var perUsersView = new List<dynamic>();
  12188. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  12189. var viewPermissionData = new List<PermissionViewUserview>();
  12190. if (feeBasePerm.Any())
  12191. {
  12192. foreach (var item in feeBasePerm)
  12193. {
  12194. if (item.Users.Any())
  12195. {
  12196. viewPermissionData.AddRange(item.Users);
  12197. }
  12198. }
  12199. }
  12200. foreach (var item in perUsers)
  12201. {
  12202. bool isView1 = false;
  12203. if (userIds.Any(x => x == item.Id)) isView1 = true;
  12204. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  12205. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  12206. }
  12207. return Ok(JsonView(perUsersView));
  12208. }
  12209. /// <summary>
  12210. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  12211. /// </summary>
  12212. /// <returns></returns>
  12213. [HttpPost]
  12214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12215. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  12216. {
  12217. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12218. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12219. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  12220. //验证查看编辑权限
  12221. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12222. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12223. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  12224. foreach (var userId in dto.UserIds)
  12225. {
  12226. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  12227. }
  12228. if (permissions.Any())
  12229. {
  12230. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  12231. {
  12232. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  12233. }
  12234. _sqlSugar.BeginTran();
  12235. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  12236. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  12237. if (result < 1)
  12238. {
  12239. _sqlSugar.RollbackTran();
  12240. return Ok(JsonView(false));
  12241. }
  12242. _sqlSugar.CommitTran();
  12243. return Ok(JsonView(true));
  12244. }
  12245. return Ok(JsonView(false));
  12246. }
  12247. /// <summary>
  12248. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  12249. /// </summary>
  12250. /// <returns></returns>
  12251. [HttpPost]
  12252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12253. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  12254. {
  12255. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12256. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12257. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12258. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  12259. int id = dto.DraftId;
  12260. if (id <= 0) //add
  12261. {
  12262. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12263. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  12264. if (add < 1) return Ok(JsonView(false));
  12265. id = add;
  12266. }
  12267. else //update
  12268. {
  12269. //验证查看编辑权限
  12270. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12271. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12272. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  12273. if (upd < 1) return Ok(JsonView(false));
  12274. }
  12275. return Ok(JsonView(new { parentId = id }));
  12276. }
  12277. /// <summary>
  12278. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  12279. /// </summary>
  12280. /// <returns></returns>
  12281. [HttpPost]
  12282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12283. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  12284. {
  12285. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12286. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12287. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12288. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  12289. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  12290. int id = dto.DraftId;
  12291. if (id <= 0) //add
  12292. {
  12293. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12294. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  12295. if (add < 1) return Ok(JsonView(false));
  12296. id = add;
  12297. }
  12298. else //update
  12299. {
  12300. //验证查看编辑权限
  12301. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12302. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12303. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  12304. if (upd < 1) return Ok(JsonView(false));
  12305. }
  12306. #region 汇率变更时更改币种相关费用
  12307. var opDayCosts = new List<Grp_DayAndCostDraft>();
  12308. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  12309. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  12310. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12311. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  12312. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  12313. .Select((dac, sd) => new
  12314. {
  12315. dac.Id,
  12316. dac.ParentId,
  12317. CurrencyCode = sd.Name,
  12318. dac.Cost
  12319. })
  12320. .ToList();
  12321. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  12322. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  12323. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  12324. .Select((dop, sd) => new
  12325. {
  12326. dop.Id,
  12327. dop.ParentId,
  12328. CurrencyCode = sd.Name,
  12329. dop.Cost
  12330. })
  12331. .ToList();
  12332. if (dayCosts.Count > 0)
  12333. {
  12334. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  12335. foreach (var dc in new_dayCosts)
  12336. {
  12337. var thisCurrency = dc.Key.ToUpper();
  12338. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  12339. if (thisRate == 0.00M) continue;
  12340. foreach (var dcSub in dc)
  12341. {
  12342. opDayCosts.Add(new Grp_DayAndCostDraft()
  12343. {
  12344. Id = dcSub.Id,
  12345. ParentId = dcSub.ParentId,
  12346. Cost = dcSub.Cost,
  12347. SubTotal = dcSub.Cost * thisRate,
  12348. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  12349. });
  12350. }
  12351. }
  12352. if (opDayCosts.Count > 0)
  12353. {
  12354. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  12355. }
  12356. }
  12357. if (dayOtherCosts.Count > 0)
  12358. {
  12359. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  12360. foreach (var dc in new_dayOtherCosts)
  12361. {
  12362. var thisCurrency = dc.Key.ToUpper();
  12363. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  12364. if (thisRate == 0.00M) continue;
  12365. foreach (var dcSub in dc)
  12366. {
  12367. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  12368. {
  12369. Id = dcSub.Id,
  12370. ParentId = dcSub.ParentId,
  12371. Cost = dcSub.Cost,
  12372. SubTotal = dcSub.Cost * thisRate,
  12373. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  12374. });
  12375. }
  12376. }
  12377. if (opDayOtherCosts.Count > 0)
  12378. {
  12379. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  12380. }
  12381. }
  12382. #endregion
  12383. ////消息通知
  12384. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12385. ////汇率信息记录
  12386. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  12387. return Ok(JsonView(new { parentId = id }));
  12388. }
  12389. /// <summary>
  12390. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  12391. /// </summary>
  12392. /// <returns></returns>
  12393. [HttpPost]
  12394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12395. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  12396. {
  12397. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12398. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12399. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12400. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12401. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12402. int id = dto.DraftId;
  12403. if (id <= 0) //add
  12404. {
  12405. checkboxInfo.ProvinceId = dto.ProvinceId;
  12406. checkboxInfo.CreateUserId = dto.CurrUserId;
  12407. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  12408. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  12409. if (add < 1) return Ok(JsonView(false));
  12410. }
  12411. else //update
  12412. {
  12413. var upd = await _sqlSugar.Updateable(checkboxInfo)
  12414. .UpdateColumns(x => new
  12415. {
  12416. x.ChoiceOne,
  12417. x.ChoiceTwo,
  12418. x.SumJJC,
  12419. x.SumGWC,
  12420. x.SumTDC,
  12421. x.ChoiceThree,
  12422. x.ChoiceFour,
  12423. x.ChoiceFive,
  12424. x.ChoiceSix,
  12425. x.OtherExpenses_Checked
  12426. })
  12427. .Where(x => x.Id == id)
  12428. .ExecuteCommandAsync();
  12429. if (upd < 1) return Ok(JsonView(false));
  12430. }
  12431. return Ok(JsonView(new { parentId = id }));
  12432. }
  12433. /// <summary>
  12434. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  12435. /// </summary>
  12436. /// <returns></returns>
  12437. [HttpPost]
  12438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12439. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  12440. {
  12441. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  12442. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  12443. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12444. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12445. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12446. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  12447. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12448. var checkboxInfo = new Grp_EnterExitCostDraft()
  12449. {
  12450. Id = draftId,
  12451. ProvinceId = dto.ProvinceId,
  12452. CreateUserId = currUserId
  12453. };
  12454. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  12455. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  12456. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  12457. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  12458. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  12459. if (draftId <= 0) //add
  12460. {
  12461. checkboxInfo.CreateUserId = dto.CurrUserId;
  12462. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12463. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  12464. if (add < 1) return Ok(JsonView(false));
  12465. }
  12466. else //update
  12467. {
  12468. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  12469. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  12470. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  12471. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  12472. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  12473. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  12474. .Where(x => x.Id == draftId)
  12475. .ExecuteCommandAsync();
  12476. if (upd < 1) return Ok(JsonView(false));
  12477. }
  12478. return Ok(JsonView(new { parentId = draftId }));
  12479. }
  12480. /// <summary>
  12481. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  12482. /// </summary>
  12483. /// <returns></returns>
  12484. [HttpPost]
  12485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12486. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  12487. {
  12488. int id = dto.DraftId, currUserId = dto.CurrUserId;
  12489. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12490. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  12491. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12492. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12493. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12494. info.ProvinceId = dto.ProvinceId;
  12495. info.FirstItemRemark = dto.FirstItemRemark;
  12496. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  12497. if (id <= 0) //add
  12498. {
  12499. info.CreateUserId = dto.CurrUserId;
  12500. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12501. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  12502. if (add < 1) return Ok(JsonView(false));
  12503. id = add;
  12504. }
  12505. else //update
  12506. {
  12507. var upd = await _sqlSugar.Updateable(info)
  12508. .UpdateColumns(x => new
  12509. {
  12510. x.ChoiceOne,
  12511. x.InsidePay,
  12512. x.VisaRemark,
  12513. x.Visa,
  12514. x.Service,
  12515. x.Safe,
  12516. x.Ticket,
  12517. x.HeSuan,
  12518. x.YiMiao,
  12519. x.FirstItemRemark
  12520. })
  12521. .Where(x => x.Id == id)
  12522. .ExecuteCommandAsync();
  12523. if (upd < 1) return Ok(JsonView(false));
  12524. }
  12525. ////消息通知
  12526. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12527. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  12528. }
  12529. /// <summary>
  12530. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  12531. /// </summary>
  12532. /// <returns></returns>
  12533. [HttpPost]
  12534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12535. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  12536. {
  12537. int id = dto.DraftId;
  12538. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12539. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  12540. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12541. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12542. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12543. info.ProvinceId = dto.ProvinceId;
  12544. info.OutsideJJPay = dto.OutsideJJPay;
  12545. info.OutsideGWPay = dto.OutsideGWPay;
  12546. info.OutsideTDPay = dto.OutsideTDPay;
  12547. info.AirJJ = dto.AirJJ;
  12548. info.AirGW = dto.AirGW;
  12549. info.AirTD = dto.AirTD;
  12550. info.CityTranffic = dto.CityTranffic;
  12551. info.TwoItemRemark = dto.TwoItemRemark;
  12552. info.SumJJC = dto.ChoiceTwoJJ;
  12553. info.SumGWC = dto.ChoiceTwoGW;
  12554. info.SumTDC = dto.ChoiceTwoTD;
  12555. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  12556. if (id <= 0) //add
  12557. {
  12558. info.CreateUserId = dto.CurrUserId;
  12559. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12560. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  12561. if (addId <= 0) return Ok(JsonView(false));
  12562. id = addId;
  12563. }
  12564. else //update
  12565. {
  12566. var upd = await _sqlSugar.Updateable(info)
  12567. .UpdateColumns(x => new
  12568. {
  12569. x.SumJJC,
  12570. x.OutsideJJPay,
  12571. x.SumGWC,
  12572. x.OutsideGWPay,
  12573. x.SumTDC,
  12574. x.OutsideTDPay,
  12575. x.AirJJ,
  12576. x.AirGW,
  12577. x.AirTD,
  12578. x.CityTranffic,
  12579. x.TwoItemRemark
  12580. })
  12581. .Where(x => x.Id == id)
  12582. .ExecuteCommandAsync();
  12583. if (upd < 1) return Ok(JsonView(false));
  12584. }
  12585. jjcItemTotal = info.AirJJ + info.CityTranffic;
  12586. gwcItemTotal = info.AirGW + info.CityTranffic;
  12587. tdcItemTotal = info.AirTD + info.CityTranffic;
  12588. ////消息通知
  12589. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12590. return Ok(JsonView(new
  12591. {
  12592. parentId = id,
  12593. choiceTwoJJ = dto.ChoiceTwoJJ,
  12594. jjcItemTotal = jjcItemTotal,
  12595. choiceTwoGW = dto.ChoiceTwoGW,
  12596. gwcItemTotal = gwcItemTotal,
  12597. choiceTwoTD = dto.ChoiceTwoTD,
  12598. tdcItemTotal = tdcItemTotal
  12599. }));
  12600. }
  12601. /// <summary>
  12602. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  12603. /// </summary>
  12604. /// <returns></returns>
  12605. [HttpPost]
  12606. [ApiExplorerSettings(IgnoreApi = true)]
  12607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12608. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  12609. {
  12610. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12611. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12612. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12613. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  12614. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  12615. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12616. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  12617. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  12618. {
  12619. Id = x.Id,
  12620. ParentId = dto.DraftId,
  12621. Type = dto.FeeType,
  12622. Days = x.Days,
  12623. NationalTravelFeeId = x.NationalTravelFeeId,
  12624. Cost = x.Cost,
  12625. Currency = x.Currency,
  12626. SubTotal = x.SubTotal,
  12627. CreateUserId = dto.CurrUserId
  12628. })
  12629. .ToList();
  12630. var adds = infos.Where(x => x.Id <= 0).ToList();
  12631. var upds = infos.Where(x => x.Id > 0).ToList();
  12632. if (adds.Count > 0)
  12633. {
  12634. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12635. if (add < 1) return Ok(JsonView(false));
  12636. }
  12637. if (upds.Count > 0)
  12638. {
  12639. var upd = await _sqlSugar.Updateable(adds)
  12640. .UpdateColumns(x => new
  12641. {
  12642. x.Days,
  12643. x.NationalTravelFeeId,
  12644. x.Cost,
  12645. x.Currency,
  12646. x.SubTotal
  12647. })
  12648. .WhereColumns(x => new { x.Id })
  12649. .ExecuteCommandAsync();
  12650. if (upd < 1) return Ok(JsonView(false));
  12651. }
  12652. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  12653. ////消息通知
  12654. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  12655. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12656. return Ok(JsonView(new { itemTotal = itemTotal }));
  12657. }
  12658. /// <summary>
  12659. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  12660. /// </summary>
  12661. /// <returns></returns>
  12662. [HttpPost]
  12663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12664. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  12665. {
  12666. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  12667. int subId = dto.SubId, feeType = dto.FeeType;
  12668. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12669. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12670. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12671. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12672. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  12673. subInfo.Id = subId;
  12674. subInfo.ParentId = dto.DraftId;
  12675. if (feeType == 3) subInfo.Type = 1;
  12676. else if (feeType == 4) subInfo.Type = 2;
  12677. else if (feeType == 5) subInfo.Type = 3;
  12678. else if (feeType == 6) subInfo.Type = 4;
  12679. subInfo.CreateUserId = dto.CurrUserId;
  12680. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  12681. if (parentId < 1) return Ok(JsonView(false));
  12682. //子表op
  12683. if (subId < 1)
  12684. {
  12685. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12686. if (subAdd < 1) return Ok(JsonView(false));
  12687. }
  12688. else
  12689. {
  12690. var subUpd = await _sqlSugar.Updateable(subInfo)
  12691. .UpdateColumns(x => new
  12692. {
  12693. x.Days,
  12694. x.NationalTravelFeeId,
  12695. x.Cost,
  12696. x.Currency,
  12697. x.SubTotal
  12698. })
  12699. .WhereColumns(x => new { x.Id })
  12700. .ExecuteCommandAsync();
  12701. if (subUpd < 1) return Ok(JsonView(false));
  12702. }
  12703. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  12704. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12705. }
  12706. /// <summary>
  12707. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  12708. /// </summary>
  12709. /// <returns></returns>
  12710. [HttpPost]
  12711. [ApiExplorerSettings(IgnoreApi = true)]
  12712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12713. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  12714. {
  12715. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12716. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12717. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12718. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  12719. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  12720. {
  12721. Id = x.Id,
  12722. ParentId = dto.DraftId,
  12723. SetDataId = x.SetDataId,
  12724. Index = x.Index,
  12725. Cost = x.Cost,
  12726. Currency = x.Currency,
  12727. SubTotal = x.SubTotal,
  12728. CreateUserId = dto.CurrUserId,
  12729. Remark = x.Remark
  12730. }).ToList();
  12731. var adds = infos.Where(x => x.Id <= 0).ToList();
  12732. var upds = infos.Where(x => x.Id > 0).ToList();
  12733. if (adds.Count > 0)
  12734. {
  12735. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12736. if (add < 1) return Ok(JsonView(false));
  12737. }
  12738. if (upds.Count > 0)
  12739. {
  12740. var upd = await _sqlSugar.Updateable(adds)
  12741. .UpdateColumns(x => new
  12742. {
  12743. x.Index,
  12744. x.SetDataId,
  12745. x.Cost,
  12746. x.Currency,
  12747. x.SubTotal,
  12748. x.Remark
  12749. })
  12750. .WhereColumns(x => new { x.Id })
  12751. .ExecuteCommandAsync();
  12752. if (upd < 1) return Ok(JsonView(false));
  12753. }
  12754. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  12755. //消息通知
  12756. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  12757. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12758. return Ok(JsonView(new { itemTotal = itemTotal }));
  12759. }
  12760. /// <summary>
  12761. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  12762. /// </summary>
  12763. /// <returns></returns>
  12764. [HttpPost]
  12765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12766. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  12767. {
  12768. int subId = dto.SubId, id = dto.DraftId;
  12769. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12770. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  12771. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12772. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  12773. subInfo.Id = subId;
  12774. subInfo.ParentId = id;
  12775. subInfo.CreateUserId = dto.CurrUserId;
  12776. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  12777. if (parentId < 1) return Ok(JsonView(false));
  12778. #region 子表op
  12779. if (subId < 1)//add
  12780. {
  12781. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12782. if (subAdd < 1) return Ok(JsonView(false));
  12783. }
  12784. else //upd
  12785. {
  12786. var subUpd = await _sqlSugar.Updateable(subInfo)
  12787. .UpdateColumns(x => new
  12788. {
  12789. x.Index,
  12790. x.SetDataId,
  12791. x.Cost,
  12792. x.Currency,
  12793. x.SubTotal,
  12794. x.Remark
  12795. })
  12796. .WhereColumns(x => new { x.Id })
  12797. .ExecuteCommandAsync();
  12798. if (subUpd < 1) return Ok(JsonView(false));
  12799. }
  12800. #endregion
  12801. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  12802. ////消息通知
  12803. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  12804. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12805. }
  12806. /// <summary>
  12807. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  12808. /// </summary>
  12809. /// <returns></returns>
  12810. [HttpPost]
  12811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12812. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  12813. {
  12814. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  12815. if (data.Code != 0)
  12816. {
  12817. return Ok(JsonView(false, data.Msg));
  12818. }
  12819. return Ok(JsonView(true, "操作成功!", data.Data));
  12820. }
  12821. /// <summary>
  12822. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  12823. /// </summary>
  12824. /// <param name="dto"></param>
  12825. /// <returns></returns>
  12826. [HttpPost]
  12827. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  12828. {
  12829. var data = new Grp_DayOtherPriceDraft()
  12830. {
  12831. Id = dto.Id,
  12832. IsDel = 1,
  12833. DeleteUserId = dto.DeleteUserId,
  12834. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  12835. };
  12836. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  12837. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  12838. return Ok(JsonView(false, "删除失败!"));
  12839. }
  12840. #endregion
  12841. #endregion
  12842. #region 团组经理模块 出入境费用报价表
  12843. /// <summary>
  12844. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  12845. /// </summary>
  12846. /// <returns></returns>
  12847. [HttpPost]
  12848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12849. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  12850. {
  12851. var initRates = await GeneralMethod.EnterExitCostInitRate();
  12852. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  12853. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  12854. initRates.Insert(0, cnyInfo);
  12855. liveRates.Insert(0, cnyInfo);
  12856. return Ok(JsonView(true, "查询成功!", new
  12857. {
  12858. InitRates = initRates,
  12859. LiveRates = liveRates
  12860. }));
  12861. }
  12862. /// <summary>
  12863. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  12864. /// </summary>
  12865. /// <returns></returns>
  12866. [HttpPost]
  12867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12868. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  12869. {
  12870. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  12871. }
  12872. /// <summary>
  12873. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  12874. /// </summary>
  12875. /// <returns></returns>
  12876. [HttpPost]
  12877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12878. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  12879. {
  12880. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  12881. }
  12882. /// <summary>
  12883. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  12884. /// </summary>
  12885. /// <returns></returns>
  12886. [HttpPost]
  12887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12888. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  12889. {
  12890. int groupId = dto.DiId,
  12891. currUserId = dto.CurrUserId;
  12892. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  12893. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  12894. //验证报价数据是否存在
  12895. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  12896. if (isNull != null)
  12897. {
  12898. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  12899. if (!info1.Rates.Any())
  12900. {
  12901. var rates = await GeneralMethod.EnterExitCostInitRate();
  12902. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12903. info1.Rates = rates.ToArray();
  12904. }
  12905. return Ok(JsonView(info1));
  12906. }
  12907. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  12908. result.GroupId = groupId;
  12909. //处理报价名称
  12910. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  12911. if (groupInfo != null)
  12912. {
  12913. var visitCountry = groupInfo.VisitCountry;
  12914. if (!string.IsNullOrEmpty(visitCountry))
  12915. {
  12916. string quoteName = string.Empty;
  12917. if (visitCountry.Contains("|"))
  12918. {
  12919. var countrys = visitCountry.Split("|");
  12920. quoteName = string.Join("、", countrys);
  12921. }
  12922. else quoteName = visitCountry;
  12923. quoteName += $"团组报价表";
  12924. result.Name = quoteName;
  12925. }
  12926. }
  12927. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  12928. if (info.Code != StatusCodes.Status200OK)
  12929. {
  12930. if (!result.Rates.Any())
  12931. {
  12932. var rates = await GeneralMethod.EnterExitCostInitRate();
  12933. result.Rates = rates.ToArray();
  12934. }
  12935. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  12936. }
  12937. var infoView = info.Data as EnterExitCostInfoView;
  12938. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  12939. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  12940. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  12941. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  12942. var eecRates = infoView.Currencys;
  12943. //默认添加人名币
  12944. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  12945. {
  12946. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12947. }
  12948. //处理团组人数
  12949. int pplNum = 1;
  12950. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  12951. var views = new List<QuoteSubItemInfo>();
  12952. #region 数据填充
  12953. var intTravelCosts = new List<QuoteSubItemInfo>();
  12954. #region 机票费用 1354
  12955. int intTravelIndex = 1;
  12956. if (infoView.SumJJC == 1)
  12957. {
  12958. intTravelCosts.Add(new QuoteSubItemInfo
  12959. {
  12960. ItemId = 1354,
  12961. Index = intTravelIndex,
  12962. FeeName = "经济舱",
  12963. UnitPrice = infoView.AirJJ,
  12964. Currency = "CNY",
  12965. Quantity = 1,
  12966. PplNum = 1,
  12967. TotalAmt = infoView.AirJJ,
  12968. Remark = "",
  12969. });
  12970. intTravelIndex++;
  12971. }
  12972. if (infoView.SumGWC == 1)
  12973. {
  12974. intTravelCosts.Add(new QuoteSubItemInfo
  12975. {
  12976. ItemId = 1354,
  12977. Index = intTravelIndex,
  12978. FeeName = "公务舱",
  12979. UnitPrice = infoView.AirGW,
  12980. Currency = "CNY",
  12981. Quantity = 1,
  12982. PplNum = 1,
  12983. TotalAmt = infoView.AirGW,
  12984. Remark = "",
  12985. });
  12986. intTravelIndex++;
  12987. }
  12988. if (infoView.SumTDC == 1)
  12989. {
  12990. intTravelCosts.Add(new QuoteSubItemInfo
  12991. {
  12992. ItemId = 1354,
  12993. Index = intTravelIndex,
  12994. FeeName = "头等舱",
  12995. UnitPrice = infoView.AirTD,
  12996. Currency = "CNY",
  12997. Quantity = 1,
  12998. PplNum = 1,
  12999. TotalAmt = infoView.AirTD,
  13000. Remark = "",
  13001. });
  13002. intTravelIndex++;
  13003. }
  13004. intTravelCosts.Add(new QuoteSubItemInfo
  13005. {
  13006. ItemId = 1354,
  13007. Index = intTravelIndex,
  13008. FeeName = "城市间交通费用",
  13009. UnitPrice = infoView.CityTranffic,
  13010. Currency = "CNY",
  13011. Quantity = 1,
  13012. PplNum = pplNum,
  13013. TotalAmt = infoView.CityTranffic * pplNum,
  13014. Remark = "",
  13015. });
  13016. views.AddRange(intTravelCosts);
  13017. #endregion
  13018. var accomCosts = new List<QuoteSubItemInfo>();
  13019. #region 住宿费 1355
  13020. if (infoView.QuarterageData.Any())
  13021. {
  13022. int accomIndex = 1;
  13023. int accomItemTypeId = 1355;
  13024. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  13025. foreach (var item in groupData)
  13026. {
  13027. string feeName = string.Empty;
  13028. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13029. if (countryInfo != null)
  13030. {
  13031. feeName = countryInfo.Country;
  13032. var city = countryInfo.City;
  13033. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13034. {
  13035. feeName += $"-{city}";
  13036. }
  13037. }
  13038. var hotelInfo = item.FirstOrDefault();
  13039. if (hotelInfo == null) continue;
  13040. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  13041. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13042. int quantity = item.ToList().Count;
  13043. accomCosts.Add(new QuoteSubItemInfo
  13044. {
  13045. ItemId = accomItemTypeId,
  13046. Index = accomIndex,
  13047. FeeName = feeName,
  13048. UnitPrice = hotelInfo.Cost,
  13049. Currency = thisCurrency,
  13050. Quantity = quantity,
  13051. PplNum = pplNum,
  13052. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  13053. Remark = "",
  13054. });
  13055. accomIndex++;
  13056. }
  13057. views.AddRange(accomCosts);
  13058. }
  13059. #endregion
  13060. var mealCosts = new List<QuoteSubItemInfo>();
  13061. #region 餐饮费 1356
  13062. if (infoView.BoardWagesData.Any())
  13063. {
  13064. var mealIndex = 1;
  13065. int mealItemTypeId = 1356;
  13066. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  13067. foreach (var item in groupData)
  13068. {
  13069. string feeName = string.Empty;
  13070. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13071. if (countryInfo != null)
  13072. {
  13073. feeName = countryInfo.Country;
  13074. var city = countryInfo.City;
  13075. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13076. {
  13077. feeName += $"-{city}";
  13078. }
  13079. }
  13080. var mealInfo = item.FirstOrDefault();
  13081. if (mealInfo == null) continue;
  13082. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  13083. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13084. int quantity = item.ToList().Count;
  13085. mealCosts.Add(new QuoteSubItemInfo
  13086. {
  13087. ItemId = mealItemTypeId,
  13088. Index = mealIndex,
  13089. FeeName = feeName,
  13090. UnitPrice = mealInfo.Cost,
  13091. Currency = thisCurrency,
  13092. Quantity = quantity,
  13093. PplNum = pplNum,
  13094. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  13095. Remark = "",
  13096. });
  13097. mealIndex++;
  13098. }
  13099. views.AddRange(mealCosts);
  13100. }
  13101. #endregion
  13102. var miscCosts = new List<QuoteSubItemInfo>();
  13103. #region 公杂费 1364
  13104. if (infoView.MiscellaneousFeeData.Any())
  13105. {
  13106. var miscIndex = 1;
  13107. int miscItemTypeId = 1364;
  13108. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  13109. foreach (var item in groupData)
  13110. {
  13111. string feeName = string.Empty;
  13112. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13113. if (countryInfo != null)
  13114. {
  13115. feeName = countryInfo.Country;
  13116. var city = countryInfo.City;
  13117. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13118. {
  13119. feeName += $"-{city}";
  13120. }
  13121. }
  13122. var miscInfo = item.FirstOrDefault();
  13123. if (miscInfo == null) continue;
  13124. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  13125. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13126. int quantity = item.ToList().Count;
  13127. miscCosts.Add(new QuoteSubItemInfo
  13128. {
  13129. ItemId = miscItemTypeId,
  13130. Index = miscIndex,
  13131. FeeName = feeName,
  13132. UnitPrice = miscInfo.Cost,
  13133. Currency = thisCurrency,
  13134. Quantity = quantity,
  13135. PplNum = pplNum,
  13136. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  13137. Remark = "",
  13138. });
  13139. miscIndex++;
  13140. }
  13141. views.AddRange(miscCosts);
  13142. }
  13143. #endregion
  13144. #region 签证+保险 1362
  13145. int visaInsIndex = 1;
  13146. int visaInsItemTypeId = 1362;
  13147. if (infoView.Visa > 0)
  13148. {
  13149. views.Add(new QuoteSubItemInfo()
  13150. {
  13151. ItemId = visaInsItemTypeId,
  13152. Index = visaInsIndex,
  13153. FeeName = $"签证",
  13154. UnitPrice = infoView.Visa,
  13155. Currency = $"CNY",
  13156. Quantity = 1,
  13157. PplNum = pplNum,
  13158. TotalAmt = infoView.Visa * pplNum,
  13159. Remark = "",
  13160. });
  13161. visaInsIndex++;
  13162. }
  13163. if (infoView.Safe > 0)
  13164. {
  13165. views.Add(new QuoteSubItemInfo()
  13166. {
  13167. ItemId = visaInsItemTypeId,
  13168. Index = visaInsIndex,
  13169. FeeName = $"保险",
  13170. UnitPrice = infoView.Safe,
  13171. Currency = $"CNY",
  13172. Quantity = 1,
  13173. PplNum = pplNum,
  13174. TotalAmt = infoView.Safe * pplNum,
  13175. Remark = "",
  13176. });
  13177. }
  13178. #endregion
  13179. #region 服务费 1363
  13180. int serviceFeeIndex = 1;
  13181. int serviceFeeItemTypeId = 1363;
  13182. if (infoView.Service > 0)
  13183. {
  13184. views.Add(new QuoteSubItemInfo()
  13185. {
  13186. ItemId = serviceFeeItemTypeId,
  13187. Index = serviceFeeIndex,
  13188. FeeName = $"服务费",
  13189. UnitPrice = infoView.Service,
  13190. Currency = $"CNY",
  13191. Quantity = 1,
  13192. PplNum = pplNum,
  13193. TotalAmt = infoView.Service * pplNum,
  13194. Remark = "",
  13195. });
  13196. }
  13197. #endregion
  13198. #endregion
  13199. if (result.FeeItems.Any())
  13200. {
  13201. result.FeeItems.Select(x =>
  13202. {
  13203. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  13204. if (feeInfos.Any()) x.Infos = feeInfos;
  13205. return x;
  13206. }
  13207. ).OrderBy(x => x.Index)
  13208. .ToList();
  13209. if (!result.Rates.Any())
  13210. {
  13211. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  13212. else
  13213. {
  13214. var rates = await GeneralMethod.EnterExitCostInitRate();
  13215. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13216. result.Rates = rates.ToArray();
  13217. }
  13218. }
  13219. }
  13220. return Ok(JsonView(result));
  13221. }
  13222. /// <summary>
  13223. /// 团组模块 - 出入境费用报价表 - Info
  13224. /// </summary>
  13225. /// <returns></returns>
  13226. [HttpPost]
  13227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13228. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  13229. {
  13230. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  13231. if (!info.Rates.Any())
  13232. {
  13233. var rates = await GeneralMethod.EnterExitCostInitRate();
  13234. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13235. info.Rates = rates.ToArray();
  13236. }
  13237. return Ok(JsonView(info));
  13238. }
  13239. /// <summary>
  13240. /// 团组模块 - 出入境费用报价表 - OP
  13241. /// </summary>
  13242. /// <returns></returns>
  13243. [HttpPost]
  13244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13245. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  13246. {
  13247. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  13248. }
  13249. /// <summary>
  13250. /// 团组模块 - 出入境费用报价表 - 删除 项
  13251. /// </summary>
  13252. /// <returns></returns>
  13253. [HttpPost]
  13254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13255. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  13256. {
  13257. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  13258. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13259. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  13260. }
  13261. /// <summary>
  13262. /// 团组模块 - 出入境费用报价表 - 导出
  13263. /// </summary>
  13264. /// <returns></returns>
  13265. [HttpPost]
  13266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13267. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  13268. {
  13269. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  13270. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13271. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  13272. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  13273. var rates = info.Rates;
  13274. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  13275. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  13276. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  13277. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  13278. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  13279. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  13280. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  13281. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  13282. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  13283. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  13284. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  13285. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  13286. //获取模板
  13287. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  13288. var designer = new WorkbookDesigner();
  13289. designer.Workbook = new Workbook(tempPath);
  13290. designer.SetDataSource("QuoteName", info.Name);
  13291. designer.SetDataSource("CompanyTitle", "公司名称");
  13292. designer.SetDataSource("CompanyLabel", "");
  13293. #region 国际旅费
  13294. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  13295. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  13296. {
  13297. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  13298. var label = new StringBuilder();
  13299. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  13300. if (infos.Any())
  13301. {
  13302. label.Append(infos.Sum(x => x.PplNum));
  13303. label.Append("人全程机票:");
  13304. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  13305. label.AppendLine("元");
  13306. }
  13307. foreach (var item in intTravelCosts.Infos)
  13308. {
  13309. label.Append(item.FeeName);
  13310. label.Append(":");
  13311. label.Append(item.UnitPrice.TruncDecimals(2));
  13312. label.Append("元/人*");
  13313. label.Append(item.PplNum);
  13314. label.AppendLine("人");
  13315. }
  13316. if (label.HasValue())
  13317. {
  13318. label.Append("\r\n以上小计:");
  13319. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  13320. label.Append("元");
  13321. }
  13322. designer.SetDataSource("IntTravelLabel", label.ToString());
  13323. }
  13324. #endregion
  13325. #region 住宿费
  13326. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  13327. if (accomCosts != null && accomCosts.Infos.Any())
  13328. {
  13329. string currencyName = string.Empty,
  13330. countryName = string.Empty;
  13331. decimal rate = 1.0000M;
  13332. var label = new StringBuilder();
  13333. label.AppendLine("全程五星酒店,每人1间房");
  13334. foreach (var item in accomCosts.Infos)
  13335. {
  13336. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  13337. string name = string.Empty, thisCountryName = string.Empty;
  13338. if (item.FeeName.Contains('-'))
  13339. {
  13340. var feeName = item.FeeName.Split('-');
  13341. thisCountryName = feeName[0];
  13342. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  13343. name = feeName[1];
  13344. }
  13345. else name = item.FeeName;
  13346. string thisFeeName = string.Empty;
  13347. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  13348. else thisFeeName = $"\r\n{name}:";
  13349. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13350. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13351. rate = rateInfo?.Rate ?? 1.0000M;
  13352. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  13353. label.AppendLine(subLabel);
  13354. }
  13355. if (label.HasValue())
  13356. {
  13357. //以上小计:52440元(美金汇率:7.5 )
  13358. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  13359. label.AppendLine(subLabel);
  13360. }
  13361. designer.SetDataSource("AccomLabel", label.ToString());
  13362. }
  13363. #endregion
  13364. #region 餐饮费
  13365. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  13366. if (mealCosts != null && mealCosts.Infos.Any())
  13367. {
  13368. string currencyName = string.Empty;
  13369. decimal rate = 1.0000M;
  13370. var label = new StringBuilder();
  13371. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  13372. foreach (var item in mealCosts.Infos)
  13373. {
  13374. string name = string.Empty;
  13375. if (item.FeeName.Contains('-'))
  13376. {
  13377. var feeName = item.FeeName.Split('-');
  13378. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  13379. }
  13380. else name = $"\r\n{item.FeeName}:";
  13381. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13382. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13383. rate = rateInfo?.Rate ?? 1.0000M;
  13384. label.Append(name);
  13385. label.Append(item.UnitPrice.TruncDecimals(2));
  13386. label.Append(currencyName);
  13387. label.Append("/天*");
  13388. label.Append(item.Quantity.ToString("#0"));
  13389. label.Append('*');
  13390. label.Append(item.PplNum);
  13391. label.Append("人\r\n");
  13392. }
  13393. if (label.HasValue())
  13394. {
  13395. label.Append("\r\n以上小计:");
  13396. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  13397. label.Append("元\r\n(");
  13398. label.Append("汇率:");
  13399. label.Append(rate.TruncDecimals(4));
  13400. label.Append(')');
  13401. }
  13402. designer.SetDataSource("MealLabel", label.ToString());
  13403. }
  13404. #endregion
  13405. #region 车辆安排
  13406. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  13407. if (vehArranges != null && vehArranges.Infos.Any())
  13408. {
  13409. string currencyName = string.Empty;
  13410. //decimal rate = 1.0000M;
  13411. var label = new StringBuilder();
  13412. foreach (var item in vehArranges.Infos)
  13413. {
  13414. label.AppendLine();
  13415. label.AppendLine();
  13416. label.Append(item.FeeName);
  13417. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  13418. }
  13419. designer.SetDataSource("VehArrangeLabel", label.ToString());
  13420. }
  13421. #endregion
  13422. #region 邀请函发放对象
  13423. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  13424. designer.SetDataSource("InviteToContent", "");
  13425. #endregion
  13426. #region 邀请函费
  13427. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  13428. var is_label = new StringBuilder();
  13429. if (inviteCosts != null && inviteCosts.Infos.Any())
  13430. {
  13431. string currencyName = string.Empty;
  13432. decimal rate = 1.0000M;
  13433. foreach (var item in inviteCosts.Infos)
  13434. {
  13435. //乌兹别克斯坦:2000美金
  13436. currencyName = item.Currency;
  13437. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  13438. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  13439. is_label.AppendLine(label);
  13440. }
  13441. if (is_label.HasValue())
  13442. {
  13443. //以上小计:28500元(美金汇率:7.5)
  13444. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  13445. is_label.AppendLine(label);
  13446. }
  13447. }
  13448. designer.SetDataSource("InviteCostContent", is_label.ToString());
  13449. #endregion
  13450. #region 邀请函发放时间
  13451. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  13452. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  13453. #endregion
  13454. #region 公务活动(含翻译)
  13455. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  13456. var oa_label = new StringBuilder();
  13457. if (officialActs != null && officialActs.Infos.Any())
  13458. {
  13459. string currencyName = string.Empty;
  13460. decimal rate = 1.0000M;
  13461. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  13462. foreach (var item in officialActs.Infos)
  13463. {
  13464. //乌兹别克斯坦:1000美金/场
  13465. currencyName = item.Currency;
  13466. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  13467. string label_remark = string.Empty;
  13468. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  13469. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  13470. }
  13471. label_content += "*总费用中未含超出公务活动价格";
  13472. //8场公务活动(以上小计:60000元)
  13473. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  13474. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  13475. oa_label.AppendLine(label_title);
  13476. oa_label.AppendLine(label_content);
  13477. }
  13478. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  13479. #endregion
  13480. #region 签证+保险
  13481. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  13482. var vi_label = new StringBuilder();
  13483. if (visaIns != null && visaIns.Infos.Any())
  13484. {
  13485. foreach (var item in visaIns.Infos)
  13486. {
  13487. //签证:500元/人
  13488. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  13489. vi_label.AppendLine(label);
  13490. }
  13491. if (vi_label.HasValue())
  13492. {
  13493. //以上小计:6000元
  13494. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  13495. vi_label.AppendLine(label);
  13496. }
  13497. }
  13498. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  13499. #endregion
  13500. #region 服务费
  13501. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  13502. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  13503. #endregion
  13504. #region 公杂费
  13505. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  13506. var pm_label = new StringBuilder();
  13507. if (pubMiscs != null && pubMiscs.Infos.Any())
  13508. {
  13509. string currencyName = string.Empty,
  13510. countryName = string.Empty;
  13511. decimal rate = 1.0000M;
  13512. foreach (var item in pubMiscs.Infos)
  13513. {
  13514. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  13515. string name = string.Empty, thisCountryName = string.Empty;
  13516. if (item.FeeName.Contains('-'))
  13517. {
  13518. var feeName = item.FeeName.Split('-');
  13519. thisCountryName = feeName[0];
  13520. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  13521. name = feeName[1];
  13522. }
  13523. else name = item.FeeName;
  13524. string thisFeeName = string.Empty;
  13525. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  13526. else thisFeeName = $"\r\n{name}:";
  13527. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13528. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13529. rate = rateInfo?.Rate ?? 1.0000M;
  13530. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  13531. pm_label.AppendLine(label);
  13532. }
  13533. if (pm_label.HasValue())
  13534. {
  13535. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  13536. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  13537. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  13538. pm_label.AppendLine(string.Format("部分发放成员"));
  13539. }
  13540. }
  13541. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  13542. #endregion
  13543. #region 税费
  13544. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  13545. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  13546. #endregion
  13547. #region 合计(单位:元)
  13548. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  13549. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  13550. #endregion
  13551. #region 汇率 Remark
  13552. var rate_label = new StringBuilder();
  13553. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  13554. foreach (var item in rateGroups)
  13555. {
  13556. //美元汇率按\r\n1:7.5
  13557. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  13558. rate_label.AppendLine(label);
  13559. }
  13560. designer.SetDataSource("RateLabel", rate_label.ToString());
  13561. #endregion
  13562. designer.Process();
  13563. //文件名
  13564. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  13565. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  13566. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  13567. return Ok(JsonView(true, "成功", url));
  13568. }
  13569. #endregion
  13570. #region 签证费用录入
  13571. /// <summary>
  13572. /// 根据diid查询签证费用列表
  13573. /// </summary>
  13574. /// <param name="dto"></param>
  13575. /// <returns></returns>
  13576. [HttpPost]
  13577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13578. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  13579. {
  13580. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  13581. if (groupData.Code != 0)
  13582. {
  13583. return Ok(JsonView(false, groupData.Msg));
  13584. }
  13585. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13586. }
  13587. /// <summary>
  13588. /// 根据签证费用Id查询单条数据及c表数据
  13589. /// </summary>
  13590. /// <param name="dto"></param>
  13591. /// <returns></returns>
  13592. [HttpPost]
  13593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13594. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  13595. {
  13596. Result groupData = await _visaPriceRep.PostVisaById(dto);
  13597. if (groupData.Code != 0)
  13598. {
  13599. return Ok(JsonView(false, groupData.Msg));
  13600. }
  13601. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13602. }
  13603. /// <summary>
  13604. /// 签证费用删除
  13605. /// </summary>
  13606. /// <param name="dto"></param>
  13607. /// <returns></returns>
  13608. [HttpPost]
  13609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13610. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  13611. {
  13612. _sqlSugar.BeginTran();
  13613. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  13614. if (!res)
  13615. {
  13616. _sqlSugar.RollbackTran();
  13617. return Ok(JsonView(false, "删除失败"));
  13618. }
  13619. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  13620. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  13621. .SetColumns(a => new Grp_CreditCardPayment()
  13622. {
  13623. IsDel = 1,
  13624. DeleteUserId = dto.DeleteUserId,
  13625. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13626. })
  13627. .ExecuteCommand();
  13628. if (resSub < 1)
  13629. {
  13630. _sqlSugar.RollbackTran();
  13631. return Ok(JsonView(false, "删除失败"));
  13632. }
  13633. _sqlSugar.CommitTran();
  13634. return Ok(JsonView(true, "删除成功!"));
  13635. }
  13636. /// <summary>
  13637. /// 签证费用录入下拉框初始化
  13638. /// </summary>
  13639. /// <returns></returns>
  13640. [HttpPost]
  13641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13642. public async Task<IActionResult> VisaPriceAddSelect()
  13643. {
  13644. //支付方式
  13645. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  13646. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  13647. //币种
  13648. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  13649. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  13650. //乘客类型
  13651. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  13652. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  13653. //卡类型
  13654. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  13655. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  13656. //代办费类型
  13657. var agencyFeeTypeData = new List<dynamic>() {
  13658. new { id = 0 , Text = "未选择" },
  13659. new { id = 1 , Text = "小公务" },
  13660. new { id = 2 , Text = "大公务" },
  13661. };
  13662. //签证费用标准国家Data
  13663. var visaSql = string.Format(@"select
  13664. id,
  13665. case
  13666. when FeeType = 0 then Country+'(因公)'
  13667. when FeeType = 1 then Country+'(因私)'
  13668. else Country+'(未设置)'
  13669. end as 'country'
  13670. from Res_VisaFeeStandard where isdel = 0");
  13671. var visaCountryFeeData = _sqlSugar.SqlQueryable<dynamic>(visaSql).ToList();
  13672. var data = new
  13673. {
  13674. Payment = _Payment,
  13675. CurrencyList = _CurrencyList,
  13676. PassengerType = _PassengerType,
  13677. BankCard = _BankCard,
  13678. AgencyFeeType = agencyFeeTypeData,
  13679. CountryFeeData = visaCountryFeeData
  13680. };
  13681. return Ok(JsonView(true, "查询成功!", data));
  13682. }
  13683. /// <summary>
  13684. /// 签证费用录入操作(Status:1.新增,2.修改)
  13685. /// </summary>
  13686. /// <param name="dto"></param>
  13687. /// <returns></returns>
  13688. [HttpPost]
  13689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13690. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  13691. {
  13692. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  13693. if (groupData.Code != 0)
  13694. {
  13695. return Ok(JsonView(false, groupData.Msg));
  13696. }
  13697. #region 应用推送
  13698. try
  13699. {
  13700. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13701. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13702. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13703. //2024-10-21 新增LZ UID
  13704. var userIds = new List<int>() { 21 };
  13705. string title = $"系统通知";
  13706. string content = "";
  13707. var diId = dto.DiId;
  13708. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13709. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13710. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13711. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13712. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13713. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  13714. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13715. }
  13716. catch (Exception ex)
  13717. {
  13718. }
  13719. #endregion
  13720. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13721. }
  13722. #endregion
  13723. #region 签证提成录入
  13724. /// <summary>
  13725. /// 签证提成录入
  13726. /// 基础数据
  13727. /// </summary>
  13728. /// <returns></returns>
  13729. [HttpGet]
  13730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13731. public async Task<IActionResult> VisaCommissionInit()
  13732. {
  13733. return Ok(await _visaCommissionRep.Init());
  13734. }
  13735. /// <summary>
  13736. /// 签证提成录入
  13737. /// Item
  13738. /// </summary>
  13739. /// <param name="_dto"></param>
  13740. /// <returns></returns>
  13741. [HttpPost]
  13742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13743. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  13744. {
  13745. var validator = new VisaCommissionItemDtoValidator();
  13746. var validatorRes = await validator.ValidateAsync(_dto);
  13747. if (!validatorRes.IsValid)
  13748. {
  13749. var sb = new StringBuilder();
  13750. foreach (var item in validatorRes.Errors)
  13751. {
  13752. sb.AppendLine(item.ErrorMessage);
  13753. }
  13754. return Ok(JsonView(false, sb.ToString()));
  13755. }
  13756. return Ok(await _visaCommissionRep.Item(_dto));
  13757. }
  13758. /// <summary>
  13759. /// 签证提成录入
  13760. /// Save
  13761. /// </summary>
  13762. /// <param name="_dto"></param>
  13763. /// <returns></returns>
  13764. [HttpPost]
  13765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13766. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  13767. {
  13768. //参数验证
  13769. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  13770. foreach (var item in _dto.Items)
  13771. {
  13772. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  13773. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  13774. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  13775. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  13776. }
  13777. return Ok(await _visaCommissionRep.Save(_dto));
  13778. }
  13779. /// <summary>
  13780. /// 签证提成录入
  13781. /// Create
  13782. /// </summary>
  13783. /// <param name="_dto"></param>
  13784. /// <returns></returns>
  13785. [HttpPost]
  13786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13787. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  13788. {
  13789. var validator = new VisaCommissionCreateDtoValidator();
  13790. var validatorRes = await validator.ValidateAsync(_dto);
  13791. if (!validatorRes.IsValid)
  13792. {
  13793. var sb = new StringBuilder();
  13794. foreach (var item in validatorRes.Errors)
  13795. {
  13796. sb.AppendLine(item.ErrorMessage);
  13797. }
  13798. return Ok(JsonView(false, sb.ToString()));
  13799. }
  13800. return Ok(await _visaCommissionRep.Create(_dto));
  13801. }
  13802. /// <summary>
  13803. /// 签证提成录入
  13804. /// Put(编辑)
  13805. /// </summary>
  13806. /// <param name="id"></param>
  13807. /// <param name="_dto"></param>
  13808. /// <returns></returns>
  13809. [HttpPut]
  13810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13811. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  13812. {
  13813. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13814. var validator = new VisaCommissionCreateDtoValidator();
  13815. var validatorRes = await validator.ValidateAsync(_dto);
  13816. if (!validatorRes.IsValid)
  13817. {
  13818. var sb = new StringBuilder();
  13819. foreach (var item in validatorRes.Errors)
  13820. {
  13821. sb.AppendLine(item.ErrorMessage);
  13822. }
  13823. return Ok(JsonView(false, sb.ToString()));
  13824. }
  13825. return Ok(await _visaCommissionRep.Edit(id, _dto));
  13826. }
  13827. /// <summary>
  13828. /// 签证提成录入
  13829. /// Del
  13830. /// </summary>
  13831. /// <param name="id"></param>
  13832. /// <param name="currUserId"></param>
  13833. /// <returns></returns>
  13834. [HttpPost]
  13835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13836. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  13837. {
  13838. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13839. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  13840. return Ok(await _visaCommissionRep.Del(id, currUserId));
  13841. }
  13842. #endregion
  13843. #region op费用录入
  13844. /// <summary>
  13845. /// 根据diid查询op费用列表
  13846. /// </summary>
  13847. /// <param name="dto"></param>
  13848. /// <returns></returns>
  13849. [HttpPost]
  13850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13851. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  13852. {
  13853. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  13854. if (groupData.Code != 0)
  13855. {
  13856. return Ok(JsonView(false, groupData.Msg));
  13857. }
  13858. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13859. }
  13860. /// <summary>
  13861. /// 根据op费用Id查询单条数据及c表数据
  13862. /// </summary>
  13863. /// <param name="dto"></param>
  13864. /// <returns></returns>
  13865. [HttpPost]
  13866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13867. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  13868. {
  13869. try
  13870. {
  13871. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  13872. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  13873. var data = new
  13874. {
  13875. CarTouristGuideGround = _groupData,
  13876. CreditCardPayment = _creditCardPayment
  13877. };
  13878. return Ok(JsonView(true, "查询成功!", data));
  13879. }
  13880. catch (Exception ex)
  13881. {
  13882. return Ok(JsonView(false, "程序错误!"));
  13883. }
  13884. }
  13885. /// <summary>
  13886. /// op费用删除
  13887. /// </summary>
  13888. /// <param name="dto"></param>
  13889. /// <returns></returns>
  13890. [HttpPost]
  13891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13892. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  13893. {
  13894. try
  13895. {
  13896. _sqlSugar.BeginTran();
  13897. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  13898. if (!res)
  13899. {
  13900. return Ok(JsonView(false, "删除失败"));
  13901. }
  13902. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  13903. {
  13904. IsDel = 1,
  13905. DeleteUserId = dto.DeleteUserId,
  13906. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13907. }).ExecuteCommandAsync();
  13908. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  13909. {
  13910. IsDel = 1,
  13911. DeleteUserId = dto.DeleteUserId,
  13912. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13913. }).ExecuteCommandAsync();
  13914. #region 删除超支相关数据
  13915. //删除导入的超支数据
  13916. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  13917. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  13918. {
  13919. IsDel = 1,
  13920. DeleteUserId = dto.DeleteUserId,
  13921. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13922. }).ExecuteCommand();
  13923. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  13924. {
  13925. IsDel = 1,
  13926. DeleteUserId = dto.DeleteUserId,
  13927. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13928. }).ExecuteCommand();
  13929. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  13930. {
  13931. IsDel = 1,
  13932. DeleteUserId = dto.DeleteUserId,
  13933. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13934. }).ExecuteCommand();
  13935. #endregion
  13936. _sqlSugar.CommitTran();
  13937. return Ok(JsonView(true, "删除成功!"));
  13938. }
  13939. catch (Exception ex)
  13940. {
  13941. _sqlSugar.RollbackTran();
  13942. return Ok(JsonView(false, "程序错误!" + ex.Message));
  13943. }
  13944. }
  13945. /// <summary>
  13946. /// op费用录入操作(Status:1.新增,2.修改)
  13947. /// </summary>
  13948. /// <param name="dto"></param>
  13949. /// <returns></returns>
  13950. [HttpPost]
  13951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13952. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  13953. {
  13954. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  13955. if (groupData.Code != 0)
  13956. {
  13957. return Ok(JsonView(false, groupData.Msg));
  13958. }
  13959. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13960. }
  13961. /// <summary>
  13962. /// 填写费用详细页面初始化绑定
  13963. /// </summary>
  13964. /// <param name="dto"></param>
  13965. /// <returns></returns>
  13966. [HttpPost]
  13967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13968. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  13969. {
  13970. try
  13971. {
  13972. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  13973. if (groupData.Code != 0)
  13974. {
  13975. return Ok(JsonView(false, groupData.Msg));
  13976. }
  13977. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13978. }
  13979. catch (Exception ex)
  13980. {
  13981. return Ok(JsonView(false, ex.Message));
  13982. }
  13983. }
  13984. /// <summary>
  13985. /// 根据op费用Id查询详细数据
  13986. /// </summary>
  13987. /// <param name="dto"></param>
  13988. /// <returns></returns>
  13989. [HttpPost]
  13990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13991. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  13992. {
  13993. try
  13994. {
  13995. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  13996. if (groupData.Code != 0)
  13997. {
  13998. return Ok(JsonView(false, groupData.Msg));
  13999. }
  14000. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14001. }
  14002. catch (Exception ex)
  14003. {
  14004. return Ok(JsonView(false, ex.Message));
  14005. }
  14006. }
  14007. /// <summary>
  14008. /// OP费用录入填写详情
  14009. /// </summary>
  14010. /// <param name="dto"></param>
  14011. /// <returns></returns>
  14012. [HttpPost]
  14013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14014. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  14015. {
  14016. try
  14017. {
  14018. #region 参数校验
  14019. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  14020. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  14021. if (di == null) return Ok(JsonView(false, "团组错误!"));
  14022. #endregion
  14023. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  14024. if (groupData.Code != 0)
  14025. {
  14026. return Ok(JsonView(false, groupData.Msg));
  14027. }
  14028. //自动审核
  14029. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  14030. #region 尾款自动审核
  14031. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  14032. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  14033. if (opinfos.PriceType == 1062)
  14034. {
  14035. var isAuto = false;
  14036. //找对应的首付款
  14037. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  14038. .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))
  14039. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  14040. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  14041. x.PriceType == 1061 && x.DiId == dto.DiId);
  14042. if (firstPrice != null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  14043. {
  14044. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  14045. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  14046. //合计中排除城市税
  14047. var cityPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  14048. .Where(x => x.SId == 1452 && x.IsDel == 0 && x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId)
  14049. .Sum(x => x.Price * x.Count);
  14050. opinfos.ServiceQuotedPrice = opinfos.ServiceQuotedPrice - cityPrice;
  14051. if (balance >= opinfos.ServiceQuotedPrice)
  14052. {
  14053. isAuto = true;
  14054. }
  14055. }
  14056. if (isAuto)
  14057. {
  14058. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  14059. .SetColumns(a => new Grp_CreditCardPayment
  14060. {
  14061. IsAuditGM = 3, //自动审核通过
  14062. AuditGMOperate = 4,
  14063. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14064. })
  14065. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  14066. .ExecuteCommand();
  14067. }
  14068. }
  14069. #endregion
  14070. #region 应用推送
  14071. try
  14072. {
  14073. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  14074. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  14075. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14076. //2024-10-21 新增LZ UID
  14077. var userIds = new List<int>() { 21 };
  14078. string title = $"系统通知";
  14079. var diId = dto.DiId;
  14080. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14081. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14082. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  14083. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14084. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  14085. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  14086. }
  14087. catch (Exception ex)
  14088. {
  14089. }
  14090. #endregion
  14091. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14092. }
  14093. catch (Exception ex)
  14094. {
  14095. return Ok(JsonView(false, ex.Message));
  14096. }
  14097. }
  14098. /// <summary>
  14099. /// 获取三公详细所有城市
  14100. /// </summary>
  14101. /// <returns></returns>
  14102. [HttpGet]
  14103. public IActionResult OpCarCityResult()
  14104. {
  14105. var jw = JsonView(false);
  14106. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  14107. {
  14108. x.Id,
  14109. x.Country,
  14110. x.City,
  14111. }).ToList();
  14112. if (data.Count > 0)
  14113. {
  14114. jw = JsonView(true, "获取成功!", data);
  14115. }
  14116. else
  14117. {
  14118. jw.Msg = "城市数据为空!";
  14119. jw.Data = Array.Empty<string>();
  14120. }
  14121. return Ok(jw);
  14122. }
  14123. /// <summary>
  14124. /// 导出地接费用明细
  14125. /// </summary>
  14126. /// <param name="dto"></param>
  14127. /// <returns></returns>
  14128. [HttpPost]
  14129. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  14130. {
  14131. var jw = JsonView(false);
  14132. if (dto.Diid < 1)
  14133. {
  14134. jw.Msg = "请输入正确的diid!";
  14135. return Ok(jw);
  14136. }
  14137. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14138. if (group == null)
  14139. {
  14140. jw.Msg = "未找到团组信息!";
  14141. return Ok(jw);
  14142. }
  14143. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  14144. if (localGuideArr.Count == 0)
  14145. {
  14146. jw.Msg = "该团组暂无地接信息!";
  14147. return Ok(jw);
  14148. }
  14149. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  14150. var overspendSoure = new Dictionary<int, int>
  14151. {
  14152. { 91, 982 }, //车
  14153. { 92 , 1059} ,//导游
  14154. { 994 , 1073}, //翻译
  14155. { 988 , 1074 }, //早餐
  14156. { 93 , 1075 }, //午餐
  14157. { 989 , 1076 }, //晚餐
  14158. };
  14159. var Zips = new Dictionary<string, Stream>();
  14160. foreach (var groupArr in localGroup)
  14161. {
  14162. var keyValue = groupArr.Key;
  14163. if (int.TryParse(keyValue, out int cityid))
  14164. {
  14165. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  14166. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  14167. }
  14168. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  14169. foreach (var item in groupArr)
  14170. {
  14171. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  14172. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  14173. new Grp_CarTouristGuideGroundReservationsContentExtend
  14174. {
  14175. Count = a.Count,
  14176. CreateTime = a.CreateTime,
  14177. CreateUserId = a.CreateUserId,
  14178. CTGGRId = a.CTGGRId,
  14179. Currency = a.Currency,
  14180. DatePrice = a.DatePrice,
  14181. DeleteTime = a.DeleteTime,
  14182. DeleteUserId = a.DeleteUserId,
  14183. DiId = a.DiId,
  14184. Id = a.Id,
  14185. IsDel = a.IsDel,
  14186. Price = a.Price,
  14187. PriceContent = a.PriceContent,
  14188. Remark = a.Remark,
  14189. SId = a.SId,
  14190. SidName = b.Name,
  14191. Units = a.Units,
  14192. }
  14193. ).ToList();
  14194. if (content.Count > 0)
  14195. {
  14196. contentArr.Add(content);
  14197. }
  14198. }
  14199. //open excel
  14200. //set excel
  14201. //save excel
  14202. try
  14203. {
  14204. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  14205. IWorkbook workbook;
  14206. if (Path.GetExtension(filePath).ToLower() == ".xls")
  14207. {
  14208. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  14209. }
  14210. else
  14211. {
  14212. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  14213. }
  14214. ISheet sheet = workbook.GetSheetAt(0);
  14215. var rowStartIndex = 2;
  14216. var clounmCount = 10;
  14217. var initStyleRow = sheet.GetRow(2);
  14218. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  14219. //var overspendArrDetail =
  14220. var existsId = new List<CarCompare>();
  14221. var lastElem = arr.Last();
  14222. var thisSid = -1;
  14223. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  14224. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  14225. {
  14226. Name = "未知币种!",
  14227. Remark = "未知币种!",
  14228. };
  14229. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  14230. Action cloneRowFn = () =>
  14231. {
  14232. rowStartIndex++;
  14233. var cloneRow = sheet.CreateRow(rowStartIndex);
  14234. // 复制样式
  14235. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  14236. {
  14237. ICell sourceCell = initStyleRow.GetCell(i);
  14238. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  14239. // 确保单元格存在样式
  14240. if (sourceCell.CellStyle != null)
  14241. {
  14242. targetCell.CellStyle = sourceCell.CellStyle;
  14243. }
  14244. }
  14245. };
  14246. var mergeRow = () =>
  14247. {
  14248. for (int i = 2; i < sheet.LastRowNum; i++)
  14249. {
  14250. var row = sheet.GetRow(i);
  14251. var cellFirst = row.GetCell(0);
  14252. var thisIndex = i + 1;
  14253. while (thisIndex < sheet.LastRowNum)
  14254. {
  14255. var nextRow = sheet.GetRow(thisIndex);
  14256. var nextCellFirst = nextRow.GetCell(0);
  14257. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  14258. {
  14259. thisIndex++;
  14260. }
  14261. else
  14262. {
  14263. break;
  14264. }
  14265. }
  14266. thisIndex--;
  14267. if (thisIndex != i)
  14268. {
  14269. //合并row
  14270. var cellRangeAddress = new CellRangeAddress(
  14271. i, // 起始行索引(0-based)
  14272. thisIndex, // 结束行索引(0-based)
  14273. 0, // 起始列索引(0-based)
  14274. 0 // 结束列索引(0-based)
  14275. );
  14276. sheet.AddMergedRegion(cellRangeAddress);
  14277. i = thisIndex;
  14278. }
  14279. }
  14280. };
  14281. var chaoshiNumber = 0;
  14282. var totalNumber = 0.00M;
  14283. string lastStr = "";
  14284. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  14285. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  14286. {
  14287. b.IsAuditGM,
  14288. x.Id,
  14289. x.Area,
  14290. b.PayPercentage,
  14291. b.PayMoney,
  14292. }).ToList();
  14293. string yesPayment = "", noPayment = "";
  14294. foreach (var item in queryCarArrByCityAndDiid)
  14295. {
  14296. if (item.IsAuditGM == 1)
  14297. {
  14298. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  14299. }
  14300. else
  14301. {
  14302. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  14303. }
  14304. }
  14305. lastStr = yesPayment + noPayment;
  14306. foreach (var item in arr)
  14307. {
  14308. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  14309. {
  14310. if (thisSid != item.SId)
  14311. {
  14312. if (thisSid == -1)
  14313. {
  14314. thisSid = item.SId;
  14315. }
  14316. else
  14317. {
  14318. //合并小计行
  14319. //创建合并区域的实例
  14320. var cellRangeAddress = new CellRangeAddress(
  14321. rowStartIndex, // 起始行索引(0-based)
  14322. rowStartIndex, // 结束行索引(0-based)
  14323. 0, // 起始列索引(0-based)
  14324. 3 // 结束列索引(0-based)
  14325. );
  14326. sheet.AddMergedRegion(cellRangeAddress);
  14327. var CellStyle = workbook.CreateCellStyle();
  14328. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14329. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  14330. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  14331. for (int i = 0; i <= clounmCount; i++)
  14332. {
  14333. if (i > 6)
  14334. {
  14335. var CellStyle1 = workbook.CreateCellStyle();
  14336. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14337. IFont Font = workbook.CreateFont(); // 创建字体
  14338. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  14339. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14340. CellStyle1.SetFont(Font);
  14341. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  14342. }
  14343. else
  14344. {
  14345. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  14346. }
  14347. }
  14348. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  14349. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  14350. //超时合计
  14351. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  14352. //超时数
  14353. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  14354. //超时合计费用
  14355. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  14356. thisSid = item.SId;
  14357. cloneRowFn();
  14358. chaoshiNumber = 0;
  14359. totalNumber = 0;
  14360. }
  14361. }
  14362. IRow row = sheet.GetRow(rowStartIndex);
  14363. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14364. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  14365. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  14366. if (isOpenOverspendSoure)
  14367. {
  14368. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14369. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  14370. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  14371. }
  14372. for (int i = 0; i <= clounmCount; i++)
  14373. {
  14374. var cell = row.GetCell(i);
  14375. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  14376. if (cell == null)
  14377. {
  14378. cell = row.CreateCell(i);
  14379. }
  14380. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  14381. fontRed.CloneStyleFrom(cell.CellStyle);
  14382. IFont Font = workbook.CreateFont(); // 创建字体
  14383. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  14384. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14385. fontRed.SetFont(Font);
  14386. byte[] rgb = new byte[3] { 255, 242, 204 };
  14387. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  14388. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  14389. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  14390. if (workbook is XSSFWorkbook)
  14391. {
  14392. BackgroundColor255_242_204.FillForegroundColor = 0;
  14393. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  14394. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  14395. }
  14396. else
  14397. {
  14398. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  14399. }
  14400. if (i == 1 || i > 6)
  14401. {
  14402. if (i > 6)
  14403. {
  14404. fontRed.FillForegroundColor = 0;
  14405. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  14406. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  14407. }
  14408. cell.CellStyle = fontRed;
  14409. }
  14410. if (i > 2 && i < 7)
  14411. {
  14412. cell.CellStyle = BackgroundColor255_242_204;
  14413. }
  14414. cell.SetCellValue(setCellValue); //写入单元格
  14415. }
  14416. if (overspendSoure.ContainsKey(thisSid))
  14417. {
  14418. var overspendId = overspendSoure[thisSid];
  14419. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14420. }
  14421. cloneRowFn();
  14422. existsId.Add(new CarCompare
  14423. {
  14424. DataPrice = item.DatePrice.ObjToDate(),
  14425. Sid = item.SId
  14426. });
  14427. }
  14428. if (item.Equals(lastElem))
  14429. {
  14430. //合并小计行
  14431. //创建合并区域的实例
  14432. var cellRangeAddress = new CellRangeAddress(
  14433. rowStartIndex, // 起始行索引(0-based)
  14434. rowStartIndex, // 结束行索引(0-based)
  14435. 0, // 起始列索引(0-based)
  14436. 3 // 结束列索引(0-based)
  14437. );
  14438. sheet.AddMergedRegion(cellRangeAddress);
  14439. var CellStyle = workbook.CreateCellStyle();
  14440. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14441. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  14442. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  14443. for (int i = 0; i <= clounmCount; i++)
  14444. {
  14445. if (i > 6)
  14446. {
  14447. var CellStyle1 = workbook.CreateCellStyle();
  14448. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14449. IFont Font = workbook.CreateFont(); // 创建字体
  14450. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  14451. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14452. CellStyle1.SetFont(Font);
  14453. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  14454. }
  14455. else
  14456. {
  14457. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  14458. }
  14459. }
  14460. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  14461. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  14462. //超时合计
  14463. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  14464. //超时数
  14465. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  14466. //超时合计费用
  14467. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  14468. cloneRowFn();
  14469. // 创建合并区域的实例
  14470. cellRangeAddress = new CellRangeAddress(
  14471. rowStartIndex, // 起始行索引(0-based)
  14472. rowStartIndex, // 结束行索引(0-based)
  14473. 0, // 起始列索引(0-based)
  14474. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  14475. );
  14476. // 添加合并区域
  14477. sheet.AddMergedRegion(cellRangeAddress);
  14478. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  14479. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  14480. }
  14481. }
  14482. mergeRow();
  14483. // 保存修改后的Excel文件到新文件
  14484. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  14485. // new FileStream(newFilePath, FileMode.CreateNew)
  14486. using (var stream = new MemoryStream())
  14487. {
  14488. workbook.Write(stream, true);
  14489. stream.Flush();
  14490. stream.Seek(0, SeekOrigin.Begin);
  14491. var memoryStream = new MemoryStream();
  14492. stream.CopyTo(memoryStream);
  14493. memoryStream.Seek(0, SeekOrigin.Begin);
  14494. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  14495. }
  14496. workbook.Close();
  14497. workbook.Dispose();
  14498. }
  14499. catch (Exception ex)
  14500. {
  14501. jw.Msg = "出现异常!" + ex.Message;
  14502. return Ok(jw);
  14503. }
  14504. }
  14505. if (Zips.Count > 0)
  14506. {
  14507. var io = new IOOperatorHelper();
  14508. var byts = io.ConvertZipStream(Zips);
  14509. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  14510. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  14511. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  14512. }
  14513. else
  14514. {
  14515. jw.Msg = "暂无生成文件!";
  14516. }
  14517. return Ok(jw);
  14518. }
  14519. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  14520. {
  14521. string outStr = string.Empty;
  14522. switch (i)
  14523. {
  14524. case 0:
  14525. outStr = arr[0].SidName;
  14526. break;
  14527. case 1:
  14528. outStr = arr[0].DataPriceStr;
  14529. break;
  14530. case 2:
  14531. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  14532. break;
  14533. case 4:
  14534. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  14535. break;
  14536. case 7:
  14537. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14538. {
  14539. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  14540. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  14541. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  14542. }
  14543. break;
  14544. case 8:
  14545. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14546. {
  14547. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  14548. }
  14549. break;
  14550. case 9:
  14551. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14552. {
  14553. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  14554. }
  14555. break;
  14556. case 10:
  14557. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14558. {
  14559. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  14560. }
  14561. break;
  14562. }
  14563. return outStr;
  14564. }
  14565. #region OP行程单
  14566. /// <summary>
  14567. /// OP行程单初始化
  14568. /// </summary>
  14569. /// <param name="dto"></param>
  14570. /// <returns></returns>
  14571. [HttpPost]
  14572. public IActionResult InitOpTravel(InitOpTravelDto dto)
  14573. {
  14574. var jw = JsonView(false);
  14575. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  14576. var group = groupList.First();
  14577. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  14578. if (group == null)
  14579. {
  14580. jw.Msg = "暂无团组!";
  14581. return Ok(jw);
  14582. }
  14583. group = groupList.Find(x => x.Id == diid);
  14584. if (group == null)
  14585. {
  14586. jw.Msg = "请输入正确的团组ID!";
  14587. return Ok(jw);
  14588. }
  14589. string city = string.Empty;
  14590. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  14591. if (blackCode.Count > 0)
  14592. {
  14593. var black = blackCode.First();
  14594. black.BlackCode = black.BlackCode ?? "";
  14595. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  14596. if (blackSp.Length > 0)
  14597. {
  14598. try
  14599. {
  14600. var cityArrCode = new List<string>(20);
  14601. foreach (var item in blackSp)
  14602. {
  14603. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  14604. var IndexSelect = itemSp[2];
  14605. var cityArrCodeLength = cityArrCode.Count - 1;
  14606. var startCity = IndexSelect.Substring(0, 3);
  14607. if (cityArrCodeLength > 0)
  14608. {
  14609. var arrEndCity = cityArrCode[cityArrCodeLength];
  14610. if (arrEndCity != startCity)
  14611. {
  14612. cityArrCode.Add(startCity.ToUpper());
  14613. }
  14614. }
  14615. else
  14616. {
  14617. cityArrCode.Add(startCity.ToUpper());
  14618. }
  14619. var endCity = IndexSelect.Substring(3, 3);
  14620. cityArrCode.Add(endCity.ToUpper());
  14621. }
  14622. var cityThree = string.Empty;
  14623. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  14624. cityThree = cityThree.TrimEnd(',');
  14625. if (string.IsNullOrWhiteSpace(cityThree))
  14626. {
  14627. throw new
  14628. Exception("error");
  14629. }
  14630. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  14631. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  14632. foreach (var item in cityArrCode)
  14633. {
  14634. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  14635. if (find != null)
  14636. {
  14637. city += find.City + "/";
  14638. }
  14639. else
  14640. {
  14641. city += item + "三字码未收入/";
  14642. }
  14643. }
  14644. city = city.TrimEnd('/');
  14645. }
  14646. catch (Exception e)
  14647. {
  14648. city = "黑屏代码格式不正确!";
  14649. }
  14650. }
  14651. }
  14652. else
  14653. {
  14654. city = "未录入黑屏代码";
  14655. }
  14656. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  14657. {
  14658. Date = x.Date,
  14659. Days = x.Days,
  14660. Diffgroup = x.Diffgroup,
  14661. Diid = x.Diid,
  14662. Traffic_First = x.Traffic_First,
  14663. Traffic_Second = x.Traffic_Second,
  14664. Trip = x.Trip,
  14665. WeekDay = x.WeekDay,
  14666. Id = x.Id
  14667. }).ToList();
  14668. jw.Data = new
  14669. {
  14670. groupList = groupList.Select(x => new
  14671. {
  14672. x.Id,
  14673. x.TeamName,
  14674. x.TourCode
  14675. }).ToList(),
  14676. groupInfo = new
  14677. {
  14678. group.VisitDays,
  14679. group.TourCode,
  14680. group.VisitPNumber,
  14681. group.TeamName,
  14682. city
  14683. },
  14684. OpTravelList
  14685. };
  14686. jw.Code = 200;
  14687. jw.Msg = "操作成功!";
  14688. return Ok(jw);
  14689. }
  14690. /// <summary>
  14691. /// 删除团组行程单
  14692. /// </summary>
  14693. /// <returns></returns>
  14694. [HttpPost]
  14695. public IActionResult DelTravel(DelOpTravelDto dto)
  14696. {
  14697. var jw = JsonView(false);
  14698. if (dto.UserId <= 0 || dto.Diid <= 0)
  14699. {
  14700. jw.Msg = "请输入正确的参数!";
  14701. return Ok(jw);
  14702. }
  14703. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  14704. .SetColumns(x => new Grp_TravelList
  14705. {
  14706. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  14707. DeleteUserId = dto.UserId,
  14708. IsDel = 1,
  14709. }).ExecuteCommand();
  14710. jw = JsonView(true);
  14711. return Ok(jw);
  14712. }
  14713. /// <summary>
  14714. /// 行程单保存
  14715. /// </summary>
  14716. /// <returns></returns>
  14717. [HttpPost]
  14718. public IActionResult TravelSave(TravelSaveDto dto)
  14719. {
  14720. var jw = JsonView(false);
  14721. if (dto.Arr.Count > 0)
  14722. {
  14723. try
  14724. {
  14725. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  14726. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  14727. .ToList();
  14728. _sqlSugar.BeginTran();
  14729. foreach (var item in dto.Arr)
  14730. {
  14731. if (item.Id == 0)
  14732. {
  14733. throw new Exception("请传入正确的Id");
  14734. }
  14735. //比较上一次的差异
  14736. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  14737. if (findTravel != null)
  14738. {
  14739. item.Trip = item.Trip.Replace("[++]", string.Empty);
  14740. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  14741. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  14742. }
  14743. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  14744. .SetColumns(x => new Grp_TravelList
  14745. {
  14746. Trip = item.Trip
  14747. }).ExecuteCommand();
  14748. }
  14749. _sqlSugar.CommitTran();
  14750. jw = JsonView(true);
  14751. }
  14752. catch (Exception ex)
  14753. {
  14754. _sqlSugar.RollbackTran();
  14755. jw.Msg = "程序异常!" + ex.Message;
  14756. }
  14757. }
  14758. else
  14759. {
  14760. jw.Msg = "请传入正确的参数!";
  14761. }
  14762. return Ok(jw);
  14763. }
  14764. private static string CheckStr(string original, string changed)
  14765. {
  14766. // 创建diff_match_patch对象
  14767. var dmp = new diff_match_patch();
  14768. // 计算差异
  14769. List<Diff> diffs = dmp.diff_main(original, changed);
  14770. // 清理和合并差异
  14771. dmp.diff_cleanupSemantic(diffs);
  14772. // 使用StringBuilder构建最终的字符串
  14773. var finalString = new StringBuilder();
  14774. // 输出差异结果,并构建变动后的字符串
  14775. foreach (Diff diff in diffs)
  14776. {
  14777. switch (diff.operation)
  14778. {
  14779. case Operation.EQUAL:
  14780. // 相等的部分,直接添加到最终字符串
  14781. finalString.Append(diff.text);
  14782. break;
  14783. case Operation.INSERT:
  14784. // 插入的部分,添加标记并添加到最终字符串
  14785. finalString.Append("[++]" + diff.text + "[++]");
  14786. break;
  14787. case Operation.DELETE:
  14788. // 删除的部分,不添加到最终字符串
  14789. //finalString.Append("[++]" + diff.text + "[++]");
  14790. break;
  14791. }
  14792. }
  14793. // 输出变动后的字符串
  14794. return finalString.ToString();
  14795. }
  14796. private class tagContent
  14797. {
  14798. public DateTime Date { get; set; }
  14799. public string StartTag { get; set; }
  14800. public string EndTag { get; set; }
  14801. public string Content { get; set; }
  14802. public static int tagLength { get { return 3; } }
  14803. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  14804. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  14805. public bool IsFinally { get; set; }
  14806. }
  14807. private static List<string> ExtractContentBetweenTags(string input, string tag)
  14808. {
  14809. var results = new List<string>();
  14810. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  14811. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  14812. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  14813. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  14814. string[] strValueArr = new string[1];
  14815. foreach (System.Text.RegularExpressions.Match match in matches)
  14816. {
  14817. var strValue = match.Groups[1].Value;
  14818. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  14819. }
  14820. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  14821. return results;
  14822. }
  14823. /// <summary>
  14824. /// 导出行程单
  14825. /// </summary>
  14826. /// <param name="dto"></param>
  14827. /// <returns></returns>
  14828. [HttpPost]
  14829. public IActionResult ExportTravel(ExportTravelDto dto)
  14830. {
  14831. var jw = JsonView(false);
  14832. jw.Data = "";
  14833. int diid = 0;
  14834. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  14835. if (Find == null)
  14836. {
  14837. jw.Msg = "请选择正确的团组!";
  14838. return Ok(jw);
  14839. }
  14840. else
  14841. {
  14842. diid = Find.Id;
  14843. }
  14844. //数据源
  14845. var _travelList = new List<Grp_TravelList>();
  14846. DataTable dtBlack = null;
  14847. try
  14848. {
  14849. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  14850. }
  14851. catch (Exception)
  14852. {
  14853. jw.Msg = "机票黑屏代码有误!";
  14854. return Ok(jw);
  14855. }
  14856. string CityStr = string.Empty;
  14857. if (dtBlack.Rows.Count == 0)
  14858. {
  14859. jw.Msg = "机票黑屏代码有误!";
  14860. return Ok(jw);
  14861. }
  14862. else
  14863. {
  14864. foreach (DataRow row in dtBlack.Rows)
  14865. {
  14866. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14867. {
  14868. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  14869. return Ok(jw);
  14870. }
  14871. }
  14872. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  14873. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  14874. }
  14875. // 指定的文字
  14876. var targetTextDic = new Dictionary<string, List<string>>();
  14877. //创建数据源Table
  14878. var dtSource = new DataTable();
  14879. dtSource.Columns.Add("Days", typeof(string));
  14880. dtSource.Columns.Add("Date", typeof(string));
  14881. dtSource.Columns.Add("Week", typeof(string));
  14882. dtSource.Columns.Add("Traffic", typeof(string));
  14883. dtSource.Columns.Add("Trip", typeof(string));
  14884. //获取数据,放到datatable
  14885. foreach (var item in _travelList)
  14886. {
  14887. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  14888. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  14889. .Replace(tagContent.TagFormat.Item2, string.Empty)
  14890. .Replace("[++]", string.Empty);
  14891. DataRow dr = dtSource.NewRow();
  14892. dr["Days"] = item.Days;
  14893. dr["Date"] = item.Date;
  14894. dr["Week"] = item.WeekDay;
  14895. dr["Traffic"] = item.Traffic_First
  14896. + "\r\n"
  14897. + item.Traffic_Second;
  14898. dr["Trip"] = item.Trip;
  14899. dtSource.Rows.Add(dr);
  14900. }
  14901. var dic = new Dictionary<string, string>
  14902. {
  14903. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  14904. { "City", CityStr },
  14905. { "Days", Find.VisitDays.ToString() },
  14906. { "DeleCode", Find.TourCode },
  14907. { "Pnum", Find.VisitPNumber.ToString() }
  14908. };
  14909. //模板路径
  14910. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  14911. //载入模板
  14912. Document doc = null;
  14913. DocumentBuilder builder = null;
  14914. try
  14915. {
  14916. //载入模板
  14917. doc = new Document(tempPath);
  14918. builder = new DocumentBuilder(doc);
  14919. }
  14920. catch (Exception)
  14921. {
  14922. jw.Msg = "模板位置不存在!";
  14923. return Ok(jw);
  14924. }
  14925. foreach (var key in dic.Keys)
  14926. {
  14927. Bookmark bookmark = doc.Range.Bookmarks[key];
  14928. if (bookmark != null)
  14929. {
  14930. builder.MoveToBookmark(key);
  14931. builder.Write(dic[key]);
  14932. }
  14933. }
  14934. //获取word里所有表格
  14935. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14936. //获取所填表格的序数
  14937. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14938. try
  14939. {
  14940. //循环赋值
  14941. for (int i = 0; i < dtSource.Rows.Count; i++)
  14942. {
  14943. builder.MoveToCell(0, i + 1, 0, 0);
  14944. builder.Write(dtSource.Rows[i]["Days"].ToString());
  14945. builder.MoveToCell(0, i + 1, 1, 0);
  14946. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  14947. builder.MoveToCell(0, i + 1, 2, 0);
  14948. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  14949. var trip = dtSource.Rows[i]["Trip"].ToString();
  14950. builder.MoveToCell(0, i + 1, 3, 0);
  14951. builder.Write(trip);
  14952. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  14953. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14954. // 获取特定索引的段落
  14955. Paragraph paragraph = (Paragraph)paragraphs[0];
  14956. Run run = paragraph.Runs[0];
  14957. Aspose.Words.Font font = run.Font;
  14958. font.Name = "黑体";
  14959. //设置双休红色
  14960. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  14961. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14962. paragraph = (Paragraph)paragraphs[1];
  14963. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  14964. {
  14965. run = paragraph.Runs[0];
  14966. font = run.Font;
  14967. font.Color = Color.Red;
  14968. }
  14969. }
  14970. }
  14971. catch (Exception ex)
  14972. {
  14973. }
  14974. //删除多余行
  14975. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  14976. {
  14977. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  14978. }
  14979. var targetTextList = new List<string>();
  14980. // 遍历文档中的表格
  14981. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14982. {
  14983. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14984. {
  14985. var cellIndex = 0;
  14986. foreach (Cell cell in row.Cells)
  14987. {
  14988. if (cellIndex == 1 && row.Cells.Count == 4)
  14989. {
  14990. foreach (var target in targetTextDic.Keys)
  14991. {
  14992. if (cell.GetText().Contains(target))
  14993. {
  14994. targetTextList = targetTextDic[target];
  14995. break;
  14996. }
  14997. }
  14998. }
  14999. // 遍历单元格中的所有段落
  15000. foreach (Paragraph paragraph in cell.Paragraphs)
  15001. {
  15002. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  15003. var runs = new List<Run>();
  15004. foreach (Run run in paragraph.Runs)
  15005. {
  15006. runs.Add(run);
  15007. }
  15008. foreach (Run run in runs)
  15009. {
  15010. foreach (var targetText in targetTextList)
  15011. {
  15012. // 检查文字是否包含指定文字
  15013. if (run.Text.Contains(targetText))
  15014. {
  15015. // 将包含的部分设置为红色
  15016. HighlightText(run, targetText, Color.Red);
  15017. }
  15018. }
  15019. }
  15020. }
  15021. cellIndex++;
  15022. }
  15023. }
  15024. }
  15025. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  15026. if (!Directory.Exists(savePath))
  15027. {
  15028. try
  15029. {
  15030. Directory.CreateDirectory(savePath);
  15031. }
  15032. catch
  15033. {
  15034. }
  15035. }
  15036. string path = savePath + Find.TeamName + "出访日程";
  15037. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  15038. try
  15039. {
  15040. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  15041. string postfix = ".docx";
  15042. if (dto.IsPDF == 1)
  15043. {
  15044. saveFormat = Aspose.Words.SaveFormat.Pdf;
  15045. postfix = ".pdf";
  15046. }
  15047. doc.Save(path + postfix, saveFormat);
  15048. jw = JsonView(true, "导出成功", ftpPath + postfix);
  15049. }
  15050. catch (Exception)
  15051. {
  15052. jw = JsonView(false);
  15053. }
  15054. return Ok(jw);
  15055. }
  15056. /// <summary>
  15057. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  15058. /// </summary>
  15059. /// <param name="num"></param>
  15060. /// <returns></returns>
  15061. static string GetNum(string num)
  15062. {
  15063. string str = "";
  15064. switch (num)
  15065. {
  15066. case "1":
  15067. str = "一";
  15068. break;
  15069. case "2":
  15070. str = "二";
  15071. break;
  15072. case "3":
  15073. str = "三";
  15074. break;
  15075. case "4":
  15076. str = "四";
  15077. break;
  15078. case "5":
  15079. str = "五";
  15080. break;
  15081. case "6":
  15082. str = "六";
  15083. break;
  15084. case "7":
  15085. str = "七";
  15086. break;
  15087. case "8":
  15088. str = "八";
  15089. break;
  15090. case "9":
  15091. str = "九";
  15092. break;
  15093. case "10":
  15094. str = "十";
  15095. break;
  15096. case "11":
  15097. str = "十一";
  15098. break;
  15099. case "12":
  15100. str = "十二";
  15101. break;
  15102. case "一":
  15103. str = "1";
  15104. break;
  15105. case "二":
  15106. str = "2";
  15107. break;
  15108. case "三":
  15109. str = "3";
  15110. break;
  15111. case "四":
  15112. str = "4";
  15113. break;
  15114. case "五":
  15115. str = "5";
  15116. break;
  15117. case "六":
  15118. str = "6";
  15119. break;
  15120. case "七":
  15121. str = "7";
  15122. break;
  15123. case "八":
  15124. str = "8";
  15125. break;
  15126. case "九":
  15127. str = "9";
  15128. break;
  15129. case "十":
  15130. str = "10";
  15131. break;
  15132. case "十一":
  15133. str = "11";
  15134. break;
  15135. case "十二":
  15136. str = "12";
  15137. break;
  15138. }
  15139. return str;
  15140. }
  15141. /// <summary>
  15142. /// 高亮包含指定文字的部分
  15143. /// </summary>
  15144. /// <param name="run"></param>
  15145. /// <param name="targetText"></param>
  15146. /// <param name="color"></param>
  15147. static void HighlightText(Run run, string targetText, Color color)
  15148. {
  15149. string text = run.Text;
  15150. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  15151. if (startIndex >= 0)
  15152. {
  15153. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  15154. // 前部分
  15155. if (startIndex > 0)
  15156. {
  15157. Run beforeRun = (Run)run.Clone(true);
  15158. beforeRun.Text = text.Substring(0, startIndex);
  15159. parentParagraph.InsertBefore(beforeRun, run);
  15160. }
  15161. // 匹配部分
  15162. Run matchRun = (Run)run.Clone(true);
  15163. matchRun.Text = text.Substring(startIndex, targetText.Length);
  15164. matchRun.Font.Color = color;
  15165. parentParagraph.InsertBefore(matchRun, run);
  15166. // 后部分
  15167. if (startIndex + targetText.Length < text.Length)
  15168. {
  15169. Run afterRun = (Run)run.Clone(true);
  15170. afterRun.Text = text.Substring(startIndex + targetText.Length);
  15171. parentParagraph.InsertBefore(afterRun, run);
  15172. }
  15173. // 删除原始Run
  15174. run.Remove();
  15175. }
  15176. }
  15177. #endregion
  15178. #endregion
  15179. #region 团组成本
  15180. /// <summary>
  15181. /// 团组成本数据初始化
  15182. /// </summary>
  15183. /// <param name="dto"></param>
  15184. /// <returns></returns>
  15185. [HttpPost]
  15186. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  15187. {
  15188. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15189. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15190. WHEN COUNT(*) >= 0 THEN 'True'
  15191. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15192. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  15193. ").ToList(); //团组列表
  15194. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  15195. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  15196. var visaCountryInfoArr = new ArrayList();
  15197. var groupinfoValue = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == diid && x.IsDel == 0);
  15198. if (groupinfoValue != null)
  15199. {
  15200. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  15201. var dicity = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == groupinfoValue.CityId);
  15202. dicity ??= new Sys_Cities()
  15203. {
  15204. ParentId = 122
  15205. };
  15206. var diparent = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == dicity.ParentId);
  15207. var spArr = new string[1] { countryArr };
  15208. if (countryArr.Contains("|"))
  15209. {
  15210. spArr = countryArr.Split("|");
  15211. }
  15212. else if (countryArr.Contains("、"))
  15213. {
  15214. spArr = countryArr.Split("、");
  15215. }
  15216. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  15217. {
  15218. try
  15219. {
  15220. var visa = _sqlSugar.Queryable<Res_VisaFeeStandard>()
  15221. .Where(x => x.IsDel == 0 && x.Country == item)
  15222. .ToList();
  15223. if (visa.Any())
  15224. {
  15225. var visainfo = _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
  15226. .Where(x => x.IsDel == 0 && visa.Select(x => x.Id).Contains(x.ParentId))
  15227. .ToList();
  15228. var visaMain = visainfo.FirstOrDefault(x => x.ProvinceId == diparent.Id);
  15229. var visayinsiValue = visainfo.FirstOrDefault(x => x.ParentId == visa.FirstOrDefault(x => x.FeeType == 1)?.Id);
  15230. visaCountryInfoArr.Add(new
  15231. {
  15232. country = item,
  15233. yinsi = new
  15234. {
  15235. Id = visayinsiValue.Id,
  15236. value = visayinsiValue.SmallVisaPrice
  15237. },
  15238. visaMain = new
  15239. {
  15240. Id = visaMain.Id,
  15241. IsVisaOnArrival = visaMain.IsVisaOnArrival ? "是" : "否",
  15242. IsElectronicSign = visaMain.IsElectronicSign ? "是" : "否",
  15243. VisaTime = visaMain.VisaTime,
  15244. IsVisaExemptionLarge = visaMain.IsVisaExemptionLarge ? "是" : "否",
  15245. LargeVisaPrice = visaMain.LargeVisaPrice,
  15246. LargeAgencyFee = visaMain.LargeAgencyFee,
  15247. IsVisaExemptionSmall = visaMain.IsVisaExemptionSmall ? "是" : "否",
  15248. SmallVisaPrice = visaMain.SmallVisaPrice,
  15249. SmallAgencyFee = visaMain.SmallAgencyFee,
  15250. NormExtFee = visaMain.NormExtFee,
  15251. UrgExtFee = visaMain.UrgExtFee,
  15252. IsUrgent = visaMain.IsUrgent ? "是" : "否",
  15253. UrgentTime = visaMain.UrgentTime,
  15254. UrgentPrice = visaMain.UrgentPrice,
  15255. UrgentPriceDesc = visaMain.UrgentPriceDesc,
  15256. Remark = visaMain.Remark,
  15257. }
  15258. });
  15259. }
  15260. }
  15261. catch (Exception ex)
  15262. {
  15263. //写入日志
  15264. _logger.LogError(ex, "团组成本解析签证异常!");
  15265. }
  15266. }
  15267. }
  15268. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  15269. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  15270. #region 屏蔽黑屏代码生成
  15271. //var create = _GroupCostRepository.
  15272. // CreateGroupCostByBlackCode(dto.Diid);
  15273. //if (groupCost.Count == 0 && create.Code == 0)
  15274. //{
  15275. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  15276. //}
  15277. #endregion
  15278. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  15279. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  15280. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  15281. groupCostMap = groupCostMap.Select(x =>
  15282. {
  15283. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  15284. {
  15285. x.Date = dataForamt.ToString("yyyy-MM-dd");
  15286. }
  15287. return x;
  15288. }).ToList();
  15289. //GroupCostParameter.Add(new
  15290. // Grp_GroupCostParameter());
  15291. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  15292. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  15293. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  15294. return Ok(JsonView(new
  15295. {
  15296. groupList,
  15297. groupInfo,
  15298. groupChecks,
  15299. groupCost = groupCostMap,
  15300. hotelNumber,
  15301. GroupCostParameter = GroupCostParameterMap,
  15302. visaCountryInfoArr = visaCountryInfoArr,
  15303. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  15304. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  15305. hotelIsTrue,
  15306. groupModuleOperators
  15307. }));
  15308. }
  15309. /// <summary>
  15310. /// 团组成本信息保存
  15311. /// </summary>
  15312. /// <param name="dto"></param>
  15313. /// <returns></returns>
  15314. [HttpPost]
  15315. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  15316. {
  15317. if (dto.Diid <= 0 || dto.Userid <= 0)
  15318. {
  15319. return Ok(JsonView(false));
  15320. }
  15321. JsonView jw = null;
  15322. bool isTrue = false;
  15323. #region 复制团组成本
  15324. //if (dto.Diid == 2581)
  15325. //{
  15326. // dto.Diid = 2599;
  15327. // dto.CheckBoxs.ForEach(x =>
  15328. // {
  15329. // x.Diid = 2599;
  15330. // });
  15331. // dto.GroupCosts.ForEach(x =>
  15332. // {
  15333. // x.Diid = 2599;
  15334. // });
  15335. // dto.CostTypeHotelNumbers.ForEach(x =>
  15336. // {
  15337. // x.Diid = 2599;
  15338. // });
  15339. // dto.GroupCostParameters.ForEach(x =>
  15340. // {
  15341. // x.DiId = 2599;
  15342. // });
  15343. //}
  15344. #endregion
  15345. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  15346. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  15347. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  15348. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  15349. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  15350. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  15351. try
  15352. {
  15353. _sqlSugar.BeginTran();
  15354. isTrue = await _GroupCostRepository.
  15355. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  15356. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  15357. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  15358. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  15359. _sqlSugar.CommitTran();
  15360. jw = JsonView(true, "保存成功!", isTrue);
  15361. }
  15362. catch (Exception)
  15363. {
  15364. _sqlSugar.RollbackTran();
  15365. jw = JsonView(false);
  15366. }
  15367. return Ok(jw);
  15368. }
  15369. /// <summary>
  15370. /// 复制团组成本信息
  15371. /// </summary>
  15372. /// <param name="dto"></param>
  15373. /// <returns></returns>
  15374. [HttpPost]
  15375. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  15376. {
  15377. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  15378. {
  15379. return Ok(JsonView(false, "参数有误!"));
  15380. }
  15381. #region 复制团组成本
  15382. dto.Diid = dto.ToGroupId;
  15383. dto.CheckBoxs.ForEach(x =>
  15384. {
  15385. x.Diid = dto.ToGroupId;
  15386. });
  15387. dto.GroupCosts.ForEach(x =>
  15388. {
  15389. x.Diid = dto.ToGroupId;
  15390. });
  15391. dto.CostTypeHotelNumbers.ForEach(x =>
  15392. {
  15393. x.Diid = dto.ToGroupId;
  15394. });
  15395. dto.GroupCostParameters.ForEach(x =>
  15396. {
  15397. x.DiId = dto.ToGroupId;
  15398. });
  15399. #endregion
  15400. JsonView jw = null;
  15401. bool isTrue = false;
  15402. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  15403. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  15404. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  15405. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  15406. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  15407. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  15408. try
  15409. {
  15410. _sqlSugar.BeginTran();
  15411. isTrue = await _GroupCostRepository.
  15412. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  15413. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  15414. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  15415. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  15416. _sqlSugar.CommitTran();
  15417. jw = JsonView(true, "保存成功!", isTrue);
  15418. }
  15419. catch (Exception)
  15420. {
  15421. _sqlSugar.RollbackTran();
  15422. jw = JsonView(false);
  15423. }
  15424. return Ok(jw);
  15425. }
  15426. /// <summary>
  15427. /// 司兼导数据
  15428. /// </summary>
  15429. /// <param name="dto"></param>
  15430. /// <returns></returns>
  15431. [HttpPost]
  15432. public IActionResult GetCarGuides(CarGuidesDto dto)
  15433. {
  15434. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  15435. return Ok(JsonView(true, "获取成功!", Data));
  15436. }
  15437. /// <summary>
  15438. /// 导游数据
  15439. /// </summary>
  15440. /// <param name="dto"></param>
  15441. /// <returns></returns>
  15442. [HttpPost]
  15443. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  15444. {
  15445. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  15446. // 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
  15447. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  15448. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  15449. return Ok(JsonView(true, "获取成功!", Data));
  15450. }
  15451. /// <summary>
  15452. /// 成本车数据
  15453. /// </summary>
  15454. /// <param name="dto"></param>
  15455. /// <returns></returns>
  15456. [HttpPost]
  15457. public IActionResult GetCarInfo(CarGuidesDto dto)
  15458. {
  15459. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  15460. return Ok(JsonView(true, "获取成功!", Data));
  15461. }
  15462. /// <summary>
  15463. /// 景点数据
  15464. /// </summary>
  15465. /// <param name="dto"></param>
  15466. /// <returns></returns>
  15467. [HttpPost]
  15468. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  15469. {
  15470. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  15471. return Ok(JsonView(true, "获取成功!", Data));
  15472. }
  15473. /// <summary>
  15474. /// 成本通知
  15475. /// </summary>
  15476. /// <param name="dto"></param>
  15477. /// <returns></returns>
  15478. [HttpPost]
  15479. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  15480. {
  15481. if (dto.Diid < 0)
  15482. {
  15483. return Ok(JsonView(false));
  15484. }
  15485. JsonView jw;
  15486. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  15487. if (GroupCostParameter != null)
  15488. {
  15489. int IsShare = 0;
  15490. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  15491. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  15492. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  15493. string msg = string.Empty;
  15494. if (isTrue)
  15495. {
  15496. if (IsShare == 0)
  15497. {
  15498. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  15499. }
  15500. else
  15501. {
  15502. #region 企微通知对应岗位用户
  15503. try
  15504. {
  15505. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  15506. }
  15507. catch (Exception)
  15508. {
  15509. }
  15510. #endregion
  15511. msg = "通知成功,其他模块操作人员可见此成本信息!";
  15512. }
  15513. jw = JsonView(isTrue, msg, new { IsShare });
  15514. }
  15515. else
  15516. {
  15517. msg = "修改失败!";
  15518. jw = JsonView(isTrue, msg);
  15519. }
  15520. }
  15521. else
  15522. {
  15523. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  15524. }
  15525. return Ok(jw);
  15526. }
  15527. /// <summary>
  15528. /// 导出报价单
  15529. /// </summary>
  15530. /// <param name="dto"></param>
  15531. /// <returns></returns>
  15532. [HttpPost]
  15533. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  15534. {
  15535. if (dto.Diid == 0)
  15536. {
  15537. return Ok(JsonView(false, "请传递团组id"));
  15538. }
  15539. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15540. if (deleInfo.Code != 0)
  15541. {
  15542. return Ok(JsonView(false, "团组信息查询失败!"));
  15543. }
  15544. var di = deleInfo.Data as DelegationInfoWebView;
  15545. if (di != null)
  15546. {
  15547. di.TeamName = di.TeamName.Replace("|", "、");
  15548. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  15549. //文件名
  15550. string strFileName = di.TeamName + "-收款账单.doc";
  15551. //获取模板
  15552. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  15553. //载入模板
  15554. Document doc = new Document(tmppath);
  15555. decimal TotalPrice = 0.00M;
  15556. string itemStr = string.Empty;
  15557. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  15558. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  15559. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  15560. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  15561. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  15562. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  15563. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  15564. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  15565. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  15566. foreach (var cost in groupCostType)
  15567. {
  15568. var List = cost.ToList();
  15569. if (cost.Key == "A")
  15570. {
  15571. foreach (var ListItem in List)
  15572. {
  15573. if (ListItem.number > 0)
  15574. {
  15575. if (ListItem.code.Contains("TBR"))
  15576. {
  15577. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15578. }
  15579. else
  15580. {
  15581. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15582. }
  15583. TotalPrice += (ListItem.number * ListItem.price);
  15584. }
  15585. }
  15586. }
  15587. else
  15588. {
  15589. itemStr = itemStr.Insert(0, "A段\r\n");
  15590. itemStr += "B段\r\n";
  15591. foreach (var ListItem in List)
  15592. {
  15593. if (ListItem.number > 0)
  15594. {
  15595. if (ListItem.code.Contains("TBR"))
  15596. {
  15597. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15598. }
  15599. else
  15600. {
  15601. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15602. }
  15603. TotalPrice += (ListItem.number * ListItem.price);
  15604. }
  15605. }
  15606. }
  15607. }
  15608. #region 替换Word模板书签内容
  15609. Dictionary<string, string> marks = new Dictionary<string, string>();
  15610. marks.Add("To", di.ClientUnit);//付款方
  15611. marks.Add("ToTel", di.TellPhone);//付款方电话
  15612. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  15613. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  15614. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  15615. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  15616. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  15617. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  15618. marks.Add("PayItemContent", itemStr);//详细信息
  15619. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  15620. #endregion
  15621. ////注
  15622. //if (doc.Range.Bookmarks["Attention"] != null)
  15623. //{
  15624. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  15625. // mark.Text = frList[0].Attention;
  15626. //}
  15627. foreach (var item in marks.Keys)
  15628. {
  15629. if (doc.Range.Bookmarks[item] != null)
  15630. {
  15631. Bookmark mark = doc.Range.Bookmarks[item];
  15632. mark.Text = marks[item];
  15633. }
  15634. }
  15635. byte[] bytes = null;
  15636. using (MemoryStream stream = new MemoryStream())
  15637. {
  15638. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15639. bytes = stream.ToArray();
  15640. }
  15641. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  15642. return Ok(JsonView(true, "", new
  15643. {
  15644. Data = bytes,
  15645. strFileName,
  15646. }));
  15647. }
  15648. else
  15649. {
  15650. return Ok(JsonView(false, "团组信息不存在!"));
  15651. }
  15652. }
  15653. /// <summary>
  15654. /// 导出团组成本
  15655. /// </summary>
  15656. /// <param name="dto"></param>
  15657. /// <returns></returns>
  15658. [HttpPost]
  15659. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  15660. {
  15661. var jw = JsonView(false);
  15662. if (dto.Diid == 0)
  15663. {
  15664. return Ok(JsonView(false, "请传递团组id"));
  15665. }
  15666. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15667. if (deleInfo.Code != 0)
  15668. {
  15669. return Ok(JsonView(false, "团组信息查询失败!"));
  15670. }
  15671. var di = deleInfo.Data as DelegationInfoWebView;
  15672. if (di == null)
  15673. {
  15674. return Ok(JsonView(false, "团组信息查询失败!"));
  15675. }
  15676. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  15677. WorkbookDesigner designer = new WorkbookDesigner();
  15678. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  15679. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  15680. List<int> hideColumnList = new List<int>();
  15681. var ColumnSetting = new[]
  15682. {
  15683. new { tag = "VF", Index = 4, P = "CarCost" },
  15684. new { tag = "VN", Index = 5, P = "CarNumber" },
  15685. new { tag = "VRD", Index = 6, P = "CarTiming" },
  15686. new { tag = "T/G S", Index = 7, P = "TGS" },
  15687. new { tag = "TGWH", Index = 8, P = "TGWH" },
  15688. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  15689. new { tag = "T/G M", Index = 10, P = "TGM" },
  15690. new { tag = "T/G A", Index = 11, P = "TGA" },
  15691. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  15692. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  15693. new { tag = "C/F S", Index = 14, P = "CFS" },
  15694. new { tag = "C/F M", Index = 15, P = "CFM" },
  15695. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  15696. new { tag = "B", Index = 17, P = "B" },
  15697. new { tag = "L", Index = 18, P = "L" },
  15698. new { tag = "D", Index = 19, P = "D" },
  15699. new { tag = "TBR", Index = 20, P = "TBR" },
  15700. new { tag = "SGR", Index = 21, P = "SGR" },
  15701. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  15702. new { tag = "Suite", Index = 23, P = "Suite" },
  15703. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  15704. new { tag = "T/V", Index = 25, P = "TV" },
  15705. new { tag = "1/L", Index = 26, P = "iL" },
  15706. new { tag = "I/F", Index = 27, P = "IF" },
  15707. new { tag = "EF", Index = 28, P = "EF" },
  15708. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  15709. new { tag = "TE", Index = 30, P = "TE" },
  15710. new { tag = "T/G T", Index = 31, P = "TGTips" },
  15711. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  15712. new { tag = "P/C", Index = 33, P = "PC" },
  15713. new { tag = "T/L F", Index = 34, P = "TLF" },
  15714. new { tag = "E/C T", Index = 35, P = "ECT" }
  15715. };
  15716. Func<string, bool> isEmpty = (str) =>
  15717. {
  15718. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  15719. {
  15720. return true;
  15721. }
  15722. if (string.IsNullOrWhiteSpace(str))
  15723. {
  15724. return true;
  15725. }
  15726. return false;
  15727. };
  15728. for (int i = 0; i < List_GC.Count; i++)
  15729. {
  15730. GroupCost_Excel gc = new GroupCost_Excel();
  15731. gc.Id = List_GC[i].Id;
  15732. gc.Diid = List_GC[i].Diid.ToString();
  15733. gc.DAY = List_GC[i].DAY;
  15734. string week = "";
  15735. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  15736. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  15737. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  15738. gc.ITIN = List_GC[i].ITIN;
  15739. gc.CarType = List_GC[i].CarType;
  15740. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  15741. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  15742. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  15743. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  15744. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  15745. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  15746. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  15747. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  15748. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  15749. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  15750. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  15751. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  15752. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  15753. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  15754. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  15755. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  15756. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  15757. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  15758. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  15759. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  15760. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  15761. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  15762. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  15763. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  15764. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  15765. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  15766. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  15767. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  15768. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  15769. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  15770. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  15771. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  15772. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  15773. gc.EFR = List_GC[i].EFR;
  15774. List_GC1.Add(gc);
  15775. }
  15776. if (List_GC1.Count > 0)
  15777. {
  15778. var p = List_GC1[0];
  15779. var prs = p.GetType().GetProperties();
  15780. foreach (var item in prs)
  15781. {
  15782. var tp = item.PropertyType;
  15783. if (tp == typeof(int))
  15784. {
  15785. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  15786. if (val == 0)
  15787. {
  15788. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15789. if (columnSetting != null)
  15790. {
  15791. hideColumnList.Add(columnSetting.Index);
  15792. }
  15793. }
  15794. }
  15795. if (tp == typeof(decimal))
  15796. {
  15797. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  15798. if (val == 0)
  15799. {
  15800. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15801. if (columnSetting != null)
  15802. {
  15803. hideColumnList.Add(columnSetting.Index);
  15804. }
  15805. }
  15806. }
  15807. if (tp == typeof(string))
  15808. {
  15809. var val = List_GC1.Sum(x =>
  15810. {
  15811. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  15812. if (decimal.TryParse(str, out decimal str_De))
  15813. {
  15814. return str_De;
  15815. }
  15816. else
  15817. {
  15818. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  15819. }
  15820. });
  15821. if (val == 0)
  15822. {
  15823. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15824. if (columnSetting != null)
  15825. {
  15826. hideColumnList.Add(columnSetting.Index);
  15827. }
  15828. }
  15829. }
  15830. }
  15831. }
  15832. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  15833. dt.TableName = "TB";
  15834. //报表标题等不用dt的值
  15835. designer.SetDataSource("TeamName", dto.title.TeamName);
  15836. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  15837. designer.SetDataSource("Tax", dto.title.Tax);
  15838. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  15839. designer.SetDataSource("Currency", dto.title.Currency);
  15840. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  15841. designer.SetDataSource("Rate", dto.title.Rate);
  15842. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  15843. var Aparams = hotels.Find(x => x.Type == "Default");
  15844. if (Aparams == null)
  15845. {
  15846. return Ok(jw);
  15847. }
  15848. //酒店数量
  15849. var txtSGRNumber = Aparams.SGR.ToString();
  15850. var txtTBRNumber = Aparams.TBR.ToString();
  15851. var txtJSESNumber = Aparams.JSES.ToString();
  15852. var txtSUITENumbe = Aparams.SUITE.ToString();
  15853. if (dto.costType == "B")
  15854. {
  15855. Aparams = hotels.Find(x => x.Type == "A");
  15856. var Bparams = hotels.Find(x => x.Type == "B");
  15857. if (Aparams == null || Bparams == null)
  15858. {
  15859. return Ok(jw);
  15860. }
  15861. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  15862. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  15863. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  15864. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  15865. }
  15866. designer.SetDataSource("SGRNumber", txtSGRNumber);
  15867. designer.SetDataSource("TBRNumber", txtTBRNumber);
  15868. designer.SetDataSource("JSESNumber", txtJSESNumber);
  15869. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  15870. var ws = designer.Workbook.Worksheets[1];
  15871. int Row = List_GC.Count;
  15872. int startIndex = 0;
  15873. int HideRows = 0;
  15874. Row = 0;
  15875. List<int> hideRowsList = new List<int>();
  15876. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  15877. #region A段left数据
  15878. var left = dto.leftInfo.Find(x => x.Type == "A");
  15879. if (left == null)
  15880. {
  15881. return Ok(jw);
  15882. }
  15883. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  15884. if (leftBindData != null)
  15885. {
  15886. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  15887. designer.SetDataSource("VisaRS", leftBindData.rs);
  15888. designer.SetDataSource("VisaXS", leftBindData.xs);
  15889. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15890. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15891. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15892. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15893. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15894. }
  15895. else
  15896. {
  15897. hideRowsList.Add(Row + startIndex + HideRows);
  15898. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15899. }
  15900. HideRows += 2;
  15901. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  15902. if (leftBindData != null)
  15903. {
  15904. designer.SetDataSource("BXDRCB", leftBindData.cb);
  15905. designer.SetDataSource("BXRS", leftBindData.rs);
  15906. designer.SetDataSource("BXXS", leftBindData.xs);
  15907. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15908. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15909. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15910. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15911. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15912. }
  15913. else
  15914. {
  15915. hideRowsList.Add(Row + startIndex + HideRows);
  15916. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15917. }
  15918. HideRows += 2;
  15919. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15920. if (leftBindData != null)
  15921. {
  15922. designer.SetDataSource("HSDRCB", leftBindData.cb);
  15923. designer.SetDataSource("HSRS", leftBindData.rs);
  15924. designer.SetDataSource("HSXS", leftBindData.xs);
  15925. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15926. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15927. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15928. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15929. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15930. }
  15931. else
  15932. {
  15933. hideRowsList.Add(Row + startIndex + HideRows);
  15934. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15935. }
  15936. HideRows += 2;
  15937. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15938. if (leftBindData != null)
  15939. {
  15940. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  15941. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  15942. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  15943. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15944. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15945. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15946. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15947. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15948. }
  15949. else
  15950. {
  15951. hideRowsList.Add(Row + startIndex + HideRows);
  15952. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15953. }
  15954. HideRows += 2;
  15955. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15956. if (leftBindData != null)
  15957. {
  15958. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  15959. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  15960. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  15961. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15962. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15963. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15964. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15965. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15966. }
  15967. else
  15968. {
  15969. hideRowsList.Add(Row + startIndex + HideRows);
  15970. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15971. }
  15972. HideRows += 2;
  15973. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15974. if (leftBindData != null)
  15975. {
  15976. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  15977. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  15978. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  15979. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15980. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15981. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15982. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15983. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15984. }
  15985. else
  15986. {
  15987. hideRowsList.Add(Row + startIndex + HideRows);
  15988. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15989. }
  15990. HideRows += 2;
  15991. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15992. if (leftBindData != null)
  15993. {
  15994. ////TBR
  15995. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  15996. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  15997. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  15998. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15999. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16000. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16001. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16002. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16003. }
  16004. else
  16005. {
  16006. hideRowsList.Add(Row + startIndex + HideRows);
  16007. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16008. }
  16009. HideRows += 2;
  16010. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  16011. if (leftBindData != null)
  16012. {
  16013. ////SGR
  16014. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  16015. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  16016. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  16017. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16018. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16019. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16020. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16021. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16022. }
  16023. else
  16024. {
  16025. hideRowsList.Add(Row + startIndex + HideRows);
  16026. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16027. }
  16028. HideRows += 2;
  16029. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  16030. if (leftBindData != null)
  16031. {
  16032. ////JS/ES
  16033. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  16034. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  16035. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  16036. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16037. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16038. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16039. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16040. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16041. }
  16042. else
  16043. {
  16044. hideRowsList.Add(Row + startIndex + HideRows);
  16045. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16046. }
  16047. HideRows += 2;
  16048. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  16049. if (leftBindData != null)
  16050. {
  16051. ////SUITE
  16052. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  16053. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  16054. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  16055. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16056. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16057. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16058. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16059. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16060. }
  16061. else
  16062. {
  16063. hideRowsList.Add(Row + startIndex + HideRows);
  16064. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16065. }
  16066. HideRows += 2;
  16067. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  16068. if (leftBindData != null)
  16069. {
  16070. designer.SetDataSource("DJDRCB", leftBindData.cb);
  16071. designer.SetDataSource("DJRS", leftBindData.rs);
  16072. designer.SetDataSource("DJXS", leftBindData.xs);
  16073. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16074. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16075. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16076. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16077. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16078. }
  16079. else
  16080. {
  16081. hideRowsList.Add(Row + startIndex + HideRows);
  16082. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16083. }
  16084. HideRows += 2;
  16085. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  16086. if (leftBindData != null)
  16087. {
  16088. designer.SetDataSource("HCPCB", leftBindData.cb);
  16089. designer.SetDataSource("HCPRS", leftBindData.rs);
  16090. designer.SetDataSource("HCPXS", leftBindData.xs);
  16091. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16092. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16093. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16094. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16095. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16096. }
  16097. else
  16098. {
  16099. hideRowsList.Add(Row + startIndex + HideRows);
  16100. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16101. }
  16102. HideRows += 2;
  16103. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  16104. if (leftBindData != null)
  16105. {
  16106. designer.SetDataSource("CPCB", leftBindData.cb);
  16107. designer.SetDataSource("CPRS", leftBindData.rs);
  16108. designer.SetDataSource("CPXS", leftBindData.xs);
  16109. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16110. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16111. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16112. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16113. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16114. }
  16115. else
  16116. {
  16117. hideRowsList.Add(Row + startIndex + HideRows);
  16118. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16119. }
  16120. HideRows += 2;
  16121. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  16122. if (leftBindData != null)
  16123. {
  16124. designer.SetDataSource("GWDRCD", leftBindData.cb);
  16125. designer.SetDataSource("GWRS", leftBindData.rs);
  16126. designer.SetDataSource("GWXS", leftBindData.xs);
  16127. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16128. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16129. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16130. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16131. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16132. }
  16133. else
  16134. {
  16135. hideRowsList.Add(Row + startIndex + HideRows);
  16136. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16137. }
  16138. HideRows += 2;
  16139. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  16140. if (leftBindData != null)
  16141. {
  16142. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  16143. designer.SetDataSource("LYJRS", leftBindData.rs);
  16144. designer.SetDataSource("LYJXS", leftBindData.xs);
  16145. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16146. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16147. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16148. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16149. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16150. }
  16151. else
  16152. {
  16153. hideRowsList.Add(Row + startIndex + HideRows);
  16154. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16155. }
  16156. #endregion
  16157. #region A段Right信息
  16158. var right = dto.rightInfo.Find(x => x.Type == "A");
  16159. if (right == null)
  16160. {
  16161. return Ok(jw);
  16162. }
  16163. HideRows += 4;
  16164. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  16165. if (rightBindData != null)
  16166. {
  16167. //经济舱 + 双人间 TBR
  16168. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  16169. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  16170. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16171. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  16172. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16173. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16174. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16175. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16176. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16177. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16178. }
  16179. else
  16180. {
  16181. hideRowsList.Add(Row + startIndex + HideRows);
  16182. }
  16183. HideRows += 2;
  16184. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  16185. if (rightBindData != null)
  16186. {
  16187. //经济舱 + 单人间 SGR
  16188. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  16189. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  16190. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16191. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  16192. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16193. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16194. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16195. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16196. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16197. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16198. }
  16199. else
  16200. {
  16201. hideRowsList.Add(Row + startIndex + HideRows);
  16202. }
  16203. HideRows += 2;
  16204. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  16205. if (rightBindData != null)
  16206. {
  16207. //公务舱 + 单人间 SGR
  16208. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  16209. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  16210. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16211. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  16212. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16213. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16214. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16215. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16216. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16217. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16218. }
  16219. else
  16220. {
  16221. hideRowsList.Add(Row + startIndex + HideRows);
  16222. }
  16223. HideRows += 2;
  16224. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  16225. if (rightBindData != null)
  16226. {
  16227. //公务舱 + 小套房 JSES
  16228. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  16229. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  16230. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16231. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  16232. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16233. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16234. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16235. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16236. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16237. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16238. }
  16239. else
  16240. {
  16241. hideRowsList.Add(Row + startIndex + HideRows);
  16242. }
  16243. HideRows += 2;
  16244. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  16245. if (rightBindData != null)
  16246. {
  16247. //公务舱 + 小套房 JSES
  16248. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  16249. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  16250. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16251. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  16252. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16253. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16254. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16255. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16256. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16257. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16258. }
  16259. else
  16260. {
  16261. hideRowsList.Add(Row + startIndex + HideRows);
  16262. }
  16263. HideRows += 2;
  16264. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  16265. if (rightBindData != null)
  16266. {
  16267. //经济舱 + 大套房
  16268. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  16269. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  16270. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16271. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  16272. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16273. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16274. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16275. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16276. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16277. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16278. }
  16279. else
  16280. {
  16281. hideRowsList.Add(Row + startIndex + HideRows);
  16282. }
  16283. HideRows += 2;
  16284. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  16285. if (rightBindData != null)
  16286. {
  16287. //头等舱 + 小套房 JSES
  16288. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  16289. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  16290. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16291. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  16292. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16293. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16294. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16295. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16296. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16297. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16298. }
  16299. else
  16300. {
  16301. hideRowsList.Add(Row + startIndex + HideRows);
  16302. }
  16303. HideRows += 2;
  16304. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  16305. if (rightBindData != null)
  16306. {
  16307. //头等舱 + 大套房
  16308. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  16309. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  16310. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16311. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  16312. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16313. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16314. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16315. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16316. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16317. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16318. }
  16319. else
  16320. {
  16321. hideRowsList.Add(Row + startIndex + HideRows);
  16322. }
  16323. #endregion
  16324. #region B段标题清空
  16325. designer.SetDataSource("CostBDRCB", "");
  16326. designer.SetDataSource("CostBRS", "");
  16327. designer.SetDataSource("CostBXS", "");
  16328. designer.SetDataSource("CostBZCB", "");
  16329. designer.SetDataSource("CostBDRBJ", "");
  16330. designer.SetDataSource("CostBZBJ", "");
  16331. designer.SetDataSource("CostBDRLR", "");
  16332. designer.SetDataSource("CostBZLR", "");
  16333. designer.SetDataSource("CostBDRCBOM", "");
  16334. designer.SetDataSource("CostBRSOM", "");
  16335. designer.SetDataSource("CostBZCBOM", "");
  16336. designer.SetDataSource("CostBDRBJOM", "");
  16337. designer.SetDataSource("CostBZBJOM", "");
  16338. designer.SetDataSource("CostBDRLROM", "");
  16339. designer.SetDataSource("CostBZLROM", "");
  16340. #endregion
  16341. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  16342. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  16343. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  16344. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  16345. designer.SetDataSource("DJName", "地接(CNY)");
  16346. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  16347. designer.SetDataSource("CPName", "地接-船票(CNY)");
  16348. designer.SetDataSource("GWName", "公务(CNY)");
  16349. designer.SetDataSource("YQHName", "邀请函(CNY)");
  16350. designer.SetDataSource("LYJName", "零用金(CNY)");
  16351. designer.SetDataSource("HSName", "核酸检测(CNY)");
  16352. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  16353. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  16354. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  16355. designer.SetDataSource("BXName", "保险(CNY)");
  16356. designer.SetDataSource("VisaName", "签证(CNY)");
  16357. #region B段基本数据
  16358. if (dto.costType == "B")
  16359. {
  16360. left = dto.leftInfo.Find(x => x.Type == "B");
  16361. if (left == null)
  16362. {
  16363. return Ok(jw);
  16364. }
  16365. #region B段left数据
  16366. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  16367. if (leftBindData != null)
  16368. {
  16369. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  16370. designer.SetDataSource("BHSRS", leftBindData.rs);
  16371. designer.SetDataSource("BHSXS", leftBindData.xs);
  16372. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16373. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16374. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16375. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16376. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16377. }
  16378. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  16379. if (leftBindData != null)
  16380. {
  16381. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  16382. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  16383. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  16384. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16385. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16386. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16387. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16388. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16389. }
  16390. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  16391. if (leftBindData != null)
  16392. {
  16393. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  16394. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  16395. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  16396. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16397. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16398. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16399. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16400. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16401. }
  16402. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  16403. if (leftBindData != null)
  16404. {
  16405. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  16406. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  16407. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  16408. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16409. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16410. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16411. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16412. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16413. }
  16414. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  16415. if (leftBindData != null)
  16416. {
  16417. designer.SetDataSource("BHCPCB", leftBindData.cb);
  16418. designer.SetDataSource("BHCPRS", leftBindData.rs);
  16419. designer.SetDataSource("BHCPXS", leftBindData.xs);
  16420. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16421. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16422. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16423. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16424. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16425. }
  16426. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  16427. if (leftBindData != null)
  16428. {
  16429. designer.SetDataSource("BCPCB", leftBindData.cb);
  16430. designer.SetDataSource("BCPRS", leftBindData.rs);
  16431. designer.SetDataSource("BCPXS", leftBindData.xs);
  16432. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16433. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16434. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16435. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16436. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16437. }
  16438. //TBR
  16439. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  16440. if (leftBindData != null)
  16441. {
  16442. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  16443. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  16444. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  16445. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16446. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16447. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16448. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16449. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16450. }
  16451. //SGR
  16452. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  16453. if (leftBindData != null)
  16454. {
  16455. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  16456. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  16457. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  16458. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16459. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16460. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16461. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16462. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16463. }
  16464. //JS/ES
  16465. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  16466. if (leftBindData != null)
  16467. {
  16468. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  16469. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  16470. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  16471. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16472. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16473. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16474. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16475. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16476. }
  16477. //SUITE
  16478. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  16479. if (leftBindData != null)
  16480. {
  16481. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  16482. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  16483. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  16484. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16485. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16486. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16487. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16488. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16489. }
  16490. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  16491. if (leftBindData != null)
  16492. {
  16493. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  16494. designer.SetDataSource("BDJRS", leftBindData.rs);
  16495. designer.SetDataSource("BDJXS", leftBindData.xs);
  16496. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16497. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16498. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16499. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16500. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16501. }
  16502. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  16503. if (leftBindData != null)
  16504. {
  16505. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  16506. designer.SetDataSource("BGWRS", leftBindData.rs);
  16507. designer.SetDataSource("BGWXS", leftBindData.xs);
  16508. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16509. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16510. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16511. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16512. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16513. }
  16514. #region 优化方案
  16515. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  16516. //excelBind.Add("零用金", new {
  16517. //cb="",
  16518. //rs="",
  16519. //xs ="",
  16520. //zcb = "",
  16521. //});
  16522. #endregion
  16523. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  16524. if (leftBindData != null)
  16525. {
  16526. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  16527. designer.SetDataSource("BLYJRS", leftBindData.rs);
  16528. designer.SetDataSource("BLYJXS", leftBindData.xs);
  16529. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16530. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16531. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16532. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16533. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16534. }
  16535. #endregion
  16536. #region B段Right信息
  16537. right = dto.rightInfo.Find(x => x.Type == "B");
  16538. if (right == null)
  16539. {
  16540. return Ok(jw);
  16541. }
  16542. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  16543. if (rightBindData != null)
  16544. {
  16545. //经济舱 + 双人间 TBR
  16546. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  16547. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  16548. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16549. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  16550. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16551. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16552. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16553. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16554. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16555. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16556. }
  16557. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  16558. if (rightBindData != null)
  16559. {
  16560. //经济舱 + 单人间 SGR
  16561. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  16562. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  16563. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16564. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  16565. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16566. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16567. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16568. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16569. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16570. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16571. }
  16572. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  16573. if (rightBindData != null)
  16574. {
  16575. //公务舱 + 单人间 SGR
  16576. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  16577. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  16578. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16579. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  16580. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16581. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16582. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16583. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16584. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16585. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16586. }
  16587. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  16588. if (rightBindData != null)
  16589. {
  16590. //公务舱 + 小套房 JSES
  16591. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  16592. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  16593. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16594. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  16595. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16596. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16597. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16598. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16599. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16600. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16601. }
  16602. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  16603. if (rightBindData != null)
  16604. {
  16605. //公务舱 + 小套房 JSES
  16606. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  16607. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  16608. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16609. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  16610. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16611. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16612. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16613. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16614. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16615. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16616. }
  16617. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  16618. if (rightBindData != null)
  16619. {
  16620. //经济舱 + 大套房
  16621. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  16622. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  16623. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16624. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  16625. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16626. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16627. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16628. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16629. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16630. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16631. }
  16632. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  16633. if (rightBindData != null)
  16634. {
  16635. //头等舱 + 小套房 JSES
  16636. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  16637. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  16638. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16639. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  16640. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16641. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16642. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16643. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16644. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16645. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16646. }
  16647. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  16648. if (rightBindData != null)
  16649. {
  16650. //头等舱 + 大套房
  16651. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  16652. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  16653. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16654. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  16655. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16656. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16657. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16658. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16659. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16660. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16661. }
  16662. #endregion
  16663. #region 标题
  16664. designer.SetDataSource("CostBDRCB", "单人成本");
  16665. designer.SetDataSource("CostBRS", "人数");
  16666. designer.SetDataSource("CostBXS", "系数");
  16667. designer.SetDataSource("CostBZCB", "总成本");
  16668. designer.SetDataSource("CostBDRBJ", "单人报价");
  16669. designer.SetDataSource("CostBZBJ", "总报价");
  16670. designer.SetDataSource("CostBDRLR", "单人利润");
  16671. designer.SetDataSource("CostBZLR", "总利润");
  16672. designer.SetDataSource("CostBDRCBOM", "单人成本");
  16673. designer.SetDataSource("CostBRSOM", "人数");
  16674. designer.SetDataSource("CostBZCBOM", "总成本");
  16675. designer.SetDataSource("CostBDRBJOM", "单人报价");
  16676. designer.SetDataSource("CostBZBJOM", "总报价");
  16677. designer.SetDataSource("CostBDRLROM", "单人利润");
  16678. designer.SetDataSource("CostBZLROM", "总利润");
  16679. #endregion
  16680. }
  16681. #endregion
  16682. designer.SetDataSource("TzZCB2", TzZCB2);
  16683. designer.SetDataSource("TzZBJ2", TzZBJ2);
  16684. designer.SetDataSource("TzZLR2", TzZLR2);
  16685. string[] dataSourceKeys = new string[]
  16686. {
  16687. "VF",
  16688. "TGS",
  16689. "TGOF",
  16690. "TGM",
  16691. "TGA",
  16692. "TGTF",
  16693. "TGEF",
  16694. "CFM",
  16695. "CFOF",
  16696. "B",
  16697. "L",
  16698. "D",
  16699. "TBR",
  16700. "SGR",
  16701. "JSES",
  16702. "Suite",
  16703. "TV",
  16704. "1L",
  16705. "IF",
  16706. "EF",
  16707. "BRF",
  16708. "TE",
  16709. "TGT",
  16710. "DRVT",
  16711. "PC",
  16712. "TLF",
  16713. "ECT"
  16714. };
  16715. foreach (var item in dataSourceKeys)
  16716. {
  16717. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  16718. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  16719. var find = dto.titleModel.FirstOrDefault(expr);
  16720. if (find != null)
  16721. {
  16722. designer.SetDataSource(item, find.text);
  16723. }
  16724. else
  16725. {
  16726. designer.SetDataSource(item, 0);
  16727. }
  16728. }
  16729. designer.SetDataSource(dt);
  16730. //根据数据源处理生成报表内容
  16731. designer.Process();
  16732. designer.Workbook.Worksheets[0].Name = "费用明细";
  16733. designer.Workbook.Worksheets[1].Name = "费用总核算";
  16734. Worksheet sheet = designer.Workbook.Worksheets[0];
  16735. #region 隐藏舱位
  16736. var settingAir = new[]
  16737. {
  16738. new { key = "经济舱", index = 7 },
  16739. new { key = "公务舱", index = 19 },
  16740. new { key = "头等舱", index = 11 }
  16741. };
  16742. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  16743. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  16744. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  16745. .Select((c, s) => s.Name)
  16746. .ToList()
  16747. .GroupBy(x => x)
  16748. .Select(x => x.Key);
  16749. foreach (var item in settingAir)
  16750. {
  16751. if (!airType.Contains(item.key))
  16752. {
  16753. hideRowsList.Add(item.index);
  16754. }
  16755. }
  16756. #endregion
  16757. foreach (var Rowindex in hideRowsList)
  16758. {
  16759. ws.Cells.HideRows(Rowindex, 2);
  16760. }
  16761. ws = designer.Workbook.Worksheets[0];
  16762. foreach (var Column in hideColumnList)
  16763. {
  16764. ws.Cells.HideColumns(Column, 1);
  16765. }
  16766. byte[] bytes = null;
  16767. string strFileName = di.TeamName + "-团组-成本.xls";
  16768. using (MemoryStream stream = new MemoryStream())
  16769. {
  16770. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  16771. bytes = stream.ToArray();
  16772. }
  16773. return Ok(JsonView(true, "", new
  16774. {
  16775. Data = bytes,
  16776. strFileName,
  16777. }));
  16778. }
  16779. /// <summary>
  16780. /// 导出客户报表
  16781. /// </summary>
  16782. /// <returns></returns>
  16783. [HttpPost]
  16784. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  16785. {
  16786. var jw = JsonView(false);
  16787. if (dto.Diid == 0)
  16788. {
  16789. return Ok(JsonView(false, "请传递团组id"));
  16790. }
  16791. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  16792. if (deleInfo.Code != 0)
  16793. {
  16794. return Ok(JsonView(false, "团组信息查询失败!"));
  16795. }
  16796. var di = deleInfo.Data as DelegationInfoWebView;
  16797. if (di == null)
  16798. {
  16799. return Ok(JsonView(false, "团组信息查询失败!"));
  16800. }
  16801. //文件名
  16802. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  16803. //获取模板
  16804. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  16805. //载入模板
  16806. Document doc = new Document(tmppath);
  16807. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  16808. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  16809. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  16810. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  16811. var AParameter = ParameterList.Find(x => x.CostType == "A");
  16812. var BParameter = ParameterList.Find(x => x.CostType == "B");
  16813. if (AParameter == null)
  16814. {
  16815. return Ok(JsonView(false, "系数不存在!"));
  16816. }
  16817. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  16818. , TzAirDesc, TzZCost;
  16819. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  16820. = TzAirDesc = TzZCost = string.Empty;
  16821. TzNumber = AParameter.CostTypenumber.ToString();
  16822. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  16823. CarGuides1 = dto.CarGuides1;
  16824. Meal = dto.Meal;
  16825. SubsidizedMeals = dto.SubsidizedMeals;
  16826. NightRepair = dto.NightRepair;
  16827. AttractionsTickets = dto.AttractionsTickets;
  16828. MiscellaneousFees = dto.MiscellaneousFees;
  16829. ATip = dto.ATip;
  16830. TzHotelDesc = "";
  16831. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  16832. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  16833. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  16834. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  16835. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  16836. TzAirDesc = "";
  16837. TzZCost = dto.TzZCost;
  16838. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  16839. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  16840. var index = 1;
  16841. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  16842. foreach (var item in TzHotelDescArr)
  16843. {
  16844. if (AinfoArr != null)
  16845. {
  16846. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16847. if (Ainfo != null)
  16848. {
  16849. if (int.Parse(Ainfo.rs) <= 0)
  16850. {
  16851. continue;
  16852. }
  16853. var hotelText = string.Empty;
  16854. switch (item)
  16855. {
  16856. case "SGR":
  16857. hotelText = "单人间";
  16858. break;
  16859. case "JSES":
  16860. hotelText = "小套房";
  16861. break;
  16862. case "SUITE":
  16863. hotelText = "套房";
  16864. break;
  16865. case "TBR":
  16866. hotelText = "双人间";
  16867. break;
  16868. }
  16869. if (item != "TBR")
  16870. {
  16871. 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";
  16872. }
  16873. else
  16874. {
  16875. 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";
  16876. }
  16877. index++;
  16878. }
  16879. }
  16880. }
  16881. index = 1;
  16882. foreach (var item in TzAirDescArr)
  16883. {
  16884. if (AinfoArr != null)
  16885. {
  16886. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16887. if (Ainfo != null)
  16888. {
  16889. if (int.Parse(Ainfo.rs) <= 0)
  16890. {
  16891. continue;
  16892. }
  16893. 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";
  16894. index++;
  16895. }
  16896. }
  16897. }
  16898. if (dto.costType == "B")
  16899. {
  16900. if (BParameter == null)
  16901. {
  16902. return Ok(JsonView(false, "B段系数不存在!"));
  16903. }
  16904. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  16905. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  16906. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  16907. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  16908. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  16909. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  16910. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  16911. foreach (var item in TzHotelDescArr)
  16912. {
  16913. if (AinfoArr != null)
  16914. {
  16915. TzHotelDesc += "B段信息 \r\n";
  16916. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16917. if (Ainfo != null)
  16918. {
  16919. if (int.Parse(Ainfo.rs) <= 0)
  16920. {
  16921. continue;
  16922. }
  16923. var hotelText = string.Empty;
  16924. switch (item)
  16925. {
  16926. case "SGR":
  16927. hotelText = "单人间";
  16928. break;
  16929. case "JSES":
  16930. hotelText = "小套房";
  16931. break;
  16932. case "SUITE":
  16933. hotelText = "套房";
  16934. break;
  16935. case "TBR":
  16936. hotelText = "双人间";
  16937. break;
  16938. }
  16939. if (item != "TBR")
  16940. {
  16941. 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";
  16942. }
  16943. else
  16944. {
  16945. 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";
  16946. }
  16947. index++;
  16948. }
  16949. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  16950. }
  16951. }
  16952. index = 1;
  16953. foreach (var item in TzAirDescArr)
  16954. {
  16955. if (AinfoArr != null)
  16956. {
  16957. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16958. if (Ainfo != null)
  16959. {
  16960. if (int.Parse(Ainfo.rs) <= 0)
  16961. {
  16962. continue;
  16963. }
  16964. 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";
  16965. index++;
  16966. }
  16967. }
  16968. }
  16969. }
  16970. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  16971. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  16972. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  16973. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  16974. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  16975. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  16976. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  16977. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  16978. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  16979. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  16980. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  16981. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  16982. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  16983. DickeyValue.Add("Visa", Visa); // 签证单人报价
  16984. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  16985. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  16986. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  16987. DickeyValue.Add("TzZCost", TzZCost);
  16988. foreach (var key in DickeyValue.Keys)
  16989. {
  16990. if (doc.Range.Bookmarks[key] != null)
  16991. {
  16992. Bookmark mark = doc.Range.Bookmarks[key];
  16993. mark.Text = DickeyValue[key];
  16994. }
  16995. }
  16996. byte[] bytes = null;
  16997. string strFileName = di.TeamName + "-客户报价.doc";
  16998. using (MemoryStream stream = new MemoryStream())
  16999. {
  17000. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  17001. bytes = stream.ToArray();
  17002. }
  17003. return Ok(JsonView(true, "", new
  17004. {
  17005. Data = bytes,
  17006. strFileName,
  17007. }));
  17008. }
  17009. /// <summary>
  17010. /// 团组成本 各模块(酒店,地接,机票)成本提示
  17011. /// </summary>
  17012. /// <param name="dto"></param>
  17013. /// <returns></returns>
  17014. [HttpPost]
  17015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17016. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  17017. {
  17018. try
  17019. {
  17020. #region 参数验证
  17021. if (dto.DiId < 0)
  17022. {
  17023. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  17024. }
  17025. List<int> cTableIds = new List<int>() {
  17026. 76 ,//酒店预订
  17027. 77 ,//行程
  17028. 79 ,//车/导游地接
  17029. 80 ,//签证
  17030. 81 ,//邀请/公务活
  17031. 82 ,//团组客户保险
  17032. 85 ,//机票预订
  17033. 98 ,//其他款项
  17034. 285 ,//收款退还
  17035. 751 ,//酒店早餐
  17036. 1015 // 超支费用
  17037. };
  17038. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  17039. {
  17040. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  17041. }
  17042. #endregion
  17043. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  17044. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  17045. if (_GroupCostParameters.Count <= 0)
  17046. {
  17047. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  17048. }
  17049. if (_GroupCostParameters[0].IsShare == 0)
  17050. {
  17051. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  17052. }
  17053. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  17054. //处理date为空问题
  17055. if (_GroupCosts.Count > 0)
  17056. {
  17057. for (int i = 0; i < _GroupCosts.Count; i++)
  17058. {
  17059. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  17060. {
  17061. if (i > 0)
  17062. {
  17063. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  17064. }
  17065. }
  17066. }
  17067. }
  17068. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  17069. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  17070. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  17071. string currCode = "";
  17072. #region currCode 验证
  17073. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  17074. if (isInt)
  17075. {
  17076. var currData = currDatas.Find(it => it.Id == intCurrency);
  17077. if (currData != null)
  17078. {
  17079. currCode = currData.Name;
  17080. }
  17081. }
  17082. else
  17083. {
  17084. currCode = _GroupCostParameters[0].Currency.Trim();
  17085. }
  17086. #endregion
  17087. //op,酒店单段模式存储
  17088. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  17089. {
  17090. CurrencyCode = currCode,
  17091. Rate = _GroupCostParameters[0].Rate,
  17092. CostType = _GroupCostParameters[0].CostType,
  17093. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  17094. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  17095. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  17096. };
  17097. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  17098. if (_GroupCostParameters.Count == 2)
  17099. {
  17100. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  17101. }
  17102. foreach (var item in _GroupCostParameters)
  17103. {
  17104. decimal _rate = 1;
  17105. decimal _rate1 = item.Rate;
  17106. decimal _scale = 1;
  17107. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  17108. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  17109. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  17110. //if (userInfo != null)
  17111. //{
  17112. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  17113. // {
  17114. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  17115. // {
  17116. // _scale = 1.00M;
  17117. // }
  17118. // }
  17119. //}
  17120. #endregion
  17121. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  17122. {
  17123. CurrencyCode = currCode,
  17124. Rate = _rate1,
  17125. CostType = item.CostType,
  17126. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  17127. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  17128. CostTypeNumber = item.CostTypenumber
  17129. };
  17130. if (_GroupCostParameters.Count > 1)
  17131. {
  17132. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  17133. }
  17134. else
  17135. {
  17136. modulePromptInfo.CostTypeNumber = item.LYJRS;
  17137. }
  17138. if (dto.CTable == 79)//
  17139. {
  17140. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  17141. modulePromptInfo.TotalCost = item.DJCB;
  17142. }
  17143. List<string> costTypes = new List<string>() { "A", "B" };
  17144. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  17145. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  17146. if (_GroupCostsDuplicates.Count() == 1)
  17147. {
  17148. _GroupCostsTypeData = _GroupCosts;
  17149. }
  17150. else
  17151. {
  17152. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  17153. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  17154. }
  17155. /*
  17156. * 76 酒店预订
  17157. * 77 行程
  17158. * 79 车/导游地接
  17159. * 80 签证
  17160. * 81 邀请/公务活动
  17161. * 82 团组客户保险
  17162. * 85 机票预订
  17163. * 98 其他款项
  17164. * 285 收款退还
  17165. * 751 酒店早餐
  17166. * 1015 超支费用
  17167. */
  17168. switch (dto.CTable)
  17169. {
  17170. case 76: // 酒店预订
  17171. _ModuleSubPromptInfo.AddRange(
  17172. _GroupCostsTypeData.Select(it => new
  17173. {
  17174. it.DAY,
  17175. it.Date,
  17176. it.ACCON,
  17177. it.ITIN,
  17178. it.SGR,
  17179. it.TBR,
  17180. it.JS_ES,
  17181. it.Suite
  17182. })
  17183. );
  17184. break;
  17185. case 79: // 车/导游地接
  17186. _ModuleSubPromptInfo.AddRange(
  17187. _GroupCostsTypeData.Select(it => new
  17188. {
  17189. Date = it.Date, //日期
  17190. CarFee = it.CarCost * _rate * _scale, //车费用
  17191. CarType = it.CarType, //车型
  17192. DriverFee = it.CFS * _rate * _scale, //司机工资
  17193. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  17194. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  17195. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  17196. GuideFee = it.TGS * _rate * _scale, //导游费用
  17197. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  17198. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  17199. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  17200. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  17201. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  17202. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  17203. Breakfast = it.B * _rate * _scale, //早餐费
  17204. Lunch = it.L * _rate * _scale, //午餐费
  17205. Dinner = it.D * _rate * _scale, //晚餐费
  17206. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  17207. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  17208. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  17209. TicketFee = it.EF * _rate * _scale, //门票费
  17210. TicketRemark = it.EFR, //门票费描述
  17211. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  17212. TravelSupplies = it.TE * _rate * _scale, //出行物资
  17213. SpentCash = it.PC * _rate * _scale, //零用金
  17214. LeadersFee = it.TLF * _rate * _scale, //领队费
  17215. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  17216. })
  17217. );
  17218. break;
  17219. case 85: // 机票
  17220. List<dynamic> datas = new List<dynamic>();
  17221. datas.Add(
  17222. new
  17223. {
  17224. AirType = "经济舱",
  17225. AirNum = item.JJCRS,
  17226. AirDRCB = item.JJCCB,
  17227. AirZCB = (item.JJCRS * item.JJCCB)
  17228. }
  17229. );
  17230. datas.Add(
  17231. new
  17232. {
  17233. AirType = "公务舱",
  17234. AirNum = item.GWCRS,
  17235. AirDRCB = item.GWCCB,
  17236. AirZCB = (item.GWCRS * item.GWCCB)
  17237. }
  17238. );
  17239. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  17240. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  17241. modulePromptInfo.Data = new
  17242. {
  17243. airFeeData = datas,
  17244. airInitData = initDatas
  17245. };
  17246. _ModulePromptInfos.Add(modulePromptInfo);
  17247. break;
  17248. default:
  17249. break;
  17250. }
  17251. }
  17252. if (dto.CTable != 85)
  17253. {
  17254. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  17255. _ModulePromptInfos.Add(_ModulePromptInfo);
  17256. }
  17257. _view.ModulePromptInfos = _ModulePromptInfos;
  17258. return Ok(JsonView(true, "操作成功!", _view));
  17259. }
  17260. catch (Exception ex)
  17261. {
  17262. return Ok(JsonView(false, ex.Message));
  17263. }
  17264. }
  17265. /// <summary>
  17266. /// 根据黑屏代码重新生成行程
  17267. /// </summary>
  17268. /// <param name="dto"></param>
  17269. /// <returns></returns>
  17270. [HttpPost]
  17271. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  17272. {
  17273. var jw = JsonView(false, "Error");
  17274. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  17275. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  17276. .Select(x => new
  17277. {
  17278. x.Id,
  17279. x.Title
  17280. })
  17281. .ToList();
  17282. if (Create.Any())
  17283. {
  17284. jw.Msg = "获取成功!";
  17285. jw.Code = 200;
  17286. jw.Data = new
  17287. {
  17288. BlackCodeListSelect = Create,
  17289. blackCodeIsTrue = true
  17290. };
  17291. }
  17292. else
  17293. {
  17294. jw.Code = 400;
  17295. jw.Data = new
  17296. {
  17297. BlackCodeListSelect = Create,
  17298. blackCodeIsTrue = false,
  17299. };
  17300. }
  17301. return Ok(jw);
  17302. }
  17303. /// <summary>
  17304. /// 根据黑屏代码Id重新生成行程
  17305. /// </summary>
  17306. /// <param name="dto"></param>
  17307. /// <returns></returns>
  17308. [HttpPost]
  17309. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  17310. {
  17311. var jw = JsonView(false, "Error");
  17312. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  17313. if (result.Code == 0)
  17314. {
  17315. jw.Msg = "获取成功!";
  17316. jw.Code = 200;
  17317. jw.Data = new
  17318. {
  17319. groupCost = result.Data,
  17320. blackCodeIsTrue = true
  17321. };
  17322. }
  17323. else
  17324. {
  17325. jw.Code = 400;
  17326. jw.Data = new
  17327. {
  17328. groupCost = result.Data,
  17329. blackCodeIsTrue = false,
  17330. };
  17331. }
  17332. return Ok(jw);
  17333. }
  17334. /// <summary>
  17335. /// 成本获取OP历史车费用
  17336. /// </summary>
  17337. /// <param name="dto"></param>
  17338. /// <returns></returns>
  17339. [HttpPost]
  17340. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  17341. {
  17342. var jw = JsonView(false);
  17343. try
  17344. {
  17345. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  17346. //获取现有所有车的数据
  17347. if (!dto.Param.IsNullOrWhiteSpace())
  17348. {
  17349. string sql = $@"
  17350. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  17351. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  17352. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  17353. 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
  17354. AND gctggr.ServiceEndTime is not NULL
  17355. ORDER by gctggrc.id DESC
  17356. ";
  17357. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  17358. var numeberResult = await Task.Run(() =>
  17359. {
  17360. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  17361. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  17362. return numberArr;
  17363. });
  17364. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  17365. foreach (var item in numeberResult)
  17366. {
  17367. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  17368. {
  17369. Country = "数据异常!",
  17370. City = string.Empty,
  17371. };
  17372. item.Area = find.Country + " " + find.City;
  17373. }
  17374. dbResult.AddRange(numeberResult);
  17375. if (dto.Param.Contains("、"))
  17376. {
  17377. var sp = dto.Param.Split("、");
  17378. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  17379. .Where(x =>
  17380. {
  17381. return System.Array.Exists(sp, e =>
  17382. {
  17383. bool where = false;
  17384. if (x.Area != null)
  17385. {
  17386. where = x.Area.Contains(e);
  17387. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  17388. {
  17389. return false;
  17390. }
  17391. }
  17392. if (x.PriceName != null && !where)
  17393. {
  17394. where = x.PriceName.Contains(e);
  17395. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  17396. {
  17397. return false;
  17398. }
  17399. }
  17400. return where;
  17401. });
  17402. }).ToList();
  17403. }
  17404. else
  17405. {
  17406. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  17407. .Where(x =>
  17408. {
  17409. bool where = false;
  17410. if (x.Area != null)
  17411. {
  17412. where = x.Area.Contains(dto.Param);
  17413. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  17414. {
  17415. return false;
  17416. }
  17417. }
  17418. if (x.PriceName != null && !where)
  17419. {
  17420. where = x.PriceName.Contains(dto.Param);
  17421. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  17422. {
  17423. return false;
  17424. }
  17425. }
  17426. return where;
  17427. }
  17428. )
  17429. .ToList();
  17430. }
  17431. }
  17432. var view = dbResult.Select(x =>
  17433. {
  17434. decimal dp = 0.00M;
  17435. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  17436. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  17437. if (string.IsNullOrWhiteSpace(x.DatePrice))
  17438. {
  17439. if (startB && endB)
  17440. {
  17441. var timesp = endD.Subtract(startD);
  17442. if ((timesp.Days + 1) != 0)
  17443. {
  17444. dp = x.Price / (timesp.Days + 1);
  17445. }
  17446. }
  17447. }
  17448. else
  17449. {
  17450. dp = x.Price;
  17451. }
  17452. return new
  17453. {
  17454. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  17455. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  17456. x.Area,
  17457. x.id,
  17458. price = x.Price.ToString("F2"),
  17459. x.PriceName,
  17460. x.PriceContent,
  17461. x.TeamName,
  17462. x.DatePrice,
  17463. dayPrice = dp.ToString("F2"),
  17464. };
  17465. }).OrderByDescending(x => x.id).ToList();
  17466. jw = JsonView(true, "获取成功!", view);
  17467. }
  17468. catch (Exception e)
  17469. {
  17470. jw = JsonView(false, e.Message);
  17471. }
  17472. return Ok(jw);
  17473. }
  17474. [HttpPost]
  17475. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  17476. {
  17477. var jw = JsonView(true);
  17478. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  17479. #region SQL语句
  17480. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  17481. //{
  17482. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  17483. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  17484. // WHEN COUNT(*) >= 0 THEN 'True'
  17485. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  17486. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  17487. // ")
  17488. // .ToList();
  17489. //}
  17490. //else
  17491. //{
  17492. // string likeKey = string.Empty;
  17493. // foreach (var item in dto.Keyword)
  17494. // {
  17495. // likeKey += "%" + item;
  17496. // }
  17497. // likeKey += "%";
  17498. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  17499. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  17500. // WHEN COUNT(*) >= 0 THEN 'True'
  17501. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  17502. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  17503. // ")
  17504. // .ToList();
  17505. //}
  17506. #endregion
  17507. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  17508. {
  17509. @KeyWord = dto.Keyword
  17510. });
  17511. if (table != null && table.Rows.Count > 0)
  17512. {
  17513. foreach (DataRow row in table.Rows)
  17514. {
  17515. matches.Add(new DelegationInfoAndIsTrueView
  17516. {
  17517. Id = row.Field<int>("Id"),
  17518. GroupName = row.Field<string>("GroupName"),
  17519. isTrue = row.Field<string>("isTrue")
  17520. });
  17521. }
  17522. }
  17523. if (matches.Any())
  17524. {
  17525. jw.Data = matches;
  17526. }
  17527. else
  17528. {
  17529. jw.Code = 201;
  17530. jw.Msg = "empty list";
  17531. jw.Data = new List<string>(1);
  17532. }
  17533. return Ok(jw);
  17534. }
  17535. /// <summary>
  17536. /// 报价Word下载
  17537. /// </summary>
  17538. /// <param name="dto"></param>
  17539. /// <returns></returns>
  17540. [HttpPost]
  17541. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  17542. {
  17543. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17544. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17545. if (di == null)
  17546. {
  17547. return Ok(JsonView(false, "团组不存在!"));
  17548. }
  17549. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17550. if (mainPrice == null || mainPrice.IsShare == 0)
  17551. {
  17552. return Ok(JsonView(false, "团组成本不存在!"));
  17553. }
  17554. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17555. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17556. if (costTypeHotelNumbers == null)
  17557. {
  17558. return Ok(JsonView(false, "团组成本不存在!"));
  17559. }
  17560. //文件名
  17561. string strFileName = di.TeamName + "-收款账单.doc";
  17562. //获取模板
  17563. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  17564. //载入模板
  17565. Document doc = new Document(tmppath);
  17566. decimal allPrice = 0.00M;
  17567. string itemStr = string.Empty;
  17568. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  17569. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  17570. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  17571. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  17572. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  17573. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  17574. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  17575. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  17576. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  17577. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  17578. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17579. {
  17580. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17581. ("BXRS", "BXCB", "BXXS", "bx"),
  17582. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17583. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17584. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  17585. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  17586. ("CPRS", "CPCB", "CPXS", "cp"),
  17587. ("HSRS", "HSCB", "HSXS", "hsjc"),
  17588. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  17589. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  17590. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  17591. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  17592. ("DJRS", "DJCB", "DJXS", "dj"),
  17593. ("GWRS", "GWCB", "GWXS", "gw"),
  17594. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  17595. };
  17596. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17597. var rightSum = 0.00M;
  17598. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17599. {
  17600. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17601. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17602. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17603. if (prefix == "tbr")
  17604. {
  17605. rsValue *= 2;
  17606. cbValue /= 2;
  17607. }
  17608. if (OtherCostPropertyBJ.Contains(prefix))
  17609. {
  17610. rightSum += cbValue * xsValue;
  17611. }
  17612. }
  17613. var hotelRooms = new Dictionary<string, int>
  17614. {
  17615. { "SGR", costTypeHotelNumbers.SGR },
  17616. { "TBR", costTypeHotelNumbers.TBR },
  17617. { "JSES", costTypeHotelNumbers.JSES },
  17618. { "SUITE", costTypeHotelNumbers.SUITE }
  17619. };
  17620. var flights = new Dictionary<string, int>
  17621. {
  17622. { "经济舱", mainPrice.JJCRS },
  17623. { "公务舱", mainPrice.GWCRS },
  17624. { "头等舱", mainPrice.TDCRS }
  17625. };
  17626. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17627. {
  17628. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17629. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17630. { "头等舱", new[] { "SUITE", "JSES" } }
  17631. };
  17632. var result = new Dictionary<string, int>();
  17633. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  17634. foreach (var flight in flights.Keys)
  17635. {
  17636. // 获取当前舱位的匹配规则
  17637. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17638. {
  17639. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17640. }
  17641. }
  17642. #region right计算
  17643. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17644. {
  17645. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17646. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17647. airHotelPriceList.Add(new
  17648. AirHotelPrice
  17649. {
  17650. Name = "经济舱TBR",
  17651. Price = rightSum + air + hotel,
  17652. Count = result["经济舱TBR"] * 2
  17653. });
  17654. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17655. }
  17656. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17657. {
  17658. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17659. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17660. airHotelPriceList.Add(new
  17661. AirHotelPrice
  17662. {
  17663. Name = "经济舱SGR",
  17664. Price = rightSum + air + hotel,
  17665. Count = result["经济舱SGR"]
  17666. });
  17667. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17668. }
  17669. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17670. {
  17671. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17672. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17673. airHotelPriceList.Add(new
  17674. AirHotelPrice
  17675. {
  17676. Name = "公务舱SGR",
  17677. Price = rightSum + air + hotel,
  17678. Count = result["公务舱SGR"]
  17679. });
  17680. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17681. }
  17682. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17683. {
  17684. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17685. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17686. airHotelPriceList.Add(new
  17687. AirHotelPrice
  17688. {
  17689. Name = "公务舱JSES",
  17690. Price = rightSum + air + hotel,
  17691. Count = result["公务舱JSES"]
  17692. });
  17693. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17694. }
  17695. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17696. {
  17697. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17698. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17699. airHotelPriceList.Add(new
  17700. AirHotelPrice
  17701. {
  17702. Name = "公务舱SUITE",
  17703. Price = rightSum + air + hotel,
  17704. Count = result["公务舱SUITE"]
  17705. });
  17706. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17707. }
  17708. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17709. {
  17710. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17711. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17712. airHotelPriceList.Add(new
  17713. AirHotelPrice
  17714. {
  17715. Name = "经济舱SUITE",
  17716. Price = rightSum + air + hotel,
  17717. Count = result["经济舱SUITE"]
  17718. });
  17719. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17720. }
  17721. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17722. {
  17723. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17724. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17725. airHotelPriceList.Add(new
  17726. AirHotelPrice
  17727. {
  17728. Name = "头等舱JSES",
  17729. Price = rightSum + air + hotel,
  17730. Count = result["头等舱JSES"]
  17731. });
  17732. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17733. }
  17734. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17735. {
  17736. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17737. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17738. airHotelPriceList.Add(new
  17739. AirHotelPrice
  17740. {
  17741. Name = "头等舱SUITE",
  17742. Price = rightSum + air + hotel,
  17743. Count = result["头等舱SUITE"]
  17744. });
  17745. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17746. }
  17747. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17748. {
  17749. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17750. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17751. airHotelPriceList.Add(new
  17752. AirHotelPrice
  17753. {
  17754. Name = "经济舱JSES",
  17755. Price = rightSum + air + hotel,
  17756. Count = result["经济舱JSES"]
  17757. });
  17758. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17759. }
  17760. #endregion
  17761. foreach (var item in airSouer.Keys)
  17762. {
  17763. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  17764. if (find != null && find.Count > 0)
  17765. {
  17766. if (item.Contains("TBR"))
  17767. {
  17768. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17769. }
  17770. else
  17771. {
  17772. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17773. }
  17774. }
  17775. }
  17776. #region 替换Word模板书签内容
  17777. Dictionary<string, string> marks = new Dictionary<string, string>();
  17778. marks.Add("To", di.ClientUnit);//付款方
  17779. marks.Add("ToTel", di.TellPhone);//付款方电话
  17780. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  17781. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  17782. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  17783. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  17784. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  17785. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  17786. marks.Add("PayItemContent", itemStr);//详细信息
  17787. marks.Add("Total", allPrice.ToString("F2"));//合计
  17788. #endregion
  17789. foreach (var item in marks.Keys)
  17790. {
  17791. if (doc.Range.Bookmarks[item] != null)
  17792. {
  17793. Bookmark mark = doc.Range.Bookmarks[item];
  17794. mark.Text = marks[item];
  17795. }
  17796. }
  17797. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  17798. doc.Save(savePaht);
  17799. var jw = new JsonView();
  17800. jw.Msg = "生成成功!";
  17801. jw.Code = 200;
  17802. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  17803. return Ok(jw);
  17804. }
  17805. /// <summary>
  17806. /// 详细报价费用Excel下载
  17807. /// </summary>
  17808. /// <param name="dto"></param>
  17809. /// <returns></returns>
  17810. [HttpPost]
  17811. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  17812. {
  17813. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17814. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17815. if (di == null)
  17816. {
  17817. return Ok(JsonView(false, "团组不存在!"));
  17818. }
  17819. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17820. if (mainPrice == null || mainPrice.IsShare == 0)
  17821. {
  17822. return Ok(JsonView(false, "团组成本不存在!"));
  17823. }
  17824. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17825. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17826. if (costTypeHotelNumbers == null)
  17827. {
  17828. return Ok(JsonView(false, "团组成本不存在!"));
  17829. }
  17830. WorkbookDesigner designer = new WorkbookDesigner();
  17831. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  17832. List<int> hideRowsList = new List<int>();
  17833. int conterStartIndex = 3;
  17834. int rowIndex = conterStartIndex;
  17835. designer.SetDataSource("GroupName", di.TeamName);
  17836. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17837. {
  17838. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17839. ("BXRS", "BXCB", "BXXS", "bx"),
  17840. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17841. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17842. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  17843. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  17844. ("CPRS", "CPCB", "CPXS", "cp") ,
  17845. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  17846. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  17847. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  17848. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  17849. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  17850. ("DJRS", "DJCB", "DJXS", "dj") ,
  17851. ("GWRS", "GWCB", "GWXS", "gw") ,
  17852. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  17853. };
  17854. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17855. var rightSum = 0.00M;
  17856. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17857. {
  17858. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17859. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17860. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17861. if (prefix == "tbr")
  17862. {
  17863. rsValue *= 2;
  17864. cbValue /= 2;
  17865. }
  17866. if (OtherCostPropertyBJ.Contains(prefix))
  17867. {
  17868. rightSum += cbValue * xsValue;
  17869. }
  17870. if (rsValue == 0)
  17871. {
  17872. hideRowsList.Add(rowIndex);
  17873. }
  17874. else
  17875. {
  17876. designer.SetDataSource($"{prefix}rs", rsValue);
  17877. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  17878. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  17879. }
  17880. rowIndex += 2;
  17881. }
  17882. var hotelRooms = new Dictionary<string, int>
  17883. {
  17884. { "SGR", costTypeHotelNumbers.SGR },
  17885. { "TBR", costTypeHotelNumbers.TBR },
  17886. { "JSES", costTypeHotelNumbers.JSES },
  17887. { "SUITE", costTypeHotelNumbers.SUITE }
  17888. };
  17889. var flights = new Dictionary<string, int>
  17890. {
  17891. { "经济舱", mainPrice.JJCRS },
  17892. { "公务舱", mainPrice.GWCRS },
  17893. { "头等舱", mainPrice.TDCRS }
  17894. };
  17895. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17896. {
  17897. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17898. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17899. { "头等舱", new[] { "SUITE", "JSES" } }
  17900. };
  17901. var result = new Dictionary<string, int>();
  17902. foreach (var flight in flights.Keys)
  17903. {
  17904. // 获取当前舱位的匹配规则
  17905. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17906. {
  17907. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17908. }
  17909. }
  17910. var allPrice = 0.00M;
  17911. #region right计算
  17912. int airRowIndex = 35;
  17913. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17914. {
  17915. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17916. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17917. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  17918. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  17919. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  17920. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17921. }
  17922. else
  17923. {
  17924. hideRowsList.Add(airRowIndex);
  17925. }
  17926. airRowIndex += 2;
  17927. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17928. {
  17929. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17930. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17931. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  17932. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  17933. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  17934. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17935. }
  17936. else
  17937. {
  17938. hideRowsList.Add(airRowIndex);
  17939. }
  17940. airRowIndex += 2;
  17941. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17942. {
  17943. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17944. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17945. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  17946. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  17947. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  17948. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17949. }
  17950. else
  17951. {
  17952. hideRowsList.Add(airRowIndex);
  17953. }
  17954. airRowIndex += 2;
  17955. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17956. {
  17957. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17958. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17959. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  17960. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  17961. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  17962. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17963. }
  17964. else
  17965. {
  17966. hideRowsList.Add(airRowIndex);
  17967. }
  17968. airRowIndex += 2;
  17969. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17970. {
  17971. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17972. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17973. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  17974. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  17975. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  17976. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17977. }
  17978. else
  17979. {
  17980. hideRowsList.Add(airRowIndex);
  17981. }
  17982. airRowIndex += 2;
  17983. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17984. {
  17985. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17986. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17987. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  17988. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  17989. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  17990. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17991. }
  17992. else
  17993. {
  17994. hideRowsList.Add(airRowIndex);
  17995. }
  17996. airRowIndex += 2;
  17997. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17998. {
  17999. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  18000. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18001. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  18002. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  18003. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  18004. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  18005. }
  18006. else
  18007. {
  18008. hideRowsList.Add(airRowIndex);
  18009. }
  18010. airRowIndex += 2;
  18011. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  18012. {
  18013. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  18014. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  18015. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  18016. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  18017. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  18018. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  18019. }
  18020. else
  18021. {
  18022. hideRowsList.Add(airRowIndex);
  18023. }
  18024. airRowIndex += 2;
  18025. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  18026. {
  18027. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18028. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18029. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  18030. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  18031. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  18032. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  18033. }
  18034. else
  18035. {
  18036. hideRowsList.Add(airRowIndex);
  18037. }
  18038. #endregion
  18039. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  18040. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  18041. var ws = designer.Workbook.Worksheets[0];
  18042. foreach (var Rowindex in hideRowsList)
  18043. {
  18044. ws.Cells.HideRows(Rowindex, 2);
  18045. }
  18046. designer.Process();
  18047. designer.Workbook.Save(savePaht);
  18048. return Ok(JsonView(true, "生成成功!", new
  18049. {
  18050. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  18051. }));
  18052. }
  18053. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  18054. {
  18055. foreach (var roomType in roomTypes)
  18056. {
  18057. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  18058. {
  18059. hotelRooms[roomType]--;
  18060. flights[flightType]--;
  18061. if (roomType == "TBR")
  18062. {
  18063. flights[flightType]--; // 双人间在减少1
  18064. }
  18065. string key = flightType + roomType;
  18066. if (result.Keys.Contains(key))
  18067. {
  18068. result[key]++;
  18069. }
  18070. else
  18071. {
  18072. result.Add(key, 1);
  18073. }
  18074. }
  18075. }
  18076. }
  18077. private class AirHotelPrice
  18078. {
  18079. public string Name { get; set; }
  18080. public decimal Price { get; set; }
  18081. public int Count { get; set; }
  18082. }
  18083. /// <summary>
  18084. /// 团组系数设置
  18085. /// </summary>
  18086. /// <param name="dto"></param>
  18087. /// <returns></returns>
  18088. [HttpPost]
  18089. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  18090. {
  18091. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  18092. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  18093. if (di == null)
  18094. {
  18095. return Ok(JsonView(false, "团组不存在!"));
  18096. }
  18097. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  18098. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  18099. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  18100. // FirstAsync(firstExpression.ToExpression());
  18101. #region JSON
  18102. string hcpJson = @"
  18103. [
  18104. {
  18105. ""min"": 1,
  18106. ""max"": 500,
  18107. ""value"": 1.50
  18108. },
  18109. {
  18110. ""min"": 501,
  18111. ""max"": 1000,
  18112. ""value"": 1.40
  18113. },
  18114. {
  18115. ""min"": 1001,
  18116. ""max"": 2000,
  18117. ""value"": 1.35
  18118. }
  18119. ]";
  18120. #endregion
  18121. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  18122. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  18123. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  18124. .ToList();
  18125. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  18126. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  18127. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  18128. // new List<(Predicate<decimal>, decimal)>()
  18129. // {
  18130. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  18131. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  18132. // }
  18133. // ));
  18134. #region 签证系数
  18135. var visaXS = 0.00M;
  18136. switch (dto.VisaCB)
  18137. {
  18138. case decimal n when (n > 1 && n < 500):
  18139. switch (dto.VisaRS)
  18140. {
  18141. case 2 or 3:
  18142. visaXS = 1.35M;
  18143. break;
  18144. case 4 or 5:
  18145. visaXS = 1.30M;
  18146. break;
  18147. case 6 or 7:
  18148. visaXS = 1.25M;
  18149. break;
  18150. case 8 or 9 or 10:
  18151. visaXS = 1.20M;
  18152. break;
  18153. case > 10:
  18154. visaXS = 1.15M;
  18155. break;
  18156. default:
  18157. visaXS = 0.00M;
  18158. break;
  18159. }
  18160. break;
  18161. case decimal n when (n >= 500 && n < 1000):
  18162. switch (dto.VisaRS)
  18163. {
  18164. case 2 or 3 or 4:
  18165. visaXS = 1.30M;
  18166. break;
  18167. case 5 or 6 or 7 or 8:
  18168. visaXS = 1.25M;
  18169. break;
  18170. case 9 or 10:
  18171. visaXS = 1.20M;
  18172. break;
  18173. case > 10:
  18174. visaXS = 1.15M;
  18175. break;
  18176. default:
  18177. visaXS = 0.00M;
  18178. break;
  18179. }
  18180. break;
  18181. default:
  18182. switch (dto.VisaRS)
  18183. {
  18184. case 2 or 3 or 4:
  18185. visaXS = 1.30M;
  18186. break;
  18187. case 5 or 6 or 7 or 8:
  18188. visaXS = 1.25M;
  18189. break;
  18190. case 9 or 10:
  18191. visaXS = 1.20M;
  18192. break;
  18193. case > 10:
  18194. visaXS = 1.15M;
  18195. break;
  18196. default:
  18197. visaXS = 0.00M;
  18198. break;
  18199. }
  18200. break;
  18201. }
  18202. #endregion
  18203. #region 火车系数
  18204. var hcpXS = 0.00M;
  18205. foreach (var (condition, result) in hcpSwitchDictionary)
  18206. {
  18207. if (condition(dto.HCPCB))
  18208. {
  18209. hcpXS = result;
  18210. break;
  18211. }
  18212. }
  18213. #endregion
  18214. #region 机票系数
  18215. #region 经济舱系数
  18216. var jjcXS = 0.00M;
  18217. switch (dto.JJCCB)
  18218. {
  18219. case decimal x when (x >= 1000 && x <= 3000):
  18220. jjcXS = 2.6M;
  18221. break;
  18222. case decimal x when (x >= 3001 && x <= 8000):
  18223. jjcXS = 2.3M;
  18224. break;
  18225. case decimal x when (x >= 8001 && x <= 15000):
  18226. jjcXS = 2.1M;
  18227. break;
  18228. case decimal x when (x >= 15001 && x <= 30000):
  18229. jjcXS = 1.95M;
  18230. break;
  18231. case > 30000:
  18232. jjcXS = 1.8M;
  18233. break;
  18234. default:
  18235. break;
  18236. }
  18237. #endregion
  18238. #region 公务舱系数
  18239. var gwcXS = 0.00M;
  18240. switch (dto.GWCCB)
  18241. {
  18242. case decimal x when (x >= 1000 && x <= 3000):
  18243. gwcXS = 2.5M;
  18244. break;
  18245. case decimal x when (x >= 3001 && x <= 8000):
  18246. gwcXS = 2.2M;
  18247. break;
  18248. case decimal x when (x >= 8001 && x <= 15000):
  18249. gwcXS = 2.0M;
  18250. break;
  18251. case decimal x when (x >= 15001 && x <= 30000):
  18252. gwcXS = 1.85M;
  18253. break;
  18254. case > 30000:
  18255. gwcXS = 1.7M;
  18256. break;
  18257. default:
  18258. break;
  18259. }
  18260. #endregion
  18261. #region 头等舱系数
  18262. var tdcXS = 0.00M;
  18263. switch (dto.TDCCB)
  18264. {
  18265. case > 70000:
  18266. tdcXS = 1.5M;
  18267. break;
  18268. default:
  18269. tdcXS = 1.9M;
  18270. break;
  18271. }
  18272. #endregion
  18273. #endregion
  18274. #region 酒店系数
  18275. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  18276. {
  18277. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  18278. {1.5M, new List<string>(){"越南社会主义共和国",
  18279. "老挝",
  18280. "柬埔寨",
  18281. "泰国",
  18282. "缅甸",
  18283. "马来西亚",
  18284. //"新加坡",
  18285. "文莱达鲁萨兰",
  18286. "印度尼西亚",
  18287. "东帝汶"}},
  18288. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  18289. };
  18290. #region SGR
  18291. var sgrXS = 1.25M;
  18292. #endregion
  18293. #region TBR
  18294. var tbrXS = 1.25M;
  18295. #endregion
  18296. #region JSES
  18297. var jsesXS = 1.25M;
  18298. #endregion
  18299. #region SUITE
  18300. var suiteXS = 1.25M;
  18301. #endregion
  18302. var countryArr = di.VisitCountry.Split("|");
  18303. foreach (var item in dic)
  18304. {
  18305. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  18306. .Count();
  18307. if (extsisCount > 0)
  18308. {
  18309. jsesXS = item.Key;
  18310. sgrXS = item.Key;
  18311. tbrXS = item.Key;
  18312. suiteXS = item.Key;
  18313. }
  18314. }
  18315. #endregion
  18316. #region 地接系数
  18317. var djXS = 0.00M;
  18318. switch (dto.DJRS)
  18319. {
  18320. case 2 or 3:
  18321. djXS = 2.65M;
  18322. break;
  18323. case 4:
  18324. djXS = 2.6M;
  18325. break;
  18326. case 5 or 6:
  18327. djXS = 2.5M;
  18328. break;
  18329. case 7 or 8:
  18330. djXS = 2.4M;
  18331. break;
  18332. case 9 or 10:
  18333. djXS = 2.3M;
  18334. break;
  18335. case 11:
  18336. djXS = 2.2M;
  18337. break;
  18338. case 12:
  18339. djXS = 2.1M;
  18340. break;
  18341. case 13 or 14:
  18342. djXS = 2M;
  18343. break;
  18344. case 15:
  18345. djXS = 1.9M;
  18346. break;
  18347. case 16 or 17 or 18:
  18348. djXS = 1.8M;
  18349. break;
  18350. case 19 or 20:
  18351. djXS = 1.7M;
  18352. break;
  18353. }
  18354. #endregion
  18355. #region 零用金系数
  18356. var lyjXS = 0.00M;
  18357. switch (dto.LYJRS)
  18358. {
  18359. case 2:
  18360. lyjXS = 1.25M;
  18361. break;
  18362. case 3 or 4 or 5:
  18363. lyjXS = 1.2M;
  18364. break;
  18365. case int number when (number > 5 && number < 10):
  18366. lyjXS = 1.15M;
  18367. break;
  18368. case > 10:
  18369. lyjXS = 1.1M;
  18370. break;
  18371. default:
  18372. break;
  18373. }
  18374. #endregion
  18375. return Ok(JsonView(true, "查询成功", new ArrayList()
  18376. {
  18377. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  18378. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  18379. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  18380. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  18381. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  18382. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  18383. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  18384. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  18385. new { label = "地接系数", value = djXS, key = "djXS" },
  18386. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  18387. new { label = "公务系数", value = 2M, key = "gwXS" }
  18388. }));
  18389. }
  18390. #endregion
  18391. #region 酒店预订 New 2023-12-28 17:45
  18392. /// <summary>
  18393. /// 酒店预订
  18394. /// 酒店费用列表 根据团组Id查询
  18395. /// </summary>
  18396. /// <param name="_dto"></param>
  18397. /// <returns></returns>
  18398. [HttpPost]
  18399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18400. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  18401. {
  18402. #region 参数验证
  18403. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18404. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18405. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18406. #region 团组操作权限验证 76 酒店预定模块
  18407. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18408. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18409. #endregion
  18410. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18411. #region 页面操作权限验证
  18412. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18413. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18414. #endregion
  18415. #endregion
  18416. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  18417. }
  18418. /// <summary>
  18419. /// 酒店预订
  18420. /// 基础数据
  18421. /// </summary>
  18422. /// <param name="_dto"></param>
  18423. /// <returns></returns>
  18424. [HttpPost]
  18425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18426. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  18427. {
  18428. #region 参数验证
  18429. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18430. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18431. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18432. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18433. #region 页面操作权限验证
  18434. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18435. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18436. #endregion
  18437. #region 团组操作权限验证 76 酒店预定模块
  18438. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18439. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18440. #endregion
  18441. #endregion
  18442. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  18443. }
  18444. /// <summary>
  18445. /// 酒店预订
  18446. /// 创建 入住卷号码
  18447. /// </summary>
  18448. /// <param name="_dto"></param>
  18449. /// <returns></returns>
  18450. [HttpPost]
  18451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18452. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  18453. {
  18454. #region 参数验证
  18455. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18456. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18457. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18458. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18459. #region 页面操作权限验证
  18460. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18461. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18462. #endregion
  18463. #region 团组操作权限验证 76 酒店预定模块
  18464. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18465. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18466. #endregion
  18467. #endregion
  18468. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  18469. if (data.Code != 0)
  18470. {
  18471. return Ok(JsonView(false, data.Msg));
  18472. }
  18473. return Ok(JsonView(true, data.Msg, data.Data));
  18474. }
  18475. /// <summary>
  18476. /// 酒店预订
  18477. /// 详情
  18478. /// </summary>
  18479. /// <param name="_dto"></param>
  18480. /// <returns></returns>
  18481. [HttpPost]
  18482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18483. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  18484. {
  18485. #region 参数验证
  18486. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  18487. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18488. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  18489. #region 团组操作权限验证 76 酒店预定模块
  18490. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18491. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18492. #endregion
  18493. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18494. #region 页面操作权限验证
  18495. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18496. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18497. #endregion
  18498. #endregion
  18499. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  18500. }
  18501. /// <summary>
  18502. /// 酒店预订
  18503. /// Add Or Edit
  18504. /// </summary>
  18505. /// <param name="_dto"></param>
  18506. /// <returns></returns>
  18507. [HttpPost]
  18508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18509. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  18510. {
  18511. #region 参数验证
  18512. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18513. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18514. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18515. #region 团组操作权限验证 76 酒店预定模块
  18516. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18517. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18518. #endregion
  18519. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18520. #region 页面操作权限验证
  18521. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18522. if (_dto.Id == 0) // Add
  18523. {
  18524. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18525. }
  18526. else if (_dto.Id > 1) // Edit
  18527. {
  18528. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  18529. }
  18530. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  18531. #endregion
  18532. #endregion
  18533. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  18534. if (_view.Code != 200)
  18535. {
  18536. return Ok(_view);
  18537. }
  18538. #region 成本无酒店价格数据进入超支
  18539. _sqlSugar.BeginTran();
  18540. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  18541. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  18542. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  18543. for (int i = 0; i < groupCost.Count; i++)
  18544. {
  18545. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  18546. {
  18547. groupCost[i].Date = groupCost[i - 1].Date;
  18548. }
  18549. }
  18550. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  18551. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  18552. List<Fin_GroupExtraCostDto_OP>();
  18553. if (start_Bool && end_Bool)
  18554. {
  18555. while (start_Time < end_Time)
  18556. {
  18557. foreach (var item in groupCost_Grp)
  18558. {
  18559. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  18560. {
  18561. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  18562. {
  18563. extraCostList.Add(new
  18564. Fin_GroupExtraCostDto_OP
  18565. {
  18566. Area = _dto.AreaId,
  18567. coefficient = 1.5M,
  18568. createUser = _dto.UserId,
  18569. currency = _dto.CardPriceCurrency,
  18570. diId = _dto.DiId,
  18571. ManagerConfirm = 0,
  18572. SupervisorConfirm = 0,
  18573. SYsupervisorConfirm = 0,
  18574. editType = 1,
  18575. PortType = 1,
  18576. price = _dto.CardPrice,
  18577. PriceCount = 1,
  18578. priceType = 1027,
  18579. priceDetailType = 1044,
  18580. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  18581. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  18582. });
  18583. }
  18584. }
  18585. }
  18586. start_Time = start_Time.AddDays(1);
  18587. }
  18588. }
  18589. if (extraCostList.Any())
  18590. {
  18591. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  18592. }
  18593. _sqlSugar.CommitTran();
  18594. #endregion
  18595. #region 应用推送
  18596. try
  18597. {
  18598. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  18599. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  18600. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  18601. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  18602. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  18603. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  18604. var diId = _dto.DiId;
  18605. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18606. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18607. #region 操作记录
  18608. var opInfo = new Crm_TableOperationRecord()
  18609. {
  18610. TableName = "Grp_HotelReservations",
  18611. PortType = _dto.PortType,
  18612. DataId = hotelId,
  18613. CreateUserId = _dto.UserId
  18614. };
  18615. //var opStatus = OperationEnum.NoOperation;
  18616. if (_dto.Id < 1) //添加操作
  18617. {
  18618. opInfo.OperationItem = OperationEnum.Add;
  18619. }
  18620. else if (_dto.Id > 0)
  18621. {
  18622. opInfo.OperationItem = OperationEnum.Edit;
  18623. }
  18624. string opRemark = string.Empty;
  18625. if (ccpInfo != null)
  18626. {
  18627. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  18628. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  18629. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  18630. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  18631. }
  18632. opInfo.Remark = opRemark;
  18633. await _tableorRep.AddAsync(opInfo);
  18634. #endregion
  18635. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  18636. //2024-10-21 新增LZ UID
  18637. var userIds = new List<int>() { 21 };
  18638. string title = $"费用审核";
  18639. string content = "";
  18640. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18641. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18642. try
  18643. {
  18644. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  18645. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  18646. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  18647. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  18648. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  18649. }
  18650. catch (Exception ex)
  18651. {
  18652. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  18653. }
  18654. }
  18655. catch (Exception ex)
  18656. {
  18657. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  18658. }
  18659. try
  18660. {
  18661. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  18662. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  18663. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  18664. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  18665. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  18666. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  18667. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18668. //自动审核
  18669. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  18670. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  18671. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  18672. //2024-10-21 新增LZ UID
  18673. var userIds = new List<int>() { 21 };
  18674. string title = $"系统通知";
  18675. var diId = _dto.DiId;
  18676. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18677. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18678. string content = "";
  18679. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18680. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18681. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18682. }
  18683. catch (Exception ex)
  18684. {
  18685. }
  18686. #endregion
  18687. return Ok(_view);
  18688. }
  18689. /// <summary>
  18690. /// 酒店自动审核测试
  18691. /// Add Or Edit
  18692. /// </summary>
  18693. /// <param name="diid"></param>
  18694. /// <param name="dataId"></param>
  18695. /// <returns></returns>
  18696. [HttpPost]
  18697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18698. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  18699. {
  18700. #region 应用推送
  18701. try
  18702. {
  18703. //自动审核
  18704. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  18705. }
  18706. catch (Exception ex)
  18707. {
  18708. return Ok(JsonView(false, ex.Message));
  18709. }
  18710. #endregion
  18711. return Ok(JsonView(false, "操作成功"));
  18712. }
  18713. /// <summary>
  18714. /// 酒店预订
  18715. /// Del
  18716. /// </summary>
  18717. /// <param name="_dto"></param>
  18718. /// <returns></returns>
  18719. [HttpPost]
  18720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18721. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  18722. {
  18723. #region 参数验证
  18724. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18725. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18726. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18727. #region 团组操作权限验证 76 酒店预定模块
  18728. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18729. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18730. #endregion
  18731. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18732. #region 页面操作权限验证
  18733. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18734. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  18735. #endregion
  18736. #endregion
  18737. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  18738. #region 操作记录
  18739. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  18740. {
  18741. TableName = "Grp_HotelReservations",
  18742. PortType = _dto.PortType,
  18743. OperationItem = OperationEnum.Del,
  18744. DataId = _dto.Id,
  18745. CreateUserId = _dto.UserId
  18746. });
  18747. #endregion
  18748. return Ok(data);
  18749. }
  18750. /// <summary>
  18751. /// 酒店预订
  18752. /// 生成VOUCHER
  18753. /// 2024.05.06 之前版本
  18754. /// </summary>
  18755. /// <param name="_dto"></param>
  18756. /// <returns></returns>
  18757. [HttpPost]
  18758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18759. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  18760. {
  18761. try
  18762. {
  18763. #region 参数验证
  18764. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18765. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18766. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18767. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  18768. #region 团组操作权限验证 76 酒店预定模块
  18769. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18770. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18771. #endregion
  18772. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18773. #region 页面操作权限验证
  18774. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18775. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18776. #endregion
  18777. #endregion
  18778. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  18779. //判断数据是否完整
  18780. if (hr != null)
  18781. {
  18782. if (!string.IsNullOrEmpty(hr.DetermineNo))
  18783. {
  18784. string strFileName = "HotelStatement/";
  18785. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18786. if (dele != null)
  18787. strFileName += dele.TourCode;
  18788. //载入模板
  18789. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  18790. Document doc = new Document(sss);
  18791. DocumentBuilder builder = new DocumentBuilder(doc);
  18792. #region 替换Word模板书签内容
  18793. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  18794. //入住卷预定号码
  18795. if (doc.Range.Bookmarks["VNO"] != null)
  18796. {
  18797. Bookmark mark = doc.Range.Bookmarks["VNO"];
  18798. mark.Text = hr.CheckNumber;
  18799. }
  18800. //酒店时间
  18801. if (doc.Range.Bookmarks["Date"] != null)
  18802. {
  18803. Bookmark mark = doc.Range.Bookmarks["Date"];
  18804. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18805. }
  18806. //团号
  18807. if (doc.Range.Bookmarks["TNo"] != null)
  18808. {
  18809. Bookmark mark = doc.Range.Bookmarks["TNo"];
  18810. mark.Text = dele.TourCode;
  18811. }
  18812. //预定号码
  18813. if (doc.Range.Bookmarks["BookingId"] != null)
  18814. {
  18815. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  18816. mark.Text = hr.ReservationsNo;
  18817. }
  18818. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  18819. {
  18820. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  18821. mark.Text = hr.DetermineNo;
  18822. }
  18823. //酒店城市
  18824. if (doc.Range.Bookmarks["City"] != null)
  18825. {
  18826. Bookmark mark = doc.Range.Bookmarks["City"];
  18827. mark.Text = hr.City;
  18828. }
  18829. //酒店名称
  18830. if (doc.Range.Bookmarks["HName"] != null)
  18831. {
  18832. Bookmark mark = doc.Range.Bookmarks["HName"];
  18833. mark.Text = hr.HotelName;
  18834. }
  18835. //酒店地址
  18836. if (doc.Range.Bookmarks["Address"] != null)
  18837. {
  18838. Bookmark mark = doc.Range.Bookmarks["Address"];
  18839. mark.Text = hr.HotelAddress;
  18840. }
  18841. //酒店电话
  18842. if (doc.Range.Bookmarks["Tel"] != null)
  18843. {
  18844. Bookmark mark = doc.Range.Bookmarks["Tel"];
  18845. mark.Text = hr.HotelTel;
  18846. }
  18847. //酒店传真
  18848. if (doc.Range.Bookmarks["Fax"] != null)
  18849. {
  18850. Bookmark mark = doc.Range.Bookmarks["Fax"];
  18851. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  18852. {
  18853. mark.Text = hr.HotelFax;
  18854. }
  18855. }
  18856. //入住时间
  18857. if (doc.Range.Bookmarks["CIn"] != null)
  18858. {
  18859. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18860. Bookmark mark = doc.Range.Bookmarks["CIn"];
  18861. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  18862. }
  18863. //退房时间
  18864. if (doc.Range.Bookmarks["COut"] != null)
  18865. {
  18866. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18867. Bookmark mark = doc.Range.Bookmarks["COut"];
  18868. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18869. }
  18870. //客户名称
  18871. if (doc.Range.Bookmarks["GName"] != null)
  18872. {
  18873. string guestName = "";
  18874. string[] clients = Array.Empty<string>();
  18875. if (hr.GuestName.Contains(","))
  18876. {
  18877. clients = hr.GuestName.Split(",");
  18878. }
  18879. else
  18880. {
  18881. clients = new string[] { hr.GuestName };
  18882. }
  18883. List<int> clientIds_int = new List<int>();
  18884. if (clients.Length > 0)
  18885. {
  18886. foreach (var item in clients)
  18887. {
  18888. if (item.IsNumeric())
  18889. {
  18890. clientIds_int.Add(int.Parse(item));
  18891. }
  18892. }
  18893. }
  18894. if (clientIds_int.Count > 0)
  18895. {
  18896. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  18897. foreach (var client in _clientDatas)
  18898. {
  18899. //男
  18900. if (client.Sex == 0) guestName += $"Mr.";
  18901. //女
  18902. else if (client.Sex == 1) guestName += $"Ms.";
  18903. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  18904. {
  18905. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  18906. }
  18907. //guestName += $"{client.Pinyin},";
  18908. }
  18909. if (guestName.Length > 0)
  18910. {
  18911. guestName = guestName.Substring(0, guestName.Length - 1);
  18912. }
  18913. }
  18914. else
  18915. {
  18916. guestName = hr.GuestName;
  18917. }
  18918. Bookmark mark = doc.Range.Bookmarks["GName"];
  18919. mark.Text = guestName;
  18920. }
  18921. //房间介绍
  18922. if (doc.Range.Bookmarks["ROOM"] != null)
  18923. {
  18924. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  18925. mark.Text = hr.RoomExplanation;
  18926. }
  18927. //报价描述
  18928. if (doc.Range.Bookmarks["NOTE"] != null)
  18929. {
  18930. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  18931. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  18932. if (ss != null)
  18933. mark.Text = ss.Name;
  18934. }
  18935. //入住时间
  18936. if (doc.Range.Bookmarks["CheckIn"] != null)
  18937. {
  18938. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18939. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  18940. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18941. }
  18942. //退房时间
  18943. if (doc.Range.Bookmarks["CheckOut"] != null)
  18944. {
  18945. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18946. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  18947. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18948. }
  18949. //日期
  18950. if (doc.Range.Bookmarks["DT"] != null)
  18951. {
  18952. Bookmark mark = doc.Range.Bookmarks["DT"];
  18953. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18954. }
  18955. //名称
  18956. if (doc.Range.Bookmarks["VName"] != null)
  18957. {
  18958. Bookmark mark = doc.Range.Bookmarks["VName"];
  18959. mark.Text = hr.HotelName;
  18960. }
  18961. //号码
  18962. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  18963. {
  18964. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  18965. mark.Text = hr.CheckNumber;
  18966. }
  18967. #endregion
  18968. strFileName += "VOUCHER.doc";
  18969. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18970. doc.Save(fileDir);
  18971. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18972. return Ok(JsonView(true, "操作成功!", Url));
  18973. }
  18974. else
  18975. {
  18976. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  18977. }
  18978. }
  18979. else
  18980. {
  18981. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  18982. }
  18983. }
  18984. catch (Exception ex)
  18985. {
  18986. return Ok(JsonView(false, ex.Message));
  18987. }
  18988. }
  18989. /// <summary>
  18990. /// 酒店预订
  18991. /// 生成VOUCHER
  18992. /// 2024.05.06 之后版本
  18993. /// </summary>
  18994. /// <param name="_dto"></param>
  18995. /// <returns></returns>
  18996. [HttpPost]
  18997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18998. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  18999. {
  19000. #region 参数验证
  19001. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19002. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19003. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19004. #region 团组操作权限验证 76 酒店预定模块
  19005. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19006. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19007. #endregion
  19008. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19009. #region 页面操作权限验证
  19010. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19011. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19012. #endregion
  19013. #endregion
  19014. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  19015. //判断数据是否完整
  19016. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  19017. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19018. string strFileName = "HotelStatement/";
  19019. string guestNames = ""; //格式Mr.xxx Ms.xxx
  19020. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  19021. #region 数据处理
  19022. List<int> guestIds = new List<int>();
  19023. //int index = 0;
  19024. foreach (var item in hrDtas)
  19025. {
  19026. if (item.GuestName.Contains(","))
  19027. {
  19028. string[] guestIdArr = item.GuestName.Split(',');
  19029. foreach (var guestIdStr in guestIdArr)
  19030. {
  19031. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  19032. if (guestBool)
  19033. {
  19034. guestIds.Add(guestId);
  19035. }
  19036. }
  19037. }
  19038. else guestNames += item.GuestName;
  19039. var voucherInfo = new HotelVoucherInfoView()
  19040. {
  19041. HotelName = item.HotelName,
  19042. CheckInDate = item.CheckInDate,
  19043. CheckOutDate = item.CheckOutDate,
  19044. ConfirmationNumber = item.DetermineNo.Trim(),
  19045. RoomType = item.RoomExplanation
  19046. };
  19047. vouchers.Add(voucherInfo);
  19048. }
  19049. if (guestIds.Count > 0)
  19050. {
  19051. guestIds = guestIds.Distinct().ToList();
  19052. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  19053. if (guestDatas.Count > 0)
  19054. {
  19055. guestNames = "";
  19056. foreach (var guest in guestDatas)
  19057. {
  19058. string guestName = "";
  19059. if (guest.Sex == 0) guestName += @"MR.";
  19060. else if (guest.Sex == 1) guestName += @"MS.";
  19061. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  19062. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  19063. guestNames += @$"{guestName.Trim()}、";
  19064. }
  19065. if (guestNames.Length > 0)
  19066. {
  19067. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  19068. }
  19069. }
  19070. }
  19071. #endregion
  19072. //载入模板
  19073. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  19074. Document doc = new Document(sss);
  19075. DocumentBuilder builder = new DocumentBuilder(doc);
  19076. if (doc.Range.Bookmarks["GuestName"] != null)
  19077. {
  19078. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  19079. mark.Text = guestNames;
  19080. }
  19081. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19082. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  19083. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  19084. for (int i = 1; i <= vouchers.Count; i++)
  19085. {
  19086. HotelVoucherInfoView hviv = vouchers[i - 1];
  19087. builder.MoveToCell(0, i, 0, 0);
  19088. builder.Write(hviv.HotelName);
  19089. builder.MoveToCell(0, i, 1, 0);
  19090. builder.Write(hviv.CheckInDate);
  19091. builder.MoveToCell(0, i, 2, 0);
  19092. builder.Write(hviv.CheckOutDate);
  19093. builder.MoveToCell(0, i, 3, 0);
  19094. builder.Write(hviv.RoomType);
  19095. builder.MoveToCell(0, i, 4, 0);
  19096. builder.Write(hviv.ConfirmationNumber);
  19097. }
  19098. //删除多余行
  19099. int currRowIndex = vouchers.Count + 1;
  19100. int delRows = 21 - currRowIndex;
  19101. if (delRows > 0)
  19102. {
  19103. for (int i = 0; i < delRows; i++)
  19104. {
  19105. table.Rows.RemoveAt(currRowIndex);
  19106. //cultivateRowIndex++;
  19107. }
  19108. }
  19109. strFileName += "VOUCHER.docx";
  19110. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19111. doc.Save(fileDir);
  19112. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19113. return Ok(JsonView(true, "操作成功!", Url));
  19114. }
  19115. /// <summary>
  19116. /// 酒店预订
  19117. /// 生成VOUCHER 批量生成
  19118. /// New
  19119. /// </summary>
  19120. /// <param name="_dto"></param>
  19121. /// <returns></returns>
  19122. [HttpPost]
  19123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19124. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  19125. {
  19126. #region 参数验证
  19127. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19128. if (_dto.PageId < 1) _dto.PageId = 28;
  19129. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19130. #region 团组操作权限验证 76 酒店预定模块
  19131. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19132. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19133. #endregion
  19134. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19135. #region 页面操作权限验证
  19136. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19137. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19138. #endregion
  19139. #endregion
  19140. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  19141. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  19142. .OrderBy(x => x.CheckInDate)
  19143. .ToListAsync();
  19144. //判断数据是否完整
  19145. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  19146. string strFileName = "HotelStatement/";
  19147. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  19148. if (dele != null)
  19149. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  19150. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  19151. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  19152. .Where(it => it.IsDel == 0)
  19153. .ToListAsync();
  19154. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  19155. for (int i = 0; i < hrDtas.Count; i++)
  19156. {
  19157. string guestNames = string.Empty;
  19158. List<int> guestIds = new List<int>();
  19159. var item = hrDtas[i];
  19160. //处理客户姓名
  19161. if (item.GuestName.Contains(","))
  19162. {
  19163. string[] guestIdArr = item.GuestName.Split(',');
  19164. foreach (var guestIdStr in guestIdArr)
  19165. if (int.TryParse(guestIdStr, out int guestId))
  19166. guestIds.Add(guestId);
  19167. }
  19168. else
  19169. {
  19170. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  19171. if (guestIdBool)
  19172. {
  19173. guestIds.Add(guestId);
  19174. }
  19175. //NaN
  19176. if (item.GuestName.Contains("NaN"))
  19177. {
  19178. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  19179. }
  19180. }
  19181. if (guestIds.Count > 0)
  19182. {
  19183. guestIds = guestIds.Distinct().ToList();
  19184. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  19185. if (guestDatas1.Count > 0)
  19186. {
  19187. guestNames = "";
  19188. foreach (var guest in guestDatas1)
  19189. {
  19190. string guestName = "";
  19191. if (guest.Sex == 0) guestName += @"MR.";
  19192. else if (guest.Sex == 1) guestName += @"MS.";
  19193. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  19194. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  19195. guestNames += @$"{guestName.Trim()}、";
  19196. }
  19197. if (guestNames.Length > 0)
  19198. {
  19199. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  19200. }
  19201. }
  19202. }
  19203. //if (!string.IsNullOrEmpty(guestNames))
  19204. //{
  19205. hrDtas[i].GuestName = guestNames;
  19206. //}
  19207. }
  19208. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  19209. Document doc = new Document();
  19210. DocumentBuilder builder = new DocumentBuilder(doc);
  19211. try
  19212. {
  19213. builder.MoveToDocumentStart();
  19214. foreach (var item in hrDtas)
  19215. {
  19216. //标题
  19217. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  19218. builder.ParagraphFormat.LineSpacing = 1;
  19219. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19220. builder.ParagraphFormat.Style.Font.Size = 9;
  19221. builder.ParagraphFormat.Style.Font.Bold = true;
  19222. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19223. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  19224. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  19225. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19226. builder.ParagraphFormat.LineSpacing = 1;
  19227. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19228. builder.ParagraphFormat.Style.Font.Size = 9;
  19229. builder.ParagraphFormat.Style.Font.Bold = true;
  19230. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  19231. builder.StartTable();
  19232. // 设置边框颜色
  19233. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  19234. //设置边框样式
  19235. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  19236. //表格
  19237. #region 第一行
  19238. builder.InsertCell();
  19239. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19240. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19241. //builder.CellFormat.AllowAutoFit = false;
  19242. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19243. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19244. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19245. builder.CellFormat.WrapText = true; //自动换行
  19246. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19247. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  19248. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19249. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19250. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19251. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19252. builder.Write("TOUR NO:");
  19253. builder.InsertCell();
  19254. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19255. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19256. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19257. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19258. builder.ParagraphFormat.Style.Font.Bold = false;
  19259. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19260. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19261. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19262. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19263. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19264. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19265. builder.Write($"{dele?.TourCode ?? "-"}");
  19266. builder.InsertCell();
  19267. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19268. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19269. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19270. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19271. builder.ParagraphFormat.Style.Font.Bold = false;
  19272. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19273. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19274. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19275. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19276. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19277. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19278. builder.Write($"CITY:");
  19279. builder.InsertCell();
  19280. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19281. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19282. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19283. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19284. builder.ParagraphFormat.Style.Font.Bold = false;
  19285. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19286. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19287. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19288. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19289. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19290. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19291. builder.Write($"{item.City}");
  19292. builder.EndRow();
  19293. #endregion
  19294. #region 第二行
  19295. builder.InsertCell();
  19296. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19297. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19298. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19299. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19300. builder.ParagraphFormat.Style.Font.Bold = false;
  19301. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19302. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19303. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19304. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19305. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19306. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19307. builder.Write("CONFIRMATION NO:");
  19308. builder.InsertCell();
  19309. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19310. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19311. builder.ParagraphFormat.Style.Font.Size = 8;
  19312. builder.ParagraphFormat.Style.Font.Bold = false;
  19313. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19314. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19315. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19316. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19317. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19318. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19319. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19320. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19321. builder.Write($"{item.DetermineNo}");
  19322. builder.InsertCell();
  19323. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19324. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19325. builder.InsertCell();
  19326. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19327. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19328. builder.EndRow();
  19329. #endregion
  19330. #region 第三行
  19331. builder.InsertCell();
  19332. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19333. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19334. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19335. builder.ParagraphFormat.Style.Font.Bold = false;
  19336. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19337. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19338. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19339. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19340. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19341. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19342. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19343. builder.Write($"HOTEL NAME:");
  19344. builder.InsertCell();
  19345. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19346. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19347. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19348. builder.ParagraphFormat.Style.Font.Bold = false;
  19349. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19350. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19351. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19352. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19353. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19354. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19355. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19356. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19357. builder.Write($"{item.HotelName}");
  19358. builder.InsertCell();
  19359. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19360. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19361. builder.InsertCell();
  19362. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19363. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19364. builder.EndRow();
  19365. #endregion
  19366. #region 第四行
  19367. builder.InsertCell();
  19368. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19369. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19370. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19371. builder.ParagraphFormat.Style.Font.Bold = false;
  19372. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19373. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19374. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19375. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19376. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19377. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19378. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19379. builder.Write($"HOTEL ADDRESS:");
  19380. builder.InsertCell();
  19381. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19382. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19383. builder.ParagraphFormat.Style.Font.Size = 8;
  19384. builder.ParagraphFormat.Style.Font.Bold = false;
  19385. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19386. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19387. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19388. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19389. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19390. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19391. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19392. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19393. builder.Write($"{item.HotelAddress}");
  19394. builder.InsertCell();
  19395. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19396. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19397. builder.InsertCell();
  19398. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19399. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19400. builder.EndRow();
  19401. #endregion
  19402. #region 第五行
  19403. builder.InsertCell();
  19404. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19405. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19406. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19407. builder.ParagraphFormat.Style.Font.Bold = false;
  19408. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19409. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19410. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19411. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19412. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19413. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19414. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19415. builder.Write("TEL:");
  19416. builder.InsertCell();
  19417. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19418. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19419. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19420. builder.ParagraphFormat.Style.Font.Bold = false;
  19421. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19422. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19423. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19424. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19425. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19426. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19427. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19428. builder.Write($"{item.HotelTel}");
  19429. builder.InsertCell();
  19430. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19431. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19432. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19433. builder.ParagraphFormat.Style.Font.Bold = false;
  19434. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19435. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19436. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19437. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19438. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19439. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19440. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19441. builder.Write($"FAX:");
  19442. builder.InsertCell();
  19443. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19444. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19445. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19446. builder.ParagraphFormat.Style.Font.Bold = false;
  19447. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19448. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19449. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19450. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19451. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19452. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19453. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19454. builder.Write($"{item.HotelFax}");
  19455. builder.EndRow();
  19456. #endregion
  19457. #region 第六行
  19458. builder.InsertCell();
  19459. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19460. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19461. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19462. builder.ParagraphFormat.Style.Font.Bold = false;
  19463. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19464. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19465. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19466. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19467. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19468. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19469. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19470. builder.Write("CHECK IN:");
  19471. builder.InsertCell();
  19472. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19473. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19474. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19475. builder.ParagraphFormat.Style.Font.Bold = false;
  19476. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19477. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19478. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19479. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19480. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19481. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19482. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19483. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  19484. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  19485. builder.Write($"{checkInStr}");
  19486. builder.InsertCell();
  19487. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19488. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19489. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19490. builder.ParagraphFormat.Style.Font.Bold = false;
  19491. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19492. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19493. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19494. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19495. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19496. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19497. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19498. builder.Write($"CHECK OUT:");
  19499. builder.InsertCell();
  19500. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19501. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19502. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19503. builder.ParagraphFormat.Style.Font.Bold = false;
  19504. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19505. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19506. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19507. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19508. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19509. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19510. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19511. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  19512. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  19513. builder.Write($"{checkOutStr}");
  19514. builder.EndRow();
  19515. #endregion
  19516. #region 第七行
  19517. builder.InsertCell();
  19518. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19519. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19520. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19521. builder.ParagraphFormat.Style.Font.Bold = false;
  19522. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19523. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19524. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19525. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19526. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19527. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19528. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19529. builder.Write($"GUEST NAME:");
  19530. builder.InsertCell();
  19531. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19532. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19533. builder.ParagraphFormat.Style.Font.Size = 8;
  19534. builder.ParagraphFormat.Style.Font.Bold = false;
  19535. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19536. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19537. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19538. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19539. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19540. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19541. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19542. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19543. builder.Write($"{item.GuestName.Trim()}");
  19544. builder.InsertCell();
  19545. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19546. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19547. builder.InsertCell();
  19548. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19549. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19550. builder.EndRow();
  19551. #endregion
  19552. #region 第八行
  19553. builder.InsertCell();
  19554. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19555. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19556. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19557. builder.ParagraphFormat.Style.Font.Bold = false;
  19558. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19559. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19560. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19561. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19562. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19563. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19564. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19565. builder.Write($"ROOM TYPE:");
  19566. builder.InsertCell();
  19567. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19568. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19569. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19570. builder.ParagraphFormat.Style.Font.Bold = false;
  19571. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19572. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19573. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19574. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19575. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19576. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19577. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19578. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19579. builder.Write($"{item.RoomExplanation}");
  19580. builder.InsertCell();
  19581. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19582. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19583. builder.InsertCell();
  19584. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19585. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19586. builder.EndRow();
  19587. #endregion
  19588. #region 第九行
  19589. builder.InsertCell();
  19590. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19591. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19592. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19593. builder.ParagraphFormat.Style.Font.Bold = false;
  19594. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19595. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19596. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19597. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19598. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19599. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19600. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19601. builder.Write($"NOTE:");
  19602. builder.InsertCell();
  19603. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19604. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19605. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19606. builder.ParagraphFormat.Style.Font.Bold = false;
  19607. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19608. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19609. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19610. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19611. 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.");
  19612. builder.InsertCell();
  19613. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19614. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19615. builder.InsertCell();
  19616. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19617. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19618. builder.EndRow();
  19619. #endregion
  19620. builder.EndTable();
  19621. //换行
  19622. builder.Writeln("");
  19623. builder.Writeln("");
  19624. }
  19625. #region 获取文档中的所有表格 设置文字自适应
  19626. // 获取文档中的所有表格。
  19627. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  19628. {
  19629. // 遍历表格中的所有行。
  19630. foreach (Aspose.Words.Tables.Row row in table.Rows)
  19631. {
  19632. foreach (Cell cell in row.Cells)
  19633. {
  19634. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  19635. cellFormat.Width = 0;
  19636. }
  19637. }
  19638. }
  19639. #endregion
  19640. #region 设置页眉
  19641. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  19642. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  19643. if (System.IO.File.Exists(voucherHeaderPath))
  19644. {
  19645. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  19646. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  19647. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  19648. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  19649. // 调整图片位置
  19650. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  19651. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  19652. shape.Top = 50; // 将图片距离页眉上边缘的距离
  19653. shape.Left = 0; // 将图片距离页面左边缘的距离
  19654. shape.Width = 81; // 设置图片宽度
  19655. shape.Height = 36; // 设置图片高度
  19656. }
  19657. //靠右
  19658. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19659. //// 设置页脚上下边距
  19660. //builder.PageSetup.HeaderDistance = 42;
  19661. // 添加页眉线
  19662. Aspose.Words.Border borderHeader = null;
  19663. try
  19664. {
  19665. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  19666. }
  19667. catch (Exception e)
  19668. {
  19669. // TODO Auto-generated catch block
  19670. //e.printStackTrace();
  19671. }
  19672. borderHeader.Shadow = true;
  19673. borderHeader.DistanceFromText = 2;
  19674. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  19675. #endregion
  19676. }
  19677. catch (Exception ex)
  19678. {
  19679. }
  19680. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19681. doc.Save(fileDir);
  19682. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19683. return Ok(JsonView(true, "操作成功!", Url));
  19684. }
  19685. /// <summary>
  19686. /// 酒店预订
  19687. /// 生成 预定成本 Excel
  19688. /// </summary>
  19689. /// <param name="_dto"></param>
  19690. /// <returns></returns>
  19691. [HttpPost]
  19692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19693. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  19694. {
  19695. #region 参数验证
  19696. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  19697. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  19698. if (!vadalitorRes.IsValid)
  19699. {
  19700. var errors = new StringBuilder();
  19701. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  19702. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  19703. }
  19704. #region 团组操作权限验证 76 酒店预定模块
  19705. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19706. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  19707. #endregion
  19708. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19709. #region 页面操作权限验证
  19710. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19711. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19712. #endregion
  19713. #endregion
  19714. decimal _rate = 1.00M;
  19715. string _currency = string.Empty;
  19716. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  19717. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19718. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  19719. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19720. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  19721. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  19722. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  19723. if (_GroupCostParameter == null)
  19724. {
  19725. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  19726. bool isIntType = int.TryParse(_currency, out int currId);
  19727. if (isIntType)
  19728. {
  19729. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19730. }
  19731. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19732. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19733. if (currInfo == null)
  19734. {
  19735. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19736. }
  19737. else _rate = currInfo.Rate;
  19738. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  19739. {
  19740. _rate = _GroupCostParameter.Rate;
  19741. }
  19742. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19743. //string strFileName = "HotelStatement/";
  19744. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19745. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19746. var rateDatas = new List<dynamic>();
  19747. #region 数据处理
  19748. foreach (var item in hrDtas)
  19749. {
  19750. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19751. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19752. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19753. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19754. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19755. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  19756. {
  19757. continue;
  19758. }
  19759. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19760. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  19761. string singleRoomFeeStr = string.Empty,
  19762. doubleRoomFeeStr = string.Empty,
  19763. suiteRoomFeeStr = string.Empty,
  19764. otherRoomFeeStr = string.Empty,
  19765. payMoneyStr = string.Empty,
  19766. cardPriceStr = string.Empty;
  19767. if (roomCurr.Equals("CNY"))
  19768. {
  19769. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  19770. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19771. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19772. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19773. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19774. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  19775. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  19776. }
  19777. else
  19778. {
  19779. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19780. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19781. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19782. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19783. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19784. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19785. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19786. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19787. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19788. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19789. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  19790. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  19791. if (ccpPaymentCurrency.Equals("CNY"))
  19792. {
  19793. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  19794. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19795. }
  19796. else
  19797. {
  19798. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  19799. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  19800. }
  19801. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  19802. if (hotelcardPriceCurrency.Equals("CNY"))
  19803. {
  19804. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19805. }
  19806. else
  19807. {
  19808. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  19809. }
  19810. }
  19811. string breakfastPriceStr = string.Empty,
  19812. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19813. governmentRentStr = string.Empty,
  19814. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19815. cityTaxStr = string.Empty,
  19816. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19817. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  19818. if (!string.IsNullOrEmpty(breakfastCurrency1))
  19819. {
  19820. if (breakfastCurrency1.Equals("CNY"))
  19821. {
  19822. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19823. }
  19824. else
  19825. {
  19826. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  19827. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  19828. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  19829. }
  19830. }
  19831. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19832. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  19833. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  19834. {
  19835. if (governmentRentCurrency.Equals("CNY"))
  19836. {
  19837. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19838. }
  19839. else
  19840. {
  19841. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  19842. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  19843. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  19844. }
  19845. }
  19846. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19847. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  19848. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  19849. {
  19850. if (cityTaxStrCurrency1.Equals("CNY"))
  19851. {
  19852. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19853. }
  19854. else
  19855. {
  19856. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  19857. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  19858. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  19859. }
  19860. }
  19861. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19862. int payDId = roomInfo?.PayDId ?? 0;
  19863. pcfds.Add(new HotelReservations_PCFD_View()
  19864. {
  19865. City = item.City,
  19866. HotelName = item.HotelName,
  19867. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19868. // SingleRoomCount = item.SingleRoomCount,
  19869. SingleRoomPrice = singleRoomFeeStr,
  19870. // DoubleRoomCount = item.DoubleRoomCount,
  19871. DoubleRoomPrice = doubleRoomFeeStr,
  19872. //SuiteRoomCount = item.SuiteRoomCount,
  19873. SuiteRoomPrice = suiteRoomFeeStr,
  19874. OtherRoomPrice = otherRoomFeeStr,
  19875. //OtherRoomCount = item.OtherRoomCount,
  19876. BreakfastPrice = breakfastPriceStr,
  19877. GovernmentRent = governmentRentStr,
  19878. CityTax = cityTaxStr,
  19879. RoomExplanation = item.RoomExplanation,
  19880. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19881. PayTime = roomInfo?.ConsumptionDate,
  19882. BankNo = roomInfo?.BankNo,
  19883. PayMoney = payMoneyStr,
  19884. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19885. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19886. CardPrice = cardPriceStr,
  19887. Remark = ccpInfo.Remark
  19888. });
  19889. }
  19890. #endregion
  19891. //载入模板
  19892. WorkbookDesigner designer = new WorkbookDesigner();
  19893. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19894. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19895. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19896. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19897. var rateDatas1 = rateDatas.Distinct();
  19898. var rateStr = string.Empty;
  19899. foreach (var item in rateDatas1)
  19900. {
  19901. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  19902. }
  19903. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  19904. designer.SetDataSource("Opertor", userInfo.CnName);
  19905. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19906. dt.TableName = "ViewMyHotelReservations";
  19907. designer.SetDataSource(dt);
  19908. designer.Process();
  19909. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19910. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19911. designer.Workbook.Save(serverPath);
  19912. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19913. #region 删除指定行
  19914. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19915. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19916. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19917. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19918. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19919. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19920. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19921. cssIndex = dt.Columns["CityTax"].Ordinal,
  19922. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19923. remarkIndex = dt.Columns["Remark"].Ordinal;
  19924. //删除指定列
  19925. foreach (DataRow item in dt.Rows)
  19926. {
  19927. string singleStr = item["SingleRoomPrice"].ToString();
  19928. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19929. if (containsDigitButNotZero1) singleDel = false;
  19930. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19931. string doubleStr = item["DoubleRoomPrice"].ToString();
  19932. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19933. if (containsDigitButNotZero2) doubleDel = false;
  19934. string suiteStr = item["SuiteRoomPrice"].ToString();
  19935. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19936. if (containsDigitButNotZero3) suiteDel = false;
  19937. string otherStr = item["OtherRoomPrice"].ToString();
  19938. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19939. if (containsDigitButNotZero4) otherDel = false;
  19940. string zcStr = item["BreakfastPrice"].ToString();
  19941. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19942. if (containsDigitButNotZero5) zcDel = false;
  19943. string dsStr = item["GovernmentRent"].ToString();
  19944. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19945. if (containsDigitButNotZero6) dsDel = false;
  19946. string cssStr = item["CityTax"].ToString();
  19947. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19948. if (containsDigitButNotZero7) cssDel = false;
  19949. string cpStr = item["ConsumptionPatterns"].ToString();
  19950. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19951. string remarkStr = item["Remark"].ToString();
  19952. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19953. }
  19954. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19955. DeleteColumn(serverPath, cpIndex, cpDel);
  19956. DeleteColumn(serverPath, dsIndex, dsDel);
  19957. DeleteColumn(serverPath, cssIndex, cssDel);
  19958. DeleteColumn(serverPath, zcIndex, zcDel);
  19959. DeleteColumn(serverPath, otherIndex, otherDel);
  19960. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19961. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19962. DeleteColumn(serverPath, singleIndex, singleDel);
  19963. #endregion
  19964. //只保留第一个表格
  19965. DeleteSheet(serverPath);
  19966. return Ok(JsonView(true, "操作成功", url = rst));
  19967. }
  19968. else
  19969. {
  19970. _currency = _GroupCostParameter.Currency;
  19971. bool isIntType = int.TryParse(_currency, out int currId);
  19972. if (isIntType)
  19973. {
  19974. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19975. }
  19976. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19977. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19978. if (currInfo == null)
  19979. {
  19980. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19981. }
  19982. if (!_currency.ToUpper().Equals("CNY"))
  19983. {
  19984. _rate = _GroupCostParameter.Rate;
  19985. }
  19986. _rate = currInfo.Rate;
  19987. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19988. //string strFileName = "HotelStatement/";
  19989. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19990. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19991. #region 数据处理
  19992. foreach (var item in hrDtas)
  19993. {
  19994. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19995. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19996. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19997. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19998. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19999. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  20000. string singleRoomFeeStr = string.Empty,
  20001. doubleRoomFeeStr = string.Empty,
  20002. suiteRoomFeeStr = string.Empty,
  20003. otherRoomFeeStr = string.Empty,
  20004. payMoneyStr = string.Empty,
  20005. cardPriceStr = string.Empty;
  20006. if (roomCurr.Equals(_currency))
  20007. {
  20008. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  20009. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  20010. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  20011. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  20012. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  20013. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  20014. }
  20015. else
  20016. {
  20017. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  20018. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  20019. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  20020. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  20021. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  20022. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  20023. }
  20024. string breakfastPriceStr = string.Empty,
  20025. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  20026. governmentRentStr = string.Empty,
  20027. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  20028. cityTaxStrStr = string.Empty,
  20029. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  20030. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  20031. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  20032. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  20033. int payDId = roomInfo?.PayDId ?? 0;
  20034. pcfds.Add(new HotelReservations_PCFD_View()
  20035. {
  20036. City = item.City,
  20037. HotelName = item.HotelName,
  20038. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  20039. // SingleRoomCount = item.SingleRoomCount,
  20040. SingleRoomPrice = singleRoomFeeStr,
  20041. // DoubleRoomCount = item.DoubleRoomCount,
  20042. DoubleRoomPrice = doubleRoomFeeStr,
  20043. //SuiteRoomCount = item.SuiteRoomCount,
  20044. SuiteRoomPrice = suiteRoomFeeStr,
  20045. OtherRoomPrice = otherRoomFeeStr,
  20046. //OtherRoomCount = item.OtherRoomCount,
  20047. BreakfastPrice = breakfastPriceStr,
  20048. GovernmentRent = governmentRentStr,
  20049. CityTax = cityTaxStrStr,
  20050. RoomExplanation = item.RoomExplanation,
  20051. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  20052. PayTime = roomInfo?.ConsumptionDate,
  20053. BankNo = roomInfo?.BankNo,
  20054. PayMoney = payMoneyStr,
  20055. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  20056. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  20057. CardPrice = cardPriceStr,
  20058. Remark = ccpInfo.Remark
  20059. });
  20060. }
  20061. #endregion
  20062. //载入模板
  20063. WorkbookDesigner designer = new WorkbookDesigner();
  20064. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  20065. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  20066. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  20067. designer.SetDataSource("TourNo", groupInfo.TourCode);
  20068. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  20069. designer.SetDataSource("Opertor", userInfo.CnName);
  20070. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  20071. dt.TableName = "ViewMyHotelReservations";
  20072. designer.SetDataSource(dt);
  20073. designer.Process();
  20074. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  20075. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  20076. designer.Workbook.Save(serverPath);
  20077. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  20078. #region 删除指定行
  20079. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  20080. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  20081. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  20082. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  20083. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  20084. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  20085. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  20086. cssIndex = dt.Columns["CityTax"].Ordinal,
  20087. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  20088. remarkIndex = dt.Columns["Remark"].Ordinal;
  20089. //删除指定列
  20090. foreach (DataRow item in dt.Rows)
  20091. {
  20092. string singleStr = item["SingleRoomPrice"].ToString();
  20093. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  20094. if (containsDigitButNotZero1) singleDel = false;
  20095. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  20096. string doubleStr = item["DoubleRoomPrice"].ToString();
  20097. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20098. if (containsDigitButNotZero2) doubleDel = false;
  20099. string suiteStr = item["SuiteRoomPrice"].ToString();
  20100. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20101. if (containsDigitButNotZero3) suiteDel = false;
  20102. string otherStr = item["OtherRoomPrice"].ToString();
  20103. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  20104. if (containsDigitButNotZero4) otherDel = false;
  20105. string zcStr = item["BreakfastPrice"].ToString();
  20106. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  20107. if (containsDigitButNotZero5) zcDel = false;
  20108. string dsStr = item["GovernmentRent"].ToString();
  20109. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  20110. if (containsDigitButNotZero6) dsDel = false;
  20111. string cssStr = item["CityTax"].ToString();
  20112. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  20113. if (containsDigitButNotZero7) cssDel = false;
  20114. string cpStr = item["ConsumptionPatterns"].ToString();
  20115. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  20116. string remarkStr = item["Remark"].ToString();
  20117. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  20118. }
  20119. DeleteColumn(serverPath, remarkIndex, remarkDel);
  20120. DeleteColumn(serverPath, cpIndex, cpDel);
  20121. DeleteColumn(serverPath, dsIndex, dsDel);
  20122. DeleteColumn(serverPath, cssIndex, cssDel);
  20123. DeleteColumn(serverPath, zcIndex, zcDel);
  20124. DeleteColumn(serverPath, otherIndex, otherDel);
  20125. DeleteColumn(serverPath, suiteIndex, suiteDel);
  20126. DeleteColumn(serverPath, doubleIndex, doubleDel);
  20127. DeleteColumn(serverPath, singleIndex, singleDel);
  20128. #endregion
  20129. //只保留第一个表格
  20130. DeleteSheet(serverPath);
  20131. return Ok(JsonView(true, "操作成功", url = rst));
  20132. }
  20133. //return Ok(JsonView(false));
  20134. }
  20135. /// <summary>
  20136. /// 删除指定列
  20137. /// </summary>
  20138. /// <param name="file"></param>
  20139. /// <param name="columnIndex"></param>
  20140. /// <param name="isDel"></param>
  20141. private void DeleteColumn(string file, int columnIndex, bool isDel)
  20142. {
  20143. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  20144. //wb.Save(file);
  20145. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  20146. if (sheet1 != null)
  20147. {
  20148. if (isDel)
  20149. {
  20150. Cells cells = sheet1.Cells;
  20151. cells.DeleteColumn(columnIndex);
  20152. }
  20153. }
  20154. wb.Save(file);
  20155. }
  20156. /// <summary>
  20157. /// 删除sheet
  20158. /// </summary>
  20159. /// <param name="file"></param>
  20160. private void DeleteSheet(string file)
  20161. {
  20162. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  20163. //wb.Save(file);
  20164. List<string> sheets = new List<string>();
  20165. foreach (var item in wb.Worksheets)
  20166. {
  20167. sheets.Add(item.Name);
  20168. }
  20169. if (sheets.Count > 0)
  20170. {
  20171. sheets.RemoveAt(0);//不删除第一个sheet
  20172. foreach (var item in sheets)
  20173. {
  20174. wb.Worksheets.RemoveAt(item);
  20175. }
  20176. }
  20177. wb.Save(file);
  20178. }
  20179. /// <summary>
  20180. /// 酒店预订
  20181. /// 确认单
  20182. /// </summary>
  20183. /// <param name="_dto"></param>
  20184. /// <returns></returns>
  20185. [HttpPost]
  20186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20187. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  20188. {
  20189. try
  20190. {
  20191. #region 参数验证
  20192. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  20193. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20194. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  20195. #region 团组操作权限验证 76 酒店预定模块
  20196. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20197. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  20198. #endregion
  20199. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20200. #region 页面操作权限验证
  20201. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20202. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20203. #endregion
  20204. #endregion
  20205. //团组信息
  20206. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  20207. //酒店数据
  20208. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  20209. if (listhoteldata.Count < 0)
  20210. {
  20211. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  20212. }
  20213. //利datatable存储
  20214. DataTable dt = new DataTable();
  20215. dt.Columns.Add("CheckInDate", typeof(string));
  20216. dt.Columns.Add("City", typeof(string));
  20217. dt.Columns.Add("Hotel", typeof(string));
  20218. dt.Columns.Add("Room", typeof(string));
  20219. for (int i = 0; i < listhoteldata.Count; i++)
  20220. {
  20221. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  20222. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  20223. while (dayStart < dayEnd)
  20224. {
  20225. string temp = "";
  20226. DataRow row = dt.NewRow();
  20227. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  20228. row["City"] = listhoteldata[i].City;
  20229. row["Hotel"] = listhoteldata[i].HotelName;
  20230. if (listhoteldata[i].SingleRoomCount > 0)
  20231. {
  20232. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  20233. }
  20234. if (listhoteldata[i].DoubleRoomCount > 0)
  20235. {
  20236. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  20237. }
  20238. if (listhoteldata[i].SuiteRoomCount > 0)
  20239. {
  20240. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  20241. }
  20242. if (listhoteldata[i].OtherRoomCount > 0)
  20243. {
  20244. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  20245. }
  20246. row["Room"] = temp;
  20247. dt.Rows.Add(row);
  20248. dayStart = dayStart.AddDays(1);
  20249. }
  20250. }
  20251. Dictionary<string, string> dic = new Dictionary<string, string>();
  20252. dic.Add("Dele", di.TeamName);
  20253. dic.Add("City", di.VisitCountry);
  20254. //模板路径
  20255. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  20256. //载入模板
  20257. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  20258. DocumentBuilder builder = new DocumentBuilder(doc);
  20259. foreach (var key in dic.Keys)
  20260. {
  20261. builder.MoveToBookmark(key);
  20262. builder.Write(dic[key]);
  20263. }
  20264. //获取word里所有表格
  20265. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20266. //获取所填表格的序数
  20267. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20268. var rowStart = tableOne.Rows[0]; //获取第1行
  20269. //循环赋值
  20270. for (int i = 0; i < dt.Rows.Count; i++)
  20271. {
  20272. builder.MoveToCell(0, i + 1, 0, 0);
  20273. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  20274. builder.MoveToCell(0, i + 1, 1, 0);
  20275. builder.Write(dt.Rows[i]["City"].ToString());
  20276. builder.MoveToCell(0, i + 1, 2, 0);
  20277. builder.Write(dt.Rows[i]["Hotel"].ToString());
  20278. builder.MoveToCell(0, i + 1, 3, 0);
  20279. builder.Write(dt.Rows[i]["Room"].ToString());
  20280. }
  20281. //删除多余行
  20282. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  20283. {
  20284. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  20285. }
  20286. string strFileName = di.TeamName + "酒店确认单.doc";
  20287. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  20288. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  20289. return Ok(JsonView(true, "成功", url));
  20290. }
  20291. catch (Exception ex)
  20292. {
  20293. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  20294. }
  20295. }
  20296. #endregion
  20297. #region 团组状态
  20298. /// <summary>
  20299. /// 团组状态列表 Page
  20300. /// </summary>
  20301. /// <param name="dto">团组列表请求dto</param>
  20302. /// <returns></returns>
  20303. [HttpPost]
  20304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20305. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  20306. {
  20307. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  20308. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  20309. {
  20310. string sqlWhere = string.Empty;
  20311. if (dto.IsSure == 0) //未完成
  20312. {
  20313. sqlWhere += string.Format(@" And IsSure = 0");
  20314. }
  20315. else if (dto.IsSure == 1) //已完成
  20316. {
  20317. sqlWhere += string.Format(@" And IsSure = 1");
  20318. }
  20319. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  20320. {
  20321. string tj = dto.SearchCriteria;
  20322. 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}%')",
  20323. tj, tj, tj, tj, tj);
  20324. }
  20325. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  20326. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  20327. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  20328. From (
  20329. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  20330. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  20331. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  20332. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  20333. From Grp_DelegationInfo gdi
  20334. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  20335. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  20336. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  20337. Where gdi.IsDel = 0 {0}
  20338. ) temp ", sqlWhere);
  20339. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  20340. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  20341. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  20342. }
  20343. else
  20344. {
  20345. return Ok(JsonView(false, "查询失败"));
  20346. }
  20347. }
  20348. /// <summary>
  20349. /// 团组状态
  20350. /// 设置操作完成
  20351. /// </summary>
  20352. /// <param name="dto">团组列表请求dto</param>
  20353. /// <returns></returns>
  20354. [HttpPost]
  20355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20356. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  20357. {
  20358. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  20359. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  20360. {
  20361. Id = dto.Id,
  20362. IsSure = 1
  20363. };
  20364. var result = await _sqlSugar.Updateable(_DelegationInfo)
  20365. .UpdateColumns(it => new { it.IsSure })
  20366. .WhereColumns(it => new { it.Id })
  20367. .ExecuteCommandAsync();
  20368. if (result > 0)
  20369. {
  20370. return Ok(JsonView(true, "操作完成!"));
  20371. }
  20372. return Ok(JsonView(false, "操作失败!"));
  20373. }
  20374. #endregion
  20375. #region 保险费用录入
  20376. /// <summary>
  20377. /// 根据团组Id查询保险费用列表
  20378. /// </summary>
  20379. /// <param name="dto"></param>
  20380. /// <returns></returns>
  20381. [HttpPost]
  20382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20383. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  20384. {
  20385. Result groupData = await _customersRep.CustomersByDiId(dto);
  20386. if (groupData.Code != 0)
  20387. {
  20388. return Ok(JsonView(false, groupData.Msg));
  20389. }
  20390. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20391. }
  20392. /// <summary>
  20393. /// 根据保险费用Id查询保险费用详细
  20394. /// </summary>
  20395. /// <param name="dto"></param>
  20396. /// <returns></returns>
  20397. [HttpPost]
  20398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20399. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  20400. {
  20401. try
  20402. {
  20403. Result groupData = await _customersRep.CustomersById(dto);
  20404. if (groupData.Code != 0)
  20405. {
  20406. return Ok(JsonView(false, groupData.Msg));
  20407. }
  20408. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20409. }
  20410. catch (Exception ex)
  20411. {
  20412. return Ok(JsonView(false, ex.Message));
  20413. }
  20414. }
  20415. /// <summary>
  20416. /// 保险费用录入页面初始化绑定
  20417. /// </summary>
  20418. /// <param name="dto"></param>
  20419. /// <returns></returns>
  20420. [HttpPost]
  20421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20422. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  20423. {
  20424. try
  20425. {
  20426. Result groupData = await _customersRep.CustomersInitialize(dto);
  20427. if (groupData.Code != 0)
  20428. {
  20429. return Ok(JsonView(false, groupData.Msg));
  20430. }
  20431. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20432. }
  20433. catch (Exception ex)
  20434. {
  20435. return Ok(JsonView(false, ex.Message));
  20436. }
  20437. }
  20438. /// <summary>
  20439. /// 保险费用操作(Status:1.新增,2.修改)
  20440. /// </summary>
  20441. /// <param name="dto"></param>
  20442. /// <returns></returns>
  20443. [HttpPost]
  20444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20445. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  20446. {
  20447. Result groupData = await _customersRep.OpCustomers(dto);
  20448. if (groupData.Code != 0)
  20449. {
  20450. return Ok(JsonView(false, groupData.Msg));
  20451. }
  20452. #region 应用推送
  20453. try
  20454. {
  20455. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  20456. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  20457. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  20458. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  20459. //自动审核
  20460. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  20461. //2024-10-21 新增LZ UID
  20462. var userIds = new List<int>() { 21 };
  20463. string title = $"系统通知";
  20464. var diId = dto.DiId;
  20465. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  20466. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  20467. string content = "";
  20468. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20469. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20470. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  20471. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  20472. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  20473. }
  20474. catch (Exception ex)
  20475. {
  20476. }
  20477. #endregion
  20478. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20479. }
  20480. /// <summary>
  20481. /// 保险文件上传
  20482. /// </summary>
  20483. /// <param name="file"></param>
  20484. /// <returns></returns>
  20485. [HttpPost]
  20486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20487. public async Task<IActionResult> UploadCus(IFormFile file)
  20488. {
  20489. try
  20490. {
  20491. if (file != null)
  20492. {
  20493. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  20494. //文件名称
  20495. string projectFileName = file.FileName;
  20496. //上传的文件的路径
  20497. string filePath = "";
  20498. if (!Directory.Exists(fileDir))
  20499. {
  20500. Directory.CreateDirectory(fileDir);
  20501. }
  20502. //上传的文件的路径
  20503. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  20504. using (FileStream fs = System.IO.File.Create(filePath))
  20505. {
  20506. file.CopyTo(fs);
  20507. fs.Flush();
  20508. }
  20509. return Ok(JsonView(true, "上传成功!", projectFileName));
  20510. }
  20511. else
  20512. {
  20513. return Ok(JsonView(false, "上传失败!"));
  20514. }
  20515. }
  20516. catch (Exception ex)
  20517. {
  20518. return Ok(JsonView(false, ex.Message));
  20519. }
  20520. }
  20521. /// <summary>
  20522. /// 保险删除指定文件
  20523. /// </summary>
  20524. /// <param name="dto"></param>
  20525. /// <returns></returns>
  20526. [HttpPost]
  20527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20528. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  20529. {
  20530. try
  20531. {
  20532. string filePath = "";
  20533. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  20534. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  20535. //int id = 0;
  20536. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  20537. // 删除该文件
  20538. try
  20539. {
  20540. System.IO.File.Delete(filePath);
  20541. 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()
  20542. {
  20543. Attachment = "",
  20544. }).ExecuteCommandAsync();
  20545. if (result != 0)
  20546. {
  20547. return Ok(JsonView(true, "成功!"));
  20548. }
  20549. else
  20550. {
  20551. return Ok(JsonView(false, "失败!"));
  20552. }
  20553. }
  20554. catch (Exception)
  20555. {
  20556. 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()
  20557. {
  20558. Attachment = "",
  20559. }).ExecuteCommandAsync();
  20560. if (result != 0)
  20561. {
  20562. return Ok(JsonView(true, "成功!"));
  20563. }
  20564. else
  20565. {
  20566. return Ok(JsonView(false, "失败!"));
  20567. }
  20568. }
  20569. }
  20570. catch (Exception ex)
  20571. {
  20572. return Ok(JsonView(false, "程序错误!"));
  20573. throw;
  20574. }
  20575. }
  20576. /// <summary>
  20577. /// 保险费用操作(删除)
  20578. /// </summary>
  20579. /// <param name="dto"></param>
  20580. /// <returns></returns>
  20581. [HttpPost]
  20582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20583. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  20584. {
  20585. try
  20586. {
  20587. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  20588. if (!res)
  20589. {
  20590. return Ok(JsonView(false, "删除失败"));
  20591. }
  20592. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  20593. {
  20594. IsDel = 1,
  20595. DeleteUserId = dto.DeleteUserId,
  20596. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  20597. }).ExecuteCommandAsync();
  20598. return Ok(JsonView(true, "删除成功!"));
  20599. }
  20600. catch (Exception ex)
  20601. {
  20602. return Ok(JsonView(false, "程序错误!"));
  20603. throw;
  20604. }
  20605. }
  20606. #endregion
  20607. #region 接团客户名单 PageId 104
  20608. /// <summary>
  20609. /// 接团客户名单
  20610. /// 迁移数据(慎用!)
  20611. /// </summary>
  20612. /// <returns></returns>
  20613. [HttpPost]
  20614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20615. public async Task<IActionResult> PostTourClientListChange()
  20616. {
  20617. try
  20618. {
  20619. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  20620. //var groupClinetData1
  20621. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  20622. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  20623. int updateCount = 0;
  20624. if (oldOAClientList.Count > 0)
  20625. {
  20626. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  20627. _sqlSugar.BeginTran();
  20628. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  20629. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  20630. foreach (var item in oldOAClientList)
  20631. {
  20632. int comId = 0;
  20633. string format = "yyyy-MM-dd HH:mm:ss";
  20634. string data11 = "1990-01-01 00:00";
  20635. var data1 = IsValidDate(item.OPdate, format);
  20636. if (data1) data11 = item.OPdate;
  20637. //客户公司验证
  20638. if (!string.IsNullOrEmpty(item.Company))
  20639. {
  20640. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  20641. if (clientComInfo == null) // add
  20642. {
  20643. var addInfo = new Crm_CustomerCompany()
  20644. {
  20645. CompanyAbbreviation = "",
  20646. CompanyFullName = item.Company,
  20647. Address = "",
  20648. PostCodes = "",
  20649. LastedOpUserId = item.OPer,
  20650. LastedOpDt = Convert.ToDateTime(data11),
  20651. CreateUserId = item.OPer,
  20652. CreateTime = Convert.ToDateTime(data11),
  20653. IsDel = 0
  20654. };
  20655. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  20656. if (comId1 > 0) comId = comId1;
  20657. }
  20658. else comId = clientComInfo.Id;
  20659. }
  20660. //客户人员验证
  20661. int clientId = 0;
  20662. string name = item.LastName + item.Name;
  20663. if (!string.IsNullOrEmpty(name))
  20664. {
  20665. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  20666. if (clientInfo == null)
  20667. {
  20668. DateTime? dateTime = null;
  20669. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  20670. if (isDt) dateTime = birthDayDt;
  20671. var addInfo1 = new Crm_DeleClient()
  20672. {
  20673. CrmCompanyId = comId,
  20674. DiId = -1,
  20675. LastName = item.LastName,
  20676. FirstName = item.Name,
  20677. OldName = "",
  20678. Pinyin = item.Pinyin,
  20679. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  20680. Marriage = 0,
  20681. Phone = item.Phone,
  20682. Job = item.Job,
  20683. BirthDay = dateTime
  20684. };
  20685. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  20686. if (clientId1 > 0) clientId = clientId1;
  20687. }
  20688. else clientId = clientInfo.Id;
  20689. }
  20690. if (clientId < 1)
  20691. {
  20692. continue;
  20693. }
  20694. int airType = 0;
  20695. if (item.AirType == "超经舱") airType = 459;
  20696. else if (item.AirType == "公务舱") airType = 458;
  20697. else if (item.AirType == "经济舱") airType = 460;
  20698. else if (item.AirType == "其他") airType = 565;
  20699. else if (item.AirType == "头等舱") airType = 457;
  20700. var _TourClientListEntity = new Grp_TourClientList()
  20701. {
  20702. DiId = item.Diid,
  20703. ClientId = clientId,
  20704. CreateUserId = item.OPer,
  20705. CreateTime = Convert.ToDateTime(data11),
  20706. Remark = item.Remark,
  20707. IsDel = item.Isdel,
  20708. ShippingSpaceTypeId = airType,
  20709. ShippingSpaceSpecialNeeds = item.AirRemark,
  20710. HotelSpecialNeeds = item.RoomType
  20711. };
  20712. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  20713. if (_TourClientList > 0)
  20714. {
  20715. updateCount++;
  20716. }
  20717. }
  20718. _sqlSugar.CommitTran();
  20719. }
  20720. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  20721. }
  20722. catch (Exception ex)
  20723. {
  20724. _sqlSugar.RollbackTran();
  20725. return Ok(JsonView(false, ex.Message));
  20726. }
  20727. //return Ok(JsonView(true));
  20728. }
  20729. private bool IsValidDate(string dateString, string format)
  20730. {
  20731. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  20732. }
  20733. /// <summary>
  20734. /// 接团客户名单
  20735. /// 根据团组Id查询List
  20736. /// </summary>
  20737. /// <param name="_dto"></param>
  20738. /// <returns></returns>
  20739. [HttpPost]
  20740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20741. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  20742. {
  20743. #region 参数验证
  20744. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  20745. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  20746. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  20747. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20748. #region 页面操作权限验证
  20749. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20750. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20751. #endregion
  20752. #endregion
  20753. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  20754. if (viewData.Code != 0)
  20755. {
  20756. return Ok(JsonView(false, viewData.Msg));
  20757. }
  20758. return Ok(JsonView(viewData.Data));
  20759. }
  20760. /// <summary>
  20761. /// 接团客户名单
  20762. /// 基础数据 Init
  20763. /// </summary>
  20764. /// <param name="_dto"></param>
  20765. /// <returns></returns>
  20766. [HttpPost]
  20767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20768. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  20769. {
  20770. #region 参数验证
  20771. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20772. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20773. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20774. #region 页面操作权限验证
  20775. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20776. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20777. #endregion
  20778. #endregion
  20779. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  20780. }
  20781. /// <summary>
  20782. /// 接团客户名单
  20783. /// 根据 Id查询 Details
  20784. /// </summary>
  20785. /// <param name="_dto"></param>
  20786. /// <returns></returns>
  20787. [HttpPost]
  20788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20789. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  20790. {
  20791. #region 参数验证
  20792. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20793. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20794. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20795. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20796. #region 页面操作权限验证
  20797. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20798. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20799. #endregion
  20800. #endregion
  20801. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  20802. if (viewData.Code != 0)
  20803. {
  20804. return Ok(JsonView(false, viewData.Msg));
  20805. }
  20806. return Ok(JsonView(viewData.Data));
  20807. }
  20808. /// <summary>
  20809. /// 接团客户名单
  20810. /// Add Or Edit
  20811. /// </summary>
  20812. /// <param name="_dto"></param>
  20813. /// <returns></returns>
  20814. [HttpPost]
  20815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20816. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  20817. {
  20818. #region 参数验证
  20819. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20820. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20821. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20822. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20823. #region 页面操作权限验证
  20824. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20825. if (_dto.Id == 0) //添加
  20826. {
  20827. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20828. }
  20829. else if (_dto.Id >= 0) //修改
  20830. {
  20831. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  20832. }
  20833. #endregion
  20834. #endregion
  20835. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  20836. if (viewData.Code != 0)
  20837. {
  20838. return Ok(JsonView(false, viewData.Msg));
  20839. }
  20840. return Ok(JsonView(true));
  20841. }
  20842. /// <summary>
  20843. /// 接团客户名单
  20844. /// json字符串 AddMultiple(添加多个)
  20845. /// </summary>
  20846. /// <param name="_dto"></param>
  20847. /// <returns></returns>
  20848. [HttpPost]
  20849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20850. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  20851. {
  20852. #region 参数验证
  20853. string jsonLabel = _dto.JsonLabel;
  20854. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20855. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20856. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20857. #region 页面操作权限验证
  20858. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20859. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20860. #endregion
  20861. #endregion
  20862. var request = new TourClientListAddMultipleDto();
  20863. request.DiId = _dto.DiId;
  20864. request.UserId = _dto.UserId;
  20865. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  20866. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  20867. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  20868. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  20869. var infos = new List<TourClientListInfo>();
  20870. foreach (var data in datas)
  20871. {
  20872. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  20873. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  20874. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  20875. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  20876. {
  20877. continue;
  20878. }
  20879. infos.Add(new TourClientListInfo()
  20880. {
  20881. IsAccompany = 1,
  20882. LastName = lastName,
  20883. FirstName = firstName,
  20884. Pinyin = lastNameEn + @"/" + firstNameEn,
  20885. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  20886. CompanyFullName = data.CompanyFullName,
  20887. Job = data.Job
  20888. });
  20889. }
  20890. if (infos.Any())
  20891. {
  20892. var viewData = await _tourClientListRep._AddMultiple(request);
  20893. if (viewData.Code != 0)
  20894. {
  20895. return Ok(JsonView(false, viewData.Msg));
  20896. }
  20897. return Ok(JsonView(true));
  20898. }
  20899. return Ok(JsonView(false));
  20900. }
  20901. /// <summary>
  20902. /// 接团客户名单
  20903. /// AddMultiple(添加多个)
  20904. /// </summary>
  20905. /// <param name="_dto"></param>
  20906. /// <returns></returns>
  20907. [HttpPost]
  20908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20909. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  20910. {
  20911. #region 参数验证
  20912. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20913. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20914. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20915. #region 页面操作权限验证
  20916. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20917. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20918. #endregion
  20919. #endregion
  20920. var viewData = await _tourClientListRep._AddMultiple(_dto);
  20921. if (viewData.Code != 0)
  20922. {
  20923. return Ok(JsonView(false, viewData.Msg));
  20924. }
  20925. return Ok(JsonView(true));
  20926. }
  20927. /// <summary>
  20928. /// 接团客户名单
  20929. /// Del
  20930. /// </summary>
  20931. /// <param name="_dto"></param>
  20932. /// <returns></returns>
  20933. [HttpPost]
  20934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20935. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  20936. {
  20937. #region 参数验证
  20938. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20939. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20940. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20941. #region 页面操作权限验证
  20942. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20943. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  20944. #endregion
  20945. #endregion
  20946. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  20947. if (viewData.Code != 0)
  20948. {
  20949. return Ok(JsonView(false, viewData.Msg));
  20950. }
  20951. return Ok(JsonView(true));
  20952. }
  20953. /// <summary>
  20954. /// 接团客户名单
  20955. /// 文件下载 客户名单
  20956. /// </summary>
  20957. /// <param name="_dto"></param>
  20958. /// <returns></returns>
  20959. [HttpPost]
  20960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20961. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  20962. {
  20963. #region 参数验证
  20964. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20965. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20966. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  20967. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20968. #region 页面操作权限验证
  20969. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20970. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20971. #endregion
  20972. #endregion
  20973. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  20974. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  20975. From Grp_TourClientList tcl
  20976. Left Join
  20977. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  20978. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  20979. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  20980. From Crm_DeleClient dc
  20981. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  20982. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  20983. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  20984. Where dc.IsDel = 0) temp
  20985. On temp.DcId =tcl.ClientId
  20986. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  20987. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  20988. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  20989. //载入模板
  20990. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  20991. if (_dto.Language == 1)
  20992. {
  20993. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  20994. }
  20995. //载入模板
  20996. var doc = new Document(tempPath);
  20997. DocumentBuilder builder = new DocumentBuilder(doc);
  20998. //获取word里所有表格
  20999. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21000. //获取所填表格的序数
  21001. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21002. var rowStart = tableOne.Rows[0]; //获取第1行
  21003. if (_dto.Language == 0)
  21004. {
  21005. //循环赋值
  21006. for (int i = 0; i < DcList.Count; i++)
  21007. {
  21008. EncryptionProcessor.DecryptProperties(DcList[i]);
  21009. builder.MoveToCell(0, i + 1, 0, 0);
  21010. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  21011. builder.MoveToCell(0, i + 1, 1, 0);
  21012. int sex = DcList[i].Sex;
  21013. string sexStr = string.Empty;
  21014. if (sex == 0) sexStr = "男";
  21015. else if (sex == 1) sexStr = "女";
  21016. else sexStr = "未设置";
  21017. builder.Write(sexStr);
  21018. builder.MoveToCell(0, i + 1, 2, 0);
  21019. string birthDay = DcList[i].BirthDay;
  21020. string birthDayStr = string.Empty;
  21021. if (!string.IsNullOrEmpty(birthDay))
  21022. {
  21023. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  21024. }
  21025. builder.Write(birthDayStr);
  21026. builder.MoveToCell(0, i + 1, 3, 0);
  21027. string company = "";
  21028. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  21029. {
  21030. company = DcList[i].CompanyFullName.ToString();
  21031. }
  21032. builder.Write(company);
  21033. builder.MoveToCell(0, i + 1, 4, 0);
  21034. builder.Write(DcList[i].Job);
  21035. }
  21036. }
  21037. else if (_dto.Language == 1)
  21038. {
  21039. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  21040. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  21041. List<string> transArrayStr = new List<string>();
  21042. string transStrRes1 = "";
  21043. var clientEnglishs = new List<ClientEnglishView>();
  21044. for (int i = 0; i < DcList.Count; i++)
  21045. {
  21046. var dc = DcList[i];
  21047. EncryptionProcessor.DecryptProperties(dc);
  21048. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  21049. if (dc.Job.Equals("暂无")) dc.Job = "-";
  21050. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  21051. if (DcList.Count - 1 == i) transStrRes1 += str1;
  21052. else transStrRes1 += $"{str1}|";
  21053. clientEnglishs.Add(new()
  21054. {
  21055. Id = dc.Id,
  21056. LastName = dc.LastName,
  21057. FirstName = dc.FirstName,
  21058. Pinyin = dc.Pinyin,
  21059. Sex = dc.Sex,
  21060. CompanyFullName = dc.CompanyFullName,
  21061. Job = dc.Job,
  21062. IDCardNo = dc.IDCardNo,
  21063. BirthDay = dc.BirthDay,
  21064. });
  21065. }
  21066. #region AI转英文
  21067. string jsonValue = JsonConvert.SerializeObject(clientEnglishs);
  21068. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  21069. List<SeedMessages> messages = new List<SeedMessages>()
  21070. {
  21071. new SeedMessages
  21072. {
  21073. Role = KimiRole.user,
  21074. Content = jsonValue + text
  21075. }
  21076. };
  21077. KiMiApiClient client = new KiMiApiClient();
  21078. var kimiApiResult = await client.SeedMessage(messages);
  21079. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  21080. string clients = kimiApiResult_JObject["content"].ToString();
  21081. string startStr = "```json", endStr = "```";
  21082. // 判断并清除开头部分
  21083. if (clients.StartsWith(startStr))
  21084. {
  21085. clients = clients.Remove(0, startStr.Length);
  21086. }
  21087. // 判断并清除结尾部分
  21088. if (clients.EndsWith(endStr))
  21089. {
  21090. clients = clients.Remove(clients.Length - endStr.Length);
  21091. }
  21092. var en_Json = JsonConvert.DeserializeObject<List<ClientEnglishView>>(clients);
  21093. //循环赋值
  21094. for (int i = 0; i < en_Json.Count; i++)
  21095. {
  21096. var dc = en_Json[i];
  21097. var dc1 = DcList.Find(x => x.Id == dc.Id);
  21098. string PYName = dc.FirstName + " " + dc.LastName;
  21099. builder.MoveToCell(0, i + 1, 0, 0);
  21100. builder.Write(PYName);
  21101. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  21102. builder.MoveToCell(0, i + 1, 1, 0);
  21103. builder.Write(sex);
  21104. DateTime birthDt;
  21105. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  21106. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  21107. builder.MoveToCell(0, i + 1, 2, 0);
  21108. builder.Write(birthday);
  21109. string company = string.Empty, job = string.Empty;
  21110. company = dc.CompanyFullName;
  21111. job = dc.Job;
  21112. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  21113. {
  21114. //查询对照表
  21115. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  21116. if (tempCec != null)
  21117. {
  21118. company = tempCec.enName;
  21119. }
  21120. }
  21121. builder.MoveToCell(0, i + 1, 3, 0);
  21122. builder.Write(company);
  21123. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  21124. {
  21125. //查询对照表
  21126. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  21127. if (tempPec != null)
  21128. {
  21129. job = tempPec.enName;
  21130. }
  21131. }
  21132. builder.MoveToCell(0, i + 1, 4, 0);
  21133. builder.Write(job);
  21134. }
  21135. #endregion
  21136. #region 旧翻译英文处理
  21137. ////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";
  21138. //string transStrRes = "";
  21139. //if (transStrRes1.Length > 0)
  21140. //{
  21141. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  21142. //}
  21143. ////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
  21144. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  21145. ////List<string> transArray = new List<string> { };
  21146. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  21147. //if (transStrRes.Contains("|"))
  21148. //{
  21149. // string[] transArray1 = transStrRes.Split('|');
  21150. // if (transArray1.Length > 0)
  21151. // {
  21152. // foreach (var item in transArray1)
  21153. // {
  21154. // if (item.Contains("&"))
  21155. // {
  21156. // string[] transArray2 = item.Split('&');
  21157. // int index = 0;
  21158. // string companyName = "", job = "";
  21159. // if (transArray2.Length > 0)
  21160. // {
  21161. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  21162. // if (1 < transArray2.Length) companyName = transArray2[1];
  21163. // if (2 < transArray2.Length) job = transArray2[2];
  21164. // }
  21165. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  21166. // }
  21167. // }
  21168. // }
  21169. //}
  21170. ////循环赋值
  21171. //for (int i = 0; i < DcList.Count; i++)
  21172. //{
  21173. // string PYName = "";
  21174. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  21175. // {
  21176. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  21177. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  21178. // PYName = PY_First + " " + PY_Last;
  21179. // }
  21180. // else
  21181. // {
  21182. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  21183. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  21184. // PYName = PY_First + " " + PY_Last;
  21185. // }
  21186. // builder.MoveToCell(0, i + 1, 0, 0);
  21187. // builder.Write(PYName);
  21188. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  21189. // builder.MoveToCell(0, i + 1, 1, 0);
  21190. // builder.Write(sex);
  21191. // DateTime birthDt;
  21192. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  21193. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  21194. // builder.MoveToCell(0, i + 1, 2, 0);
  21195. // builder.Write(birthday);
  21196. // string company = string.Empty, job = string.Empty;
  21197. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  21198. // if (dcTransInfo != null)
  21199. // {
  21200. // company = dcTransInfo.CompanyName;
  21201. // job = dcTransInfo.Job;
  21202. // }
  21203. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  21204. // {
  21205. // //查询对照表
  21206. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  21207. // if (tempCec != null)
  21208. // {
  21209. // company = tempCec.enName;
  21210. // }
  21211. // //翻译
  21212. // else
  21213. // {
  21214. // }
  21215. // }
  21216. // builder.MoveToCell(0, i + 1, 3, 0);
  21217. // builder.Write(company);
  21218. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  21219. // {
  21220. // //查询对照表
  21221. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  21222. // if (tempPec != null)
  21223. // {
  21224. // job = tempPec.enName;
  21225. // }
  21226. // //翻译
  21227. // else
  21228. // {
  21229. // }
  21230. // }
  21231. // builder.MoveToCell(0, i + 1, 4, 0);
  21232. // builder.Write(job);
  21233. //}
  21234. #endregion
  21235. }
  21236. //删除多余行
  21237. while (tableOne.Rows.Count > DcList.Count + 1)
  21238. {
  21239. tableOne.Rows.RemoveAt(DcList.Count + 1);
  21240. }
  21241. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  21242. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  21243. doc.Save(fileDir);
  21244. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  21245. return Ok(JsonView(true, "操作成功!", Url));
  21246. }
  21247. private class TranslateInfo
  21248. {
  21249. public int Index { get; set; }
  21250. public string CompanyName { get; set; }
  21251. public string Job { get; set; }
  21252. }
  21253. [HttpPost]
  21254. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  21255. {
  21256. if (files.Count == 0)
  21257. {
  21258. return Ok(JsonView(false, "文件为空"));
  21259. }
  21260. KiMiApiClient KiMiApi = new KiMiApiClient();
  21261. var seedConter = await KiMiApi.UploadFilesAsync(files);
  21262. if (seedConter.Count == 0)
  21263. {
  21264. return Ok(JsonView(false, "上传结果为空!"));
  21265. }
  21266. var messages = new List<SeedMessages>
  21267. {
  21268. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  21269. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  21270. };
  21271. messages.InsertRange(1, seedConter);
  21272. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  21273. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  21274. string clients = kimiApiResult_JObject["content"].ToString();
  21275. string startStr = "```json", endStr = "```";
  21276. // 判断并清除开头部分
  21277. if (clients.StartsWith(startStr))
  21278. {
  21279. clients = clients.Remove(0, startStr.Length);
  21280. }
  21281. // 判断并清除结尾部分
  21282. if (clients.EndsWith(endStr))
  21283. {
  21284. clients = clients.Remove(clients.Length - endStr.Length);
  21285. }
  21286. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  21287. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  21288. {
  21289. {"姓", "LastName" },
  21290. {"名", "FirstName" },
  21291. {"姓名拼音", "Pinyin" },
  21292. {"性别", "Sex" },
  21293. {"单位", "CompanyFullName" },
  21294. {"职务", "Job" },
  21295. {"出生日期", "Birthday" },
  21296. };
  21297. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  21298. foreach (var item in clients_JObject)
  21299. {
  21300. BaiduClientOCRView cdc = new BaiduClientOCRView();
  21301. foreach (var field in clientFieldMap.Keys)
  21302. {
  21303. if (item.TryGetValue(field, out JToken value))
  21304. {
  21305. var getValue = value.ToString();
  21306. System.Type type = cdc.GetType();
  21307. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  21308. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  21309. propertyInfo.SetValue(cdc, propertyValue);
  21310. }
  21311. }
  21312. crmClients.Add(cdc);
  21313. }
  21314. return Ok(JsonView(new
  21315. {
  21316. fileCount = files.Count,
  21317. UploadCount = seedConter.Count,
  21318. ApiResult = clients,
  21319. CrmClients = crmClients
  21320. }));
  21321. }
  21322. #endregion
  21323. #region 团组倒推表
  21324. /// <summary>
  21325. /// 倒推表基础数据
  21326. /// Init
  21327. /// </summary>
  21328. /// <returns></returns>
  21329. [HttpPost]
  21330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21331. public async Task<IActionResult> PostInvertedListInit()
  21332. {
  21333. var viewData = await _invertedListRep._Init();
  21334. if (viewData.Code != 0)
  21335. {
  21336. return Ok(JsonView(false, viewData.Msg));
  21337. }
  21338. return Ok(JsonView(viewData.Data));
  21339. }
  21340. /// <summary>
  21341. /// 倒推表
  21342. /// Info
  21343. /// </summary>
  21344. /// <param name="dto"></param>
  21345. /// <returns></returns>
  21346. [HttpPost]
  21347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21348. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  21349. {
  21350. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  21351. if (viewData.Code != 0)
  21352. {
  21353. return Ok(JsonView(false, viewData.Msg));
  21354. }
  21355. return Ok(JsonView(viewData.Data));
  21356. }
  21357. /// <summary>
  21358. /// 倒推表
  21359. /// Create
  21360. /// </summary>
  21361. /// <param name="dto"></param>
  21362. /// <returns></returns>
  21363. [HttpPost]
  21364. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21365. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  21366. {
  21367. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  21368. if (viewData.Code != 0)
  21369. {
  21370. return Ok(JsonView(false, viewData.Msg));
  21371. }
  21372. return Ok(JsonView(viewData.Data));
  21373. }
  21374. /// <summary>
  21375. /// 倒推表
  21376. /// Update
  21377. /// </summary>
  21378. /// <param name="dto"></param>
  21379. /// <returns></returns>
  21380. [HttpPost]
  21381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21382. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  21383. {
  21384. var viewData = await _invertedListRep._Update(dto);
  21385. if (viewData.Code != 0)
  21386. {
  21387. return Ok(JsonView(false, viewData.Msg));
  21388. }
  21389. return Ok(JsonView(viewData.Data));
  21390. }
  21391. /// <summary>
  21392. /// 倒推表
  21393. /// File Download
  21394. /// </summary>
  21395. /// <param name="dto"></param>
  21396. /// <returns></returns>
  21397. [HttpPost]
  21398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21399. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  21400. {
  21401. var info2 = await _invertedListRep._Info(1, dto.DiId);
  21402. if (info2.Code != 0)
  21403. {
  21404. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  21405. }
  21406. var info1 = info2.Data as InvertedListInfoView;
  21407. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  21408. string teamName = "";
  21409. if (info != null) teamName = info.TeamName;
  21410. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  21411. var doc = new Document();
  21412. var builder = new DocumentBuilder(doc);
  21413. #region old insert
  21414. ////载入模板
  21415. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  21416. //Document doc = new Document(tempPath);
  21417. //DocumentBuilder builder = new DocumentBuilder(doc);
  21418. //利用键值对存放数据
  21419. //Dictionary<string, string> dic = new Dictionary<string, string>();
  21420. //dic.Add("TeamName", teamName);
  21421. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  21422. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  21423. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  21424. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  21425. //dic.Add("SQRemark", info1.ApprovalRemark);
  21426. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  21427. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  21428. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  21429. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  21430. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  21431. //dic.Add("QZRemark", info1.VisaInformationRemark);
  21432. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  21433. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  21434. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  21435. //dic.Add("CQRemark", info1.IssueVisaRemark);
  21436. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  21437. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  21438. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  21439. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  21440. //#region 填充word模板书签内容
  21441. //foreach (var key in dic.Keys)
  21442. //{
  21443. // builder.MoveToBookmark(key);
  21444. // builder.Write(dic[key]);
  21445. //}
  21446. //#endregion
  21447. #endregion
  21448. #region New Insert
  21449. string titleFont = $"仿宋",
  21450. contentFont = $"仿宋";
  21451. var fontColor = Color.FromArgb(64, 64, 64);
  21452. //设置标题 团组名称
  21453. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21454. builder.Font.Name = titleFont;
  21455. builder.Font.Color = fontColor;
  21456. builder.Font.Size = 12;
  21457. builder.Font.Bold = true;
  21458. builder.Writeln(teamName);
  21459. //设置副标题 团组出访时间
  21460. builder.Font.Size = 12;
  21461. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  21462. builder.Writeln();
  21463. var backgroundColor = Color.FromArgb(199, 199, 199);
  21464. var table = builder.StartTable();
  21465. builder.InsertCell();
  21466. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  21467. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  21468. builder.CellFormat.Borders.LineWidth = 1;
  21469. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  21470. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  21471. builder.RowFormat.Height = 40;
  21472. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21473. builder.Font.Name = contentFont;
  21474. builder.Font.Size = 12;
  21475. builder.Font.Bold = true;
  21476. builder.Font.Color = fontColor;
  21477. builder.Write("时间");
  21478. builder.InsertCell();
  21479. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  21480. builder.Write("流程");
  21481. builder.InsertCell();
  21482. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  21483. builder.Write("说明");
  21484. builder.EndRow();
  21485. //报批资料准备
  21486. if (info1.IsSelectedAirportd)
  21487. {
  21488. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  21489. }
  21490. //报批/提供送签资料
  21491. if (info1.IsSelectedApprovalData)
  21492. {
  21493. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  21494. }
  21495. //出批件护照办理
  21496. if (info1.IsSelectedIssueApproval)
  21497. {
  21498. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  21499. }
  21500. //签证资料准备
  21501. if (info1.IsSelectedVisaInfo)
  21502. {
  21503. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  21504. }
  21505. //送签
  21506. if (info1.IsSelectedSendVisa)
  21507. {
  21508. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  21509. }
  21510. //出签
  21511. if (info1.IsSelectedIssueVisa)
  21512. {
  21513. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  21514. }
  21515. //机票
  21516. if (info1.IsSelectedAirTicket)
  21517. {
  21518. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  21519. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  21520. }
  21521. //酒店
  21522. if (info1.IsSelectedHotel)
  21523. {
  21524. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  21525. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  21526. }
  21527. //开行前会
  21528. if (info1.IsSelectedPreTripMeeting)
  21529. {
  21530. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  21531. }
  21532. //送机
  21533. if (info1.IsSelectedAirportdDropOff)
  21534. {
  21535. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  21536. }
  21537. builder.EndTable();
  21538. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  21539. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  21540. for (int i = 0; i < table.Rows.Count; i++)
  21541. {
  21542. var row = table.Rows[i];
  21543. //设置宽度
  21544. row.Cells[0].CellFormat.Width = 20.00;
  21545. row.Cells[1].CellFormat.Width = 30.00;
  21546. row.Cells[2].CellFormat.Width = 50.00;
  21547. if (i != 0)
  21548. {
  21549. //边框设置
  21550. InvertedListFileDownloadSetBorders(row.Cells, 0);
  21551. InvertedListFileDownloadSetBorders(row.Cells, 1);
  21552. InvertedListFileDownloadSetBorders(row.Cells, 2);
  21553. }
  21554. }
  21555. #region 页脚插入图片
  21556. // 创建页脚
  21557. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  21558. doc.FirstSection.HeadersFooters.Add(footer);
  21559. Paragraph para = new Paragraph(doc);
  21560. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  21561. footer.AppendChild(para);
  21562. builder.MoveTo(para);
  21563. string imagePath = "./Images/FMGJ_Log.png";
  21564. builder.InsertImage(imagePath);
  21565. #endregion
  21566. #endregion
  21567. var fileDir = AppSettingsHelper.Get("WordBasePath");
  21568. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  21569. string filePath = fileDir + $@"InvertedList/{fileName}";
  21570. doc.Save(filePath);
  21571. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  21572. return Ok(JsonView(true, "操作成功!", Url));
  21573. }
  21574. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  21575. {
  21576. var fontColor = Color.FromArgb(64, 64, 64);
  21577. builder.InsertCell();
  21578. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  21579. builder.RowFormat.Height = 40;
  21580. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21581. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21582. builder.Font.Name = fontName;
  21583. builder.Font.Size = 8;
  21584. builder.Font.Bold = true;
  21585. builder.Font.Color = fontColor;
  21586. builder.Write(dateTime);
  21587. builder.InsertCell();
  21588. builder.Font.Size = 9;
  21589. builder.Font.Bold = true;
  21590. builder.Font.Color = fontColor;
  21591. builder.Write(content);
  21592. builder.InsertCell();
  21593. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21594. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  21595. builder.Font.Size = 9;
  21596. builder.Font.Bold = false;
  21597. builder.Font.Color = fontColor;
  21598. builder.Write(reamrk);
  21599. builder.EndRow();
  21600. }
  21601. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  21602. {
  21603. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  21604. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  21605. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  21606. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  21607. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  21608. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  21609. }
  21610. #endregion
  21611. #region 会务倒推表
  21612. /// <summary>
  21613. /// 会务倒推表
  21614. /// Init
  21615. /// </summary>
  21616. /// <returns></returns>
  21617. [HttpPost]
  21618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21619. public async Task<IActionResult> InforRetrogressTableInit()
  21620. {
  21621. var groupData = await _groupRepository.PostShareGroupInfos(1);
  21622. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  21623. return Ok(JsonView(false, groupData.Msg));
  21624. }
  21625. /// <summary>
  21626. /// 会务倒推表
  21627. /// ExcelDownload
  21628. /// </summary>
  21629. /// <param name="dto"></param>
  21630. /// <returns></returns>
  21631. [HttpPost]
  21632. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  21633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21634. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  21635. {
  21636. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  21637. var validatorRes = await validator.ValidateAsync(dto);
  21638. if (!validatorRes.IsValid)
  21639. {
  21640. StringBuilder sb = new StringBuilder();
  21641. foreach (var item in validatorRes.Errors)
  21642. {
  21643. sb.AppendLine(item.ErrorMessage);
  21644. }
  21645. return Ok(JsonView(false, sb.ToString()));
  21646. }
  21647. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  21648. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  21649. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  21650. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  21651. #region Excel
  21652. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  21653. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  21654. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  21655. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  21656. var fileNamePrefix = string.Empty;
  21657. if (days >= 30)
  21658. {
  21659. tempPath += $"会务工作倒推进度表(30天).xlsx";
  21660. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  21661. }
  21662. else if (days < 30 && days > 7)
  21663. {
  21664. tempPath += $"会务工作倒推进度表(15天).xlsx";
  21665. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  21666. }
  21667. else if (days <= 7)
  21668. {
  21669. tempPath += $"会务工作倒推进度表(7天).xlsx";
  21670. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  21671. }
  21672. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  21673. fileName = CommonFun.ValidFileName(fileName);
  21674. //载入模板
  21675. WorkbookDesigner designer = new WorkbookDesigner();
  21676. designer.Workbook = new Workbook(tempPath);
  21677. designer.Process();
  21678. if (!Directory.Exists(savePath))
  21679. {
  21680. Directory.CreateDirectory(savePath);
  21681. }
  21682. string serverPath = $"{savePath}{fileName}";
  21683. designer.Workbook.Save(serverPath);
  21684. string rst = $"{servicePath}{ftpPath}{fileName}";
  21685. #endregion
  21686. return Ok(JsonView(new { url = rst }));
  21687. }
  21688. #endregion
  21689. #region 三公签证费用(签证费、代办费)
  21690. /// <summary>
  21691. /// 三公签证费用(签证费、代办费)
  21692. /// List
  21693. /// </summary>
  21694. /// <returns></returns>
  21695. [HttpPost]
  21696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21697. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  21698. {
  21699. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  21700. }
  21701. /// <summary>
  21702. /// 三公签证费用(签证费、代办费)
  21703. /// Add Or Update
  21704. /// </summary>
  21705. /// <returns></returns>
  21706. [HttpPost]
  21707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21708. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  21709. {
  21710. var _view = await _visaFeeInfoRep.Update(_dto);
  21711. if (_view.Code != 0)
  21712. {
  21713. return Ok(JsonView(false, _view.Msg));
  21714. }
  21715. return Ok(JsonView(true, _view.Msg));
  21716. }
  21717. #endregion
  21718. #region 酒店询价
  21719. /// <summary>
  21720. /// 酒店询价
  21721. /// Init
  21722. /// </summary>
  21723. /// <returns></returns>
  21724. [HttpPost]
  21725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21726. public async Task<IActionResult> PostHotelInquiryInit()
  21727. {
  21728. var res = await _hotelInquiryRep._Init();
  21729. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21730. return Ok(JsonView(true, res.Msg, res.Data));
  21731. }
  21732. /// <summary>
  21733. /// 酒店询价
  21734. /// page Item
  21735. /// </summary>
  21736. /// <param name="_dto"></param>
  21737. /// <returns></returns>
  21738. [HttpPost]
  21739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21740. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  21741. {
  21742. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  21743. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21744. var view = res.Data as PageDataViewBase;
  21745. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  21746. }
  21747. /// <summary>
  21748. /// 酒店询价
  21749. /// info
  21750. /// </summary>
  21751. /// <param name="_dto"></param>
  21752. /// <returns></returns>
  21753. [HttpPost]
  21754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21755. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  21756. {
  21757. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  21758. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21759. return Ok(JsonView(true, res.Msg, res.Data));
  21760. }
  21761. /// <summary>
  21762. /// 酒店询价
  21763. /// Add Or Edit
  21764. /// </summary>
  21765. /// <param name="_dto"></param>
  21766. /// <returns></returns>
  21767. [HttpPost]
  21768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21769. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  21770. {
  21771. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  21772. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21773. return Ok(JsonView(true, res.Msg, res.Data));
  21774. }
  21775. /// <summary>
  21776. /// 酒店询价
  21777. /// Del
  21778. /// </summary>
  21779. /// <param name="_dto"></param>
  21780. /// <returns></returns>
  21781. [HttpPost]
  21782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21783. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  21784. {
  21785. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  21786. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21787. return Ok(JsonView(true, res.Msg, res.Data));
  21788. }
  21789. #endregion
  21790. #region 下载匹配op行程单
  21791. /// <summary>
  21792. /// 匹配op行程单
  21793. /// Init
  21794. /// </summary>
  21795. /// <param name="dto">团组列表请求dto</param>
  21796. /// <returns></returns>
  21797. [HttpPost]
  21798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21799. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  21800. {
  21801. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21802. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21803. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  21804. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  21805. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  21806. .Where(it => it.IsDel == 0)
  21807. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  21808. .OrderByDescending(it => it.VisitStartDate)
  21809. .ToList();
  21810. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  21811. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21812. var diids = groupInfos.Select(it => it.Id).ToList();
  21813. List<string> countrys = new List<string>();
  21814. foreach (var item in country)
  21815. {
  21816. var data = _groupRepository.FormartTeamName(item);
  21817. var dataArray = _groupRepository.GroupSplitCountry(data);
  21818. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21819. }
  21820. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  21821. List<string> areaArray = new List<string>(); //GetGroupCityLine
  21822. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  21823. foreach (var item in areaItem)
  21824. {
  21825. string areaStr = item.Value;
  21826. if (!string.IsNullOrEmpty(areaStr))
  21827. {
  21828. string[] str1 = areaStr.Split("-");
  21829. if (str1.Length > 0)
  21830. {
  21831. areaArray.AddRange(str1);
  21832. }
  21833. }
  21834. }
  21835. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  21836. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  21837. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  21838. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  21839. .ToList();
  21840. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  21841. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  21842. .Where(it => countriesIds.Contains(it.Id))
  21843. .Select(it => new { it.Id, Name = it.Name_CN })
  21844. .ToList();
  21845. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  21846. .Select(it => it.TeamName).ToList();
  21847. stopwatch.Stop();
  21848. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  21849. }
  21850. ///// <summary>
  21851. ///// 匹配op行程单
  21852. ///// Init 查询区域数据
  21853. ///// </summary>
  21854. ///// <param name="dto">团组列表请求dto</param>
  21855. ///// <returns></returns>
  21856. //[HttpPost]
  21857. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21858. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  21859. //{
  21860. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21861. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  21862. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  21863. // if (string.IsNullOrEmpty(countriesDataStr))
  21864. // {
  21865. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  21866. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  21867. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  21868. // }
  21869. // else
  21870. // {
  21871. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  21872. // }
  21873. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  21874. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  21875. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  21876. // List<dynamic> childList = new List<dynamic>();
  21877. // int parentId = dto.CountriesId;
  21878. // if (provinceData.Count > 1)
  21879. // {
  21880. // foreach (var item1 in provinceData)
  21881. // {
  21882. // List<dynamic> childList1 = new List<dynamic>();
  21883. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  21884. // foreach (var item2 in citiesData1)
  21885. // {
  21886. // List<dynamic> childList2 = new List<dynamic>();
  21887. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21888. // foreach (var item3 in countiesData1)
  21889. // {
  21890. // childList2.Add(new
  21891. // {
  21892. // id = item3.Id,
  21893. // parentId = item2.Id,
  21894. // level = "district",
  21895. // name = item3.Name_CN,
  21896. // });
  21897. // }
  21898. // childList1.Add(new
  21899. // {
  21900. // id = item2.Id,
  21901. // parentId = item1.Id,
  21902. // level = "city",
  21903. // name = item2.Name_CN,
  21904. // childList = childList2
  21905. // });
  21906. // }
  21907. // childList.Add(new
  21908. // {
  21909. // id = item1.Id,
  21910. // parentId = parentId,
  21911. // level = "province",
  21912. // name = item1.Name_CN,
  21913. // childList = childList1
  21914. // });
  21915. // }
  21916. // //城市
  21917. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  21918. // foreach (var item2 in citiesData2)
  21919. // {
  21920. // List<dynamic> childList22 = new List<dynamic>();
  21921. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21922. // foreach (var item3 in countiesData1)
  21923. // {
  21924. // childList22.Add(new
  21925. // {
  21926. // id = item3.Id,
  21927. // parentId = item2.Id,
  21928. // level = "district",
  21929. // name = item3.Name_CN,
  21930. // });
  21931. // }
  21932. // childList.Add(new
  21933. // {
  21934. // id = item2.Id,
  21935. // parentId = parentId,
  21936. // level = "city",
  21937. // name = item2.Name_CN,
  21938. // childList = childList22
  21939. // });
  21940. // }
  21941. // }
  21942. // else
  21943. // {
  21944. // foreach (var item2 in citiesData)
  21945. // {
  21946. // string cname = item2.Name_CN;
  21947. // List<dynamic> childList1 = new List<dynamic>();
  21948. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21949. // foreach (var item3 in countiesData1)
  21950. // {
  21951. // childList1.Add(new
  21952. // {
  21953. // Id = item3.Id,
  21954. // parentId = item2.Id,
  21955. // level = "district",
  21956. // name = item3.Name_CN
  21957. // });
  21958. // }
  21959. // childList.Add(new
  21960. // {
  21961. // id = item2.Id,
  21962. // parentId = parentId,
  21963. // level = "city",
  21964. // name = item2.Name_CN,
  21965. // childList = childList1
  21966. // });
  21967. // }
  21968. // }
  21969. // stopwatch.Stop();
  21970. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  21971. //}
  21972. /// <summary>
  21973. /// 匹配op行程单
  21974. /// 接团信息列表 Page
  21975. /// </summary>
  21976. /// <param name="dto">团组列表请求dto</param>
  21977. /// <returns></returns>
  21978. [HttpPost]
  21979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21980. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  21981. {
  21982. var swatch = new Stopwatch();
  21983. swatch.Start();
  21984. #region 参数验证
  21985. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21986. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21987. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21988. #region 页面操作权限验证
  21989. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21990. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  21991. #endregion
  21992. #endregion
  21993. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21994. {
  21995. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  21996. //string sqlWhere = "";
  21997. if (!string.IsNullOrEmpty(dto.Country))
  21998. {
  21999. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  22000. }
  22001. if (!string.IsNullOrEmpty(dto.Area))
  22002. {
  22003. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  22004. }
  22005. if (!string.IsNullOrEmpty(dto.TeamName))
  22006. {
  22007. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  22008. }
  22009. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  22010. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  22011. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  22012. swatch.Stop();
  22013. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  22014. }
  22015. else
  22016. {
  22017. return Ok(JsonView(false, "查询失败"));
  22018. }
  22019. }
  22020. /// <summary>
  22021. /// 匹配op行程单
  22022. /// 行程单下载
  22023. /// </summary>
  22024. /// <param name="dto">团组列表请求dto</param>
  22025. /// <returns></returns>
  22026. [HttpPost]
  22027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22028. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  22029. {
  22030. #region 参数验证
  22031. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  22032. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  22033. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22034. #region 页面操作权限验证
  22035. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  22036. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  22037. #endregion
  22038. #endregion
  22039. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  22040. {
  22041. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  22042. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  22043. }
  22044. else
  22045. {
  22046. return Ok(JsonView(false, "下载失败!"));
  22047. }
  22048. }
  22049. #endregion
  22050. #region 国家信息 数据 注释
  22051. //[HttpPost]
  22052. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  22053. //{
  22054. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  22055. // foreach (var item in dto)
  22056. // {
  22057. // infos.Add(new Grp_GroupsTaskAssignment()
  22058. // {
  22059. // DIId = item,
  22060. // CTId = 82,
  22061. // UId = 248,
  22062. // IsEnable = 1,
  22063. // CreateUserId = 233,
  22064. // CreateTime = DateTime.Now,
  22065. // IsDel = 0
  22066. // });
  22067. // infos.Add(new Grp_GroupsTaskAssignment()
  22068. // {
  22069. // DIId = item,
  22070. // CTId = 82,
  22071. // UId = 286,
  22072. // IsEnable = 1,
  22073. // CreateUserId = 233,
  22074. // CreateTime = DateTime.Now,
  22075. // IsDel = 0
  22076. // });
  22077. // }
  22078. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  22079. // return Ok("操作成功");
  22080. //}
  22081. //public class paramJsonDto
  22082. //{
  22083. // public List<CountriesInfo> str { get; set; }
  22084. //}
  22085. //[HttpPost]
  22086. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  22087. //{
  22088. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  22089. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  22090. // List<Sys_Cities> cities = new List<Sys_Cities>();
  22091. // List<Sys_Cities> districts = new List<Sys_Cities>();
  22092. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  22093. // _sqlSugar.BeginTran();
  22094. // int countitiesIndex = 0;
  22095. // foreach (var item in dto.str)
  22096. // {
  22097. // dynamic data = item.c;
  22098. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  22099. // if (data != null)
  22100. // {
  22101. // countitiesIndex++;
  22102. // foreach (var item1 in data)
  22103. // {
  22104. // string cnname = item1.cn;
  22105. // string enname = item1.en;
  22106. // Sys_Cities provinceInfo = new Sys_Cities()
  22107. // {
  22108. // CountriesId = countriesId,
  22109. // Name_CN = cnname,
  22110. // Name_EN = enname,
  22111. // ParentId = 0,
  22112. // IsCapital = 1,
  22113. // CreateUserId = 208,
  22114. // CreateTime = DateTime.Now,
  22115. // IsDel = 0
  22116. // };
  22117. // if (item1.lv == "province") //省份
  22118. // {
  22119. // provinceInfo.Level = 1;
  22120. // int provinceId = 0;
  22121. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  22122. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  22123. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  22124. // var data1 = item1.c;
  22125. // foreach (var item2 in data1)
  22126. // {
  22127. // if (item2.lv == "city")
  22128. // {
  22129. // string citycnname = item2.cn;
  22130. // string cityenname = item2.en;
  22131. // Sys_Cities cityInfo = new Sys_Cities()
  22132. // {
  22133. // CountriesId = countriesId,
  22134. // ParentId = provinceId,
  22135. // Level = 2,
  22136. // Name_CN = citycnname,
  22137. // Name_EN = cityenname,
  22138. // IsCapital = 1,
  22139. // CreateUserId = 208,
  22140. // CreateTime = DateTime.Now,
  22141. // IsDel = 0
  22142. // };
  22143. // if (item2.c != null)
  22144. // {
  22145. // int cityId = 0;
  22146. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  22147. // if (citiesInfo != null) cityId = citiesInfo.Id;
  22148. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  22149. // foreach (var item3 in item2.c)
  22150. // {
  22151. // if (item3.lv == "district")
  22152. // {
  22153. // var districtInfo = new Sys_Cities()
  22154. // {
  22155. // CountriesId = countriesId,
  22156. // Name_CN = item3.cn,
  22157. // Name_EN = item3.en,
  22158. // Level = 3,
  22159. // ParentId = cityId,
  22160. // IsCapital = 1,
  22161. // CreateUserId = 208,
  22162. // CreateTime = DateTime.Now,
  22163. // IsDel = 0
  22164. // };
  22165. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  22166. // //{
  22167. // districts.Add(districtInfo);
  22168. // //}
  22169. // }
  22170. // }
  22171. // }
  22172. // else
  22173. // {
  22174. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  22175. // //{
  22176. // cities.Add(cityInfo);
  22177. // //}
  22178. // }
  22179. // }
  22180. // }
  22181. // }
  22182. // else if (item1.lv == "city")//城市
  22183. // {
  22184. // provinceInfo.Level = 2;
  22185. // if (item1.c != null)
  22186. // {
  22187. // int cityId = 0;
  22188. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  22189. // if (citiesInfo != null) cityId = citiesInfo.Id;
  22190. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  22191. // foreach (var item3 in item1.c)
  22192. // {
  22193. // if (item3.lv == "district")
  22194. // {
  22195. // var districtInfo = new Sys_Cities()
  22196. // {
  22197. // CountriesId = countriesId,
  22198. // Name_CN = item3.cn,
  22199. // Name_EN = item3.en,
  22200. // Level = 3,
  22201. // ParentId = cityId,
  22202. // IsCapital = 1,
  22203. // CreateUserId = 208,
  22204. // CreateTime = DateTime.Now,
  22205. // IsDel = 0
  22206. // };
  22207. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  22208. // //{
  22209. // districts.Add(districtInfo);
  22210. // //}
  22211. // }
  22212. // }
  22213. // }
  22214. // else
  22215. // {
  22216. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  22217. // //{
  22218. // cities.Add(provinceInfo);
  22219. // //}
  22220. // }
  22221. // }
  22222. // }
  22223. // }
  22224. // }
  22225. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  22226. // cities = cities.Distinct().ToList();
  22227. // districts = districts.Distinct().ToList();
  22228. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  22229. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  22230. // cities.AddRange(districts);
  22231. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  22232. // //_sqlSugar.RollbackTran();
  22233. // _sqlSugar.CommitTran();
  22234. // return Ok(JsonView(false, "操作成功!"));
  22235. //}
  22236. //[HttpPost]
  22237. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  22238. //{
  22239. // List<CountitiesInfo> infos = dto.MyProperty;
  22240. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  22241. // _sqlSugar.BeginTran();
  22242. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  22243. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  22244. // foreach (var item in infos)
  22245. // {
  22246. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  22247. // if (countryInfo != null)
  22248. // {
  22249. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  22250. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  22251. // if (cityInfo1 != null)
  22252. // {
  22253. // cityInfo1.IsCapital = 0;
  22254. // cityInfos.Add(cityInfo1);
  22255. // }
  22256. // }
  22257. // }
  22258. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  22259. // .UpdateColumns(it => it.IsCapital)
  22260. // .WhereColumns(it => it.Id)
  22261. // .ExecuteCommand();
  22262. // //_sqlSugar.RollbackTran();
  22263. // _sqlSugar.CommitTran();
  22264. // return Ok(JsonView(false, "操作成功!"));
  22265. //}
  22266. //public class CounrtiesDto
  22267. //{
  22268. // public List<CountitiesInfo> MyProperty { get; set; }
  22269. //}
  22270. //public class CountitiesInfo
  22271. //{
  22272. // /// <summary>
  22273. // /// 圣约翰
  22274. // /// </summary>
  22275. // public string capital_name_chinese { get; set; }
  22276. // /// <summary>
  22277. // ///
  22278. // /// </summary>
  22279. // public string capital_name { get; set; }
  22280. // /// <summary>
  22281. // ///
  22282. // /// </summary>
  22283. // public string country_type { get; set; }
  22284. // /// <summary>
  22285. // /// 安提瓜和巴布达
  22286. // /// </summary>
  22287. // public string country_name_chinese { get; set; }
  22288. // /// <summary>
  22289. // /// 安提瓜和巴布达
  22290. // /// </summary>
  22291. // public string country_name_chinese_short { get; set; }
  22292. // /// <summary>
  22293. // /// 安提瓜和巴布达
  22294. // /// </summary>
  22295. // public string country_name_chinese_UN { get; set; }
  22296. // /// <summary>
  22297. // ///
  22298. // /// </summary>
  22299. // public string country_name_english_abbreviation { get; set; }
  22300. // /// <summary>
  22301. // ///
  22302. // /// </summary>
  22303. // public string country_name_english_formal { get; set; }
  22304. // /// <summary>
  22305. // ///
  22306. // /// </summary>
  22307. // public string country_name_english_UN { get; set; }
  22308. // /// <summary>
  22309. // ///
  22310. // /// </summary>
  22311. // public string continent_name { get; set; }
  22312. // /// <summary>
  22313. // ///
  22314. // /// </summary>
  22315. // public string subregion_name { get; set; }
  22316. // /// <summary>
  22317. // ///
  22318. // /// </summary>
  22319. // public string country_code2 { get; set; }
  22320. // /// <summary>
  22321. // ///
  22322. // /// </summary>
  22323. // public string country_code3 { get; set; }
  22324. // /// <summary>
  22325. // ///
  22326. // /// </summary>
  22327. // public string phone_code { get; set; }
  22328. //}
  22329. //public class CountriesInfo : BasicInfo
  22330. //{
  22331. // public List<CitiesInfo> c { get; set; }
  22332. //}
  22333. //public class CitiesInfo : BasicInfo
  22334. //{
  22335. // public List<AreaInfo> c { get; set; }
  22336. //}
  22337. //public class AreaInfo : BasicInfo
  22338. //{
  22339. // public List<AreaInfo> c { get; set; }
  22340. //}
  22341. //public class BasicInfo
  22342. //{
  22343. // public string code { get; set; }
  22344. // public string cn { get; set; }
  22345. // public string lv { get; set; }
  22346. // public string en { get; set; }
  22347. //}
  22348. #endregion
  22349. #region 查看邀请方
  22350. /// <summary>
  22351. /// 查看邀请方
  22352. /// 邀请方信息 Init
  22353. /// </summary>
  22354. /// <param name="dto"></param>
  22355. /// <returns></returns>
  22356. [HttpPost]
  22357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22358. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  22359. {
  22360. string sqlWhere = string.Empty;
  22361. if (!string.IsNullOrEmpty(dto.Search))
  22362. {
  22363. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  22364. }
  22365. string sql = string.Format($@"Select
  22366. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  22367. Id,
  22368. UnitName
  22369. From Res_InvitationOfficialActivityData
  22370. Where IsDel = 0
  22371. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  22372. RefAsync<int> total = 0;
  22373. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22374. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  22375. }
  22376. /// <summary>
  22377. /// 查看邀请方
  22378. /// 国家信息 Init
  22379. /// </summary>
  22380. /// <param name="dto"></param>
  22381. /// <returns></returns>
  22382. [HttpPost]
  22383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22384. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  22385. {
  22386. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  22387. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  22388. var diids = groupInfos.Select(it => it.Id).ToList();
  22389. List<string> countrys = new List<string>();
  22390. foreach (var item in country)
  22391. {
  22392. var data = _groupRepository.FormartTeamName(item);
  22393. var dataArray = _groupRepository.GroupSplitCountry(data);
  22394. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  22395. }
  22396. countrys = countrys.Distinct().ToList();
  22397. for (int i = 0; i < countrys.Count; i++)
  22398. {
  22399. string item = countrys[i];
  22400. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  22401. {
  22402. countrys.Remove(item);
  22403. i--;
  22404. }
  22405. }
  22406. RefAsync<int> total = 0;
  22407. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  22408. .Where(it => countrys.Contains(it.Name_CN))
  22409. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  22410. .Select(it => new { id = it.Id, name = it.Name_CN })
  22411. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22412. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  22413. }
  22414. /// <summary>
  22415. /// 查看邀请方
  22416. /// 城市信息 Init
  22417. /// </summary>
  22418. /// <param name="dto"></param>
  22419. /// <returns></returns>
  22420. [HttpPost]
  22421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22422. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  22423. {
  22424. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  22425. RefAsync<int> total = 0;
  22426. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  22427. .Where(it => it.CountriesId == dto.CountiesId)
  22428. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  22429. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  22430. .Select(it => new { id = it.Id, name = it.Name_CN })
  22431. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22432. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  22433. }
  22434. /// <summary>
  22435. /// 查看邀请方
  22436. /// 团组名称 Init
  22437. /// </summary>
  22438. /// <param name="dto"></param>
  22439. /// <returns></returns>
  22440. [HttpPost]
  22441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22442. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  22443. {
  22444. var watch = new Stopwatch();
  22445. watch.Start();
  22446. RefAsync<int> total = 0;
  22447. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  22448. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  22449. .Where((oa, di) => oa.IsDel == 0)
  22450. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  22451. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  22452. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  22453. .Distinct()
  22454. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22455. watch.Stop();
  22456. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  22457. }
  22458. /// <summary>
  22459. /// 查看邀请方
  22460. /// 团组 & 邀请方信息
  22461. /// </summary>
  22462. /// <param name="dto"></param>
  22463. /// <returns></returns>
  22464. [HttpPost]
  22465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22466. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  22467. {
  22468. var watch = new Stopwatch();
  22469. watch.Start();
  22470. RefAsync<int> total = 0;
  22471. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  22472. .AS("Grp_DelegationInfo")
  22473. .Includes(x => x.InvitingInfos)
  22474. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  22475. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  22476. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  22477. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  22478. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  22479. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  22480. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22481. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  22482. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  22483. infos.ForEach(x =>
  22484. {
  22485. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  22486. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  22487. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  22488. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  22489. });
  22490. watch.Stop();
  22491. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  22492. }
  22493. #endregion
  22494. #region 报批行程
  22495. /// <summary>
  22496. /// 报批行程初始化
  22497. /// </summary>
  22498. /// <param name="dto"></param>
  22499. /// <returns></returns>
  22500. [HttpPost]
  22501. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  22502. {
  22503. const int chiNumber = 5;
  22504. var jw = JsonView(false);
  22505. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  22506. var group = groupList.First();
  22507. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  22508. group = groupList.First(x => x.Id == diid);
  22509. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  22510. .Where(x => x.DiId == diid && x.IsDel == 0)
  22511. .ToArray();
  22512. var count = 1;
  22513. foreach (var item in blackCodeList)
  22514. {
  22515. if (string.IsNullOrWhiteSpace(item.Title))
  22516. {
  22517. item.Title = "未设置名称数据" + count;
  22518. }
  22519. count++;
  22520. }
  22521. ;
  22522. if (group == null)
  22523. {
  22524. jw.Msg = "暂无团组!";
  22525. return Ok(jw);
  22526. }
  22527. var data = new
  22528. {
  22529. groupList = groupList.Select(x => new
  22530. {
  22531. x.TeamName,
  22532. x.Id
  22533. }),
  22534. content = new ArrayList(),
  22535. groupInfo = new
  22536. {
  22537. group.VisitDays,
  22538. group.TourCode,
  22539. group.VisitPNumber,
  22540. group.TeamName,
  22541. group.Id,
  22542. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  22543. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  22544. group.ClientUnit
  22545. },
  22546. blackCodeList = blackCodeList.Select(x => new
  22547. {
  22548. x.Title,
  22549. x.Id
  22550. }),
  22551. FileTempList = new ArrayList()
  22552. {
  22553. new { Index = 1,FileName = "旧模板" },
  22554. new { Index = 2,FileName = "省外办" },
  22555. new { Index = 3,FileName = "市外办" },
  22556. }
  22557. };
  22558. var resultArr = new ArrayList();
  22559. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  22560. #region 默认不生成行程
  22561. //if (content.Count == 0)
  22562. //{
  22563. // var stay = "-";
  22564. // var cityPath = "-";
  22565. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  22566. // .Where(x => x.DiId == diid && x.IsDel == 0)
  22567. // .ToList();
  22568. // //添加城市路径以及住宿地
  22569. // //黑屏代码数据
  22570. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  22571. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22572. // {
  22573. // jw = JsonView(true, "黑屏代码有误!", data);
  22574. // return Ok(jw);
  22575. // }
  22576. // data = data with
  22577. // {
  22578. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  22579. // {
  22580. // x.Title,
  22581. // x.Id,
  22582. // }).ToArray())
  22583. // };
  22584. // foreach (DataRow row in dtBlack.Rows)
  22585. // {
  22586. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22587. // {
  22588. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  22589. // return Ok(jw);
  22590. // }
  22591. // }
  22592. // //黑屏代码获取时间区间
  22593. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22594. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22595. // _sqlSugar.BeginTran();
  22596. // for (int i = 0; i < timeArr.Count; i++)
  22597. // {
  22598. // stay = "-";
  22599. // cityPath = "-";
  22600. // DateTime NewData = DateTime.Parse(timeArr[i]);
  22601. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  22602. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  22603. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22604. // if (tbSelect.Length > 0)
  22605. // {
  22606. // List<string> threeCodeStr = new List<string>();
  22607. // foreach (var item in tbSelect)
  22608. // {
  22609. // var threeCode = item["Three"].ToString() ?? "";
  22610. // if (threeCode.Length == 6)
  22611. // {
  22612. // var start = threeCode.Substring(0, 3);
  22613. // var end = threeCode.Substring(3, 3);
  22614. // if (threeCodeStr.Count == 0)
  22615. // {
  22616. // threeCodeStr.Add(start);
  22617. // threeCodeStr.Add(end);
  22618. // }
  22619. // else
  22620. // {
  22621. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22622. // {
  22623. // threeCodeStr.Add(end);
  22624. // }
  22625. // else
  22626. // {
  22627. // threeCodeStr.Add(start);
  22628. // threeCodeStr.Add(end);
  22629. // }
  22630. // }
  22631. // }
  22632. // }
  22633. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  22634. // var last = threeCodeStr.Last();
  22635. // foreach (var item in threeCodeStr)
  22636. // {
  22637. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  22638. // if (item.Equals(last))
  22639. // {
  22640. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  22641. // }
  22642. // }
  22643. // cityPath = cityPath.Trim('-');
  22644. // }
  22645. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  22646. // appro.Diid = diid ?? -1;
  22647. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  22648. // appro.Id = thisId;
  22649. // appro.CreateUserId = dto.UserId;
  22650. // appro.CreateTime = DateTime.Now;
  22651. // content.Add(appro);
  22652. // }
  22653. // _sqlSugar.CommitTran();
  22654. //}
  22655. #endregion
  22656. foreach (var x in content)
  22657. {
  22658. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  22659. if (chiList.Count < chiNumber)
  22660. {
  22661. for (int i = chiList.Count; i < chiNumber; i++)
  22662. {
  22663. chiList.Add(new Grp_ApprovalTravelDetails());
  22664. }
  22665. }
  22666. resultArr.Add(new
  22667. {
  22668. x.Id,
  22669. x.Date,
  22670. x.Diid,
  22671. chiList = chiList.Select(x1 => new
  22672. {
  22673. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22674. x1.Details,
  22675. x1.ParentId,
  22676. x1.Id
  22677. })
  22678. });
  22679. }
  22680. data = data with
  22681. {
  22682. content = resultArr,
  22683. };
  22684. jw = JsonView(true, "获取成功!", data);
  22685. return Ok(jw);
  22686. }
  22687. /// <summary>
  22688. /// 报批行程删除
  22689. /// </summary>
  22690. /// <param name="dto"></param>
  22691. /// <returns></returns>
  22692. [HttpPost]
  22693. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  22694. {
  22695. var jw = JsonView(false);
  22696. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22697. if (group == null)
  22698. {
  22699. jw.Msg = "团组参数有误!";
  22700. return Ok(jw);
  22701. }
  22702. try
  22703. {
  22704. _sqlSugar.BeginTran();
  22705. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  22706. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  22707. {
  22708. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22709. DeleteUserId = dto.uesrId,
  22710. IsDel = 1
  22711. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  22712. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  22713. {
  22714. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22715. DeleteUserId = dto.uesrId,
  22716. IsDel = 1
  22717. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  22718. _sqlSugar.CommitTran();
  22719. jw = JsonView(true, "删除成功");
  22720. }
  22721. catch (Exception ex)
  22722. {
  22723. jw = JsonView(false, ex.Message);
  22724. }
  22725. return Ok(jw);
  22726. }
  22727. /// <summary>
  22728. /// 报批行程保存
  22729. /// </summary>
  22730. /// <param name="dto"></param>
  22731. /// <returns></returns>
  22732. [HttpPost]
  22733. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  22734. {
  22735. var jw = JsonView(false);
  22736. var Find = dto.Arr.Find(x => x.id == 0);
  22737. if (Find != null)
  22738. {
  22739. jw.Msg = "生成的ID为0!";
  22740. return Ok(jw);
  22741. }
  22742. foreach (var item in dto.Arr)
  22743. {
  22744. foreach (var chi in item.chiList)
  22745. {
  22746. if (chi.parentId == 0)
  22747. {
  22748. chi.parentId = item.id;
  22749. }
  22750. }
  22751. }
  22752. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  22753. _sqlSugar.BeginTran();
  22754. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  22755. {
  22756. var parentIds = dto.Arr.Select(x => x.id).ToList();
  22757. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  22758. {
  22759. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22760. DeleteUserId = dto.UserId,
  22761. IsDel = 1
  22762. }).ExecuteCommand();
  22763. }
  22764. try
  22765. {
  22766. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  22767. {
  22768. CreateTime = DateTime.Now,
  22769. CreateUserId = dto.UserId,
  22770. Details = x.details,
  22771. ParentId = x.parentId,
  22772. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22773. Remark = "",
  22774. IsDel = 0
  22775. }).ToList()).ExecuteCommand();
  22776. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  22777. {
  22778. Id = x.id,
  22779. Details = x.details,
  22780. ParentId = x.parentId,
  22781. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22782. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  22783. {
  22784. Details = x.Details,
  22785. ParentId = x.ParentId,
  22786. Time = x.Time
  22787. }).ExecuteCommand();
  22788. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  22789. {
  22790. Id = x.id,
  22791. Date = x.date,
  22792. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  22793. {
  22794. Date = x.Date
  22795. }).ExecuteCommand();
  22796. _sqlSugar.CommitTran();
  22797. jw = JsonView(true, "保存成功!");
  22798. }
  22799. catch (Exception ex)
  22800. {
  22801. _sqlSugar.RollbackTran();
  22802. jw = JsonView(false, "保存失败!" + ex.Message);
  22803. }
  22804. return Ok(jw);
  22805. }
  22806. /// <summary>
  22807. /// 报批行程生成
  22808. /// </summary>
  22809. /// <param name="dto"></param>
  22810. /// <returns></returns>
  22811. [HttpPost]
  22812. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  22813. {
  22814. var jw = JsonView(false);
  22815. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22816. if (group == null)
  22817. {
  22818. jw.Msg = "暂无该团组!";
  22819. return Ok(jw);
  22820. }
  22821. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  22822. //黑屏代码数据
  22823. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  22824. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22825. {
  22826. jw.Msg = "黑屏代码有误!";
  22827. return Ok(jw);
  22828. }
  22829. foreach (DataRow row in dtBlack.Rows)
  22830. {
  22831. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22832. {
  22833. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  22834. return Ok(jw);
  22835. }
  22836. }
  22837. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  22838. var resultArr = new ArrayList();
  22839. //if (officialActivitiesArr.Count == 0)
  22840. //{
  22841. // jw.Msg = "暂无公务出访信息!";
  22842. // return Ok(jw);
  22843. //}
  22844. try
  22845. {
  22846. _sqlSugar.BeginTran();
  22847. DeleteApprovalJourney(new
  22848. Domain.Dtos.Groups.DeleteApprovalJourney
  22849. {
  22850. Diid = dto.Diid,
  22851. uesrId = dto.Userid
  22852. });
  22853. var stay = "-";
  22854. var cityPath = "-";
  22855. var arriveCountry = string.Empty;
  22856. //添加城市路径以及住宿地
  22857. //黑屏代码获取时间区间
  22858. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22859. var empty = "【未收入该三字码!请机票同事录入】";
  22860. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22861. #region 配置公务活动时间
  22862. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  22863. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  22864. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  22865. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  22866. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  22867. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22868. {
  22869. 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" }),
  22870. 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"}),
  22871. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22872. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  22873. };
  22874. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22875. {
  22876. 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" }),
  22877. 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"}),
  22878. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22879. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  22880. };
  22881. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  22882. {
  22883. 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" }),
  22884. 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"}),
  22885. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  22886. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  22887. };
  22888. #endregion
  22889. var nextDayNum = 0;
  22890. for (int i = 0; i < timeArr.Count; i++)
  22891. {
  22892. stay = "-";
  22893. cityPath = "-";
  22894. var chiarr = new List<Grp_ApprovalTravelDetails>();
  22895. DateTime NewData = DateTime.Parse(timeArr[i]);
  22896. //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();
  22897. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22898. if (nextDayNum > 0)
  22899. {
  22900. nextDayNum--;
  22901. }
  22902. if (tbSelect.Length > 0)
  22903. {
  22904. List<string> threeCodeStr = new List<string>();
  22905. bool isTrade = false;
  22906. string trip = string.Empty;
  22907. foreach (var item in tbSelect)
  22908. {
  22909. if (nextDayNum == 0)
  22910. {
  22911. nextDayNum = Convert.ToInt32(item["Sign"]);
  22912. }
  22913. var airStartTime = item["StartTime"].ToString() ?? "0000";
  22914. var airEndTime = item["EndTime"].ToString() ?? "0000";
  22915. var takeOffTime = DateTime.Parse(timeArr[i]);
  22916. var fallToTime = DateTime.Parse(timeArr[i]);
  22917. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  22918. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  22919. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  22920. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  22921. if (nextDayNum > 0)
  22922. {
  22923. fallToTime = fallToTime.AddDays(nextDayNum);
  22924. }
  22925. trip = string.Empty;
  22926. var start = string.Empty;
  22927. var end = string.Empty;
  22928. var threeCode = item["Three"].ToString() ?? "";
  22929. if (threeCode.Length == 6)
  22930. {
  22931. start = threeCode.Substring(0, 3);
  22932. end = threeCode.Substring(3, 3);
  22933. if (threeCodeStr.Count == 0)
  22934. {
  22935. threeCodeStr.Add(start);
  22936. threeCodeStr.Add(end);
  22937. }
  22938. else
  22939. {
  22940. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22941. {
  22942. threeCodeStr.Add(end);
  22943. }
  22944. else
  22945. {
  22946. threeCodeStr.Add(start);
  22947. threeCodeStr.Add(end);
  22948. }
  22949. }
  22950. }
  22951. //处理机票信息
  22952. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  22953. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  22954. if (start_Object == null)
  22955. {
  22956. start_Object = new Res_ThreeCode()
  22957. {
  22958. AirPort = empty,
  22959. AirPort_En = empty,
  22960. City = empty,
  22961. Country = empty,
  22962. Four = empty,
  22963. Three = empty,
  22964. };
  22965. }
  22966. if (end_Object == null)
  22967. {
  22968. end_Object = new Res_ThreeCode()
  22969. {
  22970. AirPort = empty,
  22971. AirPort_En = empty,
  22972. City = empty,
  22973. Country = empty,
  22974. Four = empty,
  22975. Three = empty,
  22976. };
  22977. }
  22978. //机型判断
  22979. string airModel = item["AirModel"].ToString();
  22980. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  22981. string flightTime = item["FlightTime"].ToString();
  22982. flightTime = ParseBlackTime(flightTime);
  22983. //航班号
  22984. string flightcode = item["Fliagtcode"].ToString();
  22985. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  22986. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  22987. if (aircompany == null)
  22988. {
  22989. aircompany = new Res_AirCompany
  22990. {
  22991. CnName = hsEmpty,
  22992. EnName = hsEmpty,
  22993. ShortCode = hsEmpty,
  22994. };
  22995. }
  22996. //航班前公务安排
  22997. if (tbSelect.First().Equals(item) && i != 0)
  22998. {
  22999. foreach (var takeoff in takeoffTimes)
  23000. {
  23001. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  23002. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  23003. {
  23004. foreach (var addTime in takeoff.Item2)
  23005. {
  23006. chiarr.Add(new Grp_ApprovalTravelDetails
  23007. {
  23008. Time = addTime,
  23009. CreateTime = DateTime.Now,
  23010. CreateUserId = dto.Userid,
  23011. ParentId = 0,
  23012. Details = "公务活动"
  23013. });
  23014. }
  23015. break;
  23016. }
  23017. }
  23018. }
  23019. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  23020. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  23021. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  23022. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  23023. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  23024. if (isTrade)
  23025. {
  23026. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  23027. trip += "(转机不出机场)。";
  23028. }
  23029. //else
  23030. //{
  23031. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  23032. //}
  23033. chiarr.Add(new Grp_ApprovalTravelDetails
  23034. {
  23035. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  23036. CreateTime = DateTime.Now,
  23037. CreateUserId = dto.Userid,
  23038. ParentId = 0,
  23039. Details = trip
  23040. });
  23041. //最后一条到达的时间安排公务
  23042. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  23043. {
  23044. bool isCheckCountry = false;
  23045. if (end_Object.Country != arriveCountry)
  23046. {
  23047. arriveCountry = end_Object.Country;
  23048. isCheckCountry = true;
  23049. }
  23050. if (nextDayNum == 0)
  23051. {
  23052. //需要入境的情况
  23053. if (isCheckCountry)
  23054. {
  23055. foreach (var fallTime in fallTimesCheckCountry)
  23056. {
  23057. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  23058. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  23059. {
  23060. foreach (var addTime in fallTime.Item2)
  23061. {
  23062. chiarr.Add(new Grp_ApprovalTravelDetails
  23063. {
  23064. Time = addTime,
  23065. CreateTime = DateTime.Now,
  23066. CreateUserId = dto.Userid,
  23067. ParentId = 0,
  23068. Details = "公务活动"
  23069. });
  23070. }
  23071. break;
  23072. }
  23073. }
  23074. }
  23075. else
  23076. {
  23077. foreach (var fallTime in fallTimesNotCheckCountry)
  23078. {
  23079. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  23080. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  23081. {
  23082. foreach (var addTime in fallTime.Item2)
  23083. {
  23084. chiarr.Add(new Grp_ApprovalTravelDetails
  23085. {
  23086. Time = addTime,
  23087. CreateTime = DateTime.Now,
  23088. CreateUserId = dto.Userid,
  23089. ParentId = 0,
  23090. Details = "公务活动"
  23091. });
  23092. }
  23093. break;
  23094. }
  23095. }
  23096. }
  23097. }
  23098. }
  23099. }
  23100. //添加乘车语句
  23101. //chiarr.Add(new Grp_ApprovalTravelDetails
  23102. //{
  23103. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  23104. // CreateTime = DateTime.Now,
  23105. // CreateUserId = dto.Userid,
  23106. // ParentId = 0,
  23107. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  23108. //});
  23109. //if (i != timeArr.Count - 1)
  23110. //{
  23111. // fallToTime = fallToTime.AddHours(2.5);
  23112. // foreach (var item in Times)
  23113. // {
  23114. // //排列公务时间
  23115. // if (fallToTime.Hour < item.Item1)
  23116. // {
  23117. // chiarr.Add(new Grp_ApprovalTravelDetails
  23118. // {
  23119. // Time = $"{item.Item2} - {item.Item3}",
  23120. // CreateTime = DateTime.Now,
  23121. // CreateUserId = dto.Userid,
  23122. // ParentId = 0,
  23123. // Details = "公务活动"
  23124. // });
  23125. // }
  23126. // }
  23127. //}
  23128. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  23129. var last = threeCodeStr.Last();
  23130. foreach (var item in threeCodeStr)
  23131. {
  23132. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  23133. if (item.Equals(last))
  23134. {
  23135. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  23136. }
  23137. }
  23138. cityPath = cityPath.Trim('-');
  23139. }
  23140. else
  23141. {
  23142. foreach (var item in Times)
  23143. {
  23144. chiarr.Add(new Grp_ApprovalTravelDetails
  23145. {
  23146. Time = $"{item.Item2} - {item.Item3}",
  23147. CreateTime = DateTime.Now,
  23148. CreateUserId = dto.Userid,
  23149. ParentId = 0,
  23150. Details = "公务活动"
  23151. });
  23152. }
  23153. }
  23154. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  23155. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  23156. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  23157. appro.Diid = dto.Diid;
  23158. appro.CreateUserId = dto.Userid;
  23159. appro.CreateTime = DateTime.Now;
  23160. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  23161. appro.Id = thisId;
  23162. //foreach (var item in gwinfo)
  23163. //{
  23164. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  23165. // chi.Details = "拜访" + item.Client;
  23166. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  23167. // {
  23168. // chi.Details += "," + item.ReqSample;
  23169. // }
  23170. // chi.ParentId = thisId;
  23171. // chi.Time = item.Time;
  23172. // chiarr.Add(chi);
  23173. //}
  23174. if (chiarr.Count < 6)
  23175. {
  23176. for (int j = chiarr.Count; j < 6; j++)
  23177. {
  23178. chiarr.Add(new
  23179. Grp_ApprovalTravelDetails());
  23180. }
  23181. }
  23182. resultArr.Add(new
  23183. {
  23184. appro.Id,
  23185. appro.Date,
  23186. appro.Diid,
  23187. chiList = chiarr.Select(x1 => new
  23188. {
  23189. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  23190. x1.Details,
  23191. x1.ParentId,
  23192. x1.Id
  23193. })
  23194. });
  23195. }
  23196. _sqlSugar.CommitTran();
  23197. jw = JsonView(true, "生成成功!", resultArr);
  23198. }
  23199. catch (Exception ex)
  23200. {
  23201. jw.Code = 400;
  23202. jw.Msg = "生成失败!" + ex.Message;
  23203. }
  23204. return Ok(jw);
  23205. }
  23206. /// <summary>
  23207. /// 报批行程word导出
  23208. /// </summary>
  23209. /// <param name="dto"></param>
  23210. /// <returns></returns>
  23211. [HttpPost]
  23212. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  23213. {
  23214. var jw = JsonView(false);
  23215. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  23216. if (group == null)
  23217. {
  23218. jw.Msg = "暂无该团组!";
  23219. return Ok(jw);
  23220. }
  23221. //模板路径
  23222. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  23223. var fileName = string.Empty;
  23224. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  23225. bool bold = false;
  23226. if (dto.FileIndex == 1)
  23227. {
  23228. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  23229. }
  23230. else if (dto.FileIndex == 2)
  23231. {
  23232. fileName = "省外办-报批.docx";
  23233. bold = false;
  23234. titleFont = "方正黑体简体";
  23235. timeFont = "Times New Roman";
  23236. contentFont = "方正仿宋_GBK";
  23237. }
  23238. else if (dto.FileIndex == 3)
  23239. {
  23240. fileName = "市外办-报批.docx";
  23241. titleFont = "方正黑体简体";
  23242. timeFont = "Times New Roman";
  23243. contentFont = "方正仿宋简体";
  23244. }
  23245. tempPath = tempPath + fileName;
  23246. //载入模板
  23247. Document doc = new Document(tempPath);
  23248. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  23249. //获取所填表格的序数
  23250. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  23251. Aspose.Words.Tables.Row titleRowClone = null;
  23252. Aspose.Words.Tables.Row CenterRowClone = null;
  23253. int index = 0;
  23254. int indexChi = 0;
  23255. int SetIndex = 0;
  23256. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  23257. //获取数据,放到datatable
  23258. foreach (var item in ApprovalTravelArr)
  23259. {
  23260. if (index > 0)
  23261. {
  23262. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  23263. tableOne.AppendChild(titleRowClone);
  23264. }
  23265. var textTime = item.Date;
  23266. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  23267. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  23268. SetIndex++;
  23269. if (ChiRep.Count > 0)
  23270. {
  23271. foreach (var itemChi in ChiRep)
  23272. {
  23273. var txtTime = itemChi.Time;
  23274. var txtDetail = itemChi.Details;
  23275. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  23276. {
  23277. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  23278. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  23279. //indexChi++;
  23280. //SetIndex++;
  23281. break;
  23282. }
  23283. if (indexChi > 0)
  23284. {
  23285. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  23286. tableOne.AppendChild(CenterRowClone);
  23287. }
  23288. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  23289. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  23290. indexChi++;
  23291. SetIndex++;
  23292. }
  23293. }
  23294. //else
  23295. //{
  23296. // if (indexChi > 0)
  23297. // {
  23298. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  23299. // tableOne.AppendChild(CenterRowClone);
  23300. // }
  23301. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  23302. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  23303. // indexChi++;
  23304. // SetIndex++;
  23305. //}
  23306. index++;
  23307. }
  23308. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  23309. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  23310. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  23311. jw.Code = 200;
  23312. jw.Msg = "";
  23313. return Ok(jw);
  23314. }
  23315. private string ParseBlackTime(string time)
  23316. {
  23317. // 匹配可能只有分钟的情况
  23318. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  23319. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  23320. if (match.Success)
  23321. {
  23322. string hours = match.Groups[1].Value;
  23323. string minutes = match.Groups[2].Value;
  23324. // 如果小时部分为空,则只显示分钟
  23325. if (string.IsNullOrEmpty(hours))
  23326. {
  23327. return $"{minutes}分钟";
  23328. }
  23329. // 如果分钟部分为空,则只显示小时
  23330. else if (string.IsNullOrEmpty(minutes))
  23331. {
  23332. return $"{hours}小时";
  23333. }
  23334. // 否则显示完整格式
  23335. else
  23336. {
  23337. return $"{hours}小时{minutes}分钟";
  23338. }
  23339. }
  23340. else
  23341. {
  23342. return "未知时长";
  23343. }
  23344. }
  23345. private string intToString(int numberVal)
  23346. {
  23347. string numberval = numberVal.ToString();
  23348. Dictionary<char, string> Number = new Dictionary<char, string>();
  23349. Number.Add('1', "一");
  23350. Number.Add('2', "二");
  23351. Number.Add('3', "三");
  23352. Number.Add('4', "四");
  23353. Number.Add('5', "五");
  23354. Number.Add('6', "六");
  23355. Number.Add('7', "七");
  23356. Number.Add('8', "八");
  23357. Number.Add('9', "九");
  23358. string stringNumberVal = string.Empty;
  23359. for (int i = 0; i < numberval.Length; i++)
  23360. {
  23361. if (i == 0)
  23362. {
  23363. stringNumberVal += Number[numberval[i]];
  23364. }
  23365. else if (i >= 1)
  23366. {
  23367. if (numberval[i] == '0')
  23368. {
  23369. stringNumberVal = "十";
  23370. }
  23371. else
  23372. {
  23373. stringNumberVal += "十" + Number[numberval[i]];
  23374. }
  23375. }
  23376. }
  23377. return stringNumberVal;
  23378. }
  23379. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  23380. {
  23381. //获取table中的某个单元格,从0开始
  23382. Cell lshCell = table.Rows[rows].Cells[cells];
  23383. //将单元格中段落移除
  23384. foreach (Paragraph item in lshCell.Paragraphs)
  23385. {
  23386. lshCell.Paragraphs.Remove(item);
  23387. }
  23388. if (val.Contains("\r\n"))
  23389. {
  23390. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  23391. foreach (var item in spArr)
  23392. {
  23393. //新建一个段落
  23394. Paragraph p = new Paragraph(doc);
  23395. var r = new Run(doc, item);
  23396. //设置字体
  23397. if (!string.IsNullOrEmpty(font))
  23398. {
  23399. r.Font.Name = font;
  23400. }
  23401. r.Font.Bold = bold;
  23402. //把设置的值赋给之前新建的段落
  23403. p.AppendChild(r);
  23404. //将此段落加到单元格内
  23405. lshCell.AppendChild(p);
  23406. }
  23407. }
  23408. else
  23409. {
  23410. //新建一个段落
  23411. Paragraph p = new Paragraph(doc);
  23412. var r = new Run(doc, val);
  23413. //设置字体
  23414. if (!string.IsNullOrEmpty(font))
  23415. {
  23416. r.Font.Name = font;
  23417. }
  23418. r.Font.Bold = bold;
  23419. //把设置的值赋给之前新建的段落
  23420. p.AppendChild(r);
  23421. //将此段落加到单元格内
  23422. lshCell.AppendChild(p);
  23423. }
  23424. }
  23425. /// <summary>
  23426. /// 报批行程AI续写
  23427. /// </summary>
  23428. /// <returns></returns>
  23429. [HttpPost]
  23430. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  23431. {
  23432. var jw = JsonView(false);
  23433. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  23434. {
  23435. jw.Msg = "参数有误!";
  23436. return Ok(jw);
  23437. }
  23438. KiMiApiClient kiMi = new KiMiApiClient();
  23439. List<SeedMessages> messages = new List<SeedMessages>() {
  23440. new SeedMessages
  23441. {
  23442. Role = KimiRole.system,
  23443. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  23444. },
  23445. new SeedMessages
  23446. {
  23447. Role = KimiRole.user,
  23448. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  23449. }
  23450. };
  23451. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  23452. string data = kimi_result.Choices[0]?.Message.Content;
  23453. if (string.IsNullOrWhiteSpace(data))
  23454. {
  23455. jw.Data = "Ai续写失败!";
  23456. }
  23457. else
  23458. {
  23459. jw = JsonView(true, "success!", data);
  23460. }
  23461. return Ok(jw);
  23462. }
  23463. #endregion
  23464. #region 团组接待意见调查
  23465. /// <summary>
  23466. /// 团组接待意见调查 - 信息管理
  23467. /// 基础数据(团组)
  23468. /// </summary>
  23469. /// <returns></returns>
  23470. [HttpGet]
  23471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23472. public async Task<IActionResult> OpinionaireInit()
  23473. {
  23474. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  23475. .Select(x => new
  23476. {
  23477. x.Id,
  23478. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  23479. })
  23480. .OrderByDescending(x => x.Id)
  23481. .ToListAsync();
  23482. return Ok(JsonView(groupData, groupData.Count));
  23483. }
  23484. /// <summary>
  23485. /// 团组接待意见调查 - 信息管理
  23486. /// 列表
  23487. /// </summary>
  23488. /// <param name="groupId"></param>
  23489. /// <returns></returns>
  23490. [HttpGet("{groupId}")]
  23491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23492. public async Task<IActionResult> OpinionaireManageList(int groupId)
  23493. {
  23494. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23495. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  23496. .Select(x => new
  23497. {
  23498. x.Id,
  23499. x.TourGuideName,
  23500. x.CityName,
  23501. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  23502. x.CreateTime
  23503. })
  23504. .OrderBy(x => x.Id)
  23505. .ToListAsync();
  23506. return Ok(JsonView(data));
  23507. }
  23508. /// <summary>
  23509. /// 团组接待意见调查 - 信息管理
  23510. /// 保存
  23511. /// </summary>
  23512. /// <param name="dto"></param>
  23513. /// <returns></returns>
  23514. [HttpPost]
  23515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23516. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  23517. {
  23518. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  23519. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  23520. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23521. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  23522. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  23523. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  23524. _opinionaireRep.BeginTran();
  23525. if (addData != null && addData.Count > 0)
  23526. {
  23527. foreach (var item in addData)
  23528. {
  23529. item.CreateUserId = currUserInfo.UserId;
  23530. item.DiId = dto.DiId;
  23531. }
  23532. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  23533. }
  23534. if (updData != null && updData.Count > 0)
  23535. {
  23536. var upd = await _opinionaireRep._sqlSugar
  23537. .Updateable(updData)
  23538. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  23539. .WhereColumns(x => new { x.Id })
  23540. .ExecuteCommandAsync();
  23541. }
  23542. _opinionaireRep.CommitTran();
  23543. return Ok(JsonView("操作成功!"));
  23544. }
  23545. /// <summary>
  23546. /// 团组接待意见调查 - 信息管理
  23547. /// 删除
  23548. /// </summary>
  23549. /// <param name="id"></param>
  23550. /// <returns></returns>
  23551. [HttpDelete("{id}")]
  23552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23553. public async Task<IActionResult> OpinionaireManageDel(int id)
  23554. {
  23555. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  23556. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  23557. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  23558. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  23559. if (!del) return Ok(JsonView("操作失败!"));
  23560. return Ok(JsonView("操作成功!"));
  23561. }
  23562. /// <summary>
  23563. /// 团组接待意见调查 - 用户
  23564. /// 列表
  23565. /// </summary>
  23566. /// <param name="diId"></param>
  23567. /// <returns></returns>
  23568. [HttpGet("{diId}")]
  23569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23570. public async Task<IActionResult> OpinionaireUserList(int diId)
  23571. {
  23572. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23573. var sql = string.Format(@"
  23574. SELECT
  23575. o.Id,
  23576. o.DiId,
  23577. di.TeamName AS 'GroupName',
  23578. di.VisitPNumber AS 'PeopleNumber',
  23579. di.ClientName AS 'LeadGroup',
  23580. di.VisitCountry AS 'Travel',
  23581. di.VisitDays AS 'Days',
  23582. o.CityName,
  23583. o.TourGuideName,
  23584. o.Catering,
  23585. o.CateringReason,
  23586. o.Stay,
  23587. o.StayReason,
  23588. o.[Route],
  23589. o.RouteReason,
  23590. o.OfficialActivity,
  23591. o.OfficialActivityReason,
  23592. o.TourGuide,
  23593. o.TourGuideReason,
  23594. o.[Translate],
  23595. o.TranslateReason,
  23596. o.Trip,
  23597. o.TripReason,
  23598. o.ESFileName,
  23599. o.SignatureDate,
  23600. o.Remark
  23601. FROM
  23602. Grp_Opinionaire o
  23603. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  23604. WHERE
  23605. o.IsDel = 0
  23606. AND o.DiId = {0}
  23607. ORDER BY
  23608. o.Id ASC", diId);
  23609. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  23610. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  23611. return Ok(JsonView(data));
  23612. }
  23613. /// <summary>
  23614. /// 团组接待意见调查 - 用户
  23615. /// 保存
  23616. /// </summary>
  23617. /// <param name="dto"></param>
  23618. /// <returns></returns>
  23619. [HttpPost]
  23620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23621. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  23622. {
  23623. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  23624. foreach (var item in dto)
  23625. {
  23626. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  23627. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  23628. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  23629. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  23630. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  23631. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  23632. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  23633. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  23634. }
  23635. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  23636. if (!Directory.Exists(filePathBase))
  23637. {
  23638. Directory.CreateDirectory(filePathBase);
  23639. }
  23640. #region 上传文件
  23641. var filePaths = new List<string>();
  23642. foreach (var item in dto)
  23643. {
  23644. var file = item.File;
  23645. // 将文件保存到指定位置
  23646. var filePath = Path.Combine(filePathBase, file.FileName);
  23647. using (var stream = new FileStream(filePath, FileMode.Create))
  23648. {
  23649. await file.CopyToAsync(stream);
  23650. }
  23651. //验证文件是否上传成功
  23652. if (!System.IO.File.Exists(filePath))
  23653. {
  23654. foreach (var filePathStr in filePaths)
  23655. {
  23656. System.IO.File.Delete(filePathStr);
  23657. }
  23658. return Ok(JsonView(false, "文件上传失败!"));
  23659. }
  23660. item.ESFileName = file.FileName;
  23661. }
  23662. #endregion
  23663. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  23664. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  23665. .UpdateColumns(x => new
  23666. {
  23667. x.Catering,
  23668. x.CateringReason,
  23669. x.Stay,
  23670. x.StayReason,
  23671. x.Route,
  23672. x.RouteReason,
  23673. x.OfficialActivity,
  23674. x.OfficialActivityReason,
  23675. x.TourGuide,
  23676. x.TourGuideReason,
  23677. x.Translate,
  23678. x.TranslateReason,
  23679. x.Trip,
  23680. x.TripReason,
  23681. x.ESFileName,
  23682. x.SignatureDate,
  23683. x.Remark
  23684. })
  23685. .WhereColumns(x => new { x.Id })
  23686. .ExecuteCommandAsync();
  23687. if (upd < 1)
  23688. {
  23689. foreach (var filePathStr in filePaths)
  23690. {
  23691. System.IO.File.Delete(filePathStr);
  23692. }
  23693. return Ok(JsonView(false));
  23694. }
  23695. return Ok(JsonView(true));
  23696. }
  23697. #endregion
  23698. #region 团组餐厅相关信息
  23699. /// <summary>
  23700. /// 团组相关餐厅信息
  23701. /// 基础数据(团组)
  23702. /// </summary>
  23703. /// <returns></returns>
  23704. [HttpGet]
  23705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23706. public async Task<IActionResult> RestaurantInit()
  23707. {
  23708. return Ok(await _restaurantRep.InitAsync());
  23709. }
  23710. /// <summary>
  23711. /// 团组相关餐厅信息
  23712. /// Item
  23713. /// </summary>
  23714. /// <param name="dto"></param>
  23715. /// <returns></returns>
  23716. [HttpPost]
  23717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23718. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  23719. {
  23720. int portType = dto.PortType,
  23721. groupId = dto.GroupId;
  23722. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23723. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23724. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  23725. }
  23726. /// <summary>
  23727. /// 团组相关餐厅信息
  23728. /// List
  23729. /// </summary>
  23730. /// <param name="dto"></param>
  23731. /// <returns></returns>
  23732. [HttpPost]
  23733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23734. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  23735. {
  23736. int portType = dto.PortType,
  23737. groupId = dto.GroupId;
  23738. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23739. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23740. var sql = string.Format(@" SELECT
  23741. ri.Id,
  23742. ri.GroupId,
  23743. ri.Date,
  23744. ri.StartTime,
  23745. ri.EndTime,
  23746. CASE WHEN ri.Type = 1 THEN '早餐'
  23747. WHEN ri.Type = 2 THEN '午餐'
  23748. WHEN ri.Type = 3 THEN '晚餐'
  23749. ELSE '其他'
  23750. END AS 'Type',
  23751. ri.Name,
  23752. ri.Address,
  23753. ri.Tel,
  23754. ri.Remark,
  23755. ri.CreateTime,
  23756. u.CnName AS CreateUserName
  23757. FROM
  23758. Grp_RestaurantInfo ri
  23759. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  23760. WHERE
  23761. ri.IsDel = 0
  23762. AND ri.GroupId = {0}
  23763. ORDER BY
  23764. ri.Date ASC
  23765. ", groupId);
  23766. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  23767. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  23768. return Ok(JsonView(infos));
  23769. }
  23770. /// <summary>
  23771. /// 团组相关餐厅信息
  23772. /// Info
  23773. /// </summary>
  23774. /// <param name="dto"></param>
  23775. /// <returns></returns>
  23776. [HttpPost]
  23777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23778. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  23779. {
  23780. int portType = dto.PortType,
  23781. id = dto.Id;
  23782. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23783. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23784. return Ok(await _restaurantRep.InfoAsync(portType, id));
  23785. }
  23786. /// <summary>
  23787. /// 团组相关餐厅信息
  23788. /// Op
  23789. /// </summary>
  23790. /// <param name="dto"></param>
  23791. /// <returns></returns>
  23792. [HttpPost]
  23793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23794. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  23795. {
  23796. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23797. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23798. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  23799. return Ok(await _restaurantRep.OpAsync(dto));
  23800. }
  23801. /// <summary>
  23802. /// 团组相关餐厅信息
  23803. /// Del
  23804. /// </summary>
  23805. /// <param name="dto"></param>
  23806. /// <returns></returns>
  23807. [HttpPost]
  23808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23809. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  23810. {
  23811. int userId = dto.DeleteUserId;
  23812. var id = dto.Id;
  23813. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23814. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23815. return Ok(await _restaurantRep.DelAsync(dto));
  23816. }
  23817. #endregion
  23818. #region 团组会务成本
  23819. /// <summary>
  23820. /// 团组会务成本数据初始化
  23821. /// </summary>
  23822. /// <returns></returns>
  23823. [HttpPost]
  23824. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  23825. {
  23826. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23827. .OrderByDescending(x => x.CreateTime)
  23828. .Where(x => x.IsDel == 0)
  23829. .Select<DelegationEasyView>();
  23830. DelegationEasyView di = Dto.GroupId == 0 ?
  23831. expr.First() :
  23832. expr.First(x => x.Id == Dto.GroupId);
  23833. if (di == null)
  23834. {
  23835. return Ok(JsonView(false, "团组信息不存在!"));
  23836. }
  23837. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  23838. .Where(x => x.IsDel == 0 && x.STid == 21)
  23839. .Select(x => new { x.Id, Text = x.Name })
  23840. .ToListAsync();
  23841. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  23842. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  23843. .Select(x => x.Id)
  23844. .ToList();
  23845. //仅检索会务团组
  23846. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  23847. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  23848. .OrderByDescending(x => x.VisitDate)
  23849. .Select(x => new { x.Id, x.TeamName })
  23850. .ToListAsync();
  23851. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  23852. var userList = await _sqlSugar.Queryable<Sys_Users>()
  23853. .Where(x => x.IsDel == 0)
  23854. .Select(x => new { x.Id, x.CnName })
  23855. .ToListAsync();
  23856. var units = await _sqlSugar.Queryable<Sys_SetData>()
  23857. .Where(x => x.IsDel == 0 && x.STid == 119)
  23858. .Select(x => new { x.Id, Text = x.Name })
  23859. .ToListAsync();
  23860. var FileType = new[]
  23861. {
  23862. new { Id = 0 , Name = "成本下载" },
  23863. new { Id = 1 , Name = "报价下载" },
  23864. new { Id = 2 , Name = "总表下载" },
  23865. };
  23866. var GM = new List<int>();
  23867. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  23868. try
  23869. {
  23870. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  23871. }
  23872. catch (Exception ex)
  23873. {
  23874. GM = new List<int>() { 21 };
  23875. }
  23876. var isReview = Dto.UserId == 21;
  23877. var isGM = GM.Contains(Dto.UserId);
  23878. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23879. .Where(x => x.IsDel == 0)
  23880. .Select<ConferenceAffairsCostView>()
  23881. .First(x => x.Diid == di.Id);
  23882. if (ConferenceAffairsCost == null)
  23883. {
  23884. ConferenceAffairsCost = new ConferenceAffairsCostView();
  23885. ConferenceAffairsCost.Diid = di.Id;
  23886. }
  23887. #region 权限校验
  23888. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  23889. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  23890. .Select(x => x.UserId)
  23891. .Distinct()
  23892. .ToList();
  23893. if (!ids.Contains(Dto.UserId) && !isGM)
  23894. {
  23895. return Ok(JsonView(201, "暂无权限!", new
  23896. {
  23897. typeData,
  23898. groupList,
  23899. currenyList,
  23900. isGM,
  23901. userList,
  23902. units,
  23903. isReview,
  23904. operatorUser = ids,
  23905. di,
  23906. FileType
  23907. }));
  23908. }
  23909. #endregion
  23910. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  23911. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  23912. .Select<ConferenceAffairsCostChildView>()
  23913. .OrderBy(x => x.Index)
  23914. .ToList();
  23915. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  23916. {
  23917. ConferenceAffairsCostChi[i - 1].Index = i;
  23918. }
  23919. var backData = new
  23920. {
  23921. ConferenceAffairsCost,
  23922. ConferenceAffairsCostChi,
  23923. typeData,
  23924. groupList,
  23925. currenyList,
  23926. isGM,
  23927. userList,
  23928. units,
  23929. isReview,
  23930. operatorUser = ids,
  23931. di,
  23932. FileType
  23933. };
  23934. return Ok(JsonView(true, "SUCCESS", backData));
  23935. }
  23936. /// <summary>
  23937. /// 会务成本保存
  23938. /// </summary>
  23939. /// <returns></returns>
  23940. [HttpPost]
  23941. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  23942. {
  23943. _sqlSugar.BeginTran();
  23944. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  23945. var childResult = new
  23946. {
  23947. success = 0,
  23948. error = 0
  23949. };
  23950. try
  23951. {
  23952. if (data.Id == 0)
  23953. {
  23954. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23955. .Where(x => x.Diid == Dto.GroupId)
  23956. .SetColumns(x => new Grp_ConferenceAffairsCost
  23957. {
  23958. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23959. DeleteUserId = Dto.UserId
  23960. })
  23961. .ExecuteCommand();
  23962. data.Diid = Dto.GroupId;
  23963. data.CreateTime = DateTime.Now;
  23964. data.CreateUserId = Dto.UserId;
  23965. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  23966. .ExecuteReturnIdentity();
  23967. }
  23968. else
  23969. {
  23970. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  23971. .ExecuteCommand();
  23972. data.Id = data.Id;
  23973. }
  23974. if (Dto.ConferenceAffairsCostChild.Any())
  23975. {
  23976. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  23977. var insertArr = datas.Where(x => x.Id == 0).ToList();
  23978. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  23979. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  23980. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  23981. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  23982. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  23983. .IgnoreColumns(x => new { x.ConferenceAffairsCostId })
  23984. .ExecuteCommand() : 0;
  23985. childResult = childResult with
  23986. {
  23987. error = notUpdateArr.Count(),
  23988. success = inrsetCount + updateCount
  23989. };
  23990. }
  23991. _sqlSugar.CommitTran();
  23992. }
  23993. catch (Exception ex)
  23994. {
  23995. _sqlSugar.RollbackTran();
  23996. return Ok(JsonView(false, "失败!" + ex.Message));
  23997. }
  23998. return Ok(JsonView(true, "操作成功!", childResult));
  23999. }
  24000. [HttpPost]
  24001. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  24002. {
  24003. var count = 0;
  24004. if (Dto.ConferenceAffairsCostChildids.Any())
  24005. {
  24006. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  24007. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  24008. SetColumns(x => new Grp_ConferenceAffairsCostChild
  24009. {
  24010. ReviewStatus = Dto.ReviewStatus
  24011. }).
  24012. ExecuteCommand();
  24013. }
  24014. return Ok(JsonView(true, "操作成功!", count));
  24015. }
  24016. /// <summary>
  24017. /// 会务成本所有数据清除
  24018. /// </summary>
  24019. /// <param name="Dto"></param>
  24020. /// <returns></returns>
  24021. [HttpPost]
  24022. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  24023. {
  24024. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  24025. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  24026. _sqlSugar.BeginTran();
  24027. try
  24028. {
  24029. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  24030. .Where(x => x.Diid == Dto.GroupId)
  24031. .SetColumns(x => new Grp_ConferenceAffairsCost
  24032. {
  24033. IsDel = 1,
  24034. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24035. DeleteUserId = Dto.UserId
  24036. })
  24037. .ExecuteCommand();
  24038. if (delCount > 0)
  24039. {
  24040. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  24041. .Where(x => x.Diid == Dto.GroupId)
  24042. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  24043. {
  24044. IsDel = 1,
  24045. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24046. DeleteUserId = Dto.UserId
  24047. })
  24048. .ExecuteCommand();
  24049. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  24050. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  24051. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  24052. {
  24053. IsDel = 1,
  24054. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24055. DeleteUserId = Dto.UserId
  24056. })
  24057. .ExecuteCommand();
  24058. }
  24059. _sqlSugar.CommitTran();
  24060. }
  24061. catch (Exception ex)
  24062. {
  24063. _sqlSugar.RollbackTran();
  24064. return Ok(JsonView(false, "操作失败!" + ex.Message));
  24065. }
  24066. return Ok(JsonView(true, "操作成功!"));
  24067. }
  24068. /// <summary>
  24069. /// 子项数据删除
  24070. /// </summary>
  24071. /// <param name="Dto"></param>
  24072. /// <returns></returns>
  24073. [HttpPost]
  24074. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  24075. {
  24076. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  24077. .Any(x => x.ReviewStatus == 1);
  24078. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  24079. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  24080. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  24081. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  24082. {
  24083. IsDel = 1,
  24084. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24085. DeleteUserId = Dto.UserId
  24086. })
  24087. .ExecuteCommand();
  24088. return Ok(JsonView(true, "SUCCESS!", count));
  24089. }
  24090. /// <summary>
  24091. /// 会务成本权限分配
  24092. /// </summary>
  24093. /// <param name="Dto"></param>
  24094. /// <returns></returns>
  24095. [HttpPost]
  24096. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  24097. {
  24098. _sqlSugar.BeginTran();
  24099. var count = 0;
  24100. try
  24101. {
  24102. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  24103. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  24104. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  24105. {
  24106. IsDel = 1,
  24107. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24108. DeleteUserId = Dto.CreateUserId
  24109. })
  24110. .ExecuteCommand();
  24111. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  24112. {
  24113. CreateTime = DateTime.Now,
  24114. CreateUserId = Dto.CreateUserId,
  24115. UserId = x,
  24116. Diid = Dto.GroupId,
  24117. }).ToList()).ExecuteCommand();
  24118. _sqlSugar.CommitTran();
  24119. }
  24120. catch (Exception ex)
  24121. {
  24122. _sqlSugar.RollbackTran();
  24123. return Ok(JsonView(false, "操作失败!" + ex.Message));
  24124. }
  24125. return Ok(JsonView(true, "操作成功!", count));
  24126. }
  24127. /// <summary>
  24128. /// 团组会务成本文件下载
  24129. /// </summary>
  24130. /// <returns></returns>
  24131. [HttpPost]
  24132. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  24133. {
  24134. var FileType = new[]
  24135. {
  24136. new { Id = 0 , Name = "成本下载" },
  24137. new { Id = 1 , Name = "报价下载" },
  24138. new { Id = 2 , Name = "总表下载" },
  24139. };
  24140. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  24141. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  24142. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  24143. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  24144. .Select<DelegationEasyView>()
  24145. .First();
  24146. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  24147. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  24148. if (main == null)
  24149. {
  24150. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  24151. }
  24152. JsonView jw = JsonView(false);
  24153. //总表下载
  24154. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  24155. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  24156. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  24157. var field = string.Empty;
  24158. var fileTypeName = string.Empty;
  24159. field = @$"
  24160. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  24161. b.Name as PriceTypeStr ,
  24162. c.Name as CurrencyStr ,
  24163. d.Name as UnitStr ,
  24164. case a.ReviewStatus
  24165. WHEN 1 THEN '已通过'
  24166. WHEN 0 THEN '未审核'
  24167. WHEN -1 THEN '未通过'
  24168. ELSE '未审核'
  24169. END AS ReviewStatusStr
  24170. ";
  24171. if (Dto.FileTypeId == 0)
  24172. {
  24173. fileTypeName = "会务成本成本表";
  24174. loadPath += $"{fileTypeName}.xlsx";
  24175. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24176. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24177. }
  24178. else if (Dto.FileTypeId == 1)
  24179. {
  24180. fileTypeName = "会务成本报价表";
  24181. loadPath += $"{fileTypeName}.xlsx";
  24182. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24183. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24184. }
  24185. else if (Dto.FileTypeId == 2)
  24186. {
  24187. fileTypeName = "会务成本总表";
  24188. loadPath += $"{fileTypeName}.xlsx";
  24189. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24190. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24191. }
  24192. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  24193. SELECT
  24194. {field}
  24195. FROM Grp_ConferenceAffairsCostChild a
  24196. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  24197. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  24198. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  24199. WHERE a.isdel = 0
  24200. AND a.Diid = {main.Diid}
  24201. AND a.ConferenceAffairsCostId = {main.Id}
  24202. ").ToList();
  24203. var currLists = chiExcelContent.Select(x => new CurrList
  24204. {
  24205. CurrName = x.CurrencyStr,
  24206. CurrRate = x.Rate
  24207. })
  24208. .Distinct()
  24209. .ToList();
  24210. var designer = new WorkbookDesigner
  24211. {
  24212. Workbook = new Workbook(loadPath)
  24213. };
  24214. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == main.MostCurr);
  24215. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  24216. designer.SetDataSource("TeamName", di.TeamName);
  24217. designer.SetDataSource("City", main.City);
  24218. designer.SetDataSource("AllCost", main.CostAll);
  24219. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  24220. designer.SetDataSource("Curr", MostCurr.Name);
  24221. designer.SetDataSource("Curr1", MostCurr.Name);
  24222. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  24223. dt.TableName = "TB";
  24224. designer.SetDataSource(dt);
  24225. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  24226. dt1.TableName = "currTb";
  24227. designer.SetDataSource(dt1);
  24228. designer.Process();
  24229. designer.Workbook.Save(outputPath);
  24230. jw = JsonView(true, "操作成功!", new
  24231. {
  24232. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  24233. FilePath = networkPath
  24234. });
  24235. return Ok(jw);
  24236. }
  24237. [HttpPost]
  24238. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  24239. {
  24240. return Ok(JsonView(true, "SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  24241. .Select(x => x.PriceName).ToList()));
  24242. }
  24243. #endregion
  24244. #region 团组签证流程
  24245. /// <summary>
  24246. /// 团组签证流程 - 团组列表(分页)
  24247. /// </summary>
  24248. /// <returns></returns>
  24249. [HttpPost]
  24250. public async Task<IActionResult> VisaProcessGroupNames(VisaProcessGroupNamesDto dto)
  24251. {
  24252. int currUserId = dto.CurrUserId <= 0 ? 1 : dto.CurrUserId;
  24253. string groupName = dto.GroupName.Trim();
  24254. int pageIndex = dto.PageIndex <= 0 ? 1 : dto.PageIndex;
  24255. int pageSize = dto.PageSize <= 0 ? 10 : dto.PageSize;
  24256. int portType = dto.PortType;
  24257. RefAsync<int> total = 0;
  24258. var query = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>()
  24259. .InnerJoin<Grp_DelegationInfo>((x, y) => x.DIId == y.Id)
  24260. .Where((x, y) => x.IsDel == 0 && x.CTId == 80 && x.UId == currUserId);
  24261. //构建单字模糊查询
  24262. if (!string.IsNullOrEmpty(groupName))
  24263. {
  24264. var characters = groupName.ToCharArray();
  24265. foreach (var character in characters)
  24266. {
  24267. var charString = character.ToString();
  24268. query = query.Where((x, y) =>
  24269. SqlFunc.Contains(y.TeamName, charString));
  24270. }
  24271. }
  24272. var groups = await query
  24273. .OrderByDescending((x, y) => y.VisitDate)
  24274. .Select((x, y) => new
  24275. {
  24276. y.Id,
  24277. GroupName = y.TeamName,
  24278. y.VisitDate
  24279. })
  24280. .Distinct()
  24281. .ToPageListAsync(pageIndex, pageSize, total);
  24282. var msg = "SUCCESS";
  24283. if (total <= 0) msg = "暂无可操作的团组,请联系经理分配团组!";
  24284. var groups1 = groups.Select(x => new { x.Id, x.GroupName }).ToList();
  24285. return Ok(JsonView(true, msg, groups1, total));
  24286. }
  24287. /// <summary>
  24288. /// 团组签证流程 - 详情
  24289. /// </summary>
  24290. /// <returns></returns>
  24291. [HttpPost]
  24292. public async Task<IActionResult> VisaProcessInfoByGroupId(VisaProcessInfoByGroupIdDto dto)
  24293. {
  24294. var res = await _visaProcessRep.Info(dto);
  24295. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24296. return Ok(JsonView(true, res.Msg, res.Data));
  24297. }
  24298. /// <summary>
  24299. /// 团组签证流程 - 流程创建测试
  24300. /// </summary>
  24301. /// <returns></returns>
  24302. [HttpPost]
  24303. public async Task<IActionResult> VisaProcessAdd(int groupId, int currUserId)
  24304. {
  24305. return Ok(await _visaProcessRep.Create(currUserId, groupId));
  24306. }
  24307. /// <summary>
  24308. /// 团组签证流程 - 流程Top4Init 测试
  24309. /// </summary>
  24310. /// <returns></returns>
  24311. [HttpPost]
  24312. public async Task<IActionResult> VisaProcessTop4StepInit(int groupId, int currUserId)
  24313. {
  24314. return Ok(await _visaProcessRep.UpdateBatchTop4Step(groupId, currUserId));
  24315. }
  24316. /// <summary>
  24317. /// 团组签证流程 - 设置状态为已完成
  24318. /// </summary>
  24319. /// <returns></returns>
  24320. [HttpPost]
  24321. public async Task<IActionResult> VisaProcessSetCompleted(int id, int currUserId)
  24322. {
  24323. //参数验证
  24324. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == id && x.IsDel == 0).AnyAsync();
  24325. if (!stepValid) return Ok(JsonView(false, "签证流程ID无效。"));
  24326. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == currUserId && x.IsDel == 0).AnyAsync();
  24327. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24328. var res = await _visaProcessRep.SetCompleted(id, currUserId);
  24329. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24330. return Ok(JsonView(true, res.Msg));
  24331. }
  24332. /// <summary>
  24333. /// 团组签证流程 - 修改各步骤内容
  24334. /// </summary>
  24335. /// <returns></returns>
  24336. [HttpPost]
  24337. public async Task<IActionResult> VisaProcessSetContent(VisaProcessSetContent dto)
  24338. {
  24339. //参数验证
  24340. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  24341. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  24342. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  24343. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24344. if (dto.StepContents == null && dto.StepContents.Count < 1)
  24345. {
  24346. return Ok(JsonView(false, "步骤内容无效。"));
  24347. }
  24348. //各步骤值处理
  24349. object stepVal;
  24350. if (stepValid.Step == 7) stepVal = dto.StepContents;
  24351. else stepVal = dto.StepContents[0].ToString();
  24352. var stepInfo = new Grp_VisaProcessSteps
  24353. {
  24354. Id = dto.StepId,
  24355. DataType = stepValid.DataType,
  24356. TypedValue = stepVal,
  24357. LastUpdateUserId = dto.CurrUserId
  24358. };
  24359. var res = await _visaProcessRep.Update(stepInfo);
  24360. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24361. return Ok(JsonView(true, res.Msg));
  24362. }
  24363. /// <summary>
  24364. /// 团组签证流程 - 上传文件
  24365. /// </summary>
  24366. /// <returns></returns>
  24367. [HttpPost]
  24368. public async Task<IActionResult> VisaProcessUploadFiles([FromForm] VisaProcessUploadFilesDto dto)
  24369. {
  24370. //参数验证
  24371. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  24372. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  24373. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  24374. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24375. //验证文件是否存在
  24376. if (dto.Files == null || dto.Files.Count < 1) return Ok(JsonView(false, "请选择文件。"));
  24377. //验证该步骤是否可以上传文件
  24378. var uploadSteps = new List<int>() {
  24379. 5, //实际出签时间
  24380. 6, //是否需要开出境证明
  24381. 7, //是否需要办理电子入境卡手续
  24382. };
  24383. if (!uploadSteps.Contains(stepValid.Step))
  24384. {
  24385. return Ok(JsonView(false, $"该步骤不可上传附件。可上传附件步骤({string.Join("、", uploadSteps)})"));
  24386. }
  24387. //验证根目录
  24388. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  24389. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  24390. if (!System.IO.Directory.Exists(rootPath))
  24391. {
  24392. System.IO.Directory.CreateDirectory(rootPath);
  24393. }
  24394. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  24395. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24396. .Where(x => x.IsDel == 0 && x.Id == stepValid.GroupId)
  24397. .Select(x => $"{x.TeamName}({x.Id})")
  24398. .FirstAsync();
  24399. //创建团组文件夹
  24400. var groupPath = rootPath + "GrpFile/VisaProcessFiles/" + groupName;
  24401. if (!System.IO.Directory.Exists(groupPath))
  24402. {
  24403. System.IO.Directory.CreateDirectory(groupPath);
  24404. }
  24405. List<string> filePaths = new List<string>();
  24406. //保存文件
  24407. foreach (var file in dto.Files)
  24408. {
  24409. // 生成存储文件名
  24410. var fileName = CommonFun.GenerateStoredFileName($"Step{stepValid.Step}.{file.FileName.Split(".")[1]}");
  24411. var filePath = Path.Combine(groupPath, fileName);
  24412. // 保存文件到磁盘
  24413. using (var stream = new FileStream(filePath, FileMode.Create))
  24414. {
  24415. await file.CopyToAsync(stream);
  24416. }
  24417. filePaths.Add($"GrpFile/VisaProcessFiles/{groupName}/{fileName}");
  24418. }
  24419. //数据库存储
  24420. var stepInfo = new Grp_VisaProcessSteps
  24421. {
  24422. Id = dto.StepId,
  24423. TypedFileNameValue = filePaths,
  24424. LastUpdateUserId = dto.CurrUserId
  24425. };
  24426. var res = await _sqlSugar.Updateable<Grp_VisaProcessSteps>()
  24427. .SetColumns(s => new Grp_VisaProcessSteps
  24428. {
  24429. AttachUrl = stepInfo.AttachUrl,
  24430. LastUpdateUserId = dto.CurrUserId,
  24431. LastUpdateTime = DateTime.Now
  24432. })
  24433. .Where(s => s.Id == dto.StepId && s.IsDel == 0)
  24434. .ExecuteCommandAsync();
  24435. if (res < 1) Ok(JsonView(false, "文件上传失败。"));
  24436. return Ok(JsonView(true));
  24437. }
  24438. /// <summary>
  24439. /// 团组签证流程 - step 7 资料下载
  24440. /// </summary>
  24441. /// <returns></returns>
  24442. [HttpPost]
  24443. public async Task<IActionResult> VisaProcessDownload(int groupId)
  24444. {
  24445. //验证根目录
  24446. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  24447. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  24448. if (!System.IO.Directory.Exists(rootPath))
  24449. {
  24450. System.IO.Directory.CreateDirectory(rootPath);
  24451. }
  24452. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  24453. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24454. .Where(x => x.IsDel == 0 && x.Id == groupId)
  24455. .Select(x => $"{x.TeamName}({x.Id})")
  24456. .FirstAsync();
  24457. //创建团组文件夹
  24458. var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
  24459. var randomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  24460. var dirName = $"{groupName}_相关资料_{timestamp}";
  24461. var sourceDirectoryPath = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}";
  24462. var path = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}/{dirName}";
  24463. if (!System.IO.Directory.Exists(path))
  24464. {
  24465. System.IO.Directory.CreateDirectory(path);
  24466. }
  24467. //验证接团客户名单
  24468. string sql = string.Format(@"
  24469. SELECT
  24470. tcl.Id,
  24471. tcl.DiId,
  24472. tcl.IsAccompany,
  24473. temp.*,
  24474. u.CnName AS Operator,
  24475. tcl.CreateTime AS OperatingTime,
  24476. ssd.name AS ShippingSpaceType
  24477. FROM
  24478. Grp_TourClientList tcl
  24479. LEFT JOIN (
  24480. SELECT
  24481. dc.Id AS DcId,
  24482. dc.LastName,
  24483. dc.FirstName,
  24484. ccom.CompanyFullName,
  24485. dc.Job,
  24486. cc.CertNo AS IDCardNo,
  24487. dc.Sex,
  24488. dc.BirthDay
  24489. FROM
  24490. Crm_DeleClient dc
  24491. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  24492. AND ccom.IsDel = 0
  24493. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  24494. AND cc.SdId = 773
  24495. AND cc.IsDel = 0
  24496. WHERE
  24497. dc.IsDel = 0
  24498. ) temp ON temp.DcId = tcl.ClientId
  24499. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  24500. LEFT JOIN sys_setdata ssd ON ssd.isdel = 0 AND ssd.id = tcl.ShippingSpaceTypeid
  24501. WHERE
  24502. tcl.IsDel = 0
  24503. AND tcl.DiId = {0}", groupId);
  24504. var groupClientList = await _sqlSugar.SqlQueryable<TourClientInfosView>(sql).ToListAsync();
  24505. //解密
  24506. foreach (var item in groupClientList)
  24507. {
  24508. EncryptionProcessor.DecryptProperties(item);
  24509. }
  24510. if (groupClientList == null || groupClientList.Count < 1)
  24511. {
  24512. return Ok(JsonView(false, $"团组客户名单未录入客户信息,不可生成相关资料。"));
  24513. }
  24514. #region 生成文件
  24515. //酒店信息
  24516. var hotelInfos = await _sqlSugar.Queryable<Grp_HotelReservations>()
  24517. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  24518. .OrderBy(x => x.CheckInDate)
  24519. .ToListAsync();
  24520. //航班信息
  24521. var airInfos = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  24522. .Where(x => x.IsDel == 0 && x.DIId == groupId)
  24523. .OrderBy(x => x.FlightsDate)
  24524. .ToListAsync();
  24525. foreach (var clientInfo in groupClientList)
  24526. {
  24527. var clientId = clientInfo.DcId;
  24528. var guestName = $"{clientInfo.LastName}{clientInfo.FirstName}";
  24529. #region 个人信息资料
  24530. #endregion
  24531. #region 机票航班信息
  24532. var clientAirInfos = airInfos.Where(x => x.ClientName.Contains(clientId.ToString())).ToList();
  24533. if (clientAirInfos != null && clientAirInfos.Count > 0)
  24534. {
  24535. //创建表格
  24536. Document airDoc = new Document();
  24537. DocumentBuilder airBuilder = new DocumentBuilder(airDoc);
  24538. GeneralMethod.SetupDocumentStyles(airBuilder);
  24539. GeneralMethod.AddTitle(airBuilder, $"{guestName} - 机票信息");
  24540. GeneralMethod.AddAirInfoSections(airBuilder, clientAirInfos, "机票航班信息");
  24541. var airRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  24542. var airFileName = $"{guestName}_机票信息_{airRandomStr}.docx";
  24543. airDoc.Save($"{path}/{airFileName}");
  24544. }
  24545. #endregion
  24546. #region 酒店信息
  24547. var clientHotelInfos = hotelInfos.Where(x => x.GuestName.Contains(clientId.ToString())).ToList();
  24548. if (clientHotelInfos != null && clientHotelInfos.Count > 0)
  24549. {
  24550. //创建表格
  24551. Document hotelDoc = new Document();
  24552. DocumentBuilder HotelBuilder = new DocumentBuilder(hotelDoc);
  24553. GeneralMethod.SetupDocumentStyles(HotelBuilder);
  24554. GeneralMethod.AddTitle(HotelBuilder, $"{guestName} - 酒店信息");
  24555. GeneralMethod.AddHotelInfoSections(HotelBuilder, clientHotelInfos, "酒店信息");
  24556. var hotelRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  24557. var hotelFileName = $"{guestName}_酒店信息_{hotelRandomStr}.docx";
  24558. hotelDoc.Save($"{path}/{hotelFileName}");
  24559. }
  24560. #endregion
  24561. }
  24562. #endregion
  24563. //打包文件夹
  24564. var sourceDirectory = $"{sourceDirectoryPath}/{dirName}";
  24565. var zipFilePath = $"{sourceDirectoryPath}/{dirName}.zip";
  24566. if (System.IO.File.Exists(zipFilePath))
  24567. {
  24568. System.IO.File.Delete(zipFilePath);
  24569. }
  24570. ZipFile.CreateFromDirectory(sourceDirectory, zipFilePath, CompressionLevel.Fastest, false);
  24571. // 等待并验证
  24572. await Task.Delay(300); // 给系统时间完成文件操作
  24573. if (System.IO.File.Exists(zipFilePath))
  24574. {
  24575. var fileInfo = new FileInfo(zipFilePath);
  24576. var url = $"{rootRrl}GrpFile/VisaProcessFiles/{groupName}/{dirName}.zip";
  24577. return Ok(JsonView(url));
  24578. }
  24579. return Ok(JsonView(false));
  24580. }
  24581. #endregion
  24582. #region 团组总览进程
  24583. /// <summary>
  24584. /// 团组总览进程 - 流程创建测试
  24585. /// </summary>
  24586. /// <returns></returns>
  24587. [HttpPost]
  24588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24589. public async Task<IActionResult> GroupProcessInitTest()
  24590. {
  24591. return Ok(await _processOverviewRep.ProcessInitAsync(2732, 208));
  24592. }
  24593. /// <summary>
  24594. /// 团组总览进程 - 流程详情
  24595. /// </summary>
  24596. /// <returns></returns>
  24597. [HttpGet]
  24598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24599. public async Task<IActionResult> GroupProcessDetails(int groupId)
  24600. {
  24601. var res = await _processOverviewRep.ProcessesDetailsAsync(groupId);
  24602. if (res.Code == StatusCodes.Status200OK)
  24603. {
  24604. return Ok(JsonView(res.Data));
  24605. }
  24606. return Ok(JsonView(false, res.Msg));
  24607. }
  24608. /// <summary>
  24609. /// 团组总览进程 - 更新节点状态
  24610. /// </summary>
  24611. /// <returns></returns>
  24612. [HttpPost]
  24613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24614. public async Task<IActionResult> GroupProcessUpdateNodeStatus(GroupProcessUpdateNodeStatusDto dto)
  24615. {
  24616. var res = await _processOverviewRep.UpdateNodeStatusAsync(dto.NodeId, dto.CurrUserId);
  24617. if (res.Code == StatusCodes.Status200OK)
  24618. {
  24619. return Ok(JsonView(res.Data));
  24620. }
  24621. return Ok(JsonView(false, res.Msg));
  24622. }
  24623. /// <summary>
  24624. /// 团组总览进程 - 更新签证节点信息
  24625. /// </summary>
  24626. /// <returns></returns>
  24627. [HttpPost]
  24628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24629. public async Task<IActionResult> GroupProcessUpdateVisaNodeDetails(GroupProcessUpdateVisaNodeDetailsDto dto)
  24630. {
  24631. //验证签证信息
  24632. if (dto.VisaSubNodes.Count < 1) return Ok(JsonView(false, "请传入有效的签证节点信息。"));
  24633. var res = await _processOverviewRep.UpdateVisaNodeDetailsAsync(dto);
  24634. if (res.Code == StatusCodes.Status200OK)
  24635. {
  24636. return Ok(JsonView(res.Data));
  24637. }
  24638. return Ok(JsonView(false, res.Msg));
  24639. }
  24640. #endregion
  24641. /// <summary>
  24642. /// 123132123
  24643. /// </summary>
  24644. /// <param name="_dto"></param>
  24645. /// <returns></returns>
  24646. [HttpPost]
  24647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24648. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  24649. {
  24650. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  24651. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  24652. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  24653. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  24654. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  24655. dicDetail.Add(789, 1034);
  24656. dicDetail.Add(790, 1035);
  24657. dicDetail.Add(791, 1036);
  24658. dicDetail.Add(792, 1037);
  24659. dicDetail.Add(793, 1038);
  24660. dicDetail.Add(794, 1039);
  24661. dicDetail.Add(795, 1040);
  24662. dicDetail.Add(796, 1041);
  24663. dicDetail.Add(797, 1042);
  24664. dicDetail.Add(798, 1043);
  24665. dicDetail.Add(801, 1044);
  24666. dicDetail.Add(802, 1045);
  24667. dicDetail.Add(803, 1046);
  24668. Dictionary<int, int> dic = new Dictionary<int, int>();
  24669. dic.Add(806, 1027);
  24670. dic.Add(807, 1028);
  24671. dic.Add(808, 1029);
  24672. dic.Add(809, 1030);
  24673. dic.Add(810, 1031);
  24674. dic.Add(811, 1032);
  24675. dic.Add(812, 1033);
  24676. foreach (var item in list_visa)
  24677. {
  24678. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  24679. temp.Coefficient = item.coefficient;
  24680. DateTime dtCrt;
  24681. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  24682. if (b1)
  24683. {
  24684. temp.CreateTime = dtCrt;
  24685. }
  24686. else
  24687. {
  24688. temp.CreateTime = DateTime.Now;
  24689. }
  24690. temp.CreateUserId = item.Operators;
  24691. temp.DeleteTime = "";
  24692. temp.DeleteUserId = 0;
  24693. temp.DiId = int.Parse(item.DIID);
  24694. temp.FilePath = item.FilePath;
  24695. temp.IsDel = item.IsDel;
  24696. temp.Price = item.Price;
  24697. temp.PriceCount = 1;
  24698. temp.PriceCurrency = item.Currency;
  24699. int detailId = 0;
  24700. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  24701. {
  24702. detailId = dicDetail[item.PriceTypeDetail];
  24703. }
  24704. temp.PriceDetailType = detailId;
  24705. temp.PriceDt = DateTime.Now;
  24706. temp.PriceName = item.PriceName;
  24707. temp.PriceSum = item.Price;
  24708. int tid = 0;
  24709. if (dic.ContainsKey(item.PriceType))
  24710. {
  24711. tid = dic[item.PriceType];
  24712. }
  24713. temp.PriceType = tid;
  24714. temp.Remark = item.Remark;
  24715. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  24716. }
  24717. return Ok(JsonView(true, "操作成功!"));
  24718. }
  24719. [HttpPost]
  24720. public IActionResult TimeTest()
  24721. {
  24722. var jw = JsonView(false, "error");
  24723. _sqlSugar.BeginTran();
  24724. try
  24725. {
  24726. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  24727. .Select(x => new Crm_NewClientData
  24728. {
  24729. Id = x.Id,
  24730. Client = x.Client,
  24731. Contact = x.Contact,
  24732. Location = x.Location,
  24733. })
  24734. .ToList();
  24735. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  24736. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  24737. Stopwatch stopwatch = new Stopwatch();
  24738. // 开始计时
  24739. stopwatch.Start();
  24740. foreach (var item in clientList)
  24741. {
  24742. EncryptionProcessor.DecryptProperties(item);
  24743. }
  24744. stopwatch.Stop();
  24745. jw.Code = 200;
  24746. jw.Data = stopwatch.ElapsedMilliseconds;
  24747. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  24748. }
  24749. catch (Exception ex)
  24750. {
  24751. jw.Code = 400;
  24752. jw.Msg = ex.Message;
  24753. }
  24754. return Ok(jw);
  24755. }
  24756. [HttpPost]
  24757. public async Task<IActionResult> TimeTest1()
  24758. {
  24759. var infos = await _sqlSugar.Queryable<Crm_DeleClient>().ToListAsync();
  24760. return Ok(infos);
  24761. }
  24762. }
  24763. }