GeneralMethod.cs 257 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367
  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. if (blackCode == null)
  1917. {
  1918. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null, false);
  1919. }
  1920. else
  1921. {
  1922. var listcode = new List<Air_TicketBlackCode> { blackCode };
  1923. //读取单段黑屏代码
  1924. for (int i = 0; i < listcode.Count; i++)
  1925. {
  1926. //去除序号
  1927. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  1928. //去除多余空格,方法一Linq扩展方法
  1929. CodeList = CodeList.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  1930. //读取单条黑屏代码
  1931. for (int j = 0; j < CodeList.Count(); j++)
  1932. {
  1933. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  1934. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  1935. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1936. //去除多余空格
  1937. Info = Info.Where(str => !string.IsNullOrWhiteSpace(str)).ToArray();
  1938. //判断黑屏代码是否正确拆分; 理应拆成9段
  1939. if (Info.TakeWhile((x) =>
  1940. {
  1941. return !excludeArr.Contains(x);
  1942. }).Count() != 9)
  1943. {
  1944. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null, false);
  1945. //MessageBoxEx.Show("第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误, 请联系机票同事核对");
  1946. return dt;
  1947. }
  1948. else
  1949. {
  1950. try
  1951. {
  1952. var monthEn = Info[1].Substring(4, 3);
  1953. //月
  1954. int month = Convert.ToInt32(GetLonger(monthEn));
  1955. //日
  1956. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  1957. var time = new DateTime(DateTime.Now.Year, month, day); //
  1958. var isExist = Info.Contains("[中转]");
  1959. dt.Rows.Add(Info[0],
  1960. Info[1],
  1961. Info[2],
  1962. Info[3],
  1963. Info[4],
  1964. Info[5],
  1965. Info[6],
  1966. Info[7],
  1967. Info[8],
  1968. time.ToString("yyyy-MM-dd"),
  1969. time.ToString("yyyy-MM-dd"),
  1970. "",
  1971. "0",
  1972. isExist
  1973. );
  1974. }
  1975. catch (Exception ex)
  1976. {
  1977. string exstr = ex.Message.ToString();
  1978. }
  1979. }
  1980. }
  1981. //排序
  1982. dt.DefaultView.Sort = "Day asc";
  1983. dt = dt.DefaultView.ToTable();
  1984. }
  1985. }
  1986. return dt;
  1987. }
  1988. /// <summary>
  1989. /// 根据星期,月份的缩写,转换成数字或者全称
  1990. /// 根据币种中文名称返回币种代码
  1991. /// 根据数字返回机型型号【2、3开头的就是空客,比如空客320,7开头的就是波音,比如波音777】
  1992. /// 20210903贾文滔
  1993. /// </summary>
  1994. /// <param name="temp"></param>
  1995. /// <returns></returns>
  1996. public static string GetLonger(string temp)
  1997. {
  1998. string str = "";
  1999. switch (temp.ToUpper())
  2000. {
  2001. case "美元":
  2002. str = "USD";
  2003. break;
  2004. case "日元":
  2005. str = "JPY";
  2006. break;
  2007. case "英镑":
  2008. str = "GBP";
  2009. break;
  2010. case "欧元":
  2011. str = "EUR";
  2012. break;
  2013. case "港币":
  2014. str = "HKD";
  2015. break;
  2016. case "MO":
  2017. str = "星期一";
  2018. break;
  2019. case "TU":
  2020. str = "星期二";
  2021. break;
  2022. case "WE":
  2023. str = "星期三";
  2024. break;
  2025. case "TH":
  2026. str = "星期四";
  2027. break;
  2028. case "FR":
  2029. str = "星期五";
  2030. break;
  2031. case "SA":
  2032. str = "星期六";
  2033. break;
  2034. case "SU":
  2035. str = "星期天";
  2036. break;
  2037. case "JAN":
  2038. str = "01";
  2039. break;
  2040. case "FEB":
  2041. str = "02";
  2042. break;
  2043. case "MAR":
  2044. str = "03";
  2045. break;
  2046. case "APR":
  2047. str = "04";
  2048. break;
  2049. case "MAY":
  2050. str = "05";
  2051. break;
  2052. case "JUN":
  2053. str = "06";
  2054. break;
  2055. case "JUL":
  2056. str = "07";
  2057. break;
  2058. case "AUG":
  2059. str = "08";
  2060. break;
  2061. case "SEP":
  2062. str = "09";
  2063. break;
  2064. case "OCT":
  2065. str = "10";
  2066. break;
  2067. case "NOV":
  2068. str = "11";
  2069. break;
  2070. case "DEC":
  2071. str = "12";
  2072. break;
  2073. case "MONDAY":
  2074. str = "星期一";
  2075. break;
  2076. case "TUESDAY":
  2077. str = "星期二";
  2078. break;
  2079. case "WEDNESDAY":
  2080. str = "星期三";
  2081. break;
  2082. case "THURSDAY":
  2083. str = "星期四";
  2084. break;
  2085. case "FRIDAY":
  2086. str = "星期五";
  2087. break;
  2088. case "SATURDAY":
  2089. str = "星期六";
  2090. break;
  2091. case "SUNDAY":
  2092. str = "星期日";
  2093. break;
  2094. case "01":
  2095. str = "JAN";
  2096. break;
  2097. case "02":
  2098. str = "FEB";
  2099. break;
  2100. case "03":
  2101. str = "MAR";
  2102. break;
  2103. case "04":
  2104. str = "APR";
  2105. break;
  2106. case "05":
  2107. str = "MAY";
  2108. break;
  2109. case "06":
  2110. str = "JUN";
  2111. break;
  2112. case "07":
  2113. str = "JUL";
  2114. break;
  2115. case "08":
  2116. str = "AUG";
  2117. break;
  2118. case "09":
  2119. str = "SEP";
  2120. break;
  2121. case "10":
  2122. str = "OCT";
  2123. break;
  2124. case "11":
  2125. str = "NOV";
  2126. break;
  2127. case "12":
  2128. str = "DEC";
  2129. break;
  2130. case "2":
  2131. str = "空客A";
  2132. break;
  2133. case "3":
  2134. str = "空客A";
  2135. break;
  2136. case "7":
  2137. str = "波音";
  2138. break;
  2139. }
  2140. return str;
  2141. }
  2142. /// <summary>
  2143. /// 根据月份返回天数
  2144. /// </summary>
  2145. /// <param name="Month"></param>
  2146. /// <param name="year"></param>
  2147. /// <returns></returns>
  2148. public static string GetDaysByMonth(string Month, int year)
  2149. {
  2150. string str = "";
  2151. //判断是否是闰年
  2152. if (DateTime.IsLeapYear(year) == false)
  2153. {
  2154. switch (Month.ToUpper())
  2155. {
  2156. case "JAN":
  2157. str = "31";
  2158. break;
  2159. case "FEB":
  2160. str = "28";
  2161. break;
  2162. case "MAR":
  2163. str = "31";
  2164. break;
  2165. case "APR":
  2166. str = "30";
  2167. break;
  2168. case "MAY":
  2169. str = "31";
  2170. break;
  2171. case "JUN":
  2172. str = "30";
  2173. break;
  2174. case "JUL":
  2175. str = "31";
  2176. break;
  2177. case "AUG":
  2178. str = "31";
  2179. break;
  2180. case "SEP":
  2181. str = "30";
  2182. break;
  2183. case "OCT":
  2184. str = "31";
  2185. break;
  2186. case "NOV":
  2187. str = "30";
  2188. break;
  2189. case "DEC":
  2190. str = "31";
  2191. break;
  2192. case "01":
  2193. str = "31";
  2194. break;
  2195. case "02":
  2196. str = "28";
  2197. break;
  2198. case "03":
  2199. str = "31";
  2200. break;
  2201. case "04":
  2202. str = "30";
  2203. break;
  2204. case "05":
  2205. str = "31";
  2206. break;
  2207. case "06":
  2208. str = "30";
  2209. break;
  2210. case "07":
  2211. str = "31";
  2212. break;
  2213. case "08":
  2214. str = "31";
  2215. break;
  2216. case "09":
  2217. str = "30";
  2218. break;
  2219. case "10":
  2220. str = "31";
  2221. break;
  2222. case "11":
  2223. str = "30";
  2224. break;
  2225. case "12":
  2226. str = "31";
  2227. break;
  2228. }
  2229. }
  2230. else
  2231. {
  2232. switch (Month.ToUpper())
  2233. {
  2234. case "JAN":
  2235. str = "31";
  2236. break;
  2237. case "FEB":
  2238. str = "29";
  2239. break;
  2240. case "MAR":
  2241. str = "31";
  2242. break;
  2243. case "APR":
  2244. str = "30";
  2245. break;
  2246. case "MAY":
  2247. str = "31";
  2248. break;
  2249. case "JUN":
  2250. str = "30";
  2251. break;
  2252. case "JUL":
  2253. str = "31";
  2254. break;
  2255. case "AUG":
  2256. str = "31";
  2257. break;
  2258. case "SEP":
  2259. str = "30";
  2260. break;
  2261. case "OCT":
  2262. str = "31";
  2263. break;
  2264. case "NOV":
  2265. str = "30";
  2266. break;
  2267. case "DEC":
  2268. str = "31";
  2269. break;
  2270. case "01":
  2271. str = "31";
  2272. break;
  2273. case "02":
  2274. str = "29";
  2275. break;
  2276. case "03":
  2277. str = "31";
  2278. break;
  2279. case "04":
  2280. str = "30";
  2281. break;
  2282. case "05":
  2283. str = "31";
  2284. break;
  2285. case "06":
  2286. str = "30";
  2287. break;
  2288. case "07":
  2289. str = "31";
  2290. break;
  2291. case "08":
  2292. str = "31";
  2293. break;
  2294. case "09":
  2295. str = "30";
  2296. break;
  2297. case "10":
  2298. str = "31";
  2299. break;
  2300. case "11":
  2301. str = "30";
  2302. break;
  2303. case "12":
  2304. str = "31";
  2305. break;
  2306. }
  2307. }
  2308. return str;
  2309. }
  2310. /// <summary>
  2311. /// op行程单 团组 城市路径
  2312. /// </summary>
  2313. /// <param name="diid">团组Id</param>
  2314. /// <param name="separator">分隔符</param>
  2315. /// <returns></returns>
  2316. public static string GetGroupCityLine(int diid, string separator)
  2317. {
  2318. string city = string.Empty;
  2319. var blackCode = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  2320. if (blackCode.Count > 0)
  2321. {
  2322. var black = blackCode.First();
  2323. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  2324. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  2325. if (blackSp.Length > 0)
  2326. {
  2327. try
  2328. {
  2329. var cityArrCode = new List<string>(20);
  2330. foreach (var item in blackSp)
  2331. {
  2332. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  2333. var IndexSelect = itemSp[2];
  2334. var cityArrCodeLength = cityArrCode.Count - 1;
  2335. var startCity = IndexSelect.Substring(0, 3);
  2336. if (cityArrCodeLength > 0)
  2337. {
  2338. var arrEndCity = cityArrCode[cityArrCodeLength];
  2339. if (arrEndCity != startCity)
  2340. {
  2341. cityArrCode.Add(startCity.ToUpper());
  2342. }
  2343. }
  2344. else
  2345. {
  2346. cityArrCode.Add(startCity.ToUpper());
  2347. }
  2348. var endCity = IndexSelect.Substring(3, 3);
  2349. cityArrCode.Add(endCity.ToUpper());
  2350. }
  2351. var cityThree = string.Empty;
  2352. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  2353. cityThree = cityThree.TrimEnd(',');
  2354. if (string.IsNullOrWhiteSpace(cityThree))
  2355. {
  2356. throw new Exception("error");
  2357. }
  2358. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  2359. var cityArr = _dirRep._sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  2360. foreach (var item in cityArrCode)
  2361. {
  2362. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  2363. if (find != null)
  2364. {
  2365. city += find.City + separator;
  2366. }
  2367. else
  2368. {
  2369. city += item + "[三字码未收录]" + separator;
  2370. }
  2371. }
  2372. city = city.TrimEnd(char.Parse(separator));
  2373. }
  2374. catch (Exception e)
  2375. {
  2376. city = "[黑屏代码格式不正确!]";
  2377. }
  2378. }
  2379. }
  2380. else city = "[未录入黑屏代码]";
  2381. return city;
  2382. }
  2383. /// <summary>
  2384. /// op行程单 团组 城市路径
  2385. /// </summary>
  2386. /// <param name="diids">团组Id</param>
  2387. /// <param name="separator">分隔符</param>
  2388. /// <returns></returns>
  2389. public static Dictionary<int, string> GetGroupCityLineItem(List<int> diids, string separator)
  2390. {
  2391. Dictionary<int, string> dicCitys = new Dictionary<int, string>();
  2392. var cityCodes = _dirRep._sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  2393. var blackCodes = _dirRep._sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && diids.Contains(x.DiId)).ToList();
  2394. foreach (var diid in diids)
  2395. {
  2396. string city = string.Empty;
  2397. var blackCode = blackCodes.Where(it => it.DiId == diid).ToList();
  2398. if (blackCode.Count > 0)
  2399. {
  2400. var black = blackCode.First();
  2401. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  2402. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  2403. if (blackSp.Length > 0)
  2404. {
  2405. try
  2406. {
  2407. var cityArrCode = new List<string>(20);
  2408. foreach (var item in blackSp)
  2409. {
  2410. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  2411. var IndexSelect = itemSp[2];
  2412. var cityArrCodeLength = cityArrCode.Count - 1;
  2413. var startCity = IndexSelect.Substring(0, 3);
  2414. if (cityArrCodeLength > 0)
  2415. {
  2416. var arrEndCity = cityArrCode[cityArrCodeLength];
  2417. if (arrEndCity != startCity)
  2418. {
  2419. cityArrCode.Add(startCity.ToUpper());
  2420. }
  2421. }
  2422. else
  2423. {
  2424. cityArrCode.Add(startCity.ToUpper());
  2425. }
  2426. var endCity = IndexSelect.Substring(3, 3);
  2427. cityArrCode.Add(endCity.ToUpper());
  2428. }
  2429. var cityThree = string.Empty;
  2430. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  2431. cityThree = cityThree.TrimEnd(',');
  2432. if (string.IsNullOrWhiteSpace(cityThree))
  2433. {
  2434. throw new Exception("error");
  2435. }
  2436. var cityArr = cityCodes.Where(it => cityThree.Contains(it.Three.ToUpper())).ToList();
  2437. foreach (var item in cityArrCode)
  2438. {
  2439. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  2440. if (find != null)
  2441. {
  2442. city += find.City + separator;
  2443. }
  2444. else
  2445. {
  2446. city += item + "[三字码未收录]" + separator;
  2447. }
  2448. }
  2449. city = city.TrimEnd(char.Parse(separator));
  2450. }
  2451. catch (Exception e)
  2452. {
  2453. city = "[黑屏代码格式不正确!]";
  2454. }
  2455. }
  2456. }
  2457. else city = "[未录入黑屏代码]";
  2458. dicCitys.Add(diid, city);
  2459. }
  2460. return dicCitys;
  2461. }
  2462. /// <summary>
  2463. /// op行程单相关团组信息 含途径城市
  2464. /// </summary>
  2465. /// <returns></returns>
  2466. public static async Task<List<MateOpGroupPageListView>> MateOpGroupPageListRedis()
  2467. {
  2468. List<MateOpGroupPageListView> _views = new List<MateOpGroupPageListView>();
  2469. string viewStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("MateOpGroupPageList");//string 取
  2470. if (!string.IsNullOrEmpty(viewStr))
  2471. {
  2472. _views = JsonConvert.DeserializeObject<List<MateOpGroupPageListView>>(viewStr);
  2473. }
  2474. else
  2475. {
  2476. string sql = string.Format($@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2477. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  2478. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  2479. JietuanOperator,IsSure,CreateTime,VisitCountry
  2480. From (
  2481. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  2482. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  2483. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  2484. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  2485. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.VisitCountry
  2486. From Grp_DelegationInfo gdi
  2487. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2488. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2489. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2490. Where gdi.IsDel = 0
  2491. ) temp");
  2492. _views = _dirRep._sqlSugar.SqlQueryable<MateOpGroupPageListView>(sql).ToList();
  2493. #region 处理所属部门
  2494. /*
  2495. * 1.sq 和 gyy 等显示 市场部
  2496. * 2.王鸽和主管及张总还有管理员号统一国交部
  2497. * 2-1. 4 管理员 ,21 张海麟
  2498. */
  2499. List<int> userIds = _views.Select(it => it.JietuanOperatorId).ToList();
  2500. List<int> userIds1 = new List<int>() { 4, 21 };
  2501. var UserDepDatas = _dirRep._sqlSugar.Queryable<Sys_Users>()
  2502. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  2503. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  2504. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  2505. .ToList();
  2506. #endregion
  2507. _views.ForEach(it =>
  2508. {
  2509. it.RouteCity = GetGroupCityLine(it.Id, @"/");
  2510. it.Department = UserDepDatas.Find(it1 => it.JietuanOperatorId == it1.UserId)?.DepName ?? "Unknown";
  2511. });
  2512. TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay;
  2513. await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("MateOpGroupPageList", JsonConvert.SerializeObject(_views), ts);//string 存
  2514. }
  2515. return _views;
  2516. }
  2517. /// <summary>
  2518. /// 获取黑屏代码日期列表
  2519. /// </summary>
  2520. /// <param name="dt"></param>
  2521. /// <returns></returns>
  2522. public static List<string> GetTimeListByDataTable(DataTable dt)
  2523. {
  2524. DateTime datestart = Convert.ToDateTime(dt.Rows[0]["Day"].ToString());
  2525. DateTime dateend = Convert.ToDateTime(dt.Rows[dt.Rows.Count - 1]["ArrivedDate"].ToString());
  2526. List<string> timeList = new List<string>();
  2527. while (datestart <= dateend)
  2528. {
  2529. timeList.Add(datestart.ToString("yyyy-MM-dd"));
  2530. datestart = datestart.AddDays(1);
  2531. }
  2532. return timeList;
  2533. }
  2534. const decimal conversion = 1.61M;
  2535. /// <summary>
  2536. /// 简要行程
  2537. /// </summary>
  2538. /// <param name="diid"></param>
  2539. /// <returns></returns>
  2540. public static Result GetBriefStroke(int diid)
  2541. {
  2542. DataTable resultTable = GetTableByBlackCode(diid);
  2543. if (resultTable == null)
  2544. {
  2545. return new Result { Code = -1, Msg = "黑屏代码有误或黑屏代码未录入" };
  2546. }
  2547. if (resultTable.Rows.Count == 0 || string.IsNullOrWhiteSpace(resultTable.Rows[0][1].ToString()))
  2548. {
  2549. string msg = string.Empty;
  2550. if (resultTable.Rows.Count > 0)
  2551. {
  2552. msg = resultTable.Rows[0]["Error"].ToString();
  2553. }
  2554. return new Result { Code = -1, Msg = $"黑屏代码有误;{msg}" };
  2555. }
  2556. var timeArr = GetTimeListByDataTable(resultTable);
  2557. var threeCodes = _dirRep._sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList(); //三字码
  2558. var airCompanys = _dirRep._sqlSugar.Queryable<Res_AirCompany>().Where(it => it.IsDel == 0).ToList(); //航司公司
  2559. var obDatas = _dirRep._sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == diid).ToList(); //公务信息
  2560. var NewListTravel = new List<Grp_TravelList>();
  2561. var index = 0;
  2562. var stopCity = string.Empty;
  2563. foreach (var item in timeArr)
  2564. {
  2565. string trip = string.Empty;
  2566. string weekDay = string.Empty;
  2567. DateTime time = DateTime.Now;
  2568. if (DateTime.TryParse(item, out time))
  2569. {
  2570. weekDay = weekdays[(int)time.DayOfWeek];
  2571. }
  2572. else
  2573. {
  2574. weekDay = "日期格式不正确!";
  2575. }
  2576. var empty = "【未收入该三字码!请机票同事录入】";
  2577. var tabSelect = resultTable.Select(string.Format("Day = '{0}'", item));
  2578. var isMoreTraffic = false;
  2579. if (tabSelect.Length > 0)
  2580. {
  2581. isMoreTraffic = true;
  2582. var takeOffTime = DateTime.Parse(item);
  2583. var fallToTime = DateTime.Parse(item);
  2584. Res_ThreeCode start_Object = null;
  2585. Res_ThreeCode end_Object = null;
  2586. //bool isTrade = false;
  2587. //air 处理
  2588. foreach (var tabRow in tabSelect)
  2589. {
  2590. takeOffTime = DateTime.Parse(item);
  2591. fallToTime = DateTime.Parse(item);
  2592. var takeOff = tabRow["StartTime"].ToString();
  2593. var fallTo = tabRow["EndTime"].ToString();
  2594. takeOffTime = takeOffTime.AddHours(int.Parse(takeOff.Substring(0, 2)));
  2595. takeOffTime = takeOffTime.AddMinutes(int.Parse(takeOff.Substring(2, 2)));
  2596. fallToTime = fallToTime.AddHours(int.Parse(fallTo.Substring(0, 2)));
  2597. fallToTime = fallToTime.AddMinutes(int.Parse(fallTo.Substring(2, 2)));
  2598. var threeCode = tabRow["Three"].ToString();
  2599. var start = threeCode.Substring(0, 3);
  2600. var end = threeCode.Substring(3, 3);
  2601. stopCity = end;
  2602. start_Object = threeCodes.Find(x => x.Three.ToUpper() == start.ToUpper());
  2603. end_Object = threeCodes.Find(x => x.Three.ToUpper() == end.ToUpper());
  2604. if (start_Object == null)
  2605. {
  2606. start_Object = new Res_ThreeCode()
  2607. {
  2608. AirPort = empty,
  2609. AirPort_En = empty,
  2610. City = empty,
  2611. Country = empty,
  2612. Four = empty,
  2613. Three = empty,
  2614. };
  2615. }
  2616. if (end_Object == null)
  2617. {
  2618. end_Object = new Res_ThreeCode()
  2619. {
  2620. AirPort = empty,
  2621. AirPort_En = empty,
  2622. City = empty,
  2623. Country = empty,
  2624. Four = empty,
  2625. Three = empty,
  2626. };
  2627. }
  2628. //航班号
  2629. string flightcode = tabRow["Fliagtcode"].ToString();
  2630. trip += $"{takeOffTime.ToString("HH:mm")}—{fallToTime.ToString("HH:mm")} {start_Object.City}—{end_Object.City} 航班号:{flightcode}\r\n";
  2631. }
  2632. //var airArrive = fallToTime; //航班落地时间
  2633. time = fallToTime.AddHours(1.5); //出机场一个半小时
  2634. string Time = string.Empty;
  2635. string Distance = string.Empty;
  2636. int GetGoogleResult = 0;
  2637. int GetDistResult = 0;
  2638. JObject Result = null;
  2639. try
  2640. {
  2641. Time = Result["routes"][0]["legs"][0]["duration"]["text"].ToString().Replace(" ", "").Trim();
  2642. Distance = Result["routes"][0]["legs"][0]["distance"]["text"].ToString().Replace(" ", "").Trim();
  2643. if (Time.Contains("hours"))
  2644. {
  2645. Time = Time.Replace("hours", "小时");
  2646. }
  2647. if (Time.Contains("hour"))
  2648. {
  2649. Time = Time.Replace("hour", "小时");
  2650. }
  2651. Time = Time.Replace("mins", "分钟");
  2652. if (Distance.Contains("mi"))
  2653. {
  2654. var distSp = Regex.Split(Distance, "mi");
  2655. if (distSp.Length > 0)
  2656. {
  2657. Distance = (decimal.Parse(distSp[0]) * conversion).ToString("#0.00") + " 公里";
  2658. }
  2659. }
  2660. if (Distance.Contains("km"))
  2661. {
  2662. Distance = Distance.Replace("km", "公里");
  2663. }
  2664. if (Time.Contains("小时"))
  2665. {
  2666. var xs = Regex.Split(Time, "小时");
  2667. var xsValue = int.Parse(xs[0]);
  2668. var fz = Regex.Split(xs[1], "分钟");
  2669. var fzValue = int.Parse(fz[0]);
  2670. GetGoogleResult = xsValue * 60;
  2671. GetGoogleResult += fzValue;
  2672. }
  2673. else if (Time.Contains("分钟"))
  2674. {
  2675. GetGoogleResult = int.Parse(Regex.Split(Time, "分钟")[0]);
  2676. }
  2677. if (Distance.Contains("公里"))
  2678. {
  2679. GetDistResult = (int)decimal.Parse(Regex.Split(Distance, "公里")[0]);
  2680. }
  2681. if (GetGoogleResult > 0 && GetGoogleResult % 5 != 0)
  2682. {
  2683. while (GetGoogleResult % 5 != 0)
  2684. {
  2685. GetGoogleResult++;
  2686. }
  2687. }
  2688. if (GetDistResult % 5 != 0 && GetDistResult > 0)
  2689. {
  2690. while (GetDistResult % 5 != 0)
  2691. {
  2692. GetDistResult++;
  2693. }
  2694. }
  2695. int H = (GetGoogleResult / 60);
  2696. int m = (GetGoogleResult % 60);
  2697. string TimeStr = string.Empty;
  2698. if (H != 0)
  2699. {
  2700. if (H < 10)
  2701. {
  2702. TimeStr += "0" + H + "小时";
  2703. }
  2704. else
  2705. {
  2706. TimeStr += H + "小时";
  2707. }
  2708. }
  2709. if (m < 10)
  2710. {
  2711. TimeStr += "0" + m + "分钟";
  2712. }
  2713. else
  2714. {
  2715. TimeStr += m + "分钟";
  2716. }
  2717. Time = TimeStr;
  2718. Distance = GetDistResult.ToString() + "公里";
  2719. }
  2720. catch (Exception ex)
  2721. {
  2722. Time = "未知!";
  2723. Distance = "未知!";
  2724. }
  2725. //trip += $"{time.ToString("HH:mm")} 搭乘专车前往市区({end_Object.AirPort} - {end_Object.City}市区 路程{Distance},耗时{Time})";
  2726. //trip += $"{time.ToString("HH:mm")} 搭乘专车前往市区({end_Object.AirPort} - {end_Object.City}市区)";
  2727. time = time.AddMinutes(GetGoogleResult); //到达市区时间
  2728. string tripDate = Convert.ToDateTime(item).ToString("M月d日");
  2729. if (index == timeArr.Count - 1)
  2730. {
  2731. NewListTravel.Add(new Grp_TravelList
  2732. {
  2733. CreateTime = DateTime.Now,
  2734. CreateUserId = 0,
  2735. Diid = diid,
  2736. Date = tripDate,
  2737. Trip = trip,
  2738. WeekDay = weekDay,
  2739. Days = index + 1,
  2740. Traffic_First = "飞机",
  2741. Traffic_Second = "汽车",
  2742. Diffgroup = 1,
  2743. Issel = 1,
  2744. IsDel = 0,
  2745. });
  2746. continue;
  2747. }
  2748. if (time.Day != fallToTime.Day) //超出一天
  2749. {
  2750. NewListTravel.Add(new Grp_TravelList
  2751. {
  2752. CreateTime = DateTime.Now,
  2753. CreateUserId = 0,
  2754. Diid = diid,
  2755. Date = tripDate,
  2756. Trip = trip,
  2757. WeekDay = weekDay,
  2758. Days = index + 1,
  2759. Traffic_First = "飞机",
  2760. Traffic_Second = "汽车",
  2761. Diffgroup = 1,
  2762. Issel = 1,
  2763. IsDel = 0,
  2764. });
  2765. continue;
  2766. }
  2767. var obInfo = obDatas.Find(it => Convert.ToDateTime(it.Date).ToString("M月d日").Equals(tripDate));
  2768. string obtime = "";
  2769. string obcontent = "";
  2770. if (obInfo != null)
  2771. {
  2772. obtime = obInfo.Time;
  2773. obcontent = $"拜访{obInfo.Client ?? "公务出访单位未录入"}{obInfo.Job ?? "公务出访联系人职务未录入"}{obInfo.Contact ?? "公务出访联系人职务未录入"}";
  2774. }
  2775. bool obTime_bool = DateTime.TryParse(obtime, out DateTime obTimeDt);
  2776. if (time.Hour < 9) // && (airArrive < new DateTime(airArrive.Year,airArrive.Month,airArrive.Day,6, 30, 0))
  2777. {
  2778. if (obTime_bool)
  2779. {
  2780. if (obTimeDt.Hour < 9)
  2781. {
  2782. trip += $"{obTimeDt.ToString("HH:mm")}—10:30 {obcontent};\r\n";
  2783. }
  2784. }
  2785. else
  2786. {
  2787. trip += "09:00—10:30 公务活动;\r\n";
  2788. }
  2789. }
  2790. else if (time.Hour < 10)
  2791. {
  2792. if (obTime_bool)
  2793. {
  2794. if (obTimeDt.Hour < 10)
  2795. {
  2796. trip += $"{obTimeDt.ToString("HH:mm")}—12:00 {obcontent};\r\n";
  2797. }
  2798. }
  2799. else
  2800. {
  2801. trip += "10:30—12:00 公务活动;\r\n";
  2802. }
  2803. }
  2804. if (time.Hour < 13)
  2805. {
  2806. //trip += $"\r\n{time.ToString("HH:mm")} 午餐于当地餐厅;";
  2807. }
  2808. if (time < new DateTime(time.Year, time.Month, time.Day, 14, 30, 0))
  2809. {
  2810. if (obTime_bool)
  2811. {
  2812. if (obTimeDt < new DateTime(time.Year, time.Month, time.Day, 14, 30, 0))
  2813. {
  2814. trip += $"{obTimeDt.ToString("HH:mm")}—16:00 {obcontent};\r\n";
  2815. }
  2816. }
  2817. else
  2818. {
  2819. trip += "14:00—16:00 公务活动;\r\n";
  2820. }
  2821. }
  2822. else if (time.Hour < 16)
  2823. {
  2824. if (obTime_bool)
  2825. {
  2826. if (obTimeDt.Hour < 16)
  2827. {
  2828. trip += $"{obTimeDt.ToString("HH:mm")}—17:30 {obcontent};\r\n";
  2829. }
  2830. }
  2831. else
  2832. {
  2833. trip += "16:00—17:30 公务活动;\r\n";
  2834. }
  2835. }
  2836. //if (time.Hour < 18)
  2837. //{
  2838. // trip += $"\r\n18:00 晚餐于当地餐厅;";
  2839. //}
  2840. //time = time.AddHours(1);
  2841. //trip += $"\r\n{time.ToString("HH:mm")} 搭乘专车前往酒店,抵达后办理入住;";
  2842. }
  2843. else
  2844. {
  2845. var end_Object = threeCodes.Find(x => x.Three.ToUpper() == stopCity.ToUpper());
  2846. if (end_Object == null)
  2847. {
  2848. end_Object = new Res_ThreeCode()
  2849. {
  2850. AirPort = empty,
  2851. AirPort_En = empty,
  2852. City = empty,
  2853. Country = empty,
  2854. Four = empty,
  2855. Three = empty,
  2856. };
  2857. }
  2858. //trip += $"{end_Object.City}\r\n";
  2859. // trip += @"08:00 早餐于酒店;
  2860. //09:00—10:30 公务活动;
  2861. //12:00 午餐于当地餐厅;
  2862. //14:00—16:00 公务活动;
  2863. //18:00 晚餐于当地餐厅;
  2864. //19:00 入住酒店休息;";
  2865. trip += "09:00—10:30 公务活动;\r\n14:00—16:00 公务活动;\r\n";
  2866. }
  2867. string[] traffic = new string[] { "飞机", "汽车" };
  2868. if (!isMoreTraffic)
  2869. {
  2870. traffic = new string[] { "汽车", "" };
  2871. }
  2872. NewListTravel.Add(new Grp_TravelList
  2873. {
  2874. CreateTime = DateTime.Now,
  2875. CreateUserId = 0,
  2876. Diid = diid,
  2877. Date = Convert.ToDateTime(item).ToString("M月d日"),
  2878. Trip = trip,
  2879. WeekDay = weekDay,
  2880. Days = index + 1,
  2881. Traffic_First = traffic[0],
  2882. Traffic_Second = traffic[1],
  2883. Diffgroup = 1,
  2884. Issel = 1,
  2885. IsDel = 0,
  2886. });
  2887. index++;
  2888. }
  2889. return new Result() { Code = 0, Msg = "获取成功!", Data = NewListTravel };
  2890. }
  2891. /// <summary>
  2892. /// 根据日期获取星期
  2893. /// </summary>
  2894. /// <param name="dtStr"></param>
  2895. /// <returns></returns>
  2896. public static string GetWeek(this string dtStr)
  2897. {
  2898. string week = "";
  2899. bool isDt = DateTime.TryParse(dtStr, out DateTime dt);
  2900. if (isDt)
  2901. {
  2902. week = weekdays[(int)dt.DayOfWeek];
  2903. }
  2904. return week;
  2905. }
  2906. #endregion
  2907. #region 计算国家城市当时时间
  2908. /// <summary>
  2909. /// 中文城市名称映射
  2910. /// </summary>
  2911. private static readonly Dictionary<string, string> _timeZoneCityMappings = new Dictionary<string, string>
  2912. {
  2913. {"Africa/Abidjan","非洲/阿比让"} ,
  2914. {"Africa/Accra","非洲/阿克拉"} ,
  2915. {"Africa/Addis_Ababa","非洲/亚的斯亚贝巴"} ,
  2916. {"Africa/Algiers","非洲/阿尔及尔"} ,
  2917. {"Africa/Asmara","非洲/阿斯马拉"} ,
  2918. {"Africa/Asmera","非洲/阿斯梅拉"} ,
  2919. {"Africa/Bamako","非洲/巴马科"} ,
  2920. {"Africa/Bangui","非洲/班吉"} ,
  2921. {"Africa/Banjul","非洲/班珠尔"} ,
  2922. {"Africa/Bissau","非洲/比绍"} ,
  2923. {"Africa/Blantyre","非洲/布兰太尔"} ,
  2924. {"Africa/Brazzaville","非洲/布拉柴维尔"} ,
  2925. {"Africa/Bujumbura","非洲/布琼布拉"} ,
  2926. {"Africa/Cairo","非洲/开罗"} ,
  2927. {"Africa/Casablanca","非洲/卡萨布兰卡"} ,
  2928. {"Africa/Ceuta","非洲/休达"} ,
  2929. {"Africa/Conakry","非洲/科纳克里"} ,
  2930. {"Africa/Dakar","非洲/达喀尔"} ,
  2931. {"Africa/Dar_es_Salaam","非洲/达累斯萨拉姆"} ,
  2932. {"Africa/Djibouti","非洲/吉布提"} ,
  2933. {"Africa/Douala","非洲/杜阿拉"} ,
  2934. {"Africa/El_Aaiun","非洲/阿尤恩"} ,
  2935. {"Africa/Freetown","非洲/弗里敦"} ,
  2936. {"Africa/Gaborone","非洲/哈博罗内"} ,
  2937. {"Africa/Harare","非洲/哈拉雷"} ,
  2938. {"Africa/Johannesburg","非洲/约翰内斯堡"} ,
  2939. {"Africa/Juba","非洲/朱巴"} ,
  2940. {"Africa/Kampala","非洲/坎帕拉"} ,
  2941. {"Africa/Khartoum","非洲/喀土穆"} ,
  2942. {"Africa/Kigali","非洲/基加利"} ,
  2943. {"Africa/Kinshasa","非洲/金沙萨"} ,
  2944. {"Africa/Lagos","非洲/拉各斯"} ,
  2945. {"Africa/Libreville","非洲/利伯维尔"} ,
  2946. {"Africa/Lome","非洲/洛美"} ,
  2947. {"Africa/Luanda","非洲/罗安达"} ,
  2948. {"Africa/Lubumbashi","非洲/卢本巴希"} ,
  2949. {"Africa/Lusaka","非洲/卢萨卡"} ,
  2950. {"Africa/Malabo","非洲/马拉博"} ,
  2951. {"Africa/Maputo","非洲/马普托"} ,
  2952. {"Africa/Maseru","非洲/马塞卢"} ,
  2953. {"Africa/Mbabane","非洲/姆巴巴内"} ,
  2954. {"Africa/Mogadishu","非洲/摩加迪沙"} ,
  2955. {"Africa/Monrovia","非洲/蒙罗维亚"} ,
  2956. {"Africa/Nairobi","非洲/内罗毕"} ,
  2957. {"Africa/Ndjamena","非洲/恩贾梅纳"} ,
  2958. {"Africa/Niamey","非洲/尼亚美"} ,
  2959. {"Africa/Nouakchott","非洲/努瓦克肖特"} ,
  2960. {"Africa/Ouagadougou","非洲/瓦加杜古"} ,
  2961. {"Africa/Porto-Novo","非洲/波多诺伏"} ,
  2962. {"Africa/Sao_Tome","非洲/圣多美"} ,
  2963. {"Africa/Timbuktu","非洲/廷巴克图"} ,
  2964. {"Africa/Tripoli","非洲/的黎波里"} ,
  2965. {"Africa/Tunis","非洲/突尼斯"} ,
  2966. {"Africa/Windhoek","非洲/温得和克"} ,
  2967. {"America/Adak","美洲/埃达克"} ,
  2968. {"America/Anchorage","美洲/安克雷奇"} ,
  2969. {"America/Anguilla","美洲/安圭拉"} ,
  2970. {"America/Antigua","美洲/安提瓜岛"} ,
  2971. {"America/Araguaina","美洲/阿拉瓜纳"} ,
  2972. {"America/Argentina/Buenos_Aires","美洲/阿根廷/布宜诺斯艾利斯"} ,
  2973. {"America/Argentina/Catamarca","美洲/阿根廷/卡塔马卡"} ,
  2974. {"America/Argentina/ComodRivadavia","美洲/阿根廷/科莫德里瓦达维亚"} ,
  2975. {"America/Argentina/Cordoba","美洲/阿根廷/科尔多瓦"} ,
  2976. {"America/Argentina/Jujuy","美洲/阿根廷/胡胡伊省"} ,
  2977. {"America/Argentina/La_Rioja","美洲/阿根廷/拉里奥哈"} ,
  2978. {"America/Argentina/Mendoza","美洲/阿根廷/门多萨"} ,
  2979. {"America/Argentina/Rio_Gallegos","美洲/阿根廷/里奥加耶戈斯"} ,
  2980. {"America/Argentina/Salta","美洲/阿根廷/萨尔塔"} ,
  2981. {"America/Argentina/San_Juan","美洲/阿根廷/San_Juan"} ,
  2982. {"America/Argentina/San_Luis","美洲/阿根廷/圣路易斯"} ,
  2983. {"America/Argentina/Tucuman","美洲/阿根廷/图库曼"} ,
  2984. {"America/Argentina/Ushuaia","美洲/阿根廷/乌斯怀亚"} ,
  2985. {"America/Aruba","美洲/阿鲁巴岛"} ,
  2986. {"America/Asuncion","美洲/亚松森"} ,
  2987. {"America/Atikokan","美洲/阿蒂科坎"} ,
  2988. {"America/Atka","美洲/阿特卡"} ,
  2989. {"America/Bahia","美洲/巴伊亚"} ,
  2990. {"America/Bahia_Banderas","美洲/巴伊亚_班德拉斯"} ,
  2991. {"America/Barbados","美洲/巴巴多斯"} ,
  2992. {"America/Belem","美洲/贝伦"} ,
  2993. {"America/Belize","美洲/伯利兹"} ,
  2994. {"America/Blanc-Sablon","America/Blanc-Sablon"} ,
  2995. {"America/Boa_Vista","美洲/博阿维斯塔"} ,
  2996. {"America/Bogota","美洲/波哥大"} ,
  2997. {"America/Boise","美洲/博伊西"} ,
  2998. {"America/Buenos_Aires","美洲/布宜诺斯艾利斯"} ,
  2999. {"America/Cambridge_Bay","美洲/剑桥湾"} ,
  3000. {"America/Campo_Grande","美洲/大坎普"} ,
  3001. {"America/Cancun","美洲/坎昆"} ,
  3002. {"America/Caracas","美洲/加拉加斯"} ,
  3003. {"America/Catamarca","美洲/卡塔马卡"} ,
  3004. {"America/Cayenne","美洲/卡宴"} ,
  3005. {"America/Cayman","美洲/开曼"} ,
  3006. {"America/Chicago","美洲/芝加哥"} ,
  3007. {"America/Chihuahua","美洲/奇瓦瓦州"} ,
  3008. {"America/Ciudad_Juarez","美洲/华雷斯城"} ,
  3009. {"America/Coral_Harbour","美洲/珊瑚港"} ,
  3010. {"America/Cordoba","美洲/科尔多瓦"} ,
  3011. {"America/Costa_Rica","美洲/哥斯达黎加"} ,
  3012. {"America/Creston","美洲/克雷斯顿"} ,
  3013. {"America/Cuiaba","美洲/库艾巴"} ,
  3014. {"America/Curacao","美洲/库拉索岛"} ,
  3015. {"America/Danmarkshavn","美洲/丹麦港"} ,
  3016. {"America/Dawson","美洲/道森"} ,
  3017. {"America/Dawson_Creek","美洲/道森克里克"} ,
  3018. {"America/Denver","美洲/丹佛"} ,
  3019. {"America/Detroit","美洲/底特律"} ,
  3020. {"America/Dominica","美洲/多米尼克"} ,
  3021. {"America/Edmonton","美洲/埃德蒙顿"} ,
  3022. {"America/Eirunepe","美洲/埃鲁内佩"} ,
  3023. {"America/El_Salvador","美洲/萨尔瓦多"} ,
  3024. {"America/Ensenada","美洲/恩塞纳达"} ,
  3025. {"America/Fort_Nelson","美洲/纳尔逊堡"} ,
  3026. {"America/Fort_Wayne","美洲/韦恩堡"} ,
  3027. {"America/Fortaleza","美洲/福塔莱萨"} ,
  3028. {"America/Glace_Bay","America/Glace_Bay"} ,
  3029. {"America/Godthab","美洲/戈德哈布"} ,
  3030. {"America/Goose_Bay","America/Goose_Bay"} ,
  3031. {"America/Grand_Turk","美洲/大特克岛"} ,
  3032. {"America/Grenada","美洲/格林纳达"} ,
  3033. {"America/Guadeloupe","美洲/瓜德罗普岛"} ,
  3034. {"America/Guatemala","美洲/危地马拉"} ,
  3035. {"America/Guayaquil","美洲/瓜亚基尔"} ,
  3036. {"America/Guyana","美洲/圭亚那"} ,
  3037. {"America/Halifax","美洲/哈利法克斯"} ,
  3038. {"America/Havana","美洲/哈瓦那"} ,
  3039. {"America/Hermosillo","美洲/埃莫西约"} ,
  3040. {"America/Indiana/Indianapolis","美洲/印第安纳州/印第安纳波利斯"} ,
  3041. {"America/Indiana/Knox","美洲/印第安纳州/诺克斯"} ,
  3042. {"America/Indiana/Marengo","美洲/印第安纳州/马伦戈"} ,
  3043. {"America/Indiana/Petersburg","美洲/印第安纳州/彼得斯堡"} ,
  3044. {"America/Indiana/Tell_City","美洲/印第安纳州/Tell_City"} ,
  3045. {"America/Indiana/Vevay","美洲/印第安纳州/沃韦"} ,
  3046. {"America/Indiana/Vincennes","美洲/印第安纳州/文森斯"} ,
  3047. {"America/Indiana/Winamac","美洲/印第安纳州/威纳马克"} ,
  3048. {"America/Indianapolis","美洲/印第安纳波利斯"} ,
  3049. {"America/Inuvik","美洲/伊努维克人"} ,
  3050. {"America/Iqaluit","美洲/伊魁特"} ,
  3051. {"America/Jamaica","美洲/牙买加"} ,
  3052. {"America/Jujuy","美洲/胡胡伊省"} ,
  3053. {"America/Juneau","美洲/朱诺"} ,
  3054. {"America/Kentucky/Louisville","美洲/肯塔基州/路易斯维尔"} ,
  3055. {"America/Kentucky/Monticello","美洲/肯塔基州/蒙蒂塞洛"} ,
  3056. {"America/Knox_IN","美洲/Knox_IN"} ,
  3057. {"America/Kralendijk","美洲/克拉伦代克"} ,
  3058. {"America/La_Paz","美洲/拉巴斯"} ,
  3059. {"America/Lima","美洲/利马"} ,
  3060. {"America/Los_Angeles","美洲/洛杉矶"} ,
  3061. {"America/Louisville","美洲/路易斯维尔"} ,
  3062. {"America/Lower_Princes","美洲/下王子郡"} ,
  3063. {"America/Maceio","美洲/马塞约"} ,
  3064. {"America/Managua","美洲/马那瓜"} ,
  3065. {"America/Manaus","美洲/马瑙斯"} ,
  3066. {"America/Marigot","美洲/马里戈特"} ,
  3067. {"America/Martinique","美洲/马提尼克岛"} ,
  3068. {"America/Matamoros","美洲/马塔莫罗斯"} ,
  3069. {"America/Mazatlan","美洲/马萨特兰"} ,
  3070. {"America/Mendoza","美洲/门多萨"} ,
  3071. {"America/Menominee","美国/梅诺米尼"} ,
  3072. {"America/Merida","美洲/梅里达"} ,
  3073. {"America/Metlakatla","美洲/梅特拉卡特拉"} ,
  3074. {"America/Mexico_City","美洲/墨西哥_城市"} ,
  3075. {"America/Miquelon","美洲/密克隆群岛"} ,
  3076. {"America/Moncton","美洲/蒙克顿"} ,
  3077. {"America/Monterrey","美洲/蒙特雷"} ,
  3078. {"America/Montevideo","美洲/蒙得维的亚"} ,
  3079. {"America/Montreal","美洲/蒙特利尔"} ,
  3080. {"America/Montserrat","美洲/蒙特塞拉特"} ,
  3081. {"America/Nassau","美洲/拿骚"} ,
  3082. {"America/New_York","美洲/纽约"} ,
  3083. {"America/Nipigon","美洲/尼皮贡"} ,
  3084. {"America/Nome","美国/名称"} ,
  3085. {"America/Noronha","美国/某地"} ,
  3086. {"America/North_Dakota/Beulah","美洲/北达科他州/比尤拉"} ,
  3087. {"America/North_Dakota/Center","美洲/北达科他州/中部"} ,
  3088. {"America/North_Dakota/New_Salem","美洲/北达科他州/新塞勒姆"} ,
  3089. {"America/Nuuk","美洲/努克"} ,
  3090. {"America/Ojinaga","美洲/奥吉纳加"} ,
  3091. {"America/Panama","美洲/巴拿马"} ,
  3092. {"America/Pangnirtung","美洲/庞纳通"} ,
  3093. {"America/Paramaribo","美洲/帕拉马里博"} ,
  3094. {"America/Phoenix","美洲/菲尼克斯"} ,
  3095. {"America/Port-au-Prince","美洲/太子港"} ,
  3096. {"America/Port_of_Spain","美洲/西班牙港"} ,
  3097. {"America/Porto_Acre","美洲/阿卡港"} ,
  3098. {"America/Porto_Velho","美洲/旧波尔图"} ,
  3099. {"America/Puerto_Rico","美洲/波多黎各"} ,
  3100. {"America/Punta_Arenas","美洲/蓬塔阿雷纳斯"} ,
  3101. {"America/Rainy_River","美洲/雷尼河"} ,
  3102. {"America/Rankin_Inlet","兰金因莱特"} ,
  3103. {"America/Recife","美洲/累西腓"} ,
  3104. {"America/Regina","美洲/里贾纳"} ,
  3105. {"America/Resolute","美国/坚决"} ,
  3106. {"America/Rio_Branco","美洲/里奥布兰科"} ,
  3107. {"America/Rosario","美洲/罗萨里奥"} ,
  3108. {"America/Santa_Isabel","美洲/圣伊莎贝尔"} ,
  3109. {"America/Santarem","美洲/圣塔伦"} ,
  3110. {"America/Santiago","美洲/圣地亚哥"} ,
  3111. {"America/Santo_Domingo","美洲/圣多明各"} ,
  3112. {"America/Sao_Paulo","美洲/圣保罗"} ,
  3113. {"America/Scoresbysund","美洲/斯科斯比松"} ,
  3114. {"America/Shiprock","美洲/希普洛克"} ,
  3115. {"America/Sitka","美洲/锡特卡"} ,
  3116. {"America/St_Barthelemy","美洲/圣巴泰勒米"} ,
  3117. {"America/St_Johns","美洲/圣约翰斯"} ,
  3118. {"America/St_Kitts","美洲/圣基茨"} ,
  3119. {"America/St_Lucia","美洲/圣卢西亚"} ,
  3120. {"America/St_Thomas","美洲/圣托马斯"} ,
  3121. {"America/St_Vincent","美洲/圣文森特"} ,
  3122. {"America/Swift_Current","America/Swift_Current"} ,
  3123. {"America/Tegucigalpa","美洲/特古西加尔巴"} ,
  3124. {"America/Thule","美洲/图勒"} ,
  3125. {"America/Thunder_Bay","美洲/雷湾"} ,
  3126. {"America/Tijuana","美洲/蒂华纳"} ,
  3127. {"America/Toronto","美洲/多伦多"} ,
  3128. {"America/Tortola","美洲/托尔托拉岛"} ,
  3129. {"America/Vancouver","美洲/温哥华"} ,
  3130. {"America/Virgin","美国/维珍"} ,
  3131. {"America/Whitehorse","美洲/怀特霍斯"} ,
  3132. {"America/Winnipeg","美洲/温尼伯"} ,
  3133. {"America/Yakutat","美洲/雅库塔特"} ,
  3134. {"America/Yellowknife","美洲/黄刀镇"} ,
  3135. {"Antarctica/Casey","南极洲/凯西"} ,
  3136. {"Antarctica/Davis","南极洲/戴维斯"} ,
  3137. {"Antarctica/DumontDUrville","南极洲/杜蒙杜维尔"} ,
  3138. {"Antarctica/Macquarie","南极洲/麦格理"} ,
  3139. {"Antarctica/Mawson","南极洲/莫森"} ,
  3140. {"Antarctica/McMurdo","南极洲/麦克默多"} ,
  3141. {"Antarctica/Palmer","南极洲/帕尔默"} ,
  3142. {"Antarctica/Rothera","南极洲/罗塞拉岛"} ,
  3143. {"Antarctica/South_Pole","南极洲/南极点"} ,
  3144. {"Antarctica/Syowa","南极洲/昭和"} ,
  3145. {"Antarctica/Troll","南极洲/巨魔"} ,
  3146. {"Antarctica/Vostok","南极洲/东方"} ,
  3147. {"Arctic/Longyearbyen","北极/朗伊尔城"} ,
  3148. {"Asia/Aden","亚洲/亚丁"} ,
  3149. {"Asia/Almaty","亚洲/阿拉木图"} ,
  3150. {"Asia/Amman","亚洲/安曼"} ,
  3151. {"Asia/Anadyr","亚洲/阿纳德尔"} ,
  3152. {"Asia/Aqtau","亚洲/阿克套"} ,
  3153. {"Asia/Aqtobe","亚洲/阿克托比"} ,
  3154. {"Asia/Ashgabat","亚洲/阿什哈巴德"} ,
  3155. {"Asia/Ashkhabad","亚洲/阿什哈巴德"} ,
  3156. {"Asia/Atyrau","亚洲/阿特劳"} ,
  3157. {"Asia/Baghdad","亚洲/巴格达"} ,
  3158. {"Asia/Bahrain","亚洲/巴林"} ,
  3159. {"Asia/Baku","亚洲/巴库"} ,
  3160. {"Asia/Bangkok","亚洲/曼谷"} ,
  3161. {"Asia/Barnaul","亚洲/巴尔瑙尔"} ,
  3162. {"Asia/Beirut","亚洲/贝鲁特"} ,
  3163. {"Asia/Bishkek","亚洲/比什凯克"} ,
  3164. {"Asia/Brunei","亚洲/文莱"} ,
  3165. {"Asia/Calcutta","亚洲/加尔各答"} ,
  3166. {"Asia/Chita","亚洲/赤塔"} ,
  3167. {"Asia/Choibalsan","亚洲/乔巴山"} ,
  3168. {"Asia/Chongqing","亚洲/重庆"} ,
  3169. {"Asia/Chungking","亚洲/重庆"} ,
  3170. {"Asia/Colombo","亚洲/科伦坡"} ,
  3171. {"Asia/Dacca","亚洲/达卡"} ,
  3172. {"Asia/Damascus","亚洲/大马士革"} ,
  3173. {"Asia/Dhaka","亚洲/达卡"} ,
  3174. {"Asia/Dili","亚洲/帝力"} ,
  3175. {"Asia/Dubai","亚洲/迪拜"} ,
  3176. {"Asia/Dushanbe","亚洲/杜尚别"} ,
  3177. {"Asia/Famagusta","亚洲/法马古斯塔"} ,
  3178. {"Asia/Gaza","亚洲/加沙"} ,
  3179. {"Asia/Harbin","亚洲/哈尔滨"} ,
  3180. {"Asia/Hebron","亚洲/希伯伦"} ,
  3181. {"Asia/Ho_Chi_Minh","亚洲/胡志明市"} ,
  3182. {"Asia/Hong_Kong","亚洲/香港"} ,
  3183. {"Asia/Hovd","亚洲/霍布德"} ,
  3184. {"Asia/Irkutsk","亚洲/伊尔库茨克"} ,
  3185. {"Asia/Istanbul","亚洲/伊斯坦布尔"} ,
  3186. {"Asia/Jakarta","亚洲/雅加达"} ,
  3187. {"Asia/Jayapura","亚洲/查亚普拉"} ,
  3188. {"Asia/Jerusalem","亚洲/耶路撒冷"} ,
  3189. {"Asia/Kabul","亚洲/喀布尔"} ,
  3190. {"Asia/Kamchatka","亚洲/堪察加半岛"} ,
  3191. {"Asia/Karachi","亚洲/卡拉奇"} ,
  3192. {"Asia/Kashgar","亚洲/喀什"} ,
  3193. {"Asia/Kathmandu","亚洲/加德满都"} ,
  3194. {"Asia/Katmandu","亚洲/加德满都"} ,
  3195. {"Asia/Khandyga","亚洲/坎迪加"} ,
  3196. {"Asia/Kolkata","亚洲/加尔各答"} ,
  3197. {"Asia/Krasnoyarsk","亚洲/克拉斯诺亚尔斯克"} ,
  3198. {"Asia/Kuala_Lumpur","亚洲/吉隆坡_吉隆坡"} ,
  3199. {"Asia/Kuching","亚洲/古晋"} ,
  3200. {"Asia/Kuwait","亚洲/科威特"} ,
  3201. {"Asia/Macao","亚洲/澳门"} ,
  3202. {"Asia/Macau","亚洲/澳门"} ,
  3203. {"Asia/Magadan","亚洲/马加丹"} ,
  3204. {"Asia/Makassar","亚洲/望加锡"} ,
  3205. {"Asia/Manila","亚洲/马尼拉"} ,
  3206. {"Asia/Muscat","亚洲/马斯喀特"} ,
  3207. {"Asia/Nicosia","亚洲/尼科西亚"} ,
  3208. {"Asia/Novokuznetsk","亚洲/新库兹涅茨克"} ,
  3209. {"Asia/Novosibirsk","亚洲/新西伯利亚"} ,
  3210. {"Asia/Omsk","亚洲/鄂木斯克"} ,
  3211. {"Asia/Oral","亚洲/口头"} ,
  3212. {"Asia/Phnom_Penh","亚洲/金边"} ,
  3213. {"Asia/Pontianak","亚洲/笨珍"} ,
  3214. {"Asia/Pyongyang","亚洲/平壤"} ,
  3215. {"Asia/Qatar","亚洲/卡塔尔"} ,
  3216. {"Asia/Qostanay","亚洲/库斯塔奈"} ,
  3217. {"Asia/Qyzylorda","亚洲/克孜勒奥尔达"} ,
  3218. {"Asia/Rangoon","亚洲/仰光"} ,
  3219. {"Asia/Riyadh","亚洲/利雅得"} ,
  3220. {"Asia/Saigon","亚洲/西贡"} ,
  3221. {"Asia/Sakhalin","亚洲/萨哈林岛"} ,
  3222. {"Asia/Samarkand","亚洲/撒马尔罕"} ,
  3223. {"Asia/Seoul","亚洲/首尔"} ,
  3224. {"Asia/Shanghai","亚洲/上海"} ,
  3225. {"Asia/Singapore","亚洲/新加坡"} ,
  3226. {"Asia/Srednekolymsk","亚洲/中科雷姆斯克"} ,
  3227. {"Asia/Taipei","亚洲/台北"} ,
  3228. {"Asia/Tashkent","亚洲/塔什干"} ,
  3229. {"Asia/Tbilisi","亚洲/第比利斯"} ,
  3230. {"Asia/Tehran","亚洲/德黑兰"} ,
  3231. {"Asia/Tel_Aviv","亚洲/特拉维夫"} ,
  3232. {"Asia/Thimbu","亚洲/廷布"} ,
  3233. {"Asia/Thimphu","亚洲/廷布"} ,
  3234. {"Asia/Tokyo","亚洲/东京"} ,
  3235. {"Asia/Tomsk","亚洲/托木斯克"} ,
  3236. {"Asia/Ujung_Pandang","亚洲/乌戎_潘当"} ,
  3237. {"Asia/Ulaanbaatar","亚洲/乌兰巴托"} ,
  3238. {"Asia/Ulan_Bator","亚洲/乌兰巴托"} ,
  3239. {"Asia/Urumqi","亚洲/乌鲁木齐"} ,
  3240. {"Asia/Ust-Nera","亚洲/乌斯季-内拉"} ,
  3241. {"Asia/Vientiane","亚洲/万象"} ,
  3242. {"Asia/Vladivostok","亚洲/符拉迪沃斯托克"} ,
  3243. {"Asia/Yakutsk","亚洲/雅库茨克"} ,
  3244. {"Asia/Yangon","亚洲/仰光"} ,
  3245. {"Asia/Yekaterinburg","亚洲/叶卡捷琳堡"} ,
  3246. {"Asia/Yerevan","亚洲/埃里温"} ,
  3247. {"Atlantic/Azores","大西洋/亚速尔群岛"} ,
  3248. {"Atlantic/Bermuda","大西洋/百慕大"} ,
  3249. {"Atlantic/Canary","大西洋/加那利"} ,
  3250. {"Atlantic/Cape_Verde","大西洋/佛得角"} ,
  3251. {"Atlantic/Faeroe","大西洋/法罗"} ,
  3252. {"Atlantic/Faroe","大西洋/法罗"} ,
  3253. {"Atlantic/Jan_Mayen","大西洋/扬马延"} ,
  3254. {"Atlantic/Madeira","大西洋/马德拉"} ,
  3255. {"Atlantic/Reykjavik","大西洋/雷克雅未克"} ,
  3256. {"Atlantic/South_Georgia","大西洋/南乔治亚州"} ,
  3257. {"Atlantic/St_Helena","大西洋/圣赫勒拿岛"} ,
  3258. {"Atlantic/Stanley","大西洋/斯坦利"} ,
  3259. {"Australia/ACT","澳大利亚/澳大利亚首都地区"} ,
  3260. {"Australia/Adelaide","澳大利亚/阿德莱德"} ,
  3261. {"Australia/Brisbane","澳大利亚/布里斯班"} ,
  3262. {"Australia/Broken_Hill","澳大利亚/布罗肯希尔"} ,
  3263. {"Australia/Canberra","澳大利亚/堪培拉"} ,
  3264. {"Australia/Currie","澳大利亚/柯里"} ,
  3265. {"Australia/Darwin","澳大利亚/达尔文"} ,
  3266. {"Australia/Eucla","澳大利亚/尤克拉拉"} ,
  3267. {"Australia/Hobart","澳大利亚/霍巴特"} ,
  3268. {"Australia/LHI","澳大利亚/LHI"} ,
  3269. {"Australia/Lindeman","澳大利亚/林德曼"} ,
  3270. {"Australia/Lord_Howe","澳大利亚/豪勋爵"} ,
  3271. {"Australia/Melbourne","澳大利亚/墨尔本"} ,
  3272. {"Australia/NSW","澳大利亚/新南威尔士州"} ,
  3273. {"Australia/North","澳大利亚/北部"} ,
  3274. {"Australia/Perth","澳大利亚/珀斯"} ,
  3275. {"Australia/Queensland","澳大利亚/昆士兰"} ,
  3276. {"Australia/South","澳大利亚/南部"} ,
  3277. {"Australia/Sydney","澳大利亚/悉尼"} ,
  3278. {"Australia/Tasmania","澳大利亚/塔斯马尼亚"} ,
  3279. {"Australia/Victoria","澳大利亚/维多利亚"} ,
  3280. {"Australia/West","澳大利亚/西部"} ,
  3281. {"Australia/Yancowinna","澳大利亚/扬科温纳"} ,
  3282. {"Brazil/Acre","巴西/阿卡"} ,
  3283. {"Brazil/DeNoronha","巴西/迪诺罗尼亚群岛"} ,
  3284. {"Brazil/East","巴西/东部"} ,
  3285. {"Brazil/West","巴西/西部"} ,
  3286. {"CET","CET"} ,
  3287. {"CST6CDT","CST6CDT"} ,
  3288. {"Canada/Atlantic","加拿大/大西洋"} ,
  3289. {"Canada/Central","加拿大/中部"} ,
  3290. {"Canada/Eastern","加拿大/东部"} ,
  3291. {"Canada/Mountain","加拿大/山区"} ,
  3292. {"Canada/Newfoundland","加拿大/纽芬兰"} ,
  3293. {"Canada/Pacific","加拿大/太平洋地区"} ,
  3294. {"Canada/Saskatchewan","加拿大/萨斯喀彻温省"} ,
  3295. {"Canada/Yukon","加拿大/育空地区"} ,
  3296. {"Chile/Continental","智利/大陆航空"} ,
  3297. {"Chile/EasterIsland","智利/复活节岛"} ,
  3298. {"Cuba","古巴"} ,
  3299. {"EET","欧洲东部时间"} ,
  3300. {"EST","东部时间"} ,
  3301. {"EST5EDT","EST5EDT"} ,
  3302. {"Egypt","埃及"} ,
  3303. {"Eire","爱尔兰"} ,
  3304. {"Etc/GMT","Etc/GMT"} ,
  3305. {"Etc/GMT+0","Etc/GMT+0"} ,
  3306. {"Etc/GMT+1","Etc/GMT+1"} ,
  3307. {"Etc/GMT+10","Etc/GMT+10"} ,
  3308. {"Etc/GMT+11","Etc/GMT+11"} ,
  3309. {"Etc/GMT+12","Etc/GMT+12"} ,
  3310. {"Etc/GMT+2","Etc/GMT+2"} ,
  3311. {"Etc/GMT+3","Etc/GMT+3"} ,
  3312. {"Etc/GMT+4","Etc/GMT+4"} ,
  3313. {"Etc/GMT+5","Etc/GMT+5"} ,
  3314. {"Etc/GMT+6","Etc/GMT+6"} ,
  3315. {"Etc/GMT+7","Etc/GMT+7"} ,
  3316. {"Etc/GMT+8","Etc/GMT+8"} ,
  3317. {"Etc/GMT+9","Etc/GMT+9"} ,
  3318. {"Etc/GMT-0","Etc/GMT-0"} ,
  3319. {"Etc/GMT-1","Etc/GMT-1"} ,
  3320. {"Etc/GMT-10","Etc/GMT-10"} ,
  3321. {"Etc/GMT-11","Etc/GMT-11"} ,
  3322. {"Etc/GMT-12","Etc/GMT-12"} ,
  3323. {"Etc/GMT-13","Etc/GMT-13"} ,
  3324. {"Etc/GMT-14","Etc/GMT-14"} ,
  3325. {"Etc/GMT-2","Etc/GMT-2"} ,
  3326. {"Etc/GMT-3","Etc/GMT-3"} ,
  3327. {"Etc/GMT-4","Etc/GMT-4"} ,
  3328. {"Etc/GMT-5","Etc/GMT-5"} ,
  3329. {"Etc/GMT-6","Etc/GMT-6"} ,
  3330. {"Etc/GMT-7","Etc/GMT-7"} ,
  3331. {"Etc/GMT-8","Etc/GMT-8"} ,
  3332. {"Etc/GMT-9","Etc/GMT-9"} ,
  3333. {"Etc/GMT0","Etc/GMT0"} ,
  3334. {"Etc/Greenwich","Etc/格林威治"} ,
  3335. {"Etc/UCT","Etc/UCT"} ,
  3336. {"Etc/UTC","Etc/UTC"} ,
  3337. {"Etc/Universal","Etc/通用"} ,
  3338. {"Etc/Zulu","Etc/祖鲁语"} ,
  3339. {"Europe/Amsterdam","欧洲/阿姆斯特丹"} ,
  3340. {"Europe/Andorra","欧洲/安道尔"} ,
  3341. {"Europe/Astrakhan","欧洲/阿斯特拉罕"} ,
  3342. {"Europe/Athens","欧洲/雅典"} ,
  3343. {"Europe/Belfast","欧洲/贝尔法斯特"} ,
  3344. {"Europe/Belgrade","欧洲/贝尔格莱德"} ,
  3345. {"Europe/Berlin","欧洲/柏林"} ,
  3346. {"Europe/Bratislava","欧洲/布拉迪斯拉发"} ,
  3347. {"Europe/Brussels","欧洲/布鲁塞尔"} ,
  3348. {"Europe/Bucharest","欧洲/布加勒斯特"} ,
  3349. {"Europe/Budapest","欧洲/布达佩斯"} ,
  3350. {"Europe/Busingen","欧洲/布辛根"} ,
  3351. {"Europe/Chisinau","欧洲/基希讷乌"} ,
  3352. {"Europe/Copenhagen","欧洲/哥本哈根"} ,
  3353. {"Europe/Dublin","欧洲/都柏林"} ,
  3354. {"Europe/Gibraltar","欧洲/直布罗陀"} ,
  3355. {"Europe/Guernsey","欧洲/根西岛"} ,
  3356. {"Europe/Helsinki","欧洲/赫尔辛基"} ,
  3357. {"Europe/Isle_of_Man","欧洲/马恩岛"} ,
  3358. {"Europe/Istanbul","欧洲/伊斯坦布尔"} ,
  3359. {"Europe/Jersey","欧洲/泽西岛"} ,
  3360. {"Europe/Kaliningrad","欧洲/加里宁格勒"} ,
  3361. {"Europe/Kiev","欧洲/基辅"} ,
  3362. {"Europe/Kirov","欧洲/基洛夫"} ,
  3363. {"Europe/Kyiv","欧洲/基辅"} ,
  3364. {"Europe/Lisbon","欧洲/里斯本"} ,
  3365. {"Europe/Ljubljana","欧洲/卢布尔雅那"} ,
  3366. {"Europe/London","欧洲/伦敦"} ,
  3367. {"Europe/Luxembourg","欧洲/卢森堡"} ,
  3368. {"Europe/Madrid","欧洲/马德里"} ,
  3369. {"Europe/Malta","欧洲/马耳他"} ,
  3370. {"Europe/Mariehamn","欧洲/玛丽港"} ,
  3371. {"Europe/Minsk","欧洲/明斯克"} ,
  3372. {"Europe/Monaco","欧洲/摩纳哥"} ,
  3373. {"Europe/Moscow","欧洲/莫斯科"} ,
  3374. {"Europe/Nicosia","欧洲/尼科西亚"} ,
  3375. {"Europe/Oslo","欧洲/奥斯陆"} ,
  3376. {"Europe/Paris","欧洲/巴黎"} ,
  3377. {"Europe/Podgorica","欧洲/波德戈里察"} ,
  3378. {"Europe/Prague","欧洲/布拉格"} ,
  3379. {"Europe/Riga","欧洲/里加"} ,
  3380. {"Europe/Rome","欧洲/罗马"} ,
  3381. {"Europe/Samara","欧洲/萨马拉"} ,
  3382. {"Europe/San_Marino","欧洲/圣马力诺"} ,
  3383. {"Europe/Sarajevo","欧洲/萨拉热窝"} ,
  3384. {"Europe/Saratov","欧洲/萨拉托夫"} ,
  3385. {"Europe/Simferopol","欧洲/辛菲罗波尔"} ,
  3386. {"Europe/Skopje","欧洲/斯科普里"} ,
  3387. {"Europe/Sofia","欧洲/索非亚"} ,
  3388. {"Europe/Stockholm","欧洲/斯德哥尔摩"} ,
  3389. {"Europe/Tallinn","欧洲/塔林"} ,
  3390. {"Europe/Tirane","欧洲/地拉那"} ,
  3391. {"Europe/Tiraspol","欧洲/蒂拉斯波尔"} ,
  3392. {"Europe/Ulyanovsk","欧洲/乌里扬诺夫斯克"} ,
  3393. {"Europe/Uzhgorod","欧洲/乌日哥罗德"} ,
  3394. {"Europe/Vaduz","欧洲/瓦杜兹"} ,
  3395. {"Europe/Vatican","欧洲/梵蒂冈"} ,
  3396. {"Europe/Vienna","欧洲/维也纳"} ,
  3397. {"Europe/Vilnius","欧洲/维尔纽斯"} ,
  3398. {"Europe/Volgograd","欧洲/伏尔加格勒"} ,
  3399. {"Europe/Warsaw","欧洲/华沙"} ,
  3400. {"Europe/Zagreb","欧洲/萨格勒布"} ,
  3401. {"Europe/Zaporozhye","欧洲/扎波罗热"} ,
  3402. {"Europe/Zurich","欧洲/苏黎世"} ,
  3403. {"GB","国标"} ,
  3404. {"GB-Eire","英国-爱尔兰"} ,
  3405. {"GMT","格林威治标准时间"} ,
  3406. {"GMT+0","格林威治标准时间+0"} ,
  3407. {"GMT-0","GMT-0"} ,
  3408. {"GMT0","格林威治标准时间0"} ,
  3409. {"Greenwich","格林威治"} ,
  3410. {"HST","高温试验"} ,
  3411. {"Hongkong","香港"} ,
  3412. {"Iceland","冰岛"} ,
  3413. {"Indian/Antananarivo","印度/塔那那利佛"} ,
  3414. {"Indian/Chagos","印第安人/查戈斯人"} ,
  3415. {"Indian/Christmas","印度/圣诞节"} ,
  3416. {"Indian/Cocos","印度/科科斯"} ,
  3417. {"Indian/Comoro","印度/科摩罗"} ,
  3418. {"Indian/Kerguelen","印度/凯尔盖朗"} ,
  3419. {"Indian/Mahe","印度/马埃岛"} ,
  3420. {"Indian/Maldives","印度/马尔代夫"} ,
  3421. {"Indian/Mauritius","印度/毛里求斯"} ,
  3422. {"Indian/Mayotte","印度/马约特岛"} ,
  3423. {"Indian/Reunion","印度/留尼汪岛"} ,
  3424. {"Iran","伊朗"} ,
  3425. {"Israel","以色列"} ,
  3426. {"Jamaica","牙买加"} ,
  3427. {"Japan","日本"} ,
  3428. {"Kwajalein","夸贾林环礁"} ,
  3429. {"Libya","利比亚"} ,
  3430. {"MET","梅特"} ,
  3431. {"MST","MST"} ,
  3432. {"MST7MDT","MST7MDT"} ,
  3433. {"Mexico/BajaNorte","墨西哥/北下巴"} ,
  3434. {"Mexico/BajaSur","墨西哥/巴哈苏尔"} ,
  3435. {"Mexico/General","墨西哥/一般"} ,
  3436. {"NZ","新西兰"} ,
  3437. {"NZ-CHAT","新西兰聊天室"} ,
  3438. {"Navajo","纳瓦霍语"} ,
  3439. {"PRC","中国"} ,
  3440. {"PST8PDT","PST8PDT"} ,
  3441. {"Pacific/Apia","太平洋/阿皮亚"} ,
  3442. {"Pacific/Auckland","太平洋/奥克兰"} ,
  3443. {"Pacific/Bougainville","太平洋/布干维尔岛"} ,
  3444. {"Pacific/Chatham","太平洋/查塔姆"} ,
  3445. {"Pacific/Chuuk","太平洋/楚克"} ,
  3446. {"Pacific/Easter","太平洋/复活节"} ,
  3447. {"Pacific/Efate","太平洋/埃法特"} ,
  3448. {"Pacific/Enderbury","太平洋/恩德伯里"} ,
  3449. {"Pacific/Fakaofo","太平洋/法考福"} ,
  3450. {"Pacific/Fiji","太平洋/斐济"} ,
  3451. {"Pacific/Funafuti","太平洋/富纳富提"} ,
  3452. {"Pacific/Galapagos","太平洋/加拉帕戈斯群岛"} ,
  3453. {"Pacific/Gambier","太平洋/甘比尔"} ,
  3454. {"Pacific/Guadalcanal","太平洋/瓜达尔卡纳尔岛"} ,
  3455. {"Pacific/Guam","太平洋/关岛"} ,
  3456. {"Pacific/Honolulu","太平洋/檀香山"} ,
  3457. {"Pacific/Johnston","太平洋/约翰斯顿"} ,
  3458. {"Pacific/Kanton","太平洋/关东"} ,
  3459. {"Pacific/Kiritimati","太平洋/基里蒂马蒂"} ,
  3460. {"Pacific/Kosrae","太平洋/科斯雷"} ,
  3461. {"Pacific/Kwajalein","太平洋/夸贾林环礁"} ,
  3462. {"Pacific/Majuro","太平洋/马朱罗"} ,
  3463. {"Pacific/Marquesas","太平洋/马克萨斯"} ,
  3464. {"Pacific/Midway","太平洋/中途岛"} ,
  3465. {"Pacific/Nauru","太平洋/瑙鲁"} ,
  3466. {"Pacific/Niue","太平洋/纽埃"} ,
  3467. {"Pacific/Norfolk","太平洋/诺福克"} ,
  3468. {"Pacific/Noumea","太平洋/努美阿"} ,
  3469. {"Pacific/Pago_Pago","太平洋/帕果"} ,
  3470. {"Pacific/Palau","太平洋/帕劳"} ,
  3471. {"Pacific/Pitcairn","太平洋/皮特凯恩"} ,
  3472. {"Pacific/Pohnpei","太平洋/波纳佩"} ,
  3473. {"Pacific/Ponape","太平洋/波纳佩"} ,
  3474. {"Pacific/Port_Moresby","太平洋/莫尔兹比港"} ,
  3475. {"Pacific/Rarotonga","太平洋/拉罗汤加"} ,
  3476. {"Pacific/Saipan","太平洋/塞班岛"} ,
  3477. {"Pacific/Samoa","太平洋/萨摩亚"} ,
  3478. {"Pacific/Tahiti","太平洋/大溪地"} ,
  3479. {"Pacific/Tarawa","太平洋/塔拉瓦"} ,
  3480. {"Pacific/Tongatapu","太平洋/汤加塔布岛"} ,
  3481. {"Pacific/Truk","太平洋/特鲁克"} ,
  3482. {"Pacific/Wake","太平洋/威克"} ,
  3483. {"Pacific/Wallis","太平洋/沃利斯"} ,
  3484. {"Pacific/Yap","太平洋/雅浦岛"} ,
  3485. {"Poland","波兰"} ,
  3486. {"Portugal","葡萄牙"} ,
  3487. {"ROC","ROC"} ,
  3488. {"ROK","韩国"} ,
  3489. {"Singapore","新加坡"} ,
  3490. {"Turkey","Turkey"} ,
  3491. {"UCT","世界标准时间"} ,
  3492. {"US/Alaska","美国/阿拉斯加"} ,
  3493. {"US/Aleutian","美国/阿留申群岛"} ,
  3494. {"US/Arizona","美国/亚利桑那州"} ,
  3495. {"US/Central","美国/中部"} ,
  3496. {"US/East-Indiana","美国/东印第安纳州"} ,
  3497. {"US/Eastern","美国/东部"} ,
  3498. {"US/Hawaii","美国/夏威夷"} ,
  3499. {"US/Indiana-Starke","美国/印第安纳州斯塔克"} ,
  3500. {"US/Michigan","美国/密歇根州"} ,
  3501. {"US/Mountain","美国/山地"} ,
  3502. {"US/Pacific","美国/太平洋地区"} ,
  3503. {"US/Samoa","美国/萨摩亚"} ,
  3504. {"UTC","世界标准时间"} ,
  3505. {"Universal","Universal"} ,
  3506. {"W-SU","W-SU"} ,
  3507. {"WET","WET"} ,
  3508. {"Zulu","Zulu"}
  3509. };
  3510. /// <summary>
  3511. /// 获取国家或城市当地时间
  3512. /// </summary>
  3513. /// <param name="country"></param>
  3514. /// <param name="city"></param>
  3515. /// <returns></returns>
  3516. public static DateTime? GetCountryOrCityCurrentDateTime(string country, string city)
  3517. {
  3518. DateTime? currDt = null;
  3519. var currTimezones = _timeZoneCityMappings.Where(x => x.Value.Contains(city)).ToList();
  3520. if (!currTimezones.Any()) {
  3521. currTimezones = _timeZoneCityMappings.Where(x => x.Value.Contains(country)).ToList();
  3522. };
  3523. string timeZoneId = string.Empty;
  3524. if (currTimezones.Count > 1)
  3525. {
  3526. currTimezones = currTimezones.Where(x => x.Value.Contains(country)).ToList();
  3527. timeZoneId = currTimezones.FirstOrDefault().Key ?? string.Empty;
  3528. }else timeZoneId = currTimezones.FirstOrDefault().Key ?? string.Empty;
  3529. if (string.IsNullOrEmpty(timeZoneId)) return currDt;
  3530. // Step 1: 获取当前 UTC 时间
  3531. Instant now = SystemClock.Instance.GetCurrentInstant();
  3532. // Step 2: 加载目标时区(以 "Asia/Shanghai" 为例)
  3533. var timeZone = DateTimeZoneProviders.Tzdb[timeZoneId];
  3534. if (timeZone == null) return currDt;
  3535. // Step 3: 将 UTC 时间转换为目标时区的本地时间
  3536. currDt = now.InZone(timeZone).ToDateTimeUnspecified();
  3537. return currDt;
  3538. }
  3539. #endregion
  3540. #region aspose
  3541. /// <summary>
  3542. /// aspose word 设置页脚
  3543. /// </summary>
  3544. /// <param name="builder"></param>
  3545. /// <param name="footerLabel">页脚内容</param>
  3546. /// <param name="font">字体名称</param>
  3547. /// <param name="fontSize"><字体大小/param>
  3548. public static void AsposeWordSetFooter(DocumentBuilder builder,string footerLabel,string font,int fontSize)
  3549. {
  3550. Section currentSection = builder.CurrentSection;
  3551. var pageSetup = currentSection.PageSetup;
  3552. pageSetup.DifferentFirstPageHeaderFooter = true;
  3553. //第一页页脚
  3554. builder.MoveToHeaderFooter(HeaderFooterType.FooterFirst);
  3555. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  3556. builder.Font.Name = font;
  3557. builder.Font.Bold = true;
  3558. builder.Font.Size = fontSize;
  3559. builder.Write(footerLabel);
  3560. //非第一页页脚
  3561. builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
  3562. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  3563. builder.Font.Name = font;
  3564. builder.Font.Bold = true;
  3565. builder.Font.Size = fontSize;
  3566. builder.Write(footerLabel);
  3567. }
  3568. #endregion
  3569. #region 出入境费用
  3570. #region 汇率
  3571. /// <summary>
  3572. /// 出入境费用 初始化汇率
  3573. /// </summary>
  3574. /// <returns></returns>
  3575. public static async Task<List<CurrencyInfo>> EnterExitCostInitRate()
  3576. {
  3577. //默认币种显示
  3578. List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>()
  3579. {
  3580. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3581. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3582. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3583. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3584. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3585. };
  3586. var currencyRate = await _juHeApi.PostItemRateAsync(currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  3587. if (currencyRate.Count > 0)
  3588. {
  3589. foreach (var item in currencyInfos)
  3590. {
  3591. var rateInfo = currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3592. if (rateInfo != null)
  3593. {
  3594. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3595. if (rateInfo.Name.Equals("日元")) rate1 *= 1.3700M; //rate1 = rate1 * 1;
  3596. else rate1 *= 1.035M;
  3597. item.Rate = rate1.TruncDecimals(4) + 0.01M;
  3598. }
  3599. }
  3600. }
  3601. return currencyInfos;
  3602. }
  3603. /// <summary>
  3604. /// 出入境费用 实时汇率
  3605. /// </summary>
  3606. /// <returns></returns>
  3607. public static async Task<List<dynamic>> EnterExitCostLiveRate()
  3608. {
  3609. List<dynamic> reteInfos = new List<dynamic>();
  3610. //默认币种显示
  3611. List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>()
  3612. {
  3613. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3614. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3615. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3616. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3617. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3618. };
  3619. var currencyRate = await _juHeApi.PostItemRateAsync(currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  3620. if (currencyRate.Count > 0)
  3621. {
  3622. foreach (var item in currencyInfos)
  3623. {
  3624. var rateInfo = currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3625. if (rateInfo != null)
  3626. {
  3627. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3628. decimal rate1 = item.Rate * 1.0300M;
  3629. //rate1 += 0.01M;
  3630. reteInfos.Add(new
  3631. {
  3632. currCode = item.CurrencyCode,
  3633. currName = item.CurrencyName,
  3634. rate = rate1.TruncDecimals(4),
  3635. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3636. });
  3637. }
  3638. }
  3639. }
  3640. return reteInfos;
  3641. }
  3642. #endregion
  3643. #region 三公费用明细 文件下载
  3644. /// <summary>
  3645. /// 获取三公费用标准city
  3646. /// </summary>
  3647. /// <param name="placeData"></param>
  3648. /// <param name="nationalTravelFeeId"></param>
  3649. /// <returns></returns>
  3650. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  3651. {
  3652. string _city = string.Empty;
  3653. if (placeData.Count < 1) return _city;
  3654. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  3655. if (data == null) return _city;
  3656. string country = data.Country;
  3657. string city = data.City;
  3658. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  3659. else _city = city;
  3660. return _city;
  3661. }
  3662. /// <summary>
  3663. /// 三公费用明细 文件下载
  3664. /// </summary>
  3665. /// <param name="dto"></param>
  3666. /// <param name="fileFormat"></param>
  3667. /// <returns></returns>
  3668. public static async Task<JsonView> EnterExitCostDownload(EnterExitCostDownloadDto dto, string fileFormat = "pdf")
  3669. {
  3670. var _view = new JsonView() { Code = StatusCodes.Status204NoContent };
  3671. if (dto.DiId < 1)
  3672. {
  3673. _view.Msg = "请传入有效的DiId参数;";
  3674. return _view;
  3675. }
  3676. if (dto.ExportType < 1)
  3677. {
  3678. _view.Msg = MsgTips.Port;
  3679. return _view;
  3680. }
  3681. if (dto.SubTypeId < 1)
  3682. {
  3683. _view.Msg = @"请传入有效的SubTypeId参数;
  3684. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3685. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3686. 3 团组成员名单 1 团组成员名单";
  3687. return _view;
  3688. }
  3689. try
  3690. {
  3691. var enterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3692. var dayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3693. if (enterExitCosts == null)
  3694. {
  3695. _view.Msg = @"该团组未填写出入境费用;";
  3696. return _view;
  3697. }
  3698. //数据源
  3699. List<Grp_DayAndCost> dac1 = dayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3700. List<Grp_DayAndCost> dac2 = dayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3701. List<Grp_DayAndCost> dac3 = dayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3702. List<Grp_DayAndCost> dac4 = dayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3703. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3704. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3705. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3706. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3707. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3708. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3709. .Select((tcl, dc, cc) => new
  3710. {
  3711. Name = dc.LastName + dc.FirstName,
  3712. Sex = dc.Sex,
  3713. Birthday = dc.BirthDay,
  3714. Company = cc.CompanyFullName,
  3715. Job = dc.Job
  3716. })
  3717. .ToList();
  3718. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3719. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3720. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3721. var rateDatas = await enterExitCosts.CurrencyRemark.SplitExchangeRate();
  3722. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  3723. if (dto.ExportType == 1) //明细表
  3724. {
  3725. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3726. {
  3727. if (!fileFormat.Equals("pdf")) fileFormat = "docx";
  3728. //获取模板
  3729. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3730. //载入模板
  3731. Document doc = new Document(tempPath);
  3732. DocumentBuilder builder = new DocumentBuilder(doc);
  3733. //利用键值对存放数据
  3734. Dictionary<string, string> dic = new Dictionary<string, string>();
  3735. decimal stayFeeTotal = dayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3736. decimal mealsFeeTotal = dayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3737. decimal miscellaneousFeeTotal = dayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3738. decimal tainFeeTotal = dayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3739. decimal insidePayTotal = enterExitCosts.InsidePay;
  3740. string row1_1 = "";
  3741. if (enterExitCosts.Visa > 0)
  3742. {
  3743. //insidePayTotal += enterExitCosts.Visa;
  3744. row1_1 = $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3745. if (!string.IsNullOrEmpty(enterExitCosts.VisaRemark))
  3746. {
  3747. row1_1 += $"\t签证费用描述: {enterExitCosts.VisaRemark}";
  3748. }
  3749. }
  3750. string row1_2 = "";
  3751. if (enterExitCosts.YiMiao > 0)
  3752. {
  3753. //insidePayTotal += enterExitCosts.YiMiao;
  3754. row1_2 += $"疫苗费:{enterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3755. }
  3756. if (enterExitCosts.HeSuan > 0)
  3757. {
  3758. //insidePayTotal += enterExitCosts.HeSuan;
  3759. row1_2 += $"核酸检测费:{enterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3760. }
  3761. if (enterExitCosts.Service > 0)
  3762. {
  3763. //insidePayTotal += enterExitCosts.Service;
  3764. row1_2 += $"服务费:{enterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3765. }
  3766. string row1_3 = "";
  3767. if (enterExitCosts.Safe > 0)
  3768. {
  3769. //insidePayTotal += enterExitCosts.Safe;
  3770. row1_3 += $"保险费:{enterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3771. }
  3772. if (enterExitCosts.Ticket > 0)
  3773. {
  3774. //insidePayTotal += enterExitCosts.Ticket;
  3775. row1_3 += $"参展门票:{enterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3776. }
  3777. string row1 = "";
  3778. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3779. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3780. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3781. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3782. dic.Add("Row1Str", row1);
  3783. dic.Add("OutsideJJ", enterExitCosts.OutsideJJPay.ToString("#0.00"));
  3784. dic.Add("OutsaideGW", enterExitCosts.OutsideGWPay.ToString("#0.00"));
  3785. dic.Add("AirJJ", enterExitCosts.AirJJ.ToString("#0.00"));
  3786. dic.Add("AirGW", enterExitCosts.AirGW.ToString("#0.00"));
  3787. dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
  3788. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3789. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3790. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3791. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3792. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3793. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + enterExitCosts.OutsideJJPay;
  3794. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + enterExitCosts.OutsideGWPay;
  3795. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3796. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3797. #region 填充word模板书签内容
  3798. foreach (var key in dic.Keys)
  3799. {
  3800. builder.MoveToBookmark(key);
  3801. builder.Write(dic[key]);
  3802. }
  3803. #endregion
  3804. #region 填充word表格内容
  3805. ////获读取指定表格方法二
  3806. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3807. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3808. for (int i = 0; i < dac1.Count; i++)
  3809. {
  3810. Grp_DayAndCost dac = dac1[i];
  3811. if (dac == null) continue;
  3812. builder.MoveToCell(0, i, 0, 0);
  3813. builder.Write("第" + dac.Days.ToString() + "晚:");
  3814. builder.MoveToCell(0, i, 1, 0);
  3815. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3816. //builder.Write(dac.Place == null ? "" : dac.Place);
  3817. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3818. builder.MoveToCell(0, i, 2, 0);
  3819. builder.Write("费用标准:");
  3820. string curr = "";
  3821. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3822. if (currData != null)
  3823. {
  3824. curr = currData.Name;
  3825. }
  3826. builder.MoveToCell(0, i, 3, 0);
  3827. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3828. builder.MoveToCell(0, i, 4, 0);
  3829. builder.Write("费用小计:");
  3830. builder.MoveToCell(0, i, 5, 0);
  3831. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3832. }
  3833. //删除多余行
  3834. while (table1.Rows.Count > dac1.Count)
  3835. {
  3836. table1.Rows.RemoveAt(dac1.Count);
  3837. }
  3838. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3839. for (int i = 0; i < dac2.Count; i++)
  3840. {
  3841. Grp_DayAndCost dac = dac2[i];
  3842. if (dac == null) continue;
  3843. builder.MoveToCell(1, i, 0, 0);
  3844. builder.Write("第" + dac.Days.ToString() + "天:");
  3845. builder.MoveToCell(1, i, 1, 0);
  3846. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3847. builder.MoveToCell(1, i, 2, 0);
  3848. builder.Write("费用标准:");
  3849. string curr = "";
  3850. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3851. if (currData != null)
  3852. {
  3853. curr = currData.Name;
  3854. }
  3855. builder.MoveToCell(1, i, 3, 0);
  3856. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3857. builder.MoveToCell(1, i, 4, 0);
  3858. builder.Write("费用小计:");
  3859. builder.MoveToCell(1, i, 5, 0);
  3860. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3861. }
  3862. //删除多余行
  3863. while (table2.Rows.Count > dac2.Count)
  3864. {
  3865. table2.Rows.RemoveAt(dac2.Count);
  3866. }
  3867. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3868. for (int i = 0; i < dac3.Count; i++)
  3869. {
  3870. Grp_DayAndCost dac = dac3[i];
  3871. if (dac == null) continue;
  3872. builder.MoveToCell(2, i, 0, 0);
  3873. builder.Write("第" + dac.Days.ToString() + "天:");
  3874. builder.MoveToCell(2, i, 1, 0);
  3875. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3876. builder.MoveToCell(2, i, 2, 0);
  3877. builder.Write("费用标准:");
  3878. string curr = "";
  3879. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3880. if (currData != null)
  3881. {
  3882. curr = currData.Name;
  3883. }
  3884. builder.MoveToCell(2, i, 3, 0);
  3885. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3886. builder.MoveToCell(2, i, 4, 0);
  3887. builder.Write("费用小计:");
  3888. builder.MoveToCell(2, i, 5, 0);
  3889. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3890. }
  3891. //删除多余行
  3892. while (table3.Rows.Count > dac3.Count)
  3893. {
  3894. table3.Rows.RemoveAt(dac3.Count);
  3895. }
  3896. #endregion
  3897. //文件名
  3898. //string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.{fileFormat}";
  3899. //string strFileName = $"{_DelegationInfo.TeamName}-出入境费用{Guid.NewGuid().ToString()}.{fileFormat}";
  3900. string strFileName = $"{_DelegationInfo.TeamName}{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.{fileFormat}";
  3901. AsposeHelper.removewatermark_v2180();
  3902. //doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3903. var saveFormat = Aspose.Words.SaveFormat.Docx;
  3904. if (fileFormat.Equals("pdf"))
  3905. {
  3906. //doc.LayoutOptions.IsShowComments = false;
  3907. doc.LayoutOptions.IsShowHiddenText = false;
  3908. doc.LayoutOptions.IsShowParagraphMarks = false;
  3909. doc.LayoutOptions.RevisionOptions.DeletedTextEffect = RevisionTextEffect.None;
  3910. doc.AcceptAllRevisions();
  3911. Aspose.Words.Saving.PdfSaveOptions options = new Aspose.Words.Saving.PdfSaveOptions();
  3912. options.Compliance = PdfCompliance.PdfA1a;
  3913. options.CreateNoteHyperlinks = true;
  3914. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName, options);
  3915. //_view.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName };
  3916. _view.Data = new { Url = strFileName };
  3917. _view.Msg = "成功";
  3918. return _view;
  3919. }
  3920. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName, saveFormat);
  3921. _view.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName };
  3922. _view.Msg = "成功";
  3923. return _view;
  3924. }
  3925. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3926. {
  3927. //获取模板
  3928. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3929. //载入模板
  3930. Document doc = new Document(tempPath);
  3931. DocumentBuilder builder = new DocumentBuilder(doc);
  3932. Dictionary<string, string> dic = new Dictionary<string, string>();
  3933. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3934. {
  3935. List<string> list = new List<string>();
  3936. try
  3937. {
  3938. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3939. foreach (var item in spilitArr)
  3940. {
  3941. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3942. var depCode = spDotandEmpty[2].Substring(0, 3);
  3943. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3944. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3945. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3946. list.Add(depName);
  3947. list.Add(arrName);
  3948. }
  3949. list = list.Distinct().ToList();
  3950. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3951. }
  3952. catch (Exception)
  3953. {
  3954. dic.Add("ReturnCode", "行程录入不正确!");
  3955. }
  3956. }
  3957. else
  3958. {
  3959. dic.Add("ReturnCode", "未录入行程!");
  3960. }
  3961. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3962. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3963. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3964. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3965. {
  3966. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3967. dic.Add("Day", sp.Days.ToString());
  3968. }
  3969. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3970. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3971. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3972. //dic.Add("Names", Names);
  3973. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3974. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3975. decimal dac1totalPrice = 0.00M;
  3976. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3977. foreach (var dac in dac1)
  3978. {
  3979. if (dac.SubTotal == 0.00M)
  3980. {
  3981. continue;
  3982. }
  3983. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3984. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3985. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3986. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3987. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3988. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3989. builder.Write(currency);//币种
  3990. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3991. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3992. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3993. builder.Write("");//人数
  3994. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3995. builder.Write("");//天数
  3996. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3997. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3998. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3999. decimal rate = 0.00M;
  4000. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4001. builder.Write(rate.ToString("#0.0000"));//汇率
  4002. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4003. decimal rbmPrice = dac.SubTotal;
  4004. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4005. accommodationStartIndex++;
  4006. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4007. }
  4008. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4009. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4010. {
  4011. table1.Rows.RemoveAt(i - 1);
  4012. foodandotherStartIndex--;
  4013. }
  4014. if (dac2.Count == dac3.Count)//国家 币种 金额
  4015. {
  4016. for (int i = 0; i < dac2.Count; i++)
  4017. {
  4018. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4019. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4020. }
  4021. }
  4022. decimal dac2totalPrice = 0.00M;
  4023. foreach (var dac in dac2)
  4024. {
  4025. if (dac.SubTotal == 0)
  4026. {
  4027. continue;
  4028. }
  4029. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4030. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4031. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4032. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4033. builder.Write(currency);//币种
  4034. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4035. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4036. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4037. builder.Write("");//人数
  4038. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4039. builder.Write("");//天数
  4040. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4041. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4042. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4043. decimal rate = 0.00M;
  4044. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4045. builder.Write(rate.ToString("#0.0000"));//汇率
  4046. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4047. decimal rbmPrice = dac.SubTotal;
  4048. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4049. foodandotherStartIndex++;
  4050. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4051. }
  4052. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4053. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4054. {
  4055. table1.Rows.RemoveAt(i - 1);
  4056. }
  4057. dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
  4058. string otherFeeStr = "";
  4059. if (enterExitCosts.Visa > 0) otherFeeStr += $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 元,";
  4060. if (enterExitCosts.Safe > 0) otherFeeStr += $"保险费: {enterExitCosts.Safe.ToString("#0.00")} 元,";
  4061. if (enterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {enterExitCosts.Ticket.ToString("#0.00")} 元,";
  4062. if (otherFeeStr.Length > 0)
  4063. {
  4064. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4065. otherFeeStr = $"({otherFeeStr})";
  4066. dic.Add("OtherFeeStr", otherFeeStr);
  4067. }
  4068. //总计
  4069. decimal allPrice = dac1totalPrice + dac2totalPrice + enterExitCosts.Visa + enterExitCosts.Safe + enterExitCosts.Ticket;
  4070. //国际旅费
  4071. string outsideJJ = "";
  4072. string allPriceJJ = "";
  4073. if (enterExitCosts.SumJJC == 1)
  4074. {
  4075. outsideJJ = string.Format(@"经济舱:{0} 元/人", enterExitCosts.AirJJ.ToString("#0.00"));
  4076. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + enterExitCosts.OutsideJJPay).ToString("#0.00"));
  4077. }
  4078. string outsideGW = "";
  4079. string allPriceGW = "";
  4080. if (enterExitCosts.SumGWC == 1)
  4081. {
  4082. outsideGW = string.Format(@"公务舱:{0} 元/人", enterExitCosts.AirGW.ToString("#0.00"));
  4083. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + enterExitCosts.OutsideGWPay).ToString("#0.00"));
  4084. }
  4085. if (enterExitCosts.SumJJC == 1 || enterExitCosts.SumGWC == 1)
  4086. {
  4087. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  4088. dic.Add("InTravelPrice", InTravelPriceStr);
  4089. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  4090. dic.Add("FinalSumPrice", FinalSumPriceStr);
  4091. }
  4092. //dic.Add("VisaPay", enterExitCosts.Visa.ToString("#0.00"));
  4093. //dic.Add("SafePay", enterExitCosts.Safe.ToString("#0.00"));
  4094. //dic.Add("YiMiao", enterExitCosts.YiMiao.ToString("#0.00"));
  4095. foreach (var key in dic.Keys)
  4096. {
  4097. builder.MoveToBookmark(key);
  4098. builder.Write(dic[key]);
  4099. }
  4100. //模板文件名
  4101. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  4102. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4103. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4104. _view.Data = new { Url = url };
  4105. _view.Msg = "成功";
  4106. return _view;
  4107. }
  4108. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4109. {
  4110. //获取模板
  4111. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4112. //载入模板
  4113. WorkbookDesigner designer = new WorkbookDesigner();
  4114. designer.Workbook = new Workbook(tempPath);
  4115. Dictionary<string, string> dic = new Dictionary<string, string>();
  4116. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4117. {
  4118. List<string> list = new List<string>();
  4119. try
  4120. {
  4121. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4122. foreach (var item in spilitArr)
  4123. {
  4124. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4125. var depCode = spDotandEmpty[2].Substring(0, 3);
  4126. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4127. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4128. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4129. list.Add(depName);
  4130. list.Add(arrName);
  4131. }
  4132. list = list.Distinct().ToList();
  4133. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4134. }
  4135. catch (Exception)
  4136. {
  4137. dic.Add("ReturnCode", "行程录入不正确!");
  4138. }
  4139. }
  4140. else
  4141. {
  4142. dic.Add("ReturnCode", "未录入行程!");
  4143. }
  4144. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4145. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4146. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4147. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4148. {
  4149. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4150. dic.Add("Day", sp.Days.ToString());
  4151. }
  4152. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4153. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4154. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4155. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4156. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4157. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4158. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4159. designer.SetDataSource("Name", Names);
  4160. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4161. designer.SetDataSource("Day", dic["Day"] + "天");
  4162. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4163. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4164. int startIndex = 10;
  4165. const int startIndexcopy = 10;
  4166. if (dac2.Count == dac3.Count)//国家 币种 金额
  4167. {
  4168. for (int i = 0; i < dac2.Count; i++)
  4169. {
  4170. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4171. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4172. }
  4173. }
  4174. DataTable dtdac1 = new DataTable();
  4175. List<string> place = new List<string>();
  4176. dtdac1.Columns.AddRange(new DataColumn[] {
  4177. new DataColumn(){ ColumnName = "city"},
  4178. new DataColumn(){ ColumnName = "curr"},
  4179. new DataColumn(){ ColumnName = "criterion"},
  4180. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4181. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4182. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4183. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4184. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4185. });
  4186. DataTable dtdac2 = new DataTable();
  4187. dtdac2.Columns.AddRange(new DataColumn[] {
  4188. new DataColumn(){ ColumnName = "city"},
  4189. new DataColumn(){ ColumnName = "curr"},
  4190. new DataColumn(){ ColumnName = "criterion"},
  4191. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4192. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4193. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4194. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4195. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4196. });
  4197. dtdac1.TableName = "tb1";
  4198. dtdac2.TableName = "tb2";
  4199. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4200. foreach (var item in dac1)
  4201. {
  4202. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4203. if (place.Contains(item.Place))
  4204. {
  4205. continue;
  4206. }
  4207. DataRow row = dtdac1.NewRow();
  4208. row["city"] = item.Place;
  4209. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4210. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4211. row["curr"] = currency;
  4212. row["rate"] = rate.ToString("#0.0000");
  4213. row["criterion"] = item.Cost.ToString("#0.00");
  4214. row["number"] = 1;
  4215. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4216. //row["costRMB"] = rbmPrice;
  4217. dtdac1.Rows.Add(row);
  4218. place.Add(item.Place);
  4219. }
  4220. place = new List<string>();
  4221. foreach (var item in dac2)
  4222. {
  4223. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4224. if (place.Contains(item.Place))
  4225. {
  4226. continue;
  4227. }
  4228. DataRow row = dtdac2.NewRow();
  4229. row["city"] = item.Place;
  4230. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4231. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4232. row["curr"] = currency;
  4233. row["rate"] = rate.ToString("#0.0000");
  4234. row["criterion"] = item.Cost.ToString("#0.00");
  4235. row["number"] = 1;
  4236. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4237. //row["cost"] = item.SubTotal;
  4238. //row["costRMB"] = rbmPrice;
  4239. dtdac2.Rows.Add(row);
  4240. place.Add(item.Place);
  4241. //dac2totalPrice += rbmPrice;
  4242. }
  4243. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4244. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4245. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4246. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4247. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {enterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4248. designer.SetDataSource("sumCityTranffic", @$"{enterExitCosts.CityTranffic.ToString("#0.00")} ");
  4249. string cell4Str = $" 4.国际旅费:经济舱:{enterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{enterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4250. string cellStr = $" 5.其他费用(";
  4251. if (enterExitCosts.Visa > 0) cellStr += $"签证费:{enterExitCosts.Visa.ToString("#0.00")}元,";
  4252. if (enterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{enterExitCosts.YiMiao.ToString("#0.00")}元,";
  4253. if (enterExitCosts.HeSuan > 0) cellStr += $"核酸费:{enterExitCosts.HeSuan.ToString("#0.00")}元,";
  4254. if (enterExitCosts.Safe > 0) cellStr += $"保险费:{enterExitCosts.Safe.ToString("#0.00")}元,";
  4255. if (enterExitCosts.Ticket > 0) cellStr += $"参展门票费:{enterExitCosts.Ticket.ToString("#0.00")}元,";
  4256. if (enterExitCosts.Service > 0) cellStr += $"服务费:{enterExitCosts.Service.ToString("#0.00")}元,";
  4257. if (cellStr.Length > 8)
  4258. {
  4259. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4260. }
  4261. cellStr += ")";
  4262. decimal otherFee = enterExitCosts.Visa + enterExitCosts.YiMiao + enterExitCosts.HeSuan + enterExitCosts.Safe + enterExitCosts.Ticket + enterExitCosts.Service;
  4263. decimal s = dac1totalPrice + dac2totalPrice + enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay + otherFee;
  4264. decimal pxFee = dac4.Sum(it => it.Cost);
  4265. decimal glvFee = enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay;
  4266. string celllastStr1 = "";
  4267. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4268. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4269. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4270. celllastStr1 += $",国际旅费 元";
  4271. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4272. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4273. designer.SetDataSource("cell4Str", cell4Str);
  4274. designer.SetDataSource("cellStr", cellStr);
  4275. designer.SetDataSource("cellSum", (enterExitCosts.Visa + enterExitCosts.Safe).ToString("#0.00"));
  4276. designer.SetDataSource("cellSum4", (enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay).ToString("#0.00"));
  4277. designer.SetDataSource("celllastStr", celllastStr);
  4278. Workbook wb = designer.Workbook;
  4279. var sheet = wb.Worksheets[0];
  4280. //绑定datatable数据集
  4281. designer.SetDataSource(dtdac1);
  4282. designer.SetDataSource(dtdac2);
  4283. designer.Process();
  4284. var rowStart = dtdac1.Rows.Count;
  4285. while (rowStart > 0)
  4286. {
  4287. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4288. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4289. startIndex++;
  4290. rowStart--;
  4291. }
  4292. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4293. startIndex += 1; //总计行
  4294. rowStart = dtdac2.Rows.Count;
  4295. while (rowStart > 0)
  4296. {
  4297. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4298. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4299. startIndex++;
  4300. rowStart--;
  4301. }
  4302. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4303. wb.CalculateFormula(true);
  4304. //模板文件名
  4305. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls"; ;//$".xls";
  4306. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4307. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4308. _view.Data = new { Url = url };
  4309. _view.Msg = "成功";
  4310. return _view;
  4311. }
  4312. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4313. {
  4314. //获取模板
  4315. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4316. //载入模板
  4317. Document doc = new Document(tempPath);
  4318. DocumentBuilder builder = new DocumentBuilder(doc);
  4319. Dictionary<string, string> dic = new Dictionary<string, string>();
  4320. dic.Add("GroupName", _DelegationInfo.TeamName);
  4321. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4322. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4323. string missionLeaderJob = "";//负责人job
  4324. //int groupNumber = 0; //团人数
  4325. if (DeleClientList.Count > 0)
  4326. {
  4327. missionLeader = DeleClientList[0]?.Name ?? "";
  4328. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4329. }
  4330. dic.Add("MissionLeader", missionLeader); //团负责人
  4331. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4332. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4333. #region MyRegion
  4334. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4335. //{
  4336. // List<string> list = new List<string>();
  4337. // try
  4338. // {
  4339. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4340. // foreach (var item in spilitArr)
  4341. // {
  4342. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4343. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4344. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4345. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4346. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4347. // list.Add(depName);
  4348. // list.Add(arrName);
  4349. // }
  4350. // list = list.Distinct().ToList();
  4351. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4352. // }
  4353. // catch (Exception)
  4354. // {
  4355. // dic.Add("ReturnCode", "行程录入不正确!");
  4356. // }
  4357. //}
  4358. //else
  4359. //{
  4360. // dic.Add("ReturnCode", "未录入行程!");
  4361. //}
  4362. List<string> countrys = _dirRep.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4363. dic.Add("ReturnCode", string.Join("、", countrys));
  4364. #endregion
  4365. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4366. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4367. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4368. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4369. //{
  4370. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4371. // dic.Add("Day", sp.Days.ToString());
  4372. //}
  4373. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4374. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4375. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4376. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4377. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4378. //培训人员名单
  4379. int cultivateRowIndex = 7;
  4380. foreach (var item in DeleClientList)
  4381. {
  4382. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4383. builder.Write(item.Name);
  4384. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4385. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4386. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4387. string birthDay = "";
  4388. if (item.Birthday != null)
  4389. {
  4390. DateTime dt = Convert.ToDateTime(item.Birthday);
  4391. birthDay = $"{dt.Year}.{dt.Month}";
  4392. }
  4393. builder.Write(birthDay);
  4394. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4395. builder.Write(item.Company);
  4396. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4397. builder.Write(item.Job);
  4398. cultivateRowIndex++;
  4399. }
  4400. //删除多余行
  4401. //cultivateRowIndex -= 2;
  4402. int delRows = 10 + 7 - cultivateRowIndex;
  4403. if (delRows > 0)
  4404. {
  4405. for (int i = 0; i < delRows; i++)
  4406. {
  4407. table1.Rows.RemoveAt(cultivateRowIndex);
  4408. //cultivateRowIndex++;
  4409. }
  4410. }
  4411. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4412. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4413. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4414. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4415. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4416. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4417. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4418. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4419. decimal cityTranfficFeeToatal = enterExitCosts.CityTranffic; //城市区间交通费
  4420. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4421. //其他费用
  4422. decimal otherFeeTotal = enterExitCosts.Visa + enterExitCosts.Safe + enterExitCosts.Ticket + enterExitCosts.YiMiao + enterExitCosts.HeSuan + enterExitCosts.Service;
  4423. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4424. //其他费用合计
  4425. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4426. decimal _jjcFeeToatal = enterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4427. decimal _gwcFeeToatal = enterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4428. //公务舱合计
  4429. //国际旅费
  4430. //string outsideJJ = "";
  4431. //string allPriceJJ = "";
  4432. if (enterExitCosts.SumJJC == 1 && enterExitCosts.SumGWC == 0)
  4433. {
  4434. dic.Add("AirFeeTotal", enterExitCosts.AirJJ.ToString("#0.00"));
  4435. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4436. }
  4437. if (enterExitCosts.SumGWC == 1 && enterExitCosts.SumJJC == 0)
  4438. {
  4439. dic.Add("AirFeeTotal", enterExitCosts.AirGW.ToString("#0.00"));
  4440. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4441. }
  4442. if (enterExitCosts.SumJJC == 1 && enterExitCosts.SumGWC == 1)
  4443. {
  4444. string airFeeTotalStr = string.Format(@$"经济舱:{enterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{enterExitCosts.AirGW.ToString("#0.00")}");
  4445. dic.Add("AirFeeTotal", airFeeTotalStr);
  4446. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4447. dic.Add("FeeTotal", feeTotalStr);
  4448. }
  4449. foreach (var key in dic.Keys)
  4450. {
  4451. builder.MoveToBookmark(key);
  4452. builder.Write(dic[key]);
  4453. }
  4454. //模板文件名
  4455. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4456. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4457. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4458. _view.Data = new { Url = url };
  4459. _view.Msg = "成功";
  4460. return _view;
  4461. }
  4462. }
  4463. else if (dto.ExportType == 2) //表格
  4464. {
  4465. //利用键值对存放数据
  4466. Dictionary<string, string> dic = new Dictionary<string, string>();
  4467. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4468. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4469. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4470. dic.Add("Day", sp.Days.ToString());
  4471. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4472. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4473. {
  4474. //获取模板
  4475. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4476. //载入模板
  4477. Document doc = new Document(tempPath);
  4478. DocumentBuilder builder = new DocumentBuilder(doc);
  4479. dic.Add("TeamName", _DelegationInfo.TeamName);
  4480. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4481. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4482. string missionLeaderName = "",
  4483. missionLeaderJob = "";
  4484. if (DeleClientList.Count > 0)
  4485. {
  4486. missionLeaderName = DeleClientList[0].Name;
  4487. missionLeaderJob = DeleClientList[0].Job;
  4488. }
  4489. dic.Add("MissionLeaderName", missionLeaderName);
  4490. dic.Add("MissionLeaderJob", missionLeaderJob);
  4491. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4492. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4493. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4494. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4495. int rowCount = 10;//总人数行
  4496. int startRowIndex = 7; //起始行
  4497. for (int i = 0; i < DeleClientList.Count; i++)
  4498. {
  4499. builder.MoveToCell(0, startRowIndex, 0, 0);
  4500. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4501. builder.MoveToCell(0, startRowIndex, 1, 0);
  4502. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4503. builder.Write(sex);//性别
  4504. builder.MoveToCell(0, startRowIndex, 2, 0);
  4505. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4506. builder.MoveToCell(0, startRowIndex, 3, 0);
  4507. builder.Write(DeleClientList[i].Company);//工作单位
  4508. builder.MoveToCell(0, startRowIndex, 4, 0);
  4509. builder.Write(DeleClientList[i].Job);//职务及级别
  4510. builder.MoveToCell(0, startRowIndex, 5, 0);
  4511. builder.Write("");//人员属性
  4512. builder.MoveToCell(0, startRowIndex, 6, 0);
  4513. builder.Write("");//上次出国时间
  4514. startRowIndex++;
  4515. }
  4516. int nullRow = rowCount - DeleClientList.Count;//空行
  4517. for (int i = 0; i < nullRow; i++)
  4518. {
  4519. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4520. }
  4521. foreach (var key in dic.Keys)
  4522. {
  4523. builder.MoveToBookmark(key);
  4524. builder.Write(dic[key]);
  4525. }
  4526. //模板文件名
  4527. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4528. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4529. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4530. _view.Data = new { Url = url };
  4531. _view.Msg = "成功";
  4532. return _view;
  4533. }
  4534. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4535. {
  4536. //获取模板
  4537. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4538. //载入模板
  4539. Document doc = new Document(tempPath);
  4540. DocumentBuilder builder = new DocumentBuilder(doc);
  4541. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4542. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4543. dic.Add("Names", Names);
  4544. int accommodationRows = 12, foodandotherRows = 12;
  4545. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4546. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4547. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4548. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4549. int accommodationStartIndex = 6;
  4550. decimal dac1totalPrice = 0.00M;
  4551. foreach (var dac in dac1)
  4552. {
  4553. if (dac.SubTotal == 0)
  4554. {
  4555. continue;
  4556. }
  4557. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4558. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4559. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4560. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4561. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4562. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4563. builder.Write(currency);//币种
  4564. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4565. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4566. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4567. builder.Write("");//人数
  4568. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4569. builder.Write("");//天数
  4570. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4571. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4572. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4573. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4574. builder.Write(rate.ToString("#0.0000"));//汇率
  4575. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4576. decimal rbmPrice = rate * dac.SubTotal;
  4577. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4578. accommodationStartIndex++;
  4579. dac1totalPrice += rbmPrice;
  4580. }
  4581. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4582. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4583. builder.Write("小计");
  4584. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4585. builder.Write(dac1totalPrice.ToString("#0.00"));
  4586. accommodationStartIndex++;
  4587. int nullRow = accommodationRows - dac1.Count;
  4588. //删除空行
  4589. //if (nullRow > 0)
  4590. //{
  4591. // int rowIndex = accommodationStartIndex;
  4592. // for (int i = 0; i < nullRow; i++)
  4593. // {
  4594. // Row row = table1.Rows[rowIndex];
  4595. // row.Remove();
  4596. // rowIndex++;
  4597. // }
  4598. //}
  4599. if (dac2.Count == dac3.Count)//国家 币种 金额
  4600. {
  4601. for (int i = 0; i < dac2.Count; i++)
  4602. {
  4603. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4604. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4605. }
  4606. }
  4607. int foodandotherStartIndex = 19;//
  4608. decimal dac2totalPrice = 0.00M;
  4609. foreach (var dac in dac2)
  4610. {
  4611. if (dac.SubTotal == 0)
  4612. {
  4613. continue;
  4614. }
  4615. //foodandotherStartIndex = 12;
  4616. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4617. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4618. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4619. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4620. builder.Write(currency);//币种
  4621. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4622. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4623. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4624. builder.Write("");//人数
  4625. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4626. builder.Write("");//天数
  4627. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4628. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4629. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4630. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4631. builder.Write(rate.ToString("#0.0000"));//汇率
  4632. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4633. decimal rbmPrice = rate * dac.SubTotal;
  4634. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4635. foodandotherStartIndex++;
  4636. dac2totalPrice += rbmPrice;
  4637. }
  4638. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4639. //删除空行
  4640. if (dac2.Count < foodandotherRows)
  4641. {
  4642. //int nullRow = accommodationRows - dac2.Count;
  4643. //while (table2.Rows.Count > dac2.Count)
  4644. //{
  4645. // table2.Rows.RemoveAt(dac2.Count);
  4646. //}
  4647. }
  4648. dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
  4649. string otherFeeStr = "";
  4650. if (enterExitCosts.Visa > 0) otherFeeStr += $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 元,";
  4651. if (enterExitCosts.Safe > 0) otherFeeStr += $"保险费: {enterExitCosts.Safe.ToString("#0.00")} 元,";
  4652. if (enterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {enterExitCosts.Ticket.ToString("#0.00")} 元,";
  4653. if (otherFeeStr.Length > 0)
  4654. {
  4655. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4656. otherFeeStr = $"({otherFeeStr})";
  4657. dic.Add("OtherFeeStr", otherFeeStr);
  4658. }
  4659. foreach (var key in dic.Keys)
  4660. {
  4661. builder.MoveToBookmark(key);
  4662. builder.Write(dic[key]);
  4663. }
  4664. //模板文件名
  4665. string strFileName = $"省级单位出(境)经费报销单.docx";
  4666. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4667. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4668. _view.Data = new { Url = url };
  4669. _view.Msg = "成功";
  4670. return _view;
  4671. }
  4672. }
  4673. else if (dto.ExportType == 3)
  4674. {
  4675. if (dto.SubTypeId == 1) //团组成员名单
  4676. {
  4677. if (DeleClientList.Count < 1)
  4678. {
  4679. _view.Msg = "团组成员暂未录入!!!";
  4680. return _view;
  4681. }
  4682. //获取模板
  4683. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4684. //载入模板
  4685. Document doc = new Document(tempPath);
  4686. DocumentBuilder builder = new DocumentBuilder(doc);
  4687. //获取word里所有表格
  4688. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4689. //获取所填表格的序数
  4690. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4691. var rowStart = tableOne.Rows[0]; //获取第1行
  4692. //循环赋值
  4693. for (int i = 0; i < DeleClientList.Count; i++)
  4694. {
  4695. builder.MoveToCell(0, i + 1, 0, 0);
  4696. builder.Write(DeleClientList[i].Name);
  4697. builder.MoveToCell(0, i + 1, 1, 0);
  4698. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4699. builder.Write(sex);
  4700. builder.MoveToCell(0, i + 1, 2, 0);
  4701. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4702. builder.MoveToCell(0, i + 1, 3, 0);
  4703. builder.Write(DeleClientList[i].Company);
  4704. builder.MoveToCell(0, i + 1, 4, 0);
  4705. builder.Write(DeleClientList[i].Job);
  4706. }
  4707. //删除多余行
  4708. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4709. {
  4710. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4711. }
  4712. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4713. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  4714. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  4715. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4716. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4717. _view.Data = new { Url = url };
  4718. _view.Msg = "成功";
  4719. return _view;
  4720. }
  4721. }
  4722. }
  4723. catch (Exception ex)
  4724. {
  4725. _view.Code = StatusCodes.Status500InternalServerError;
  4726. _view.Msg = ex.Message;
  4727. return _view;
  4728. }
  4729. return _view;
  4730. }
  4731. #endregion
  4732. #endregion
  4733. }
  4734. }