|
|
@ -25,6 +25,7 @@ import org.nl.wms.sch.point.service.dao.SchBasePoint; |
|
|
|
import org.nl.wms.sch.task.service.ISchBaseTaskService; |
|
|
|
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService; |
|
|
|
import org.nl.wms.sch.task.service.dao.SchBaseTask; |
|
|
|
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig; |
|
|
|
import org.nl.wms.sch.task_manage.AbstractTask; |
|
|
|
import org.nl.wms.sch.task_manage.GeneralDefinition; |
|
|
|
import org.nl.wms.sch.task_manage.enums.GroupBindMaterialStatusEnum; |
|
|
@ -81,42 +82,67 @@ public class YCLCKTask extends AbstractTask { |
|
|
|
protected void create() throws BadRequestException { |
|
|
|
// 获取任务
|
|
|
|
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); |
|
|
|
for (SchBaseTask task : tasks) { |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(task.getExt_group_data()); |
|
|
|
String region; |
|
|
|
if ("0".equals(jsonObject.getString("mode"))) { |
|
|
|
region = "HW"; |
|
|
|
} else if ("1".equals(jsonObject.getString("mode"))) { |
|
|
|
region = "HWK"; |
|
|
|
} else { |
|
|
|
log.error("任务:" + task.getTask_code() + "回温mode:" + jsonObject.getString("mode") + "模式不正确!"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
SchBasePoint point = findNextPoint(task, region); |
|
|
|
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("任务下发"); |
|
|
|
SchBasePoint schBasePoint = pointService.getOne(new LambdaQueryWrapper<SchBasePoint>() |
|
|
|
.eq(SchBasePoint::getPoint_code, task.getPoint_code1())); |
|
|
|
task.setVehicle_code(schBasePoint.getVehicle_code()); |
|
|
|
task.setVehicle_code2(schBasePoint.getVehicle_code2()); |
|
|
|
taskService.update(task); |
|
|
|
|
|
|
|
//发起任务时先把点位占用,防止发起重复任务
|
|
|
|
point.setIng_task_code(task.getTask_code()); |
|
|
|
pointService.update(point); |
|
|
|
//pdm_bd_workorder_two任务下发时,status改为2
|
|
|
|
workorderService.update(schBasePoint.getVehicle_code2(),"2"); |
|
|
|
//下发
|
|
|
|
this.renotifyAcs(task); |
|
|
|
// 配置信息
|
|
|
|
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>() |
|
|
|
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); |
|
|
|
// 获取任务配置最大生成任务数
|
|
|
|
Integer tcmn = taskConfig.getTask_issue_max_num(); |
|
|
|
// 获取执行中的任务
|
|
|
|
List<SchBaseTask> unFinishTasksByTaskConfig = taskService.findCreateTasksByTaskConfig(TASK_CONFIG_CODE); |
|
|
|
//执行中任务数量小于最大可生成任务数
|
|
|
|
if(unFinishTasksByTaskConfig.size() < tcmn){ |
|
|
|
Integer now_num = unFinishTasksByTaskConfig.size(); |
|
|
|
for (SchBaseTask task : tasks) { |
|
|
|
if(now_num < tcmn){ |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(task.getExt_group_data()); |
|
|
|
String region; |
|
|
|
if ("0".equals(jsonObject.getString("mode"))) { |
|
|
|
region = "HW"; |
|
|
|
} else if ("1".equals(jsonObject.getString("mode"))) { |
|
|
|
region = "HWK"; |
|
|
|
} else { |
|
|
|
log.error("任务:" + task.getTask_code() + "回温mode:" + jsonObject.getString("mode") + "模式不正确!"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
SchBasePoint point = findNextPoint(task, region); |
|
|
|
if (ObjectUtil.isEmpty(point)) { |
|
|
|
task.setRemark("未找到所需点位!"); |
|
|
|
taskService.update(task); |
|
|
|
// 消息通知
|
|
|
|
log.info("原材料出库未找到所需点位!"); |
|
|
|
continue; |
|
|
|
}else{ |
|
|
|
// 获取任务
|
|
|
|
List<SchBaseTask> taskList = taskService.findUnFinishTasksByPoint_code2(task.getTask_code(),point.getPoint_code()); |
|
|
|
if(taskList.size()>0){ |
|
|
|
task.setRemark("分配终点点位"+point.getPoint_code()+"已存在未完成任务!"); |
|
|
|
taskService.update(task); |
|
|
|
// 消息通知
|
|
|
|
log.info("分配终点点位"+point.getPoint_code()+"已存在未完成任务!"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
// 设置终点并修改创建成功状态
|
|
|
|
task.setPoint_code2(point.getPoint_code()); |
|
|
|
task.setTask_status(TaskStatus.CREATED.getCode()); |
|
|
|
task.setRemark("任务下发"); |
|
|
|
SchBasePoint schBasePoint = pointService.getOne(new LambdaQueryWrapper<SchBasePoint>() |
|
|
|
.eq(SchBasePoint::getPoint_code, task.getPoint_code1())); |
|
|
|
task.setVehicle_code(schBasePoint.getVehicle_code()); |
|
|
|
task.setVehicle_code2(schBasePoint.getVehicle_code2()); |
|
|
|
taskService.update(task); |
|
|
|
|
|
|
|
//发起任务时先把点位占用,防止发起重复任务
|
|
|
|
point.setIng_task_code(task.getTask_code()); |
|
|
|
pointService.update(point); |
|
|
|
//pdm_bd_workorder_two任务下发时,status改为2
|
|
|
|
workorderService.update(schBasePoint.getVehicle_code2(),"2"); |
|
|
|
//下发
|
|
|
|
this.renotifyAcs(task); |
|
|
|
now_num++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -132,7 +158,7 @@ public class YCLCKTask extends AbstractTask { |
|
|
|
} |
|
|
|
if (schBasePoint.getIs_used() |
|
|
|
&& schBasePoint.getVehicle_qty() == 0 |
|
|
|
&&ObjectUtil.isEmpty(schBasePoint.getIng_task_code()) |
|
|
|
&& ObjectUtil.isEmpty(schBasePoint.getIng_task_code()) |
|
|
|
&& ObjectUtil.isEmpty(schBasePoint.getVehicle_code2())) { |
|
|
|
log.info("原材料出库任务找到当前符合条件的缓存区位置{}", schBasePoint.getPoint_code()); |
|
|
|
return schBasePoint; |
|
|
|