两个电池相关修改

master
xjl 4 months ago
parent 1ab9746844
commit 3ad892a020

@ -70,37 +70,47 @@ public class CommonMgr
public void SaveSwapBattery(SwappingStateMachine machine) public void SaveSwapBattery(SwappingStateMachine machine)
{ {
BinInfo upBin = machine.SwapOrderBatteryInfo.UpBinInfo; List<BinInfo> upBin = machine.SwapOrderBatteryInfo.UpBinInfo;
BinInfo inBin = machine.SwapOrderBatteryInfo.InBinInfo; List<BinInfo> inBin = machine.SwapOrderBatteryInfo.InBinInfo;
SwapOrderBattery swapOrderBattery = new SwapOrderBattery()
List<SwapOrderBattery> swapOrderBatteryList = new List<SwapOrderBattery>();
for (int i = 0; i < upBin.Count; i++)
{ {
SwapOrderSn = machine.SwapOrder.Sn, SwapOrderBattery swapOrderBattery = new SwapOrderBattery()
UpBatterySoc = upBin.Soc, {
UpBatteryNo = upBin.BatteryNo, SwapOrderSn = machine.SwapOrder.Sn,
UpBatterySoe = upBin.Soe, UpBatterySoc = upBin[i].Soc,
UpBatteryBinNo = int.Parse(upBin.No), UpBatteryNo = upBin[i].BatteryNo,
DownBatteryBinNo = int.Parse(inBin.No), UpBatterySoe = upBin[i].Soe,
DownBatteryNo = inBin.BatteryNo, UpBatteryBinNo = int.Parse(upBin[i].No),
DownBatterySoc = inBin.Soc, DownBatteryBinNo = int.Parse(inBin[i].No),
DownBatterySoe = inBin.Soe, DownBatteryNo = inBin[i].BatteryNo,
CreatedTime = DateTime.Now DownBatterySoc = inBin[i].Soc,
}; DownBatterySoe = inBin[i].Soe,
CreatedTime = DateTime.Now
};
swapOrderBatteryList.Add(swapOrderBattery);
}
_swapOrderBatteryRepository.Insert(swapOrderBattery); _swapOrderBatteryRepository.Insert(swapOrderBatteryList);
} }
/// <summary> /// <summary>
/// 1.锁仓 /// 1.锁仓 锁两个
/// 2.更改预约单 /// 2.更改预约单
/// </summary> /// </summary>
public void LockBinAndUpdateAmt(SwapOrderBatteryInfo orderBatteryInfo) public void LockBinAndUpdateAmt(SwapOrderBatteryInfo orderBatteryInfo)
{ {
//
var configBinInfo = var configBinInfo =
new MapperConfiguration(cfg => cfg.CreateMap<BinInfo, BinInfo>().ReverseMap()); new MapperConfiguration(cfg => cfg.CreateMap<BinInfo, BinInfo>().ReverseMap());
IMapper mapperBinInfo = configBinInfo.CreateMapper(); IMapper mapperBinInfo = configBinInfo.CreateMapper();
BinInfo dbBinInfo = mapperBinInfo.Map<BinInfo>(orderBatteryInfo.UpBinInfo); List<BinInfo> dbBinInfo = mapperBinInfo.Map<List<BinInfo>>(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); _binInfoRepository.Update(dbBinInfo);
if (!orderBatteryInfo.isAmt) if (!orderBatteryInfo.isAmt)
{ {
@ -156,14 +166,18 @@ public class CommonMgr
.Ticks) .Ticks)
.TotalMinutes > StaticStationInfo.SwapFinishChargeTime && .TotalMinutes > StaticStationInfo.SwapFinishChargeTime &&
UpBin.Soc > StaticStationInfo.SwapSoc; UpBin.Soc > StaticStationInfo.SwapSoc;
//第二块电池信息去第一块电池编号+10
int no = Convert.ToInt32(UpBin.No) + 10;
BinInfo UpBin2 = _binInfoRepository.QueryByClause(i => i.No == no.ToString());
if (!CanSwap) if (!CanSwap)
{ {
orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.AmtError; orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.AmtError;
return orderBatteryInfo; return orderBatteryInfo;
} }
orderBatteryInfo.UpBinInfo=new List<BinInfo> { UpBin , UpBin2 };
orderBatteryInfo.UpBinInfo = UpBin;
InBin(orderBatteryInfo, machine); InBin(orderBatteryInfo, machine);
return orderBatteryInfo; return orderBatteryInfo;
} }
@ -174,12 +188,16 @@ public class CommonMgr
/// </summary> /// </summary>
/// <param name="orderBatteryInfo"></param> /// <param name="orderBatteryInfo"></param>
public void UpBin(SwapOrderBatteryInfo orderBatteryInfo) public void UpBin(SwapOrderBatteryInfo orderBatteryInfo)
{//TODO 选包只选右侧的1~8 {
SelectPackDto selectPack = SelectPackDto selectPack =
_binInfoRepository.SelectPack(StaticStationInfo.SwapSoc, StaticStationInfo.SwapFinishChargeTime, _binInfoRepository.SelectPack(StaticStationInfo.SwapSoc, StaticStationInfo.SwapFinishChargeTime,
QueryMoveBinNo()[0]); 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<BinInfo>() { selectPack.BinInfo, UpBin2 };
orderBatteryInfo.CanSwap = selectPack.Info; 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, MoveBinRecord queryByClause = MoveBinRecordRepository.QueryByClause(i => i.Status == 0 || i.Status == 1,
i => i.CreatedTime, i => i.CreatedTime,
@ -237,19 +255,38 @@ public class CommonMgr
return; return;
} }
orderBatteryInfo.InBinInfo = list[0]; //第二块电池信息去第一块电池编号+10
orderBatteryInfo.InBinInfo.BatteryNo = "-1"; int no = Convert.ToInt32(list[0].No) + 10;
orderBatteryInfo.InBinInfo.Soc = -1; BinInfo UpBin2 = _binInfoRepository.QueryByClause(i => i.No == no.ToString());
orderBatteryInfo.InBinInfo.Soe = -1;
orderBatteryInfo.InBinInfo.Soh = -1; orderBatteryInfo.InBinInfo = new List<BinInfo>() { 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; var carInfoBatteryInfos = machine.BoxCarInfoModel?.CarInfo?.BatteryInfos;
if (carInfoBatteryInfos != null && carInfoBatteryInfos.Count > 0) 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; orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.Success;
@ -301,14 +338,23 @@ public class CommonMgr
//修改入仓顺序 //修改入仓顺序
BinInfo binInfo = _binInfoRepository BinInfo binInfo = _binInfoRepository
.QueryListByClause(i => i.BatteryEnterSeq != null, "battery_enter_seq desc").First(); .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); _binInfoRepository.Update(inBinInfo);
var upBinInfo = machineSwapOrderBatteryInfo.UpBinInfo; var upBinInfo = machineSwapOrderBatteryInfo.UpBinInfo;
upBinInfo.Soc = -1; upBinInfo[0].Soc = -1;
upBinInfo.Soe = -1; upBinInfo[0].Soe = -1;
upBinInfo.BatteryNo = "-1"; upBinInfo[0].BatteryNo = "-1";
//
upBinInfo[1].Soc = -1;
upBinInfo[1].Soe = -1;
upBinInfo[1].BatteryNo = "-1";
_binInfoRepository.Update(upBinInfo); _binInfoRepository.Update(upBinInfo);
} }
} }

