From 5a1d840f60c85440235db6a7fab3b69d77a5fc28 Mon Sep 17 00:00:00 2001 From: tuqiang <437016993@qq.com> Date: Mon, 22 Apr 2024 17:08:20 +0800 Subject: [PATCH] =?UTF-8?q?rev:=E6=96=B0=E5=A2=9Elms=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E8=A1=A8=E5=A4=84=E8=A1=8C=E6=9E=B6?= =?UTF-8?q?4=E7=82=B9=E4=BB=BB=E5=8A=A1=E4=B8=8B=E5=8F=91=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E8=AE=BE=E5=A4=87=E7=9B=91=E6=8E=A7=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...nishedProductOutBindLableDeviceDriver.java | 238 ++++++++++++++---- .../BlankManipulatorDeviceDriver.java | 87 +++++-- .../blank_manipulator/ItemProtocol.java | 14 ++ .../acs/enums/AcsToLmsApplyTaskTypeEnum.java | 8 +- .../src/views/system/monitor/device/index.vue | 2 +- 5 files changed, 273 insertions(+), 76 deletions(-) diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java index 64faa9519..d1e8845c0 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java @@ -238,10 +238,36 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr instruction_require(); } break; + case 5: + //申请贴标 + applyLabeling(mode); + break; case 10: //申请捆轧贴标信息 if (move > 0 && !requireSucess) { - applyLaStrangulationAndLabeling(); + applyLaStrangulationAndLabeling(mode); + } + break; + case 12: + //申请贴标(未贴标) + applyLabeling(mode); + break; + case 13: + //申请捆轧贴标信息(未捆扎) + if (move > 0 && !requireSucess) { + applyLaStrangulationAndLabeling(mode); + } + break; + case 14: + //申请捆轧贴标信息(未贴标) + if (move > 0 && !requireSucess) { + applyLaStrangulationAndLabeling(mode); + } + break; + case 16: + //申请捆轧贴标信息(未贴标,未捆扎) + if (move > 0 && !requireSucess) { + applyLaStrangulationAndLabeling(mode); } break; } @@ -261,7 +287,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr last_to_height = to_height; } - private void applyLaStrangulationAndLabeling() { + private void applyLaStrangulationAndLabeling(int mode) { 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); @@ -288,7 +314,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr .build(); luceneExecuteLogService.deviceExecuteLog(logDto2); // Map datas = applyLabelingAndBindingResponse.getData(); - packagePLCData(jo.getString("data")); + packagePLCData(jo.getString("data"), mode); requireSucess = true; } else { LuceneLogDto logDto2 = LuceneLogDto.builder() @@ -302,7 +328,57 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr } - private void packagePLCData(String datas) { + // 申请贴标 + public synchronized void applyLabeling(int mode) { + 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 = ""; +// + Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task)); + if (StrUtil.isEmpty(inst.getVehicle_code())) { + message = LangProcess.msg("one_message8") + ": " + task + LangProcess.msg("one_message11"); + return; + } + JSONObject param = new JSONObject(); + param.put("device_code", device_code); + param.put("vehicle_code", inst.getVehicle_code()); + param.put("type", AcsToLmsApplyTaskTypeEnum.LABEL.getType()); + String response = acsToWmsService.deviceApplyTwo(param); + JSONObject jo = JSON.parseObject(response); + if (jo.getInteger("status") == 200) { + LuceneLogDto logDto2 = LuceneLogDto.builder() + .device_code(device_code) + .content("申请贴标成功:" + jo) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto2); + List list = new ArrayList(); + Map map5 = new HashMap(); + map5.put("code", "to_command"); + map5.put("value", mode); + list.add(map5); + try { + this.writing(list); + } catch (Exception e) { + message = "universal_write_erro"; + } +// Map datas = applyLabelingAndBindingResponse.getData(); + requireSucess = true; + } else { + LuceneLogDto logDto2 = LuceneLogDto.builder() + .device_code(device_code) + .content("申请贴标失败,接口返回:" + jo.getString("body")) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto2); + } + + } + } + + private void packagePLCData(String datas, int mode) { JSONObject jo = JSON.parseObject(datas); String length = jo.get("length").toString(); @@ -317,54 +393,112 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr String bundleTimes = jo.get("bundleTimes").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", weight); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_height"); - map3.put("value", height); - list.add(map3); - Map map4 = new HashMap(); - map4.put("code", "to_is_binding"); - map4.put("value", isBinding); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_command"); - map5.put("value", 10); - list.add(map5); - Map map6 = new HashMap(); - map6.put("code", "to_is_labeling"); - map6.put("value", isLabeling); - list.add(map6); - Map map7 = new HashMap(); - map7.put("code", "to_print_qty"); - map7.put("value", printQty); - list.add(map7); - Map map8 = new HashMap(); - map8.put("code", "to_print_qty"); - map8.put("value", printQty); - list.add(map8); - Map map9 = new HashMap(); - map9.put("code", "to_print_device"); - map9.put("value", printDevice); - list.add(map9); - Map map10 = new HashMap(); - map10.put("code", "to_binding_template"); - map10.put("value", bindingTemplate); - list.add(map10); - Map map11 = new HashMap(); - map11.put("code", "to_binding_times"); - map11.put("value", bundleTimes); - list.add(map11); - Map map12 = new HashMap(); - map12.put("code", "to_labeling_template"); - map12.put("value", labelingTemplate); - list.add(map12); + if (mode == 10 || mode == 16) { + 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", weight); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_height"); + map3.put("value", height); + list.add(map3); + Map map4 = new HashMap(); + map4.put("code", "to_is_binding"); + map4.put("value", isBinding); + list.add(map4); + Map map5 = new HashMap(); + map5.put("code", "to_command"); + map5.put("value", mode); + list.add(map5); + Map map6 = new HashMap(); + map6.put("code", "to_is_labeling"); + map6.put("value", isLabeling); + list.add(map6); + Map map7 = new HashMap(); + map7.put("code", "to_print_qty"); + map7.put("value", printQty); + list.add(map7); + Map map8 = new HashMap(); + map8.put("code", "to_print_qty"); + map8.put("value", printQty); + list.add(map8); + Map map9 = new HashMap(); + map9.put("code", "to_print_device"); + map9.put("value", printDevice); + list.add(map9); + Map map10 = new HashMap(); + map10.put("code", "to_binding_template"); + map10.put("value", bindingTemplate); + list.add(map10); + Map map11 = new HashMap(); + map11.put("code", "to_binding_times"); + map11.put("value", bundleTimes); + list.add(map11); + Map map12 = new HashMap(); + map12.put("code", "to_labeling_template"); + map12.put("value", labelingTemplate); + list.add(map12); + } + if (mode == 13) { + 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", weight); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_height"); + map3.put("value", height); + list.add(map3); + Map map5 = new HashMap(); + map5.put("code", "to_command"); + map5.put("value", mode); + list.add(map5); + Map map11 = new HashMap(); + map11.put("code", "to_binding_times"); + map11.put("value", bundleTimes); + list.add(map11); + } + if (mode == 14) { + Map map4 = new HashMap(); + map4.put("code", "to_is_binding"); + map4.put("value", isBinding); + list.add(map4); + Map map5 = new HashMap(); + map5.put("code", "to_command"); + map5.put("value", mode); + list.add(map5); + Map map6 = new HashMap(); + map6.put("code", "to_is_labeling"); + map6.put("value", isLabeling); + list.add(map6); + Map map7 = new HashMap(); + map7.put("code", "to_print_qty"); + map7.put("value", printQty); + list.add(map7); + Map map8 = new HashMap(); + map8.put("code", "to_print_qty"); + map8.put("value", printQty); + list.add(map8); + Map map9 = new HashMap(); + map9.put("code", "to_print_device"); + map9.put("value", printDevice); + list.add(map9); + Map map10 = new HashMap(); + map10.put("code", "to_binding_template"); + map10.put("value", bindingTemplate); + list.add(map10); + Map map12 = new HashMap(); + map12.put("code", "to_labeling_template"); + map12.put("value", labelingTemplate); + list.add(map12); + } try { this.writing(list); } catch (Exception e) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDeviceDriver.java index 2a05cd40d..a246621cf 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDeviceDriver.java @@ -139,6 +139,12 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem int to_onset = 0; int last_to_onset = 0; + int to_onset2 = 0; + int last_to_onset2 = 0; + + int to_target2 = 0; + int last_to_target2 = 0; + Boolean isonline = true; int hasGoods = 0; String message = null; @@ -226,6 +232,7 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem if (StrUtil.equals(inst.getInstruction_status(), CommonFinalParam.ZERO)) { inst.setInstruction_status(CommonFinalParam.ONE); inst.setExecute_device_code(this.device_code); + inst.setUpdate_time(DateUtil.now()); instructionService.update(inst); } } @@ -387,6 +394,8 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem last_to_command = to_command; last_to_target = to_target; last_to_onset = to_onset; + last_to_target2 = to_target2; + last_to_onset2 = to_onset2; last_weight = weight; last_barcode = barcode; } @@ -417,9 +426,8 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code()); String startCode = instruction.getStart_device_code(); String nextCode = instruction.getNext_device_code(); - instruction.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - instruction.setUpdate_time(DateUtil.now()); - instructionService.update(instruction); + String startCode2 = instruction.getStart_device_code2(); + String nextCode2 = instruction.getNext_device_code2(); Device startDevice = deviceAppService.findDeviceByCode(startCode); Device nextDevice = deviceAppService.findDeviceByCode(nextCode); if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { @@ -431,10 +439,25 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem String startAddr = startDevice.getExtraValue().get("address").toString(); String nextAddr = nextDevice.getExtraValue().get("address").toString(); Map map = new LinkedHashMap<>(); - map.put("to_command", CommonFinalParam.ONE); map.put("to_onset", startAddr); map.put("to_task", instruction.getInstruction_code()); map.put("to_target", nextAddr); + map.put("to_command", CommonFinalParam.ONE); + + if (StrUtil.isNotEmpty(startCode2)){ + Device startDevice2 = deviceAppService.findDeviceByCode(startCode2); + Device nextDevice2 = deviceAppService.findDeviceByCode(nextCode2); + if (ObjectUtil.isEmpty(startDevice2.getExtraValue().get("address"))) { + throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice.getDevice_code())); + } + if (ObjectUtil.isEmpty(nextDevice2.getExtraValue().get("address"))) { + throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice.getDevice_code())); + } + String start_addr2 = startDevice2.getExtraValue().get("address").toString(); + String next_addr2 = nextDevice2.getExtraValue().get("address").toString(); + map.put("to_onset2", start_addr2); + map.put("to_target2", next_addr2); + } this.writing(map); this.setRequireSucess(true); return true; @@ -460,6 +483,8 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem String routePlanCode = task.getRoute_plan_code(); String nextPointCode = task.getNext_point_code(); String nextDeviceCode = task.getNext_device_code(); + String startDeviceCode2 = task.getStart_device_code2(); + String nextDeviceCode2 = task.getNext_device_code2(); Instruction instdto = new Instruction(); instdto.setInstruction_id(IdUtil.simpleUUID()); @@ -481,22 +506,7 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); instdto.setExecute_device_code(startPointCode); - try { - instructionService.create(instdto); - } catch (Exception e) { - notCreateInstMessage = e.getMessage(); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(LangProcess.msg("universal_message9") + e.getMessage()) - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto); - return false; - } - //创建指令后修改任务状态 - task.setTask_status(TaskStatusEnum.BUSY.getIndex()); - task.setUpdate_time(DateUtil.now()); - taskserver.update(task); - + Map map = new LinkedHashMap<>(); Device startDevice = deviceAppService.findDeviceByCode(instdto.getStart_device_code()); Device nextDevice = deviceAppService.findDeviceByCode(instdto.getNext_device_code()); if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { @@ -520,11 +530,46 @@ public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implem } String startAddr = startDevice.getExtraValue().get("address").toString(); String nextAddr = nextDevice.getExtraValue().get("address").toString(); - Map map = new LinkedHashMap<>(); map.put("to_command", CommonFinalParam.ONE); map.put("to_onset", startAddr); map.put("to_task", instdto.getInstruction_code()); map.put("to_target", nextAddr); + + if (StrUtil.isNotEmpty(startDeviceCode2)){ + //判断任务点位是否配置电气信号 + Device startDevice2 = deviceAppService.findDeviceByCode(startDeviceCode2); + Device nextDevice2 = deviceAppService.findDeviceByCode(nextDeviceCode2); + if (ObjectUtil.isEmpty(startDevice2.getExtraValue().get("address"))) { + throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice2.getDevice_code())); + } + if (ObjectUtil.isEmpty(nextDevice2.getExtraValue().get("address"))) { + throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice2.getDevice_code())); + } + String start_addr2 = startDevice2.getExtraValue().get("address").toString(); + String next_addr2 = nextDevice2.getExtraValue().get("address").toString(); + instdto.setStart_device_code2(startDeviceCode2); + instdto.setNext_device_code2(nextDeviceCode2); + instdto.setStart_point_code2(startDeviceCode2); + instdto.setNext_point_code2(nextDeviceCode2); + map.put("to_onset2", start_addr2); + map.put("to_target2", next_addr2); + } + try { + instructionService.create(instdto); + } catch (Exception e) { + notCreateInstMessage = e.getMessage(); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(LangProcess.msg("universal_message9") + e.getMessage()) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); + return false; + } + //创建指令后修改任务状态 + task.setTask_status(TaskStatusEnum.BUSY.getIndex()); + task.setUpdate_time(DateUtil.now()); + taskserver.update(task); + this.writing(map); this.setRequireSucess(true); notCreateInstMessage = ""; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/ItemProtocol.java index 1d9615135..10b818b6e 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/ItemProtocol.java @@ -38,6 +38,10 @@ public class ItemProtocol { public static String item_to_onset = "to_onset"; //下发目标站 public static String item_to_target = "to_target"; + //下发起始站 + public static String item_to_onset2 = "to_onset2"; + //下发目标站 + public static String item_to_target2 = "to_target2"; //下发任务号 public static String item_to_task = "to_task"; @@ -99,6 +103,14 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_to_target); } + public int getTo_onset2() { + return this.getOpcIntegerValue(item_to_onset2); + } + + public int getTo_target2() { + return this.getOpcIntegerValue(item_to_target2); + } + Boolean isonline; Boolean isError; @@ -149,6 +161,8 @@ public class ItemProtocol { list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); list.add(new ItemDto(item_to_onset, "下发起始站", "DB2.W2")); list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); + list.add(new ItemDto(item_to_onset2, "下发起始站2", "DB2.W3")); + list.add(new ItemDto(item_to_target2, "下发目标站2", "DB2.W5")); list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); return list; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/AcsToLmsApplyTaskTypeEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/AcsToLmsApplyTaskTypeEnum.java index 54f94586f..8b3504e0d 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/AcsToLmsApplyTaskTypeEnum.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/AcsToLmsApplyTaskTypeEnum.java @@ -6,9 +6,13 @@ import lombok.Getter; @Getter @AllArgsConstructor public enum AcsToLmsApplyTaskTypeEnum { - LABEL_BIND("1", "捆轧贴标"), + LABEL_BIND("1", "申请捆轧贴标信息"), + + AGV("2", "AGV任务"), + + LABEL("3", "申请贴标"); + - AGV("2", "AGV任务"); /** * 索引 */ diff --git a/acs2/nladmin-ui/src/views/system/monitor/device/index.vue b/acs2/nladmin-ui/src/views/system/monitor/device/index.vue index a2858741c..717b97213 100644 --- a/acs2/nladmin-ui/src/views/system/monitor/device/index.vue +++ b/acs2/nladmin-ui/src/views/system/monitor/device/index.vue @@ -281,7 +281,7 @@ export default { dialogFormVisible9: false, dialogFormVisible10: false, Stages: [], - stage_code: '', + stage_code: 'stage_code', form: { device_code: '', hasGoodStatus: null,