diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/IndoorManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/IndoorManipulatorDeviceDriver.java index 17ca5758b..62f9cac42 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/IndoorManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/IndoorManipulatorDeviceDriver.java @@ -5,27 +5,18 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.nl.acs.AcsConfig; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver; -import org.nl.acs.device_driver.basedriver.lamp_three_color.LampThreecolorDeviceDriver; -import org.nl.acs.device_driver.basedriver.photoelectric_inspection_site.PhotoelectricInspectionSiteDeviceDriver; import org.nl.acs.device_driver.basedriver.plugging_unplugging_machine.PluggingUnpluggingMachineDeviceDriver; import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver; -import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest; -import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse; import org.nl.acs.ext.wms.data.ApplyManipulatorActionRequest; import org.nl.acs.ext.wms.data.ApplyManipulatorActionResponse; import org.nl.acs.ext.wms.service.AcsToWmsService; @@ -36,7 +27,6 @@ import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.log.service.DeviceExecuteLogService; -import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; @@ -312,13 +302,13 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple logServer.deviceExecuteLog(this.device_code, "", "", "信号inflatable_shaft_size:" + last_inflatable_shaft_size + "->" + inflatable_shaft_size); } - if (task > 0 && getTo_task_type() == 1) { + if (task > 0 && getTo_task_type() == 1 && !requireSucess) { update_instruction_status(); - } else if (task > 0 && getTo_task_type() == 2) {// + } else if (task > 0 && getTo_task_type() == 2 && !requireSucess) { update_instruction_status2(); - } else if (task > 0 && getTo_task_type() == 6) { + } else if (task > 0 && getTo_task_type() == 6 && !requireSucess) { update_instruction_status3(); - } else if (task > 0 && getTo_task_type() == 7) { + } else if (task > 0 && getTo_task_type() == 7 && !requireSucess) { update_instruction_status4(); } @@ -426,503 +416,446 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple } private synchronized void update_instruction_status() { + ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); + ApplyManipulatorActionResponse applyManipulatorActionResponse; 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 = checkInst(); - if (inst1 != null) { - if (StrUtil.equals(inst1.getInstruction_status(), "0")) { - inst1.setInstruction_status("1"); - inst1.setExecute_device_code(this.device_code); - instructionService.update(inst1); + Instruction inst1 = checkInst(); + if (inst1 != null) { + 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 + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + inst1.setInstruction_status("1"); + inst1.setExecute_device_code(this.device_code); + instructionService.update(inst1); + } } } - } - - ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); - ApplyManipulatorActionResponse applyManipulatorActionResponse; - //反馈尺寸 - if (action == 2) { - Instruction inst2 = checkInst(); - String task_code = inst2.getTask_code(); - TaskDto taskDto = taskserver.findByCode(task_code); - String truss_type = taskDto.getTruss_type(); - applyManipulatorActionRequest.setType(truss_type); - applyManipulatorActionRequest.setTask_code(task_code); - applyManipulatorActionRequest.setSize(String.valueOf(inflatable_shaft_size)); - applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); - if (applyManipulatorActionResponse.getstatus() == 200) { - requireSucess = true; - message = "反馈LMS成功..."; - logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); - String version = applyManipulatorActionResponse.getVersion(); - String bushing_num = applyManipulatorActionResponse.getBushing_num(); - String is_bushing = applyManipulatorActionResponse.getIs_bushing(); - String detail_type = applyManipulatorActionResponse.getDetail_type(); - String put_device_code = applyManipulatorActionResponse.getPut_device_code(); - Map map = new LinkedHashMap<>(); - map.put("to_command", "2"); - map.put("inflatableShaftVersion", version); - map.put("tube_num", bushing_num); - map.put("is_wrapped", is_bushing); - map.put("to_putpoint", put_device_code); - this.writing(map); - } else { - requireSucess = true; - message = "完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse); - logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + //反馈尺寸 + if (action == 2) { + String task_code = inst1.getTask_code(); + applyManipulatorActionRequest.setType("2"); + applyManipulatorActionRequest.setTask_code(task_code); + applyManipulatorActionRequest.setSize(String.valueOf(inflatable_shaft_size)); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + if (applyManipulatorActionResponse.getstatus() == 200) { + requireSucess = true; + message = "反馈LMS成功..."; + logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + Map map = new LinkedHashMap<>(); + map.put("to_command", "2"); + this.writing(map); + } else { + requireSucess = false; + message = "完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + } } - } - //任务完成 - if (action == 8) { - Instruction inst2 = checkInst(); - if (inst2 != null) { + //任务完成 + if (action == 8) { try { - finish_instruction(inst2); + finish_instruction(inst1); this.writing("to_command", "8"); + requireSucess = true; } catch (Exception e) { e.printStackTrace(); } feedMessage = ""; - } - } else { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; - } - if (action != 8) { - feedMessage = feedMessage + "动作信号(action)不为完成状态,"; - } - if (move != 0) { - feedMessage = feedMessage + "光电信号(move)不为无货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + } else { + feedMessage = "行架机械手:"; + if (mode != 3) { + feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + } + if (action != 8) { + feedMessage = feedMessage + "动作信号(action)不为完成状态,"; + } + if (move != 0) { + feedMessage = feedMessage + "光电信号(move)不为无货状态,"; + } + if (task == 0) { + feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + } } } - - + } else { + feedMessage = ""; } } private synchronized void update_instruction_status2() { + ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); + ApplyManipulatorActionResponse applyManipulatorActionResponse; 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); + Instruction inst1 = checkInst(); + if (inst1 != null) { + 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 = checkInst(); - if (inst1 != null) { - if (StrUtil.equals(inst1.getInstruction_status(), "0")) { - inst1.setInstruction_status("1"); - inst1.setExecute_device_code(this.device_code); - instructionService.update(inst1); - } - } - } - - ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); - ApplyManipulatorActionResponse applyManipulatorActionResponse; - //反馈气胀轴尺寸 - if (action == 2) { - Instruction inst2 = checkInst(); - String task_code = inst2.getTask_code(); - TaskDto taskDto = taskserver.findByCode(task_code); - String truss_type = taskDto.getTruss_type(); - applyManipulatorActionRequest.setType(truss_type); - applyManipulatorActionRequest.setTask_code(task_code); - applyManipulatorActionRequest.setSize(String.valueOf(inflatable_shaft_size)); - applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); - if (applyManipulatorActionResponse.getstatus() == 200) { - requireSucess = true; - message = "反馈LMS成功..."; - logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); - Map map = new LinkedHashMap<>(); - map.put("to_command", "2"); - map.put("to_task_type", "2"); - this.writing(map); - } else { - requireSucess = true; - message = "完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse); - logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); - } - } - - //申请放货点 - if (action == 3) { - Instruction inst2 = checkInst(); - String task_code = inst2.getTask_code(); - TaskDto taskDto = taskserver.findByCode(task_code); - String truss_type = taskDto.getTruss_type(); - applyManipulatorActionRequest.setType(truss_type); - applyManipulatorActionRequest.setTask_code(String.valueOf(task)); - applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); - String put_device_code = applyManipulatorActionResponse.getPut_device_code(); - String detail_type = applyManipulatorActionResponse.getDetail_type(); - Map map = new LinkedHashMap<>(); - map.put("to_command", "3"); - map.put("to_putpoint", put_device_code); - this.writing(map); - requireSucess = true; - } - - //任务完成 - if (action == 8) { - Instruction inst2 = checkInst(); - if (inst2 != null) { - try { - finish_instruction(inst2); - this.writing("to_command", "8"); - } catch (Exception e) { - e.printStackTrace(); - } - feedMessage = ""; - } } else { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + this.instruction_update_time = date; + //更改任务状态 + if (task > 0) { + //inst_message + 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 (action != 8) { - feedMessage = feedMessage + "动作信号(action)不为完成状态,"; + + //反馈气胀轴尺寸 + if (action == 2) { + String task_code = inst1.getTask_code(); + applyManipulatorActionRequest.setType("2"); + applyManipulatorActionRequest.setTask_code(task_code); + applyManipulatorActionRequest.setSize(String.valueOf(inflatable_shaft_size)); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + if (applyManipulatorActionResponse.getstatus() == 200) { + requireSucess = true; + message = "反馈LMS成功..."; + logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + Map map = new LinkedHashMap<>(); + map.put("to_command", "2"); + map.put("to_task_type", "2"); + this.writing(map); + } else { + requireSucess = false; + message = "完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + } } - if (move != 0) { - feedMessage = feedMessage + "光电信号(move)不为无货状态,"; + + //申请放货点 + if (action == 3) { + String task_code = inst1.getTask_code(); + applyManipulatorActionRequest.setType("3"); + applyManipulatorActionRequest.setTask_code(task_code); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + String put_device_code = applyManipulatorActionResponse.getPut_device_code(); + Map map = new LinkedHashMap<>(); + map.put("to_command", "3"); + map.put("to_putpoint", put_device_code); + this.writing(map); + requireSucess = true; } - if (task == 0) { - feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + + //任务完成 + if (action == 8) { + if (inst1 != null) { + try { + requireSucess = true; + finish_instruction(inst1); + this.writing("to_command", "8"); + } catch (Exception e) { + e.printStackTrace(); + } + feedMessage = ""; + } + } else { + feedMessage = "行架机械手:"; + if (mode != 3) { + feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + } + if (action != 8) { + feedMessage = feedMessage + "动作信号(action)不为完成状态,"; + } + if (move != 0) { + feedMessage = feedMessage + "光电信号(move)不为无货状态,"; + } + if (task == 0) { + feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + } } } - - + } else { + feedMessage = ""; } } private synchronized void update_instruction_status3() { + ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); + ApplyManipulatorActionResponse applyManipulatorActionResponse; 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); + Instruction inst1 = checkInst(); + if (inst1 != null) { + 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 = checkInst(); - 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 = checkInst(); - if (ObjectUtil.isNotEmpty(inst2)) { - String start_device_code = inst2.getStart_device_code(); - Device device = deviceAppService.findDeviceByCode(start_device_code); - PluggingUnpluggingMachineDeviceDriver pluggingUnpluggingMachineDeviceDriver; - if (device.getDeviceDriver() instanceof PluggingUnpluggingMachineDeviceDriver) { - pluggingUnpluggingMachineDeviceDriver = (PluggingUnpluggingMachineDeviceDriver) device.getDeviceDriver(); - int mode = pluggingUnpluggingMachineDeviceDriver.getMode(); - int error1 = pluggingUnpluggingMachineDeviceDriver.getError(); - int move = pluggingUnpluggingMachineDeviceDriver.getMove(); - if (mode == 2 && error1 == 0 && move == 1) { - Map map = new LinkedHashMap<>(); - map.put("to_command", "1"); - this.writing(map); - this.setFeedbackSucess(true); + } else { + this.instruction_update_time = date; + //更改任务状态 + if (task > 0) { + //inst_message + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + inst1.setInstruction_status("1"); + inst1.setExecute_device_code(this.device_code); + instructionService.update(inst1); } } } - } else { - 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。"; - } - } - ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); - ApplyManipulatorActionResponse applyManipulatorActionResponse; - //反馈尺寸 - if (action == 2) { - Instruction inst2 = checkInst(); - String task_code = inst2.getTask_code(); - TaskDto taskDto = taskserver.findByCode(task_code); - String truss_type = taskDto.getTruss_type(); - applyManipulatorActionRequest.setType(truss_type); - applyManipulatorActionRequest.setTask_code(task_code); - applyManipulatorActionRequest.setSize(String.valueOf(inflatable_shaft_size)); - applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); - if (applyManipulatorActionResponse.getstatus() == 200) { - requireSucess = true; - message = "反馈LMS成功..."; - logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); - String version = applyManipulatorActionResponse.getVersion(); - String bushing_num = applyManipulatorActionResponse.getBushing_num(); - String is_bushing = applyManipulatorActionResponse.getIs_bushing(); - String detail_type = applyManipulatorActionResponse.getDetail_type(); + //反馈尺寸 + if (action == 2) { + String task_code = inst1.getTask_code(); + applyManipulatorActionRequest.setType("2"); + applyManipulatorActionRequest.setTask_code(task_code); + applyManipulatorActionRequest.setSize(String.valueOf(inflatable_shaft_size)); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + if (applyManipulatorActionResponse.getstatus() == 200) { + requireSucess = true; + message = "反馈LMS成功..."; + logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + Map map = new LinkedHashMap<>(); + map.put("to_command", "2"); + this.writing(map); + } else { + requireSucess = false; + message = "完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + } + } + + //从拔轴机取货的新行架任务 + if (mode == 3 && action == 1 && move == 0 && task > 0) { + if (ObjectUtil.isNotEmpty(inst1)) { + String start_device_code = inst1.getStart_device_code(); + Device device = deviceAppService.findDeviceByCode(start_device_code); + PluggingUnpluggingMachineDeviceDriver pluggingUnpluggingMachineDeviceDriver; + if (device.getDeviceDriver() instanceof PluggingUnpluggingMachineDeviceDriver) { + pluggingUnpluggingMachineDeviceDriver = (PluggingUnpluggingMachineDeviceDriver) device.getDeviceDriver(); + int mode = pluggingUnpluggingMachineDeviceDriver.getMode(); + int error1 = pluggingUnpluggingMachineDeviceDriver.getError(); + int move = pluggingUnpluggingMachineDeviceDriver.getMove(); + if (mode == 2 && error1 == 0 && move == 1) { + Map map = new LinkedHashMap<>(); + map.put("to_command", "1"); + this.writing(map); + requireSucess = true; + } + } + } + } else { + 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 (action == 3) { + String task_code = inst1.getTask_code(); + applyManipulatorActionRequest.setType("3"); + applyManipulatorActionRequest.setTask_code(task_code); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); String put_device_code = applyManipulatorActionResponse.getPut_device_code(); Map map = new LinkedHashMap<>(); - map.put("to_command", "2"); - map.put("inflatableShaftVersion", version); - map.put("tube_num", bushing_num); - map.put("is_wrapped", is_bushing); + map.put("to_command", "3"); map.put("to_putpoint", put_device_code); this.writing(map); - } else { requireSucess = true; - message = "完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse); - logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); } - } - - //申请放货点 - if (action == 3) { - Instruction inst2 = checkInst(); - String task_code = inst2.getTask_code(); - TaskDto taskDto = taskserver.findByCode(task_code); - String truss_type = taskDto.getTruss_type(); - applyManipulatorActionRequest.setType(truss_type); - applyManipulatorActionRequest.setTask_code(String.valueOf(task)); - applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); - String put_device_code = applyManipulatorActionResponse.getPut_device_code(); - String detail_type = applyManipulatorActionResponse.getDetail_type(); - Map map = new LinkedHashMap<>(); - map.put("to_command", "3"); - map.put("to_putpoint", put_device_code); - this.writing(map); - this.setFeedbackSucess(true); - } - //任务完成 - if (action == 8) { - Instruction inst2 = checkInst(); - if (inst2 != null) { + //任务完成 + if (action == 8) { try { - String task_code = inst2.getTask_code(); - TaskDto taskDto = taskserver.findByCode(task_code); - String truss_type = taskDto.getTruss_type(); - finish_instruction(inst2); + requireSucess = true; + finish_instruction(inst1); this.writing("to_command", "8"); } catch (Exception e) { e.printStackTrace(); } feedMessage = ""; - } - } else { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; - } - if (action != 8) { - feedMessage = feedMessage + "动作信号(action)不为完成状态,"; - } - if (move != 0) { - feedMessage = feedMessage + "光电信号(move)不为无货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + } else { + feedMessage = "行架机械手:"; + if (mode != 3) { + feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + } + if (action != 8) { + feedMessage = feedMessage + "动作信号(action)不为完成状态,"; + } + if (move != 0) { + feedMessage = feedMessage + "光电信号(move)不为无货状态,"; + } + if (task == 0) { + feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + } } } - - + } else { + feedMessage = ""; } } private synchronized void update_instruction_status4() { + ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); + ApplyManipulatorActionResponse applyManipulatorActionResponse; 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); + Instruction inst1 = checkInst(); + if (inst1 != null) { + 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 = checkInst(); - if (inst1 != null) { - if (StrUtil.equals(inst1.getInstruction_status(), "0")) { - inst1.setInstruction_status("1"); - inst1.setExecute_device_code(this.device_code); - instructionService.update(inst1); - } - } - } - - ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); - ApplyManipulatorActionResponse applyManipulatorActionResponse; - //反馈尺寸 - if (action == 2) { - Instruction inst2 = checkInst(); - String task_code = inst2.getTask_code(); - TaskDto taskDto = taskserver.findByCode(task_code); - String truss_type = taskDto.getTruss_type(); - applyManipulatorActionRequest.setType(truss_type); - applyManipulatorActionRequest.setTask_code(task_code); - applyManipulatorActionRequest.setSize(String.valueOf(inflatable_shaft_size)); - applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); - if (applyManipulatorActionResponse.getstatus() == 200) { - requireSucess = true; - message = "反馈LMS成功..."; - logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); - String version = applyManipulatorActionResponse.getVersion(); - String bushing_num = applyManipulatorActionResponse.getBushing_num(); - String is_bushing = applyManipulatorActionResponse.getIs_bushing(); - String detail_type = applyManipulatorActionResponse.getDetail_type(); - String put_device_code = applyManipulatorActionResponse.getPut_device_code(); - Map map = new LinkedHashMap<>(); - map.put("to_command", "2"); - map.put("inflatableShaftVersion", version); - map.put("tube_num", bushing_num); - map.put("is_wrapped", is_bushing); - map.put("to_putpoint", put_device_code); - this.writing(map); - } else { - requireSucess = true; - message = "完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse); - logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); - } - } - - //申请放货点 - if (action == 3) { - Instruction inst2 = checkInst(); - String task_code = inst2.getTask_code(); - TaskDto taskDto = taskserver.findByCode(task_code); - String truss_type = taskDto.getTruss_type(); - applyManipulatorActionRequest.setType(truss_type); - applyManipulatorActionRequest.setTask_code(String.valueOf(task)); - applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); - String put_device_code = applyManipulatorActionResponse.getPut_device_code(); - String detail_type = applyManipulatorActionResponse.getDetail_type(); - Map map = new LinkedHashMap<>(); - map.put("to_command", "3"); - map.put("to_task_type", detail_type); - map.put("to_putpoint", put_device_code); - this.writing(map); - this.setFeedbackSucess(true); - } - - //申请新取货点 - if (action == 4) { - applyManipulatorActionRequest.setType("4"); - applyManipulatorActionRequest.setTask_code(String.valueOf(task)); - applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); - if (applyManipulatorActionResponse.getstatus() == 200) { - String get_device_code = applyManipulatorActionResponse.getGet_device_code(); - String put_device_code = applyManipulatorActionResponse.getPut_device_code(); - Map map = new LinkedHashMap<>(); - map.put("to_command", "4"); - map.put("to_new_getpoint", get_device_code); - map.put("to_putpoint", put_device_code); - this.writing(map); - requireSucess = true; - logServer.deviceExecuteLog(this.device_code, "", "", "申请新取货点,返回参数:" + applyManipulatorActionResponse); - message = "申请新取货点成功"; - } else { - requireSucess = true; - message = "申请失败"; - logServer.deviceExecuteLog(this.device_code, "", "", "申请失败,返回参数:" + applyManipulatorActionResponse); - } - } - - //申请二次放货点 - if (action == 5) { - applyManipulatorActionRequest.setType("5"); - applyManipulatorActionRequest.setTask_code(String.valueOf(task)); - applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); - if (applyManipulatorActionResponse.getstatus() == 200) { - String put_device_code2 = applyManipulatorActionResponse.getPut_device_code2(); - String detail_type = applyManipulatorActionResponse.getDetail_type(); - String get_device_code = applyManipulatorActionResponse.getGet_device_code(); - Map map = new LinkedHashMap<>(); - map.put("to_command", "5"); - map.put("to_task_type", detail_type); - map.put("to_two_putpoint", put_device_code2); - map.put("to_new_getpoint", get_device_code); - this.writing(map); - requireSucess = true; - logServer.deviceExecuteLog(this.device_code, "", "", "申请二次放货点,返回参数:" + applyManipulatorActionResponse); - message = "申请二次放货点成功"; - } else { - requireSucess = true; - message = "申请失败"; - logServer.deviceExecuteLog(this.device_code, "", "", "申请失败,返回参数:" + applyManipulatorActionResponse); - } - } - - //缓存库取货完成 - if (action == 6) { - Map map = new LinkedHashMap<>(); - map.put("to_command", "6"); - requireSucess = true; - } - - //缓存库放货完成 - if (action == 7) { - Map map = new LinkedHashMap<>(); - map.put("to_command", "7"); - requireSucess = true; - } - - - //放货完成 - if (action == 8) { - Instruction inst2 = checkInst(); - if (inst2 != null) { - try { - String task_code = inst2.getTask_code(); - TaskDto taskDto = taskserver.findByCode(task_code); - String truss_type = taskDto.getTruss_type(); - finish_instruction(inst2); - this.writing("to_command", "8"); - } catch (Exception e) { - e.printStackTrace(); - } - feedMessage = ""; - } } else { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + this.instruction_update_time = date; + //更改任务状态 + if (task > 0) { + //inst_message + 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 (action != 8) { - feedMessage = feedMessage + "动作信号(action)不为放货完成状态,"; + + + //反馈尺寸 + if (action == 2) { + String task_code = inst1.getTask_code(); + applyManipulatorActionRequest.setType("2"); + applyManipulatorActionRequest.setTask_code(task_code); + applyManipulatorActionRequest.setSize(String.valueOf(inflatable_shaft_size)); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + if (applyManipulatorActionResponse.getstatus() == 200) { + requireSucess = true; + message = "反馈LMS成功..."; + logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + Map map = new LinkedHashMap<>(); + map.put("to_command", "2"); + this.writing(map); + } else { + requireSucess = false; + message = "完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + } } - if (move != 0) { - feedMessage = feedMessage + "光电信号(move)不为无货状态,"; + + //申请放货点 + if (action == 3) { + String task_code = inst1.getTask_code(); + applyManipulatorActionRequest.setType("3"); + applyManipulatorActionRequest.setTask_code(task_code); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + String put_device_code = applyManipulatorActionResponse.getPut_device_code(); + Map map = new LinkedHashMap<>(); + map.put("to_command", "3"); + map.put("to_putpoint", put_device_code); + this.writing(map); + requireSucess = true; } - if (task == 0) { - feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + + //申请新取货点 + if (action == 4) { + String task_code = inst1.getTask_code(); + applyManipulatorActionRequest.setType("4"); + applyManipulatorActionRequest.setTask_code(task_code); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + if (applyManipulatorActionResponse.getstatus() == 200) { + String get_device_code = applyManipulatorActionResponse.getGet_device_code(); + Map map = new LinkedHashMap<>(); + map.put("to_command", "4"); + map.put("to_new_getpoint", get_device_code); + this.writing(map); + requireSucess = true; + logServer.deviceExecuteLog(this.device_code, "", "", "申请新取货点,返回参数:" + applyManipulatorActionResponse); + message = "申请新取货点成功"; + } else { + requireSucess = false; + message = "申请失败"; + logServer.deviceExecuteLog(this.device_code, "", "", "申请失败,返回参数:" + applyManipulatorActionResponse); + } } + + //申请二次放货点 + if (action == 5) { + String task_code = inst1.getTask_code(); + applyManipulatorActionRequest.setType("5"); + applyManipulatorActionRequest.setTask_code(task_code); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + if (applyManipulatorActionResponse.getstatus() == 200) { + String put_device_code2 = applyManipulatorActionResponse.getPut_device_code2(); + Map map = new LinkedHashMap<>(); + map.put("to_command", "5"); + map.put("to_two_putpoint", put_device_code2); + this.writing(map); + requireSucess = true; + logServer.deviceExecuteLog(this.device_code, "", "", "申请二次放货点,返回参数:" + applyManipulatorActionResponse); + message = "申请二次放货点成功"; + } else { + requireSucess = false; + message = "申请失败"; + logServer.deviceExecuteLog(this.device_code, "", "", "申请失败,返回参数:" + applyManipulatorActionResponse); + } + } + + //缓存库取货完成 + if (action == 6) { + Map map = new LinkedHashMap<>(); + map.put("to_command", "6"); + requireSucess = true; + } + + //缓存库放货完成 + if (action == 7) { + Map map = new LinkedHashMap<>(); + map.put("to_command", "7"); + requireSucess = true; + } + + + //放货完成 + if (action == 8) { + if (inst1 != null) { + try { + requireSucess = true; + finish_instruction(inst1); + this.writing("to_command", "8"); + } catch (Exception e) { + e.printStackTrace(); + } + feedMessage = ""; + } + } else { + feedMessage = "行架机械手:"; + if (mode != 3) { + feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + } + if (action != 8) { + feedMessage = feedMessage + "动作信号(action)不为放货完成状态,"; + } + if (move != 0) { + feedMessage = feedMessage + "光电信号(move)不为无货状态,"; + } + if (task == 0) { + feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + } + } + + } - - + } else { + feedMessage = ""; } } @@ -1086,7 +1019,7 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple taskDtoList = this.sortTask(taskDtoList); task = taskDtoList.get(j); // 9 行架任务 - if (!StrUtil.equals(task.getTruss_type(), "9")) { + if (!StrUtil.equals(task.getTask_type(), "9")) { task = null; continue; } @@ -1098,7 +1031,6 @@ public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple if (!ObjectUtil.isEmpty(task)) { Device nextdevice = deviceAppService.findDeviceByCode(task.getNext_device_code()); Device startdevice = deviceAppService.findDeviceByCode(task.getStart_device_code()); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; if (startdevice.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) startdevice.getDeviceDriver(); 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 a1e99d098..3d8aae307 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 @@ -303,8 +303,10 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme if (task != last_task) { logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); + if ("true".equals(this.device.getExtraValue().get("task_update"))) { + taskDeviceUpdate(); + } } - if (move != 0 && task > 0) { // logServer.deviceExecuteLog(device_code, "", "", "输送线任务开始反馈任务状态,指令号:" + task); //inst_message @@ -431,6 +433,22 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme } + private void taskDeviceUpdate() { + Instruction inst = checkInst(); + JSONObject param = new JSONObject() {{ + put("device_code", device_code); + put("task_code", inst.getTask_code()); + + }}; + logServer.deviceExecuteLog(this.device_code, "", "", "task变化请求LMS,参数:" + param); + HttpResponse response = acsToWmsService.taskDeviceUpdate(param); + if (response == null || response.getStatus() == 200) { + logServer.deviceExecuteLog(this.device_code, "", "", "task变化请求LMS,接口返回:" + response.body()); + } + } + + + public boolean exe_error() { if (this.error == 0) { return true; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java index e7765a03e..d5039b06a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java @@ -112,6 +112,8 @@ public interface AcsToWmsService { // 输送线有货变成无货时向lms请求 HttpResponse shipDeviceUpdate(JSONObject param); + HttpResponse taskDeviceUpdate(JSONObject param); + void sendDeviceStatus(JSONObject param); ApplyManipulatorActionResponse applyManipulatorActionRequest(ApplyManipulatorActionRequest param); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index 1715b5d6a..451ae2399 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -608,6 +608,29 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { return null; } + @Override + public HttpResponse taskDeviceUpdate(JSONObject param) { + try { + MDC.put(log_file_type, log_type); +// log.info("shipDeviceUpdate-----输入参数{}", param); + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { + String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + AddressDto addressDto = addressService.findByCode("taskDeviceUpdate"); + String methods_url = addressDto.getMethods_url(); + String url = wmsUrl + methods_url; + return HttpRequest + .post(url) + .body(param.toString()) + .execute(); + } + } catch (Throwable ignored) { + + } finally { + MDC.remove(log_file_type); + } + return null; + } + @Override public void sendDeviceStatus(JSONObject param) { try { diff --git a/acs/nladmin-ui/src/views/acs/device/driver/siemens_conveyor.vue b/acs/nladmin-ui/src/views/acs/device/driver/siemens_conveyor.vue index 50e0323fa..1d3381c43 100644 --- a/acs/nladmin-ui/src/views/acs/device/driver/siemens_conveyor.vue +++ b/acs/nladmin-ui/src/views/acs/device/driver/siemens_conveyor.vue @@ -153,6 +153,13 @@ + + + + + + + @@ -326,7 +333,8 @@ export default { link_device_code: [], ship_device_update: true, special_flag: true, - sendDeviceStatus: true + sendDeviceStatus: true, + task_update: true }, rules: {} }