2024-12-25 16:25:16 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
2024-12-27 17:00:31 +08:00
|
|
|
|
using System.Net;
|
2024-12-25 16:25:16 +08:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2024-12-27 17:00:31 +08:00
|
|
|
|
using DotNetCore.CAP;
|
|
|
|
|
|
using JiShe.CollectBus.Common.Enums;
|
|
|
|
|
|
using JiShe.CollectBus.Common.Extensions;
|
|
|
|
|
|
using JiShe.CollectBus.Common.Models;
|
2024-12-25 16:25:16 +08:00
|
|
|
|
using JiShe.CollectBus.EnergySystem.Dto;
|
2024-12-27 17:00:31 +08:00
|
|
|
|
using JiShe.CollectBus.FreeSql;
|
|
|
|
|
|
using JiShe.CollectBus.PrepayModel;
|
|
|
|
|
|
using JiShe.CollectBus.Protocol.Contracts;
|
2025-01-15 21:08:04 +08:00
|
|
|
|
using JiShe.CollectBus.Records;
|
2024-12-27 17:00:31 +08:00
|
|
|
|
using MassTransit;
|
2025-01-15 21:08:04 +08:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2024-12-27 17:00:31 +08:00
|
|
|
|
using Newtonsoft.Json;
|
2025-01-15 21:08:04 +08:00
|
|
|
|
using Volo.Abp.Domain.Repositories;
|
2024-12-25 16:25:16 +08:00
|
|
|
|
|
|
|
|
|
|
namespace JiShe.CollectBus.EnergySystem
|
|
|
|
|
|
{
|
|
|
|
|
|
public class EnergySystemAppService: CollectBusAppService,IEnergySystemAppService
|
|
|
|
|
|
{
|
2025-01-15 21:08:04 +08:00
|
|
|
|
private readonly IRepository<FocusRecord, Guid> _focusRecordRepository;
|
|
|
|
|
|
private readonly IRepository<CsqRecord,Guid> _csqRecordRepository;
|
|
|
|
|
|
private readonly IRepository<ConrOnlineRecord,Guid> _conrOnlineRecordRepository;
|
2024-12-27 17:00:31 +08:00
|
|
|
|
private readonly ICapPublisher _capBus;
|
|
|
|
|
|
|
2025-01-15 21:08:04 +08:00
|
|
|
|
public EnergySystemAppService(IRepository<FocusRecord, Guid> focusRecordRepository, IRepository<CsqRecord, Guid> csqRecordRepository,
|
|
|
|
|
|
IRepository<ConrOnlineRecord, Guid> conrOnlineRecordRepository, ICapPublisher capBus)
|
2024-12-25 16:25:16 +08:00
|
|
|
|
{
|
2025-01-15 21:08:04 +08:00
|
|
|
|
_focusRecordRepository = focusRecordRepository;
|
|
|
|
|
|
_csqRecordRepository = csqRecordRepository;
|
|
|
|
|
|
_conrOnlineRecordRepository = conrOnlineRecordRepository;
|
|
|
|
|
|
_capBus = capBus;
|
2024-12-25 16:25:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 电表、水表阀控 透明转发
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/TranspondSend_10_98")]
|
2024-12-27 17:00:31 +08:00
|
|
|
|
public async Task<BaseResultDto<ValveControlOutput>> ValveControl(ValveControlInput input)
|
2024-12-25 16:25:16 +08:00
|
|
|
|
{
|
2024-12-27 17:00:31 +08:00
|
|
|
|
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;
|
2024-12-25 16:25:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 批量抄读时段 透明转发
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/TranspondSend_10_94")]
|
2024-12-27 17:00:31 +08:00
|
|
|
|
public async Task<BaseResultDto<ReadTimeOutput>> ReadTime(ReadTimeInput input)
|
2024-12-25 16:25:16 +08:00
|
|
|
|
{
|
2024-12-27 17:00:31 +08:00
|
|
|
|
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;
|
2024-12-25 16:25:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 档案下发 AFN:04 FN:10
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/IssueArchives")]
|
2024-12-27 17:00:31 +08:00
|
|
|
|
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>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/ReadMeterAddress_10_105")]
|
2024-12-25 16:25:16 +08:00
|
|
|
|
public Task<BaseResultDto> AmmeterArchivesMatch(AmmeterArchivesMatchInput input)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 通讯参数设置 AFN:04 FN:3
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/EquitDubg")]
|
2024-12-27 17:00:31 +08:00
|
|
|
|
public async Task<BaseResultDto> CommunicationParametersSet(CommunicationParametersSetInput input)
|
2024-12-25 16:25:16 +08:00
|
|
|
|
{
|
2024-12-27 17:00:31 +08:00
|
|
|
|
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;
|
2024-12-25 16:25:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 召测时间 AFN:0C FN:2
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/EquitDubg")]
|
2024-12-27 17:00:31 +08:00
|
|
|
|
public async Task<BaseResultDto> CallTimeTesting(CallTimeTestingInput input)
|
2024-12-25 16:25:16 +08:00
|
|
|
|
{
|
2024-12-27 17:00:31 +08:00
|
|
|
|
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;
|
2024-12-25 16:25:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 时间校准 AFN:05 FN:31
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/EquitDubg")]
|
2024-12-27 17:00:31 +08:00
|
|
|
|
public async Task<BaseResultDto> TimeAdjust(TimeAdjustInput input)
|
2024-12-25 16:25:16 +08:00
|
|
|
|
{
|
2024-12-27 17:00:31 +08:00
|
|
|
|
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;
|
2024-12-25 16:25:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 重启终端 AFN:01 FN:1
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/EquitDubg")]
|
2024-12-27 17:00:31 +08:00
|
|
|
|
public async Task<BaseResultDto> TerminalRestart(TerminalRestartInput input)
|
2024-12-25 16:25:16 +08:00
|
|
|
|
{
|
2024-12-27 17:00:31 +08:00
|
|
|
|
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;
|
2024-12-25 16:25:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 读取表号 AFN:0A FN:10
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/EquitDubg")]
|
2024-12-27 17:00:31 +08:00
|
|
|
|
public async Task<BaseResultDto<ReadMeterNumOutput>> ReadMeterNum(ReadMeterNumInput input)
|
2024-12-25 16:25:16 +08:00
|
|
|
|
{
|
2024-12-27 17:00:31 +08:00
|
|
|
|
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;
|
2024-12-25 16:25:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 随抄
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/IssueCmd")]
|
2024-12-27 17:00:31 +08:00
|
|
|
|
public async Task<BaseResultDto<ReadingOutput>> Reading(ReadingInput input)
|
2024-12-25 16:25:16 +08:00
|
|
|
|
{
|
2024-12-27 17:00:31 +08:00
|
|
|
|
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;
|
2024-12-25 16:25:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置时间段 透明转发
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/IssueTranspondTimeSet_10_103")]
|
2024-12-27 17:00:31 +08:00
|
|
|
|
public async Task<BaseResultDto> TimeSet(TimeSetInput input)
|
2024-12-25 16:25:16 +08:00
|
|
|
|
{
|
2024-12-27 17:00:31 +08:00
|
|
|
|
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;
|
2024-12-25 16:25:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置自动上报采集项 数据库操作
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/SetAutoItemCode")]
|
2024-12-25 16:25:16 +08:00
|
|
|
|
public Task<BaseResultDto> AutoReportCollectionItemsSet(AutoReportCollectionItemsSetInput input)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置自动上报 数据库操作
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/SetAutoUpSwitch")]
|
2024-12-25 16:25:16 +08:00
|
|
|
|
public Task<BaseResultDto> AutoReportSet(AutoReportSetInput input)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询自动上报开启状态 数据库操作
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/QueryAutoUpSwitch")]
|
2024-12-25 16:25:16 +08:00
|
|
|
|
public Task<BaseResultDto> QueryAutoReportOpenStatus(QueryAutoReportOpenStatusInput input)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 批量抄读版本号 AFN:09 FN:1
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/BatchIssueVersion_09_1")]
|
2024-12-27 17:00:31 +08:00
|
|
|
|
public async Task<BaseResultDto<BatchReadVersionOutput>> BatchReadVersion(BatchReadVersionInput input)
|
2024-12-25 16:25:16 +08:00
|
|
|
|
{
|
2024-12-27 17:00:31 +08:00
|
|
|
|
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;
|
2024-12-25 16:25:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询采集日志 数据库
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Record/QueryRecordLog")]
|
2024-12-25 16:25:16 +08:00
|
|
|
|
public Task<BaseResultDto<QueryRecordLogOutput>> QueryRecordLog(QueryRecordLogInput input)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-27 17:00:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 校准电表时间 透明转发
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("Handmould/MeterTiming_10_104")]
|
2024-12-27 17:00:31 +08:00
|
|
|
|
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>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("AfterSaleApi/AddConrOnlineRecord")]
|
|
|
|
|
|
public async Task<BaseResultDto> AddConrOnlineRecord(AddConrOnlineRecordInput input)
|
2024-12-27 17:00:31 +08:00
|
|
|
|
{
|
2025-01-15 21:08:04 +08:00
|
|
|
|
var conrOnlineRecord = new ConrOnlineRecord(input.AreaCode,input.Address,input.State,input.LastTime);
|
|
|
|
|
|
await _conrOnlineRecordRepository.InsertAsync(conrOnlineRecord);
|
|
|
|
|
|
return new BaseResultDto()
|
|
|
|
|
|
{
|
|
|
|
|
|
Status = true
|
|
|
|
|
|
};
|
2024-12-27 17:00:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 记录信号强度 数据库
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("AfterSaleApi/RssiToWebApi")]
|
|
|
|
|
|
public async Task<BaseResultDto> AddSignalStrength(AddSignalStrengthInput input)
|
2024-12-27 17:00:31 +08:00
|
|
|
|
{
|
2025-01-15 21:08:04 +08:00
|
|
|
|
var csqRecord = new CsqRecord(input.Address, input.AreaCode,input.DeviceType,input.Csq);
|
|
|
|
|
|
await _csqRecordRepository.InsertAsync(csqRecord);
|
|
|
|
|
|
|
|
|
|
|
|
return new BaseResultDto()
|
|
|
|
|
|
{
|
|
|
|
|
|
Status = true
|
|
|
|
|
|
};
|
2024-12-27 17:00:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 集中器上下线、心跳记录 数据库
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
2025-01-15 21:08:04 +08:00
|
|
|
|
[Route("AfterSaleApi/AddFocusLog")]
|
|
|
|
|
|
public async Task<BaseResultDto> AddFocusLog(AddFocusLogInput input)
|
2024-12-25 16:25:16 +08:00
|
|
|
|
{
|
2025-01-15 21:08:04 +08:00
|
|
|
|
var focusLog = new FocusRecord(input.Address, input.GatherServerId, int.Parse(input.IntervalTime), input.LogTime,
|
|
|
|
|
|
input.LogType, input.Remark);
|
|
|
|
|
|
await _focusRecordRepository.InsertAsync(focusLog);
|
|
|
|
|
|
|
|
|
|
|
|
return new BaseResultDto()
|
|
|
|
|
|
{
|
|
|
|
|
|
Status = true
|
|
|
|
|
|
};
|
2024-12-25 16:25:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|