From 3ad892a0208de9f3fa8db59e90657de4beda47c3 Mon Sep 17 00:00:00 2001 From: xjl <2595686544@qq.com> Date: Fri, 2 Aug 2024 17:33:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=A4=E4=B8=AA=E7=94=B5=E6=B1=A0=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/Execute/Mgr/CommonMgr.cs | 118 ++++++++++++------ Service/Execute/Model/SwapOrderBatteryInfo.cs | 7 +- Service/Execute/Step/DoSwappingState.cs | 6 +- Service/Execute/SwappingStateMachine.cs | 6 +- 4 files changed, 94 insertions(+), 43 deletions(-) diff --git a/Service/Execute/Mgr/CommonMgr.cs b/Service/Execute/Mgr/CommonMgr.cs index ac5e16c..ea647d4 100644 --- a/Service/Execute/Mgr/CommonMgr.cs +++ b/Service/Execute/Mgr/CommonMgr.cs @@ -70,37 +70,47 @@ public class CommonMgr public void SaveSwapBattery(SwappingStateMachine machine) { - BinInfo upBin = machine.SwapOrderBatteryInfo.UpBinInfo; - BinInfo inBin = machine.SwapOrderBatteryInfo.InBinInfo; - SwapOrderBattery swapOrderBattery = new SwapOrderBattery() + List upBin = machine.SwapOrderBatteryInfo.UpBinInfo; + List inBin = machine.SwapOrderBatteryInfo.InBinInfo; + + List swapOrderBatteryList = new List(); + + for (int i = 0; i < upBin.Count; i++) { - SwapOrderSn = machine.SwapOrder.Sn, - UpBatterySoc = upBin.Soc, - UpBatteryNo = upBin.BatteryNo, - UpBatterySoe = upBin.Soe, - UpBatteryBinNo = int.Parse(upBin.No), - DownBatteryBinNo = int.Parse(inBin.No), - DownBatteryNo = inBin.BatteryNo, - DownBatterySoc = inBin.Soc, - DownBatterySoe = inBin.Soe, - CreatedTime = DateTime.Now - }; + SwapOrderBattery swapOrderBattery = new SwapOrderBattery() + { + SwapOrderSn = machine.SwapOrder.Sn, + UpBatterySoc = upBin[i].Soc, + UpBatteryNo = upBin[i].BatteryNo, + UpBatterySoe = upBin[i].Soe, + UpBatteryBinNo = int.Parse(upBin[i].No), + DownBatteryBinNo = int.Parse(inBin[i].No), + DownBatteryNo = inBin[i].BatteryNo, + DownBatterySoc = inBin[i].Soc, + DownBatterySoe = inBin[i].Soe, + CreatedTime = DateTime.Now + }; + swapOrderBatteryList.Add(swapOrderBattery); + } + - _swapOrderBatteryRepository.Insert(swapOrderBattery); + _swapOrderBatteryRepository.Insert(swapOrderBatteryList); } /// - /// 1.锁仓 + /// 1.锁仓 锁两个 /// 2.更改预约单 /// public void LockBinAndUpdateAmt(SwapOrderBatteryInfo orderBatteryInfo) { + // var configBinInfo = new MapperConfiguration(cfg => cfg.CreateMap().ReverseMap()); IMapper mapperBinInfo = configBinInfo.CreateMapper(); - BinInfo dbBinInfo = mapperBinInfo.Map(orderBatteryInfo.UpBinInfo); + List dbBinInfo = mapperBinInfo.Map>(orderBatteryInfo.UpBinInfo); - dbBinInfo.AmtLock = (int)InfoEnum.AmtBatLockStatus.Lock; + dbBinInfo[0].AmtLock = (int)InfoEnum.AmtBatLockStatus.Lock; + dbBinInfo[1].AmtLock = (int)InfoEnum.AmtBatLockStatus.Lock; _binInfoRepository.Update(dbBinInfo); if (!orderBatteryInfo.isAmt) { @@ -156,14 +166,18 @@ public class CommonMgr .Ticks) .TotalMinutes > StaticStationInfo.SwapFinishChargeTime && UpBin.Soc > StaticStationInfo.SwapSoc; + //第二块电池信息去第一块电池编号+10 + int no = Convert.ToInt32(UpBin.No) + 10; + BinInfo UpBin2 = _binInfoRepository.QueryByClause(i => i.No == no.ToString()); + if (!CanSwap) { orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.AmtError; return orderBatteryInfo; } + orderBatteryInfo.UpBinInfo=new List { UpBin , UpBin2 }; - orderBatteryInfo.UpBinInfo = UpBin; InBin(orderBatteryInfo, machine); return orderBatteryInfo; } @@ -174,12 +188,16 @@ public class CommonMgr /// /// public void UpBin(SwapOrderBatteryInfo orderBatteryInfo) - {//TODO 选包只选右侧的1~8 + { SelectPackDto selectPack = _binInfoRepository.SelectPack(StaticStationInfo.SwapSoc, StaticStationInfo.SwapFinishChargeTime, QueryMoveBinNo()[0]); - orderBatteryInfo.UpBinInfo = selectPack.BinInfo; + //第二块电池信息去第一块电池编号+10 + int no = Convert.ToInt32(selectPack.BinInfo.No) + 10; + BinInfo UpBin2 = _binInfoRepository.QueryByClause(i => i.No == no.ToString()); + + orderBatteryInfo.UpBinInfo = new List() { selectPack.BinInfo, UpBin2 }; orderBatteryInfo.CanSwap = selectPack.Info; } @@ -190,7 +208,7 @@ public class CommonMgr //当前有移仓任务 - if (PlcMgr.PlcClient?.ReadTaskNo() == 2) + if (PlcMgr.PlcClient?.ReadTaskNo() == 6) { MoveBinRecord queryByClause = MoveBinRecordRepository.QueryByClause(i => i.Status == 0 || i.Status == 1, i => i.CreatedTime, @@ -237,19 +255,38 @@ public class CommonMgr return; } - orderBatteryInfo.InBinInfo = list[0]; - orderBatteryInfo.InBinInfo.BatteryNo = "-1"; - orderBatteryInfo.InBinInfo.Soc = -1; - orderBatteryInfo.InBinInfo.Soe = -1; - orderBatteryInfo.InBinInfo.Soh = -1; + //第二块电池信息去第一块电池编号+10 + int no = Convert.ToInt32(list[0].No) + 10; + BinInfo UpBin2 = _binInfoRepository.QueryByClause(i => i.No == no.ToString()); + + orderBatteryInfo.InBinInfo = new List() { list[0], UpBin2 }; + + //orderBatteryInfo.InBinInfo = list[0]; + orderBatteryInfo.InBinInfo[0].BatteryNo = "-1"; + orderBatteryInfo.InBinInfo[0].Soc = -1; + orderBatteryInfo.InBinInfo[0].Soe = -1; + orderBatteryInfo.InBinInfo[0].Soh = -1; + + orderBatteryInfo.InBinInfo[1].BatteryNo = "-1"; + orderBatteryInfo.InBinInfo[1].Soc = -1; + orderBatteryInfo.InBinInfo[1].Soe = -1; + orderBatteryInfo.InBinInfo[1].Soh = -1; + var carInfoBatteryInfos = machine.BoxCarInfoModel?.CarInfo?.BatteryInfos; if (carInfoBatteryInfos != null && carInfoBatteryInfos.Count > 0) { + for ( int i = 0; i < carInfoBatteryInfos.Count; i++ ) + { + orderBatteryInfo.InBinInfo[i].BatteryNo = carInfoBatteryInfos[i].BatteryNo; + // orderBatteryInfo.InBinInfo.Soc = carInfoBatteryInfos[0].Soc; + orderBatteryInfo.InBinInfo[i].Soe = carInfoBatteryInfos[i].Soe; + orderBatteryInfo.InBinInfo[i].Soh = carInfoBatteryInfos[i].Soh; + if (i==1) + { + break; + } + } - orderBatteryInfo.InBinInfo.BatteryNo = carInfoBatteryInfos[0].BatteryNo; - // orderBatteryInfo.InBinInfo.Soc = carInfoBatteryInfos[0].Soc; - orderBatteryInfo.InBinInfo.Soe = carInfoBatteryInfos[0].Soe; - orderBatteryInfo.InBinInfo.Soh = carInfoBatteryInfos[0].Soh; } orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.Success; @@ -301,14 +338,23 @@ public class CommonMgr //修改入仓顺序 BinInfo binInfo = _binInfoRepository .QueryListByClause(i => i.BatteryEnterSeq != null, "battery_enter_seq desc").First(); - inBinInfo.BatteryEnterSeq = binInfo.BatteryEnterSeq + 1; - inBinInfo.InTime = DateTime.Now; + + inBinInfo[0].BatteryEnterSeq = binInfo.BatteryEnterSeq + 1; + inBinInfo[0].InTime = DateTime.Now; + inBinInfo[1].InTime = DateTime.Now; _binInfoRepository.Update(inBinInfo); + var upBinInfo = machineSwapOrderBatteryInfo.UpBinInfo; - upBinInfo.Soc = -1; - upBinInfo.Soe = -1; - upBinInfo.BatteryNo = "-1"; + upBinInfo[0].Soc = -1; + upBinInfo[0].Soe = -1; + upBinInfo[0].BatteryNo = "-1"; + // + upBinInfo[1].Soc = -1; + upBinInfo[1].Soe = -1; + upBinInfo[1].BatteryNo = "-1"; _binInfoRepository.Update(upBinInfo); + + } } diff --git a/Service/Execute/Model/SwapOrderBatteryInfo.cs b/Service/Execute/Model/SwapOrderBatteryInfo.cs index 84d7659..44c51be 100644 --- a/Service/Execute/Model/SwapOrderBatteryInfo.cs +++ b/Service/Execute/Model/SwapOrderBatteryInfo.cs @@ -11,9 +11,12 @@ public class SwapOrderBatteryInfo public InfoEnum.SelectBinStatusInfo CanSwap; - public BinInfo UpBinInfo; + /// + /// λϢ + /// + public List UpBinInfo; /// /// downBinNo /// - public BinInfo InBinInfo; + public List InBinInfo; } \ No newline at end of file diff --git a/Service/Execute/Step/DoSwappingState.cs b/Service/Execute/Step/DoSwappingState.cs index e76f5cb..8eef4e2 100644 --- a/Service/Execute/Step/DoSwappingState.cs +++ b/Service/Execute/Step/DoSwappingState.cs @@ -105,9 +105,9 @@ public class DoSwappingState : IState bool unLock = result.Result; if (unLock) { - //查询车辆锁止状态 - var startSwapping = PlcApi.StartSwapping(machine.SwapOrderBatteryInfo.InBinInfo.No, - machine.SwapOrderBatteryInfo.UpBinInfo.No); + //下发启动换电 + var startSwapping = PlcApi.StartSwapping(machine.SwapOrderBatteryInfo.InBinInfo[0].No, + machine.SwapOrderBatteryInfo.UpBinInfo[0].No); //查詢當前任務狀態是否被更改 var readPlcTaskStatus = PlcApi.ReadTaskStatus(2); diff --git a/Service/Execute/SwappingStateMachine.cs b/Service/Execute/SwappingStateMachine.cs index 49f89e6..c5dd100 100644 --- a/Service/Execute/SwappingStateMachine.cs +++ b/Service/Execute/SwappingStateMachine.cs @@ -451,13 +451,15 @@ public class SwappingStateMachine : IDisposable //关于仓库锁定相关重置 private void ResetOrderAmtStatus() { - //仓库解锁 + //仓库解锁 解锁两个 if (SwapOrderBatteryInfo != null) { if (SwapOrderBatteryInfo?.UpBinInfo != null) ; { BinInfoRepository.Update(i => i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock, - i => i.Id == SwapOrderBatteryInfo.UpBinInfo.Id); + i => i.Id == SwapOrderBatteryInfo.UpBinInfo[0].Id); + BinInfoRepository.Update(i => i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock, + i => i.Id == SwapOrderBatteryInfo.UpBinInfo[1].Id); } }