GeneralMethod.cs 248 KB

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