diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java index 200ed5d..626c348 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java @@ -141,7 +141,7 @@ public class AgvServiceImpl implements AgvService { properties.add(pro2); destinationOrder.put("properties", properties); //不等待 - } else { + } else if ("4".equals(pro)){ JSONArray properties = new JSONArray(); JSONObject pro1 = new JSONObject(); pro1.put("key", "EntryRequired"); @@ -152,6 +152,13 @@ public class AgvServiceImpl implements AgvService { pro2.put("value", "False"); properties.add(pro2); destinationOrder.put("properties", properties); + } else if ("5".equals(pro)){ + JSONArray properties = new JSONArray(); + JSONObject pro2 = new JSONObject(); + pro2.put("key", "PauseOnStation"); + pro2.put("value", "True"); + properties.add(pro2); + destinationOrder.put("properties", properties); } } else if (propertiesType.equals("2")) {//Spin转动 @@ -274,7 +281,7 @@ public class AgvServiceImpl implements AgvService { } else if (i == pathlist.size() - 1) { ja.add(destination(device_code, "Unload", "1", "1")); } else { - ja.add(destination(device_code, "OP_DUMP", "1", "4")); + ja.add(destination(device_code, "NOP", "1", "5")); } } diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_one_rgv/LnshOneRGVDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_one_rgv/LnshOneRGVDeviceDriver.java index 1b28567..7b5a3bf 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_one_rgv/LnshOneRGVDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_one_rgv/LnshOneRGVDeviceDriver.java @@ -99,6 +99,11 @@ public class LnshOneRGVDeviceDriver extends AbstractOpcDeviceDriver implements D String specifications = ""; String last_specifications = ""; + //当前指令 + Instruction inst = null; + //上次指令 + Instruction last_inst = null; + @Override public Device getDevice() { return this.device; @@ -173,6 +178,28 @@ public class LnshOneRGVDeviceDriver extends AbstractOpcDeviceDriver implements D logServer.deviceLogToacs(this.device_code,"","","信号specifications:" + last_specifications + "->" + specifications); } + if ( action_1 == 1 && move_1 != 0 && task1 > 0) { + //inst_message + inst = instructionService.findByCodeFromCache(String.valueOf(task1)); + if (inst != null) { + if (StrUtil.equals(inst.getInstruction_status(), "0")) { + inst.setInstruction_status("1"); + instructionService.update(inst); + } + } + + } + if ( action_1 == 4 && task1 > 0) { + //inst_message + inst = instructionService.findByCodeFromCache(String.valueOf(task1)); + if (inst != null) { + if (StrUtil.equals(inst.getInstruction_status(), "1")) { + finish_instruction(); + } + } + + } + } catch (Exception var17) { return; } @@ -263,9 +290,6 @@ public class LnshOneRGVDeviceDriver extends AbstractOpcDeviceDriver implements D } - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } public void writing1(int command) { String to_command1 = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() @@ -278,14 +302,28 @@ public class LnshOneRGVDeviceDriver extends AbstractOpcDeviceDriver implements D ReadUtil.write(itemMap, server); } + public void executing(Server server, Map itemMap) { + ReadUtil.write(itemMap, server); + } + + public void writing(String type,String value) { + String to_command1 = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command1; - public void writing(int type, int command) { String opcservcerid = this.getDevice().getOpc_server_id(); Server server = ReadUtil.getServer(opcservcerid); Map itemMap = new HashMap(); + itemMap.put(type, value); ReadUtil.write(itemMap, server); + } + public synchronized boolean finish_instruction() throws Exception { + instructionService.finish(inst); + return true; + } + + public synchronized boolean instruction_require() throws Exception { Date date = new Date(); if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { @@ -310,11 +348,10 @@ public class LnshOneRGVDeviceDriver extends AbstractOpcDeviceDriver implements D String start_point_code = task.getStart_point_code(); String start_device_code = task.getStart_device_code(); String route_plan_code = task.getRoute_plan_code(); - String next_device_code = ""; - + String next_point_code = task.getNext_point_code(); + String next_device_code = task.getNext_device_code(); Device startdevice = deviceAppservice.findDeviceByCode(start_device_code); Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); - String next_point_code; Instruction instdto = new Instruction(); instdto.setInstruction_id(IdUtil.simpleUUID()); @@ -331,7 +368,7 @@ public class LnshOneRGVDeviceDriver extends AbstractOpcDeviceDriver implements D instdto.setStart_device_code(start_device_code); instdto.setNext_device_code(next_device_code); instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_device_code); + instdto.setNext_point_code(next_point_code); instdto.setPriority(priority); instdto.setInstruction_status("0"); instdto.setExecute_device_code(start_point_code); @@ -344,14 +381,22 @@ public class LnshOneRGVDeviceDriver extends AbstractOpcDeviceDriver implements D //创建指令后修改任务状态 WQLObject taskwo = WQLObject.getWQLObject("acs_task"); - task.setTask_status("1"); //创建指令后修改任务状态 task.setTask_status("1"); taskserver.update(task); - requireSucess = false; + + String start_addr = startdevice.getAddress(); + String next_addr = nextdevice.getAddress(); + + writing("to_command1","1"); + writing("item_to_onset1",start_addr); + writing("item_to_target1",next_addr); + writing("item_to_task1",instdto.getInstruction_code()); + + } else { } diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index bfd2b25..dcd1da5 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -239,24 +239,11 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu } @Override - @Transactional(rollbackFor = Exception.class) public void create(Instruction dto) throws Exception { dto = foramte(dto); String task_code = dto.getTask_code(); TaskDto task = taskService.findByCodeFromCache(task_code); String excutetype = null; - //起点输送、终点货架 -- 入库 - if (StrUtil.equals(deviceAppService.findDeviceByCode(task.getStart_device_code()).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "conveyor") - && StrUtil.equals(deviceAppService.findDeviceByCode(task.getNext_device_code()).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "storage")) { - excutetype = TaskTypeEnum.IN.getName(); - //起点货架、终点输送 -- 出库 - } else if (StrUtil.equals(deviceAppService.findDeviceByCode(task.getStart_device_code()).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "storage") - && StrUtil.equals(deviceAppService.findDeviceByCode(task.getNext_device_code()).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "conveyor")) { - excutetype = TaskTypeEnum.OUT.getName(); - //起点输送、终点输送 -- 移动 - } else { - excutetype = TaskTypeEnum.MOVE.getName(); - } WQLObject instwo = WQLObject.getWQLObject("acs_instruction"); String currentUsername = SecurityUtils.getCurrentUsername(); @@ -311,115 +298,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu Device startdevice = appService.findDeviceByCode(dto.getStart_device_code()); Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code()); - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; - StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; - StandardCoveyorControlWithPlcScannerDeviceDriver standardCoveyorControlWithPlcScannerDeviceDriver; - StandardCoveyorControlDeviceDriver standardCoveyorControlDeviceDriver; - StandardStorageDeviceDriver standardStorageDeviceDriver; - //将指令赋予对象 下发指令号给电气 - if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); - standardInspectSiteDeviceDriver.setBranchProtocol(2); - standardInspectSiteDeviceDriver.setInst(dto); - standardInspectSiteDeviceDriver.setMessage("下发指令:dto.getInstruction_code(),执行中"); - standardInspectSiteDeviceDriver.writing(3, 1); - } - if (startdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { - standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) startdevice.getDeviceDriver(); - if (StrUtil.equals(excutetype, TaskTypeEnum.IN.getName())) { - if (standardCoveyorControlWithScannerDeviceDriver.getOperation_type() != 1) { - throw new RuntimeException("输送线非入库模式,无法下发"); - } - } - if (StrUtil.equals(excutetype, TaskTypeEnum.OUT.getName())) { - if (standardCoveyorControlWithScannerDeviceDriver.getOperation_type() != 2) { - throw new RuntimeException("输送线非出库模式,无法下发"); - } - } - standardCoveyorControlWithScannerDeviceDriver.setInst(dto); - if (!StrUtil.equals(nextdevice.getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "storage") && isInteger(nextdevice.getAddress())) { - standardCoveyorControlWithScannerDeviceDriver.writing(1, Integer.parseInt(nextdevice.getAddress()), Integer.parseInt(dto.getInstruction_code())); - } - } - if (startdevice.getDeviceDriver() instanceof StandardCoveyorControlWithPlcScannerDeviceDriver) { - standardCoveyorControlWithPlcScannerDeviceDriver = (StandardCoveyorControlWithPlcScannerDeviceDriver) startdevice.getDeviceDriver(); - if (StrUtil.equals(excutetype, TaskTypeEnum.IN.getName())) { - if (standardCoveyorControlWithPlcScannerDeviceDriver.getOperation_type() != 1) { - throw new RuntimeException("输送线非入库模式,无法下发"); - } - } - if (StrUtil.equals(excutetype, TaskTypeEnum.OUT.getName())) { - if (standardCoveyorControlWithPlcScannerDeviceDriver.getOperation_type() != 2) { - throw new RuntimeException("输送线非出库模式,无法下发"); - } - } - standardCoveyorControlWithPlcScannerDeviceDriver.setInst(dto); - if (!StrUtil.equals(nextdevice.getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "storage") && isInteger(nextdevice.getAddress())) { - standardCoveyorControlWithPlcScannerDeviceDriver.writing(1, Integer.parseInt(nextdevice.getAddress()), Integer.parseInt(dto.getInstruction_code())); - } - } - if (startdevice.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) startdevice.getDeviceDriver(); - if (StrUtil.equals(excutetype, TaskTypeEnum.IN.getName()) -// || StrUtil.equals(excutetype, TaskTypeEnum.MOVE.getName()) - ) { - if (standardCoveyorControlDeviceDriver.getOperation_type() != 1) { - throw new RuntimeException("输送线非入库模式,无法下发"); - } - } - if (StrUtil.equals(excutetype, TaskTypeEnum.OUT.getName())) { - if (standardCoveyorControlDeviceDriver.getOperation_type() != 2) { - throw new RuntimeException("输送线非出库模式,无法下发"); - } - } - standardCoveyorControlDeviceDriver.setInst(dto); - if (!StrUtil.equals(nextdevice.getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "storage") && isInteger(nextdevice.getAddress())) { - standardCoveyorControlDeviceDriver.writing(1, Integer.parseInt(nextdevice.getAddress()), Integer.parseInt(dto.getInstruction_code())); - } - } - - if (!ObjectUtils.isEmpty(nextdevice.getExtraValue().get("link_three_lamp"))) { - String lamd_device = nextdevice.getExtraValue().get("link_three_lamp").toString(); - Device lamddevice = appService.findDeviceByCode(lamd_device); - - if (lamddevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lamddevice.getDeviceDriver(); - lampThreecolorDeviceDriver.writing(2); - } - } - - if (nextdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { - standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) nextdevice.getDeviceDriver(); - if (StrUtil.equals(excutetype, TaskTypeEnum.IN.getName())) { - if (standardCoveyorControlWithScannerDeviceDriver.getOperation_type() != 1) { - throw new RuntimeException("输送线非入库模式,无法下发"); - } - } - if (StrUtil.equals(excutetype, TaskTypeEnum.OUT.getName())) { - if (standardCoveyorControlWithScannerDeviceDriver.getOperation_type() != 2) { - throw new RuntimeException("输送线非出库模式,无法下发"); - } - } - } - if (nextdevice.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) nextdevice.getDeviceDriver(); - if (StrUtil.equals(excutetype, TaskTypeEnum.IN.getName())) { - if (standardCoveyorControlDeviceDriver.getOperation_type() != 1) { - throw new RuntimeException("指令终点输送线非入库模式,无法下发"); - } - } - if (StrUtil.equals(excutetype, TaskTypeEnum.OUT.getName()) -// || StrUtil.equals(excutetype, TaskTypeEnum.MOVE.getName()) - ) { - if (standardCoveyorControlDeviceDriver.getOperation_type() != 2) { - throw new RuntimeException("指令终点输送线非出库模式,无法下发"); - } - } - - } - - try { // != 0 为agv任务 if (!StrUtil.equals(type, "0")) { diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java b/acs/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java index a9b5422..52c9844 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java @@ -57,6 +57,7 @@ public class AutoCreateInst { String vehicleType = acsTask.getVehicle_type(); //是否复合任务 =0非复合任务 String compound_task = acsTask.getCompound_task(); + String compound_task_data = null; String next_point_code = acsTask.getNext_point_code(); String next_device_code = acsTask.getNext_device_code(); if (StrUtil.isEmpty(start_device_code)) { @@ -83,21 +84,6 @@ public class AutoCreateInst { } } - //特殊任务 起点终点处理 -// if (StrUtil.equals("2", acsTask.getTask_type())) { -// next_device_code = acsTask.getNext_device_code(); -// if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { -// next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); -// } else { -// next_point_code = next_device_code; -// } -// if(taskserver.querySameTaskByType("2")>0){ -// acsTask.setRemark("该任务类型任务暂不允许生成指令"); -// log.debug("该任务类型任务暂不允许生成指令"); -// taskserver.updateByCodeFromCache(acsTask); -// continue; -// } -// } /** * 开始平均分解校验 @@ -110,14 +96,26 @@ public class AutoCreateInst { 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; + 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); } - next_device_code = pathlist.get(index); } else { next_device_code = this_device_code; } @@ -175,8 +173,6 @@ public class AutoCreateInst { acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); taskserver.updateByCodeFromCache(acsTask); log.info(LogMarkerTypeEnum.getMarker(LogMarkerTypeEnum.AUTO_CREATE_INST),"目标设备:{}设备未待机,任务号:{}",nextdevice.getDevice_code(),taskcode); - //this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); - //this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); continue; } @@ -186,43 +182,6 @@ public class AutoCreateInst { } } - //目的点校验 - if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMode() != 2) { - log.info("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); - acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); - taskserver.updateByCodeFromCache(acsTask); - log.info(LogMarkerTypeEnum.getMarker(LogMarkerTypeEnum.AUTO_CREATE_INST),"目标设备:{}设备未待机,任务号:{}",nextdevice.getDevice_code(),taskcode); - //this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); - //this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); - continue; - } - if (standardInspectSiteDeviceDriver.getMove() != 0) { - log.info("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); - acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); - taskserver.updateByCodeFromCache(acsTask); - log.info(LogMarkerTypeEnum.getMarker(LogMarkerTypeEnum.AUTO_CREATE_INST),"目标设备:{}设备不满足放货条件,任务号:{}",nextdevice.getDevice_code(),taskcode); - //this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); - //this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备不满足放货条件,任务号:" + taskcode); - continue; - } - } - - - if (nextdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver(); - if (standardOrdinarySiteDeviceDriver.getHasGoods() != 0) { - log.info("目标设备:" + nextdevice.getDevice_code() + "有货,无法生成任务,任务号:" + taskcode); - acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "有货,无法生成任务,任务号:" + taskcode); - taskserver.updateByCodeFromCache(acsTask); - log.info(LogMarkerTypeEnum.getMarker(LogMarkerTypeEnum.AUTO_CREATE_INST),"目标设备:{}有货,无法生成任务,任务号:{}",nextdevice.getDevice_code(),taskcode); - //this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); - //this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "有货,无法生成任务,任务号:" + taskcode); - continue; - } - } - //校验 是否同任务是否存在相同终点、未完成的指令 int sameqty = instructionService.querySameDestinationInst(next_point_code); if (sameqty > 0) { @@ -230,8 +189,6 @@ public class AutoCreateInst { acsTask.setRemark("存在相同终点的指令,任务号:" + taskcode); taskserver.updateByCodeFromCache(acsTask); log.info(LogMarkerTypeEnum.getMarker(LogMarkerTypeEnum.AUTO_CREATE_INST),"存在相同的指令,任务号:{}",taskcode); - //this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); - //this.execute_log.log("存在相同终点的指令,任务号:" + taskcode); continue; } } @@ -244,8 +201,6 @@ public class AutoCreateInst { acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "设备未待机"); taskserver.updateByCodeFromCache(acsTask); log.info(LogMarkerTypeEnum.getMarker(LogMarkerTypeEnum.AUTO_CREATE_INST),"目标设备:{}设备未待机,任务号:{}",nextdevice.getDevice_code(),taskcode); - //this.execute_log.setResource(nextdevice.getDevice_code(), nextdevice.getDevice_code()); - //this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "设备未待机,任务号:" + taskcode); continue; } int max_emptypalletnum = Integer.parseInt(nextdevice.getExtraValue().get("max_emptypalletnum").toString()); @@ -255,7 +210,6 @@ public class AutoCreateInst { acsTask.setRemark("目标设备:" + nextdevice.getDevice_code() + "空盘位已满等待入库,任务号:" + taskcode); taskserver.updateByCodeFromCache(acsTask); log.info(LogMarkerTypeEnum.getMarker(LogMarkerTypeEnum.AUTO_CREATE_INST),"目标设备:{}空盘位已满等待入库,任务号:{}",nextdevice.getDevice_code(),taskcode); - //this.execute_log.log("目标设备:" + nextdevice.getDevice_code() + "空盘位已满等待入库,任务号:" + taskcode); continue; } // 查看是否有相同终点的指令 @@ -316,6 +270,7 @@ public class AutoCreateInst { instdto.setNext_device_code(next_device_code); instdto.setStart_point_code(start_point_code); instdto.setNext_point_code(next_point_code); + instdto.setCompound_inst_data(compound_task_data); instdto.setPriority(priority); instdto.setInstruction_status("0"); instdto.setExecute_device_code(start_point_code);