Compare commits
No commits in common. "653c9b1fc83f41a75f79287728444c1f4c4140e4" and "355aad3ee5f242d7bdeb795857ed7b55a0baed50" have entirely different histories.
653c9b1fc8
...
355aad3ee5
@ -1,5 +1,4 @@
|
|||||||
using JiShe.CollectBus.Common.Consts;
|
using JiShe.CollectBus.Common.Enums;
|
||||||
using JiShe.CollectBus.Common.Enums;
|
|
||||||
using JiShe.CollectBus.Common.Extensions;
|
using JiShe.CollectBus.Common.Extensions;
|
||||||
using JiShe.CollectBus.Common.Models;
|
using JiShe.CollectBus.Common.Models;
|
||||||
using JiShe.CollectBus.IotSystems.Protocols;
|
using JiShe.CollectBus.IotSystems.Protocols;
|
||||||
@ -90,8 +89,8 @@ namespace JiShe.CollectBus.Protocol.T6452007
|
|||||||
Telemetry3761PacketResponse builderResponse = null;
|
Telemetry3761PacketResponse builderResponse = null;
|
||||||
|
|
||||||
List<string> dataUnit = new List<string>();
|
List<string> dataUnit = new List<string>();
|
||||||
//数据转发场景 10H_F1
|
//数据转发场景 10H_F1_1CH
|
||||||
if (request.ItemCode == T37612012PacketItemCodeConst.AFN10HFN01H && request.SubProtocolRequest != null && string.IsNullOrWhiteSpace(request.SubProtocolRequest.ItemCode) == false)
|
if (aFNStr == "10" && request.SubProtocolRequest != null && string.IsNullOrWhiteSpace(request.SubProtocolRequest.ItemCode) == false)
|
||||||
{
|
{
|
||||||
var t645PacketHandlerName = $"C{request.SubProtocolRequest.ItemCode}_Send";
|
var t645PacketHandlerName = $"C{request.SubProtocolRequest.ItemCode}_Send";
|
||||||
Telemetry6452007PacketResponse t645PacketResponse = null;
|
Telemetry6452007PacketResponse t645PacketResponse = null;
|
||||||
|
|||||||
@ -82,6 +82,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region 水表采集处理
|
#region 水表采集处理
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取水表信息
|
/// 获取水表信息
|
||||||
@ -105,29 +106,6 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 集中器处理
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 自动获取终端版
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="timeDensity">采集频率</param>
|
|
||||||
/// <param name="ammeterInfo">电表信息</param>
|
|
||||||
/// <param name="groupIndex">集中器所在分组</param>
|
|
||||||
/// <param name="timestamps">采集频率对应的时间戳</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task ConcentratorScheduledAutomaticGetTerminalVersion(int timeDensity, AmmeterInfo ammeterInfo, int groupIndex, DateTime timestamps);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 自动获取远程通信模块(SIM)版本信息
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="timeDensity">采集频率</param>
|
|
||||||
/// <param name="ammeterInfo">电表信息</param>
|
|
||||||
/// <param name="groupIndex">集中器所在分组</param>
|
|
||||||
/// <param name="timestamps">采集频率对应的时间戳</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task ConcentratorScheduledAutomaticGetTelematicsModule(int timeDensity, AmmeterInfo ammeterInfo, int groupIndex, DateTime timestamps);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -135,11 +135,14 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
|
|
||||||
//电表定时广播校时,一天一次。
|
//电表定时广播校时,一天一次。
|
||||||
string currentTimeStr = $"{currentTime:HH:mm:00}";
|
string currentTimeStr = $"{currentTime:HH:mm:00}";
|
||||||
if (string.Equals(currentTimeStr, _applicationOptions.AutomaticVerificationTime, StringComparison.CurrentCultureIgnoreCase))//自动校时
|
//判断是否是自动校时时间
|
||||||
|
if (!string.Equals(currentTimeStr, _applicationOptions.AutomaticVerificationTime, StringComparison.CurrentCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
_logger.LogInformation($"{nameof(AmmeterScheduledAutomaticVerificationTime)} 电表自动校时,非自动校时时间");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
//_logger.LogInformation($"{nameof(AmmeterScheduledAutomaticVerificationTime)} 电表自动校时,非自动校时时间");
|
|
||||||
//return;
|
|
||||||
|
|
||||||
_ = CreateMeterPublishTask<AmmeterInfo>(
|
_ = CreateMeterPublishTask<AmmeterInfo>(
|
||||||
timeDensity: timeDensity,
|
timeDensity: timeDensity,
|
||||||
nextTaskTime: currentTime,
|
nextTaskTime: currentTime,
|
||||||
@ -149,32 +152,6 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
await AmmeterScheduledAutomaticVerificationTime(timeDensity, data, groupIndex, timestamps);
|
await AmmeterScheduledAutomaticVerificationTime(timeDensity, data, groupIndex, timestamps);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (string.Equals(currentTimeStr, _applicationOptions.AutomaticGetTerminalVersionTime, StringComparison.CurrentCultureIgnoreCase))//集中器版本号读取
|
|
||||||
{
|
|
||||||
_ = CreateMeterPublishTask<AmmeterInfo>(
|
|
||||||
timeDensity: timeDensity,
|
|
||||||
nextTaskTime: currentTime,
|
|
||||||
meterType: MeterTypeEnum.Ammeter,
|
|
||||||
taskCreateAction: async (timeDensity, data, groupIndex, timestamps) =>
|
|
||||||
{
|
|
||||||
await ConcentratorScheduledAutomaticGetTerminalVersion(timeDensity, data, groupIndex, timestamps);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (string.Equals(currentTimeStr, _applicationOptions.AutomaticGetTelematicsModuleTime, StringComparison.CurrentCultureIgnoreCase))//SIM卡读取
|
|
||||||
{
|
|
||||||
_ = CreateMeterPublishTask<AmmeterInfo>(
|
|
||||||
timeDensity: timeDensity,
|
|
||||||
nextTaskTime: currentTime,
|
|
||||||
meterType: MeterTypeEnum.Ammeter,
|
|
||||||
taskCreateAction: async (timeDensity, data, groupIndex, timestamps) =>
|
|
||||||
{
|
|
||||||
await ConcentratorScheduledAutomaticGetTelematicsModule(timeDensity, data, groupIndex, timestamps);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.LogInformation($"{nameof(CreateToBeIssueTasks)} 不是自动校时、采集终端信息等时间,继续处理其他");
|
|
||||||
}
|
|
||||||
|
|
||||||
//检查任务时间节点,由于定时任务10秒钟运行一次,需要判定当前时间是否在任务时间节点内,不在则跳过
|
//检查任务时间节点,由于定时任务10秒钟运行一次,需要判定当前时间是否在任务时间节点内,不在则跳过
|
||||||
if (!IsTaskTime(tasksToBeIssueModel.NextTaskTime, timeDensity))
|
if (!IsTaskTime(tasksToBeIssueModel.NextTaskTime, timeDensity))
|
||||||
@ -759,8 +736,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
List<MeterReadingTelemetryPacketInfo> taskList = new List<MeterReadingTelemetryPacketInfo>();
|
List<MeterReadingTelemetryPacketInfo> taskList = new List<MeterReadingTelemetryPacketInfo>();
|
||||||
var metadata = await _dbProvider.GetMetadata<MeterReadingTelemetryPacketInfo>();
|
var metadata = await _dbProvider.GetMetadata<MeterReadingTelemetryPacketInfo>();
|
||||||
|
|
||||||
var itemCode = T37612012PacketItemCodeConst.AFN10HFN01H;
|
var temCode = "10_01";
|
||||||
var subItemCode = T6452007PacketItemCodeConst.C08;
|
|
||||||
|
|
||||||
//根据电表型号获取协议插件
|
//根据电表型号获取协议插件
|
||||||
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(ammeterInfo.BrandType);
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(ammeterInfo.BrandType);
|
||||||
@ -774,12 +750,12 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
{
|
{
|
||||||
FocusAddress = ammeterInfo.FocusAddress,
|
FocusAddress = ammeterInfo.FocusAddress,
|
||||||
Pn = ammeterInfo.MeteringCode,
|
Pn = ammeterInfo.MeteringCode,
|
||||||
ItemCode = itemCode,
|
ItemCode = temCode,
|
||||||
SubProtocolRequest = new SubProtocolBuildRequest()
|
SubProtocolRequest = new SubProtocolBuildRequest()
|
||||||
{
|
{
|
||||||
MeterAddress = ammeterInfo.AmmerterAddress,
|
MeterAddress = ammeterInfo.AmmerterAddress,
|
||||||
Password = ammeterInfo.Password,
|
Password = ammeterInfo.Password,
|
||||||
ItemCode = subItemCode,
|
ItemCode = T6452007PacketItemCodeConst.C08,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -799,8 +775,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
Fn = builderResponse.Fn,
|
Fn = builderResponse.Fn,
|
||||||
Seq = builderResponse.Seq,
|
Seq = builderResponse.Seq,
|
||||||
MSA = builderResponse.MSA,
|
MSA = builderResponse.MSA,
|
||||||
ItemCode = itemCode,
|
ItemCode = temCode,
|
||||||
SubItemCode = subItemCode,
|
|
||||||
TaskMark = taskMark,
|
TaskMark = taskMark,
|
||||||
IsSend = false,
|
IsSend = false,
|
||||||
ManualOrNot = false,
|
ManualOrNot = false,
|
||||||
@ -1022,6 +997,37 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
List<MeterReadingTelemetryPacketInfo> taskList = new List<MeterReadingTelemetryPacketInfo>();
|
List<MeterReadingTelemetryPacketInfo> taskList = new List<MeterReadingTelemetryPacketInfo>();
|
||||||
|
|
||||||
|
|
||||||
|
List<string> tempCodes = new List<string>() { "10_1" };
|
||||||
|
|
||||||
|
//todo 后续从协议池获取
|
||||||
|
if (watermeter.MeterTypeName.Equals("水表") && (watermeter.Protocol.Equals((int)MeterLinkProtocol.CJT_188_2018) || watermeter.Protocol.Equals((int)MeterLinkProtocol.DLT_645_1997) || watermeter.Protocol.Equals((int)MeterLinkProtocol.DLT_645_2007)))//水表且(CJT_188_2018或DLT_645_1997)都采用0C_129
|
||||||
|
{
|
||||||
|
if (watermeter.MeterBrand.Contains("炬华有线"))
|
||||||
|
{
|
||||||
|
tempCodes = new List<string>() { "0C_188" };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tempCodes = new List<string>() { "0C_129" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (typeName.Trim().Equals("西恩超声波流量计"))
|
||||||
|
{
|
||||||
|
tempCodes = new List<string>() { "10_1" };
|
||||||
|
}
|
||||||
|
else if (typeName.Trim().Equals("江苏华海涡街流量计积算仪"))
|
||||||
|
{
|
||||||
|
tempCodes = new List<string>() { "10_1" };
|
||||||
|
}
|
||||||
|
else if (typeName.Trim().Equals("V880BR涡街流量计"))
|
||||||
|
{
|
||||||
|
tempCodes = new List<string>() { "10_1" };
|
||||||
|
}
|
||||||
|
else if (typeName.Trim().Equals("拓思特涡街流量计H880BR"))
|
||||||
|
{
|
||||||
|
tempCodes = new List<string>() { "10_1" };
|
||||||
|
}
|
||||||
|
|
||||||
//根据表型号获取协议插件
|
//根据表型号获取协议插件
|
||||||
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(watermeter.Code);
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(watermeter.Code);
|
||||||
@ -1031,31 +1037,66 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
//return;
|
//return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string itemCode = T37612012PacketItemCodeConst.AFN10HFN01H;
|
foreach (var tempItem in tempCodes)
|
||||||
string subItemCode = T1882018PacketItemCodeConst.CTR0190;
|
{
|
||||||
|
//排除已发送日冻结和月冻结采集项配置
|
||||||
|
if (DayFreezeCodes.Contains(tempItem))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MonthFreezeCodes.Contains(tempItem))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//var itemCodeArr = tempItem.Split('_');
|
||||||
|
//var aFNStr = itemCodeArr[0];
|
||||||
|
//var aFN = (AFN)aFNStr.HexToDec();
|
||||||
|
//var fn = int.Parse(itemCodeArr[1]);
|
||||||
|
//TelemetryPacketResponse builderResponse = null;
|
||||||
|
|
||||||
|
//string methonCode = $"AFN{aFNStr}_Fn_Send";
|
||||||
|
////特殊表暂不处理
|
||||||
|
//if (handlerPacketBuilder != null && handlerPacketBuilder.TryGetValue(methonCode
|
||||||
|
// , out var handler))
|
||||||
|
//{
|
||||||
|
// builderResponse = handler(new TelemetryPacketRequest()
|
||||||
|
// {
|
||||||
|
// FocusAddress = watermeter.FocusAddress,
|
||||||
|
// Fn = fn,
|
||||||
|
// Pn = watermeter.MeteringCode,
|
||||||
|
// DataUnit = Build188SendData.Build188WaterMeterReadingSendDataUnit(watermeter.Address),
|
||||||
|
// });
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// _logger.LogWarning($"{nameof(WatermeterCreatePublishTaskAction)} 集中器{watermeter.FocusAddress}的水表{watermeter.Name}采集项{tempItem}无效编码。");
|
||||||
|
// continue;
|
||||||
|
//}
|
||||||
|
|
||||||
ProtocolBuildResponse builderResponse = await protocolPlugin.BuildAsync(new ProtocolBuildRequest()
|
ProtocolBuildResponse builderResponse = await protocolPlugin.BuildAsync(new ProtocolBuildRequest()
|
||||||
{
|
{
|
||||||
FocusAddress = watermeter.FocusAddress,
|
FocusAddress = watermeter.FocusAddress,
|
||||||
Pn = watermeter.MeteringCode,
|
Pn = watermeter.MeteringCode,
|
||||||
ItemCode = itemCode,
|
ItemCode = tempItem,
|
||||||
SubProtocolRequest = new SubProtocolBuildRequest()
|
SubProtocolRequest = new SubProtocolBuildRequest()
|
||||||
{
|
{
|
||||||
MeterAddress = watermeter.MeterAddress,
|
MeterAddress = watermeter.MeterAddress,
|
||||||
Password = watermeter.Password,
|
Password = watermeter.Password,
|
||||||
ItemCode = subItemCode,
|
ItemCode = tempItem,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (builderResponse == null || builderResponse.Data.Length <= 0)
|
if (builderResponse == null || builderResponse.Data.Length <= 0)
|
||||||
{
|
{
|
||||||
//_logger.LogWarning($"{nameof(AmmerterCreatePublishTask)} 集中器{ammeterInfo.FocusAddress}的电表{ammeterInfo.Name}采集项{tempItem}未能正确获取报文。");
|
//_logger.LogWarning($"{nameof(AmmerterCreatePublishTask)} 集中器{ammeterInfo.FocusAddress}的电表{ammeterInfo.Name}采集项{tempItem}未能正确获取报文。");
|
||||||
return null;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (builderResponse == null || builderResponse.Data.Length <= 0)
|
if (builderResponse == null || builderResponse.Data.Length <= 0)
|
||||||
{
|
{
|
||||||
_logger.LogWarning($"{nameof(WatermeterCreatePublishTaskAction)} 集中器{watermeter.FocusAddress}的水表{watermeter.Name}采集项{itemCode}未能正确获取报文。");
|
_logger.LogWarning($"{nameof(WatermeterCreatePublishTaskAction)} 集中器{watermeter.FocusAddress}的水表{watermeter.Name}采集项{tempItem}未能正确获取报文。");
|
||||||
return null;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1075,8 +1116,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
Fn = builderResponse.Fn,
|
Fn = builderResponse.Fn,
|
||||||
Seq = builderResponse.Seq,
|
Seq = builderResponse.Seq,
|
||||||
MSA = builderResponse.MSA,
|
MSA = builderResponse.MSA,
|
||||||
ItemCode = itemCode,
|
ItemCode = tempItem,
|
||||||
SubItemCode = subItemCode,
|
|
||||||
TaskMark = taskMark,
|
TaskMark = taskMark,
|
||||||
IsSend = false,
|
IsSend = false,
|
||||||
ManualOrNot = false,
|
ManualOrNot = false,
|
||||||
@ -1088,6 +1128,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
};
|
};
|
||||||
|
|
||||||
taskList.Add(meterReadingRecords);
|
taskList.Add(meterReadingRecords);
|
||||||
|
}
|
||||||
|
|
||||||
return taskList;
|
return taskList;
|
||||||
|
|
||||||
@ -1095,209 +1136,6 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 集中器处理
|
|
||||||
/// <summary>
|
|
||||||
/// 自动获取终端版
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="timeDensity">采集频率</param>
|
|
||||||
/// <param name="ammeterInfo">电表信息</param>
|
|
||||||
/// <param name="groupIndex">集中器所在分组</param>
|
|
||||||
/// <param name="timestamps">采集频率对应的时间戳</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public virtual async Task ConcentratorScheduledAutomaticGetTerminalVersion(int timeDensity, AmmeterInfo ammeterInfo, int groupIndex, DateTime timestamps)
|
|
||||||
{
|
|
||||||
var currentTime = DateTime.Now;
|
|
||||||
string currentTimeStr = $"{currentTime:HH:mm:00}";
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//判断是否是自动获取版本号时间
|
|
||||||
if (!string.Equals(currentTimeStr, _applicationOptions.AutomaticGetTerminalVersionTime, StringComparison.CurrentCultureIgnoreCase))
|
|
||||||
{
|
|
||||||
_logger.LogInformation($"{nameof(ConcentratorScheduledAutomaticGetTerminalVersion)} 集中器自动获取版本号,非自动处理时间");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<MeterReadingTelemetryPacketInfo> taskList = new List<MeterReadingTelemetryPacketInfo>();
|
|
||||||
var metadata = await _dbProvider.GetMetadata<MeterReadingTelemetryPacketInfo>();
|
|
||||||
|
|
||||||
var itemCode = T37612012PacketItemCodeConst.AFN09HFN01H;
|
|
||||||
//var subItemCode = T6452007PacketItemCodeConst.C08;
|
|
||||||
|
|
||||||
//根据电表型号获取协议插件
|
|
||||||
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(ammeterInfo.BrandType);
|
|
||||||
if (protocolPlugin == null)
|
|
||||||
{
|
|
||||||
_logger.LogError($"{nameof(AmmeterScheduledAutoValveControl)} 集中器自动获取版本号{currentTime}没有找到对应的协议组件,-105");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProtocolBuildResponse builderResponse = await protocolPlugin.BuildAsync(new ProtocolBuildRequest()
|
|
||||||
{
|
|
||||||
FocusAddress = ammeterInfo.FocusAddress,
|
|
||||||
Pn = ammeterInfo.MeteringCode,
|
|
||||||
ItemCode = itemCode,
|
|
||||||
//SubProtocolRequest = new SubProtocolBuildRequest()
|
|
||||||
//{
|
|
||||||
// MeterAddress = ammeterInfo.AmmerterAddress,
|
|
||||||
// Password = ammeterInfo.Password,
|
|
||||||
// ItemCode = subItemCode,
|
|
||||||
//}
|
|
||||||
});
|
|
||||||
|
|
||||||
string taskMark = CommonHelper.GetTaskMark(builderResponse.AFn, builderResponse.Fn, ammeterInfo.MeteringCode, builderResponse.MSA, builderResponse.Seq);
|
|
||||||
var meterReadingRecords = new MeterReadingTelemetryPacketInfo()
|
|
||||||
{
|
|
||||||
SystemName = SystemType,
|
|
||||||
ProjectId = $"{ammeterInfo.ProjectID}",
|
|
||||||
DeviceType = $"{MeterTypeEnum.Ammeter}",
|
|
||||||
DeviceId = $"{ammeterInfo.MeterId}",
|
|
||||||
Timestamps = currentTime.GetDateTimeOffset().ToUnixTimeNanoseconds(),
|
|
||||||
DatabaseBusiID = ammeterInfo.DatabaseBusiID,
|
|
||||||
PendingCopyReadTime = currentTime,
|
|
||||||
CreationTime = currentTime,
|
|
||||||
MeterAddress = ammeterInfo.AmmerterAddress,
|
|
||||||
AFN = builderResponse.AFn,
|
|
||||||
Fn = builderResponse.Fn,
|
|
||||||
Seq = builderResponse.Seq,
|
|
||||||
MSA = builderResponse.MSA,
|
|
||||||
ItemCode = itemCode,
|
|
||||||
//SubItemCode = subItemCode,
|
|
||||||
TaskMark = taskMark,
|
|
||||||
IsSend = false,
|
|
||||||
ManualOrNot = false,
|
|
||||||
Pn = ammeterInfo.MeteringCode,
|
|
||||||
IssuedMessageId = GuidGenerator.Create().ToString(),
|
|
||||||
IssuedMessageHexString = Convert.ToHexString(builderResponse.Data),
|
|
||||||
IsReceived = false,
|
|
||||||
ScoreValue = $"{ammeterInfo.FocusAddress}.{taskMark}".Md5Fun(),
|
|
||||||
};
|
|
||||||
taskList.Add(meterReadingRecords);
|
|
||||||
|
|
||||||
if (taskList == null || taskList.Count <= 0)
|
|
||||||
{
|
|
||||||
_logger.LogError($"{nameof(AmmeterScheduledAutoValveControl)} 定时阀控运行时间{currentTime}没有自动阀控任务生成,-106");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//任务记录入库
|
|
||||||
await _dbProvider.BatchInsertAsync(metadata, taskList);
|
|
||||||
|
|
||||||
//任务信息推送Kafka
|
|
||||||
_ = DeviceGroupBalanceControl.ProcessWithThrottleAsync<MeterReadingTelemetryPacketInfo>(
|
|
||||||
items: taskList,
|
|
||||||
deviceIdSelector: data => data.DeviceId,
|
|
||||||
processor: (data, groupIndex) =>
|
|
||||||
{
|
|
||||||
_ = KafkaProducerIssuedMessageAction(ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, data, groupIndex);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 自动获取远程通信模块(SIM)版本信息
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="timeDensity">采集频率</param>
|
|
||||||
/// <param name="ammeterInfo">电表信息</param>
|
|
||||||
/// <param name="groupIndex">集中器所在分组</param>
|
|
||||||
/// <param name="timestamps">采集频率对应的时间戳</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public virtual async Task ConcentratorScheduledAutomaticGetTelematicsModule(int timeDensity, AmmeterInfo ammeterInfo, int groupIndex, DateTime timestamps)
|
|
||||||
{
|
|
||||||
var currentTime = DateTime.Now;
|
|
||||||
string currentTimeStr = $"{currentTime:HH:mm:00}";
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//判断是否是自动获取版本号时间
|
|
||||||
if (!string.Equals(currentTimeStr, _applicationOptions.AutomaticGetTerminalVersionTime, StringComparison.CurrentCultureIgnoreCase))
|
|
||||||
{
|
|
||||||
_logger.LogInformation($"{nameof(ConcentratorScheduledAutomaticGetTelematicsModule)} 自动获取远程通信模块(SIM)版本信息,非自动处理时间");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<MeterReadingTelemetryPacketInfo> taskList = new List<MeterReadingTelemetryPacketInfo>();
|
|
||||||
var metadata = await _dbProvider.GetMetadata<MeterReadingTelemetryPacketInfo>();
|
|
||||||
|
|
||||||
var itemCode = T37612012PacketItemCodeConst.AFN09HFN09H;
|
|
||||||
|
|
||||||
//根据电表型号获取协议插件
|
|
||||||
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(ammeterInfo.BrandType);
|
|
||||||
if (protocolPlugin == null)
|
|
||||||
{
|
|
||||||
_logger.LogError($"{nameof(ConcentratorScheduledAutomaticGetTelematicsModule)} 自动获取远程通信模块(SIM)版本信息{currentTime}没有找到对应的协议组件,-105");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProtocolBuildResponse builderResponse = await protocolPlugin.BuildAsync(new ProtocolBuildRequest()
|
|
||||||
{
|
|
||||||
FocusAddress = ammeterInfo.FocusAddress,
|
|
||||||
Pn = ammeterInfo.MeteringCode,
|
|
||||||
ItemCode = itemCode,
|
|
||||||
});
|
|
||||||
|
|
||||||
string taskMark = CommonHelper.GetTaskMark(builderResponse.AFn, builderResponse.Fn, ammeterInfo.MeteringCode, builderResponse.MSA, builderResponse.Seq);
|
|
||||||
var meterReadingRecords = new MeterReadingTelemetryPacketInfo()
|
|
||||||
{
|
|
||||||
SystemName = SystemType,
|
|
||||||
ProjectId = $"{ammeterInfo.ProjectID}",
|
|
||||||
DeviceType = $"{MeterTypeEnum.Ammeter}",
|
|
||||||
DeviceId = $"{ammeterInfo.MeterId}",
|
|
||||||
Timestamps = currentTime.GetDateTimeOffset().ToUnixTimeNanoseconds(),
|
|
||||||
DatabaseBusiID = ammeterInfo.DatabaseBusiID,
|
|
||||||
PendingCopyReadTime = currentTime,
|
|
||||||
CreationTime = currentTime,
|
|
||||||
MeterAddress = ammeterInfo.AmmerterAddress,
|
|
||||||
AFN = builderResponse.AFn,
|
|
||||||
Fn = builderResponse.Fn,
|
|
||||||
Seq = builderResponse.Seq,
|
|
||||||
MSA = builderResponse.MSA,
|
|
||||||
ItemCode = itemCode,
|
|
||||||
//SubItemCode = subItemCode,
|
|
||||||
TaskMark = taskMark,
|
|
||||||
IsSend = false,
|
|
||||||
ManualOrNot = false,
|
|
||||||
Pn = ammeterInfo.MeteringCode,
|
|
||||||
IssuedMessageId = GuidGenerator.Create().ToString(),
|
|
||||||
IssuedMessageHexString = Convert.ToHexString(builderResponse.Data),
|
|
||||||
IsReceived = false,
|
|
||||||
ScoreValue = $"{ammeterInfo.FocusAddress}.{taskMark}".Md5Fun(),
|
|
||||||
};
|
|
||||||
taskList.Add(meterReadingRecords);
|
|
||||||
|
|
||||||
if (taskList == null || taskList.Count <= 0)
|
|
||||||
{
|
|
||||||
_logger.LogError($"{nameof(AmmeterScheduledAutoValveControl)} 定时阀控运行时间{currentTime}没有自动阀控任务生成,-106");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//任务记录入库
|
|
||||||
await _dbProvider.BatchInsertAsync(metadata, taskList);
|
|
||||||
|
|
||||||
//任务信息推送Kafka
|
|
||||||
_ = DeviceGroupBalanceControl.ProcessWithThrottleAsync<MeterReadingTelemetryPacketInfo>(
|
|
||||||
items: taskList,
|
|
||||||
deviceIdSelector: data => data.DeviceId,
|
|
||||||
processor: (data, groupIndex) =>
|
|
||||||
{
|
|
||||||
_ = KafkaProducerIssuedMessageAction(ProtocolConst.AmmeterSubscriberWorkerOtherIssuedEventName, data, groupIndex);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
#region 公共处理方法
|
#region 公共处理方法
|
||||||
|
|
||||||
|
|||||||
@ -227,7 +227,6 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
//获取对应的缓存电表信息
|
//获取对应的缓存电表信息
|
||||||
var ammeterInfo = ammeterInfos.First();
|
var ammeterInfo = ammeterInfos.First();
|
||||||
bool tripStateResult = false;
|
bool tripStateResult = false;
|
||||||
string itemCode = T37612012PacketItemCodeConst.AFN10HFN01H;
|
|
||||||
string subItemCode = string.Empty;
|
string subItemCode = string.Empty;
|
||||||
if (settingInfo.TripType.Equals("on"))
|
if (settingInfo.TripType.Equals("on"))
|
||||||
{
|
{
|
||||||
@ -251,6 +250,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var temCode = "10_01_";
|
||||||
|
|
||||||
//根据电表型号获取协议插件
|
//根据电表型号获取协议插件
|
||||||
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(ammeterInfo.BrandType);
|
var protocolPlugin = await _protocolService.GetProtocolServiceAsync(ammeterInfo.BrandType);
|
||||||
@ -264,7 +264,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
{
|
{
|
||||||
FocusAddress = ammeterInfo.FocusAddress,
|
FocusAddress = ammeterInfo.FocusAddress,
|
||||||
Pn = ammeterInfo.MeteringCode,
|
Pn = ammeterInfo.MeteringCode,
|
||||||
ItemCode = itemCode,
|
ItemCode = temCode,
|
||||||
SubProtocolRequest = new SubProtocolBuildRequest()
|
SubProtocolRequest = new SubProtocolBuildRequest()
|
||||||
{
|
{
|
||||||
MeterAddress = ammeterInfo.AmmerterAddress,
|
MeterAddress = ammeterInfo.AmmerterAddress,
|
||||||
@ -289,8 +289,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
Fn = builderResponse.Fn,
|
Fn = builderResponse.Fn,
|
||||||
Seq = builderResponse.Seq,
|
Seq = builderResponse.Seq,
|
||||||
MSA = builderResponse.MSA,
|
MSA = builderResponse.MSA,
|
||||||
ItemCode = itemCode,
|
ItemCode = temCode,
|
||||||
SubItemCode = subItemCode,
|
|
||||||
TaskMark = taskMark,
|
TaskMark = taskMark,
|
||||||
IsSend = false,
|
IsSend = false,
|
||||||
ManualOrNot = false,
|
ManualOrNot = false,
|
||||||
|
|||||||
@ -104,13 +104,6 @@ namespace JiShe.CollectBus.IotSystems.MeterReadingRecords
|
|||||||
[FIELDColumn]
|
[FIELDColumn]
|
||||||
public string ItemCode { get; set; }
|
public string ItemCode { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 子项编码,一般用于透明转发的编码
|
|
||||||
/// </summary>
|
|
||||||
[FIELDColumn]
|
|
||||||
public string SubItemCode { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 帧序列域 SEQ
|
/// 帧序列域 SEQ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
namespace JiShe.CollectBus.Common.Consts
|
namespace JiShe.CollectBus.Common.Consts
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// T188-2018报文项编码
|
/// T188报文项编码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class T1882018PacketItemCodeConst
|
public class T1882018PacketItemCodeConst
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,40 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace JiShe.CollectBus.Common.Consts
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// T376.1-2012报文项编码
|
|
||||||
/// </summary>
|
|
||||||
public class T37612012PacketItemCodeConst
|
|
||||||
{
|
|
||||||
#region 非可配置的,下行报文编码管理,主要是数据库没有配置,但是需要读取的采集项
|
|
||||||
|
|
||||||
#region 读数据
|
|
||||||
/// <summary>
|
|
||||||
/// 透明转发
|
|
||||||
/// </summary>
|
|
||||||
public const string AFN10HFN01H = $"10_01";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 读取终端信息
|
|
||||||
/// </summary>
|
|
||||||
public const string AFN09HFN01H = $"09_01";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 远程通信模块版本信息
|
|
||||||
/// </summary>
|
|
||||||
public const string AFN09HFN09H = $"09_09";
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 写数据
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
namespace JiShe.CollectBus.Common.Consts
|
namespace JiShe.CollectBus.Common.Consts
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// T645-2007报文项编码
|
/// T6452007报文项编码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class T6452007PacketItemCodeConst
|
public class T6452007PacketItemCodeConst
|
||||||
{
|
{
|
||||||
|
|||||||
@ -19,15 +19,5 @@
|
|||||||
/// 自动验证时间
|
/// 自动验证时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public required string AutomaticVerificationTime { get; set;}
|
public required string AutomaticVerificationTime { get; set;}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 自动获取终端版时间
|
|
||||||
/// </summary>
|
|
||||||
public required string AutomaticGetTerminalVersionTime { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 自动获取远程通信模块(SIM)版本时间
|
|
||||||
/// </summary>
|
|
||||||
public required string AutomaticGetTelematicsModuleTime { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -142,12 +142,4 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"PlugInFolder": "C:\\Users\\Dai Zan\\Desktop\\Plugins"
|
"PlugInFolder": "C:\\Users\\Dai Zan\\Desktop\\Plugins"
|
||||||
|
|
||||||
"ServerApplicationOptions": {
|
|
||||||
"ServerTagName": "JiSheCollectBus100",
|
|
||||||
"FirstCollectionTime": "2025-04-22 16:07:00",
|
|
||||||
"AutomaticVerificationTime": "16:07:00",
|
|
||||||
"AutomaticGetTerminalVersionTime": "17:07:00",
|
|
||||||
"AutomaticGetTelematicsModuleTime": "17:30:00"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user