diff --git a/acs2/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java b/acs2/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java index 5818344..cf03e55 100644 --- a/acs2/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java +++ b/acs2/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java @@ -14,7 +14,8 @@ public enum DriverTypeEnum { PHOTOELECTRIC_DETECTION_DEVICE_DRIVER(3, "photoelectric_detection_station", "光电检测站点", "station"), XIANGONG_AGV_DEVICE_DRIVER(4, "xg_agv", "仙工AGV", "agv"), RGV_DEVICE_DRIVER(5, "rgv_station", "RGV", "rgv"), - ELEVATOR_DRIVER(6, "standard_elevator", "电梯", "elevator"); + ELEVATOR_DRIVER(6, "standard_elevator", "电梯", "elevator"), + CONVEYOR_CONTROL(7, "standard_conveyor_control", "标准版-输送线", "conveyor"); //驱动索引 private int index; //驱动编码 diff --git a/acs2/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs2/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 27c72b8..c725d44 100644 --- a/acs2/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs2/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -224,14 +224,18 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public void create(Instruction dto) throws Exception { + // 指令表 + WQLObject instwo = WQLObject.getWQLObject("acs_instruction"); + + // 格式化操作 dto = format(dto); String task_code = dto.getTask_code(); TaskDto task = taskService.findByCodeFromCache(task_code); String excutetype = null; - WQLObject instwo = WQLObject.getWQLObject("acs_instruction"); String currentUsername = SecurityUtils.getCurrentUsername(); String now = DateUtil.now(); + if (StrUtil.isEmpty(dto.getRoute_plan_code())) { dto.setRoute_plan_code(task.getRoute_plan_code()); } @@ -245,10 +249,13 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu dto.setInstruction_id(IdUtil.simpleUUID()); } dto.setInstruction_type(task.getTask_type()); + + // 校验路由 List shortPathsList = routeLineService.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), dto.getRoute_plan_code()); if (ObjectUtils.isEmpty(shortPathsList)) { throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通"); } + // 判断是否已经存在指令 String type = shortPathsList.get(0).getType(); if (!StrUtil.equals(type, "0")) { JSONObject instcheckjson = instwo.query(" instruction_status <2 and next_point_code= '" + dto.getNext_point_code() + "'" + " and start_point_code = '" + dto.getStart_point_code() + "'" + " and task_id = '" + dto.getTask_id() + "'").uniqueResult(0); @@ -271,7 +278,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu dto.setStart_parent_code(task.getStart_parent_code()); dto.setNext_parent_code(task.getNext_parent_code()); - + // 判断任务类型(要下发的系统) try { // != 0 为agv任务 if (!StrUtil.equals(type, "0")) { diff --git a/acs2/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs2/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 437f88b..0e23b91 100644 --- a/acs2/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs2/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -250,7 +250,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { String plan_code = dto.getRoute_plan_code(); //判断起点终点设备类型 - if (routeLineService.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code).isEmpty()) { + if (routeLineService.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code).size()==0) { throw new Exception(dto.getStart_point_code() + "->" + dto.getNext_point_code() + "路由不通!"); } @@ -357,44 +357,32 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { } } - - /** - * 开始平均分解校验 - */ - String this_device_code = this.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code()); - if (StrUtil.isEmpty(this_device_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - List pathlist = Arrays.asList(str); - if (StrUtil.equals(acsTask.getTask_type(), "2")) { - for (int j = 0; j < pathlist.size(); j++) { - if (j == 0) { - compound_task_data = pathlist.get(j).trim(); - } else { - compound_task_data = compound_task_data + "->" + pathlist.get(j).trim(); - } - } - next_device_code = pathlist.get(pathlist.size() - 1); - - } else { - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 1; - break; - } - } - next_device_code = pathlist.get(index); + // 获取路由路线并拆分 + List shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code); + RouteLineDto routeLineDto = shortPathsList.get(0); + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(start_device_code)) { + index = m + 1; + break; } + } + next_device_code = pathlist.get(index); + + if (StrUtil.equals(deviceAppService.findDeviceTypeByCode(next_device_code), "storage")) { + // next_point_code = next_device_code + CommonFinalParam.HYPHEN_ + acsTask.getTo_y() + CommonFinalParam.HYPHEN_ + acsTask.getTo_z(); } else { - next_device_code = this_device_code; + next_point_code = next_device_code; } + + //校验路由关系 - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - if (ObjectUtils.isEmpty(shortPathsList)) { + List shortPathsList2= routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); + if (ObjectUtils.isEmpty(shortPathsList2)) { throw new BadRequestException("路由不通无法生成指令。"); } diff --git a/acs2/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java b/acs2/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java index 3d5d294..73a3fde 100644 --- a/acs2/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java +++ b/acs2/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java @@ -32,14 +32,22 @@ public class AutoCreateInst { * 根据任务状态创建指令、生成下一条指令 */ public void run() throws Exception { + // 任务接口 TaskService taskserver = SpringContextHolder.getBean(TaskService.class); + // 指令接口 InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + // 路由接口 RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + // 系统参数接口 ParamService acsConfigService = SpringContextHolder.getBean(ParamService.class); - List list = taskserver.findReadyTask(); + // 设备接口 DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + + // 查询所有就绪的任务 + List list = taskserver.findReadyTask(); for (int i = 0; i < list.size(); i++) { TaskDto acsTask = list.get(i); + // 获取任务对应的字段参数 String taskid = acsTask.getTask_id(); String taskcode = acsTask.getTask_code(); String vehiclecode = acsTask.getVehicle_code(); @@ -69,8 +77,12 @@ public class AutoCreateInst { taskserver.updateByCodeFromCache(acsTask); continue; } + + // 找指令状态 小于 完成(2)的指令 List instructions = instructionService.queryAll("instruction_status < 2"); + // 系统参数maxInstNumber(最大指令数量) String maxInstnumber = acsConfigService.findByCode(AcsConfig.MAX_INST_NUMBER).getValue(); + // 不允许超过最大系统指令数量 if (ObjectUtils.isNotEmpty(maxInstnumber)) { if (instructions.size() >= Integer.parseInt(maxInstnumber)) { log.info("已达到系统参数配置的最大指令数 [" + maxInstnumber + "] ,无法生成指令。"); @@ -80,44 +92,31 @@ public class AutoCreateInst { } } - - /** - * 开始平均分解校验 - */ - String this_device_code = taskserver.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code()); - if (StrUtil.isEmpty(this_device_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - List pathlist = Arrays.asList(str); - if (StrUtil.equals(acsTask.getTask_type(), "2")) { - for (int j = 0; j < pathlist.size(); j++) { - if (j == 0) { - compound_task_data = pathlist.get(j).trim(); - } else { - compound_task_data = compound_task_data + "->" + pathlist.get(j).trim(); - } - } - next_device_code = pathlist.get(pathlist.size() - 1); - - } else { - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 1; - break; - } - } - next_device_code = pathlist.get(index); + // 获取路由路线并拆分 + List shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code); + RouteLineDto routeLineDto = shortPathsList.get(0); + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(start_device_code)) { + index = m + 1; + break; } + } + next_device_code = pathlist.get(index); + + if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { + // next_point_code = next_device_code + CommonFinalParam.HYPHEN_ + acsTask.getTo_y() + CommonFinalParam.HYPHEN_ + acsTask.getTo_z(); } else { - next_device_code = this_device_code; + next_point_code = next_device_code; } + //校验路由关系 - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - if (ObjectUtils.isEmpty(shortPathsList)) { + List shortPathsList2 = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); + if (ObjectUtils.isEmpty(shortPathsList2)) { log.info("任务 [" + taskcode + "] 路由不通无法生成指令。"); acsTask.setRemark("任务 [" + taskcode + "] 路由不通无法生成指令。"); taskserver.updateByCodeFromCache(acsTask); @@ -127,6 +126,7 @@ public class AutoCreateInst { if (!StrUtil.equals(shortPathsList.get(0).getType(), "1")) { continue; } + Device startdevice = appService.findDeviceByCode(start_device_code); Device nextdevice = appService.findDeviceByCode(next_device_code); if (ObjectUtils.isEmpty(startdevice)) {