diff --git a/Repository/Station/BinInfoRepository.cs b/Repository/Station/BinInfoRepository.cs index 129cfb5..419b1e1 100644 --- a/Repository/Station/BinInfoRepository.cs +++ b/Repository/Station/BinInfoRepository.cs @@ -73,6 +73,7 @@ public class BinInfoRepository : BaseRepository return selectPackDto; } + //校验电池编码是否匹配 foreach (var binInfo in list) { var normalBinInfo = QueryByClause(i => @@ -98,14 +99,6 @@ public class BinInfoRepository : BaseRepository } } - /*list = list.Where(i => i.LastChargeFinishTime != null || new TimeSpan(DateTime.Now.Ticks - - i.LastChargeFinishTime.ToDateTime().Ticks) - .TotalMinutes > swapFinishChargeTime).ToList(); - if (list.Count <= 0) - { selectPackDto.Info = InfoEnum.SelectBinStatusInfo.LessOf3Minute; - return selectPackDto; - }*/ - return selectPackDto; } diff --git a/Service/Execute/Mgr/CommonMgr.cs b/Service/Execute/Mgr/CommonMgr.cs index bcd45d0..1c3e194 100644 --- a/Service/Execute/Mgr/CommonMgr.cs +++ b/Service/Execute/Mgr/CommonMgr.cs @@ -73,27 +73,27 @@ public class CommonMgr { List upBin = machine.SwapOrderBatteryInfo.UpBinInfo; List inBin = machine.SwapOrderBatteryInfo.InBinInfo; - List swapOrderBatteryList = new List(); for (int i = 0; i < upBin.Count; i++) { - 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 - }; + SwapOrderBattery swapOrderBattery = new SwapOrderBattery(); + + swapOrderBattery.SwapOrderSn = machine.SwapOrder.Sn; + swapOrderBattery.UpBatterySoc = upBin[i].Soc; + swapOrderBattery.UpBatteryNo = upBin[i].BatteryNo; + swapOrderBattery.UpBatterySoe = upBin[i].Soe; + swapOrderBattery.UpBatteryBinNo = int.Parse(upBin[i].No); + + swapOrderBattery.DownBatteryBinNo = int.Parse(inBin[i].No); + swapOrderBattery.DownBatteryNo = "-1"; //inBin[i].BatteryNo; + swapOrderBattery.DownBatterySoc = -1; //inBin[i].Soc; + swapOrderBattery.DownBatterySoe = -1; //inBin[i].Soe; + swapOrderBattery.CreatedTime = DateTime.Now; + swapOrderBatteryList.Add(swapOrderBattery); } - + _swapOrderBatteryRepository.Insert(swapOrderBatteryList); } @@ -176,7 +176,8 @@ public class CommonMgr return orderBatteryInfo; } - orderBatteryInfo.UpBinInfo=new List { UpBin , UpBin2 }; + + orderBatteryInfo.UpBinInfo = new List { UpBin, UpBin2 }; InBin(orderBatteryInfo, machine); return orderBatteryInfo; @@ -191,15 +192,15 @@ public class CommonMgr { SelectPackDto selectPack = _binInfoRepository.SelectPack(StaticStationInfo.SwapSoc, StaticStationInfo.SwapFinishChargeTime, - QueryMoveBinNo()[0],BatteryGroupRepository); + QueryMoveBinNo()[0], BatteryGroupRepository); - if (selectPack != null) + if (selectPack != null && selectPack.BinInfo != null) { //第二块电池信息去第一块电池编号+10 int no = Convert.ToInt32(selectPack.BinInfo.No) + 10; - BinInfo UpBin2 = _binInfoRepository.QueryByClause(i => i.No == no.ToString()); + BinInfo UpBin = _binInfoRepository.QueryByClause(i => i.No == no.ToString()); - orderBatteryInfo.UpBinInfo = new List() { selectPack.BinInfo, UpBin2 }; + orderBatteryInfo.UpBinInfo = new List() { selectPack.BinInfo, UpBin }; orderBatteryInfo.CanSwap = selectPack.Info; } } @@ -248,6 +249,7 @@ public class CommonMgr { list = list.Where(i => i.No != value).ToList(); } + if (list.Count <= 0) { orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.LessOfEmptyBin; @@ -256,9 +258,9 @@ public class CommonMgr //第二块电池信息去第一块电池编号+10 int no = Convert.ToInt32(list[0].No) + 10; - BinInfo UpBin2 = _binInfoRepository.QueryByClause(i => i.No == no.ToString()); + BinInfo UpBin = _binInfoRepository.QueryByClause(i => i.No == no.ToString()); - orderBatteryInfo.InBinInfo = new List() { list[0], UpBin2 }; + orderBatteryInfo.InBinInfo = new List() { list[0], UpBin }; orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.Success; } diff --git a/Service/Execute/Step/CarCtrlState.cs b/Service/Execute/Step/CarCtrlState.cs index f15892b..8f29bee 100644 --- a/Service/Execute/Step/CarCtrlState.cs +++ b/Service/Execute/Step/CarCtrlState.cs @@ -119,7 +119,7 @@ public class CarCtrlState : IState if (resultHeartBeatMsg?.HighVoltage != 2) { - SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoTboxEnergyDown); + //SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoTboxEnergyDown); } if (resultHeartBeatMsg?.LockStatus == 1 || machine.ManualConfirmCarUnlockFlag) diff --git a/Service/Execute/Step/DoSwappingState.cs b/Service/Execute/Step/DoSwappingState.cs index 3e33647..da8d7a2 100644 --- a/Service/Execute/Step/DoSwappingState.cs +++ b/Service/Execute/Step/DoSwappingState.cs @@ -126,8 +126,8 @@ public class DoSwappingState : IState { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.HoldOn); //读取任务状态 - var taskPrepare = PlcApi.ReadTaskStatus(2); - if (taskPrepare) + /*var taskPrepare = PlcApi.ReadTaskStatus(2); + if (taskPrepare)*/ { bool holdOn = PlcApi.HoldOn(); if (holdOn) diff --git a/Service/Execute/Step/SwapDoneState.cs b/Service/Execute/Step/SwapDoneState.cs index 0e281ba..4464d0e 100644 --- a/Service/Execute/Step/SwapDoneState.cs +++ b/Service/Execute/Step/SwapDoneState.cs @@ -137,7 +137,6 @@ public class SwapDoneState : IState } }, () => { - // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrLockCar.GetLed()); SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrLockCar); }, false, () => { machine.ExceptionReason = ExceptionReason.LockCarError; } , 10, InvokeStatus.None); @@ -217,7 +216,6 @@ public class SwapDoneState : IState } }, () => { - // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoTboxDown); }, false, () => { } , 10, InvokeStatus.None); @@ -248,7 +246,6 @@ public class SwapDoneState : IState } }, () => { - // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrUnLockCar.GetLed()); SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoTboxEnergyUp); }, false, () => { } , 5, InvokeStatus.None); diff --git a/Service/Mgr/SwapOrderMgr.cs b/Service/Mgr/SwapOrderMgr.cs index 0950b01..4cf1a4f 100644 --- a/Service/Mgr/SwapOrderMgr.cs +++ b/Service/Mgr/SwapOrderMgr.cs @@ -35,8 +35,8 @@ public class SwapOrderMgr List batterys = _swapOrderBatteryRepository.QueryListByClause(i => - swapOrderSn.Contains(i.SwapOrderSn) && i.DownBatteryNo != null && i.DownBatteryNo!="-1" - && i.DownBatterySoc!=-1 && i.DownBatterySoc!=null); + swapOrderSn.Contains(i.SwapOrderSn) && i.DownBatteryNo != null && i.DownBatteryNo != "-1" + && i.DownBatterySoc != -1 && i.DownBatterySoc != null); if (batterys.Count <= 0) { @@ -60,12 +60,13 @@ public class SwapOrderMgr continue; } - + if (null == swapOrderBattery.DownBatteryNo || "-1".Equals(swapOrderBattery.DownBatteryNo)) { continue; } - if (null == swapOrderBattery.DownBatterySoc || -1==swapOrderBattery.DownBatterySoc) + + if (null == swapOrderBattery.DownBatterySoc || -1 == swapOrderBattery.DownBatterySoc) { continue; } @@ -78,25 +79,22 @@ public class SwapOrderMgr var count = _swapOrderRepository.GetCount(i => i.SwapResult == 1 && i.SwapEndTime >= DateTime.Today && i.SwapEndTime < swapOrder.SwapEndTime); swapOrderReportClouds.TryGetValue(swapOrder.Id, out SwapOrderReportCloud value); - var uploadSwapOrder = CloudApi.UploadSwapOrder(swapOrder, count++, swapOrderBattery, uploadType,value); - + var uploadSwapOrder = CloudApi.UploadSwapOrder(swapOrder, count++, swapOrderBattery, uploadType, value); + if (uploadSwapOrder == 0) { swapOrder.CloudReportStatus = 1; updateDbOrder.Add(swapOrder); - // value.CloudReportStatus = 1000; + // value.CloudReportStatus = 1000; value.UploadTime = DateTime.Now; - - } else { //当 cloudReportStatus >=100 就不需要上传了 value.CloudReportStatus++; - } + updateDbCloudReport.Add(value); - } if (updateDbOrder.Count > 0) diff --git a/Service/MyTask/UpdateDownBatteryInfoTask.cs b/Service/MyTask/UpdateDownBatteryInfoTask.cs index dfbd656..c0536c4 100644 --- a/Service/MyTask/UpdateDownBatteryInfoTask.cs +++ b/Service/MyTask/UpdateDownBatteryInfoTask.cs @@ -34,6 +34,12 @@ public class UpdateDownBatteryInfoTask : ITask return 1000 * 2; } + /// + /// 更新换下电池包及上辅源 + /// 逻辑 + /// 查最新一条换电订单,看里面soc,电池编码,以及在位状态 + /// 如果订单中soc,电池编码,都为负数,并且仓位电池数据都在就可以更新了 + /// public void Handle() {