diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java index 40008724b..ef881798a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java @@ -104,7 +104,8 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i int hasGoods = 0; String message = null; Boolean iserror = false; - + private Date instruction_update_time = new Date(); + private int instruction_update_time_out = 1000; Integer heartbeat_tag; private Date instruction_require_time = new Date(); @@ -213,274 +214,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); } - //更改任务状态 - if (task > 0) { - //inst_message - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst1 != null) { - if (StrUtil.equals(inst1.getInstruction_status(), "0")) { - inst1.setInstruction_status("1"); - inst1.setExecute_device_code(this.device_code); - instructionService.update(inst1); - } - } - } + update_instruction_status(); - //申请取货 - if (mode == 3 && action == 1 && move == 0 && task > 0) { - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); - if (ObjectUtil.isNotEmpty(inst2)) { - String start_device_code = inst2.getStart_device_code(); - Device device = deviceAppService.findDeviceByCode(start_device_code); - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); - //hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); - int mode = hongXiangConveyorDeviceDriver.getMode(); - int door = hongXiangConveyorDeviceDriver.getDoor(); - int action = hongXiangConveyorDeviceDriver.getAction(); - int error1 = hongXiangConveyorDeviceDriver.getError1(); - int move = hongXiangConveyorDeviceDriver.getMove(); - if (mode == 1 && door == 1 && action == 1 && error1 == 0 && move == 1) { - if (this.getNow_steps_type() == 2) { - this.writing("to_command", "2"); - this.setNow_steps_type(3); - } else { - //logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为下发电气信号(now_steps_type!=2)"); - } - } else { - if (this.getNow_steps_type() == 2) { - feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code(); - if (mode != 1) { - feedMessage = feedMessage + "工作模式(mode)信号未联机,"; - } - if (door != 1) { - feedMessage = feedMessage + "门状态(door)信号未开门,"; - } - if (action != 1) { - feedMessage = feedMessage + "允许取放(action)信号未允许取放,"; - } - if (move != 1) { - feedMessage = feedMessage + "取货位光电信号(move)不应该为无货状态,"; - } - if (error1 != 0) { - feedMessage = feedMessage + "故障(error1)信号出现故障,故障值:" + error1 + "。"; - } - } - } - } else { - if (this.getNow_steps_type() == 2) { - this.writing("to_command", "2"); - this.setNow_steps_type(3); - } else { - //logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为下发电气信号(now_steps_type!=2)\")"); - } - } - } - } else { - if (this.getNow_steps_type() == 2) { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; - } - if (action != 1) { - feedMessage = feedMessage + "动作信号(action)不为取货中状态,"; - } - if (move != 0) { - feedMessage = feedMessage + "光电信号(move)不为无货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; - } - } - } - //取货完成关闭烘箱门 - if (mode == 3 && action == 2 && move == 1 && task > 0) { - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); - if (ObjectUtil.isNotEmpty(inst2)) { - String start_device_code = inst2.getStart_device_code(); - Device device = deviceAppService.findDeviceByCode(start_device_code); - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); - } - if (this.getNow_steps_type() == 3) { - this.writing("to_command", "3"); - this.setNow_steps_type(4); - } else { - //logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许取货(now_steps_type!=3)"); - } - } - } else { - if (this.getNow_steps_type() == 3) { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; - } - if (action != 2) { - feedMessage = feedMessage + "动作信号(action)不为取货完成状态,"; - } - if (move != 1) { - feedMessage = feedMessage + "光电信号(move)不为有货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; - } - } - } - - //申请放货 - if (mode == 3 && action == 3 && move == 1 && task > 0) { - Instruction instructionDto = instructionService.findByCodeFromCache(String.valueOf(task)); - String next_device_code = instructionDto.getNext_device_code(); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - PhotoelectricInspectionSiteDeviceDriver photoelectricInspectionSiteDeviceDriver; - if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); - //hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); - int mode = hongXiangConveyorDeviceDriver.getMode(); - int door = hongXiangConveyorDeviceDriver.getDoor(); - int action = hongXiangConveyorDeviceDriver.getAction(); - int error1 = hongXiangConveyorDeviceDriver.getError1(); - int move = hongXiangConveyorDeviceDriver.getMove(); - if (mode == 1 && door == 1 && action == 1 && error1 == 0 && move == 0) { - if (this.getNow_steps_type() == 4) { - this.writing("to_command", "4"); - this.setNow_steps_type(5); - } else { - feedMessage = "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)"; - //logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)"); - } - } else { - if (this.getNow_steps_type() == 4) { - feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code(); - if (mode != 1) { - feedMessage = feedMessage + "工作模式(mode)信号未联机,"; - } - if (door != 1) { - feedMessage = feedMessage + "门状态(door)信号未开门,"; - } - if (action != 1) { - feedMessage = feedMessage + "允许取放(action)信号未允许取放,"; - } - if (move != 0) { - feedMessage = feedMessage + "放货位光电信号不应该为有货状态"; - } - if (error1 != 0) { - feedMessage = feedMessage + "故障(error1)信号出现故障。"; - } - } - } - } else { - if (this.getNow_steps_type() == 4) { - this.writing("to_command", "4"); - this.setNow_steps_type(5); - } else { - //logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)"); - } - - } - } else { - if (this.getNow_steps_type() == 4) { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; - } - if (action != 3) { - feedMessage = feedMessage + "动作信号(action)不为放货中状态,"; - } - if (move != 1) { - feedMessage = feedMessage + "光电信号(move)不为有货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; - } - } - } - - //放货完成 - if (mode == 3 && action == 4 && move == 0 && task > 0) { - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst2 != null) { - if (StrUtil.equals(inst2.getInstruction_status(), "1")) { - - TaskDto taskDto = taskserver.findByCode(inst2.getTask_code()); - - String next_device_code = inst2.getNext_device_code(); - //String start_device_code = taskDto.getStart_device_code(); - //Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; -// if (startDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { -// hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startDevice.getDeviceDriver(); -// hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); -// } - if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); - if (StrUtil.isNotEmpty(taskDto.getOven_time())) { - //下发烘箱时间 - int time = Integer.parseInt(taskDto.getOven_time()); - int hours = (time % (60 * 60 * 24)) / (60 * 60); - int minutes = (time % (60 * 60)) / 60; - hongXiangConveyorDeviceDriver.writing("to_time_house", String.valueOf(hours)); - hongXiangConveyorDeviceDriver.writing("to_time_min", String.valueOf(minutes)); - } - } - - if (nextDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextDevice.getDeviceDriver(); -// hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); - - if (!StrUtil.startWith(taskDto.getTask_code(), "-")) { - if (ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("link_three_lamp"))) { - String lamp = nextDevice.getExtraValue().get("link_three_lamp").toString(); - Device lampDevice = deviceAppService.findDeviceByCode(lamp); - if (ObjectUtil.isEmpty(lampDevice)) { - return; - } - if (lampDevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lampDevice.getDeviceDriver(); - logServer.deviceExecuteLog(lampDevice.getDeviceDriver().getDeviceCode(), "", "", "下发报警灯" + lamp + "报警信号"); - lampThreecolorDeviceDriver.writing("to_command", "1"); - } - } - } - - } - this.writing("to_command", "5"); - this.setNow_steps_type(6); - this.setNow_steps_type(0); - try { - finish_instruction(inst2); - } catch (Exception e) { - e.printStackTrace(); - } - feedMessage = ""; - } - } - } else { - if (this.getNow_steps_type() == 5) { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; - } - if (action != 4) { - feedMessage = feedMessage + "动作信号(action)不为放货完成状态,"; - } - if (move != 0) { - feedMessage = feedMessage + "光电信号(move)不为无货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; - } - } - } } catch (Exception var17) { var17.printStackTrace(); @@ -1036,4 +772,282 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i // // } + public synchronized void update_instruction_status() throws Exception { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + //更改任务状态 + if (task > 0) { + //inst_message + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task)); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + inst1.setInstruction_status("1"); + inst1.setExecute_device_code(this.device_code); + instructionService.update(inst1); + } + } + } + + //申请取货 + if (mode == 3 && action == 1 && move == 0 && task > 0) { + Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); + if (ObjectUtil.isNotEmpty(inst2)) { + String start_device_code = inst2.getStart_device_code(); + Device device = deviceAppService.findDeviceByCode(start_device_code); + HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; + if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); + //hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); + int mode = hongXiangConveyorDeviceDriver.getMode(); + int door = hongXiangConveyorDeviceDriver.getDoor(); + int action = hongXiangConveyorDeviceDriver.getAction(); + int error1 = hongXiangConveyorDeviceDriver.getError1(); + int move = hongXiangConveyorDeviceDriver.getMove(); + if (mode == 1 && door == 1 && action == 1 && error1 == 0 && move == 1) { + if (this.getNow_steps_type() == 2) { + this.writing("to_command", "2"); + this.setNow_steps_type(3); + } else { + //logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为下发电气信号(now_steps_type!=2)"); + } + } else { + if (this.getNow_steps_type() == 2) { + feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code(); + if (mode != 1) { + feedMessage = feedMessage + "工作模式(mode)信号未联机,"; + } + if (door != 1) { + feedMessage = feedMessage + "门状态(door)信号未开门,"; + } + if (action != 1) { + feedMessage = feedMessage + "允许取放(action)信号未允许取放,"; + } + if (move != 1) { + feedMessage = feedMessage + "取货位光电信号(move)不应该为无货状态,"; + } + if (error1 != 0) { + feedMessage = feedMessage + "故障(error1)信号出现故障,故障值:" + error1 + "。"; + } + } + } + } else { + if (this.getNow_steps_type() == 2) { + this.writing("to_command", "2"); + this.setNow_steps_type(3); + } else { + //logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为下发电气信号(now_steps_type!=2)\")"); + } + } + } + } else { + if (this.getNow_steps_type() == 2) { + feedMessage = "行架机械手:"; + if (mode != 3) { + feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + } + if (action != 1) { + feedMessage = feedMessage + "动作信号(action)不为取货中状态,"; + } + if (move != 0) { + feedMessage = feedMessage + "光电信号(move)不为无货状态,"; + } + if (task == 0) { + feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + } + } + } + + //取货完成关闭烘箱门 + if (mode == 3 && action == 2 && move == 1 && task > 0) { + Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); + if (ObjectUtil.isNotEmpty(inst2)) { + String start_device_code = inst2.getStart_device_code(); + Device device = deviceAppService.findDeviceByCode(start_device_code); + HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; + if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); + hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); + } + if (this.getNow_steps_type() == 3) { + this.writing("to_command", "3"); + this.setNow_steps_type(4); + } else { + //logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许取货(now_steps_type!=3)"); + } + } + } else { + if (this.getNow_steps_type() == 3) { + feedMessage = "行架机械手:"; + if (mode != 3) { + feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + } + if (action != 2) { + feedMessage = feedMessage + "动作信号(action)不为取货完成状态,"; + } + if (move != 1) { + feedMessage = feedMessage + "光电信号(move)不为有货状态,"; + } + if (task == 0) { + feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + } + } + } + + //申请放货 + if (mode == 3 && action == 3 && move == 1 && task > 0) { + Instruction instructionDto = instructionService.findByCodeFromCache(String.valueOf(task)); + String next_device_code = instructionDto.getNext_device_code(); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; + PhotoelectricInspectionSiteDeviceDriver photoelectricInspectionSiteDeviceDriver; + if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); + //hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); + int mode = hongXiangConveyorDeviceDriver.getMode(); + int door = hongXiangConveyorDeviceDriver.getDoor(); + int action = hongXiangConveyorDeviceDriver.getAction(); + int error1 = hongXiangConveyorDeviceDriver.getError1(); + int move = hongXiangConveyorDeviceDriver.getMove(); + if (mode == 1 && door == 1 && action == 1 && error1 == 0 && move == 0) { + if (this.getNow_steps_type() == 4) { + this.writing("to_command", "4"); + this.setNow_steps_type(5); + } else { + feedMessage = "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)"; + //logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)"); + } + } else { + if (this.getNow_steps_type() == 4) { + feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code(); + if (mode != 1) { + feedMessage = feedMessage + "工作模式(mode)信号未联机,"; + } + if (door != 1) { + feedMessage = feedMessage + "门状态(door)信号未开门,"; + } + if (action != 1) { + feedMessage = feedMessage + "允许取放(action)信号未允许取放,"; + } + if (move != 0) { + feedMessage = feedMessage + "放货位光电信号不应该为有货状态"; + } + if (error1 != 0) { + feedMessage = feedMessage + "故障(error1)信号出现故障。"; + } + } + } + } else { + if (this.getNow_steps_type() == 4) { + this.writing("to_command", "4"); + this.setNow_steps_type(5); + } else { + //logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)"); + } + + } + } else { + if (this.getNow_steps_type() == 4) { + feedMessage = "行架机械手:"; + if (mode != 3) { + feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + } + if (action != 3) { + feedMessage = feedMessage + "动作信号(action)不为放货中状态,"; + } + if (move != 1) { + feedMessage = feedMessage + "光电信号(move)不为有货状态,"; + } + if (task == 0) { + feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + } + } + } + + //放货完成 + if (mode == 3 && action == 4 && move == 0 && task > 0) { + Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); + if (inst2 != null) { + if (StrUtil.equals(inst2.getInstruction_status(), "1")) { + + TaskDto taskDto = taskserver.findByCode(inst2.getTask_code()); + + String next_device_code = inst2.getNext_device_code(); + //String start_device_code = taskDto.getStart_device_code(); + //Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; + StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; + LampThreecolorDeviceDriver lampThreecolorDeviceDriver; +// if (startDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { +// hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startDevice.getDeviceDriver(); +// hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); +// } + if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); + hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); + if (StrUtil.isNotEmpty(taskDto.getOven_time())) { + //下发烘箱时间 + int time = Integer.parseInt(taskDto.getOven_time()); + int hours = (time % (60 * 60 * 24)) / (60 * 60); + int minutes = (time % (60 * 60)) / 60; + hongXiangConveyorDeviceDriver.writing("to_time_house", String.valueOf(hours)); + hongXiangConveyorDeviceDriver.writing("to_time_min", String.valueOf(minutes)); + } + } + + if (nextDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextDevice.getDeviceDriver(); +// hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); + + if (!StrUtil.startWith(taskDto.getTask_code(), "-")) { + if (ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("link_three_lamp"))) { + String lamp = nextDevice.getExtraValue().get("link_three_lamp").toString(); + Device lampDevice = deviceAppService.findDeviceByCode(lamp); + if (ObjectUtil.isEmpty(lampDevice)) { + return; + } + if (lampDevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { + lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lampDevice.getDeviceDriver(); + logServer.deviceExecuteLog(lampDevice.getDeviceDriver().getDeviceCode(), "", "", "下发报警灯" + lamp + "报警信号"); + lampThreecolorDeviceDriver.writing("to_command", "1"); + } + } + } + + } + this.writing("to_command", "5"); + this.setNow_steps_type(6); + this.setNow_steps_type(0); + try { + finish_instruction(inst2); + } catch (Exception e) { + e.printStackTrace(); + } + feedMessage = ""; + } + } + } else { + if (this.getNow_steps_type() == 5) { + feedMessage = "行架机械手:"; + if (mode != 3) { + feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + } + if (action != 4) { + feedMessage = feedMessage + "动作信号(action)不为放货完成状态,"; + } + if (move != 0) { + feedMessage = feedMessage + "光电信号(move)不为无货状态,"; + } + if (task == 0) { + feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + } + } + } + } + } + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java index c7d71642b..decaec13d 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java @@ -131,6 +131,9 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme String hand_barcode = null; Integer heartbeat_tag; + private Date instruction_update_time = new Date(); + private int instruction_update_time_out = 500; + private Date instruction_require_time = new Date(); private Date require_apply_labeling_time = new Date(); private Date require_apply_strangulation_time = new Date(); @@ -268,33 +271,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme if (move != 0 && task > 0) { // logServer.deviceExecuteLog(device_code, "", "", "输送线任务开始反馈任务状态,指令号:" + task); //inst_message - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst != null) { - inst_message = "当前指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); - vehicle_code = inst.getVehicle_code(); - task_code = inst.getTask_code(); - if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status("1"); - inst.setExecute_device_code(this.device_code); - instructionService.update(inst); - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task + ",载具号:"+ inst.getVehicle_code()); - } - if (StrUtil.equals(inst.getInstruction_status(), "1")) { - if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - vehicle_code = inst.getVehicle_code(); - inst.setExecute_device_code(this.device_code); - finish_instruction(); - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task + ",载具号:"+ inst.getVehicle_code()); - } else { - - - } - - } - } else { -// message = "输送线任务反馈状态,查询不到指令号:" + task +"指令已完成"; - inst_message = null; - } + update_instruction_status(); } } catch (Exception var17) { @@ -648,7 +625,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme map3.put("value", "1"); list.add(map3); this.writing(list); - + requireSucess = true; while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , inst.getInstruction_code())) { this.writing(list); @@ -659,6 +636,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme e.printStackTrace(); } if(ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))){ + requireSucess = false; return false; } } @@ -770,6 +748,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme map3.put("value", "1"); list.add(map3); this.writing(list); + requireSucess = true; while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , instdto.getInstruction_code())) { this.writing(list); @@ -780,6 +759,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme e.printStackTrace(); } if(ObjectUtil.isEmpty(taskserver.findByCode(taskdto.getTask_code()))){ + requireSucess = false; return false; } } @@ -818,6 +798,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme map3.put("value", "1"); list.add(map3); this.writing(list); + requireSucess = true; while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , inst.getInstruction_code())) { this.writing(list); @@ -828,6 +809,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme e.printStackTrace(); } if(ObjectUtil.isEmpty(instructionService.findByDeviceCodeFromCache(this.device_code))){ + requireSucess = false; return false; } } @@ -1110,4 +1092,42 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme } } + /** + * 更新指令状态 + */ + public synchronized void update_instruction_status() throws Exception { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + if (inst != null) { + inst_message = "当前指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); + vehicle_code = inst.getVehicle_code(); + task_code = inst.getTask_code(); + if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { + inst.setInstruction_status("1"); + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task + ",载具号:"+ inst.getVehicle_code()); + } + if (StrUtil.equals(inst.getInstruction_status(), "1")) { + if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { + vehicle_code = inst.getVehicle_code(); + inst.setExecute_device_code(this.device_code); + finish_instruction(); + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task + ",载具号:"+ inst.getVehicle_code()); + } else { + + } + } + } else { +// message = "输送线任务反馈状态,查询不到指令号:" + task +"指令已完成"; + inst_message = null; + } + + } + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java index a86490157..fd8675851 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java @@ -106,6 +106,9 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl String hand_barcode = null; String barcode = null; + private Date instruction_update_time = new Date(); + private int instruction_update_time_out = 500; + Integer heartbeat_tag; private Date instruction_require_time = new Date(); private Date require_apply_labeling_time = new Date(); @@ -222,30 +225,10 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl if (move != 0 && task > 0) { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst != null) { - inst_message = "当前指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); - vehicle_code = inst.getVehicle_code(); - task_code = inst.getTask_code(); - if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status("1"); - inst.setExecute_device_code(this.device_code); - instructionService.update(inst); - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task + ",载具号:"+ inst.getVehicle_code()); - } - if (StrUtil.equals(inst.getInstruction_status(), "1")) { - if (!StrUtil.equals(inst.getExecute_code(), this.device_code)) { - inst.setExecute_device_code(this.device_code); - instructionService.update(inst); - } - } - } else { -// logServer.deviceExecuteLog(device_code, "", "", "输送线任务开始反馈任务状态,反馈失败,查询不到指令号:" + task); -// message = "输送线任务反馈状态,查询不到指令号:" + task +"指令已完成"; - inst_message = null; - } + update_instruction_status(); } + } catch (Exception var17) { var17.printStackTrace(); inst_message = var17.getMessage(); @@ -522,6 +505,39 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl } + /** + * 更新指令状态 + */ + public synchronized void update_instruction_status() throws Exception { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + if (inst != null) { + inst_message = "当前指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); + vehicle_code = inst.getVehicle_code(); + task_code = inst.getTask_code(); + if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { + inst.setInstruction_status("1"); + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task); + } + if (StrUtil.equals(inst.getInstruction_status(), "1")) { + if (!StrUtil.equals(inst.getExecute_code(), this.device_code)) { + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + } + } + } else { + inst_message = null; + } + } + } + /** * 请求指令 @@ -585,16 +601,6 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl map3.put("value", "1"); list.add(map3); this.writing(list); - while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , inst.getInstruction_code())) { - this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号"); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } return true; } try { @@ -621,7 +627,7 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl } catch (Exception e) { e.printStackTrace(); } - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task + ",载具号:"+ inst.getVehicle_code()); + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task); } } } else { @@ -658,34 +664,18 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl list.add(map); Map map2 = new HashMap(); map2.put("code", "to_task"); - map2.put("value", "0"); + map2.put("value", inst.getInstruction_code()); list.add(map2); Map map3 = new HashMap(); map3.put("code", "to_command"); map3.put("value", "1"); list.add(map3); - Map map4 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", inst.getInstruction_code()); - list.add(map4); this.writing(list); -// if (task != Integer.parseInt(inst.getInstruction_code())) { -// this.writing(list); -// message = "重新下发电气信号"; -// logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); -// } - - while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , inst.getInstruction_code())) { + if (task != Integer.parseInt(inst.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号"); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } + message = "重新下发电气信号"; + logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); } - message = "下发电气任务号成功"; requireSucess = true; return true; @@ -781,31 +771,17 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl list.add(map); Map map2 = new HashMap(); map2.put("code", "to_task"); - map2.put("value", "0"); + map2.put("value", instdto.getInstruction_code()); list.add(map2); Map map3 = new HashMap(); map3.put("code", "to_command"); map3.put("value", "1"); list.add(map3); - Map map4 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", inst.getInstruction_code()); - list.add(map4); this.writing(list); -// if (task != Integer.parseInt(inst.getInstruction_code())) { -// this.writing(list); -// message = "重新下发电气信号"; -// logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); -// } - while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , inst.getInstruction_code())) { + if (task != Integer.parseInt(inst.getInstruction_code())) { this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号"); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } + message = "重新下发电气信号"; + logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); } } else { //如果不存在则直接找对应指令 @@ -831,10 +807,8 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl map3.put("value", "1"); list.add(map3); this.writing(list); -// if (task != Integer.parseInt(inst.getInstruction_code())) { -// this.writing(list); -// logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); -// } + // while true + requireSucess = true; while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , inst.getInstruction_code())) { this.writing(list); @@ -844,8 +818,15 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl } catch (InterruptedException e) { e.printStackTrace(); } + if(ObjectUtil.isEmpty(inst.getInstruction_code())){ + requireSucess = false; + return false; + } } + + message = "下发电气任务号成功"; requireSucess = true; + } return true; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_labeling/SiemensConveyorLabelingDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_labeling/SiemensConveyorLabelingDeviceDriver.java index 2b9e5897f..400413818 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_labeling/SiemensConveyorLabelingDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor_labeling/SiemensConveyorLabelingDeviceDriver.java @@ -110,7 +110,8 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver int hasGoods = 0; String message = null; Boolean iserror = false; - + private Date instruction_update_time = new Date(); + private int instruction_update_time_out = 500; Integer heartbeat_tag; private Date instruction_require_time = new Date(); private Date require_apply_labeling_time = new Date(); @@ -129,6 +130,7 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver private String error_type = "ssx_error_type"; int branchProtocol = 0; String inst_message; + String task_code = null; // 当前指令 @@ -205,36 +207,7 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver } if (mode == 2 && move != 0 && task > 0) { - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈任务状态,指令号:" + task); - // inst_message - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst != null) { - inst_message = - "指令号:" - + inst.getInstruction_code() - + " " - + inst.getStart_point_code() - + "->" - + inst.getNext_point_code() - + " 载具号:" - + inst.getVehicle_code(); - if (StrUtil.equals(inst.getInstruction_status(), "1") - && StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - vehicle_code = inst.getVehicle_code(); - finish_instruction(); - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task); - } else if (StrUtil.equals(inst.getInstruction_status(), "0") - && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status("1"); - instructionService.update(inst); - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task); - } else { - logServer.deviceExecuteLog( - device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈失败任务状态不为就绪或者执行中状态,指令号:" + task); - } - } else { -// logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈任务状态,反馈失败,查询不到指令号:" + task); - } + update_instruction_status(); } } catch (Exception var17) { @@ -965,4 +938,43 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver } } } + + /** + * 更新指令状态 + */ + public synchronized void update_instruction_status() throws Exception { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + if (inst != null) { + inst_message = "当前指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); + vehicle_code = inst.getVehicle_code(); + task_code = inst.getTask_code(); + if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { + inst.setInstruction_status("1"); + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task + ",载具号:"+ inst.getVehicle_code()); + } + if (StrUtil.equals(inst.getInstruction_status(), "1")) { + if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { + vehicle_code = inst.getVehicle_code(); + inst.setExecute_device_code(this.device_code); + finish_instruction(); + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task + ",载具号:"+ inst.getVehicle_code()); + } else { + + } + } + } else { +// message = "输送线任务反馈状态,查询不到指令号:" + task +"指令已完成"; + inst_message = null; + } + + } + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java index 4bfaf5f26..32fd2cdf5 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java @@ -69,7 +69,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl private String error_type = "fqhj_error_type"; Instruction cache_inst = null; String inst_type = null; - + private Date instruction_update_time = new Date(); + private int instruction_update_time_out = 500; //工作模式 int mode = 0; int last_mode = 0; @@ -159,6 +160,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl private Date instruction_write_time = new Date(); + private int apply_task_time_out = 1000; + private Date apply_task_time = new Date(); + String notCreateTaskMessage = ""; String notCreateInstMessage = ""; @@ -287,416 +291,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl logServer.deviceExecuteLog(this.device_code, "", "", "信号task2:" + last_task2 + "->" + task2); } - //单任务 前工位任务更新指令状态 - if (task1 > 0 && type == 1) { - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); - if (inst1 != null) { - if (StrUtil.equals(inst1.getInstruction_status(), "0")) { - //当前执行步骤为更新任务状态 - inst1.setInstruction_status("1"); - inst1.setExecute_device_code(this.getDevice_code()); - instructionService.update(inst1); - } - } - } - - //单任务 后工位任务更新指令状态 - if (task2 > 0 && type == 2) { - //inst_message - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); - if (inst2 != null) { - if (StrUtil.equals(inst2.getInstruction_status(), "0")) { - //当前指令更新状态 - now_steps_type2 = 1; - inst2.setInstruction_status("1"); - inst2.setExecute_device_code(this.device_code); - instructionService.update(inst2); - } - } - } - - //双任务更新指令状态 - if (task2 > 0 && task1 > 0 && type == 3) { - //inst_message - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task1)); - if (inst2 != null) { - if (StrUtil.equals(inst2.getInstruction_status(), "0")) { - //当前指令更新状态 - inst2.setInstruction_status("1"); - inst2.setExecute_device_code(this.device_code); - instructionService.update(inst2); - } - } - } - - //双任务/单任务 后工位取空时判断动作信号,并反馈 - if (mode == 3 && action2 == 1 && move2 == 0 && task2 > 0) { - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task2)); - String start_device_code = inst1.getStart_device_code(); - Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); - if (ObjectUtil.isEmpty(startDevice)) { - feedMessage = "后工位取货位:" + start_device_code + "为空!"; - logServer.deviceExecuteLog(this.getDeviceCode(), "", "", "后工位取货位:" + start_device_code + "为空!"); - throw new BadRequestException("后工位取货位:" + start_device_code + "为空!"); - } - SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; - if (startDevice.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) startDevice.getDeviceDriver(); - int move = siemensConveyorDeviceDriver.getMove(); - int mode = siemensConveyorDeviceDriver.getMode(); - if (mode == 2 && move == 1) { - if (to_command2 != 2) { - this.writing("to_command2", "2"); - } - if (type == 2) { - this.setNow_steps_type2(3); - } else if (type == 3) { - this.setNow_steps_type3(3); - } - } else { - log.warn("后工位取货位无货,取货位:{},mode:{},move:{}", start_device_code, mode, move); - if (this.getNow_steps_type2() == 2 || this.getNow_steps_type3() == 2) { - feedMessage = "后工位未取货原因-->取货位:" + siemensConveyorDeviceDriver.getDevice_code(); - if (mode != 2) { - feedMessage += "工作模式不为待机(mode != 2),"; - } - if (move != 1) { - feedMessage += "光电信号不应该为无货状态(move != 1)"; - } - } - } - } - } else { - if (this.getNow_steps_type2() == 2 || this.getNow_steps_type3() == 2) { - feedMessage = "后工位未取货原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action2 != 1) { - feedMessage += "后工位动作信号不为取货中(action2 != 1),"; - } - if (move2 != 0) { - feedMessage += "后工位光电信号应该为0(move2 != 0),"; - } - if (task2 == 0) { - feedMessage += "后工位没有任务号(task2 == 0)"; - } - } - } - - //单任务/或双任务 后工位收到取货完成信号并反馈 - if (mode == 3 && action2 == 2 && move2 == 1 && task2 > 0) { - if (to_command2 != 3) { - this.writing("to_command2", "3"); - } - if (type == 2) { - this.setNow_steps_type2(4); - } - if (type == 3) { - this.setNow_steps_type3(4); - } - } else { - if (this.getNow_steps_type2() == 3 || this.getNow_steps_type3() == 3) { - feedMessage = "后工位取货完成后未反馈原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action2 != 2) { - feedMessage += "后工位动作信号未取货完成(action2 != 2),"; - } - if (move2 == 0) { - feedMessage += "后工位光电信号不应该为0(move2 == 0),"; - } - if (task2 == 0) { - feedMessage += "后工位没有任务号(task2 == 0)"; - } - } - } - - //单任务/双任务 前工位取货时判断动作信号并反馈 - if (mode == 3 && action1 == 1 && move1 == 0 && task1 > 0) { - if (to_command1 != 2) { - this.writing("to_command1", "2"); - } - if (type == 1) { - this.setNow_steps_type1(3); - } else if (type == 3) { - this.setNow_steps_type3(5); - } - } else { - if (this.getNow_steps_type1() == 2 || this.getNow_steps_type3() == 4) { - feedMessage = "前工位未取货原因:"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action1 != 1) { - feedMessage += "前工位动作信号不为取货中(action2 != 1),"; - } - if (move1 != 0) { - feedMessage += "前工位光电信号应该为0(move2 != 0),"; - } - if (task1 == 0) { - feedMessage += "前工位没有任务号(task2 == 0)"; - } - } - } - - //单任务/双任务 前工位取货完成并反馈 - if (mode == 3 && action1 == 2 && move1 == 1 && task1 > 0) { - if (to_command1 != 3) { - this.writing("to_command1", "3"); - } - if (type == 1) { - this.setNow_steps_type1(4); - } - if (type == 3) { - this.setNow_steps_type3(6); - } - } else { - if (this.getNow_steps_type1() == 3 || this.getNow_steps_type3() == 5) { - feedMessage = "前工位取货完成后未反馈原因"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action1 != 2) { - feedMessage += "前工位动作信号未取货完成(action2 != 2),"; - } - if (move1 == 0) { - feedMessage += "前工位光电信号不应该为无货状态(move2 == 0),"; - } - if (task1 == 0) { - feedMessage += "前工位没有任务号(task2 == 0)"; - } - } - } - - - //单任务/双任务 后工位放货时判断信号并反馈 - if (mode == 3 && action2 == 3 && move2 == 1 && task2 > 0) { - if (to_command2 != 4) { - this.writing("to_command2", "4"); - } - if (type == 2) { - this.setNow_steps_type2(5); - } else if (type == 3) { - this.setNow_steps_type3(7); - } - } else { - if (this.getNow_steps_type2() == 4 || this.getNow_steps_type3() == 6) { - feedMessage = "后工位未放货原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action2 != 3) { - feedMessage += "后工位动作信号不为放货中(action2 != 3),"; - } - if (move2 == 0) { - feedMessage += "后工位光电信号为不应该为0(move2 == 0),"; - } - if (task2 == 0) { - feedMessage += "后工位没有任务号(task2 == 0)"; - } - } - } - - //单任务 后工位放货完成 任务完成 - if (mode == 3 && action2 == 4 && move2 == 0 && task2 > 0 && type == 2) { - //inst_message - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); - if (inst2 != null) { - if (StrUtil.equals(inst2.getInstruction_status(), "1")) { - if (to_command2 != 5) { - this.writing("to_command2", "5"); - } - this.setNow_steps_type2(6); - this.setNow_steps_type2(0); - finish_instruction(inst2); - } - } - } else { - if (this.getNow_steps_type2() == 5) { - feedMessage = "单任务后工位放货完成后未反馈原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action2 != 4) { - feedMessage += "后工位动作信号未放货完成(action2 != 4),"; - } - if (move2 != 0) { - feedMessage += "后工位光电信号应该为无货状态(move2 != 0),"; - } - if (task2 == 0) { - feedMessage += "后工位没有任务号(task2 == 0),"; - } - if (type != 2) { - feedMessage += "不是后工位单任务(type != 2)"; - } - } - } - - //双任务 后工位反馈任务完成 并反馈 - if (mode == 3 && action2 == 4 && move2 == 0 && task1 > 0 && task2 > 0 && type == 3) { - if (to_command2 != 5) { - this.writing("to_command2", "5"); - } - this.setNow_steps_type3(8); - } else { - if (this.getNow_steps_type3() == 7) { - feedMessage = "双任务后工位放货完成后未反馈原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action2 != 4) { - feedMessage += "后工位动作信号未放货完成(action2 != 4),"; - } - if (move2 != 0) { - feedMessage += "后工位光电信号不应该为有货状态(move2 != 0),"; - } - if (task1 == 0) { - feedMessage += "前工位没有任务号(task1 == 0),"; - } - if (task2 == 0) { - feedMessage += "后工位没有任务号(task2 == 0),"; - } - if (type != 3) { - feedMessage += "不是双任务(type != 3)"; - } - } - } - - //单任务/双任务 前工位放货时判断放货位光电信号 - if (mode == 3 && action1 == 3 && move1 == 1 && task1 > 0) { - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); - String next_device_code = ""; - if (type == 1) { - next_device_code = inst1.getNext_device_code(); - } else if (type == 3) { - next_device_code = inst1.getNext_device_code2(); - } - Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); - if (ObjectUtil.isEmpty(nextDevice)) { - feedMessage = "前工位放货位:" + next_device_code + "为空!"; - throw new BadRequestException("前工位放货位:" + next_device_code + "为空!"); - } - SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; - if (nextDevice.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) nextDevice.getDeviceDriver(); - int move = siemensConveyorDeviceDriver.getMove(); - int mode = siemensConveyorDeviceDriver.getMode(); - if (move == 1 && mode == 2) { - if (to_command1 != 4) { - this.writing("to_command1", "4"); - } - if (type == 1) { - this.setNow_steps_type1(5); - } else if (type == 3) { - this.setNow_steps_type3(9); - } - } else { -// log.warn("后工位放货位有货,放货位:{},mode:{},move:{}", next_device_code, mode, move); - if (this.getNow_steps_type1() == 4 || this.getNow_steps_type3() == 8) { - feedMessage = "前工位未放货原因-->"; - if (mode != 2) { - feedMessage += "前工位放货位工作模式不为待机状态(mode != 2),"; - } - if (move == 0) { - feedMessage += "前工位放货位不应该为无货状态(move == 0)"; - } - } - } - } - } else { - if (this.getNow_steps_type1() == 4 || this.getNow_steps_type3() == 8) { - feedMessage = "前工位未放货原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action1 != 3) { - feedMessage += "前工位动作信号不为放货中(action1 != 3),"; - } - if (move1 == 0) { - feedMessage += "前工位光电信号不应为无货状态(move1 == 0),"; - } - if (task1 == 0) { - feedMessage += "前工位没有任务号(task1 == 0),"; - } - } - } - - - //单任务前工位放货完成 任务完成 - if (mode == 3 && action1 == 4 && move1 == 0 && task1 > 0 && type == 1) { - //inst_message - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); - if (inst1 != null) { - if (StrUtil.equals(inst1.getInstruction_status(), "1")) { - if (to_command1 != 5) { - this.writing("to_command1", "5"); - } - this.setNow_steps_type1(6); - this.setNow_steps_type1(0); - this.finish_instruction(inst1); - } - } - } else { - if (this.getNow_steps_type1() == 5) { - feedMessage = "单任务前工位放货完成后未反馈原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action1 != 4) { - feedMessage += "前工位动作信号未放货完成(action1 != 4),"; - } - if (move1 != 0) { - feedMessage += "前工位光电信号为不应为有货状态(move1 != 0),"; - } - if (task1 == 0) { - feedMessage += "前工位没有任务号(task1 == 0),"; - } - if (type != 1) { - feedMessage += "不为前工位单任务(type != 1)"; - } - } - } - - - //双工位 任务完成 前工位反馈4 - if (mode == 3 && action1 == 4 && move1 == 0 && task1 > 0 && task2 > 0 && type == 3) { - //inst_message - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); - if (inst1 != null) { - if (StrUtil.equals(inst1.getInstruction_status(), "1")) { - if (to_command1 != 5) { - this.writing("to_command1", "5"); - } - this.setNow_steps_type3(10); - this.setNow_steps_type3(0); - this.finish_instruction(inst1); - } - } - } else { - if (this.getNow_steps_type3() == 9) { - feedMessage = "双任务前工位放货完成后未反馈原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action1 != 4) { - feedMessage += "前工位动作信号未放货完成(action1 != 4),"; - } - if (move1 != 0) { - feedMessage += "前工位光电信号为不应为有货状态(move1 != 0),"; - } - if (task1 == 0) { - feedMessage += "前工位没有任务(task1 == 0),"; - } - if (task2 == 0) { - feedMessage += "后工位没有任务号(task2 == 0),"; - } - if (type != 3) { - feedMessage += "不是双任务(type != 3)"; - } - } - } + update_instruction_status(); task_check(); @@ -724,33 +319,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl case 2: //申请任务 if (mode == 2 && move1 == 0 && move2 == 0 && action1 == 0 && action2 == 0 && task1 == 0 && task2 == 0 && !requireSucess) { - //获取关联设备驱动信息 判断关联设备是否禁用 - String link_device_code = String.valueOf(this.getDevice().getExtraValue().get("link_device_code")); - Device device = deviceAppservice.findDeviceByCode(link_device_code); - SlitTwoManipulatorDeviceDriver slitTwoManipulatorDeviceDriver; - if (device.getDeviceDriver() instanceof SlitTwoManipulatorDeviceDriver) { - slitTwoManipulatorDeviceDriver = (SlitTwoManipulatorDeviceDriver) device.getDeviceDriver(); - //如果禁用 - if (slitTwoManipulatorDeviceDriver.getIs_disable() == 1) { - boolean flag = false; - try { - //就去走关联设备异常取放货工位的任务 任务生成成功返回true 就不会走下面正常生成任务的逻辑 - flag = instruction_require2(); - } catch (Exception e) { - flag = false; - } - if (flag) { - break; - } - } - } - //没有生成异常取放货工位的任务 就生成正常关联取放货工位的任务 - boolean res = instruction_require(); - if (res) { - feedMessage = ""; - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - } + apply_task(); + } else { if (!requireSucess) { @@ -836,6 +406,44 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl return true; } + public synchronized boolean apply_task() { + Date date = new Date(); + if (date.getTime() - this.apply_task_time.getTime() < (long) this.apply_task_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.apply_task_time); + return false; + } else { + this.apply_task_time = date; + //获取关联设备驱动信息 判断关联设备是否禁用 + String link_device_code = String.valueOf(this.getDevice().getExtraValue().get("link_device_code")); + Device device = deviceAppservice.findDeviceByCode(link_device_code); + SlitTwoManipulatorDeviceDriver slitTwoManipulatorDeviceDriver; + if (device.getDeviceDriver() instanceof SlitTwoManipulatorDeviceDriver) { + slitTwoManipulatorDeviceDriver = (SlitTwoManipulatorDeviceDriver) device.getDeviceDriver(); + //如果禁用 + if (slitTwoManipulatorDeviceDriver.getIs_disable() == 1) { + boolean flag = false; + try { + //就去走关联设备异常取放货工位的任务 任务生成成功返回true 就不会走下面正常生成任务的逻辑 + flag = instruction_require2(); + } catch (Exception e) { + flag = false; + } + if (flag) { + return false; + } + } + } + //没有生成异常取放货工位的任务 就生成正常关联取放货工位的任务 + boolean res = instruction_require(); + if (res) { + feedMessage = ""; + notCreateInstMessage = ""; + notCreateTaskMessage = ""; + } + return true; + } + } + //关联设备异常申请任务 public synchronized boolean instruction_require2() { @@ -1601,4 +1209,427 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl jo.put("fault_type", error_type); return jo; } + + /** + * 更新指令状态 + */ + public synchronized void update_instruction_status() throws Exception { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + //单任务 前工位任务更新指令状态 + if (task1 > 0 && type == 1) { + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + //当前执行步骤为更新任务状态 + inst1.setInstruction_status("1"); + inst1.setExecute_device_code(this.getDevice_code()); + instructionService.update(inst1); + } + } + } + + //单任务 后工位任务更新指令状态 + if (task2 > 0 && type == 2) { + //inst_message + Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); + if (inst2 != null) { + if (StrUtil.equals(inst2.getInstruction_status(), "0")) { + //当前指令更新状态 + now_steps_type2 = 1; + inst2.setInstruction_status("1"); + inst2.setExecute_device_code(this.device_code); + instructionService.update(inst2); + } + } + } + + //双任务更新指令状态 + if (task2 > 0 && task1 > 0 && type == 3) { + //inst_message + Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task1)); + if (inst2 != null) { + if (StrUtil.equals(inst2.getInstruction_status(), "0")) { + //当前指令更新状态 + inst2.setInstruction_status("1"); + inst2.setExecute_device_code(this.device_code); + instructionService.update(inst2); + } + } + } + + //双任务/单任务 后工位取空时判断动作信号,并反馈 + if (mode == 3 && action2 == 1 && move2 == 0 && task2 > 0) { + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task2)); + String start_device_code = inst1.getStart_device_code(); + Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); + if (ObjectUtil.isEmpty(startDevice)) { + feedMessage = "后工位取货位:" + start_device_code + "为空!"; + logServer.deviceExecuteLog(this.getDeviceCode(), "", "", "后工位取货位:" + start_device_code + "为空!"); + throw new BadRequestException("后工位取货位:" + start_device_code + "为空!"); + } + SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; + if (startDevice.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { + siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) startDevice.getDeviceDriver(); + int move = siemensConveyorDeviceDriver.getMove(); + int mode = siemensConveyorDeviceDriver.getMode(); + if (mode == 2 && move == 1) { + if (to_command2 != 2) { + this.writing("to_command2", "2"); + } + if (type == 2) { + this.setNow_steps_type2(3); + } else if (type == 3) { + this.setNow_steps_type3(3); + } + } else { + log.warn("后工位取货位无货,取货位:{},mode:{},move:{}", start_device_code, mode, move); + if (this.getNow_steps_type2() == 2 || this.getNow_steps_type3() == 2) { + feedMessage = "后工位未取货原因-->取货位:" + siemensConveyorDeviceDriver.getDevice_code(); + if (mode != 2) { + feedMessage += "工作模式不为待机(mode != 2),"; + } + if (move != 1) { + feedMessage += "光电信号不应该为无货状态(move != 1)"; + } + } + } + } + } else { + if (this.getNow_steps_type2() == 2 || this.getNow_steps_type3() == 2) { + feedMessage = "后工位未取货原因-->"; + if (mode != 3) { + feedMessage += "行架工作模式不为运行中(mode != 3),"; + } + if (action2 != 1) { + feedMessage += "后工位动作信号不为取货中(action2 != 1),"; + } + if (move2 != 0) { + feedMessage += "后工位光电信号应该为0(move2 != 0),"; + } + if (task2 == 0) { + feedMessage += "后工位没有任务号(task2 == 0)"; + } + } + } + + //单任务/或双任务 后工位收到取货完成信号并反馈 + if (mode == 3 && action2 == 2 && move2 == 1 && task2 > 0) { + if (to_command2 != 3) { + this.writing("to_command2", "3"); + } + if (type == 2) { + this.setNow_steps_type2(4); + } + if (type == 3) { + this.setNow_steps_type3(4); + } + } else { + if (this.getNow_steps_type2() == 3 || this.getNow_steps_type3() == 3) { + feedMessage = "后工位取货完成后未反馈原因-->"; + if (mode != 3) { + feedMessage += "行架工作模式不为运行中(mode != 3),"; + } + if (action2 != 2) { + feedMessage += "后工位动作信号未取货完成(action2 != 2),"; + } + if (move2 == 0) { + feedMessage += "后工位光电信号不应该为0(move2 == 0),"; + } + if (task2 == 0) { + feedMessage += "后工位没有任务号(task2 == 0)"; + } + } + } + + //单任务/双任务 前工位取货时判断动作信号并反馈 + if (mode == 3 && action1 == 1 && move1 == 0 && task1 > 0) { + if (to_command1 != 2) { + this.writing("to_command1", "2"); + } + if (type == 1) { + this.setNow_steps_type1(3); + } else if (type == 3) { + this.setNow_steps_type3(5); + } + } else { + if (this.getNow_steps_type1() == 2 || this.getNow_steps_type3() == 4) { + feedMessage = "前工位未取货原因:"; + if (mode != 3) { + feedMessage += "行架工作模式不为运行中(mode != 3),"; + } + if (action1 != 1) { + feedMessage += "前工位动作信号不为取货中(action2 != 1),"; + } + if (move1 != 0) { + feedMessage += "前工位光电信号应该为0(move2 != 0),"; + } + if (task1 == 0) { + feedMessage += "前工位没有任务号(task2 == 0)"; + } + } + } + + //单任务/双任务 前工位取货完成并反馈 + if (mode == 3 && action1 == 2 && move1 == 1 && task1 > 0) { + if (to_command1 != 3) { + this.writing("to_command1", "3"); + } + if (type == 1) { + this.setNow_steps_type1(4); + } + if (type == 3) { + this.setNow_steps_type3(6); + } + } else { + if (this.getNow_steps_type1() == 3 || this.getNow_steps_type3() == 5) { + feedMessage = "前工位取货完成后未反馈原因"; + if (mode != 3) { + feedMessage += "行架工作模式不为运行中(mode != 3),"; + } + if (action1 != 2) { + feedMessage += "前工位动作信号未取货完成(action2 != 2),"; + } + if (move1 == 0) { + feedMessage += "前工位光电信号不应该为无货状态(move2 == 0),"; + } + if (task1 == 0) { + feedMessage += "前工位没有任务号(task2 == 0)"; + } + } + } + + + //单任务/双任务 后工位放货时判断信号并反馈 + if (mode == 3 && action2 == 3 && move2 == 1 && task2 > 0) { + if (to_command2 != 4) { + this.writing("to_command2", "4"); + } + if (type == 2) { + this.setNow_steps_type2(5); + } else if (type == 3) { + this.setNow_steps_type3(7); + } + } else { + if (this.getNow_steps_type2() == 4 || this.getNow_steps_type3() == 6) { + feedMessage = "后工位未放货原因-->"; + if (mode != 3) { + feedMessage += "行架工作模式不为运行中(mode != 3),"; + } + if (action2 != 3) { + feedMessage += "后工位动作信号不为放货中(action2 != 3),"; + } + if (move2 == 0) { + feedMessage += "后工位光电信号为不应该为0(move2 == 0),"; + } + if (task2 == 0) { + feedMessage += "后工位没有任务号(task2 == 0)"; + } + } + } + + //单任务 后工位放货完成 任务完成 + if (mode == 3 && action2 == 4 && move2 == 0 && task2 > 0 && type == 2) { + //inst_message + Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); + if (inst2 != null) { + if (StrUtil.equals(inst2.getInstruction_status(), "1")) { + if (to_command2 != 5) { + this.writing("to_command2", "5"); + } + this.setNow_steps_type2(6); + this.setNow_steps_type2(0); + finish_instruction(inst2); + } + } + } else { + if (this.getNow_steps_type2() == 5) { + feedMessage = "单任务后工位放货完成后未反馈原因-->"; + if (mode != 3) { + feedMessage += "行架工作模式不为运行中(mode != 3),"; + } + if (action2 != 4) { + feedMessage += "后工位动作信号未放货完成(action2 != 4),"; + } + if (move2 != 0) { + feedMessage += "后工位光电信号应该为无货状态(move2 != 0),"; + } + if (task2 == 0) { + feedMessage += "后工位没有任务号(task2 == 0),"; + } + if (type != 2) { + feedMessage += "不是后工位单任务(type != 2)"; + } + } + } + + //双任务 后工位反馈任务完成 并反馈 + if (mode == 3 && action2 == 4 && move2 == 0 && task1 > 0 && task2 > 0 && type == 3) { + if (to_command2 != 5) { + this.writing("to_command2", "5"); + } + this.setNow_steps_type3(8); + } else { + if (this.getNow_steps_type3() == 7) { + feedMessage = "双任务后工位放货完成后未反馈原因-->"; + if (mode != 3) { + feedMessage += "行架工作模式不为运行中(mode != 3),"; + } + if (action2 != 4) { + feedMessage += "后工位动作信号未放货完成(action2 != 4),"; + } + if (move2 != 0) { + feedMessage += "后工位光电信号不应该为有货状态(move2 != 0),"; + } + if (task1 == 0) { + feedMessage += "前工位没有任务号(task1 == 0),"; + } + if (task2 == 0) { + feedMessage += "后工位没有任务号(task2 == 0),"; + } + if (type != 3) { + feedMessage += "不是双任务(type != 3)"; + } + } + } + + //单任务/双任务 前工位放货时判断放货位光电信号 + if (mode == 3 && action1 == 3 && move1 == 1 && task1 > 0) { + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); + String next_device_code = ""; + if (type == 1) { + next_device_code = inst1.getNext_device_code(); + } else if (type == 3) { + next_device_code = inst1.getNext_device_code2(); + } + Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); + if (ObjectUtil.isEmpty(nextDevice)) { + feedMessage = "前工位放货位:" + next_device_code + "为空!"; + throw new BadRequestException("前工位放货位:" + next_device_code + "为空!"); + } + SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; + if (nextDevice.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { + siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) nextDevice.getDeviceDriver(); + int move = siemensConveyorDeviceDriver.getMove(); + int mode = siemensConveyorDeviceDriver.getMode(); + if (move == 1 && mode == 2) { + if (to_command1 != 4) { + this.writing("to_command1", "4"); + } + if (type == 1) { + this.setNow_steps_type1(5); + } else if (type == 3) { + this.setNow_steps_type3(9); + } + } else { +// log.warn("后工位放货位有货,放货位:{},mode:{},move:{}", next_device_code, mode, move); + if (this.getNow_steps_type1() == 4 || this.getNow_steps_type3() == 8) { + feedMessage = "前工位未放货原因-->"; + if (mode != 2) { + feedMessage += "前工位放货位工作模式不为待机状态(mode != 2),"; + } + if (move == 0) { + feedMessage += "前工位放货位不应该为无货状态(move == 0)"; + } + } + } + } + } else { + if (this.getNow_steps_type1() == 4 || this.getNow_steps_type3() == 8) { + feedMessage = "前工位未放货原因-->"; + if (mode != 3) { + feedMessage += "行架工作模式不为运行中(mode != 3),"; + } + if (action1 != 3) { + feedMessage += "前工位动作信号不为放货中(action1 != 3),"; + } + if (move1 == 0) { + feedMessage += "前工位光电信号不应为无货状态(move1 == 0),"; + } + if (task1 == 0) { + feedMessage += "前工位没有任务号(task1 == 0),"; + } + } + } + + + //单任务前工位放货完成 任务完成 + if (mode == 3 && action1 == 4 && move1 == 0 && task1 > 0 && type == 1) { + //inst_message + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "1")) { + if (to_command1 != 5) { + this.writing("to_command1", "5"); + } + this.setNow_steps_type1(6); + this.setNow_steps_type1(0); + this.finish_instruction(inst1); + } + } + } else { + if (this.getNow_steps_type1() == 5) { + feedMessage = "单任务前工位放货完成后未反馈原因-->"; + if (mode != 3) { + feedMessage += "行架工作模式不为运行中(mode != 3),"; + } + if (action1 != 4) { + feedMessage += "前工位动作信号未放货完成(action1 != 4),"; + } + if (move1 != 0) { + feedMessage += "前工位光电信号为不应为有货状态(move1 != 0),"; + } + if (task1 == 0) { + feedMessage += "前工位没有任务号(task1 == 0),"; + } + if (type != 1) { + feedMessage += "不为前工位单任务(type != 1)"; + } + } + } + + + //双工位 任务完成 前工位反馈4 + if (mode == 3 && action1 == 4 && move1 == 0 && task1 > 0 && task2 > 0 && type == 3) { + //inst_message + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "1")) { + if (to_command1 != 5) { + this.writing("to_command1", "5"); + } + this.setNow_steps_type3(10); + this.setNow_steps_type3(0); + this.finish_instruction(inst1); + } + } + } else { + if (this.getNow_steps_type3() == 9) { + feedMessage = "双任务前工位放货完成后未反馈原因-->"; + if (mode != 3) { + feedMessage += "行架工作模式不为运行中(mode != 3),"; + } + if (action1 != 4) { + feedMessage += "前工位动作信号未放货完成(action1 != 4),"; + } + if (move1 != 0) { + feedMessage += "前工位光电信号为不应为有货状态(move1 != 0),"; + } + if (task1 == 0) { + feedMessage += "前工位没有任务(task1 == 0),"; + } + if (task2 == 0) { + feedMessage += "后工位没有任务号(task2 == 0),"; + } + if (type != 3) { + feedMessage += "不是双任务(type != 3)"; + } + } + } + } + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java index 79701f989..c851ddd68 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java @@ -65,7 +65,7 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { String inst_code = requestParam.getOrderId(); String status = requestParam.getState(); String carNo = requestParam.getRobotId(); - Instruction inst = instructionService.findByCodeFromCache(inst_code); + Instruction inst = instructionService.findByCode(inst_code); if (ObjectUtil.isEmpty(inst)) { InStoreReportResponse inStoreReportResponse = new InStoreReportResponse(); inStoreReportResponse.setOrderId(inst_code); @@ -77,7 +77,18 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { log.info("入库任务状态反馈-----输出参数{}", result); return RespUtil.getResp(result.toString(), new InStoreReportResponse()); } - TaskDto task = taskService.findByCodeFromCache(inst.getTask_code()); + if (!StrUtil.equals(inst.getInstruction_status(),"0") && !StrUtil.equals(inst.getInstruction_status(),"1")) { + InStoreReportResponse inStoreReportResponse = new InStoreReportResponse(); + inStoreReportResponse.setOrderId(inst_code); + JSONObject result = new JSONObject(); + result.put("result", "false"); + result.put("code", "0"); + result.put("comment", "未找到未完成的对应指令"); + result.put("data", inStoreReportResponse ); + log.info("入库任务状态反馈-----输出参数{}", result); + return RespUtil.getResp(result.toString(), new InStoreReportResponse()); + } + TaskDto task = taskService.findByCode(inst.getTask_code()); if (ObjectUtil.isEmpty(task)) { InStoreReportResponse inStoreReportResponse = new InStoreReportResponse(); inStoreReportResponse.setOrderId(inst_code); @@ -89,6 +100,17 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { log.info("入库任务状态反馈-----输出参数{}", result); return RespUtil.getResp(result.toString(), new InStoreReportResponse()); } + if (!StrUtil.equals(task.getTask_status(),"0") && !StrUtil.equals(task.getTask_status(),"1")) { + InStoreReportResponse inStoreReportResponse = new InStoreReportResponse(); + inStoreReportResponse.setOrderId(inst_code); + JSONObject result = new JSONObject(); + result.put("result", "false"); + result.put("code", "0"); + result.put("comment", "未找到未完成的对应任务"); + result.put("data", inStoreReportResponse ); + log.info("入库任务状态反馈-----输出参数{}", result); + return RespUtil.getResp(result.toString(), new InStoreReportResponse()); + } // 1 已接收 2 开始执行 3执行完成 4 5 取消 if(StrUtil.equals(status,"1") || StrUtil.equals(status,"2") ){ task.setTask_status("1"); @@ -127,7 +149,7 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { String inst_code = requestParam.getOrderId(); String status = requestParam.getState(); String carNo = requestParam.getRobotId(); - Instruction inst = instructionService.findByCodeFromCache(inst_code); + Instruction inst = instructionService.findByCode(inst_code); if (ObjectUtil.isEmpty(inst)) { OutStoreReportResponse outStoreReportResponse = new OutStoreReportResponse(); outStoreReportResponse.setOrderId(inst_code); @@ -139,7 +161,18 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { log.info("出库任务状态反馈-----输出参数{}", result); return RespUtil.getResp(result.toString(), new OutStoreReportResponse()); } - TaskDto task = taskService.findByCodeFromCache(inst.getTask_code()); + if (!StrUtil.equals(inst.getInstruction_status(),"0") && !StrUtil.equals(inst.getInstruction_status(),"1")) { + OutStoreReportResponse outStoreReportResponse = new OutStoreReportResponse(); + outStoreReportResponse.setOrderId(inst_code); + JSONObject result = new JSONObject(); + result.put("result", "false"); + result.put("code", "0"); + result.put("comment", "未找到对应未完成的指令"); + result.put("data", outStoreReportResponse ); + log.info("出库任务状态反馈-----输出参数{}", result); + return RespUtil.getResp(result.toString(), new OutStoreReportResponse()); + } + TaskDto task = taskService.findByCode(inst.getTask_code()); if (ObjectUtil.isEmpty(task)) { OutStoreReportResponse outStoreReportResponse = new OutStoreReportResponse(); outStoreReportResponse.setOrderId(inst_code); @@ -151,6 +184,17 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { log.info("出库任务状态反馈-----输出参数{}", result); return RespUtil.getResp(result.toString(), new OutStoreReportResponse()); } + if (!StrUtil.equals(task.getTask_status(),"0") && !StrUtil.equals(task.getTask_status(),"1")) { + OutStoreReportResponse outStoreReportResponse = new OutStoreReportResponse(); + outStoreReportResponse.setOrderId(inst_code); + JSONObject result = new JSONObject(); + result.put("result", "false"); + result.put("code", "0"); + result.put("comment", "未找到未完成的对应任务"); + result.put("data", outStoreReportResponse ); + log.info("出库任务状态反馈-----输出参数{}", result); + return RespUtil.getResp(result.toString(), new OutStoreReportResponse()); + } // 1 已接收 2 开始执行 3执行完成 4 阻挡 5 空洞 if(StrUtil.equals(status,"1") || StrUtil.equals(status,"2") ){ task.setTask_status("1"); @@ -210,7 +254,7 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { String inst_code = requestParam.getOrderId(); String status = requestParam.getState(); String carNo = requestParam.getRobotId(); - Instruction inst = instructionService.findByCodeFromCache(inst_code); + Instruction inst = instructionService.findByCode(inst_code); if (ObjectUtil.isEmpty(inst)) { MoveStoreReportResponse moveStoreReportResponse = new MoveStoreReportResponse(); moveStoreReportResponse.setOrderId(inst_code); @@ -222,7 +266,18 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { log.info("移库任务状态反馈-----输出参数{}", result); return RespUtil.getResp(result.toString(), new MoveStoreReportResponse()); } - TaskDto task = taskService.findByCodeFromCache(inst.getTask_code()); + if (!StrUtil.equals(inst.getInstruction_status(),"0") && !StrUtil.equals(inst.getInstruction_status(),"1")) { + MoveStoreReportResponse moveStoreReportResponse = new MoveStoreReportResponse(); + moveStoreReportResponse.setOrderId(inst_code); + JSONObject result = new JSONObject(); + result.put("result", "false"); + result.put("code", "0"); + result.put("comment", "未找到未完成的对应指令"); + result.put("data", moveStoreReportResponse ); + log.info("移库任务状态反馈-----输出参数{}", result); + return RespUtil.getResp(result.toString(), new MoveStoreReportResponse()); + } + TaskDto task = taskService.findByCode(inst.getTask_code()); if (ObjectUtil.isEmpty(task)) { MoveStoreReportResponse moveStoreReportResponse = new MoveStoreReportResponse(); moveStoreReportResponse.setOrderId(inst_code); @@ -233,7 +288,19 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { result.put("data", moveStoreReportResponse ); log.info("移库任务状态反馈-----输出参数{}", result); return RespUtil.getResp(result.toString(), new MoveStoreReportResponse()); - } // 1 已接收 2 开始执行 3执行完成 4 阻挡 5 空洞 + } + if (!StrUtil.equals(task.getTask_status(),"0") && !StrUtil.equals(task.getTask_status(),"1")) { + MoveStoreReportResponse moveStoreReportResponse = new MoveStoreReportResponse(); + moveStoreReportResponse.setOrderId(inst_code); + JSONObject result = new JSONObject(); + result.put("result", "false"); + result.put("code", "0"); + result.put("comment", "未找到未完成的对应任务"); + result.put("data", moveStoreReportResponse ); + log.info("移库任务状态反馈-----输出参数{}", result); + return RespUtil.getResp(result.toString(), new MoveStoreReportResponse()); + } + // 1 已接收 2 开始执行 3执行完成 4 阻挡 5 空洞 if(StrUtil.equals(status,"1") || StrUtil.equals(status,"2") ){ task.setTask_status("1"); taskService.update(task); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/Instruction.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/Instruction.java index 3efb4757f..4b00b062a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/Instruction.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/Instruction.java @@ -10,5 +10,14 @@ public class Instruction extends InstructionDto { public Instruction() { } + @Override + public String toString(){ + return "task_code:" + this.getTask_code() + + ",inst_code:" + this.getInstruction_code() + + ",inst_type" + this.getInstruction_type() + + ",start_device_code:" + this.getStart_device_code() + + ",next_device_code:" +this.getNext_device_code() + + ",status:"+ this.getInstruction_status(); + } } \ No newline at end of file diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java index af3bd6d92..7c5875db1 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java @@ -307,4 +307,13 @@ public class TaskDto implements Serializable { */ private String next_height = "0"; + + @Override + public String toString(){ + return "task_code:" + this.getTask_code() + + ",task_type" + this.getTask_type() + + ",start_device_code:" + this.getStart_device_code() + + ",next_device_code:" +this.getNext_device_code() + + ",status:"+ this.getTask_status(); + } }