dev #2
@ -1,4 +1,5 @@
|
||||
using FreeRedis;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -23,7 +24,14 @@ public class FreeRedisProviderService : IFreeRedisProviderService, ISingletonDep
|
||||
freeRedisOptions = options.Value;
|
||||
}
|
||||
|
||||
public IRedisClient FreeRedis { get => GetClient(); }
|
||||
[NotNull]
|
||||
public IRedisClient FreeRedis
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetClient();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取 FreeRedis 客户端
|
||||
@ -31,8 +39,8 @@ public class FreeRedisProviderService : IFreeRedisProviderService, ISingletonDep
|
||||
/// <returns></returns>
|
||||
public IRedisClient GetClient()
|
||||
{
|
||||
|
||||
var redisClinet = new RedisClient(freeRedisOptions.ConnectionString);
|
||||
string connectionString = $"{freeRedisOptions.Configuration},defaultdatabase={freeRedisOptions.DefaultDB}";
|
||||
var redisClinet = new RedisClient(connectionString);
|
||||
redisClinet.Serialize = obj => JsonSerializer.Serialize(obj);
|
||||
redisClinet.Deserialize = (json, type) => JsonSerializer.Deserialize(json, type);
|
||||
redisClinet.Notice += (s, e) => Trace.WriteLine(e.Log);
|
||||
|
||||
@ -11,7 +11,7 @@ public class FreeRedisOptions
|
||||
/// <summary>
|
||||
/// 连接字符串
|
||||
/// </summary>
|
||||
public string? ConnectionString { get; set; }
|
||||
public string? Configuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认数据库
|
||||
|
||||
@ -22,8 +22,4 @@
|
||||
<ProjectReference Include="..\JiShe.CollectBus.Domain\JiShe.CollectBus.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Workers\DTO\Prepay\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -1,28 +1,47 @@
|
||||
using JiShe.CollectBus.Ammeters;
|
||||
using JiShe.CollectBus.Watermeter;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace JiShe.CollectBus.Workers
|
||||
{
|
||||
/// <summary>
|
||||
/// 定时任务基础约束
|
||||
/// </summary>
|
||||
interface IWorkerScheduledService
|
||||
public interface IScheduledMeterReadingService : IApplicationService
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取电表信息
|
||||
/// </summary>
|
||||
/// <param name="gatherCode">采集端Code</param>
|
||||
/// <returns></returns>
|
||||
Task<List<AmmeterInfo>> GetAmmeterInfoList();
|
||||
Task<List<AmmeterInfo>> GetAmmeterInfoList(string gatherCode = "");
|
||||
|
||||
/// <summary>
|
||||
/// 初始化电表缓存数据
|
||||
/// </summary>
|
||||
/// <param name="gatherCode">采集端Code</param>
|
||||
/// <returns></returns>
|
||||
Task InitAmmeterCacheData();
|
||||
Task InitAmmeterCacheData(string gatherCode = "");
|
||||
|
||||
/// <summary>
|
||||
/// 获取水表信息
|
||||
/// </summary>
|
||||
/// <param name="gatherCode">采集端Code</param>
|
||||
/// <returns></returns>
|
||||
Task<List<WatermeterInfo>> GetWatermeterInfoList(string gatherCode = "");
|
||||
|
||||
/// <summary>
|
||||
/// 初始化水表缓存数据
|
||||
/// </summary>
|
||||
/// <param name="gatherCode">采集端Code</param>
|
||||
/// <returns></returns>
|
||||
Task InitWatermeterCacheData(string gatherCode = "");
|
||||
|
||||
/// <summary>
|
||||
/// 1分钟采集电表数据
|
||||
@ -1,99 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.CollectBus.Ammeters
|
||||
{
|
||||
public class AmmeterInfo
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int FocusID { get; set; }
|
||||
public string Address { get; set; }
|
||||
public string AreaCode { get; set; }
|
||||
/// <summary>
|
||||
/// 电表类别 (1单相、2三相三线、3三相四线),
|
||||
/// 07协议: 开合闸指令(1A开闸断电,1C单相表合闸,1B多相表合闸) 645 2007 表
|
||||
/// 97协议://true(合闸);false(跳闸) 545 1997 没有单相多相 之分 "true" ? "9966" : "3355"
|
||||
/// </summary>
|
||||
public int TypeName { get; set; }
|
||||
/// <summary>
|
||||
/// 跳合闸状态字段: 0 合闸,1 跳闸
|
||||
/// 电表:TripState (0 合闸-通电, 1 断开、跳闸);
|
||||
/// </summary>
|
||||
public int TripState { get; set; }
|
||||
/// <summary>
|
||||
/// 规约 -电表default(30) 1:97协议,30:07协议
|
||||
/// </summary>
|
||||
public int? Protocol { get; set; }
|
||||
/// <summary>
|
||||
/// 一个集中器下的[MeteringCode]必须唯一。 PN
|
||||
/// </summary>
|
||||
public int MeteringCode { get; set; }
|
||||
/// <summary>
|
||||
/// 电表通信地址
|
||||
/// </summary>
|
||||
public string AmmerterAddress { get; set; }
|
||||
/// <summary>
|
||||
/// 波特率 default(2400)
|
||||
/// </summary>
|
||||
public int Baudrate { get; set; }
|
||||
/// <summary>
|
||||
/// MeteringPort 端口就几个可以枚举。
|
||||
/// </summary>
|
||||
public int MeteringPort { get; set; }
|
||||
/// <summary>
|
||||
/// 电表密码
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
/// <summary>
|
||||
/// 采集时间间隔(分钟,如15)
|
||||
/// </summary>
|
||||
public int TimeDensity { get; set; }
|
||||
/// <summary>
|
||||
/// 该电表方案下采集项,如:0D_80
|
||||
/// </summary>
|
||||
public string ItemCodes { get; set; }
|
||||
/// <summary>
|
||||
/// State表状态:
|
||||
/// 0新装(未下发),1运行(档案下发成功时设置状态值1), 2暂停, 100销表(销表后是否重新启用)
|
||||
/// 特定:State -1 已删除
|
||||
/// </summary>
|
||||
public int State { get; set; }
|
||||
/// <summary>
|
||||
/// 是否自动采集(0:主动采集,1:自动采集)
|
||||
/// </summary>
|
||||
public int AutomaticReport { get; set; }
|
||||
/// <summary>
|
||||
/// 该电表方案下采集项编号
|
||||
/// </summary>
|
||||
public string DataTypes { get; set; }
|
||||
/// <summary>
|
||||
/// 品牌型号
|
||||
/// </summary>
|
||||
public string BrandType { get; set; }
|
||||
/// <summary>
|
||||
/// 采集器编号
|
||||
/// </summary>
|
||||
public string GatherCode { get; set; }
|
||||
/// <summary>
|
||||
/// 是否特殊表
|
||||
/// </summary>
|
||||
public int Special { get; set; }
|
||||
/// <summary>
|
||||
/// 费率类型,单、多 (SingleRate :单费率(单相表1),多费率(其他0) ,与TypeName字段无关)
|
||||
/// SingleRate ? "单" : "复"
|
||||
/// [SingleRate] --0 复费率 false , 1 单费率 true (与PayPlanID保持一致)
|
||||
///对应 TB_PayPlan.Type: 1复费率,2单费率
|
||||
/// </summary>
|
||||
public bool SingleRate { get; set; }
|
||||
public int ProjectID { get; set; }
|
||||
/// <summary>
|
||||
/// 是否异常集中器 0:正常,1异常
|
||||
/// </summary>
|
||||
public int AbnormalState { get; set; }
|
||||
public DateTime LastTime { get; set; }
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,6 @@ using FreeSql;
|
||||
using JiShe.CollectBus.FreeRedisProvider;
|
||||
using JiShe.CollectBus.FreeSql;
|
||||
using JiShe.CollectBus.Localization;
|
||||
using JiShe.CollectBus.Workers.DTO.Energy;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
@ -15,30 +14,11 @@ namespace JiShe.CollectBus;
|
||||
public abstract class CollectBusAppService : ApplicationService
|
||||
{
|
||||
public IFreeSqlProvider SqlProvider => LazyServiceProvider.LazyGetRequiredService<IFreeSqlProvider>();
|
||||
protected IRedisClient? FreeRedis => LazyServiceProvider.LazyGetService<IFreeRedisProviderService>()?.FreeRedis;
|
||||
protected IFreeRedisProviderService FreeRedisProvider => LazyServiceProvider.LazyGetService<IFreeRedisProviderService>()!;
|
||||
|
||||
protected CollectBusAppService()
|
||||
{
|
||||
LocalizationResource = typeof(CollectBusResource);
|
||||
ObjectMapperContext = typeof(CollectBusApplicationModule);
|
||||
}
|
||||
|
||||
|
||||
#region 能耗相关
|
||||
/// <summary>
|
||||
/// 查找当前采集器下所有电表
|
||||
/// </summary>
|
||||
/// <param name="gatherCode">采集端Code</param>
|
||||
/// <returns></returns>
|
||||
protected async Task<List<EnergyAmmeterInfoDto>> GetAmmetersByGatherCode(string gatherCode = "V4-Gather-8890")
|
||||
{
|
||||
string sql = $@"SELECT C.ID,C.Name,C.FocusID,C.SingleRate,C.MeteringCode,C.Code AS BrandType,C.Baudrate,C.Password,C.MeteringPort,C.[Address] AS AmmerterAddress,C.TypeName,C.Protocol,C.TripState,C.[State],B.[Address],B.AreaCode,B.AutomaticReport,D.DataTypes,B.TimeDensity,A.GatherCode,C.Special,C.[ProjectID],B.AbnormalState,B.LastTime
|
||||
FROM TB_GatherInfo(NOLOCK) AS A
|
||||
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_AmmeterGatherItem(NOLOCK) AS D ON C.ID = D.AmmeterID AND D.State>=0
|
||||
WHERE A.GatherCode = {gatherCode}";
|
||||
return await SqlProvider.Instance.Change(DbEnum.EnergyDB).Select<EnergyAmmeterInfoDto>(sql).ToListAsync();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -0,0 +1,137 @@
|
||||
using FreeRedis;
|
||||
using JiShe.CollectBus.Ammeters;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Watermeter;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Application.Services;
|
||||
|
||||
namespace JiShe.CollectBus.Workers
|
||||
{
|
||||
/// <summary>
|
||||
/// 定时采集服务
|
||||
/// </summary>
|
||||
public abstract class BasicScheduledMeterReadingService : CollectBusAppService, IScheduledMeterReadingService
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统类型
|
||||
/// </summary>
|
||||
public abstract string SystemType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取电表信息
|
||||
/// </summary>
|
||||
/// <param name="gatherCode">采集端Code</param>
|
||||
/// <returns></returns>
|
||||
public virtual Task<List<AmmeterInfo>> GetAmmeterInfoList(string gatherCode = "")
|
||||
{
|
||||
throw new NotImplementedException($"{nameof(GetAmmeterInfoList)}请根据不同系统类型进行实现");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化电表缓存数据
|
||||
/// </summary>
|
||||
/// <param name="gatherCode">采集端Code</param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task InitAmmeterCacheData(string gatherCode = "")
|
||||
{
|
||||
var meterInfos = await GetAmmeterInfoList(gatherCode);
|
||||
if (meterInfos == null || meterInfos.Count <= 0)
|
||||
{
|
||||
throw new NullReferenceException($"{nameof(InitWatermeterCacheData)} 初始化电表缓存数据时,电表数据为空");
|
||||
}
|
||||
|
||||
//将表计信息根据集中器分组
|
||||
var meterInfoGroup = meterInfos.GroupBy(x => x.FocusAddress).ToList();
|
||||
foreach (var item in meterInfoGroup)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(item.Key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var redisCacheKey = $"{string.Format(FreeRedisConst.CacheAmmeterInfoKey, SystemTypeConst.Energy)}{item.Key}";
|
||||
Dictionary<string, AmmeterInfo> keyValuePairs = new Dictionary<string, AmmeterInfo>();
|
||||
foreach (var subItem in item)
|
||||
{
|
||||
|
||||
keyValuePairs.TryAdd($"{subItem.ID}", subItem);
|
||||
}
|
||||
await FreeRedisProvider.FreeRedis.HSetAsync(redisCacheKey, keyValuePairs);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取水表信息
|
||||
/// </summary>
|
||||
/// <param name="gatherCode">采集端Code</param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<List<WatermeterInfo>> GetWatermeterInfoList(string gatherCode = "")
|
||||
{
|
||||
throw new NotImplementedException($"{nameof(GetWatermeterInfoList)}请根据不同系统类型进行实现");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化水表缓存数据
|
||||
/// </summary>
|
||||
/// <param name="gatherCode">采集端Code</param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task InitWatermeterCacheData(string gatherCode = "")
|
||||
{
|
||||
var meterInfos = await GetWatermeterInfoList(gatherCode);
|
||||
if (meterInfos == null || meterInfos.Count <= 0)
|
||||
{
|
||||
throw new NullReferenceException($"{nameof(InitWatermeterCacheData)} 初始化水表缓存数据时,水表数据为空");
|
||||
}
|
||||
|
||||
//将表计信息根据集中器分组
|
||||
var meterInfoGroup = meterInfos.GroupBy(x => x.FocusAddress).ToList();
|
||||
foreach (var item in meterInfoGroup)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(item.Key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var redisCacheKey = $"{string.Format(FreeRedisConst.CacheWatermeterInfoKey, SystemTypeConst.Energy)}{item.Key}";
|
||||
Dictionary<string, WatermeterInfo> keyValuePairs = new Dictionary<string, WatermeterInfo>();
|
||||
foreach (var subItem in item)
|
||||
{
|
||||
|
||||
keyValuePairs.TryAdd($"{subItem.ID}", subItem);
|
||||
}
|
||||
await FreeRedisProvider.FreeRedis.HSetAsync(redisCacheKey, keyValuePairs);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 1分钟采集电表数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual Task ScheduledMeterOneMinuteReading()
|
||||
{
|
||||
throw new NotImplementedException($"{nameof(ScheduledMeterOneMinuteReading)}请根据不同系统类型进行实现");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 5分钟采集电表数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual Task ScheduledMeterFiveMinuteReading()
|
||||
{
|
||||
throw new NotImplementedException($"{nameof(ScheduledMeterFiveMinuteReading)}请根据不同系统类型进行实现");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 15分钟采集电表数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual Task ScheduledMeterFifteenMinuteReading()
|
||||
{
|
||||
throw new NotImplementedException($"{nameof(ScheduledMeterFifteenMinuteReading)}请根据不同系统类型进行实现");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,103 @@
|
||||
using FreeRedis;
|
||||
using JiShe.CollectBus.Ammeters;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.FreeRedisProvider;
|
||||
using JiShe.CollectBus.FreeSql;
|
||||
using JiShe.CollectBus.Watermeter;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace JiShe.CollectBus.Workers
|
||||
{
|
||||
/// <summary>
|
||||
/// 能耗系统定时采集服务
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
//[Route($"/energy/app/scheduled")]
|
||||
public class EnergySystemScheduledMeterReadingService : BasicScheduledMeterReadingService
|
||||
{
|
||||
public sealed override string SystemType => SystemTypeConst.Energy;
|
||||
|
||||
/// <summary>
|
||||
/// 获取电表信息
|
||||
/// </summary>
|
||||
/// <param name="gatherCode">采集端Code</param>
|
||||
/// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route($"ammeter/list")]
|
||||
public override async Task<List<AmmeterInfo>> GetAmmeterInfoList(string gatherCode = "V4-Gather-8890")
|
||||
{
|
||||
string sql = $@"SELECT C.ID,C.Name,C.FocusID,C.SingleRate,C.MeteringCode,C.Code AS BrandType,C.Baudrate,C.Password,C.MeteringPort,C.[Address] AS AmmerterAddress,C.TypeName,C.Protocol,C.TripState,C.[State],B.[Address],B.AreaCode,B.AutomaticReport,D.DataTypes,B.TimeDensity,A.GatherCode,C.Special,C.[ProjectID],B.AbnormalState,B.LastTime,CONCAT(B.AreaCode, B.[Address]) AS FocusAddress
|
||||
FROM TB_GatherInfo(NOLOCK) AS A
|
||||
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_AmmeterGatherItem(NOLOCK) AS D ON C.ID = D.AmmeterID AND D.State>=0
|
||||
WHERE 1=1 ";
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(gatherCode))
|
||||
{
|
||||
sql = $@"{sql} A.GatherCode = '{gatherCode}'";
|
||||
}
|
||||
return await SqlProvider.Instance.Change(DbEnum.EnergyDB)
|
||||
.Ado
|
||||
.QueryAsync<AmmeterInfo>(sql);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取水表信息
|
||||
/// </summary>
|
||||
/// <param name="gatherCode">采集端Code</param>
|
||||
/// <returns></returns>
|
||||
//[HttpGet]
|
||||
//[Route($"ammeter/list")]
|
||||
public override async Task<List<WatermeterInfo>> GetWatermeterInfoList(string gatherCode = "V4-Gather-8890")
|
||||
{
|
||||
string sql = $@"SELECT
|
||||
A.ID,
|
||||
A.Name,
|
||||
A.FocusID,
|
||||
A.MeteringCode,
|
||||
A.Baudrate,
|
||||
A.MeteringPort,
|
||||
A.[Address] AS MeterAddress,
|
||||
A.[Password],
|
||||
A.TypeName,
|
||||
A.Protocol,
|
||||
A.Code,
|
||||
A.LinkType,
|
||||
A.HaveValve,
|
||||
A.MeterType AS MeterTypeName,
|
||||
A.MeterBrand,
|
||||
A.TimesRate,
|
||||
A.TimeDensity,
|
||||
A.TripState,
|
||||
B.[Address],
|
||||
B.AreaCode,
|
||||
B.AutomaticReport,
|
||||
A.[State],
|
||||
C.GatherCode,
|
||||
A.[ProjectID],
|
||||
B.AbnormalState,
|
||||
B.LastTime
|
||||
FROM [dbo].[TB_WatermeterInfo](NOLOCK) AS A
|
||||
INNER JOIN [dbo].[TB_FocusInfo](NOLOCK) AS B ON A.FocusID=B.ID AND B.RemoveState >= 0 AND B.State>=0
|
||||
INNER JOIN [dbo].[TB_GatherInfo](NOLOCK) AS C ON B.GatherInfoID=C.ID
|
||||
WHERE A.State>=0 AND A.State<100 ";
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(gatherCode))
|
||||
{
|
||||
sql = $@"{sql} AND C.GatherCode= '{gatherCode}'";
|
||||
}
|
||||
return await SqlProvider.Instance.Change(DbEnum.EnergyDB)
|
||||
.Ado
|
||||
.QueryAsync<WatermeterInfo>(sql);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
using FreeRedis;
|
||||
using JiShe.CollectBus.FreeRedisProvider;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace JiShe.CollectBus.Workers
|
||||
{
|
||||
/// <summary>
|
||||
/// 定时采集服务
|
||||
/// </summary>
|
||||
public class ScheduledMeterReadingService : CollectBusAppService, IScheduledMeterReadingService
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化能耗电表数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task InitEnergyAmmeterData()
|
||||
{
|
||||
var ammerterList = await GetAmmetersByGatherCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,7 @@ using JiShe.CollectBus.Devices;
|
||||
using JiShe.CollectBus.MessageReceiveds;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TouchSocket.Sockets;
|
||||
@ -19,6 +20,7 @@ namespace JiShe.CollectBus.Subscribers
|
||||
/// <summary>
|
||||
/// 定时抄读任务消息消费订阅
|
||||
/// </summary>
|
||||
[Route($"/worker/app/subscriber")]
|
||||
public class WorkerSubscriberAppService : CollectBusAppService, IWorkerSubscriberAppService,ICapSubscribe
|
||||
{
|
||||
private readonly ILogger<WorkerSubscriberAppService> _logger;
|
||||
@ -45,6 +47,8 @@ namespace JiShe.CollectBus.Subscribers
|
||||
/// </summary>
|
||||
/// <param name="receivedMessage"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("oneminute/issued-event")]
|
||||
[CapSubscribe(ProtocolConst.SubscriberWorkerOneMinuteIssuedEventName)]
|
||||
public async Task ScheduledMeterOneMinuteReadingIssuedEvent(IssuedEventMessage receivedMessage)
|
||||
{
|
||||
@ -65,6 +69,8 @@ namespace JiShe.CollectBus.Subscribers
|
||||
/// </summary>
|
||||
/// <param name="receivedMessage"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("fiveminute/issued-event")]
|
||||
[CapSubscribe(ProtocolConst.SubscriberWorkerOneMinuteIssuedEventName)]
|
||||
public async Task ScheduledMeterFiveMinuteReadingIssuedEvent(IssuedEventMessage receivedMessage)
|
||||
{
|
||||
@ -85,6 +91,8 @@ namespace JiShe.CollectBus.Subscribers
|
||||
/// </summary>
|
||||
/// <param name="receivedMessage"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("fifteenminute/issued-event")]
|
||||
[CapSubscribe(ProtocolConst.SubscriberWorkerOneMinuteIssuedEventName)]
|
||||
public async Task ScheduledMeterFifteenMinuteReadingIssuedEvent(IssuedEventMessage receivedMessage)
|
||||
{
|
||||
|
||||
@ -12,9 +12,15 @@ namespace JiShe.CollectBus.Common.Consts
|
||||
/// 缓存基础目录
|
||||
/// </summary>
|
||||
public const string CacheBasicDirectoryKey = "CollectBus:";
|
||||
|
||||
/// <summary>
|
||||
/// 缓存电表信息
|
||||
/// </summary>
|
||||
public const string CacheAmmeterInfoKey = $"{CacheBasicDirectoryKey}AmmeterInfo:";
|
||||
public const string CacheAmmeterInfoKey = $"{CacheBasicDirectoryKey}{"{0}"}:AmmeterInfo:";
|
||||
|
||||
/// <summary>
|
||||
/// 缓存水表信息
|
||||
/// </summary>
|
||||
public const string CacheWatermeterInfoKey = $"{CacheBasicDirectoryKey}{"{0}"}:WatermeterInfo:";
|
||||
}
|
||||
}
|
||||
|
||||
24
src/JiShe.CollectBus.Common/Consts/SystemTypeConst.cs
Normal file
24
src/JiShe.CollectBus.Common/Consts/SystemTypeConst.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.CollectBus.Common.Consts
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统类型常量
|
||||
/// </summary>
|
||||
public class SystemTypeConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 预付费系统
|
||||
/// </summary>
|
||||
public const string Prepay = "Prepay";
|
||||
|
||||
/// <summary>
|
||||
/// 能耗系统
|
||||
/// </summary>
|
||||
public const string Energy = "Energy";
|
||||
}
|
||||
}
|
||||
53
src/JiShe.CollectBus.Common/Enums/MeterTypeEnum.cs
Normal file
53
src/JiShe.CollectBus.Common/Enums/MeterTypeEnum.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.CollectBus.Common.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// 表计类型
|
||||
/// 电表= 1,水表= 2,燃气表= 3,热能表= 4,水表流量计=5,燃气表流量计=6
|
||||
/// </summary>
|
||||
public enum MeterTypeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 电表
|
||||
/// </summary>
|
||||
Ammeter = 1,
|
||||
/// <summary>
|
||||
/// 水表
|
||||
/// </summary>
|
||||
WaterMeter = 2,
|
||||
/// <summary>
|
||||
/// 燃气表
|
||||
/// </summary>
|
||||
Gasmeter = 3,
|
||||
/// <summary>
|
||||
/// 热能表
|
||||
/// </summary>
|
||||
HeatMeter = 4,
|
||||
/// <summary>
|
||||
/// 水表流量计
|
||||
/// </summary>
|
||||
WaterMeterFlowmeter = 5,
|
||||
/// <summary>
|
||||
/// 燃气表流量计
|
||||
/// </summary>
|
||||
GasmeterFlowmeter = 6,
|
||||
/// <summary>
|
||||
/// 特殊电表
|
||||
/// </summary>
|
||||
SpecialAmmeter = 7,
|
||||
/// <summary>
|
||||
/// 传感器
|
||||
/// </summary>
|
||||
Sensor = 8,
|
||||
|
||||
/// <summary>
|
||||
/// 采集器
|
||||
/// </summary>
|
||||
Collector = 9,
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,7 @@ namespace JiShe.CollectBus.Ammeters
|
||||
/// 电表ID
|
||||
/// </summary>
|
||||
public int ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电表名称
|
||||
/// </summary>
|
||||
@ -22,6 +23,11 @@ namespace JiShe.CollectBus.Ammeters
|
||||
/// </summary>
|
||||
public int FocusID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 集中器地址
|
||||
/// </summary>
|
||||
public string FocusAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 集中器地址
|
||||
/// </summary>
|
||||
@ -129,16 +135,12 @@ namespace JiShe.CollectBus.Ammeters
|
||||
/// 项目ID
|
||||
/// </summary>
|
||||
public int ProjectID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否异常集中器 0:正常,1异常
|
||||
/// </summary>
|
||||
public int AbnormalState { get; set; }
|
||||
|
||||
public DateTime LastTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 集中器地址
|
||||
/// </summary>
|
||||
public string FocusAddress { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,24 +1,30 @@
|
||||
using System;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JiShe.CollectBus.Workers.DTO.Energy
|
||||
namespace JiShe.CollectBus.Watermeter
|
||||
{
|
||||
/// <summary>
|
||||
/// 能耗电表信息数据模型
|
||||
/// 水表信息
|
||||
/// </summary>
|
||||
public class EnergyAmmeterInfoDto
|
||||
public class WatermeterInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 电表ID
|
||||
/// 水表ID
|
||||
/// </summary>
|
||||
public int ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电表名称
|
||||
/// 水表名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// 表密码
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 集中器ID
|
||||
@ -28,40 +34,13 @@ namespace JiShe.CollectBus.Workers.DTO.Energy
|
||||
/// <summary>
|
||||
/// 集中器地址
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 集中器区域代码
|
||||
/// </summary>
|
||||
public string AreaCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电表类别 (1单相、2三相三线、3三相四线),
|
||||
/// 07协议: 开合闸指令(1A开闸断电,1C单相表合闸,1B多相表合闸) 645 2007 表
|
||||
/// 97协议://true(合闸);false(跳闸) 545 1997 没有单相多相 之分 "true" ? "9966" : "3355"
|
||||
/// </summary>
|
||||
public int TypeName { get; set; }
|
||||
/// <summary>
|
||||
/// 跳合闸状态字段: 0 合闸,1 跳闸
|
||||
/// 电表:TripState (0 合闸-通电, 1 断开、跳闸);
|
||||
/// </summary>
|
||||
public int TripState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 规约 -电表default(30) 1:97协议,30:07协议
|
||||
/// </summary>
|
||||
public int? Protocol { get; set; }
|
||||
public string FocusAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 一个集中器下的[MeteringCode]必须唯一。 PN
|
||||
/// </summary>
|
||||
public int MeteringCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电表通信地址
|
||||
/// </summary>
|
||||
public string AmmerterAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 波特率 default(2400)
|
||||
/// </summary>
|
||||
@ -73,74 +52,107 @@ namespace JiShe.CollectBus.Workers.DTO.Energy
|
||||
public int MeteringPort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电表密码
|
||||
/// 水表通信地址 (当protocol=32时,Address为14位字符;否则12位字符)
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
public string MeterAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 采集时间间隔(分钟,如15)
|
||||
/// 水表类别 (水表类型改成“公称口径”)
|
||||
/// </summary>
|
||||
public int TimeDensity { get; set; }
|
||||
public string TypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 该电表方案下采集项,如:0D_80
|
||||
/// 规约 -电表default(30) 1:97协议,30:07协议,32:CJ/T 188—2018协议
|
||||
/// </summary>
|
||||
public string ItemCodes { get; set; }
|
||||
public int? Protocol { get; set; }
|
||||
|
||||
|
||||
public string Code { get; set; }
|
||||
/// <summary>
|
||||
/// 通讯方案:
|
||||
/// NB-IOT常德水表、NB-IOT泽联电表、GPRS华立水表、
|
||||
/// RS-485、无线、载波
|
||||
/// </summary>
|
||||
public string LinkType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// HaveValve: 是否带阀 (0 不带阀, 1 带阀)
|
||||
/// 注意:NULL表示未设置
|
||||
/// </summary>
|
||||
public int? HaveValve { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备类型: 水表\气表、流量计
|
||||
/// </summary>
|
||||
public string MeterTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 表计类型
|
||||
//// 电表= 1,水表= 2,燃气表= 3,热能表= 4,水表流量计=5,燃气表流量计=6,特殊电表=7
|
||||
/// </summary>
|
||||
public MeterTypeEnum MeterType { get; set; }
|
||||
/// <summary>
|
||||
/// 设备品牌;
|
||||
/// (当 MeterType = 水表, 如 威铭、捷先 等)
|
||||
/// (当 MeterType = 流量计, 如 西恩超声波流量计、西恩电磁流量计、涡街流量计 等)
|
||||
/// </summary>
|
||||
public string MeterBrand { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 倍率
|
||||
/// </summary>
|
||||
public decimal TimesRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 集中器地址
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 网关地址
|
||||
/// </summary>
|
||||
public string GateAddress { get; set; }
|
||||
/// <summary>
|
||||
/// 集中器区域
|
||||
/// </summary>
|
||||
public string AreaCode { get; set; }
|
||||
/// <summary>
|
||||
/// 通讯状态
|
||||
/// 水表:TripState (0 合闸-开阀, 1 关阀);开阀关阀
|
||||
/// </summary>
|
||||
public int TripState { get; set; }
|
||||
/// <summary>
|
||||
/// 是否自动采集
|
||||
/// </summary>
|
||||
public int AutomaticReport { get; set; }
|
||||
/// <summary>
|
||||
/// State表状态:
|
||||
/// 0新装(未下发),1运行(档案下发成功时设置状态值1), 2暂停, 100销表(销表后是否重新启用)
|
||||
/// 特定:State -1 已删除
|
||||
/// </summary>
|
||||
public int State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否自动采集(0:主动采集,1:自动采集)
|
||||
/// 采集时间间隔(分钟,如15)
|
||||
/// </summary>
|
||||
public int AutomaticReport { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 该电表方案下采集项编号
|
||||
/// </summary>
|
||||
public string DataTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 品牌型号
|
||||
/// </summary>
|
||||
public string BrandType { get; set; }
|
||||
|
||||
public int TimeDensity { get; set; }
|
||||
/// <summary>
|
||||
/// 采集器编号
|
||||
/// </summary>
|
||||
public string GatherCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否特殊表
|
||||
/// </summary>
|
||||
public int Special { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 费率类型,单、多 (SingleRate :单费率(单相表1),多费率(其他0) ,与TypeName字段无关)
|
||||
/// SingleRate ? "单" : "复"
|
||||
/// [SingleRate] --0 复费率 false , 1 单费率 true (与PayPlanID保持一致)
|
||||
///对应 TB_PayPlan.Type: 1复费率,2单费率
|
||||
/// </summary>
|
||||
public bool SingleRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 项目ID
|
||||
/// </summary>
|
||||
public int ProjectID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否异常集中器 0:正常,1异常
|
||||
/// </summary>
|
||||
public int AbnormalState { get; set; }
|
||||
|
||||
public DateTime LastTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 集中器地址
|
||||
/// 集中器最后在线时间
|
||||
/// </summary>
|
||||
public string FocusAddress { get; set; }
|
||||
public DateTime LastTime { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user