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 18768628d..8e9c35796 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 @@ -111,6 +111,8 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme String message = null; Boolean iserror = false; + String barcode = null; + Integer heartbeat_tag; private Date instruction_require_time = new Date(); private Date require_apply_labeling_time = new Date(); @@ -164,24 +166,19 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme // logServer.deviceExecuteLog(this.device_code, "", "", "heartbeat:" + last_heartbeat + "->" + heartbeat); // } if (mode != last_mode) { - if (mode == 2) { - requireSucess = false; - requireApplyLabelingSuccess = false; - requireApplyLaStrangulationSuccess = false; - requireEmptyInSuccess = false; - requireEmptyOutSuccess = false; - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记"); - } - if (mode == 6) { - requireEmptyInSuccess = false; - } - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); + requireSucess = false; + requireApplyLabelingSuccess = false; + requireApplyLaStrangulationSuccess = false; + requireEmptyInSuccess = false; + requireEmptyOutSuccess = false; + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记:" + requireSucess); logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); } if (move != last_move) { message = null; if (move == 0) { inst_message = null; + this.barcode = null; this.clearWrite(); } if (move == 0 && last_move == 1) { @@ -494,6 +491,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError()))); jo.put("isError", this.getIserror()); jo.put("message", this.getMessage()); + jo.put("barcode", barcode); jo.put("is_click", true); jo.put("requireSucess", requireSucess); jo.put("driver_type", "siemens_conveyor"); @@ -508,6 +506,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme } else if (StrUtil.equals(requestSucess, "1")) { this.requireSucess = true; } + this.barcode = data.getString("barcode"); } @Override @@ -931,6 +930,34 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme } else { this.instruction_require_time = date; if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { + //判断是否有手动补码 如果有就申请补码agv任务 + if (StrUtil.isNotEmpty(barcode)) { + message = "申请补码AGV搬运任务中..."; + JSONObject apply = new JSONObject(); + apply.put("device_code", device_code); + apply.put("type", "4"); + apply.put("vehicle_code", barcode); + + String str = acsToWmsService.applyTaskToWms(apply); + logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,请求参数:" + apply + ",响应参数," + str); + + JSONObject jo = JSON.parseObject(str); + if (ObjectUtil.isEmpty(jo)) { + message = "申请补码AGV搬运任务接口不通"; +// requireSucess = true; + } else { + if (jo.getInteger("status") == 200) { + message = "申请补码AGV搬运任务成功"; + logServer.deviceExecuteLog(this.device_code, "", "", "申请补码AGV任务,返回参数:" + jo); + requireSucess = true; + } else { +// requireSucess = true; + message = "申请补码AGV搬运任务失败," + jo.get("message").toString(); + } + } + return; + } + //没有就正常申请agv任务 Instruction instruction = instructionService.findByCode(String.valueOf(task)); if (ObjectUtil.isEmpty(instruction)) { message = "指令号" + task + "未找到对应指令"; @@ -940,6 +967,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme message = "指令号" + task + "未找到对应木箱号"; return; } + message = "申请AGV搬运任务中..."; JSONObject apply = new JSONObject(); apply.put("device_code", device_code); @@ -947,7 +975,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme apply.put("vehicle_code", instruction.getVehicle_code()); String str = acsToWmsService.applyTaskToWms(apply); - logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,请求参数:" + apply); + logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,请求参数:" + apply + ",响应参数"); JSONObject jo = JSON.parseObject(str); if (ObjectUtil.isEmpty(jo)) { 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 81f9405ea..33fea5d2b 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 @@ -103,6 +103,7 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl int hasGoods = 0; String message = null; Boolean iserror = false; + String barcode = null; Integer heartbeat_tag; private Date instruction_require_time = new Date(); @@ -170,6 +171,7 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl message = null; if (move == 0) { inst_message = null; + barcode = null; requireSucess = false; this.clearWrite(); } @@ -437,8 +439,7 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl jo.put("task", task); jo.put("last_task", last_task); jo.put("task_code", task_code); - -// jo.put("barcode", barcode); + jo.put("barcode", barcode); // jo.put("last_task", last_task); jo.put("inst_message", this.inst_message); jo.put("last_inst_message", this.last_inst_message); @@ -448,7 +449,7 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl jo.put("message", this.getMessage()); jo.put("is_click", true); jo.put("requireSucess", requireSucess); - jo.put("driver_type", "siemens_conveyor"); + jo.put("driver_type", "siemens_conveyor_ckk"); return jo; } @@ -460,16 +461,18 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl } else if (StrUtil.equals(requestSucess, "1")) { this.requireSucess = true; } + String barcode = data.getString("barcode"); + this.setBarcode(barcode); } @Override public JSONObject feedLmsRealFailedInfo() { JSONObject jo = new JSONObject(); - jo.put("device_code",this.getDevice().getDevice_code()); - jo.put("device_name",this.getDevice().getDevice_name()); - jo.put("fault_code",String.valueOf(error)); - jo.put("fault_info",ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); - jo.put("fault_type",error_type); + jo.put("device_code", this.getDevice().getDevice_code()); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("fault_code", String.valueOf(error)); + jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); + jo.put("fault_type", error_type); return jo; } @@ -503,29 +506,92 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl return false; } else { this.instruction_require_time = date; - if (task > 0) { - Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task)); - if (ObjectUtil.isEmpty(instruction)) { - //instruction = instructionService.findByCode(String.valueOf(task)); - message = "任务号:" + task + "未找到对应立库指令,请检查"; + if (!StrUtil.isEmpty(barcode) && task == 0) { + Instruction inst = instructionService.findByBarcodeFromCache(barcode); + if (ObjectUtil.isEmpty(inst)) { + TaskDto taskDto = taskserver.findByContainer(barcode); + if (ObjectUtil.isEmpty(taskDto)) { + message = "未找到手动补码:" + barcode + "对应立库指令,请检查"; + return false; + } + String next_device_code = taskDto.getNext_device_code(); + Instruction instdto = new Instruction(); + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(taskDto.getRoute_plan_code()); + instdto.setRemark(taskDto.getRemark()); + instdto.setMaterial(taskDto.getMaterial()); + instdto.setQuantity(taskDto.getQuantity()); + instdto.setTask_id(taskDto.getTask_id()); + instdto.setTask_code(taskDto.getTask_code()); + instdto.setVehicle_code(barcode); + String now = DateUtil.now(); + instdto.setCreate_time(now); + instdto.setCreate_by("auto"); + instdto.setStart_device_code(this.device.getDevice_code()); + instdto.setNext_device_code(taskDto.getNext_device_code()); + instdto.setStart_point_code(this.device.getDevice_code()); + instdto.setNext_point_code(taskDto.getNext_device_code()); + instdto.setPriority(taskDto.getPriority()); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(this.device.getDevice_code()); + try { + instructionService.create(instdto); + } catch (Exception e) { + e.printStackTrace(); + log.error("指令创建失败!", e.getMessage()); + return false; + } + Device nextdevice = deviceAppservice.findDeviceByCode(taskDto.getNext_device_code()); + requireSucess = true; + String next_addr = nextdevice.getExtraValue().get("address").toString(); + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_target"); + map.put("value", next_addr); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_task"); + 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); + this.writing(list); + return true; + } + try { + instructionService.finish(inst); + } catch (Exception e) { + e.printStackTrace(); + } + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务手动补码完成指令成功,指令号:" + inst.getInstruction_code()); + + } else { + if (task > 0) { + Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task)); + if (ObjectUtil.isEmpty(instruction)) { + //instruction = instructionService.findByCode(String.valueOf(task)); + message = "任务号:" + task + "未找到对应立库指令,请检查"; + return false; + } + if (StrUtil.equals(instruction.getInstruction_status(), "1")) { + if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { + vehicle_code = inst.getVehicle_code(); + inst.setExecute_device_code(this.device_code); + try { + finish_instruction(); + } catch (Exception e) { + e.printStackTrace(); + } + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task); + } + } + } else { + logServer.deviceExecuteLog(device_code, "", "", "申请输送任务电气设备任务号:" + task + "异常"); + message = "申请输送任务电气设备任务号:" + task + "异常"; return false; } - if (StrUtil.equals(instruction.getInstruction_status(), "1")) { - if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - vehicle_code = inst.getVehicle_code(); - inst.setExecute_device_code(this.device_code); - try { - finish_instruction(); - } catch (Exception e) { - e.printStackTrace(); - } - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task); - } - } - } else { - logServer.deviceExecuteLog(device_code, "", "", "申请输送任务电气设备任务号:" + task + "异常"); - message = "申请输送任务电气设备任务号:" + task + "异常"; - return false; } //判断是否存在起点相同 任务状态就绪的任务 @@ -708,239 +774,5 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl } } - //申请贴标 - public synchronized void applyLabeling() { - Date date = new Date(); - if (date.getTime() - this.require_apply_labeling_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_apply_labeling_time = date; - String vehicle_code = ""; - if (task > 0) { - Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task)); - vehicle_code = instruction.getVehicle_code(); - } else { - logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "异常"); - message = "申请贴标电气设备任务号:" + task + "异常"; - throw new RuntimeException("任务号为空!"); - } - if (StrUtil.isEmpty(vehicle_code)) { - logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "未找到载具号"); - message = "申请贴标电气设备任务号:" + task + "未找到载具号"; - throw new RuntimeException("载具号为空!"); - } - ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = - new ApplyLabelingAndBindingRequest(); - JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0); - String start_point_code = null; - if (!ObjectUtil.isEmpty(device_json)) { - start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code"); - } - applyLabelingAndBindingRequest.setDevice_code(start_point_code); - applyLabelingAndBindingRequest.setType("1"); - applyLabelingAndBindingRequest.setVehicle_code(vehicle_code); - ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest); - - if (applyLabelingAndBindingResponse.getstatus() == 200) { - message = "申请贴标成功"; - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", "5"); - list.add(map); - this.writing(list); - this.writing(list); - message = "申请贴标下发电气信号成功"; - requireApplyLabelingSuccess = true; - } else { - message = "申请贴标失败," + applyLabelingAndBindingResponse.getMessage(); - } - } - } - - //申请捆扎 - @SneakyThrows - public synchronized void applyLaStrangulation() { - Date date = new Date(); - if (date.getTime() - this.require_apply_strangulation_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_apply_strangulation_time = date; - String vehicle_code = ""; - if (task > 0) { - Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task)); - if (ObjectUtil.isEmpty(instruction)) { - message = "申请捆扎电气设备任务号:" + task + "未找到对应指令"; - throw new RuntimeException("该电气任务号未找到对应指令!"); - } - vehicle_code = instruction.getVehicle_code(); - } else { - logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:" + task + "异常"); - message = "申请捆扎电气设备任务号:" + task + "异常"; - throw new RuntimeException("任务号为空!"); - } - if (StrUtil.isEmpty(vehicle_code)) { - logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:" + task + "未找到载具号"); - message = "申请捆扎电气设备任务号:" + task + "未找到载具号"; - throw new RuntimeException("载具号为空!"); - } - ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = - new ApplyLabelingAndBindingRequest(); - JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0); - String start_point_code = null; - if (!ObjectUtil.isEmpty(device_json)) { - start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code"); - } - applyLabelingAndBindingRequest.setDevice_code(start_point_code); - applyLabelingAndBindingRequest.setType("2"); - applyLabelingAndBindingRequest.setVehicle_code(vehicle_code); - ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest); - if (applyLabelingAndBindingResponse.getstatus() == 200) { - if (ObjectUtil.isNotEmpty(applyLabelingAndBindingResponse.getData())) { - Map datas = applyLabelingAndBindingResponse.getData(); - String length = datas.get("box_length").toString(); - String width = datas.get("box_width").toString(); - String box_high = datas.get("box_high").toString(); - String bundle_times = datas.get("bundle_times").toString(); - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_length"); - map.put("value", length); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_weight"); - map2.put("value", width); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_height"); - map3.put("value", box_high); - list.add(map3); - Map map4 = new HashMap(); - map4.put("code", "to_strap_times"); - map4.put("value", bundle_times); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_command"); - map5.put("value", "4"); - list.add(map5); - this.writing(list); -// this.writing(list); - - message = "申请捆扎成功"; - requireSucess = true; - } else { - message = "未返回尺寸信息"; - } - - } else { - message = applyLabelingAndBindingResponse.getMessage(); - } - - } - } - - public synchronized void emptyIn() { - Date date = new Date(); - if (date.getTime() - this.require_empty_in_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_empty_in_time = date; - - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { - message = "申请空盘入库任务中..."; - JSONObject apply = new JSONObject(); - apply.put("device_code", device_code); - apply.put("type", "2"); - String str = acsToWmsService.applyTaskToWms(apply); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "申请空盘入库接口不通"; - requireEmptyInSuccess = true; - } else { - if (jo.getInteger("status") == 200) { - message = "申请空盘入库成功"; - requireEmptyInSuccess = true; - } else { - requireEmptyInSuccess = true; - message = "申请空盘入库失败," + jo.get("message").toString(); - } - } - - } - } - } - - public synchronized void applyAgvTask() { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.instruction_require_time = date; - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { - Instruction instruction = instructionService.findByCode(String.valueOf(task)); - if (ObjectUtil.isEmpty(instruction)) { - message = "指令号" + task + "未找到对应指令"; - return; - } - message = "申请AGV搬运任务中..."; - JSONObject apply = new JSONObject(); - apply.put("device_code", device_code); - apply.put("type", "4"); - apply.put("vehicle_code", instruction.getVehicle_code()); - String str = acsToWmsService.applyTaskToWms(apply); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "申请AGV搬运任务接口不通"; - requireSucess = true; - } else { - if (jo.getInteger("status") == 200) { - message = "申请AGV搬运任务成功"; - requireSucess = true; - } else { - requireSucess = true; - message = "申请AGV搬运任务失败," + jo.get("message").toString(); - } - } - - } - } - } - - public synchronized void emptyOut() { - Date date = new Date(); - if (date.getTime() - this.require_empty_out_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_empty_out_time = date; - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { - message = "申请空盘出库任务中..."; - JSONObject apply = new JSONObject(); - apply.put("device_code", device_code); - apply.put("type", "3"); - String str = acsToWmsService.applyTaskToWms(apply); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "申请空盘出库接口不通"; -// requireSucess = true; - } else { - if (jo.getInteger("status") == 200) { - message = "申请空盘出库成功"; - requireSucess = true; - } else { -// requireSucess = true; - message = "申请空盘出库失败," + jo.get("message").toString(); - } - } - - } - } - } - } diff --git a/acs/nladmin-ui/src/views/system/monitor/device/index.vue b/acs/nladmin-ui/src/views/system/monitor/device/index.vue index f8b72ca4f..5167e2bda 100644 --- a/acs/nladmin-ui/src/views/system/monitor/device/index.vue +++ b/acs/nladmin-ui/src/views/system/monitor/device/index.vue @@ -38,9 +38,9 @@ - 禁止进出 - 允许进入 - 允许离开 + 禁止进出 + 允许进入 + 允许离开 @@ -116,6 +116,27 @@ + + + + + + + + + + + + + + + + + + @@ -147,7 +168,7 @@ - + @@ -190,6 +211,7 @@ export default { dialogFormVisible4: false, dialogFormVisible5: false, dialogFormVisible6: false, + dialogFormVisible7: false, form: { device_code: '', hasGoodStatus: null, @@ -331,7 +353,13 @@ export default { } else if (clickObj.data.driver_type === 'slit_two_manipulator') { this.dialogFormVisible4 = true } else if (clickObj.data.driver_type === 'siemens_conveyor') { - this.dialogFormVisible5 = true + if (clickObj.data.device_name.includes('1016')) { + this.dialogFormVisible7 = true + } else { + this.dialogFormVisible5 = true + } + } else if (clickObj.data.driver_type === 'siemens_conveyor_ckk') { + this.dialogFormVisible7 = true } else if (clickObj.data.driver_type === 'standard_conveyor_control_with_scanner') { this.dialogFormVisible6 = true } else { @@ -347,6 +375,7 @@ export default { this.form.fullrequireSucess = clickObj.data.fullrequireSucess this.form.is_disable = clickObj.data.is_disable1 this.form.applySucess = clickObj.data.applySucess + this.form.barcode = clickObj.data.barcode }, moveShow(nodeData) { // 点击之后显示出来的数据----只需要设备信息 let item = '' @@ -582,12 +611,14 @@ export default { this.dialogFormVisible4 = false this.dialogFormVisible5 = false this.dialogFormVisible6 = false + this.dialogFormVisible7 = false this.initStageData() }).catch(err => { this.dialogFormVisible = false this.dialogFormVisible3 = false this.dialogFormVisible4 = false this.dialogFormVisible5 = false + this.dialogFormVisible7 = false console.log(err.response.data.message) }) },