GeneralMethod.cs 262 KB

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