|
|
|
|
@ -38,6 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.util.List; |
|
|
|
|
@ -80,7 +81,7 @@ public class PipelineServiceImpl implements IPipelineService { |
|
|
|
|
// 1. 判断是否超重
|
|
|
|
|
if (WeighData.RETURN_STATUS_RETURNED.equals(returnStatus)) { |
|
|
|
|
// 2. 保存称重数据
|
|
|
|
|
taskService.savePipelineWeigh(boxBarcode,actualWeight); |
|
|
|
|
taskService.savePipelineWeigh(boxBarcode,actualWeight,Task.STATUS_RETURNED); |
|
|
|
|
|
|
|
|
|
// 3.超重处理,解绑
|
|
|
|
|
BoxBindingDto boxBindingDto = new BoxBindingDto(); |
|
|
|
|
@ -93,7 +94,7 @@ public class PipelineServiceImpl implements IPipelineService { |
|
|
|
|
return false; |
|
|
|
|
} else { |
|
|
|
|
// 2. 保存称重数据
|
|
|
|
|
taskService.savePipelineWeigh(boxBarcode,actualWeight); |
|
|
|
|
taskService.savePipelineWeigh(boxBarcode,actualWeight,Task.STATUS_START); |
|
|
|
|
log.info("物料箱[{}]重量校验通过", boxBarcode); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
@ -125,6 +126,10 @@ public class PipelineServiceImpl implements IPipelineService { |
|
|
|
|
throw new ServiceException("查询不到该物料箱: " + boxBarcode); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 1.2 更新状态 为运输中
|
|
|
|
|
task.setTaskStatus(Task.STATUS_CONVEYOR_END); |
|
|
|
|
taskService.updateById(task); |
|
|
|
|
|
|
|
|
|
// 2. 判断站点是否有预占(是否站点没满)
|
|
|
|
|
if (null != task.getStationId()) { |
|
|
|
|
// 站点没满,有预占 - 送往指定站点
|
|
|
|
|
@ -139,32 +144,91 @@ public class PipelineServiceImpl implements IPipelineService { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理有预占的情况(站点没满)- 直接送往指定站点 |
|
|
|
|
* |
|
|
|
|
* @param boxBarcode 物料箱条码 |
|
|
|
|
* @param stationId 预占站点ID |
|
|
|
|
* @return true-处理成功 false-处理失败 |
|
|
|
|
*/ |
|
|
|
|
private boolean handlePreOccupiedStation(String boxBarcode, Long stationId) { |
|
|
|
|
log.info("开始处理预占站点,boxBarcode:{},stationId:{}", boxBarcode, stationId); |
|
|
|
|
|
|
|
|
|
// 1. 参数校验
|
|
|
|
|
if (StringUtils.isEmpty(boxBarcode)) { |
|
|
|
|
log.error("物料箱条码为空"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (null == stationId) { |
|
|
|
|
log.error("站点ID为空"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 2. 查询站点信息
|
|
|
|
|
Station station = stationService.getById(stationId); |
|
|
|
|
if (null == station) { |
|
|
|
|
log.error("预占站点不存在:{}", stationId); |
|
|
|
|
log.error("预占站点不存在,stationId:{}", stationId); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 校验站点状态是否为预占用
|
|
|
|
|
// 3. 校验站点状态是否为预占用
|
|
|
|
|
if (!Station.PRE_STATUS_OCCUPIED.equals(station.getStationStatus())) { |
|
|
|
|
log.error("站点状态不是预占用,无法送往:{}", station.getStationCode()); |
|
|
|
|
log.error("站点状态不是预占用,当前状态:{},站点:{}", |
|
|
|
|
station.getStationStatus(), station.getStationCode()); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("站点有预占,将物料箱送往指定站点:{}", station.getStationCode()); |
|
|
|
|
|
|
|
|
|
String taskType = agvTaskTypeUtil.getTaskTypeByPositions(Station.PICKUP_CONVEYOR_LINE,station.getStationCode()); |
|
|
|
|
|
|
|
|
|
// 入库记录
|
|
|
|
|
// 4. 查询任务信息
|
|
|
|
|
Task task = taskService.getBoxBarcode(boxBarcode); |
|
|
|
|
if (null == task) { |
|
|
|
|
log.error("根据箱码未查询到任务,boxBarcode:{}", boxBarcode); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
boolean agvSchedulingTask = iTaskExecuteRecordService.genAgvSchedulingTask |
|
|
|
|
(taskType, Station.PICKUP_CONVEYOR_LINE, station.getStationCode(), AgvConstant.EQUIPMENT_TYPE_AGV, task); |
|
|
|
|
// 5. 生成任务类型
|
|
|
|
|
String taskType = agvTaskTypeUtil.getTaskTypeByPositions( |
|
|
|
|
Station.PICKUP_CONVEYOR_LINE, |
|
|
|
|
station.getStationCode() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return agvSchedulingTask; |
|
|
|
|
if (StringUtils.isEmpty(taskType)) { |
|
|
|
|
log.error("生成任务类型失败,from:{},to:{}", |
|
|
|
|
Station.PICKUP_CONVEYOR_LINE, station.getStationCode()); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 6. 调用AGV调度
|
|
|
|
|
boolean agvSchedulingTask = iTaskExecuteRecordService.genAgvSchedulingTask( |
|
|
|
|
taskType, |
|
|
|
|
Station.PICKUP_CONVEYOR_LINE, |
|
|
|
|
station.getStationCode(), |
|
|
|
|
AgvConstant.EQUIPMENT_TYPE_AGV, |
|
|
|
|
task |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (!agvSchedulingTask) { |
|
|
|
|
log.error("AGV调度失败,boxBarcode:{},station:{}", |
|
|
|
|
boxBarcode, station.getStationCode()); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 7. 更新任务状态
|
|
|
|
|
task.setTaskStatus(Task.STATUS_FINISHED); |
|
|
|
|
boolean taskUpdate = taskService.updateById(task); |
|
|
|
|
if (!taskUpdate) { |
|
|
|
|
log.error("任务状态更新失败,但AGV调度已成功,taskId:{}", task.getId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 8. 更新站点状态为占用
|
|
|
|
|
station.setStationStatus(Station.STATUS_OCCUPIED); |
|
|
|
|
boolean stationUpdate = stationService.updateById(station); |
|
|
|
|
if (!stationUpdate) { |
|
|
|
|
log.error("站点状态更新失败,但AGV调度已成功,stationId:{}", stationId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("预占站点处理成功,boxBarcode:{},station:{}", boxBarcode, station.getStationCode()); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -185,10 +249,36 @@ public class PipelineServiceImpl implements IPipelineService { |
|
|
|
|
stationService.updateById(station); |
|
|
|
|
|
|
|
|
|
String taskType = agvTaskTypeUtil.getTaskTypeByPositions(Station.PICKUP_CONVEYOR_LINE,station.getStationCode()); |
|
|
|
|
if (StringUtils.isEmpty(taskType)) { |
|
|
|
|
log.error("生成任务类型失败,from:{},to:{}", |
|
|
|
|
Station.PICKUP_CONVEYOR_LINE, station.getStationCode()); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
boolean agvSchedulingTask = iTaskExecuteRecordService.genAgvSchedulingTask |
|
|
|
|
(taskType, Station.PICKUP_CONVEYOR_LINE, station.getStationCode(), AgvConstant.EQUIPMENT_TYPE_AGV, task); |
|
|
|
|
|
|
|
|
|
if (!agvSchedulingTask) { |
|
|
|
|
log.error("AGV调度失败,station:{}", station.getStationCode()); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 更新任务状态
|
|
|
|
|
task.setTaskStatus(Task.STATUS_FINISHED); |
|
|
|
|
boolean taskUpdate = taskService.updateById(task); |
|
|
|
|
if (!taskUpdate) { |
|
|
|
|
log.error("任务状态更新失败,但AGV调度已成功,taskId:{}", task.getId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 更新站点状态为占用
|
|
|
|
|
station.setStationStatus(Station.STATUS_OCCUPIED); |
|
|
|
|
boolean stationUpdate = stationService.updateById(station); |
|
|
|
|
if (!stationUpdate) { |
|
|
|
|
log.error("站点状态更新失败,但AGV调度已成功,stationId:{}", station.getId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("预占站点处理成功,station:{}", station.getStationCode()); |
|
|
|
|
|
|
|
|
|
return agvSchedulingTask; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|