From 6f603ac7a0c281a00e8830af827055f37df347d3 Mon Sep 17 00:00:00 2001 From: yanps Date: Mon, 15 Jan 2024 13:15:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=88=86=E5=88=87?= =?UTF-8?q?=E8=A1=8C=E6=9E=B6=E4=B8=80=E7=9B=B4=E5=86=99=E4=BF=A1=E5=8F=B7?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...PluggingUnpluggingMachineDeviceDriver.java | 17 +++-- .../basedriver/rgv/RgvDeviceDriver.java | 51 +++++++++++++-- .../SlitTwoManipulatorDeviceDriver.java | 65 ++++++++++--------- .../data/ApplyManipulatorActionRequest.java | 11 +++- .../service/InstructionService.java | 7 ++ .../service/impl/InstructionServiceImpl.java | 11 ++++ .../task/service/impl/TaskServiceImpl.java | 4 +- 7 files changed, 119 insertions(+), 47 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/plugging_unplugging_machine/PluggingUnpluggingMachineDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/plugging_unplugging_machine/PluggingUnpluggingMachineDeviceDriver.java index 794abc16e..95f1b9aed 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/plugging_unplugging_machine/PluggingUnpluggingMachineDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/plugging_unplugging_machine/PluggingUnpluggingMachineDeviceDriver.java @@ -65,12 +65,14 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv int error = 0; int move = 0; int task1 = 0; - // int task2 = 0; + int to_command = 0; + int last_mode = 0; int last_error = 0; int last_move = 0; int last_task1 = 0; - // int last_task2 = 0; + int last_to_command = 0; + Boolean isonline = true; Boolean iserror = false; @@ -101,7 +103,7 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv error = this.itemProtocol.getError(); move = this.itemProtocol.getMove(); task1 = this.itemProtocol.getTask1(); -// task2 = this.itemProtocol.getTask2(); + to_command = this.itemProtocol.getToCommand(); if (mode != last_mode) { this.requireSucess = false; @@ -110,7 +112,12 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv if (move != last_move) { logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); } - + if (task1 != last_task1) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task1 + "->" + task1); + } + if (to_command != last_to_command) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); + } } catch (Exception var17) { logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(var17.getStackTrace())); @@ -164,7 +171,7 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv last_error = error; last_move = move; last_task1 = task1; -// last_task2 = task2; + last_to_command = to_command; } private synchronized void pullingSucess() { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/rgv/RgvDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/rgv/RgvDeviceDriver.java index 92e3fd08d..58985a5d7 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/rgv/RgvDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/rgv/RgvDeviceDriver.java @@ -161,6 +161,11 @@ public class RgvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDr feedbackQty(); } break; + case 5: + if (task > 0 && !requireSucess && (qty1 > 0 || qty2 > 0)) { + manualFeedbackQty(); + } + break; default: break; @@ -176,31 +181,63 @@ public class RgvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDr last_qty2 = qty2; } + private void manualFeedbackQty() { + ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); + ApplyManipulatorActionResponse applyManipulatorActionResponse; + Instruction inst1 = instructionService.findByCode(String.valueOf(task)); + String task_code = inst1.getTask_code(); + applyManipulatorActionRequest.setType("9"); + if (qty1 > 0) { + applyManipulatorActionRequest.setQty1(String.valueOf(qty1)); + } + if (qty2 > 0) { + applyManipulatorActionRequest.setQty2(String.valueOf(qty2)); + } + applyManipulatorActionRequest.setIs_hand("1"); + applyManipulatorActionRequest.setTask_code1(task_code); + 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", 5); + this.writing(map); + } else { + requireSucess = false; + message = "手动完成反馈LMS失败," + applyManipulatorActionResponse.getMessage(); + logServer.deviceExecuteLog(this.device_code, "", "", "手动反馈重量请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + Map map = new LinkedHashMap<>(); + map.put("to_command", 99); + this.writing(map); + } + } + private void feedbackQty() { ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); ApplyManipulatorActionResponse applyManipulatorActionResponse; Instruction inst1 = instructionService.findByCode(String.valueOf(task)); String task_code = inst1.getTask_code(); - applyManipulatorActionRequest.setType("2"); + applyManipulatorActionRequest.setType("9"); if (qty1 > 0) { - applyManipulatorActionRequest.setQty(String.valueOf(qty1)); + applyManipulatorActionRequest.setQty1(String.valueOf(qty1)); } if (qty2 > 0) { - applyManipulatorActionRequest.setQty(String.valueOf(qty2)); + applyManipulatorActionRequest.setQty2(String.valueOf(qty2)); } applyManipulatorActionRequest.setTask_code1(task_code); applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); if (applyManipulatorActionResponse.getstatus() == 200) { requireSucess = true; - message = "反馈LMS成功..."; - logServer.deviceExecuteLog(this.device_code, "", "", "反馈重量请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + message = "自动反馈LMS成功..."; + logServer.deviceExecuteLog(this.device_code, "", "", "自动反馈重量请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); Map map = new LinkedHashMap<>(); map.put("to_command", 4); this.writing(map); } else { requireSucess = false; - message = "完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse); - logServer.deviceExecuteLog(this.device_code, "", "", "反馈重量请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + message = "自动完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "自动反馈重量请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); Map map = new LinkedHashMap<>(); map.put("to_command", 99); this.writing(map); 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 fc783a738..72d07ed55 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 @@ -287,8 +287,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl param.put("product_area", paramService.findByCode("productArea").getValue()); acsToWmsService.sendDeviceStatus(param); - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); + /*logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);*/ } if (status != last_status) { logServer.deviceItemValue(this.device_code, "status", String.valueOf(status)); @@ -310,10 +310,10 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl logServer.deviceItemValue(this.device_code, "action2", String.valueOf(action2)); logServer.deviceExecuteLog(this.device_code, "", "", "信号action2:" + last_action2 + "->" + action2); } - if (walk_y != last_walk_y) { + /*if (walk_y != last_walk_y) { logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); - } + }*/ if (task1 != last_task1) { logServer.deviceItemValue(this.device_code, "task1", String.valueOf(task1)); logServer.deviceExecuteLog(this.device_code, "", "", "信号task1:" + last_task1 + "->" + task1); @@ -322,14 +322,14 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl logServer.deviceItemValue(this.device_code, "task2", String.valueOf(task2)); logServer.deviceExecuteLog(this.device_code, "", "", "信号task2:" + last_task2 + "->" + task2); } - if (x_position != last_x_position) { + /*if (x_position != last_x_position) { logServer.deviceItemValue(this.device_code, "x_position", String.valueOf(x_position)); logServer.deviceExecuteLog(this.device_code, "", "", "信号x_position:" + last_x_position + "->" + x_position); - } - if (y_position != last_y_position) { + }*/ + /*if (y_position != last_y_position) { logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position)); logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position:" + last_y_position + "->" + y_position); - } + }*/ update_instruction_status(); @@ -446,6 +446,7 @@ 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) { @@ -517,9 +518,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //按照优先级排序 优先级相等按照创建时间排序 taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); - if(getDeviceCode.endsWith("X")){ - Boolean result = this.checkIsSafe(getDeviceCode,taskDto); - if(!result){ + if (getDeviceCode.endsWith("X")) { + Boolean result = this.checkIsSafe(getDeviceCode, taskDto); + if (!result) { taskDto = null; notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; continue; @@ -539,9 +540,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //按照优先级排序 优先级相等按照创建时间排序 taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); - if(backGetDeviceCode.endsWith("X")){ - Boolean result = this.checkIsSafe(backGetDeviceCode,taskDto); - if(!result){ + if (backGetDeviceCode.endsWith("X")) { + Boolean result = this.checkIsSafe(backGetDeviceCode, taskDto); + if (!result) { taskDto = null; notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; continue; @@ -556,9 +557,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //按照优先级排序 优先级相等按照创建时间排序 taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); - if(backGetDeviceCode.endsWith("X")){ - Boolean result = this.checkIsSafe(backGetDeviceCode,taskDto); - if(!result){ + if (backGetDeviceCode.endsWith("X")) { + Boolean result = this.checkIsSafe(backGetDeviceCode, taskDto); + if (!result) { taskDto = null; notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; continue; @@ -605,9 +606,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //按照优先级排序 优先级相等按照创建时间排序 taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); - if(getDeviceCode.endsWith("X")){ - Boolean result = this.checkIsSafe(getDeviceCode,taskDto); - if(!result){ + if (getDeviceCode.endsWith("X")) { + Boolean result = this.checkIsSafe(getDeviceCode, taskDto); + if (!result) { taskDto = null; notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; continue; @@ -622,9 +623,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //按照优先级排序 优先级相等按照创建时间排序 taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); - if(getDeviceCode.endsWith("X")){ - Boolean result = this.checkIsSafe(getDeviceCode,taskDto); - if(!result){ + if (getDeviceCode.endsWith("X")) { + Boolean result = this.checkIsSafe(getDeviceCode, taskDto); + if (!result) { taskDto = null; notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; continue; @@ -644,9 +645,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //按照优先级排序 优先级相等按照创建时间排序 taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); - if(backGetDeviceCode.endsWith("X")){ - Boolean result = this.checkIsSafe(backGetDeviceCode,taskDto); - if(!result){ + if (backGetDeviceCode.endsWith("X")) { + Boolean result = this.checkIsSafe(backGetDeviceCode, taskDto); + if (!result) { taskDto = null; notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; continue; @@ -661,9 +662,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //按照优先级排序 优先级相等按照创建时间排序 taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); - if(backGetDeviceCode.endsWith("X")){ - Boolean result = this.checkIsSafe(backGetDeviceCode,taskDto); - if(!result){ + if (backGetDeviceCode.endsWith("X")) { + Boolean result = this.checkIsSafe(backGetDeviceCode, taskDto); + if (!result) { taskDto = null; notCreateInstMessage = "该设备存在上工位任务,此任务无法执行!"; continue; @@ -1731,16 +1732,16 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl } } - public boolean checkIsSafe(String device_code,TaskDto dto){ + public boolean checkIsSafe(String device_code, TaskDto dto) { String newDevice_code = forametDevice_code(device_code); List list = taskserver.queryTaskByDeviceCode(newDevice_code); - if(list.size()>0){ + if (list.size() > 0) { return false; } return true; } - public String forametDevice_code(String device_code){ + public String forametDevice_code(String device_code) { if (device_code.endsWith("X")) { return device_code.substring(0, device_code.length() - 1) + "S"; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionRequest.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionRequest.java index 18cf94a85..13a342c3d 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionRequest.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionRequest.java @@ -39,7 +39,16 @@ public class ApplyManipulatorActionRequest extends BaseRequest { /** * 重量 */ - private String qty; + private String qty1; + /** + * 重量 + */ + private String qty2; + + /** + * 手动 + */ + private String is_hand; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java index de0237145..2ba804f3e 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java @@ -95,6 +95,13 @@ public interface InstructionService { Instruction findByTaskcodeAndStatus(String code); + /** + * 根据任务号查询缓存中的指令 + * @param code + * @return + */ + Instruction findByTaskcodeCache(String code); + Instruction findByTaskcodeAndStatus(String code,String status); /** diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 0a85edbe4..ecb833cfc 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -279,6 +279,17 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu return null; } + public Instruction findByTaskcodeCache(String code) { + Iterator var3 = instructions.iterator(); + while (var3.hasNext()) { + Instruction instruction = (Instruction) var3.next(); + if (StrUtil.equals(instruction.getTask_code(), code)) { + return instruction; + } + } + return null; + } + @Override public Instruction findByTaskcodeAndStatus(String code,String status) { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 7bca1d530..62229877c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -344,8 +344,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { continue; } if ((task.getStart_device_code().equals(start_device_code) - || (StrUtil.isNotEmpty(task.getStart_device_code2()) && task.getStart_device_code2().equals(start_device_code)) - && StrUtil.equals(task.getTask_status(), "0"))) { + || (StrUtil.isNotEmpty(task.getStart_device_code2()) && task.getStart_device_code2().equals(start_device_code))) + && StrUtil.equals(task.getTask_status(), "0")) { list.add(task); } }