|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
using DotNetty.Transport.Channels;
|
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Repository.Station;
|
|
|
|
|
using Service.Charger.Client;
|
|
|
|
|
using Service.Charger.Msg.Charger.Req;
|
|
|
|
|
using Service.Charger.Msg.Host.Resp;
|
|
|
|
@ -16,15 +17,33 @@ namespace Service.Charger.Handler
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Order(8)]
|
|
|
|
|
[Scope("InstancePerDependency")]
|
|
|
|
|
public class StopChargingHandler : SimpleChannelInboundHandler<StopCharging>, IBaseHandler
|
|
|
|
|
public class FinishStopChargingHandler : SimpleChannelInboundHandler<FinishStopCharging>, IBaseHandler
|
|
|
|
|
{
|
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(StopChargingHandler));
|
|
|
|
|
protected override void ChannelRead0(IChannelHandlerContext ctx, StopCharging msg)
|
|
|
|
|
|
|
|
|
|
public BinInfoRepository BinInfoRepository { get; set; }
|
|
|
|
|
|
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(FinishStopChargingHandler));
|
|
|
|
|
protected override void ChannelRead0(IChannelHandlerContext ctx, FinishStopCharging msg)
|
|
|
|
|
{
|
|
|
|
|
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
|
|
|
|
|
{
|
|
|
|
|
Log.Info($"receive {msg} from {sn}");
|
|
|
|
|
client.IsCanSendStopCmd = false;
|
|
|
|
|
int chargeStatus = 0;
|
|
|
|
|
if (msg.Result == 0)
|
|
|
|
|
{
|
|
|
|
|
client.IsStopped = true;
|
|
|
|
|
chargeStatus = 4;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
client.IsStopped = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int update = BinInfoRepository.Update(t => t.ChargeStatus == chargeStatus, t => t.No == client.BinNo);
|
|
|
|
|
Log.Info($"update {update} start charge finish status {chargeStatus} for {client.BinNo}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ChargingStopFsdRes stopFsdRes = new ChargingStopFsdRes(0);
|
|
|
|
|
ctx.Channel.WriteAndFlushAsync(stopFsdRes);
|
|
|
|
|
}
|