|
|
@ -1,6 +1,7 @@
|
|
|
|
using DotNetty.Transport.Channels;
|
|
|
|
using DotNetty.Transport.Channels;
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
using log4net;
|
|
|
|
using log4net;
|
|
|
|
|
|
|
|
using Repository.Station;
|
|
|
|
using Service.Charger.Client;
|
|
|
|
using Service.Charger.Client;
|
|
|
|
using Service.Charger.Msg.Charger.Req;
|
|
|
|
using Service.Charger.Msg.Charger.Req;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
@ -19,14 +20,26 @@ namespace Service.Charger.Handler
|
|
|
|
public class VoltageCurrentSocHandler : SimpleChannelInboundHandler<VoltageCurrentSoc>, IBaseHandler
|
|
|
|
public class VoltageCurrentSocHandler : SimpleChannelInboundHandler<VoltageCurrentSoc>, IBaseHandler
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly ILog Log = LogManager.GetLogger(typeof(VoltageCurrentSocHandler));
|
|
|
|
private readonly ILog Log = LogManager.GetLogger(typeof(VoltageCurrentSocHandler));
|
|
|
|
|
|
|
|
private BinInfoRepository _binInfoRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public VoltageCurrentSocHandler(BinInfoRepository binInfoRepository)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_binInfoRepository = binInfoRepository;
|
|
|
|
|
|
|
|
}
|
|
|
|
protected override void ChannelRead0(IChannelHandlerContext ctx, VoltageCurrentSoc msg)
|
|
|
|
protected override void ChannelRead0(IChannelHandlerContext ctx, VoltageCurrentSoc msg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client))
|
|
|
|
if (ClientMgr.TryGetClient(ctx.Channel, out string sn, out var client))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log.Info($"receive {msg} from {sn}");
|
|
|
|
Log.Info($"receive {msg} from {sn}");
|
|
|
|
|
|
|
|
if (_binInfoRepository.Update(t => t.Soc == (decimal)msg.SOC, t => t.No == client.BinNo) > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info($"succeed update battery soc {msg.SOC} for {client.BinNo}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info($"fail update battery soc {msg.SOC} for {client.BinNo}");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|