GeneralMethod.cs 276 KB

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