Merge branch 'dev' of https://310.jisheyun.com/daizan/JiShe.CollectBus into dev
This commit is contained in:
commit
798c48650a
@ -1,5 +1,6 @@
|
|||||||
using System.Threading.Tasks;
|
using JiShe.CollectBus.IotSystems.MessageIssueds;
|
||||||
using JiShe.CollectBus.Common.Models;
|
using JiShe.CollectBus.IotSystems.MessageReceiveds;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Volo.Abp.Application.Services;
|
using Volo.Abp.Application.Services;
|
||||||
|
|
||||||
namespace JiShe.CollectBus.Subscribers
|
namespace JiShe.CollectBus.Subscribers
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -13,6 +14,8 @@ using JiShe.CollectBus.Common.Extensions;
|
|||||||
using JiShe.CollectBus.Common.Helpers;
|
using JiShe.CollectBus.Common.Helpers;
|
||||||
using JiShe.CollectBus.Common.Models;
|
using JiShe.CollectBus.Common.Models;
|
||||||
using JiShe.CollectBus.GatherItem;
|
using JiShe.CollectBus.GatherItem;
|
||||||
|
using JiShe.CollectBus.IotSystems.Devices;
|
||||||
|
using JiShe.CollectBus.IotSystems.MessageIssueds;
|
||||||
using JiShe.CollectBus.IotSystems.MessageReceiveds;
|
using JiShe.CollectBus.IotSystems.MessageReceiveds;
|
||||||
using JiShe.CollectBus.IotSystems.Watermeter;
|
using JiShe.CollectBus.IotSystems.Watermeter;
|
||||||
using JiShe.CollectBus.Protocol.Contracts;
|
using JiShe.CollectBus.Protocol.Contracts;
|
||||||
@ -20,6 +23,7 @@ using JiShe.CollectBus.Workers;
|
|||||||
using MassTransit;
|
using MassTransit;
|
||||||
using MassTransit.Internals.GraphValidation;
|
using MassTransit.Internals.GraphValidation;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Volo.Abp.Domain.Repositories;
|
||||||
|
|
||||||
namespace JiShe.CollectBus.ScheduledMeterReading
|
namespace JiShe.CollectBus.ScheduledMeterReading
|
||||||
{
|
{
|
||||||
@ -30,10 +34,17 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
{
|
{
|
||||||
private readonly ILogger<BasicScheduledMeterReadingService> _logger;
|
private readonly ILogger<BasicScheduledMeterReadingService> _logger;
|
||||||
private readonly ICapPublisher _capBus;
|
private readonly ICapPublisher _capBus;
|
||||||
public BasicScheduledMeterReadingService(ILogger<BasicScheduledMeterReadingService> logger, ICapPublisher capBus)
|
private readonly IRepository<ScheduledMeterReadingIssuedEventMessage, Guid> _meterReadingIssuedRepository;
|
||||||
|
|
||||||
|
|
||||||
|
public BasicScheduledMeterReadingService(
|
||||||
|
ILogger<BasicScheduledMeterReadingService> logger,
|
||||||
|
ICapPublisher capBus,
|
||||||
|
IRepository<ScheduledMeterReadingIssuedEventMessage, Guid> meterReadingIssuedRepository)
|
||||||
{
|
{
|
||||||
_capBus = capBus;
|
_capBus = capBus;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_meterReadingIssuedRepository = meterReadingIssuedRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -118,7 +129,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
List<string> itemCodeList = new List<string>();
|
List<string> itemCodeList = new List<string>();
|
||||||
foreach (var dataType in itemArr)
|
foreach (var dataType in itemArr)
|
||||||
{
|
{
|
||||||
var excludeItemCode = "10_98,10_94";//排除透明转发:尖峰平谷时段、跳合闸
|
var excludeItemCode = "10_98,10_94";//TODO 排除透明转发:尖峰平谷时段、跳合闸,特殊电表
|
||||||
var gatherItem = gatherItemInfos.FirstOrDefault(f => f.DataType.Equals(dataType));
|
var gatherItem = gatherItemInfos.FirstOrDefault(f => f.DataType.Equals(dataType));
|
||||||
if (gatherItem != null)
|
if (gatherItem != null)
|
||||||
{
|
{
|
||||||
@ -127,17 +138,21 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
itemCodeList.Add(gatherItem.ItemCode);
|
itemCodeList.Add(gatherItem.ItemCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 特殊电表采集项编号处理
|
||||||
|
if (itemArr.Exists(e => e.Equals("95"))) //德力西DTS
|
||||||
|
{
|
||||||
|
itemCodeList.Add("10_95");
|
||||||
|
}
|
||||||
|
if (itemArr.Exists(e => e.Equals("109")))//WAVE_109
|
||||||
|
{
|
||||||
|
itemCodeList.Add("10_109");
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 特殊电表采集项编号处理
|
|
||||||
if (itemArr.Exists(e => e.Equals("95"))) //德力西DTS
|
|
||||||
{
|
|
||||||
itemCodeList.Add("10_95");
|
|
||||||
}
|
|
||||||
//if (itemArr.Exists(e => e.Equals("109")))//WAVE_109
|
|
||||||
// ammeter.ItemCodes += "10_109,";
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
ammeter.ItemCodes = itemCodeList.Serialize();//转换成JSON字符串
|
ammeter.ItemCodes = itemCodeList.Serialize();//转换成JSON字符串
|
||||||
|
|
||||||
@ -207,7 +222,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
_logger.LogError($"{nameof(AmmeterScheduledMeterFiveMinuteReading)} 5分钟采集电表数据处理时没有获取到缓存信息,-102");
|
_logger.LogError($"{nameof(AmmeterScheduledMeterFiveMinuteReading)} 5分钟采集电表数据处理时没有获取到缓存信息,-102");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await AmmerterScheduledMeterReadingIssued(ProtocolConst.AmmeterSubscriberWorkerOneMinuteIssuedEventName, meterInfos);
|
await AmmerterScheduledMeterReadingIssued(ProtocolConst.AmmeterSubscriberWorkerFiveMinuteIssuedEventName, meterInfos);
|
||||||
|
|
||||||
_logger.LogInformation($"{nameof(AmmeterScheduledMeterFiveMinuteReading)} 5分钟采集电表数据处理完成");
|
_logger.LogInformation($"{nameof(AmmeterScheduledMeterFiveMinuteReading)} 5分钟采集电表数据处理完成");
|
||||||
}
|
}
|
||||||
@ -235,8 +250,14 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await AmmerterScheduledMeterReadingIssued(ProtocolConst.AmmeterSubscriberWorkerOneMinuteIssuedEventName, meterInfos);
|
Stopwatch stopwatch = new Stopwatch();
|
||||||
_logger.LogInformation($"{nameof(AmmeterScheduledMeterFifteenMinuteReading)} 15分钟采集电表数据处理完成");
|
stopwatch.Start();
|
||||||
|
|
||||||
|
await AmmerterScheduledMeterReadingIssued(ProtocolConst.AmmeterSubscriberWorkerFifteenMinuteIssuedEventName, meterInfos);
|
||||||
|
|
||||||
|
stopwatch.Stop();
|
||||||
|
|
||||||
|
_logger.LogError($"{nameof(AmmeterScheduledMeterFifteenMinuteReading)} 15分钟采集电表数据处理完成,共消耗{stopwatch.ElapsedMilliseconds}毫秒。");
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -459,7 +480,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
//将采集器编号的hash值取模分组
|
//将采集器编号的hash值取模分组
|
||||||
const int TotalShards = 20;
|
const int TotalShards = 1024;
|
||||||
var focusHashGroups = new Dictionary<int, Dictionary<string, Dictionary<string, AmmeterInfo>>>();
|
var focusHashGroups = new Dictionary<int, Dictionary<string, Dictionary<string, AmmeterInfo>>>();
|
||||||
|
|
||||||
foreach (var (collectorId, ammetersDictionary) in focusGroup)
|
foreach (var (collectorId, ammetersDictionary) in focusGroup)
|
||||||
@ -493,10 +514,12 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
//根据分组创建线程批处理集中器
|
//根据分组创建线程批处理集中器
|
||||||
foreach (var group in focusHashGroups)
|
foreach (var group in focusHashGroups)
|
||||||
{
|
{
|
||||||
_ = Task.Run(async () => { await CreatePublishTask(eventName, group.Value); });
|
//TODO _meterReadingIssuedRepository 需要优化
|
||||||
|
//_ = Task.Run(async () => { await CreatePublishTask(eventName, group.Value); });
|
||||||
|
await CreatePublishTask(eventName, group.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.CompletedTask;
|
//await Task.CompletedTask;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@ -538,12 +561,12 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//排除1天未在线的集中器生成指令 或 排除集中器配置为自动上报的集中器
|
////排除1天未在线的集中器生成指令 或 排除集中器配置为自动上报的集中器
|
||||||
if (!IsGennerateCmd(ammeter.LastTime, -1))
|
//if (!IsGennerateCmd(ammeter.LastTime, -1))
|
||||||
{
|
//{
|
||||||
_logger.LogInformation($"{nameof(CreatePublishTask)} 集中器{ammeter.FocusAddress}的电表{ammeter.Name},采集时间:{ammeter.LastTime},已超过1天未在线,不生成指令");
|
// _logger.LogInformation($"{nameof(CreatePublishTask)} 集中器{ammeter.FocusAddress}的电表{ammeter.Name},采集时间:{ammeter.LastTime},已超过1天未在线,不生成指令");
|
||||||
continue;
|
// continue;
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(ammeter.AreaCode))
|
if (string.IsNullOrWhiteSpace(ammeter.AreaCode))
|
||||||
{
|
{
|
||||||
@ -598,6 +621,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<ScheduledMeterReadingIssuedEventMessage> evenMessageInfoList = new List<ScheduledMeterReadingIssuedEventMessage>();
|
||||||
foreach (var tempItem in tempCodes)
|
foreach (var tempItem in tempCodes)
|
||||||
{
|
{
|
||||||
//排除已发送日冻结和月冻结采集项配置
|
//排除已发送日冻结和月冻结采集项配置
|
||||||
@ -615,20 +639,22 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
var aFN = (AFN)itemCodeArr[0].HexToDec();
|
var aFN = (AFN)itemCodeArr[0].HexToDec();
|
||||||
var fn = int.Parse(itemCodeArr[1]);
|
var fn = int.Parse(itemCodeArr[1]);
|
||||||
byte[] dataInfos = null;
|
byte[] dataInfos = null;
|
||||||
if(ammeter.AutomaticReport.Equals(1) && aFN == AFN.请求实时数据)
|
if (ammeter.AutomaticReport.Equals(1) && aFN == AFN.请求实时数据)
|
||||||
{
|
{
|
||||||
//实时数据
|
//实时数据
|
||||||
dataInfos = Build3761SendData.BuildAmmeterReadRealTimeDataSendCmd(ammeter.FocusAddress, ammeter.MeteringCode, (ATypeOfDataItems)fn);
|
dataInfos = Build3761SendData.BuildAmmeterReadRealTimeDataSendCmd(ammeter.FocusAddress, ammeter.MeteringCode, (ATypeOfDataItems)fn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//特殊表暂不处理
|
||||||
if (TelemetryPacketBuilder.AFNHandlers.TryGetValue(tempItem, out var handler))
|
if (TelemetryPacketBuilder.AFNHandlers.TryGetValue(tempItem, out var handler))
|
||||||
{
|
{
|
||||||
dataInfos = handler(ammeter.FocusAddress, fn, ammeter.MeteringCode);
|
dataInfos = handler(ammeter.FocusAddress, fn, ammeter.MeteringCode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException($"无效编码: {tempItem}");
|
_logger.LogWarning($"{nameof(CreatePublishTask)} 集中器{ammeter.FocusAddress}的电表{ammeter.Name}采集项{tempItem}无效编码。");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//TODO:特殊表
|
//TODO:特殊表
|
||||||
@ -643,13 +669,15 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
{
|
{
|
||||||
Message = dataInfos!,
|
Message = dataInfos!,
|
||||||
DeviceNo = ammeter.FocusAddress,
|
DeviceNo = ammeter.FocusAddress,
|
||||||
MessageId = NewId.NextGuid().ToString()
|
MessageId = NewId.NextGuid().ToString(),
|
||||||
|
TimeDensity = eventName,
|
||||||
|
WasSuccessful = false,
|
||||||
};
|
};
|
||||||
await _capBus.PublishAsync(eventName, evenMessageInfo);
|
await _capBus.PublishAsync(eventName, evenMessageInfo);
|
||||||
|
evenMessageInfoList.Add(evenMessageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await _meterReadingIssuedRepository.InsertManyAsync(evenMessageInfoList);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using DotNetCore.CAP;
|
using DotNetCore.CAP;
|
||||||
using JiShe.CollectBus.Ammeters;
|
using JiShe.CollectBus.Ammeters;
|
||||||
using JiShe.CollectBus.Common.Consts;
|
using JiShe.CollectBus.Common.Consts;
|
||||||
using JiShe.CollectBus.FreeSql;
|
using JiShe.CollectBus.FreeSql;
|
||||||
using JiShe.CollectBus.GatherItem;
|
using JiShe.CollectBus.GatherItem;
|
||||||
|
using JiShe.CollectBus.IotSystems.MessageIssueds;
|
||||||
using JiShe.CollectBus.IotSystems.Watermeter;
|
using JiShe.CollectBus.IotSystems.Watermeter;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Volo.Abp.Domain.Repositories;
|
||||||
|
|
||||||
namespace JiShe.CollectBus.ScheduledMeterReading
|
namespace JiShe.CollectBus.ScheduledMeterReading
|
||||||
{
|
{
|
||||||
@ -19,7 +22,7 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
public class EnergySystemScheduledMeterReadingService : BasicScheduledMeterReadingService
|
public class EnergySystemScheduledMeterReadingService : BasicScheduledMeterReadingService
|
||||||
{
|
{
|
||||||
|
|
||||||
public EnergySystemScheduledMeterReadingService(ILogger<EnergySystemScheduledMeterReadingService> logger, ICapPublisher capBus) :base(logger, capBus)
|
public EnergySystemScheduledMeterReadingService(ILogger<EnergySystemScheduledMeterReadingService> logger, ICapPublisher capBus, IRepository<ScheduledMeterReadingIssuedEventMessage, Guid> meterReadingIssuedRepository) :base(logger, capBus, meterReadingIssuedRepository)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -59,11 +62,12 @@ namespace JiShe.CollectBus.ScheduledMeterReading
|
|||||||
INNER JOIN TB_FocusInfo(NOLOCK) AS B ON A.ID = B.GatherInfoID AND B.RemoveState >= 0 AND B.State>=0
|
INNER JOIN TB_FocusInfo(NOLOCK) AS B ON A.ID = B.GatherInfoID AND B.RemoveState >= 0 AND B.State>=0
|
||||||
INNER JOIN TB_AmmeterInfo(NOLOCK) AS C ON B.ID = C.FocusID AND C.State>= 0 AND C.State<100
|
INNER JOIN TB_AmmeterInfo(NOLOCK) AS C ON B.ID = C.FocusID AND C.State>= 0 AND C.State<100
|
||||||
INNER JOIN TB_AmmeterGatherItem(NOLOCK) AS D ON C.ID = D.AmmeterID AND D.State>=0
|
INNER JOIN TB_AmmeterGatherItem(NOLOCK) AS D ON C.ID = D.AmmeterID AND D.State>=0
|
||||||
WHERE 1=1 ";
|
WHERE 1=1 and C.Special = 0 ";
|
||||||
|
//TODO 记得移除特殊表过滤
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(gatherCode))
|
if (!string.IsNullOrWhiteSpace(gatherCode))
|
||||||
{
|
{
|
||||||
sql = $@"{sql} A.GatherCode = '{gatherCode}'";
|
sql = $@"{sql} AND A.GatherCode = '{gatherCode}'";
|
||||||
}
|
}
|
||||||
return await SqlProvider.Instance.Change(DbEnum.EnergyDB)
|
return await SqlProvider.Instance.Change(DbEnum.EnergyDB)
|
||||||
.Ado
|
.Ado
|
||||||
|
|||||||
@ -3,8 +3,9 @@ using System.Threading.Tasks;
|
|||||||
using DeviceDetectorNET.Parser.Device;
|
using DeviceDetectorNET.Parser.Device;
|
||||||
using DotNetCore.CAP;
|
using DotNetCore.CAP;
|
||||||
using JiShe.CollectBus.Common.Enums;
|
using JiShe.CollectBus.Common.Enums;
|
||||||
using JiShe.CollectBus.Common.Models;
|
|
||||||
using JiShe.CollectBus.IotSystems.Devices;
|
using JiShe.CollectBus.IotSystems.Devices;
|
||||||
|
using JiShe.CollectBus.IotSystems.MessageIssueds;
|
||||||
|
using JiShe.CollectBus.IotSystems.MessageReceiveds;
|
||||||
using JiShe.CollectBus.Protocol.Contracts;
|
using JiShe.CollectBus.Protocol.Contracts;
|
||||||
using JiShe.CollectBus.Protocol.Contracts.Interfaces;
|
using JiShe.CollectBus.Protocol.Contracts.Interfaces;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@ -81,7 +82,7 @@ namespace JiShe.CollectBus.Subscribers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("ammeter/fiveminute/issued-event")]
|
[Route("ammeter/fiveminute/issued-event")]
|
||||||
[CapSubscribe(ProtocolConst.AmmeterSubscriberWorkerOneMinuteIssuedEventName)]
|
[CapSubscribe(ProtocolConst.AmmeterSubscriberWorkerFiveMinuteIssuedEventName)]
|
||||||
public async Task AmmeterScheduledMeterFiveMinuteReadingIssuedEvent(ScheduledMeterReadingIssuedEventMessage receivedMessage)
|
public async Task AmmeterScheduledMeterFiveMinuteReadingIssuedEvent(ScheduledMeterReadingIssuedEventMessage receivedMessage)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("5分钟采集电表数据下行消息消费队列开始处理");
|
_logger.LogInformation("5分钟采集电表数据下行消息消费队列开始处理");
|
||||||
@ -108,7 +109,7 @@ namespace JiShe.CollectBus.Subscribers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("ammeter/fifteenminute/issued-event")]
|
[Route("ammeter/fifteenminute/issued-event")]
|
||||||
[CapSubscribe(ProtocolConst.AmmeterSubscriberWorkerOneMinuteIssuedEventName)]
|
[CapSubscribe(ProtocolConst.AmmeterSubscriberWorkerFifteenMinuteIssuedEventName)]
|
||||||
public async Task AmmeterScheduledMeterFifteenMinuteReadingIssuedEvent(ScheduledMeterReadingIssuedEventMessage receivedMessage)
|
public async Task AmmeterScheduledMeterFifteenMinuteReadingIssuedEvent(ScheduledMeterReadingIssuedEventMessage receivedMessage)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("15分钟采集电表数据下行消息消费队列开始处理");
|
_logger.LogInformation("15分钟采集电表数据下行消息消费队列开始处理");
|
||||||
@ -164,7 +165,7 @@ namespace JiShe.CollectBus.Subscribers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("watermeter/fiveminute/issued-event")]
|
[Route("watermeter/fiveminute/issued-event")]
|
||||||
[CapSubscribe(ProtocolConst.WatermeterSubscriberWorkerOneMinuteIssuedEventName)]
|
[CapSubscribe(ProtocolConst.AmmeterSubscriberWorkerFiveMinuteIssuedEventName)]
|
||||||
public async Task WatermeterScheduledMeterFiveMinuteReadingIssuedEvent(ScheduledMeterReadingIssuedEventMessage receivedMessage)
|
public async Task WatermeterScheduledMeterFiveMinuteReadingIssuedEvent(ScheduledMeterReadingIssuedEventMessage receivedMessage)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("5分钟采集电表数据下行消息消费队列开始处理");
|
_logger.LogInformation("5分钟采集电表数据下行消息消费队列开始处理");
|
||||||
@ -191,7 +192,7 @@ namespace JiShe.CollectBus.Subscribers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("watermeter/fifteenminute/issued-event")]
|
[Route("watermeter/fifteenminute/issued-event")]
|
||||||
[CapSubscribe(ProtocolConst.WatermeterSubscriberWorkerOneMinuteIssuedEventName)]
|
[CapSubscribe(ProtocolConst.AmmeterSubscriberWorkerFifteenMinuteIssuedEventName)]
|
||||||
public async Task WatermeterScheduledMeterFifteenMinuteReadingIssuedEvent(ScheduledMeterReadingIssuedEventMessage receivedMessage)
|
public async Task WatermeterScheduledMeterFifteenMinuteReadingIssuedEvent(ScheduledMeterReadingIssuedEventMessage receivedMessage)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("15分钟采集电表数据下行消息消费队列开始处理");
|
_logger.LogInformation("15分钟采集电表数据下行消息消费队列开始处理");
|
||||||
|
|||||||
@ -0,0 +1,44 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Hangfire;
|
||||||
|
using JiShe.CollectBus.ScheduledMeterReading;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Volo.Abp.BackgroundWorkers.Hangfire;
|
||||||
|
using Volo.Abp.DependencyInjection;
|
||||||
|
using Volo.Abp.Uow;
|
||||||
|
|
||||||
|
namespace JiShe.CollectBus.Workers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 15分钟采集数据
|
||||||
|
/// </summary>
|
||||||
|
public class SubscriberFifteenMinuteWorker : HangfireBackgroundWorkerBase, ITransientDependency, ICollectWorker
|
||||||
|
{
|
||||||
|
private readonly ILogger<SubscriberFifteenMinuteWorker> _logger;
|
||||||
|
private readonly IScheduledMeterReadingService _scheduledMeterReadingService;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="SubscriberFifteenMinuteWorker"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logger">The logger.</param>
|
||||||
|
/// <param name="scheduledMeterReadingService">定时任务</param>
|
||||||
|
public SubscriberFifteenMinuteWorker(ILogger<SubscriberFifteenMinuteWorker> logger, IScheduledMeterReadingService scheduledMeterReadingService)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
RecurringJobId = nameof(SubscriberFifteenMinuteWorker);
|
||||||
|
CronExpression = Cron.Hourly(15);
|
||||||
|
this._scheduledMeterReadingService = scheduledMeterReadingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
|
||||||
|
{
|
||||||
|
await _scheduledMeterReadingService.AmmeterScheduledMeterFifteenMinuteReading();
|
||||||
|
//using (var uow = LazyServiceProvider.LazyGetRequiredService<IUnitOfWorkManager>().Begin())
|
||||||
|
//{
|
||||||
|
// Logger.LogInformation("Executed MyLogWorker..!");
|
||||||
|
// return Task.CompletedTask;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Hangfire;
|
||||||
|
using JiShe.CollectBus.ScheduledMeterReading;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Volo.Abp.BackgroundWorkers.Hangfire;
|
||||||
|
using Volo.Abp.DependencyInjection;
|
||||||
|
using Volo.Abp.Uow;
|
||||||
|
|
||||||
|
namespace JiShe.CollectBus.Workers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 5分钟采集数据
|
||||||
|
/// </summary>
|
||||||
|
public class SubscriberFiveMinuteWorker : HangfireBackgroundWorkerBase, ITransientDependency,ICollectWorker
|
||||||
|
{
|
||||||
|
private readonly ILogger<SubscriberFiveMinuteWorker> _logger;
|
||||||
|
private readonly IScheduledMeterReadingService _scheduledMeterReadingService;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="SubscriberFifteenMinuteWorker"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logger">The logger.</param>
|
||||||
|
/// <param name="scheduledMeterReadingService">定时任务</param>
|
||||||
|
public SubscriberFiveMinuteWorker(ILogger<SubscriberFiveMinuteWorker> logger, IScheduledMeterReadingService scheduledMeterReadingService)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
RecurringJobId = nameof(SubscriberFiveMinuteWorker);
|
||||||
|
CronExpression = Cron.Hourly(15);
|
||||||
|
this._scheduledMeterReadingService = scheduledMeterReadingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
|
||||||
|
{
|
||||||
|
await _scheduledMeterReadingService.AmmeterScheduledMeterFifteenMinuteReading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Hangfire;
|
||||||
|
using JiShe.CollectBus.ScheduledMeterReading;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Volo.Abp.BackgroundWorkers.Hangfire;
|
||||||
|
using Volo.Abp.DependencyInjection;
|
||||||
|
using Volo.Abp.Uow;
|
||||||
|
|
||||||
|
namespace JiShe.CollectBus.Workers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 1分钟采集数据
|
||||||
|
/// </summary>
|
||||||
|
public class SubscriberOneMinuteWorker : HangfireBackgroundWorkerBase, ITransientDependency,ICollectWorker
|
||||||
|
{
|
||||||
|
private readonly ILogger<SubscriberOneMinuteWorker> _logger;
|
||||||
|
private readonly IScheduledMeterReadingService _scheduledMeterReadingService;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="SubscriberFifteenMinuteWorker"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logger">The logger.</param>
|
||||||
|
/// <param name="scheduledMeterReadingService">定时任务</param>
|
||||||
|
public SubscriberOneMinuteWorker(ILogger<SubscriberOneMinuteWorker> logger, IScheduledMeterReadingService scheduledMeterReadingService)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
RecurringJobId = nameof(SubscriberOneMinuteWorker);
|
||||||
|
CronExpression = Cron.Hourly(15);
|
||||||
|
this._scheduledMeterReadingService = scheduledMeterReadingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
|
||||||
|
{
|
||||||
|
await _scheduledMeterReadingService.AmmeterScheduledMeterFifteenMinuteReading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1401,7 +1401,7 @@ namespace JiShe.CollectBus.Common.BuildSendDatas
|
|||||||
cmdStrList.AddRange(userDatas);
|
cmdStrList.AddRange(userDatas);
|
||||||
cmdStrList.Add(cs);
|
cmdStrList.Add(cs);
|
||||||
cmdStrList.Add(endStr);
|
cmdStrList.Add(endStr);
|
||||||
Console.WriteLine(string.Join(" ", cmdStrList));
|
//Console.WriteLine(string.Join(" ", cmdStrList));
|
||||||
var bytes = cmdStrList.Select(x => Convert.ToByte(x, 16)).ToArray();
|
var bytes = cmdStrList.Select(x => Convert.ToByte(x, 16)).ToArray();
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -119,7 +119,7 @@ namespace JiShe.CollectBus.Ammeters
|
|||||||
public string GatherCode { get; set; }
|
public string GatherCode { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否特殊表
|
/// 是否特殊表,1是特殊电表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Special { get; set; }
|
public int Special { get; set; }
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,14 @@
|
|||||||
using JiShe.CollectBus.Common.Enums;
|
using JiShe.CollectBus.Common.Enums;
|
||||||
|
using System;
|
||||||
|
using Volo.Abp.Domain.Entities;
|
||||||
|
|
||||||
namespace JiShe.CollectBus.Common.Models
|
namespace JiShe.CollectBus.IotSystems.MessageIssueds
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 定时抄读Kafka消息实体,1分钟、5分钟、15分钟
|
/// 定时抄读Kafka消息实体,1分钟、5分钟、15分钟
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ScheduledMeterReadingIssuedEventMessage
|
public class ScheduledMeterReadingIssuedEventMessage : AggregateRoot<Guid>
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 消息接收客户端Id
|
|
||||||
/// </summary>
|
|
||||||
public string ClientId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 消息内容
|
/// 消息内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -22,14 +19,19 @@ namespace JiShe.CollectBus.Common.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string DeviceNo { get; set; }
|
public string DeviceNo { get; set; }
|
||||||
|
|
||||||
///// <summary>
|
/// <summary>
|
||||||
///// 采集时间间隔(分钟,如15)
|
/// 采集时间间隔,通过Kafka主题区分(分钟,如15)
|
||||||
///// </summary>
|
/// </summary>
|
||||||
//public int TimeDensity { get; set; }
|
public string TimeDensity { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 消息Id
|
/// 消息Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string MessageId { get; set; }
|
public string MessageId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否下发成功
|
||||||
|
/// </summary>
|
||||||
|
public bool WasSuccessful { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,9 +86,9 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
.container {
|
.container {
|
||||||
width: 1170 px;
|
width: 1170px;
|
||||||
padding-right: 15 px;
|
padding-right: 15px;
|
||||||
padding-left: 15 px;
|
padding-left: 15px;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
@ -97,31 +97,31 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
font-weight: 200;
|
font-weight: 200;
|
||||||
display: block;
|
display: block;
|
||||||
margin: 60 px auto 40 px !important;
|
margin: 60px auto 40px !important;
|
||||||
}
|
}
|
||||||
.page-header {
|
.page-header {
|
||||||
padding-bottom: 9px;
|
padding-bottom: 9px;
|
||||||
margin: 40px auto;
|
margin: 40px auto;
|
||||||
border-bottom: 1 px solid #eee;
|
border-bottom: 1px solid #eee;
|
||||||
}
|
}
|
||||||
.projects-header h2 {
|
.projects-header h2 {
|
||||||
font-size: 42px;
|
font-size: 42px;
|
||||||
letter-spacing: -1px;
|
letter-spacing: -1px;
|
||||||
}
|
}
|
||||||
h2 {
|
h2 {
|
||||||
margin-top: 20 px;
|
margin-top: 20px;
|
||||||
margin-bottom: 10 px;
|
margin-bottom: 10px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 1.1;
|
line-height: 1.1;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
/* text-align: center; */
|
/* text-align: center; */
|
||||||
}
|
}
|
||||||
p {
|
p {
|
||||||
margin: 0 0 10 px;
|
margin: 0 0 10px;
|
||||||
}
|
}
|
||||||
.row {
|
.row {
|
||||||
margin-right: -15 px;
|
margin-right: -15px;
|
||||||
margin-left: -15 px;
|
margin-left: -15px;
|
||||||
}
|
}
|
||||||
.col-lg-3 {
|
.col-lg-3 {
|
||||||
width: 25%;
|
width: 25%;
|
||||||
@ -131,7 +131,7 @@
|
|||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-bottom: 30 px;
|
margin-bottom: 30px;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
.thumbnail {
|
.thumbnail {
|
||||||
@ -139,7 +139,7 @@
|
|||||||
padding: 4px;
|
padding: 4px;
|
||||||
line-height: 1.42857143;
|
line-height: 1.42857143;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border: 1 px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
.transition(border 0.2s ease-in-out);
|
.transition(border 0.2s ease-in-out);
|
||||||
}
|
}
|
||||||
a {
|
a {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Warning",
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
"Serilog.Sinks.File"
|
"Serilog.Sinks.File"
|
||||||
],
|
],
|
||||||
"MinimumLevel": {
|
"MinimumLevel": {
|
||||||
"Default": "Information",
|
"Default": "Warning",
|
||||||
"Override": {
|
"Override": {
|
||||||
"Microsoft": "Information",
|
"Microsoft": "Information",
|
||||||
"Volo.Abp": "Warning",
|
"Volo.Abp": "Warning",
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using JiShe.CollectBus.IotSystems.Devices;
|
using JiShe.CollectBus.IotSystems.Devices;
|
||||||
|
using JiShe.CollectBus.IotSystems.MessageIssueds;
|
||||||
using JiShe.CollectBus.IotSystems.MessageReceiveds;
|
using JiShe.CollectBus.IotSystems.MessageReceiveds;
|
||||||
using JiShe.CollectBus.IotSystems.Protocols;
|
using JiShe.CollectBus.IotSystems.Protocols;
|
||||||
using MongoDB.Driver;
|
using MongoDB.Driver;
|
||||||
@ -22,6 +23,8 @@ public class CollectBusMongoDbContext : AbpMongoDbContext, ICollectBusMongoDbCon
|
|||||||
public IMongoCollection<Device> Devices => Collection<Device>();
|
public IMongoCollection<Device> Devices => Collection<Device>();
|
||||||
public IMongoCollection<ProtocolInfo> ProtocolInfos => Collection<ProtocolInfo>();
|
public IMongoCollection<ProtocolInfo> ProtocolInfos => Collection<ProtocolInfo>();
|
||||||
|
|
||||||
|
public IMongoCollection<ScheduledMeterReadingIssuedEventMessage> MeterReadingIssued => Collection<ScheduledMeterReadingIssuedEventMessage>();
|
||||||
|
|
||||||
protected override void CreateModel(IMongoModelBuilder modelBuilder)
|
protected override void CreateModel(IMongoModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
base.CreateModel(modelBuilder);
|
base.CreateModel(modelBuilder);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user