|
|
@ -63,20 +63,113 @@ public class TBXBKJTask extends AbstractTask { |
|
|
|
@Autowired |
|
|
|
private WmsToAcsService wmsToAcsService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 涂版线工位发起叫料请求 |
|
|
|
* 从对应AB区的空固化架缓存位生成搬运任务 |
|
|
|
* 不记录组盘,不考虑点位状态 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
|
protected void create() throws BadRequestException { |
|
|
|
// 获取任务
|
|
|
|
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); |
|
|
|
// 配置信息
|
|
|
|
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>() |
|
|
|
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); |
|
|
|
for (SchBaseTask task : tasks) { |
|
|
|
// 找起点
|
|
|
|
SchBasePoint startPoint = pointService.getOne(new LambdaQueryWrapper<SchBasePoint>() |
|
|
|
.eq(SchBasePoint::getPoint_code, task.getPoint_code1())); |
|
|
|
SchBasePoint point = findNextPoint(startPoint); |
|
|
|
if (ObjectUtil.isEmpty(point)) { |
|
|
|
task.setRemark("未找到所需点位!"); |
|
|
|
taskService.update(task); |
|
|
|
// 消息通知
|
|
|
|
log.info("涂板线补空架未找到空架缓存点存在空架!"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 设置终点并修改创建成功状态
|
|
|
|
task.setPoint_code2(point.getPoint_code()); |
|
|
|
task.setTask_status(TaskStatus.CREATED.getCode()); |
|
|
|
task.setRemark(""); |
|
|
|
taskService.update(task); |
|
|
|
|
|
|
|
//发起任务时先把点位占用,防止发起重复任务
|
|
|
|
point.setIng_task_code(task.getTask_code()); |
|
|
|
//空固化架区别于组盘,任务完成后再扣除库存
|
|
|
|
// point.setVehicle_qty(point.getVehicle_qty() - 1);
|
|
|
|
pointService.update(point); |
|
|
|
|
|
|
|
//下发
|
|
|
|
this.renotifyAcs(task); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 从01到10顺序判断最先有货的工位 |
|
|
|
*/ |
|
|
|
private SchBasePoint findNextPoint(SchBasePoint startPoint) { |
|
|
|
String regionCode = null; |
|
|
|
if ("TBX1".equals(startPoint.getRegion_code())) { |
|
|
|
//KGHJ1找A区
|
|
|
|
regionCode = "KGHJ1"; |
|
|
|
|
|
|
|
} else if ("TBX2".equals(startPoint.getRegion_code())) { |
|
|
|
//KGHJ2找B区
|
|
|
|
regionCode = "KGHJ2"; |
|
|
|
} |
|
|
|
List<SchBasePoint> schBasePointList = pointMapper.findPointByRegion(regionCode,null); |
|
|
|
for (SchBasePoint schBasePoint : schBasePointList) { |
|
|
|
if (schBasePoint.getVehicle_qty() > 0) { |
|
|
|
log.info("涂板线补空架找到当前符合条件的点位{}",schBasePoint.getPoint_code()); |
|
|
|
return schBasePoint; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
|
protected void updateStatus(String task_code, TaskStatus status) { |
|
|
|
// 校验任务
|
|
|
|
SchBaseTask taskObj = taskService.getById(task_code); |
|
|
|
if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) { |
|
|
|
throw new BadRequestException("该任务已完成!"); |
|
|
|
} |
|
|
|
if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) { |
|
|
|
throw new BadRequestException("该任务已取消!"); |
|
|
|
} |
|
|
|
|
|
|
|
String startPoint = taskObj.getPoint_code1(); // 获取起点
|
|
|
|
String endPoint = taskObj.getPoint_code2(); // 获取终点
|
|
|
|
SchBasePoint startPointObj = pointService.getById(startPoint); |
|
|
|
SchBasePoint endPointObj = pointService.getById(endPoint); |
|
|
|
// 根据传来的类型去对任务进行操作
|
|
|
|
if (status.equals(TaskStatus.EXECUTING)) { // 执行中
|
|
|
|
taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); |
|
|
|
taskObj.setRemark("执行中"); |
|
|
|
} |
|
|
|
if (status.equals(TaskStatus.FINISHED)) { // 完成
|
|
|
|
// 起点解锁,库存减少
|
|
|
|
startPointObj.setIng_task_code(""); |
|
|
|
startPointObj.setVehicle_qty(startPointObj.getVehicle_qty()-1); |
|
|
|
pointService.update(endPointObj); |
|
|
|
|
|
|
|
// 任务完成
|
|
|
|
taskObj.setTask_status(TaskStatus.FINISHED.getCode()); |
|
|
|
taskObj.setRemark("任务完成"); |
|
|
|
} |
|
|
|
if (status.equals(TaskStatus.CANCELED)) { // 取消
|
|
|
|
// 终点解锁
|
|
|
|
if (ObjectUtil.isNotEmpty(endPointObj)) { |
|
|
|
endPointObj.setIng_task_code(""); |
|
|
|
pointService.update(endPointObj); |
|
|
|
} |
|
|
|
taskObj.setRemark("任务取消"); |
|
|
|
taskObj.setTask_status(TaskStatus.CANCELED.getCode()); |
|
|
|
} |
|
|
|
taskService.update(taskObj); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|