|
|
|
@ -70,37 +70,47 @@ public class CommonMgr
|
|
|
|
|
|
|
|
|
|
public void SaveSwapBattery(SwappingStateMachine machine)
|
|
|
|
|
{
|
|
|
|
|
BinInfo upBin = machine.SwapOrderBatteryInfo.UpBinInfo;
|
|
|
|
|
BinInfo inBin = machine.SwapOrderBatteryInfo.InBinInfo;
|
|
|
|
|
List<BinInfo> upBin = machine.SwapOrderBatteryInfo.UpBinInfo;
|
|
|
|
|
List<BinInfo> inBin = machine.SwapOrderBatteryInfo.InBinInfo;
|
|
|
|
|
|
|
|
|
|
List<SwapOrderBattery> swapOrderBatteryList = new List<SwapOrderBattery>();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < upBin.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
SwapOrderBattery swapOrderBattery = new SwapOrderBattery()
|
|
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 1.锁仓
|
|
|
|
|
/// 1.锁仓 锁两个
|
|
|
|
|
/// 2.更改预约单
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void LockBinAndUpdateAmt(SwapOrderBatteryInfo orderBatteryInfo)
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
var configBinInfo =
|
|
|
|
|
new MapperConfiguration(cfg => cfg.CreateMap<BinInfo, BinInfo>().ReverseMap());
|
|
|
|
|
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);
|
|
|
|
|
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<BinInfo> { UpBin , UpBin2 };
|
|
|
|
|
|
|
|
|
|
orderBatteryInfo.UpBinInfo = UpBin;
|
|
|
|
|
InBin(orderBatteryInfo, machine);
|
|
|
|
|
return orderBatteryInfo;
|
|
|
|
|
}
|
|
|
|
@ -174,12 +188,16 @@ public class CommonMgr
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="orderBatteryInfo"></param>
|
|
|
|
|
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<BinInfo>() { 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<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;
|
|
|
|
|
if (carInfoBatteryInfos != null && carInfoBatteryInfos.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
orderBatteryInfo.InBinInfo.BatteryNo = carInfoBatteryInfos[0].BatteryNo;
|
|
|
|
|
for ( int i = 0; i < carInfoBatteryInfos.Count; i++ )
|
|
|
|
|
{
|
|
|
|
|
orderBatteryInfo.InBinInfo[i].BatteryNo = carInfoBatteryInfos[i].BatteryNo;
|
|
|
|
|
// orderBatteryInfo.InBinInfo.Soc = carInfoBatteryInfos[0].Soc;
|
|
|
|
|
orderBatteryInfo.InBinInfo.Soe = carInfoBatteryInfos[0].Soe;
|
|
|
|
|
orderBatteryInfo.InBinInfo.Soh = carInfoBatteryInfos[0].Soh;
|
|
|
|
|
orderBatteryInfo.InBinInfo[i].Soe = carInfoBatteryInfos[i].Soe;
|
|
|
|
|
orderBatteryInfo.InBinInfo[i].Soh = carInfoBatteryInfos[i].Soh;
|
|
|
|
|
if (i==1)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|