抄读接口

This commit is contained in:
Dai Mr 2024-12-27 17:00:31 +08:00
parent 9705c2f67a
commit 8250cf1e0c
12 changed files with 1453 additions and 82 deletions

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JiShe.CollectBus.EnergySystem.Dto
{
/// <summary>
/// 集中器上下线、心跳记录
/// </summary>
public class AddFocusLogInput
{
/// <summary>
/// 集中器编号
/// </summary>
public string Address { get; set; }
/// <summary>
/// 采集主站
/// </summary>
public string GatherServerId { get; set; }
/// <summary>
/// 间隔时间 DateTime.Now.Minute - LogTime.Minute
/// </summary>
public string IntervalTime { get; set; }
/// <summary>
/// 离/在线发生时间
/// </summary>
public DateTime LogTime { get; set; }
/// <summary>
/// HeartBeat 终端心跳SignIn 终端登录SignOut 终端登出
/// </summary>
public string LogType { get; set; }
public string Remark { get; set; }
}
}

View File

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JiShe.CollectBus.EnergySystem.Dto
{
/// <summary>
/// 记录信号强度
/// </summary>
public class AddSignalStrengthInput
{
/// <summary>
/// 区域编号
/// </summary>
public string AreaCode { get; set; }
/// <summary>
/// 区域地址
/// </summary>
public string Address { get; set; }
/// <summary>
/// 1电表 2水表 3集中器
/// </summary>
public int DeviceType { get; set; }
/// <summary>
/// 信号强度
/// </summary>
public string Csq { get; set; }
}
}

View File

@ -91,7 +91,7 @@ namespace JiShe.CollectBus.EnergySystem.Dto
public int DecimalCount { get; set; } public int DecimalCount { get; set; }
/// <summary> /// <summary>
/// 器地址 /// 集器地址
/// </summary> /// </summary>
public string GatherAddress { get; set; } public string GatherAddress { get; set; }

View File

@ -14,7 +14,7 @@ namespace JiShe.CollectBus.EnergySystem.Dto
/// <summary> /// <summary>
/// 电表ID /// 电表ID
/// </summary> /// </summary>
public string AmmeterId { get; set; } public int AmmeterId { get; set; }
/// <summary> /// <summary>
///采集编码 {"0C_129", "0C_131"}, 采集编码.0C_129:正向有功C_131:反向有功 ///采集编码 {"0C_129", "0C_131"}, 采集编码.0C_129:正向有功C_131:反向有功

View File

@ -41,18 +41,18 @@ namespace JiShe.CollectBus.EnergySystem.Dto
/// </summary> /// </summary>
public string Month { get; set; } public string Month { get; set; }
public List<TimeSetDataDataInput> Data { get; set; } public List<TimeSetMutileRateDetailInput> Data { get; set; }
} }
public class TimeSetDataDataInput public class TimeSetMutileRateDetailInput
{ {
public string Rate { get; set; } public string Rate { get; set; }
public List<TimeSetDataDataTimeInput> Times { get; set; } public List<TimeSetTimesInput> Times { get; set; }
} }
public class TimeSetDataDataTimeInput public class TimeSetTimesInput
{ {
public string StartTime { get; set; } public string StartTime { get; set; }

View File

@ -124,4 +124,25 @@ public interface IEnergySystemAppService : IApplicationService
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
Task<BaseResultDto> AdjustMeterTiming(AdjustMeterTimingInput input); Task<BaseResultDto> AdjustMeterTiming(AdjustMeterTimingInput input);
/// <summary>
/// 更新集中器在线记录
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task<BaseResultDto> AddConrOnlineRecord(AddConrOnlineRecordInput input);
/// <summary>
/// 记录信号强度
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task<BaseResultDto> AddSignalStrength(AddSignalStrengthInput input);
/// <summary>
/// 集中器上下线、心跳记录
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task<BaseResultDto> AddFocusLog(AddFocusLogInput input);
} }

View File

