移仓内部增加try catch

master
rszn 5 months ago
parent 47d2522c2b
commit 5aac8e7f0b

@ -149,6 +149,9 @@ public class MonitorService
/// <param name="putBinNo"></param> /// <param name="putBinNo"></param>
/// <returns></returns> /// <returns></returns>
public Result<bool> BatteryRelocation(ushort removeBinNo, ushort putBinNo, int type = 0) public Result<bool> BatteryRelocation(ushort removeBinNo, ushort putBinNo, int type = 0)
{
MoveBinRecord moveBinRecord = null;
try
{ {
//校验:出仓位 //校验:出仓位
BinInfo? removeBin = BinInfoRepository.QueryByClause(i => BinInfo? removeBin = BinInfoRepository.QueryByClause(i =>
@ -173,6 +176,7 @@ public class MonitorService
Log.Info("当前存在其他任务"); Log.Info("当前存在其他任务");
return Result<bool>.Fail("当前存在其他任务"); return Result<bool>.Fail("当前存在其他任务");
} }
PlcMgr.PlcClient?.ExChangeTaskNo(2); PlcMgr.PlcClient?.ExChangeTaskNo(2);
var result = PlcMgr.DistributeTask(putBinNo, removeBinNo, 2); var result = PlcMgr.DistributeTask(putBinNo, removeBinNo, 2);
@ -183,7 +187,6 @@ public class MonitorService
} }
int count = 3; int count = 3;
while (count > 0) while (count > 0)
{ {
@ -204,7 +207,7 @@ public class MonitorService
return Result<bool>.Fail(); return Result<bool>.Fail();
} }
MoveBinRecord moveBinRecord = new MoveBinRecord() moveBinRecord = new MoveBinRecord()
{ {
UpBinNo = removeBinNo.ToString(), UpBinNo = removeBinNo.ToString(),
UpBatteryNo = removeBin.BatteryNo, UpBatteryNo = removeBin.BatteryNo,
@ -270,6 +273,21 @@ public class MonitorService
Log.Info($"move battery success update moveBin={JsonConvert.SerializeObject(moveBinRecord)}"); Log.Info($"move battery success update moveBin={JsonConvert.SerializeObject(moveBinRecord)}");
MoveBinRecordRepository.Update(moveBinRecord); MoveBinRecordRepository.Update(moveBinRecord);
PlcMgr.PlcClient?.ExChangeTaskNo(0); PlcMgr.PlcClient?.ExChangeTaskNo(0);
}
catch (Exception e)
{
Log.Error($"move battery fail e={e.Message}");
if (moveBinRecord != null)
{
moveBinRecord.Status = 3;
MoveBinRecordRepository.Update(moveBinRecord);
}
PlcMgr.PlcClient?.ResetTaskNo();
return Result<bool>.Fail();
}
return Result<bool>.Success(); return Result<bool>.Success();
} }

Loading…
Cancel
Save