From 4ce1741f7e26def24d7391ac467aba603888d392 Mon Sep 17 00:00:00 2001 From: ChenYi <296215406@outlook.com> Date: Tue, 20 May 2025 21:55:48 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BasicScheduledMeterReadingService.cs | 236 +++++++++--------- .../Extensions/DateTimeExtensions.cs | 74 ++++++ .../Helpers/CommonHelper.cs | 52 +--- 3 files changed, 198 insertions(+), 164 deletions(-) diff --git a/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs b/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs index a4bee34..38166c7 100644 --- a/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs +++ b/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs @@ -137,115 +137,99 @@ namespace JiShe.CollectBus.ScheduledMeterReading //电表定时广播校时,一天一次。 string currentTimeStr = $"{currentTime:HH:mm:00}"; - //if (string.Equals(currentTimeStr, _applicationOptions.AutomaticVerificationTime, StringComparison.CurrentCultureIgnoreCase))//自动校时 - //{ - // //_logger.LogInformation($"{nameof(AmmeterScheduledAutomaticVerificationTime)} 电表自动校时,非自动校时时间"); - // //return; + if (string.Equals(currentTimeStr, _applicationOptions.AutomaticVerificationTime, StringComparison.CurrentCultureIgnoreCase))//自动校时 + { + //_logger.LogInformation($"{nameof(AmmeterScheduledAutomaticVerificationTime)} 电表自动校时,非自动校时时间"); + //return; - // _ = CreateMeterPublishTask( - // timeDensity: timeDensity, - // nextTaskTime: currentTime, - // meterType: MeterTypeEnum.Ammeter, - // taskCreateAction: async (timeDensity, data, groupIndex, timestamps) => - // { - // var tempTask = await AmmeterScheduledAutomaticVerificationTime(timeDensity, data, groupIndex, timestamps); - - // if (tempTask == null || tempTask.Count <= 0) - // { - // _logger.LogWarning($"电表自动校时 {data.Name} 任务数据构建失败:{data.Serialize()}"); - // return; - // } - // _ = _dataChannelManage.ScheduledMeterTaskWriterAsync(DataChannelManage.TaskDataChannel.Writer, (ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, tempTask)); - // }); - //} - //else if (string.Equals(currentTimeStr, _applicationOptions.AutomaticTerminalVersionTime, StringComparison.CurrentCultureIgnoreCase))//集中器版本号读取 - //{ - // _ = CreateMeterPublishTask( - // timeDensity: timeDensity, - // nextTaskTime: currentTime, - // meterType: MeterTypeEnum.Ammeter, - // taskCreateAction: async (timeDensity, data, groupIndex, timestamps) => - // { - // var tempTask = await ConcentratorScheduledAutomaticGetTerminalVersion(timeDensity, data, groupIndex, timestamps); - // if (tempTask == null || tempTask.Count <= 0) - // { - // _logger.LogWarning($"集中器终端版本信息 {data.Name} 任务数据构建失败:{data.Serialize()}"); - // return; - // } - // _ = _dataChannelManage.ScheduledMeterTaskWriterAsync(DataChannelManage.TaskDataChannel.Writer, (ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, tempTask)); - // }); - //} - //else if (string.Equals(currentTimeStr, _applicationOptions.AutomaticTelematicsModuleTime, StringComparison.CurrentCultureIgnoreCase))//SIM卡读取 - //{ - // _ = CreateMeterPublishTask( - // timeDensity: timeDensity, - // nextTaskTime: currentTime, - // meterType: MeterTypeEnum.Ammeter, - // taskCreateAction: async (timeDensity, data, groupIndex, timestamps) => - // { - // var tempTask = await ConcentratorScheduledAutomaticGetTelematicsModule(timeDensity, data, groupIndex, timestamps); - // if (tempTask == null || tempTask.Count <= 0) - // { - // _logger.LogWarning($"集中器SIM卡读取 {data.Name} 任务数据构建失败:{data.Serialize()}"); - // return; - // } - // _ = _dataChannelManage.ScheduledMeterTaskWriterAsync(DataChannelManage.TaskDataChannel.Writer, (ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, tempTask)); - // }); - //} - //else if (string.Equals(currentTimeStr, _applicationOptions.AutomaticTelematicsModuleTime, StringComparison.CurrentCultureIgnoreCase))//月冻结 - //{ - // _ = CreateMeterPublishTask( - // timeDensity: timeDensity, - // nextTaskTime: currentTime, - // meterType: MeterTypeEnum.Ammeter, - // taskCreateAction: async (timeDensity, data, groupIndex, timestamps) => - // { - // var tempTask = await AmmeterScheduledGetAutomaticDayFreezeData(timeDensity, data, groupIndex, timestamps); - // if (tempTask == null || tempTask.Count <= 0) - // { - // _logger.LogWarning($"电表月冻结 {data.Name} 任务数据构建失败:{data.Serialize()}"); - // return; - // } - // _ = _dataChannelManage.ScheduledMeterTaskWriterAsync(DataChannelManage.TaskDataChannel.Writer, (ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, tempTask)); - // }); - //} - //else if (string.Equals(currentTimeStr, _applicationOptions.AutomaticDayFreezeTime, StringComparison.CurrentCultureIgnoreCase))//日冻结 - //{ - // _ = CreateMeterPublishTask( - // timeDensity: timeDensity, - // nextTaskTime: currentTime, - // meterType: MeterTypeEnum.Ammeter, - // taskCreateAction: async (timeDensity, data, groupIndex, timestamps) => - // { - // var tempTask = await AmmeterScheduledGetAutomaticMonthFreezeData(timeDensity, data, groupIndex, timestamps); - // if (tempTask == null || tempTask.Count <= 0) - // { - // _logger.LogWarning($"电表日冻结 {data.Name} 任务数据构建失败:{data.Serialize()}"); - // return; - // } - // _ = _dataChannelManage.ScheduledMeterTaskWriterAsync(DataChannelManage.TaskDataChannel.Writer, (ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, tempTask)); - // }); - //} - //else - //{ - // _logger.LogInformation($"{nameof(CreateToBeIssueTasks)} 不是自动校时、采集终端信息等时间,继续处理其他"); - //} - - - _ = CreateMeterPublishTask( - timeDensity: timeDensity, - nextTaskTime: currentTime, - meterType: MeterTypeEnum.Ammeter, - taskCreateAction: async (timeDensity, data, groupIndex, timestamps) => - { - var tempTask = await ConcentratorScheduledAutomaticGetTelematicsModule(timeDensity, data, groupIndex, timestamps); - if (tempTask == null || tempTask.Count <= 0) + _ = CreateMeterPublishTask( + timeDensity: timeDensity, + nextTaskTime: currentTime, + meterType: MeterTypeEnum.Ammeter, + taskCreateAction: async (timeDensity, data, groupIndex, timestamps) => { - _logger.LogWarning($"集中器SIM卡读取 {data.Name} 任务数据构建失败:{data.Serialize()}"); - return; - } - _ = _dataChannelManage.ScheduledMeterTaskWriterAsync(DataChannelManage.TaskDataChannel.Writer, (ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, tempTask)); - }); + var tempTask = await AmmeterScheduledAutomaticVerificationTime(timeDensity, data, groupIndex, timestamps); + + if (tempTask == null || tempTask.Count <= 0) + { + _logger.LogWarning($"电表自动校时 {data.Name} 任务数据构建失败:{data.Serialize()}"); + return; + } + _ = _dataChannelManage.ScheduledMeterTaskWriterAsync(DataChannelManage.TaskDataChannel.Writer, (ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, tempTask)); + }); + } + else if (string.Equals(currentTimeStr, _applicationOptions.AutomaticTerminalVersionTime, StringComparison.CurrentCultureIgnoreCase))//集中器版本号读取 + { + _ = CreateMeterPublishTask( + timeDensity: timeDensity, + nextTaskTime: currentTime, + meterType: MeterTypeEnum.Ammeter, + taskCreateAction: async (timeDensity, data, groupIndex, timestamps) => + { + var tempTask = await ConcentratorScheduledAutomaticGetTerminalVersion(timeDensity, data, groupIndex, timestamps); + if (tempTask == null || tempTask.Count <= 0) + { + _logger.LogWarning($"集中器终端版本信息 {data.Name} 任务数据构建失败:{data.Serialize()}"); + return; + } + _ = _dataChannelManage.ScheduledMeterTaskWriterAsync(DataChannelManage.TaskDataChannel.Writer, (ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, tempTask)); + }); + } + else if (string.Equals(currentTimeStr, _applicationOptions.AutomaticTelematicsModuleTime, StringComparison.CurrentCultureIgnoreCase))//SIM卡读取 + { + _ = CreateMeterPublishTask( + timeDensity: timeDensity, + nextTaskTime: currentTime, + meterType: MeterTypeEnum.Ammeter, + taskCreateAction: async (timeDensity, data, groupIndex, timestamps) => + { + var tempTask = await ConcentratorScheduledAutomaticGetTelematicsModule(timeDensity, data, groupIndex, timestamps); + if (tempTask == null || tempTask.Count <= 0) + { + _logger.LogWarning($"集中器SIM卡读取 {data.Name} 任务数据构建失败:{data.Serialize()}"); + return; + } + _ = _dataChannelManage.ScheduledMeterTaskWriterAsync(DataChannelManage.TaskDataChannel.Writer, (ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, tempTask)); + }); + } + else if (string.Equals(currentTimeStr, _applicationOptions.AutomaticMonthFreezeTime, StringComparison.CurrentCultureIgnoreCase))//月冻结 + { + _ = CreateMeterPublishTask( + timeDensity: timeDensity, + nextTaskTime: currentTime, + meterType: MeterTypeEnum.Ammeter, + taskCreateAction: async (timeDensity, data, groupIndex, timestamps) => + { + var tempTask = await AmmeterScheduledGetAutomaticMonthFreezeData(timeDensity, data, groupIndex, timestamps); + if (tempTask == null || tempTask.Count <= 0) + { + _logger.LogWarning($"电表月冻结 {data.Name} 任务数据构建失败:{data.Serialize()}"); + return; + } + _ = _dataChannelManage.ScheduledMeterTaskWriterAsync(DataChannelManage.TaskDataChannel.Writer, (ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, tempTask)); + }); + } + else if (string.Equals(currentTimeStr, _applicationOptions.AutomaticDayFreezeTime, StringComparison.CurrentCultureIgnoreCase))//日冻结 + { + _ = CreateMeterPublishTask( + timeDensity: timeDensity, + nextTaskTime: currentTime, + meterType: MeterTypeEnum.Ammeter, + taskCreateAction: async (timeDensity, data, groupIndex, timestamps) => + { + var tempTask = await AmmeterScheduledGetAutomaticDayFreezeData(timeDensity, data, groupIndex, timestamps); + if (tempTask == null || tempTask.Count <= 0) + { + _logger.LogWarning($"电表日冻结 {data.Name} 任务数据构建失败:{data.Serialize()}"); + return; + } + _ = _dataChannelManage.ScheduledMeterTaskWriterAsync(DataChannelManage.TaskDataChannel.Writer, (ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, tempTask)); + }); + } + else + { + _logger.LogInformation($"{nameof(CreateToBeIssueTasks)} 不是自动校时、采集终端信息等时间,继续处理其他"); + } @@ -933,7 +917,13 @@ namespace JiShe.CollectBus.ScheduledMeterReading { FocusAddress = ammeterInfo.FocusAddress, Pn = ammeterInfo.MeteringCode, - ItemCode = item + ItemCode = item, + DataTimeMark = new Protocol.DataTimeMark() + { + Density = ammeterInfo.TimeDensity.GetFocusDensity(),//转换成协议的值 + Point = 1, + DataTime = currentTime.AddDays(-1),//日冻结抄读时间为昨天 + }, }); var meterReadingRecords = CreateAmmeterPacketInfo( @@ -978,12 +968,22 @@ namespace JiShe.CollectBus.ScheduledMeterReading { var currentTime = DateTime.Now; string currentTimeStr = $"{currentTime:HH:mm:00}"; - + try { - #if DEBUG #else + //需要检查是不是每月1号抄读上个月的数据 + if (currentTime.Date != currentTime.FirstDayOfMonth().Date) + { + _logger.LogInformation($"{nameof(AmmeterScheduledGetAutomaticMonthFreezeData)} 非月冻结数据抄读时间,暂不处理"); + return null; + } + else + { + timestamps = currentTime.LastDayOfPrdviousMonth(); + } + //判断是否是月冻结数据抄读 if (!string.Equals(currentTimeStr, _applicationOptions.AutomaticMonthFreezeTime, StringComparison.CurrentCultureIgnoreCase)) { @@ -1002,13 +1002,23 @@ namespace JiShe.CollectBus.ScheduledMeterReading return null; } - foreach (var item in DayFreezeCodes) + foreach (var item in MonthFreezeCodes) { ProtocolBuildResponse builderResponse = await protocolPlugin.BuildAsync(new ProtocolBuildRequest() { FocusAddress = ammeterInfo.FocusAddress, Pn = ammeterInfo.MeteringCode, - ItemCode = item + ItemCode = item, + DataTimeMark = new Protocol.DataTimeMark() + { + Density = ammeterInfo.TimeDensity.GetFocusDensity(),//转换成协议的值 + Point = 1, +#if DEBUG + DataTime = currentTime.AddMonths(-1),//月冻结抄读时间为上个月 +#else + DataTime = timestamps,//月冻结抄读时间为上个月 +#endif + }, }); var meterReadingRecords = CreateAmmeterPacketInfo( @@ -1108,7 +1118,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading } } - #endregion +#endregion #region 水表采集处理 diff --git a/shared/JiShe.CollectBus.Common/Extensions/DateTimeExtensions.cs b/shared/JiShe.CollectBus.Common/Extensions/DateTimeExtensions.cs index 3254edc..2a7f037 100644 --- a/shared/JiShe.CollectBus.Common/Extensions/DateTimeExtensions.cs +++ b/shared/JiShe.CollectBus.Common/Extensions/DateTimeExtensions.cs @@ -265,5 +265,79 @@ namespace JiShe.CollectBus.Common.Extensions } 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/shared/JiShe.CollectBus.Common/Helpers/CommonHelper.cs b/shared/JiShe.CollectBus.Common/Helpers/CommonHelper.cs index e6cbafd..a7a65c6 100644 --- a/shared/JiShe.CollectBus.Common/Helpers/CommonHelper.cs +++ b/shared/JiShe.CollectBus.Common/Helpers/CommonHelper.cs @@ -136,57 +136,7 @@ namespace JiShe.CollectBus.Common.Helpers return objModel; } - /// - /// 取得某月的第一天 - /// - /// 要取得月份第一天的时间 - /// - 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); - } - - /// - /// 取得某月第一天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)); - } + /// /// 获取指定枚举的所有 Attribute 说明以及value组成的键值对 From 5d7e7bd7ed0f97f5b12fe882bd7f137161e83e92 Mon Sep 17 00:00:00 2001 From: Dai Mr <1822802785@qq.com> Date: Wed, 21 May 2025 09:16:01 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=BA=E6=9C=AC=E5=9C=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/JiShe.CollectBus.Host/appsettings.Production.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/JiShe.CollectBus.Host/appsettings.Production.json b/web/JiShe.CollectBus.Host/appsettings.Production.json index 41b027b..23af53e 100644 --- a/web/JiShe.CollectBus.Host/appsettings.Production.json +++ b/web/JiShe.CollectBus.Host/appsettings.Production.json @@ -23,8 +23,10 @@ }, "IoTDBOptions": { "UserName": "root", - "Password": "Yp2eU6MVdIjXCL", - "ClusterList": [ "47.110.53.196:6667", "47.110.60.222:6667", "47.110.62.104:6667" ], + //"Password": "Yp2eU6MVdIjXCL", + //"ClusterList": [ "47.110.53.196:6667", "47.110.60.222:6667", "47.110.62.104:6667" ], + "Password": "root", + "ClusterList": [ "121.42.175.177:16667" ], "PoolSize": 2, "DataBaseName": "energy", "OpenDebugMode": true, From ee1f3e3ca9b4b2ebe7160cd5c96036214c906f5a Mon Sep 17 00:00:00 2001 From: Dai Mr <1822802785@qq.com> Date: Wed, 21 May 2025 10:01:19 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/JiShe.CollectBus.Host/appsettings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/JiShe.CollectBus.Host/appsettings.json b/web/JiShe.CollectBus.Host/appsettings.json index fe2bcf9..4d07d2a 100644 --- a/web/JiShe.CollectBus.Host/appsettings.json +++ b/web/JiShe.CollectBus.Host/appsettings.json @@ -26,7 +26,7 @@ "IoTDBOptions": { "UserName": "root", "Password": "root", - "ClusterList": [ "192.168.5.9:6667" ], + "ClusterList": [ "121.42.175.177:16667" ], "PoolSize": 32, "DataBaseName": "energy", "OpenDebugMode": true, From 6bc3b31f81215b29ea231431e0cbbf570084a5ff Mon Sep 17 00:00:00 2001 From: ChenYi <296215406@outlook.com> Date: Wed, 21 May 2025 10:14:33 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=9A=82=E5=AD=98=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../T1882018ProtocolPlugin.cs | 2 +- .../BasicScheduledMeterReadingService.cs | 16 +++----- ...nergySystemScheduledMeterReadingService.cs | 37 ++++++++++++++++++- .../IotSystems/Devices/DeviceInfo.cs | 11 +----- 4 files changed, 44 insertions(+), 22 deletions(-) diff --git a/protocols/JiShe.CollectBus.Protocol.T1882018/T1882018ProtocolPlugin.cs b/protocols/JiShe.CollectBus.Protocol.T1882018/T1882018ProtocolPlugin.cs index 5b3044a..7b0edbe 100644 --- a/protocols/JiShe.CollectBus.Protocol.T1882018/T1882018ProtocolPlugin.cs +++ b/protocols/JiShe.CollectBus.Protocol.T1882018/T1882018ProtocolPlugin.cs @@ -31,7 +31,7 @@ namespace JiShe.CollectBus.Protocol.T1882018 T188ControlHandlers = Telemetry1882018PacketBuilder.T1882018ControlHandlers; } - public sealed override ProtocolInfo Info => new(nameof(T1882018ProtocolPlugin), "376.1/188-2018", "TCP", "376.1/188-2018协议", "HJ-LXS-15 DN15"); + public sealed override ProtocolInfo Info => new(nameof(T1882018ProtocolPlugin), "376.1/188-2018", "TCP", "376.1/188-2018协议", "云集"); public override async Task AnalyzeAsync(ITcpSessionClient client, string messageReceived, Action? sendAction = null) { diff --git a/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs b/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs index 38166c7..e4a8843 100644 --- a/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs +++ b/services/JiShe.CollectBus.Application/ScheduledMeterReading/BasicScheduledMeterReadingService.cs @@ -230,9 +230,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading { _logger.LogInformation($"{nameof(CreateToBeIssueTasks)} 不是自动校时、采集终端信息等时间,继续处理其他"); } - - - + //检查任务时间节点,由于定时任务10秒钟运行一次,需要判定当前时间是否在任务时间节点内,不在则跳过 var currentTaskTime = tasksToBeIssueModel.LastTaskTime.CalculateNextCollectionTime(timeDensity);//程序启动缓存电表的时候,NextTaskTime需要格式化到下一个采集点时间。 if (!IsTaskTime(currentTaskTime, timeDensity))//todo 如果时间超过两个采集频率周期,就一直处理,直到追加到下一个采集频率周期。 @@ -242,9 +240,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading } var meterTypes = EnumExtensions.ToEnumDictionary(); - - //tasksToBeIssueModel.NextTaskTime; - + if (meteryType == MeterTypeEnum.Ammeter.ToString()) { _ = CreateMeterPublishTask( @@ -256,7 +252,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading var tempTask = await AmmerterCreatePublishTaskAction(timeDensity, data, groupIndex, timestamps); if (tempTask == null || tempTask.Count <= 0) { - //_logger.LogWarning($"电表 {data.Name} 任务数据构建失败:{data.Serialize()}"); + _logger.LogWarning($"电表 {data.Name} 任务数据构建失败:{data.Serialize()}"); return; } _ = _dataChannelManage.ScheduledMeterTaskWriterAsync(DataChannelManage.TaskDataChannel.Writer, (ProtocolConst.AmmeterSubscriberWorkerFifteenMinuteIssuedEventName, tempTask)); @@ -1280,14 +1276,14 @@ namespace JiShe.CollectBus.ScheduledMeterReading { timeDensity = watermeter.TimeDensity;//水表默认为60分钟 typeName = watermeter.LinkType; - if (watermeter.MeterBrand.Contains("泉高阀门") || watermeter.MeterBrand.Equals("LXSY-山水翔")) + if (watermeter.BrandType.Contains("泉高阀门") || watermeter.BrandType.Equals("LXSY-山水翔")) { - typeName = watermeter.MeterBrand; + typeName = watermeter.BrandType; } } else if (watermeter.MeterType == MeterTypeEnum.WaterMeterFlowmeter) { - typeName = watermeter.MeterBrand; + typeName = watermeter.BrandType; } else { diff --git a/services/JiShe.CollectBus.Application/ScheduledMeterReading/EnergySystemScheduledMeterReadingService.cs b/services/JiShe.CollectBus.Application/ScheduledMeterReading/EnergySystemScheduledMeterReadingService.cs index 7c9df0c..c5fb86b 100644 --- a/services/JiShe.CollectBus.Application/ScheduledMeterReading/EnergySystemScheduledMeterReadingService.cs +++ b/services/JiShe.CollectBus.Application/ScheduledMeterReading/EnergySystemScheduledMeterReadingService.cs @@ -560,7 +560,39 @@ namespace JiShe.CollectBus.ScheduledMeterReading { try { - string sql = $@"SELECT +#if DEBUG + var redisCacheDeviceInfoHashKeyTemp = $"CollectBus:Energy:JiSheCollectBus109:DeviceInfo"; + + List deviceInfos = FreeRedisProvider.Instance.Get>(redisCacheDeviceInfoHashKeyTemp); + + if (deviceInfos == null || deviceInfos.Count <= 0) + { + deviceInfos = new List(); + deviceInfos.Add(new DeviceInfo() + { + Baudrate = 2400, + FocusAddress = "322011149", + Name = "LXSY-25E 保利", + FocusId = 57675, + DatabaseBusiID = 1, + MeteringCode = 0, + MeterAddress = "341587000473", + MeterId = 1025, + TypeName = 1, + TimeDensity = 60, + BrandType = "云集", + MeterType = MeterTypeEnum.WaterMeter, + ProjectID = 1, + MeteringPort = MeteringPortConst.MeteringPortTwo, + Password = "000000", + LinkType = "RS-485", + TimesRate = 1.0000m, + }); + } + + return deviceInfos; +#else + string sql = $@"SELECT A.ID as MeterId, A.Name, A.FocusID as FocusId, @@ -575,7 +607,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading A.LinkType, A.HaveValve, A.MeterType AS MeterTypeName, - A.MeterBrand, + A.MeterBrand AS BrandType, A.TimesRate, A.TimeDensity, A.TripState, @@ -602,6 +634,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading return await SqlProvider.Instance.Change(DbEnum.EnergyDB) .Ado .QueryAsync(sql); +#endif } catch (Exception) { diff --git a/services/JiShe.CollectBus.Domain/IotSystems/Devices/DeviceInfo.cs b/services/JiShe.CollectBus.Domain/IotSystems/Devices/DeviceInfo.cs index 61fe6f5..11145a7 100644 --- a/services/JiShe.CollectBus.Domain/IotSystems/Devices/DeviceInfo.cs +++ b/services/JiShe.CollectBus.Domain/IotSystems/Devices/DeviceInfo.cs @@ -46,14 +46,7 @@ namespace JiShe.CollectBus.IotSystems.Devices /// 设备类型: 水表\气表、流量计 /// public string MeterTypeName { get; set; } - - /// - /// 设备品牌; - /// (当 MeterType = 水表, 如 威铭、捷先 等) - /// (当 MeterType = 流量计, 如 西恩超声波流量计、西恩电磁流量计、涡街流量计 等) - /// - public string MeterBrand { get; set; } - + /// /// 倍率 /// @@ -75,7 +68,7 @@ namespace JiShe.CollectBus.IotSystems.Devices public string AreaCode { get; set; } /// - /// 电表类别 (1单相、2三相三线、3三相四线), + /// 仅当MeterType为电表时,电表类别 (1单相、2三相三线、3三相四线), /// 07协议: 开合闸指令(1A开闸断电,1C单相表合闸,1B多相表合闸) 645 2007 表 /// 97协议://true(合闸);false(跳闸) 545 1997 没有单相多相 之分 "true" ? "9966" : "3355" ///