using Common.Util; using DotNetty.Transport.Channels; using Entity.DbModel.Station; using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Repository.Station; using Service.Charger.Client; using Service.Charger.Msg.Charger.OutCharger.Resp; using Service.Charger.Msg.Http.Resp; namespace Service.Charger.Handler.OutCharger; [Order(8)] [Scope("InstancePerDependency")] public class PileStopChargeResHandler : SimpleChannelInboundHandler, IBaseHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(PileStopChargeResHandler)); public ChargeOrderRepository ChargeOrderRepository { get; set; } protected override void ChannelRead0(IChannelHandlerContext ctx, PileStopChargeRes msg) { if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client)) { Log.Info($"receive {msg} from {sn}"); ChargeOrder? chargeOrder = ChargeOrderRepository.GetLatestChargeGunOrder(msg.pn.ToString(), sn); if (chargeOrder == null) { return; } if (msg.rs == 0 || msg.rs == 1) { client.GunCharged[msg.pn] = false; chargeOrder.EndTime = DateTime.Now; ChargeOrderRepository.Update(chargeOrder); PileStopChargeHttpRes res = new PileStopChargeHttpRes(); res.pn = chargeOrder.ChargerGunNo; res.rs = msg.rs.ToString(); HttpUtil.SendPostRequest(res, "http://127.0.0.1:5034/api/OutCharger/ResStartOutCharger"); } } } }