GeneralMethod.cs 258 KB

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