GeneralMethod.cs 320 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990
  1. 
  2. using Aspose.Cells;
  3. using Aspose.Words;
  4. using Aspose.Words.Layout;
  5. using Aspose.Words.Saving;
  6. using Aspose.Words.Tables;
  7. using Humanizer;
  8. using Microsoft.AspNetCore.SignalR;
  9. using Microsoft.International.Converters.PinYinConverter;
  10. using NodaTime;
  11. using OASystem.API.OAMethodLib.File;
  12. using OASystem.API.OAMethodLib.Hub.HubClients;
  13. using OASystem.API.OAMethodLib.Hub.Hubs;
  14. using OASystem.API.OAMethodLib.JuHeAPI;
  15. using OASystem.API.OAMethodLib.KiMiApi;
  16. using OASystem.API.OAMethodLib.SignalR.Hubs;
  17. using OASystem.Domain.AesEncryption;
  18. using OASystem.Domain.Dtos.Groups;
  19. using OASystem.Domain.Dtos.PersonnelModule;
  20. using OASystem.Domain.Entities.Customer;
  21. using OASystem.Domain.Entities.Financial;
  22. using OASystem.Domain.Entities.Groups;
  23. using OASystem.Domain.ViewModels.Financial;
  24. using OASystem.Domain.ViewModels.Groups;
  25. using OASystem.Domain.ViewModels.JuHeExchangeRate;
  26. using OASystem.Domain.ViewModels.PersonnelModule;
  27. using OASystem.Infrastructure.Repositories.CRM;
  28. using OASystem.Infrastructure.Repositories.Groups;
  29. using System.Data;
  30. using System.IdentityModel.Tokens.Jwt;
  31. using System.Security.Claims;
  32. namespace OASystem.API.OAMethodLib
  33. {
  34. public static class GeneralMethod
  35. {
  36. //团组信息
  37. private static readonly SqlSugarClient _sqlSugar = AutofacIocManager.Instance.GetService<SqlSugarClient>();
  38. private static readonly DelegationInfoRepository _dirRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
  39. private static readonly TeamRateRepository _teamRateRep = AutofacIocManager.Instance.GetService<TeamRateRepository>();
  40. private static readonly IJuHeApiService _juHeApi = AutofacIocManager.Instance.GetService<IJuHeApiService>();
  41. private static readonly SetDataRepository _setDataRep = AutofacIocManager.Instance.GetService<SetDataRepository>();
  42. private static readonly TableOperationRecordRepository _tableOperationRecordRep = AutofacIocManager.Instance.GetService<TableOperationRecordRepository>();
  43. private static readonly MessageRepository _messageRep = AutofacIocManager.Instance.GetService<MessageRepository>();
  44. private static readonly IHubContext<ChatHub, IChatClient> _hubContext = AutofacIocManager.Instance.GetService<IHubContext<ChatHub, IChatClient>>();
  45. private readonly static string[] weekdays = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  46. #region 团组操作-->团组归属部门
  47. /// <summary>
  48. /// 团组操作-->团组归属部门
  49. /// </summary>
  50. /// <returns></returns>
  51. public static async Task<List<GroupOpAffiliationBranchView>> GroupOpAffiliationBranchInit()
  52. {
  53. /*
  54. * 1.sq 和 gyy 等显示 市场部
  55. * 2.王鸽和主管及张总还有管理员号统一国交部
  56. * 2-1. 4 管理员 ,21 张海麟
  57. */
  58. //List<int> userIds = new List<int>() { 4, 21 };
  59. var userDepDatas = new List<GroupOpAffiliationBranchView>();
  60. //userDepDatas = _sqlSugar.Queryable<Sys_Users>()
  61. // .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  62. // .Where(u => u.IsDel == 0)
  63. // .Select((u, d) => new GroupOpAffiliationBranchView { value = userIds.Contains(u.Id) ? "国交部" : d.DepName, text = userIds.Contains(u.Id) ? "国交部" : d.DepName })
  64. // .ToList();
  65. //userDepDatas.Insert(0, new GroupOpAffiliationBranchView() { text = "公司", value = "公司" });
  66. userDepDatas.Insert(0, new GroupOpAffiliationBranchView() { text = "全部", value = "全部" });
  67. userDepDatas.Insert(1, new GroupOpAffiliationBranchView() { text = "国交部", value = "国交部" });
  68. userDepDatas.Insert(2, new GroupOpAffiliationBranchView() { text = "市场部", value = "市场部" });
  69. userDepDatas.Insert(3, new GroupOpAffiliationBranchView() { text = "策划部", value = "策划部" });
  70. return userDepDatas;
  71. }
  72. public class GroupOpAffiliationBranchView
  73. {
  74. public string value { get; set; }
  75. public string text { get; set; }
  76. }
  77. #endregion
  78. #region 员工注册默认添加基础页面
  79. /// <summary>
  80. /// 默认职位权限
  81. /// </summary>
  82. public static bool DefaultPostAuth(int depId, int postId, int userId, int createUserId)
  83. {
  84. if (depId < 1) return false;
  85. if (postId < 1) return false;
  86. if (userId < 1) return false;
  87. if (createUserId < 1) return false;
  88. List<DefaultPostPageAuthView> _defaultData = AppSettingsHelper.Get<DefaultPostPageAuthView>("DefaultPostPageData");
  89. if (_defaultData.Count < 1) return false;
  90. var postJobDatas = _dirRep._sqlSugar.Queryable<Sys_JobPost>().Where(it => it.IsDel == 0).ToList();
  91. List<int> pageData = new List<int>();
  92. //添加公司公共页面
  93. pageData.AddRange(_defaultData.Find(it => it.DepId == -1)?.PostPageAuths[0].PageIds ?? new List<int>());
  94. //添加部门页面
  95. var depPublicPageData = _defaultData.Find(it => it.DepId == depId);
  96. var jobPublicPageData = postJobDatas.Find(it => it.DepId == depId && it.Id == postId);
  97. if (depPublicPageData != null) //特殊部门
  98. {
  99. //公共页面
  100. pageData.AddRange(depPublicPageData.PostPageAuths.Find(it => it.PostId == -1)?.PageIds ?? new List<int>());
  101. if (depId == 7) //国交部特殊处理
  102. {
  103. List<string> postNames = new List<string>() { "主管", "经理" };
  104. //岗位页面
  105. if (jobPublicPageData != null)
  106. {
  107. if (postNames.Contains(jobPublicPageData.JobName))
  108. {
  109. pageData.AddRange(depPublicPageData.PostPageAuths.Find(it => it.PostId == 0)?.PageIds ?? new List<int>());
  110. }
  111. else
  112. {
  113. pageData.AddRange(depPublicPageData.PostPageAuths.Find(it => it.PostId == postId)?.PageIds ?? new List<int>());
  114. }
  115. }
  116. }
  117. #region 按照岗位默认分配页面 特殊处理 市场部-销售顾问
  118. var salesDefaultPages = new List<int>() {
  119. 27 , //团组操作
  120. 104, //接团客户名单
  121. 106, //倒推表
  122. 118, //出入境费用明细
  123. 168, //出入境国家三公费用标准
  124. 194, //出入境费用明细-草稿
  125. 196, //前期需求表单收集
  126. };
  127. var jobName = jobPublicPageData.JobName;
  128. if (!string.IsNullOrEmpty(jobName))
  129. {
  130. if (jobPublicPageData.JobName.Equals("销售顾问"))
  131. {
  132. pageData.AddRange(salesDefaultPages);
  133. pageData = pageData.Distinct().OrderBy(x => x).ToList();
  134. }
  135. }
  136. #endregion
  137. }
  138. else //通用部门
  139. {
  140. pageData.AddRange(_defaultData.Find(it => it.DepId == 0)?.PostPageAuths[0].PageIds ?? new List<int>());
  141. }
  142. if (pageData.Count > 0)
  143. {
  144. //页面操作权限数据(添加修改等...)
  145. var pageFunctionData = _dirRep._sqlSugar.Queryable<Sys_SystemMenuAndFunction>().Where(it => pageData.Contains(it.SmId) && it.IsDel == 0).ToList();
  146. var defaultPageData = pageFunctionData.Select(it => new Sys_UserAuthority()
  147. {
  148. UId = userId,
  149. SmId = it.SmId,
  150. FId = it.FId,
  151. CreateUserId = createUserId, //管理员
  152. CreateTime = DateTime.Now,
  153. IsDel = 0,
  154. IsTemp = 1
  155. }).ToList();
  156. if (defaultPageData.Count > 0)
  157. {
  158. //移除每个页面的审核权限,审核权限需要单独开启
  159. defaultPageData = defaultPageData.Where(it => it.FId != 12).ToList();
  160. //添加页面操作权限
  161. var s = _dirRep._sqlSugar.Fastest<Sys_UserAuthority>().PageSize(100000).BulkCopy(defaultPageData);
  162. if (s > 0)
  163. {
  164. return true;
  165. }
  166. }
  167. }
  168. return false;
  169. }
  170. #endregion
  171. #region 消息
  172. /// <summary>
  173. /// 消息 发布And 通知
  174. /// </summary>
  175. /// <param name="msgTypeEnum">
  176. /// 消息类型
  177. /// 1 公告通知
  178. /// 2 团组流程管控通知
  179. /// 3 团组业务操作通知
  180. /// 4 团组费用审核消息
  181. /// 5 团组签证进度通知
  182. /// 6 团组任务进度通知
  183. /// 7 日付申请通知
  184. /// </param>
  185. /// <param name="title">消息标题</param>
  186. /// <param name="content">消息内容</param>
  187. /// <param name="userIds"></param>
  188. /// <param name="diId">团组id</param>
  189. /// <param name="param">团组id</param>
  190. /// <returns></returns>
  191. public static async Task<bool> MessageIssueAndNotification(MessageTypeEnum msgTypeEnum, string title, string content, List<int> userIds, int diId = 0, string param = "")
  192. {
  193. MessageDto messageDto = new()
  194. {
  195. Type = msgTypeEnum,
  196. IssuerId = 4,//管理员
  197. DiId = diId,
  198. Title = title,
  199. Content = content,
  200. ReleaseTime = DateTime.Now,
  201. UIdList = userIds,
  202. Param = param
  203. };
  204. var status = await _messageRep.AddMsg(messageDto);//添加消息
  205. if (status)
  206. {
  207. //给在线在用户发送消息
  208. var connIds = UserStore.OnlineUser.Where(it => userIds.Contains(it.UserId)).Select(it => it.ConnectionId).ToList();
  209. var notificationTypeStr1 = GetMsgNotificationType(msgTypeEnum);
  210. var notificationTypeStr = JsonConvert.SerializeObject(
  211. new
  212. {
  213. UserIds = userIds,
  214. Msg = $"您有一条{notificationTypeStr1}相关的消息!"
  215. }
  216. );
  217. await _hubContext.Clients.Clients(connIds).ReceiveMessage($"您有一条{notificationTypeStr1}相关的消息!");
  218. return true;
  219. }
  220. return false;
  221. }
  222. /// <summary>
  223. /// 根据消息类型 获取 消息通知类型
  224. /// </summary>
  225. /// <returns></returns>
  226. public static string GetMsgNotificationType(MessageTypeEnum msgTypeEnum)
  227. {
  228. int notificationType = 0;
  229. string notificationStr = "";
  230. List<NotificationTypeView> notificationTypeViews = AppSettingsHelper.Get<NotificationTypeView>("MessageNotificationType");
  231. notificationType = notificationTypeViews.Where(it => it.MsgTypeIds.Contains((int)msgTypeEnum)).Select(it => it.TypeId).FirstOrDefault();
  232. if (notificationType == 1021) notificationStr = "操作";
  233. else if (notificationType == 1020) notificationStr = "任务";
  234. return notificationStr;
  235. }
  236. #endregion
  237. #region md5 加密
  238. /// <summary>
  239. /// MD5加密,和动网上的16/32位MD5加密结果相同,
  240. /// 使用的UTF8编码
  241. /// </summary>
  242. /// <param name="source">待加密字串</param>
  243. /// <param name="length">16或32值之一,其它则采用.net默认MD5加密算法</param>
  244. /// <returns>加密后的字串</returns>
  245. public static string Encrypt(string source, int length = 32)
  246. {
  247. if (string.IsNullOrWhiteSpace(source))
  248. return string.Empty;
  249. HashAlgorithm hashAlgorithm = CryptoConfig.CreateFromName("MD5") as HashAlgorithm;
  250. byte[] bytes = Encoding.UTF8.GetBytes(source);
  251. byte[] hashValue = hashAlgorithm.ComputeHash(bytes);
  252. StringBuilder sb = new StringBuilder();
  253. switch (length)
  254. {
  255. case 16://16位密文是32位密文的9到24位字符
  256. for (int i = 4; i < 12; i++)
  257. {
  258. sb.Append(hashValue[i].ToString("x2"));
  259. }
  260. break;
  261. case 32:
  262. for (int i = 0; i < 16; i++)
  263. {
  264. sb.Append(hashValue[i].ToString("x2"));
  265. }
  266. break;
  267. default:
  268. for (int i = 0; i < hashValue.Length; i++)
  269. {
  270. sb.Append(hashValue[i].ToString("x2"));
  271. }
  272. break;
  273. }
  274. return sb.ToString();
  275. }
  276. #endregion
  277. #region jwt
  278. /// <summary>
  279. /// 获取token
  280. /// </summary>
  281. /// <param name="_config"></param>
  282. /// <param name="Number"></param>
  283. /// <param name="uId"></param>
  284. /// <param name="uName"></param>
  285. /// <param name="exp"></param>
  286. /// <returns></returns>
  287. public static async Task<string> GetToken(IConfiguration _config, string Number, int uId, string uName, DateTime exp)
  288. {
  289. string userId = Guid.NewGuid().ToString().Replace("-", "");
  290. var claims = new[] {
  291. new Claim(ClaimTypes.NameIdentifier, uName),
  292. new Claim(ClaimTypes.NameIdentifier, uId.ToString()),
  293. new Claim(ClaimTypes.NameIdentifier, userId),
  294. new Claim("Number",Number)
  295. };
  296. var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["JwtSecurityKey"]));
  297. var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
  298. var token = new JwtSecurityToken(
  299. issuer: "OASystem.com",
  300. audience: "OASystem.com",
  301. claims: claims,
  302. expires: exp,
  303. signingCredentials: creds);
  304. var identity = new ClaimsIdentity(claims, "login");
  305. var principal = new ClaimsPrincipal(identity);
  306. // await _httpContext.SignInAsync (CookieAuthenticationDefaults.AuthenticationScheme, principal);
  307. return new JwtSecurityTokenHandler().WriteToken(token);
  308. }
  309. #endregion
  310. #region 数据类型转换
  311. /// <summary>
  312. /// object 转 Int
  313. /// </summary>
  314. /// <param name="obj"></param>
  315. /// <returns></returns>
  316. public static int GetInt(this object obj)
  317. {
  318. if (obj == null)
  319. return 0;
  320. var number = 0;
  321. var reslut = Int32.TryParse(obj.ToString(), out number);
  322. return number;
  323. }
  324. private static DateTime _dateStart = new DateTime(1970, 1, 1, 8, 0, 0);
  325. private static long _longTime = 621355968000000000;
  326. private static int _samllTime = 10000000;
  327. /// <summary>
  328. /// 时间戳 转 datetime
  329. /// </summary>
  330. /// <param name="timeStamp"></param>
  331. /// <returns></returns>
  332. public static DateTime GetTimeSpmpToDate(this object timeStamp)
  333. {
  334. if (timeStamp == null) return _dateStart;
  335. DateTime dateTime = new DateTime(_longTime + Convert.ToInt64(timeStamp) * _samllTime, DateTimeKind.Utc).ToLocalTime();
  336. return dateTime;
  337. }
  338. #endregion
  339. #region 用户页面操作功能 权限
  340. /// <summary>
  341. /// 用户页面操作功能(可使用)
  342. /// </summary>
  343. /// <param name="userId">用户Id</param>
  344. /// <param name="PageId">页面Id</param>
  345. /// <returns></returns>
  346. public static async Task<PageFunAuthViewBase> PostUserPageFuncDatas(int userId, int PageId)
  347. {
  348. PageFunAuthViewBase pageFunAuth = new PageFunAuthViewBase();
  349. List<UserPageFuncView> userPageFuncDatas = new List<UserPageFuncView>();
  350. string sql = string.Format(@"Select ua.UId As UserId, u.CnName As UserName, pa.ModuleId,pa.ModuleName,pa.PageId,pa.PageName,pa.PageIsEnable,
  351. pa.PagePhoneIsEnable,pa.FuncId,pa.FuncName,pa.FuncIsEnable
  352. From Sys_UserAuthority ua
  353. Left Join Sys_Users u On ua.UId = u.Id
  354. Left Join (
  355. Select sd.Id As ModuleId,sd.Name As ModuleName, smp.Id As PageId,smp.Name As PageName,smp.IsEnable As PageIsEnable,
  356. smp.phoneIsEnable As PagePhoneIsEnable,pfp.Id As FuncId,pfp.FunctionName As FuncName,pfp.IsEnable As FuncIsEnable
  357. From Sys_SystemMenuAndFunction smaf
  358. Left Join Sys_SystemMenuPermission smp On smaf.SmId = smp.Id
  359. Left Join Sys_SetData sd On sd.STid = 5 And smp.Mid = sd.Id
  360. Left Join Sys_PageFunctionPermission pfp On smaf.FId = pfp.Id
  361. Where smaf.IsDel = 0 And smp.IsDel = 0 And pfp.IsDel = 0 And sd.IsDel = 0 And smp.IsEnable = 1
  362. ) As pa On ua.SmId = pa.PageId And ua.FId = pa.FuncId
  363. Where ua.IsDel = 0 And ua.UId = {0} And pa.PageId = {1}
  364. Order By ModuleId,PageId,FuncId Asc", userId, PageId);
  365. userPageFuncDatas = await _dirRep._sqlSugar.SqlQueryable<UserPageFuncView>(sql).ToListAsync();
  366. if (userPageFuncDatas.Count <= 0)
  367. {
  368. return pageFunAuth;
  369. }
  370. UserPageFuncView userPageFunc = new UserPageFuncView();
  371. //查询 1
  372. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 1).FirstOrDefault();
  373. if (userPageFunc != null) pageFunAuth.CheckAuth = 1;
  374. //删除 2
  375. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 2).FirstOrDefault();
  376. if (userPageFunc != null) pageFunAuth.DeleteAuth = 1;
  377. //编辑 3
  378. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 3).FirstOrDefault();
  379. if (userPageFunc != null) pageFunAuth.EditAuth = 1;
  380. //下载 4
  381. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 4).FirstOrDefault();
  382. if (userPageFunc != null) pageFunAuth.FilesDownloadAuth = 1;
  383. //上传 5
  384. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 5).FirstOrDefault();
  385. if (userPageFunc != null) pageFunAuth.FilesUploadAuth = 1;
  386. //添加 11
  387. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 11).FirstOrDefault();
  388. if (userPageFunc != null) pageFunAuth.AddAuth = 1;
  389. //审核 12
  390. userPageFunc = userPageFuncDatas.Where(it => it.FuncId == 12).FirstOrDefault();
  391. if (userPageFunc != null) pageFunAuth.AuditAuth = 1;
  392. return pageFunAuth;
  393. }
  394. #endregion
  395. #region 业务模块 团组权限
  396. /// <summary>
  397. /// 业务模块 团组操作权限
  398. /// 验证 并返回可操作的团
  399. /// </summary>
  400. /// <param name="diId">团组Id</param>
  401. /// <param name="userId">用户Id</param>
  402. /// <param name="CTable">业务模块Id</param>
  403. /// <returns></returns>
  404. public static async Task<Result> PostGroupOperationAuth(int diId, int userId, int CTable)
  405. {
  406. Result _result = new Result { Code = -1, Msg = "No Operation Authorty!" };
  407. if (CTable < 1)
  408. {
  409. _result.Msg = "请填写正确的用户Id!";
  410. return _result;
  411. }
  412. var data = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(it => it.DIId == diId && it.UId == userId && it.CTId == CTable && it.IsDel == 0).First();
  413. if (data == null)
  414. {
  415. _result.Msg = "你没有本团下的该业务模块操作,请联系主管分配操作权限!";
  416. }
  417. else
  418. {
  419. _result.Code = 0;
  420. }
  421. return _result;
  422. }
  423. /// <summary>
  424. /// 业务模块 团组操作权限
  425. /// 返回可操作的团
  426. /// </summary>
  427. /// <param name="userId">用户Id</param>
  428. /// <param name="CTable">业务模块Id</param>
  429. /// <returns></returns>
  430. public static async Task<List<Web_ShareGroupInfoView>> PostOperationAuthReturnGroupInfosAsync(int userId, int CTable)
  431. {
  432. var shareGroupInfoViews = new List<Web_ShareGroupInfoView>();
  433. var taskData = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(it => it.UId == userId && it.CTId == CTable && it.IsDel == 0).ToList();
  434. if (taskData.Count < 1) return shareGroupInfoViews;
  435. var diIds = string.Join(",", taskData.Select(it => it.DIId).ToList());
  436. var sql = string.Format(@"Select Id,TeamName,TourCode,ClientName,VisitCountry,VisitStartDate,VisitEndDate,VisitDays,VisitPNumber
  437. From Grp_DelegationInfo Where Id In({0}) And IsDel = 0 Order By Id Desc", diIds);
  438. shareGroupInfoViews = await _dirRep._sqlSugar.SqlQueryable<Web_ShareGroupInfoView>(sql).ToListAsync();
  439. return shareGroupInfoViews;
  440. }
  441. #endregion
  442. #region 团组相关
  443. #region 费用录入 编辑、删除前验证
  444. /// <summary>
  445. /// 费用录入 编辑、删除 验证
  446. /// </summary>
  447. /// <param name="id">费用Id</param>
  448. /// <param name="feeType">
  449. /// 费用类型
  450. /// 85:机票
  451. /// 82:保险
  452. /// 81:商邀
  453. /// 80:签证
  454. /// 79:OP
  455. /// 76:酒店
  456. /// </param>
  457. /// <returns>
  458. /// (是否验证通过, 验证失败时的错误信息)
  459. /// 通过:true, null
  460. /// 失败:false, 错误信息
  461. /// </returns>
  462. public static async Task<(bool IsValid, string? ErrorMessage)> FeeOpValid(int id, int feeType)
  463. {
  464. // 查询费用记录
  465. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  466. .Where(x => x.IsDel == 0 && x.CId == id && x.CTable == feeType)
  467. .FirstAsync();
  468. // 记录不存在
  469. if (ccpInfo == null)
  470. return (false, "当前费用不存在,不可操作!");
  471. // 自动审核 费用类型为签证时不校验
  472. if (feeType != 80)
  473. {
  474. if (ccpInfo.IsAuditGM == 3)
  475. return (false, "当前费用已自动审核,不可操作!");
  476. }
  477. // 已审核
  478. if (ccpInfo.IsAuditGM == 1)
  479. return (false, "当前费用已审核,不可操作!");
  480. // 已付款
  481. if (ccpInfo.IsPay == 1)
  482. return (false, "当前费用已付款,不可操作!");
  483. // 验证通过
  484. return (true, null);
  485. }
  486. #endregion
  487. #region 建团按国家默认添加汇率 / 默认权限分配
  488. /// <summary>
  489. /// 团组汇率
  490. /// 建团时 添加基础汇率 CNY
  491. /// 按国家 添加 默认币种
  492. /// </summary>
  493. /// <param name="userId"></param>
  494. /// <param name="diId"></param>
  495. /// <returns></returns>
  496. public static async Task<Result> PostGroupRateAddInit(int userId, int diId)
  497. {
  498. Result result = new() { Code = -2 };
  499. if (userId < 1)
  500. {
  501. result.Msg = string.Format(@"请传入正确的userId");
  502. return result;
  503. }
  504. if (diId < 1)
  505. {
  506. result.Msg = string.Format(@"请传入正确的DiId");
  507. return result;
  508. }
  509. //美元(USD):1.0000|欧元(EUR):1.0000|墨西哥比索(MXN):1.0000
  510. string rateInit = string.Format(@"人民币(CNY):1.0000");
  511. //var gropInfo = _dirRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == diId).First();
  512. //if (gropInfo == null)
  513. //{
  514. // result.Msg = $@"未查询到团组信息!";
  515. // return result;
  516. //}
  517. var juheRateData = await _juHeApi.GetExchangeRateAsync();
  518. if (juheRateData.Error_code != 0)
  519. {
  520. result.Msg = juheRateData.Reason;
  521. return result;
  522. }
  523. List<ExchangeRateModel> exchangeRateModels = (List<ExchangeRateModel>)juheRateData.Result;
  524. if (exchangeRateModels.Count <= 0)
  525. {
  526. result.Msg = $@"未查询到聚合接口汇率信息!";
  527. return result;
  528. }
  529. if (exchangeRateModels.Count > 0)
  530. {
  531. var codes = _dirRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  532. for (int i = 0; i < exchangeRateModels.Count; i++)
  533. {
  534. string currencyName = exchangeRateModels[i].Name;
  535. string code = "";
  536. var currencyData = codes.Where(it => it.Remark == currencyName).FirstOrDefault();
  537. if (currencyData != null)
  538. {
  539. code = currencyData.Name;
  540. decimal currRate = 0.00M;
  541. string MSellPri = exchangeRateModels[i].MSellPri;
  542. if (!string.IsNullOrEmpty(MSellPri))
  543. {
  544. currRate = Convert.ToDecimal(MSellPri) / 100M;
  545. }
  546. rateInit += $@"|{currencyName}({code}):{currRate.ToString("#0.0000")}";
  547. }
  548. }
  549. }
  550. var cTableIds = _dirRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  551. if (cTableIds.Count < 1)
  552. {
  553. result.Msg = $@"未查询到操作模块信息!";
  554. return result;
  555. }
  556. List<Grp_TeamRate> grp_TeamRates = new List<Grp_TeamRate>();
  557. foreach (var item in cTableIds)
  558. {
  559. grp_TeamRates.Add(
  560. new Grp_TeamRate() { DiId = diId, CTable = item.Id, Remark = rateInit, CreateUserId = userId }
  561. );
  562. }
  563. if (grp_TeamRates.Count > 0)
  564. {
  565. var addId = _teamRateRep._sqlSugar.Insertable(grp_TeamRates).ExecuteCommand();
  566. if (addId < 1)
  567. {
  568. result.Msg = string.Format(@"添加失败!");
  569. return result;
  570. }
  571. }
  572. result.Code = 0;
  573. result.Msg = string.Format(@"操作成功!");
  574. return result;
  575. }
  576. /// <summary>
  577. /// 团组任务分配
  578. /// 建团时 默认按照岗位分配权限
  579. /// </summary>
  580. /// <param name="userId"></param>
  581. /// <param name="diId"></param>
  582. /// <param name="companyId"></param>
  583. /// <returns></returns>
  584. public static async Task<Result> PostGroupAuthAddInit(int userId, int diId, int companyId = 2)
  585. {
  586. Result result = new() { Code = -2 };
  587. if (userId < 0)
  588. {
  589. result.Msg = string.Format(@"请传入正确的userId");
  590. return result;
  591. }
  592. if (companyId < 0)
  593. {
  594. result.Msg = string.Format(@"请传入正确的companyId");
  595. return result;
  596. }
  597. if (diId < 0)
  598. {
  599. result.Msg = string.Format(@"请传入正确的DiId");
  600. return result;
  601. }
  602. var usersData = await _teamRateRep._sqlSugar.Queryable<Sys_Users>()
  603. .LeftJoin<Sys_Department>((su, sd) => su.DepId == sd.Id && sd.IsDel == 0)
  604. .LeftJoin<Sys_JobPost>((su, sd, sjp) => su.JobPostId == sjp.Id && sjp.IsDel == 0)
  605. .Where(su => su.IsDel == 0)
  606. .Select((su, sd, sjp) => new
  607. {
  608. su.DepId,
  609. sd.DepName,
  610. su.JobPostId,
  611. sjp.JobName,
  612. su.Id,
  613. su.CnName
  614. })
  615. .ToListAsync();
  616. /*
  617. * 76 酒店预订 --> 国交部门 酒店,主管 岗位
  618. * 77 行程 --> 国交部门 经理,主管 岗位
  619. * 79 车/导游地接 --> 国交部门 OP,主管 岗位
  620. * 80 签证 --> 国交部门 签证 岗位
  621. * 81 邀请/公务活动 --> 国交部门 商邀 岗位
  622. * 82 团组客户保险 --> 国交部 经理,主管 岗位
  623. * 85 机票预订 --> 国交部门 机票 岗位
  624. * 98 其他款项 --> 总经办部门 总经理 岗位/国交部门(ALL) 岗位/财务部门(ALL) 岗位/策划部门(ALL) 岗位/人事部门 采购 岗位
  625. * 1015 超支费用,69 收款退还 --> 财务部门(ALL)岗位
  626. * 1015 超支费用 --> 国交部(ALL)岗位
  627. * 1081 文档下载 --> 国交部门 酒店,主管 岗位
  628. */
  629. var groupsTaskAssignments = new List<Grp_GroupsTaskAssignment>();
  630. // 76 酒店预订 --> 国交部门(7) 酒店(25)、主管(22) 岗位
  631. groupsTaskAssignments.AddRange(
  632. usersData
  633. .Where(it => it.DepId == 7 && (it.JobPostId == 25 || it.JobPostId == 22))
  634. .Select(it => new Grp_GroupsTaskAssignment()
  635. {
  636. DIId = diId,
  637. CTId = 76,
  638. UId = it.Id,
  639. CreateUserId = userId
  640. }).ToList()
  641. );
  642. // 77 行程 --> 国交部门(7) 经理(32),主管(22) 岗位
  643. groupsTaskAssignments.AddRange(
  644. usersData
  645. .Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 32))
  646. .Select(it => new Grp_GroupsTaskAssignment()
  647. {
  648. DIId = diId,
  649. CTId = 77,
  650. UId = it.Id,
  651. CreateUserId = userId
  652. }).ToList()
  653. );
  654. //79 车/导游地接 --> 国交部门(7) OP(28)、主管(22) 岗位
  655. //groupsTaskAssignments.AddRange(
  656. // usersData.Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 28))
  657. // .Select(it => new Grp_GroupsTaskAssignment()
  658. // {
  659. // DIId = diId,
  660. // CTId = 79,
  661. // UId = it.Id,
  662. // CreateUserId = userId
  663. // }).ToList()
  664. //);
  665. //81 邀请/公务活动 --> 国交部门(7) 商邀(27) 岗位
  666. //groupsTaskAssignments.AddRange(
  667. // usersData.Where(it => it.DepId == 7 && it.JobPostId == 27)
  668. // .Select(it => new Grp_GroupsTaskAssignment()
  669. // {
  670. // DIId = diId,
  671. // CTId = 81,
  672. // UId = it.Id,
  673. // CreateUserId = userId
  674. // }).ToList()
  675. //);
  676. //2024年8月26日16点27分 “邀请公务活动分配给王鸽(UserID:149)”
  677. //groupsTaskAssignments.Add(
  678. // new Grp_GroupsTaskAssignment()
  679. // {
  680. // DIId = diId,
  681. // CTId = 81,
  682. // UId = 149,
  683. // CreateUserId = userId
  684. // }
  685. //);
  686. //80 签证 --> 国交部门(7) 签证(26) 岗位
  687. groupsTaskAssignments.AddRange(
  688. usersData
  689. .Where(it => it.DepId == 7 && it.JobPostId == 26)
  690. .Select(it => new Grp_GroupsTaskAssignment()
  691. {
  692. DIId = diId,
  693. CTId = 80,
  694. UId = it.Id,
  695. CreateUserId = userId
  696. }).ToList()
  697. );
  698. //82 团组客户保险 --> 国交部(7) 经理(32),主管(22) 岗位
  699. //2024-06-25 默认将保险权限分配给签证岗。 签证(26) 岗位
  700. List<int> insurancePositions = new List<int>() { 32, 22, 26 };
  701. groupsTaskAssignments.AddRange(
  702. usersData
  703. .Where(it => it.DepId == 7 && insurancePositions.Contains(it.JobPostId))
  704. .Select(it => new Grp_GroupsTaskAssignment()
  705. {
  706. DIId = diId,
  707. CTId = 82,
  708. UId = it.Id,
  709. CreateUserId = userId
  710. }).ToList()
  711. );
  712. //85 机票预订 --> 国交部门(7) 机票(24),主管(22) 岗位
  713. groupsTaskAssignments.AddRange(
  714. usersData
  715. .Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 24))
  716. .Select(it => new Grp_GroupsTaskAssignment()
  717. {
  718. DIId = diId,
  719. CTId = 85,
  720. UId = it.Id,
  721. CreateUserId = userId
  722. }).ToList()
  723. );
  724. //98 其他款项 --> 总经办部门(1) 总经理(1) 岗位/国交部门(7)(ALL) 岗位/财务部门(3)(ALL) 岗位/策划部门(5)(ALL) 岗位/人事部门(4) 采购(74) 岗位
  725. var depIds = new List<int>() { 7, 3, 5 };
  726. var jobIds = new List<int>() { 1, 74 };
  727. groupsTaskAssignments.AddRange(
  728. usersData
  729. .Where(it => depIds.Contains(it.DepId) || jobIds.Contains(it.JobPostId))
  730. .Select(it => new Grp_GroupsTaskAssignment()
  731. {
  732. DIId = diId,
  733. CTId = 98,
  734. UId = it.Id,
  735. CreateUserId = userId
  736. }).ToList()
  737. );
  738. //2024年8月26日16点27分 “其他款项分配给王鸽(UserID:149)”
  739. groupsTaskAssignments.Add(new Grp_GroupsTaskAssignment()
  740. {
  741. DIId = diId,
  742. CTId = 98,
  743. UId = 149,
  744. CreateUserId = userId
  745. });
  746. //1015 超支费用,285 收款退还 --> 财务部门(ALL)岗位
  747. groupsTaskAssignments.AddRange(
  748. usersData
  749. .Where(it => it.DepId == 3)
  750. .Select(it => new Grp_GroupsTaskAssignment()
  751. {
  752. DIId = diId,
  753. CTId = 1015,
  754. UId = it.Id,
  755. CreateUserId = userId
  756. }).ToList()
  757. );
  758. groupsTaskAssignments.AddRange(
  759. usersData
  760. .Where(it => it.DepId == 3)
  761. .Select(it => new Grp_GroupsTaskAssignment()
  762. {
  763. DIId = diId,
  764. CTId = 285,
  765. UId = it.Id,
  766. CreateUserId = userId
  767. }).ToList()
  768. );
  769. //1015 超支费用 --> 国交部(ALL)岗位
  770. groupsTaskAssignments.AddRange(
  771. usersData
  772. .Where(it => it.DepId == 7)
  773. .Select(it => new Grp_GroupsTaskAssignment()
  774. {
  775. DIId = diId,
  776. CTId = 1015,
  777. UId = it.Id,
  778. CreateUserId = userId
  779. }).ToList()
  780. );
  781. if (groupsTaskAssignments.Count > 0)
  782. {
  783. var addId = await _teamRateRep._sqlSugar.Insertable(groupsTaskAssignments).ExecuteCommandAsync();
  784. }
  785. result.Code = 0;
  786. result.Msg = string.Format(@"操作成功!");
  787. return result;
  788. }
  789. #endregion
  790. #region 员工是否是市场部人员
  791. /// <summary>
  792. /// 验证市场部客户人员
  793. /// </summary>
  794. /// <param name="userId"></param>
  795. /// <returns></returns>
  796. public static async Task<bool> IsMarketingStaff(int userId)
  797. {
  798. var userInfos = await _dirRep._sqlSugar
  799. .Queryable<Sys_Users>()
  800. .InnerJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  801. .Where((u, d) => u.IsDel == 0 && u.Id == userId && d.DepName.Contains("市场部"))
  802. .ToListAsync();
  803. if (userInfos.Count > 0) return true;
  804. return false;
  805. }
  806. #endregion
  807. #region 三公费用相关
  808. /// <summary>
  809. /// 保存操作前汇率
  810. /// </summary>
  811. /// <param name="currUserId"></param>
  812. /// <param name="diId"></param>
  813. /// <param name="linkModule"></param>
  814. /// <returns></returns>
  815. public static async Task<bool> RateRecordSave(int currUserId, int diId, string linkModule)
  816. {
  817. //var selectData = await _enterExitCostRep._sqlSugar.Queryable<Sys_ExchangeRateRecord>()
  818. // .Where(x => Convert.ToDateTime(x.RateDateTime).ToString("yyyy-MM-dd").Equals(DateTime.Now.ToString("yyyy-MM-dd")))
  819. // .FirstAsync();
  820. //if (selectData != null) return false;
  821. var _currencyRate = await _juHeApi.PostItemRateAsync(Array.Empty<string>());
  822. string rateInfoStr = string.Empty;
  823. var oaCurrencyData = await _sqlSugar.Queryable<Sys_SetData>()
  824. .Where(x => x.IsDel == 0 && x.STid == 66)
  825. .ToListAsync();
  826. //只记录 五种币种 汇率
  827. var currencyCodes = new List<string>() {
  828. "USD",
  829. "EUR",
  830. "JPY",
  831. "GBP",
  832. "HKD"
  833. };
  834. foreach (var rate in _currencyRate)
  835. {
  836. var oaCurrncy = oaCurrencyData.Find(x => x.Remark.Equals(rate.Name));
  837. if (oaCurrncy == null) continue;
  838. if (!currencyCodes.Contains(oaCurrncy.Name)) continue;
  839. //美元(USD):7.5|
  840. string rateStr = rate.FSellPri ?? "0.00";
  841. rateInfoStr += $"{rate.Name}({oaCurrncy.Name}):{rateStr}|";
  842. }
  843. if (string.IsNullOrEmpty(rateInfoStr)) return false;
  844. var add = await _sqlSugar
  845. .Insertable<Sys_ExchangeRateRecord>(new Sys_ExchangeRateRecord()
  846. {
  847. DiId = diId,
  848. LinkModule = linkModule,
  849. RateDateTime = DateTime.Now,
  850. RateInfo = rateInfoStr,
  851. CreateUserId = currUserId,
  852. IsDel = 0
  853. })
  854. .ExecuteCommandAsync();
  855. return add > 0;
  856. }
  857. /// <summary>
  858. /// 三公费用导入收款账单数据
  859. /// </summary>
  860. /// <param name="groupId"></param>
  861. /// <returns></returns>
  862. public static async Task<List<Fin_ForeignReceivables>> ReceivablesImportFeeAsync(int groupId)
  863. {
  864. var data = new List<Fin_ForeignReceivables>();
  865. var enterExitCosts = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == groupId).FirstAsync();
  866. var dayAndCosts = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == groupId).ToListAsync();
  867. var dayOtherCosts = await _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == groupId).ToListAsync(); //其他款项
  868. if (enterExitCosts == null) return data;
  869. //数据源
  870. var stayData = dayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  871. var mealData = dayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  872. var miscellaneousData = dayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  873. var trainData = dayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  874. //筛选 陪同人员 = 1
  875. var groupClientList = await _sqlSugar.Queryable<Grp_TourClientList>()
  876. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id)
  877. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id)
  878. .LeftJoin<Sys_SetData>((tcl, dc, cc, sd) => tcl.ShippingSpaceTypeId == sd.Id)
  879. .Where(tcl => tcl.IsDel == 0 &&
  880. tcl.DiId == groupId &&
  881. tcl.IsAccompany == 1
  882. )
  883. .Select((tcl, dc, cc, sd) => new
  884. {
  885. DiId = tcl.DiId,
  886. CompanyId = cc.Id,
  887. CompanyName = cc.CompanyFullName,
  888. ClienId = dc.Id,
  889. ClientName = dc.FirstName + dc.LastName,
  890. SpaceId = tcl.ShippingSpaceTypeId,
  891. SpaceName = sd.Name
  892. })
  893. .ToListAsync();
  894. if (!groupClientList.Any()) return data;
  895. decimal domesticFeeTotal = 0.00M, //境内费用
  896. economyClassFeeTotal = 0.00M, //经济舱费用
  897. businessClassFeeTotal = 0.00M, //公务舱费用
  898. firstClassFeeTotal = 0.00M, //头等舱费用
  899. stayFeeTotal = 0.00M, //住宿费
  900. mealsFeeTotal = 0.00M, //餐食费
  901. miscellaneousFeeTotal = 0.00M, //公杂费
  902. trainFeeTotal = 0.00M, //培训费
  903. otherPriceTotal = 0.00M; //其他款项
  904. //境内费用(其他费用)
  905. if (enterExitCosts.ChoiceOne == 1) domesticFeeTotal = enterExitCosts.InsidePay;
  906. //住宿费
  907. if (enterExitCosts.ChoiceThree == 1) stayFeeTotal = stayData.Sum(x => x.SubTotal);
  908. //伙食费
  909. if (enterExitCosts.ChoiceFour == 1) mealsFeeTotal = mealData.Sum(x => x.SubTotal);
  910. //公杂费
  911. if (enterExitCosts.ChoiceFive == 1) miscellaneousFeeTotal = miscellaneousData.Sum(x => x.SubTotal);
  912. //培训费
  913. if (enterExitCosts.ChoiceSix == 1) trainFeeTotal = trainData.Sum(x => x.SubTotal);
  914. //其他款项
  915. if (enterExitCosts.OtherExpenses_Checked == 1) otherPriceTotal = dayOtherCosts.Sum(x => x.SubTotal);
  916. decimal otherFeeTotal = domesticFeeTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainFeeTotal + otherPriceTotal;
  917. //国际旅费合计
  918. //经济舱
  919. if (enterExitCosts.SumJJC == 1) economyClassFeeTotal = enterExitCosts.OutsideJJPay + otherFeeTotal;
  920. //公务舱
  921. if (enterExitCosts.SumGWC == 1) businessClassFeeTotal = enterExitCosts.OutsideGWPay + otherFeeTotal;
  922. //头等舱
  923. if (enterExitCosts.SumTDC == 1) firstClassFeeTotal = enterExitCosts.OutsideTDPay + otherFeeTotal;
  924. var groupClientListGroup = groupClientList.GroupBy(x => x.CompanyId);
  925. foreach (var item in groupClientListGroup)
  926. {
  927. var companyName = AesEncryptionHelper.Decrypt(item.FirstOrDefault().CompanyName);
  928. var airTicketGroup = item.GroupBy(x => x.SpaceId);
  929. foreach (var airTicket in airTicketGroup)
  930. {
  931. int quantity = airTicket.Count();
  932. if (quantity > 0)
  933. {
  934. var price = 0.00M;
  935. var spaceName = airTicket.FirstOrDefault()?.SpaceName ?? string.Empty;
  936. if (spaceName.Equals("经济舱")) price = economyClassFeeTotal;
  937. else if (spaceName.Equals("公务舱")) price = businessClassFeeTotal;
  938. else if (spaceName.Equals("头等舱")) price = firstClassFeeTotal;
  939. if (price > 0)
  940. {
  941. decimal itemTotal = price * quantity;
  942. data.Add(new Fin_ForeignReceivables()
  943. {
  944. Id = 0,
  945. CreateTime = DateTime.Now,
  946. Diid = groupId,
  947. PriceName = $"{companyName}-{spaceName}",
  948. Price = price,
  949. Count = quantity,
  950. Unit = "人",
  951. ItemSumPrice = itemTotal,
  952. Currency = 836,
  953. Rate = 1.0000M,
  954. AddingWay = 2,
  955. Remark = "由出入境费用导入费用",
  956. });
  957. }
  958. }
  959. }
  960. }
  961. return data;
  962. }
  963. #endregion
  964. #region 根据团ID获取各板块实际操作人
  965. /// <summary>
  966. /// 获取 团组模块操作人
  967. /// </summary>
  968. /// <param name="groupId"></param>
  969. /// <returns></returns>
  970. public static List<GroupOperationUserView> GetGroupModuleOperators(int groupId)
  971. {
  972. var modoule = new GroupOperationUserView();
  973. var view = modoule.GetOperationUsersInit();
  974. if (groupId < 1) return view;
  975. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>()
  976. .Where(it => it.IsDel == 0 && it.Id == groupId)
  977. .First();
  978. if (groupInfo == null) return view;
  979. var authUsers = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>()
  980. .LeftJoin<Sys_Users>((x, u) => x.UId == u.Id)
  981. .Where((x, u) => x.DIId == groupId && x.IsDel == 0)
  982. .Select((x, u) => new
  983. {
  984. GroupId = x.DIId,
  985. CType = x.CTId,
  986. UserId = u.Id,
  987. UserName = u.CnName
  988. }).Distinct().ToList();
  989. //获取团组下的操作人
  990. //车/导游地接
  991. var opUers = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  992. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 79)
  993. .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
  994. .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
  995. .Select((x, y, u) => new GroupOperationUserInfo
  996. {
  997. UserId = u.Id,
  998. UserName = u.CnName
  999. }).Distinct().ToList();
  1000. view.Where(it => it.CTableId == 79).FirstOrDefault().OperationUsers = opUers.Distinct().ToList();
  1001. //签证
  1002. var visaUsers = _sqlSugar.Queryable<Grp_VisaInfo>()
  1003. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 80)
  1004. .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
  1005. .Where((x, y, u) => x.DIId == groupId && x.IsDel == 0)
  1006. .Select((x, y, u) => new GroupOperationUserInfo
  1007. {
  1008. UserId = u.Id,
  1009. UserName = u.CnName
  1010. }).Distinct().ToList();
  1011. view.Where(it => it.CTableId == 80).FirstOrDefault().OperationUsers = visaUsers.Distinct().ToList();
  1012. //保险
  1013. var insUsers = _sqlSugar.Queryable<Grp_Customers>()
  1014. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 82)
  1015. .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
  1016. .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
  1017. .Select((x, y, u) => new GroupOperationUserInfo
  1018. {
  1019. UserId = u.Id,
  1020. UserName = u.CnName
  1021. }).Distinct().ToList();
  1022. view.Where(it => it.CTableId == 82).FirstOrDefault().OperationUsers = insUsers.Distinct().ToList();
  1023. //邀请/公务活动
  1024. var ioaUsers = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>()
  1025. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 81)
  1026. .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
  1027. .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
  1028. .Select((x, y, u) => new GroupOperationUserInfo
  1029. {
  1030. UserId = u.Id,
  1031. UserName = u.CnName
  1032. }).Distinct().ToList();
  1033. if (!ioaUsers.Any())
  1034. {
  1035. ioaUsers = _sqlSugar.Queryable<Res_OfficialActivities>()
  1036. .LeftJoin<Sys_Users>((x, y) => x.CreateUserId == y.Id)
  1037. .Where((x, y) => x.DiId == groupId && x.IsDel == 0)
  1038. .Select((x, y) => new GroupOperationUserInfo
  1039. {
  1040. UserId = y.Id,
  1041. UserName = y.CnName
  1042. }).Distinct().ToList();
  1043. }
  1044. ////公务资料信息
  1045. //var ioaUsers1 = _sqlSugar.Queryable< Res_OfficialActivities >()
  1046. // .LeftJoin<Sys_Users>((x,y) => x.CreateUserId == y.Id)
  1047. // .Where((x,y) => x.DiId == groupId && x.IsDel == 0)
  1048. // .Select((x, y) => new GroupOperationUserInfo
  1049. // {
  1050. // UserId = y.Id,
  1051. // UserName = y.CnName
  1052. // }).Distinct().ToList();
  1053. //if (!ioaUsers.Any())
  1054. //{
  1055. // ioaUsers.AddRange(ioaUsers1);
  1056. //}
  1057. view.Where(it => it.CTableId == 81).FirstOrDefault().OperationUsers = ioaUsers.Distinct().ToList();
  1058. //其他款项 98
  1059. var otherUsers = _sqlSugar.Queryable<Grp_DecreasePayments>()
  1060. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == 98)
  1061. .LeftJoin<Sys_Users>((x, y, u) => x.CreateUserId == u.Id)
  1062. .Where((x, y, u) => x.DiId == groupId && x.IsDel == 0)
  1063. .Select((x, y, u) => new GroupOperationUserInfo
  1064. {
  1065. UserId = u.Id,
  1066. UserName = u.CnName
  1067. }).Distinct().ToList();
  1068. view.Where(it => it.CTableId == 98).FirstOrDefault().OperationUsers = otherUsers.Distinct().ToList();
  1069. //添加分配人员
  1070. // 79 车/导游地接
  1071. // 80 签证
  1072. // 81 邀请/公务活动
  1073. var setdataids = new List<int>() { 79, 81, 80 };
  1074. //职位Id
  1075. // 27 商邀
  1076. // 28 OP
  1077. // 22 王鸽(主管)
  1078. // 26 签证
  1079. var jobSetdataids = new List<int>() { 22, 27, 28, 26 };
  1080. var q = _sqlSugar.Queryable<Grp_GroupsTaskAssignment, Sys_Users>(
  1081. (ccta, su) => new JoinQueryInfos(
  1082. JoinType.Left, ccta.UId == su.Id && su.IsDel == 0))
  1083. .Where((ccta, su) =>
  1084. ccta.IsDel == 0 &&
  1085. ccta.DIId == groupId &&
  1086. jobSetdataids.Contains(su.JobPostId) &&
  1087. setdataids.Contains(ccta.CTId))
  1088. .Select((ccta, su) => new
  1089. {
  1090. userid = su.Id,
  1091. su.JobPostId,
  1092. ccta.CTId,
  1093. ccta.DIId,
  1094. su.CnName,
  1095. });
  1096. var qtb = q.ToDataTable();
  1097. foreach (var groupModule in view)
  1098. {
  1099. if (setdataids.Contains(groupModule.CTableId) && !groupModule.OperationUsers.Any())
  1100. {
  1101. var qtbUsers = qtb.AsEnumerable().
  1102. Where(x => x.Field<int>("CTId") == groupModule.CTableId).
  1103. Select(x => x.Field<int>("userid")).ToList();
  1104. //王鸽、王思雨、朱琳
  1105. groupModule.OperationUsers = qtbUsers.Select(x => new GeneralMethod.GroupOperationUserInfo()
  1106. {
  1107. UserId = x,
  1108. UserName = qtb.AsEnumerable().FirstOrDefault(y => y.Field<int>("userid") == x)?.Field<string>("CnName") ?? ""
  1109. }).ToList();
  1110. }
  1111. }
  1112. return view;
  1113. }
  1114. public class GroupOperationUserView
  1115. {
  1116. public int CTableId { get; set; }
  1117. public string CTableName { get; set; }
  1118. public List<GroupOperationUserInfo> OperationUsers { get; set; }
  1119. public GroupOperationUserView() { }
  1120. /// <summary>
  1121. /// 默认模块List
  1122. /// </summary>
  1123. /// <returns></returns>
  1124. public List<GroupOperationUserView> GetOperationUsersInit()
  1125. {
  1126. var modules = new List<GroupOperationUserView>() {
  1127. new(){ CTableId = 76,CTableName = "酒店预订",
  1128. OperationUsers=new List<GroupOperationUserInfo>(){ new() {UserId = 226,UserName = "宋夏雨" } } },
  1129. new(){ CTableId = 79,CTableName = "车/导游地接" },
  1130. new(){ CTableId = 80,CTableName = "签证" },
  1131. new(){ CTableId = 82,CTableName = "团组客户保险" },
  1132. new(){ CTableId = 81,CTableName = "邀请/公务活动" },
  1133. new(){ CTableId = 85,CTableName = "机票预订",
  1134. OperationUsers=new List<GroupOperationUserInfo>(){ new() {UserId = 385, UserName = "雍婷玉" } } },
  1135. new(){ CTableId = 98,CTableName = "其他款项" },
  1136. };
  1137. return modules;
  1138. }
  1139. }
  1140. public class GroupOperationUserInfo
  1141. {
  1142. public int UserId { get; set; }
  1143. public string UserName { get; set; }
  1144. }
  1145. #endregion
  1146. #region 商邀AI invName 整合
  1147. /// <summary>
  1148. /// 商邀AI invName 整合
  1149. /// </summary>
  1150. /// <returns></returns>
  1151. public static async Task<List<InvitationAIInvNameView>> InvitationAIInvName()
  1152. {
  1153. // 预定义 UnionAll 查询
  1154. var query1 = _sqlSugar.Queryable<Grp_DelegationInfo>()
  1155. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  1156. .Select(x => new InvitationAIInvNameView { Id = x.Id, Name = x.TeamName, Source = 1, SortTime = x.VisitDate });
  1157. var query2 = _sqlSugar.Queryable<Res_InvitationAI>()
  1158. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.InvName))
  1159. .Select(x => new InvitationAIInvNameView { Id = x.Id, Name = x.InvName, Source = 2, SortTime = x.CreateTime });
  1160. var unionQuery = _sqlSugar.UnionAll(query1, query2);
  1161. return await _sqlSugar.Queryable(unionQuery)
  1162. .PartitionBy(it => it.Name) // 按 Name 分组
  1163. .OrderBy(it => it.Source) // 优先级:Source=1 会排在 Source=2 之前
  1164. .OrderByDescending(it => it.SortTime) // 同 Source 下保留最新时间
  1165. .Select(it => it) // 此时 SqlSugar 会自动应用 RowNumber == 1 的过滤
  1166. .ToListAsync();
  1167. }
  1168. /// <summary>
  1169. /// 商邀AI ClientName 处理
  1170. /// </summary>
  1171. /// <returns></returns>
  1172. public static async Task<List<string>> InvitationAIClientName()
  1173. {
  1174. var rawEncryptedDatas = await _sqlSugar.Queryable<Crm_NewClientData>()
  1175. .Where(x => x.IsDel == 0 && x.Client != null)
  1176. .Select(x => x.Client)
  1177. .ToListAsync();
  1178. // 2. 内存精炼:解密 -> 去空格 -> 排除横杠 -> 去重
  1179. var unitNames = rawEncryptedDatas
  1180. .Select(encryptedItem =>
  1181. {
  1182. try
  1183. {
  1184. return AesEncryptionHelper.Decrypt(encryptedItem);
  1185. }
  1186. catch
  1187. {
  1188. return null; // 异常解密处理
  1189. }
  1190. })
  1191. .Where(decrypted => !string.IsNullOrWhiteSpace(decrypted)) // 排除空或纯空格
  1192. .Select(decrypted => decrypted.Replace(" ", "")) // 去除所有内部空格
  1193. .Where(cleaned => !cleaned.Contains("-")) // 此时过滤解密后的 "-" 才有效
  1194. .Distinct() // 最终去重
  1195. .ToList();
  1196. return unitNames;
  1197. }
  1198. /// <summary>
  1199. /// 商邀AI CountryName 处理
  1200. /// </summary>
  1201. /// <returns></returns>
  1202. public static async Task<List<string>> InvitationAICountryName()
  1203. {
  1204. return await _sqlSugar.Queryable<Sys_Countries>()
  1205. .Where(x => x.IsDel == 0)
  1206. .Select(x => x.Name_CN)
  1207. .Distinct()
  1208. .ToListAsync();
  1209. }
  1210. #endregion
  1211. #endregion
  1212. #region 团组汇率
  1213. /// <summary>
  1214. /// 团组汇率
  1215. /// 获取板块 币种 及 汇率
  1216. /// 76 酒店预订 77 行程 79 车/导游地接
  1217. /// 80 签证 82 团组客户保险 85 机票预订
  1218. /// 98 其他款项 285 收款退还
  1219. /// </summary>
  1220. /// <param name="teamRateModels"></param>
  1221. /// <param name="cTable"></param>
  1222. /// <param name="currencyCodes"></param>
  1223. /// <returns>
  1224. /// string
  1225. /// eg: CNY 1.0000
  1226. /// </returns>
  1227. public static async Task<string> PostGroupRateByCTableAndCurrency(List<TeamRateModelView> teamRateModels, int cTable, List<string> currencyCodes)
  1228. {
  1229. string str = "";
  1230. List<string> currencyRates = new List<string>();
  1231. TeamRateModelView hotelRateData = teamRateModels.Where(it => it.CTableId == cTable).FirstOrDefault();
  1232. if (hotelRateData != null)
  1233. {
  1234. var hotelRates = hotelRateData.TeamRates;
  1235. foreach (var item in currencyCodes)
  1236. {
  1237. if (!string.IsNullOrEmpty(item))
  1238. {
  1239. var hotelRateInfo = hotelRates.Where(it => it.CurrencyCode.Equals(item)).FirstOrDefault();
  1240. if (hotelRateInfo != null)
  1241. {
  1242. string str1 = string.Format("{0} {1}\r\n", hotelRateInfo.CurrencyCode, hotelRateInfo.Rate.ToString("#0.0000"));
  1243. currencyRates.Add(str1);
  1244. }
  1245. }
  1246. }
  1247. if (currencyRates != null || currencyRates.Count > 0)
  1248. {
  1249. currencyRates = currencyRates.Distinct().ToList();
  1250. foreach (var item in currencyRates)
  1251. {
  1252. str += item;
  1253. }
  1254. }
  1255. }
  1256. return str;
  1257. }
  1258. /// <summary>
  1259. /// 团组汇率 币种 Item (来源:团组汇率)
  1260. /// 根据 团组Id And 业务类型(CTable)Id
  1261. /// api处理CTable = 285,默认返回CNY
  1262. /// </summary>
  1263. /// <param name="portType"></param>
  1264. /// <param name="diId"></param>
  1265. /// <param name="cTable"></param>
  1266. /// <returns></returns>
  1267. public static async Task<TeamRateModelGeneralView> PostGroupTeamRateByDiIdAndCTableId(int portType, int diId, int cTable)
  1268. {
  1269. TeamRateModelGeneralView _view = new TeamRateModelGeneralView();
  1270. _view = await _teamRateRep.PostGroupTeamRateByDiIdAndCTableId(portType, diId, cTable);
  1271. return _view;
  1272. }
  1273. /// <summary>
  1274. /// 汇率备注拆分
  1275. /// (美元(USD):7.2370|日元(JPY):0.0499|欧元(EUR):8.3000|英镑(GBP):9.1996|港币(HKD):0.9291)
  1276. /// </summary>
  1277. /// <param name="rateRemark"></param>
  1278. /// <returns></returns>
  1279. public static async Task<List<TeamRateDescAddCurrencyIdView>> SplitExchangeRate(this string rateRemark)
  1280. {
  1281. List<TeamRateDescAddCurrencyIdView> _view = new List<TeamRateDescAddCurrencyIdView>();
  1282. List<SetDataInfoView> currencyDatas = new List<SetDataInfoView>();
  1283. #region 获取所有币种
  1284. string sql = string.Format(@"select * from Sys_SetData where STid = {0} and isdel = 0", 66);
  1285. var DBdata = _setDataRep.GetListBySqlWithNolock(sql);
  1286. if (DBdata == null || DBdata.Count == 0)
  1287. {
  1288. return _view;
  1289. }
  1290. currencyDatas = DBdata.Select(x => new SetDataInfoView
  1291. {
  1292. Name = x.Name,
  1293. Id = x.Id,
  1294. Remark = x.Remark,
  1295. }).ToList();
  1296. #endregion
  1297. #region 拆分remark里的汇率
  1298. if (string.IsNullOrEmpty(rateRemark))
  1299. {
  1300. return _view;
  1301. }
  1302. if (rateRemark.Contains("|"))
  1303. {
  1304. string[] currencyArr = rateRemark.Split("|");
  1305. foreach (string currency in currencyArr)
  1306. {
  1307. string[] currency1 = currency.Split(":");
  1308. string[] currency2 = currency1[0].Split("(");
  1309. string currencyCode = currency2[1].Replace(")", "").TrimEnd();
  1310. TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
  1311. {
  1312. CurrencyId = currencyDatas.Find(it => it.Name == currencyCode).Id,
  1313. CurrencyCode = currencyCode,
  1314. CurrencyName = currency2[0],
  1315. Rate = decimal.Parse(currency1[1]),
  1316. };
  1317. _view.Add(rateDescView);
  1318. }
  1319. }
  1320. else
  1321. {
  1322. try
  1323. {
  1324. string[] currency1 = rateRemark.Split(":");
  1325. string[] currency2 = currency1[0].Split("(");
  1326. string currencyCode = currency2[1].Replace(")", "").TrimEnd();
  1327. TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
  1328. {
  1329. CurrencyId = currencyDatas.Find(it => it.Name == currencyCode).Id,
  1330. CurrencyCode = currencyCode,
  1331. CurrencyName = currency2[0],
  1332. Rate = decimal.Parse(currency1[1]),
  1333. };
  1334. _view.Add(rateDescView);
  1335. }
  1336. catch (Exception)
  1337. {
  1338. return _view;
  1339. }
  1340. }
  1341. #endregion
  1342. return _view;
  1343. }
  1344. #endregion
  1345. #region 汉字转换拼音
  1346. private static Dictionary<int, List<string>> GetTotalPingYinDictionary(string text)
  1347. {
  1348. var chs = text.ToCharArray();
  1349. //记录每个汉字的全拼
  1350. Dictionary<int, List<string>> totalPingYinList = new Dictionary<int, List<string>>();
  1351. for (int i = 0; i < chs.Length; i++)
  1352. {
  1353. var pinyinList = new List<string>();
  1354. //是否是有效的汉字
  1355. if (ChineseChar.IsValidChar(chs[i]))
  1356. {
  1357. ChineseChar cc = new ChineseChar(chs[i]);
  1358. pinyinList = cc.Pinyins.Where(p => !string.IsNullOrWhiteSpace(p)).ToList();
  1359. }
  1360. else
  1361. {
  1362. pinyinList.Add(chs[i].ToString());
  1363. }
  1364. //去除声调,转小写
  1365. pinyinList = pinyinList.ConvertAll(p => Regex.Replace(p, @"\d", "").ToLower());
  1366. //去重
  1367. pinyinList = pinyinList.Where(p => !string.IsNullOrWhiteSpace(p)).Distinct().ToList();
  1368. if (pinyinList.Any())
  1369. {
  1370. totalPingYinList[i] = pinyinList;
  1371. }
  1372. }
  1373. return totalPingYinList;
  1374. }
  1375. /// <summary>
  1376. /// 获取汉语拼音全拼
  1377. /// </summary>
  1378. /// <param name="text">The string.</param>
  1379. /// <returns></returns>
  1380. public static List<string> GetTotalPingYin(this string text)
  1381. {
  1382. var result = new List<string>();
  1383. foreach (var pys in GetTotalPingYinDictionary(text))
  1384. {
  1385. var items = pys.Value;
  1386. if (result.Count <= 0)
  1387. {
  1388. result = items;
  1389. }
  1390. else
  1391. {
  1392. //全拼循环匹配
  1393. var newTotalPingYinList = new List<string>();
  1394. foreach (var totalPingYin in result)
  1395. {
  1396. newTotalPingYinList.AddRange(items.Select(item => totalPingYin + item));
  1397. }
  1398. newTotalPingYinList = newTotalPingYinList.Distinct().ToList();
  1399. result = newTotalPingYinList;
  1400. }
  1401. }
  1402. return result;
  1403. }
  1404. /// <summary>
  1405. /// 获取中文第一个拼音
  1406. /// </summary>
  1407. /// <param name="text"></param>
  1408. /// <param name="isUp"></param>
  1409. /// <returns></returns>
  1410. public static string GetTotalPingYinFirst(this string text, bool isUp = true)
  1411. {
  1412. var returnstr = string.Empty;
  1413. var enResult = text.GetTotalPingYin();
  1414. if (enResult.Count == 0)
  1415. {
  1416. returnstr = text;
  1417. }
  1418. else if (isUp)
  1419. {
  1420. returnstr = enResult[0].ToUpper();
  1421. }
  1422. else
  1423. {
  1424. returnstr = enResult[0].ToLower();
  1425. }
  1426. return returnstr;
  1427. }
  1428. /// <summary>
  1429. /// 获取汉语拼音首字母
  1430. /// </summary>
  1431. /// <param name="text"></param>
  1432. /// <returns></returns>
  1433. public static List<string> GetFirstPingYin(this string text)
  1434. {
  1435. var result = new List<string>();
  1436. foreach (var pys in GetTotalPingYinDictionary(text))
  1437. {
  1438. var items = pys.Value;
  1439. if (result.Count <= 0)
  1440. {
  1441. result = items.ConvertAll(p => p.Substring(0, 1)).Distinct().ToList();
  1442. }
  1443. else
  1444. {
  1445. //首字母循环匹配
  1446. var newFirstPingYinList = new List<string>();
  1447. foreach (var firstPingYin in result)
  1448. {
  1449. newFirstPingYinList.AddRange(items.Select(item => firstPingYin + item.Substring(0, 1)));
  1450. }
  1451. newFirstPingYinList = newFirstPingYinList.Distinct().ToList();
  1452. result = newFirstPingYinList;
  1453. }
  1454. }
  1455. return result;
  1456. }
  1457. #endregion
  1458. #region 新客户资料表 操作记录
  1459. /// <summary>
  1460. /// 新客户资料表
  1461. /// 操作记录添加
  1462. /// </summary>
  1463. /// <param name="portType"></param>
  1464. /// <param name="operationEnum"></param>
  1465. /// <param name="userId"></param>
  1466. /// <param name="dataId"></param>
  1467. /// <param name="remark"></param>
  1468. /// <returns></returns>
  1469. public static async Task<bool> NewClientOperationRecord(int portType, OperationEnum operationEnum, int userId, int dataId, string remark)
  1470. {
  1471. Crm_TableOperationRecord _TableOperationRecord = new Crm_TableOperationRecord()
  1472. {
  1473. TableName = "Crm_NewClientData",
  1474. PortType = portType,
  1475. OperationItem = operationEnum,
  1476. DataId = dataId,
  1477. CreateUserId = userId,
  1478. CreateTime = DateTime.Now,
  1479. Remark = remark
  1480. };
  1481. bool add = await _tableOperationRecordRep._Add(_TableOperationRecord);
  1482. if (add) return false;
  1483. return false;
  1484. }
  1485. #endregion
  1486. #region 金额转大写
  1487. /// <summary>
  1488. /// 金额转换为大写数字
  1489. /// <para>1、支持的最大数字:999999999999.99(玖仟玖佰玖拾玖亿玖仟玖佰玖拾玖万玖仟玖佰玖拾玖元玖角玖分)</para>
  1490. /// <para>2、小数点后最多支持两位</para>
  1491. /// </summary>
  1492. /// <param name="num">数值</param>
  1493. /// <returns></returns>
  1494. public static string ConvertCNYUpper(this decimal num)
  1495. {
  1496. if (num == 0)
  1497. {
  1498. return "零元";
  1499. }
  1500. // 解决327000000转换后缺少单位万的问题
  1501. return ConvertToChinese(num);
  1502. }
  1503. #region 实例
  1504. /// <summary>
  1505. /// 要转换的数字
  1506. /// </summary>
  1507. private static decimal j;
  1508. /// <summary>
  1509. ///
  1510. /// </summary>
  1511. private static string[] NumChineseCharacter = new string[] { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
  1512. /// <summary>
  1513. /// 判断输入的数字是否大于double类型
  1514. /// </summary>
  1515. private static bool IsNumber
  1516. {
  1517. get
  1518. {
  1519. if (j > decimal.MaxValue || j <= 0)
  1520. return false;
  1521. else
  1522. return true;
  1523. }
  1524. }
  1525. /// <summary>
  1526. /// 数字转换成大写汉字主函数
  1527. /// </summary>
  1528. /// <returns>返回转换后的大写汉字</returns>
  1529. public static string ConvertToChinese(decimal m)
  1530. {
  1531. j = m;
  1532. string bb = "";
  1533. if (IsNumber)
  1534. {
  1535. string str = j.ToString();
  1536. string[] Num = str.Split('.');
  1537. if (Num.Length == 1)
  1538. {
  1539. bb = NumberString(Num[0]) + "元整";
  1540. bb = bb.Replace("零零", "零");
  1541. }
  1542. else
  1543. {
  1544. bb = NumberString(Num[0]) + "元";
  1545. bb += FloatString(Num[1]);
  1546. bb = bb.Replace("零零", "零");
  1547. }
  1548. }
  1549. else
  1550. {
  1551. throw new FormatException("你输入的数字格式不正确或不是数字!");
  1552. }
  1553. return bb;
  1554. }
  1555. /// <summary>
  1556. /// 小数位转换只支持两位的小数
  1557. /// </summary>
  1558. /// <param name="Num">转换的小数</param>
  1559. /// <returns>小数转换成汉字</returns>
  1560. private static string FloatString(string Num)
  1561. {
  1562. string cc = "";
  1563. if (Num.Length > 2)
  1564. {
  1565. throw new FormatException("小数位数过多.");
  1566. }
  1567. else
  1568. {
  1569. string bb = ConvertString(Num);
  1570. int len = bb.IndexOf("零");
  1571. if (len != 0)
  1572. {
  1573. bb = bb.Replace("零", "");
  1574. if (bb.Length == 1)
  1575. {
  1576. cc = bb.Substring(0, 1) + "角";
  1577. }
  1578. else
  1579. {
  1580. cc = bb.Substring(0, 1) + "角";
  1581. cc += bb.Substring(1, 1) + "分";
  1582. }
  1583. }
  1584. else
  1585. cc = bb + "分";
  1586. }
  1587. return cc;
  1588. }
  1589. /// <summary>
  1590. /// 判断数字位数以进行拆分转换
  1591. /// </summary>
  1592. /// <param name="Num">要进行拆分的数字</param>
  1593. /// <returns>转换成的汉字</returns>
  1594. private static string NumberString(string Num)
  1595. {
  1596. string bb = "";
  1597. if (Num.Length <= 4)
  1598. {
  1599. bb = Convert4(Num);
  1600. }
  1601. else if (Num.Length > 4 && Num.Length <= 8)
  1602. {
  1603. bb = Convert4(Num.Substring(0, Num.Length - 4)) + "万";
  1604. bb += Convert4(Num.Substring(Num.Length - 4, 4));
  1605. }
  1606. else if (Num.Length > 8 && Num.Length <= 12)
  1607. {
  1608. bb = Convert4(Num.Substring(0, Num.Length - 8)) + "亿";
  1609. if (Convert4(Num.Substring(Num.Length - 8, 4)) == "")
  1610. if (Convert4(Num.Substring(Num.Length - 4, 4)) != "")
  1611. bb += "零";
  1612. else
  1613. bb += "";
  1614. else
  1615. bb += Convert4(Num.Substring(Num.Length - 8, 4)) + "万";
  1616. bb += Convert4(Num.Substring(Num.Length - 4, 4));
  1617. }
  1618. else
  1619. {
  1620. throw new Exception("整数部分最多支持12位");
  1621. }
  1622. return bb;
  1623. }
  1624. /// <summary>
  1625. /// 四位数字的转换
  1626. /// </summary>
  1627. /// <param name="Num">准备转换的四位数字</param>
  1628. /// <returns>转换以后的汉字</returns>
  1629. private static string Convert4(string Num)
  1630. {
  1631. string bb = "";
  1632. if (Num.Length == 1)
  1633. {
  1634. bb = ConvertString(Num);
  1635. }
  1636. else if (Num.Length == 2)
  1637. {
  1638. bb = ConvertString(Num);
  1639. bb = Convert2(bb);
  1640. }
  1641. else if (Num.Length == 3)
  1642. {
  1643. bb = ConvertString(Num);
  1644. bb = Convert3(bb);
  1645. }
  1646. else
  1647. {
  1648. bb = ConvertString(Num);
  1649. string cc = "";
  1650. string len = bb.Substring(0, 4);
  1651. if (len != "零零零零")
  1652. {
  1653. len = bb.Substring(0, 3);
  1654. if (len != "零零零")
  1655. {
  1656. bb = bb.Replace("零零零", "");
  1657. if (bb.Length == 1)
  1658. {
  1659. bb = bb.Substring(0, 1) + "仟";
  1660. }
  1661. else
  1662. {
  1663. if (bb.Substring(0, 1) != "零" && bb.Substring(0, 2) != "零")
  1664. cc = bb.Substring(0, 1) + "仟";
  1665. else
  1666. cc = bb.Substring(0, 1);
  1667. bb = cc + Convert3(bb.Substring(1, 3));
  1668. }
  1669. }
  1670. else
  1671. {
  1672. bb = bb.Replace("零零零", "零");
  1673. }
  1674. }
  1675. else
  1676. {
  1677. bb = bb.Replace("零零零零", "");
  1678. }
  1679. }
  1680. return bb;
  1681. }
  1682. /// <summary>
  1683. /// 将数字转换成汉字
  1684. /// </summary>
  1685. /// <param name="Num">需要转换的数字</param>
  1686. /// <returns>转换后的汉字</returns>
  1687. private static string ConvertString(string Num)
  1688. {
  1689. string bb = "";
  1690. for (int i = 0; i < Num.Length; i++)
  1691. {
  1692. bb += NumChineseCharacter[int.Parse(Num.Substring(i, 1))];
  1693. }
  1694. return bb;
  1695. }
  1696. /// <summary>
  1697. /// 两位数字的转换
  1698. /// </summary>
  1699. /// <param name="Num">两位数字</param>
  1700. /// <returns>转换后的汉字</returns>
  1701. private static string Convert2(string Num)
  1702. {
  1703. string bb = ""; string cc = "";
  1704. string len = Num.Substring(0, 1);
  1705. if (len != "零")
  1706. {
  1707. bb = Num.Replace("零", "");
  1708. if (bb.Length == 1)
  1709. {
  1710. cc = bb.Substring(0, 1) + "拾";
  1711. }
  1712. else
  1713. {
  1714. cc = bb.Substring(0, 1) + "拾";
  1715. cc += bb.Substring(1, 1);
  1716. }
  1717. }
  1718. else
  1719. cc = Num;
  1720. return cc;
  1721. }
  1722. /// <summary>
  1723. /// 三位数字的转换
  1724. /// </summary>
  1725. /// <param name="Num">三位数字</param>
  1726. /// <returns>转换后的汉字</returns>
  1727. private static string Convert3(string Num)
  1728. {
  1729. string bb = ""; string cc = "";
  1730. string len = Num.Substring(0, 2);
  1731. if (len != "零零")
  1732. {
  1733. bb = Num.Replace("零零", "");
  1734. if (bb.Length == 1)
  1735. {
  1736. bb = bb.Substring(0, 1) + "佰";
  1737. }
  1738. else
  1739. {
  1740. if (bb.Substring(0, 1) != "零")
  1741. cc = bb.Substring(0, 1) + "佰";
  1742. else
  1743. cc = bb.Substring(0, 1);
  1744. bb = cc + Convert2(bb.Substring(1, 2));
  1745. }
  1746. }
  1747. else
  1748. {
  1749. bb = Num.Replace("零零", "零");
  1750. }
  1751. return bb;
  1752. }
  1753. #endregion
  1754. #endregion
  1755. #region 数字验证
  1756. /// <summary>
  1757. /// 验证数字字符串
  1758. /// </summary>
  1759. /// <param name="numStr"></param>
  1760. /// <returns></returns>
  1761. public static bool IsNumeric(this string numStr)
  1762. {
  1763. bool isNumeric = Regex.IsMatch(numStr, @"^\d+$");
  1764. if (isNumeric)
  1765. {
  1766. return true;
  1767. }
  1768. return false;
  1769. }
  1770. #endregion
  1771. #region 日期 格式转换
  1772. /// <summary>
  1773. /// 验证日期字符串
  1774. /// </summary>
  1775. /// <param name="str"></param>
  1776. /// <returns></returns>
  1777. public static string ConvertToDatetime(this string str)
  1778. {
  1779. if (!string.IsNullOrEmpty(str))
  1780. {
  1781. DateTime currentDate = Convert.ToDateTime(str);
  1782. return $"{currentDate.Year}年{currentDate.Month}月{currentDate.Day}日";
  1783. }
  1784. return "";
  1785. }
  1786. #endregion
  1787. #region 月份/季度
  1788. /// <summary>
  1789. /// 获取月份对应的起始天数
  1790. /// </summary>
  1791. /// <param name="year"></param>
  1792. /// <returns></returns>
  1793. public static List<MonthInfo> GetMonthInfos(int year)
  1794. {
  1795. List<MonthInfo> months = new List<MonthInfo>();
  1796. if (year > 1)
  1797. {
  1798. for (int i = 1; i < 13; i++)
  1799. {
  1800. months.Add(new MonthInfo()
  1801. {
  1802. Month = i,
  1803. Days = new DaysInfo() { BeginDays = 1, EndDays = DateTime.DaysInMonth(year, i) }
  1804. });
  1805. }
  1806. }
  1807. return months;
  1808. }
  1809. /// <summary>
  1810. /// 获取季度对应的起始天数
  1811. /// </summary>
  1812. /// <param name="year"></param>
  1813. /// <returns></returns>
  1814. public static List<MonthInfo> GetQuarter(int year)
  1815. {
  1816. List<MonthInfo> months = new List<MonthInfo>();
  1817. months.Add(new MonthInfo() { Month = 1, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //1.1 - 3.31
  1818. months.Add(new MonthInfo() { Month = 2, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //4.1 - 6.30
  1819. months.Add(new MonthInfo() { Month = 3, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //7.1 - 9.31
  1820. months.Add(new MonthInfo() { Month = 4, Days = new DaysInfo() { BeginDays = 1, EndDays = 31 } }); //10.1 - 12.31
  1821. return months;
  1822. }
  1823. public class MonthInfo
  1824. {
  1825. public int Month { get; set; }
  1826. public DaysInfo Days { get; set; }
  1827. }
  1828. public class DaysInfo
  1829. {
  1830. public int BeginDays { get; set; }
  1831. public int EndDays { get; set; }
  1832. }
  1833. #endregion
  1834. #region op行程单,黑屏幕代码
  1835. public static string GetCountryStandingTime(int diId)
  1836. {
  1837. DataTable datas = GetTableByBlackCode(diId);
  1838. string countryStr = "[黑屏代码未录入].";
  1839. if (datas.Rows.Count > 0)
  1840. {
  1841. var airDatas = from row in datas.AsEnumerable()
  1842. select new
  1843. {
  1844. Three = row.Field<string>("Three"),
  1845. Day = row.Field<string>("Day"),
  1846. ArrivedDate = row.Field<string>("ArrivedDate"),
  1847. };
  1848. //三字码信息
  1849. List<Res_ThreeCode> listcode = _dirRep._sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).ToList();
  1850. //string countryStr = "";
  1851. int index = 0;
  1852. List<string> cityCodes = new List<string>();
  1853. //去掉开始和结束城市
  1854. foreach (var row in airDatas)
  1855. {
  1856. if (!string.IsNullOrEmpty(row.Three))
  1857. {
  1858. if (index == 0) cityCodes.Add(row.Three.Substring(3, 3)); //到达国家
  1859. else if (airDatas.Count() - 1 == index) cityCodes.Add(row.Three.Substring(0, 3)); //到达国家
  1860. else cityCodes.Add(row.Three.Substring(0, 3)); //到达国家
  1861. }
  1862. index++;
  1863. }
  1864. cityCodes = cityCodes.Distinct().ToList();
  1865. if (cityCodes.Count > 0) countryStr = "";
  1866. foreach (var item in cityCodes)
  1867. {
  1868. var airData = airDatas.Where(it => it.Three.Contains(item)).ToList();
  1869. string country = listcode.Find(it => it.Three.Equals(item))?.Country ?? "Unknown";
  1870. if (country.Equals("中国"))
  1871. {
  1872. country = listcode.Find(it => it.Three.Equals(item))?.City ?? "Unknown";
  1873. }
  1874. //int days = 0;
  1875. if (airData.Count == 2)
  1876. {
  1877. DateTime arr_dt = Convert.ToDateTime(airData[0].ArrivedDate); //抵达时间
  1878. DateTime dep_dt = Convert.ToDateTime(airData[1].Day); //离开时间
  1879. //days = (dep_dt - arr_dt).Days;
  1880. //countryStr += $@"{country}停留{days}日、";
  1881. countryStr += $@"{country}停留 日、";
  1882. }
  1883. }
  1884. if (countryStr.Length > 0) countryStr = countryStr.Substring(0, countryStr.Length - 1);
  1885. }
  1886. return countryStr;
  1887. }
  1888. /// <summary>
  1889. ///根据机票黑屏代码整理DataTable
  1890. /// </summary>
  1891. /// <param name="diid"></param>
  1892. /// <returns></returns>
  1893. public static DataTable GetTableByBlackCode1(int diid)
  1894. {
  1895. //黑屏代码信息
  1896. List<Air_TicketBlackCode> listcode = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  1897. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  1898. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  1899. DataTable dt = new DataTable();
  1900. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  1901. dt.Columns.Add("Date", typeof(string));//起飞日期
  1902. dt.Columns.Add("Three", typeof(string));//三字码
  1903. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  1904. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  1905. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  1906. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  1907. dt.Columns.Add("AirModel", typeof(string)); //机型
  1908. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  1909. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  1910. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  1911. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  1912. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  1913. //判断是否录入黑屏代码
  1914. if (listcode.Count == 0 || listcode == null)
  1915. {
  1916. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null);
  1917. }
  1918. else
  1919. {
  1920. //读取单段黑屏代码
  1921. for (int i = 0; i < listcode.Count; i++)
  1922. {
  1923. //去除序号
  1924. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  1925. //去除多余空格,方法一Linq扩展方法
  1926. CodeList = CodeList.Where(str => str != "").ToArray();
  1927. CodeList = CodeList.Where(str => str != " ").ToArray();
  1928. //年
  1929. int year = Convert.ToInt32(DateTime.Now.Year.ToString());
  1930. //读取单条黑屏代码
  1931. for (int j = 0; j < CodeList.Length; j++)
  1932. {
  1933. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  1934. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  1935. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1936. //string[] Info = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  1937. // .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1938. //去除多余空格
  1939. Info = Info.Where(str => str != "").ToArray();
  1940. Info = Info.Where(str => str != " ").ToArray();
  1941. //判断黑屏代码是否正确拆分; 理应拆成9段
  1942. if (Info.Length < 9)
  1943. {
  1944. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null);
  1945. }
  1946. else
  1947. {
  1948. try
  1949. {
  1950. //月
  1951. int month = Convert.ToInt32(GetLonger(Info[1].Substring(4, 3)));
  1952. //日
  1953. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  1954. #region 逐一比较月份,判断是否翻年;逐一比较三字码顶真,判断是否跑错机场
  1955. if (j > 0)
  1956. {
  1957. string[] Temp = CodeList[j - 1].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  1958. .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1959. Temp = Temp.Where(str => str != "").ToArray();
  1960. Temp = Temp.Where(str => str != " ").ToArray();
  1961. int monthTemp = Convert.ToInt32(GetLonger(Temp[1].Substring(4, 3)));
  1962. // 如果相邻月份之差小于0,则证明次一条年份需+1
  1963. if (month - monthTemp < 0)
  1964. {
  1965. year = year + 1;
  1966. }
  1967. //如果相邻代码三字码不顶真,提醒
  1968. string FootThree = Temp[2].Substring(3, 3);
  1969. string HeadThree = Info[2].Substring(0, 3);
  1970. if (FootThree != HeadThree)
  1971. {
  1972. //DelegationInfoService s = new DelegationInfoService();
  1973. //UsersService us = new UsersService();
  1974. //GroupsTaskAssignmentService gts = new GroupsTaskAssignmentService();
  1975. //77 行程
  1976. List<Grp_GroupsTaskAssignment> list2 = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 77 && x.DIId == diid && x.IsDel == 0).ToList();
  1977. foreach (var temp in list2)
  1978. {
  1979. //if (temp.UId != 21)
  1980. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  1981. // "黑屏代码提醒",
  1982. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  1983. }
  1984. //85 机票预订
  1985. List<Grp_GroupsTaskAssignment> list6 = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 85 && x.DIId == diid && x.IsDel == 0).ToList();
  1986. foreach (var temp in list6)
  1987. {
  1988. //if (temp.UId != 21)
  1989. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  1990. // "黑屏代码提醒",
  1991. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  1992. }
  1993. }
  1994. }
  1995. #endregion
  1996. #region 判断到达日期是否需要加1
  1997. if (Info[4].Contains("+"))
  1998. {
  1999. //日期+1
  2000. day = day + 1;
  2001. //判断是否进入下一月
  2002. if (day > Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year)))
  2003. {
  2004. day = day - Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year));
  2005. month = month + 1;
  2006. //判断是否进入下一年
  2007. if (month > 12)
  2008. {
  2009. month = month - 12;
  2010. year = year + 1;
  2011. }
  2012. }
  2013. //月份整理格式
  2014. string monthTemp = month.ToString();
  2015. if (month < 10)
  2016. {
  2017. monthTemp = "0" + monthTemp;
  2018. }
  2019. //日期整理格式
  2020. string daytemp = day.ToString();
  2021. if (day < 10)
  2022. {
  2023. daytemp = "0" + daytemp;
  2024. }
  2025. string temp = Info[4].Split('+')[0];
  2026. //添加起飞数据
  2027. dt.Rows.Add(Info[0],
  2028. Info[1],
  2029. Info[2],
  2030. Info[3],
  2031. temp,
  2032. Info[5],
  2033. Info[6],
  2034. Info[7],
  2035. Info[8],
  2036. year + "-" + GetLonger(Info[1].Substring(4, 3)) + "-" + Info[1].Substring(2, 2),
  2037. year + "-" + monthTemp + "-" + daytemp,
  2038. "",
  2039. "0");
  2040. //加1天,添加到达数据
  2041. dt.Rows.Add(Info[0],
  2042. Info[1].Replace(Info[1].Substring(2, 2), daytemp),
  2043. Info[2],
  2044. Info[3],
  2045. temp,
  2046. Info[5],
  2047. Info[6],
  2048. Info[7],
  2049. Info[8],
  2050. year + "-" + monthTemp + "-" + daytemp,
  2051. year + "-" + monthTemp + "-" + daytemp,
  2052. "",
  2053. "1");
  2054. }
  2055. else
  2056. {
  2057. //月份整理格式
  2058. string monthTemp = month.ToString();
  2059. if (month < 10)
  2060. {
  2061. monthTemp = "0" + monthTemp;
  2062. }
  2063. //日期整理格式
  2064. string daytemp = day.ToString();
  2065. if (day < 10)
  2066. {
  2067. daytemp = "0" + daytemp;
  2068. }
  2069. dt.Rows.Add(Info[0],
  2070. Info[1],
  2071. Info[2],
  2072. Info[3],
  2073. Info[4],
  2074. Info[5],
  2075. Info[6],
  2076. Info[7],
  2077. Info[8],
  2078. year + "-" + monthTemp + "-" + daytemp,
  2079. year + "-" + monthTemp + "-" + daytemp,
  2080. "",
  2081. "0");
  2082. }
  2083. #endregion
  2084. }
  2085. catch (Exception ex)
  2086. {
  2087. string exstr = ex.Message.ToString();
  2088. }
  2089. }
  2090. }
  2091. //排序
  2092. dt.DefaultView.Sort = "Day asc";
  2093. dt = dt.DefaultView.ToTable();
  2094. }
  2095. }
  2096. return dt;
  2097. }
  2098. private readonly static string[] excludeArr = new string[] { "[中转]", "[转机]", "[国内]" };
  2099. /// <summary>
  2100. ///根据机票黑屏代码整理DataTable
  2101. /// </summary>
  2102. /// <param name="diid"></param>
  2103. /// <returns></returns>
  2104. public static DataTable GetTableByBlackCode(int diid)
  2105. {
  2106. //黑屏代码信息
  2107. List<Air_TicketBlackCode> listcode = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  2108. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  2109. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  2110. DataTable dt = new DataTable();
  2111. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  2112. dt.Columns.Add("Date", typeof(string));//起飞日期
  2113. dt.Columns.Add("Three", typeof(string));//三字码
  2114. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  2115. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  2116. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  2117. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  2118. dt.Columns.Add("AirModel", typeof(string)); //机型
  2119. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  2120. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  2121. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  2122. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  2123. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  2124. //添加转机标识
  2125. dt.Columns.Add("isTransitShipment", typeof(bool));
  2126. //判断是否录入黑屏代码
  2127. if (listcode.Count == 0 || listcode == null)
  2128. {
  2129. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null, false);
  2130. }
  2131. else
  2132. {
  2133. //读取单段黑屏代码
  2134. for (int i = 0; i < listcode.Count; i++)
  2135. {
  2136. //去除序号
  2137. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  2138. //去除多余空格,方法一Linq扩展方法
  2139. CodeList = CodeList.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  2140. //读取单条黑屏代码
  2141. for (int j = 0; j < CodeList.Length; j++)
  2142. {
  2143. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  2144. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  2145. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2146. //去除多余空格
  2147. Info = Info.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  2148. //判断黑屏代码是否正确拆分; 理应拆成9段
  2149. if (Info.TakeWhile((x) =>
  2150. {
  2151. return !excludeArr.Contains(x);
  2152. }).Count() != 9)
  2153. {
  2154. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null, false);
  2155. //MessageBoxEx.Show("第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误, 请联系机票同事核对");
  2156. return dt;
  2157. }
  2158. else
  2159. {
  2160. try
  2161. {
  2162. var monthEn = Info[1].Substring(4, 3);
  2163. //月
  2164. int month = Convert.ToInt32(GetLonger(monthEn));
  2165. //日
  2166. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  2167. var time = new DateTime(DateTime.Now.Year, month, day); //
  2168. var isExist = Info.Contains("[中转]");
  2169. //dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  2170. //dt.Columns.Add("Date", typeof(string));//起飞日期
  2171. //dt.Columns.Add("Three", typeof(string));//三字码
  2172. //dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  2173. //dt.Columns.Add("EndTime", typeof(string));//到达时刻
  2174. //dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  2175. //dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  2176. //dt.Columns.Add("AirModel", typeof(string)); //机型
  2177. //dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  2178. //dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  2179. //dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  2180. //dt.Columns.Add("Error", typeof(string));//整理的到达日期
  2181. //dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  2182. dt.Rows.Add(Info[0],
  2183. Info[1],
  2184. Info[2],
  2185. Info[3],
  2186. Info[4],
  2187. Info[5],
  2188. Info[6],
  2189. Info[7],
  2190. Info[8],
  2191. time.ToString("yyyy-MM-dd"),
  2192. time.ToString("yyyy-MM-dd"),
  2193. "",
  2194. "0",
  2195. isExist
  2196. );
  2197. }
  2198. catch (Exception ex)
  2199. {
  2200. string exstr = ex.Message.ToString();
  2201. }
  2202. }
  2203. }
  2204. //排序
  2205. dt.DefaultView.Sort = "Day asc";
  2206. dt = dt.DefaultView.ToTable();
  2207. }
  2208. }
  2209. return dt;
  2210. }
  2211. /// <summary>
  2212. ///根据黑屏代码整理DataTable
  2213. /// </summary>
  2214. /// <param name="blackCode"></param>
  2215. /// <returns></returns>
  2216. public static DataTable GetTableByBlackCodeBySingle(Air_TicketBlackCode blackCode)
  2217. {
  2218. DataTable dt = new DataTable();
  2219. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  2220. dt.Columns.Add("Date", typeof(string));//起飞日期
  2221. dt.Columns.Add("Three", typeof(string));//三字码
  2222. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  2223. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  2224. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  2225. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  2226. dt.Columns.Add("AirModel", typeof(string)); //机型
  2227. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  2228. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  2229. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  2230. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  2231. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  2232. //添加转机标识
  2233. dt.Columns.Add("isTransitShipment", typeof(bool));
  2234. //添加国内段标识
  2235. dt.Columns.Add("isDomesticSection", typeof(bool));
  2236. //判断是否录入黑屏代码
  2237. if (blackCode == null)
  2238. {
  2239. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null, false, false);
  2240. }
  2241. else
  2242. {
  2243. var listcode = new List<Air_TicketBlackCode> { blackCode };
  2244. //读取单段黑屏代码
  2245. for (int i = 0; i < listcode.Count; i++)
  2246. {
  2247. //去除序号
  2248. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  2249. //去除多余空格,方法一Linq扩展方法
  2250. CodeList = CodeList.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  2251. //读取单条黑屏代码
  2252. for (int j = 0; j < CodeList.Length; j++)
  2253. {
  2254. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  2255. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  2256. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2257. //去除多余空格
  2258. Info = Info.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  2259. //判断黑屏代码是否正确拆分; 理应拆成9段
  2260. if (Info.TakeWhile((x) =>
  2261. {
  2262. return !excludeArr.Contains(x);
  2263. }).Count() != 9)
  2264. {
  2265. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null, false, false);
  2266. //MessageBoxEx.Show("第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误, 请联系机票同事核对");
  2267. return dt;
  2268. }
  2269. else
  2270. {
  2271. try
  2272. {
  2273. var monthEn = Info[1].Substring(4, 3);
  2274. //月
  2275. int month = Convert.ToInt32(GetLonger(monthEn));
  2276. //日
  2277. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  2278. var time = new DateTime(DateTime.Now.Year, month, day); //
  2279. var isExist = Info.Contains("[中转]");
  2280. if (!isExist)
  2281. {
  2282. isExist = Info.Contains("[转机]");
  2283. }
  2284. var isDomesticSection = Info.Contains("[国内]");
  2285. if (isDomesticSection)
  2286. {
  2287. continue;
  2288. }
  2289. dt.Rows.Add(Info[0],
  2290. Info[1],
  2291. Info[2],
  2292. Info[3],
  2293. Info[4],
  2294. Info[5],
  2295. Info[6],
  2296. Info[7],
  2297. Info[8],
  2298. time.ToString("yyyy-MM-dd"),
  2299. time.ToString("yyyy-MM-dd"),
  2300. "",
  2301. ExtractNumberAfterPlus(Info[4]),
  2302. isExist,
  2303. isDomesticSection
  2304. );
  2305. }
  2306. catch (Exception ex)
  2307. {
  2308. string exstr = ex.Message.ToString();
  2309. }
  2310. }
  2311. }
  2312. //排序
  2313. dt.DefaultView.Sort = "Day asc";
  2314. dt = dt.DefaultView.ToTable();
  2315. }
  2316. }
  2317. return dt;
  2318. }
  2319. private static int ExtractNumberAfterPlus(string input)
  2320. {
  2321. int value = 0;
  2322. if (string.IsNullOrEmpty(input))
  2323. {
  2324. return value;
  2325. }
  2326. string pattern = @"\+\d+"; // 匹配“+”及其后的数字
  2327. Match match = Regex.Match(input, pattern);
  2328. if (match.Success)
  2329. {
  2330. int.TryParse(match.Value.Substring(1), out value); // 去掉“+”符号,只保留数字部分
  2331. }
  2332. return value;
  2333. }
  2334. /// <summary>
  2335. /// 根据星期,月份的缩写,转换成数字或者全称
  2336. /// 根据币种中文名称返回币种代码
  2337. /// 根据数字返回机型型号【2、3开头的就是空客,比如空客320,7开头的就是波音,比如波音777】
  2338. /// 20210903贾文滔
  2339. /// </summary>
  2340. /// <param name="temp"></param>
  2341. /// <returns></returns>
  2342. public static string GetLonger(string temp)
  2343. {
  2344. string str = "";
  2345. switch (temp.ToUpper())
  2346. {
  2347. case "美元":
  2348. str = "USD";
  2349. break;
  2350. case "日元":
  2351. str = "JPY";
  2352. break;
  2353. case "英镑":
  2354. str = "GBP";
  2355. break;
  2356. case "欧元":
  2357. str = "EUR";
  2358. break;
  2359. case "港币":
  2360. str = "HKD";
  2361. break;
  2362. case "MO":
  2363. str = "星期一";
  2364. break;
  2365. case "TU":
  2366. str = "星期二";
  2367. break;
  2368. case "WE":
  2369. str = "星期三";
  2370. break;
  2371. case "TH":
  2372. str = "星期四";
  2373. break;
  2374. case "FR":
  2375. str = "星期五";
  2376. break;
  2377. case "SA":
  2378. str = "星期六";
  2379. break;
  2380. case "SU":
  2381. str = "星期天";
  2382. break;
  2383. case "JAN":
  2384. str = "01";
  2385. break;
  2386. case "FEB":
  2387. str = "02";
  2388. break;
  2389. case "MAR":
  2390. str = "03";
  2391. break;
  2392. case "APR":
  2393. str = "04";
  2394. break;
  2395. case "MAY":
  2396. str = "05";
  2397. break;
  2398. case "JUN":
  2399. str = "06";
  2400. break;
  2401. case "JUL":
  2402. str = "07";
  2403. break;
  2404. case "AUG":
  2405. str = "08";
  2406. break;
  2407. case "SEP":
  2408. str = "09";
  2409. break;
  2410. case "OCT":
  2411. str = "10";
  2412. break;
  2413. case "NOV":
  2414. str = "11";
  2415. break;
  2416. case "DEC":
  2417. str = "12";
  2418. break;
  2419. case "MONDAY":
  2420. str = "星期一";
  2421. break;
  2422. case "TUESDAY":
  2423. str = "星期二";
  2424. break;
  2425. case "WEDNESDAY":
  2426. str = "星期三";
  2427. break;
  2428. case "THURSDAY":
  2429. str = "星期四";
  2430. break;
  2431. case "FRIDAY":
  2432. str = "星期五";
  2433. break;
  2434. case "SATURDAY":
  2435. str = "星期六";
  2436. break;
  2437. case "SUNDAY":
  2438. str = "星期日";
  2439. break;
  2440. case "01":
  2441. str = "JAN";
  2442. break;
  2443. case "02":
  2444. str = "FEB";
  2445. break;
  2446. case "03":
  2447. str = "MAR";
  2448. break;
  2449. case "04":
  2450. str = "APR";
  2451. break;
  2452. case "05":
  2453. str = "MAY";
  2454. break;
  2455. case "06":
  2456. str = "JUN";
  2457. break;
  2458. case "07":
  2459. str = "JUL";
  2460. break;
  2461. case "08":
  2462. str = "AUG";
  2463. break;
  2464. case "09":
  2465. str = "SEP";
  2466. break;
  2467. case "10":
  2468. str = "OCT";
  2469. break;
  2470. case "11":
  2471. str = "NOV";
  2472. break;
  2473. case "12":
  2474. str = "DEC";
  2475. break;
  2476. case "2":
  2477. str = "空客A";
  2478. break;
  2479. case "3":
  2480. str = "空客A";
  2481. break;
  2482. case "7":
  2483. str = "波音";
  2484. break;
  2485. }
  2486. return str;
  2487. }
  2488. /// <summary>
  2489. /// 根据月份返回天数
  2490. /// </summary>
  2491. /// <param name="Month"></param>
  2492. /// <param name="year"></param>
  2493. /// <returns></returns>
  2494. public static string GetDaysByMonth(string Month, int year)
  2495. {
  2496. string str = "";
  2497. //判断是否是闰年
  2498. if (DateTime.IsLeapYear(year) == false)
  2499. {
  2500. switch (Month.ToUpper())
  2501. {
  2502. case "JAN":
  2503. str = "31";
  2504. break;
  2505. case "FEB":
  2506. str = "28";
  2507. break;
  2508. case "MAR":
  2509. str = "31";
  2510. break;
  2511. case "APR":
  2512. str = "30";
  2513. break;
  2514. case "MAY":
  2515. str = "31";
  2516. break;
  2517. case "JUN":
  2518. str = "30";
  2519. break;
  2520. case "JUL":
  2521. str = "31";
  2522. break;
  2523. case "AUG":
  2524. str = "31";
  2525. break;
  2526. case "SEP":
  2527. str = "30";
  2528. break;
  2529. case "OCT":
  2530. str = "31";
  2531. break;
  2532. case "NOV":
  2533. str = "30";
  2534. break;
  2535. case "DEC":
  2536. str = "31";
  2537. break;
  2538. case "01":
  2539. str = "31";
  2540. break;
  2541. case "02":
  2542. str = "28";
  2543. break;
  2544. case "03":
  2545. str = "31";
  2546. break;
  2547. case "04":
  2548. str = "30";
  2549. break;
  2550. case "05":
  2551. str = "31";
  2552. break;
  2553. case "06":
  2554. str = "30";
  2555. break;
  2556. case "07":
  2557. str = "31";
  2558. break;
  2559. case "08":
  2560. str = "31";
  2561. break;
  2562. case "09":
  2563. str = "30";
  2564. break;
  2565. case "10":
  2566. str = "31";
  2567. break;
  2568. case "11":
  2569. str = "30";
  2570. break;
  2571. case "12":
  2572. str = "31";
  2573. break;
  2574. }
  2575. }
  2576. else
  2577. {
  2578. switch (Month.ToUpper())
  2579. {
  2580. case "JAN":
  2581. str = "31";
  2582. break;
  2583. case "FEB":
  2584. str = "29";
  2585. break;
  2586. case "MAR":
  2587. str = "31";
  2588. break;
  2589. case "APR":
  2590. str = "30";
  2591. break;
  2592. case "MAY":
  2593. str = "31";
  2594. break;
  2595. case "JUN":
  2596. str = "30";
  2597. break;
  2598. case "JUL":
  2599. str = "31";
  2600. break;
  2601. case "AUG":
  2602. str = "31";
  2603. break;
  2604. case "SEP":
  2605. str = "30";
  2606. break;
  2607. case "OCT":
  2608. str = "31";
  2609. break;
  2610. case "NOV":
  2611. str = "30";
  2612. break;
  2613. case "DEC":
  2614. str = "31";
  2615. break;
  2616. case "01":
  2617. str = "31";
  2618. break;
  2619. case "02":
  2620. str = "29";
  2621. break;
  2622. case "03":
  2623. str = "31";
  2624. break;
  2625. case "04":
  2626. str = "30";
  2627. break;
  2628. case "05":
  2629. str = "31";
  2630. break;
  2631. case "06":
  2632. str = "30";
  2633. break;
  2634. case "07":
  2635. str = "31";
  2636. break;
  2637. case "08":
  2638. str = "31";
  2639. break;
  2640. case "09":
  2641. str = "30";
  2642. break;
  2643. case "10":
  2644. str = "31";
  2645. break;
  2646. case "11":
  2647. str = "30";
  2648. break;
  2649. case "12":
  2650. str = "31";
  2651. break;
  2652. }
  2653. }
  2654. return str;
  2655. }
  2656. /// <summary>
  2657. /// op行程单 团组 城市路径
  2658. /// </summary>
  2659. /// <param name="diid">团组Id</param>
  2660. /// <param name="separator">分隔符</param>
  2661. /// <returns></returns>
  2662. public static string GetGroupCityLine(int diid, string separator)
  2663. {
  2664. string city = string.Empty;
  2665. var blackCode = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  2666. if (blackCode.Count > 0)
  2667. {
  2668. var black = blackCode.First();
  2669. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  2670. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  2671. if (blackSp.Length > 0)
  2672. {
  2673. try
  2674. {
  2675. var cityArrCode = new List<string>(20);
  2676. foreach (var item in blackSp)
  2677. {
  2678. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  2679. var IndexSelect = itemSp[2];
  2680. var cityArrCodeLength = cityArrCode.Count - 1;
  2681. var startCity = IndexSelect.Substring(0, 3);
  2682. if (cityArrCodeLength > 0)
  2683. {
  2684. var arrEndCity = cityArrCode[cityArrCodeLength];
  2685. if (arrEndCity != startCity)
  2686. {
  2687. cityArrCode.Add(startCity.ToUpper());
  2688. }
  2689. }
  2690. else
  2691. {
  2692. cityArrCode.Add(startCity.ToUpper());
  2693. }
  2694. var endCity = IndexSelect.Substring(3, 3);
  2695. cityArrCode.Add(endCity.ToUpper());
  2696. }
  2697. var cityThree = string.Empty;
  2698. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  2699. cityThree = cityThree.TrimEnd(',');
  2700. if (string.IsNullOrWhiteSpace(cityThree))
  2701. {
  2702. throw new Exception("error");
  2703. }
  2704. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  2705. var cityArr = _dirRep._sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  2706. foreach (var item in cityArrCode)
  2707. {
  2708. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  2709. if (find != null)
  2710. {
  2711. city += find.City + separator;
  2712. }
  2713. else
  2714. {
  2715. city += item + "[三字码未收录]" + separator;
  2716. }
  2717. }
  2718. city = city.TrimEnd(char.Parse(separator));
  2719. }
  2720. catch (Exception e)
  2721. {
  2722. city = "[黑屏代码格式不正确!]";
  2723. }
  2724. }
  2725. }
  2726. else city = "[未录入黑屏代码]";
  2727. return city;
  2728. }
  2729. /// <summary>
  2730. /// op行程单 团组 城市路径
  2731. /// </summary>
  2732. /// <param name="black">黑屏代码实例</param>
  2733. /// <param name="separator">分隔符</param>
  2734. /// <returns></returns>
  2735. public static string GetGroupCityLine(Air_TicketBlackCode black, string separator)
  2736. {
  2737. string city = string.Empty;
  2738. if (black != null)
  2739. {
  2740. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  2741. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  2742. if (blackSp.Length > 0)
  2743. {
  2744. try
  2745. {
  2746. var cityArrCode = new List<string>(20);
  2747. foreach (var item in blackSp)
  2748. {
  2749. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  2750. var IndexSelect = itemSp[2];
  2751. var cityArrCodeLength = cityArrCode.Count - 1;
  2752. var startCity = IndexSelect.Substring(0, 3);
  2753. if (cityArrCodeLength > 0)
  2754. {
  2755. var arrEndCity = cityArrCode[cityArrCodeLength];
  2756. if (arrEndCity != startCity)
  2757. {
  2758. cityArrCode.Add(startCity.ToUpper());
  2759. }
  2760. }
  2761. else
  2762. {
  2763. cityArrCode.Add(startCity.ToUpper());
  2764. }
  2765. var endCity = IndexSelect.Substring(3, 3);
  2766. cityArrCode.Add(endCity.ToUpper());
  2767. }
  2768. var cityThree = string.Empty;
  2769. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  2770. cityThree = cityThree.TrimEnd(',');
  2771. if (string.IsNullOrWhiteSpace(cityThree))
  2772. {
  2773. throw new Exception("error");
  2774. }
  2775. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  2776. var cityArr = _dirRep._sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  2777. foreach (var item in cityArrCode)
  2778. {
  2779. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  2780. if (find != null)
  2781. {
  2782. city += find.City + separator;
  2783. }
  2784. else
  2785. {
  2786. city += item + "[三字码未收录]" + separator;
  2787. }
  2788. }
  2789. city = city.TrimEnd(char.Parse(separator));
  2790. }
  2791. catch (Exception e)
  2792. {
  2793. city = "[黑屏代码格式不正确!]";
  2794. }
  2795. }
  2796. }
  2797. else city = "[黑屏代码有误!]";
  2798. return city;
  2799. }
  2800. /// <summary>
  2801. /// op行程单 团组 城市路径
  2802. /// </summary>
  2803. /// <param name="diids">团组Id</param>
  2804. /// <param name="separator">分隔符</param>
  2805. /// <returns></returns>
  2806. public static Dictionary<int, string> GetGroupCityLineItem(List<int> diids, string separator)
  2807. {
  2808. Dictionary<int, string> dicCitys = new Dictionary<int, string>();
  2809. var cityCodes = _dirRep._sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  2810. var blackCodes = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && diids.Contains(x.DiId)).ToList();
  2811. foreach (var diid in diids)
  2812. {
  2813. string city = string.Empty;
  2814. var blackCode = blackCodes.Where(it => it.DiId == diid).ToList();
  2815. if (blackCode.Count > 0)
  2816. {
  2817. var black = blackCode.First();
  2818. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  2819. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  2820. if (blackSp.Length > 0)
  2821. {
  2822. try
  2823. {
  2824. var cityArrCode = new List<string>(20);
  2825. foreach (var item in blackSp)
  2826. {
  2827. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  2828. var IndexSelect = itemSp[2];
  2829. var cityArrCodeLength = cityArrCode.Count - 1;
  2830. var startCity = IndexSelect.Substring(0, 3);
  2831. if (cityArrCodeLength > 0)
  2832. {
  2833. var arrEndCity = cityArrCode[cityArrCodeLength];
  2834. if (arrEndCity != startCity)
  2835. {
  2836. cityArrCode.Add(startCity.ToUpper());
  2837. }
  2838. }
  2839. else
  2840. {
  2841. cityArrCode.Add(startCity.ToUpper());
  2842. }
  2843. var endCity = IndexSelect.Substring(3, 3);
  2844. cityArrCode.Add(endCity.ToUpper());
  2845. }
  2846. var cityThree = string.Empty;
  2847. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  2848. cityThree = cityThree.TrimEnd(',');
  2849. if (string.IsNullOrWhiteSpace(cityThree))
  2850. {
  2851. throw new Exception("error");
  2852. }
  2853. var cityArr = cityCodes.Where(it => cityThree.Contains(it.Three.ToUpper())).ToList();
  2854. foreach (var item in cityArrCode)
  2855. {
  2856. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  2857. if (find != null)
  2858. {
  2859. city += find.City + separator;
  2860. }
  2861. else
  2862. {
  2863. city += item + "[三字码未收录]" + separator;
  2864. }
  2865. }
  2866. city = city.TrimEnd(char.Parse(separator));
  2867. }
  2868. catch (Exception e)
  2869. {
  2870. city = "[黑屏代码格式不正确!]";
  2871. }
  2872. }
  2873. }
  2874. else city = "[未录入黑屏代码]";
  2875. dicCitys.Add(diid, city);
  2876. }
  2877. return dicCitys;
  2878. }
  2879. /// <summary>
  2880. /// op行程单相关团组信息 含途径城市
  2881. /// </summary>
  2882. /// <returns></returns>
  2883. public static async Task<List<MateOpGroupPageListView>> MateOpGroupPageListRedis()
  2884. {
  2885. List<MateOpGroupPageListView> _views = new List<MateOpGroupPageListView>();
  2886. string viewStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("MateOpGroupPageList");//string 取
  2887. if (!string.IsNullOrEmpty(viewStr))
  2888. {
  2889. _views = JsonConvert.DeserializeObject<List<MateOpGroupPageListView>>(viewStr);
  2890. }
  2891. else
  2892. {
  2893. string sql = string.Format($@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2894. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  2895. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  2896. JietuanOperator,IsSure,CreateTime,VisitCountry
  2897. From (
  2898. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  2899. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  2900. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  2901. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  2902. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.VisitCountry
  2903. From Grp_DelegationInfo gdi
  2904. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2905. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2906. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2907. Where gdi.IsDel = 0
  2908. ) temp");
  2909. _views = _dirRep._sqlSugar.SqlQueryable<MateOpGroupPageListView>(sql).ToList();
  2910. #region 处理所属部门
  2911. /*
  2912. * 1.sq 和 gyy 等显示 市场部
  2913. * 2.王鸽和主管及张总还有管理员号统一国交部
  2914. * 2-1. 4 管理员 ,21 张海麟
  2915. */
  2916. List<int> userIds = _views.Select(it => it.JietuanOperatorId).ToList();
  2917. List<int> userIds1 = new List<int>() { 4, 21 };
  2918. var UserDepDatas = _dirRep._sqlSugar.Queryable<Sys_Users>()
  2919. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  2920. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  2921. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  2922. .ToList();
  2923. #endregion
  2924. _views.ForEach(it =>
  2925. {
  2926. it.RouteCity = GetGroupCityLine(it.Id, @"/");
  2927. it.Department = UserDepDatas.Find(it1 => it.JietuanOperatorId == it1.UserId)?.DepName ?? "Unknown";
  2928. });
  2929. TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay;
  2930. await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("MateOpGroupPageList", JsonConvert.SerializeObject(_views), ts);//string 存
  2931. }
  2932. return _views;
  2933. }
  2934. /// <summary>
  2935. /// 获取黑屏代码日期列表
  2936. /// </summary>
  2937. /// <param name="dt"></param>
  2938. /// <returns></returns>
  2939. public static List<string> GetTimeListByDataTable(DataTable dt)
  2940. {
  2941. DateTime datestart = Convert.ToDateTime(dt.Rows[0]["Day"].ToString());
  2942. DateTime dateend = Convert.ToDateTime(dt.Rows[dt.Rows.Count - 1]["ArrivedDate"].ToString());
  2943. List<string> timeList = new List<string>();
  2944. while (datestart <= dateend)
  2945. {
  2946. timeList.Add(datestart.ToString("yyyy-MM-dd"));
  2947. datestart = datestart.AddDays(1);
  2948. }
  2949. return timeList;
  2950. }
  2951. const decimal conversion = 1.61M;
  2952. /// <summary>
  2953. /// 简要行程
  2954. /// </summary>
  2955. /// <param name="diid"></param>
  2956. /// <returns></returns>
  2957. public static Result GetBriefStroke(int diid)
  2958. {
  2959. DataTable resultTable = GetTableByBlackCode(diid);
  2960. if (resultTable == null)
  2961. {
  2962. return new Result { Code = -1, Msg = "黑屏代码有误或黑屏代码未录入" };
  2963. }
  2964. if (resultTable.Rows.Count == 0 || string.IsNullOrWhiteSpace(resultTable.Rows[0][1].ToString()))
  2965. {
  2966. string msg = string.Empty;
  2967. if (resultTable.Rows.Count > 0)
  2968. {
  2969. msg = resultTable.Rows[0]["Error"].ToString();
  2970. }
  2971. return new Result { Code = -1, Msg = $"黑屏代码有误;{msg}" };
  2972. }
  2973. var timeArr = GetTimeListByDataTable(resultTable);
  2974. var threeCodes = _dirRep._sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList(); //三字码
  2975. var airCompanys = _dirRep._sqlSugar.Queryable<Res_AirCompany>().Where(it => it.IsDel == 0).ToList(); //航司公司
  2976. var obDatas = _dirRep._sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == diid).ToList(); //公务信息
  2977. var NewListTravel = new List<Grp_TravelList>();
  2978. var index = 0;
  2979. var stopCity = string.Empty;
  2980. foreach (var item in timeArr)
  2981. {
  2982. string trip = string.Empty;
  2983. string weekDay = string.Empty;
  2984. DateTime time = DateTime.Now;
  2985. if (DateTime.TryParse(item, out time))
  2986. {
  2987. weekDay = weekdays[(int)time.DayOfWeek];
  2988. }
  2989. else
  2990. {
  2991. weekDay = "日期格式不正确!";
  2992. }
  2993. var empty = "【未收入该三字码!请机票同事录入】";
  2994. var tabSelect = resultTable.Select(string.Format("Day = '{0}'", item));
  2995. var isMoreTraffic = false;
  2996. if (tabSelect.Length > 0)
  2997. {
  2998. isMoreTraffic = true;
  2999. var takeOffTime = DateTime.Parse(item);
  3000. var fallToTime = DateTime.Parse(item);
  3001. Res_ThreeCode start_Object = null;
  3002. Res_ThreeCode end_Object = null;
  3003. //bool isTrade = false;
  3004. //air 处理
  3005. foreach (var tabRow in tabSelect)
  3006. {
  3007. takeOffTime = DateTime.Parse(item);
  3008. fallToTime = DateTime.Parse(item);
  3009. var takeOff = tabRow["StartTime"].ToString();
  3010. var fallTo = tabRow["EndTime"].ToString();
  3011. takeOffTime = takeOffTime.AddHours(int.Parse(takeOff.Substring(0, 2)));
  3012. takeOffTime = takeOffTime.AddMinutes(int.Parse(takeOff.Substring(2, 2)));
  3013. fallToTime = fallToTime.AddHours(int.Parse(fallTo.Substring(0, 2)));
  3014. fallToTime = fallToTime.AddMinutes(int.Parse(fallTo.Substring(2, 2)));
  3015. var threeCode = tabRow["Three"].ToString();
  3016. var start = threeCode.Substring(0, 3);
  3017. var end = threeCode.Substring(3, 3);
  3018. stopCity = end;
  3019. start_Object = threeCodes.Find(x => x.Three.ToUpper() == start.ToUpper());
  3020. end_Object = threeCodes.Find(x => x.Three.ToUpper() == end.ToUpper());
  3021. if (start_Object == null)
  3022. {
  3023. start_Object = new Res_ThreeCode()
  3024. {
  3025. AirPort = empty,
  3026. AirPort_En = empty,
  3027. City = empty,
  3028. Country = empty,
  3029. Four = empty,
  3030. Three = empty,
  3031. };
  3032. }
  3033. if (end_Object == null)
  3034. {
  3035. end_Object = new Res_ThreeCode()
  3036. {
  3037. AirPort = empty,
  3038. AirPort_En = empty,
  3039. City = empty,
  3040. Country = empty,
  3041. Four = empty,
  3042. Three = empty,
  3043. };
  3044. }
  3045. //航班号
  3046. string flightcode = tabRow["Fliagtcode"].ToString();
  3047. trip += $"{takeOffTime.ToString("HH:mm")}—{fallToTime.ToString("HH:mm")} {start_Object.City}—{end_Object.City} 航班号:{flightcode}\r\n";
  3048. }
  3049. //var airArrive = fallToTime; //航班落地时间
  3050. time = fallToTime.AddHours(1.5); //出机场一个半小时
  3051. string Time = string.Empty;
  3052. string Distance = string.Empty;
  3053. int GetGoogleResult = 0;
  3054. int GetDistResult = 0;
  3055. JObject Result = null;
  3056. try
  3057. {
  3058. Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace(" ", "").Trim();
  3059. Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString().Replace(" ", "").Trim();
  3060. if (Time.Contains("hours"))
  3061. {
  3062. Time = Time.Replace("hours", "小时");
  3063. }
  3064. if (Time.Contains("hour"))
  3065. {
  3066. Time = Time.Replace("hour", "小时");
  3067. }
  3068. Time = Time.Replace("mins", "分钟");
  3069. if (Distance.Contains("mi"))
  3070. {
  3071. var distSp = Regex.Split(Distance, "mi");
  3072. if (distSp.Length > 0)
  3073. {
  3074. Distance = (decimal.Parse(distSp[0]) * conversion).ToString("#0.00") + " 公里";
  3075. }
  3076. }
  3077. if (Distance.Contains("km"))
  3078. {
  3079. Distance = Distance.Replace("km", "公里");
  3080. }
  3081. if (Time.Contains("小时"))
  3082. {
  3083. var xs = Regex.Split(Time, "小时");
  3084. var xsValue = int.Parse(xs[0]);
  3085. var fz = Regex.Split(xs[1], "分钟");
  3086. var fzValue = int.Parse(fz[0]);
  3087. GetGoogleResult = xsValue * 60;
  3088. GetGoogleResult += fzValue;
  3089. }
  3090. else if (Time.Contains("分钟"))
  3091. {
  3092. GetGoogleResult = int.Parse(Regex.Split(Time, "分钟")[0]);
  3093. }
  3094. if (Distance.Contains("公里"))
  3095. {
  3096. GetDistResult = (int)decimal.Parse(Regex.Split(Distance, "公里")[0]);
  3097. }
  3098. if (GetGoogleResult > 0 && GetGoogleResult % 5 != 0)
  3099. {
  3100. while (GetGoogleResult % 5 != 0)
  3101. {
  3102. GetGoogleResult++;
  3103. }
  3104. }
  3105. if (GetDistResult % 5 != 0 && GetDistResult > 0)
  3106. {
  3107. while (GetDistResult % 5 != 0)
  3108. {
  3109. GetDistResult++;
  3110. }
  3111. }
  3112. int H = (GetGoogleResult / 60);
  3113. int m = (GetGoogleResult % 60);
  3114. string TimeStr = string.Empty;
  3115. if (H != 0)
  3116. {
  3117. if (H < 10)
  3118. {
  3119. TimeStr += "0" + H + "小时";
  3120. }
  3121. else
  3122. {
  3123. TimeStr += H + "小时";
  3124. }
  3125. }
  3126. if (m < 10)
  3127. {
  3128. TimeStr += "0" + m + "分钟";
  3129. }
  3130. else
  3131. {
  3132. TimeStr += m + "分钟";
  3133. }
  3134. Time = TimeStr;
  3135. Distance = GetDistResult.ToString() + "公里";
  3136. }
  3137. catch (Exception ex)
  3138. {
  3139. Time = "未知!";
  3140. Distance = "未知!";
  3141. }
  3142. //trip += $"{time.ToString("HH:mm")} 搭乘专车前往市区({end_Object.AirPort} - {end_Object.City}市区 路程{Distance},耗时{Time})";
  3143. //trip += $"{time.ToString("HH:mm")} 搭乘专车前往市区({end_Object.AirPort} - {end_Object.City}市区)";
  3144. time = time.AddMinutes(GetGoogleResult); //到达市区时间
  3145. string tripDate = Convert.ToDateTime(item).ToString("M月d日");
  3146. if (index == timeArr.Count - 1)
  3147. {
  3148. NewListTravel.Add(new Grp_TravelList
  3149. {
  3150. CreateTime = DateTime.Now,
  3151. CreateUserId = 0,
  3152. Diid = diid,
  3153. Date = tripDate,
  3154. Trip = trip,
  3155. WeekDay = weekDay,
  3156. Days = index + 1,
  3157. Traffic_First = "飞机",
  3158. Traffic_Second = "汽车",
  3159. Diffgroup = 1,
  3160. Issel = 1,
  3161. IsDel = 0,
  3162. });
  3163. continue;
  3164. }
  3165. if (time.Day != fallToTime.Day) //超出一天
  3166. {
  3167. NewListTravel.Add(new Grp_TravelList
  3168. {
  3169. CreateTime = DateTime.Now,
  3170. CreateUserId = 0,
  3171. Diid = diid,
  3172. Date = tripDate,
  3173. Trip = trip,
  3174. WeekDay = weekDay,
  3175. Days = index + 1,
  3176. Traffic_First = "飞机",
  3177. Traffic_Second = "汽车",
  3178. Diffgroup = 1,
  3179. Issel = 1,
  3180. IsDel = 0,
  3181. });
  3182. continue;
  3183. }
  3184. var obInfo = obDatas.Find(it => Convert.ToDateTime(it.Date).ToString("M月d日").Equals(tripDate));
  3185. string obtime = "";
  3186. string obcontent = "";
  3187. if (obInfo != null)
  3188. {
  3189. obtime = obInfo.Time;
  3190. obcontent = $"拜访{obInfo.Client ?? "公务出访单位未录入"}{obInfo.Job ?? "公务出访联系人职务未录入"}{obInfo.Contact ?? "公务出访联系人职务未录入"}";
  3191. }
  3192. bool obTime_bool = DateTime.TryParse(obtime, out DateTime obTimeDt);
  3193. if (time.Hour < 9) // && (airArrive < new DateTime(airArrive.Year,airArrive.Month,airArrive.Day,6, 30, 0))
  3194. {
  3195. if (obTime_bool)
  3196. {
  3197. if (obTimeDt.Hour < 9)
  3198. {
  3199. trip += $"{obTimeDt.ToString("HH:mm")}—10:30 {obcontent};\r\n";
  3200. }
  3201. }
  3202. else
  3203. {
  3204. trip += "09:00—10:30 公务活动;\r\n";
  3205. }
  3206. }
  3207. else if (time.Hour < 10)
  3208. {
  3209. if (obTime_bool)
  3210. {
  3211. if (obTimeDt.Hour < 10)
  3212. {
  3213. trip += $"{obTimeDt.ToString("HH:mm")}—12:00 {obcontent};\r\n";
  3214. }
  3215. }
  3216. else
  3217. {
  3218. trip += "10:30—12:00 公务活动;\r\n";
  3219. }
  3220. }
  3221. if (time.Hour < 13)
  3222. {
  3223. //trip += $"\r\n{time.ToString("HH:mm")} 午餐于当地餐厅;";
  3224. }
  3225. if (time < new DateTime(time.Year, time.Month, time.Day, 14, 30, 0))
  3226. {
  3227. if (obTime_bool)
  3228. {
  3229. if (obTimeDt < new DateTime(time.Year, time.Month, time.Day, 14, 30, 0))
  3230. {
  3231. trip += $"{obTimeDt.ToString("HH:mm")}—16:00 {obcontent};\r\n";
  3232. }
  3233. }
  3234. else
  3235. {
  3236. trip += "14:00—16:00 公务活动;\r\n";
  3237. }
  3238. }
  3239. else if (time.Hour < 16)
  3240. {
  3241. if (obTime_bool)
  3242. {
  3243. if (obTimeDt.Hour < 16)
  3244. {
  3245. trip += $"{obTimeDt.ToString("HH:mm")}—17:30 {obcontent};\r\n";
  3246. }
  3247. }
  3248. else
  3249. {
  3250. trip += "16:00—17:30 公务活动;\r\n";
  3251. }
  3252. }
  3253. //if (time.Hour < 18)
  3254. //{
  3255. // trip += $"\r\n18:00 晚餐于当地餐厅;";
  3256. //}
  3257. //time = time.AddHours(1);
  3258. //trip += $"\r\n{time.ToString("HH:mm")} 搭乘专车前往酒店,抵达后办理入住;";
  3259. }
  3260. else
  3261. {
  3262. var end_Object = threeCodes.Find(x => x.Three.ToUpper() == stopCity.ToUpper());
  3263. if (end_Object == null)
  3264. {
  3265. end_Object = new Res_ThreeCode()
  3266. {
  3267. AirPort = empty,
  3268. AirPort_En = empty,
  3269. City = empty,
  3270. Country = empty,
  3271. Four = empty,
  3272. Three = empty,
  3273. };
  3274. }
  3275. //trip += $"{end_Object.City}\r\n";
  3276. // trip += @"08:00 早餐于酒店;
  3277. //09:00—10:30 公务活动;
  3278. //12:00 午餐于当地餐厅;
  3279. //14:00—16:00 公务活动;
  3280. //18:00 晚餐于当地餐厅;
  3281. //19:00 入住酒店休息;";
  3282. trip += "09:00—10:30 公务活动;\r\n14:00—16:00 公务活动;\r\n";
  3283. }
  3284. string[] traffic = new string[] { "飞机", "汽车" };
  3285. if (!isMoreTraffic)
  3286. {
  3287. traffic = new string[] { "汽车", "" };
  3288. }
  3289. NewListTravel.Add(new Grp_TravelList
  3290. {
  3291. CreateTime = DateTime.Now,
  3292. CreateUserId = 0,
  3293. Diid = diid,
  3294. Date = Convert.ToDateTime(item).ToString("M月d日"),
  3295. Trip = trip,
  3296. WeekDay = weekDay,
  3297. Days = index + 1,
  3298. Traffic_First = traffic[0],
  3299. Traffic_Second = traffic[1],
  3300. Diffgroup = 1,
  3301. Issel = 1,
  3302. IsDel = 0,
  3303. });
  3304. index++;
  3305. }
  3306. return new Result() { Code = 0, Msg = "获取成功!", Data = NewListTravel };
  3307. }
  3308. /// <summary>
  3309. /// 根据日期获取星期
  3310. /// </summary>
  3311. /// <param name="dtStr"></param>
  3312. /// <returns></returns>
  3313. public static string GetWeek(this string dtStr)
  3314. {
  3315. string week = "";
  3316. bool isDt = DateTime.TryParse(dtStr, out DateTime dt);
  3317. if (isDt)
  3318. {
  3319. week = weekdays[(int)dt.DayOfWeek];
  3320. }
  3321. return week;
  3322. }
  3323. #endregion
  3324. #region 计算国家城市当时时间
  3325. /// <summary>
  3326. /// 中文城市名称映射
  3327. /// </summary>
  3328. private static readonly Dictionary<string, string> _timeZoneCityMappings = new Dictionary<string, string>
  3329. {
  3330. {"Africa/Abidjan","非洲/阿比让"} ,
  3331. {"Africa/Accra","非洲/阿克拉"} ,
  3332. {"Africa/Addis_Ababa","非洲/亚的斯亚贝巴"} ,
  3333. {"Africa/Algiers","非洲/阿尔及尔"} ,
  3334. {"Africa/Asmara","非洲/阿斯马拉"} ,
  3335. {"Africa/Asmera","非洲/阿斯梅拉"} ,
  3336. {"Africa/Bamako","非洲/巴马科"} ,
  3337. {"Africa/Bangui","非洲/班吉"} ,
  3338. {"Africa/Banjul","非洲/班珠尔"} ,
  3339. {"Africa/Bissau","非洲/比绍"} ,
  3340. {"Africa/Blantyre","非洲/布兰太尔"} ,
  3341. {"Africa/Brazzaville","非洲/布拉柴维尔"} ,
  3342. {"Africa/Bujumbura","非洲/布琼布拉"} ,
  3343. {"Africa/Cairo","非洲/开罗"} ,
  3344. {"Africa/Casablanca","非洲/卡萨布兰卡"} ,
  3345. {"Africa/Ceuta","非洲/休达"} ,
  3346. {"Africa/Conakry","非洲/科纳克里"} ,
  3347. {"Africa/Dakar","非洲/达喀尔"} ,
  3348. {"Africa/Dar_es_Salaam","非洲/达累斯萨拉姆"} ,
  3349. {"Africa/Djibouti","非洲/吉布提"} ,
  3350. {"Africa/Douala","非洲/杜阿拉"} ,
  3351. {"Africa/El_Aaiun","非洲/阿尤恩"} ,
  3352. {"Africa/Freetown","非洲/弗里敦"} ,
  3353. {"Africa/Gaborone","非洲/哈博罗内"} ,
  3354. {"Africa/Harare","非洲/哈拉雷"} ,
  3355. {"Africa/Johannesburg","非洲/约翰内斯堡"} ,
  3356. {"Africa/Juba","非洲/朱巴"} ,
  3357. {"Africa/Kampala","非洲/坎帕拉"} ,
  3358. {"Africa/Khartoum","非洲/喀土穆"} ,
  3359. {"Africa/Kigali","非洲/基加利"} ,
  3360. {"Africa/Kinshasa","非洲/金沙萨"} ,
  3361. {"Africa/Lagos","非洲/拉各斯"} ,
  3362. {"Africa/Libreville","非洲/利伯维尔"} ,
  3363. {"Africa/Lome","非洲/洛美"} ,
  3364. {"Africa/Luanda","非洲/罗安达"} ,
  3365. {"Africa/Lubumbashi","非洲/卢本巴希"} ,
  3366. {"Africa/Lusaka","非洲/卢萨卡"} ,
  3367. {"Africa/Malabo","非洲/马拉博"} ,
  3368. {"Africa/Maputo","非洲/马普托"} ,
  3369. {"Africa/Maseru","非洲/马塞卢"} ,
  3370. {"Africa/Mbabane","非洲/姆巴巴内"} ,
  3371. {"Africa/Mogadishu","非洲/摩加迪沙"} ,
  3372. {"Africa/Monrovia","非洲/蒙罗维亚"} ,
  3373. {"Africa/Nairobi","非洲/内罗毕"} ,
  3374. {"Africa/Ndjamena","非洲/恩贾梅纳"} ,
  3375. {"Africa/Niamey","非洲/尼亚美"} ,
  3376. {"Africa/Nouakchott","非洲/努瓦克肖特"} ,
  3377. {"Africa/Ouagadougou","非洲/瓦加杜古"} ,
  3378. {"Africa/Porto-Novo","非洲/波多诺伏"} ,
  3379. {"Africa/Sao_Tome","非洲/圣多美"} ,
  3380. {"Africa/Timbuktu","非洲/廷巴克图"} ,
  3381. {"Africa/Tripoli","非洲/的黎波里"} ,
  3382. {"Africa/Tunis","非洲/突尼斯"} ,
  3383. {"Africa/Windhoek","非洲/温得和克"} ,
  3384. {"America/Adak","美洲/埃达克"} ,
  3385. {"America/Anchorage","美洲/安克雷奇"} ,
  3386. {"America/Anguilla","美洲/安圭拉"} ,
  3387. {"America/Antigua","美洲/安提瓜岛"} ,
  3388. {"America/Araguaina","美洲/阿拉瓜纳"} ,
  3389. {"America/Argentina/Buenos_Aires","美洲/阿根廷/布宜诺斯艾利斯"} ,
  3390. {"America/Argentina/Catamarca","美洲/阿根廷/卡塔马卡"} ,
  3391. {"America/Argentina/ComodRivadavia","美洲/阿根廷/科莫德里瓦达维亚"} ,
  3392. {"America/Argentina/Cordoba","美洲/阿根廷/科尔多瓦"} ,
  3393. {"America/Argentina/Jujuy","美洲/阿根廷/胡胡伊省"} ,
  3394. {"America/Argentina/La_Rioja","美洲/阿根廷/拉里奥哈"} ,
  3395. {"America/Argentina/Mendoza","美洲/阿根廷/门多萨"} ,
  3396. {"America/Argentina/Rio_Gallegos","美洲/阿根廷/里奥加耶戈斯"} ,
  3397. {"America/Argentina/Salta","美洲/阿根廷/萨尔塔"} ,
  3398. {"America/Argentina/San_Juan","美洲/阿根廷/San_Juan"} ,
  3399. {"America/Argentina/San_Luis","美洲/阿根廷/圣路易斯"} ,
  3400. {"America/Argentina/Tucuman","美洲/阿根廷/图库曼"} ,
  3401. {"America/Argentina/Ushuaia","美洲/阿根廷/乌斯怀亚"} ,
  3402. {"America/Aruba","美洲/阿鲁巴岛"} ,
  3403. {"America/Asuncion","美洲/亚松森"} ,
  3404. {"America/Atikokan","美洲/阿蒂科坎"} ,
  3405. {"America/Atka","美洲/阿特卡"} ,
  3406. {"America/Bahia","美洲/巴伊亚"} ,
  3407. {"America/Bahia_Banderas","美洲/巴伊亚_班德拉斯"} ,
  3408. {"America/Barbados","美洲/巴巴多斯"} ,
  3409. {"America/Belem","美洲/贝伦"} ,
  3410. {"America/Belize","美洲/伯利兹"} ,
  3411. {"America/Blanc-Sablon","America/Blanc-Sablon"} ,
  3412. {"America/Boa_Vista","美洲/博阿维斯塔"} ,
  3413. {"America/Bogota","美洲/波哥大"} ,
  3414. {"America/Boise","美洲/博伊西"} ,
  3415. {"America/Buenos_Aires","美洲/布宜诺斯艾利斯"} ,
  3416. {"America/Cambridge_Bay","美洲/剑桥湾"} ,
  3417. {"America/Campo_Grande","美洲/大坎普"} ,
  3418. {"America/Cancun","美洲/坎昆"} ,
  3419. {"America/Caracas","美洲/加拉加斯"} ,
  3420. {"America/Catamarca","美洲/卡塔马卡"} ,
  3421. {"America/Cayenne","美洲/卡宴"} ,
  3422. {"America/Cayman","美洲/开曼"} ,
  3423. {"America/Chicago","美洲/芝加哥"} ,
  3424. {"America/Chihuahua","美洲/奇瓦瓦州"} ,
  3425. {"America/Ciudad_Juarez","美洲/华雷斯城"} ,
  3426. {"America/Coral_Harbour","美洲/珊瑚港"} ,
  3427. {"America/Cordoba","美洲/科尔多瓦"} ,
  3428. {"America/Costa_Rica","美洲/哥斯达黎加"} ,
  3429. {"America/Creston","美洲/克雷斯顿"} ,
  3430. {"America/Cuiaba","美洲/库艾巴"} ,
  3431. {"America/Curacao","美洲/库拉索岛"} ,
  3432. {"America/Danmarkshavn","美洲/丹麦港"} ,
  3433. {"America/Dawson","美洲/道森"} ,
  3434. {"America/Dawson_Creek","美洲/道森克里克"} ,
  3435. {"America/Denver","美洲/丹佛"} ,
  3436. {"America/Detroit","美洲/底特律"} ,
  3437. {"America/Dominica","美洲/多米尼克"} ,
  3438. {"America/Edmonton","美洲/埃德蒙顿"} ,
  3439. {"America/Eirunepe","美洲/埃鲁内佩"} ,
  3440. {"America/El_Salvador","美洲/萨尔瓦多"} ,
  3441. {"America/Ensenada","美洲/恩塞纳达"} ,
  3442. {"America/Fort_Nelson","美洲/纳尔逊堡"} ,
  3443. {"America/Fort_Wayne","美洲/韦恩堡"} ,
  3444. {"America/Fortaleza","美洲/福塔莱萨"} ,
  3445. {"America/Glace_Bay","America/Glace_Bay"} ,
  3446. {"America/Godthab","美洲/戈德哈布"} ,
  3447. {"America/Goose_Bay","America/Goose_Bay"} ,
  3448. {"America/Grand_Turk","美洲/大特克岛"} ,
  3449. {"America/Grenada","美洲/格林纳达"} ,
  3450. {"America/Guadeloupe","美洲/瓜德罗普岛"} ,
  3451. {"America/Guatemala","美洲/危地马拉"} ,
  3452. {"America/Guayaquil","美洲/瓜亚基尔"} ,
  3453. {"America/Guyana","美洲/圭亚那"} ,
  3454. {"America/Halifax","美洲/哈利法克斯"} ,
  3455. {"America/Havana","美洲/哈瓦那"} ,
  3456. {"America/Hermosillo","美洲/埃莫西约"} ,
  3457. {"America/Indiana/Indianapolis","美洲/印第安纳州/印第安纳波利斯"} ,
  3458. {"America/Indiana/Knox","美洲/印第安纳州/诺克斯"} ,
  3459. {"America/Indiana/Marengo","美洲/印第安纳州/马伦戈"} ,
  3460. {"America/Indiana/Petersburg","美洲/印第安纳州/彼得斯堡"} ,
  3461. {"America/Indiana/Tell_City","美洲/印第安纳州/Tell_City"} ,
  3462. {"America/Indiana/Vevay","美洲/印第安纳州/沃韦"} ,
  3463. {"America/Indiana/Vincennes","美洲/印第安纳州/文森斯"} ,
  3464. {"America/Indiana/Winamac","美洲/印第安纳州/威纳马克"} ,
  3465. {"America/Indianapolis","美洲/印第安纳波利斯"} ,
  3466. {"America/Inuvik","美洲/伊努维克人"} ,
  3467. {"America/Iqaluit","美洲/伊魁特"} ,
  3468. {"America/Jamaica","美洲/牙买加"} ,
  3469. {"America/Jujuy","美洲/胡胡伊省"} ,
  3470. {"America/Juneau","美洲/朱诺"} ,
  3471. {"America/Kentucky/Louisville","美洲/肯塔基州/路易斯维尔"} ,
  3472. {"America/Kentucky/Monticello","美洲/肯塔基州/蒙蒂塞洛"} ,
  3473. {"America/Knox_IN","美洲/Knox_IN"} ,
  3474. {"America/Kralendijk","美洲/克拉伦代克"} ,
  3475. {"America/La_Paz","美洲/拉巴斯"} ,
  3476. {"America/Lima","美洲/利马"} ,
  3477. {"America/Los_Angeles","美洲/洛杉矶"} ,
  3478. {"America/Louisville","美洲/路易斯维尔"} ,
  3479. {"America/Lower_Princes","美洲/下王子郡"} ,
  3480. {"America/Maceio","美洲/马塞约"} ,
  3481. {"America/Managua","美洲/马那瓜"} ,
  3482. {"America/Manaus","美洲/马瑙斯"} ,
  3483. {"America/Marigot","美洲/马里戈特"} ,
  3484. {"America/Martinique","美洲/马提尼克岛"} ,
  3485. {"America/Matamoros","美洲/马塔莫罗斯"} ,
  3486. {"America/Mazatlan","美洲/马萨特兰"} ,
  3487. {"America/Mendoza","美洲/门多萨"} ,
  3488. {"America/Menominee","美国/梅诺米尼"} ,
  3489. {"America/Merida","美洲/梅里达"} ,
  3490. {"America/Metlakatla","美洲/梅特拉卡特拉"} ,
  3491. {"America/Mexico_City","美洲/墨西哥_城市"} ,
  3492. {"America/Miquelon","美洲/密克隆群岛"} ,
  3493. {"America/Moncton","美洲/蒙克顿"} ,
  3494. {"America/Monterrey","美洲/蒙特雷"} ,
  3495. {"America/Montevideo","美洲/蒙得维的亚"} ,
  3496. {"America/Montreal","美洲/蒙特利尔"} ,
  3497. {"America/Montserrat","美洲/蒙特塞拉特"} ,
  3498. {"America/Nassau","美洲/拿骚"} ,
  3499. {"America/New_York","美洲/纽约"} ,
  3500. {"America/Nipigon","美洲/尼皮贡"} ,
  3501. {"America/Nome","美国/名称"} ,
  3502. {"America/Noronha","美国/某地"} ,
  3503. {"America/North_Dakota/Beulah","美洲/北达科他州/比尤拉"} ,
  3504. {"America/North_Dakota/Center","美洲/北达科他州/中部"} ,
  3505. {"America/North_Dakota/New_Salem","美洲/北达科他州/新塞勒姆"} ,
  3506. {"America/Nuuk","美洲/努克"} ,
  3507. {"America/Ojinaga","美洲/奥吉纳加"} ,
  3508. {"America/Panama","美洲/巴拿马"} ,
  3509. {"America/Pangnirtung","美洲/庞纳通"} ,
  3510. {"America/Paramaribo","美洲/帕拉马里博"} ,
  3511. {"America/Phoenix","美洲/菲尼克斯"} ,
  3512. {"America/Port-au-Prince","美洲/太子港"} ,
  3513. {"America/Port_of_Spain","美洲/西班牙港"} ,
  3514. {"America/Porto_Acre","美洲/阿卡港"} ,
  3515. {"America/Porto_Velho","美洲/旧波尔图"} ,
  3516. {"America/Puerto_Rico","美洲/波多黎各"} ,
  3517. {"America/Punta_Arenas","美洲/蓬塔阿雷纳斯"} ,
  3518. {"America/Rainy_River","美洲/雷尼河"} ,
  3519. {"America/Rankin_Inlet","兰金因莱特"} ,
  3520. {"America/Recife","美洲/累西腓"} ,
  3521. {"America/Regina","美洲/里贾纳"} ,
  3522. {"America/Resolute","美国/坚决"} ,
  3523. {"America/Rio_Branco","美洲/里奥布兰科"} ,
  3524. {"America/Rosario","美洲/罗萨里奥"} ,
  3525. {"America/Santa_Isabel","美洲/圣伊莎贝尔"} ,
  3526. {"America/Santarem","美洲/圣塔伦"} ,
  3527. {"America/Santiago","美洲/圣地亚哥"} ,
  3528. {"America/Santo_Domingo","美洲/圣多明各"} ,
  3529. {"America/Sao_Paulo","美洲/圣保罗"} ,
  3530. {"America/Scoresbysund","美洲/斯科斯比松"} ,
  3531. {"America/Shiprock","美洲/希普洛克"} ,
  3532. {"America/Sitka","美洲/锡特卡"} ,
  3533. {"America/St_Barthelemy","美洲/圣巴泰勒米"} ,
  3534. {"America/St_Johns","美洲/圣约翰斯"} ,
  3535. {"America/St_Kitts","美洲/圣基茨"} ,
  3536. {"America/St_Lucia","美洲/圣卢西亚"} ,
  3537. {"America/St_Thomas","美洲/圣托马斯"} ,
  3538. {"America/St_Vincent","美洲/圣文森特"} ,
  3539. {"America/Swift_Current","America/Swift_Current"} ,
  3540. {"America/Tegucigalpa","美洲/特古西加尔巴"} ,
  3541. {"America/Thule","美洲/图勒"} ,
  3542. {"America/Thunder_Bay","美洲/雷湾"} ,
  3543. {"America/Tijuana","美洲/蒂华纳"} ,
  3544. {"America/Toronto","美洲/多伦多"} ,
  3545. {"America/Tortola","美洲/托尔托拉岛"} ,
  3546. {"America/Vancouver","美洲/温哥华"} ,
  3547. {"America/Virgin","美国/维珍"} ,
  3548. {"America/Whitehorse","美洲/怀特霍斯"} ,
  3549. {"America/Winnipeg","美洲/温尼伯"} ,
  3550. {"America/Yakutat","美洲/雅库塔特"} ,
  3551. {"America/Yellowknife","美洲/黄刀镇"} ,
  3552. {"Antarctica/Casey","南极洲/凯西"} ,
  3553. {"Antarctica/Davis","南极洲/戴维斯"} ,
  3554. {"Antarctica/DumontDUrville","南极洲/杜蒙杜维尔"} ,
  3555. {"Antarctica/Macquarie","南极洲/麦格理"} ,
  3556. {"Antarctica/Mawson","南极洲/莫森"} ,
  3557. {"Antarctica/McMurdo","南极洲/麦克默多"} ,
  3558. {"Antarctica/Palmer","南极洲/帕尔默"} ,
  3559. {"Antarctica/Rothera","南极洲/罗塞拉岛"} ,
  3560. {"Antarctica/South_Pole","南极洲/南极点"} ,
  3561. {"Antarctica/Syowa","南极洲/昭和"} ,
  3562. {"Antarctica/Troll","南极洲/巨魔"} ,
  3563. {"Antarctica/Vostok","南极洲/东方"} ,
  3564. {"Arctic/Longyearbyen","北极/朗伊尔城"} ,
  3565. {"Asia/Aden","亚洲/亚丁"} ,
  3566. {"Asia/Almaty","亚洲/阿拉木图"} ,
  3567. {"Asia/Amman","亚洲/安曼"} ,
  3568. {"Asia/Anadyr","亚洲/阿纳德尔"} ,
  3569. {"Asia/Aqtau","亚洲/阿克套"} ,
  3570. {"Asia/Aqtobe","亚洲/阿克托比"} ,
  3571. {"Asia/Ashgabat","亚洲/阿什哈巴德"} ,
  3572. {"Asia/Ashkhabad","亚洲/阿什哈巴德"} ,
  3573. {"Asia/Atyrau","亚洲/阿特劳"} ,
  3574. {"Asia/Baghdad","亚洲/巴格达"} ,
  3575. {"Asia/Bahrain","亚洲/巴林"} ,
  3576. {"Asia/Baku","亚洲/巴库"} ,
  3577. {"Asia/Bangkok","亚洲/曼谷"} ,
  3578. {"Asia/Barnaul","亚洲/巴尔瑙尔"} ,
  3579. {"Asia/Beirut","亚洲/贝鲁特"} ,
  3580. {"Asia/Bishkek","亚洲/比什凯克"} ,
  3581. {"Asia/Brunei","亚洲/文莱"} ,
  3582. {"Asia/Calcutta","亚洲/加尔各答"} ,
  3583. {"Asia/Chita","亚洲/赤塔"} ,
  3584. {"Asia/Choibalsan","亚洲/乔巴山"} ,
  3585. {"Asia/Chongqing","亚洲/重庆"} ,
  3586. {"Asia/Chungking","亚洲/重庆"} ,
  3587. {"Asia/Colombo","亚洲/科伦坡"} ,
  3588. {"Asia/Dacca","亚洲/达卡"} ,
  3589. {"Asia/Damascus","亚洲/大马士革"} ,
  3590. {"Asia/Dhaka","亚洲/达卡"} ,
  3591. {"Asia/Dili","亚洲/帝力"} ,
  3592. {"Asia/Dubai","亚洲/迪拜"} ,
  3593. {"Asia/Dushanbe","亚洲/杜尚别"} ,
  3594. {"Asia/Famagusta","亚洲/法马古斯塔"} ,
  3595. {"Asia/Gaza","亚洲/加沙"} ,
  3596. {"Asia/Harbin","亚洲/哈尔滨"} ,
  3597. {"Asia/Hebron","亚洲/希伯伦"} ,
  3598. {"Asia/Ho_Chi_Minh","亚洲/胡志明市"} ,
  3599. {"Asia/Hong_Kong","亚洲/香港"} ,
  3600. {"Asia/Hovd","亚洲/霍布德"} ,
  3601. {"Asia/Irkutsk","亚洲/伊尔库茨克"} ,
  3602. {"Asia/Istanbul","亚洲/伊斯坦布尔"} ,
  3603. {"Asia/Jakarta","亚洲/雅加达"} ,
  3604. {"Asia/Jayapura","亚洲/查亚普拉"} ,
  3605. {"Asia/Jerusalem","亚洲/耶路撒冷"} ,
  3606. {"Asia/Kabul","亚洲/喀布尔"} ,
  3607. {"Asia/Kamchatka","亚洲/堪察加半岛"} ,
  3608. {"Asia/Karachi","亚洲/卡拉奇"} ,
  3609. {"Asia/Kashgar","亚洲/喀什"} ,
  3610. {"Asia/Kathmandu","亚洲/加德满都"} ,
  3611. {"Asia/Katmandu","亚洲/加德满都"} ,
  3612. {"Asia/Khandyga","亚洲/坎迪加"} ,
  3613. {"Asia/Kolkata","亚洲/加尔各答"} ,
  3614. {"Asia/Krasnoyarsk","亚洲/克拉斯诺亚尔斯克"} ,
  3615. {"Asia/Kuala_Lumpur","亚洲/吉隆坡_吉隆坡"} ,
  3616. {"Asia/Kuching","亚洲/古晋"} ,
  3617. {"Asia/Kuwait","亚洲/科威特"} ,
  3618. {"Asia/Macao","亚洲/澳门"} ,
  3619. {"Asia/Macau","亚洲/澳门"} ,
  3620. {"Asia/Magadan","亚洲/马加丹"} ,
  3621. {"Asia/Makassar","亚洲/望加锡"} ,
  3622. {"Asia/Manila","亚洲/马尼拉"} ,
  3623. {"Asia/Muscat","亚洲/马斯喀特"} ,
  3624. {"Asia/Nicosia","亚洲/尼科西亚"} ,
  3625. {"Asia/Novokuznetsk","亚洲/新库兹涅茨克"} ,
  3626. {"Asia/Novosibirsk","亚洲/新西伯利亚"} ,
  3627. {"Asia/Omsk","亚洲/鄂木斯克"} ,
  3628. {"Asia/Oral","亚洲/口头"} ,
  3629. {"Asia/Phnom_Penh","亚洲/金边"} ,
  3630. {"Asia/Pontianak","亚洲/笨珍"} ,
  3631. {"Asia/Pyongyang","亚洲/平壤"} ,
  3632. {"Asia/Qatar","亚洲/卡塔尔"} ,
  3633. {"Asia/Qostanay","亚洲/库斯塔奈"} ,
  3634. {"Asia/Qyzylorda","亚洲/克孜勒奥尔达"} ,
  3635. {"Asia/Rangoon","亚洲/仰光"} ,
  3636. {"Asia/Riyadh","亚洲/利雅得"} ,
  3637. {"Asia/Saigon","亚洲/西贡"} ,
  3638. {"Asia/Sakhalin","亚洲/萨哈林岛"} ,
  3639. {"Asia/Samarkand","亚洲/撒马尔罕"} ,
  3640. {"Asia/Seoul","亚洲/首尔"} ,
  3641. {"Asia/Shanghai","亚洲/上海"} ,
  3642. {"Asia/Singapore","亚洲/新加坡"} ,
  3643. {"Asia/Srednekolymsk","亚洲/中科雷姆斯克"} ,
  3644. {"Asia/Taipei","亚洲/台北"} ,
  3645. {"Asia/Tashkent","亚洲/塔什干"} ,
  3646. {"Asia/Tbilisi","亚洲/第比利斯"} ,
  3647. {"Asia/Tehran","亚洲/德黑兰"} ,
  3648. {"Asia/Tel_Aviv","亚洲/特拉维夫"} ,
  3649. {"Asia/Thimbu","亚洲/廷布"} ,
  3650. {"Asia/Thimphu","亚洲/廷布"} ,
  3651. {"Asia/Tokyo","亚洲/东京"} ,
  3652. {"Asia/Tomsk","亚洲/托木斯克"} ,
  3653. {"Asia/Ujung_Pandang","亚洲/乌戎_潘当"} ,
  3654. {"Asia/Ulaanbaatar","亚洲/乌兰巴托"} ,
  3655. {"Asia/Ulan_Bator","亚洲/乌兰巴托"} ,
  3656. {"Asia/Urumqi","亚洲/乌鲁木齐"} ,
  3657. {"Asia/Ust-Nera","亚洲/乌斯季-内拉"} ,
  3658. {"Asia/Vientiane","亚洲/万象"} ,
  3659. {"Asia/Vladivostok","亚洲/符拉迪沃斯托克"} ,
  3660. {"Asia/Yakutsk","亚洲/雅库茨克"} ,
  3661. {"Asia/Yangon","亚洲/仰光"} ,
  3662. {"Asia/Yekaterinburg","亚洲/叶卡捷琳堡"} ,
  3663. {"Asia/Yerevan","亚洲/埃里温"} ,
  3664. {"Atlantic/Azores","大西洋/亚速尔群岛"} ,
  3665. {"Atlantic/Bermuda","大西洋/百慕大"} ,
  3666. {"Atlantic/Canary","大西洋/加那利"} ,
  3667. {"Atlantic/Cape_Verde","大西洋/佛得角"} ,
  3668. {"Atlantic/Faeroe","大西洋/法罗"} ,
  3669. {"Atlantic/Faroe","大西洋/法罗"} ,
  3670. {"Atlantic/Jan_Mayen","大西洋/扬马延"} ,
  3671. {"Atlantic/Madeira","大西洋/马德拉"} ,
  3672. {"Atlantic/Reykjavik","大西洋/雷克雅未克"} ,
  3673. {"Atlantic/South_Georgia","大西洋/南乔治亚州"} ,
  3674. {"Atlantic/St_Helena","大西洋/圣赫勒拿岛"} ,
  3675. {"Atlantic/Stanley","大西洋/斯坦利"} ,
  3676. {"Australia/ACT","澳大利亚/澳大利亚首都地区"} ,
  3677. {"Australia/Adelaide","澳大利亚/阿德莱德"} ,
  3678. {"Australia/Brisbane","澳大利亚/布里斯班"} ,
  3679. {"Australia/Broken_Hill","澳大利亚/布罗肯希尔"} ,
  3680. {"Australia/Canberra","澳大利亚/堪培拉"} ,
  3681. {"Australia/Currie","澳大利亚/柯里"} ,
  3682. {"Australia/Darwin","澳大利亚/达尔文"} ,
  3683. {"Australia/Eucla","澳大利亚/尤克拉拉"} ,
  3684. {"Australia/Hobart","澳大利亚/霍巴特"} ,
  3685. {"Australia/LHI","澳大利亚/LHI"} ,
  3686. {"Australia/Lindeman","澳大利亚/林德曼"} ,
  3687. {"Australia/Lord_Howe","澳大利亚/豪勋爵"} ,
  3688. {"Australia/Melbourne","澳大利亚/墨尔本"} ,
  3689. {"Australia/NSW","澳大利亚/新南威尔士州"} ,
  3690. {"Australia/North","澳大利亚/北部"} ,
  3691. {"Australia/Perth","澳大利亚/珀斯"} ,
  3692. {"Australia/Queensland","澳大利亚/昆士兰"} ,
  3693. {"Australia/South","澳大利亚/南部"} ,
  3694. {"Australia/Sydney","澳大利亚/悉尼"} ,
  3695. {"Australia/Tasmania","澳大利亚/塔斯马尼亚"} ,
  3696. {"Australia/Victoria","澳大利亚/维多利亚"} ,
  3697. {"Australia/West","澳大利亚/西部"} ,
  3698. {"Australia/Yancowinna","澳大利亚/扬科温纳"} ,
  3699. {"Brazil/Acre","巴西/阿卡"} ,
  3700. {"Brazil/DeNoronha","巴西/迪诺罗尼亚群岛"} ,
  3701. {"Brazil/East","巴西/东部"} ,
  3702. {"Brazil/West","巴西/西部"} ,
  3703. {"CET","CET"} ,
  3704. {"CST6CDT","CST6CDT"} ,
  3705. {"Canada/Atlantic","加拿大/大西洋"} ,
  3706. {"Canada/Central","加拿大/中部"} ,
  3707. {"Canada/Eastern","加拿大/东部"} ,
  3708. {"Canada/Mountain","加拿大/山区"} ,
  3709. {"Canada/Newfoundland","加拿大/纽芬兰"} ,
  3710. {"Canada/Pacific","加拿大/太平洋地区"} ,
  3711. {"Canada/Saskatchewan","加拿大/萨斯喀彻温省"} ,
  3712. {"Canada/Yukon","加拿大/育空地区"} ,
  3713. {"Chile/Continental","智利/大陆航空"} ,
  3714. {"Chile/EasterIsland","智利/复活节岛"} ,
  3715. {"Cuba","古巴"} ,
  3716. {"EET","欧洲东部时间"} ,
  3717. {"EST","东部时间"} ,
  3718. {"EST5EDT","EST5EDT"} ,
  3719. {"Egypt","埃及"} ,
  3720. {"Eire","爱尔兰"} ,
  3721. {"Etc/GMT","Etc/GMT"} ,
  3722. {"Etc/GMT+0","Etc/GMT+0"} ,
  3723. {"Etc/GMT+1","Etc/GMT+1"} ,
  3724. {"Etc/GMT+10","Etc/GMT+10"} ,
  3725. {"Etc/GMT+11","Etc/GMT+11"} ,
  3726. {"Etc/GMT+12","Etc/GMT+12"} ,
  3727. {"Etc/GMT+2","Etc/GMT+2"} ,
  3728. {"Etc/GMT+3","Etc/GMT+3"} ,
  3729. {"Etc/GMT+4","Etc/GMT+4"} ,
  3730. {"Etc/GMT+5","Etc/GMT+5"} ,
  3731. {"Etc/GMT+6","Etc/GMT+6"} ,
  3732. {"Etc/GMT+7","Etc/GMT+7"} ,
  3733. {"Etc/GMT+8","Etc/GMT+8"} ,
  3734. {"Etc/GMT+9","Etc/GMT+9"} ,
  3735. {"Etc/GMT-0","Etc/GMT-0"} ,
  3736. {"Etc/GMT-1","Etc/GMT-1"} ,
  3737. {"Etc/GMT-10","Etc/GMT-10"} ,
  3738. {"Etc/GMT-11","Etc/GMT-11"} ,
  3739. {"Etc/GMT-12","Etc/GMT-12"} ,
  3740. {"Etc/GMT-13","Etc/GMT-13"} ,
  3741. {"Etc/GMT-14","Etc/GMT-14"} ,
  3742. {"Etc/GMT-2","Etc/GMT-2"} ,
  3743. {"Etc/GMT-3","Etc/GMT-3"} ,
  3744. {"Etc/GMT-4","Etc/GMT-4"} ,
  3745. {"Etc/GMT-5","Etc/GMT-5"} ,
  3746. {"Etc/GMT-6","Etc/GMT-6"} ,
  3747. {"Etc/GMT-7","Etc/GMT-7"} ,
  3748. {"Etc/GMT-8","Etc/GMT-8"} ,
  3749. {"Etc/GMT-9","Etc/GMT-9"} ,
  3750. {"Etc/GMT0","Etc/GMT0"} ,
  3751. {"Etc/Greenwich","Etc/格林威治"} ,
  3752. {"Etc/UCT","Etc/UCT"} ,
  3753. {"Etc/UTC","Etc/UTC"} ,
  3754. {"Etc/Universal","Etc/通用"} ,
  3755. {"Etc/Zulu","Etc/祖鲁语"} ,
  3756. {"Europe/Amsterdam","欧洲/阿姆斯特丹"} ,
  3757. {"Europe/Andorra","欧洲/安道尔"} ,
  3758. {"Europe/Astrakhan","欧洲/阿斯特拉罕"} ,
  3759. {"Europe/Athens","欧洲/雅典"} ,
  3760. {"Europe/Belfast","欧洲/贝尔法斯特"} ,
  3761. {"Europe/Belgrade","欧洲/贝尔格莱德"} ,
  3762. {"Europe/Berlin","欧洲/柏林"} ,
  3763. {"Europe/Bratislava","欧洲/布拉迪斯拉发"} ,
  3764. {"Europe/Brussels","欧洲/布鲁塞尔"} ,
  3765. {"Europe/Bucharest","欧洲/布加勒斯特"} ,
  3766. {"Europe/Budapest","欧洲/布达佩斯"} ,
  3767. {"Europe/Busingen","欧洲/布辛根"} ,
  3768. {"Europe/Chisinau","欧洲/基希讷乌"} ,
  3769. {"Europe/Copenhagen","欧洲/哥本哈根"} ,
  3770. {"Europe/Dublin","欧洲/都柏林"} ,
  3771. {"Europe/Gibraltar","欧洲/直布罗陀"} ,
  3772. {"Europe/Guernsey","欧洲/根西岛"} ,
  3773. {"Europe/Helsinki","欧洲/赫尔辛基"} ,
  3774. {"Europe/Isle_of_Man","欧洲/马恩岛"} ,
  3775. {"Europe/Istanbul","欧洲/伊斯坦布尔"} ,
  3776. {"Europe/Jersey","欧洲/泽西岛"} ,
  3777. {"Europe/Kaliningrad","欧洲/加里宁格勒"} ,
  3778. {"Europe/Kiev","欧洲/基辅"} ,
  3779. {"Europe/Kirov","欧洲/基洛夫"} ,
  3780. {"Europe/Kyiv","欧洲/基辅"} ,
  3781. {"Europe/Lisbon","欧洲/里斯本"} ,
  3782. {"Europe/Ljubljana","欧洲/卢布尔雅那"} ,
  3783. {"Europe/London","欧洲/伦敦"} ,
  3784. {"Europe/Luxembourg","欧洲/卢森堡"} ,
  3785. {"Europe/Madrid","欧洲/马德里"} ,
  3786. {"Europe/Malta","欧洲/马耳他"} ,
  3787. {"Europe/Mariehamn","欧洲/玛丽港"} ,
  3788. {"Europe/Minsk","欧洲/明斯克"} ,
  3789. {"Europe/Monaco","欧洲/摩纳哥"} ,
  3790. {"Europe/Moscow","欧洲/莫斯科"} ,
  3791. {"Europe/Nicosia","欧洲/尼科西亚"} ,
  3792. {"Europe/Oslo","欧洲/奥斯陆"} ,
  3793. {"Europe/Paris","欧洲/巴黎"} ,
  3794. {"Europe/Podgorica","欧洲/波德戈里察"} ,
  3795. {"Europe/Prague","欧洲/布拉格"} ,
  3796. {"Europe/Riga","欧洲/里加"} ,
  3797. {"Europe/Rome","欧洲/罗马"} ,
  3798. {"Europe/Samara","欧洲/萨马拉"} ,
  3799. {"Europe/San_Marino","欧洲/圣马力诺"} ,
  3800. {"Europe/Sarajevo","欧洲/萨拉热窝"} ,
  3801. {"Europe/Saratov","欧洲/萨拉托夫"} ,
  3802. {"Europe/Simferopol","欧洲/辛菲罗波尔"} ,
  3803. {"Europe/Skopje","欧洲/斯科普里"} ,
  3804. {"Europe/Sofia","欧洲/索非亚"} ,
  3805. {"Europe/Stockholm","欧洲/斯德哥尔摩"} ,
  3806. {"Europe/Tallinn","欧洲/塔林"} ,
  3807. {"Europe/Tirane","欧洲/地拉那"} ,
  3808. {"Europe/Tiraspol","欧洲/蒂拉斯波尔"} ,
  3809. {"Europe/Ulyanovsk","欧洲/乌里扬诺夫斯克"} ,
  3810. {"Europe/Uzhgorod","欧洲/乌日哥罗德"} ,
  3811. {"Europe/Vaduz","欧洲/瓦杜兹"} ,
  3812. {"Europe/Vatican","欧洲/梵蒂冈"} ,
  3813. {"Europe/Vienna","欧洲/维也纳"} ,
  3814. {"Europe/Vilnius","欧洲/维尔纽斯"} ,
  3815. {"Europe/Volgograd","欧洲/伏尔加格勒"} ,
  3816. {"Europe/Warsaw","欧洲/华沙"} ,
  3817. {"Europe/Zagreb","欧洲/萨格勒布"} ,
  3818. {"Europe/Zaporozhye","欧洲/扎波罗热"} ,
  3819. {"Europe/Zurich","欧洲/苏黎世"} ,
  3820. {"GB","国标"} ,
  3821. {"GB-Eire","英国-爱尔兰"} ,
  3822. {"GMT","格林威治标准时间"} ,
  3823. {"GMT+0","格林威治标准时间+0"} ,
  3824. {"GMT-0","GMT-0"} ,
  3825. {"GMT0","格林威治标准时间0"} ,
  3826. {"Greenwich","格林威治"} ,
  3827. {"HST","高温试验"} ,
  3828. {"Hongkong","香港"} ,
  3829. {"Iceland","冰岛"} ,
  3830. {"Indian/Antananarivo","印度/塔那那利佛"} ,
  3831. {"Indian/Chagos","印第安人/查戈斯人"} ,
  3832. {"Indian/Christmas","印度/圣诞节"} ,
  3833. {"Indian/Cocos","印度/科科斯"} ,
  3834. {"Indian/Comoro","印度/科摩罗"} ,
  3835. {"Indian/Kerguelen","印度/凯尔盖朗"} ,
  3836. {"Indian/Mahe","印度/马埃岛"} ,
  3837. {"Indian/Maldives","印度/马尔代夫"} ,
  3838. {"Indian/Mauritius","印度/毛里求斯"} ,
  3839. {"Indian/Mayotte","印度/马约特岛"} ,
  3840. {"Indian/Reunion","印度/留尼汪岛"} ,
  3841. {"Iran","伊朗"} ,
  3842. {"Israel","以色列"} ,
  3843. {"Jamaica","牙买加"} ,
  3844. {"Japan","日本"} ,
  3845. {"Kwajalein","夸贾林环礁"} ,
  3846. {"Libya","利比亚"} ,
  3847. {"MET","梅特"} ,
  3848. {"MST","MST"} ,
  3849. {"MST7MDT","MST7MDT"} ,
  3850. {"Mexico/BajaNorte","墨西哥/北下巴"} ,
  3851. {"Mexico/BajaSur","墨西哥/巴哈苏尔"} ,
  3852. {"Mexico/General","墨西哥/一般"} ,
  3853. {"NZ","新西兰"} ,
  3854. {"NZ-CHAT","新西兰聊天室"} ,
  3855. {"Navajo","纳瓦霍语"} ,
  3856. {"PRC","中国"} ,
  3857. {"PST8PDT","PST8PDT"} ,
  3858. {"Pacific/Apia","太平洋/阿皮亚"} ,
  3859. {"Pacific/Auckland","太平洋/奥克兰"} ,
  3860. {"Pacific/Bougainville","太平洋/布干维尔岛"} ,
  3861. {"Pacific/Chatham","太平洋/查塔姆"} ,
  3862. {"Pacific/Chuuk","太平洋/楚克"} ,
  3863. {"Pacific/Easter","太平洋/复活节"} ,
  3864. {"Pacific/Efate","太平洋/埃法特"} ,
  3865. {"Pacific/Enderbury","太平洋/恩德伯里"} ,
  3866. {"Pacific/Fakaofo","太平洋/法考福"} ,
  3867. {"Pacific/Fiji","太平洋/斐济"} ,
  3868. {"Pacific/Funafuti","太平洋/富纳富提"} ,
  3869. {"Pacific/Galapagos","太平洋/加拉帕戈斯群岛"} ,
  3870. {"Pacific/Gambier","太平洋/甘比尔"} ,
  3871. {"Pacific/Guadalcanal","太平洋/瓜达尔卡纳尔岛"} ,
  3872. {"Pacific/Guam","太平洋/关岛"} ,
  3873. {"Pacific/Honolulu","太平洋/檀香山"} ,
  3874. {"Pacific/Johnston","太平洋/约翰斯顿"} ,
  3875. {"Pacific/Kanton","太平洋/关东"} ,
  3876. {"Pacific/Kiritimati","太平洋/基里蒂马蒂"} ,
  3877. {"Pacific/Kosrae","太平洋/科斯雷"} ,
  3878. {"Pacific/Kwajalein","太平洋/夸贾林环礁"} ,
  3879. {"Pacific/Majuro","太平洋/马朱罗"} ,
  3880. {"Pacific/Marquesas","太平洋/马克萨斯"} ,
  3881. {"Pacific/Midway","太平洋/中途岛"} ,
  3882. {"Pacific/Nauru","太平洋/瑙鲁"} ,
  3883. {"Pacific/Niue","太平洋/纽埃"} ,
  3884. {"Pacific/Norfolk","太平洋/诺福克"} ,
  3885. {"Pacific/Noumea","太平洋/努美阿"} ,
  3886. {"Pacific/Pago_Pago","太平洋/帕果"} ,
  3887. {"Pacific/Palau","太平洋/帕劳"} ,
  3888. {"Pacific/Pitcairn","太平洋/皮特凯恩"} ,
  3889. {"Pacific/Pohnpei","太平洋/波纳佩"} ,
  3890. {"Pacific/Ponape","太平洋/波纳佩"} ,
  3891. {"Pacific/Port_Moresby","太平洋/莫尔兹比港"} ,
  3892. {"Pacific/Rarotonga","太平洋/拉罗汤加"} ,
  3893. {"Pacific/Saipan","太平洋/塞班岛"} ,
  3894. {"Pacific/Samoa","太平洋/萨摩亚"} ,
  3895. {"Pacific/Tahiti","太平洋/大溪地"} ,
  3896. {"Pacific/Tarawa","太平洋/塔拉瓦"} ,
  3897. {"Pacific/Tongatapu","太平洋/汤加塔布岛"} ,
  3898. {"Pacific/Truk","太平洋/特鲁克"} ,
  3899. {"Pacific/Wake","太平洋/威克"} ,
  3900. {"Pacific/Wallis","太平洋/沃利斯"} ,
  3901. {"Pacific/Yap","太平洋/雅浦岛"} ,
  3902. {"Poland","波兰"} ,
  3903. {"Portugal","葡萄牙"} ,
  3904. {"ROC","ROC"} ,
  3905. {"ROK","韩国"} ,
  3906. {"Singapore","新加坡"} ,
  3907. {"Turkey","Turkey"} ,
  3908. {"UCT","世界标准时间"} ,
  3909. {"US/Alaska","美国/阿拉斯加"} ,
  3910. {"US/Aleutian","美国/阿留申群岛"} ,
  3911. {"US/Arizona","美国/亚利桑那州"} ,
  3912. {"US/Central","美国/中部"} ,
  3913. {"US/East-Indiana","美国/东印第安纳州"} ,
  3914. {"US/Eastern","美国/东部"} ,
  3915. {"US/Hawaii","美国/夏威夷"} ,
  3916. {"US/Indiana-Starke","美国/印第安纳州斯塔克"} ,
  3917. {"US/Michigan","美国/密歇根州"} ,
  3918. {"US/Mountain","美国/山地"} ,
  3919. {"US/Pacific","美国/太平洋地区"} ,
  3920. {"US/Samoa","美国/萨摩亚"} ,
  3921. {"UTC","世界标准时间"} ,
  3922. {"Universal","Universal"} ,
  3923. {"W-SU","W-SU"} ,
  3924. {"WET","WET"} ,
  3925. {"Zulu","Zulu"}
  3926. };
  3927. /// <summary>
  3928. /// 获取国家或城市当地时间
  3929. /// </summary>
  3930. /// <param name="country"></param>
  3931. /// <param name="city"></param>
  3932. /// <returns></returns>
  3933. public static DateTime? GetCountryOrCityCurrentDateTime(string country, string city)
  3934. {
  3935. DateTime? currDt = null;
  3936. var currTimezones = _timeZoneCityMappings.Where(x => x.Value.Contains(city)).ToList();
  3937. if (!currTimezones.Any())
  3938. {
  3939. currTimezones = _timeZoneCityMappings.Where(x => x.Value.Contains(country)).ToList();
  3940. }
  3941. ;
  3942. string timeZoneId = string.Empty;
  3943. if (currTimezones.Count > 1)
  3944. {
  3945. currTimezones = currTimezones.Where(x => x.Value.Contains(country)).ToList();
  3946. timeZoneId = currTimezones.FirstOrDefault().Key ?? string.Empty;
  3947. }
  3948. else timeZoneId = currTimezones.FirstOrDefault().Key ?? string.Empty;
  3949. if (string.IsNullOrEmpty(timeZoneId)) return currDt;
  3950. // Step 1: 获取当前 UTC 时间
  3951. Instant now = SystemClock.Instance.GetCurrentInstant();
  3952. // Step 2: 加载目标时区(以 "Asia/Shanghai" 为例)
  3953. var timeZone = DateTimeZoneProviders.Tzdb[timeZoneId];
  3954. if (timeZone == null) return currDt;
  3955. // Step 3: 将 UTC 时间转换为目标时区的本地时间
  3956. currDt = now.InZone(timeZone).ToDateTimeUnspecified();
  3957. return currDt;
  3958. }
  3959. #endregion
  3960. #region aspose
  3961. /// <summary>
  3962. /// aspose word 设置页脚
  3963. /// </summary>
  3964. /// <param name="builder"></param>
  3965. /// <param name="footerLabel">页脚内容</param>
  3966. /// <param name="font">字体名称</param>
  3967. /// <param name="fontSize"><字体大小/param>
  3968. public static void AsposeWordSetFooter(DocumentBuilder builder, string footerLabel, string font, int fontSize)
  3969. {
  3970. Section currentSection = builder.CurrentSection;
  3971. var pageSetup = currentSection.PageSetup;
  3972. pageSetup.DifferentFirstPageHeaderFooter = true;
  3973. //第一页页脚
  3974. builder.MoveToHeaderFooter(HeaderFooterType.FooterFirst);
  3975. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  3976. builder.Font.Name = font;
  3977. builder.Font.Bold = true;
  3978. builder.Font.Size = fontSize;
  3979. builder.Write(footerLabel);
  3980. //非第一页页脚
  3981. builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
  3982. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  3983. builder.Font.Name = font;
  3984. builder.Font.Bold = true;
  3985. builder.Font.Size = fontSize;
  3986. builder.Write(footerLabel);
  3987. }
  3988. #endregion
  3989. #region 出入境费用
  3990. #region 汇率
  3991. /// <summary>
  3992. /// 三公费用实时汇率调差
  3993. /// </summary>
  3994. private readonly static decimal _xchgRateAdj = 0.00M;
  3995. /// <summary>
  3996. /// 三公费用实时汇率上浮比例
  3997. /// </summary>
  3998. private readonly static decimal _fxRateRise = 1.0350M;
  3999. #region 城市区间费用详情
  4000. /// <summary>
  4001. /// 城市区间费用详情 使用的币种及汇率
  4002. /// </summary>
  4003. /// <param name="groupId"></param>
  4004. /// <returns></returns>
  4005. public static async Task<List<CurrencyInfo>> EnterExitCostOVFeeUsedCurrencyAsync(int groupId = 0)
  4006. {
  4007. var infos = new List<CurrencyInfo>();
  4008. bool isUsedGroup = false;
  4009. var countryies = new List<string>();
  4010. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == groupId).FirstAsync();
  4011. if (groupInfo != null)
  4012. {
  4013. countryies = _dirRep.GroupSplitCountry(groupInfo.VisitCountry);
  4014. if (countryies.Any())
  4015. {
  4016. isUsedGroup = true;
  4017. }
  4018. }
  4019. infos = await _sqlSugar.Queryable<Res_OverseaVehicle>()
  4020. .LeftJoin<Sys_SetData>((ov, sd) => ov.Currency == sd.Id)
  4021. .Where((ov, sd) => ov.IsDel == 0)
  4022. .WhereIF(isUsedGroup, (ov, sd) => countryies.Contains(ov.CountryName))
  4023. .Select((ov, sd) => new CurrencyInfo()
  4024. {
  4025. CurrencyCode = sd.Name.ToUpper(),
  4026. CurrencyName = sd.Remark
  4027. })
  4028. .Distinct()
  4029. .ToListAsync();
  4030. //出入境费用存储的币种及汇率
  4031. var eexCurrencyInfos = new List<CurrencyInfo>();
  4032. if (infos.Any())
  4033. {
  4034. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).FirstAsync();
  4035. if (eecInfo != null)
  4036. {
  4037. eexCurrencyInfos = CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark);
  4038. }
  4039. }
  4040. //合并已使用币种及汇率
  4041. infos.ForEach(x =>
  4042. {
  4043. x.Rate = x.Rate == 0.00M ? 1.0000M : x.Rate;
  4044. var eexCurrencyInfo = eexCurrencyInfos.Where(y => y.CurrencyCode == x.CurrencyCode).FirstOrDefault();
  4045. if (eexCurrencyInfo != null)
  4046. {
  4047. x.Rate = eexCurrencyInfo.Rate;
  4048. }
  4049. });
  4050. //未存储费用集合
  4051. var unSaveCurrInfos = infos.Where(x => !eexCurrencyInfos.Any(y => y.CurrencyCode == x.CurrencyCode)).ToList();
  4052. if (unSaveCurrInfos.Any())
  4053. {
  4054. var currencyRate = await _juHeApi.PostItemRateAsync(unSaveCurrInfos.Select(it => it.CurrencyCode!).ToArray());
  4055. if (currencyRate.Count > 0)
  4056. {
  4057. foreach (var item in infos)
  4058. {
  4059. var rateInfo = currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4060. if (rateInfo != null)
  4061. {
  4062. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4063. rate1 *= _fxRateRise;
  4064. item.Rate = rate1.TruncDecimals(4) + _xchgRateAdj;
  4065. }
  4066. }
  4067. }
  4068. }
  4069. return infos;
  4070. }
  4071. /// <summary>
  4072. /// 城市区间-草稿费用详情 使用的币种及汇率
  4073. /// </summary>
  4074. /// <param name="draftId"></param>
  4075. /// <returns></returns>
  4076. public static async Task<List<CurrencyInfo>> EnterExitCostDrafOVFeeUsedCurrencyAsync(int draftId = 0)
  4077. {
  4078. var infos = new List<CurrencyInfo>();
  4079. bool isUsedDraft = false;
  4080. var countryies = new List<string>();
  4081. var drafInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.Id == draftId).FirstAsync();
  4082. if (drafInfo != null)
  4083. {
  4084. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  4085. .Where(x => x.IsDel == 0 && x.ParentId == draftId)
  4086. .Select(x => x.NationalTravelFeeId)
  4087. .Distinct()
  4088. .ToListAsync();
  4089. var countries = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  4090. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  4091. .Select(x => x.Country)
  4092. .Distinct()
  4093. .ToListAsync();
  4094. if (countryies.Any())
  4095. {
  4096. isUsedDraft = true;
  4097. }
  4098. }
  4099. infos = await _sqlSugar.Queryable<Res_OverseaVehicle>()
  4100. .LeftJoin<Sys_SetData>((ov, sd) => ov.Currency == sd.Id)
  4101. .Where((ov, sd) => ov.IsDel == 0)
  4102. .WhereIF(isUsedDraft, (ov, sd) => countryies.Contains(ov.CountryName))
  4103. .Select((ov, sd) => new CurrencyInfo()
  4104. {
  4105. CurrencyCode = sd.Name.ToUpper(),
  4106. CurrencyName = sd.Remark
  4107. })
  4108. .Distinct()
  4109. .ToListAsync();
  4110. //出入境费用存储的币种及汇率
  4111. var eexCurrencyInfos = new List<CurrencyInfo>();
  4112. if (infos.Any())
  4113. {
  4114. if (drafInfo != null)
  4115. {
  4116. eexCurrencyInfos = CommonFun.GetCurrencyChinaToList(drafInfo.CurrencyRemark);
  4117. }
  4118. }
  4119. //合并已使用币种及汇率
  4120. infos.ForEach(x =>
  4121. {
  4122. if (x.CurrencyCode.Equals("CNY")) x.Rate = 1.0000M;
  4123. var eexCurrencyInfo = eexCurrencyInfos.Where(y => y.CurrencyCode == x.CurrencyCode).FirstOrDefault();
  4124. if (eexCurrencyInfo != null)
  4125. {
  4126. x.Rate = eexCurrencyInfo.Rate;
  4127. }
  4128. });
  4129. //未存储费用集合
  4130. var unSaveCurrInfos = infos.Where(x => !eexCurrencyInfos.Any(y => y.CurrencyCode == x.CurrencyCode)).ToList();
  4131. if (unSaveCurrInfos.Any())
  4132. {
  4133. var currencyRate = await _juHeApi.PostItemRateAsync(unSaveCurrInfos.Select(it => it.CurrencyCode!).ToArray());
  4134. if (currencyRate.Count > 0)
  4135. {
  4136. foreach (var item in infos)
  4137. {
  4138. var rateInfo = currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4139. if (rateInfo != null)
  4140. {
  4141. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4142. rate1 *= _fxRateRise;
  4143. item.Rate = rate1.TruncDecimals(4) + _xchgRateAdj;
  4144. }
  4145. }
  4146. }
  4147. }
  4148. return infos;
  4149. }
  4150. #endregion
  4151. /// <summary>
  4152. /// 出入境费用 初始化汇率
  4153. /// </summary>
  4154. /// <returns></returns>
  4155. public static async Task<List<CurrencyInfo>> EnterExitCostInitRate()
  4156. {
  4157. //默认币种显示
  4158. var currencyInfos = new List<CurrencyInfo>()
  4159. {
  4160. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4161. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4162. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4163. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4164. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4165. };
  4166. var currencyRate = await _juHeApi.PostItemRateAsync(currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  4167. if (currencyRate.Count > 0)
  4168. {
  4169. foreach (var item in currencyInfos)
  4170. {
  4171. var rateInfo = currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4172. if (rateInfo != null)
  4173. {
  4174. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4175. rate1 *= _fxRateRise;
  4176. item.Rate = rate1.TruncDecimals(4) + _xchgRateAdj;
  4177. }
  4178. }
  4179. }
  4180. return currencyInfos;
  4181. }
  4182. /// <summary>
  4183. /// 出入境费用 实时汇率
  4184. /// </summary>
  4185. /// <returns></returns>
  4186. public static async Task<List<dynamic>> EnterExitCostLiveRate()
  4187. {
  4188. List<dynamic> reteInfos = new List<dynamic>();
  4189. //默认币种显示
  4190. List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>()
  4191. {
  4192. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4193. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4194. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4195. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4196. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M }
  4197. };
  4198. var currencyRate = await _juHeApi.PostItemRateAsync(currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  4199. if (currencyRate.Count > 0)
  4200. {
  4201. foreach (var item in currencyInfos)
  4202. {
  4203. var rateInfo = currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4204. if (rateInfo != null)
  4205. {
  4206. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4207. decimal rate1 = item.Rate * _fxRateRise + _xchgRateAdj;
  4208. reteInfos.Add(new
  4209. {
  4210. currCode = item.CurrencyCode,
  4211. currName = item.CurrencyName,
  4212. rate = rate1.TruncDecimals(4),
  4213. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4214. });
  4215. }
  4216. }
  4217. }
  4218. return reteInfos;
  4219. }
  4220. /// <summary>
  4221. /// 出入境费用 汇率验证
  4222. /// </summary>
  4223. /// <param name="groupId"></param>
  4224. /// <param name="checkCurrencys">已使用币种</param>
  4225. /// <returns></returns>
  4226. public static async Task<(bool, string, List<CurrencyInfo>)> EnterExitCostCheckRate(int groupId, List<CurrencyInfo> checkCurrencys)
  4227. {
  4228. if (checkCurrencys == null || checkCurrencys.Count < 1) return (false, string.Empty, new List<CurrencyInfo>());
  4229. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == groupId);
  4230. if (info == null) return (false, string.Empty, new List<CurrencyInfo>());
  4231. List<CurrencyInfo> liveRates;
  4232. var cacheRateInfo = await _sqlSugar.Queryable<Sys_ExchangeRateRecord>()
  4233. .OrderByDescending(x => x.CreateTime)
  4234. .FirstAsync(x => x.IsDel == 0 && x.DiId == info.Id);
  4235. if (cacheRateInfo == null)
  4236. {
  4237. var _currencyRate = await _juHeApi.PostItemRateAsync(Array.Empty<string>());
  4238. if (_currencyRate.Count < 1) return (false, "获取汇率失败,请稍后再试!", new List<CurrencyInfo>());
  4239. liveRates = _currencyRate.Select(it => new CurrencyInfo
  4240. {
  4241. CurrencyCode = it.Name,
  4242. CurrencyName = it.Name,
  4243. Rate = Convert.ToDecimal((Convert.ToDecimal(it.FSellPri == null ? 0.00M : it.FSellPri) / 100.00M).ToString("#0.0000"))
  4244. }).ToList();
  4245. }
  4246. else
  4247. {
  4248. liveRates = CommonFun.GetCurrencyChinaToList(cacheRateInfo.RateInfo);
  4249. foreach (var x in liveRates)
  4250. x.Rate = (x.Rate / 100.00M).TruncDecimals(4);
  4251. }
  4252. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  4253. var isSendMsg = true;
  4254. var msgContent = new StringBuilder();
  4255. //去掉费用未使用得币种
  4256. if (checkCurrencys != null && checkCurrencys.Count > 0)
  4257. {
  4258. cacheRateInfos = cacheRateInfos.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  4259. }
  4260. if (cacheRateInfos.Any())
  4261. {
  4262. decimal rowthRate = _fxRateRise;
  4263. foreach (var cacheRate in cacheRateInfos)
  4264. {
  4265. var liveRate = liveRates.Find(x => x.CurrencyName.Equals(cacheRate.CurrencyName));
  4266. if (liveRate == null) continue;
  4267. var currRate = (rowthRate * liveRate.Rate).TruncDecimals(4) + _xchgRateAdj;
  4268. //if (cacheRate.Rate != currRate)
  4269. //{
  4270. // isSendMsg = true;
  4271. //>团组归属:<font color='info'>{groupName}</font>
  4272. msgContent.AppendLine($">- {cacheRate.CurrencyName}汇率(页面保存):{cacheRate.Rate:#0.0000} / 实时汇率(接口保存,已上浮1.0350):{currRate:#0.0000}【原接口输出汇率为:{liveRate.Rate:#0.0000}】");
  4273. //}
  4274. }
  4275. return (isSendMsg, msgContent.ToString(), liveRates);
  4276. }
  4277. return (false, string.Empty, new List<CurrencyInfo>());
  4278. }
  4279. #endregion
  4280. #region 三公费用明细 文件下载
  4281. /// <summary>
  4282. /// 获取三公费用标准city
  4283. /// </summary>
  4284. /// <param name="placeData"></param>
  4285. /// <param name="nationalTravelFeeId"></param>
  4286. /// <returns></returns>
  4287. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  4288. {
  4289. string _city = string.Empty;
  4290. if (placeData.Count < 1) return _city;
  4291. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  4292. if (data == null) return _city;
  4293. string country = data.Country;
  4294. string city = data.City;
  4295. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  4296. else _city = city;
  4297. return _city;
  4298. }
  4299. /// <summary>
  4300. /// 三公费用明细 文件下载
  4301. /// </summary>
  4302. /// <param name="dto"></param>
  4303. /// <param name="fileFormat"></param>
  4304. /// <returns></returns>
  4305. public static async Task<JsonView> EnterExitCostDownload(EnterExitCostDownloadDto dto, string fileFormat = "pdf")
  4306. {
  4307. var _view = new JsonView() { Code = StatusCodes.Status204NoContent };
  4308. if (dto.DiId < 1)
  4309. {
  4310. _view.Msg = "请传入有效的DiId参数;";
  4311. return _view;
  4312. }
  4313. if (dto.ExportType < 1)
  4314. {
  4315. _view.Msg = MsgTips.Port;
  4316. return _view;
  4317. }
  4318. if (dto.SubTypeId < 1)
  4319. {
  4320. _view.Msg = @"请传入有效的SubTypeId参数;
  4321. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4322. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4323. 3 团组成员名单 1 团组成员名单";
  4324. return _view;
  4325. }
  4326. try
  4327. {
  4328. var enterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4329. var dayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4330. if (enterExitCosts == null)
  4331. {
  4332. _view.Msg = @"该团组未填写出入境费用;";
  4333. return _view;
  4334. }
  4335. //数据源
  4336. List<Grp_DayAndCost> dac1 = dayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4337. List<Grp_DayAndCost> dac2 = dayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4338. List<Grp_DayAndCost> dac3 = dayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4339. List<Grp_DayAndCost> dac4 = dayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4340. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4341. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).First();
  4342. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4343. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4344. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4345. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4346. .Select((tcl, dc, cc) => new
  4347. {
  4348. Name = dc.LastName + dc.FirstName,
  4349. Sex = dc.Sex,
  4350. Birthday = dc.BirthDay,
  4351. Company = cc.CompanyFullName,
  4352. Job = dc.Job
  4353. })
  4354. .ToList();
  4355. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4356. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4357. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4358. var rateDatas = await enterExitCosts.CurrencyRemark.SplitExchangeRate();
  4359. _DelegationInfo.VisitCountry = _DelegationInfo?.VisitCountry?.Replace("|", "、") ?? "";
  4360. if (dto.ExportType == 1) //明细表
  4361. {
  4362. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4363. {
  4364. if (!fileFormat.Equals("pdf")) fileFormat = "docx";
  4365. //获取模板
  4366. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4367. //载入模板
  4368. Document doc = new Document(tempPath);
  4369. DocumentBuilder builder = new DocumentBuilder(doc);
  4370. //利用键值对存放数据
  4371. Dictionary<string, string> dic = new Dictionary<string, string>();
  4372. decimal stayFeeTotal = dayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4373. decimal mealsFeeTotal = dayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4374. decimal miscellaneousFeeTotal = dayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4375. decimal tainFeeTotal = dayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4376. decimal insidePayTotal = enterExitCosts.InsidePay;
  4377. string row1_1 = "";
  4378. if (enterExitCosts.Visa > 0)
  4379. {
  4380. //insidePayTotal += enterExitCosts.Visa;
  4381. row1_1 = $"签证费: {enterExitCosts.Visa:#0.00} 人民币/人";
  4382. //if (!string.IsNullOrEmpty(enterExitCosts.VisaRemark))
  4383. //{
  4384. // row1_1 += $"\t签证费用描述: {enterExitCosts.VisaRemark}";
  4385. //}
  4386. }
  4387. string row1_2 = "";
  4388. if (enterExitCosts.YiMiao > 0)
  4389. {
  4390. //insidePayTotal += enterExitCosts.YiMiao;
  4391. row1_2 += $"疫苗费:{enterExitCosts.YiMiao:#0.00} 人民币/人";
  4392. }
  4393. if (enterExitCosts.HeSuan > 0)
  4394. {
  4395. //insidePayTotal += enterExitCosts.HeSuan;
  4396. row1_2 += $"核酸检测费:{enterExitCosts.HeSuan:#0.00} 人民币/人";
  4397. }
  4398. if (enterExitCosts.Service > 0)
  4399. {
  4400. //insidePayTotal += enterExitCosts.Service;
  4401. row1_2 += $"服务费:{enterExitCosts.Service:#0.00} 人民币/人";
  4402. }
  4403. string row1_3 = "";
  4404. if (enterExitCosts.Safe > 0)
  4405. {
  4406. //insidePayTotal += enterExitCosts.Safe;
  4407. row1_3 += $"保险费:{enterExitCosts.Safe:#0.00} 人民币/人";
  4408. }
  4409. if (enterExitCosts.Ticket > 0)
  4410. {
  4411. //insidePayTotal += enterExitCosts.Ticket;
  4412. row1_3 += $"参展门票:{enterExitCosts.Ticket:#0.00} 人民币/人";
  4413. }
  4414. string row1 = "";
  4415. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4416. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4417. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4418. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4419. dic.Add("Row1Str", row1);
  4420. dic.Add("OutsideJJ", enterExitCosts.OutsideJJPay.ToString("#0.00"));
  4421. dic.Add("OutsaideGW", enterExitCosts.OutsideGWPay.ToString("#0.00"));
  4422. dic.Add("AirJJ", enterExitCosts.AirJJ.ToString("#0.00"));
  4423. dic.Add("AirGW", enterExitCosts.AirGW.ToString("#0.00"));
  4424. var cityTrafficLable = new StringBuilder()
  4425. .AppendFormat($"经济舱费用:{enterExitCosts.CityTranffic:#0.00} 元/人、")
  4426. .AppendFormat($"公务舱费用:{enterExitCosts.CityTranffic1:#0.00} 元/人、")
  4427. .AppendFormat($"头等舱费用:{enterExitCosts.CityTranffic2:#0.00}")
  4428. .ToString();
  4429. dic.Add("CityTranffic", cityTrafficLable);
  4430. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4431. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4432. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  4433. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  4434. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  4435. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + enterExitCosts.OutsideJJPay;
  4436. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + enterExitCosts.OutsideGWPay;
  4437. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4438. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4439. #region 填充word模板书签内容
  4440. foreach (var key in dic.Keys)
  4441. {
  4442. builder.MoveToBookmark(key);
  4443. builder.Write(dic[key]);
  4444. }
  4445. #endregion
  4446. #region 填充word表格内容
  4447. ////获读取指定表格方法二
  4448. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4449. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4450. for (int i = 0; i < dac1.Count; i++)
  4451. {
  4452. Grp_DayAndCost dac = dac1[i];
  4453. if (dac == null) continue;
  4454. builder.MoveToCell(0, i, 0, 0);
  4455. builder.Write("第" + dac.Days.ToString() + "晚:");
  4456. builder.MoveToCell(0, i, 1, 0);
  4457. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4458. //builder.Write(dac.Place == null ? "" : dac.Place);
  4459. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4460. builder.MoveToCell(0, i, 2, 0);
  4461. builder.Write("费用标准:");
  4462. string curr = "";
  4463. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4464. if (currData != null)
  4465. {
  4466. curr = currData.Name;
  4467. }
  4468. builder.MoveToCell(0, i, 3, 0);
  4469. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4470. builder.MoveToCell(0, i, 4, 0);
  4471. builder.Write("费用小计:");
  4472. builder.MoveToCell(0, i, 5, 0);
  4473. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4474. }
  4475. //删除多余行
  4476. while (table1.Rows.Count > dac1.Count)
  4477. {
  4478. table1.Rows.RemoveAt(dac1.Count);
  4479. }
  4480. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4481. for (int i = 0; i < dac2.Count; i++)
  4482. {
  4483. Grp_DayAndCost dac = dac2[i];
  4484. if (dac == null) continue;
  4485. builder.MoveToCell(1, i, 0, 0);
  4486. builder.Write("第" + dac.Days.ToString() + "天:");
  4487. builder.MoveToCell(1, i, 1, 0);
  4488. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4489. builder.MoveToCell(1, i, 2, 0);
  4490. builder.Write("费用标准:");
  4491. string curr = "";
  4492. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4493. if (currData != null)
  4494. {
  4495. curr = currData.Name;
  4496. }
  4497. builder.MoveToCell(1, i, 3, 0);
  4498. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4499. builder.MoveToCell(1, i, 4, 0);
  4500. builder.Write("费用小计:");
  4501. builder.MoveToCell(1, i, 5, 0);
  4502. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4503. }
  4504. //删除多余行
  4505. while (table2.Rows.Count > dac2.Count)
  4506. {
  4507. table2.Rows.RemoveAt(dac2.Count);
  4508. }
  4509. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4510. for (int i = 0; i < dac3.Count; i++)
  4511. {
  4512. Grp_DayAndCost dac = dac3[i];
  4513. if (dac == null) continue;
  4514. builder.MoveToCell(2, i, 0, 0);
  4515. builder.Write("第" + dac.Days.ToString() + "天:");
  4516. builder.MoveToCell(2, i, 1, 0);
  4517. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4518. builder.MoveToCell(2, i, 2, 0);
  4519. builder.Write("费用标准:");
  4520. string curr = "";
  4521. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4522. if (currData != null)
  4523. {
  4524. curr = currData.Name;
  4525. }
  4526. builder.MoveToCell(2, i, 3, 0);
  4527. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4528. builder.MoveToCell(2, i, 4, 0);
  4529. builder.Write("费用小计:");
  4530. builder.MoveToCell(2, i, 5, 0);
  4531. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4532. }
  4533. //删除多余行
  4534. while (table3.Rows.Count > dac3.Count)
  4535. {
  4536. table3.Rows.RemoveAt(dac3.Count);
  4537. }
  4538. #endregion
  4539. //文件名
  4540. //string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.{fileFormat}";
  4541. //string strFileName = $"{_DelegationInfo.TeamName}-出入境费用{Guid.NewGuid().ToString()}.{fileFormat}";
  4542. string strFileName = $"{_DelegationInfo.TeamName}{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.{fileFormat}";
  4543. AsposeHelper.removewatermark_v2180();
  4544. //doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4545. var saveFormat = Aspose.Words.SaveFormat.Docx;
  4546. if (fileFormat.Equals("pdf"))
  4547. {
  4548. //doc.LayoutOptions.IsShowComments = false;
  4549. doc.LayoutOptions.IsShowHiddenText = false;
  4550. doc.LayoutOptions.IsShowParagraphMarks = false;
  4551. doc.LayoutOptions.RevisionOptions.DeletedTextEffect = RevisionTextEffect.None;
  4552. doc.AcceptAllRevisions();
  4553. Aspose.Words.Saving.PdfSaveOptions options = new Aspose.Words.Saving.PdfSaveOptions();
  4554. options.Compliance = PdfCompliance.PdfA1a;
  4555. options.CreateNoteHyperlinks = true;
  4556. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName, options);
  4557. //_view.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName };
  4558. _view.Data = new { Url = strFileName };
  4559. _view.Msg = "成功";
  4560. return _view;
  4561. }
  4562. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName, saveFormat);
  4563. _view.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName };
  4564. _view.Msg = "成功";
  4565. return _view;
  4566. }
  4567. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4568. {
  4569. //获取模板
  4570. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4571. //载入模板
  4572. Document doc = new Document(tempPath);
  4573. DocumentBuilder builder = new DocumentBuilder(doc);
  4574. Dictionary<string, string> dic = new Dictionary<string, string>();
  4575. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4576. {
  4577. List<string> list = new List<string>();
  4578. try
  4579. {
  4580. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4581. foreach (var item in spilitArr)
  4582. {
  4583. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4584. var depCode = spDotandEmpty[2].Substring(0, 3);
  4585. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4586. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4587. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4588. list.Add(depName);
  4589. list.Add(arrName);
  4590. }
  4591. list = list.Distinct().ToList();
  4592. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4593. }
  4594. catch (Exception)
  4595. {
  4596. dic.Add("ReturnCode", "行程录入不正确!");
  4597. }
  4598. }
  4599. else
  4600. {
  4601. dic.Add("ReturnCode", "未录入行程!");
  4602. }
  4603. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4604. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4605. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4606. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4607. {
  4608. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4609. dic.Add("Day", sp.Days.ToString());
  4610. }
  4611. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4612. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4613. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4614. //dic.Add("Names", Names);
  4615. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4616. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4617. decimal dac1totalPrice = 0.00M;
  4618. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4619. foreach (var dac in dac1)
  4620. {
  4621. if (dac.SubTotal == 0.00M)
  4622. {
  4623. continue;
  4624. }
  4625. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4626. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4627. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4628. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4629. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4630. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4631. builder.Write(currency);//币种
  4632. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4633. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4634. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4635. builder.Write("");//人数
  4636. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4637. builder.Write("");//天数
  4638. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4639. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4640. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4641. decimal rate = 0.00M;
  4642. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4643. builder.Write(rate.ToString("#0.0000"));//汇率
  4644. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4645. decimal rbmPrice = dac.SubTotal;
  4646. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4647. accommodationStartIndex++;
  4648. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4649. }
  4650. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4651. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4652. {
  4653. table1.Rows.RemoveAt(i - 1);
  4654. foodandotherStartIndex--;
  4655. }
  4656. if (dac2.Count == dac3.Count)//国家 币种 金额
  4657. {
  4658. for (int i = 0; i < dac2.Count; i++)
  4659. {
  4660. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4661. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4662. }
  4663. }
  4664. decimal dac2totalPrice = 0.00M;
  4665. foreach (var dac in dac2)
  4666. {
  4667. if (dac.SubTotal == 0)
  4668. {
  4669. continue;
  4670. }
  4671. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4672. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4673. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4674. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4675. builder.Write(currency);//币种
  4676. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4677. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4678. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4679. builder.Write("");//人数
  4680. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4681. builder.Write("");//天数
  4682. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4683. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4684. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4685. decimal rate = 0.00M;
  4686. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4687. builder.Write(rate.ToString("#0.0000"));//汇率
  4688. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4689. decimal rbmPrice = dac.SubTotal;
  4690. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4691. foodandotherStartIndex++;
  4692. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4693. }
  4694. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4695. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4696. {
  4697. table1.Rows.RemoveAt(i - 1);
  4698. }
  4699. //dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
  4700. string otherFeeStr = "";
  4701. if (enterExitCosts.Visa > 0) otherFeeStr += $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 元,";
  4702. if (enterExitCosts.Safe > 0) otherFeeStr += $"保险费: {enterExitCosts.Safe.ToString("#0.00")} 元,";
  4703. if (enterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {enterExitCosts.Ticket.ToString("#0.00")} 元,";
  4704. if (otherFeeStr.Length > 0)
  4705. {
  4706. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4707. otherFeeStr = $"({otherFeeStr})";
  4708. dic.Add("OtherFeeStr", otherFeeStr);
  4709. }
  4710. //总计
  4711. decimal allPrice = dac1totalPrice + dac2totalPrice + enterExitCosts.Visa + enterExitCosts.Safe + enterExitCosts.Ticket;
  4712. //国际旅费
  4713. string outsideJJ = "";
  4714. string allPriceJJ = "";
  4715. if (enterExitCosts.SumJJC == 1)
  4716. {
  4717. outsideJJ = string.Format(@"经济舱:{0} 元/人", enterExitCosts.AirJJ.ToString("#0.00"));
  4718. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + enterExitCosts.OutsideJJPay).ToString("#0.00"));
  4719. }
  4720. string outsideGW = "";
  4721. string allPriceGW = "";
  4722. if (enterExitCosts.SumGWC == 1)
  4723. {
  4724. outsideGW = string.Format(@"公务舱:{0} 元/人", enterExitCosts.AirGW.ToString("#0.00"));
  4725. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + enterExitCosts.OutsideGWPay).ToString("#0.00"));
  4726. }
  4727. if (enterExitCosts.SumJJC == 1 || enterExitCosts.SumGWC == 1)
  4728. {
  4729. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  4730. dic.Add("InTravelPrice", InTravelPriceStr);
  4731. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  4732. dic.Add("FinalSumPrice", FinalSumPriceStr);
  4733. }
  4734. //dic.Add("VisaPay", enterExitCosts.Visa.ToString("#0.00"));
  4735. //dic.Add("SafePay", enterExitCosts.Safe.ToString("#0.00"));
  4736. //dic.Add("YiMiao", enterExitCosts.YiMiao.ToString("#0.00"));
  4737. foreach (var key in dic.Keys)
  4738. {
  4739. builder.MoveToBookmark(key);
  4740. builder.Write(dic[key]);
  4741. }
  4742. //模板文件名
  4743. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  4744. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4745. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4746. _view.Data = new { Url = url };
  4747. _view.Msg = "成功";
  4748. return _view;
  4749. }
  4750. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4751. {
  4752. //获取模板
  4753. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4754. //载入模板
  4755. WorkbookDesigner designer = new WorkbookDesigner();
  4756. designer.Workbook = new Workbook(tempPath);
  4757. Dictionary<string, string> dic = new Dictionary<string, string>();
  4758. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4759. {
  4760. List<string> list = new List<string>();
  4761. try
  4762. {
  4763. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4764. foreach (var item in spilitArr)
  4765. {
  4766. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4767. var depCode = spDotandEmpty[2].Substring(0, 3);
  4768. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4769. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4770. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4771. list.Add(depName);
  4772. list.Add(arrName);
  4773. }
  4774. list = list.Distinct().ToList();
  4775. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4776. }
  4777. catch (Exception)
  4778. {
  4779. dic.Add("ReturnCode", "行程录入不正确!");
  4780. }
  4781. }
  4782. else
  4783. {
  4784. dic.Add("ReturnCode", "未录入行程!");
  4785. }
  4786. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4787. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4788. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4789. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4790. {
  4791. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4792. dic.Add("Day", sp.Days.ToString());
  4793. }
  4794. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4795. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4796. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4797. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4798. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4799. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4800. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4801. designer.SetDataSource("Name", Names);
  4802. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4803. designer.SetDataSource("Day", dic["Day"] + "天");
  4804. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4805. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4806. int startIndex = 10;
  4807. const int startIndexcopy = 10;
  4808. if (dac2.Count == dac3.Count)//国家 币种 金额
  4809. {
  4810. for (int i = 0; i < dac2.Count; i++)
  4811. {
  4812. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4813. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4814. }
  4815. }
  4816. DataTable dtdac1 = new DataTable();
  4817. List<string> place = new List<string>();
  4818. dtdac1.Columns.AddRange(new DataColumn[] {
  4819. new DataColumn(){ ColumnName = "city"},
  4820. new DataColumn(){ ColumnName = "curr"},
  4821. new DataColumn(){ ColumnName = "criterion"},
  4822. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4823. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4824. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4825. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4826. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4827. });
  4828. DataTable dtdac2 = new DataTable();
  4829. dtdac2.Columns.AddRange(new DataColumn[] {
  4830. new DataColumn(){ ColumnName = "city"},
  4831. new DataColumn(){ ColumnName = "curr"},
  4832. new DataColumn(){ ColumnName = "criterion"},
  4833. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4834. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4835. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4836. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4837. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4838. });
  4839. dtdac1.TableName = "tb1";
  4840. dtdac2.TableName = "tb2";
  4841. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4842. foreach (var item in dac1)
  4843. {
  4844. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4845. if (place.Contains(item.Place))
  4846. {
  4847. continue;
  4848. }
  4849. DataRow row = dtdac1.NewRow();
  4850. row["city"] = item.Place;
  4851. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4852. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4853. row["curr"] = currency;
  4854. row["rate"] = rate.ToString("#0.0000");
  4855. row["criterion"] = item.Cost.ToString("#0.00");
  4856. row["number"] = 1;
  4857. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4858. //row["costRMB"] = rbmPrice;
  4859. dtdac1.Rows.Add(row);
  4860. place.Add(item.Place);
  4861. }
  4862. place = new List<string>();
  4863. foreach (var item in dac2)
  4864. {
  4865. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4866. if (place.Contains(item.Place))
  4867. {
  4868. continue;
  4869. }
  4870. DataRow row = dtdac2.NewRow();
  4871. row["city"] = item.Place;
  4872. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4873. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4874. row["curr"] = currency;
  4875. row["rate"] = rate.ToString("#0.0000");
  4876. row["criterion"] = item.Cost.ToString("#0.00");
  4877. row["number"] = 1;
  4878. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4879. //row["cost"] = item.SubTotal;
  4880. //row["costRMB"] = rbmPrice;
  4881. dtdac2.Rows.Add(row);
  4882. place.Add(item.Place);
  4883. //dac2totalPrice += rbmPrice;
  4884. }
  4885. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4886. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4887. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4888. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4889. //designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {enterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4890. //designer.SetDataSource("sumCityTranffic", @$"{enterExitCosts.CityTranffic.ToString("#0.00")} ");
  4891. string cell4Str = $" 4.国际旅费:经济舱:{enterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{enterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4892. string cellStr = $" 5.其他费用(";
  4893. if (enterExitCosts.Visa > 0) cellStr += $"签证费:{enterExitCosts.Visa.ToString("#0.00")}元,";
  4894. if (enterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{enterExitCosts.YiMiao.ToString("#0.00")}元,";
  4895. if (enterExitCosts.HeSuan > 0) cellStr += $"核酸费:{enterExitCosts.HeSuan.ToString("#0.00")}元,";
  4896. if (enterExitCosts.Safe > 0) cellStr += $"保险费:{enterExitCosts.Safe.ToString("#0.00")}元,";
  4897. if (enterExitCosts.Ticket > 0) cellStr += $"参展门票费:{enterExitCosts.Ticket.ToString("#0.00")}元,";
  4898. if (enterExitCosts.Service > 0) cellStr += $"服务费:{enterExitCosts.Service.ToString("#0.00")}元,";
  4899. if (cellStr.Length > 8)
  4900. {
  4901. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4902. }
  4903. cellStr += ")";
  4904. decimal otherFee = enterExitCosts.Visa + enterExitCosts.YiMiao + enterExitCosts.HeSuan + enterExitCosts.Safe + enterExitCosts.Ticket + enterExitCosts.Service;
  4905. decimal s = dac1totalPrice + dac2totalPrice + enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay + otherFee;
  4906. decimal pxFee = dac4.Sum(it => it.Cost);
  4907. decimal glvFee = enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay;
  4908. string celllastStr1 = "";
  4909. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4910. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4911. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4912. celllastStr1 += $",国际旅费 元";
  4913. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4914. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4915. designer.SetDataSource("cell4Str", cell4Str);
  4916. designer.SetDataSource("cellStr", cellStr);
  4917. designer.SetDataSource("cellSum", (enterExitCosts.Visa + enterExitCosts.Safe).ToString("#0.00"));
  4918. designer.SetDataSource("cellSum4", (enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay).ToString("#0.00"));
  4919. designer.SetDataSource("celllastStr", celllastStr);
  4920. Workbook wb = designer.Workbook;
  4921. var sheet = wb.Worksheets[0];
  4922. //绑定datatable数据集
  4923. designer.SetDataSource(dtdac1);
  4924. designer.SetDataSource(dtdac2);
  4925. designer.Process();
  4926. var rowStart = dtdac1.Rows.Count;
  4927. while (rowStart > 0)
  4928. {
  4929. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4930. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4931. startIndex++;
  4932. rowStart--;
  4933. }
  4934. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4935. startIndex += 1; //总计行
  4936. rowStart = dtdac2.Rows.Count;
  4937. while (rowStart > 0)
  4938. {
  4939. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4940. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4941. startIndex++;
  4942. rowStart--;
  4943. }
  4944. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4945. wb.CalculateFormula(true);
  4946. //模板文件名
  4947. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls"; ;//$".xls";
  4948. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4949. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4950. _view.Data = new { Url = url };
  4951. _view.Msg = "成功";
  4952. return _view;
  4953. }
  4954. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4955. {
  4956. //获取模板
  4957. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4958. //载入模板
  4959. Document doc = new Document(tempPath);
  4960. DocumentBuilder builder = new DocumentBuilder(doc);
  4961. Dictionary<string, string> dic = new Dictionary<string, string>();
  4962. dic.Add("GroupName", _DelegationInfo.TeamName);
  4963. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4964. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4965. string missionLeaderJob = "";//负责人job
  4966. //int groupNumber = 0; //团人数
  4967. if (DeleClientList.Count > 0)
  4968. {
  4969. missionLeader = DeleClientList[0]?.Name ?? "";
  4970. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4971. }
  4972. dic.Add("MissionLeader", missionLeader); //团负责人
  4973. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4974. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4975. #region MyRegion
  4976. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4977. //{
  4978. // List<string> list = new List<string>();
  4979. // try
  4980. // {
  4981. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4982. // foreach (var item in spilitArr)
  4983. // {
  4984. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4985. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4986. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4987. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4988. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4989. // list.Add(depName);
  4990. // list.Add(arrName);
  4991. // }
  4992. // list = list.Distinct().ToList();
  4993. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4994. // }
  4995. // catch (Exception)
  4996. // {
  4997. // dic.Add("ReturnCode", "行程录入不正确!");
  4998. // }
  4999. //}
  5000. //else
  5001. //{
  5002. // dic.Add("ReturnCode", "未录入行程!");
  5003. //}
  5004. List<string> countrys = _dirRep.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5005. dic.Add("ReturnCode", string.Join("、", countrys));
  5006. #endregion
  5007. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5008. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5009. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5010. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5011. //{
  5012. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5013. // dic.Add("Day", sp.Days.ToString());
  5014. //}
  5015. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5016. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5017. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5018. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5019. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5020. //培训人员名单
  5021. int cultivateRowIndex = 7;
  5022. foreach (var item in DeleClientList)
  5023. {
  5024. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5025. builder.Write(item.Name);
  5026. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5027. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5028. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5029. string birthDay = "";
  5030. if (item.Birthday != null)
  5031. {
  5032. DateTime dt = Convert.ToDateTime(item.Birthday);
  5033. birthDay = $"{dt.Year}.{dt.Month}";
  5034. }
  5035. builder.Write(birthDay);
  5036. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5037. builder.Write(item.Company);
  5038. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5039. builder.Write(item.Job);
  5040. cultivateRowIndex++;
  5041. }
  5042. //删除多余行
  5043. //cultivateRowIndex -= 2;
  5044. int delRows = 10 + 7 - cultivateRowIndex;
  5045. if (delRows > 0)
  5046. {
  5047. for (int i = 0; i < delRows; i++)
  5048. {
  5049. table1.Rows.RemoveAt(cultivateRowIndex);
  5050. //cultivateRowIndex++;
  5051. }
  5052. }
  5053. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5054. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5055. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5056. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5057. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5058. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5059. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5060. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5061. decimal cityTranfficFeeToatal = 0.00M;
  5062. //decimal cityTranfficFeeToatal = enterExitCosts.CityTranffic; //城市区间交通费
  5063. //dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5064. //其他费用
  5065. decimal otherFeeTotal = enterExitCosts.Visa + enterExitCosts.Safe + enterExitCosts.Ticket + enterExitCosts.YiMiao + enterExitCosts.HeSuan + enterExitCosts.Service;
  5066. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5067. //其他费用合计
  5068. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5069. decimal _jjcFeeToatal = enterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5070. decimal _gwcFeeToatal = enterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5071. //公务舱合计
  5072. //国际旅费
  5073. //string outsideJJ = "";
  5074. //string allPriceJJ = "";
  5075. if (enterExitCosts.SumJJC == 1 && enterExitCosts.SumGWC == 0)
  5076. {
  5077. dic.Add("AirFeeTotal", enterExitCosts.AirJJ.ToString("#0.00"));
  5078. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5079. }
  5080. if (enterExitCosts.SumGWC == 1 && enterExitCosts.SumJJC == 0)
  5081. {
  5082. dic.Add("AirFeeTotal", enterExitCosts.AirGW.ToString("#0.00"));
  5083. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5084. }
  5085. if (enterExitCosts.SumJJC == 1 && enterExitCosts.SumGWC == 1)
  5086. {
  5087. string airFeeTotalStr = string.Format(@$"经济舱:{enterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{enterExitCosts.AirGW.ToString("#0.00")}");
  5088. dic.Add("AirFeeTotal", airFeeTotalStr);
  5089. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5090. dic.Add("FeeTotal", feeTotalStr);
  5091. }
  5092. foreach (var key in dic.Keys)
  5093. {
  5094. builder.MoveToBookmark(key);
  5095. builder.Write(dic[key]);
  5096. }
  5097. //模板文件名
  5098. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5099. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5100. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5101. _view.Data = new { Url = url };
  5102. _view.Msg = "成功";
  5103. return _view;
  5104. }
  5105. }
  5106. else if (dto.ExportType == 2) //表格
  5107. {
  5108. //利用键值对存放数据
  5109. Dictionary<string, string> dic = new Dictionary<string, string>();
  5110. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5111. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5112. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5113. dic.Add("Day", sp.Days.ToString());
  5114. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5115. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5116. {
  5117. //获取模板
  5118. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5119. //载入模板
  5120. Document doc = new Document(tempPath);
  5121. DocumentBuilder builder = new DocumentBuilder(doc);
  5122. dic.Add("TeamName", _DelegationInfo.TeamName);
  5123. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5124. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5125. string missionLeaderName = "",
  5126. missionLeaderJob = "";
  5127. if (DeleClientList.Count > 0)
  5128. {
  5129. missionLeaderName = DeleClientList[0].Name;
  5130. missionLeaderJob = DeleClientList[0].Job;
  5131. }
  5132. dic.Add("MissionLeaderName", missionLeaderName);
  5133. dic.Add("MissionLeaderJob", missionLeaderJob);
  5134. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5135. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5136. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5137. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5138. int rowCount = 10;//总人数行
  5139. int startRowIndex = 7; //起始行
  5140. for (int i = 0; i < DeleClientList.Count; i++)
  5141. {
  5142. builder.MoveToCell(0, startRowIndex, 0, 0);
  5143. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5144. builder.MoveToCell(0, startRowIndex, 1, 0);
  5145. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5146. builder.Write(sex);//性别
  5147. builder.MoveToCell(0, startRowIndex, 2, 0);
  5148. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5149. builder.MoveToCell(0, startRowIndex, 3, 0);
  5150. builder.Write(DeleClientList[i].Company);//工作单位
  5151. builder.MoveToCell(0, startRowIndex, 4, 0);
  5152. builder.Write(DeleClientList[i].Job);//职务及级别
  5153. builder.MoveToCell(0, startRowIndex, 5, 0);
  5154. builder.Write("");//人员属性
  5155. builder.MoveToCell(0, startRowIndex, 6, 0);
  5156. builder.Write("");//上次出国时间
  5157. startRowIndex++;
  5158. }
  5159. int nullRow = rowCount - DeleClientList.Count;//空行
  5160. for (int i = 0; i < nullRow; i++)
  5161. {
  5162. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5163. }
  5164. foreach (var key in dic.Keys)
  5165. {
  5166. builder.MoveToBookmark(key);
  5167. builder.Write(dic[key]);
  5168. }
  5169. //模板文件名
  5170. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5171. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5172. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5173. _view.Data = new { Url = url };
  5174. _view.Msg = "成功";
  5175. return _view;
  5176. }
  5177. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5178. {
  5179. //获取模板
  5180. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5181. //载入模板
  5182. Document doc = new Document(tempPath);
  5183. DocumentBuilder builder = new DocumentBuilder(doc);
  5184. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5185. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5186. dic.Add("Names", Names);
  5187. int accommodationRows = 12, foodandotherRows = 12;
  5188. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5189. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5190. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5191. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5192. int accommodationStartIndex = 6;
  5193. decimal dac1totalPrice = 0.00M;
  5194. foreach (var dac in dac1)
  5195. {
  5196. if (dac.SubTotal == 0)
  5197. {
  5198. continue;
  5199. }
  5200. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5201. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5202. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5203. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5204. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5205. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5206. builder.Write(currency);//币种
  5207. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5208. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5209. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5210. builder.Write("");//人数
  5211. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5212. builder.Write("");//天数
  5213. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5214. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5215. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5216. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5217. builder.Write(rate.ToString("#0.0000"));//汇率
  5218. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5219. decimal rbmPrice = rate * dac.SubTotal;
  5220. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5221. accommodationStartIndex++;
  5222. dac1totalPrice += rbmPrice;
  5223. }
  5224. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5225. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5226. builder.Write("小计");
  5227. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5228. builder.Write(dac1totalPrice.ToString("#0.00"));
  5229. accommodationStartIndex++;
  5230. int nullRow = accommodationRows - dac1.Count;
  5231. //删除空行
  5232. //if (nullRow > 0)
  5233. //{
  5234. // int rowIndex = accommodationStartIndex;
  5235. // for (int i = 0; i < nullRow; i++)
  5236. // {
  5237. // Row row = table1.Rows[rowIndex];
  5238. // row.Remove();
  5239. // rowIndex++;
  5240. // }
  5241. //}
  5242. if (dac2.Count == dac3.Count)//国家 币种 金额
  5243. {
  5244. for (int i = 0; i < dac2.Count; i++)
  5245. {
  5246. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5247. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5248. }
  5249. }
  5250. int foodandotherStartIndex = 19;//
  5251. decimal dac2totalPrice = 0.00M;
  5252. foreach (var dac in dac2)
  5253. {
  5254. if (dac.SubTotal == 0)
  5255. {
  5256. continue;
  5257. }
  5258. //foodandotherStartIndex = 12;
  5259. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5260. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5261. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5262. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5263. builder.Write(currency);//币种
  5264. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5265. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5266. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5267. builder.Write("");//人数
  5268. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5269. builder.Write("");//天数
  5270. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5271. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5272. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5273. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5274. builder.Write(rate.ToString("#0.0000"));//汇率
  5275. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5276. decimal rbmPrice = rate * dac.SubTotal;
  5277. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5278. foodandotherStartIndex++;
  5279. dac2totalPrice += rbmPrice;
  5280. }
  5281. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5282. //删除空行
  5283. if (dac2.Count < foodandotherRows)
  5284. {
  5285. //int nullRow = accommodationRows - dac2.Count;
  5286. //while (table2.Rows.Count > dac2.Count)
  5287. //{
  5288. // table2.Rows.RemoveAt(dac2.Count);
  5289. //}
  5290. }
  5291. //dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
  5292. string otherFeeStr = "";
  5293. if (enterExitCosts.Visa > 0) otherFeeStr += $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 元,";
  5294. if (enterExitCosts.Safe > 0) otherFeeStr += $"保险费: {enterExitCosts.Safe.ToString("#0.00")} 元,";
  5295. if (enterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {enterExitCosts.Ticket.ToString("#0.00")} 元,";
  5296. if (otherFeeStr.Length > 0)
  5297. {
  5298. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5299. otherFeeStr = $"({otherFeeStr})";
  5300. dic.Add("OtherFeeStr", otherFeeStr);
  5301. }
  5302. foreach (var key in dic.Keys)
  5303. {
  5304. builder.MoveToBookmark(key);
  5305. builder.Write(dic[key]);
  5306. }
  5307. //模板文件名
  5308. string strFileName = $"省级单位出(境)经费报销单.docx";
  5309. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5310. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5311. _view.Data = new { Url = url };
  5312. _view.Msg = "成功";
  5313. return _view;
  5314. }
  5315. }
  5316. else if (dto.ExportType == 3)
  5317. {
  5318. if (dto.SubTypeId == 1) //团组成员名单
  5319. {
  5320. if (DeleClientList.Count < 1)
  5321. {
  5322. _view.Msg = "团组成员暂未录入!!!";
  5323. return _view;
  5324. }
  5325. //获取模板
  5326. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5327. //载入模板
  5328. Document doc = new Document(tempPath);
  5329. DocumentBuilder builder = new DocumentBuilder(doc);
  5330. //获取word里所有表格
  5331. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5332. //获取所填表格的序数
  5333. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5334. var rowStart = tableOne.Rows[0]; //获取第1行
  5335. //循环赋值
  5336. for (int i = 0; i < DeleClientList.Count; i++)
  5337. {
  5338. builder.MoveToCell(0, i + 1, 0, 0);
  5339. builder.Write(DeleClientList[i].Name);
  5340. builder.MoveToCell(0, i + 1, 1, 0);
  5341. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5342. builder.Write(sex);
  5343. builder.MoveToCell(0, i + 1, 2, 0);
  5344. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5345. builder.MoveToCell(0, i + 1, 3, 0);
  5346. builder.Write(DeleClientList[i].Company);
  5347. builder.MoveToCell(0, i + 1, 4, 0);
  5348. builder.Write(DeleClientList[i].Job);
  5349. }
  5350. //删除多余行
  5351. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5352. {
  5353. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5354. }
  5355. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5356. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5357. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5358. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5359. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5360. _view.Data = new { Url = url };
  5361. _view.Msg = "成功";
  5362. return _view;
  5363. }
  5364. }
  5365. }
  5366. catch (Exception ex)
  5367. {
  5368. _view.Code = StatusCodes.Status500InternalServerError;
  5369. _view.Msg = ex.Message;
  5370. return _view;
  5371. }
  5372. return _view;
  5373. }
  5374. #endregion
  5375. #region 机票费用提示
  5376. /// <summary>
  5377. /// 三公机票费用提示
  5378. /// </summary>
  5379. /// <param name="diId"></param>
  5380. /// <returns></returns>
  5381. public static async Task<EntryAndExitTipsView[]> EntryAndExitTips(int diId)
  5382. {
  5383. if (diId < 1) return Array.Empty<EntryAndExitTipsView>();
  5384. var airFees = await _sqlSugar.Queryable<Air_TicketBlackCode>().Where(a => a.IsDel == 0 && a.DiId == diId).ToListAsync();
  5385. if (airFees.Any())
  5386. {
  5387. var result = new List<EntryAndExitTipsView>();
  5388. foreach (var x in airFees)
  5389. {
  5390. string tripDesc = "";
  5391. if (!string.IsNullOrEmpty(x.BlackCode))
  5392. {
  5393. var redisKeyName = string.Format("AirTripDesc_{0}_{1}", x.DiId, x.Id);
  5394. tripDesc = await KIMIAirTripCodeRec(redisKeyName, x.BlackCode);
  5395. }
  5396. result.Add(new EntryAndExitTipsView
  5397. {
  5398. jjcCurrentRate = x.ECPrice,
  5399. gwcCurrentRate = x.BCPrice,
  5400. tdcCurrentRate = x.FCPrice,
  5401. remark = $"经济舱全价:{x.ECPrice.ToString("#0.00")} 元/人 公务舱全价:{x.BCPrice.ToString("#0.00")} 元/人 头等舱全价:{x.FCPrice.ToString("#0.00")} 元/人",
  5402. TripDesc = tripDesc
  5403. });
  5404. }
  5405. return result.OrderByDescending(x => x.jjcCurrentRate + x.gwcCurrentRate + x.tdcCurrentRate).ToArray();
  5406. }
  5407. return Array.Empty<EntryAndExitTipsView>();
  5408. }
  5409. /// <summary>
  5410. /// 机票行程代码识别
  5411. /// </summary>
  5412. /// <param name="redisKeyName">redis缓存名称(名称定义格式:AirTripDesc_Diid_Id)</param>
  5413. /// <param name="msg"></param>
  5414. /// <returns></returns>
  5415. public static async Task<string> KIMIAirTripCodeRec(string redisKeyName, string msg)
  5416. {
  5417. string result = string.Empty;
  5418. if (!string.IsNullOrEmpty(redisKeyName))
  5419. {
  5420. result = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>(redisKeyName);//string 取
  5421. if (!string.IsNullOrEmpty(result)) return result;
  5422. }
  5423. if (string.IsNullOrEmpty(msg)) return result;
  5424. KiMiApiClient KiMiApi = new KiMiApiClient();
  5425. var kimiMsgs = new List<SeedMessages>() {
  5426. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  5427. new SeedMessages { Role = KimiRole.user, Content = "请将提供的三字码行程信息翻译成中文,每条信息独立一行,并在次日到达的时间后加上“+1”以表示次日。日期(星期)格式请按照“04月14日(星期一)”标注。航站楼信息请按照“T1”、“T2”、“ ”等格式标注。只输出正文数据,不要除正文数据外的任何文字以及符号。格式示例如下:\r\n1. CA445 05月17日(星期六) 成都天府 T1 - 米兰马尔彭萨 T1 01:50 06:55" },
  5428. new SeedMessages { Role = KimiRole.user, Content = msg }
  5429. };
  5430. var kimiApiResult = await KiMiApi.SeedMessage(kimiMsgs);
  5431. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  5432. result = kimiApiResult_JObject["content"].ToString();
  5433. if (!string.IsNullOrEmpty(result))
  5434. {
  5435. TimeSpan expiry = TimeSpan.FromMinutes(5); // 5分钟
  5436. await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>(redisKeyName, result, expiry);//string 存
  5437. }
  5438. return result;
  5439. }
  5440. #endregion
  5441. #endregion
  5442. #region Excel导出服务
  5443. #region 类
  5444. public class FileExportSettings
  5445. {
  5446. public string ExportBasePath { get; set; } = "wwwroot/exports";
  5447. public string DownloadBaseUrl { get; set; } = "/exports";
  5448. public int RetentionDays { get; set; } = 7;
  5449. public int MaxFileSizeMB { get; set; } = 50;
  5450. public string ExcelTemplatesPath { get; set; } = "Templates/Excel";
  5451. }
  5452. public class ExportResult
  5453. {
  5454. public bool Success { get; set; }
  5455. public string FilePath { get; set; }
  5456. public string DownloadUrl { get; set; }
  5457. public string FileName { get; set; }
  5458. public long FileSize { get; set; }
  5459. public string MimeType { get; set; } = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
  5460. public string ErrorMessage { get; set; }
  5461. public DateTime GeneratedAt { get; set; } = DateTime.Now;
  5462. }
  5463. public class ExportRequest
  5464. {
  5465. public IEnumerable<object> Data { get; set; }
  5466. public string FileName { get; set; }
  5467. public string SheetName { get; set; } = "Sheet1";
  5468. public string TemplateType { get; set; } = "default";
  5469. public Dictionary<string, string> CustomHeaders { get; set; }
  5470. }
  5471. public class ExportResponse
  5472. {
  5473. public string FilePath { get; set; }
  5474. public string DownloadUrl { get; set; }
  5475. public string FileName { get; set; }
  5476. public long FileSize { get; set; }
  5477. public DateTime GeneratedAt { get; set; }
  5478. public string Message { get; set; }
  5479. }
  5480. #endregion
  5481. public static async Task<ExportResult> ExportToExcel<T>(IEnumerable<T> data, string fileName, string sheetName = "Sheet1", string templateType = "default")
  5482. {
  5483. try
  5484. {
  5485. byte[] excelBytes = templateType.ToLower() switch
  5486. {
  5487. "styled" => GenerateStyledExcel(data, sheetName),
  5488. "with_formulas" => GenerateExcelWithFormulas(data, sheetName),
  5489. //"with_charts" => GenerateExcelWithCharts(data, sheetName),
  5490. _ => GenerateDefaultExcel(data, sheetName)
  5491. };
  5492. var filePath = await SaveFileAsync(excelBytes, fileName, "excel");
  5493. var downloadUrl = $"wwwroot/exports/{filePath}";
  5494. return new ExportResult
  5495. {
  5496. Success = true,
  5497. FilePath = filePath,
  5498. DownloadUrl = downloadUrl,
  5499. FileName = Path.GetFileName(filePath),
  5500. FileSize = excelBytes.Length,
  5501. MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  5502. };
  5503. }
  5504. catch (Exception ex)
  5505. {
  5506. return new ExportResult
  5507. {
  5508. Success = false,
  5509. ErrorMessage = ex.Message
  5510. };
  5511. }
  5512. }
  5513. public static async Task<ExportResult> ExportWithTemplate<T>(IEnumerable<T> data, byte[] templateBytes, string fileName, string sheetName = "Sheet1")
  5514. {
  5515. try
  5516. {
  5517. using var templateStream = new MemoryStream(templateBytes);
  5518. using var workbook = new Workbook(templateStream);
  5519. var worksheet = workbook.Worksheets[sheetName] ?? workbook.Worksheets[0];
  5520. // 查找数据起始行(可以根据模板中的标记来定位)
  5521. int startRow = FindDataStartRow(worksheet);
  5522. // 填充数据
  5523. FillWorksheetWithData(worksheet, data, startRow);
  5524. using var outputStream = new MemoryStream();
  5525. workbook.Save(outputStream, Aspose.Cells.SaveFormat.Xlsx);
  5526. var excelBytes = outputStream.ToArray();
  5527. var filePath = await SaveFileAsync(excelBytes, fileName, "excel/templates");
  5528. var downloadUrl = $"wwwroot/exports/exports/{filePath}";
  5529. return new ExportResult
  5530. {
  5531. Success = true,
  5532. FilePath = filePath,
  5533. DownloadUrl = downloadUrl,
  5534. FileName = Path.GetFileName(filePath),
  5535. FileSize = excelBytes.Length,
  5536. MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  5537. };
  5538. }
  5539. catch (Exception ex)
  5540. {
  5541. return new ExportResult
  5542. {
  5543. Success = false,
  5544. ErrorMessage = ex.Message
  5545. };
  5546. }
  5547. }
  5548. public static async Task<ExportResult> ExportMultipleSheets<T>(Dictionary<string, IEnumerable<T>> sheetsData, string fileName)
  5549. {
  5550. try
  5551. {
  5552. using var workbook = new Workbook();
  5553. workbook.Worksheets.Clear(); // 清除默认工作表
  5554. foreach (var sheet in sheetsData)
  5555. {
  5556. var worksheet = workbook.Worksheets.Add(sheet.Key);
  5557. var data = sheet.Value;
  5558. if (data != null && data.Any())
  5559. {
  5560. FillWorksheetWithData(worksheet, data, 0);
  5561. worksheet.AutoFitColumns();
  5562. }
  5563. }
  5564. using var stream = new MemoryStream();
  5565. workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  5566. var excelBytes = stream.ToArray();
  5567. var filePath = await SaveFileAsync(excelBytes, fileName, "excel/multi-sheets");
  5568. var downloadUrl = $"wwwroot/exports/exports/{filePath}";
  5569. return new ExportResult
  5570. {
  5571. Success = true,
  5572. FilePath = filePath,
  5573. DownloadUrl = downloadUrl,
  5574. FileName = Path.GetFileName(filePath),
  5575. FileSize = excelBytes.Length,
  5576. MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  5577. };
  5578. }
  5579. catch (Exception ex)
  5580. {
  5581. return new ExportResult
  5582. {
  5583. Success = false,
  5584. ErrorMessage = ex.Message
  5585. };
  5586. }
  5587. }
  5588. public static async Task<ExportResult> ExportWithCustomHeaders<T>(IEnumerable<T> data, Dictionary<string, string> headers, string fileName, string sheetName = "Sheet1")
  5589. {
  5590. try
  5591. {
  5592. using var workbook = new Workbook();
  5593. var worksheet = workbook.Worksheets[0];
  5594. worksheet.Name = sheetName;
  5595. // 设置自定义表头
  5596. int colIndex = 0;
  5597. foreach (var header in headers)
  5598. {
  5599. worksheet.Cells[0, colIndex].PutValue(header.Value);
  5600. colIndex++;
  5601. }
  5602. // 填充数据
  5603. if (data != null && data.Any())
  5604. {
  5605. int rowIndex = 1;
  5606. var properties = typeof(T).GetProperties();
  5607. foreach (var item in data)
  5608. {
  5609. colIndex = 0;
  5610. foreach (var header in headers)
  5611. {
  5612. var property = properties.FirstOrDefault(p => p.Name == header.Key);
  5613. if (property != null)
  5614. {
  5615. var value = property.GetValue(item);
  5616. worksheet.Cells[rowIndex, colIndex].PutValue(value);
  5617. }
  5618. colIndex++;
  5619. }
  5620. rowIndex++;
  5621. }
  5622. }
  5623. worksheet.AutoFitColumns();
  5624. using var stream = new MemoryStream();
  5625. workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  5626. var excelBytes = stream.ToArray();
  5627. var filePath = await SaveFileAsync(excelBytes, fileName, "excel/custom-headers");
  5628. var downloadUrl = $"filePath";
  5629. return new ExportResult
  5630. {
  5631. Success = true,
  5632. FilePath = filePath,
  5633. DownloadUrl = downloadUrl,
  5634. FileName = Path.GetFileName(filePath),
  5635. FileSize = excelBytes.Length,
  5636. MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  5637. };
  5638. }
  5639. catch (Exception ex)
  5640. {
  5641. return new ExportResult
  5642. {
  5643. Success = false,
  5644. ErrorMessage = ex.Message
  5645. };
  5646. }
  5647. }
  5648. private static byte[] GenerateDefaultExcel<T>(IEnumerable<T> data, string sheetName)
  5649. {
  5650. using var workbook = new Workbook();
  5651. var worksheet = workbook.Worksheets[0];
  5652. worksheet.Name = sheetName;
  5653. if (data != null && data.Any())
  5654. {
  5655. FillWorksheetWithData(worksheet, data, 0);
  5656. worksheet.AutoFitColumns();
  5657. }
  5658. return SaveWorkbookToBytes(workbook);
  5659. }
  5660. private static byte[] GenerateStyledExcel<T>(IEnumerable<T> data, string sheetName)
  5661. {
  5662. using var workbook = new Workbook();
  5663. var worksheet = workbook.Worksheets[0];
  5664. worksheet.Name = sheetName;
  5665. if (data != null && data.Any())
  5666. {
  5667. FillWorksheetWithData(worksheet, data, 0);
  5668. // 设置样式
  5669. var headerStyle = workbook.CreateStyle();
  5670. headerStyle.Pattern = BackgroundType.Solid;
  5671. headerStyle.ForegroundColor = System.Drawing.Color.LightGray;
  5672. headerStyle.Font.IsBold = true;
  5673. headerStyle.HorizontalAlignment = TextAlignmentType.Center;
  5674. var properties = typeof(T).GetProperties();
  5675. Aspose.Cells.Range headerRange = worksheet.Cells.CreateRange(0, 0, 1, properties.Length);
  5676. headerRange.ApplyStyle(headerStyle, new StyleFlag { All = true });
  5677. worksheet.AutoFitColumns();
  5678. }
  5679. return SaveWorkbookToBytes(workbook);
  5680. }
  5681. private static byte[] GenerateExcelWithFormulas<T>(IEnumerable<T> data, string sheetName)
  5682. {
  5683. using var workbook = new Workbook();
  5684. var worksheet = workbook.Worksheets[0];
  5685. worksheet.Name = sheetName;
  5686. if (data != null && data.Any())
  5687. {
  5688. FillWorksheetWithData(worksheet, data, 0);
  5689. // 添加公式(例如:求和公式)
  5690. var properties = typeof(T).GetProperties();
  5691. int lastRow = data.Count() + 1;
  5692. for (int i = 0; i < properties.Length; i++)
  5693. {
  5694. if (IsNumericType(properties[i].PropertyType))
  5695. {
  5696. worksheet.Cells[lastRow, i].Formula = $"=SUM({worksheet.Cells[1, i].Name}:{worksheet.Cells[lastRow - 1, i].Name})";
  5697. }
  5698. }
  5699. worksheet.AutoFitColumns();
  5700. }
  5701. return SaveWorkbookToBytes(workbook);
  5702. }
  5703. private static void FillWorksheetWithData<T>(Worksheet worksheet, IEnumerable<T> data, int startRow)
  5704. {
  5705. var properties = typeof(T).GetProperties();
  5706. // 设置表头
  5707. for (int i = 0; i < properties.Length; i++)
  5708. {
  5709. worksheet.Cells[startRow, i].PutValue(properties[i].Name);
  5710. }
  5711. // 填充数据
  5712. int rowIndex = startRow + 1;
  5713. foreach (var item in data)
  5714. {
  5715. for (int colIndex = 0; colIndex < properties.Length; colIndex++)
  5716. {
  5717. var value = properties[colIndex].GetValue(item);
  5718. worksheet.Cells[rowIndex, colIndex].PutValue(value);
  5719. }
  5720. rowIndex++;
  5721. }
  5722. }
  5723. private static int FindDataStartRow(Worksheet worksheet)
  5724. {
  5725. // 在实际项目中,可以根据模板中的特定标记来定位数据起始行
  5726. // 例如查找 "{{DATA_START}}" 这样的标记
  5727. for (int row = 0; row < 50; row++)
  5728. {
  5729. for (int col = 0; col < 10; col++)
  5730. {
  5731. var value = worksheet.Cells[row, col].StringValue;
  5732. if (value == "{{DATA_START}}")
  5733. {
  5734. worksheet.Cells[row, col].PutValue(""); // 清空标记
  5735. return row + 1;
  5736. }
  5737. }
  5738. }
  5739. return 1; // 默认从第2行开始
  5740. }
  5741. private static byte[] SaveWorkbookToBytes(Workbook workbook)
  5742. {
  5743. using var stream = new MemoryStream();
  5744. workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  5745. return stream.ToArray();
  5746. }
  5747. private static bool IsNumericType(Type type)
  5748. {
  5749. return Type.GetTypeCode(type) switch
  5750. {
  5751. TypeCode.Byte or TypeCode.SByte or TypeCode.UInt16 or TypeCode.UInt32 or
  5752. TypeCode.UInt64 or TypeCode.Int16 or TypeCode.Int32 or TypeCode.Int64 or
  5753. TypeCode.Decimal or TypeCode.Double or TypeCode.Single => true,
  5754. _ => false
  5755. };
  5756. }
  5757. public static async Task<string> SaveFileAsync(byte[] fileData, string fileName, string subFolder = "")
  5758. {
  5759. try
  5760. {
  5761. var basePath = "wwwroot/exports/exports";
  5762. var folderPath = Path.Combine(basePath, subFolder);
  5763. Directory.CreateDirectory(folderPath);
  5764. var uniqueFileName = $"{Path.GetFileNameWithoutExtension(fileName)}_{Guid.NewGuid():N}{Path.GetExtension(fileName)}.xlsx";
  5765. var filePath = Path.Combine(folderPath, uniqueFileName);
  5766. await System.IO.File.WriteAllBytesAsync(filePath, fileData);
  5767. var relativePath = Path.Combine(basePath, subFolder, uniqueFileName).Replace("\\", "/");
  5768. return relativePath;
  5769. }
  5770. catch (Exception ex)
  5771. {
  5772. throw;
  5773. }
  5774. }
  5775. #endregion
  5776. #region 动态构架word表格
  5777. /// <summary>
  5778. /// 设置表格样式
  5779. /// </summary>
  5780. /// <param name="builder"></param>
  5781. public static void SetupDocumentStyles(DocumentBuilder builder)
  5782. {
  5783. builder.Font.Name = "微软雅黑";
  5784. builder.Font.Size = 10;
  5785. builder.ParagraphFormat.SpaceAfter = 0;
  5786. }
  5787. /// <summary>
  5788. /// 添加标题
  5789. /// </summary>
  5790. /// <param name="builder"></param>
  5791. /// <param name="title"></param>
  5792. public static void AddTitle(DocumentBuilder builder, string title)
  5793. {
  5794. // 主标题
  5795. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  5796. builder.Font.Size = 16;
  5797. builder.Font.Bold = true;
  5798. builder.Font.Color = System.Drawing.Color.DarkBlue;
  5799. builder.Writeln(title);
  5800. // 空行
  5801. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  5802. builder.Font.Size = 10;
  5803. builder.Font.Bold = false;
  5804. builder.Font.Color = System.Drawing.Color.Black;
  5805. builder.Writeln();
  5806. }
  5807. /// <summary>
  5808. /// 生成酒机票表格信息
  5809. /// </summary>
  5810. /// <param name="builder"></param>
  5811. /// <param name="airInfos"></param>
  5812. /// <param name="footerText"></param>
  5813. public static void AddAirInfoSections(DocumentBuilder builder, List<Grp_AirTicketReservations> airInfos, string? footerText)
  5814. {
  5815. if (airInfos == null || !airInfos.Any())
  5816. {
  5817. builder.Writeln("暂无机票航班信息。");
  5818. return;
  5819. }
  5820. int airCount = 0;
  5821. const int maxAirPerPage = 3; // 每页最多显示3个酒店,确保有足够空间
  5822. for (int i = 0; i < airInfos.Count; i++)
  5823. {
  5824. var info = airInfos[i];
  5825. // 检查是否需要分页
  5826. if (airCount > 0 && airCount > maxAirPerPage)
  5827. {
  5828. builder.InsertBreak(BreakType.PageBreak);
  5829. airCount = 0;
  5830. }
  5831. airCount++;
  5832. // 为每个酒店创建详细信息表格
  5833. CreateAirDetailTable(builder, info);
  5834. // 酒店之间添加间距,但不是最后一个
  5835. if (i < airInfos.Count() - 1)
  5836. {
  5837. AddSpacingBetweenHotels(builder);
  5838. }
  5839. // 检查是否达到每页最大酒店数量
  5840. if (airCount >= maxAirPerPage && (i < airInfos.Count - 1 || i < airInfos.Count() - 1))
  5841. {
  5842. builder.InsertBreak(BreakType.PageBreak);
  5843. airCount = 0;
  5844. }
  5845. }
  5846. if (!string.IsNullOrEmpty(footerText))
  5847. {
  5848. AddFooter(builder, footerText);
  5849. }
  5850. }
  5851. /// <summary>
  5852. /// 生成酒店表格信息
  5853. /// </summary>
  5854. /// <param name="builder"></param>
  5855. /// <param name="hotelInfos"></param>
  5856. /// <param name="footerText"></param>
  5857. public static void AddHotelInfoSections(DocumentBuilder builder, List<Grp_HotelReservations> hotelInfos, string? footerText)
  5858. {
  5859. if (hotelInfos == null || !hotelInfos.Any())
  5860. {
  5861. builder.Writeln("暂无酒店信息");
  5862. return;
  5863. }
  5864. int hotelCount = 0;
  5865. const int maxHotelsPerPage = 3; // 每页最多显示3个酒店,确保有足够空间
  5866. for (int i = 0; i < hotelInfos.Count; i++)
  5867. {
  5868. var info = hotelInfos[i];
  5869. // 检查是否需要分页
  5870. if (hotelCount > 0 && hotelCount > maxHotelsPerPage)
  5871. {
  5872. builder.InsertBreak(BreakType.PageBreak);
  5873. hotelCount = 0;
  5874. }
  5875. hotelCount++;
  5876. AddCityHeader(builder, info.City);
  5877. // 为每个酒店创建详细信息表格
  5878. CreateHotelDetailTable(builder, info);
  5879. // 酒店之间添加间距,但不是最后一个
  5880. if (i < hotelInfos.Count() - 1)
  5881. {
  5882. AddSpacingBetweenHotels(builder);
  5883. }
  5884. // 检查是否达到每页最大酒店数量
  5885. if (hotelCount >= maxHotelsPerPage && (i < hotelInfos.Count - 1 || i < hotelInfos.Count() - 1))
  5886. {
  5887. builder.InsertBreak(BreakType.PageBreak);
  5888. hotelCount = 0;
  5889. }
  5890. }
  5891. if (!string.IsNullOrEmpty(footerText))
  5892. {
  5893. AddFooter(builder, footerText);
  5894. }
  5895. }
  5896. private static void AddSpacingBetweenHotels(DocumentBuilder builder)
  5897. {
  5898. builder.Writeln();
  5899. builder.InsertBreak(BreakType.LineBreak);
  5900. }
  5901. private static void AddCityHeader(DocumentBuilder builder, string cityName)
  5902. {
  5903. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  5904. builder.Font.Size = 14;
  5905. builder.Font.Bold = true;
  5906. builder.Font.Color = System.Drawing.Color.DarkGreen;
  5907. builder.Writeln($"城市:{cityName}");
  5908. builder.Font.Size = 10;
  5909. builder.Font.Bold = false;
  5910. builder.Font.Color = System.Drawing.Color.Black;
  5911. }
  5912. private static void CreateHotelDetailTable(DocumentBuilder builder, Grp_HotelReservations hotel)
  5913. {
  5914. // 设置表格不允许跨页断行,确保整个表格在一页上
  5915. Table table = builder.StartTable();
  5916. //table.AllowBreakAcrossPages = false; // 关键设置:不允许表格跨页
  5917. // 设置表格样式
  5918. ApplyTableStyle(table);
  5919. // 添加酒店基本信息行
  5920. AddTableRow(builder, "酒店名称", hotel.HotelName ?? "-", true);
  5921. AddTableRow(builder, "联系电话", hotel.HotelTel ?? "-");
  5922. AddTableRow(builder, "酒店地址", hotel.HotelAddress ?? "-");
  5923. AddTableRow(builder, "确认号码", hotel.DetermineNo ?? "-");
  5924. AddTableRow(builder, "入住日期", hotel.CheckInDate);
  5925. AddTableRow(builder, "离店日期", hotel.CheckOutDate);
  5926. AddTableRow(builder, "房间信息", hotel.RoomExplanation ?? "-");
  5927. builder.EndTable();
  5928. }
  5929. private static void CreateAirDetailTable(DocumentBuilder builder, Grp_AirTicketReservations air)
  5930. {
  5931. // 设置表格不允许跨页断行,确保整个表格在一页上
  5932. Table table = builder.StartTable();
  5933. //table.AllowBreakAcrossPages = false; // 关键设置:不允许表格跨页
  5934. // 设置表格样式
  5935. ApplyTableStyle(table);
  5936. // 添加酒店基本信息行
  5937. AddTableRow(builder, "城市(A-B)", air.FlightsCity ?? "-", true);
  5938. AddTableRow(builder, "航班日期", air.FlightsDate + " " + air.FlightsTime ?? "-");
  5939. AddTableRow(builder, "机票票号", air.TicketNumber ?? "-");
  5940. AddTableRow(builder, "航班简述", air.FlightsCode ?? "-");
  5941. AddTableRow(builder, "航班描述", air.FlightsDescription);
  5942. builder.EndTable();
  5943. }
  5944. private static void AddTableRow(DocumentBuilder builder, string title, string value, bool isHeaderRow = false)
  5945. {
  5946. // 左边单元格 - 标题
  5947. builder.InsertCell();
  5948. //builder.CellFormat.BackColor = isHeaderRow ? System.Drawing.Color.LightBlue : System.Drawing.Color.LightGray;
  5949. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  5950. builder.CellFormat.Width = 60;
  5951. builder.Font.Bold = true;
  5952. builder.Font.Size = isHeaderRow ? 12 : 10;
  5953. builder.Font.Color = isHeaderRow ? System.Drawing.Color.DarkBlue : System.Drawing.Color.Black;
  5954. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  5955. builder.Write(title);
  5956. // 右边单元格 - 值
  5957. builder.InsertCell();
  5958. //builder.CellFormat.BackColor = System.Drawing.Color.White;
  5959. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  5960. builder.CellFormat.Width = 200;
  5961. builder.Font.Bold = isHeaderRow;
  5962. builder.Font.Size = isHeaderRow ? 12 : 10;
  5963. builder.Font.Color = System.Drawing.Color.Black;
  5964. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  5965. builder.Write(value);
  5966. builder.EndRow();
  5967. // 重置单元格格式(除了宽度)
  5968. //builder.CellFormat.BackColor = System.Drawing.Color.White;
  5969. builder.Font.Bold = false;
  5970. builder.Font.Size = 10;
  5971. builder.Font.Color = System.Drawing.Color.Black;
  5972. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  5973. }
  5974. private static void ApplyTableStyle(Table table)
  5975. {
  5976. try
  5977. {
  5978. // 设置表格边框
  5979. table.SetBorders(LineStyle.Single, 1.0, System.Drawing.Color.Gray);
  5980. // 设置表格属性
  5981. table.LeftPadding = 5;
  5982. table.RightPadding = 5;
  5983. table.TopPadding = 3;
  5984. table.BottomPadding = 3;
  5985. table.Alignment = TableAlignment.Left;
  5986. table.AllowAutoFit = false;
  5987. //table.AllowBreakAcrossPages = true;
  5988. // 设置表格宽度
  5989. table.PreferredWidth = PreferredWidth.FromPoints(400);
  5990. // 设置列宽
  5991. if (table.FirstRow != null && table.FirstRow.Cells.Count == 2)
  5992. {
  5993. table.FirstRow.Cells[0].CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
  5994. table.FirstRow.Cells[1].CellFormat.PreferredWidth = PreferredWidth.FromPercent(80);
  5995. }
  5996. }
  5997. catch (Exception ex)
  5998. {
  5999. //_logger.LogWarning(ex, "设置表格样式时发生错误");
  6000. }
  6001. }
  6002. private static void AddFooter(DocumentBuilder builder, string footerText)
  6003. {
  6004. builder.InsertBreak(BreakType.ParagraphBreak);
  6005. builder.Writeln();
  6006. builder.Writeln();
  6007. // 添加分隔线
  6008. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  6009. builder.Font.Size = 8;
  6010. builder.Font.Color = System.Drawing.Color.LightGray;
  6011. //builder.Writeln("────────────────────────────────────");
  6012. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  6013. builder.Font.Size = 9;
  6014. builder.Font.Italic = true;
  6015. builder.Font.Color = System.Drawing.Color.Gray;
  6016. builder.Writeln(footerText);
  6017. builder.Writeln($"文档生成时间:{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
  6018. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  6019. builder.Font.Size = 10;
  6020. builder.Font.Italic = false;
  6021. builder.Font.Color = System.Drawing.Color.Black;
  6022. }
  6023. #endregion
  6024. #region 动态参数字符串格式化
  6025. /// <summary>
  6026. /// 动态参数字符串格式化
  6027. /// </summary>
  6028. /// <param name="dto">字符串格式化参数DTO</param>
  6029. /// <returns>格式化结果View</returns>
  6030. public static Task<StringFormatView> StringFormatAsync(StringFormatDto dto)
  6031. {
  6032. // 参数验证
  6033. if (string.IsNullOrWhiteSpace(dto?.FormatTemplate))
  6034. {
  6035. return Task.FromResult(new StringFormatView
  6036. {
  6037. Success = false,
  6038. Message = "格式化模板不能为空!"
  6039. });
  6040. }
  6041. if (dto.Parameters == null)
  6042. {
  6043. dto.Parameters = new List<string>();
  6044. }
  6045. try
  6046. {
  6047. // 计算需要的占位符数量
  6048. var placeholderCount = CountPlaceholders(dto.FormatTemplate);
  6049. // 验证参数数量是否匹配
  6050. if (dto.Parameters.Count != placeholderCount)
  6051. {
  6052. return Task.FromResult(new StringFormatView
  6053. {
  6054. Success = false,
  6055. Message = $"参数数量不匹配!模板需要 {placeholderCount} 个参数,但提供了 {dto.Parameters.Count} 个参数。"
  6056. });
  6057. }
  6058. // 格式化字符串
  6059. string formattedResult = string.Format(dto.FormatTemplate, dto.Parameters.Cast<object>().ToArray());
  6060. var result = new StringFormatView
  6061. {
  6062. Success = true,
  6063. Message = "操作成功!",
  6064. OriginalTemplate = dto.FormatTemplate,
  6065. FormattedResult = formattedResult,
  6066. Parameters = dto.Parameters,
  6067. ParameterCount = dto.Parameters.Count
  6068. };
  6069. return Task.FromResult(result);
  6070. }
  6071. catch (FormatException ex)
  6072. {
  6073. return Task.FromResult(new StringFormatView
  6074. {
  6075. Success = false,
  6076. Message = $"格式化错误:{ex.Message}"
  6077. });
  6078. }
  6079. catch (Exception ex)
  6080. {
  6081. return Task.FromResult(new StringFormatView
  6082. {
  6083. Success = false,
  6084. Message = $"处理失败:{ex.Message}"
  6085. });
  6086. }
  6087. }
  6088. /// <summary>
  6089. /// 计算模板字符串中的占位符数量
  6090. /// </summary>
  6091. private static int CountPlaceholders(string template)
  6092. {
  6093. if (string.IsNullOrWhiteSpace(template))
  6094. return 0;
  6095. int maxIndex = -1;
  6096. int index = 0;
  6097. while (index < template.Length)
  6098. {
  6099. if (template[index] == '{')
  6100. {
  6101. int endIndex = template.IndexOf('}', index);
  6102. if (endIndex > index)
  6103. {
  6104. string placeholder = template.Substring(index + 1, endIndex - index - 1);
  6105. if (int.TryParse(placeholder, out int placeholderIndex))
  6106. {
  6107. maxIndex = Math.Max(maxIndex, placeholderIndex);
  6108. }
  6109. index = endIndex + 1;
  6110. }
  6111. else
  6112. {
  6113. index++;
  6114. }
  6115. }
  6116. else
  6117. {
  6118. index++;
  6119. }
  6120. }
  6121. return maxIndex + 1; // 返回最大索引+1(因为索引从0开始)
  6122. }
  6123. #endregion
  6124. }
  6125. }