From bf368ec156a331c48022fe6bdc273452bd86cde6 Mon Sep 17 00:00:00 2001 From: lishuai <1793460677@qq.com> Date: Thu, 1 Feb 2024 16:37:50 +0800 Subject: [PATCH] =?UTF-8?q?fix=20:=20=E7=94=B3=E8=AF=B7=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=85=88=E6=89=BE=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../task/service/impl/TaskServiceImpl.java | 7 - .../BeltConveyorDeviceDriver.java | 8 +- .../DoubleBeltConveyorDeviceDriver.java | 3 +- .../BoxStorageOutConveyorDeviceDriver.java | 6 +- .../BoxSubvolumesConveyorDeviceDriver.java | 40 +-- ...nishedProductOutBindLableDeviceDriver.java | 3 +- ...ConveyorWithScannerWeightDeviceDriver.java | 3 +- .../UnBoxLableConveyorDeviceDriver.java | 3 +- .../BoxPackageManipulatorDeviceDriver.java | 238 ++++++++------ .../BoxStorageManipulatorDeviceDriver.java | 292 ++++++++++-------- .../ReturnGoodManipulatorDeviceDriver.java | 256 +++++++++------ ...pedManipulatorManipulatorDeviceDriver.java | 257 +++++++++------ ...TwoManipulatorManipulatorDeviceDriver.java | 249 +++++++++------ .../PaperTubeConveyor2DeviceDriver.java | 2 +- .../StandardStackerDeviceDriver.java | 112 +++++-- .../SlitTwoManipulatorDeviceDriver.java | 3 +- .../org/nl/acs/enums/RequestSucessEnum.java | 20 ++ .../org/nl/acs/task/service/TaskService.java | 7 + .../task/service/impl/TaskServiceImpl.java | 28 ++ .../main/resources/config/application-dev.yml | 5 +- .../src/views/acs/monitor/device/index.vue | 5 +- .../src/views/system/monitor/device/index.vue | 38 ++- 22 files changed, 972 insertions(+), 613 deletions(-) create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/RequestSucessEnum.java 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 1504c8294..34740dbfd 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 @@ -443,13 +443,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { } } else { if (StrUtil.equals(task.getTask_type(), "9") && StrUtil.isNotEmpty(task.getPut_device_code())) { -// if(task.getNext_device_code().equals(device_code) -// && StrUtil.equals(task.getTask_status(), "1")){ -// Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code()); -// if (ObjectUtil.isNotEmpty(instruction)) { -// list.add(task); -// } -// } Instruction instruction = instructionService.findByDeviceCodeFromCache(task.getNext_device_code()); if (ObjectUtil.isNotEmpty(instruction)) { if (StrUtil.equals(instruction.getStart_device_code(), device_code)) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java index db13c6e8b..f9b0b526f 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java @@ -747,6 +747,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements jo.put("inventory_qty", inventory_qty); jo.put("out_finish", out_finish); jo.put("material", material); + jo.put("is_click", true); jo.put("isOnline", this.getIsonline()); return jo; @@ -822,7 +823,12 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements @Override public void setDeviceStatus(JSONObject data) { - + String requestSucess = data.getString("requireSucess"); + if (StrUtil.equals(requestSucess, "0")) { + this.requireSucess = false; + } else if (StrUtil.equals(requestSucess, "1")) { + this.requireSucess = true; + } } public static boolean arrayEquals(int[] a, int[] b) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_belt_conveyor/DoubleBeltConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_belt_conveyor/DoubleBeltConveyorDeviceDriver.java index d9116a778..bcec9130a 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_belt_conveyor/DoubleBeltConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_belt_conveyor/DoubleBeltConveyorDeviceDriver.java @@ -27,6 +27,7 @@ import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.dto.RouteLineDto; +import org.nl.acs.task.enums.TaskStatusEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.config.SpringContextHolder; @@ -494,7 +495,7 @@ public class DoubleBeltConveyorDeviceDriver extends AbstractOpcDeviceDriver impl log.error("指令创建失败!", e.getMessage()); return false; } - taskdto.setTask_status("1"); + taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); taskserver.update(taskdto); requireSucess = true; Map map = new LinkedHashMap<>(); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java index 904130d24..cb3ccc486 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java @@ -30,6 +30,7 @@ import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.dto.RouteLineDto; +import org.nl.acs.task.enums.TaskStatusEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.config.SpringContextHolder; @@ -172,8 +173,7 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i heartbeat = this.itemProtocol.getHeartbeat(); - - if (move != 0 && task > 0) { + if (move != 0 && task > 0) { update_instruction_status(); } @@ -421,7 +421,7 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i return false; } //创建指令后修改任务状态 - taskdto.setTask_status("1"); + taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); taskserver.update(taskdto); requireSucess = true; String next_addr = nextdevice.getExtraValue().get("address").toString(); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java index 4fcb21da1..eb0c4f787 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java @@ -28,6 +28,7 @@ import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.dto.RouteLineDto; +import org.nl.acs.task.enums.TaskStatusEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.config.SpringContextHolder; @@ -169,47 +170,12 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i to_task = this.itemProtocol.getTo_task(); heartbeat = this.itemProtocol.getHeartbeat(); material_barcode = this.itemProtocol.getMaterialBarCode(); - - - - if (to_length != last_to_length) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_length:" + last_to_length + "->" + to_length); - } - if (to_weight != last_to_weight) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_weight:" + last_to_weight + "->" + to_weight); - } - if (to_height != last_to_height) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_height:" + last_to_height + "->" + to_height); - } - if (to_command != last_to_command) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); - } - if (to_target != last_to_target) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); - } - if (to_task != last_to_task) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); - } - if (mode != last_mode) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记:" + requireSucess); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - - if (carrier_direction != last_carrier_direction) { - logServer.deviceItemValue(this.device_code, "carrier_direction", String.valueOf(carrier_direction)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号carrier_direction:" + last_carrier_direction + "->" + carrier_direction); - } - if (error != last_error) { - - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } + // 更新指令状态 if (move != 0 && task > 0) { update_instruction_status(); } - } catch (Exception var17) { var17.printStackTrace(); logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); @@ -531,7 +497,7 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i return false; } //创建指令后修改任务状态 - taskdto.setTask_status("1"); + taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); taskserver.update(taskdto); requireSucess = true; String next_addr = nextdevice.getExtraValue().get("address").toString(); 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 9159cdb3d..393693a31 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 @@ -34,6 +34,7 @@ import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.dto.RouteLineDto; import org.nl.acs.storage_cell.domain.StorageCell; import org.nl.acs.storage_cell.service.mapper.StorageCellMapper; +import org.nl.acs.task.enums.TaskStatusEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.config.SpringContextHolder; @@ -638,7 +639,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr return false; } //创建指令后修改任务状态 - taskdto.setTask_status("1"); + taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); taskserver.update(taskdto); requireSucess = true; String next_addr = nextdevice.getExtraValue().get("address").toString(); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java index b939ac8ef..ccdf499c0 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java @@ -35,6 +35,7 @@ import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.dto.RouteLineDto; import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.enums.TaskStatusEnum; import org.nl.acs.task.enums.TaskTypeEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; @@ -409,7 +410,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv Device nextdevice = deviceAppservice.findDeviceByCode(taskdto.getNext_device_code()); //创建指令后修改任务状态 - taskdto.setTask_status("1"); + taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); taskserver.update(taskdto); String next_addr = nextdevice.getExtraValue().get("address").toString(); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java index 27ae88f9a..c67e6aff5 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java @@ -31,6 +31,7 @@ import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.dto.RouteLineDto; +import org.nl.acs.task.enums.TaskStatusEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.config.SpringContextHolder; @@ -519,7 +520,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl return false; } //创建指令后修改任务状态 - taskdto.setTask_status("1"); + taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); taskserver.update(taskdto); requireSucess = true; String next_addr = nextdevice.getExtraValue().get("address").toString(); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/BoxPackageManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/BoxPackageManipulatorDeviceDriver.java index 76cee61c0..602435f47 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/BoxPackageManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/BoxPackageManipulatorDeviceDriver.java @@ -1,5 +1,6 @@ package org.nl.acs.device_driver.one_manipulator.box_package_manipulator; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; @@ -30,9 +31,11 @@ import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.enums.TaskStatusEnum; import org.nl.acs.task.enums.TaskTypeEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; +import org.nl.common.exception.BadRequestException; import org.nl.config.SpringContextHolder; import java.util.*; @@ -319,101 +322,103 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i //找终点为入库输送线工位任务类型为行架的任务 for (int i = 0; i < getDeviceCodeList.size(); i++) { String startDeviceCode = getDeviceCodeList.get(i); - TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) { - String interactionJson = taskDto.getInteraction_json(); - InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); - String start_device_code = taskDto.getStart_device_code(); - String next_device_code = taskDto.getNext_device_code(); - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - String start_addr = startDevice.getExtraValue().get("address").toString(); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - String taskid = taskDto.getTask_id(); - String taskcode = taskDto.getTask_code(); - String start_point_code = taskDto.getStart_point_code(); - String route_plan_code = taskDto.getRoute_plan_code(); - String next_point_code = taskDto.getNext_point_code(); - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(device_code); + //先查指令 + List taskDtoInstruction = taskserver.queryTaskByDeviceCodeAndStatus2(startDeviceCode); + if (CollUtil.isNotEmpty(taskDtoInstruction)){ + TaskDto taskDtoIns = taskDtoInstruction.get(0); + if (TaskTypeEnum.Truss_Task.getIndex().equals(taskDtoIns.getTask_type())) { + Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDtoIns.getTask_code()); + String interactionJson = taskDtoIns.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String start_device_code = taskDtoIns.getStart_device_code(); + String next_device_code = taskDtoIns.getNext_device_code(); + Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + if (ObjectUtil.isEmpty(start_addr)) { + throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); + } + if (ObjectUtil.isEmpty(next_addr)) { + throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); + } + Map map1 = new HashMap<>(); + Map map2 = new HashMap<>(); + Map map3 = new HashMap<>(); + Map map4 = new HashMap<>(); + Map map5 = new HashMap<>(); + Map map6 = new HashMap<>(); + Map map7 = new HashMap<>(); + Map map8 = new HashMap<>(); + try { + pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8); + } catch (Exception e) { - try { - instructionService.create(instdto); - } catch (Exception e) { - notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); - return false; + logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + + instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code() + + ",指令终点:" + instruction.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); + } + this.setRequireSucess(true); + return true; } - //创建指令后修改任务状态 - taskDto.setTask_status("1"); - taskserver.update(taskDto); - requireSucess = true; + }else { + TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode); + if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) { + String interactionJson = taskDto.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String start_device_code = taskDto.getStart_device_code(); + String next_device_code = taskDto.getNext_device_code(); + Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + if (ObjectUtil.isEmpty(start_addr)) { + throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); + } + if (ObjectUtil.isEmpty(next_addr)) { + throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); + } - Map map1 = new HashMap<>(); - List list = new ArrayList(); - map1.put("code", "to_command"); - map1.put("value", 1); - list.add(map1); - Map map2 = new HashMap<>(); - map2.put("code", "to_target"); - map2.put("value", next_addr); - list.add(map2); - Map map3 = new HashMap<>(); - map3.put("code", "to_onset"); - map3.put("value", start_addr); - list.add(map3); - Map map4 = new HashMap<>(); - map4.put("code", "to_task"); - map4.put("value", instdto.getInstruction_code()); - list.add(map4); - if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getSeq())) { - Map map5 = new HashMap<>(); - map5.put("code", "to_seq"); - map5.put("value", interactionJsonDTO.getSeq()); - list.add(map5); - } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLastOne())) { - Map map6 = new HashMap<>(); - map6.put("code", "to_last_one"); - map6.put("value", interactionJsonDTO.getLastOne()); - list.add(map6); - } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getDirection())) { - Map map7 = new HashMap<>(); - map7.put("code", "to_direction"); - map7.put("value", interactionJsonDTO.getDirection()); - list.add(map7); - } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getMaxNo())) { - Map map8 = new HashMap<>(); - map8.put("code", "to_max_no"); - map8.put("value", interactionJsonDTO.getMaxNo()); - list.add(map8); - } - } + String taskid = taskDto.getTask_id(); + String taskcode = taskDto.getTask_code(); + String start_point_code = taskDto.getStart_point_code(); + String route_plan_code = taskDto.getRoute_plan_code(); + String next_point_code = taskDto.getNext_point_code(); + Instruction instdto = new Instruction(); + packageData(instdto, route_plan_code, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code); - try { - this.writing(list); - } catch (Exception e) { - logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" - + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() - + ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); + try { + instructionService.create(instdto); + } catch (Exception e) { + notCreateInstMessage = e.getMessage(); + logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); + return false; + } + //创建指令后修改任务状态 + taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskserver.update(taskDto); + requireSucess = true; + + Map map1 = new HashMap<>(); + Map map2 = new HashMap<>(); + Map map3 = new HashMap<>(); + Map map4 = new HashMap<>(); + Map map5 = new HashMap<>(); + Map map6 = new HashMap<>(); + Map map7 = new HashMap<>(); + Map map8 = new HashMap<>(); + try { + pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8); + } catch (Exception e) { + logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() + + ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); + } + this.setRequireSucess(true); + return true; + } else { + notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; } - this.setRequireSucess(true); - return true; - }else{ - notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; } } return true; @@ -421,6 +426,59 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i } + private void pushPLC(Map map1, Map map2, String next_addr, Map map3, String start_addr, Map map4, String task, InteractionJsonDTO interactionJsonDTO, Map map5, Map map6, Map map7, Map map8) { + List list = new ArrayList(); + map1.put("code", "to_command"); + map1.put("value", 1); + list.add(map1); + map2.put("code", "to_target"); + map2.put("value", next_addr); + list.add(map2); + map3.put("code", "to_onset"); + map3.put("value", start_addr); + list.add(map3); + map4.put("code", "to_task"); + map4.put("value", task); + list.add(map4); + if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getSeq())) { + map5.put("code", "to_seq"); + map5.put("value", interactionJsonDTO.getSeq()); + list.add(map5); + } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLastOne())) { + map6.put("code", "to_last_one"); + map6.put("value", interactionJsonDTO.getLastOne()); + list.add(map6); + } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getDirection())) { + map7.put("code", "to_direction"); + map7.put("value", interactionJsonDTO.getDirection()); + list.add(map7); + } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getMaxNo())) { + map8.put("code", "to_max_no"); + map8.put("value", interactionJsonDTO.getMaxNo()); + list.add(map8); + } + } + this.writing(list); + } + + private void packageData(Instruction instdto, String route_plan_code, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code) { + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(route_plan_code); + instdto.setTask_id(taskid); + instdto.setTask_code(taskcode); + instdto.setCreate_by("auto"); + instdto.setStart_device_code(start_device_code); + instdto.setNext_device_code(next_device_code); + instdto.setStart_point_code(start_point_code); + instdto.setNext_point_code(next_point_code); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(device_code); + } + public synchronized boolean finish_instruction(Instruction inst) throws Exception { instructionService.finish(inst); return true; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java index 52c86bc27..ed13d1187 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java @@ -1,5 +1,6 @@ package org.nl.acs.device_driver.one_manipulator.box_storage_manipulator; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; @@ -31,10 +32,14 @@ import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.enums.TaskStatusEnum; import org.nl.acs.task.enums.TaskTypeEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; +import org.nl.common.exception.BadRequestException; import org.nl.config.SpringContextHolder; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; import java.util.*; @@ -61,37 +66,21 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - + LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); int mode = 0; - int last_mode = 0; int move = 0; - int last_move = 0; int action = 0; - int last_action = 0; int error = 0; - int last_error = 0; int task = 0; - int last_task = 0; - - int heartbeat = 0; - int last_heartbeat = 0; int to_command = 0; - int last_to_command = 0; - int to_target = 0; - int last_to_target = 0; - int to_onset = 0; - int last_to_onset = 0; int to_task = 0; - int last_to_task = 0; int to_layer = 0; - int last_to_layer = 0; String to_barcode = null; - String last_to_barcode = null; Boolean isonline = true; int hasGoods = 0; @@ -161,7 +150,11 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i } } catch (Exception e) { - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(e.getStackTrace())); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("读取信号值时出现异常" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + Arrays.toString(e.getStackTrace())) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); } @@ -209,17 +202,6 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i } } - last_mode = mode; - last_move = move; - last_action = action; - last_error = error; - last_task = task; - last_heartbeat = heartbeat; - last_to_task = to_task; - last_to_command = to_command; - last_to_target = to_target; - last_to_layer = to_layer; - last_to_barcode = to_barcode; } @@ -299,110 +281,104 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i //找终点为入库输送线工位任务类型为行架的任务 for (int i = 0; i < getDeviceCodeList.size(); i++) { String startDeviceCode = getDeviceCodeList.get(i); - TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) { - String interactionJson = taskDto.getInteraction_json(); - InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); - String start_device_code = taskDto.getStart_device_code(); - String next_device_code = taskDto.getNext_device_code(); - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - String start_addr = startDevice.getExtraValue().get("address").toString(); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - String taskid = taskDto.getTask_id(); - String taskcode = taskDto.getTask_code(); - String start_point_code = taskDto.getStart_point_code(); - String route_plan_code = taskDto.getRoute_plan_code(); - String next_point_code = taskDto.getNext_point_code(); - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(device_code); - - try { - instructionService.create(instdto); - } catch (Exception e) { - notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); - return false; + //先查指令 + List taskDtoInstruction = taskserver.queryTaskByDeviceCodeAndStatus2(startDeviceCode); + if (CollUtil.isNotEmpty(taskDtoInstruction)) { + TaskDto taskDtoIns = taskDtoInstruction.get(0); + if (TaskTypeEnum.Truss_Task.getIndex().equals(taskDtoIns.getTask_type())) { + Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDtoIns.getTask_code()); + String interactionJson = taskDtoIns.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String start_device_code = taskDtoIns.getStart_device_code(); + String next_device_code = taskDtoIns.getNext_device_code(); + Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + if (ObjectUtil.isEmpty(start_addr)) { + throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); + } + if (ObjectUtil.isEmpty(next_addr)) { + throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); + } + Map map1 = new HashMap<>(); + Map map2 = new HashMap<>(); + Map map3 = new HashMap<>(); + Map map4 = new HashMap<>(); + Map map5 = new HashMap<>(); + Map map6 = new HashMap<>(); + Map map7 = new HashMap<>(); + Map map8 = new HashMap<>(); + Map map9 = new HashMap<>(); + try { + pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9); + } catch (Exception e) { + logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + + instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code() + + ",指令终点:" + instruction.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); + } + this.setRequireSucess(true); + return true; } - logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" - + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() - + ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO); - //创建指令后修改任务状态 - taskDto.setTask_status("1"); - taskserver.update(taskDto); - requireSucess = true; + } else { + TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode); + if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) { + String interactionJson = taskDto.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String start_device_code = taskDto.getStart_device_code(); + String next_device_code = taskDto.getNext_device_code(); + Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + if (ObjectUtil.isEmpty(start_addr)) { + throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); + } + if (ObjectUtil.isEmpty(next_addr)) { + throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); + } - Map map1 = new HashMap<>(); - List list = new ArrayList(); - map1.put("code", "to_command"); - map1.put("value", 1); - list.add(map1); - Map map2 = new HashMap<>(); - map2.put("code", "to_target"); - map2.put("value", next_addr); - list.add(map2); - Map map3 = new HashMap<>(); - map3.put("code", "to_onset"); - map3.put("value", start_addr); - list.add(map3); - Map map4 = new HashMap<>(); - map4.put("code", "to_task"); - map4.put("value", instdto.getInstruction_code()); - list.add(map4); - if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getWeight())) { - Map map5 = new HashMap<>(); - map5.put("code", "to_weight"); - map5.put("value", interactionJsonDTO.getWeight()); - list.add(map5); - } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLength())) { - Map map6 = new HashMap<>(); - map6.put("code", "to_length"); - map6.put("value", interactionJsonDTO.getLength()); - list.add(map6); - } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getHeight())) { - Map map7 = new HashMap<>(); - map7.put("code", "to_height"); - map7.put("value", interactionJsonDTO.getHeight()); - list.add(map7); - } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getBarcode())) { - Map map8 = new HashMap<>(); - map8.put("code", "to_barcode"); - map8.put("value", interactionJsonDTO.getBarcode()); - list.add(map8); - } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLayer())) { - Map map9 = new HashMap<>(); - map9.put("code", "to_layer"); - map9.put("value", interactionJsonDTO.getLayer()); - list.add(map9); - } - } + String taskid = taskDto.getTask_id(); + String taskcode = taskDto.getTask_code(); + String start_point_code = taskDto.getStart_point_code(); + String route_plan_code = taskDto.getRoute_plan_code(); + String next_point_code = taskDto.getNext_point_code(); + Instruction instdto = new Instruction(); + packageData(instdto, route_plan_code, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code); - try { - this.writing(list); - } catch (Exception e) { - logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" - + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() - + ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); + try { + instructionService.create(instdto); + } catch (Exception e) { + notCreateInstMessage = e.getMessage(); + logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); + return false; + } + //创建指令后修改任务状态 + taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskserver.update(taskDto); + requireSucess = true; + + Map map1 = new HashMap<>(); + Map map2 = new HashMap<>(); + Map map3 = new HashMap<>(); + Map map4 = new HashMap<>(); + Map map5 = new HashMap<>(); + Map map6 = new HashMap<>(); + Map map7 = new HashMap<>(); + Map map8 = new HashMap<>(); + Map map9 = new HashMap<>(); + try { + pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9); + } catch (Exception e) { + logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() + + ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); + } + this.setRequireSucess(true); + return true; + } else { + notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; } - this.setRequireSucess(true); - return true; - }else{ - notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; } } return true; @@ -410,6 +386,64 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i } + private void pushPLC(Map map1, Map map2, String next_addr, Map map3, String start_addr, Map map4, String task, InteractionJsonDTO interactionJsonDTO, Map map5, Map map6, Map map7, Map map8, Map map9) { + + List list = new ArrayList(); + map1.put("code", "to_command"); + map1.put("value", 1); + list.add(map1); + map2.put("code", "to_target"); + map2.put("value", next_addr); + list.add(map2); + map3.put("code", "to_onset"); + map3.put("value", start_addr); + list.add(map3); + map4.put("code", "to_task"); + map4.put("value", task); + list.add(map4); + if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getWeight())) { + map5.put("code", "to_weight"); + map5.put("value", interactionJsonDTO.getWeight()); + list.add(map5); + } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLength())) { + map6.put("code", "to_length"); + map6.put("value", interactionJsonDTO.getLength()); + list.add(map6); + } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getHeight())) { + map7.put("code", "to_height"); + map7.put("value", interactionJsonDTO.getHeight()); + list.add(map7); + } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getBarcode())) { + map8.put("code", "to_barcode"); + map8.put("value", interactionJsonDTO.getBarcode()); + list.add(map8); + } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLayer())) { + map9.put("code", "to_layer"); + map9.put("value", interactionJsonDTO.getLayer()); + list.add(map9); + } + } + this.writing(list); + } + + private void packageData(Instruction instdto, String route_plan_code, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code) { + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(route_plan_code); + instdto.setTask_id(taskid); + instdto.setTask_code(taskcode); + instdto.setCreate_by("auto"); + instdto.setStart_device_code(start_device_code); + instdto.setNext_device_code(next_device_code); + instdto.setStart_point_code(start_point_code); + instdto.setNext_point_code(next_point_code); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(device_code); + } public void writing(List list) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ReturnGoodManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ReturnGoodManipulatorDeviceDriver.java index 7e0cb7383..e7fc8f369 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ReturnGoodManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ReturnGoodManipulatorDeviceDriver.java @@ -1,5 +1,6 @@ package org.nl.acs.device_driver.one_manipulator.return_good_manipulator; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; @@ -32,9 +33,11 @@ import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.enums.TaskStatusEnum; import org.nl.acs.task.enums.TaskTypeEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; +import org.nl.common.exception.BadRequestException; import org.nl.config.SpringContextHolder; import java.util.*; @@ -296,116 +299,169 @@ public class ReturnGoodManipulatorDeviceDriver extends AbstractOpcDeviceDriver i //找终点为入库输送线工位任务类型为行架的任务 for (int i = 0; i < getDeviceCodeList.size(); i++) { String startDeviceCode = getDeviceCodeList.get(i); - TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) { - String interactionJson = taskDto.getInteraction_json(); - InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); - String start_device_code = taskDto.getStart_device_code(); - String next_device_code = taskDto.getNext_device_code(); - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - String start_addr = startDevice.getExtraValue().get("address").toString(); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - String taskid = taskDto.getTask_id(); - String taskcode = taskDto.getTask_code(); - String start_point_code = taskDto.getStart_point_code(); - String route_plan_code = taskDto.getRoute_plan_code(); - String next_point_code = taskDto.getNext_point_code(); - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(device_code); - - try { - instructionService.create(instdto); - } catch (Exception e) { - notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); - return false; + //先查指令 + List taskDtoInstruction = taskserver.queryTaskByDeviceCodeAndStatus2(startDeviceCode); + if (CollUtil.isNotEmpty(taskDtoInstruction)) { + TaskDto taskDtoIns = taskDtoInstruction.get(0); + if (TaskTypeEnum.Truss_Task.getIndex().equals(taskDtoIns.getTask_type())) { + Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDtoIns.getTask_code()); + String interactionJson = taskDtoIns.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String start_device_code = taskDtoIns.getStart_device_code(); + String next_device_code = taskDtoIns.getNext_device_code(); + Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + if (ObjectUtil.isEmpty(start_addr)) { + throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); + } + if (ObjectUtil.isEmpty(next_addr)) { + throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); + } + Map map1 = new HashMap<>(); + Map map2 = new HashMap<>(); + Map map3 = new HashMap<>(); + Map map4 = new HashMap<>(); + Map map5 = new HashMap<>(); + Map map6 = new HashMap<>(); + Map map7 = new HashMap<>(); + Map map8 = new HashMap<>(); + Map map9 = new HashMap<>(); + try { + pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9); + } catch (Exception e) { + logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + + instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code() + + ",指令终点:" + instruction.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); + } + this.setRequireSucess(true); + return true; } - logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" - + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() - + ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO); - //创建指令后修改任务状态 - taskDto.setTask_status("1"); - taskserver.update(taskDto); - requireSucess = true; + } else { + TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode); + if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) { + String interactionJson = taskDto.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String start_device_code = taskDto.getStart_device_code(); + String next_device_code = taskDto.getNext_device_code(); + Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + if (ObjectUtil.isEmpty(start_addr)) { + throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); + } + if (ObjectUtil.isEmpty(next_addr)) { + throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); + } - Map map1 = new HashMap<>(); - List list = new ArrayList(); - map1.put("code", "to_command"); - map1.put("value", 1); - list.add(map1); - Map map2 = new HashMap<>(); - map2.put("code", "to_target"); - map2.put("value", next_addr); - list.add(map2); - Map map3 = new HashMap<>(); - map3.put("code", "to_onset"); - map3.put("value", start_addr); - list.add(map3); - Map map4 = new HashMap<>(); - map4.put("code", "to_task"); - map4.put("value", instdto.getInstruction_code()); - list.add(map4); - if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getWeight())) { - Map map5 = new HashMap<>(); - map5.put("code", "to_weight"); - map5.put("value", interactionJsonDTO.getWeight()); - list.add(map5); - } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLength())) { - Map map6 = new HashMap<>(); - map6.put("code", "to_length"); - map6.put("value", interactionJsonDTO.getLength()); - list.add(map6); - } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getHeight())) { - Map map7 = new HashMap<>(); - map7.put("code", "to_height"); - map7.put("value", interactionJsonDTO.getHeight()); - list.add(map7); - } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getBarcode())) { - Map map8 = new HashMap<>(); - map8.put("code", "to_barcode"); - map8.put("value", interactionJsonDTO.getBarcode()); - list.add(map8); - } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getContainerType())) { - Map map9 = new HashMap<>(); - map9.put("code", "to_container_type"); - map9.put("value", interactionJsonDTO.getContainerType()); - list.add(map9); - } - } + String taskid = taskDto.getTask_id(); + String taskcode = taskDto.getTask_code(); + String start_point_code = taskDto.getStart_point_code(); + String route_plan_code = taskDto.getRoute_plan_code(); + String next_point_code = taskDto.getNext_point_code(); + Instruction instdto = new Instruction(); + packageData(instdto, route_plan_code, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code); - try { - this.writing(list); - } catch (Exception e) { - logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" - + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() - + ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); + try { + instructionService.create(instdto); + } catch (Exception e) { + notCreateInstMessage = e.getMessage(); + logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); + return false; + } + //创建指令后修改任务状态 + taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskserver.update(taskDto); + requireSucess = true; + + Map map1 = new HashMap<>(); + Map map2 = new HashMap<>(); + Map map3 = new HashMap<>(); + Map map4 = new HashMap<>(); + Map map5 = new HashMap<>(); + Map map6 = new HashMap<>(); + Map map7 = new HashMap<>(); + Map map8 = new HashMap<>(); + Map map9 = new HashMap<>(); + try { + pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9); + } catch (Exception e) { + logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() + + ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); + } + this.setRequireSucess(true); + return true; + } else { + notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; } - this.setRequireSucess(true); - return true; - }else{ - notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; } } return true; } } + private void pushPLC(Map map1, Map map2, String next_addr, Map map3, String start_addr, Map map4, String task, InteractionJsonDTO interactionJsonDTO, Map map5, Map map6, Map map7, Map map8, Map map9) { + List list = new ArrayList(); + map1.put("code", "to_command"); + map1.put("value", 1); + list.add(map1); + map2.put("code", "to_target"); + map2.put("value", next_addr); + list.add(map2); + map3.put("code", "to_onset"); + map3.put("value", start_addr); + list.add(map3); + map4.put("code", "to_task"); + map4.put("value", task); + list.add(map4); + if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getWeight())) { + map5.put("code", "to_weight"); + map5.put("value", interactionJsonDTO.getWeight()); + list.add(map5); + } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLength())) { + map6.put("code", "to_length"); + map6.put("value", interactionJsonDTO.getLength()); + list.add(map6); + } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getHeight())) { + map7.put("code", "to_height"); + map7.put("value", interactionJsonDTO.getHeight()); + list.add(map7); + } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getBarcode())) { + map8.put("code", "to_barcode"); + map8.put("value", interactionJsonDTO.getBarcode()); + list.add(map8); + } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getContainerType())) { + map9.put("code", "to_container_type"); + map9.put("value", interactionJsonDTO.getContainerType()); + list.add(map9); + } + } + + this.writing(list); + } + + private void packageData(Instruction instdto, String route_plan_code, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code) { + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(route_plan_code); + instdto.setTask_id(taskid); + instdto.setTask_code(taskcode); + instdto.setCreate_by("auto"); + instdto.setStart_device_code(start_device_code); + instdto.setNext_device_code(next_device_code); + instdto.setStart_point_code(start_point_code); + instdto.setNext_point_code(next_point_code); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(device_code); + } + /** * 下发 * @param list diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java index ea180aaea..328042826 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java @@ -1,5 +1,6 @@ package org.nl.acs.device_driver.one_manipulator.trapped_manipulator; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; @@ -30,9 +31,11 @@ import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.enums.TaskStatusEnum; import org.nl.acs.task.enums.TaskTypeEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; +import org.nl.common.exception.BadRequestException; import org.nl.config.SpringContextHolder; import java.util.*; @@ -295,116 +298,172 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice //找终点为入库输送线工位任务类型为行架的任务 for (int i = 0; i < getDeviceCodeList.size(); i++) { String startDeviceCode = getDeviceCodeList.get(i); - TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) { - String interactionJson = taskDto.getInteraction_json(); - InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); - String start_device_code = taskDto.getStart_device_code(); - String next_device_code = taskDto.getNext_device_code(); - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - String start_addr = startDevice.getExtraValue().get("address").toString(); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - String taskid = taskDto.getTask_id(); - String taskcode = taskDto.getTask_code(); - String start_point_code = taskDto.getStart_point_code(); - String route_plan_code = taskDto.getRoute_plan_code(); - String next_point_code = taskDto.getNext_point_code(); - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(device_code); + //先查指令 + List taskDtoInstruction = taskserver.queryTaskByDeviceCodeAndStatus2(startDeviceCode); + if (CollUtil.isNotEmpty(taskDtoInstruction)) { + TaskDto taskDtoIns = taskDtoInstruction.get(0); + if (TaskTypeEnum.Truss_Task.getIndex().equals(taskDtoIns.getTask_type())) { + Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDtoIns.getTask_code()); + String interactionJson = taskDtoIns.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String start_device_code = taskDtoIns.getStart_device_code(); + String next_device_code = taskDtoIns.getNext_device_code(); + Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + if (ObjectUtil.isEmpty(start_addr)) { + throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); + } + if (ObjectUtil.isEmpty(next_addr)) { + throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); + } + Map map1 = new HashMap<>(); + Map map2 = new HashMap<>(); + Map map3 = new HashMap<>(); + Map map4 = new HashMap<>(); + Map map5 = new HashMap<>(); + Map map6 = new HashMap<>(); + Map map7 = new HashMap<>(); + Map map8 = new HashMap<>(); + Map map9 = new HashMap<>(); + try { + pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9); + } catch (Exception e) { + logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + + instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code() + + ",指令终点:" + instruction.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); + } + this.setRequireSucess(true); + return true; + } + } else { + TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode); + if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) { + String interactionJson = taskDto.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String start_device_code = taskDto.getStart_device_code(); + String next_device_code = taskDto.getNext_device_code(); + Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + if (ObjectUtil.isEmpty(start_addr)) { + throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); + } + if (ObjectUtil.isEmpty(next_addr)) { + throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); + } - try { - instructionService.create(instdto); - } catch (Exception e) { - notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); - return false; - } - logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" - + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() - + ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO); - //创建指令后修改任务状态 - taskDto.setTask_status("1"); - taskserver.update(taskDto); - requireSucess = true; + String taskid = taskDto.getTask_id(); + String taskcode = taskDto.getTask_code(); + String start_point_code = taskDto.getStart_point_code(); + String route_plan_code = taskDto.getRoute_plan_code(); + String next_point_code = taskDto.getNext_point_code(); + Instruction instdto = new Instruction(); + packageData(instdto, route_plan_code, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code); - Map map1 = new HashMap<>(); - List list = new ArrayList(); - map1.put("code", "to_command"); - map1.put("value", 1); - list.add(map1); - Map map2 = new HashMap<>(); - map2.put("code", "to_target"); - map2.put("value", next_addr); - list.add(map2); - Map map3 = new HashMap<>(); - map3.put("code", "to_onset"); - map3.put("value", start_addr); - list.add(map3); - Map map4 = new HashMap<>(); - map4.put("code", "to_task"); - map4.put("value", instdto.getInstruction_code()); - list.add(map4); - if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getWeight())) { - Map map5 = new HashMap<>(); - map5.put("code", "to_weight"); - map5.put("value", interactionJsonDTO.getWeight()); - list.add(map5); + try { + instructionService.create(instdto); + } catch (Exception e) { + notCreateInstMessage = e.getMessage(); + logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); + return false; } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLength())) { - Map map6 = new HashMap<>(); - map6.put("code", "to_length"); - map6.put("value", interactionJsonDTO.getLength()); - list.add(map6); - } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getHeight())) { - Map map7 = new HashMap<>(); - map7.put("code", "to_height"); - map7.put("value", interactionJsonDTO.getHeight()); - list.add(map7); - } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getTemplate())) { - Map map8 = new HashMap<>(); - map8.put("code", "to_template"); - map8.put("value", interactionJsonDTO.getTemplate()); - list.add(map8); - } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getTemplate())) { - Map map9 = new HashMap<>(); - map9.put("code", "to_last_one"); - map9.put("value", interactionJsonDTO.getIsLastOne()); - list.add(map9); + //创建指令后修改任务状态 + taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskserver.update(taskDto); + requireSucess = true; + + Map map1 = new HashMap<>(); + Map map2 = new HashMap<>(); + Map map3 = new HashMap<>(); + Map map4 = new HashMap<>(); + Map map5 = new HashMap<>(); + Map map6 = new HashMap<>(); + Map map7 = new HashMap<>(); + Map map8 = new HashMap<>(); + Map map9 = new HashMap<>(); + try { + pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9); + } catch (Exception e) { + logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() + + ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); } + this.setRequireSucess(true); + return true; + } else { + notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; } - try { - this.writing(list); - } catch (Exception e) { - logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" - + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() - + ",指令终点:" + instdto.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); - } - this.setRequireSucess(true); - return true; - }else{ - notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; } } return true; } - } + + + private void pushPLC(Map map1, Map map2, String next_addr, Map map3, String start_addr, Map map4, String task, InteractionJsonDTO interactionJsonDTO, Map map5, Map map6, Map map7, Map map8, Map map9) { + + List list = new ArrayList(); + map1.put("code", "to_command"); + map1.put("value", 1); + list.add(map1); + map2.put("code", "to_target"); + map2.put("value", next_addr); + list.add(map2); + map3.put("code", "to_onset"); + map3.put("value", start_addr); + list.add(map3); + map4.put("code", "to_task"); + map4.put("value", task); + list.add(map4); + if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getWeight())) { + map5.put("code", "to_weight"); + map5.put("value", interactionJsonDTO.getWeight()); + list.add(map5); + } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLength())) { + map6.put("code", "to_length"); + map6.put("value", interactionJsonDTO.getLength()); + list.add(map6); + } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getHeight())) { + map7.put("code", "to_height"); + map7.put("value", interactionJsonDTO.getHeight()); + list.add(map7); + } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getTemplate())) { + map8.put("code", "to_template"); + map8.put("value", interactionJsonDTO.getTemplate()); + list.add(map8); + } + if (ObjectUtil.isNotEmpty(interactionJsonDTO.getTemplate())) { + map9.put("code", "to_last_one"); + map9.put("value", interactionJsonDTO.getIsLastOne()); + list.add(map9); + } + } + + this.writing(list); + } + + private void packageData(Instruction instdto, String route_plan_code, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code) { + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(route_plan_code); + instdto.setTask_id(taskid); + instdto.setTask_code(taskcode); + instdto.setCreate_by("auto"); + instdto.setStart_device_code(start_device_code); + instdto.setNext_device_code(next_device_code); + instdto.setStart_point_code(start_point_code); + instdto.setNext_point_code(next_point_code); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(device_code); + } + /** * 完成指令 * @param inst diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/volume_two_manipulator/VolumeTwoManipulatorManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/volume_two_manipulator/VolumeTwoManipulatorManipulatorDeviceDriver.java index 9f1ba4199..1404b130b 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/volume_two_manipulator/VolumeTwoManipulatorManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/volume_two_manipulator/VolumeTwoManipulatorManipulatorDeviceDriver.java @@ -1,5 +1,6 @@ package org.nl.acs.device_driver.one_manipulator.volume_two_manipulator; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; @@ -30,9 +31,11 @@ import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.enums.TaskStatusEnum; import org.nl.acs.task.enums.TaskTypeEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; +import org.nl.common.exception.BadRequestException; import org.nl.config.SpringContextHolder; import java.util.*; @@ -265,10 +268,10 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi } //放货完成 - if ( action == 4 && move == 0) { + if (action == 4 && move == 0) { if (inst != null) { try { - logServer.deviceExecuteLog(this.device_code,"","","放货完成"); + logServer.deviceExecuteLog(this.device_code, "", "", "放货完成"); finish_instruction(inst); Map map1 = new HashMap<>(); List list = new ArrayList(); @@ -282,7 +285,7 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi e.printStackTrace(); } feedMessage = ""; - }else { + } else { feedMessage = "行架机械手:"; if (mode != 3) { feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; @@ -319,104 +322,96 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi //找终点为入库输送线工位任务类型为行架的任务 for (int i = 0; i < getDeviceCodeList.size(); i++) { String startDeviceCode = getDeviceCodeList.get(i); - TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) { - String start_device_code = taskDto.getStart_device_code(); - String next_device_code = taskDto.getNext_device_code(); - String start_device_code2 = taskDto.getStart_device_code2(); - String next_device_code2 = taskDto.getNext_device_code2(); - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - String start_addr = startDevice.getExtraValue().get("address").toString(); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - - String taskid = taskDto.getTask_id(); - String taskcode = taskDto.getTask_code(); - String start_point_code = taskDto.getStart_point_code(); - String next_point_code = taskDto.getNext_point_code(); - String start_point_code2 = taskDto.getStart_point_code2(); - String next_point_code2 = taskDto.getNext_point_code2(); - String route_plan_code = taskDto.getRoute_plan_code(); - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setStart_device_code2(start_device_code2); - instdto.setNext_device_code2(next_device_code2); - instdto.setStart_point_code2(start_point_code2); - instdto.setNext_point_code2(next_point_code2); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(device_code); - - try { - instructionService.create(instdto); - } catch (Exception e) { - notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); - return false; - } - logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" - + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() - + ",指令终点:" + instdto.getNext_device_code() ); - //创建指令后修改任务状态 - taskDto.setTask_status("1"); - taskserver.update(taskDto); - requireSucess = true; - - Map map1 = new HashMap<>(); - List list = new ArrayList(); - map1.put("code", "to_command"); - map1.put("value", 1); - list.add(map1); - Map map2 = new HashMap<>(); - map2.put("code", "to_target"); - map2.put("value", next_addr); - list.add(map2); - Map map3 = new HashMap<>(); - map3.put("code", "to_onset"); - map3.put("value", start_addr); - list.add(map3); - Map map4 = new HashMap<>(); - map4.put("code", "to_task"); - map4.put("value", instdto.getInstruction_code()); - list.add(map4); - String toType = VolumeTwoTypeEnum.TOW.getType(); - if (StrUtil.isNotEmpty(start_device_code2)) { - toType = VolumeTwoTypeEnum.FOUR.getType(); - Device startDevice2 = deviceAppService.findDeviceByCode(start_device_code2); - Device nextDevice2 = deviceAppService.findDeviceByCode(next_device_code2); - String start_addr2 = startDevice2.getExtraValue().get("address").toString(); - String next_addr2 = nextDevice2.getExtraValue().get("address").toString(); + //先查指令 + List taskDtoInstruction = taskserver.queryTaskByDeviceCodeAndStatus2(startDeviceCode); + if (CollUtil.isNotEmpty(taskDtoInstruction)) { + TaskDto taskDtoIns = taskDtoInstruction.get(0); + if (TaskTypeEnum.Truss_Task.getIndex().equals(taskDtoIns.getTask_type())) { + Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDtoIns.getTask_code()); + String interactionJson = taskDtoIns.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String start_device_code = taskDtoIns.getStart_device_code(); + String next_device_code = taskDtoIns.getNext_device_code(); + Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + if (ObjectUtil.isEmpty(start_addr)) { + throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); + } + if (ObjectUtil.isEmpty(next_addr)) { + throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); + } + Map map1 = new HashMap<>(); + Map map2 = new HashMap<>(); + Map map3 = new HashMap<>(); + Map map4 = new HashMap<>(); Map map5 = new HashMap<>(); - map5.put("code", "to_target2"); - map5.put("value", next_addr2); - list.add(map5); Map map6 = new HashMap<>(); - map6.put("code", "to_onset2"); - map6.put("value", start_addr2); - list.add(map6); + Map map7 = new HashMap<>(); + + try { + pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), map5, map6,map7,taskDtoIns); + } catch (Exception e) { + logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + + instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code() + + ",指令终点:" + instruction.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); + } + this.setRequireSucess(true); + return true; } - Map map7 = new HashMap<>(); - map7.put("code", "to_type"); - map7.put("value", toType); - list.add(map7); - try { - this.writing(list); - } catch (Exception e) { + }else { + TaskDto taskDto = taskserver.findByStartCodeAndReady(startDeviceCode); + if (ObjectUtil.isNotEmpty(taskDto) && TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) { + String start_device_code = taskDto.getStart_device_code(); + String next_device_code = taskDto.getNext_device_code(); + String start_device_code2 = taskDto.getStart_device_code2(); + String next_device_code2 = taskDto.getNext_device_code2(); + Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + String taskid = taskDto.getTask_id(); + String taskcode = taskDto.getTask_code(); + String start_point_code = taskDto.getStart_point_code(); + String next_point_code = taskDto.getNext_point_code(); + String route_plan_code = taskDto.getRoute_plan_code(); + Instruction instdto = new Instruction(); + packageData(instdto, route_plan_code, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code,start_device_code2,next_device_code2); + try { + instructionService.create(instdto); + } catch (Exception e) { + notCreateInstMessage = e.getMessage(); + logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); + return false; + } logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() - + ",指令终点:" + instdto.getNext_device_code() + ",指令执行失败:" + e.getMessage()); + + ",指令终点:" + instdto.getNext_device_code()); + //创建指令后修改任务状态 + taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskserver.update(taskDto); + requireSucess = true; + + this.setRequireSucess(true); + Map map1 = new HashMap<>(); + Map map2 = new HashMap<>(); + Map map3 = new HashMap<>(); + Map map4 = new HashMap<>(); + Map map5 = new HashMap<>(); + Map map6 = new HashMap<>(); + Map map7 = new HashMap<>(); + try { + pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), map5, map6,map7,taskDto); + } catch (Exception e) { + logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() + + ",指令终点:" + instdto.getNext_device_code() + ",指令执行失败:" + e.getMessage()); + } + return true; + } else { + notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; } - this.setRequireSucess(true); - return true; - }else{ - notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; } } return true; @@ -424,8 +419,70 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi } + private void packageData(Instruction instdto, String route_plan_code, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code, String start_device_code2, String next_device_code2) { + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(route_plan_code); + instdto.setTask_id(taskid); + instdto.setTask_code(taskcode); + instdto.setCreate_by("auto"); + instdto.setStart_device_code(start_device_code); + instdto.setNext_device_code(next_device_code); + instdto.setStart_point_code(start_point_code); + instdto.setNext_point_code(next_point_code); + instdto.setStart_device_code2(start_device_code2); + instdto.setNext_device_code2(next_device_code2); + instdto.setStart_point_code2(start_device_code2); + instdto.setNext_point_code2(next_device_code2); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(device_code); + } + + private void pushPLC(Map map1, Map map2, String next_addr, Map map3, String start_addr, Map map4, String task, Map map5, Map map6, Map map7, TaskDto taskDtoIns) { + + List list = new ArrayList(); + map1.put("code", "to_command"); + map1.put("value", 1); + list.add(map1); + map2.put("code", "to_target"); + map2.put("value", next_addr); + list.add(map2); + map3.put("code", "to_onset"); + map3.put("value", start_addr); + list.add(map3); + map4.put("code", "to_task"); + map4.put("value", task); + list.add(map4); + String toType = VolumeTwoTypeEnum.TOW.getType(); + if (StrUtil.isNotEmpty(taskDtoIns.getStart_device_code2())) { + toType = VolumeTwoTypeEnum.FOUR.getType(); + Device startDevice2 = deviceAppService.findDeviceByCode(taskDtoIns.getStart_device_code2()); + Device nextDevice2 = deviceAppService.findDeviceByCode(taskDtoIns.getNext_device_code2()); + String start_addr2 = startDevice2.getExtraValue().get("address").toString(); + String next_addr2 = nextDevice2.getExtraValue().get("address").toString(); + if (ObjectUtil.isEmpty(start_addr2)) { + throw new BadRequestException("设备:" + startDevice2.getDevice_code() + "未设置电气调度号!"); + } + if (ObjectUtil.isEmpty(next_addr2)) { + throw new BadRequestException("设备:" + nextDevice2.getDevice_code() + "未设置电气调度号!"); + } + map5.put("code", "to_target2"); + map5.put("value", next_addr2); + list.add(map5); + map6.put("code", "to_onset2"); + map6.put("value", start_addr2); + list.add(map6); + } + + map7.put("code", "to_type"); + map7.put("value", toType); + list.add(map7); + + this.writing(list); + } + /** * 完成指令 + * * @param inst * @return * @throws Exception @@ -437,6 +494,7 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi /** * 下发信号 + * * @param list */ public void writing(List list) { @@ -473,6 +531,7 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi public String getToParam() { return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; } + @Override public JSONObject getDeviceStatusName() { JSONObject jo = new JSONObject(); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java index 36226b70a..e2a9e3a68 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java @@ -592,7 +592,7 @@ public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver impl log.error("指令创建失败!{}", e.getMessage()); return false; } - taskdto.setTask_status("1"); + taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); taskserver.update(taskdto); requireSucess = true; Map map = new HashMap(); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java index 2df4b6367..384b301bd 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java @@ -66,7 +66,21 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme @Autowired DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - /** + + /** + * 禁止入库 + */ + private boolean prohibitInWarehouse = false; + /** + * 禁止出库 + */ + private boolean prohibitOutWarehouse = false; + /** + * 停止接收任务 + */ + private boolean stopReceiveTask = false; + + /** * 心跳 */ Integer heartbeat = 0; @@ -76,17 +90,17 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme */ Integer item_deviceCode = 0; Integer last_item_deviceCode = 0; - /** + /** * 工作模式 */ Integer mode = 0; Integer last_mode = 0; /** - *作业状态 + * 作业状态 */ Integer command = 0; Integer last_command = 0; - /** + /** * 任务号 */ Integer task = 0; @@ -111,7 +125,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme */ Integer y = 0; Integer last_y = 0; - /** + /** * 行走开关信号 */ Float move = 0F; @@ -121,12 +135,12 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme */ Float cargoMove = 0F; Float last_cargoMove = 0F; - /** + /** * 行走动作信号 */ Float action = 0F; Float last_action = 0F; - /** + /** * 行走激光数值 */ Integer distancex = 0; @@ -137,41 +151,41 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme Integer distancey = 0; Integer last_distancey = 0; /** - *载货台超限信号 + * 载货台超限信号 */ Float cargoError = 0F; Float last_cargoError = 0F; /** - *货叉探货信号 + * 货叉探货信号 */ Float forkCargo = 0F; Float last_forkCargo = 0F; /** - *货叉位置信号 + * 货叉位置信号 */ Float forkLocation = 0F; Float last_forkLocation = 0F; /** - *货叉动作信号 + * 货叉动作信号 */ Float forkAction = 0F; Float last_forkAction = 0F; - /** + /** * 特殊开关量1 */ Float special1 = 0F; Float last_special1 = 0F; - /** + /** * 特殊开关量2 */ Float special2 = 0F; Float last_special2 = 0F; /** - *托盘条码 + * 托盘条码 */ int[] trayCode; int[] last_trayCode; - /** + /** * 水箱和消防缓存位有无货 */ Float storage_cache = 0F; @@ -181,58 +195,58 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme */ Integer stacker_rpm = 0; Integer last_stacker_rpm = 0; - /** + /** * 电流 */ Integer stacker_electricCurrent = 0; Integer last_stacker_electricCurrent = 0; - /** + /** * 轴运行次数 */ Integer stacker_runing_time = 0; Integer last_stacker_runing_time = 0; - /** + /** * 轴工作时间(小时) */ Integer stacker_workingHours = 0; Integer last_stacker_workingHours = 0; /** - *载货台速度(转/分钟) + * 载货台速度(转/分钟) */ Integer cargo_rpm = 0; Integer last_cargo_rpm = 0; /** - *载货台电流 + * 载货台电流 */ Integer cargo_electric_Current = 0; Integer last_cargo_electric_Current = 0; /** - *载货台轴工作小时数 + * 载货台轴工作小时数 */ Integer cargo_workingHour = 0; Integer last_cargo_workingHour = 0; /** - *载货台轴运行次数 + * 载货台轴运行次数 */ Integer cargo_runingTimes = 0; Integer last_cargo_runingTimes = 0; /** - *货叉速度(转/分钟 + * 货叉速度(转/分钟 */ Integer fork_rpm = 0; Integer last_fork_rpm = 0; /** - *货叉电流 + * 货叉电流 */ Integer fork_electric_Current = 0; Integer last_fork_electric_Current = 0; /** - *货叉轴工作时间(小时 + * 货叉轴工作时间(小时 */ Integer fork_workingHours = 0; Integer last_fork_workingHours = 0; /** - *货叉轴运行次数 + * 货叉轴运行次数 */ Integer fork_runingTimes = 0; Integer last_fork_runingTimes = 0; @@ -250,7 +264,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme List getDeviceCodeList = null; List putDeviceCodeList = null; - /** + /** * 请求成功标记 */ Boolean requireSucess = false; @@ -368,7 +382,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme if (ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("z"))) { Map map = new HashMap(); map.put("code", "to_x"); - map.put("value", nextDevice.getExtraValue().get("z")); + map.put("value", nextDevice.getExtraValue().get("z")); list.add(map); } if (ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("x"))) { @@ -616,7 +630,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } map.put("to_x", inst.getFrom_y()); } - if(ObjectUtil.isNotEmpty(map)){ + if (ObjectUtil.isNotEmpty(map)) { list.add(map); this.writing(list); } @@ -714,7 +728,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme if (command == 8) { map.put("to_command", 8); } - if(ObjectUtil.isNotEmpty(map)){ + if (ObjectUtil.isNotEmpty(map)) { list.add(map); this.writing(list); } @@ -725,12 +739,43 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme @Override public JSONObject getDeviceStatusName() throws Exception { - return null; + JSONObject jo = new JSONObject(); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("is_click", true); + String requireSucess = "0"; + if (this.requireSucess) { + requireSucess = "1"; + } + jo.put("prohibitInWarehouse", this.prohibitInWarehouse); + jo.put("prohibitOutWarehouse", this.prohibitOutWarehouse); + jo.put("stopReceiveTask", this.stopReceiveTask); + jo.put("requireSucess", requireSucess); + jo.put("driver_type", "standard_stacker"); + return jo; } @Override public void setDeviceStatus(JSONObject data) { - + String requestSucess = data.getString("requireSucess"); + if (StrUtil.equals(requestSucess, "0")) { + this.requireSucess = false; + } else if (StrUtil.equals(requestSucess, CommonFinalParam.ONE)) { + this.requireSucess = true; + } + //监控大屏下发作业命令清警-5、召回-7、急停-8 + Integer toCommand = data.getInteger("toCommand"); + if (toCommand != null) { + Map map = new HashMap<>(); + map.put("to_command", toCommand); + this.writing(map); + } + //ACS监控大屏设置禁止入库、禁止出库、停止接收任务 + Boolean prohibitInWarehouse = data.getBoolean("prohibitInWarehouse"); + this.prohibitInWarehouse = prohibitInWarehouse; + Boolean prohibitOutWarehouse = data.getBoolean("prohibitOutWarehouse"); + this.prohibitOutWarehouse = prohibitOutWarehouse; + Boolean stopReceiveTask = data.getBoolean("stopReceiveTask"); + this.stopReceiveTask = stopReceiveTask; } @@ -759,6 +804,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } } + /** * 完成指令 * @@ -812,7 +858,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } - /** + /** * 将扩展表中的字符串数据转换成集合 */ @Override diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java index 00f37490d..389447f02 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java @@ -24,6 +24,7 @@ import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.enums.TaskStatusEnum; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.common.exception.BadRequestException; @@ -488,7 +489,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl logServer.deviceExecuteLog(device_code, "", instdto.getInstruction_code(), "指令创建失败,原因->" + e.getMessage()); } //创建指令后修改任务状态 - taskDto.setTask_status("1"); + taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); taskDto.setUpdate_time(DateUtil.now()); taskserver.update(taskDto); try { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/RequestSucessEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/RequestSucessEnum.java new file mode 100644 index 000000000..a25e5b6d2 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/RequestSucessEnum.java @@ -0,0 +1,20 @@ +package org.nl.acs.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum RequestSucessEnum { + YES("1", "是"), + + NO("0", "否"); + /** + * 状态 + */ + private String type; + /** + * 描述 + */ + private String value; +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java index d29f850d9..00b7bdea1 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java @@ -48,6 +48,13 @@ public interface TaskService extends CommonService { */ Task getById(String id); + /** + * 根据设备号和任务状态查询 + * @param device_code + * @return + */ + List queryTaskByDeviceCodeAndStatus2(String device_code); + /** * 根据ID查询 * diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 9cb91930a..f1a38fbc5 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -44,6 +44,7 @@ import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.dto.RouteLineDto; import org.nl.acs.route.service.mapper.RoutePlanMapper; import org.nl.acs.task.enums.TaskStatusEnum; +import org.nl.acs.task.enums.TaskTypeEnum; import org.nl.acs.task.service.TaskFeedbackService; import org.nl.acs.task.service.dto.TaskFeedbackDto; import org.nl.acs.common.base.PageInfo; @@ -133,6 +134,33 @@ public class TaskServiceImpl extends CommonServiceImpl impleme return taskMapper.selectById(id); } + @Override + public List queryTaskByDeviceCodeAndStatus2(String device_code) { + List list = new ArrayList<>(); + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if (task.getStart_device_code().equals(device_code) + && StrUtil.equals(task.getTask_status(), TaskStatusEnum.BUSY.getIndex())) { + Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code()); + if (ObjectUtil.isNotEmpty(instruction)) { + list.add(task); + } + } else { + if (StrUtil.equals(task.getTask_type(), TaskTypeEnum.Inner_Truss_Task.getIndex()) && StrUtil.isNotEmpty(task.getPut_device_code())) { + Instruction instruction = instructionService.findByDeviceCodeFromCache(task.getNext_device_code()); + if (ObjectUtil.isNotEmpty(instruction)) { + if (StrUtil.equals(instruction.getStart_device_code(), device_code)) { + list.add(task); + } + } + } + } + } + return list; + } + + @Override public TaskDto findById(String id) { return ConvertUtil.convert(getById(id), TaskDto.class); diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml b/acs2/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml index b335b9386..372569df2 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml @@ -9,10 +9,11 @@ spring: db-type: com.alibaba.druid.pool.DruidDataSource driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy # url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:stand_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true - url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true +# url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true + url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true username: ${DB_USER:root} # password: ${DB_PWD:Root.123456} - password: ${DB_PWD:p@ssw0rd} + password: ${DB_PWD:root} # 初始连接数 initial-size: 5 # 最小连接数 diff --git a/acs2/nladmin-ui/src/views/acs/monitor/device/index.vue b/acs2/nladmin-ui/src/views/acs/monitor/device/index.vue index d800fc2b2..c55970dee 100644 --- a/acs2/nladmin-ui/src/views/acs/monitor/device/index.vue +++ b/acs2/nladmin-ui/src/views/acs/monitor/device/index.vue @@ -240,6 +240,7 @@ export default { dialogFormVisible2: false, dialogFormVisible3: false, dialogFormVisible4: false, + dialogFormVisible5: false, arr2: [], currentItem: '', stageSelectList: [], @@ -283,7 +284,9 @@ export default { this.dialogFormVisible4 = true } else if (clickObj.data.driver_type === 'hailiang_xj_plc_test') { this.$refs.child1.setForm(clickObj) - } else { + } else if (clickObj.data.driver_type === 'standard_stacker') { + this.dialogFormVisible4 = true + }else { this.dialogFormVisible = true } } 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 c876040a9..398bdba82 100644 --- a/acs2/nladmin-ui/src/views/system/monitor/device/index.vue +++ b/acs2/nladmin-ui/src/views/system/monitor/device/index.vue @@ -32,15 +32,16 @@ - + - - - - 禁止进出 - 允许进入 - 允许离开 + + + + + + + @@ -49,7 +50,6 @@ 确 定 - @@ -186,7 +186,7 @@ - 召回 + 召回 急停 清警 @@ -387,7 +387,7 @@ export default { this.dialogFormVisible7 = true } else if (clickObj.data.driver_type === 'standard_conveyor_control_with_scanner') { this.dialogFormVisible6 = true - } else if (clickObj.data.driver_type === 'double_station_stacker') { + } else if (clickObj.data.driver_type === 'standard_stacker') { this.dialogFormVisible8 = true } else { this.dialogFormVisible = true @@ -750,4 +750,22 @@ body { z-index: 10; background: #e5e5e5; } + +::v-deep.el-radio-button{ + margin-right: 15px; + border-radius:4px; + .el-radio-button__inner { + width: 90px; + height: 30px; + background: #F7F8FA; + color:#333; + border: 0 !important; + } + .el-radio-button__orig-radio:checked + .el-radio-button__inner { + color: #fff; + background-color: blue; + border-color: blue; + box-shadow: -1px 0 0 0 blue; + } +}