using Entity.Constant; using Entity.DbModel.Station; using HybirdFrameworkCore.Autofac.Attribute; using Newtonsoft.Json; using Repository.Station; using Service.Cloud.Client; using Service.Cloud.Common; using Service.Cloud.Msg.Cloud.Req; using Service.Cloud.Msg.Host.Resp; namespace Service.Cloud.Handler; [Scope("InstancePerDependency")] public class CancelAmtBatHandler : IBaseHandler { private SwapAmtOrderRepository _swapAmtOrderRepository; public CancelAmtBatHandler(SwapAmtOrderRepository swapAmtOrderRepository) { _swapAmtOrderRepository = swapAmtOrderRepository; } public bool CanHandle(string cmd) { return CloudConst.cancleAmtBat == cmd; } public void Handle(string t) { CancelAmt? amtBat = JsonConvert.DeserializeObject(t); if (amtBat==null) { return; } List swapAmtOrderList = _swapAmtOrderRepository.QueryListByClause(i => i.CarNo ==amtBat.carNo&&i.Status==(byte)InfoEnum.AmtOrderStatus.Success); if (swapAmtOrderList.Any()) { swapAmtOrderList.ForEach(order => order.Status = (byte)InfoEnum.AmtOrderStatus.Cancel); _swapAmtOrderRepository.Update(swapAmtOrderList); } CancelAmtRes res = new CancelAmtRes { stationNo = amtBat.stationNo, result = 0, carNo = amtBat.carNo }; CloudClientMgr.CloudClient?.Publish(res); } }