电表数据更新

master
xjl 2 weeks ago
parent 08790cb902
commit 5c8c2671a3

@ -1,9 +1,11 @@
using DotNetty.Transport.Channels;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Configuration;
using HybirdFrameworkCore.Redis;
using log4net;
using Newtonsoft.Json;
using Repository.Station;
using Service.Charger.Client;
using Service.Charger.Msg.Charger.Req;
@ -18,13 +20,27 @@ namespace Service.Charger.Handler
public class UploadTelemetryDataHandler : SimpleChannelInboundHandler<UploadTelemetryData>, IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(UploadTelemetryDataHandler));
public ChargeOrderRepository ChargeOrderRepository { get; set; }
public RedisHelper RedisHelper { get; set; }
protected override void ChannelRead0(IChannelHandlerContext ctx, UploadTelemetryData msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
{
msg.ChargerNo = sn;
float DcMeterCurrentPower = client.UploadTelemetryData.DcMeterCurrentPower;
if (DcMeterCurrentPower==0)
{
List<ChargeOrder> chargeOrders = ChargeOrderRepository
.QueryListByClause(i => i.ChargerNo == client.BinNo&&i.StopDcElec!=null, "created_time desc")
.Take(1).ToList();
if (chargeOrders.Count>0)
{
DcMeterCurrentPower = (float)chargeOrders[0].StopDcElec;
}
}
Log.Info($"receive {msg} from {sn}");
/*if (!AppSettingsConstVars.DisabledTask.Contains("UploadTelemetryData"))
@ -33,8 +49,11 @@ namespace Service.Charger.Handler
}*/
client.UploadTelemetryData = msg;
if (msg.DcMeterCurrentPower< DcMeterCurrentPower)//处理电表数据在电池移走之后值变小的问题
{
client.UploadTelemetryData.DcMeterCurrentPower = DcMeterCurrentPower;
}
//充电机实时充电功率
//client.RealTimeChargePower = msg.HighVoltageAcquisitionCurrent * msg.HighVoltageAcquisitionVoltage;
client.RealTimeChargePower = msg.DcMeterCurrent * msg.DcMeterVoltage;
}

Loading…
Cancel
Save