|
|
|
@ -27,6 +27,8 @@ public class MonitorService
|
|
|
|
|
public ChargeOrderRepository ChargeOrderRepository { get; set; }
|
|
|
|
|
public PlcTaskMgr PlcTaskMgr { get; set; }
|
|
|
|
|
|
|
|
|
|
public MoveBinRecordRepository MoveBinRecordRepository { get; set; }
|
|
|
|
|
|
|
|
|
|
public Result<SwapMonitorScreenResp> GetSwapMonitorData()
|
|
|
|
|
{
|
|
|
|
|
var configBinInfo =
|
|
|
|
@ -145,7 +147,7 @@ public class MonitorService
|
|
|
|
|
/// <param name="removeBinNo"></param>
|
|
|
|
|
/// <param name="putBinNo"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public Result<bool> BatteryRelocation(ushort removeBinNo, ushort putBinNo)
|
|
|
|
|
public Result<bool> BatteryRelocation(ushort removeBinNo, ushort putBinNo,int type=0)
|
|
|
|
|
{
|
|
|
|
|
//校验:出仓位
|
|
|
|
|
BinInfo? removeBin = BinInfoRepository.QueryByClause(i =>
|
|
|
|
@ -165,13 +167,22 @@ public class MonitorService
|
|
|
|
|
return Result<bool>.Fail("入仓位状态有误");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (PlcMgr.PlcClient?.ReadTaskNo() != 0)
|
|
|
|
|
{
|
|
|
|
|
Log.Info("当前存在其他任务");
|
|
|
|
|
return Result<bool>.Fail("当前存在其他任务");
|
|
|
|
|
}
|
|
|
|
|
PlcMgr.PlcClient?.ExChangeTaskNo(2);
|
|
|
|
|
var result = PlcMgr.DistributeTask(putBinNo, removeBinNo, 2);
|
|
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
|
{
|
|
|
|
|
PlcMgr.PlcClient?.ExChangeTaskNo(0);
|
|
|
|
|
return Result<bool>.Fail();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int count = 3;
|
|
|
|
|
while (count > 0)
|
|
|
|
|
{
|
|
|
|
@ -187,22 +198,40 @@ public class MonitorService
|
|
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
|
{
|
|
|
|
|
PlcMgr.PlcClient?.ExChangeTaskNo(0);
|
|
|
|
|
Log.Error("BatteryRelocation PlcMgr.ReadTaskStatus(2) =false");
|
|
|
|
|
return Result<bool>.Fail();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MoveBinRecord moveBinRecord = new MoveBinRecord()
|
|
|
|
|
{
|
|
|
|
|
UpBinNo = removeBinNo.ToString(),
|
|
|
|
|
UpBatteryNo = removeBin.BatteryNo,
|
|
|
|
|
UpBatterySoc = removeBin.Soc.ToString(),
|
|
|
|
|
InBatteryNo = putBin.BatteryNo,
|
|
|
|
|
InBatterySoc = putBin.Soc.ToString(),
|
|
|
|
|
InBinNo = putBinNo.ToString(),
|
|
|
|
|
Status = 0,
|
|
|
|
|
Type = type
|
|
|
|
|
};
|
|
|
|
|
MoveBinRecordRepository.Insert(moveBinRecord);
|
|
|
|
|
|
|
|
|
|
result = PlcMgr.HoldOn();
|
|
|
|
|
if (!result)
|
|
|
|
|
{
|
|
|
|
|
{ PlcMgr.PlcClient?.ExChangeTaskNo(0);
|
|
|
|
|
Log.Error("BatteryRelocation PlcMgr.HoldOn() =false");
|
|
|
|
|
return Result<bool>.Fail();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log.Info($"battery move task Manual removeBinNo={removeBinNo}, putBinNo={putBinNo} ");
|
|
|
|
|
|
|
|
|
|
Log.Info($"battery move task Manual removeBinNo={removeBinNo}, putBinNo={putBinNo} type={type} ");
|
|
|
|
|
moveBinRecord.Status = 1;
|
|
|
|
|
MoveBinRecordRepository.Update(moveBinRecord);
|
|
|
|
|
var queryPlcTask = PlcTaskMgr.QueryPlcTask(2, 1200, 1201);
|
|
|
|
|
if (!queryPlcTask)
|
|
|
|
|
{
|
|
|
|
|
PlcMgr.PlcClient?.ExChangeTaskNo(0);
|
|
|
|
|
moveBinRecord.Status = 3;
|
|
|
|
|
MoveBinRecordRepository.Update(moveBinRecord);
|
|
|
|
|
return Result<bool>.Fail();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -231,8 +260,9 @@ public class MonitorService
|
|
|
|
|
|
|
|
|
|
removeBin.BatteryEnterSeq = 0;
|
|
|
|
|
BinInfoRepository.Update(removeBin);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
moveBinRecord.Status = 2;
|
|
|
|
|
MoveBinRecordRepository.Update(moveBinRecord);
|
|
|
|
|
PlcMgr.PlcClient?.ExChangeTaskNo(0);
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|