From cf5625b9f9e4db700d2a8e7330ad0358bc44eb1a Mon Sep 17 00:00:00 2001 From: pangshenghao Date: Wed, 14 Jun 2023 10:37:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8F=96=E6=B6=88=E5=90=8E?= =?UTF-8?q?=E8=B5=B7=E7=82=B9=E5=BA=93=E5=AD=98=E5=8F=98=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StandardInspectSiteDeviceDriver.java | 27 +++++++----- .../service/impl/InstructionServiceImpl.java | 44 +++++++++---------- .../org/nl/acs/task/service/TaskService.java | 5 +++ .../task/service/impl/TaskServiceImpl.java | 13 ++++++ .../auto/run/NDCSocketConnectionAutoRun.java | 10 +---- 5 files changed, 59 insertions(+), 40 deletions(-) diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java index 232c566..922b72f 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java @@ -489,13 +489,17 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp return false; } else { this.instruction_require_time = date; - TaskDto task = taskserver.findByNextCode(this.devicecode); + List taskList = taskserver.queryTaskByNextDeviceCode(this.devicecode); try { - Instruction inst = instructionService.findByTaskCodeFromCache(task.getTask_code()); - if (ObjectUtil.isNotEmpty(inst)) { - instructionService.cancel(inst.getInstruction_id()); + if (taskList.size() != 0) { + for (TaskDto task : taskList) { + Instruction inst = instructionService.findByTaskCodeFromCache(task.getTask_code()); + if (ObjectUtil.isNotEmpty(inst)) { + instructionService.cancel(inst.getInstruction_id()); + } + taskserver.cancel(task.getTask_id()); + } } - taskserver.cancel(task.getTask_id()); } catch (Exception e) { e.printStackTrace(); } @@ -639,11 +643,11 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp Device route_link_device = deviceAppservice.findDeviceByCode(start_device_code); //判断终点设备驱动是否为检测站点驱动 if (route_link_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { -// standardInspectSiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) route_link_device.getDeviceDriver(); -// //判断该终点设备是否无货,无货就结束循环 -// if (standardInspectSiteDeviceDriver.getHasGoods() == 0) { -// continue; -// } + standardInspectSiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) route_link_device.getDeviceDriver(); +// //判断该起点设备是否无货,无货就结束循环 + if (standardInspectSiteDeviceDriver.getHasGoods() == 0) { + continue; + } //判断是否已经有该起点设备的任务,如果有就结束循环 int num1 = taskserver.querySameOriginTask(start_device_code); @@ -712,6 +716,9 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp inrequireSucess = true; this.execute_log.log("设备:" + devicecode + "", "", "对应路由设备,生成任务成功已锁定"); + } else { + message = "当前站点所有路由都为无货状态"; + writing(7); } return true; } diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 1d5eacc..1a577f0 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -970,30 +970,30 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu JSONObject json = JSONObject.fromObject(entity); wo.update(json); DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); +// DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); // 如果是无光电的设备 指令完成变更起点、终点状态 - JSONObject jo = new JSONObject(); - jo.put("device_code", entity.getStart_device_code()); - if (StrUtil.equals(entity.getMaterial(), "1")) { - jo.put("hasGoodStatus", "1"); - } else if (!StrUtil.equals(entity.getMaterial(), "1") && !StrUtil.isEmpty(entity.getMaterial())) { - jo.put("hasGoodStatus", "2"); - } else { - jo.put("hasGoodStatus", "0"); - } - jo.put("material_type", entity.getMaterial()); - jo.put("batch", entity.getBatch()); - jo.put("islock", "false"); - deviceService.changeDeviceStatus(jo); - - JSONObject jo1 = new JSONObject(); - jo1.put("device_code", entity.getNext_device_code()); - jo.put("hasGoodStatus", "0"); - jo.put("material_type", ""); - jo.put("batch", ""); - jo1.put("islock", "false"); - deviceService.changeDeviceStatus(jo1); +// JSONObject jo = new JSONObject(); +// jo.put("device_code", entity.getStart_device_code()); +// if (StrUtil.equals(entity.getMaterial(), "1")) { +// jo.put("hasGoodStatus", "1"); +// } else if (!StrUtil.equals(entity.getMaterial(), "1") && !StrUtil.isEmpty(entity.getMaterial())) { +// jo.put("hasGoodStatus", "2"); +// } else { +// jo.put("hasGoodStatus", "0"); +// } +// jo.put("material_type", entity.getMaterial()); +// jo.put("batch", entity.getBatch()); +// jo.put("islock", "false"); +// deviceService.changeDeviceStatus(jo); +// +// JSONObject jo1 = new JSONObject(); +// jo1.put("device_code", entity.getNext_device_code()); +// jo.put("hasGoodStatus", "0"); +// jo.put("material_type", ""); +// jo.put("batch", ""); +// jo1.put("islock", "false"); +// deviceService.changeDeviceStatus(jo1); String instnextdevice = entity.getNext_device_code(); Device device = appService.findDeviceByCode(instnextdevice); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java index cb20fd5..b7d9f06 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java @@ -115,6 +115,11 @@ public interface TaskService { */ List queryTaskByDeviceCode(String device_code); + /** + * 根据设备号查询未执行的任务 + */ + List queryTaskByNextDeviceCode(String device_code); + /** * 创建 * diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index f6513d9..53cafae 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -421,6 +421,19 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { return list; } + @Override + public List queryTaskByNextDeviceCode(String device_code) { + List list = new ArrayList<>(); + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if (task.getNext_device_code().equals(device_code)) { + list.add(task); + } + } + return list; + } + @Override public List queryByStauts(String status) { WQLObject wo = WQLObject.getWQLObject("acs_task"); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java b/acs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java index 7e899e0..101afde 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java @@ -633,20 +633,14 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { } //请求删除任务 else if (phase == 0x30) { - flag = true; - if (!ObjectUtil.isEmpty(inst)) { - data = AgvService.sendAgvOneModeInst(0x8F, index, 0); - } else { - log.info("未找到对应的指令无法删除"); - break; - } + data = AgvService.sendAgvOneModeInst(0x8F, index, 0); } //任务删除确认 //(需要WCS反馈) else if (phase == 0xFF) { flag = true; if (!ObjectUtil.isEmpty(inst)) { - instructionService.cancel(inst.getInstruction_id()); + instructionService.cancelNOSendAgv(inst.getInstruction_id()); } data = AgvService.sendAgvOneModeInst(phase, index, 0); }