抄读接口
This commit is contained in:
parent
9705c2f67a
commit
8250cf1e0c
@ -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; }
|
||||
}
|
||||
}
|
||||
@ -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; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -91,7 +91,7 @@ namespace JiShe.CollectBus.EnergySystem.Dto
|
||||
public int DecimalCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 集中器地址
|
||||
/// 采集器地址
|
||||
/// </summary>
|
||||
public string GatherAddress { get; set; }
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ namespace JiShe.CollectBus.EnergySystem.Dto
|
||||
/// <summary>
|
||||
/// 电表ID
|
||||
/// </summary>
|
||||
public string AmmeterId { get; set; }
|
||||
public int AmmeterId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///采集编码 {"0C_129", "0C_131"}, 采集编码.0C_129:正向有功;C_131:反向有功
|
||||
|
||||
@ -41,18 +41,18 @@ namespace JiShe.CollectBus.EnergySystem.Dto
|
||||
/// </summary>
|
||||
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 List<TimeSetDataDataTimeInput> Times { get; set; }
|
||||
public List<TimeSetTimesInput> Times { get; set; }
|
||||
}
|
||||
|
||||
public class TimeSetDataDataTimeInput
|
||||
public class TimeSetTimesInput
|
||||
{
|
||||
|
||||
public string StartTime { get; set; }
|
||||
|
||||
@ -124,4 +124,25 @@ public interface IEnergySystemAppService : IApplicationService
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
}
|
||||
@ -1,95 +1,542 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
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.FreeSql;
|
||||
using JiShe.CollectBus.PrepayModel;
|
||||
using JiShe.CollectBus.Protocol.Contracts;
|
||||
using MassTransit;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace JiShe.CollectBus.EnergySystem
|
||||
{
|
||||
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:水表阀控
|
||||
}
|
||||
|
||||
public Task<BaseResultDto<AmmeterArchivesDownOutput>> AmmeterArchivesDown(AmmeterArchivesDownInput input)
|
||||
if (bytes == null)
|
||||
return result;
|
||||
|
||||
|
||||
await _capBus.PublishAsync(ProtocolConst.SubscriberIssuedEventName, new IssuedEventMessage
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//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 async Task<BaseResultDto<ReadTimeOutput>> ReadTime(ReadTimeInput input)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
public Task<BaseResultDto> CallTimeTesting(CallTimeTestingInput input)
|
||||
var bytes = HexStringExtensions.BuildCommunicationParametersSetSendCmd(address, masterIP, materPort,
|
||||
backupIP, backupPort, input.Data.APN);
|
||||
await _capBus.PublishAsync(ProtocolConst.SubscriberIssuedEventName, new IssuedEventMessage
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//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: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> TerminalRestart(TerminalRestartInput 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<ReadMeterNumOutput>> ReadMeterNum(ReadMeterNumInput 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<ReadingOutput>> Reading(ReadingInput 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> TimeSet(TimeSetInput 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置时间段 透明转发
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<BaseResultDto> TimeSet(TimeSetInput input)
|
||||
{
|
||||
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)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置自动上报 数据库操作
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public Task<BaseResultDto> AutoReportSet(AutoReportSetInput input)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询自动上报开启状态 数据库操作
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public Task<BaseResultDto> QueryAutoReportOpenStatus(QueryAutoReportOpenStatusInput input)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System.ComponentModel;
|
||||
using System.Reflection.Metadata;
|
||||
|
||||
namespace JiShe.CollectBus.Common.Enums
|
||||
{
|
||||
@ -190,7 +189,8 @@ namespace JiShe.CollectBus.Common.Enums
|
||||
{
|
||||
相位角=49,
|
||||
当前正向有功电能示值=129,
|
||||
上月最大需量=149,
|
||||
当前反向无功电能示值 = 131,
|
||||
上月最大需量 =149,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -315,4 +315,54 @@ namespace JiShe.CollectBus.Common.Enums
|
||||
[Description("月冻结类")]
|
||||
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
@ -17,7 +17,9 @@ namespace JiShe.CollectBus.Common.Extensions
|
||||
{
|
||||
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>
|
||||
/// <param name="str">The string.</param>
|
||||
@ -1082,16 +1084,20 @@ namespace JiShe.CollectBus.Common.Extensions
|
||||
/// 字符串分割成2个字符一组
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <param name="isReverse">是否翻转顺序</param>
|
||||
/// <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 })
|
||||
.GroupBy(x => x.index / 2)
|
||||
.Select(g => string.Concat(g.Select(x => x.ch)))
|
||||
.ToList();
|
||||
if (isReverse)
|
||||
pairs.Reverse();
|
||||
return pairs;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 格式化字符串
|
||||
/// </summary>
|
||||
@ -1214,6 +1220,16 @@ namespace JiShe.CollectBus.Common.Extensions
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
for (int i = 0; i < length; i++)
|
||||
|
||||
@ -30,6 +30,10 @@ namespace JiShe.CollectBus.Common.Models
|
||||
|
||||
public class AmmeterParameter
|
||||
{
|
||||
/// <summary>
|
||||
/// 电能表/交流采样装置序号
|
||||
/// </summary>
|
||||
public int SerialNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 测量点号 0~2040 为0被删除
|
||||
/// </summary>
|
||||
@ -45,7 +49,8 @@ namespace JiShe.CollectBus.Common.Models
|
||||
/// </summary>
|
||||
public int Port { get; set; }
|
||||
|
||||
public CommunicationProtocolType ProtocolType { get; set; }
|
||||
public int ProtocolType { get; set; }
|
||||
//public CommunicationProtocolType ProtocolType { get; set; }
|
||||
/// <summary>
|
||||
/// 通信地址 0~999999999999
|
||||
/// </summary>
|
||||
@ -145,4 +150,22 @@ namespace JiShe.CollectBus.Common.Models
|
||||
/// </summary>
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ using System.Linq;
|
||||
using JiShe.CollectBus.Protocol.Contracts.Models;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using System;
|
||||
using MassTransit.Internals.GraphValidation;
|
||||
|
||||
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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user