@ -1,95 +1,542 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using DotNetCore.CAP;
using JiShe.CollectBus.Common.Enums;
using JiShe.CollectBus.Common.Extensions;
using JiShe.CollectBus.Common.Models;
using JiShe.CollectBus.EnergySystem.Dto; using JiShe.CollectBus.EnergySystem.Dto;
using JiShe.CollectBus.FreeSql;
using JiShe.CollectBus.PrepayModel;
using JiShe.CollectBus.Protocol.Contracts;
using MassTransit;
using Newtonsoft.Json;
namespace JiShe.CollectBus.EnergySystem namespace JiShe.CollectBus.EnergySystem
{ {
public class EnergySystemAppService: CollectBusAppService,IEnergySystemAppService public class EnergySystemAppService: CollectBusAppService,IEnergySystemAppService
{ {
public Task<BaseResultDto<ValveControlOutput>> ValveControl(ValveControlInput input) private readonly ICapPublisher _capBus;
public EnergySystemAppService(ICapPublisher capBus)
{ {
throw new NotImplementedException(); _capBus = capBus;
} }
public Task<BaseResultDto<ReadTimeOutput>> ReadTime(ReadTimeInput input) /// <summary>
/// 电表、水表阀控 透明转发
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<BaseResultDto<ValveControlOutput>> ValveControl(ValveControlInput input)
{ {
throw new NotImplementedException(); var result = new BaseResultDto<ValveControlOutput>();
byte[] bytes = null;
var state = input.TripState == 0 ? true : false;
var address = $"{input.AreaCode}{input.Address}";
if (input.MeterType == 1)
{
var ammeter = await SqlProvider.Instance.Change(DbEnum.EnergyDB).Select<Vi_BaseAmmeterInfo>().Where(d => d.ID == input.AmmeterId).FirstAsync();
if (ammeter == null) return result;
var dataUnit =
HexStringExtensions.BuildAmmeterValveControlSendDataUnit(ammeter.Address, "", ammeter.Password,
state);
bytes = HexStringExtensions.BuildTransparentForwardingSendCmd(address, ammeter.PortNumber ?? 2, ammeter.BaudRate, dataUnit);
}
else if(input.MeterType == 2)
{
//TODO:水表阀控
}
if (bytes == null)
return result;
await _capBus.PublishAsync(ProtocolConst.SubscriberIssuedEventName, new IssuedEventMessage
{
//ClientId = messageReceived.ClientId,
DeviceNo = address,
Message = bytes,
Type = IssuedEventType.Data,
MessageId = NewId.NextGuid().ToString()
});
result.Status = true;
result.Msg = "操作成功";
result.Data.ValidData = true;
return result;
} }
public Task<BaseResultDto<AmmeterArchivesDownOutput>> AmmeterArchivesDown(AmmeterArchivesDownInput input) /// <summary>
/// 批量抄读时段 透明转发
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<BaseResultDto<ReadTimeOutput>> ReadTime(ReadTimeInput input)
{ {
throw new NotImplementedException(); var result = new BaseResultDto<ReadTimeOutput>
{
Data = new ReadTimeOutput()
};
var ammeter = await SqlProvider.Instance.Change(DbEnum.EnergyDB).Select<Vi_BaseAmmeterInfo>().Where(d => d.ID == input.AmmeterId).FirstAsync();
if (ammeter == null) return result;
var address = $"{input.AreaCode}{input.Address}";
var bytesList = HexStringExtensions.BuildReadMeterTimeSetSendCmd(address, ammeter.Code, ammeter.Address, ammeter.Password,
ammeter.PortNumber ?? 2, ammeter.BaudRate);
foreach (var bytes in bytesList)
{
await _capBus.PublishAsync(ProtocolConst.SubscriberIssuedEventName, new IssuedEventMessage
{
//ClientId = messageReceived.ClientId,
DeviceNo = address,
Message = bytes,
Type = IssuedEventType.Data,
MessageId = NewId.NextGuid().ToString()
});
}
return result;
} }
/// <summary>
/// 档案下发 AFN:04 FN:10
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<BaseResultDto<AmmeterArchivesDownOutput>> AmmeterArchivesDown(AmmeterArchivesDownInput input)
{
var result = new BaseResultDto<AmmeterArchivesDownOutput>();
var address = $"{input.AreaCode}{input.Address}";
var meterParameters = input.Details.Data.Select(it => new AmmeterParameter()
{
SerialNumber = it.SerialNumber,
Pn = it.Pn,
BaudRate = HexStringExtensions.GetBaudreate(it.Rate.ToString()),
Port = it.Port,
ProtocolType = HexStringExtensions.GetProtocolType(it.AgreementType),
Address = it.Addrress,
Password = it.Password.ToString(),
RateNumber = it.RatesCount,
IntegerBitNumber = it.IntegerCount,
DecimalBitNumber = it.DecimalCount,
CollectorAddress = it.GatherAddress,
//UserCategoryNumber = it.UserBigNumber,
//UserSubclassNumber = it.UserSmallNumber
}).ToList();
var bytes = HexStringExtensions.BuildAmmeterParameterSetSendCmd(address, meterParameters);
await _capBus.PublishAsync(ProtocolConst.SubscriberIssuedEventName, new IssuedEventMessage
{
//ClientId = messageReceived.ClientId,
DeviceNo = address,
Message = bytes,
Type = IssuedEventType.Data,
MessageId = NewId.NextGuid().ToString()
});
result.Status = true;
result.Msg = "操作成功";
result.Data.ValidData = true;
return result;
}
/// <summary>
/// 一键匹配 透明转发
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<BaseResultDto> AmmeterArchivesMatch(AmmeterArchivesMatchInput input) public Task<BaseResultDto> AmmeterArchivesMatch(AmmeterArchivesMatchInput input)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<BaseResultDto> CommunicationParametersSet(CommunicationParametersSetInput input) /// <summary>
/// 通讯参数设置 AFN:04 FN:3
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<BaseResultDto> CommunicationParametersSet(CommunicationParametersSetInput input)
{ {
throw new NotImplementedException(); var result = new BaseResultDto();
var address = $"{input.AreaCode}{input.Address}";
var masterIPAndPortArr = input.Data.MasterIPandPort.Split(':');
var masterIP = masterIPAndPortArr[0];
var materPort = masterIPAndPortArr[1];
if (!masterIP.IsValidIPv4() || !materPort.IsValidPort())
{
result.Status = false;
result.Msg = "主站IP和端口格式错误";
return result;
}
var backupIPAndPortArr = input.Data.BackupIPandPort.Split(':');
var backupIP = backupIPAndPortArr[0];
var backupPort = backupIPAndPortArr[1];
if (!backupIP.IsValidIPv4() || !backupPort.IsValidPort())
{
result.Status = false;
result.Msg = "主站IP和端口格式错误";
return result;
}
var bytes = HexStringExtensions.BuildCommunicationParametersSetSendCmd(address, masterIP, materPort,
backupIP, backupPort, input.Data.APN);
await _capBus.PublishAsync(ProtocolConst.SubscriberIssuedEventName, new IssuedEventMessage
{
//ClientId = messageReceived.ClientId,
DeviceNo = address,
Message = bytes,
Type = IssuedEventType.Data,
MessageId = NewId.NextGuid().ToString()
});
result.Status = true;
result.Msg = "操作成功";
return result;
} }
public Task<BaseResultDto> CallTimeTesting(CallTimeTestingInput input) /// <summary>
/// 召测时间 AFN:0C FN:2
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<BaseResultDto> CallTimeTesting(CallTimeTestingInput input)
{ {
throw new NotImplementedException(); var result = new BaseResultDto();
var address = $"{input.AreaCode}{input.Address}";
var bytes = HexStringExtensions.BuildTerminalCalendarClockSendCmd(address);
await _capBus.PublishAsync(ProtocolConst.SubscriberIssuedEventName, new IssuedEventMessage
{
//ClientId = messageReceived.ClientId,
DeviceNo = address,
Message = bytes,
Type = IssuedEventType.Data,
MessageId = NewId.NextGuid().ToString()
});
result.Status = true;
result.Msg = "操作成功";
return result;
} }
public Task<BaseResultDto> TimeAdjust(TimeAdjustInput input) /// <summary>
/// 时间校准 AFN:05 FN:31
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<BaseResultDto> TimeAdjust(TimeAdjustInput input)
{ {
throw new NotImplementedException(); var result = new BaseResultDto();
var address = $"{input.AreaCode}{input.Address}";
var bytes = HexStringExtensions.BuildConrCheckTimeSendCmd(address,DateTime.Now);
await _capBus.PublishAsync(ProtocolConst.SubscriberIssuedEventName, new IssuedEventMessage
{
//ClientId = messageReceived.ClientId,
DeviceNo = address,
Message = bytes,
Type = IssuedEventType.Data,
MessageId = NewId.NextGuid().ToString()
});
result.Status = true;
result.Msg = "操作成功";
return result;
} }
public Task<BaseResultDto> TerminalRestart(TerminalRestartInput input) /// <summary>
/// 重启终端 AFN:01 FN:1
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<BaseResultDto> TerminalRestart(TerminalRestartInput input)
{ {
throw new NotImplementedException(); var result = new BaseResultDto();
var address = $"{input.AreaCode}{input.Address}";
var bytes = HexStringExtensions.BuildConrRebootSendCmd(address);
await _capBus.PublishAsync(ProtocolConst.SubscriberIssuedEventName, new IssuedEventMessage
{
//ClientId = messageReceived.ClientId,
DeviceNo = address,
Message = bytes,
Type = IssuedEventType.Data,
MessageId = NewId.NextGuid().ToString()
});
result.Status = true;
result.Msg = "操作成功";
return result;
} }
public Task<BaseResultDto<ReadMeterNumOutput>> ReadMeterNum(ReadMeterNumInput input) /// <summary>
/// 读取表号 AFN:0A FN:10
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<BaseResultDto<ReadMeterNumOutput>> ReadMeterNum(ReadMeterNumInput input)
{ {
throw new NotImplementedException(); var result = new BaseResultDto<ReadMeterNumOutput>();
var address = $"{input.AreaCode}{input.Address}";
var pnList = input.Data.Split(',').Select(it => int.Parse(it)).ToList();
var bytes = HexStringExtensions.BuildAmmeterParameterReadingSendCmd(address, pnList);
await _capBus.PublishAsync(ProtocolConst.SubscriberIssuedEventName, new IssuedEventMessage
{
//ClientId = messageReceived.ClientId,
DeviceNo = address,
Message = bytes,
Type = IssuedEventType.Data,
MessageId = NewId.NextGuid().ToString()
});
result.Status = true;
result.Msg = "操作成功";
return result;
} }
public Task<BaseResultDto<ReadingOutput>> Reading(ReadingInput input) /// <summary>
/// 随抄
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<BaseResultDto<ReadingOutput>> Reading(ReadingInput input)
{ {
throw new NotImplementedException(); var result = new BaseResultDto<ReadingOutput>();
var ammeter = await SqlProvider.Instance.Change(DbEnum.EnergyDB).Select<Vi_BaseAmmeterInfo>().Where(d => d.ID == input.AmmeterId).FirstAsync();
if (ammeter == null || !ammeter.MeterCode.HasValue) return result;
var bytesList = new List<byte[]>();
var address = $"{input.AreaCode}{input.Address}";
var itemCodeList = JsonConvert.DeserializeObject<List<string>>(input.ItemCodes);
foreach (var itemCode in itemCodeList)
{
var itemCodeArr = itemCode.Split('_');
var aFN = (AFN)itemCodeArr[0].HexToDec();
var fn = int.Parse(itemCodeArr[1]);
if (aFN == AFN.)
{
var bytes = HexStringExtensions.BuildAmmeterReadRealTimeDataSendCmd(address, ammeter.MeterCode.Value, (ATypeOfDataItems)fn);
bytesList.Add(bytes);
}
else if (aFN == AFN.)
{
var density = (FreezeDensity)input.Density;
var bytes = HexStringExtensions.BuildAmmeterReadingIIdataTypeItemsSendCmd(address, ammeter.MeterCode.Value, (IIdataTypeItems)fn, density,0);
bytesList.Add(bytes);
}
}
foreach (var bytes in bytesList)
{
await _capBus.PublishAsync(ProtocolConst.SubscriberIssuedEventName, new IssuedEventMessage
{
//ClientId = messageReceived.ClientId,
DeviceNo = address,
Message = bytes,
Type = IssuedEventType.Data,
MessageId = NewId.NextGuid().ToString()
});
}
result.Status = true;
result.Msg = "操作成功";
return result;
} }
public Task<BaseResultDto> TimeSet(TimeSetInput input) /// <summary>
/// 设置时间段 透明转发
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<BaseResultDto> TimeSet(TimeSetInput input)
{ {
throw new NotImplementedException(); var result = new BaseResultDto();
var ammeter = await SqlProvider.Instance.Change(DbEnum.EnergyDB).Select<Vi_BaseAmmeterInfo>().Where(d => d.ID == input.MeterID).FirstAsync();
if (ammeter == null) return result;
var address = input.FocusCode;
var timeDataList = input.Data.Select(it => new TimeSetDetail()
{
Months = it.Month.Split(',').Select(m => int.Parse(m)).ToArray(),
Data = it.Data.Select(d => new MutileRateDetail()
{
Rate = d.Rate,
Times = d.Times.Select(t => new Times()
{
StartTime = t.StartTime,
EndTime = t.EndTime
}).ToList()
}).ToList()
}).ToList();
var bytesList = HexStringExtensions.BuildAmmeterSetTimeSetSendCmd(address, ammeter.Code, ammeter.Address,
ammeter.PortNumber ?? 2, ammeter.BaudRate, timeDataList);
foreach (var bytes in bytesList)
{
await _capBus.PublishAsync(ProtocolConst.SubscriberIssuedEventName, new IssuedEventMessage
{
//ClientId = messageReceived.ClientId,
DeviceNo = address,
Message = bytes,
Type = IssuedEventType.Data,
MessageId = NewId.NextGuid().ToString()
});
}
result.Status = true;
result.Msg = "操作成功";
return result;
} }
/// <summary>
/// 设置自动上报采集项 数据库操作
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<BaseResultDto> AutoReportCollectionItemsSet(AutoReportCollectionItemsSetInput input) public Task<BaseResultDto> AutoReportCollectionItemsSet(AutoReportCollectionItemsSetInput input)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary>
/// 设置自动上报 数据库操作
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<BaseResultDto> AutoReportSet(AutoReportSetInput input) public Task<BaseResultDto> AutoReportSet(AutoReportSetInput input)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary>
/// 查询自动上报开启状态 数据库操作
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<BaseResultDto> QueryAutoReportOpenStatus(QueryAutoReportOpenStatusInput input) public Task<BaseResultDto> QueryAutoReportOpenStatus(QueryAutoReportOpenStatusInput input)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<BaseResultDto<BatchReadVersionOutput>> BatchReadVersion(BatchReadVersionInput input) /// <summary>
/// 批量抄读版本号 AFN:09 FN:1
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<BaseResultDto<BatchReadVersionOutput>> BatchReadVersion(BatchReadVersionInput input)
{ {
throw new NotImplementedException(); var result = new BaseResultDto<BatchReadVersionOutput>();
foreach (var data in input.Data)
{
var address = $"{data.AreaCode}{data.Address}";
var bytes = HexStringExtensions.BuildTerminalVersionInfoReadingSendCmd(address);
await _capBus.PublishAsync(ProtocolConst.SubscriberIssuedEventName, new IssuedEventMessage
{
//ClientId = messageReceived.ClientId,
DeviceNo = address,
Message = bytes,
Type = IssuedEventType.Data,
MessageId = NewId.NextGuid().ToString()
});
}
result.Status = true;
result.Msg = "操作成功";
return result;
} }
/// <summary>
/// 查询采集日志 数据库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<BaseResultDto<QueryRecordLogOutput>> QueryRecordLog(QueryRecordLogInput input) public Task<BaseResultDto<QueryRecordLogOutput>> QueryRecordLog(QueryRecordLogInput input)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<BaseResultDto> AdjustMeterTiming(AdjustMeterTimingInput input) /// <summary>
/// 校准电表时间 透明转发
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<BaseResultDto> AdjustMeterTiming(AdjustMeterTimingInput input)
{
var result = new BaseResultDto();
var ammeter = await SqlProvider.Instance.Change(DbEnum.EnergyDB).Select<Vi_BaseAmmeterInfo>().Where(d => d.Address == input.MeterAddress).FirstAsync();
if (ammeter == null) return result;
var address = $"{input.AreaCode}{input.Address}";
var bytesList = HexStringExtensions.BuildAmmeterCorrectionTimeSendCmd(address, ammeter.Code, ammeter.Address, ammeter.Password,
ammeter.PortNumber ?? 2, ammeter.BaudRate);
foreach (var bytes in bytesList)
{
await _capBus.PublishAsync(ProtocolConst.SubscriberIssuedEventName, new IssuedEventMessage
{
//ClientId = messageReceived.ClientId,
DeviceNo = address,
Message = bytes,
Type = IssuedEventType.Data,
MessageId = NewId.NextGuid().ToString()
});
}
result.Status = true;
result.Msg = "操作成功";
return result;
}
/// <summary>
/// 更新集中器在线记录 数据库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<BaseResultDto> AddConrOnlineRecord(AddConrOnlineRecordInput input)
{
throw new NotImplementedException();
}
/// <summary>
/// 记录信号强度 数据库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<BaseResultDto> AddSignalStrength(AddSignalStrengthInput input)
{
throw new NotImplementedException();
}
/// <summary>
/// 集中器上下线、心跳记录 数据库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<BaseResultDto> AddFocusLog(AddFocusLogInput input)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -1,5 +1,4 @@
using System.ComponentModel; using System.ComponentModel;
using System.Reflection.Metadata;
namespace JiShe.CollectBus.Common.Enums namespace JiShe.CollectBus.Common.Enums
{ {
@ -190,7 +189,8 @@ namespace JiShe.CollectBus.Common.Enums
{ {
=49, =49,
=129, =129,
=149, = 131,
=149,
} }
/// <summary> /// <summary>
@ -315,4 +315,54 @@ namespace JiShe.CollectBus.Common.Enums
[Description("月冻结类")] [Description("月冻结类")]
Td_m, Td_m,
} }
public enum CmdType
{
Valve = 1,
Lock,
Reading,
BalanceDown,
BalanceRead,
PowerDown,
PowerRead,
ArchivesDown,
ArchivesRead,
Clear,
TimeSet,
Identity,
ReadMeterNum,
Event,
/// <summary>
/// 抄读电流
/// </summary>
ReadingCurrent,
CurrentDown,
CurrentRead,
/// <summary>
/// 威胜的功率下发(海洋职业学院专用)
/// </summary>
WsPowerDown,
WsOnPowerDown,
ReadMeterStatus,
ReadTimeSetMonth,
ReadTimeSet,
ReadTimeSetNum,
/// <summary>
/// 读取正在运行的时段
/// </summary>
ReadCurrentTime
}
public enum TerminalVersionInfoEnum
{
MakerNo = 0,
DeviceNo = 4,
SoftwareVersionNo =12,
SoftwareReleaseDate=16,
HardwareVersionNo = 30
}
} }

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,9 @@ namespace JiShe.CollectBus.Common.Extensions
{ {
public static class StringExtensions public static class StringExtensions
{ {
private const string IPV4_REGEX = @"^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$";
// 正则表达式用于验证端口号格式1到65535
private const string PORT_REGEX = @"^([1-9]\d{0,4}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$";
/// <summary>Determines whether [is null or empty].</summary> /// <summary>Determines whether [is null or empty].</summary>
/// <param name="str">The string.</param> /// <param name="str">The string.</param>
@ -1082,16 +1084,20 @@ namespace JiShe.CollectBus.Common.Extensions
/// 字符串分割成2个字符一组 /// 字符串分割成2个字符一组
/// </summary> /// </summary>
/// <param name="str"></param> /// <param name="str"></param>
/// <param name="isReverse">是否翻转顺序</param>
/// <returns></returns> /// <returns></returns>
public static List<string> StringToPairs(this string str) public static List<string> StringToPairs(this string str, bool isReverse = false)
{ {
var pairs = str.Select((ch, index) => new { ch, index }) var pairs = str.Select((ch, index) => new { ch, index })
.GroupBy(x => x.index / 2) .GroupBy(x => x.index / 2)
.Select(g => string.Concat(g.Select(x => x.ch))) .Select(g => string.Concat(g.Select(x => x.ch)))
.ToList(); .ToList();
if (isReverse)
pairs.Reverse();
return pairs; return pairs;
} }
/// <summary> /// <summary>
/// 格式化字符串 /// 格式化字符串
/// </summary> /// </summary>
@ -1214,6 +1220,16 @@ namespace JiShe.CollectBus.Common.Extensions
return rlist; return rlist;
} }
public static bool IsValidIPv4(this string str)
{
return Regex.IsMatch(str, IPV4_REGEX);
}
public static bool IsValidPort(this string str)
{
return Regex.IsMatch(str, PORT_REGEX);
}
private static string AddHex33(this string strGet) private static string AddHex33(this string strGet)
{ {
string result; string result;
@ -1248,6 +1264,15 @@ namespace JiShe.CollectBus.Common.Extensions
} }
} }
public static object TakeTimeToInt(this string timeStr)
{
var timeArr = timeStr.Split(':');
int.TryParse(timeArr[0], out int hourInt);
int.TryParse(timeArr[1], out int minInt);
return (hourInt * 60 + minInt) / 15;
}
private static void CreateAlphaNumMask(StringBuilder buffer, string source, char mask, int length) private static void CreateAlphaNumMask(StringBuilder buffer, string source, char mask, int length)
{ {
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)

View File

@ -30,6 +30,10 @@ namespace JiShe.CollectBus.Common.Models
public class AmmeterParameter public class AmmeterParameter
{ {
/// <summary>
/// 电能表/交流采样装置序号
/// </summary>
public int SerialNumber { get; set; }
/// <summary> /// <summary>
/// 测量点号 0~2040 为0被删除 /// 测量点号 0~2040 为0被删除
/// </summary> /// </summary>
@ -45,7 +49,8 @@ namespace JiShe.CollectBus.Common.Models
/// </summary> /// </summary>
public int Port { get; set; } public int Port { get; set; }
public CommunicationProtocolType ProtocolType { get; set; } public int ProtocolType { get; set; }
//public CommunicationProtocolType ProtocolType { get; set; }
/// <summary> /// <summary>
/// 通信地址 0~999999999999 /// 通信地址 0~999999999999
/// </summary> /// </summary>
@ -145,4 +150,22 @@ namespace JiShe.CollectBus.Common.Models
/// </summary> /// </summary>
public int UserSubclassNumber { get; set; } public int UserSubclassNumber { get; set; }
} }
public class TimeSetDetail
{
public int[] Months { get; set; }
public List<MutileRateDetail> Data { get; set; }
}
public class MutileRateDetail
{
public string Rate { get; set; }
public List<Times> Times { get; set; }
}
public class Times
{
public string StartTime { get; set; }
public string EndTime { get; set; }
}
} }

View File

@ -11,6 +11,7 @@ using System.Linq;
using JiShe.CollectBus.Protocol.Contracts.Models; using JiShe.CollectBus.Protocol.Contracts.Models;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using System; using System;
using MassTransit.Internals.GraphValidation;
namespace JiShe.CollectBus.Protocol.Contracts.Abstracts namespace JiShe.CollectBus.Protocol.Contracts.Abstracts
{ {
@ -410,6 +411,24 @@ namespace JiShe.CollectBus.Protocol.Contracts.Abstracts
} }
/// <summary>
/// 解析终端版本信息抄读
/// </summary>
/// <param name="messageReceived"></param>
/// <param name="sendAction"></param>
/// <returns></returns>
public virtual async Task AnalyzeTerminalVersionInfoReadingDataAsync(MessageReceivedHeartbeat messageReceived, Action<byte[]>? sendAction = null)
{
var hexDatas = GetHexDatas(messageReceived.MessageHexString);
var makerNo = string.Join("",hexDatas.Take(4).Select(s => (char)s.HexToDec()));//厂商代码
var deviceNo = string.Join("", hexDatas.Skip((int)TerminalVersionInfoEnum.DeviceNo).Take(8).Select(s => (char)s.HexToDec()));//设备编号
var softwareVersionNo = string.Join("", hexDatas.Skip((int)TerminalVersionInfoEnum.SoftwareVersionNo).Take(4).Select(s => (char)s.HexToDec()));//软件版本号
var softwareReleaseDateList = hexDatas.Skip((int)TerminalVersionInfoEnum.SoftwareReleaseDate).Take(3).ToList();
var softwareReleaseDate = $"20{AnalyzeDataAccordingToA20(softwareReleaseDateList[0], softwareReleaseDateList[1], softwareReleaseDateList[2])}";//软件发布日期
var hardwareVersionNo = string.Join("", hexDatas.Skip((int)TerminalVersionInfoEnum.HardwareVersionNo).Take(4).Select(s => (char)s.HexToDec()));//硬件版本号
}
/// <summary> /// <summary>
/// 解析相位角 /// 解析相位角
/// </summary> /// </summary>