diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/ISchBaseTaskService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/ISchBaseTaskService.java index b7f9ad5..4668765 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/ISchBaseTaskService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/ISchBaseTaskService.java @@ -52,32 +52,27 @@ public interface ISchBaseTaskService extends IService { /** - * 根据任务配置查询为完成的列表 + * 根据任务配置查询下发中的列表 * * @param config_code 任务配置编码 * @return 未完成任务列表 */ - List findUnFinishTasksByTaskConfig(String config_code); + List findCreateTasksByTaskConfig(String config_code); /** - * 根据任务配置查询为完成的列表 - * - * @param config_code 任务配置编码 - * @param task_code 当前任务 - * @return 未完成任务列表 + * 根据任务号和点位查询未完成的任务 + * @param task_code + * @param point_code2 + * @return */ - List findUnFinishTasksByTaskConfig(String config_code, String task_code); + List findUnFinishTasksByPoint_code2(String task_code, String point_code2); /** - * 根据任务配置查询同台设备未完成的任务列表 - * - * @param config_code 任务配置 - * @param device_code 设备 + * 根据任务类型和任务状态查询任务 + * @param config_code + * @param status * @return */ - List findUnFinishTasksByTaskConfig(String config_code, String device_code, String direction); - - List findTasksByTaskStatus(String config_code, TaskStatus status); /** diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/impl/SchBaseTaskServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/impl/SchBaseTaskServiceImpl.java index 541bb2c..d8de2ac 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/impl/SchBaseTaskServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/impl/SchBaseTaskServiceImpl.java @@ -115,36 +115,26 @@ public class SchBaseTaskServiceImpl extends ServiceImpl findUnFinishTasksByTaskConfig(String config_code) { + public List findCreateTasksByTaskConfig(String config_code) { Assert.notNull(config_code, "任务配置编码不能为空!"); LambdaQueryWrapper lam = new LambdaQueryWrapper<>(); lam.eq(SchBaseTask::getConfig_code, config_code) .ne(SchBaseTask::getIs_delete, true) + .gt(SchBaseTask::getTask_status, TaskStatus.APPLY.getCode()) .lt(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode()); List schBaseTasks = schBaseTaskMapper.selectList(lam); return schBaseTasks; } - @Override - public List findUnFinishTasksByTaskConfig(String config_code, String task_code) { - Assert.notNull(config_code, "任务配置编码不能为空!"); + public List findUnFinishTasksByPoint_code2(String task_code, String point_code2) { + Assert.notNull(task_code, "任务编码不能为空!"); + Assert.notNull(point_code2, "点位不能为空!"); LambdaQueryWrapper lam = new LambdaQueryWrapper<>(); - lam.eq(SchBaseTask::getConfig_code, config_code) - .lt(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode()) - .ne(SchBaseTask::getTask_code, task_code) // 不是当前任务 - .eq(SchBaseTask::getIs_delete, false); - List schBaseTasks = schBaseTaskMapper.selectList(lam); - return schBaseTasks; - } - - @Override - public List findUnFinishTasksByTaskConfig(String config_code, String device_code, String direction) { - Assert.notNull(config_code, "任务配置编码不能为空!"); - LambdaQueryWrapper lam = new LambdaQueryWrapper<>(); - lam.eq(SchBaseTask::getConfig_code, config_code) - .lt(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode()) - .eq(direction.equals("1"), SchBaseTask::getPoint_code1, device_code) - .eq(direction.equals("2"), SchBaseTask::getPoint_code2, device_code) + lam.lt(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode()) + .ne(ObjectUtil.isNotEmpty(task_code),SchBaseTask::getTask_code, task_code)// 不是当前任务 + .and(slam -> slam.eq(SchBaseTask::getPoint_code1, point_code2) + .or() + .eq(SchBaseTask::getPoint_code2, point_code2)) .eq(SchBaseTask::getIs_delete, false); List schBaseTasks = schBaseTaskMapper.selectList(lam); return schBaseTasks; diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java index 335fbb5..79891a1 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java @@ -167,22 +167,42 @@ public abstract class AbstractTask { // 申请任务 SchBaseTask task = new SchBaseTask(); // 任务实体 String apply_point_code = param.getString("device_code"); // 请求点 + String next_point = param.getString("next_point"); // 目的点 String config_code = param.getString("config_code"); // 1、校验数据 SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper() .eq(SchBaseTaskconfig::getConfig_code, config_code)); Assert.notNull(taskConfig, "找不到配置文件,请确认[" + config_code + "]配置是否存在!"); - // 最大任务数 + //判断该申请点位是否存在起点或终点的未完成任务 + List apply_point_lists = taskService.findUnFinishTasksByPoint_code2("",apply_point_code); + Assert.isFalse(apply_point_lists.size()>0, + "该任务申请点位["+apply_point_code+"]已存在未完成的任务,无法申请任务!"); + // 最大可创建任务数 Integer tcmn = taskConfig.getTask_create_max_num(); - // 获取执行中的任务 - List unFinishTasksByTaskConfig = taskService.findUnFinishTasksByTaskConfig( - taskConfig.getConfig_code(), apply_point_code, taskConfig.getTask_direction()); - + // 获取申请的任务 + List unFinishTasksByTaskConfig = taskService.findTasksByTaskStatus( + taskConfig.getConfig_code(), TaskStatus.APPLY); Assert.isFalse(unFinishTasksByTaskConfig.size() >= tcmn, - "该点位申请的任务未完成数已超过上限,无法申请任务"); + "该任务类型["+taskConfig.getTask_name()+"]的任务最大可申请数已超过上限,无法申请任务"); // 获取对接位点位对象 SchBasePoint pointObj = pointService.getOne(new LambdaQueryWrapper() .eq(SchBasePoint::getPoint_code, apply_point_code)); + //如果是点对点,判断目标点是否有载具 + if("3".equals( taskConfig.getTask_direction())){ + SchBasePoint nextSchBasePoint= pointService.getOne(new LambdaQueryWrapper() + .eq(SchBasePoint::getPoint_code, next_point)); + if(ObjectUtil.isEmpty(nextSchBasePoint)) { + throw new BadRequestException(next_point+"点位信息异常,请检查输入的点位!" ); + } + if(!next_point.startsWith("DKT")){ + if (nextSchBasePoint.getVehicle_qty() > 0 + || ObjectUtil.isNotEmpty(nextSchBasePoint.getVehicle_code2()) + || ObjectUtil.isNotEmpty(nextSchBasePoint.getIng_task_code())) { + // 消息通知 + throw new BadRequestException(next_point+"点位已存在载具或任务信息!" ); + } + } + } // 判断是否校验工单 if (taskConfig.getIs_check_workorder()) { //如果点位上没货 @@ -206,22 +226,6 @@ public abstract class AbstractTask { //更新对应载具工单状态为已生成任务,不可在工单页面取消 //pdm_bd_workorder_two任务生成时,status改为2 workorderService.updateByPda(pointObj.getVehicle_code2(),"2",param.getString("mode")); - // 校验工单 - // 根据对接位的父点位编码(设备)找到工单设备 - /*SchBasePoint one = pointService.getOne(new LambdaQueryWrapper() - .eq(SchBasePoint::getPoint_code, pointObj.getParent_point_code())); - // 查找当前设备、生产中 - PdmBdWorkorder workorder = workorderService.getOne(new LambdaQueryWrapper() - .eq(PdmBdWorkorder::getPoint_code, one.getPoint_code()) - .eq(PdmBdWorkorder::getWorkorder_status, WorkOrderStatusEnum.PRODUCING.getCode())); - if (ObjectUtil.isEmpty(workorder)) { - throw new BadRequestException("设备" + one.getPoint_code() + "工单未生产!"); - } - MdBaseMaterial mdBaseMaterial=materialService.getOne(new LambdaQueryWrapper() - .eq(MdBaseMaterial::getMaterial_id,workorder.getMaterial_id())); - param.put("workorder_code", workorder.getWorkorder_code()); // 静置时间 - // 设置任务数据 - task.setVehicle_type(workorder.getVehicle_type());*/ } // 校验是否需要自动agv if (!pointObj.getIs_auto()) { @@ -259,7 +263,6 @@ public abstract class AbstractTask { task.setUpdate_id(currentUserId); task.setUpdate_name(nickName); taskService.create(task); - } public void updateTaskStatus(String task_code, TaskStatus status) { diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/KJRKTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/KJRKTask.java index f7be36f..5556758 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/KJRKTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/KJRKTask.java @@ -57,34 +57,48 @@ public class KJRKTask extends AbstractTask { // 配置信息 SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper() .eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); - for (SchBaseTask task : tasks) { - // 找终点 - SchBasePoint startPoint = pointService.getOne(new LambdaQueryWrapper() - .eq(SchBasePoint::getPoint_code, task.getPoint_code1())); - String extGroupData = task.getExt_group_data(); - JSONObject jsonObject = JSONObject.parseObject(extGroupData); -// String materialType = jsonObject.getString("material_type"); - SchBasePoint point = findNextPoint(); - 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); + // 获取任务配置最大生成任务数 + Integer tcmn = taskConfig.getTask_issue_max_num(); + // 获取执行中的任务 + List unFinishTasksByTaskConfig = taskService.findCreateTasksByTaskConfig(TASK_CONFIG_CODE); + if(unFinishTasksByTaskConfig.size() < tcmn){ + Integer now_num = unFinishTasksByTaskConfig.size(); + for (SchBaseTask task : tasks) { + if(now_num < tcmn){ + // 找终点 + SchBasePoint point = findNextPoint(); + if (ObjectUtil.isEmpty(point)) { + task.setRemark("未找到所需点位!"); + taskService.update(task); + // 消息通知 + log.info("空架入库未找到当前符合条件的点位!"); + continue; + }else{ + // 获取任务 + List 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("下发"); + taskService.update(task); + + //发起任务时先把点位占用,防止发起重复任务 + point.setIng_task_code(task.getTask_code()); + pointService.update(point); - //发起任务时先把点位占用,防止发起重复任务 - point.setIng_task_code(task.getTask_code()); -// point.setVehicle_type(materialType); - pointService.update(point); + //下发 + this.renotifyAcs(task); - //下发 - this.renotifyAcs(task); + } + } } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/POINTTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/POINTTask.java index e01fb6f..0d7f4d7 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/POINTTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/POINTTask.java @@ -67,39 +67,62 @@ public class POINTTask extends AbstractTask { .eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); Assert.notNull(taskConfig, "找不到任务配置文件,请确认YCLCKTask配置是否存在!"); // 获取任务配置最大生成任务数 - Integer tcmn = taskConfig.getTask_create_max_num(); + Integer tcmn = taskConfig.getTask_issue_max_num(); // 获取执行中的任务 - List unFinishTasksByTaskConfig = taskService.findUnFinishTasksByTaskConfig(TASK_CONFIG_CODE); + List unFinishTasksByTaskConfig = taskService.findCreateTasksByTaskConfig(TASK_CONFIG_CODE); //执行中任务数量小于最大可生成任务数 if(unFinishTasksByTaskConfig.size() < tcmn){ + Integer now_num = unFinishTasksByTaskConfig.size(); for (SchBaseTask task : tasks) { - task.setTask_status(TaskStatus.CREATED.getCode()); - task.setRemark(""); - SchBasePoint schBasePoint= pointService.getOne(new LambdaQueryWrapper() - .eq(SchBasePoint::getPoint_code, task.getPoint_code1())); - SchBasePoint nextSchBasePoint= pointService.getOne(new LambdaQueryWrapper() - .eq(SchBasePoint::getPoint_code, task.getPoint_code2())); - if(task.getPoint_code2().startsWith("DKT")){ - //如果是叠盘位,根据当前数量+1为目标地址 - int qty=nextSchBasePoint.getVehicle_qty()+1; - task.setPoint_code2(task.getPoint_code2().substring(0,task.getPoint_code2().length()-1)+qty); - } - task.setVehicle_code(schBasePoint.getVehicle_code()); - task.setVehicle_code2(schBasePoint.getVehicle_code2()); - taskService.update(task); + if(now_num < tcmn){ + SchBasePoint schBasePoint= pointService.getOne(new LambdaQueryWrapper() + .eq(SchBasePoint::getPoint_code, task.getPoint_code1())); + SchBasePoint nextSchBasePoint= pointService.getOne(new LambdaQueryWrapper() + .eq(SchBasePoint::getPoint_code, task.getPoint_code2())); + if(task.getPoint_code2().startsWith("DKT")){ + //如果是叠盘位,根据当前数量+1为目标地址 + int qty=nextSchBasePoint.getVehicle_qty()+1; + task.setPoint_code2(task.getPoint_code2().substring(0,task.getPoint_code2().length()-1)+qty); + }else{ + if (nextSchBasePoint.getVehicle_qty() > 0 + || ObjectUtil.isNotEmpty(nextSchBasePoint.getVehicle_code2())) { + task.setRemark("分配终点点位"+task.getPoint_code2()+"已存在载具!"); + taskService.update(task); + // 消息通知 + log.info("分配终点点位"+task.getPoint_code2()+"已存在已存在载具!"); + continue; + } + // 获取任务 + List taskList = taskService.findUnFinishTasksByPoint_code2(task.getTask_code(),task.getPoint_code2()); + if(taskList.size()>0){ + task.setRemark("分配终点点位"+task.getPoint_code2()+"已存在未完成任务!"); + taskService.update(task); + // 消息通知 + log.info("分配终点点位"+task.getPoint_code2()+"已存在未完成任务!"); + continue; + } + } + task.setTask_status(TaskStatus.CREATED.getCode()); + task.setVehicle_code(schBasePoint.getVehicle_code()); + task.setVehicle_code2(schBasePoint.getVehicle_code2()); + task.setRemark("下发"); + taskService.update(task); - //发起任务时先把点位占用,防止发起重复任务 - schBasePoint.setIng_task_code(task.getTask_code()); - pointService.update(schBasePoint); - nextSchBasePoint.setIng_task_code(task.getTask_code()); - pointService.update(nextSchBasePoint); - //去回温库的任务,更细工单表 - if(nextSchBasePoint.getPoint_code().contains("XHW")){ - //pdm_bd_workorder_two任务完成时,status改为2出库中 - workorderService.update(schBasePoint.getVehicle_code2(),"2"); + //发起任务时先把点位占用,防止发起重复任务 + schBasePoint.setIng_task_code(task.getTask_code()); + pointService.update(schBasePoint); + nextSchBasePoint.setIng_task_code(task.getTask_code()); + pointService.update(nextSchBasePoint); + //去回温库的任务,更细工单表 + if(nextSchBasePoint.getPoint_code().contains("XHW")){ + //pdm_bd_workorder_two任务完成时,status改为2出库中 + workorderService.update(schBasePoint.getVehicle_code2(),"2"); + } + //下发 + this.renotifyAcs(task); + now_num++; } - //下发 - this.renotifyAcs(task); + } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/SSXBKJTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/SSXBKJTask.java index cdba214..fac17c9 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/SSXBKJTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/SSXBKJTask.java @@ -57,32 +57,47 @@ public class SSXBKJTask extends AbstractTask { // 配置信息 SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper() .eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); - for (SchBaseTask task : tasks) { - // 找终点 - SchBasePoint startPoint = pointService.getOne(new LambdaQueryWrapper() - .eq(SchBasePoint::getPoint_code, task.getPoint_code1())); - String extGroupData = task.getExt_group_data(); - JSONObject jsonObject = JSONObject.parseObject(extGroupData); - SchBasePoint point = findNextPoint(); - if (ObjectUtil.isEmpty(point)) { - task.setRemark("未找到所需点位!"); - taskService.update(task); - // 消息通知 - log.info("原材料入库未找到当前符合条件的点位!"); - continue; - } - // 设置起点并修改创建成功状态 - task.setPoint_code1(point.getPoint_code()); - task.setTask_status(TaskStatus.CREATED.getCode()); - task.setRemark(""); - taskService.update(task); - - //发起任务时先把点位占用,防止发起重复任务 - point.setIng_task_code(task.getTask_code()); - pointService.update(point); + // 获取任务配置最大生成任务数 + Integer tcmn = taskConfig.getTask_issue_max_num(); + // 获取执行中的任务 + List unFinishTasksByTaskConfig = taskService.findCreateTasksByTaskConfig(TASK_CONFIG_CODE); + //执行中任务数量小于最大可生成任务数 + if(unFinishTasksByTaskConfig.size() < tcmn){ + Integer now_num = unFinishTasksByTaskConfig.size(); + for (SchBaseTask task : tasks) { + if(now_num < tcmn){ + SchBasePoint point = findNextPoint(); + if (ObjectUtil.isEmpty(point)) { + task.setRemark("未找到所需点位!"); + taskService.update(task); + // 消息通知 + log.info("输送线补空架未找到当前符合条件的点位!"); + continue; + }else{ + // 获取任务 + List 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_code1(point.getPoint_code()); + task.setTask_status(TaskStatus.CREATED.getCode()); + task.setRemark("下发"); + taskService.update(task); - //下发 - this.renotifyAcs(task); + //发起任务时先把点位占用,防止发起重复任务 + point.setIng_task_code(task.getTask_code()); + pointService.update(point); + //下发 + this.renotifyAcs(task); + now_num++; + } + } } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLCKTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLCKTask.java index 3b27c5e..cfaf4bf 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLCKTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLCKTask.java @@ -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 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() - .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() + .eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); + // 获取任务配置最大生成任务数 + Integer tcmn = taskConfig.getTask_issue_max_num(); + // 获取执行中的任务 + List 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 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() + .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; diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLRKTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLRKTask.java index 781c600..56c30db 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLRKTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLRKTask.java @@ -86,34 +86,51 @@ public class YCLRKTask extends AbstractTask { // 配置信息 SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper() .eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); - for (SchBaseTask task : tasks) { - // 当前输送线 - SchBasePoint startPoint = pointService.getOne(new LambdaQueryWrapper() - .eq(SchBasePoint::getPoint_code, task.getPoint_code1())); - String extGroupData = task.getExt_group_data(); - JSONObject jsonObject = JSONObject.parseObject(extGroupData); - SchBasePoint point = findNextPoint(jsonObject.getString("sub_tray")); - 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.setVehicle_code(jsonObject.getString("mother_tray")); - task.setVehicle_code2(jsonObject.getString("sub_tray")); - task.setRemark(""); - taskService.update(task); - - //发起任务时先把点位占用,防止发起重复任务 - point.setIng_task_code(task.getTask_code()); - pointService.update(point); + // 获取任务配置最大下发任务数 + Integer tcmn = taskConfig.getTask_issue_max_num(); + // 获取执行中的任务 + List unFinishTasksByTaskConfig = taskService.findCreateTasksByTaskConfig(TASK_CONFIG_CODE); + //执行中任务数量小于最大可生成任务数 + if(unFinishTasksByTaskConfig.size() < tcmn){ + Integer now_num = unFinishTasksByTaskConfig.size(); + for (SchBaseTask task : tasks) { + if(now_num < tcmn){ + String extGroupData = task.getExt_group_data(); + JSONObject jsonObject = JSONObject.parseObject(extGroupData); + SchBasePoint point = findNextPoint(jsonObject.getString("sub_tray")); + if (ObjectUtil.isEmpty(point)) { + task.setRemark("未找到所需点位!"); + taskService.update(task); + // 消息通知 + log.info("原材料入库未找到当前符合条件的点位!"); + continue; + }else{ + // 获取任务 + List 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.setVehicle_code(jsonObject.getString("mother_tray")); + task.setVehicle_code2(jsonObject.getString("sub_tray")); + task.setRemark("下发"); + taskService.update(task); - //下发 - this.renotifyAcs(task); + //发起任务时先把点位占用,防止发起重复任务 + point.setIng_task_code(task.getTask_code()); + pointService.update(point); + //下发 + this.renotifyAcs(task); + now_num++; + } + } } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/workorder/service/impl/WorkorderServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/workorder/service/impl/WorkorderServiceImpl.java index efbdf9c..52086c3 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/workorder/service/impl/WorkorderServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/workorder/service/impl/WorkorderServiceImpl.java @@ -22,6 +22,7 @@ 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.task.core.TaskStatus; import org.nl.wms.sch.workorder.service.IWorkorderService; import org.nl.wms.sch.workorder.service.dao.Workorder; import org.nl.wms.sch.workorder.service.dao.mapper.WorkorderMapper; @@ -191,8 +192,8 @@ public class WorkorderServiceImpl extends ServiceImpl unFinishTasksByTaskConfig = new ArrayList(); + // 获取申请的任务 + List unFinishTasksByTaskConfig = taskService.findTasksByTaskStatus(config_code, TaskStatus.APPLY); JSONObject param=new JSONObject(); for(YCLKCDto workorder : list){ //子载具 @@ -203,9 +204,7 @@ public class WorkorderServiceImpl extends ServiceImpl