|
|
|
|
@ -201,6 +201,14 @@ public class TaskExecuteRecordServiceImpl extends BaseServiceImpl<TaskExecuteRec |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 7. 任务取消,将终点站点设置为空闲,将任务设置为失败
|
|
|
|
|
if (method.equals(TaskExecuteRecord.STATUS_CANCEL)){ |
|
|
|
|
boolean conCtuReturn = taskCancelled(agvCallBack.getTaskCode()); |
|
|
|
|
if (!conCtuReturn) { |
|
|
|
|
return R.fail("任务取消失败"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 回调处理成功
|
|
|
|
|
log.info("AGV回调成功:任务单号{}的执行记录已更新,状态为{}", agvCallBack.getTaskCode(), method); |
|
|
|
|
@ -210,6 +218,71 @@ public class TaskExecuteRecordServiceImpl extends BaseServiceImpl<TaskExecuteRec |
|
|
|
|
return r; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
private boolean taskCancelled(String taskCode) { |
|
|
|
|
try { |
|
|
|
|
TaskExecuteRecord taskExecuteRecord = baseMapper.selectByTaskCode(taskCode); |
|
|
|
|
if (null == taskExecuteRecord) { |
|
|
|
|
log.error("未根据taskCode查询到有效数据,请求参数:{}", taskCode); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
log.info("任务取消,taskCode:{}", taskCode); |
|
|
|
|
log.info("任务取消,开始位置:{},结束位置:{}", taskExecuteRecord.getStartPos(), taskExecuteRecord.getEndPos()); |
|
|
|
|
|
|
|
|
|
// 1. 将任务设置为失败
|
|
|
|
|
Task task = taskService.getById(taskExecuteRecord.getTaskId()); |
|
|
|
|
if (task == null) { |
|
|
|
|
log.error("任务不存在, taskId:{}", taskExecuteRecord.getTaskId()); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
task.setTaskStatus(Task.STATUS_FAILING); |
|
|
|
|
boolean taskUpdate = taskService.updateById(task); |
|
|
|
|
if (!taskUpdate) { |
|
|
|
|
log.error("任务更新失败, taskId:{}", task.getId()); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 2. 释放终点位置
|
|
|
|
|
String positionCode = taskExecuteRecord.getEndPos(); |
|
|
|
|
|
|
|
|
|
// 2.1 站点:需要释放
|
|
|
|
|
Station station = stationService.getByStationCode(positionCode); |
|
|
|
|
if (station != null) { |
|
|
|
|
station.setStationStatus(Station.STATUS_FREE); |
|
|
|
|
boolean update = stationService.updateById(station); |
|
|
|
|
if (update) { |
|
|
|
|
log.info("站点释放成功:{}", station.getStationCode()); |
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
log.error("站点释放失败:{}", station.getStationCode()); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 2.2 梳齿架/库位:需要释放
|
|
|
|
|
Location location = locationService.selectByLocationCode(positionCode, 0); |
|
|
|
|
if (location != null) { |
|
|
|
|
location.setLocationStatus(Location.STATUS_FREE); |
|
|
|
|
boolean update = locationService.updateById(location); |
|
|
|
|
if (update) { |
|
|
|
|
log.info("库位/梳齿架释放成功:{}", location.getLocationCode()); |
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
log.error("库位/梳齿架释放失败:{}", location.getLocationCode()); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 2.3 输送线终点:不处理
|
|
|
|
|
log.info("输送线终点无需释放,positionCode:{}", positionCode); |
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("taskCancelled执行异常,taskCode:{}", taskCode, e); |
|
|
|
|
throw new RuntimeException("任务取消失败", e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean releaseSite(String taskCode) { |
|
|
|
|
try { |
|
|
|
|
|