diff --git a/Directory.Build.props b/Directory.Build.props index 64df1da..cf19e11 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ - 1.0.5.08 + 1.0.5.13 9.1.1 diff --git a/services/JiShe.CollectBus.Application/DataChannels/DataChannelManageService.cs b/services/JiShe.CollectBus.Application/DataChannels/DataChannelManageService.cs index c45c242..242a646 100644 --- a/services/JiShe.CollectBus.Application/DataChannels/DataChannelManageService.cs +++ b/services/JiShe.CollectBus.Application/DataChannels/DataChannelManageService.cs @@ -1,5 +1,4 @@ using JiShe.CollectBus.Common; -using JiShe.CollectBus.Common.DeviceBalanceControl; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using System.Diagnostics; diff --git a/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs b/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs index 19fe3d7..ca4e541 100644 --- a/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs +++ b/services/JiShe.CollectBus.Application/Samples/SampleAppService.cs @@ -1,6 +1,5 @@ using JiShe.CollectBus.Ammeters; using JiShe.CollectBus.Common.Consts; -using JiShe.CollectBus.Common.DeviceBalanceControl; using JiShe.CollectBus.Common.Extensions; using JiShe.CollectBus.Common.Helpers; using JiShe.CollectBus.IotSystems.Devices; diff --git a/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs b/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs index 8e04734..1b17916 100644 --- a/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs +++ b/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs @@ -1,6 +1,5 @@ using JiShe.CollectBus.Common; using JiShe.CollectBus.Common.Consts; -using JiShe.CollectBus.Common.DeviceBalanceControl; using JiShe.CollectBus.Common.Enums; using JiShe.CollectBus.Common.Extensions; using JiShe.CollectBus.Common.Models; diff --git a/shared/JiShe.CollectBus.Common/Extensions/DateTimeExtensions.cs b/shared/JiShe.CollectBus.Common/Extensions/DateTimeExtensions.cs deleted file mode 100644 index 2a7f037..0000000 --- a/shared/JiShe.CollectBus.Common/Extensions/DateTimeExtensions.cs +++ /dev/null @@ -1,343 +0,0 @@ -using JiShe.CollectBus.Common.Enums; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; - -namespace JiShe.CollectBus.Common.Extensions -{ - public static class DateTimeExtensions - { - /// - /// Converts a DateTime to a Unix Timestamp - /// - /// This DateTime - /// - [Description("将日期时间转换为Unix时间戳")] - public static double ToUnixTimestamp(this DateTime target) - { - var origin = new DateTime(1970, 1, 1, 0, 0, 0, 0); - var diff = target - origin; - return Math.Floor(diff.TotalSeconds); - } - - /// - /// Converts a Unix Timestamp in to a DateTime - /// - /// This Unix Timestamp - /// - [Description("将Unix时间戳转换为日期时间")] - public static DateTime FromUnixTimestamp(this double unixTime) - { - var epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0); - return epoch.AddSeconds(unixTime); - } - - /// - /// Gets the value of the End of the day (23:59) - /// - /// - /// - [Description("获取一天结束的值(23:59)")] - public static DateTime ToDayEnd(this DateTime target) - { - return target.Date.AddDays(1).AddMilliseconds(-1); - } - - /// - /// Gets the First Date of the week for the specified date - /// - /// this DateTime - /// The Start Day of the Week (ie, Sunday/Monday) - /// The First Date of the week - [Description("获取指定日期的星期的第一个日期")] - public static DateTime StartOfWeek(this DateTime dt, DayOfWeek startOfWeek) - { - var diff = dt.DayOfWeek - startOfWeek; - - if (diff < 0) - diff += 7; - - return dt.AddDays(-1 * diff).Date; - } - - /// - /// Returns all the days of a month. - /// - /// The year. - /// The month. - /// - [Description("获取一个月的所有日期")] - public static IEnumerable DaysOfMonth(int year, int month) - { - return Enumerable.Range(0, DateTime.DaysInMonth(year, month)) - .Select(day => new DateTime(year, month, day + 1)); - } - - /// - /// Determines the Nth instance of a Date's DayOfWeek in a month - /// - /// - /// 11/29/2011 would return 5, because it is the 5th Tuesday of each month - [Description("获取当前日期在一个月的第几个星期")] - public static int WeekDayInstanceOfMonth(this DateTime dateTime) - { - var y = 0; - return DaysOfMonth(dateTime.Year, dateTime.Month) - .Where(date => dateTime.DayOfWeek.Equals(date.DayOfWeek)) - .Select(x => new { n = ++y, date = x }) - .Where(x => x.date.Equals(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day))) - .Select(x => x.n).FirstOrDefault(); - } - - /// - /// Gets the total days in a month - /// - /// The date time. - /// - [Description("获取一个月内的总天数")] - public static int TotalDaysInMonth(this DateTime dateTime) - { - return DaysOfMonth(dateTime.Year, dateTime.Month).Count(); - } - - /// - /// Get the first day in a month - /// - /// The date time. - /// - [Description("获取一个月内的第一天")] - public static DateTime FirstInMonth(this DateTime dateTime) - { - return DateTime.Now.AddDays(1 - DateTime.Now.Day); - } - - /// - /// Get the Last Day in a Month 23:59:59 - /// - /// - /// - [Description("获取一个月内的最后一天 23:59:59")] - public static DateTime LastInMonth(this DateTime dateTime) - { - return DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.AddMonths(1).AddSeconds(-1); - } - - /// - /// Takes any date and returns it's value as an Unspecified DateTime - /// - /// - /// - [Description("获取Unspecified日期")] - public static DateTime ToDateTimeUnspecified(this DateTime date) - { - if (date.Kind == DateTimeKind.Unspecified) - { - return date; - } - - return new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, DateTimeKind.Unspecified); - } - - /// - /// Trims the milliseconds off of a datetime - /// - /// - /// - [Description("将日期时间缩短毫秒")] - public static DateTime TrimMilliseconds(this DateTime date) - { - return new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Kind); - } - - /// - /// Clears the time. - /// - /// The date time. - /// - [Description("清除时间")] - public static DateTime ClearTime(this DateTime dateTime) - { - return dateTime.Subtract( - new TimeSpan( - 0, - dateTime.Hour, - dateTime.Minute, - dateTime.Second, - dateTime.Millisecond - ) - ); - } - - /// - /// 获取数据表分片策略 - /// - /// - /// - public static string GetDataTableShardingStrategy(this DateTime dateTime, TableTimeStrategyEnum tableStrategy) - { - switch (tableStrategy) - { - case TableTimeStrategyEnum.MinuteShardingStrategy: - return $"{dateTime:yyyyMMddHHmm}"; - case TableTimeStrategyEnum.HourShardingStrategy: - return $"{dateTime:yyyyMMddHH}"; - case TableTimeStrategyEnum.DayShardingStrategy: - return $"{dateTime:yyyyMMdd}"; - case TableTimeStrategyEnum.MonthShardingStrategy: - return $"{dateTime:yyyyMM}"; - case TableTimeStrategyEnum.YearShardingStrategy: - return $"{dateTime:yyyy}"; - default: - return $""; // 默认不分表 - - } - } - - - /// - /// 采集时间节点计算 - /// - /// 待采集时间 - /// - /// - public static DateTime CalculateNextCollectionTime(this DateTime referenceTime, int interval) - { - // 计算精确到分钟的基准时间 - var baseTime = new DateTime( - referenceTime.Year, - referenceTime.Month, - referenceTime.Day, - referenceTime.Hour, - referenceTime.Minute, - 0); - - // 计算总分钟数和下一个间隔点 - int totalMinutes = baseTime.Hour * 60 + baseTime.Minute; - int nextTotalMinutes = ((totalMinutes / interval) + 1) * interval; - - // 处理跨天情况 - int daysToAdd = nextTotalMinutes / (24 * 60); - int remainingMinutes = nextTotalMinutes % (24 * 60); - int hours = remainingMinutes / 60; - int minutes = remainingMinutes % 60; - - return baseTime.Date - .AddDays(daysToAdd) - .AddHours(hours) - .AddMinutes(minutes); - } - - - /// - /// 格式化为微秒(μs) - /// - /// - /// - public static string ToMicrosecondString(this DateTime dt) - { - long microseconds = (dt.Ticks % TimeSpan.TicksPerSecond) / 10; // 1 Tick = 100ns → 0.1μs - return $"{dt:yyyy-MM-dd HH:mm:ss.fffffff}".Remove(23) + $"{microseconds:D6}"; - } - - /// - /// 格式化为纳秒(ns) - /// - /// - /// - public static string ToNanosecondString(this DateTime dt) - { - long nanoseconds = (dt.Ticks % TimeSpan.TicksPerSecond) * 100; // 1 Tick = 100ns - return $"{dt:yyyy-MM-dd HH:mm:ss.fffffff}".Remove(23) + $"{nanoseconds:D9}"; - } - - /// - /// 毫米、微秒、纳秒时间戳转DateTime - /// - /// - /// - /// - public static DateTime ParseIntToDate(this long dateLong) - { - if (dateLong < 10000101 || dateLong > 99991231) - { - throw new ArgumentException("Date must be between 10000101 and 99991231."); - } - return DateTime.TryParseExact(dateLong.ToString(), "yyyyMMdd HHmmssZZ", null, System.Globalization.DateTimeStyles.None, out DateTime date) ? date : throw new ArgumentException("Date must be between 10000101 and 99991231."); - } - - - /// - /// 取得某月的第一天 - /// - /// 要取得月份第一天的时间 - /// - public static DateTime FirstDayOfMonth(this DateTime datetime) - { - return datetime.AddDays(1 - datetime.Day); - } - - /// - /// 取得某月的最后一天 - /// - /// 要取得月份最后一天的时间 - /// - public static DateTime LastDayOfMonth(this DateTime datetime) - { - return datetime.AddDays(1 - datetime.Day).AddMonths(1).AddDays(-1); - } - - /// - /// 取得上个月第一天 - /// - /// 要取得上个月第一天的当前时间 - /// - public static DateTime FirstDayOfPreviousMonth(this DateTime datetime) - { - return datetime.AddDays(1 - datetime.Day).AddMonths(-1); - } - - /// - /// 取得上个月的最后一天 - /// - /// 要取得上个月最后一天的当前时间 - /// - public static DateTime LastDayOfPrdviousMonth(this DateTime datetime) - { - return datetime.AddDays(1 - datetime.Day).AddDays(-1); - } - - - /// - /// 取得某月第一天0点以及最后一天的23:59:59时间范围 - /// - /// - /// - public static Tuple GetMonthDateRange(this DateTime datetime) - { - var lastDayOfMonthDate = LastDayOfMonth(datetime); - return new Tuple(datetime.FirstDayOfMonth(), new DateTime(lastDayOfMonthDate.Year, lastDayOfMonthDate.Month, lastDayOfMonthDate.Day, 23, 59, 59)); - } - - /// - /// 取得某一天0点到当月最后一天的23:59:59时间范围 - /// - /// - /// - public static Tuple GetCurrentDateToLastDayRange(this DateTime datetime) - { - var lastDayOfMonthDate = LastDayOfMonth(datetime); - return new Tuple(datetime.Date, new DateTime(lastDayOfMonthDate.Year, lastDayOfMonthDate.Month, lastDayOfMonthDate.Day, 23, 59, 59)); - } - - /// - /// 取得某一天0点到23:59:59时间范围 - /// - /// - /// - public static Tuple GetCurrentDateRange(this DateTime datetime) - { - return new Tuple(datetime.Date, new DateTime(datetime.Year, datetime.Month, datetime.Day, 23, 59, 59)); - } - } -} diff --git a/web/JiShe.CollectBus.Host/appsettings.Production.json b/web/JiShe.CollectBus.Host/appsettings.Production.json index 93b480c..c71f8b6 100644 --- a/web/JiShe.CollectBus.Host/appsettings.Production.json +++ b/web/JiShe.CollectBus.Host/appsettings.Production.json @@ -1,11 +1,11 @@ { "ConnectionStrings": { - "Default": "mongodb://admin:4mFmPTTB8tn6aI@47.110.62.104:27017,47.110.53.196:27017,47.110.60.222:27017/JiSheCollectBus?authSource=admin&maxPoolSize=400&minPoolSize=10&waitQueueTimeoutMS=5000", + "Default": "", "PrepayDB": "server=rm-m5el3d1u1k0wzk70n2o.sqlserver.rds.aliyuncs.com,3433;database=jishe.sysdb;uid=v3sa;pwd=JiShe123;Encrypt=False;Trust Server Certificate=False", "EnergyDB": "server=rm-wz9hw529i3j1e3b5fbo.sqlserver.rds.aliyuncs.com,3433;database=db_energy;uid=yjdb;pwd=Kdjdhf+9*7ad222LL;Encrypt=False;Trust Server Certificate=False" }, "FreeRedisOptions": { - "ConnectionString": "47.110.53.196:6379,password=1q3J@BGf!yhTaD46nS#,syncTimeout=30000,abortConnect=false,connectTimeout=30000,allowAdmin=true,maxPoolSize=50,defaultdatabase=14", + "ConnectionString": "172.21.40.197:6379,password=1q3J@BGf!yhTaD46nS#,syncTimeout=30000,abortConnect=false,connectTimeout=30000,allowAdmin=true,maxPoolSize=50,defaultdatabase=14", "UseDistributedCache": true }, "FreeSqlProviderOptions": { @@ -14,7 +14,7 @@ "PrintLog": true }, "Kafka": { - "BootstrapServers": "47.110.62.104:9094,47.110.53.196:9094,47.110.60.222:9094", + "BootstrapServers": "172.21.40.198:9092,172.21.40.197:9092,172.21.40.199:9092", "EnableFilter": true, "EnableAuthorization": false, "SaslUserName": "lixiao", @@ -26,8 +26,8 @@ "IoTDBOptions": { "UserName": "root", "Password": "Lixiao@1980", - "TreeModelClusterList": [ "47.110.53.196:6667", "47.110.60.222:6667", "47.110.62.104:6667" ], - "TableModelClusterList": [ "47.110.53.196:6667", "47.110.60.222:6667", "47.110.62.104:6667" ], + "TreeModelClusterList": [ "172.21.40.198:6667", "172.21.40.197:6667", "172.21.40.199:6667" ], + "TableModelClusterList": [ "172.21.40.198:6667", "172.21.40.197:6667", "172.21.40.199:6667" ], "PoolSize": 32, "TableModelDataBaseName": "energy", "OpenDebugMode": true, diff --git a/web/JiShe.CollectBus.Host/appsettings.json b/web/JiShe.CollectBus.Host/appsettings.json index efc776d..fde49e3 100644 --- a/web/JiShe.CollectBus.Host/appsettings.json +++ b/web/JiShe.CollectBus.Host/appsettings.json @@ -1,7 +1,6 @@ { "ConnectionStrings": { - "Default": "mongodb://mongo_PmEeF3:lixiao1980@192.168.5.9:27017/JiSheCollectBus?authSource=admin&maxPoolSize=400&minPoolSize=10&waitQueueTimeoutMS=5000", - "Kafka": "192.168.5.9:29092,192.168.5.9:39092,192.168.5.9:49092", + "Default": "", "PrepayDB": "server=118.190.144.92;database=jishe.sysdb;uid=sa;pwd=admin@2023;Encrypt=False;Trust Server Certificate=False", "EnergyDB": "server=118.190.144.92;database=db_energy;uid=sa;pwd=admin@2023;Encrypt=False;Trust Server Certificate=False" },