@ -11,9 +11,12 @@ public class SwapOrderBatteryInfo
public InfoEnum.SelectBinStatusInfo CanSwap; public InfoEnum.SelectBinStatusInfo CanSwap;
public BinInfo UpBinInfo; /// <summary>
/// 出仓位信息
/// </summary>
public List<BinInfo> UpBinInfo;
/// <summary> /// <summary>
/// downBinNo /// downBinNo
/// </summary> /// </summary>
public BinInfo InBinInfo; public List<BinInfo> InBinInfo;
} }

@ -105,9 +105,9 @@ public class DoSwappingState : IState
bool unLock = result.Result; bool unLock = result.Result;
if (unLock) if (unLock)
{ {
//查询车辆锁止状态 //下发启动换电
var startSwapping = PlcApi.StartSwapping(machine.SwapOrderBatteryInfo.InBinInfo.No, var startSwapping = PlcApi.StartSwapping(machine.SwapOrderBatteryInfo.InBinInfo[0].No,
machine.SwapOrderBatteryInfo.UpBinInfo.No); machine.SwapOrderBatteryInfo.UpBinInfo[0].No);
//查詢當前任務狀態是否被更改 //查詢當前任務狀態是否被更改
var readPlcTaskStatus = PlcApi.ReadTaskStatus(2); var readPlcTaskStatus = PlcApi.ReadTaskStatus(2);

@ -451,13 +451,15 @@ public class SwappingStateMachine : IDisposable
//关于仓库锁定相关重置 //关于仓库锁定相关重置
private void ResetOrderAmtStatus() private void ResetOrderAmtStatus()
{ {
//仓库解锁 //仓库解锁 解锁两个
if (SwapOrderBatteryInfo != null) if (SwapOrderBatteryInfo != null)
{ {
if (SwapOrderBatteryInfo?.UpBinInfo != null) ; if (SwapOrderBatteryInfo?.UpBinInfo != null) ;
{ {
BinInfoRepository.Update(i => i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock, 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);
} }
} }

Loading…
Cancel
Save