From 618c9fa5271bef7e4ec6b8c045d37d4f368d14c7 Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Thu, 23 Apr 2026 16:42:17 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=E4=B8=80=E6=A5=BC=E4=BB=93?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/nl/acs/agv/AgvWaitUtil.java | 6 +- .../server/impl/CustomPolicyServiceImpl.java | 6 +- .../service/impl/DeviceServiceImpl.java | 20 +- .../BeltConveyorDeviceDriver.java | 1023 ------------- .../conveyor/belt_conveyor/ItemProtocol.java | 197 --- .../conveyor/belt_conveyor/Paper.java | 21 - .../DoubleStationStackerDeviceDriver.java | 4 +- .../belt_conveyor/BeltConveyorDefination.java | 2 +- .../BeltConveyorDeviceDriver.java | 608 ++++++++ .../belt_conveyor/ItemProtocol.java | 93 ++ .../BoxSubvolumesConveyorDefination.java | 9 +- .../BoxSubvolumesConveyorDeviceDriver.java | 619 ++++++++ .../box_subvolumes_conveyor/ItemProtocol.java | 94 ++ .../lk_conveyor/enums/ActionEnum.java | 29 + .../lk_conveyor/enums/ContainerTypeEnum.java | 29 + .../lk_conveyor/enums/ErrorEnum.java | 67 + .../lk_conveyor/enums/ModeEnum.java | 53 + .../lk_conveyor/enums/MoveEnum.java | 29 + .../lk_conveyor/enums/ToCommandEnum.java | 23 + ...ProductOutBindLableConveyorDefination.java | 2 +- ...nishedProductOutBindLableDeviceDriver.java | 812 ++++++++++ .../ItemProtocol.java | 109 ++ .../FoldDiscSiteDefination.java | 4 +- .../FoldDiscSiteDeviceDriver.java | 602 ++++++++ .../fold_disc_site/ItemProtocol.java | 95 ++ .../ConveyorWithScannerWeightDefination.java | 2 +- ...ConveyorWithScannerWeightDeviceDriver.java | 854 +++++++++++ .../scanner_weight_conveyor/ItemProtocol.java | 103 ++ .../un_box_lable_conveyor/ItemProtocol.java | 100 ++ .../UnBoxLableConveyorDefination.java | 2 +- .../UnBoxLableConveyorDeviceDriver.java | 451 ++++++ .../BoxManipulatorDefination.java | 65 + .../BoxManipulatorDeviceDriver.java | 616 ++++++++ .../box_manipulator/InteractionJsonDTO.java | 28 + .../box_manipulator/ItemProtocol.java | 99 ++ .../lk_manipulator/enums/Action2Enum.java | 35 + .../lk_manipulator/enums/ActionEnum.java | 32 + .../enums/ContainerTypeEnum.java | 29 + .../lk_manipulator/enums/ErrorEnum.java | 67 + .../lk_manipulator/enums/ModeEnum.java | 31 + .../lk_manipulator/enums/MoveEnum.java | 29 + .../open_close_manipulator/ItemProtocol.java | 90 ++ .../OpenCloseManipulatorDefination.java | 65 + .../OpenCloseManipulatorDeviceDriver.java | 359 +++++ .../InteractionJsonDTO.java | 2 +- .../trapped_manipulator/ItemProtocol.java | 98 ++ .../TrappedManipulatorDefination.java | 6 +- ...pedManipulatorManipulatorDeviceDriver.java | 644 ++++++++ .../BoxSubvolumesConveyorDeviceDriver.java | 827 ---------- .../box_subvolumes_conveyor/ItemProtocol.java | 190 --- ...nishedProductOutBindLableDeviceDriver.java | 1066 ------------- .../ItemProtocol.java | 257 ---- .../FoldDiscSiteDeviceDriver.java | 806 ---------- .../fold_disc_site/ItemProtocol.java | 156 -- ...ConveyorWithScannerWeightDeviceDriver.java | 1328 ----------------- .../scanner_weight_conveyor/ItemProtocol.java | 228 --- .../un_box_lable_conveyor/ItemProtocol.java | 235 --- .../UnBoxLableConveyorDeviceDriver.java | 756 ---------- .../BoxPackageManipulatorDeviceDriver.java | 2 +- .../BoxStorageManipulatorDeviceDriver.java | 6 +- .../ReturnGoodManipulatorDeviceDriver.java | 7 +- .../trapped_manipulator/ItemProtocol.java | 229 --- ...pedManipulatorManipulatorDeviceDriver.java | 770 ---------- ...TwoManipulatorManipulatorDeviceDriver.java | 2 +- .../standard_stacker/ItemProtocol.java | 392 +---- .../StandardStackerDeviceDriver.java | 347 ++--- .../enums/CustomPolicyTaskTypeEnum.java | 38 - .../ToCommandControl.java | 6 - .../org/nl/acs/enums/StorageTypeEnum.java | 8 +- .../wms/service/impl/WmsToAcsServiceImpl.java | 46 +- .../service/InstructionService.java | 20 +- .../service/impl/InstructionServiceImpl.java | 85 +- .../org/nl/acs/opc/DeviceExecuteAutoRun.java | 4 +- .../org/nl/acs/task/service/TaskService.java | 6 + .../task/service/impl/TaskServiceImpl.java | 96 +- .../service/impl/TaskScreenServiceImpl.java | 6 +- .../service/quartz/task/CreateDDJInst.java | 14 +- .../main/resources/config/application-dev.yml | 6 +- .../src/main/resources/config/application.yml | 4 +- .../monitor/universal/universal.properties | 185 +++ .../universal/universal_en_US.properties | 86 ++ .../universal/universal_in_ID.properties | 85 ++ .../universal/universal_zh_CN.properties | 192 ++- .../src/main/resources/logback-spring.xml | 12 +- acs2/nladmin-system/package-lock.json | 6 + acs2/nladmin-ui/.env.development | 4 +- acs2/nladmin-ui/src/i18n/langs/monitor/zh.js | 4 +- .../src/views/acs/device/config.vue | 8 +- .../views/acs/device/driver/belt_conveyor.vue | 370 +++-- .../acs/device/driver/box_manipulator.vue | 82 +- .../driver/conveyor_with_scanner_weight.vue | 125 +- .../one_conveyor/box_subvolumes_conveyor.vue | 137 +- ...d_product_out_with_bind_lable_conveyor.vue | 136 +- .../driver/one_conveyor/fold_disc_site.vue | 136 +- .../one_conveyor/un_box_lable_conveyor.vue | 102 +- .../one_manipulator/trapped_manipulator.vue | 96 +- .../device/driver/standard_stacker_device.vue | 835 +++++++++++ .../src/views/system/monitor/device/index.vue | 275 ++-- 98 files changed, 10073 insertions(+), 9109 deletions(-) delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/Paper.java rename acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/{conveyor => lk_conveyor}/belt_conveyor/BeltConveyorDefination.java (96%) create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/belt_conveyor/BeltConveyorDeviceDriver.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/belt_conveyor/ItemProtocol.java rename acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/{one_conveyor => lk_conveyor}/box_subvolumes_conveyor/BoxSubvolumesConveyorDefination.java (87%) create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/box_subvolumes_conveyor/ItemProtocol.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ActionEnum.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ContainerTypeEnum.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ErrorEnum.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ModeEnum.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/MoveEnum.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ToCommandEnum.java rename acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/{one_conveyor => lk_conveyor}/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableConveyorDefination.java (94%) create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/finished_product_out_with_bind_lable_conveyor/ItemProtocol.java rename acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/{one_conveyor => lk_conveyor}/fold_disc_site/FoldDiscSiteDefination.java (93%) create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/fold_disc_site/ItemProtocol.java rename acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/{one_conveyor => lk_conveyor}/scanner_weight_conveyor/ConveyorWithScannerWeightDefination.java (95%) create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/scanner_weight_conveyor/ItemProtocol.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/un_box_lable_conveyor/ItemProtocol.java rename acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/{one_conveyor => lk_conveyor}/un_box_lable_conveyor/UnBoxLableConveyorDefination.java (95%) create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/BoxManipulatorDefination.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/BoxManipulatorDeviceDriver.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/InteractionJsonDTO.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/ItemProtocol.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/Action2Enum.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ActionEnum.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ContainerTypeEnum.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ErrorEnum.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ModeEnum.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/MoveEnum.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/open_close_manipulator/ItemProtocol.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/open_close_manipulator/OpenCloseManipulatorDefination.java create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/open_close_manipulator/OpenCloseManipulatorDeviceDriver.java rename acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/{one_manipulator => lk_manipulator}/trapped_manipulator/InteractionJsonDTO.java (89%) create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/trapped_manipulator/ItemProtocol.java rename acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/{one_manipulator => lk_manipulator}/trapped_manipulator/TrappedManipulatorDefination.java (90%) create mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/ItemProtocol.java delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/ItemProtocol.java delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/ItemProtocol.java delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/ItemProtocol.java delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/ItemProtocol.java delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java delete mode 100644 acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/enums/CustomPolicyTaskTypeEnum.java create mode 100644 acs2/nladmin-system/package-lock.json create mode 100644 acs2/nladmin-ui/src/views/acs/device/driver/standard_stacker_device.vue diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/AgvWaitUtil.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/AgvWaitUtil.java index bf37006..88f8f11 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/AgvWaitUtil.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/AgvWaitUtil.java @@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.device.domain.Device; -import org.nl.acs.device_driver.one_conveyor.box_subvolumes_conveyor.BoxSubvolumesConveyorDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.box_subvolumes_conveyor.BoxSubvolumesConveyorDeviceDriver; import org.nl.acs.device_driver.two_conveyor.manipulator_agv_station.ManipulatorAgvStationDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.instruction.domain.Instruction; @@ -97,7 +97,7 @@ public class AgvWaitUtil { } else { LuceneLogDto logDto1 = LuceneLogDto.builder() .device_code(inst.getCarno()) - .content("agv叉车对接位输送线不允许取货:" + inst.getCarno() + "点位号" + boxSubvolumesConveyorDeviceDriver.getDevice_code()) + .content("agv叉车对接位输送线不允许取货:" + inst.getCarno() + "点位号" + boxSubvolumesConveyorDeviceDriver.getCurrentDeviceCode()) .build(); logDto1.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto1); @@ -124,7 +124,7 @@ public class AgvWaitUtil { BoxSubvolumesConveyorDeviceDriver boxSubvolumesConveyorDeviceDriver; boxSubvolumesConveyorDeviceDriver = (BoxSubvolumesConveyorDeviceDriver) startDevice.getDeviceDriver(); if (boxSubvolumesConveyorDeviceDriver.getTo_command() != 3) { - boxSubvolumesConveyorDeviceDriver.writing(3); + boxSubvolumesConveyorDeviceDriver.writing("to_command",3); } } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/server/impl/CustomPolicyServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/server/impl/CustomPolicyServiceImpl.java index 77dc09b..9fb2b9e 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/server/impl/CustomPolicyServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/server/impl/CustomPolicyServiceImpl.java @@ -21,11 +21,9 @@ import org.nl.acs.custompolicy.server.vo.CustomPolicyPlantVO; import org.nl.acs.device.domain.Device; import org.nl.acs.device_driver.stacker.standard_stacker.StandardStackerDeviceDriver; import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.utils.ConvertUtil; import org.nl.acs.utils.PageUtil; import org.nl.common.utils.SecurityUtils; -import org.nl.config.SpringContextHolder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; @@ -133,9 +131,9 @@ public class CustomPolicyServiceImpl extends CommonServiceImpl i }else if (device.getDeviceDriver() instanceof TrappedManipulatorManipulatorDeviceDriver) { TrappedManipulatorManipulatorDeviceDriver trappedManipulatorManipulatorDeviceDriver = (TrappedManipulatorManipulatorDeviceDriver) device.getDeviceDriver(); trappedManipulatorManipulatorDeviceDriver.setDeviceStatus(form); + } else if (device.getDeviceDriver() instanceof BoxSubvolumesConveyorDeviceDriver){ + BoxSubvolumesConveyorDeviceDriver boxSubvolumesConveyorDeviceDriver = (BoxSubvolumesConveyorDeviceDriver) device.getDeviceDriver(); + boxSubvolumesConveyorDeviceDriver.setDeviceStatus(form); + } else if (device.getDeviceDriver() instanceof FinishedProductOutBindLableDeviceDriver){ + FinishedProductOutBindLableDeviceDriver finishedProductOutBindLableDeviceDriver = (FinishedProductOutBindLableDeviceDriver) device.getDeviceDriver(); + finishedProductOutBindLableDeviceDriver.setDeviceStatus(form); + } else if (device.getDeviceDriver() instanceof FoldDiscSiteDeviceDriver) { + FoldDiscSiteDeviceDriver foldDiscSiteDeviceDriver = (FoldDiscSiteDeviceDriver) device.getDeviceDriver(); + foldDiscSiteDeviceDriver.setDeviceStatus(form); } } 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 deleted file mode 100644 index f0aafc0..0000000 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java +++ /dev/null @@ -1,1023 +0,0 @@ -package org.nl.acs.device_driver.conveyor.belt_conveyor; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import lombok.val; -import org.apache.commons.lang3.ObjectUtils; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.common.base.CommonFinalParam; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device.service.dto.DeviceDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.device_driver.one_conveyor.fold_disc_site.FoldDiscSiteDeviceDriver; -import org.nl.acs.device_driver.one_manipulator.box_package_manipulator.InteractionJsonDTO; -import org.nl.acs.enums.StorageTypeEnum; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.history.ErrorUtil; -import org.nl.acs.history.service.DeviceErrorLogService; -import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; -import org.nl.acs.instruction.domain.Instruction; -import org.nl.acs.instruction.enums.InstructionStatusEnum; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.log.service.DeviceExecuteLogService; -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.route.service.dto.RouteLineDto; -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.acs.utils.DeviceErrorUtil; -import org.nl.common.utils.SecurityUtils; -import org.nl.config.SpringContextHolder; -import org.nl.config.language.LangProcess; -import org.nl.config.lucene.service.LuceneExecuteLogService; -import org.nl.config.lucene.service.dto.LuceneLogDto; -import org.nl.system.service.param.ISysParamService; -import org.springframework.beans.factory.annotation.Autowired; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.*; -import java.util.concurrent.CompletableFuture; - -/** - * 输送线 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); - @Autowired - AgvService agvService = SpringContextHolder.getBean(AgvService.class); - @Autowired - DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - - LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); - - ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - - private Date instruction_update_time = new Date(); - private Date require_apply_strangulation_time = new Date(); - private int instruction_update_time_out = 500; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - private Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - private int require_apply_strangulation_time_out = 4000; - - String notCreateInstMessage = ""; - - - /** - * 心跳 - */ - int heartbeat = 0; - int last_heartbeat = 0; - /** - * 工作模式 - */ - int mode = 0; - int last_mode = 0; - /** - * 光电信号 - */ - int move = 0; - int last_move = 0; - /** - * 托盘方向 - */ - int container_direction = 0; - int last_container_direction = 0; - /** - * 报警 - */ - int error = 0; - int last_error = 0; - /** - * 动作信号 - */ - int action = 0; - int last_action = 0; - /** - * 任务号 - */ - int task = 0; - int last_task = 0; - /** - * 托盘类型 - */ - int container_type = 0; - int last_container_type = 0; - /** - * 纯数字托盘号 - */ - int container_no = 0; - int last_container_no = 0; - - int inventory_qty = 0; - int out_finish = 0; - /** - * 下发命令 - */ - String to_command = null; - String last_to_command = null; - /** - * 下发目标站 - */ - String to_target = null; - String last_to_target = null; - /** - * 下发任务号 - */ - String to_task = null; - String last_to_task = null; - /** - * 下发接纯数字托盘号 - */ - int to_container_no = 0; - int last_to_container_no = 0; - /** - * 下发托盘类型 - */ - int to_container_type = 0; - int last_to_container_type = 0; - - int to_height_level = 0; - int last_to_height_level = 0; - - - //子卷条码 - String material_barcode = null; - String last_material_barcode = null; - /** - * 当前指令 - */ - Instruction inst = null; - - String material = null; - String vehicle_code2; - - Boolean isonline = true; - - Boolean iserror = false; - - /** - * 1-执行任务;2-取货完成;3-放货完成; - */ - int flag; - - - int last_inventory_qty = 0; - int last_out_finish = 0; - - String last_material = null; - String message = null; - String device_code; - String task_code = null; - String vehicle_code; - String inst_message; - - String hand_barcode = null; - - Boolean ignore_pickup_check = false; - - List getDeviceCodeList = null; - - List putDeviceCodeList = null; - - /** - * led点阵屏信息 - */ - JSONObject led_message = null; - - - @Override - public Device getDevice() { - return this.device; - } - - /** - * 请求成功标记 - */ - Boolean requireSucess = false; - - @Override - public void execute() { - try { - device_code = this.getDeviceCode(); - heartbeat = this.itemProtocol.getHeartbeat(); - mode = this.itemProtocol.getMode(); - move = this.itemProtocol.getMove(); - action = this.itemProtocol.getAction(); - container_direction = this.itemProtocol.getContainer_direction(); - container_type = this.itemProtocol.getContainer_type(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - to_command = this.itemProtocol.getTo_command(); - to_target = this.itemProtocol.getTotarget(); - to_task = this.itemProtocol.getTo_task(); - to_container_no = this.itemProtocol.getContainer_direction(); - - - if (move != last_move && last_move == 1 && mode > 0) { - requireSucess = false; - clearWrite(); - } - - if (mode != last_mode) { - requireSucess = false; - } - - if (move != 0 && task > 0) { - CompletableFuture.runAsync(() -> { - // 异步更新指令状态 - try { - update_instruction_status(); - } catch (Exception e) { - e.printStackTrace(); - log.error("更新指令失败原因:{}", e.getMessage()); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("设备号" + device_code + "报错原因:" + e.getMessage()) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - } - }); - if (null != inst) { - inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code(); - vehicle_code2 = inst.getVehicle_code2(); - } - } - //申请空托盘出库 - if (mode == 8 && !requireSucess) { - if (container_type == 0) { - message = "托盘类型为空"; - } else { - applyEmptyTask(StorageTypeEnum.DISKS_OUT.getType(), mode); - } - } - - - if (mode == 0) { - this.setIsonline(false); - message = "脱机"; - } else if (error != 0) { - this.setIserror(true); - message = "有报警"; - - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - - switch (mode) { - case 1: - log.debug("弃用(留作兼容)"); - break; - case 2: - //申请任务 - if (move == 1 && !requireSucess) { - - instruction_require(); - } else { - String remark = ""; - ; - if (mode != 2) { - remark = "universal_remark2"; - } - if (move != 0) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = "universal_remark4"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = "universal_remark5"; - } - this.setNotCreateInstMessage(remark); - //} - } - break; - case 3: - log.info(this.device_code + ",运行中"); - break; - case 4: - //申请出货 - if (move == 1 && !requireSucess) { - } - break; - - - default: - break; - } - } - - } catch (Exception var17) { - this.iserror = true; - message = "读取信号值时出现异常"; - String extracted = DeviceErrorUtil.extracted(var17); - if (var17 instanceof NullPointerException) { - message += " - 空指针异常"; - // 记录详细的堆栈跟踪信息 - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - var17.printStackTrace(pw); - String stackTrace = sw.toString(); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(this.device_code + extracted + ",报错信息:" + var17.getMessage() + ",堆栈跟踪:" + stackTrace) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - } else { - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(this.device_code + extracted + ",报错信息:" + var17.getMessage()) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - var17.printStackTrace(); - } - } - - last_heartbeat = heartbeat; - last_mode = mode; - last_move = move; - last_error = error; - last_container_direction = container_direction; - last_container_no = container_no; - last_container_type = container_type; - last_action = action; - last_task = task; - last_to_command = to_command; - last_to_target = to_target; - last_to_task = to_task; - last_to_container_no = to_container_no; - last_to_container_type = to_container_type; - } - - public void clearWrite() { - List list = new ArrayList<>(); - Map map = new HashMap<>(); - map.put("code", "to_target"); - map.put("value", "0"); - list.add(map); - Map map2 = new HashMap<>(); - map2.put("code", "to_task"); - map2.put("value", "0"); - list.add(map2); - Map map4 = new HashMap<>(); - map4.put("code", "to_container_type"); - map4.put("value", "0"); - list.add(map4); - - this.writing(list); - message = null; - vehicle_code = null; - inst_message = null; - - } - - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.conveyor.belt_conveyor.ItemProtocol.item_to_command; - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - this.control(itemMap); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("下发多个电气信号" + itemMap) - .build(); - logDto.setLog_level(3); - luceneExecuteLogService.deviceExecuteLog(logDto); - } - - private void applyEmptyTask(String type, int mode) { - Date date = new Date(); - if (date.getTime() - this.require_apply_strangulation_time.getTime() - < (long) this.require_apply_strangulation_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_apply_strangulation_time = date; - try { - JSONObject param = new JSONObject(); - param.put("device_code", device_code); - param.put("container_type", container_type); - param.put("type", type); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("申请空托盘出入库,参数:" + param) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - HttpResponse httpResponse = acsToWmsService.applyTwo(param); - JSONObject jsonObject = null; - if(ObjectUtil.isNotEmpty(httpResponse)){ - String body = httpResponse.body(); - jsonObject = JSONObject.parseObject(body); - } - message = "申请空托盘出入库,返回参数:" + jsonObject; - if (ObjectUtil.isNotNull(jsonObject) && jsonObject.getInteger("status") == 200) { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请空托盘出入库,参数,接口返回:" + jsonObject) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - List list1 = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", mode); - list1.add(map); - this.writing(list1); - this.requireSucess = true; - } else { - this.iserror = true; - message = "申请空托盘出入库出错,返回参数:" + jsonObject; - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请空托盘出入库,返回参数:" + jsonObject) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - - /** - * 申请任务 - */ - public synchronized Boolean - instruction_require() { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_require_time = date; - //查找有没有对应的指令 - Instruction inst = instructionService.findByStartCodeAndReady(this.device_code); - if (ObjectUtil.isNotNull(inst)) { - List routeLineDtos = routeLineService.selectDeviceCodeList(this.device_code); - if (routeLineDtos.size() < 1) { - return false; - } - int i = 0; - for (RouteLineDto routeLineDto : routeLineDtos) { - if (routeLineDto.getNext_device_code().equals(inst.getNext_device_code())) { - i++; - } - } - if (i == 0) { - return false; - } - Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code()); - String next_addr = nextdevice.getExtraValue().get("address").toString(); - TaskDto taskDto = taskserver.findByCodeFromCache(inst.getTask_code()); - //List paperArray = getPaperArray(null); - if (ObjectUtil.isEmpty(inst)) { - return false; - } - String interactionJson = taskDto.getInteraction_json(); - InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); - String containerType = ""; - if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { - containerType = interactionJsonDTO.getContainerType(); - } - List list = new ArrayList(); - writeData(next_addr, list, inst, containerType); -// led_message = getLedMessage(inst); - requireSucess = true; - return true; - } else { - //移除行架任务 - - //查看是否存在输送线到对接为的指令 - Instruction byNextDeviceCodeFromCache = instructionService.findByNextDeviceCodeFromCache(this.device_code); - - if (ObjectUtil.isNotEmpty(byNextDeviceCodeFromCache)) { - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("存在到堆垛机对接位的就绪指令或者执行中的指令,"+"指令号为:"+byNextDeviceCodeFromCache.getInstruction_code()) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - } - //补码生成堆垛机对接位到货架的指令 - if (StrUtil.isNotEmpty(hand_barcode) && ObjectUtil.isEmpty(byNextDeviceCodeFromCache)) { - TaskDto taskDtoHandCode = taskserver.findByVehicleCodeCodeAndReady(hand_barcode); - if (Objects.nonNull(taskDtoHandCode)) { - String taskid = taskDtoHandCode.getTask_id(); - String taskcode = taskDtoHandCode.getTask_code(); - String priority = taskDtoHandCode.getPriority(); - String start_point_code = taskDtoHandCode.getStart_point_code(); - String start_device_code = ""; - String route_plan_code = taskDtoHandCode.getRoute_plan_code(); - String next_device_code = taskDtoHandCode.getNext_device_code(); - String interactionJson = taskDtoHandCode.getInteraction_json(); - String vehicleCode = taskDtoHandCode.getVehicle_code(); - String containerType = ""; - if (StrUtil.isNotEmpty(interactionJson)) { - InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); - containerType = interactionJsonDTO.getContainerType(); - } - List shortPathsList = routeLineService.getShortPathLines(taskDtoHandCode.getStart_device_code(), next_device_code, route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - String path = routeLineDto.getPath(); - String[] str = path.split("->"); - List pathlist = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 2; - break; - } - } - start_device_code = pathlist.get(index); - //校验路由关系 - List shortPathsList2 = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - if (ObjectUtils.isEmpty(shortPathsList2) || shortPathsList2.size() < 1) { - throw new RuntimeException("路由不通!"); - } - Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); - String next_point_code; - if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) { - next_point_code = next_device_code + "-" + taskDtoHandCode.getTo_y() + "-" + taskDtoHandCode.getTo_z(); - Instruction instdto = new Instruction(); - packageData(instdto, route_plan_code, taskDtoHandCode, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code, priority, containerType, vehicleCode); - try { - instructionService.create(instdto); - } catch (Exception e) { - e.printStackTrace(); - log.error("指令创建失败!,{}", e.getMessage()); - return false; - } - return updateTask(taskDtoHandCode, nextdevice, instdto); - } - } else { - return false; - } - } - - //入库异常口为起点的任务 - TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); - if (ObjectUtil.isNotNull(taskdto)) { - //移除行架任务 - if (taskdto.getTask_type().equals(TaskTypeEnum.Truss_Task.getIndex())) { - return false; - } - //判断指令的起点和当前的设备号相同 - if (!taskdto.getStart_device_code().equals(device_code)) { - return false; - } - if ("RK1002".equals(taskdto.getStart_device_code())) { - String route_plan_code = taskdto.getRoute_plan_code(); - - List shortPathsList = routeLineService.getShortPathLines(taskdto.getStart_device_code(), taskdto.getNext_device_code(), route_plan_code); - if (CollectionUtil.isEmpty(shortPathsList)) { - return true; - } - RouteLineDto routeLineDto = shortPathsList.get(0); - String path = routeLineDto.getPath(); - String[] str = path.split("->"); - List pathlist = Arrays.asList(str); - Integer start = 0; - String start_device_code = pathlist.get(start); - String next_device_code = pathlist.get(start + 1); - //判断有无出入库任务是相同路线 - //判断有没有DDJ对接位出入库的指令 - List byCodeAndExcute = instructionService.findByCodeAndExcute(next_device_code); - if (CollUtil.isNotEmpty(byCodeAndExcute)) { - this.message = "有DDJ对接位出入库的指令"; - requireSucess = false; - return true; - } - //关联站点判断 - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - BeltConveyorDeviceDriver beltConveyorDeviceDriver; - if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver(); - //判断对接位和关联站点光电信号 - getDeviceCodeList = beltConveyorDeviceDriver.getExtraDeviceCodes("link_device_code"); - if (CollUtil.isNotEmpty(getDeviceCodeList)) { - String linkDeviceCode = getDeviceCodeList.get(0); - Device linkDevice = deviceAppService.findDeviceByCode(linkDeviceCode); - BeltConveyorDeviceDriver linkDeviceDriver; - if (linkDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - linkDeviceDriver = (BeltConveyorDeviceDriver) linkDevice.getDeviceDriver(); - if ((beltConveyorDeviceDriver.getMode() == 0 || beltConveyorDeviceDriver.getMove() == 1) || (linkDeviceDriver.getMode() == 0 || linkDeviceDriver.getMove() == 1)) { - this.message = "DDJ对接位或关联输送线存在正在移动的货物或者未联机"; - requireSucess = false; - return true; - } - } - - } - } - } - - //判断当前任务号是否存在指令 - String taskid = taskdto.getTask_id(); - String taskcode = taskdto.getTask_code(); - String priority = taskdto.getPriority(); - String start_point_code = taskdto.getStart_point_code(); - String start_device_code = taskdto.getStart_device_code(); - String route_plan_code = taskdto.getRoute_plan_code(); - String vehicleCode = taskdto.getVehicle_code(); - - String next_device_code = ""; - String containerType = ""; - String interactionJson = taskdto.getInteraction_json(); - if (StrUtil.isNotEmpty(interactionJson)) { - InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); - containerType = interactionJsonDTO.getContainerType(); - } - - String this_coevice_code = taskserver.queryAssignedByDevice(device_code, taskdto.getNext_device_code()); - - if (StrUtil.isEmpty(this_coevice_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, taskdto.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - - List pathlist = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 1; - break; - } - } - next_device_code = pathlist.get(index); - } else { - next_device_code = this_coevice_code; - } - //校验路由关系 - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - if (ObjectUtils.isEmpty(shortPathsList) || shortPathsList.size() < 1) { - throw new RuntimeException("路由不通!"); - } - Device startdevice = deviceAppservice.findDeviceByCode(start_device_code); - Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); - String next_point_code; - if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) { - next_point_code = taskdto.getTo_x() + "-" + taskdto.getTo_y() + "-" + taskdto.getTo_z(); - } else { - next_point_code = next_device_code; - } - - //判断下一个输送线点位是否有货 - BeltConveyorDeviceDriver beltConveyorDeviceDriver; - //异常位到叠盘位 - FoldDiscSiteDeviceDriver foldDiscSiteDeviceDriver; - - if (nextdevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextdevice.getDeviceDriver(); - String ignorePickupCheck = (String) beltConveyorDeviceDriver.getExtraValue().get("ignore_pickup_check"); - if ("false".equals(ignorePickupCheck)) { - if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) { - log.error("输送机,{}未联机或执行中", next_device_code); - this.setNotCreateInstMessage("universal_notCreateInstMessage4"); - return false; - } - } - } else if (nextdevice.getDeviceDriver() instanceof FoldDiscSiteDeviceDriver) { - foldDiscSiteDeviceDriver = (FoldDiscSiteDeviceDriver) nextdevice.getDeviceDriver(); - if (foldDiscSiteDeviceDriver.getMode() != 2 || foldDiscSiteDeviceDriver.getMove() == 1) { - log.error("输送机,{}未联机或执行中", next_device_code); - this.setNotCreateInstMessage("universal_notCreateInstMessage4"); - return false; - } - } else { - //下一个设备不是输送线指令 - this.setNotCreateInstMessage("universal_notCreateInstMessage6"); - return false; - } - Instruction instdto = new Instruction(); - packageData(instdto, route_plan_code, taskdto, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code, priority, containerType, vehicleCode); - log.error("=================================,{}", instdto.getCreate_by()); - try { - instructionService.create(instdto); - } catch (Exception e) { - e.printStackTrace(); - log.error("指令创建失败!,{}", e.getMessage()); - return false; - } - return updateTask(taskdto, nextdevice, instdto); - } - - - } - return false; - } - } - - private boolean updateTask(TaskDto taskdto, Device nextdevice, Instruction instdto) { - taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskserver.update(taskdto); - String next_addr = nextdevice.getExtraValue().get("address").toString(); - String interactionJson = taskdto.getInteraction_json(); - InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); - String containerType = ""; - if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { - containerType = interactionJsonDTO.getContainerType(); - } - List list = new ArrayList(); - writeData(next_addr, list, instdto, containerType); -// led_message = getLedMessage(instdto); - requireSucess = true; - return true; - } - - private void writeData(String next_addr, List list, Instruction inst, String containerType) { - List list1 = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_target"); - map.put("value", next_addr); - list1.add(map); - this.writing(list1); - List list2 = new ArrayList(); - Map map1 = new HashMap(); - map1.put("code", "to_task"); - map1.put("value", inst.getInstruction_code()); - list2.add(map1); - this.writing(list2); - List list4 = new ArrayList(); - Map map3 = new HashMap(); - map3.put("code", "to_container_type"); - map3.put("value", containerType); - list4.add(map3); - this.writing(list4); - List list3 = new ArrayList(); - Map map2 = new HashMap(); - map2.put("code", "to_command"); - map2.put("value", "1"); - list3.add(map2); - this.writing(list3); - } - - private static void packageData(Instruction instdto, String route_plan_code, TaskDto taskdto, String taskid, String taskcode, String start_device_code, String next_device_code, String start_point_code, String next_point_code, String priority, String containerType, String vehicleCode) { - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(taskdto.getRemark()); - instdto.setMaterial(taskdto.getMaterial()); - instdto.setQuantity(taskdto.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by(SecurityUtils.getCurrentNickName()); - 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.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - instdto.setVehicle_type(containerType); - instdto.setVehicle_code(vehicleCode); - } - - public void writeData(String next_addr, Instruction instdto, Map map) { - - } - - public String getToParam() { - return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; - } - - public void writing(List list) { - - Map itemMap = new HashMap(); - for (int i = 0; i < list.size(); i++) { - Object ob = list.get(i); - JSONObject json = (JSONObject) JSONObject.toJSON(ob); - if (!StrUtil.isEmpty(json.getString("value"))) { - String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + json.getString("code"); - itemMap.put(to_param, json.getString("value")); - } - } - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("下发多个电气信号" + itemMap) - .build(); - logDto.setLog_level(3); - luceneExecuteLogService.deviceExecuteLog(logDto); - logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); - try { - this.checkcontrol(itemMap); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - public void writing(String key, String param) { - - String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + key; - //String opcservcerid = this.getDevice().getOpc_server_id(); - //Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - - itemMap.put(to_param, Integer.parseInt(param)); - //itemMap.put(to_param, Integer.parseInt(value)); - this.control(itemMap); - logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + param); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("下发多个电气信号" + itemMap) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - } - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String move = ""; - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = "1"; - } - if (this.getMode() == 0) { - mode = LangProcess.msg("universal_off-line"); - } else if (this.getMode() == 1) { - mode = LangProcess.msg("universal_stand-alone"); - } else if (this.getMode() == 2) { - mode = LangProcess.msg("universal_standby"); - } else if (this.getMode() == 3) { - mode = LangProcess.msg("universal_operation"); - } else if (this.getMode() == 5) { - mode = LangProcess.msg("one_mode3"); - } - - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("message", message); - jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError()))); - if (this.getMove() == 0) { - move = LangProcess.msg("universal_no"); - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = LangProcess.msg("universal_yes"); - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = LangProcess.msg("universal_two_yes"); - jo.put("hasGoods", true); - } - String container_type = ""; - if (this.container_type == 1) { - container_type = LangProcess.msg("universal_small_pallets"); - } else if (this.container_type == 2) { - container_type = LangProcess.msg("universal_large_pallets"); - } - jo.put("move", move); - jo.put("task", task); - jo.put("type", container_type); - jo.put("is_click", true); - jo.put("isOnline", this.getIsonline()); - jo.put("requireSucess", requireSucess); - jo.put("hand_barcode", hand_barcode); - jo.put("materiel", material_barcode); - jo.put("inst_message", this.inst_message); - jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); - jo.put("vehicle_code2", this.vehicle_code2); - return jo; - } - - - /** - * 更新指令状态 - */ - public synchronized void update_instruction_status() throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); - } else { - this.instruction_update_time = date; - inst = checkInst(); - if (inst != null) { - //a点到b点,给状态说允许取货 - if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex()) && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status(CommonFinalParam.ONE); - inst.setExecute_device_code(this.device_code); - instructionService.update(inst); - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task); - } - //当货物到达b点,实现完成指令 - - if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex()) || StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { - if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - inst.setExecute_device_code(this.device_code); - finish_instruction(); - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task); - } - } - } - } - } - - public Instruction checkInst() { - if (ObjectUtil.isNotEmpty(this.inst)) { - if (this.task > 0) { - if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { - return this.inst; - } else { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - return inst; - } - } - } else { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - return inst; - } - return null; - } - - - @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; - } - String hand_barcode = data.getString("hand_barcode"); - this.setHand_barcode(hand_barcode); - } - - public static boolean arrayEquals(int[] a, int[] b) { - // 判断两个数组长度是否相等 - if (a.length != b.length) { - return false; - } - // 判断两个数组对应位置上的元素是否相同 - for (int i = 0; i < a.length; i++) { - if (a[i] != b[i]) { - return false; - } - } - return true; - } - - -} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java deleted file mode 100644 index 3dac73a..0000000 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java +++ /dev/null @@ -1,197 +0,0 @@ -package org.nl.acs.device_driver.conveyor.belt_conveyor; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -@Data -public class ItemProtocol { - - /** - * 心跳 - */ - public static String item_heartbeat = "heartbeat"; - /** - * 工作模式 - */ - public static String item_mode = "mode"; - /** - * 光电信号 - */ - public static String item_move = "move"; - /** - * 动作信号 - */ - public static String item_action = "action"; - /** - * 报警 - */ - public static String item_error = "error"; - /** - * 托盘方向 - */ - public static String item_container_direction = "container_direction"; - /** - * 托盘类型 - */ - public static String item_container_type = "container_type"; - /** - * 任务号 - */ - public static String item_task = "task"; - - /** - * 下发命令 - */ - public static String item_to_command = "to_command"; - /** - * 下发托盘类型 - */ - public static String item_to_container_type = "to_container_type"; - /** - * 下发任务号 - */ - public static String item_to_task = "to_task"; - /** - * 下发目标站 - */ - public static String item_to_target = "to_target"; - - - - - - - - - private BeltConveyorDeviceDriver driver; - - public ItemProtocol(BeltConveyorDeviceDriver driver) { - this.driver = driver; - } - - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getMove() { - return this.getOpcIntegerValue(item_move); - } - - public int getContainer_direction() { - return this.getOpcIntegerValue(item_container_direction); - } - - public int getContainer_type() { - return this.getOpcIntegerValue(item_container_type); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public String getTo_task() { - return this.getOpcStringValue(item_to_task); - } - - - - - public String getTotarget() { - return this.getOpcStringValue(item_to_target); - } - - public String getTo_command() { - return this.getOpcStringValue(item_to_command); - } - - public int getTo_container_type() { - return this.getOpcIntegerValue(item_to_container_type); - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - } - - - public String getOpcStringValue(String protocol) { - String value = this.driver.getStringValue(protocol); - if (StrUtil.isBlank(value)) { - //throw new BusinessException("{} : {}", new Object[]{protocol, DeviceErrorProtocol.getMessage(10000)}); - - } else { - return value; - } - return ""; - } - - public int[] getOpcArrayValue(String protocol) { - int[] arrayValue = this.driver.getIntegeregerArrayValue(protocol); - if (ObjectUtil.isNull(arrayValue)) { - - } else { - return arrayValue; - } - return new int[3]; - } - - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB101.B0")); - list.add(new ItemDto(item_mode, "工作模式", "DB101.B2")); - list.add(new ItemDto(item_move, "光电信号", "DB101.B3")); - list.add(new ItemDto(item_container_direction, "托盘方向", "DB101.B4")); - list.add(new ItemDto(item_container_type, "托盘类型", "DB101.B5")); - list.add(new ItemDto(item_action, "动作类型", "DB101.B6")); - list.add(new ItemDto(item_error, "报警", "DB101.B58")); - list.add(new ItemDto(item_task, "任务号", "DB101.D68")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_target, "下发仓位号", "DB102.W2")); - list.add(new ItemDto(item_to_command, "下发命令", "DB102.W4")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB102.D1")); - list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB102.B5")); - - return list; - } - - @Override - public String toString() { - return ""; - } - -} - diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/Paper.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/Paper.java deleted file mode 100644 index d98844d..0000000 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/Paper.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.nl.acs.device_driver.conveyor.belt_conveyor; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; - -@Data -@NoArgsConstructor -@AllArgsConstructor -public class Paper implements Serializable { - /** - * 设备号 - */ - private String device_code; - - private String material_code; - private String qty; - -} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDeviceDriver.java index efbcb06..a786704 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDeviceDriver.java @@ -21,7 +21,7 @@ import org.nl.acs.device.service.DeviceExtraService; import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.belt_conveyor.BeltConveyorDeviceDriver; import org.nl.acs.device_driver.conveyor.double_station_stacker.enums.CommandEnum; import org.nl.acs.device_driver.conveyor.double_station_stacker.enums.SortEnum; import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver; @@ -561,7 +561,7 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im if (startDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) startDevice.getDeviceDriver(); if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 0) { - notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + beltConveyorDeviceDriver.getDevice_code() + + notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + beltConveyorDeviceDriver.getCurrentDeviceCode() + "无货或未联机,无法下发指令!指令号:" + inst.get(0).getInstruction_code(); return true; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDefination.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/belt_conveyor/BeltConveyorDefination.java similarity index 96% rename from acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDefination.java rename to acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/belt_conveyor/BeltConveyorDefination.java index 0008a24..2ab6340 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDefination.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/belt_conveyor/BeltConveyorDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.conveyor.belt_conveyor; +package org.nl.acs.device_driver.lk_conveyor.belt_conveyor; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/belt_conveyor/BeltConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/belt_conveyor/BeltConveyorDeviceDriver.java new file mode 100644 index 0000000..2fcd310 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/belt_conveyor/BeltConveyorDeviceDriver.java @@ -0,0 +1,608 @@ +package org.nl.acs.device_driver.lk_conveyor.belt_conveyor; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.common.util.concurrent.Uninterruptibles; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.enums.*; +import org.nl.acs.device_driver.one_manipulator.box_package_manipulator.InteractionJsonDTO; +import org.nl.acs.enums.StorageTypeEnum; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; +import org.nl.acs.instruction.domain.Instruction; +import org.nl.acs.instruction.enums.InstructionStatusEnum; +import org.nl.acs.instruction.service.InstructionService; +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.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.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.SpringContextHolder; +import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; + +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import java.util.stream.Collectors; + +/** + * 输送线 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { + + private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + private final TaskService taskService = SpringContextHolder.getBean(TaskService.class); + private final RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); + private final LuceneExecuteLogService logService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); + private final DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + + /** + * 心跳 + */ + private int heartbeat = 0; + private int lastHeartbeat = 0; + /** + * 工作模式 + */ + private int mode = 0; + private int lastMode = 0; + /** + * 光电信号 + */ + private int move = 0; + private int lastMove = 0; + /** + * 托盘方向 + */ + private int carrier_direction = 0; + private int lastCarrier_direction = 0; + /** + * 托盘类型 + */ + private int container_type = 0; + private int lastContainer_type = 0; + /** + * 动作信号 + */ + private int action = 0; + private int lastAction = 0; + /** + * 报警 + */ + private int error = 0; + private int lastError = 0; + /** + * 任务号 + */ + private int task = 0; + private int lastTask = 0; + /** + * 下发命令 + */ + private int to_command = 0; + private int lastTo_command = 0; + /** + * 下发目标站 + */ + private int to_target = 0; + private int lastTo_target = 0; + /** + * 下发任务号 + */ + private int to_task = 0; + private int lastTo_task = 0; + /** + * 下发托盘类型 + */ + private int to_container_type = 0; + private int lastTo_container_type = 0; + + /** + * 当前设备编号 + */ + private String currentDeviceCode = null; + /** + * 设备在线状态 + */ + private Boolean isOnline = false; + /** + * 消息 + */ + String message = null; + /** + * 设备报警标记 + */ + private boolean isError = false; + /** + * 请求标记 + */ + boolean requireSuccess = false; + /** + * 请求时间 + */ + private long requireTime = System.currentTimeMillis(); + /** + * 请求间隔时间 + */ + private long requireTimeOut = 5000L; + /** + * 未执行任务原因 + */ + private String unExecutedMessage = null; + /** + * 不需要记录日志的点位 + */ + private static final List No_SET_LOG_KEYS = Arrays.asList(ItemProtocol.HEARTBEAT.getKey()); + + private static final Lock LOCK = new ReentrantLock(); + + public void setLog(String key, Object newValue, Object oldValue) { + if (!No_SET_LOG_KEYS.contains(key)) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "设备线程读取信号:" + key + ",由" + oldValue + "->" + newValue)); + } + } + + /** + * 更新指令状态 + */ + public void update_instruction_status() throws Exception { + Instruction inst = instructionService.findByCodeFromCache(String.valueOf(this.task)); + if (ObjectUtil.isNotEmpty(inst)) { + if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex()) && StrUtil.equals(this.currentDeviceCode, inst.getStart_device_code())) { + inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.update(inst); + } else if (StrUtil.equals(this.currentDeviceCode, inst.getNext_device_code())) { + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.finish(inst); + } + } + } + + private void clearWrite() { + List keys = Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_CONTAINER_TYPE.getKey()); + List values = Arrays.asList(0, 0, 0); + this.writing(keys, values); + } + + + private boolean isTimeValid(long currentTimeMillis) { + return currentTimeMillis - this.requireTime >= this.requireTimeOut; + } + + + private boolean isIssued(Device device) { + boolean isTwoWay = Optional.ofNullable(device.getExtraValue().get("isTwoWayPoint")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + if (isTwoWay) { + Instruction instruction = instructionService.findByStartAndNextDeviceCode(device.getDevice_code()); + if (ObjectUtil.isNotEmpty(instruction)) { + return false; + } + } + return true; + } + + private int getTargetAddress(Device nextDevice) { + return Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0); + } + + private String getNextDeviceCode(TaskDto taskDto) { + List shortPathsList = routeLineService.getShortPathLines(taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code()); + if (ObjectUtils.isEmpty(shortPathsList)) { + return null; + } + RouteLineDto routeLineDto = shortPathsList.get(0); + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(taskDto.getStart_device_code())) { + index = m + 1; + break; + } + } + return pathlist.get(index); + } + + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + try { + this.currentDeviceCode = this.getDeviceCode(); + this.heartbeat = ItemProtocol.HEARTBEAT.getIntegerValue(this); + this.mode = ItemProtocol.MODE.getIntegerValue(this); + this.move = ItemProtocol.MOVE.getIntegerValue(this); + this.carrier_direction = ItemProtocol.CARRIER_DIRECTION.getIntegerValue(this); + this.container_type = ItemProtocol.CONTAINER_TYPE.getIntegerValue(this); + this.action = ItemProtocol.ACTION.getIntegerValue(this); + this.error = ItemProtocol.ERROR.getIntegerValue(this); + this.task = ItemProtocol.TASK.getIntegerValue(this); + this.to_target = ItemProtocol.TO_TARGET.getIntegerValue(this); + this.to_command = ItemProtocol.TO_COMMAND.getIntegerValue(this); + this.to_container_type = ItemProtocol.TO_CONTAINER_TYPE.getIntegerValue(this); + this.to_task = ItemProtocol.TO_TASK.getIntegerValue(this); + + if (this.heartbeat != this.lastHeartbeat) { + this.setLog(ItemProtocol.HEARTBEAT.getKey(), this.heartbeat, this.lastHeartbeat); + } + if (this.mode != this.lastMode) { + this.requireSuccess = false; + this.setLog(ItemProtocol.MODE.getKey(), this.mode, this.lastMode); + } + if (this.move != this.lastMove) { + this.setLog(ItemProtocol.MOVE.getKey(), this.move, this.lastMove); + } + if (this.action != this.lastAction) { + this.setLog(ItemProtocol.ACTION.getKey(), this.action, this.lastAction); + } + if (this.error != this.lastError) { + this.setLog(ItemProtocol.ERROR.getKey(), this.error, this.lastError); + } + if (this.container_type != this.lastContainer_type) { + this.setLog(ItemProtocol.CONTAINER_TYPE.getKey(), this.container_type, this.lastContainer_type); + } + if (this.carrier_direction != this.lastCarrier_direction) { + this.setLog(ItemProtocol.CARRIER_DIRECTION.getKey(), this.carrier_direction, this.lastCarrier_direction); + } + if (this.task != this.lastTask) { + this.setLog(ItemProtocol.TASK.getKey(), this.task, this.lastTask); + } + if (this.to_target != this.lastTo_target) { + this.setLog(ItemProtocol.TO_TARGET.getKey(), this.to_target, this.lastTo_target); + } + if (this.to_command != this.lastTo_command) { + this.setLog(ItemProtocol.TO_COMMAND.getKey(), this.to_command, this.lastTo_command); + } + if (this.to_task != this.lastTo_task) { + this.setLog(ItemProtocol.TO_TASK.getKey(), this.to_task, this.lastTo_task); + } + if (this.to_container_type != this.lastTo_container_type) { + this.setLog(ItemProtocol.TO_CONTAINER_TYPE.getKey(), this.to_container_type, this.lastTo_container_type); + } + if (this.move != this.lastMove && this.lastMove == 1 && this.mode > 0) { + this.requireSuccess = false; + clearWrite(); + } + + if (this.move != 0 && this.task > 0) { + update_instruction_status(); + } + + Boolean isApplyTask = Optional.ofNullable(this.getExtraValue().get("apply_task")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + //申请空托盘出库 + if (this.mode == 8 && !this.requireSuccess) { + if (this.container_type == 0) { + this.message = LangProcess.msg("310001"); + } else { + if (isApplyTask) { + applyEmptyTask(StorageTypeEnum.DISKS_OUT.getType(), this.mode); + } else { + this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode); + } + } + } + + //退货异常申请桁架任务 + if (this.mode == 24 && !this.requireSuccess) { + if (this.container_type == 0) { + this.message = LangProcess.msg("310001"); + } else { + if (isApplyTask) { + applyEmptyTask(StorageTypeEnum.BOX_RETURN_HJ.getType(), this.mode); + } else { + this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode); + } + } + } + + //装箱异常申请任务 + if (this.mode == 25 && !this.requireSuccess) { + if (this.container_type == 0) { + this.message = LangProcess.msg("310001"); + } else { + if (isApplyTask) { + applyEmptyTask(StorageTypeEnum.PACK_ERROR.getType(), this.mode); + } else { + this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode); + } + } + } + + if (this.mode == 0) { + this.isOnline = false; + this.message = LangProcess.msg("110000"); + } else if (this.error != 0) { + this.isError = true; + this.message = LangProcess.msg(ErrorEnum.getDesc(this.error)); + } else { + this.isOnline = true; + this.isError = false; + this.message = null; + + if (this.mode == 2 && this.move == 1 && !this.requireSuccess) { + instruction_require(); + } + + } + + this.lastHeartbeat = this.heartbeat; + this.lastMode = this.mode; + this.lastMove = this.move; + this.lastAction = this.action; + this.lastError = this.error; + this.lastTask = this.task; + this.lastTo_command = this.to_command; + this.lastTo_target = this.to_target; + this.lastTo_task = this.to_task; + this.lastTo_container_type = this.to_container_type; + this.lastContainer_type = this.container_type; + this.lastCarrier_direction = this.carrier_direction; + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1005"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "当前设备执行逻辑报错, 错误详情: " + e.getMessage() + ", 错误堆栈信息: " + Arrays.toString(e.getStackTrace()))); + Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); + } + } + + private void applyEmptyTask(String type, int mode) { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + JSONObject param = new JSONObject(); + param.put("device_code", this.currentDeviceCode); + param.put("container_type", this.container_type); + param.put("type", type); + HttpResponse httpResponse = acsToWmsService.applyTwo(param); + if (httpResponse != null) { + JSONObject resp = JSONObject.parseObject(httpResponse.body()); + if (resp != null && resp.getIntValue("status") == 200) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), mode); + this.requireSuccess = true; + } else { + this.message = LangProcess.msg("310002"); + } + } else { + this.message = LangProcess.msg("310002"); + } + } + } + + + /** + * 申请任务 + */ + public void instruction_require() { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + //查找有没有对应的指令 + Instruction inst = instructionService.findByStartCodeAndReady(this.currentDeviceCode); + if (ObjectUtil.isNotEmpty(inst)) { + //获取起点配置的目标站点,若指令终点不是配置的目标站点,则不下发 + List targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode"); + if (!targetDeviceCode.contains(inst.getNext_device_code())) { + this.unExecutedMessage = LangProcess.msg("310003"); + return; + } + Device nextDevice = deviceAppService.findDeviceByCode(inst.getNext_device_code()); + if (nextDevice == null) { + this.unExecutedMessage = LangProcess.msg("1008") + ":" + inst.getNext_device_code(); + return; + } + if (!this.isIssued(nextDevice)) { + this.unExecutedMessage = LangProcess.msg("310004"); + return; + } + TaskDto taskDto = taskService.findByCodeFromCache(inst.getTask_code()); + String interactionJson = taskDto.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String containerType = "0"; + if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { + containerType = interactionJsonDTO.getContainerType(); + } + List keys = Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_CONTAINER_TYPE.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(getTargetAddress(nextDevice), Integer.parseInt(inst.getInstruction_code()), Integer.parseInt(containerType), 1); + this.writing(keys, values); + this.requireSuccess = true; + return; + } + + boolean isCreateInst = Optional.ofNullable(this.getExtraValue().get("isCreateInst")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + if (!isCreateInst) { + this.unExecutedMessage = LangProcess.msg("310005"); + return; + } + //入库异常口为起点的任务 + TaskDto taskDto = taskService.findByStartCodeAndReady(this.currentDeviceCode); + if (ObjectUtil.isNotEmpty(taskDto)) { + String next_device_code = null; + String assignedDeviceCode = taskService.queryAssignedByDevice(this.currentDeviceCode, taskDto.getNext_device_code()); + if (StrUtil.isEmpty(assignedDeviceCode)) { + next_device_code = this.getNextDeviceCode(taskDto); + if (next_device_code == null) { + this.unExecutedMessage = taskDto.getStart_device_code() + "->" + next_device_code + LangProcess.msg("1009"); + return; + } + } else { + next_device_code = assignedDeviceCode; + } + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + if (nextDevice == null) { + this.unExecutedMessage = LangProcess.msg("1008") + ":" + next_device_code; + return; + } + List targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode"); + if (!targetDeviceCode.contains(inst.getNext_device_code())) { + this.unExecutedMessage = LangProcess.msg("310006"); + return; + } + //判断终点是否是双向点位 + if (!this.isIssued(nextDevice)) { + this.unExecutedMessage = LangProcess.msg("310004"); + return; + } + Instruction instDto = new Instruction(); + try { + packageInst(instDto, taskDto, next_device_code); + instructionService.create(instDto); + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1006"); + return; + } + taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskService.update(taskDto); + String interactionJson = taskDto.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String containerType = "0"; + if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { + containerType = interactionJsonDTO.getContainerType(); + } + List keys = Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_CONTAINER_TYPE.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(getTargetAddress(nextDevice), Integer.parseInt(instDto.getInstruction_code()), Integer.parseInt(containerType), ToCommandEnum.COMMAND_ONE.getSignalNum()); + this.writing(keys, values); + this.requireSuccess = true; + } + } + } + + /** + * 下发单个电气信号 + * + * @param key + * @param value + */ + public void writing(String key, Object value) { + Map itemMap = new HashMap(); + itemMap.put(getId() + key, value); + try { + this.checkcontrol(itemMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 下发多个电气信号 + * + * @param keys + * @param values + */ + public void writing(List keys, List values) { + if (keys.size() != values.size()) { + this.message = LangProcess.msg("1007"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "参数长度不一致,不允许下发")); + throw new BadRequestException("参数长度不一致,不允许下发"); + } + Map controlMap = new LinkedHashMap<>(); + for (int i = 0; i < keys.size(); i++) { + controlMap.put(getId() + keys.get(i), values.get(i)); + } + try { + this.checkcontrol(controlMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 抽取统一下发电气信号前缀 + * + * @return + */ + public String getId() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } + + private void packageInst(Instruction instDto, TaskDto taskDto, String next_device_code) { + instDto.setInstruction_id(IdUtil.simpleUUID()); + instDto.setRoute_plan_code(taskDto.getRoute_plan_code()); + instDto.setRemark(taskDto.getRemark()); + instDto.setMaterial(taskDto.getMaterial()); + instDto.setQuantity(taskDto.getQuantity()); + instDto.setTask_id(taskDto.getTask_id()); + instDto.setTask_code(taskDto.getTask_code()); + instDto.setVehicle_code(taskDto.getVehicle_code()); + String now = DateUtil.now(); + instDto.setCreate_time(now); + instDto.setCreate_by(SecurityUtils.getCurrentNickName()); + instDto.setStart_device_code(taskDto.getStart_device_code()); + instDto.setNext_device_code(next_device_code); + instDto.setStart_point_code(taskDto.getStart_point_code()); + instDto.setNext_point_code(next_device_code); + instDto.setPriority(taskDto.getPriority()); + instDto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); + instDto.setExecute_device_code(this.currentDeviceCode); + instDto.setInstruction_type(taskDto.getTask_type()); + instDto.setVehicle_type(taskDto.getVehicle_type()); + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", LangProcess.msg(ModeEnum.getDescByNum(this.mode))); + jo.put("move", LangProcess.msg(MoveEnum.getDescByNum(this.move))); + jo.put("hasGoods", this.move == 1 ? true : false); + jo.put("error", LangProcess.msg(ErrorEnum.getDesc(this.getError()))); + jo.put("isError", this.isError); + jo.put("container_type", LangProcess.msg(ContainerTypeEnum.getDescByNum(this.container_type))); + jo.put("action", LangProcess.msg(ActionEnum.getDescByNum(this.action))); + jo.put("task", this.task); + jo.put("message", this.message); + jo.put("unExecutedMessage", this.unExecutedMessage); + jo.put("is_click", true); + jo.put("driver_type", "belt_conveyor"); + jo.put("isOnline", this.isOnline); + jo.put("requireSuccess", this.requireSuccess); + return jo; + } + + + @Override + public void setDeviceStatus(JSONObject data) { + Boolean requireSuccess = data.getBoolean("requireSuccess"); + if (requireSuccess != null) { + this.requireSuccess = requireSuccess; + } + } + +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/belt_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/belt_conveyor/ItemProtocol.java new file mode 100644 index 0000000..f7beab0 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/belt_conveyor/ItemProtocol.java @@ -0,0 +1,93 @@ +package org.nl.acs.device_driver.lk_conveyor.belt_conveyor; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + +public enum ItemProtocol { + + HEARTBEAT("heartbeat", "心跳", "DB1.B0"), + MODE("mode", "工作模式", "DB1.B2"), + MOVE("move", "光电信号", "DB1.B3"), + CARRIER_DIRECTION("carrier_direction", "托盘方向", "DB1.B4"), + CONTAINER_TYPE("container_type", "载具类型", "DB1.B5"), + ACTION("action", "取放信号", "DB1.B6"), + ERROR("error", "报警信号", "DB1.B58"), + TASK("task", "任务号", "DB1.D68"), + TO_TARGET("to_target", "下发目标站", "DB2.W2"), + TO_COMMAND("to_command", "下发命令", "DB2.W4"), + TO_CONTAINER_TYPE("to_container_type", "下发托盘类型", "DB2.B5"), + TO_TASK("to_task", "下发任务号", "DB2.D1"); + + private final String key; + private final String description; + private final String address; + + ItemProtocol(String key, String description, String address) { + this.key = key; + this.description = description; + this.address = address; + } + + public String getKey() { + return this.key; + } + + public String getDescription() { + return description; + } + + public String getAddress() { + return address; + } + + // 获取 Integer 类型的值 + public Integer getIntegerValue(BeltConveyorDeviceDriver driver) { + Integer value = driver.getIntegerValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0; + } + + // 获取 Float 类型的值 + public Float getFloatValue(BeltConveyorDeviceDriver driver) { + Float value = driver.getFloatValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0.00f; + } + + public String getStringValue(BeltConveyorDeviceDriver driver) { + return driver.getStringValue(this.getKey()); + } + + public static List getReadableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (!prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } + + public static List getWriteableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } +} + diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDefination.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDefination.java similarity index 87% rename from acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDefination.java rename to acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDefination.java index 49523a5..194b3ef 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDefination.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.one_conveyor.box_subvolumes_conveyor; +package org.nl.acs.device_driver.lk_conveyor.box_subvolumes_conveyor; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; @@ -12,8 +12,6 @@ import java.util.List; /** * 一楼木箱机械手、子卷机械手对接位 - * - * */ @Service public class BoxSubvolumesConveyorDefination implements OpcDeviceDriverDefination { @@ -24,12 +22,12 @@ public class BoxSubvolumesConveyorDefination implements OpcDeviceDriverDefinatio @Override public String getDriverName() { - return "一楼木箱机械手、子卷机械手对接位"; + return "出库AGV对接位"; } @Override public String getDriverDescription() { - return "一楼木箱机械手、子卷机械手对接位"; + return "出库AGV对接位"; } @Override @@ -56,7 +54,6 @@ public class BoxSubvolumesConveyorDefination implements OpcDeviceDriverDefinatio } - @Override public List getWriteableItemDtos() { return ItemProtocol.getWriteableItemDtos(); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java new file mode 100644 index 0000000..064262d --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java @@ -0,0 +1,619 @@ +package org.nl.acs.device_driver.lk_conveyor.box_subvolumes_conveyor; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.common.util.concurrent.Uninterruptibles; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.enums.*; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.instruction.domain.Instruction; +import org.nl.acs.instruction.enums.InstructionStatusEnum; +import org.nl.acs.instruction.service.InstructionService; +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.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.SpringContextHolder; +import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; +import org.nl.system.service.param.ISysParamService; + +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import java.util.stream.Collectors; + +/** + * 一楼木箱机械手、子卷机械手对接位 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver + implements DeviceDriver, + ExecutableDeviceDriver, + RouteableDeviceDriver, + DeviceStageMonitor { + + private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + private final TaskService taskService = SpringContextHolder.getBean(TaskService.class); + private final DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); + private final RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); + private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class); + private final ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); + + /** + * 心跳 + */ + private int heartbeat = 0; + private int lastHeartbeat = 0; + /** + * 工作模式 + */ + private int mode = 0; + private int lastMode = 0; + /** + * 光电信号 + */ + private int move = 0; + private int lastMove = 0; + /** + * 托盘方向 + */ + private int carrier_direction = 0; + private int lastCarrier_direction = 0; + /** + * 动作信号 + */ + private int action = 0; + private int lastAction = 0; + /** + * 报警信号 + */ + private int error = 0; + private int lastError = 0; + /** + * 托盘类型 + */ + private int container_type = 0; + private int lastContainer_type = 0; + /** + * 任务号 + */ + private int task = 0; + private int lastTask = 0; + /** + * 木箱条码或子卷条码 + */ + private String material_code = null; + private String lastMaterial_code = null; + /** + * 下发命令 + */ + private int to_command = 0; + private int lastTo_command = 0; + /** + * 下发目标站 + */ + private int to_target = 0; + private int lastTo_target = 0; + /** + * 下发任务号 + */ + private int to_task = 0; + private int lastTo_task = 0; + /** + * 下发托盘类型 + */ + private int to_container_type = 0; + private int lastTo_container_type = 0; + /** + * 当前设备编号 + */ + private String currentDeviceCode = null; + /** + * 设备在线状态 + */ + private Boolean isOnline = false; + /** + * 消息 + */ + String message = null; + /** + * 设备报警标记 + */ + private boolean isError = false; + /** + * 请求标记 + */ + boolean requireSuccess = false; + /** + * 请求时间 + */ + private long requireTime = System.currentTimeMillis(); + /** + * 请求间隔时间 + */ + private long requireTimeOut = 5000L; + /** + * 未执行任务原因 + */ + private String unExecutedMessage = null; + /** + * 不需要记录日志的点位 + */ + private static final List No_SET_LOG_KEYS = Arrays.asList(ItemProtocol.HEARTBEAT.getKey()); + + /** + * 手补条码 + */ + private String hand_barcode = null; + + private static final Lock LOCK = new ReentrantLock(); + + + public void setLog(String key, Object newValue, Object oldValue) { + if (!No_SET_LOG_KEYS.contains(key)) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "设备线程读取信号:" + key + ",由" + oldValue + "->" + newValue)); + } + } + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + try { + this.currentDeviceCode = this.getDevice().getDevice_code(); + this.heartbeat = ItemProtocol.HEARTBEAT.getIntegerValue(this); + this.mode = ItemProtocol.MODE.getIntegerValue(this); + this.move = ItemProtocol.MOVE.getIntegerValue(this); + this.action = ItemProtocol.ACTION.getIntegerValue(this); + this.error = ItemProtocol.ERROR.getIntegerValue(this); + this.container_type = ItemProtocol.CONTAINER_TYPE.getIntegerValue(this); + this.carrier_direction = ItemProtocol.CARRIER_DIRECTION.getIntegerValue(this); + this.task = ItemProtocol.TASK.getIntegerValue(this); + this.material_code = ItemProtocol.MATERIAL_CODE.getStringValue(this); + this.to_command = ItemProtocol.TO_COMMAND.getIntegerValue(this); + this.to_target = ItemProtocol.TO_TARGET.getIntegerValue(this); + this.to_task = ItemProtocol.TO_TASK.getIntegerValue(this); + this.to_container_type = ItemProtocol.TO_CONTAINER_TYPE.getIntegerValue(this); + + if (this.heartbeat != this.lastHeartbeat) { + this.setLog(ItemProtocol.HEARTBEAT.getKey(), this.heartbeat, this.lastHeartbeat); + } + if (this.mode != this.lastMode) { + this.requireSuccess = false; + this.setLog(ItemProtocol.MODE.getKey(), this.mode, this.lastMode); + } + if (this.move != this.lastMove) { + this.setLog(ItemProtocol.MOVE.getKey(), this.move, this.lastMove); + } + if (this.action != this.lastAction) { + this.setLog(ItemProtocol.ACTION.getKey(), this.action, this.lastAction); + } + if (this.error != this.lastError) { + this.setLog(ItemProtocol.ERROR.getKey(), this.error, this.lastError); + } + if (this.container_type != this.lastContainer_type) { + this.setLog(ItemProtocol.CONTAINER_TYPE.getKey(), this.container_type, this.lastContainer_type); + } + if (this.carrier_direction != this.lastCarrier_direction) { + this.setLog(ItemProtocol.CARRIER_DIRECTION.getKey(), this.carrier_direction, this.lastCarrier_direction); + } + if (!StrUtil.equals(this.material_code, this.lastMaterial_code)) { + this.setLog(ItemProtocol.MATERIAL_CODE.getKey(), this.material_code, this.lastMaterial_code); + } + if (this.task != this.lastTask) { + this.setLog(ItemProtocol.TASK.getKey(), this.task, this.lastTask); + } + if (this.to_command != this.lastTo_command) { + this.setLog(ItemProtocol.TO_COMMAND.getKey(), this.to_command, this.lastTo_command); + } + if (this.to_target != this.lastTo_target) { + this.setLog(ItemProtocol.TO_TARGET.getKey(), this.to_target, this.lastTo_target); + } + if (this.to_task != this.lastTo_task) { + this.setLog(ItemProtocol.TO_TASK.getKey(), this.to_task, this.lastTo_task); + } + if (this.to_container_type != this.lastTo_container_type) { + this.setLog(ItemProtocol.TO_CONTAINER_TYPE.getKey(), this.to_container_type, this.lastTo_container_type); + } + if (this.to_container_type != this.lastTo_container_type) { + this.setLog(ItemProtocol.TO_CONTAINER_TYPE.getKey(), this.to_container_type, this.lastTo_container_type); + } + + if (this.move != 0 && this.task > 0) { + update_instruction_status(); + } + + if (this.move != this.lastMove && this.move == 0 && this.lastMove == 1 && this.mode > 0) { + this.requireSuccess = false; + clearWrite(); + } + + + if (this.mode == 0) { + this.isOnline = false; + this.message = LangProcess.msg("110000"); + } else if (this.error > 0) { + this.isError = true; + this.message = LangProcess.msg(ErrorEnum.getDesc(this.error)); + } else { + this.isOnline = true; + this.isError = false; + this.message = null; + + Boolean isApplyTask = Optional.ofNullable(this.getExtraValue().get("apply_task")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + + switch (this.mode) { + case 19: + //申请AGV任务 + if (this.move == 1 && !this.requireSuccess) { + if (StrUtil.isEmpty(this.material_code)) { + this.message = LangProcess.msg("310007"); + } else { + if (isApplyTask) { + applyAgvTask(); + } else { + this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode); + } + } + } + break; + case 2: + //申请任务 + if (this.move > 0 && !this.requireSuccess) { + instruction_require(); + } + break; + } + } + this.lastHeartbeat = this.heartbeat; + this.lastMode = this.mode; + this.lastMove = this.move; + this.lastAction = this.action; + this.lastError = this.error; + this.lastContainer_type = this.container_type; + this.lastCarrier_direction = this.carrier_direction; + this.lastTask = this.task; + this.lastMaterial_code = this.material_code; + this.lastTo_task = this.to_task; + this.lastTo_command = this.to_command; + this.lastTo_target = this.to_target; + this.lastTo_container_type = this.to_container_type; + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1005"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "当前设备执行逻辑报错, 错误详情: " + e.getMessage() + ", 错误堆栈信息: " + Arrays.toString(e.getStackTrace()))); + Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); + } + } + + private void clearWrite() { + List keys = Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_CONTAINER_TYPE.getKey()); + List values = Arrays.asList(0, 0, 0); + this.writing(keys, values); + } + + private boolean isTimeValid(long currentTimeMillis) { + return currentTimeMillis - this.requireTime >= this.requireTimeOut; + } + + private boolean isIssued(Device device) { + boolean isTwoWay = Optional.ofNullable(device.getExtraValue().get("isTwoWayPoint")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + if (isTwoWay) { + Instruction instruction = instructionService.findByStartAndNextDeviceCode(device.getDevice_code()); + if (ObjectUtil.isNotEmpty(instruction)) { + return false; + } + } + return true; + } + + private int getTargetAddress(Device nextDevice) { + return Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0); + } + + private String getNextDeviceCode(TaskDto taskDto) { + List shortPathsList = routeLineService.getShortPathLines(taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code()); + if (ObjectUtils.isEmpty(shortPathsList)) { + return null; + } + RouteLineDto routeLineDto = shortPathsList.get(0); + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(taskDto.getStart_device_code())) { + index = m + 1; + break; + } + } + return pathlist.get(index); + } + + public void applyAgvTask() { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + } + Boolean isApplyAgvTask = Optional.ofNullable(this.getExtraValue().get("isApplyAgvTask")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + if (!isApplyAgvTask) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode); + this.message = LangProcess.msg("310008"); + return; + } + //判断是否有手动补码 如果有就申请补码agv任务 + if (StrUtil.isNotEmpty(this.hand_barcode)) { + JSONObject apply = new JSONObject(); + apply.put("device_code", this.currentDeviceCode); + apply.put("vehicle_code", this.hand_barcode); + String str = acsToWmsService.applySendOutTwo(apply); + if (StrUtil.isNotBlank(str)) { + JSONObject jo = JSON.parseObject(str); + if (jo.getIntValue("status") == 200) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode); + this.hand_barcode = null; + this.requireSuccess = true; + } else { + this.message = LangProcess.msg("310002"); + } + } else { + this.message = LangProcess.msg("310002"); + } + return; + } + JSONObject apply = new JSONObject(); + apply.put("device_code", this.currentDeviceCode); + apply.put("vehicle_code", this.material_code); + String str = acsToWmsService.applySendOutTwo(apply); + if (StrUtil.isNotBlank(str)) { + JSONObject jo = JSON.parseObject(str); + if (jo.getIntValue("status") == 200) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode); + this.requireSuccess = true; + } else { + this.message = LangProcess.msg("310002"); + } + } else { + this.message = LangProcess.msg("310002"); + } + } + + + /** + * 请求指令 + */ + public void instruction_require() { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + //先查询是否有就绪状态下的指令 + Instruction inst = instructionService.findByDeviceCodeFromCache(this.currentDeviceCode); + if (ObjectUtil.isNotEmpty(inst)) { + List targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode"); + if (!targetDeviceCode.contains(inst.getNext_device_code())) { + this.unExecutedMessage = LangProcess.msg("310003"); + return; + } + Device nextDevice = deviceAppService.findDeviceByCode(inst.getNext_device_code()); + if (nextDevice == null) { + this.unExecutedMessage = LangProcess.msg("1008") + ":" + inst.getNext_device_code(); + return; + } + if (!this.isIssued(nextDevice)) { + this.unExecutedMessage = LangProcess.msg("310004"); + return; + } + this.writing(Arrays.asList(ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_COMMAND.getKey()), + Arrays.asList(Integer.parseInt(inst.getInstruction_code()), getTargetAddress(nextDevice), ToCommandEnum.COMMAND_ONE.getSignalNum())); + this.requireSuccess = true; + return; + } + boolean isCreateInst = Optional.ofNullable(this.getExtraValue().get("isCreateInst")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + if (!isCreateInst) { + this.unExecutedMessage = LangProcess.msg("310005"); + return; + } + //如果为空,则查找就绪的任务,并创建指令下发给电气 + TaskDto taskDto = taskService.findByStartCodeAndReady(this.currentDeviceCode); + if (ObjectUtil.isNotEmpty(taskDto)) { + String next_device_code = null; + String assignedDeviceCode = taskService.queryAssignedByDevice(this.currentDeviceCode, taskDto.getNext_device_code()); + if (StrUtil.isEmpty(assignedDeviceCode)) { + next_device_code = this.getNextDeviceCode(taskDto); + if (next_device_code == null) { + this.unExecutedMessage = taskDto.getStart_device_code() + "->" + next_device_code + LangProcess.msg("1009"); + return; + } + } else { + next_device_code = assignedDeviceCode; + } + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + if (nextDevice == null) { + this.unExecutedMessage = LangProcess.msg("1008") + ":" + next_device_code; + return; + } + List targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode"); + if (!targetDeviceCode.contains(inst.getNext_device_code())) { + this.unExecutedMessage = LangProcess.msg("310006"); + return; + } + //判断终点是否是双向点位 + if (!this.isIssued(nextDevice)) { + this.unExecutedMessage = LangProcess.msg("310004"); + return; + } + Instruction instDto = new Instruction(); + try { + packageInst(instDto, taskDto, next_device_code); + instructionService.create(instDto); + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1006"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 原因:" + e.getMessage())); + return; + } + //创建指令后修改任务状态 + taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskService.update(taskDto); + List keys = Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(getTargetAddress(nextDevice), Integer.parseInt(instDto.getInstruction_code()), ToCommandEnum.COMMAND_ONE.getSignalNum()); + this.writing(keys, values); + this.requireSuccess = true; + this.unExecutedMessage = ""; + } + } + } + + private void packageInst(Instruction instDto, TaskDto taskDto, String next_device_code) { + instDto.setInstruction_id(IdUtil.simpleUUID()); + instDto.setRoute_plan_code(taskDto.getRoute_plan_code()); + instDto.setRemark(taskDto.getRemark()); + instDto.setMaterial(taskDto.getMaterial()); + instDto.setQuantity(taskDto.getQuantity()); + instDto.setTask_id(taskDto.getTask_id()); + instDto.setTask_code(taskDto.getTask_code()); + instDto.setVehicle_code(taskDto.getVehicle_code()); + String now = DateUtil.now(); + instDto.setCreate_time(now); + instDto.setCreate_by(SecurityUtils.getCurrentNickName()); + instDto.setStart_device_code(taskDto.getStart_device_code()); + instDto.setNext_device_code(next_device_code); + instDto.setStart_point_code(taskDto.getStart_point_code()); + instDto.setNext_point_code(next_device_code); + instDto.setPriority(taskDto.getPriority()); + instDto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); + instDto.setExecute_device_code(this.currentDeviceCode); + instDto.setInstruction_type(taskDto.getTask_type()); + instDto.setVehicle_type(taskDto.getVehicle_type()); + } + + /** + * 更新指令状态 + */ + public void update_instruction_status() throws Exception { + Instruction inst = instructionService.findByCodeFromCache(String.valueOf(this.task)); + if (ObjectUtil.isNotEmpty(inst)) { + if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex()) && StrUtil.equals(this.currentDeviceCode, inst.getStart_device_code())) { + inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.update(inst); + } else if (StrUtil.equals(this.currentDeviceCode, inst.getNext_device_code())) { + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.finish(inst); + } + } + } + + /** + * 下发单个电气信号 + * + * @param key + * @param value + */ + public void writing(String key, Object value) { + Map itemMap = new HashMap(); + itemMap.put(getId() + key, value); + try { + this.checkcontrol(itemMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 下发多个电气信号 + * + * @param keys + * @param values + */ + public void writing(List keys, List values) { + if (keys.size() != values.size()) { + this.message = LangProcess.msg("1007"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "参数长度不一致,不允许下发")); + throw new BadRequestException("参数长度不一致,不允许下发"); + } + Map controlMap = new LinkedHashMap<>(); + for (int i = 0; i < keys.size(); i++) { + controlMap.put(getId() + keys.get(i), values.get(i)); + } + try { + this.checkcontrol(controlMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 抽取统一下发电气信号前缀 + * + * @return + */ + public String getId() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", LangProcess.msg(ModeEnum.getDescByNum(this.mode))); + jo.put("move", LangProcess.msg(MoveEnum.getDescByNum(this.move))); + jo.put("hasGoods", this.move == 1 ? true : false); + jo.put("error", LangProcess.msg(ErrorEnum.getDesc(this.getError()))); + jo.put("isError", this.isError); + jo.put("container_type", LangProcess.msg(ContainerTypeEnum.getDescByNum(this.container_type))); + jo.put("action", LangProcess.msg(ActionEnum.getDescByNum(this.action))); + jo.put("task", this.task); + jo.put("isOnline", this.isOnline); + jo.put("message", this.message); + jo.put("unExecutedMessage", this.unExecutedMessage); + jo.put("hand_barcode", this.hand_barcode); + jo.put("material_code", this.material_code); + jo.put("is_click", true); + jo.put("requireSuccess", this.requireSuccess); + jo.put("driver_type", "box_subvolumes_conveyor"); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + Boolean requireSuccess = data.getBoolean("requireSuccess"); + if (requireSuccess != null) { + this.requireSuccess = requireSuccess; + } + String hand_barcode = data.getString("hand_barcode"); + this.setHand_barcode(hand_barcode); + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/box_subvolumes_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/box_subvolumes_conveyor/ItemProtocol.java new file mode 100644 index 0000000..af4f32d --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/box_subvolumes_conveyor/ItemProtocol.java @@ -0,0 +1,94 @@ +package org.nl.acs.device_driver.lk_conveyor.box_subvolumes_conveyor; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + + +public enum ItemProtocol { + HEARTBEAT("heartbeat", "心跳", "DB600.B0"), + MODE("mode", "工作模式", "DB600.B2"), + MOVE("move", "光电信号", "DB600.B3"), + CARRIER_DIRECTION("carrier_direction", "托盘方向", "DB600.B4"), + ACTION("action", "取放信号", "DB600.B5"), + ERROR("error", "报警信号", "DB600.B6"), + CONTAINER_TYPE("container_type", "载具类型", "DB600.B7"), + TASK("task", "任务号", "DB600.D8"), + MATERIAL_CODE("material_code", "物料条码", "DB600.D9"), + TO_COMMAND("to_command", "下发命令", "DB601.W2"), + TO_TARGET("to_target", "下发目标站", "DB601.W4"), + TO_CONTAINER_TYPE("to_container_type", "下发托盘类型", "DB601.W6"), + TO_TASK("to_task", "下发任务号", "DB601.D8"); + + private final String key; + private final String description; + private final String address; + + ItemProtocol(String key, String description, String address) { + this.key = key; + this.description = description; + this.address = address; + } + + public String getKey() { + return this.key; + } + + public String getDescription() { + return description; + } + + public String getAddress() { + return address; + } + + // 获取 Integer 类型的值 + public Integer getIntegerValue(BoxSubvolumesConveyorDeviceDriver driver) { + Integer value = driver.getIntegerValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0; + } + + // 获取 Float 类型的值 + public Float getFloatValue(BoxSubvolumesConveyorDeviceDriver driver) { + Float value = driver.getFloatValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0.00f; + } + + public String getStringValue(BoxSubvolumesConveyorDeviceDriver driver) { + return driver.getStringValue(this.getKey()); + } + + public static List getReadableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (!prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } + + public static List getWriteableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } +} + diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ActionEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ActionEnum.java new file mode 100644 index 0000000..c906815 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ActionEnum.java @@ -0,0 +1,29 @@ +package org.nl.acs.device_driver.lk_conveyor.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Description TODO + * @Author Gengby + * @Date 2024/5/17 + */ +@Getter +@AllArgsConstructor +public enum ActionEnum { + + ACTION_0(0, "1013"), + ACTION_1(1, "1014"); + + private final Integer num; + private final String desc; + + public static String getDescByNum(Integer num) { + for (ActionEnum mode : ActionEnum.values()) { + if (mode.getNum().equals(num)) { + return mode.getDesc(); + } + } + return "1010"; + } +} \ No newline at end of file diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ContainerTypeEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ContainerTypeEnum.java new file mode 100644 index 0000000..c9cd1df --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ContainerTypeEnum.java @@ -0,0 +1,29 @@ +package org.nl.acs.device_driver.lk_conveyor.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Description TODO + * @Author Gengby + * @Date 2024/5/17 + */ +@Getter +@AllArgsConstructor +public enum ContainerTypeEnum { + + TYPE_1(1, "1015"), + TYPE_2(2, "1016"); + + private final Integer num; + private final String desc; + + public static String getDescByNum(Integer num) { + for (ContainerTypeEnum mode : ContainerTypeEnum.values()) { + if (mode.getNum().equals(num)) { + return mode.getDesc(); + } + } + return "1010"; + } +} \ No newline at end of file diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ErrorEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ErrorEnum.java new file mode 100644 index 0000000..b6dc101 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ErrorEnum.java @@ -0,0 +1,67 @@ +package org.nl.acs.device_driver.lk_conveyor.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Description TODO + * @Author Gengby + * @Date 2024/6/26 + */ +@Getter +@AllArgsConstructor +public enum ErrorEnum { + NO(0, "210000"), + ERROR_1(1, "210001"), + ERROR_2(2, "210002"), + ERROR_3(3, "210003"), + ERROR_4(4, "210004"), + ERROR_5(5, "210005"), + ERROR_6(6, "210006"), + ERROR_7(7, "210007"), + ERROR_8(8, "210008"), + ERROR_9(9, "210009"), + ERROR_10(10, "210010"), + ERROR_11(11, "210011"), + ERROR_12(12, "210012"), + ERROR_13(13, "210013"), + ERROR_14(14, "210014"), + ERROR_15(15, "210015"), + ERROR_16(16, "210016"), + ERROR_17(17, "210017"), + ERROR_18(18, "210018"), + ERROR_19(19, "210019"), + ERROR_20(20, "210020"), + ERROR_21(21, "210021"), + ERROR_22(22, "210022"), + ERROR_23(23, "210023"), + ERROR_24(24, "210024"), + ERROR_25(25, "210025"), + ERROR_26(26, "210026"), + ERROR_27(27, "210027"), + ERROR_28(28, "210028"), + ERROR_29(29, "210029"), + ERROR_30(30, "210030"), + ERROR_31(31, "210031"), + ERROR_32(32, "210032"), + ERROR_33(33, "210033"), + ERROR_34(34, "210034"), + ERROR_35(35, "210035"), + ERROR_36(36, "210036"), + ERROR_37(37, "210037"), + ERROR_38(38, "210038"), + ERROR_40(40, "210040"), + ERROR_41(41, "210041"); + + private int code; + private String desc; + + public static String getDesc(Integer code) { + for (ErrorEnum e : ErrorEnum.values()) { + if (e.getCode() == code) { + return e.getDesc(); + } + } + return "未知报警信息"; + } +} \ No newline at end of file diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ModeEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ModeEnum.java new file mode 100644 index 0000000..e4264ec --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ModeEnum.java @@ -0,0 +1,53 @@ +package org.nl.acs.device_driver.lk_conveyor.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Description TODO + * @Author Gengby + * @Date 2024/5/17 + */ +@Getter +@AllArgsConstructor +public enum ModeEnum { + + MODE_0(0, "110000"), + MODE_1(1, "110001"), + MODE_2(2, "110002"), + MODE_3(3, "110003"), + MODE_4(4, "110004"), + MODE_5(5, "110005"), + MODE_6(6, "110006"), + MODE_7(7, "110007"), + MODE_8(8, "110008"), + MODE_9(9, "110009"), + MODE_10(10, "110010"), + MODE_11(11, "110011"), + MODE_12(12, "110012"), + MODE_13(13, "110013"), + MODE_14(14, "110014"), + MODE_15(15, "110015"), + MODE_16(16, "110016"), + MODE_17(17, "110017"), + MODE_18(18, "110018"), + MODE_19(19, "110019"), + MODE_20(20, "110020"), + MODE_21(21, "110021"), + MODE_22(22, "110022"), + MODE_23(23, "110023"), + MODE_24(24, "110024"), + MODE_25(25, "110025"); + + private final Integer num; + private final String desc; + + public static String getDescByNum(Integer num) { + for (ModeEnum mode : ModeEnum.values()) { + if (mode.getNum().equals(num)) { + return mode.getDesc(); + } + } + return "110011"; + } +} \ No newline at end of file diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/MoveEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/MoveEnum.java new file mode 100644 index 0000000..2a10c3c --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/MoveEnum.java @@ -0,0 +1,29 @@ +package org.nl.acs.device_driver.lk_conveyor.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Description TODO + * @Author Gengby + * @Date 2024/5/17 + */ +@Getter +@AllArgsConstructor +public enum MoveEnum { + + MOVE_0(0, "1012"), + MOVE_1(1, "1011"); + + private final Integer num; + private final String desc; + + public static String getDescByNum(Integer num) { + for (MoveEnum mode : MoveEnum.values()) { + if (mode.getNum().equals(num)) { + return mode.getDesc(); + } + } + return "100006"; + } +} \ No newline at end of file diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ToCommandEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ToCommandEnum.java new file mode 100644 index 0000000..0239ccd --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/enums/ToCommandEnum.java @@ -0,0 +1,23 @@ +package org.nl.acs.device_driver.lk_conveyor.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Description TODO + * @Author Gengby + * @Date 2024/4/23 + */ +@Getter +@AllArgsConstructor +public enum ToCommandEnum { + COMMAND_ONE(1, "执行任务"), + COMMAND_TWO(2, "申请取货"), + COMMAND_THREE(3, "取货完成"), + CHOOSE_FOUR(4, "申请放货"), + CHOOSE_FIVE(5, "放货完成"); + + private final int signalNum; + private final String signalDesc; + +} \ No newline at end of file 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/FinishedProductOutBindLableConveyorDefination.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableConveyorDefination.java similarity index 94% rename from acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableConveyorDefination.java rename to acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableConveyorDefination.java index 368f69b..2e3432d 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableConveyorDefination.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableConveyorDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.one_conveyor.finished_product_out_with_bind_lable_conveyor; +package org.nl.acs.device_driver.lk_conveyor.finished_product_out_with_bind_lable_conveyor; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java new file mode 100644 index 0000000..5c70aa1 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java @@ -0,0 +1,812 @@ +package org.nl.acs.device_driver.lk_conveyor.finished_product_out_with_bind_lable_conveyor; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.common.util.concurrent.Uninterruptibles; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.enums.*; +import org.nl.acs.enums.AcsToLmsApplyTaskTypeEnum; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.instruction.domain.Instruction; +import org.nl.acs.instruction.enums.InstructionStatusEnum; +import org.nl.acs.instruction.service.InstructionService; +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.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.SpringContextHolder; +import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; + +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import java.util.stream.Collectors; + +/** + * 一楼出库捆轧贴标位 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDriver + implements DeviceDriver, + ExecutableDeviceDriver, + RouteableDeviceDriver, + DeviceStageMonitor { + + private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + private final RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + private final TaskService taskService = SpringContextHolder.getBean(TaskService.class); + private final DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); + private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); + private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class); + + /** + * 心跳 + */ + private int heartbeat = 0; + private int lastHeartbeat = 0; + /** + * 工作模式 + */ + private int mode = 0; + private int lastMode = 0; + /** + * 光电信号 + */ + private int move = 0; + private int lastMove = 0; + /** + * 动作信号 + */ + private int action = 0; + private int lastAction = 0; + /** + * 报警信号 + */ + private int error = 0; + private int lastError = 0; + /** + * 数量 + */ + private String material_code = null; + private String lastMaterial_code = null; + /** + * 托盘类型 + */ + private int container_type = 0; + private int lastContainer_type = 0; + /** + * 托盘方向 + */ + private int carrier_direction = 0; + private int lastCarrier_direction = 0; + /** + * 任务号 + */ + private int task = 0; + private int lastTask = 0; + /** + * 下发命令 + */ + private int to_command = 0; + private int lastTo_command = 0; + /** + * 下发目标站 + */ + private int to_target = 0; + private int lastTo_target = 0; + /** + * 下发托盘类型 + */ + private int to_container_type = 0; + private int lastTo_container_type = 0; + /** + * 下发任务号 + */ + private int to_task = 0; + private int lastTo_task = 0; + /** + * 是否捆扎 + */ + private int to_is_binding = 0; + private int lastTo_is_binding = 0; + /** + * 是否贴标 + */ + private int to_is_labeling = 0; + private int lastTo_is_labeling = 0; + /** + * 下发贴标数量 + */ + private int to_print_qty = 0; + private int lastTo_print_qty = 0; + /** + * 下发贴标模板 + */ + private int to_labeling_template = 0; + private int lastTo_labeling_template = 0; + /** + * 下发使用打印机 + */ + private int to_print_device = 0; + private int lastTo_print_device = 0; + /** + * 下发捆扎模板 + */ + private int to_binding_template = 0; + private int lastTo_binding_template = 0; + /** + * 下发捆扎次数 + */ + private int to_binding_times = 0; + private int lastTo_binding_times = 0; + /** + * 下发木箱长度 + */ + private int to_length; + private int lastTo_length; + /** + * 下发木箱宽度 + */ + private int to_width = 0; + private int lastTo_width = 0; + /** + * 下发木箱高度 + */ + private int to_height = 0; + private int lastTo_height = 0; + /** + * 下发木箱规格 + */ + private int to_case = 0; + private int lastTo_case = 0; + /** + * 下发贴标方向 + */ + private int to_direction = 0; + private int lastTo_direction = 0; + /** + * 当前设备编号 + */ + private String currentDeviceCode = null; + /** + * 设备在线状态 + */ + private Boolean isOnline = false; + /** + * 消息 + */ + String message = null; + /** + * 设备报警标记 + */ + private boolean isError = false; + /** + * 请求标记 + */ + boolean requireSuccess = false; + /** + * 请求时间 + */ + private long requireTime = System.currentTimeMillis(); + /** + * 请求间隔时间 + */ + private long requireTimeOut = 5000L; + /** + * 未执行任务原因 + */ + private String unExecutedMessage = null; + /** + * 不需要记录日志的点位 + */ + private static final List No_SET_LOG_KEYS = Arrays.asList(ItemProtocol.HEARTBEAT.getKey()); + + /** + * 手补条码 + */ + private String hand_barcode = null; + + private static final Lock LOCK = new ReentrantLock(); + + + public void setLog(String key, Object newValue, Object oldValue) { + if (!No_SET_LOG_KEYS.contains(key)) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "设备线程读取信号:" + key + ",由" + oldValue + "->" + newValue)); + } + } + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + try { + this.currentDeviceCode = this.getDevice().getDevice_code(); + this.heartbeat = ItemProtocol.HEARTBEAT.getIntegerValue(this); + this.mode = ItemProtocol.MODE.getIntegerValue(this); + this.move = ItemProtocol.MOVE.getIntegerValue(this); + this.action = ItemProtocol.ACTION.getIntegerValue(this); + this.error = ItemProtocol.ERROR.getIntegerValue(this); + this.material_code = ItemProtocol.MATERIAL_CODE.getStringValue(this); + this.container_type = ItemProtocol.CONTAINER_TYPE.getIntegerValue(this); + this.carrier_direction = ItemProtocol.CARRIER_DIRECTION.getIntegerValue(this); + this.task = ItemProtocol.TASK.getIntegerValue(this); + this.to_command = ItemProtocol.TO_COMMAND.getIntegerValue(this); + this.to_target = ItemProtocol.TO_TARGET.getIntegerValue(this); + this.to_task = ItemProtocol.TO_TASK.getIntegerValue(this); + this.to_container_type = ItemProtocol.TO_CONTAINER_TYPE.getIntegerValue(this); + this.to_is_binding = ItemProtocol.TO_IS_BINDING.getIntegerValue(this); + this.to_is_labeling = ItemProtocol.TO_IS_LABELING.getIntegerValue(this); + this.to_print_qty = ItemProtocol.TO_PRINT_QTY.getIntegerValue(this); + this.to_labeling_template = ItemProtocol.TO_LABELING_TEMPLATE.getIntegerValue(this); + this.to_print_device = ItemProtocol.TO_PRINT_DEVICE.getIntegerValue(this); + this.to_binding_template = ItemProtocol.TO_BINDING_TEMPLATE.getIntegerValue(this); + this.to_binding_times = ItemProtocol.TO_BINDING_TIMES.getIntegerValue(this); + this.to_length = ItemProtocol.TO_LENGTH.getIntegerValue(this); + this.to_width = ItemProtocol.TO_WIDTH.getIntegerValue(this); + this.to_height = ItemProtocol.TO_HEIGHT.getIntegerValue(this); + this.to_case = ItemProtocol.TO_CASE.getIntegerValue(this); + this.to_direction = ItemProtocol.TO_DIRECTION.getIntegerValue(this); + + if (this.heartbeat != this.lastHeartbeat) { + this.setLog(ItemProtocol.HEARTBEAT.getKey(), this.heartbeat, this.lastHeartbeat); + } + if (this.mode != this.lastMode) { + this.requireSuccess = false; + this.setLog(ItemProtocol.MODE.getKey(), this.mode, this.lastMode); + } + if (this.move != this.lastMove) { + this.setLog(ItemProtocol.MOVE.getKey(), this.move, this.lastMove); + } + if (this.action != this.lastAction) { + this.setLog(ItemProtocol.ACTION.getKey(), this.action, this.lastAction); + } + if (this.error != this.lastError) { + this.setLog(ItemProtocol.ERROR.getKey(), this.error, this.lastError); + } + if (this.container_type != this.lastContainer_type) { + this.setLog(ItemProtocol.CONTAINER_TYPE.getKey(), this.container_type, this.lastContainer_type); + } + if (this.carrier_direction != this.lastCarrier_direction) { + this.setLog(ItemProtocol.CARRIER_DIRECTION.getKey(), this.carrier_direction, this.lastCarrier_direction); + } + if (!StrUtil.equals(this.material_code, this.lastMaterial_code)) { + this.setLog(ItemProtocol.MATERIAL_CODE.getKey(), this.material_code, this.lastMaterial_code); + } + if (this.task != this.lastTask) { + this.setLog(ItemProtocol.TASK.getKey(), this.task, this.lastTask); + } + if (this.to_command != this.lastTo_command) { + this.setLog(ItemProtocol.TO_COMMAND.getKey(), this.to_command, this.lastTo_command); + } + if (this.to_target != this.lastTo_target) { + this.setLog(ItemProtocol.TO_TARGET.getKey(), this.to_target, this.lastTo_target); + } + if (this.to_task != this.lastTo_task) { + this.setLog(ItemProtocol.TO_TASK.getKey(), this.to_task, this.lastTo_task); + } + if (this.to_container_type != this.lastTo_container_type) { + this.setLog(ItemProtocol.TO_CONTAINER_TYPE.getKey(), this.to_container_type, this.lastTo_container_type); + } + if (this.to_is_binding != this.lastTo_is_binding) { + this.setLog(ItemProtocol.TO_IS_BINDING.getKey(), this.to_is_binding, this.lastTo_is_binding); + } + if (this.to_is_labeling != this.lastTo_is_labeling) { + this.setLog(ItemProtocol.TO_IS_LABELING.getKey(), this.to_is_labeling, this.lastTo_is_labeling); + } + if (this.to_print_qty != this.lastTo_print_qty) { + this.setLog(ItemProtocol.TO_PRINT_QTY.getKey(), this.to_print_qty, this.lastTo_print_qty); + } + if (this.to_labeling_template != this.lastTo_labeling_template) { + this.setLog(ItemProtocol.TO_LABELING_TEMPLATE.getKey(), this.to_labeling_template, this.lastTo_labeling_template); + } + if (this.to_print_device != this.lastTo_print_device) { + this.setLog(ItemProtocol.TO_PRINT_DEVICE.getKey(), this.to_print_device, this.lastTo_print_device); + } + if (this.to_binding_template != this.lastTo_binding_template) { + this.setLog(ItemProtocol.TO_BINDING_TEMPLATE.getKey(), this.to_binding_template, this.lastTo_binding_template); + } + if (this.to_binding_times != this.lastTo_binding_times) { + this.setLog(ItemProtocol.TO_BINDING_TIMES.getKey(), this.to_binding_times, this.lastTo_binding_times); + } + if (this.to_length != this.lastTo_length) { + this.setLog(ItemProtocol.TO_LENGTH.getKey(), this.to_length, this.lastTo_length); + } + if (this.to_width != this.lastTo_width) { + this.setLog(ItemProtocol.TO_WIDTH.getKey(), this.to_width, this.lastTo_width); + } + if (this.to_height != this.lastTo_height) { + this.setLog(ItemProtocol.TO_HEIGHT.getKey(), this.to_height, this.lastTo_height); + } + if (this.to_case != this.lastTo_case) { + this.setLog(ItemProtocol.TO_CASE.getKey(), this.to_case, this.lastTo_case); + } + if (this.to_direction != this.lastTo_direction) { + this.setLog(ItemProtocol.TO_DIRECTION.getKey(), this.to_direction, this.lastTo_direction); + } + + if (this.move != 0 && this.task > 0) { + update_instruction_status(); + } + + if (this.move != this.lastMove && this.move == 0 && this.lastMove == 1 && this.mode > 0) { + this.requireSuccess = false; + clearWrite(); + } + + if (this.mode == 0) { + this.isOnline = false; + this.message = LangProcess.msg("110000"); + } else if (this.error > 0) { + this.isError = true; + this.message = LangProcess.msg(ErrorEnum.getDesc(this.error)); + } else { + this.isOnline = true; + this.isError = false; + this.message = null; + switch (this.mode) { + case 2: + if (this.move > 0 && !this.requireSuccess) { + instruction_require(); + } + break; + case 12: + //申请贴标 + if (this.move > 0 && !this.requireSuccess) { + applyLabeling(); + } + break; + case 10: + case 13: + case 14: + case 16: + case 17: + //申请捆轧贴标信息 + if (this.move > 0 && !this.requireSuccess) { + applyLaStrangulationAndLabeling(); + } + break; + } + } + this.lastHeartbeat = this.heartbeat; + this.lastMode = this.mode; + this.lastMove = this.move; + this.lastAction = this.action; + this.lastError = this.error; + this.lastMaterial_code = this.material_code; + this.lastContainer_type = this.container_type; + this.lastCarrier_direction = this.carrier_direction; + this.lastTask = this.task; + this.lastTo_command = this.to_command; + this.lastTo_target = this.to_target; + this.lastTo_task = this.to_task; + this.lastTo_container_type = this.to_container_type; + this.lastTo_is_binding = this.to_is_binding; + this.lastTo_is_labeling = this.to_is_labeling; + this.lastTo_print_qty = this.to_print_qty; + this.lastTo_labeling_template = this.to_labeling_template; + this.lastTo_print_device = this.to_print_device; + this.lastTo_binding_template = this.to_binding_template; + this.lastTo_binding_times = this.to_binding_times; + this.lastTo_length = this.to_length; + this.lastTo_width = this.to_width; + this.lastTo_height = this.to_height; + this.lastTo_case = this.to_case; + this.lastTo_direction = this.to_direction; + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1005"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "当前设备执行逻辑报错, 错误详情: " + e.getMessage() + ", 错误堆栈信息: " + Arrays.toString(e.getStackTrace()))); + Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); + } + } + + private void clearWrite() { + List keys = Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_CONTAINER_TYPE.getKey()); + List values = Arrays.asList(0, 0, 0); + this.writing(keys, values); + } + + /** + * 下发单个电气信号 + * + * @param key + * @param value + */ + public void writing(String key, Object value) { + Map itemMap = new HashMap(); + itemMap.put(getId() + key, value); + try { + this.checkcontrol(itemMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 下发多个电气信号 + * + * @param keys + * @param values + */ + public void writing(List keys, List values) { + if (keys.size() != values.size()) { + this.message = LangProcess.msg("1007"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "参数长度不一致,不允许下发")); + throw new BadRequestException("参数长度不一致,不允许下发"); + } + Map controlMap = new LinkedHashMap<>(); + for (int i = 0; i < keys.size(); i++) { + controlMap.put(getId() + keys.get(i), values.get(i)); + } + try { + this.checkcontrol(controlMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 抽取统一下发电气信号前缀 + * + * @return + */ + public String getId() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } + + + private boolean isTimeValid(long currentTimeMillis) { + return currentTimeMillis - this.requireTime >= this.requireTimeOut; + } + + private int getTargetAddress(Device nextDevice) { + return Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0); + } + + private void applyLaStrangulationAndLabeling() throws Exception { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task)); + if (ObjectUtil.isNotEmpty(inst)) { + applyLaStrangulationAndLabeling2(inst.getVehicle_code()); + } else { + this.message = LangProcess.msg("310009") + ": " + this.task; + } + if (StrUtil.isNotEmpty(hand_barcode)) { + TaskDto taskDtoHandCode = taskService.findByVehicleCode2AndExcute(hand_barcode); + if (ObjectUtil.isNotEmpty(taskDtoHandCode)) { + inst = instructionService.findByTaskCodeFromCache(taskDtoHandCode.getTask_code()); + if (ObjectUtil.isNotEmpty(inst)) { + applyLaStrangulationAndLabeling2(inst.getVehicle_code()); + } else { + this.message = LangProcess.msg("310010") + ": " + this.hand_barcode; + } + } + } + } + } + + public void applyLaStrangulationAndLabeling2(String vehicle_code) throws Exception { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + JSONObject param = new JSONObject(); + param.put("device_code", this.currentDeviceCode); + param.put("vehicle_code", vehicle_code); + param.put("type", AcsToLmsApplyTaskTypeEnum.LABEL_BIND.getType()); + String response = acsToWmsService.deviceApplyTwo(param); + if (response != null) { + JSONObject jo = JSON.parseObject(response); + if (jo.getIntValue("status") == 200) { + packagePLCData(jo.getString("data"), this.mode); + this.requireSuccess = true; + } else { + this.message = LangProcess.msg("310002"); + } + } else { + this.message = LangProcess.msg("310002"); + } + } + } + + // 申请贴标 + public void applyLabeling() { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + Instruction inst = instructionService.findByCodeFromCache(String.valueOf(this.task)); + if (StrUtil.isEmpty(inst.getVehicle_code())) { + this.message = LangProcess.msg("310011"); + return; + } + JSONObject param = new JSONObject(); + param.put("device_code", this.currentDeviceCode); + param.put("vehicle_code", inst.getVehicle_code()); + param.put("type", AcsToLmsApplyTaskTypeEnum.LABEL.getType()); + String response = acsToWmsService.deviceApplyTwo(param); + if (StrUtil.isNotBlank(response)) { + JSONObject jo = JSON.parseObject(response); + if (jo.getIntValue("status") == 200) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode); + this.requireSuccess = true; + } else { + this.message = LangProcess.msg("310002"); + } + } else { + this.message = LangProcess.msg("310002"); + } + } + } + + private void packagePLCData(String datas, int mode) { + JSONObject jo = JSON.parseObject(datas); + String length = jo.get("length").toString(); + String width = jo.get("width").toString(); + String height = jo.get("height").toString(); + String isBinding = jo.get("isBinding").toString(); + String isLabeling = jo.get("isLabeling").toString(); + String printQty = jo.get("printQty").toString(); + String labelingTemplate = jo.get("labelingTemplate").toString(); + String bindingTemplate = jo.get("bindingTemplate").toString(); + String printDevice = jo.get("printDevice").toString(); + String bundleTimes = jo.get("bundleTimes").toString(); + String to_case = jo.get("box_structure").toString(); + + if (mode == 10 || mode == 16) { + List keys = Arrays.asList(ItemProtocol.TO_LENGTH.getKey(), ItemProtocol.TO_WIDTH.getKey(), ItemProtocol.TO_HEIGHT.getKey(), + ItemProtocol.TO_IS_BINDING.getKey(), ItemProtocol.TO_COMMAND.getKey(), ItemProtocol.TO_IS_LABELING.getKey(), + ItemProtocol.TO_PRINT_QTY.getKey(), ItemProtocol.TO_PRINT_DEVICE.getKey(), ItemProtocol.TO_BINDING_TEMPLATE.getKey(), + ItemProtocol.TO_BINDING_TIMES.getKey(), ItemProtocol.TO_LABELING_TEMPLATE.getKey(), ItemProtocol.TO_CASE.getKey()); + List values = Arrays.asList(length, width, height, isBinding, mode, isLabeling, printQty, printDevice, bindingTemplate, bundleTimes, labelingTemplate, to_case); + this.writing(keys, values); + } + if (mode == 13) { + List keys = Arrays.asList(ItemProtocol.TO_LENGTH.getKey(), ItemProtocol.TO_WIDTH.getKey(), ItemProtocol.TO_HEIGHT.getKey(), ItemProtocol.TO_COMMAND.getKey(), + ItemProtocol.TO_BINDING_TIMES.getKey(), ItemProtocol.TO_CASE.getKey()); + List values = Arrays.asList(length, width, height, mode, bundleTimes, to_case); + this.writing(keys, values); + } + if (mode == 14) { + List keys = Arrays.asList(ItemProtocol.TO_IS_BINDING.getKey(), ItemProtocol.TO_COMMAND.getKey(), ItemProtocol.TO_IS_LABELING.getKey(), + ItemProtocol.TO_PRINT_QTY.getKey(), ItemProtocol.TO_PRINT_DEVICE.getKey(), ItemProtocol.TO_BINDING_TEMPLATE.getKey(), + ItemProtocol.TO_LABELING_TEMPLATE.getKey(), ItemProtocol.TO_BINDING_TIMES.getKey(), ItemProtocol.TO_CASE.getKey()); + List values = Arrays.asList(isBinding, mode, isLabeling, printQty, printDevice, bindingTemplate, labelingTemplate, bundleTimes, to_case); + this.writing(keys, values); + } + if (mode == 17) { + String aCase = Optional.ofNullable(jo.get("case")).map(Objects::toString).orElse(null); + Integer direction = Optional.ofNullable(jo.get("direction")).map(Objects::toString).map(Integer::parseInt).orElse(0); + List keys = Arrays.asList(ItemProtocol.TO_LENGTH.getKey(), ItemProtocol.TO_WIDTH.getKey(), ItemProtocol.TO_HEIGHT.getKey(), ItemProtocol.TO_COMMAND.getKey(), + ItemProtocol.TO_CASE.getKey(), ItemProtocol.TO_DIRECTION.getKey()); + List values = Arrays.asList(length, width, height, mode, to_case, direction); + if (aCase != null) { + keys.add(ItemProtocol.TO_BINDING_TIMES.getKey()); + values.add(bundleTimes); + } + this.writing(keys, values); + } + this.requireSuccess = true; + + } + + private boolean isIssued(Device device) { + boolean isTwoWay = Optional.ofNullable(device.getExtraValue().get("isTwoWayPoint")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + if (isTwoWay) { + Instruction instruction = instructionService.findByStartAndNextDeviceCode(device.getDevice_code()); + if (ObjectUtil.isNotEmpty(instruction)) { + return false; + } + } + return true; + } + + private String getNextDeviceCode(TaskDto taskDto) { + List shortPathsList = routeLineService.getShortPathLines(taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code()); + if (ObjectUtils.isEmpty(shortPathsList)) { + return null; + } + RouteLineDto routeLineDto = shortPathsList.get(0); + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(taskDto.getStart_device_code())) { + index = m + 1; + break; + } + } + return pathlist.get(index); + } + + /** + * 请求指令 + */ + public void instruction_require() { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + //先查询是否有就绪状态下的指令 + Instruction inst = instructionService.findByDeviceCodeFromCache(this.currentDeviceCode); + if (ObjectUtil.isNotEmpty(inst)) { + List targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode"); + if (!targetDeviceCode.contains(inst.getNext_device_code())) { + this.unExecutedMessage = LangProcess.msg("310003"); + return; + } + Device nextDevice = deviceAppService.findDeviceByCode(inst.getNext_device_code()); + if (nextDevice == null) { + this.unExecutedMessage = LangProcess.msg("1008") + ":" + inst.getNext_device_code(); + return; + } + if (!this.isIssued(nextDevice)) { + this.unExecutedMessage = LangProcess.msg("310004"); + return; + } + this.writing(Arrays.asList(ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_COMMAND.getKey()), Arrays.asList(Integer.parseInt(inst.getInstruction_code()), getTargetAddress(nextDevice), ToCommandEnum.COMMAND_ONE.getSignalNum())); + this.requireSuccess = true; + return; + } + boolean isCreateInst = Optional.ofNullable(this.getExtraValue().get("isCreateInst")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + if (!isCreateInst) { + this.unExecutedMessage = LangProcess.msg("310005"); + return; + } + //如果为空,则查找就绪的任务,并创建指令下发给电气 + TaskDto taskDto = taskService.findByStartCodeAndReady(this.currentDeviceCode); + if (ObjectUtil.isNotEmpty(taskDto)) { + String next_device_code = null; + String assignedDeviceCode = taskService.queryAssignedByDevice(this.currentDeviceCode, taskDto.getNext_device_code()); + if (StrUtil.isEmpty(assignedDeviceCode)) { + next_device_code = this.getNextDeviceCode(taskDto); + if (next_device_code == null) { + this.unExecutedMessage = taskDto.getStart_device_code() + "->" + next_device_code + LangProcess.msg("1009"); + return; + } + } else { + next_device_code = assignedDeviceCode; + } + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + if (nextDevice == null) { + this.unExecutedMessage = LangProcess.msg("1008") + ":" + next_device_code; + return; + } + List targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode"); + if (!targetDeviceCode.contains(inst.getNext_device_code())) { + this.unExecutedMessage = LangProcess.msg("310006"); + return; + } + //判断终点是否是双向点位 + if (!this.isIssued(nextDevice)) { + this.unExecutedMessage = LangProcess.msg("310004"); + return; + } + Instruction instDto = new Instruction(); + try { + packageInst(instDto, taskDto, next_device_code); + instructionService.create(instDto); + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1006"); + return; + } + //创建指令后修改任务状态 + taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskService.update(taskDto); + List keys = Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(getTargetAddress(nextDevice), Integer.parseInt(instDto.getInstruction_code()), ToCommandEnum.COMMAND_ONE.getSignalNum()); + this.writing(keys, values); + this.requireSuccess = true; + } + } + } + + private void packageInst(Instruction instDto, TaskDto taskDto, String next_device_code) { + instDto.setInstruction_id(IdUtil.simpleUUID()); + instDto.setRoute_plan_code(taskDto.getRoute_plan_code()); + instDto.setRemark(taskDto.getRemark()); + instDto.setMaterial(taskDto.getMaterial()); + instDto.setQuantity(taskDto.getQuantity()); + instDto.setTask_id(taskDto.getTask_id()); + instDto.setTask_code(taskDto.getTask_code()); + instDto.setVehicle_code(taskDto.getVehicle_code()); + String now = DateUtil.now(); + instDto.setCreate_time(now); + instDto.setCreate_by(SecurityUtils.getCurrentNickName()); + instDto.setStart_device_code(taskDto.getStart_device_code()); + instDto.setNext_device_code(next_device_code); + instDto.setStart_point_code(taskDto.getStart_point_code()); + instDto.setNext_point_code(next_device_code); + instDto.setPriority(taskDto.getPriority()); + instDto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); + instDto.setExecute_device_code(this.currentDeviceCode); + instDto.setInstruction_type(taskDto.getTask_type()); + instDto.setVehicle_type(taskDto.getVehicle_type()); + } + + /** + * 更新指令状态 + */ + public void update_instruction_status() throws Exception { + Instruction inst = instructionService.findByCodeFromCache(String.valueOf(this.task)); + if (ObjectUtil.isNotEmpty(inst)) { + if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex()) && StrUtil.equals(this.currentDeviceCode, inst.getStart_device_code())) { + inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.update(inst); + } else if (StrUtil.equals(this.currentDeviceCode, inst.getNext_device_code())) { + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.finish(inst); + } + } + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", LangProcess.msg(ModeEnum.getDescByNum(this.mode))); + jo.put("move", LangProcess.msg(MoveEnum.getDescByNum(this.move))); + jo.put("hasGoods", this.move == 1 ? true : false); + jo.put("error", LangProcess.msg(ErrorEnum.getDesc(this.getError()))); + jo.put("isError", this.isError); + jo.put("container_type", LangProcess.msg(ContainerTypeEnum.getDescByNum(this.container_type))); + jo.put("action", LangProcess.msg(ActionEnum.getDescByNum(this.action))); + jo.put("carrier_direction", this.carrier_direction); + jo.put("task", this.task); + jo.put("isOnline", this.isOnline); + jo.put("message", this.message); + jo.put("unExecutedMessage", this.unExecutedMessage); + jo.put("hand_barcode", this.hand_barcode); + jo.put("is_click", true); + jo.put("requireSuccess", this.requireSuccess); + jo.put("driver_type", "box_subvolumes_conveyor"); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + Boolean requireSuccess = data.getBoolean("requireSuccess"); + if (requireSuccess != null) { + this.requireSuccess = requireSuccess; + } + String hand_barcode = data.getString("hand_barcode"); + this.setHand_barcode(hand_barcode); + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/finished_product_out_with_bind_lable_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/finished_product_out_with_bind_lable_conveyor/ItemProtocol.java new file mode 100644 index 0000000..77d7741 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/finished_product_out_with_bind_lable_conveyor/ItemProtocol.java @@ -0,0 +1,109 @@ +package org.nl.acs.device_driver.lk_conveyor.finished_product_out_with_bind_lable_conveyor; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device_driver.lk_conveyor.finished_product_out_with_bind_lable_conveyor.FinishedProductOutBindLableDeviceDriver; + +import java.util.ArrayList; +import java.util.List; + + +public enum ItemProtocol { + + HEARTBEAT("heartbeat", "心跳", "DB1.B0"), + MODE("mode", "工作模式", "DB1.B1"), + MOVE("move", "光电信号", "DB1.B2"), + ACTION("action", "取放信号", "DB1.B3"), + ERROR("error", "报警信号", "DB1.B4"), + MATERIAL_CODE("material_code", "物料条码", "DB1.String.200"), + CONTAINER_TYPE("container_type", "载具类型", "DB1.B6"), + CARRIER_DIRECTION("carrier_direction", "托盘方向", "DB1.B7"), + TASK("task", "任务号", "DB1.D8"), + TO_COMMAND("to_command", "下发命令", "DB2.W2"), + TO_TARGET("to_target", "下发目标站", "DB2.W4"), + TO_CONTAINER_TYPE("to_container_type", "下发托盘类型", "DB2.W6"), + TO_TASK("to_task", "下发任务号", "DB2.D8"), + TO_IS_BINDING("to_is_binding", "下发是否捆扎", "DB2.D10"), + TO_IS_LABELING("to_is_labeling", "下发是否贴标", "DB2.D12"), + TO_PRINT_QTY("to_print_qty", "下发贴标数量", "DB2.D14"), + TO_LABELING_TEMPLATE("to_labeling_template", "下发贴标模板", "DB2.D16"), + TO_PRINT_DEVICE("to_print_device", "下发使用打印机", "DB2.D18"), + TO_BINDING_TEMPLATE("to_binding_template", "下发捆扎模板", "DB2.D20"), + TO_BINDING_TIMES("to_binding_times", "下发捆扎次数", "DB2.D22"), + TO_LENGTH("to_length", "下发木箱长度", "DB2.W24"), + TO_WIDTH("to_width", "下发木箱宽度", "DB2.W26"), + TO_HEIGHT("to_height", "下发木箱高度", "DB2.W28"), + TO_CASE("to_case", "下发木箱规格", "DB2.W30"), + TO_DIRECTION("to_task", "下发贴标方向", "DB2.W32"); + + private final String key; + private final String description; + private final String address; + + ItemProtocol(String key, String description, String address) { + this.key = key; + this.description = description; + this.address = address; + } + + public String getKey() { + return this.key; + } + + public String getDescription() { + return description; + } + + public String getAddress() { + return address; + } + + // 获取 Integer 类型的值 + public Integer getIntegerValue(FinishedProductOutBindLableDeviceDriver driver) { + Integer value = driver.getIntegerValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0; + } + + // 获取 Float 类型的值 + public Float getFloatValue(FinishedProductOutBindLableDeviceDriver driver) { + Float value = driver.getFloatValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0.00f; + } + + public String getStringValue(FinishedProductOutBindLableDeviceDriver driver) { + return driver.getStringValue(this.getKey()); + } + + public static List getReadableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (!prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } + + public static List getWriteableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } + +} + diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDefination.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/fold_disc_site/FoldDiscSiteDefination.java similarity index 93% rename from acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDefination.java rename to acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/fold_disc_site/FoldDiscSiteDefination.java index 98d753a..0d453f2 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDefination.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/fold_disc_site/FoldDiscSiteDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.one_conveyor.fold_disc_site; +package org.nl.acs.device_driver.lk_conveyor.fold_disc_site; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; @@ -24,7 +24,7 @@ public class FoldDiscSiteDefination implements OpcDeviceDriverDefination { @Override public String getDriverDescription() { - return "叠盘机位"; + return "拆叠盘机位"; } @Override diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java new file mode 100644 index 0000000..c4a4df5 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java @@ -0,0 +1,602 @@ +package org.nl.acs.device_driver.lk_conveyor.fold_disc_site; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSONObject; +import com.google.common.util.concurrent.Uninterruptibles; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.enums.*; +import org.nl.acs.enums.StorageTypeEnum; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.instruction.domain.Instruction; +import org.nl.acs.instruction.enums.InstructionStatusEnum; +import org.nl.acs.instruction.service.InstructionService; +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.route.service.dto.RouteLineDto; +import org.nl.acs.route.service.impl.RouteLineServiceImpl; +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; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.SpringContextHolder; +import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; + +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import java.util.stream.Collectors; + +/** + * 拆叠盘机 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver + implements DeviceDriver, + ExecutableDeviceDriver, + RouteableDeviceDriver, + DeviceStageMonitor { + + private final TaskService taskService = SpringContextHolder.getBean(TaskService.class); + private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + private final DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + private final RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); + private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); + private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class); + + /** + * 心跳 + */ + private int heartbeat = 0; + private int lastHeartbeat = 0; + /** + * 工作模式 + */ + private int mode = 0; + private int lastMode = 0; + /** + * 光电信号 + */ + private int move = 0; + private int lastMove = 0; + /** + * 动作信号 + */ + private int action = 0; + private int lastAction = 0; + /** + * 报警信号 + */ + private int error = 0; + private int lastError = 0; + /** + * 数量 + */ + private int qty = 0; + private int lastQty = 0; + /** + * 托盘类型 + */ + private int container_type = 0; + private int lastContainer_type = 0; + /** + * 托盘方向 + */ + private int carrier_direction = 0; + private int lastCarrier_direction = 0; + /** + * 任务号 + */ + private int task = 0; + private int lastTask = 0; + /** + * 托盘条码 + */ + private String barcode = null; + private String lastBarcode = null; + /** + * 下发命令 + */ + private int to_command = 0; + private int lastTo_command = 0; + /** + * 下发目标站 + */ + private int to_target = 0; + private int lastTo_target = 0; + /** + * 下发任务号 + */ + private int to_task = 0; + private int lastTo_task = 0; + /** + * 下发托盘类型 + */ + private int to_container_type = 0; + private int lastTo_container_type = 0; + /** + * 当前设备编号 + */ + private String currentDeviceCode = null; + /** + * 设备在线状态 + */ + private Boolean isOnline = false; + /** + * 消息 + */ + String message = null; + /** + * 设备报警标记 + */ + private boolean isError = false; + /** + * 请求标记 + */ + boolean requireSuccess = false; + /** + * 请求时间 + */ + private long requireTime = System.currentTimeMillis(); + /** + * 请求间隔时间 + */ + private long requireTimeOut = 5000L; + /** + * 未执行任务原因 + */ + private String unExecutedMessage = null; + /** + * 不需要记录日志的点位 + */ + private static final List No_SET_LOG_KEYS = Arrays.asList(ItemProtocol.HEARTBEAT.getKey()); + + private static final Lock LOCK = new ReentrantLock(); + + public void setLog(String key, Object newValue, Object oldValue) { + if (!No_SET_LOG_KEYS.contains(key)) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "设备线程读取信号:" + key + ",由" + oldValue + "->" + newValue)); + } + } + + + @Override + public Device getDevice() { + return this.device; + } + + @Override + public void execute() { + try { + this.currentDeviceCode = this.getDevice().getDevice_code(); + this.heartbeat = ItemProtocol.HEARTBEAT.getIntegerValue(this); + this.mode = ItemProtocol.MODE.getIntegerValue(this); + this.move = ItemProtocol.MOVE.getIntegerValue(this); + this.action = ItemProtocol.ACTION.getIntegerValue(this); + this.error = ItemProtocol.ERROR.getIntegerValue(this); + this.qty = ItemProtocol.QTY.getIntegerValue(this); + this.container_type = ItemProtocol.CONTAINER_TYPE.getIntegerValue(this); + this.carrier_direction = ItemProtocol.CARRIER_DIRECTION.getIntegerValue(this); + this.task = ItemProtocol.TASK.getIntegerValue(this); + this.barcode = ItemProtocol.BARCODE.getStringValue(this); + this.to_command = ItemProtocol.TO_COMMAND.getIntegerValue(this); + this.to_target = ItemProtocol.TO_TARGET.getIntegerValue(this); + this.to_task = ItemProtocol.TO_TASK.getIntegerValue(this); + this.to_container_type = ItemProtocol.TO_CONTAINER_TYPE.getIntegerValue(this); + + if (this.heartbeat != this.lastHeartbeat) { + this.setLog(ItemProtocol.HEARTBEAT.getKey(), this.heartbeat, this.lastHeartbeat); + } + if (this.mode != this.lastMode) { + this.requireSuccess = false; + this.setLog(ItemProtocol.MODE.getKey(), this.mode, this.lastMode); + } + if (this.move != this.lastMove) { + this.setLog(ItemProtocol.MOVE.getKey(), this.move, this.lastMove); + } + if (this.action != this.lastAction) { + this.setLog(ItemProtocol.ACTION.getKey(), this.action, this.lastAction); + } + if (this.error != this.lastError) { + this.setLog(ItemProtocol.ERROR.getKey(), this.error, this.lastError); + } + if (this.qty != this.lastQty) { + this.setLog(ItemProtocol.QTY.getKey(), this.qty, this.lastQty); + } + if (this.container_type != this.lastContainer_type) { + this.setLog(ItemProtocol.CONTAINER_TYPE.getKey(), this.container_type, this.lastContainer_type); + } + if (this.carrier_direction != this.lastCarrier_direction) { + this.setLog(ItemProtocol.CARRIER_DIRECTION.getKey(), this.carrier_direction, this.lastCarrier_direction); + } + if (this.task != this.lastTask) { + this.setLog(ItemProtocol.TASK.getKey(), this.task, this.lastTask); + } + if (this.barcode != null && !this.barcode.equals(this.lastBarcode)) { + this.setLog(ItemProtocol.BARCODE.getKey(), this.barcode, this.lastBarcode); + } + if (this.to_command != this.lastTo_command) { + this.setLog(ItemProtocol.TO_COMMAND.getKey(), this.to_command, this.lastTo_command); + } + if (this.to_target != this.lastTo_target) { + this.setLog(ItemProtocol.TO_TARGET.getKey(), this.to_target, this.lastTo_target); + } + if (this.to_task != this.lastTo_task) { + this.setLog(ItemProtocol.TO_TASK.getKey(), this.to_task, this.lastTo_task); + } + if (this.to_container_type != this.lastTo_container_type) { + this.setLog(ItemProtocol.TO_CONTAINER_TYPE.getKey(), this.to_container_type, this.lastTo_container_type); + } + + // 更新指令状态 + if (this.move != 0 && this.task > 0) { + this.update_instruction_status(); + } + //无货变有货清除下发信息 + if (this.move != this.lastMove && this.move == 0 && this.lastMove == 1 && this.mode > 0) { + this.requireSuccess = false; + this.clearWrite(); + } + + if (this.mode == 0) { + this.isOnline = false; + this.message = LangProcess.msg("110000"); + //有报警 + } else if (this.error != 0) { + this.isError = true; + this.message = LangProcess.msg(ErrorEnum.getDesc(this.error)); + //无报警 + } else { + this.setIsOnline(true); + this.isError = false; + this.message = null; + + Boolean isApplyTask = Optional.ofNullable(this.getExtraValue().get("apply_task")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + //申请空托盘入库 + if (this.mode == 9 && this.move == 1 && !this.requireSuccess) { + if (this.container_type == 0) { + this.message = LangProcess.msg("310001"); + } else { + if (isApplyTask) { + applyEmptyTask(StorageTypeEnum.DISKS_IN.getType(), this.mode); + } else { + this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode); + } + } + } + + //申请空托盘出库 + if (this.mode == 8 && !this.requireSuccess) { + if (this.container_type == 0) { + this.message = LangProcess.msg("310001"); + } else { + if (isApplyTask) { + applyEmptyTask(StorageTypeEnum.DISKS_OUT.getType(), this.mode); + } else { + this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode); + } + } + } + + //叠盘位申请任务 + if (this.mode == 2 && this.move == 1 && !this.requireSuccess) { + instruction_require(); + } + + } + this.lastHeartbeat = this.heartbeat; + this.lastMode = this.mode; + this.lastMove = this.move; + this.lastAction = this.action; + this.lastError = this.error; + this.lastQty = this.qty; + this.lastContainer_type = this.container_type; + this.lastCarrier_direction = this.carrier_direction; + this.lastTask = this.task; + this.lastBarcode = this.barcode; + this.lastTo_command = this.to_command; + this.lastTo_target = this.to_target; + this.lastTo_task = this.to_task; + this.lastTo_container_type = this.to_container_type; + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1005"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "当前设备执行逻辑报错, 错误详情: " + e.getMessage() + ", 错误堆栈信息: " + Arrays.toString(e.getStackTrace()))); + Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); + } + } + + private void clearWrite() { + List keys = Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_CONTAINER_TYPE.getKey()); + List values = Arrays.asList(0, 0, 0); + this.writing(keys, values); + } + + private boolean isTimeValid(long currentTimeMillis) { + return currentTimeMillis - this.requireTime >= this.requireTimeOut; + } + + private boolean isIssued(Device device) { + boolean isTwoWay = Optional.ofNullable(device.getExtraValue().get("isTwoWayPoint")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + if (isTwoWay) { + Instruction instruction = instructionService.findByStartAndNextDeviceCode(device.getDevice_code()); + if (ObjectUtil.isNotEmpty(instruction)) { + return false; + } + } + return true; + } + + private int getTargetAddress(Device nextDevice) { + return Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0); + } + + private String getNextDeviceCode(TaskDto taskDto) { + List shortPathsList = routeLineService.getShortPathLines(taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code()); + if (ObjectUtils.isEmpty(shortPathsList)) { + return null; + } + RouteLineDto routeLineDto = shortPathsList.get(0); + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(taskDto.getStart_device_code())) { + index = m + 1; + break; + } + } + return pathlist.get(index); + } + + /** + * 请求指令 + */ + public void instruction_require() { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + //先查询是否有就绪状态下的指令 + Instruction inst = instructionService.findByDeviceCodeFromCache(this.currentDeviceCode); + if (ObjectUtil.isNotEmpty(inst)) { + List targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode"); + if (!targetDeviceCode.contains(inst.getNext_device_code())) { + this.unExecutedMessage = LangProcess.msg("310003"); + return; + } + Device nextDevice = deviceAppService.findDeviceByCode(inst.getNext_device_code()); + if (nextDevice == null) { + this.unExecutedMessage = LangProcess.msg("1008") + ":" + inst.getNext_device_code(); + return; + } + if (!this.isIssued(nextDevice)) { + this.unExecutedMessage = LangProcess.msg("310004"); + return; + } + this.writing(Arrays.asList(ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_COMMAND.getKey()), Arrays.asList(Integer.parseInt(inst.getInstruction_code()), getTargetAddress(nextDevice), ToCommandEnum.COMMAND_ONE.getSignalNum())); + this.requireSuccess = true; + return; + } + boolean isCreateInst = Optional.ofNullable(this.getExtraValue().get("isCreateInst")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + if (!isCreateInst) { + this.unExecutedMessage = LangProcess.msg("310005"); + return; + } + //如果为空,则查找就绪的任务,并创建指令下发给电气 + TaskDto taskDto = taskService.findByStartCodeAndReady(this.currentDeviceCode); + if (ObjectUtil.isNotEmpty(taskDto)) { + String next_device_code = null; + String assignedDeviceCode = taskService.queryAssignedByDevice(this.currentDeviceCode, taskDto.getNext_device_code()); + if (StrUtil.isEmpty(assignedDeviceCode)) { + next_device_code = this.getNextDeviceCode(taskDto); + if (next_device_code == null) { + this.unExecutedMessage = taskDto.getStart_device_code() + "->" + next_device_code + LangProcess.msg("1009"); + return; + } + } else { + next_device_code = assignedDeviceCode; + } + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + if (nextDevice == null) { + this.unExecutedMessage = LangProcess.msg("1008") + ":" + next_device_code; + return; + } + List targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode"); + if (!targetDeviceCode.contains(inst.getNext_device_code())) { + this.unExecutedMessage = LangProcess.msg("310006"); + return; + } + //判断终点是否是双向点位 + if (!this.isIssued(nextDevice)) { + this.unExecutedMessage = LangProcess.msg("310004"); + return; + } + Instruction instDto = new Instruction(); + try { + packageInst(instDto, taskDto, next_device_code); + instructionService.create(instDto); + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1006"); + return; + } + //创建指令后修改任务状态 + taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskService.update(taskDto); + List keys = Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(getTargetAddress(nextDevice), Integer.parseInt(instDto.getInstruction_code()), ToCommandEnum.COMMAND_ONE.getSignalNum()); + this.writing(keys, values); + this.requireSuccess = true; + } + } + } + + + /** + * 下发单个电气信号 + * + * @param key + * @param value + */ + public void writing(String key, Object value) { + Map itemMap = new HashMap(); + itemMap.put(getId() + key, value); + try { + this.checkcontrol(itemMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 下发多个电气信号 + * + * @param keys + * @param values + */ + public void writing(List keys, List values) { + if (keys.size() != values.size()) { + this.message = LangProcess.msg("1007"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "参数长度不一致,不允许下发")); + throw new BadRequestException("参数长度不一致,不允许下发"); + } + Map controlMap = new LinkedHashMap<>(); + for (int i = 0; i < keys.size(); i++) { + controlMap.put(getId() + keys.get(i), values.get(i)); + } + try { + this.checkcontrol(controlMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 抽取统一下发电气信号前缀 + * + * @return + */ + public String getId() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } + + private void applyEmptyTask(String type, int mode) { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + JSONObject param = new JSONObject(); + param.put("device_code", this.currentDeviceCode); + param.put("container_type", this.container_type); + param.put("type", type); + HttpResponse httpResponse = acsToWmsService.applyTwo(param); + if (httpResponse != null) { + JSONObject resp = JSONObject.parseObject(httpResponse.body()); + if (resp != null && resp.getIntValue("status") == 200) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), mode); + this.requireSuccess = true; + } else { + this.message = LangProcess.msg("310002"); + } + } else { + this.message = LangProcess.msg("310002"); + } + } + } + + /** + * 更新指令状态 + */ + public void update_instruction_status() throws Exception { + Instruction inst = instructionService.findByCodeFromCache(String.valueOf(this.task)); + if (ObjectUtil.isNotEmpty(inst)) { + if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex()) && StrUtil.equals(this.currentDeviceCode, inst.getStart_device_code())) { + inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.update(inst); + } else if (StrUtil.equals(this.currentDeviceCode, inst.getNext_device_code())) { + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.finish(inst); + } + } + } + + private void packageInst(Instruction instDto, TaskDto taskDto, String next_device_code) { + instDto.setInstruction_id(IdUtil.simpleUUID()); + instDto.setRoute_plan_code(taskDto.getRoute_plan_code()); + instDto.setRemark(taskDto.getRemark()); + instDto.setMaterial(taskDto.getMaterial()); + instDto.setQuantity(taskDto.getQuantity()); + instDto.setTask_id(taskDto.getTask_id()); + instDto.setTask_code(taskDto.getTask_code()); + instDto.setVehicle_code(taskDto.getVehicle_code()); + String now = DateUtil.now(); + instDto.setCreate_time(now); + instDto.setCreate_by(SecurityUtils.getCurrentNickName()); + instDto.setStart_device_code(taskDto.getStart_device_code()); + instDto.setNext_device_code(next_device_code); + instDto.setStart_point_code(taskDto.getStart_point_code()); + instDto.setNext_point_code(next_device_code); + instDto.setPriority(taskDto.getPriority()); + instDto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); + instDto.setExecute_device_code(this.currentDeviceCode); + instDto.setInstruction_type(taskDto.getTask_type()); + instDto.setVehicle_type(taskDto.getVehicle_type()); + } + + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", LangProcess.msg(ModeEnum.getDescByNum(this.mode))); + jo.put("move", LangProcess.msg(MoveEnum.getDescByNum(this.move))); + jo.put("hasGoods", this.move == 1 ? true : false); + jo.put("error", LangProcess.msg(ErrorEnum.getDesc(this.getError()))); + jo.put("isError", this.isError); + jo.put("container_type", LangProcess.msg(ContainerTypeEnum.getDescByNum(this.container_type))); + jo.put("action", LangProcess.msg(ActionEnum.getDescByNum(this.action))); + jo.put("carrier_direction", carrier_direction); + jo.put("barcode", this.barcode); + jo.put("task", task); + jo.put("isOnline", this.isOnline); + jo.put("message", this.message); + jo.put("unExecutedMessage", this.unExecutedMessage); + jo.put("is_click", true); + jo.put("requireSuccess", this.requireSuccess); + jo.put("driver_type", "belt_conveyor"); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + Boolean requireSuccess = data.getBoolean("requireSuccess"); + if (requireSuccess != null) { + this.requireSuccess = requireSuccess; + } + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/fold_disc_site/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/fold_disc_site/ItemProtocol.java new file mode 100644 index 0000000..113620c --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/fold_disc_site/ItemProtocol.java @@ -0,0 +1,95 @@ +package org.nl.acs.device_driver.lk_conveyor.fold_disc_site; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + + +public enum ItemProtocol { + HEARTBEAT("heartbeat", "心跳", "DB1.B0"), + MODE("mode", "工作模式", "DB1.B1"), + MOVE("move", "光电信号", "DB1.B2"), + ACTION("action", "取放信号", "DB1.B3"), + ERROR("error", "报警信号", "DB1.B4"), + QTY("qty", "数量", "DB1.B5"), + CONTAINER_TYPE("container_type", "载具类型", "DB1.B6"), + CARRIER_DIRECTION("carrier_direction", "托盘方向", "DB1.B7"), + TASK("task", "任务号", "DB1.D8"), + BARCODE("barcode", "托盘条码", "DB1.String10"), + TO_COMMAND("to_command", "下发命令", "DB2.W0"), + TO_TARGET("to_target", "下发目标站", "DB2.W4"), + TO_CONTAINER_TYPE("to_container_type", "下发托盘类型", "DB2.D6"), + TO_TASK("to_task", "下发任务号", "DB2.W8"); + + private final String key; + private final String description; + private final String address; + + ItemProtocol(String key, String description, String address) { + this.key = key; + this.description = description; + this.address = address; + } + + public String getKey() { + return this.key; + } + + public String getDescription() { + return description; + } + + public String getAddress() { + return address; + } + + // 获取 Integer 类型的值 + public Integer getIntegerValue(FoldDiscSiteDeviceDriver driver) { + Integer value = driver.getIntegerValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0; + } + + // 获取 Float 类型的值 + public Float getFloatValue(FoldDiscSiteDeviceDriver driver) { + Float value = driver.getFloatValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0.00f; + } + + public String getStringValue(FoldDiscSiteDeviceDriver driver) { + return driver.getStringValue(this.getKey()); + } + + public static List getReadableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (!prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } + + public static List getWriteableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } + +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDefination.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDefination.java similarity index 95% rename from acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDefination.java rename to acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDefination.java index 5a3a077..3b13071 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDefination.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.one_conveyor.scanner_weight_conveyor; +package org.nl.acs.device_driver.lk_conveyor.scanner_weight_conveyor; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java new file mode 100644 index 0000000..33314e1 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java @@ -0,0 +1,854 @@ +package org.nl.acs.device_driver.lk_conveyor.scanner_weight_conveyor; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.common.util.concurrent.Uninterruptibles; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.enums.*; +import org.nl.acs.enums.StorageTypeEnum; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.instruction.domain.Instruction; +import org.nl.acs.instruction.enums.InstructionStatusEnum; +import org.nl.acs.instruction.service.InstructionService; +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.route.service.dto.RouteLineDto; +import org.nl.acs.route.service.impl.RouteLineServiceImpl; +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; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.SpringContextHolder; +import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; +import org.nl.system.service.param.ISysParamService; + +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import java.util.stream.Collectors; + +/** + * 输送线工位-带扫码称重 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriver + implements DeviceDriver, + ExecutableDeviceDriver, + RouteableDeviceDriver, + DeviceStageMonitor { + + private final TaskService taskService = SpringContextHolder.getBean(TaskService.class); + private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + private final DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + private final RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); + private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); + private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class); + private final ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); + + /** + * 心跳 + */ + private int heartbeat = 0; + private int lastHeartbeat = 0; + /** + * 工作模式 + */ + private int mode = 0; + private int lastMode = 0; + /** + * 光电信号 + */ + private int move = 0; + private int lastMove = 0; + /** + * 动作信号 + */ + private int action = 0; + private int lastAction = 0; + /** + * 报警信号 + */ + private int error = 0; + private int lastError = 0; + /** + * 任务号 + */ + private int task = 0; + private int lastTask = 0; + /** + * 载具类型 + */ + private int container_type = 0; + private int lastContainer_type = 0; + /** + * 托盘方向 + */ + private int carrier_direction = 0; + private int lastCarrier_direction = 0; + /** + * 重量 + */ + private float weight = 0.0f; + private float lastWeight = 0.0f; + /** + * 高度 + */ + private int height = 0; + private int lastHeight = 0; + /** + * 托盘条码 + */ + private String barcode = null; + private String lastBarcode = null; + /** + * 子卷条码 + */ + private String material_barcode = null; + private String lastMaterial_barcode = null; + /** + * 下发命令 + */ + private int to_command = 0; + private int lastTo_command = 0; + /** + * 下发目标站 + */ + private int to_target = 0; + private int lastTo_target = 0; + /** + * 下发任务号 + */ + private int to_task = 0; + private int lastTo_task = 0; + /** + * 下发托盘类型 + */ + private int to_container_type = 0; + private int lastTo_container_type = 0; + /** + * 下发高度等级 + */ + private int to_height_level = 0; + private int lastTo_height_level = 0; + /** + * 手补托盘条码 + */ + private String hand_barcode = null; + /** + * 手补子卷条码 + */ + private String hand_material_barcode = null; + /** + * 当前设备编号 + */ + private String currentDeviceCode; + /** + * 设备在线状态 + */ + private Boolean isOnline = false; + /** + * 消息 + */ + String message = null; + /** + * 设备报警标记 + */ + private boolean isError = false; + /** + * 请求标记 + */ + boolean requireSuccess = false; + /** + * 请求时间 + */ + private long requireTime = System.currentTimeMillis(); + /** + * 请求间隔时间 + */ + private long requireTimeOut = 5000L; + /** + * 未执行任务原因 + */ + private String unExecutedMessage = null; + /** + * 不需要记录日志的点位 + */ + private static final List No_SET_LOG_KEYS = Arrays.asList(ItemProtocol.HEARTBEAT.getKey()); + + + private String led_message; + + private static final Lock LOCK = new ReentrantLock(); + + public void setLog(String key, Object newValue, Object oldValue) { + if (!No_SET_LOG_KEYS.contains(key)) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "设备线程读取信号:" + key + ",由" + oldValue + "->" + newValue)); + } + } + + @Override + public Device getDevice() { + return this.device; + } + + @Override + public void execute() { + try { + this.currentDeviceCode = this.getDevice().getDevice_code(); + this.heartbeat = ItemProtocol.HEARTBEAT.getIntegerValue(this); + this.mode = ItemProtocol.MODE.getIntegerValue(this); + this.move = ItemProtocol.MOVE.getIntegerValue(this); + this.action = ItemProtocol.ACTION.getIntegerValue(this); + this.error = ItemProtocol.ERROR.getIntegerValue(this); + this.task = ItemProtocol.TASK.getIntegerValue(this); + this.container_type = ItemProtocol.CONTAINER_TYPE.getIntegerValue(this); + this.carrier_direction = ItemProtocol.CARRIER_DIRECTION.getIntegerValue(this); + this.weight = ItemProtocol.WEIGHT.getFloatValue(this); + this.height = ItemProtocol.HEIGHT.getIntegerValue(this); + this.barcode = ItemProtocol.BARCODE.getStringValue(this); + this.material_barcode = ItemProtocol.MATERIAL_BARCODE.getStringValue(this); + this.to_command = ItemProtocol.TO_COMMAND.getIntegerValue(this); + this.to_target = ItemProtocol.TO_TARGET.getIntegerValue(this); + this.to_task = ItemProtocol.TO_TASK.getIntegerValue(this); + this.to_container_type = ItemProtocol.TO_CONTAINER_TYPE.getIntegerValue(this); + this.to_height_level = ItemProtocol.TO_HEIGHT_LEVEL.getIntegerValue(this); + if (this.heartbeat != this.lastHeartbeat) { + this.setLog(ItemProtocol.HEARTBEAT.getKey(), this.heartbeat, this.lastHeartbeat); + } + if (this.mode != this.lastMode) { + this.requireSuccess = false; + this.setLog(ItemProtocol.MODE.getKey(), this.mode, this.lastMode); + } + if (this.move != this.lastMove) { + this.setLog(ItemProtocol.MOVE.getKey(), this.move, this.lastMove); + } + if (this.action != this.lastAction) { + this.setLog(ItemProtocol.ACTION.getKey(), this.action, this.lastAction); + } + if (this.error != this.lastError) { + this.setLog(ItemProtocol.ERROR.getKey(), this.error, this.lastError); + } + if (this.task != this.lastTask) { + this.setLog(ItemProtocol.TASK.getKey(), this.task, this.lastTask); + } + if (this.container_type != this.lastContainer_type) { + this.setLog(ItemProtocol.CONTAINER_TYPE.getKey(), this.container_type, this.lastContainer_type); + } + if (this.carrier_direction != this.lastCarrier_direction) { + this.setLog(ItemProtocol.CARRIER_DIRECTION.getKey(), this.carrier_direction, this.lastCarrier_direction); + } + if (this.carrier_direction != this.lastCarrier_direction) { + this.setLog(ItemProtocol.CARRIER_DIRECTION.getKey(), this.carrier_direction, this.lastCarrier_direction); + } + if (!StrUtil.equals(this.barcode, this.lastBarcode)) { + this.setLog(ItemProtocol.BARCODE.getKey(), this.barcode, this.lastBarcode); + } + if (!StrUtil.equals(this.material_barcode, this.lastMaterial_barcode)) { + this.setLog(ItemProtocol.MATERIAL_BARCODE.getKey(), this.material_barcode, this.lastMaterial_barcode); + } + if (this.weight != this.lastWeight) { + this.setLog(ItemProtocol.WEIGHT.getKey(), this.weight, this.lastWeight); + } + if (this.height != this.lastHeight) { + this.setLog(ItemProtocol.HEIGHT.getKey(), this.height, this.lastHeight); + } + if (this.to_command != this.lastTo_command) { + this.setLog(ItemProtocol.TO_COMMAND.getKey(), this.to_command, this.lastTo_command); + } + if (this.to_target != this.lastTo_target) { + this.setLog(ItemProtocol.TO_TARGET.getKey(), this.to_target, this.lastTo_target); + } + if (this.to_task != this.lastTo_task) { + this.setLog(ItemProtocol.TO_TASK.getKey(), this.to_task, this.lastTo_task); + } + if (this.to_container_type != this.lastTo_container_type) { + this.setLog(ItemProtocol.TO_CONTAINER_TYPE.getKey(), this.to_container_type, this.lastTo_container_type); + } + if (this.to_height_level != this.lastTo_height_level) { + this.setLog(ItemProtocol.TO_HEIGHT_LEVEL.getKey(), this.to_height_level, this.lastTo_height_level); + } + + if (this.move != this.lastMove && this.move == 0 && this.lastMove == 1 && this.mode > 0) { + this.requireSuccess = false; + clearWrite(); + } + + if (this.move != 0 && this.task > 0) { + update_instruction_status(); + } + + if (this.mode == 0) { + this.isOnline = false; + this.message = LangProcess.msg("110000"); + //有报警 + } else if (this.error != 0) { + this.isError = true; + this.message = LangProcess.msg(ErrorEnum.getDesc(this.error)); + } else { + this.isOnline = true; + this.isError = false; + this.message = null; + + Boolean isApplyTask = Optional.ofNullable(this.getExtraValue().get("apply_task")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + + //申请木箱装箱任务 + if (this.mode == 6 && this.move > 0 && !this.requireSuccess) { + if (!isApplyTask) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode); + return; + } + if (StrUtil.isNotBlank(hand_barcode) && StrUtil.isNotBlank(hand_material_barcode)) { + applyInByHand(StorageTypeEnum.BOX_IN.getType(), this.mode); + } else if (StrUtil.isNotBlank(barcode) && StrUtil.isNotBlank(material_barcode)) { + applyIn(StorageTypeEnum.BOX_IN.getType(), this.mode); + } else { + this.message = LangProcess.msg("310012"); + } + } + + //子卷入库申请入库任务 + if (this.mode == 7 && this.move > 0 && !this.requireSuccess) { + if (!isApplyTask) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode); + return; + } + if (StrUtil.isNotBlank(hand_barcode) && StrUtil.isNotBlank(hand_material_barcode)) { + applyInByHand(StorageTypeEnum.STORAGE.getType(), this.mode); + } else if (StrUtil.isNotBlank(this.barcode) && StrUtil.isNotBlank(this.material_barcode)) { + applyIn(StorageTypeEnum.STORAGE.getType(), this.mode); + } else { + this.message = LangProcess.msg("310012"); + } + } + + //申请空托盘入库 + if (this.mode == 9 && this.move > 0 && !this.requireSuccess) { + if (!isApplyTask) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode); + return; + } + if (this.container_type == 0 || StrUtil.isEmpty(this.barcode)) { + this.message = LangProcess.msg("310001"); + } else { + applyEmptyTask(StorageTypeEnum.DISKS_IN.getType(), this.mode); + } + } + + //申请退货入库 + if (this.mode == 18 && this.move > 0 && !this.requireSuccess) { + if (!isApplyTask) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), this.mode); + return; + } + if (StrUtil.isNotBlank(this.hand_barcode) && StrUtil.isNotBlank(this.hand_material_barcode)) { + applyBoxReturnTask(StorageTypeEnum.BOX_RETURN.getType(), this.mode); + } else if (StrUtil.isNotBlank(this.barcode) && StrUtil.isNotBlank(this.material_barcode)) { + applyBoxReturnTask(StorageTypeEnum.BOX_RETURN.getType(), this.mode); + } else { + this.message = LangProcess.msg("310012"); + } + } + + //申请高度 + if (this.mode == 23 && this.move > 0 && !this.requireSuccess) { + if (StrUtil.isNotBlank(this.hand_barcode) && StrUtil.isNotBlank(this.hand_material_barcode)) { + applyErrorHeight(); + } else if (StrUtil.isNotBlank(this.barcode) && StrUtil.isNotBlank(this.material_barcode)) { + applyErrorHeight(); + } else { + this.message = LangProcess.msg("310012"); + } + } + + //申请入库指令、异常位指令 + if (this.mode == 2 && this.move > 0 && !this.requireSuccess) { + instruction_require(); + } + + } + this.lastHeartbeat = this.heartbeat; + this.lastMode = this.mode; + this.lastMove = this.move; + this.lastAction = this.action; + this.lastError = this.error; + this.lastWeight = this.weight; + this.lastHeight = this.height; + this.lastTask = this.task; + this.lastContainer_type = this.container_type; + this.lastCarrier_direction = this.carrier_direction; + this.lastBarcode = this.barcode; + this.lastTo_command = this.to_command; + this.lastTo_target = this.to_target; + this.lastTo_task = this.to_task; + this.lastTo_container_type = this.to_container_type; + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1005"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "当前设备执行逻辑报错, 错误详情: " + e.getMessage() + ", 错误堆栈信息: " + Arrays.toString(e.getStackTrace()))); + Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); + } + + } + + private void applyErrorHeight() { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + JSONObject param = new JSONObject(); + param.put("device_code", this.currentDeviceCode); + if (StrUtil.isNotEmpty(this.barcode) && (this.barcode.startsWith("A") || this.barcode.startsWith("B"))) { + param.put("vehicle_code", this.barcode); + } + if (StrUtil.isNotEmpty(this.material_barcode)) { + param.put("material_barcode", this.material_barcode); + } + if (StrUtil.isNotEmpty(this.hand_barcode)) { + param.put("vehicle_code", this.hand_barcode); + } + if (StrUtil.isNotEmpty(this.hand_material_barcode)) { + param.put("material_barcode", this.hand_material_barcode); + } + String response = acsToWmsService.getBoxInfo(param); + if (response != null) { + JSONObject resp = JSON.parseObject(response); + if (resp != null && resp.getIntValue("status") != 200) { + String heightLevel = resp.getString("heightLevel"); + List keys = Arrays.asList(ItemProtocol.TO_HEIGHT_LEVEL.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(Integer.parseInt(heightLevel), this.mode); + this.writing(keys, values); + this.requireSuccess = true; + } else { + this.message = LangProcess.msg("310002"); + } + } else { + this.message = LangProcess.msg("310002"); + } + } + } + + private void applyBoxReturnTask(String type, int mode) { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + JSONObject param = new JSONObject(); + param.put("device_code", this.currentDeviceCode); + if (StrUtil.isNotEmpty(this.hand_barcode)) { + param.put("vehicle_code", this.hand_barcode); + } else { + if (StrUtil.isNotEmpty(this.barcode) && (this.barcode.startsWith("A") || this.barcode.startsWith("B"))) { + param.put("vehicle_code", this.barcode); + } + } + if (StrUtil.isNotEmpty(this.hand_material_barcode)) { + param.put("material_barcode", this.hand_material_barcode); + } else { + if (StrUtil.isNotEmpty(this.material_barcode)) { + param.put("material_barcode", this.material_barcode); + } + } + param.put("type", type); + TaskDto dto = taskService.findByBarcodeFromCache(barcode); + if (ObjectUtil.isNotEmpty(dto)) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), 1); + this.requireSuccess = true; + } else { + HttpResponse httpResponse = acsToWmsService.applyTwo(param); + if (httpResponse != null) { + JSONObject resp = JSONObject.parseObject(httpResponse.body()); + if (resp != null && resp.getIntValue("status") == 200) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), mode); + this.requireSuccess = true; + } else { + this.message = LangProcess.msg("310002"); + } + } else { + this.message = LangProcess.msg("310002"); + } + } + } + } + + public void clearWrite() { + List keys = Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_CONTAINER_TYPE.getKey()); + List values = Arrays.asList(0, 0, 0); + this.writing(keys, values); + } + + private void applyEmptyTask(String type, int mode) { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + JSONObject param = new JSONObject(); + param.put("device_code", this.currentDeviceCode); + param.put("container_type", this.container_type); + if (StrUtil.isNotEmpty(this.hand_barcode)) { + param.put("vehicle_code", this.hand_barcode); + } else { + if (StrUtil.isNotEmpty(this.barcode) && (this.barcode.startsWith("A") || this.barcode.startsWith("B"))) { + param.put("vehicle_code", this.barcode); + } + } + param.put("type", type); + HttpResponse httpResponse = acsToWmsService.applyTwo(param); + if (httpResponse != null) { + JSONObject resp = JSONObject.parseObject(httpResponse.body()); + if (resp.getIntValue("status") == 200) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), mode); + this.hand_barcode = null; + this.requireSuccess = true; + } else { + this.message = LangProcess.msg("310002"); + } + } else { + this.message = LangProcess.msg("310002"); + } + + } + } + + private void applyIn(String type, int mode) { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + JSONObject param = new JSONObject(); + param.put("device_code", this.currentDeviceCode); + if (this.barcode.startsWith("A") || this.barcode.startsWith("B")) { + param.put("vehicle_code", this.barcode); + } + param.put("material_barcode", this.material_barcode); + if (mode == 7 && this.weight != 0) { + param.put("weight", this.weight); + } + param.put("type", type); + HttpResponse httpResponse = acsToWmsService.applyTwo(param); + if (ObjectUtil.isNotEmpty(httpResponse)) { + JSONObject resp = JSONObject.parseObject(httpResponse.body()); + if (resp != null && resp.getIntValue("status") == 200) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), mode); + this.requireSuccess = true; + } else { + this.message = LangProcess.msg("310002"); + } + } else { + this.message = LangProcess.msg("310002"); + } + } + } + + private void applyInByHand(String type, int mode) { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + JSONObject param = new JSONObject(); + param.put("device_code", this.currentDeviceCode); + param.put("vehicle_code", this.hand_barcode); + param.put("material_barcode", this.hand_material_barcode); + if (mode == 7 && this.weight != 0) { + param.put("weight", this.weight); + } + param.put("type", type); + HttpResponse httpResponse = acsToWmsService.applyTwo(param); + if (ObjectUtil.isNotEmpty(httpResponse)) { + JSONObject resp = JSONObject.parseObject(httpResponse.body()); + if (resp != null && resp.getIntValue("status") == 200) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), mode); + this.hand_barcode = null; + this.hand_material_barcode = null; + this.requireSuccess = true; + return; + } + this.message = LangProcess.msg("310002"); + } else { + this.message = LangProcess.msg("310002"); + } + } + } + + + /** + * 更新指令状态 + */ + public void update_instruction_status() throws Exception { + Instruction inst = instructionService.findByCodeFromCache(String.valueOf(this.task)); + if (ObjectUtil.isNotEmpty(inst)) { + if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex()) && StrUtil.equals(this.currentDeviceCode, inst.getStart_device_code())) { + inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.update(inst); + } else if (StrUtil.equals(this.currentDeviceCode, inst.getNext_device_code())) { + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.finish(inst); + } + } + } + + + private boolean isIssued(Device device) { + boolean isTwoWay = Optional.ofNullable(device.getExtraValue().get("isTwoWayPoint")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + if (isTwoWay) { + Instruction instruction = instructionService.findByStartAndNextDeviceCode(device.getDevice_code()); + if (ObjectUtil.isNotEmpty(instruction)) { + return false; + } + } + return true; + } + + private int getTargetAddress(Device nextDevice) { + return Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0); + } + + private String getNextDeviceCode(TaskDto taskDto) { + List shortPathsList = routeLineService.getShortPathLines(taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code()); + if (ObjectUtils.isEmpty(shortPathsList)) { + return null; + } + RouteLineDto routeLineDto = shortPathsList.get(0); + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(taskDto.getStart_device_code())) { + index = m + 1; + break; + } + } + return pathlist.get(index); + } + + /** + * 请求指令 + */ + public void instruction_require() { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + String queryBarcode = null; + //先判断补码是否为空 + if (StrUtil.isNotBlank(this.hand_barcode)) { + queryBarcode = this.hand_barcode; + } else if (StrUtil.isNotBlank(this.barcode)) { + queryBarcode = this.barcode; + } else { + this.message = LangProcess.msg("310013"); + return; + } + Instruction inst = instructionService.findByBarcodeFromCache(queryBarcode); + if (ObjectUtil.isNotEmpty(inst)) { + Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); + if (next_device == null) { + this.message = LangProcess.msg("1008") + ":" + inst.getNext_device_code(); + return; + } + List targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode"); + if (!targetDeviceCode.contains(inst.getNext_device_code())) { + this.message = LangProcess.msg("310003"); + return; + } + List keys = Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(getTargetAddress(next_device), Integer.parseInt(inst.getInstruction_code()), 1); + this.writing(keys, values); + this.requireSuccess = true; + return; + } + boolean isCreateInst = Optional.ofNullable(this.getExtraValue().get("isCreateInst")).map(Object::toString).map(Boolean::parseBoolean).orElse(false); + if (!isCreateInst) { + this.unExecutedMessage = LangProcess.msg("310005"); + return; + } + TaskDto taskDto = taskService.findByVehicleCodeCodeAndReady(queryBarcode); + if (ObjectUtil.isNotEmpty(taskDto)) { + String next_device_code = null; + String assignedDeviceCode = taskService.queryAssignedByDevice(this.currentDeviceCode, taskDto.getNext_device_code()); + if (StrUtil.isEmpty(assignedDeviceCode)) { + next_device_code = this.getNextDeviceCode(taskDto); + if (next_device_code == null) { + this.unExecutedMessage = taskDto.getStart_device_code() + "->" + next_device_code + LangProcess.msg("1009"); + return; + } + } else { + next_device_code = assignedDeviceCode; + } + Device next_device = deviceAppService.findDeviceByCode(next_device_code); + if (next_device == null) { + this.unExecutedMessage = LangProcess.msg("1008") + ":" + next_device_code; + return; + } + List targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode"); + if (!targetDeviceCode.contains(inst.getNext_device_code())) { + this.unExecutedMessage = LangProcess.msg("310006"); + return; + } + //判断终点是否是双向点位 + if (!this.isIssued(next_device)) { + this.unExecutedMessage = LangProcess.msg("310004"); + return; + } + Instruction instDto = new Instruction(); + try { + packageInst(instDto, taskDto, next_device_code); + instructionService.create(instDto); + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1006"); + return; + } + taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskService.update(taskDto); + List keys = Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_COMMAND.getKey()); + List values = Arrays.asList(this.getTargetAddress(next_device), Integer.parseInt(inst.getInstruction_code()), 1); + this.writing(keys, values); + this.requireSuccess = true; + } + } + } + + + private void packageInst(Instruction instDto, TaskDto taskDto, String next_device_code) { + instDto.setInstruction_id(IdUtil.simpleUUID()); + instDto.setRoute_plan_code(taskDto.getRoute_plan_code()); + instDto.setRemark(taskDto.getRemark()); + instDto.setMaterial(taskDto.getMaterial()); + instDto.setQuantity(taskDto.getQuantity()); + instDto.setTask_id(taskDto.getTask_id()); + instDto.setTask_code(taskDto.getTask_code()); + instDto.setVehicle_code(taskDto.getVehicle_code()); + String now = DateUtil.now(); + instDto.setCreate_time(now); + instDto.setCreate_by(SecurityUtils.getCurrentNickName()); + instDto.setStart_device_code(taskDto.getStart_device_code()); + instDto.setNext_device_code(next_device_code); + instDto.setStart_point_code(taskDto.getStart_point_code()); + instDto.setNext_point_code(next_device_code); + instDto.setPriority(taskDto.getPriority()); + instDto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); + instDto.setExecute_device_code(this.currentDeviceCode); + instDto.setInstruction_type(taskDto.getTask_type()); + instDto.setVehicle_type(taskDto.getVehicle_type()); + } + + private boolean isTimeValid(long currentTimeMillis) { + return currentTimeMillis - this.requireTime >= this.requireTimeOut; + } + + /** + * 下发单个电气信号 + * + * @param key + * @param value + */ + public void writing(String key, Object value) { + Map itemMap = new HashMap(); + itemMap.put(getId() + key, value); + try { + this.checkcontrol(itemMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 下发多个电气信号 + * + * @param keys + * @param values + */ + public void writing(List keys, List values) { + if (keys.size() != values.size()) { + this.message = LangProcess.msg("1007"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "参数长度不一致,不允许下发")); + throw new BadRequestException("参数长度不一致,不允许下发"); + } + Map controlMap = new LinkedHashMap<>(); + for (int i = 0; i < keys.size(); i++) { + controlMap.put(getId() + keys.get(i), values.get(i)); + } + try { + this.checkcontrol(controlMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 抽取统一下发电气信号前缀 + * + * @return + */ + public String getId() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", LangProcess.msg(ModeEnum.getDescByNum(this.mode))); + jo.put("move", LangProcess.msg(MoveEnum.getDescByNum(this.move))); + jo.put("hasGoods", this.move == 1 ? true : false); + jo.put("error", LangProcess.msg(ErrorEnum.getDesc(this.getError()))); + jo.put("isError", this.isError); + jo.put("container_type", LangProcess.msg(ContainerTypeEnum.getDescByNum(this.container_type))); + jo.put("action", LangProcess.msg(ActionEnum.getDescByNum(this.action))); + jo.put("carrier_direction", carrier_direction); + jo.put("task", this.task); + jo.put("weight", this.weight); + jo.put("height", this.height); + jo.put("barcode", this.barcode); + jo.put("material_barcode", this.material_barcode); + jo.put("isOnline", this.isOnline); + jo.put("message", this.message); + jo.put("unExecutedMessage", this.unExecutedMessage); + jo.put("requireSuccess", this.requireSuccess); + jo.put("driver_type", "conveyor_with_scanner_weight"); + jo.put("is_click", true); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + Boolean requireSuccess = data.getBoolean("requireSuccess"); + if (requireSuccess != null) { + this.requireSuccess = requireSuccess; + } + String hand_barcode = data.getString("hand_barcode"); + this.setHand_barcode(hand_barcode); + String hand_material_barcode = data.getString("hand_material_barcode"); + this.setHand_material_barcode(hand_material_barcode); + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/scanner_weight_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/scanner_weight_conveyor/ItemProtocol.java new file mode 100644 index 0000000..2f80dcb --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/scanner_weight_conveyor/ItemProtocol.java @@ -0,0 +1,103 @@ +package org.nl.acs.device_driver.lk_conveyor.scanner_weight_conveyor; + +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + +@Slf4j +public enum ItemProtocol { + HEARTBEAT("heartbeat", "心跳", "DB1.B0"), + MODE("mode", "工作模式", "DB1.B1"), + MOVE("move", "光电信号", "DB1.B2"), + ACTION("action", "动作信号", "DB1.B3"), + ERROR("error", "报警信号", "DB1.B5"), + TASK("task", "任务号", "DB1.D6"), + CONTAINER_TYPE("container_type", "载具类型", "DB1.B7"), + CARRIER_DIRECTION("carrier_direction", "托盘方向", "DB1.B8"), + WEIGHT("weight", "重量", "DB1.B10"), + HEIGHT("height", "高度", "DB1.B11"), + BARCODE("barcode", "托盘条码", "DB602.STRING1.50"), + MATERIAL_BARCODE("material_barcode", "子卷条码", "DB601.STRING1.50"), + TO_COMMAND("to_command", "下发命令", "DB2.W0"), + TO_TARGET("to_target", "下发目标站", "DB2.W4"), + TO_TASK("to_task", "下发任务号", "DB2.D6"), + TO_CONTAINER_TYPE("to_container_type", "下发托盘类型", "DB2.W8"), + TO_HEIGHT_LEVEL("to_height_level", "下发高度等级", "DB2.W10"); + + private final String key; + private final String description; + private final String address; + + ItemProtocol(String key, String description, String address) { + this.key = key; + this.description = description; + this.address = address; + } + + public String getKey() { + return this.key; + } + + public String getDescription() { + return description; + } + + public String getAddress() { + return address; + } + + // 获取 Integer 类型的值 + public Integer getIntegerValue(ConveyorWithScannerWeightDeviceDriver driver) { + Integer value = driver.getIntegerValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0; + } + + // 获取 Float 类型的值 + public Float getFloatValue(ConveyorWithScannerWeightDeviceDriver driver) { + Float value = driver.getFloatValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0.00f; + } + + public String getStringValue(ConveyorWithScannerWeightDeviceDriver driver) { + return driver.getStringValue(this.getKey()); + } + + public static List getReadableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (!prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } + + public static List getWriteableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } + + @Override + public String toString() { + return ""; + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/un_box_lable_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/un_box_lable_conveyor/ItemProtocol.java new file mode 100644 index 0000000..58b6ca6 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/un_box_lable_conveyor/ItemProtocol.java @@ -0,0 +1,100 @@ +package org.nl.acs.device_driver.lk_conveyor.un_box_lable_conveyor; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + +public enum ItemProtocol { + + HEARTBEAT("heartbeat", "心跳", "DB600.B0"), + MODE("mode", "工作模式", "DB600.B2"), + MOVE("move", "光电信号", "DB600.B3"), + ACTION("action", "取放信号", "DB600.B4"), + ERROR("error", "报警信号", "DB600.B5"), + MATERIAL_CODE("material_code", "物料编码", "DB600.B6"), + CONTAINER_TYPE("container_type", "载具类型", "DB600.B7"), + CARRIER_DIRECTION("carrier_direction", "托盘方向", "DB600.B8"), + TASK("task", "任务号", "DB600.D10"), + TO_COMMAND("to_command", "下发命令", "DB601.W2"), + TO_TARGET("to_target", "下发目标站", "DB601.W4"), + TO_CONTAINER_TYPE("to_container_type", "下发托盘类型", "DB601.W6"), + TO_TASK("to_task", "下发任务号", "DB601.D8"), + TO_LENGTH("to_length", "下发木箱长", "DB601.W10"), + TO_WIDTH("to_width", "下发木箱宽", "DB601.W12"), + TO_HEIGHT("to_height", "下发木箱高", "DB601.W14"), + TO_TYPE("to_type", "下发任务类型", "DB601.W16"), + TO_DESICCANT("to_desiccant", "下发干燥机模板", "DB601.W18"); + + private final String key; + private final String description; + private final String address; + + ItemProtocol(String key, String description, String address) { + this.key = key; + this.description = description; + this.address = address; + } + + public String getKey() { + return this.key; + } + + public String getDescription() { + return description; + } + + public String getAddress() { + return address; + } + + // 获取 Integer 类型的值 + public Integer getIntegerValue(UnBoxLableConveyorDeviceDriver driver) { + Integer value = driver.getIntegerValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0; + } + + // 获取 Float 类型的值 + public Float getFloatValue(UnBoxLableConveyorDeviceDriver driver) { + Float value = driver.getFloatValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0.00f; + } + + public String getStringValue(UnBoxLableConveyorDeviceDriver driver) { + return driver.getStringValue(this.getKey()); + } + + public static List getReadableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (!prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } + + public static List getWriteableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } + +} + diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDefination.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDefination.java similarity index 95% rename from acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDefination.java rename to acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDefination.java index 5e5a5b3..3603db3 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDefination.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.one_conveyor.un_box_lable_conveyor; +package org.nl.acs.device_driver.lk_conveyor.un_box_lable_conveyor; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java new file mode 100644 index 0000000..87a9376 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java @@ -0,0 +1,451 @@ +package org.nl.acs.device_driver.lk_conveyor.un_box_lable_conveyor; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.common.util.concurrent.Uninterruptibles; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.enums.*; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.instruction.domain.Instruction; +import org.nl.acs.instruction.enums.InstructionStatusEnum; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.monitor.DeviceStageMonitor; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.route.service.RouteLineService; +import org.nl.common.exception.BadRequestException; +import org.nl.config.SpringContextHolder; +import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; + +import java.util.*; +import java.util.concurrent.TimeUnit; + +/** + * 一楼申请开箱位、贴标位 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver + implements DeviceDriver, + ExecutableDeviceDriver, + RouteableDeviceDriver, + DeviceStageMonitor { + + private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + private final RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + private final DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); + private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); + private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class); + + /** + * 心跳 + */ + private int heartbeat = 0; + private int lastHeartbeat = 0; + /** + * 工作模式 + */ + private int mode = 0; + private int lastMode = 0; + /** + * 光电信号 + */ + private int move = 0; + private int lastMove = 0; + /** + * 动作信号 + */ + private int action = 0; + private int lastAction = 0; + /** + * 报警信号 + */ + private int error = 0; + private int lastError = 0; + /** + * 物料编码 + */ + private String material_barcode = null; + private String lastMaterial_barcode = null; + /** + * 载具类型 + */ + private int container_type = 0; + private int lastContainer_type = 0; + /** + * 托盘方向 + */ + private int carrier_direction = 0; + private int lastCarrier_direction = 0; + /** + * 任务号 + */ + private int task = 0; + private int lastTask = 0; + /** + * 下发命令 + */ + private int to_command = 0; + private int lastTo_command = 0; + /** + * 下发目标站 + */ + private int to_target = 0; + private int lastTo_target = 0; + /** + * 下发任务号 + */ + private int to_task = 0; + private int lastTo_task = 0; + /** + * 下发托盘类型 + */ + private int to_container_type = 0; + private int lastTo_container_type = 0; + /** + * 下发木箱长度 + */ + private int to_length = 0; + private int lastTo_length = 0; + /** + * 下发木箱宽度 + */ + private int to_width = 0; + private int lastTo_width = 0; + /** + * 下发木箱高度 + */ + private int to_height = 0; + private int lastTo_height = 0; + /** + * 下发干燥机模板 + */ + private int to_desiccant = 0; + private int lastTo_desiccant = 0; + /** + * 手补子卷条码 + */ + private String hand_material_barcode = null; + /** + * 当前设备编号 + */ + private String currentDeviceCode; + /** + * 设备在线状态 + */ + private Boolean isOnline = false; + /** + * 消息 + */ + String message = null; + /** + * 设备报警标记 + */ + private boolean isError = false; + /** + * 请求标记 + */ + boolean requireSuccess = false; + /** + * 请求时间 + */ + private long requireTime = System.currentTimeMillis(); + /** + * 请求间隔时间 + */ + private long requireTimeOut = 5000L; + /** + * 未执行任务原因 + */ + private String unExecutedMessage = null; + /** + * 不需要记录日志的点位 + */ + private static final List No_SET_LOG_KEYS = Arrays.asList(ItemProtocol.HEARTBEAT.getKey()); + + + public void setLog(String key, Object newValue, Object oldValue) { + if (!No_SET_LOG_KEYS.contains(key)) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "设备线程读取信号:" + key + ",由" + oldValue + "->" + newValue)); + } + } + + private boolean isTimeValid(long currentTimeMillis) { + return currentTimeMillis - this.requireTime >= this.requireTimeOut; + } + + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + try { + this.currentDeviceCode = this.getDevice().getDevice_code(); + this.heartbeat = ItemProtocol.HEARTBEAT.getIntegerValue(this); + this.mode = ItemProtocol.MODE.getIntegerValue(this); + this.move = ItemProtocol.MOVE.getIntegerValue(this); + this.action = ItemProtocol.ACTION.getIntegerValue(this); + this.error = ItemProtocol.ERROR.getIntegerValue(this); + this.container_type = ItemProtocol.CONTAINER_TYPE.getIntegerValue(this); + this.carrier_direction = ItemProtocol.CARRIER_DIRECTION.getIntegerValue(this); + this.task = ItemProtocol.TASK.getIntegerValue(this); + this.material_barcode = ItemProtocol.MATERIAL_CODE.getStringValue(this); + this.to_command = ItemProtocol.TO_COMMAND.getIntegerValue(this); + this.to_target = ItemProtocol.TO_TARGET.getIntegerValue(this); + this.to_task = ItemProtocol.TO_TASK.getIntegerValue(this); + this.to_container_type = ItemProtocol.TO_CONTAINER_TYPE.getIntegerValue(this); + this.to_length = ItemProtocol.TO_LENGTH.getIntegerValue(this); + this.to_width = ItemProtocol.TO_WIDTH.getIntegerValue(this); + this.to_height = ItemProtocol.TO_HEIGHT.getIntegerValue(this); + this.to_desiccant = ItemProtocol.TO_DESICCANT.getIntegerValue(this); + if (this.heartbeat != this.lastHeartbeat) { + this.setLog(ItemProtocol.HEARTBEAT.getKey(), this.heartbeat, this.lastHeartbeat); + } + if (this.mode != this.lastMode) { + this.requireSuccess = false; + this.setLog(ItemProtocol.MODE.getKey(), this.mode, this.lastMode); + } + if (this.move != this.lastMove) { + this.setLog(ItemProtocol.MOVE.getKey(), this.move, this.lastMove); + } + if (this.action != this.lastAction) { + this.setLog(ItemProtocol.ACTION.getKey(), this.action, this.lastAction); + } + if (this.error != this.lastError) { + this.setLog(ItemProtocol.ERROR.getKey(), this.error, this.lastError); + } + if (this.container_type != this.lastContainer_type) { + this.setLog(ItemProtocol.CONTAINER_TYPE.getKey(), this.container_type, this.lastContainer_type); + } + if (this.carrier_direction != this.lastCarrier_direction) { + this.setLog(ItemProtocol.CARRIER_DIRECTION.getKey(), this.carrier_direction, this.lastCarrier_direction); + } + if (!StrUtil.equals(this.material_barcode, this.lastMaterial_barcode)) { + this.setLog(ItemProtocol.MATERIAL_CODE.getKey(), this.material_barcode, this.lastMaterial_barcode); + } + if (this.task != this.lastTask) { + this.setLog(ItemProtocol.TASK.getKey(), this.task, this.lastTask); + } + if (this.to_command != this.lastTo_command) { + this.setLog(ItemProtocol.TO_COMMAND.getKey(), this.to_command, this.lastTo_command); + } + if (this.to_target != this.lastTo_target) { + this.setLog(ItemProtocol.TO_TARGET.getKey(), this.to_target, this.lastTo_target); + } + if (this.to_task != this.lastTo_task) { + this.setLog(ItemProtocol.TO_TASK.getKey(), this.to_task, this.lastTo_task); + } + if (this.to_container_type != this.lastTo_container_type) { + this.setLog(ItemProtocol.TO_CONTAINER_TYPE.getKey(), this.to_container_type, this.lastTo_container_type); + } + if (this.to_length != this.lastTo_length) { + this.setLog(ItemProtocol.TO_LENGTH.getKey(), this.to_length, this.lastTo_length); + } + if (this.to_width != this.lastTo_width) { + this.setLog(ItemProtocol.TO_WIDTH.getKey(), this.to_width, this.lastTo_width); + } + if (this.to_height != this.lastTo_height) { + this.setLog(ItemProtocol.TO_HEIGHT.getKey(), this.to_height, this.lastTo_height); + } + if (this.to_desiccant != this.lastTo_desiccant) { + this.setLog(ItemProtocol.TO_DESICCANT.getKey(), this.to_desiccant, this.lastTo_desiccant); + } + + if (this.mode == 0) { + this.isOnline = false; + this.message = LangProcess.msg("110000"); + } else if (this.error > 0) { + this.isError = true; + this.message = LangProcess.msg(ErrorEnum.getDesc(this.error)); + } else { + this.isOnline = true; + this.isError = false; + //空箱出库开盖位,申请开盖 + if (this.mode == 15 && this.move == 1 && this.task > 0) { + Instruction instruction = instructionService.findByCode(String.valueOf(this.task)); + //不允许开盖,完成出库任务,自动去扫码位 + if (StrUtil.isEmpty(instruction.getVehicle_code())) { + this.message = LangProcess.msg("310014"); + return; + } + applyUnbox(instruction.getVehicle_code()); + } + } + + this.lastHeartbeat = this.heartbeat; + this.lastMode = this.mode; + this.lastMove = this.move; + this.lastAction = this.action; + this.lastError = this.error; + this.lastContainer_type = this.container_type; + this.lastCarrier_direction = this.carrier_direction; + this.lastTask = this.task; + this.lastMaterial_barcode = this.material_barcode; + this.lastTo_command = this.to_command; + this.lastTo_target = this.to_target; + this.lastTo_task = this.to_task; + this.lastTo_container_type = this.to_container_type; + this.lastTo_length = this.to_length; + this.lastTo_width = this.to_width; + this.lastTo_height = this.to_height; + this.lastTo_desiccant = this.to_desiccant; + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1005"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "当前设备执行逻辑报错, 错误详情: " + e.getMessage() + ", 错误堆栈信息: " + Arrays.toString(e.getStackTrace()))); + Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); + } + } + + private void applyUnbox(String vehicleCode) { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + JSONObject param = new JSONObject(); + param.put("device_code", this.currentDeviceCode); + param.put("material_barcode", vehicleCode); + param.put("task", this.task); + String response = acsToWmsService.getIsUncap(param); + JSONObject jo = JSON.parseObject(response); + if (jo.getIntValue("status") == 200) { + Integer length = jo.getInteger("boxLength"); + Integer weight = jo.getInteger("boxWidth"); + Integer height = jo.getInteger("boxHigh"); + Integer desiccant = jo.getInteger("desiccantTemplate"); + Integer type = jo.getInteger("type"); + List keys = Arrays.asList(ItemProtocol.TO_LENGTH.getKey(), ItemProtocol.TO_WIDTH.getKey(), ItemProtocol.TO_HEIGHT.getKey(), ItemProtocol.TO_DESICCANT.getKey(), ItemProtocol.TO_TYPE.getKey()); + List values = Arrays.asList(length, weight, height, desiccant, type); + this.writing(keys, values); + String isUncap = jo.getString("isUncap"); + if ("1".equals(isUncap)) { + this.writing(ItemProtocol.TO_COMMAND.getKey(), 15); + } else { + this.writing(ItemProtocol.TO_COMMAND.getKey(), 99); + try { + instructionService.finish(String.valueOf(this.task)); + } catch (Exception e) { + this.message = LangProcess.msg("310015"); + return; + } + } + this.requireSuccess = true; + } else { + this.message = LangProcess.msg("310002"); + } + } + } + + /** + * 下发单个电气信号 + * + * @param key + * @param value + */ + public void writing(String key, Object value) { + Map itemMap = new HashMap(); + itemMap.put(getId() + key, value); + try { + this.checkcontrol(itemMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 下发多个电气信号 + * + * @param keys + * @param values + */ + public void writing(List keys, List values) { + if (keys.size() != values.size()) { + this.message = "1007"; + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "参数长度不一致,不允许下发")); + throw new BadRequestException("参数长度不一致,不允许下发"); + } + Map controlMap = new LinkedHashMap<>(); + for (int i = 0; i < keys.size(); i++) { + controlMap.put(getId() + keys.get(i), values.get(i)); + } + try { + this.checkcontrol(controlMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 抽取统一下发电气信号前缀 + * + * @return + */ + public String getId() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } + + /** + * 更新指令状态 + */ + public void update_instruction_status() throws Exception { + Instruction inst = instructionService.findByCodeFromCache(String.valueOf(this.task)); + if (ObjectUtil.isNotEmpty(inst)) { + if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex()) && StrUtil.equals(this.currentDeviceCode, inst.getStart_device_code())) { + inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.update(inst); + } else if (StrUtil.equals(this.currentDeviceCode, inst.getNext_device_code())) { + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.finish(inst); + } + } + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", LangProcess.msg(ModeEnum.getDescByNum(this.mode))); + jo.put("move", LangProcess.msg(MoveEnum.getDescByNum(this.move))); + jo.put("hasGoods", this.move == 1 ? true : false); + jo.put("error", LangProcess.msg(ErrorEnum.getDesc(this.getError()))); + jo.put("isError", this.isError); + jo.put("type", LangProcess.msg(ContainerTypeEnum.getDescByNum(this.container_type))); + jo.put("action", LangProcess.msg(ActionEnum.getDescByNum(this.action))); + jo.put("carrier_direction", this.carrier_direction); + jo.put("task", this.task); + jo.put("isOnline", this.isOnline); + jo.put("message", this.message); + jo.put("unExecutedMessage", this.unExecutedMessage); + jo.put("is_click", true); + jo.put("requireSuccess", this.requireSuccess); + jo.put("driver_type", "belt_conveyor"); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + Boolean requireSuccess = data.getBoolean("requireSuccess"); + if (requireSuccess != null) { + this.requireSuccess = requireSuccess; + } + } + +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/BoxManipulatorDefination.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/BoxManipulatorDefination.java new file mode 100644 index 0000000..cd5cd68 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/BoxManipulatorDefination.java @@ -0,0 +1,65 @@ +package org.nl.acs.device_driver.lk_manipulator.box_manipulator; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.enums.DeviceType; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +/** + * 一楼木箱机械手、子卷机械手对接位 + * + * + */ +@Service +public class BoxManipulatorDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "box_manipulator"; + } + + @Override + public String getDriverName() { + return "一楼木箱机械手"; + } + + @Override + public String getDriverDescription() { + return "一楼木箱机械手"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new BoxManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return BoxManipulatorDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.robot); + return types; + } + + @Override + public List getReadableItemDtos() { + return ItemProtocol.getReadableItemDtos(); + } + + + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/BoxManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/BoxManipulatorDeviceDriver.java new file mode 100644 index 0000000..59a0a79 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/BoxManipulatorDeviceDriver.java @@ -0,0 +1,616 @@ +package org.nl.acs.device_driver.lk_manipulator.box_manipulator; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.common.util.concurrent.Uninterruptibles; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.lk_manipulator.enums.ActionEnum; +import org.nl.acs.device_driver.lk_manipulator.enums.ErrorEnum; +import org.nl.acs.device_driver.lk_manipulator.enums.ModeEnum; +import org.nl.acs.device_driver.lk_manipulator.enums.MoveEnum; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.instruction.domain.Instruction; +import org.nl.acs.instruction.enums.InstructionStatusEnum; +import org.nl.acs.instruction.service.InstructionService; +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.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.SpringContextHolder; +import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; +import org.nl.system.service.param.ISysParamService; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.TimeUnit; + +/** + * 一楼木箱机械手 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class BoxManipulatorDeviceDriver extends AbstractOpcDeviceDriver + implements DeviceDriver, + ExecutableDeviceDriver, + RouteableDeviceDriver, + DeviceStageMonitor { + + private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + private final TaskService taskService = SpringContextHolder.getBean(TaskService.class); + private final DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); + private final RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); + private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class); + private final ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); + + /** + * 心跳 + */ + private int heartbeat = 0; + private int lastHeartbeat = 0; + /** + * 工作模式 + */ + private int mode = 0; + private int lastMode = 0; + /** + * 光电信号 + */ + private int move = 0; + private int lastMove = 0; + /** + * 动作信号 + */ + private int action = 0; + private int lastAction = 0; + /** + * 报警信号 + */ + private int error = 0; + private int lastError = 0; + /** + * 任务号 + */ + private int task = 0; + private int lastTask = 0; + /** + * x坐标 + */ + private int x = 0; + private int lastX = 0; + /** + * y坐标 + */ + private int y = 0; + private int lastY = 0; + /** + * 行走列 + */ + private int walk_y = 0; + private int lastWalk_y = 0; + /** + * 下发命令 + */ + private int to_command = 0; + private int lastTo_command = 0; + /** + * 下发起始点 + */ + private int to_onset = 0; + private int lastTo_onset = 0; + /** + * 下发目标点 + */ + private int to_target = 0; + private int lastTo_target = 0; + /** + * 下发任务号 + */ + private int to_task = 0; + private int lastTo_task = 0; + /** + * 下发托盘类型 + */ + private int to_container_type = 0; + private int lastTo_container_type = 0; + /** + * 下发长度 + */ + private int to_length = 0; + private int lastTo_length = 0; + /** + * 下发宽度 + */ + private int to_width = 0; + private int lastTo_width = 0; + /** + * 下发高度 + */ + private int to_height = 0; + private int lastTo_height = 0; + /** + * 下发木箱条码 + */ + private String to_barcode = null; + private String lastTo_barcode = null; + + + /** + * 当前设备编号 + */ + private String currentDeviceCode = null; + /** + * 设备在线状态 + */ + private Boolean isOnline = false; + /** + * 消息 + */ + String message = null; + /** + * 设备报警标记 + */ + private boolean isError = false; + /** + * 请求标记 + */ + boolean requireSuccess = false; + /** + * 请求时间 + */ + private long requireTime = System.currentTimeMillis(); + /** + * 请求间隔时间 + */ + private long requireTimeOut = 1000L; + /** + * 未执行任务原因 + */ + private String unExecutedMessage = null; + /** + * 不需要记录日志的点位 + */ + private static final List No_SET_LOG_KEYS = Arrays.asList(ItemProtocol.HEARTBEAT.getKey()); + + + public void setLog(String key, Object newValue, Object oldValue) { + if (!No_SET_LOG_KEYS.contains(key)) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "设备线程读取信号:" + key + ",由" + oldValue + "->" + newValue)); + } + } + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + try { + this.currentDeviceCode = this.getDevice().getDevice_code(); + this.heartbeat = ItemProtocol.HEARTBEAT.getIntegerValue(this); + this.mode = ItemProtocol.MODE.getIntegerValue(this); + this.move = ItemProtocol.MOVE.getIntegerValue(this); + this.action = ItemProtocol.ACTION.getIntegerValue(this); + this.error = ItemProtocol.ERROR.getIntegerValue(this); + this.task = ItemProtocol.TASK.getIntegerValue(this); + this.x = ItemProtocol.X.getIntegerValue(this); + this.y = ItemProtocol.Y.getIntegerValue(this); + this.walk_y = ItemProtocol.WALK_Y.getIntegerValue(this); + this.to_command = ItemProtocol.TO_COMMAND.getIntegerValue(this); + this.to_onset = ItemProtocol.TO_ONSET.getIntegerValue(this); + this.to_target = ItemProtocol.TO_TARGET.getIntegerValue(this); + this.to_task = ItemProtocol.TO_TASK.getIntegerValue(this); + this.to_container_type = ItemProtocol.TO_CONTAINER_TYPE.getIntegerValue(this); + this.to_length = ItemProtocol.TO_LENGTH.getIntegerValue(this); + this.to_width = ItemProtocol.TO_WIDTH.getIntegerValue(this); + this.to_height = ItemProtocol.TO_HEIGHT.getIntegerValue(this); + this.to_barcode = ItemProtocol.TO_BARCODE.getStringValue(this); + + if (this.heartbeat != this.lastHeartbeat) { + this.setLog(ItemProtocol.HEARTBEAT.getKey(), this.heartbeat, this.lastHeartbeat); + } + if (this.mode != this.lastMode) { + this.requireSuccess = false; + this.setLog(ItemProtocol.MODE.getKey(), this.mode, this.lastMode); + } + if (this.move != this.lastMove) { + this.setLog(ItemProtocol.MOVE.getKey(), this.move, this.lastMove); + } + if (this.action != this.lastAction) { + this.setLog(ItemProtocol.ACTION.getKey(), this.action, this.lastAction); + } + if (this.error != this.lastError) { + this.setLog(ItemProtocol.ERROR.getKey(), this.error, this.lastError); + } + if (this.task != this.lastTask) { + this.setLog(ItemProtocol.TASK.getKey(), this.task, this.lastTask); + } + if (this.x != this.lastX) { + this.setLog(ItemProtocol.X.getKey(), this.x, this.lastX); + } + if (this.y != this.lastY) { + this.setLog(ItemProtocol.Y.getKey(), this.y, this.lastY); + } + if (this.walk_y != this.lastWalk_y) { + this.setLog(ItemProtocol.WALK_Y.getKey(), this.walk_y, this.lastWalk_y); + } + if (this.to_command != this.lastTo_command) { + this.setLog(ItemProtocol.TO_COMMAND.getKey(), this.to_command, this.lastTo_command); + } + if (this.to_onset != this.lastTo_onset) { + this.setLog(ItemProtocol.TO_ONSET.getKey(), this.to_onset, this.lastTo_onset); + } + if (this.to_target != this.lastTo_target) { + this.setLog(ItemProtocol.TO_TARGET.getKey(), this.to_target, this.lastTo_target); + } + if (this.to_task != this.lastTo_task) { + this.setLog(ItemProtocol.TO_TASK.getKey(), this.to_task, this.lastTo_task); + } + if (this.to_container_type != this.lastTo_container_type) { + this.setLog(ItemProtocol.TO_CONTAINER_TYPE.getKey(), this.to_container_type, this.lastTo_container_type); + } + if (this.to_length != this.lastTo_length) { + this.setLog(ItemProtocol.TO_LENGTH.getKey(), this.to_length, this.lastTo_length); + } + if (this.to_width != this.lastTo_width) { + this.setLog(ItemProtocol.TO_WIDTH.getKey(), this.to_width, this.lastTo_width); + } + if (this.to_height != this.lastTo_height) { + this.setLog(ItemProtocol.TO_HEIGHT.getKey(), this.to_height, this.lastTo_height); + } + if (!StrUtil.equals(this.to_barcode, this.lastTo_barcode)) { + this.setLog(ItemProtocol.TO_BARCODE.getKey(), this.to_barcode, this.lastTo_barcode); + } + + if (this.mode == 3 && this.task > 0) { + update_instruction_status(); + } + + if (this.mode == 0) { + this.isOnline = false; + this.message = LangProcess.msg("120000"); + } else if (this.error > 0) { + this.isError = true; + this.message = LangProcess.msg(ErrorEnum.getDesc(this.error)); + } else { + this.isOnline = true; + this.isError = false; + this.message = null; + if (this.mode == 2 && this.move == 0 && this.action == 0 && !this.requireSuccess) { + instruction_require(); + } + + } + this.lastHeartbeat = this.heartbeat; + this.lastMode = this.mode; + this.lastMove = this.move; + this.lastAction = this.action; + this.lastWalk_y = this.walk_y; + this.lastError = this.error; + this.lastX = this.x; + this.lastY = this.y; + this.lastTask = this.task; + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1005"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "当前设备执行逻辑报错, 错误详情: " + e.getMessage() + ", 错误堆栈信息: " + Arrays.toString(e.getStackTrace()))); + Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); + } + } + + private void instruction_require() { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + //先判断桁架上报指令号是否存在 + Instruction inst = instructionService.findByCodeFromCache(String.valueOf(this.task)); + if (ObjectUtil.isNotEmpty(inst) && StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex())) { + this.unExecutedMessage = LangProcess.msg("320001"); + return; + } else if (ObjectUtil.isNotEmpty(inst) && StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { + //下发桁架执行指令 + TaskDto taskDto = taskService.findByTaskCode(inst.getTask_code()); + if (ObjectUtil.isEmpty(taskDto)) { + this.unExecutedMessage = LangProcess.msg("320002"); + } + this.issuedPlc(inst, taskDto); + this.requireSuccess = true; + return; + } + List getDeviceCodeList = this.getExtraDeviceCodes("get_device_code"); + if (CollectionUtil.isEmpty(getDeviceCodeList)) { + this.unExecutedMessage = LangProcess.msg("320003"); + } + List putDeviceCodeList = this.getExtraDeviceCodes("put_device_code"); + if (CollectionUtil.isEmpty(putDeviceCodeList)) { + this.unExecutedMessage = LangProcess.msg("320004"); + } + //先去查询该桁架可以取放的点位信息的指令信息 + //并按照时间优先级、时间顺序进行排序 + //然后下发给桁架执行 + Instruction readyInst = findReadyInst(getDeviceCodeList, putDeviceCodeList); + if (ObjectUtil.isNotEmpty(readyInst)) { + TaskDto taskDto = taskService.findByTaskCode(readyInst.getTask_code()); + if (ObjectUtil.isEmpty(taskDto)) { + this.unExecutedMessage = LangProcess.msg("320002"); + } + issuedPlc(readyInst, taskDto); + this.requireSuccess = true; + } else { + //若没有就绪的指令,则查询就绪的任务 + //若任务不为空,则创建指令并下发桁架 + TaskDto readyTask = findReadyTask(getDeviceCodeList, putDeviceCodeList); + if (ObjectUtil.isEmpty(readyTask)) { + this.unExecutedMessage = LangProcess.msg("320005"); + return; + } + String nextDeviceCode = this.getNextDeviceCode(readyTask); + if (nextDeviceCode == null) { + this.unExecutedMessage = readyTask.getStart_device_code() + "->" + readyTask + LangProcess.msg("1009"); + return; + } + Device startDevice = deviceAppService.findDeviceByCode(readyTask.getStart_device_code()); + if (startDevice == null) { + this.unExecutedMessage = LangProcess.msg("1008") + ":" + readyTask.getStart_device_code(); + return; + } + Device nextDevice = deviceAppService.findDeviceByCode(nextDeviceCode); + if (nextDevice == null) { + this.unExecutedMessage = LangProcess.msg("1008") + ":" + nextDeviceCode; + return; + } + Instruction instDto = new Instruction(); + try { + packageInst(instDto, readyTask, nextDeviceCode); + instructionService.create(instDto); + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1006"); + return; + } + readyTask.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskService.update(readyTask); + this.issuedPlc(instDto, readyTask); + this.requireSuccess = true; + } + } + } + + private String getNextDeviceCode(TaskDto taskDto) { + List shortPathsList = routeLineService.getShortPathLines(taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code()); + if (ObjectUtils.isEmpty(shortPathsList)) { + return null; + } + RouteLineDto routeLineDto = shortPathsList.get(0); + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(taskDto.getStart_device_code())) { + index = m + 1; + break; + } + } + return pathlist.get(index); + } + + private void issuedPlc(Instruction inst, TaskDto taskDto) { + String interactionJson = taskDto.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); + Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); + int onset = getAddress(start_device); + int target = getAddress(next_device); + List keys = Arrays.asList(ItemProtocol.TO_COMMAND.getKey(), ItemProtocol.TO_ONSET.getKey(), ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey()); + List values = Arrays.asList(1, onset, target, Integer.parseInt(inst.getInstruction_code())); + if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { + String containerType = interactionJsonDTO.getContainerType(); + if (StrUtil.isNotBlank(containerType)) { + keys.add(ItemProtocol.TO_CONTAINER_TYPE.getKey()); + values.add(Integer.parseInt(containerType)); + } + String length = interactionJsonDTO.getLength(); + if (StrUtil.isNotBlank(length)) { + keys.add(ItemProtocol.TO_LENGTH.getKey()); + values.add(Integer.parseInt(length)); + } + String width = interactionJsonDTO.getWeight(); + if (StrUtil.isNotBlank(width)) { + keys.add(ItemProtocol.TO_WIDTH.getKey()); + values.add(Integer.parseInt(width)); + } + String height = interactionJsonDTO.getHeight(); + if (StrUtil.isNotBlank(height)) { + keys.add(ItemProtocol.TO_HEIGHT.getKey()); + values.add(Integer.parseInt(height)); + } + String barcode = interactionJsonDTO.getBarcode(); + if (StrUtil.isNotBlank(barcode)) { + keys.add(ItemProtocol.TO_BARCODE.getKey()); + values.add(barcode); + } + } + this.writing(keys, values); + } + + private boolean isTimeValid(long currentTimeMillis) { + return currentTimeMillis - this.requireTime >= this.requireTimeOut; + } + + private int getAddress(Device device) { + return Optional.ofNullable(device.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0); + } + + private void packageInst(Instruction instDto, TaskDto taskDto, String next_device_code) { + instDto.setInstruction_id(IdUtil.simpleUUID()); + instDto.setRoute_plan_code(taskDto.getRoute_plan_code()); + instDto.setRemark(taskDto.getRemark()); + instDto.setMaterial(taskDto.getMaterial()); + instDto.setQuantity(taskDto.getQuantity()); + instDto.setTask_id(taskDto.getTask_id()); + instDto.setTask_code(taskDto.getTask_code()); + instDto.setVehicle_code(taskDto.getVehicle_code()); + String now = DateUtil.now(); + instDto.setCreate_time(now); + instDto.setCreate_by(SecurityUtils.getCurrentNickName()); + instDto.setStart_device_code(taskDto.getStart_device_code()); + instDto.setNext_device_code(next_device_code); + instDto.setStart_point_code(taskDto.getStart_point_code()); + instDto.setNext_point_code(next_device_code); + instDto.setPriority(taskDto.getPriority()); + instDto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); + instDto.setExecute_device_code(this.currentDeviceCode); + instDto.setInstruction_type(taskDto.getTask_type()); + instDto.setVehicle_type(taskDto.getVehicle_type()); + } + + private Instruction findReadyInst(List getDeviceCodeList, List putDeviceCodeList) { + List instructions = instructionService.findAllInstFromCache(); + return Optional.ofNullable(instructions) + .orElse(new CopyOnWriteArrayList<>()) + .stream() + .filter(inst -> inst.getInstruction_status().equals(InstructionStatusEnum.READY.getIndex())) + .filter(inst -> getDeviceCodeList.contains(inst.getStart_device_code())) + .filter(inst -> putDeviceCodeList.contains(inst.getNext_device_code())) + .sorted(Comparator.comparing(Instruction::getPriority).reversed() + .thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) + .findFirst() + .orElse(null); + } + + private TaskDto findReadyTask(List getDeviceCodeList, List putDeviceCodeList) { + List tasks = taskService.findAllTaskFromCache(); + return Optional.ofNullable(tasks) + .orElse(new CopyOnWriteArrayList<>()) + .stream() + .filter(task -> task.getTask_status().equals(TaskStatusEnum.READY.getIndex())) + .filter(task -> getDeviceCodeList.contains(task.getStart_device_code())) + .filter(task -> putDeviceCodeList.contains(task.getNext_device_code())) + .sorted(Comparator.comparing(TaskDto::getPriority).reversed() + .thenComparing(task -> LocalDateTime.parse(task.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) + .findFirst() + .orElse(null); + } + + /** + * 更新指令状态 + */ + public void update_instruction_status() throws Exception { + Instruction inst = instructionService.findByCodeFromCache(String.valueOf(this.task)); + if (ObjectUtil.isNotEmpty(inst)) { + if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { + inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.update(inst); + } else if (this.action == 4 && this.move == 0) { + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.finish(inst); + } + } + } + + /** + * 下发单个电气信号 + * + * @param key + * @param value + */ + public void writing(String key, Object value) { + Map itemMap = new HashMap(); + itemMap.put(getId() + key, value); + try { + this.checkcontrol(itemMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 下发多个电气信号 + * + * @param keys + * @param values + */ + public void writing(List keys, List values) { + if (keys.size() != values.size()) { + this.message = LangProcess.msg("1007"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "参数长度不一致,不允许下发")); + throw new BadRequestException("参数长度不一致,不允许下发"); + } + Map controlMap = new LinkedHashMap<>(); + for (int i = 0; i < keys.size(); i++) { + controlMap.put(getId() + keys.get(i), values.get(i)); + } + try { + this.checkcontrol(controlMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 抽取统一下发电气信号前缀 + * + * @return + */ + public String getId() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", ModeEnum.getDescByNum(this.mode)); + jo.put("move", MoveEnum.getDescByNum(this.mode)); + jo.put("hasGoods", this.move == 1 ? true : false); + jo.put("error", ErrorEnum.getDesc(this.getError())); + jo.put("isError", this.isError); + jo.put("action", ActionEnum.getDescByNum(this.action)); + jo.put("task", this.task); + jo.put("isOnline", this.isOnline); + jo.put("message", this.message); + jo.put("unExecutedMessage", this.unExecutedMessage); + jo.put("is_click", true); + jo.put("requireSuccess", this.requireSuccess); + jo.put("driver_type", "siemens_conveyor"); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + Boolean requireSuccess = data.getBoolean("requireSuccess"); + if (requireSuccess != null) { + this.requireSuccess = requireSuccess; + } + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/InteractionJsonDTO.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/InteractionJsonDTO.java new file mode 100644 index 0000000..cf496af --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/InteractionJsonDTO.java @@ -0,0 +1,28 @@ +package org.nl.acs.device_driver.lk_manipulator.box_manipulator; + +import lombok.Data; + +@Data +public class InteractionJsonDTO { + /** + * 托盘类型 + */ + private String containerType; + /** + *木箱长度 + */ + private String length; + /** + *木箱宽度 + */ + private String weight; + /** + *木箱高度 + */ + private String height; + /** + *木箱条码 + */ + private String barcode; + +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/ItemProtocol.java new file mode 100644 index 0000000..30c22e3 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/box_manipulator/ItemProtocol.java @@ -0,0 +1,99 @@ +package org.nl.acs.device_driver.lk_manipulator.box_manipulator; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + + +public enum ItemProtocol { + HEARTBEAT("heartbeat", "心跳", "DB600.B0"), + MODE("mode", "工作模式", "DB600.B2"), + MOVE("move", "光电信号", "DB600.B3"), + ACTION("action", "取放信号", "DB600.B4"), + ERROR("error", "报警信号", "DB600.B5"), + TASK("task", "任务号", "DB600.D6"), + X("x", "x坐标", "DB600.B7"), + Y("y", "y坐标", "DB600.B8"), + WALK_Y("walk_y", "行走列", "DB600.B9"), + TO_COMMAND("to_command", "下发命令", "DB601.W2"), + TO_ONSET("to_onset", "下发起始站", "DB601.W4"), + TO_TARGET("to_target", "下发目标站", "DB601.W6"), + TO_TASK("to_task", "下发任务号", "DB601.D8"), + TO_CONTAINER_TYPE("to_container_type", "写法托盘类型", "DB601.W10"), + TO_LENGTH("to_length", "下发木箱长度", "DB601.W12"), + TO_WIDTH("to_width", "下发木箱宽度", "DB601.W14"), + TO_HEIGHT("to_height", "下发木箱高度", "DB601.W16"), + TO_BARCODE("to_barcode", "下发木箱条码", "DB601.String.50"); + + private final String key; + private final String description; + private final String address; + + ItemProtocol(String key, String description, String address) { + this.key = key; + this.description = description; + this.address = address; + } + + public String getKey() { + return this.key; + } + + public String getDescription() { + return description; + } + + public String getAddress() { + return address; + } + + // 获取 Integer 类型的值 + public Integer getIntegerValue(BoxManipulatorDeviceDriver driver) { + Integer value = driver.getIntegerValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0; + } + + // 获取 Float 类型的值 + public Float getFloatValue(BoxManipulatorDeviceDriver driver) { + Float value = driver.getFloatValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0.00f; + } + + public String getStringValue(BoxManipulatorDeviceDriver driver) { + return driver.getStringValue(this.getKey()); + } + + public static List getReadableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (!prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } + + public static List getWriteableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } +} + diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/Action2Enum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/Action2Enum.java new file mode 100644 index 0000000..6e4ecd6 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/Action2Enum.java @@ -0,0 +1,35 @@ +package org.nl.acs.device_driver.lk_manipulator.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Description TODO + * @Author Gengby + * @Date 2024/5/17 + */ +@Getter +@AllArgsConstructor +public enum Action2Enum { + + ACTION_0(0, "420000"), + ACTION_1(1, "420005"), + ACTION_2(2, "420006"), + ACTION_3(3, "420007"), + ACTION_4(4, "420008"), + ACTION_5(5, "420009"), + ACTION_6(6, "420010"), + ACTION_7(7, "420011"); + + private final Integer num; + private final String desc; + + public static String getDescByNum(Integer num) { + for (Action2Enum mode : Action2Enum.values()) { + if (mode.getNum().equals(num)) { + return mode.getDesc(); + } + } + return "1010"; + } +} \ No newline at end of file diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ActionEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ActionEnum.java new file mode 100644 index 0000000..92a93d2 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ActionEnum.java @@ -0,0 +1,32 @@ +package org.nl.acs.device_driver.lk_manipulator.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Description TODO + * @Author Gengby + * @Date 2024/5/17 + */ +@Getter +@AllArgsConstructor +public enum ActionEnum { + + ACTION_0(0, "420000"), + ACTION_1(1, "420001"), + ACTION_2(2, "420002"), + ACTION_3(3, "420003"), + ACTION_4(4, "420004"); + + private final Integer num; + private final String desc; + + public static String getDescByNum(Integer num) { + for (ActionEnum mode : ActionEnum.values()) { + if (mode.getNum().equals(num)) { + return mode.getDesc(); + } + } + return "1010"; + } +} \ No newline at end of file diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ContainerTypeEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ContainerTypeEnum.java new file mode 100644 index 0000000..5d091da --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ContainerTypeEnum.java @@ -0,0 +1,29 @@ +package org.nl.acs.device_driver.lk_manipulator.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Description TODO + * @Author Gengby + * @Date 2024/5/17 + */ +@Getter +@AllArgsConstructor +public enum ContainerTypeEnum { + + TYPE_1(1, "1015"), + TYPE_2(2, "1016"); + + private final Integer num; + private final String desc; + + public static String getDescByNum(Integer num) { + for (ContainerTypeEnum mode : ContainerTypeEnum.values()) { + if (mode.getNum().equals(num)) { + return mode.getDesc(); + } + } + return "100006"; + } +} \ No newline at end of file diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ErrorEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ErrorEnum.java new file mode 100644 index 0000000..ced0ee4 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ErrorEnum.java @@ -0,0 +1,67 @@ +package org.nl.acs.device_driver.lk_manipulator.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Description TODO + * @Author Gengby + * @Date 2024/6/26 + */ +@Getter +@AllArgsConstructor +public enum ErrorEnum { + NO(0, "220000"), + ERROR_1(1, "220001"), + ERROR_2(2, "220002"), + ERROR_3(3, "220003"), + ERROR_4(4, "220004"), + ERROR_5(5, "220005"), + ERROR_6(6, "220006"), + ERROR_7(7, "220007"), + ERROR_8(8, "220008"), + ERROR_9(9, "220009"), + ERROR_10(10, "220010"), + ERROR_11(11, "220011"), + ERROR_12(12, "220012"), + ERROR_13(13, "220013"), + ERROR_14(14, "220014"), + ERROR_15(15, "220015"), + ERROR_16(16, "220016"), + ERROR_17(17, "220017"), + ERROR_18(18, "220018"), + ERROR_19(19, "220019"), + ERROR_20(20, "220020"), + ERROR_21(21, "220021"), + ERROR_22(22, "220022"), + ERROR_23(23, "220023"), + ERROR_24(24, "220024"), + ERROR_25(25, "220025"), + ERROR_26(26, "220026"), + ERROR_27(27, "220027"), + ERROR_28(28, "220028"), + ERROR_29(29, "220029"), + ERROR_30(30, "220030"), + ERROR_31(31, "220031"), + ERROR_32(32, "220032"), + ERROR_33(33, "220033"), + ERROR_34(34, "220034"), + ERROR_35(35, "220035"), + ERROR_36(36, "220036"), + ERROR_37(37, "220037"), + ERROR_38(38, "220038"), + ERROR_40(40, "220040"), + ERROR_41(41, "220041"); + + private int code; + private String desc; + + public static String getDesc(Integer code) { + for (ErrorEnum e : ErrorEnum.values()) { + if (e.getCode() == code) { + return e.getDesc(); + } + } + return "未知报警信息"; + } +} \ No newline at end of file diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ModeEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ModeEnum.java new file mode 100644 index 0000000..2ad4c9d --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/ModeEnum.java @@ -0,0 +1,31 @@ +package org.nl.acs.device_driver.lk_manipulator.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Description TODO + * @Author Gengby + * @Date 2024/5/17 + */ +@Getter +@AllArgsConstructor +public enum ModeEnum { + + MODE_0(0, "120000"), + MODE_1(1, "120001"), + MODE_2(2, "120002"), + MODE_3(3, "120003"); + + private final Integer num; + private final String desc; + + public static String getDescByNum(Integer num) { + for (ModeEnum mode : ModeEnum.values()) { + if (mode.getNum().equals(num)) { + return mode.getDesc(); + } + } + return "110011"; + } +} \ No newline at end of file diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/MoveEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/MoveEnum.java new file mode 100644 index 0000000..81afb8f --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/enums/MoveEnum.java @@ -0,0 +1,29 @@ +package org.nl.acs.device_driver.lk_manipulator.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Description TODO + * @Author Gengby + * @Date 2024/5/17 + */ +@Getter +@AllArgsConstructor +public enum MoveEnum { + + MOVE_0(0, "1012"), + MOVE_1(1, "1011"); + + private final Integer num; + private final String desc; + + public static String getDescByNum(Integer num) { + for (MoveEnum mode : MoveEnum.values()) { + if (mode.getNum().equals(num)) { + return mode.getDesc(); + } + } + return "100006"; + } +} \ No newline at end of file diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/open_close_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/open_close_manipulator/ItemProtocol.java new file mode 100644 index 0000000..49a02d3 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/open_close_manipulator/ItemProtocol.java @@ -0,0 +1,90 @@ +package org.nl.acs.device_driver.lk_manipulator.open_close_manipulator; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + + +public enum ItemProtocol { + HEARTBEAT("heartbeat", "心跳", "DB600.B0"), + MODE("mode", "工作模式", "DB600.B2"), + MOVE("move", "光电信号", "DB600.B3"), + ACTION("action", "取放信号", "DB600.B4"), + WALK_Y("walk_y", "行走列", "DB600.B5"), + ERROR("error", "报警信号", "DB600.B6"), + X("x", "x坐标", "DB600.B7"), + Y("y", "y坐标", "DB600.B8"), + TASK("task", "任务号", "DB600.D10"); + + private final String key; + private final String description; + private final String address; + + ItemProtocol(String key, String description, String address) { + this.key = key; + this.description = description; + this.address = address; + } + + public String getKey() { + return this.key; + } + + public String getDescription() { + return description; + } + + public String getAddress() { + return address; + } + + // 获取 Integer 类型的值 + public Integer getIntegerValue(OpenCloseManipulatorDeviceDriver driver) { + Integer value = driver.getIntegerValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0; + } + + // 获取 Float 类型的值 + public Float getFloatValue(OpenCloseManipulatorDeviceDriver driver) { + Float value = driver.getFloatValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0.00f; + } + + public String getStringValue(OpenCloseManipulatorDeviceDriver driver) { + return driver.getStringValue(this.getKey()); + } + + public static List getReadableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (!prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } + + public static List getWriteableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } +} + diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/open_close_manipulator/OpenCloseManipulatorDefination.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/open_close_manipulator/OpenCloseManipulatorDefination.java new file mode 100644 index 0000000..bce5361 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/open_close_manipulator/OpenCloseManipulatorDefination.java @@ -0,0 +1,65 @@ +package org.nl.acs.device_driver.lk_manipulator.open_close_manipulator; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.enums.DeviceType; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +/** + * 一楼木箱机械手、子卷机械手对接位 + * + * + */ +@Service +public class OpenCloseManipulatorDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "open_close_manipulator"; + } + + @Override + public String getDriverName() { + return "开合盖机械手"; + } + + @Override + public String getDriverDescription() { + return "开合盖机械手"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new OpenCloseManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return OpenCloseManipulatorDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.robot); + return types; + } + + @Override + public List getReadableItemDtos() { + return ItemProtocol.getReadableItemDtos(); + } + + + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/open_close_manipulator/OpenCloseManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/open_close_manipulator/OpenCloseManipulatorDeviceDriver.java new file mode 100644 index 0000000..f60812b --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/open_close_manipulator/OpenCloseManipulatorDeviceDriver.java @@ -0,0 +1,359 @@ +package org.nl.acs.device_driver.lk_manipulator.open_close_manipulator; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import com.google.common.util.concurrent.Uninterruptibles; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.lk_manipulator.enums.Action2Enum; +import org.nl.acs.device_driver.lk_manipulator.enums.ErrorEnum; +import org.nl.acs.device_driver.lk_manipulator.enums.ModeEnum; +import org.nl.acs.device_driver.lk_manipulator.enums.MoveEnum; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.instruction.domain.Instruction; +import org.nl.acs.instruction.enums.InstructionStatusEnum; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.monitor.DeviceStageMonitor; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; +import org.nl.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.SpringContextHolder; +import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; +import org.nl.system.service.param.ISysParamService; + +import java.util.*; +import java.util.concurrent.TimeUnit; + +/** + * 开合盖机械手 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class OpenCloseManipulatorDeviceDriver extends AbstractOpcDeviceDriver + implements DeviceDriver, + ExecutableDeviceDriver, + RouteableDeviceDriver, + DeviceStageMonitor { + + private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + private final TaskService taskService = SpringContextHolder.getBean(TaskService.class); + private final DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); + private final RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); + private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class); + private final ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); + + /** + * 心跳 + */ + private int heartbeat = 0; + private int lastHeartbeat = 0; + /** + * 工作模式 + */ + private int mode = 0; + private int lastMode = 0; + /** + * 光电信号 + */ + private int move = 0; + private int lastMove = 0; + /** + * 动作信号 + */ + private int action = 0; + private int lastAction = 0; + /** + * 行走列 + */ + private int walk_y = 0; + private int lastWalk_y = 0; + /** + * 报警信号 + */ + private int error = 0; + private int lastError = 0; + /** + * x坐标 + */ + private int x = 0; + private int lastX = 0; + /** + * y坐标 + */ + private int y = 0; + private int lastY = 0; + /** + * 任务号 + */ + private int task = 0; + private int lastTask = 0; + /** + * 当前设备编号 + */ + private String currentDeviceCode = null; + /** + * 设备在线状态 + */ + private Boolean isOnline = false; + /** + * 消息 + */ + String message = null; + /** + * 设备报警标记 + */ + private boolean isError = false; + /** + * 请求标记 + */ + boolean requireSuccess = false; + /** + * 请求时间 + */ + private long requireTime = System.currentTimeMillis(); + /** + * 请求间隔时间 + */ + private long requireTimeOut = 5000L; + /** + * 未执行任务原因 + */ + private String unExecutedMessage = null; + /** + * 不需要记录日志的点位 + */ + private static final List No_SET_LOG_KEYS = Arrays.asList(ItemProtocol.HEARTBEAT.getKey()); + + + public void setLog(String key, Object newValue, Object oldValue) { + if (!No_SET_LOG_KEYS.contains(key)) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "设备线程读取信号:" + key + ",由" + oldValue + "->" + newValue)); + } + } + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + try { + this.currentDeviceCode = this.getDevice().getDevice_code(); + this.heartbeat = ItemProtocol.HEARTBEAT.getIntegerValue(this); + this.mode = ItemProtocol.MODE.getIntegerValue(this); + this.move = ItemProtocol.MOVE.getIntegerValue(this); + this.action = ItemProtocol.ACTION.getIntegerValue(this); + this.walk_y = ItemProtocol.WALK_Y.getIntegerValue(this); + this.error = ItemProtocol.ERROR.getIntegerValue(this); + this.x = ItemProtocol.X.getIntegerValue(this); + this.y = ItemProtocol.Y.getIntegerValue(this); + this.task = ItemProtocol.TASK.getIntegerValue(this); + + if (this.heartbeat != this.lastHeartbeat) { + this.setLog(ItemProtocol.HEARTBEAT.getKey(), this.heartbeat, this.lastHeartbeat); + } + if (this.mode != this.lastMode) { + this.requireSuccess = false; + this.setLog(ItemProtocol.MODE.getKey(), this.mode, this.lastMode); + } + if (this.move != this.lastMove) { + this.setLog(ItemProtocol.MOVE.getKey(), this.move, this.lastMove); + } + if (this.action != this.lastAction) { + this.setLog(ItemProtocol.ACTION.getKey(), this.action, this.lastAction); + } + if (this.walk_y != this.lastWalk_y) { + this.setLog(ItemProtocol.WALK_Y.getKey(), this.walk_y, this.lastWalk_y); + } + if (this.error != this.lastError) { + this.setLog(ItemProtocol.ERROR.getKey(), this.error, this.lastError); + } + if (this.x != this.lastX) { + this.setLog(ItemProtocol.X.getKey(), this.x, this.lastX); + } + if (this.y != this.lastY) { + this.setLog(ItemProtocol.Y.getKey(), this.y, this.lastY); + } + if (this.task != this.lastTask) { + this.setLog(ItemProtocol.TASK.getKey(), this.task, this.lastTask); + } + + if (this.mode == 3 && this.task > 0) { + update_instruction_status(); + } + + if (this.mode == 0) { + this.isOnline = false; + this.message = LangProcess.msg("120000"); + } else if (this.error > 0) { + this.isError = true; + this.message = LangProcess.msg(ErrorEnum.getDesc(this.error)); + } else { + this.isOnline = true; + this.isError = false; + this.message = null; + } + this.lastHeartbeat = this.heartbeat; + this.lastMode = this.mode; + this.lastMove = this.move; + this.lastAction = this.action; + this.lastWalk_y = this.walk_y; + this.lastError = this.error; + this.lastX = this.x; + this.lastY = this.y; + this.lastTask = this.task; + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1005"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "当前设备执行逻辑报错, 错误详情: " + e.getMessage() + ", 错误堆栈信息: " + Arrays.toString(e.getStackTrace()))); + Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); + } + } + + private void clearWrite() { + + } + + private boolean isTimeValid(long currentTimeMillis) { + return currentTimeMillis - this.requireTime >= this.requireTimeOut; + } + + private int getTargetAddress(Device nextDevice) { + return Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0); + } + + private void packageInst(Instruction instDto, TaskDto taskDto, String next_device_code) { + instDto.setInstruction_id(IdUtil.simpleUUID()); + instDto.setRoute_plan_code(taskDto.getRoute_plan_code()); + instDto.setRemark(taskDto.getRemark()); + instDto.setMaterial(taskDto.getMaterial()); + instDto.setQuantity(taskDto.getQuantity()); + instDto.setTask_id(taskDto.getTask_id()); + instDto.setTask_code(taskDto.getTask_code()); + instDto.setVehicle_code(taskDto.getVehicle_code()); + String now = DateUtil.now(); + instDto.setCreate_time(now); + instDto.setCreate_by(SecurityUtils.getCurrentNickName()); + instDto.setStart_device_code(taskDto.getStart_device_code()); + instDto.setNext_device_code(next_device_code); + instDto.setStart_point_code(taskDto.getStart_point_code()); + instDto.setNext_point_code(next_device_code); + instDto.setPriority(taskDto.getPriority()); + instDto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); + instDto.setExecute_device_code(this.currentDeviceCode); + instDto.setInstruction_type(taskDto.getTask_type()); + instDto.setVehicle_type(taskDto.getVehicle_type()); + } + + /** + * 更新指令状态 + */ + public void update_instruction_status() throws Exception { + Instruction inst = instructionService.findByCodeFromCache(String.valueOf(this.task)); + if (ObjectUtil.isNotEmpty(inst)) { + if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { + inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.update(inst); + } else if (this.action == 4 && this.move == 0) { + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.finish(inst); + } + } + } + + /** + * 下发单个电气信号 + * + * @param key + * @param value + */ + public void writing(String key, Object value) { + Map itemMap = new HashMap(); + itemMap.put(getId() + key, value); + try { + this.checkcontrol(itemMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 下发多个电气信号 + * + * @param keys + * @param values + */ + public void writing(List keys, List values) { + if (keys.size() != values.size()) { + this.message = LangProcess.msg("1007"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "参数长度不一致,不允许下发")); + throw new BadRequestException("参数长度不一致,不允许下发"); + } + Map controlMap = new LinkedHashMap<>(); + for (int i = 0; i < keys.size(); i++) { + controlMap.put(getId() + keys.get(i), values.get(i)); + } + try { + this.checkcontrol(controlMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 抽取统一下发电气信号前缀 + * + * @return + */ + public String getId() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", LangProcess.msg(ModeEnum.getDescByNum(this.mode))); + jo.put("move", LangProcess.msg(MoveEnum.getDescByNum(this.move))); + jo.put("hasGoods", this.move == 1 ? true : false); + jo.put("error", LangProcess.msg(ErrorEnum.getDesc(this.getError()))); + jo.put("isError", this.isError); + jo.put("action", LangProcess.msg(Action2Enum.getDescByNum(this.action))); + jo.put("task", this.task); + jo.put("isOnline", this.isOnline); + jo.put("message", this.message); + jo.put("unExecutedMessage", this.unExecutedMessage); + jo.put("is_click", true); + jo.put("requireSuccess", this.requireSuccess); + jo.put("driver_type", "siemens_conveyor"); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + Boolean requireSuccess = data.getBoolean("requireSuccess"); + if (requireSuccess != null) { + this.requireSuccess = requireSuccess; + } + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/InteractionJsonDTO.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/trapped_manipulator/InteractionJsonDTO.java similarity index 89% rename from acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/InteractionJsonDTO.java rename to acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/trapped_manipulator/InteractionJsonDTO.java index 9150df9..88b6b7f 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/InteractionJsonDTO.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/trapped_manipulator/InteractionJsonDTO.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.one_manipulator.trapped_manipulator; +package org.nl.acs.device_driver.lk_manipulator.trapped_manipulator; import lombok.Data; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/trapped_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/trapped_manipulator/ItemProtocol.java new file mode 100644 index 0000000..a59b983 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/trapped_manipulator/ItemProtocol.java @@ -0,0 +1,98 @@ +package org.nl.acs.device_driver.lk_manipulator.trapped_manipulator; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + +public enum ItemProtocol { + + HEARTBEAT("heartbeat", "心跳", "DB600.B0"), + MODE("mode", "工作模式", "DB600.B2"), + MOVE("move", "光电信号", "DB600.B3"), + ACTION("action", "取放信号", "DB600.B4"), + ERROR("error", "报警信号", "DB600.B5"), + TASK("task", "任务号", "DB600.D6"), + TO_COMMAND("to_command", "下发命令", "DB601.W2"), + TO_ONSET("to_onset", "下发起始站", "DB601.W4"), + TO_TARGET("to_target", "下发目标站", "DB601.W6"), + TO_TASK("to_task", "下发任务号", "DB601.D8"), + TO_LENGTH("to_length", "下发木箱长度", "DB601.W10"), + TO_WIDTH("to_width", "下发木箱宽度", "DB601.W12"), + TO_HEIGHT("to_height", "下发木箱高度", "DB601.W14"), + TO_TEMPLATE("to_template", "下发堆叠模板", "DB601.W16"), + TO_IS_BINDING("to_is_binding", "下发是否捆扎", "DB601.W18"), + TO_BINDING_TIMES("to_binding_times", "下发捆扎次数", "DB601.W20"), + TO_IS_LEAVE("to_is_leave", "下发是否离开", "DB601.W22"), + TO_MATERIAL("to_material", "下发木箱条码", "DB601.String.50"); + + private final String key; + private final String description; + private final String address; + + ItemProtocol(String key, String description, String address) { + this.key = key; + this.description = description; + this.address = address; + } + + public String getKey() { + return this.key; + } + + public String getDescription() { + return description; + } + + public String getAddress() { + return address; + } + + // 获取 Integer 类型的值 + public Integer getIntegerValue(TrappedManipulatorManipulatorDeviceDriver driver) { + Integer value = driver.getIntegerValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0; + } + + // 获取 Float 类型的值 + public Float getFloatValue(TrappedManipulatorManipulatorDeviceDriver driver) { + Float value = driver.getFloatValue(this.getKey()); + if (value == null) { + driver.setIsOnline(false); + } else { + driver.setIsOnline(true); + return value; + } + return 0.00f; + } + + public String getStringValue(TrappedManipulatorManipulatorDeviceDriver driver) { + return driver.getStringValue(this.getKey()); + } + + public static List getReadableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (!prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } + + public static List getWriteableItemDtos() { + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } + return list; + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorDefination.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/trapped_manipulator/TrappedManipulatorDefination.java similarity index 90% rename from acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorDefination.java rename to acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/trapped_manipulator/TrappedManipulatorDefination.java index 9bfeb08..e77e353 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorDefination.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/trapped_manipulator/TrappedManipulatorDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.one_manipulator.trapped_manipulator; +package org.nl.acs.device_driver.lk_manipulator.trapped_manipulator; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; @@ -19,12 +19,12 @@ public class TrappedManipulatorDefination implements OpcDeviceDriverDefination { @Override public String getDriverName() { - return "堆叠行架"; + return "一楼出库区堆叠桁架"; } @Override public String getDriverDescription() { - return "堆叠行架"; + return "一楼出库区堆叠桁"; } @Override diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java new file mode 100644 index 0000000..6e03572 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/lk_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java @@ -0,0 +1,644 @@ +package org.nl.acs.device_driver.lk_manipulator.trapped_manipulator; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.common.util.concurrent.Uninterruptibles; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.lk_manipulator.enums.ActionEnum; +import org.nl.acs.device_driver.lk_manipulator.enums.ErrorEnum; +import org.nl.acs.device_driver.lk_manipulator.enums.ModeEnum; +import org.nl.acs.device_driver.lk_manipulator.enums.MoveEnum; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; +import org.nl.acs.instruction.domain.Instruction; +import org.nl.acs.instruction.enums.InstructionStatusEnum; +import org.nl.acs.instruction.service.InstructionService; +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.route.service.dto.RouteLineDto; +import org.nl.acs.route.service.impl.RouteLineServiceImpl; +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; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.SpringContextHolder; +import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.TimeUnit; + +/** + * 捆扎智能行架 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDeviceDriver + implements DeviceDriver, + ExecutableDeviceDriver, + RouteableDeviceDriver, + DeviceStageMonitor { + + private final TaskService taskService = SpringContextHolder.getBean(TaskService.class); + private final InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + private final DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + private final RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); + private final LuceneExecuteLogService logService = SpringContextHolder.getBean(LuceneExecuteLogService.class); + private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); + + /** + * 心跳 + */ + private int heartbeat = 0; + private int lastHeartbeat = 0; + /** + * 工作模式 + */ + private int mode = 0; + private int lastMode = 0; + /** + * 光电信号 + */ + private int move = 0; + private int lastMove = 0; + /** + * 动作信号 + */ + private int action = 0; + private int lastAction = 0; + /** + * 报警信号 + */ + private int error = 0; + private int lastError = 0; + /** + * 任务号 + */ + private int task = 0; + private int lastTask = 0; + /** + * 下发命令 + */ + private int to_command = 0; + private int lastTo_command = 0; + /** + * 下发起始点 + */ + private int to_onset = 0; + private int lastTo_onset = 0; + /** + * 下发目标点 + */ + private int to_target = 0; + private int lastTo_target = 0; + /** + * 下发任务号 + */ + private int to_task = 0; + private int lastTo_task = 0; + /** + * 下发长度 + */ + private int to_length = 0; + private int lastTo_length = 0; + /** + * 下发宽度 + */ + private int to_width = 0; + private int lastTo_width = 0; + /** + * 下发高度 + */ + private int to_height = 0; + private int lastTo_height = 0; + /** + * 下发堆叠模板 + */ + private int to_template = 0; + private int lastTo_template = 0; + /** + * 下发是否捆扎 + */ + private int to_is_binding = 0; + private int lastTo_is_binding = 0; + /** + * 下发捆扎次数 + */ + private int to_binding_times = 0; + private int lastTo_binding_times = 0; + /** + * 下发是否离开 + */ + private int to_is_leave = 0; + private int lastTo_is_leave = 0; + /** + * 下发木箱条码 + */ + private String to_material = null; + private String lastTo_material = null; + + /** + * 当前设备编号 + */ + private String currentDeviceCode = null; + /** + * 设备在线状态 + */ + private Boolean isOnline = false; + /** + * 消息 + */ + String message = null; + /** + * 设备报警标记 + */ + private boolean isError = false; + /** + * 请求标记 + */ + boolean requireSuccess = false; + /** + * 请求时间 + */ + private long requireTime = System.currentTimeMillis(); + /** + * 请求间隔时间 + */ + private long requireTimeOut = 1000L; + /** + * 未执行任务原因 + */ + private String unExecutedMessage = null; + /** + * 不需要记录日志的点位 + */ + private static final List No_SET_LOG_KEYS = Arrays.asList(ItemProtocol.HEARTBEAT.getKey()); + + + public void setLog(String key, Object newValue, Object oldValue) { + if (!No_SET_LOG_KEYS.contains(key)) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "设备线程读取信号:" + key + ",由" + oldValue + "->" + newValue)); + } + } + + @Override + public Device getDevice() { + return this.device; + } + + @Override + public void execute() { + try { + this.currentDeviceCode = this.getDevice().getDevice_code(); + this.heartbeat = ItemProtocol.HEARTBEAT.getIntegerValue(this); + this.mode = ItemProtocol.MODE.getIntegerValue(this); + this.move = ItemProtocol.MOVE.getIntegerValue(this); + this.action = ItemProtocol.ACTION.getIntegerValue(this); + this.error = ItemProtocol.ERROR.getIntegerValue(this); + this.task = ItemProtocol.TASK.getIntegerValue(this); + this.to_command = ItemProtocol.TO_COMMAND.getIntegerValue(this); + this.to_onset = ItemProtocol.TO_ONSET.getIntegerValue(this); + this.to_target = ItemProtocol.TO_TARGET.getIntegerValue(this); + this.to_task = ItemProtocol.TO_TASK.getIntegerValue(this); + this.to_length = ItemProtocol.TO_LENGTH.getIntegerValue(this); + this.to_width = ItemProtocol.TO_WIDTH.getIntegerValue(this); + this.to_height = ItemProtocol.TO_HEIGHT.getIntegerValue(this); + this.to_template = ItemProtocol.TO_TEMPLATE.getIntegerValue(this); + this.to_is_binding = ItemProtocol.TO_IS_BINDING.getIntegerValue(this); + this.to_binding_times = ItemProtocol.TO_BINDING_TIMES.getIntegerValue(this); + this.to_is_leave = ItemProtocol.TO_IS_LEAVE.getIntegerValue(this); + this.to_material = ItemProtocol.TO_MATERIAL.getStringValue(this); + + if (this.heartbeat != this.lastHeartbeat) { + this.setLog(ItemProtocol.HEARTBEAT.getKey(), this.heartbeat, this.lastHeartbeat); + } + if (this.mode != this.lastMode) { + this.requireSuccess = false; + this.setLog(ItemProtocol.MODE.getKey(), this.mode, this.lastMode); + } + if (this.move != this.lastMove) { + this.setLog(ItemProtocol.MOVE.getKey(), this.move, this.lastMove); + } + if (this.action != this.lastAction) { + this.setLog(ItemProtocol.ACTION.getKey(), this.action, this.lastAction); + } + if (this.error != this.lastError) { + this.setLog(ItemProtocol.ERROR.getKey(), this.error, this.lastError); + } + if (this.task != this.lastTask) { + this.setLog(ItemProtocol.TASK.getKey(), this.task, this.lastTask); + } + if (this.to_command != this.lastTo_command) { + this.setLog(ItemProtocol.TO_COMMAND.getKey(), this.to_command, this.lastTo_command); + } + if (this.to_onset != this.lastTo_onset) { + this.setLog(ItemProtocol.TO_ONSET.getKey(), this.to_onset, this.lastTo_onset); + } + if (this.to_target != this.lastTo_target) { + this.setLog(ItemProtocol.TO_TARGET.getKey(), this.to_target, this.lastTo_target); + } + if (this.to_task != this.lastTo_task) { + this.setLog(ItemProtocol.TO_TASK.getKey(), this.to_task, this.lastTo_task); + } + if (this.to_length != this.lastTo_length) { + this.setLog(ItemProtocol.TO_LENGTH.getKey(), this.to_length, this.lastTo_length); + } + if (this.to_width != this.lastTo_width) { + this.setLog(ItemProtocol.TO_WIDTH.getKey(), this.to_width, this.lastTo_width); + } + if (this.to_height != this.lastTo_height) { + this.setLog(ItemProtocol.TO_HEIGHT.getKey(), this.to_height, this.lastTo_height); + } + if (this.to_template != this.lastTo_template) { + this.setLog(ItemProtocol.TO_TEMPLATE.getKey(), this.to_template, this.lastTo_template); + } + if (this.to_is_binding != this.lastTo_is_binding) { + this.setLog(ItemProtocol.TO_IS_BINDING.getKey(), this.to_is_binding, this.lastTo_is_binding); + } + if (this.to_is_leave != this.lastTo_is_leave) { + this.setLog(ItemProtocol.TO_IS_LEAVE.getKey(), this.to_is_leave, this.lastTo_is_leave); + } + if (!StrUtil.equals(this.to_material, this.lastTo_material)) { + this.setLog(ItemProtocol.TO_MATERIAL.getKey(), this.to_material, this.lastTo_material); + } + + // 更新指令状态 + if (this.mode == 3 && this.task > 0) { + updateInstructionStatus(); + } + + if (this.mode == 0) { + this.isOnline = false; + this.message = LangProcess.msg("120000"); + //有报警 + } else if (this.error != 0) { + this.isError = true; + this.message = LangProcess.msg(ErrorEnum.getDesc(this.error)); + //无报警 + } else { + this.isOnline = true; + this.isError = false; + this.message = null; + //行架机械手申请任务 + if (this.mode == 2 && this.move == 0 && this.action == 0 && !this.requireSuccess) { + applyTask(); + } + + } + + this.lastHeartbeat = this.heartbeat; + this.lastMode = this.mode; + this.lastMove = this.move; + this.lastAction = this.action; + this.lastError = this.error; + this.lastTask = this.task; + this.lastTo_command = this.to_command; + this.lastTo_onset = this.to_onset; + this.lastTo_target = this.to_target; + this.lastTo_task = this.to_task; + this.lastTo_length = this.to_length; + this.lastTo_width = this.to_width; + this.lastTo_height = this.to_height; + this.lastTo_template = this.to_template; + this.lastTo_is_binding = this.to_is_binding; + this.lastTo_binding_times = this.to_binding_times; + this.lastTo_is_leave = this.to_is_leave; + this.lastTo_material = this.to_material; + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1005"); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "当前设备执行逻辑报错, 错误详情: " + e.getMessage() + ", 错误堆栈信息: " + Arrays.toString(e.getStackTrace()))); + Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); + } + } + + private void updateInstructionStatus() throws Exception { + Instruction inst = instructionService.findByCodeFromCache(String.valueOf(this.task)); + if (ObjectUtil.isNotEmpty(inst)) { + if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { + inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.update(inst); + } else if (this.action == 4 && this.move == 0) { + inst.setExecute_device_code(this.currentDeviceCode); + instructionService.finish(inst); + } + } + } + + public void applyTask() { + long currentTimeMillis = System.currentTimeMillis(); + if (!isTimeValid(currentTimeMillis)) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut); + } else { + this.requireTime = currentTimeMillis; + //先判断桁架上报指令号是否存在 + Instruction inst = instructionService.findByCodeFromCache(String.valueOf(this.task)); + if (ObjectUtil.isNotEmpty(inst) && StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex())) { + this.unExecutedMessage = LangProcess.msg("320001"); + return; + } else if (ObjectUtil.isNotEmpty(inst) && StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { + //下发桁架执行指令 + TaskDto taskDto = taskService.findByTaskCode(inst.getTask_code()); + if (ObjectUtil.isEmpty(taskDto)) { + this.unExecutedMessage = LangProcess.msg("320002"); + } + this.issuedPlc(inst, taskDto); + this.requireSuccess = true; + return; + } + List getDeviceCodeList = this.getExtraDeviceCodes("get_device_code"); + if (CollectionUtil.isEmpty(getDeviceCodeList)) { + this.unExecutedMessage = LangProcess.msg("320003"); + } + List putDeviceCodeList = this.getExtraDeviceCodes("put_device_code"); + if (CollectionUtil.isEmpty(putDeviceCodeList)) { + this.unExecutedMessage = LangProcess.msg("320004"); + } + Instruction readyInst = findReadyInst(getDeviceCodeList, putDeviceCodeList); + if (ObjectUtil.isNotEmpty(readyInst)) { + TaskDto taskDto = taskService.findByTaskCode(readyInst.getTask_code()); + if (ObjectUtil.isEmpty(taskDto)) { + this.unExecutedMessage = LangProcess.msg("320002"); + } + issuedPlc(readyInst, taskDto); + this.requireSuccess = true; + } else { + //若没有就绪的指令,则查询就绪的任务 + //若任务不为空,则创建指令并下发桁架 + TaskDto readyTask = findReadyTask(getDeviceCodeList, putDeviceCodeList); + if (ObjectUtil.isEmpty(readyTask)) { + this.unExecutedMessage = LangProcess.msg("320005"); + return; + } + String nextDeviceCode = this.getNextDeviceCode(readyTask); + if (nextDeviceCode == null) { + this.unExecutedMessage = readyTask.getStart_device_code() + "->" + readyTask + LangProcess.msg("1009"); + return; + } + Device startDevice = deviceAppService.findDeviceByCode(readyTask.getStart_device_code()); + if (startDevice == null) { + this.unExecutedMessage = LangProcess.msg("1008") + ":" + readyTask.getStart_device_code(); + return; + } + Device nextDevice = deviceAppService.findDeviceByCode(nextDeviceCode); + if (nextDevice == null) { + this.unExecutedMessage = LangProcess.msg("1008") + ":" + nextDeviceCode; + return; + } + Instruction instDto = new Instruction(); + try { + packageInst(instDto, readyTask, nextDeviceCode); + instructionService.create(instDto); + } catch (Exception e) { + this.unExecutedMessage = LangProcess.msg("1006"); + return; + } + readyTask.setTask_status(TaskStatusEnum.BUSY.getIndex()); + taskService.update(readyTask); + this.issuedPlc(instDto, readyTask); + this.requireSuccess = true; + } + } + } + + private void issuedPlc(Instruction inst, TaskDto taskDto) { + String interactionJson = taskDto.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); + Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); + int onset = getAddress(start_device); + int target = getAddress(next_device); + List keys = Arrays.asList(ItemProtocol.TO_COMMAND.getKey(), ItemProtocol.TO_ONSET.getKey(), ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey()); + List values = Arrays.asList(1, onset, target, Integer.parseInt(inst.getInstruction_code())); + if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { + String length = interactionJsonDTO.getLength(); + if (StrUtil.isNotBlank(length)) { + keys.add(ItemProtocol.TO_LENGTH.getKey()); + values.add(Integer.parseInt(length)); + } + String width = interactionJsonDTO.getWeight(); + if (StrUtil.isNotBlank(width)) { + keys.add(ItemProtocol.TO_WIDTH.getKey()); + values.add(Integer.parseInt(width)); + } + String height = interactionJsonDTO.getHeight(); + if (StrUtil.isNotBlank(height)) { + keys.add(ItemProtocol.TO_HEIGHT.getKey()); + values.add(Integer.parseInt(height)); + } + String template = interactionJsonDTO.getTemplate(); + if (StrUtil.isNotBlank(template)) { + keys.add(ItemProtocol.TO_TEMPLATE.getKey()); + values.add(Integer.parseInt(template)); + } + String isLeave = interactionJsonDTO.getIsLeave(); + if (StrUtil.isNotBlank(isLeave)) { + keys.add(ItemProtocol.TO_IS_LEAVE.getKey()); + values.add(Integer.parseInt(isLeave)); + } + String bindingTimes = interactionJsonDTO.getBindingTimes(); + if (StrUtil.isNotBlank(bindingTimes)) { + keys.add(ItemProtocol.TO_BINDING_TIMES.getKey()); + values.add(Integer.parseInt(bindingTimes)); + } + String isBinding = interactionJsonDTO.getIsBinding(); + if (StrUtil.isNotBlank(isBinding)) { + keys.add(ItemProtocol.TO_IS_BINDING.getKey()); + values.add(Integer.parseInt(isBinding)); + } + String barcode = interactionJsonDTO.getBarcode(); + if (StrUtil.isNotBlank(barcode)) { + keys.add(ItemProtocol.TO_MATERIAL.getKey()); + values.add(barcode); + } + } + this.writing(keys, values); + } + + /** + * 抽取统一下发电气信号前缀 + * + * @return + */ + 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(); + jo.put("mode", LangProcess.msg(ModeEnum.getDescByNum(this.mode))); + jo.put("move", LangProcess.msg(MoveEnum.getDescByNum(this.move))); + jo.put("hasGoods", this.move == 1 ? true : false); + jo.put("error", LangProcess.msg(ErrorEnum.getDesc(this.getError()))); + jo.put("isError", this.isError); + jo.put("action", LangProcess.msg(ActionEnum.getDescByNum(this.action))); + jo.put("task", this.task); + jo.put("requireSuccess", this.requireSuccess); + jo.put("isOnline", this.isOnline); + jo.put("unExecutedMessage", this.unExecutedMessage); + jo.put("message", this.message); + jo.put("driver_type", "siemens_conveyor"); + jo.put("is_click", true); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + Boolean requireSuccess = data.getBoolean("requireSuccess"); + if (requireSuccess != null) { + this.requireSuccess = requireSuccess; + } + } + + private String getNextDeviceCode(TaskDto taskDto) { + List shortPathsList = routeLineService.getShortPathLines(taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code()); + if (ObjectUtils.isEmpty(shortPathsList)) { + return null; + } + RouteLineDto routeLineDto = shortPathsList.get(0); + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(taskDto.getStart_device_code())) { + index = m + 1; + break; + } + } + return pathlist.get(index); + } + + + private boolean isTimeValid(long currentTimeMillis) { + return currentTimeMillis - this.requireTime >= this.requireTimeOut; + } + + private int getAddress(Device device) { + return Optional.ofNullable(device.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0); + } + + private void packageInst(Instruction instDto, TaskDto taskDto, String next_device_code) { + instDto.setInstruction_id(IdUtil.simpleUUID()); + instDto.setRoute_plan_code(taskDto.getRoute_plan_code()); + instDto.setRemark(taskDto.getRemark()); + instDto.setMaterial(taskDto.getMaterial()); + instDto.setQuantity(taskDto.getQuantity()); + instDto.setTask_id(taskDto.getTask_id()); + instDto.setTask_code(taskDto.getTask_code()); + instDto.setVehicle_code(taskDto.getVehicle_code()); + String now = DateUtil.now(); + instDto.setCreate_time(now); + instDto.setCreate_by(SecurityUtils.getCurrentNickName()); + instDto.setStart_device_code(taskDto.getStart_device_code()); + instDto.setNext_device_code(next_device_code); + instDto.setStart_point_code(taskDto.getStart_point_code()); + instDto.setNext_point_code(next_device_code); + instDto.setPriority(taskDto.getPriority()); + instDto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); + instDto.setExecute_device_code(this.currentDeviceCode); + instDto.setInstruction_type(taskDto.getTask_type()); + instDto.setVehicle_type(taskDto.getVehicle_type()); + } + + private Instruction findReadyInst(List getDeviceCodeList, List putDeviceCodeList) { + List instructions = instructionService.findAllInstFromCache(); + return Optional.ofNullable(instructions) + .orElse(new CopyOnWriteArrayList<>()) + .stream() + .filter(inst -> inst.getInstruction_status().equals(InstructionStatusEnum.READY.getIndex())) + .filter(inst -> getDeviceCodeList.contains(inst.getStart_device_code())) + .filter(inst -> putDeviceCodeList.contains(inst.getNext_device_code())) + .sorted(Comparator.comparing(Instruction::getPriority).reversed() + .thenComparing(inst -> LocalDateTime.parse(inst.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) + .findFirst() + .orElse(null); + } + + private TaskDto findReadyTask(List getDeviceCodeList, List putDeviceCodeList) { + List tasks = taskService.findAllTaskFromCache(); + return Optional.ofNullable(tasks) + .orElse(new CopyOnWriteArrayList<>()) + .stream() + .filter(task -> task.getTask_status().equals(TaskStatusEnum.READY.getIndex())) + .filter(task -> getDeviceCodeList.contains(task.getStart_device_code())) + .filter(task -> putDeviceCodeList.contains(task.getNext_device_code())) + .sorted(Comparator.comparing(TaskDto::getPriority).reversed() + .thenComparing(task -> LocalDateTime.parse(task.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) + .findFirst() + .orElse(null); + } + + /** + * 下发单个电气信号 + * + * @param key + * @param value + */ + public void writing(String key, Object value) { + Map itemMap = new HashMap(); + itemMap.put(getId() + key, value); + try { + this.checkcontrol(itemMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC单个信号, " + itemMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 下发多个电气信号 + * + * @param keys + * @param values + */ + public void writing(List keys, List values) { + if (keys.size() != values.size()) { + this.message = "1007"; + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "参数长度不一致,不允许下发")); + throw new BadRequestException("参数长度不一致,不允许下发"); + } + Map controlMap = new LinkedHashMap<>(); + for (int i = 0; i < keys.size(); i++) { + controlMap.put(getId() + keys.get(i), values.get(i)); + } + try { + this.checkcontrol(controlMap); + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap)); + } catch (Exception e) { + logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "下发PLC多个信号, " + controlMap + ". 下发失败, 失败原因: " + e.getMessage())); + } + } + + /** + * 抽取统一下发电气信号前缀 + * + * @return + */ + public String getId() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } +} 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 deleted file mode 100644 index cd75538..0000000 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java +++ /dev/null @@ -1,827 +0,0 @@ -package org.nl.acs.device_driver.one_conveyor.box_subvolumes_conveyor; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; -import org.nl.acs.AcsConfig; -import org.nl.acs.agv.server.NDCAgvService; -import org.nl.acs.common.base.CommonFinalParam; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.FeedLmsRealFailed; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.history.ErrorUtil; -import org.nl.acs.history.service.DeviceErrorLogService; -import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; -import org.nl.acs.instruction.domain.Instruction; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.log.service.DeviceExecuteLogService; -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.common.utils.SecurityUtils; -import org.nl.config.SpringContextHolder; -import org.nl.config.language.LangProcess; -import org.nl.config.lucene.service.LuceneExecuteLogService; -import org.nl.config.lucene.service.dto.LuceneLogDto; -import org.nl.config.thread.ThreadPoolExecutorUtil; -import org.nl.system.service.param.ISysParamService; -import org.openscada.opc.lib.da.Server; - -import java.util.*; -import java.util.concurrent.Executor; -import java.util.concurrent.ThreadPoolExecutor; - -/** - * 一楼木箱机械手、子卷机械手对接位 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { - private final static Executor EXECUTOR = ThreadPoolExecutorUtil.getPoll(); - protected ItemProtocol itemProtocol = new ItemProtocol(this); - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - - RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class); - - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - - - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - - - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); - - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - - NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class); - - DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); - - ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); - - //当前指令 - Instruction inst = null; - - private String error_type = "ssx_error_type"; - - String notCreateInstMessage = ""; - - //工作模式 - int mode = 0; - int last_mode = 0; - //光电信号 - int move = 0; - int last_move = 0; - //托盘方向 - int carrier_direction = 0; - int last_carrier_direction = 0; - //报警信号 - int error = 0; - int last_error = 0; - //任务号 - int task = 0; - int last_task = 0; - int agvphase = 0; - String task_code = null; - int to_command = 0; - int last_to_command = 0; - - int to_target = 0; - int last_to_target = 0; - - int to_task = 0; - int last_to_task = 0; - - int to_length = 0; - int last_to_length = 0; - int to_weight = 0; - int last_to_weight = 0; - int to_height = 0; - int last_to_height = 0; - - String material_barcode = null; - String last_material_barcode = null; - - int phase = 0; - int index = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - String hand_barcode = null; - - Integer heartbeat_tag; - private Date instruction_update_time = new Date(); - private int instruction_update_time_out = 500; - - private Date instruction_require_time = new Date(); - private Date require_apply_labeling_time = new Date(); - private Date require_apply_strangulation_time = new Date(); - private Date require_empty_in_time = new Date(); - private Date require_empty_out_time = new Date(); - - private int instruction_require_time_out = 3000; - //行架机械手申请任务成功标识 - boolean requireSucess = false; - boolean requireEmptyInSuccess = false; - boolean requiresShipDeviceUpdate = true; - private int instruction_finished_time_out; - - int branchProtocol = 0; - String inst_message; - String last_inst_message; - int heartbeat = 0; - int last_heartbeat = 0; - //当前指令 - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String device_code; - - String vehicle_code; - String last_vehicle_code; - - String vehicle_code2; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - move = this.itemProtocol.getMove(); - carrier_direction = this.itemProtocol.getContainer_direction(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - to_command = this.itemProtocol.getTo_command(); - to_target = this.itemProtocol.getTo_target(); - to_task = this.itemProtocol.getTo_task(); - heartbeat = this.itemProtocol.getHeartbeat(); - material_barcode = this.itemProtocol.getMaterialBarCode(); - - // 更新指令状态 - if (mode != last_mode) { - - requireSucess = false; - } - if (move != 0 && task > 0) { - update_instruction_status(); - if (null != inst) { - inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code(); - vehicle_code2 = inst.getVehicle_code2(); - } - } - - if (move != last_move && move == 0 && last_move == 1 && mode > 0) { - requireSucess = false; - clearWrite(); - } - - - if (mode == 0) { - this.setIsonline(false); - - } else { - this.setIsonline(true); - this.setIserror(false); - if (error != 0) { - this.setIserror(true); - message = "有报警"; - } - - Instruction instruction = null; - List toInstructions; - - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 19: - //申请AGV任务 - if (move == 1 && !requireSucess) { - if (StrUtil.isEmpty(material_barcode)) { - message = "条码为空"; - } else { - applyAgvTask(); - } - - } - break; - case 2: - //申请任务 - if (move > 0 && !requireSucess) { - instruction_require(); - } else { - String remark = ""; - ; - if (mode != 2) { - remark = "universal_remark2"; - } - if (move != 0) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = "universal_remark4"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = "universal_remark5"; - } - this.setNotCreateInstMessage(remark); - //} - } - break; - } - } - } catch (Exception var17) { - this.iserror = true; - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(this.device_code + "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null") - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - message = "读取信号值时出现异常"; - var17.printStackTrace(); - } - - - last_mode = mode; - last_move = move; - last_carrier_direction = carrier_direction; - 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_material_barcode = material_barcode; - last_to_length = to_length; - last_to_weight = to_weight; - last_to_height = to_height; - } - - private void clearWrite() { - List list = new ArrayList<>(); - Map map = new HashMap<>(); - map.put("code", "to_target"); - map.put("value", "0"); - list.add(map); - Map map2 = new HashMap<>(); - map2.put("code", "to_task"); - map2.put("value", "0"); - list.add(map2); - Map map4 = new HashMap<>(); - map4.put("code", "to_container_type"); - map4.put("value", "0"); - list.add(map4); - - this.writing(list); - message = null; - vehicle_code = null; - inst_message = null; - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - public synchronized void applyAgvTask() { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - String hand_barcode = null; - this.instruction_require_time = date; - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { - if (StrUtil.equals(paramService.findByCode(AcsConfig.ISWMS).getValue(), "1")) { - //判断是否有手动补码 如果有就申请补码agv任务 - if (StrUtil.isNotEmpty(hand_barcode)) { - JSONObject apply = new JSONObject(); - apply.put("device_code", device_code); - apply.put("vehicle_code", hand_barcode); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("申请AGV任务,请求参数:" + apply) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - String str = acsToWmsService.applySendOutTwo(apply); - JSONObject jo = JSON.parseObject(str); - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请AGV任务,参数,接口返回:" + jo) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - message = "申请AGV任务,参数,接口返回:" + jo; - - if (jo.getInteger("status") == 200) { - List list1 = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", 19); - list1.add(map); - this.writing(list1); - LuceneLogDto logDto1 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请AGV任务,返回参数:" + str) - .build(); - logDto1.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto1); - requireSucess = true; - } - return; - } - JSONObject apply = new JSONObject(); - apply.put("device_code", device_code); - - apply.put("vehicle_code", material_barcode); - - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("申请AGV任务,请求参数:" + apply) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - String str = acsToWmsService.applySendOutTwo(apply); - logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,请求参数:" + apply + ",响应参数"); - - JSONObject jo = JSON.parseObject(str); - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请AGV任务,参数,接口返回:" + jo) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - message = "申请AGV任务,参数,接口返回:" + jo; - if (jo.getInteger("status") == 200) { - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", 19); - list.add(map); - this.writing(list); - logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,返回参数:" + jo); - requireSucess = true; - } else { - message = "申请AGV任务报错,参数,接口返回:" + jo; - this.iserror = true; - } - - } - } - } - } - - - public boolean exe_business() { - return true; - } - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - - protected void thingToNothing() throws Exception { - requireSucess = false; - } - - - public void executing(Server server, Map itemMap) { - this.control(itemMap); - } - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.two_conveyor.hongxiang_conveyor.ItemProtocol.item_to_command; - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - this.control(itemMap); - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String move = ""; - String carrier_direction = ""; - if (this.getMode() == 0) { - mode = LangProcess.msg("universal_off-line"); - } else if (this.getMode() == 1) { - mode = LangProcess.msg("universal_stand-alone"); - } else if (this.getMode() == 2) { - mode = LangProcess.msg("universal_standby"); - } else if (this.getMode() == 3) { - mode = LangProcess.msg("universal_operation"); - } - - if (this.getMove() == 0) { - move = LangProcess.msg("universal_no"); - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = LangProcess.msg("universal_yes"); - jo.put("hasGoods", true); - } - - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = "1"; - } - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("carrier_direction", carrier_direction); - jo.put("task", task); - jo.put("last_task", last_task); - jo.put("vehicle_code2", this.vehicle_code2); - jo.put("task_code", task_code); - jo.put("inst_message", this.inst_message); - jo.put("last_inst_message", this.last_inst_message); - jo.put("isOnline", this.getIsonline()); - jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError()))); - jo.put("isError", this.getIserror()); - jo.put("message", message); - jo.put("hand_barcode", hand_barcode); - jo.put("material_barcode", material_barcode); - jo.put("is_click", true); - jo.put("requireSucess", requireSucess); - jo.put("driver_type", "siemens_conveyor"); - jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); - 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, "1")) { - this.requireSucess = true; - } - - String hand_barcode = data.getString("hand_barcode"); - this.setHand_barcode(hand_barcode); - } - - @Override - public JSONObject feedLmsRealFailedInfo() { - JSONObject jo = new JSONObject(); - jo.put("device_code", this.getDevice().getDevice_code()); - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("fault_code", String.valueOf(error)); - jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); - jo.put("fault_type", error_type); - return jo; - } - - public void writing(List list) { - - Map itemMap = new HashMap(); - for (int i = 0; i < list.size(); i++) { - Object ob = list.get(i); - JSONObject json = (JSONObject) JSONObject.toJSON(ob); - if (!StrUtil.isEmpty(json.getString("value"))) { - String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + json.getString("code"); - itemMap.put(to_param, json.getString("value")); - } - } - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("下发多个电气信号" + itemMap) - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto); - logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); - try { - this.checkcontrol(itemMap); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - - /** - * 请求指令 - */ - public synchronized boolean instruction_require() { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_require_time = date; - //判断是否存在起点相同 任务状态就绪的任务 - TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); - if (!ObjectUtil.isEmpty(taskdto)) { - //需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建 - Instruction inst = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()); - if (ObjectUtil.isNotEmpty(inst)) { - List list = new ArrayList(); - Map map2 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", inst.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "1"); - list.add(map3); - this.writing(list); - requireSucess = true; - while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , inst.getInstruction_code())) { - this.writing(list); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + inst.getInstruction_code() + "再次下发电气信号") - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))) { - requireSucess = false; - return false; - } - } - requireSucess = true; - return true; - } - String taskid = taskdto.getTask_id(); - String taskcode = taskdto.getTask_code(); - String vehiclecode = taskdto.getVehicle_code(); - String priority = taskdto.getPriority(); - String start_point_code = taskdto.getStart_point_code(); - String start_device_code = taskdto.getStart_device_code(); - String route_plan_code = taskdto.getRoute_plan_code(); - String next_device_code = ""; - - /** - * 开始平均分配 - */ - String this_coevice_code = taskserver.queryAssignedByDevice(device_code, taskdto.getNext_device_code()); - if (StrUtil.isEmpty(this_coevice_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, taskdto.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - - List pathlist = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 1; - break; - } - } - next_device_code = pathlist.get(index); - } else { - next_device_code = this_coevice_code; - } - //校验路由关系 - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - if (ObjectUtils.isEmpty(shortPathsList)) { - throw new RuntimeException("路由不通!"); - } - - Device startdevice = deviceAppservice.findDeviceByCode(start_device_code); - Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); - String next_point_code; - if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) { - next_point_code = taskdto.getTo_x() + "-" + taskdto.getTo_y() + "-" + taskdto.getTo_z(); - } else { - next_point_code = next_device_code; - } - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(taskdto.getRemark()); - instdto.setMaterial(taskdto.getMaterial()); - instdto.setQuantity(taskdto.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by(SecurityUtils.getCurrentNickName()); - 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.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - try { - instructionService.create(instdto); - } catch (Exception e) { - e.printStackTrace(); - log.error("指令创建失败!", e.getMessage()); - return false; - } - //创建指令后修改任务状态 - taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskserver.update(taskdto); - requireSucess = true; - String next_addr = nextdevice.getExtraValue().get("address").toString(); - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_target"); - map.put("value", next_addr); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", instdto.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "1"); - list.add(map3); - this.writing(list); - requireSucess = true; - while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , instdto.getInstruction_code())) { - this.writing(list); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + inst.getInstruction_code() + "再次下发电气信号") - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (ObjectUtil.isEmpty(taskserver.findByCode(taskdto.getTask_code()))) { - requireSucess = false; - return false; - } - } - } else { - //如果不存在则直接找对应指令 - Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); - if (ObjectUtil.isEmpty(inst)) { - return false; - } - - Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code()); - String next_addr = nextdevice.getExtraValue().get("address").toString(); - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_target"); - map.put("value", next_addr); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", inst.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "1"); - list.add(map3); - this.writing(list); - requireSucess = true; - while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , inst.getInstruction_code())) { - this.writing(list); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + inst.getInstruction_code() + "再次下发电气信号") - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (ObjectUtil.isEmpty(instructionService.findByDeviceCodeFromCache(this.device_code))) { - requireSucess = false; - return false; - } - } - } - return true; - } - } - - /** - * 更新指令状态 - */ - public synchronized void update_instruction_status() throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); - - } else { - this.instruction_update_time = date; - inst = checkInst(); - if (inst != null) { - vehicle_code = inst.getVehicle_code(); - task_code = inst.getTask_code(); - if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status("1"); - inst.setExecute_device_code(this.device_code); - instructionService.update(inst); - logServer.deviceExecuteLog(device_code, "", "", "纸箱入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task + ",载具号:" + inst.getVehicle_code()); - } - if (StrUtil.equals(inst.getInstruction_status(), "1") || StrUtil.equals(inst.getInstruction_status(), "0")) { - if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - vehicle_code = inst.getVehicle_code(); - inst.setExecute_device_code(this.device_code); - if (mode == 2) { - finish_instruction(); - } - logServer.deviceExecuteLog(device_code, "", "", "纸箱入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task + ",载具号:" + inst.getVehicle_code()); - } else { - - } - } - } else { -// message = "输送线任务反馈状态,查询不到指令号:" + task +"指令已完成"; - inst_message = null; - } - - } - } - - public void writing(String param, String value) { - - String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + param; - - Map itemMap = new HashMap(); - - itemMap.put(to_param, Integer.parseInt(value)); - this.control(itemMap); - logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("下发多个电气信号" + itemMap) - .build(); - logDto.setLog_level(3); - luceneExecuteLogService.deviceExecuteLog(logDto); - } - - public Instruction checkInst() { - if (ObjectUtil.isNotEmpty(this.inst)) { - if (this.task > 0) { - if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { - return this.inst; - } else { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - return inst; - } - } - } else { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - return inst; - } - return null; - } -} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/ItemProtocol.java deleted file mode 100644 index 7755f3b..0000000 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/ItemProtocol.java +++ /dev/null @@ -1,190 +0,0 @@ -package org.nl.acs.device_driver.one_conveyor.box_subvolumes_conveyor; - -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -@Data -public class ItemProtocol { - - /** - * 心跳 - */ - public static String item_heartbeat = "heartbeat"; - /** - * 工作模式 - */ - public static String item_mode = "mode"; - /** - * 光电信号 - */ - public static String item_move = "move"; - /** - * 托盘方向 - */ - public static String item_container_direction = "container_direction"; - - /** - * 载具类型 - */ - public static String item_container_type = "container_type"; - - /** - * 物料条码 - */ - public static String item_material_barcode = "material_barcode"; - - /** - * 报警 - */ - public static String item_error = "error"; - /** - * 任务号 - */ - public static String item_task = "task"; - - /** - * 动作信号 - */ - public static String item_action = "action"; - - /** - * 下发命令 - */ - public static String item_to_command = "to_command"; - /** - * 下发目标站 - */ - public static String item_to_target = "to_target"; - /** - * 下发托盘类型 - */ - public static String item_to_container_type = "to_container_type"; - /** - * 下发任务号 - */ - public static String item_to_task = "to_task"; - - - - private BoxSubvolumesConveyorDeviceDriver driver; - - public int getContainer_type() { - return this.getOpcIntegerValue(item_container_type); - } - - - public ItemProtocol(BoxSubvolumesConveyorDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getMove() { - return this.getOpcIntegerValue(item_move); - } - - public int getContainer_direction() { - return this.getOpcIntegerValue(item_container_direction); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_target() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getTo_task() { - return this.getOpcIntegerValue(item_to_task); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - - - - Boolean isonline; - - public String getMaterialBarCode() { - return this.getOpcStringValue(item_material_barcode); - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public String getOpcStringValue(String protocol) { - String value = this.driver.getStringValue(protocol); - if (StrUtil.isEmpty(value)) { - - } else { - return value; - } - return ""; - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作模式", "DB600.B2")); - list.add(new ItemDto(item_move, "光电信号", "DB600.B3")); - list.add(new ItemDto(item_container_direction, "托盘方向", "DB600.B4")); - list.add(new ItemDto(item_action, "动作信号", "DB600.B5")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_container_type, "托盘类型", "DB101.B7")); - list.add(new ItemDto(item_task, "任务号", "DB600.D8")); - list.add(new ItemDto(item_material_barcode, "物料条码", "DB600.D9")); - - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "DB601.W2")); - list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W4")); - list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB601.W6")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB601.D8")); - - return list; - } - - @Override - public String toString() { - return ""; - } - -} - 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 deleted file mode 100644 index 25f9d37..0000000 --- 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 +++ /dev/null @@ -1,1066 +0,0 @@ -package org.nl.acs.device_driver.one_conveyor.finished_product_out_with_bind_lable_conveyor; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; -import org.nl.acs.agv.server.NDCAgvService; -import org.nl.acs.common.base.CommonFinalParam; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.FeedLmsRealFailed; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.device_driver.one_manipulator.box_package_manipulator.InteractionJsonDTO; -import org.nl.acs.enums.AcsToLmsApplyTaskTypeEnum; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.history.ErrorUtil; -import org.nl.acs.history.service.DeviceErrorLogService; -import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; -import org.nl.acs.instruction.domain.Instruction; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.log.service.DeviceExecuteLogService; -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.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.common.utils.SecurityUtils; -import org.nl.config.SpringContextHolder; -import org.nl.config.language.LangProcess; -import org.nl.config.lucene.service.LuceneExecuteLogService; -import org.nl.config.lucene.service.dto.LuceneLogDto; -import org.nl.config.thread.ThreadPoolExecutorUtil; -import org.openscada.opc.lib.da.Server; - -import java.util.*; -import java.util.concurrent.ThreadPoolExecutor; - -/** - * 一楼出库捆轧贴标位 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - - RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class); - - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - - - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - - - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); - - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - - NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class); - - DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - - LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class); - - - //当前指令 - Instruction inst = null; - - private StorageCellMapper storageCellMapper; - - private String error_type = "ssx_error_type"; - - String notCreateInstMessage = ""; - - String vehicle_code2; - - //工作模式 - int mode = 0; - int last_mode = 0; - //光电信号 - int move = 0; - int last_move = 0; - //托盘方向 - int carrier_direction = 0; - int last_carrier_direction = 0; - //报警信号 - int error = 0; - int last_error = 0; - //任务号 - int task = 0; - int last_task = 0; - int agvphase = 0; - String task_code = null; - int to_command = 0; - int last_to_command = 0; - - int to_target = 0; - int last_to_target = 0; - - int to_task = 0; - int last_to_task = 0; - - int to_length = 0; - int last_to_length = 0; - - int to_height = 0; - int last_to_height = 0; - - - String material_barcode = null; - String last_material_barcode = null; - - int phase = 0; - int index = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - String hand_barcode = null; - - Integer heartbeat_tag; - private Date instruction_update_time = new Date(); - private int instruction_update_time_out = 500; - - private Date instruction_require_time = new Date(); - private Date require_apply_labeling_time = new Date(); - private Date require_apply_strangulation_time = new Date(); - private Date require_empty_in_time = new Date(); - private Date require_empty_out_time = new Date(); - - private int instruction_require_time_out = 3000; - //行架机械手申请任务成功标识 - boolean requireSucess = false; - boolean requireEmptyInSuccess = false; - boolean requiresShipDeviceUpdate = true; - private int instruction_finished_time_out; - - int branchProtocol = 0; - String inst_message; - String last_inst_message; - int heartbeat = 0; - int last_heartbeat = 0; - //当前指令 - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String device_code; - - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - move = this.itemProtocol.getMove(); - carrier_direction = this.itemProtocol.getContainer_direction(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - to_command = this.itemProtocol.getTo_command(); - to_target = this.itemProtocol.getTo_target(); - to_task = this.itemProtocol.getTo_task(); - heartbeat = this.itemProtocol.getHeartbeat(); - material_barcode = this.itemProtocol.getMaterialBarCode(); - - if (mode != last_mode) { - JSONObject param = new JSONObject(); - param.put("device_code", this.device_code); - param.put("mode", Math.min(mode, 3)); - param.put("device_name", this.getDevice().getDevice_name()); - param.put("device_type", CommonFinalParam.ONE); - requireSucess = false; - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记:" + requireSucess); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - - - if (move != 0 && task > 0) { - update_instruction_status(); - } - if (move != last_move && move == 0 && last_move == 1 && mode > 0) { - requireSucess = false; - clearWrite(); - } - - - if (mode == 0) { - this.setIsonline(false); - message = "脱机"; - - //有报警 - - } else { - this.setIsonline(true); - this.setIserror(false); - if (error != 0) { - this.setIserror(true); - message = "有警报"; - } - - Instruction instruction = null; - List toInstructions; - - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - //申请任务 - if (move > 0 && !requireSucess) { - instruction_require(); - } else { - String remark = ""; - ; - if (mode != 2) { - remark = "universal_remark2"; - } - if (move != 0) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = "universal_remark4"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = "universal_remark5"; - } - this.setNotCreateInstMessage(remark); - //} - } - break; - case 5: - //申请贴标 - applyLabeling(mode); - break; - case 10: - //申请捆轧贴标信息 - if (move > 0 && !requireSucess) { - applyLaStrangulationAndLabeling(mode); - } - break; - case 12: - //申请贴标(未贴标) - applyLabeling(mode); - break; - case 13: - //申请捆轧贴标信息(未捆扎) - if (move > 0 && !requireSucess) { - applyLaStrangulationAndLabeling(mode); - } - break; - case 14: - //申请捆轧贴标信息(未贴标) - if (move > 0 && !requireSucess) { - applyLaStrangulationAndLabeling(mode); - } - break; - case 16: - //申请捆轧贴标信息(未贴标,未捆扎) - if (move > 0 && !requireSucess) { - applyLaStrangulationAndLabeling(mode); - } - case 17: - //申请调试贴标 - if (move > 0 && !requireSucess) { - applyLaStrangulationAndLabeling(mode); - } - break; - } - } - - } catch (Exception var17) { - this.iserror = true; - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(this.device_code + "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null") - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - message = "读取信号值时出现异常"; - var17.printStackTrace(); - } - - - last_mode = mode; - last_move = move; - last_carrier_direction = carrier_direction; - 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_material_barcode = material_barcode; - last_to_length = to_length; - last_to_height = to_height; - } - - private void clearWrite() { - List list = new ArrayList<>(); - Map map = new HashMap<>(); - map.put("code", "to_target"); - map.put("value", "0"); - list.add(map); - Map map2 = new HashMap<>(); - map2.put("code", "to_task"); - map2.put("value", "0"); - list.add(map2); - Map map4 = new HashMap<>(); - map4.put("code", "to_container_type"); - map4.put("value", "0"); - list.add(map4); - - this.writing(list); - message = null; - inst_message = null; - } - - private void applyLaStrangulationAndLabeling(int mode) throws Exception { - Date date = new Date(); - if (date.getTime() - this.require_apply_strangulation_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_apply_strangulation_time = date; - Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task)); - if (ObjectUtil.isNotEmpty(inst)) { - applyLaStrangulationAndLabeling2(); - } else { - message = "当前指令号:" + task + "有误,需补码重新申请捆扎贴标"; - } - if (StrUtil.isNotEmpty(hand_barcode)) { - TaskDto taskDtoHandCode = taskserver.findByVehicleCode2AndExcute(hand_barcode); - if (ObjectUtil.isNotEmpty(taskDtoHandCode)) { - applyLaStrangulationAndLabeling2(); - message = ""; - } - } - return; - } - } - - public synchronized void applyLaStrangulationAndLabeling2() throws Exception { - JSONObject param = new JSONObject(); - param.put("device_code", device_code); - param.put("vehicle_code", inst.getVehicle_code()); - param.put("type", AcsToLmsApplyTaskTypeEnum.LABEL_BIND.getType()); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("申请捆扎,请求参数:" + param) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - String response = acsToWmsService.deviceApplyTwo(param); - JSONObject jo = JSON.parseObject(response); - message = "申请捆扎,参数,接口返回:" + jo; - if (jo.getInteger("status") == 200) { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请捆扎,参数,接口返回:" + jo) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); -// Map datas = applyLabelingAndBindingResponse.getData(); - packagePLCData(jo.getString("data"), mode); - requireSucess = true; - } else { - this.iserror = true; - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请捆扎失败,接口返回:" + response) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - message = "申请捆扎报错,参数,接口返回:" + jo; - } - } - - // 申请贴标 - public synchronized void applyLabeling(int mode) { - Date date = new Date(); - if (date.getTime() - this.require_apply_strangulation_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_apply_strangulation_time = date; -// String vehicle_code = ""; -// - Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task)); - if (StrUtil.isEmpty(inst.getVehicle_code())) { - message = "托盘码为空"; - return; - } - JSONObject param = new JSONObject(); - param.put("device_code", device_code); - param.put("vehicle_code", inst.getVehicle_code()); - param.put("type", AcsToLmsApplyTaskTypeEnum.LABEL.getType()); - String response = acsToWmsService.deviceApplyTwo(param); - JSONObject jo = JSON.parseObject(response); - message = "申请贴标,参数,接口返回:" + jo; - if (jo.getInteger("status") == 200) { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请贴标成功:" + jo) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - List list = new ArrayList(); - Map map5 = new HashMap(); - map5.put("code", "to_command"); - map5.put("value", mode); - list.add(map5); - try { - this.writing(list); - } catch (Exception e) { - message = "写入异常"; - } -// Map datas = applyLabelingAndBindingResponse.getData(); - requireSucess = true; - } else { - this.iserror = false; - message = "申请贴标报错,接口返回:" + jo; - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请贴标失败,接口返回:" + jo) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - } - - } - } - - private void packagePLCData(String datas, int mode) { - - JSONObject jo = JSON.parseObject(datas); - String length = jo.get("length").toString(); - String width = jo.get("width").toString(); - String height = jo.get("height").toString(); - String isBinding = jo.get("isBinding").toString(); - String isLabeling = jo.get("isLabeling").toString(); - String printQty = jo.get("printQty").toString(); - String labelingTemplate = jo.get("labelingTemplate").toString(); - String bindingTemplate = jo.get("bindingTemplate").toString(); - String printDevice = jo.get("printDevice").toString(); - String bundleTimes = jo.get("bundleTimes").toString(); - String to_case = jo.get("box_structure").toString(); - - - List list = new ArrayList(); - if (mode == 10 || mode == 16) { - Map map = new HashMap(); - map.put("code", "to_length"); - map.put("value", length); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_width"); - map2.put("value", width); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_height"); - map3.put("value", height); - list.add(map3); - Map map4 = new HashMap(); - map4.put("code", "to_is_binding"); - map4.put("value", isBinding); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_command"); - map5.put("value", mode); - list.add(map5); - Map map6 = new HashMap(); - map6.put("code", "to_is_labeling"); - map6.put("value", isLabeling); - list.add(map6); - Map map7 = new HashMap(); - map7.put("code", "to_print_qty"); - map7.put("value", printQty); - list.add(map7); - Map map8 = new HashMap(); - map8.put("code", "to_print_qty"); - map8.put("value", printQty); - list.add(map8); - Map map9 = new HashMap(); - map9.put("code", "to_print_device"); - map9.put("value", printDevice); - list.add(map9); - Map map10 = new HashMap(); - map10.put("code", "to_binding_template"); - map10.put("value", bindingTemplate); - list.add(map10); - Map map11 = new HashMap(); - map11.put("code", "to_binding_times"); - map11.put("value", bundleTimes); - list.add(map11); - Map map12 = new HashMap(); - map12.put("code", "to_labeling_template"); - map12.put("value", labelingTemplate); - list.add(map12); - Map map13 = new HashMap(); - map13.put("code", "to_case"); - map13.put("value", to_case); - list.add(map13); - } - if (mode == 13) { - Map map = new HashMap(); - map.put("code", "to_length"); - map.put("value", length); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_width"); - map2.put("value", width); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_height"); - map3.put("value", height); - list.add(map3); - Map map5 = new HashMap(); - map5.put("code", "to_command"); - map5.put("value", mode); - list.add(map5); - Map map11 = new HashMap(); - map11.put("code", "to_binding_times"); - map11.put("value", bundleTimes); - list.add(map11); - Map map13 = new HashMap(); - map13.put("code", "to_case"); - map13.put("value", to_case); - list.add(map13); - } - if (mode == 14) { - Map map4 = new HashMap(); - map4.put("code", "to_is_binding"); - map4.put("value", isBinding); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_command"); - map5.put("value", mode); - list.add(map5); - Map map6 = new HashMap(); - map6.put("code", "to_is_labeling"); - map6.put("value", isLabeling); - list.add(map6); - Map map7 = new HashMap(); - map7.put("code", "to_print_qty"); - map7.put("value", printQty); - list.add(map7); - Map map8 = new HashMap(); - map8.put("code", "to_print_qty"); - map8.put("value", printQty); - list.add(map8); - Map map9 = new HashMap(); - map9.put("code", "to_print_device"); - map9.put("value", printDevice); - list.add(map9); - Map map10 = new HashMap(); - map10.put("code", "to_binding_template"); - map10.put("value", bindingTemplate); - list.add(map10); - Map map12 = new HashMap(); - map12.put("code", "to_labeling_template"); - map12.put("value", labelingTemplate); - - Map map11 = new HashMap(); - map11.put("code", "to_binding_times"); - map11.put("value", bundleTimes); - list.add(map11); - Map map13 = new HashMap(); - map13.put("code", "to_case"); - map13.put("value", to_case); - list.add(map13); - } - - if (mode == 17) { - String case1 = jo.get("case").toString(); - String direction = jo.get("direction").toString(); - Map map = new HashMap(); - map.put("code", "to_length"); - map.put("value", length); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_width"); - map2.put("value", width); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_height"); - map3.put("value", height); - list.add(map3); - Map map5 = new HashMap(); - map5.put("code", "to_command"); - map5.put("value", mode); - list.add(map5); - Map map11 = new HashMap(); - map11.put("code", "to_binding_times"); - map11.put("value", bundleTimes); - list.add(map11); - Map map6 = new HashMap(); - map6.put("code", "to_case"); - map.put("value", to_case); - list.add(map6); - if (StrUtil.isNotEmpty(case1) && !" ".equals(case1)) { - Map map12 = new HashMap(); - map12.put("code", "to_binding_times"); - map12.put("value", bundleTimes); - list.add(map12); - } - if (StrUtil.isNotEmpty(direction) && !" ".equals(direction)) { - Map map13 = new HashMap(); - map13.put("code", "to_direction"); - map13.put("value", direction); - list.add(map13); - } - } - try { - this.writing(list); - } catch (Exception e) { - message = "写入异常"; - } - this.setRequireSucess(true); - - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - - public boolean exe_business() { - return true; - } - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - - protected void thingToNothing() throws Exception { - requireSucess = false; - } - - - public void executing(Server server, Map itemMap) { - this.control(itemMap); - } - - public void writing(int command) { - Map itemMap = new HashMap(); - this.control(itemMap); - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String move = ""; - String carrier_direction = ""; - if (this.getMode() == 0) { - mode = LangProcess.msg("universal_off-line"); - } else if (this.getMode() == 1) { - mode = LangProcess.msg("universal_stand-alone"); - } else if (this.getMode() == 2) { - mode = LangProcess.msg("universal_standby"); - } else if (this.getMode() == 3) { - mode = LangProcess.msg("universal_operation"); - } - - if (this.getMove() == 0) { - move = LangProcess.msg("universal_no"); - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = LangProcess.msg("universal_yes"); - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = LangProcess.msg("universal_two_yes"); - jo.put("hasGoods", true); - } - - - if (this.carrier_direction == 1) { - carrier_direction = LangProcess.msg("universal_forward_rotation"); - } else if (this.carrier_direction == 2) { - carrier_direction = LangProcess.msg("universal_rollback"); - } - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = "1"; - } - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("carrier_direction", carrier_direction); - jo.put("task", task); - jo.put("last_task", last_task); - jo.put("task_code", task_code); - jo.put("inst_message", this.inst_message); - jo.put("last_inst_message", this.last_inst_message); - jo.put("isOnline", this.getIsonline()); - jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError()))); - jo.put("isError", this.getIserror()); - jo.put("message", message); - jo.put("hand_barcode", hand_barcode); - jo.put("is_click", true); - jo.put("requireSucess", requireSucess); - jo.put("driver_type", "siemens_conveyor"); - jo.put("vehicle_code2", this.vehicle_code2); - jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); - 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, "1")) { - this.requireSucess = true; - } - - String hand_barcode = data.getString("hand_barcode"); - this.setHand_barcode(hand_barcode); - } - - @Override - public JSONObject feedLmsRealFailedInfo() { - JSONObject jo = new JSONObject(); - jo.put("device_code", this.getDevice().getDevice_code()); - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("fault_code", String.valueOf(error)); - jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); - jo.put("fault_type", error_type); - return jo; - } - - public void writing(List list) { - - Map itemMap = new HashMap(); - for (int i = 0; i < list.size(); i++) { - Object ob = list.get(i); - JSONObject json = (JSONObject) JSONObject.toJSON(ob); - if (!StrUtil.isEmpty(json.getString("value"))) { - String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + json.getString("code"); - itemMap.put(to_param, json.getString("value")); - } - } - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("下发多个电气信号" + itemMap) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); - try { - this.checkcontrol(itemMap); - } catch (Exception e) { - e.printStackTrace(); - - } - - } - - - /** - * 请求指令 - */ - public synchronized boolean instruction_require() { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_require_time = date; - //判断是否存在起点相同 任务状态就绪的任务 - TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); - if (!ObjectUtil.isEmpty(taskdto)) { - //需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建 - Instruction inst = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()); - if (ObjectUtil.isNotEmpty(inst)) { - List list = new ArrayList(); - Map map2 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", inst.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "1"); - list.add(map3); - this.writing(list); - requireSucess = true; - while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , inst.getInstruction_code())) { - this.writing(list); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + inst.getInstruction_code() + "再次下发电气信号") - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))) { - requireSucess = false; - return false; - } - } - requireSucess = true; - return true; - } - String taskid = taskdto.getTask_id(); - String taskcode = taskdto.getTask_code(); - String vehiclecode = taskdto.getVehicle_code(); - String priority = taskdto.getPriority(); - String start_point_code = taskdto.getStart_point_code(); - String start_device_code = taskdto.getStart_device_code(); - String route_plan_code = taskdto.getRoute_plan_code(); - String next_device_code = ""; - - /** - * 开始平均分配 - */ - String this_coevice_code = taskserver.queryAssignedByDevice(device_code, taskdto.getNext_device_code()); - if (StrUtil.isEmpty(this_coevice_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, taskdto.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - - List pathlist = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 1; - break; - } - } - next_device_code = pathlist.get(index); - } else { - next_device_code = this_coevice_code; - } - //校验路由关系 - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - if (ObjectUtils.isEmpty(shortPathsList)) { - throw new RuntimeException("路由不通!"); - } - - Device startdevice = deviceAppservice.findDeviceByCode(start_device_code); - Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); - String next_point_code; - if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) { - next_point_code = taskdto.getTo_x() + "-" + taskdto.getTo_y() + "-" + taskdto.getTo_z(); - } else { - next_point_code = next_device_code; - } - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(taskdto.getRemark()); - instdto.setMaterial(taskdto.getMaterial()); - instdto.setQuantity(taskdto.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by(SecurityUtils.getCurrentNickName()); - 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.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - try { - instructionService.create(instdto); - } catch (Exception e) { - e.printStackTrace(); - log.error("指令创建失败!", e.getMessage()); - return false; - } - //创建指令后修改任务状态 - taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskserver.update(taskdto); - requireSucess = true; - String next_addr = nextdevice.getExtraValue().get("address").toString(); - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_target"); - map.put("value", next_addr); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", instdto.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "1"); - list.add(map3); - this.writing(list); - requireSucess = true; - while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , instdto.getInstruction_code())) { - this.writing(list); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + inst.getInstruction_code() + "再次下发电气信号") - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (ObjectUtil.isEmpty(taskserver.findByCode(taskdto.getTask_code()))) { - requireSucess = false; - return false; - } - } - } else { - //如果不存在则直接找对应指令 - Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); - if (ObjectUtil.isEmpty(inst)) { - return false; - } - - Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code()); - String next_addr = nextdevice.getExtraValue().get("address").toString(); - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_target"); - map.put("value", next_addr); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", inst.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "1"); - list.add(map3); - this.writing(list); - requireSucess = true; - while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , inst.getInstruction_code())) { - this.writing(list); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + inst.getInstruction_code() + "再次下发电气信号") - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (ObjectUtil.isEmpty(instructionService.findByDeviceCodeFromCache(this.device_code))) { - requireSucess = false; - return false; - } - } - } - return true; - } - } - - /** - * 更新指令状态 - */ - public synchronized void update_instruction_status() throws Exception { - if (null != inst) { - inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code(); - vehicle_code2 = inst.getVehicle_code2(); - } - Date date = new Date(); - if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); - - } else { - this.instruction_update_time = date; - inst = checkInst(); - if (inst != null) { - inst_message = "当前指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); - task_code = inst.getTask_code(); - if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status("1"); - inst.setExecute_device_code(this.device_code); - instructionService.update(inst); - logServer.deviceExecuteLog(device_code, "", "", "纸箱入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task + ",载具号:" + inst.getVehicle_code()); - } - if (StrUtil.equals(inst.getInstruction_status(), "1") || StrUtil.equals(inst.getInstruction_status(), "0")) { - if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - inst.setExecute_device_code(this.device_code); - if (mode == 2) { - finish_instruction(); - } - logServer.deviceExecuteLog(device_code, "", "", "纸箱入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task + ",载具号:" + inst.getVehicle_code()); - } else { - - } - } - } else { -// message = "输送线任务反馈状态,查询不到指令号:" + task +"指令已完成"; - inst_message = null; - } - - } - } - - public Instruction checkInst() { - if (ObjectUtil.isNotEmpty(this.inst)) { - if (this.task > 0) { - if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { - return this.inst; - } else { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - return inst; - } - } - } else { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - return inst; - } - return null; - } -} 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/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/ItemProtocol.java deleted file mode 100644 index 2656c6e..0000000 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/ItemProtocol.java +++ /dev/null @@ -1,257 +0,0 @@ -package org.nl.acs.device_driver.one_conveyor.finished_product_out_with_bind_lable_conveyor; - -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -@Data -public class ItemProtocol { - - /** - * 心跳 - */ - public static String item_heartbeat = "heartbeat"; - /** - * 工作模式 - */ - public static String item_mode = "mode"; - /** - * 光电信号 - */ - public static String item_move = "move"; - /** - * 托盘方向 - */ - public static String item_container_direction = "container_direction"; - - /** - * 载具类型 - */ - public static String item_container_type = "container_type"; - - /** - * 物料类型 - */ - public static String item_material_barcode = "material_barcode"; - - /** - * 报警 - */ - public static String item_error = "error"; - /** - * 任务号 - */ - public static String item_task = "task"; - - - /** - * 动作信号 - */ - public static String item_action = "action"; - - /** - * 下发命令 - */ - public static String item_to_command = "to_command"; - /** - * 下发目标站 - */ - public static String item_to_target = "to_target"; - /** - * 下发托盘类型 - */ - public static String item_to_container_type = "to_container_type"; - /** - * 下发任务号 - */ - public static String item_to_task = "to_task"; - - /** - * 下发是否捆轧 - */ - public static String item_to_is_binding = "to_is_binding"; - - /** - * 下发是否贴标 - */ - public static String item_to_is_labeling = "to_is_labeling"; - - - /** - * 下发贴标数量 - */ - public static String item_to_print_qty = "to_print_qty"; - - /** - * 下发贴标模板 - */ - public static String item_to_labeling_template = "to_labeling_template"; - - - /** - * 下发使用打印机 - */ - public static String item_to_print_device = "to_print_device"; - - /** - * 下发捆轧模板 - */ - public static String item_to_binding_template = "to_binding_template"; - - /** - * 下发捆扎次数 - */ - public static String item_to_binding_times = "to_binding_times"; - - /** - * 下发木箱规格 - */ - public static String item_to_case = "to_case"; - - - - /** - *木箱长度 - */ - public static String item_to_length = "to_length"; - /** - *木箱宽度 - */ - public static String item_to_weight = "to_width"; - /** - *木箱高度 - */ - public static String item_to_height = "to_height"; - - - - private FinishedProductOutBindLableDeviceDriver driver; - - public int getContainer_type() { - return this.getOpcIntegerValue(item_container_type); - } - - - public ItemProtocol(FinishedProductOutBindLableDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getMove() { - return this.getOpcIntegerValue(item_move); - } - - public int getContainer_direction() { - return this.getOpcIntegerValue(item_container_direction); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_target() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getTo_task() { - return this.getOpcIntegerValue(item_to_task); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - - - Boolean isonline; - - public String getMaterialBarCode() { - return this.getOpcStringValue(item_material_barcode); - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public String getOpcStringValue(String protocol) { - String value = this.driver.getStringValue(protocol); - if (StrUtil.isEmpty(value)) { - - } else { - return value; - } - return ""; - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作模式", "DB600.B2")); - list.add(new ItemDto(item_move, "光电信号", "DB600.B3")); - list.add(new ItemDto(item_container_direction, "托盘方向", "DB600.B4")); - list.add(new ItemDto(item_action, "动作信号", "DB600.B5")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_container_type, "托盘类型", "DB101.B7")); - list.add(new ItemDto(item_task, "任务号", "DB600.D8")); - list.add(new ItemDto(item_material_barcode, "物料条码", "DB81.STRING14.50")); - - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "DB601.W2")); - list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W4")); - list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB601.W6")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB601.D8")); - list.add(new ItemDto(item_to_is_binding, "下发是否捆轧", "DB601.D10")); - list.add(new ItemDto(item_to_is_labeling, "下发是否贴标", "DB601.D12")); - list.add(new ItemDto(item_to_print_qty, "下发贴标数量", "DB601.D14")); - list.add(new ItemDto(item_to_labeling_template, "下发贴标模板", "DB601.D16")); - list.add(new ItemDto(item_to_print_device, "下发使用打印机", "DB601.D18")); - list.add(new ItemDto(item_to_binding_template, "下发捆轧模板", "DB601.D20")); - list.add(new ItemDto(item_to_binding_times, "下发捆扎次数", "DB601.D22")); - list.add(new ItemDto(item_to_length, "木箱长度", "DB601.W24")); - list.add(new ItemDto(item_to_weight, "木箱宽度", "DB601.W26")); - list.add(new ItemDto(item_to_height, "木箱高度", "DB601.W28")); - list.add(new ItemDto(item_to_case, "下发木箱规格", "DB601.W30")); - return list; - } - - @Override - public String toString() { - return ""; - } - -} - diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java deleted file mode 100644 index 0dd048c..0000000 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java +++ /dev/null @@ -1,806 +0,0 @@ -package org.nl.acs.device_driver.one_conveyor.fold_disc_site; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; -import org.nl.acs.common.base.CommonFinalParam; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device.service.DeviceExtraService; -import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.FeedLmsRealFailed; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.enums.StorageTypeEnum; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.history.ErrorUtil; -import org.nl.acs.history.service.DeviceErrorLogService; -import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; -import org.nl.acs.instruction.domain.Instruction; -import org.nl.acs.instruction.enums.InstructionStatusEnum; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.log.service.DeviceExecuteLogService; -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.route.service.dto.RouteLineDto; -import org.nl.acs.route.service.impl.RouteLineServiceImpl; -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.utils.SecurityUtils; -import org.nl.config.SpringContextHolder; -import org.nl.config.language.LangProcess; -import org.nl.config.lucene.service.LuceneExecuteLogService; -import org.nl.config.lucene.service.dto.LuceneLogDto; -import org.springframework.beans.factory.annotation.Autowired; - -import java.time.LocalDateTime; -import java.util.*; - -/** - * 拆叠盘机 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); - @Autowired - DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); - @Autowired - DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); - - @Autowired - LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); - - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - - //工作模式 - 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_task = 0; - int last_to_task = 0; - - int to_container_type = 0; - int last_to_container_type = 0; - - //托盘类型 - int container_type = 0; - int last_container_type = 0; - - //数量 - int qty = 0; - int last_qty = 0; - - //托盘方向 - int carrier_direction = 0; - int last_carrier_direction = 0; - - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - private Date instruction_update_time = new Date(); - private int instruction_update_time_out = 1000; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date require_apply_strangulation_time = new Date(); - - private int instruction_require_time_out = 3000; - //行架机械手申请任务成功标识 - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - private String error_type = "hxhj_error_type"; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String device_code; - - //托盘条码 - String barcode = null; - String last_barcode = null; - - //当前指令 - Instruction inst = null; - - //0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 - int now_steps_type = 0; - String notCreateTaskMessage = ""; - String notCreateInstMessage = ""; - String feedMessage = ""; - String vehicle_code; - String inst_message; - String task_code = null; - - - List getDeviceCodeList = null; - - List putDeviceCodeList = null; - - - @Override - public Device getDevice() { - return this.device; - } - - @Override - public void execute() { - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - move = this.itemProtocol.getMove(); - action = this.itemProtocol.getAction(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - heartbeat = this.itemProtocol.getHeartbeat(); - to_command = this.itemProtocol.getTo_command(); - to_target = this.itemProtocol.getTo_target(); - to_task = this.itemProtocol.getTo_task(); - qty = this.itemProtocol.getQty(); - to_container_type = this.itemProtocol.getTo_container_type(); - container_type = this.itemProtocol.getContainer_type(); - carrier_direction = this.itemProtocol.getCarrier_direction(); - if (mode != last_mode) { - requireSucess = false; - } - // 更新指令状态 - if (move != 0 && task > 0) { - update_instruction_status(); - } - if (move != last_move && move == 0 && last_move == 1 && mode > 0) { - requireSucess = false; - clearWrite(); - } - - - //托盘去扫码位 - if (mode == 4) { - List list1 = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", 0); - list1.add(map); - this.writing(list1); - } - - if (mode == 0) { - this.setIsonline(false); - message = "脱机"; - - //有报警 - } else if (error != 0) { - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - - //申请空托盘入库 - if (mode == 9 && move == 1 && !requireSucess) { - if (container_type == 0) { - message = "托盘类型为空"; - } else { - applyEmptyTask(StorageTypeEnum.DISKS_IN.getType(), mode); - } - } - - - //申请空托盘出库 - if (mode == 8 && !requireSucess) { - if (container_type == 0) { - message = "托盘类型为空"; - } else { - applyEmptyTask(StorageTypeEnum.DISKS_OUT.getType(), mode); - } - - } - - - //碟盘位申请任务 - if (mode == 2 && move == 1 && !requireSucess) { - boolean res = instruction_require(); - if (res) { - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - feedMessage = ""; - } - } else { - if (mode == 2) { - //if (!requireSucess) { - String remark = ""; - ; - if (mode != 2) { - remark = "universal_remark2"; - } - if (move != 0) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = LangProcess.msg("universal_remark4"); - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = LangProcess.msg("universal_remark5"); - } - this.setNotCreateTaskMessage(remark); - //} - } - } - - } - - } catch (Exception var17) { - this.iserror = true; - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(this.device_code + "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null") - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - message = "读取信号值时出现异常"; - var17.printStackTrace(); - - } - - - - 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_qty = qty; - last_container_type = container_type; - last_carrier_direction = carrier_direction; - } - - private void clearWrite() { - - List list = new ArrayList<>(); - Map map = new HashMap<>(); - map.put("code", "to_target"); - map.put("value", "0"); - list.add(map); - Map map2 = new HashMap<>(); - map2.put("code", "to_task"); - map2.put("value", "0"); - list.add(map2); - Map map4 = new HashMap<>(); - map4.put("code", "to_container_type"); - map4.put("value", "0"); - list.add(map4); - - this.writing(list); - message = null; - vehicle_code = null; - inst_message = null; - } - - - /** - * 请求指令 - */ - public synchronized boolean instruction_require() { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_require_time = date; - //判断是否存在起点相同 任务状态就绪的任务 - TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); - if (!ObjectUtil.isEmpty(taskdto)) { - //需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建 - Instruction inst = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()); - if (ObjectUtil.isNotEmpty(inst)) { - List list = new ArrayList(); - Map map2 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", inst.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "1"); - list.add(map3); - this.writing(list); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , inst.getInstruction_code())) { - this.writing(list); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + "电气的指令号:" + this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() + "与系统下发的指令:+" + inst.getInstruction_code() + "不一致,再次下发电气信号") - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - if (ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))) { - requireSucess = false; - return false; - } - } - requireSucess = true; - return true; - } - String taskid = taskdto.getTask_id(); - String taskcode = taskdto.getTask_code(); - String vehiclecode = taskdto.getVehicle_code(); - String priority = taskdto.getPriority(); - String start_point_code = taskdto.getStart_point_code(); - String start_device_code = taskdto.getStart_device_code(); - String route_plan_code = taskdto.getRoute_plan_code(); - String next_device_code = ""; - - - - /** - * 开始平均分配 - */ - String this_coevice_code = taskserver.queryAssignedByDevice(device_code, taskdto.getNext_device_code()); - if (StrUtil.isEmpty(this_coevice_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, taskdto.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - - List pathlist = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 1; - break; - } - } - next_device_code = pathlist.get(index); - } else { - next_device_code = this_coevice_code; - } - //校验路由关系 - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - if (ObjectUtils.isEmpty(shortPathsList)) { - throw new RuntimeException("路由不通!"); - } - //判断有没有DDJ对接位出入库的指令 - List byCodeAndExcute = instructionService.findByCodeAndExcute(next_device_code); - if (CollUtil.isNotEmpty(byCodeAndExcute)){ - this.message="有DDJ对接位出入库的指令"; - requireSucess = false; - return true; - } - //关联站点判断 - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - BeltConveyorDeviceDriver beltConveyorDeviceDriver; - if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver(); - //判断对接位和关联站点光电信号 - getDeviceCodeList = beltConveyorDeviceDriver.getExtraDeviceCodes("link_device_code"); - if (CollUtil.isNotEmpty(getDeviceCodeList)) { - String linkDeviceCode = getDeviceCodeList.get(0); - Device linkDevice = deviceAppService.findDeviceByCode(linkDeviceCode); - BeltConveyorDeviceDriver linkDeviceDriver; - if (linkDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - linkDeviceDriver = (BeltConveyorDeviceDriver) linkDevice.getDeviceDriver(); - if ((beltConveyorDeviceDriver.getMode() == 0 || beltConveyorDeviceDriver.getMove() == 1) || (linkDeviceDriver.getMode() == 0 || linkDeviceDriver.getMove() == 1)) { - this.message = "DDJ对接位或关联输送线存在正在移动的货物或者未联机"; - requireSucess = false; - return true; - } - } - - } - } - String next_point_code; - if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) { - next_point_code = taskdto.getTo_x() + "-" + taskdto.getTo_y() + "-" + taskdto.getTo_z(); - } else { - next_point_code = next_device_code; - } - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(taskdto.getRemark()); - instdto.setMaterial(taskdto.getMaterial()); - instdto.setQuantity(taskdto.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by(SecurityUtils.getCurrentNickName()); - 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.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - try { - instructionService.create(instdto); - } catch (Exception e) { - e.printStackTrace(); - log.error("指令创建失败!", e.getMessage()); - return false; - } - //创建指令后修改任务状态 - taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskserver.update(taskdto); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_target"); - map.put("value", next_addr); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", instdto.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "1"); - list.add(map3); - this.writing(list); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , instdto.getInstruction_code())) { - this.writing(list); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + instdto.getInstruction_code() + "再次下发电气信号") - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - - if (ObjectUtil.isEmpty(taskserver.findByCode(taskdto.getTask_code()))) { - requireSucess = false; - return false; - } - } - requireSucess = true; - } else { - //如果不存在则直接找对应指令 - Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); - if (ObjectUtil.isEmpty(inst)) { - return false; - } - - Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code()); - String next_addr = nextdevice.getExtraValue().get("address").toString(); - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_target"); - map.put("value", next_addr); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", inst.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "1"); - list.add(map3); - this.writing(list); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , inst.getInstruction_code())) { - this.writing(list); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + inst.getInstruction_code() + "再次下发电气信号") - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - if (ObjectUtil.isEmpty(instructionService.findByDeviceCodeFromCache(this.device_code))) { - requireSucess = false; - return false; - } - } - requireSucess = true; - } - return true; - } - } - - public void writing(List list) { - - Map itemMap = new HashMap(); - for (int i = 0; i < list.size(); i++) { - Object ob = list.get(i); - JSONObject json = (JSONObject) JSONObject.toJSON(ob); - if (!StrUtil.isEmpty(json.getString("value"))) { - String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + json.getString("code"); - itemMap.put(to_param, json.getString("value")); - } - } - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("下发多个电气信号" + itemMap) - .build(); - logDto.setLog_level(3); - luceneExecuteLogService.deviceExecuteLog(logDto); - logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); - try { - this.checkcontrol(itemMap); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - private void applyEmptyTask(String type, int mode) { - Date date = new Date(); - if (date.getTime() - this.require_apply_strangulation_time.getTime() - < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - try { - JSONObject param = new JSONObject(); - param.put("device_code", device_code); - param.put("container_type", container_type); - param.put("type", type); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("申请空托盘出入库,参数:" + param) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - HttpResponse httpResponse = acsToWmsService.applyTwo(param); - JSONObject jsonObject = null; - if(ObjectUtil.isNotEmpty(httpResponse)){ - String body = httpResponse.body(); - jsonObject = JSONObject.parseObject(body); - } - message = "申请空托盘出入库,参数,接口返回:" + jsonObject; - LuceneLogDto logDto3 = LuceneLogDto.builder() - .device_code(device_code) - .content("测试申请空托盘出入库,参数,接口返回:" + jsonObject) - .build(); - logDto3.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto3); - if (ObjectUtil.isNotNull(jsonObject) && jsonObject.getInteger("status") == 200) { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请空托盘出入库,参数,接口返回:" + jsonObject) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - List list1 = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", mode); - list1.add(map); - this.writing(list1); - this.requireSucess = true; - } else { - this.iserror = true; - message = "申请空托盘出入库报错,接口返回:" + jsonObject; - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请空托盘出入库,返回参数:" + jsonObject) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String move = ""; - String action = ""; - String walk_y = ""; - if (this.getMode() == 0) { - mode = LangProcess.msg("universal_off-line"); - } else if (this.getMode() == 1) { - mode = LangProcess.msg("universal_stand-alone"); - } else if (this.getMode() == 2) { - mode = LangProcess.msg("universal_standby"); - } else if (this.getMode() == 3) { - mode = LangProcess.msg("universal_operation"); - } else if (this.getMode() == 9) { - mode = LangProcess.msg("one_mode2"); - } else if (this.getMode() == 8) { - mode = LangProcess.msg("one_mode4"); - } - - - if (this.getMove() == 0) { - move = LangProcess.msg("universal_no"); - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = LangProcess.msg("universal_yes"); - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = LangProcess.msg("universal_two_yes"); - jo.put("hasGoods", true); - } - - - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = "1"; - } - jo.put("requireSucess", requireSucess); - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("action", action); - jo.put("task", task); - jo.put("isOnline", this.getIsonline()); - jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError()))); - jo.put("isError", this.getIserror()); - jo.put("message", message); - jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); - jo.put("feedMessage", LangProcess.msg(feedMessage)); - jo.put("inst_message", this.inst_message); - jo.put("driver_type", "siemens_conveyor"); - jo.put("is_click", true); - 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, "1")) { - this.requireSucess = true; - } - } - - - /** - * 更新指令状态 - */ - public synchronized void update_instruction_status() throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); - - } else { - this.instruction_update_time = date; - inst = checkInst(); - if (inst != null) { - inst_message = "当前指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); - vehicle_code = inst.getVehicle_code(); - task_code = inst.getTask_code(); - if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - inst.setExecute_device_code(this.device_code); - instructionService.update(inst); - logServer.deviceExecuteLog(device_code, "", "", "纸箱入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task + ",载具号:" + inst.getVehicle_code()); - } - if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex()) || StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { - if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - inst.setExecute_device_code(this.device_code); - finish_instruction(); - logServer.deviceExecuteLog(device_code, "", "", "纸箱入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task + ",载具号:" + inst.getVehicle_code()); - } else { - - } - } - } else { -// message = "输送线任务反馈状态,查询不到指令号:" + task +"指令已完成"; - inst_message = null; - } - - } - } - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - @Override - public JSONObject feedLmsRealFailedInfo() { - JSONObject jo = new JSONObject(); - jo.put("device_code", this.getDevice().getDevice_code()); - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("fault_code", String.valueOf(error)); - jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); - jo.put("fault_type", error_type); - return jo; - } - - - public Instruction checkInst() { - if (ObjectUtil.isNotEmpty(this.inst)) { - if (this.task > 0) { - if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { - return this.inst; - } else { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - return inst; - } - } - } else { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - return inst; - } - return null; - } -} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/ItemProtocol.java deleted file mode 100644 index 79e29d7..0000000 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/ItemProtocol.java +++ /dev/null @@ -1,156 +0,0 @@ -package org.nl.acs.device_driver.one_conveyor.fold_disc_site; - -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -@Data -public class ItemProtocol { - //心跳 - public static String item_heartbeat = "heartbeat"; - //工作模式 - public static String item_mode = "mode"; - //光电信号 - public static String item_move = "move"; - //动作信号 - public static String item_action = "action"; - //数量 - public static String item_qty = "qty"; - //任务号 - public static String item_task = "task"; - //报警 - public static String item_error = "error"; - //托盘类型 - public static String item_container_type="container_type"; - //托盘方向 - public static String item_container_direction="container_direction"; - - //下发命令 - public static String item_to_command = "to_command"; - //下发目标站 - public static String item_to_target = "to_target"; - //下发任务号 - public static String item_to_task = "to_task"; - //下发托盘类型 - public static String item_to_container_type = "to_container_type"; - - - - private FoldDiscSiteDeviceDriver driver; - - - - public ItemProtocol(FoldDiscSiteDeviceDriver driver){ - this.driver=driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getMove() { - return this.getOpcIntegerValue(item_move); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getQty(){ - return this.getOpcIntegerValue(item_qty); - } - - public int getCarrier_direction(){ - return this.getOpcIntegerValue(item_container_direction); - } - - public int getTo_task() { - return this.getOpcIntegerValue(item_to_task); - } - - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_target() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getContainer_type(){ - return this.getOpcIntegerValue(item_container_type); - } - - public int getTo_container_type(){ - return this.getOpcIntegerValue(item_to_container_type); - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - } - - public String getOpcStringValue(String protocol) { - String value = this.driver.getStringValue(protocol); - if (StrUtil.isBlank(value)) { - //throw new BusinessException("{} : {}", new Object[]{protocol, DeviceErrorProtocol.getMessage(10000)}); - - } else { - return value; - } - return ""; - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList<>(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0")); - list.add(new ItemDto(item_mode, "工作模式", "DB1.B1")); - list.add(new ItemDto(item_move, "光电信号", "DB1.B2")); - list.add(new ItemDto(item_action, "动作信号", "DB1.B3")); - list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); - list.add(new ItemDto(item_task, "任务号", "DB1.D6")); - list.add(new ItemDto(item_container_type, "托盘类型", "DB1.B7")); - list.add(new ItemDto(item_qty, "数量", "DB1.B8")); - - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList<>(); - list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); - list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); - list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB2.W8")); - return list; - } - - @Override - public String toString() { - return ""; - } -} 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 deleted file mode 100644 index bbe2ed0..0000000 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java +++ /dev/null @@ -1,1328 +0,0 @@ -package org.nl.acs.device_driver.one_conveyor.scanner_weight_conveyor; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; -import org.nl.acs.AcsConfig; -import org.nl.acs.common.base.CommonFinalParam; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device.enums.DeviceType; -import org.nl.acs.device.service.DeviceExtraService; -import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.FeedLmsRealFailed; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.device_driver.led.led_screen.LedScreenDeviceDriver; -import org.nl.acs.device_driver.one_manipulator.box_package_manipulator.InteractionJsonDTO; -import org.nl.acs.device_driver.stacker.standard_stacker.StandardStackerDeviceDriver; -import org.nl.acs.device_driver.two_conveyor.manipulator_agv_station.ManipulatorAgvStationDeviceDriver; -import org.nl.acs.enums.StorageTypeEnum; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.history.ErrorUtil; -import org.nl.acs.history.service.DeviceErrorLogService; -import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; -import org.nl.acs.instruction.domain.Instruction; -import org.nl.acs.instruction.enums.InstructionStatusEnum; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.log.service.DeviceExecuteLogService; -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.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; -import org.nl.acs.taskscreen.service.TaskScreenService; -import org.nl.acs.utils.DeviceErrorUtil; -import org.nl.common.exception.BadRequestException; -import org.nl.common.utils.SecurityUtils; -import org.nl.config.SpringContextHolder; -import org.nl.config.language.LangProcess; -import org.nl.config.lucene.service.LuceneExecuteLogService; -import org.nl.config.lucene.service.dto.LuceneLogDto; -import org.nl.system.service.param.ISysParamService; -import org.springframework.beans.factory.annotation.Autowired; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.time.LocalDateTime; -import java.util.*; - -/** - * 输送线工位-带扫码称重 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); - - DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); - - DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); - - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - - LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class); - - ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); - - TaskScreenService taskScreenService = SpringContextHolder.getBean(TaskScreenService.class); - //工作模式 - 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; - String to_command = null; - String last_to_command = null; - - String to_target = null; - String last_to_target = null; - - String to_task = null; - String last_to_task = null; - - String to_container_type = null; - String last_to_container_type = null; - - String to_height_level = null; - String last_to_height_level = null; - - //托盘类型 - int container_type = 0; - int last_container_type = 0; - - - //行架任务号 - int hj_task = 0; - int last_hj_task = 0; - - //重量 - Float weight = 0.0F; - Float last_weight = 0.0F; - - //托盘条码 - String barcode = null; - String last_barcode = null; - - - //木箱条码 - String material_barcode = null; - String last_material_barcode = null; - - String hand_barcode = null; - - String hand_material_barcode = null; - - //高度 - int height = 0; - int last_height = 0; - - //托盘方向 - int carrier_direction = 0; - int last_carrier_direction = 0; - String vehicle_code2; - - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - private Date instruction_update_time = new Date(); - private Date require_apply_strangulation_time = new Date(); - //木箱入库申请时间 - private Date require_apply_mxrk_time = new Date(); - //托盘入库申请时间 - private Date require_apply_tprk_time = new Date(); - //子卷入库申请时间 - private Date require_apply_zjrk_time = new Date(); - //退货入库申请时间 - private Date require_apply_thrk_time = new Date(); - private int instruction_update_time_out = 1000; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - - private int instruction_require_time_out = 3000; - private int require_apply_mxrk_time_out = 4000; - private int require_apply_tprk_time_out = 4000; - private int require_apply_zjrk_time_out = 4000; - private int require_apply_thrk_time_out = 4000; - //行架机械手申请任务成功标识 - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - private String error_type = "hxhj_error_type"; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String device_code; - - //当前指令 - Instruction inst = null; - /** - * led点阵屏信息 - */ - JSONObject led_message = null; - - //0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 - int now_steps_type = 0; - String notCreateTaskMessage = ""; - String notCreateInstMessage = ""; - String feedMessage = ""; - String inst_message; - String task_code = null; - String vehicle_code; - - - List getDeviceCodeList = null; - - List putDeviceCodeList = null; - - - @Override - public Device getDevice() { - return this.device; - } - - @Override - public void execute() { - - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - move = this.itemProtocol.getMove(); - action = this.itemProtocol.getAction(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - heartbeat = this.itemProtocol.getHeartbeat(); - to_command = this.itemProtocol.getTo_command(); - to_target = this.itemProtocol.getTo_target(); - to_task = this.itemProtocol.getTo_task(); - to_container_type = this.itemProtocol.getTo_container_type(); - container_type = this.itemProtocol.getContainer_type(); - carrier_direction = this.itemProtocol.getContainer_direction(); - weight = this.itemProtocol.getWeight(); - barcode = this.itemProtocol.getBarcode(); - material_barcode = this.itemProtocol.getMaterialBarcode(); - to_height_level = this.itemProtocol.getTo_height_level(); - } catch (Exception e) { - this.iserror = true; - String extracted = DeviceErrorUtil.extracted(e); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(this.device_code + extracted + ",读取信号异常:" + e.getMessage()) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - e.printStackTrace(); - } - - try { - if (mode != last_mode) { - JSONObject param = new JSONObject(); - param.put("device_code", this.device_code); - param.put("mode", Math.min(mode, 3)); - param.put("device_name", this.getDevice().getDevice_name()); - param.put("device_type", CommonFinalParam.ONE); - requireSucess = false; - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记:" + requireSucess); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - - - if (move != last_move && move == 0 && last_move == 1 && mode > 0) { - requireSucess = false; - clearWrite(); - } - - if (move != 0 && task > 0) { - update_instruction_status(); - } - - if (mode == 0) { - this.setIsonline(false); - //有报警 - } else if (error != 0) { - this.setIserror(true); - message = "有报警"; - //申请异常位任务 - applyErrorTask(); - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - //木箱入库申请入库任务 - if (mode == 6 && !requireSucess) { - Date date = new Date(); - if (date.getTime() - this.require_apply_mxrk_time.getTime() - < (long) this.require_apply_mxrk_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.require_apply_mxrk_time_out); - return; - } else { - this.require_apply_mxrk_time = date; - if (StrUtil.isNotEmpty(hand_barcode) && StrUtil.isNotEmpty(hand_material_barcode)) { - applyInByHand(StorageTypeEnum.BOX_IN.getType(), mode); - } else if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) { - message = "托盘条码为空、或者子卷码为空"; - } else { - applyIn(StorageTypeEnum.BOX_IN.getType(), mode); - } - } - - } - - //子卷入库申请入库任务 - if (mode == 7 && move == 1 && !requireSucess) { - Date date = new Date(); - if (date.getTime() - this.require_apply_zjrk_time.getTime() - < (long) this.require_apply_zjrk_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.require_apply_zjrk_time_out); - return; - } else { - this.require_apply_zjrk_time = date; - if (StrUtil.isNotEmpty(hand_barcode) && StrUtil.isNotEmpty(hand_material_barcode)) { - applyInByHand(StorageTypeEnum.STORAGE.getType(), mode); - } else if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) { - message = "托盘条码为空、或者子卷码为空"; - } else { - applyIn(StorageTypeEnum.STORAGE.getType(), mode); - } - } - - } - - - //申请空托盘入库 - if (mode == 9 && move == 1 && !requireSucess) { - if (container_type == 0 || StrUtil.isEmpty(barcode)) { - message = "托盘类型为空"; - } else { - applyEmptyTask(StorageTypeEnum.DISKS_IN.getType(), mode); - } - } - - //申请退货入库 - if (mode == 18 && move == 1 && !requireSucess) { - if (StrUtil.isNotEmpty(hand_barcode) && StrUtil.isNotEmpty(hand_material_barcode)) { - applyBoxReturnTask(StorageTypeEnum.BOX_RETURN.getType(), mode); - } else if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) { - message = "托盘条码为空或者木箱号为空"; - } else { - applyBoxReturnTask(StorageTypeEnum.BOX_RETURN.getType(), mode); - } - - } - //申请高度 - if (mode == 23 && !requireSucess) { - if (StrUtil.isNotEmpty(hand_barcode) && StrUtil.isNotEmpty(hand_material_barcode)) { - applyErrorHeight(); - } else if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) { - message = "托盘条码为空或者木箱号为空"; - } else { - applyErrorHeight(); - } - - } - - //申请入库指令、异常位指令 - if (mode == 2 && move == 1 && !requireSucess) { - boolean res = instruction_require(); - if (res) { - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - feedMessage = ""; - } - } else { - String remark = ""; - ; - if (mode != 2) { - remark = "universal_remark2"; - } - if (move != 1) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = "universal_remark4"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = "universal_remark5"; - } - this.setNotCreateInstMessage(remark); - //} - } - - } - } catch (Exception e) { - this.iserror = true; - log.error("空指针:{}", e); - String extracted = DeviceErrorUtil.extracted(e); - if (e instanceof NullPointerException) { - message += " - 空指针异常"; - // 记录详细的堆栈跟踪信息 - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - e.printStackTrace(pw); - String stackTrace = sw.toString(); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(this.device_code + extracted + ",报错信息:" + e.getMessage() + ",堆栈跟踪:" + stackTrace) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - } else { - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(this.device_code + extracted + ",报错信息:" + e.getMessage()) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - e.printStackTrace(); - } - } - - - 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_hj_task = hj_task; - last_container_type = container_type; - last_carrier_direction = carrier_direction; - last_height = height; - last_weight = weight; - last_barcode = barcode; - } - - private void applyErrorHeight() { - Date date = new Date(); - if (date.getTime() - this.require_apply_strangulation_time.getTime() - < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_apply_strangulation_time = date; - try { - JSONObject param = new JSONObject(); - param.put("device_code", device_code); - if (StrUtil.isNotEmpty(hand_barcode)) { - param.put("vehicle_code", hand_barcode); - } - if (StrUtil.isNotEmpty(barcode) && (barcode.startsWith("A") || barcode.startsWith("B"))) { - param.put("vehicle_code", barcode); - } - if (StrUtil.isNotEmpty(material_barcode)) { - param.put("material_barcode", material_barcode); - } - if (StrUtil.isNotEmpty(hand_material_barcode)) { - param.put("material_barcode", hand_material_barcode); - } - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("申请高度等级,参数:" + param) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - String response = acsToWmsService.getBoxInfo(param); - JSONObject jo = JSON.parseObject(response); - message = "申请高度等级,返回参数:" + jo; - if (jo.getInteger("status") == 200) { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请高度等级,参数,接口返回:" + jo) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - String heightLevel = jo.getString("heightLevel"); - List list1 = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_height_level"); - map.put("value", heightLevel); - list1.add(map); - this.writing(list1); - List list2 = new ArrayList(); - Map map2 = new HashMap(); - map2.put("code", "to_command"); - map2.put("value", 23); - list2.add(map2); - this.writing(list2); - requireSucess = true; - } else { - this.iserror = true; - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请高度等级,返回参数:" + response) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - message = "申请高度等级报错,返回参数:" + jo; - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - private void applyBoxReturnTask(String type, int mode) { - Date date = new Date(); - if (date.getTime() - this.require_apply_thrk_time.getTime() - < (long) this.require_apply_thrk_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.require_apply_thrk_time_out); - return; - } else { - this.require_apply_thrk_time = date; - try { - JSONObject param = new JSONObject(); - param.put("device_code", device_code); - if (StrUtil.isNotEmpty(hand_barcode)) { - param.put("vehicle_code", hand_barcode); - } - if (StrUtil.isNotEmpty(barcode) && (barcode.startsWith("A") || barcode.startsWith("B"))) { - param.put("vehicle_code", barcode); - } - if (StrUtil.isNotEmpty(material_barcode)) { - param.put("material_barcode", material_barcode); - } - if (StrUtil.isNotEmpty(hand_material_barcode)) { - param.put("material_barcode", hand_material_barcode); - } - param.put("type", type); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("申请退货入库,参数:" + param) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - TaskDto dto = taskserver.findByBarcodeFromCache(barcode); - if (ObjectUtil.isNotEmpty(dto)) { - List list1 = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", mode); - list1.add(map); - this.writing(list1); - this.requireSucess = true; - } else { - HttpResponse httpResponse = acsToWmsService.applyTwo(param); - JSONObject jsonObject = null; - if (ObjectUtil.isNotEmpty(httpResponse)) { - String body = httpResponse.body(); - jsonObject = JSONObject.parseObject(body); - } - message = "申请退货入库,返回参数:" + jsonObject; - if (ObjectUtil.isNotNull(jsonObject) && jsonObject.getInteger("status") == 200) { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请退货入库,参数,接口返回:" + jsonObject) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - List list1 = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", mode); - list1.add(map); - this.writing(list1); - this.requireSucess = true; - } else { - this.iserror = true; - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请退货入库,返回参数:" + jsonObject) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - message = "申请退货入库报错,返回参数:" + jsonObject; - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - public void clearWrite() { - List list = new ArrayList<>(); - Map map = new HashMap<>(); - map.put("code", "to_target"); - map.put("value", "0"); - list.add(map); - Map map2 = new HashMap<>(); - map2.put("code", "to_task"); - map2.put("value", "0"); - list.add(map2); - Map map4 = new HashMap<>(); - map4.put("code", "to_container_type"); - map4.put("value", "0"); - list.add(map4); - - this.writing(list); - message = null; - vehicle_code = null; - hand_barcode = null; - inst_message = null; - - } - - private void applyErrorTask() { - Date date = new Date(); - if (date.getTime() - this.require_apply_strangulation_time.getTime() - < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - try { - JSONObject param = new JSONObject(); - param.put("device_code", device_code); - param.put("vehicle_code", barcode); - param.put("material_barcode", material_barcode); - param.put("type", StorageTypeEnum.ERROR.getType()); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("木箱入库申请异常位任务,参数:" + param) - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto); - HttpResponse response = acsToWmsService.shipDeviceUpdate(param); - if (response == null || response.getStatus() == 200) { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("木箱入库申请异常位任务,接口返回:" + response) - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto2); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - private void applyEmptyTask(String type, int mode) { - Date date = new Date(); - if (date.getTime() - this.require_apply_tprk_time.getTime() - < (long) this.require_apply_tprk_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.require_apply_tprk_time_out); - return; - } else { - this.require_apply_tprk_time = date; - try { - JSONObject param = new JSONObject(); - param.put("device_code", device_code); - param.put("container_type", container_type); - if (StrUtil.isNotEmpty(hand_barcode)) { - param.put("vehicle_code", hand_barcode); - } - if (StrUtil.isNotEmpty(barcode) && (barcode.startsWith("A") || barcode.startsWith("B"))) { - param.put("vehicle_code", barcode); - } - param.put("type", type); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("申请空托盘出入库,参数:" + param) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - HttpResponse httpResponse = acsToWmsService.applyTwo(param); - JSONObject jsonObject = null; - if (ObjectUtil.isNotEmpty(httpResponse)) { - String body = httpResponse.body(); - jsonObject = JSONObject.parseObject(body); - } - message = "申请空托盘出入库,返回参数:" + jsonObject; - if (jsonObject.getInteger("status") == 200) { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请空托盘出入库,参数,接口返回:" + jsonObject) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - List list1 = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", mode); - list1.add(map); - this.writing(list1); - this.requireSucess = true; - } else { - this.iserror = true; - message = "申请空托盘出入库报错,返回参数:" + jsonObject; - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请空托盘出入库,返回参数:" + jsonObject) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - private void applyIn(String type, int mode) { - try { - JSONObject param = new JSONObject(); - param.put("device_code", device_code); - if (StrUtil.isNotEmpty(barcode) && (barcode.startsWith("A") || barcode.startsWith("B"))) { - param.put("vehicle_code", barcode); - } - if (StrUtil.isNotEmpty(material_barcode)) { - param.put("material_barcode", material_barcode); - } - if (mode == 7 && weight != 0) { - param.put("weight", weight); - } - param.put("type", type); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("木箱、子卷入库申请入库任务,参数:" + param) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - HttpResponse httpResponse = acsToWmsService.applyTwo(param); - JSONObject jsonObject = null; - if (ObjectUtil.isNotEmpty(httpResponse)) { - String body = httpResponse.body(); - jsonObject = JSONObject.parseObject(body); - } - log.info("wms反馈结果:{}", jsonObject); - message = "木箱、子卷入库申请入库任务,返回参数:" + jsonObject; - LuceneLogDto logDto3 = LuceneLogDto.builder() - .device_code(device_code) - .content("木箱、子卷入库申请入库任务,参数,接口返回:" + jsonObject) - .build(); - logDto3.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto3); - if (ObjectUtil.isNotNull(jsonObject) && Integer.valueOf(200).equals(jsonObject.getInteger("status"))) { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("木箱、子卷入库申请入库任务,参数,接口返回:" + jsonObject) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - List list1 = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", mode); - list1.add(map); - log.error("下发电气--------:{}", map); - this.writing(list1); - requireSucess = true; - } else { - this.iserror = true; - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("木箱、子卷入库申请入库任务,返回参数:" + jsonObject) - .build(); - logDto2.setLog_level(4); - message = "木箱、子卷入库申请入库任务报错,返回参数:" + jsonObject; - luceneExecuteLogService.deviceExecuteLog(logDto2); - } - } catch (Exception e) { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("木箱、子卷入库申请入库任务,返回参数:" + e.getMessage()) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - } - - } - - private void applyInByHand(String type, int mode) { - try { - JSONObject param = new JSONObject(); - param.put("device_code", device_code); - if (StrUtil.isNotEmpty(hand_barcode)) { - param.put("vehicle_code", hand_barcode); - } - if (StrUtil.isNotEmpty(hand_material_barcode)) { - param.put("material_barcode", hand_material_barcode); - } - if (mode == 7 && weight != 0) { - param.put("weight", weight); - } - param.put("type", type); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("木箱、子卷入库申请入库任务,参数:" + param) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - HttpResponse httpResponse = acsToWmsService.applyTwo(param); - JSONObject jsonObject = null; - if (ObjectUtil.isNotEmpty(httpResponse)) { - String body = httpResponse.body(); - jsonObject = JSONObject.parseObject(body); - } - log.info("wms反馈结果:{}", jsonObject); - message = "木箱、子卷入库申请入库任务,返回参数:" + jsonObject; - LuceneLogDto logDto3 = LuceneLogDto.builder() - .device_code(device_code) - .content("木箱、子卷入库申请入库任务,参数,接口返回:" + jsonObject) - .build(); - logDto3.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto3); - if (ObjectUtil.isNotNull(jsonObject) && Integer.valueOf(200).equals(jsonObject.getInteger("status"))) { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("木箱、子卷入库申请入库任务,参数,接口返回:" + jsonObject) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - List list1 = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", mode); - list1.add(map); - log.error("下发电气--------:{}", map); - this.writing(list1); - requireSucess = true; - } else { - this.iserror = true; - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("木箱、子卷入库申请入库任务,返回参数:" + jsonObject) - .build(); - logDto2.setLog_level(4); - message = "木箱、子卷入库申请入库任务报错,返回参数:" + jsonObject; - luceneExecuteLogService.deviceExecuteLog(logDto2); - } - } catch (Exception e) { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("木箱、子卷入库申请入库任务,返回参数:" + e.getMessage()) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - } - - } - - - /** - * 更新指令状态 - */ - public synchronized void update_instruction_status() throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); - - } else { - this.instruction_update_time = date; - inst = checkInst(); - if (inst != null) { - inst_message = "当前指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); - vehicle_code = inst.getVehicle_code(); - task_code = inst.getTask_code(); - if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status("1"); - inst.setExecute_device_code(this.device_code); - instructionService.update(inst); - logServer.deviceExecuteLog(device_code, "", "", "纸箱入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task + ",载具号:" + inst.getVehicle_code()); - } - if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex()) || StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { - if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - inst.setExecute_device_code(this.device_code); - if (mode == 2) { - finish_instruction(); - } - logServer.deviceExecuteLog(device_code, "", "", "纸箱入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task + ",载具号:" + inst.getVehicle_code()); - } else { - - } - } - } else { -// message = "输送线任务反馈状态,查询不到指令号:" + task +"指令已完成"; - inst_message = null; - } - - } - } - - /** - * 请求指令 - */ - public synchronized boolean instruction_require() { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_require_time = date; - //根据补码查找任务 - if (StrUtil.isNotBlank(hand_barcode)) { - TaskDto taskdto = taskserver.findByVehicleCodeCodeAndReady(hand_barcode); - if (!ObjectUtil.isEmpty(taskdto)) { - if (creatInstruction(taskdto)) return false; - } else { - message = "未找到补码信息相匹配的任务"; - //如果不存在则直接找对应指令直接下发信号 - if (pushPLC()) return false; - - } - } else { - if (StrUtil.isNotBlank(barcode)) { - //根据载具号查找任务 - TaskDto taskdto = taskserver.findByVehicleCodeCodeAndReady(barcode); - if (!ObjectUtil.isEmpty(taskdto)) { - if (creatInstruction(taskdto)) return false; - } else { - message = "未找到载具码信息相匹配的任务"; - //如果不存在则直接找对应指令直接下发信号 - if (pushPLC()) return false; - - } - } - } - return true; - } - } - - private boolean pushPLC() { - Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); - if (ObjectUtil.isEmpty(inst)) { - return true; - } - - Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code()); - String next_addr = nextdevice.getExtraValue().get("address").toString(); - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_target"); - map.put("value", next_addr); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", inst.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "1"); - list.add(map3); - this.writing(list); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , inst.getInstruction_code())) { - this.writing(list); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + "电气的指令号:" + this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() + "与系统下发的指令:+" + inst.getInstruction_code() + "不一致,再次下发电气信号") - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - if (ObjectUtil.isEmpty(instructionService.findByDeviceCodeFromCache(this.device_code))) { - requireSucess = false; - return true; - } - } - requireSucess = true; - return false; - } - - private boolean creatInstruction(TaskDto taskdto) { - String taskid = taskdto.getTask_id(); - String taskcode = taskdto.getTask_code(); - String vehiclecode = taskdto.getVehicle_code(); - String priority = taskdto.getPriority(); - Instruction instdto = new Instruction(); - String interactionJson = taskdto.getInteraction_json(); - InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); - String containerType = ""; - if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { - containerType = interactionJsonDTO.getContainerType(); - } - if (TaskTypeEnum.AGV_Task.getIndex().equals(taskdto.getTask_type())) { - String route_plan_code = taskdto.getRoute_plan_code(); - - List shortPathsList = routeLineService.getShortPathLines(taskdto.getStart_device_code(), taskdto.getNext_device_code(), route_plan_code); - if (CollectionUtil.isEmpty(shortPathsList)) { - return true; - } - RouteLineDto routeLineDto = shortPathsList.get(0); - String path = routeLineDto.getPath(); - String[] str = path.split("->"); - List pathlist = Arrays.asList(str); - Integer start = 0; - String start_device_code = pathlist.get(start); - String next_device_code = pathlist.get(start + 1); - - //判断有无出入库任务是相同路线 - //判断有没有DDJ对接位出入库的指令 - List byCodeAndExcute = instructionService.findByCodeAndExcute(next_device_code); - if (CollUtil.isNotEmpty(byCodeAndExcute)) { - this.message = "有DDJ对接位出入库的指令"; - requireSucess = false; - return true; - } - //关联站点判断 - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - BeltConveyorDeviceDriver beltConveyorDeviceDriver; - if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver(); - //判断对接位和关联站点光电信号 - getDeviceCodeList = beltConveyorDeviceDriver.getExtraDeviceCodes("link_device_code"); - if (CollUtil.isNotEmpty(getDeviceCodeList)) { - String linkDeviceCode = getDeviceCodeList.get(0); - Device linkDevice = deviceAppService.findDeviceByCode(linkDeviceCode); - BeltConveyorDeviceDriver linkDeviceDriver; - if (linkDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - linkDeviceDriver = (BeltConveyorDeviceDriver) linkDevice.getDeviceDriver(); - if ((beltConveyorDeviceDriver.getMode() == 0 || beltConveyorDeviceDriver.getMove() == 1) || (linkDeviceDriver.getMode() == 0 || linkDeviceDriver.getMove() == 1)) { - this.message = "DDJ对接位或关联输送线存在正在移动的货物或者未联机"; - requireSucess = false; - return true; - } - } - - } - } - TaskDto dto = taskserver.findByCodeAndExcute(taskdto.getNext_device_code(), taskdto.getStart_device_code()); - if (ObjectUtil.isNotEmpty(dto)) { - requireSucess = false; - return true; - } - - - packageInstrcutData(instdto, taskdto, taskid, taskcode, vehiclecode, priority, start_device_code, next_device_code, containerType); - } else { - - packageInstrcutData(instdto, taskdto, taskid, taskcode, vehiclecode, priority, taskdto.getStart_device_code(), taskdto.getNext_device_code(), containerType); - } - try { - instructionService.create(instdto); - } catch (Exception e) { - e.printStackTrace(); - log.error("指令创建失败!", e.getMessage()); - return true; - } - Device nextdevice = deviceAppservice.findDeviceByCode(instdto.getNext_device_code()); - BeltConveyorDeviceDriver beltConveyorDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextdevice.getDeviceDriver(); - String ignorePickupCheck = (String) beltConveyorDeviceDriver.getExtraValue().get("ignore_pickup_check"); - if ("false".equals(ignorePickupCheck)) { - if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) { - log.error("输送机,{}未联机或执行中", instdto.getNext_device_code()); - this.setNotCreateInstMessage("universal_notCreateInstMessage4"); - return false; - } - } - } - //创建指令后修改任务状态 - taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskserver.update(taskdto); - String next_addr = nextdevice.getExtraValue().get("address").toString(); - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_target"); - map.put("value", next_addr); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", instdto.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_container_type"); - map3.put("value", containerType); - list.add(map3); - this.writing(list); - List list2 = new ArrayList(); - Map map4 = new HashMap(); - map4.put("code", "to_command"); - map4.put("value", "1"); - list2.add(map4); - this.writing(list2); -// led_message = getLedMessage(instdto); -// List deviceCodes = this.getExtraDeviceCodes("link_device_code"); -// String device = null; -// if (ObjectUtil.isNotEmpty(deviceCodes)) { -// for (String deviceCode : deviceCodes) { -// Device linkDevice = deviceAppService.findDeviceByCode(deviceCode); -// if (ObjectUtil.isEmpty(linkDevice)) { -// throw new BadRequestException("设备:" + device_code + "关联设备->" + deviceCode + "为空!"); -// } -// if (linkDevice.getDeviceDriver() instanceof LedScreenDeviceDriver) { -// device = deviceCode; -// } -// } -// } -// taskScreenService.getLedMessage(device); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , instdto.getInstruction_code())) { - this.writing(list); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + "电气的指令号:" + this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() + "与系统下发的指令:+" + instdto.getInstruction_code() + "不一致,再次下发电气信号") - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - if (ObjectUtil.isEmpty(taskserver.findByCode(taskdto.getTask_code()))) { - requireSucess = false; - return true; - } - } - requireSucess = true; - return false; - } - - /** - * 获取任务信息 - */ - public JSONObject getLedMessage(Instruction instdto) { - JSONObject json = new JSONObject(); - json.put("task_code", instdto.getTask_code()); - json.put("inst_code", instdto.getInstruction_code()); - json.put("start_device_code", instdto.getStart_device_code()); - json.put("next_device_code", instdto.getNext_device_code()); - json.put("material_type", instdto.getMaterial()); - json.put("quantity", instdto.getQuantity()); - json.put("vehicle_code", instdto.getVehicle_code()); - json.put("instruction_status", instdto.getInstruction_status()); - json.put("entry_time", instdto.getCreate_time()); - String acsIp = paramService.findByCode(AcsConfig.ACSIP).getValue(); - json.put("ip", acsIp); - return json; - } - - /** - * 清空任务信息任务信息 - */ - public JSONObject clearMessage() { - JSONObject json = new JSONObject(); - json.put("task_code", "0"); - json.put("inst_code", "0"); - json.put("start_device_code", "0"); - json.put("next_device_code", "0"); - json.put("material_type", "0"); - json.put("quantity", "0"); - json.put("vehicle_code", "0"); - json.put("instruction_status", "0"); - json.put("entry_time", "0"); - json.put("ip", "0"); - return json; - } - - private void packageInstrcutData(Instruction instdto, TaskDto taskdto, String taskid, String taskcode, String vehiclecode, String priority, String startCode, String endCode, String containerType) { - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(taskdto.getRoute_plan_code()); - instdto.setRemark(taskdto.getRemark()); - instdto.setMaterial(taskdto.getMaterial()); - instdto.setQuantity(taskdto.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by(SecurityUtils.getCurrentNickName()); - instdto.setStart_device_code(startCode); - instdto.setNext_device_code(endCode); - instdto.setStart_point_code(startCode); - instdto.setNext_point_code(endCode); - instdto.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(device_code); - instdto.setInstruction_type(taskdto.getTask_type()); - instdto.setVehicle_type(containerType); - - } - - - public void writing(List list) { - - Map itemMap = new HashMap(); - for (int i = 0; i < list.size(); i++) { - Object ob = list.get(i); - JSONObject json = (JSONObject) JSONObject.toJSON(ob); - if (!StrUtil.isEmpty(json.getString("value"))) { - String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + json.getString("code"); - itemMap.put(to_param, json.getString("value")); - } - } - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("下发多个电气信号" + itemMap) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); - try { - this.checkcontrol(itemMap); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String move = ""; - String action = ""; - String walk_y = ""; - if (this.getMode() == 0) { - mode = LangProcess.msg("universal_off-line"); - } else if (this.getMode() == 1) { - mode = LangProcess.msg("universal_stand-alone"); - } else if (this.getMode() == 2) { - mode = LangProcess.msg("universal_standby"); - } else if (this.getMode() == 3) { - mode = LangProcess.msg("universal_operation"); - } else if (this.getMode() == 6) { - mode = LangProcess.msg("one_mode1"); - } - - - if (this.getMove() == 0) { - move = LangProcess.msg("universal_no"); - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = LangProcess.msg("universal_yes"); - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = LangProcess.msg("universal_two_yes"); - jo.put("hasGoods", true); - } - - - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = "1"; - } - jo.put("requireSucess", requireSucess); - - - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("hand_barcode", hand_barcode); - jo.put("barcode", barcode); - jo.put("material_barcode", material_barcode); - jo.put("move", move); - jo.put("action", action); - jo.put("task", task); - jo.put("vehicle_code2", this.vehicle_code2); - jo.put("isOnline", this.getIsonline()); - jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError()))); - jo.put("isError", this.getIserror()); - jo.put("message", message); - jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); - jo.put("feedMessage", LangProcess.msg(feedMessage)); - jo.put("driver_type", "conveyor_with_scanner_weight"); - jo.put("is_click", true); - jo.put("inst_message", this.inst_message); - 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, "1")) { - this.requireSucess = true; - } - String hand_barcode = data.getString("hand_barcode"); - this.setHand_barcode(hand_barcode); - String hand_material_barcode = data.getString("hand_material_barcode"); - this.setHand_material_barcode(hand_material_barcode); - } - - @Override - public JSONObject feedLmsRealFailedInfo() { - JSONObject jo = new JSONObject(); - jo.put("device_code", this.getDevice().getDevice_code()); - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("fault_code", String.valueOf(error)); - jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); - jo.put("fault_type", error_type); - return jo; - } - - - public Instruction checkInst() { - if (ObjectUtil.isNotEmpty(this.inst)) { - if (this.task > 0) { - if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { - return this.inst; - } else { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - return inst; - } - } - } else { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - return inst; - } - return null; - } -} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java deleted file mode 100644 index 4ca9770..0000000 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java +++ /dev/null @@ -1,228 +0,0 @@ -package org.nl.acs.device_driver.one_conveyor.scanner_weight_conveyor; - -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -@Data -public class ItemProtocol { - /** - * 心跳 - */ - public static String item_heartbeat = "heartbeat"; - /** - * 工作模式 - */ - public static String item_mode = "mode"; - /** - * 光电信号 - */ - public static String item_move = "move"; - /** - * 动作信号 - */ - public static String item_action = "action"; - /** - * 报警 - */ - public static String item_error = "error"; - - /** - * 任务号 - */ - public static String item_task = "task"; - - /** - * 载具类型 - */ - public static String item_container_type="container_type"; - /** - * 托盘方向 - */ - public static String item_container_direction="container_direction"; - - - /** - * 托盘条码 - */ - public static String item_barcode = "barcode"; - - /** - * 子卷条码 - */ - public static String item_material_barcode = "material_barcode"; - /** - * 重量 - */ - public static String item_weight = "weight"; - - - /** - * 下发命令 - */ - public static String item_to_command = "to_command"; - /** - * 下发目标站 - */ - public static String item_to_target = "to_target"; - /** - * 下发任务号 - */ - public static String item_to_task = "to_task"; - /** - * 下发托盘类型 - */ - public static String item_to_container_type = "to_container_type"; - - /** - * 下发高度等级 - */ - public static String item_to_height_level = "to_height_level"; - - private ConveyorWithScannerWeightDeviceDriver driver; - - public ItemProtocol(ConveyorWithScannerWeightDeviceDriver driver){ - this.driver=driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getMove() { - return this.getOpcIntegerValue(item_move); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - - - public int getContainer_direction(){ - return this.getOpcIntegerValue(item_container_direction); - } - - - public String getBarcode() { - return this.getOpcStringValue(item_barcode); - } - - public String getMaterialBarcode() { - return this.getOpcStringValue(item_material_barcode); - } - - public Float getWeight(){ - return this.getOpcFloatValue(item_weight); - } - public String getTo_task() { - return this.getOpcStringValue(item_to_task); - } - - public String getTo_command() { - return this.getOpcStringValue(item_to_command); - } - - public String getTo_target() { - return this.getOpcStringValue(item_to_target); - } - - public int getContainer_type(){ - return this.getOpcIntegerValue(item_container_type); - } - - public String getTo_container_type(){ - return this.getOpcStringValue(item_to_container_type); - } - - public String getTo_height_level(){ - return this.getOpcStringValue(item_to_height_level); - } - Boolean isonline; - - - public String getOpcStringValue(String protocol) { - String value = this.driver.getStringValue(protocol); - if (StrUtil.isBlank(value)) { - //throw new BusinessException("{} : {}", new Object[]{protocol, DeviceErrorProtocol.getMessage(10000)}); - - } else { - return value; - } - return ""; - } - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - } - - - public float getOpcFloatValue(String protocol) { - Float value = this.driver.getDoubleValue(protocol); - if (value == null) { - // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList<>(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0")); - list.add(new ItemDto(item_mode, "工作模式", "DB1.B1")); - list.add(new ItemDto(item_move, "光电信号", "DB1.B2")); - list.add(new ItemDto(item_action, "动作信号", "DB1.B3")); - list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); - list.add(new ItemDto(item_task, "任务号", "DB1.D6")); - list.add(new ItemDto(item_container_type, "托盘类型", "DB1.B7")); - list.add(new ItemDto(item_container_direction, "托盘方向", "DB1.B8")); - list.add(new ItemDto(item_weight, "重量", "DB1.B10")); - list.add(new ItemDto(item_barcode, "托盘条码", "DB602.STRING1.50")); - list.add(new ItemDto(item_material_barcode, "子卷条码", "DB601.STRING1.50")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList<>(); - list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); - list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); - list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB2.W8")); - list.add(new ItemDto(item_to_height_level, "下发高度等级", "DB2.W10")); - return list; - } - - @Override - public String toString() { - return ""; - } -} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/ItemProtocol.java deleted file mode 100644 index 32abccf..0000000 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/ItemProtocol.java +++ /dev/null @@ -1,235 +0,0 @@ -package org.nl.acs.device_driver.one_conveyor.un_box_lable_conveyor; - -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -@Data -public class ItemProtocol { - - /** - * 心跳 - */ - public static String item_heartbeat = "heartbeat"; - /** - * 工作模式 - */ - public static String item_mode = "mode"; - /** - * 光电信号 - */ - public static String item_move = "move"; - /** - * 托盘方向 - */ - public static String item_container_direction = "container_direction"; - - /** - * 物料条码 - */ - public static String item_material_barcode = "material_barcode"; - - /** - * 载具类型 - */ - public static String item_container_type = "container_type"; - - /** - * 报警 - */ - public static String item_error = "error"; - /** - * 任务号 - */ - public static String item_task = "task"; - - /** - * 干燥机模板 - */ - public static String item_desiccant = "desiccant"; - - /** - * 动作信号 - */ - public static String item_action = "action"; - - /** - * 下发命令 - */ - public static String item_to_command = "to_command"; - /** - * 下发目标站 - */ - public static String item_to_target = "to_target"; - /** - * 下发托盘类型 - */ - public static String item_to_container_type = "to_container_type"; - /** - * 下发任务号 - */ - public static String item_to_task = "to_task"; - - /** - * 下发贴标数量 - */ - public static String item_to_print_qty = "to_print_qty"; - - - - /** - * 下发使用打印机 - */ - public static String item_to_print_device = "to_print_device"; - - - /** - *木箱长度 - */ - public static String item_to_length = "to_length"; - /** - *木箱宽度 - */ - public static String item_to_width = "to_width"; - /** - *木箱高度 - */ - public static String item_to_height = "to_height"; - - /** - *干燥机模板 - */ - public static String item_to_desiccant = "to_desiccant"; - - /** - *下发捆扎次数 - */ - public static String item_to_binding_times = "to_binding_times"; - - private UnBoxLableConveyorDeviceDriver driver; - - public String getMaterialBarCode() { - return this.getOpcStringValue(item_material_barcode); - } - - public int getContainer_type() { - return this.getOpcIntegerValue(item_container_type); - } - - - public ItemProtocol(UnBoxLableConveyorDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getMove() { - return this.getOpcIntegerValue(item_move); - } - - public int getCarrier_direction() { - return this.getOpcIntegerValue(item_container_direction); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_target() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getTo_task() { - return this.getOpcIntegerValue(item_to_task); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public String getOpcStringValue(String protocol) { - String value = this.driver.getStringValue(protocol); - if (StrUtil.isEmpty(value)) { - - } else { - return value; - } - return ""; - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作模式", "DB600.B2")); - list.add(new ItemDto(item_move, "光电信号", "DB600.B3")); - list.add(new ItemDto(item_container_direction, "托盘方向", "DB600.B4")); - list.add(new ItemDto(item_action, "动作信号", "DB600.B5")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_container_type, "托盘类型", "DB101.B7")); - list.add(new ItemDto(item_task, "任务号", "DB600.D10")); - list.add(new ItemDto(item_desiccant, "干燥机模板", "DB600.D10")); - - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "DB601.W2")); - list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W4")); - list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB601.W6")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB601.D8")); - list.add(new ItemDto(item_to_print_qty, "下发贴标数量", "DB601.D9")); - list.add(new ItemDto(item_to_print_device, "下发贴标数量", "DB601.D10")); - list.add(new ItemDto(item_to_length, "木箱长度", "DB601.W14")); - list.add(new ItemDto(item_to_width, "木箱宽度", "DB601.W16")); - list.add(new ItemDto(item_to_height, "木箱高度", "DB601.W18")); - list.add(new ItemDto(item_to_binding_times, "下发捆扎次数", "DB601.W20")); - list.add(new ItemDto(item_to_desiccant, "干燥机模板", "DB601.W22")); - - - - return list; - } - - @Override - public String toString() { - return ""; - } - -} - 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 deleted file mode 100644 index 340c7b4..0000000 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java +++ /dev/null @@ -1,756 +0,0 @@ -package org.nl.acs.device_driver.one_conveyor.un_box_lable_conveyor; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; -import org.nl.acs.agv.server.NDCAgvService; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.FeedLmsRealFailed; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.history.ErrorUtil; -import org.nl.acs.history.service.DeviceErrorLogService; -import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; -import org.nl.acs.instruction.domain.Instruction; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.log.service.DeviceExecuteLogService; -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.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.common.utils.SecurityUtils; -import org.nl.config.SpringContextHolder; -import org.nl.config.language.LangProcess; -import org.nl.config.lucene.service.LuceneExecuteLogService; -import org.nl.config.lucene.service.dto.LuceneLogDto; -import org.nl.config.thread.ThreadPoolExecutorUtil; -import org.openscada.opc.lib.da.Server; - -import java.util.*; -import java.util.concurrent.ThreadPoolExecutor; - -/** - * 一楼申请开箱位、贴标位 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - - RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class); - - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - - - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - - - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); - - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - - NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class); - - DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - - LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); - - //当前指令 - Instruction inst = null; - - private String error_type = "ssx_error_type"; - - //工作模式 - int mode = 0; - int last_mode = 0; - //光电信号 - int move = 0; - int last_move = 0; - //托盘方向 - int carrier_direction = 0; - int last_carrier_direction = 0; - //报警信号 - int error = 0; - int last_error = 0; - //任务号 - int task = 0; - int last_task = 0; - int agvphase = 0; - String task_code = null; - int to_command = 0; - int last_to_command = 0; - - int to_target = 0; - int last_to_target = 0; - - int to_task = 0; - int last_to_task = 0; - - int to_strap_times = 0; - int last_to_strap_times = 0; - int to_length = 0; - int last_to_length = 0; - int to_weight = 0; - int last_to_weight = 0; - int to_height = 0; - int last_to_height = 0; - - int phase = 0; - int index = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - String hand_barcode = null; - - Integer heartbeat_tag; - private Date instruction_update_time = new Date(); - private int instruction_update_time_out = 500; - - private Date instruction_require_time = new Date(); - private Date require_apply_labeling_time = new Date(); - private Date require_apply_strangulation_time = new Date(); - private Date require_empty_in_time = new Date(); - private Date require_empty_out_time = new Date(); - - private int instruction_require_time_out = 3000; - //行架机械手申请任务成功标识 - boolean requireSucess = false; - boolean requireEmptyInSuccess = false; - boolean requiresShipDeviceUpdate = true; - private int instruction_finished_time_out; - - int branchProtocol = 0; - String inst_message; - String last_inst_message; - int heartbeat = 0; - int last_heartbeat = 0; - //当前指令 - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String device_code; - - String vehicle_code; - String last_vehicle_code; - - String vehicle_code2; - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - move = this.itemProtocol.getMove(); - carrier_direction = this.itemProtocol.getCarrier_direction(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - to_command = this.itemProtocol.getTo_command(); - to_target = this.itemProtocol.getTo_target(); - to_task = this.itemProtocol.getTo_task(); - heartbeat = this.itemProtocol.getHeartbeat(); - if (mode != last_mode) { - - requireSucess = false; - } - if (mode == 0) { - this.setIsonline(false); - message = "脱机"; - - //有报警 - - } else { - this.setIsonline(true); - this.setIserror(false); - if (error != 0) { - this.setIserror(true); - message = "有报警"; - } - inst = checkInst(); - if (inst != null) { - inst_message = "当前指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); - vehicle_code2 = inst.getVehicle_code2(); - } - - //空箱出库开盖位,申请开盖 - if (mode == 15 && move == 1 && task > 0 ) { - Instruction instruction = instructionService.findByCode(String.valueOf(task)); - //不允许开盖,完成出库任务,自动去扫码位 - if (StrUtil.isEmpty(instruction.getVehicle_code())){ - message = "任务托盘码为空"; - } - applyUnbox(instruction.getVehicle_code()); - - } - } - } catch (Exception e) { - this.iserror = true; - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(this.device_code + "读取信号值时出现异常:" + e.getMessage() + ",this.itemProtocol is null") - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - message = "读取信号值时出现异常"; - e.printStackTrace(); - } - - - - - - last_mode =mode; - last_move =move; - last_carrier_direction =carrier_direction; - 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_strap_times =to_strap_times; - last_to_length =to_length; - last_to_weight =to_weight; - last_to_height =to_height; -} - - private Boolean applyUnbox(String vehicleCode) { - Date date = new Date(); - if (date.getTime() - this.require_apply_strangulation_time.getTime() - < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - try { - JSONObject param = new JSONObject(); - param.put("device_code", device_code); - param.put("material_barcode", vehicleCode); - param.put("task", task); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("木箱开盖,参数:" + param) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - String response = acsToWmsService.getIsUncap(param); - JSONObject jo = JSON.parseObject(response); - message = "木箱开盖,返回参数:" + jo; - if (jo.getInteger("status") == 200) { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("木箱开盖,接口返回:" + response) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - requireSucess = true; - packagePLCData(jo); - String isUncap = jo.getString("isUncap"); - if ("1".equals(isUncap)){ - List list1 = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", 15); - list1.add(map); - this.writing(list1); - }else { - List list1 = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", 99); - list1.add(map); - this.writing(list1); - Instruction inst = checkInst(); - finish_instruction(inst); - } - - }else { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("木箱开盖报错,接口返回:" + response) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - message = "木箱开盖报错,返回参数:" + jo; - this.iserror = true; - } - - - } catch (Exception e) { - e.printStackTrace(); - } - } - return false; - } - - private void packagePLCData(JSONObject datas) { - String length = datas.getString("boxLength"); - String weight = datas.getString("boxWidth"); - String height = datas.getString("boxHigh"); - String desiccant = datas.getString("desiccantTemplate"); - List list = new ArrayList(); - Map map4 = new HashMap(); - map4.put("code", "to_length"); - map4.put("value", length); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_width"); - map5.put("value", weight); - list.add(map5); - Map map6 = new HashMap(); - map6.put("code", "to_height"); - map6.put("value", height); - list.add(map6); - Map map7 = new HashMap(); - map7.put("code", "to_desiccant"); - map7.put("value", desiccant); - list.add(map7); - - try { - this.writing(list); - } catch (Exception e) { - message = "写入异常"; - } - this.setRequireSucess(true); - - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - - public boolean exe_business() { - return true; - } - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - public synchronized boolean finish_instruction(Instruction inst) throws Exception { - instructionService.finish(inst); - return true; - } - - - protected void thingToNothing() throws Exception { - requireSucess = false; - } - - - public void executing(Server server, Map itemMap) { - this.control(itemMap); - } - - public void writing(int command) { - Map itemMap = new HashMap(); - this.control(itemMap); - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String move = ""; - String carrier_direction = ""; - if (this.getMode() == 0) { - mode = LangProcess.msg("universal_off-line"); - } else if (this.getMode() == 1) { - mode = LangProcess.msg("universal_stand-alone"); - } else if (this.getMode() == 2) { - mode = LangProcess.msg("universal_standby"); - } else if (this.getMode() == 3) { - mode = LangProcess.msg("universal_operation"); - } - - - if (this.getMove() == 0) { - move = LangProcess.msg("universal_no"); - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = LangProcess.msg("universal_yes"); - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = LangProcess.msg("universal_two_yes"); - jo.put("hasGoods", true); - } - - - if (this.carrier_direction == 1) { - carrier_direction = LangProcess.msg("universal_forward_rotation"); - } else if (this.carrier_direction == 2) { - carrier_direction = LangProcess.msg("universal_rollback"); - } - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = "1"; - } - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("carrier_direction", carrier_direction); - jo.put("task", task); - jo.put("last_task", last_task); - jo.put("task_code", task_code); - jo.put("inst_message", this.inst_message); - jo.put("last_inst_message", this.last_inst_message); - jo.put("isOnline", this.getIsonline()); - jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError()))); - jo.put("isError", this.getIserror()); - jo.put("message", message); - jo.put("hand_barcode", hand_barcode); - jo.put("barcode", this.getMove() == 0 ? null : checkInst() == null ? vehicle_code : checkInst().getVehicle_code()); - jo.put("is_click", true); - jo.put("requireSucess", requireSucess); - jo.put("driver_type", "siemens_conveyor"); - jo.put("vehicle_code2", this.vehicle_code2); - 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, "1")) { - this.requireSucess = true; - } - - String hand_barcode = data.getString("hand_barcode"); - this.setHand_barcode(hand_barcode); - } - - @Override - public JSONObject feedLmsRealFailedInfo() { - JSONObject jo = new JSONObject(); - jo.put("device_code", this.getDevice().getDevice_code()); - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("fault_code", String.valueOf(error)); - jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); - jo.put("fault_type", error_type); - return jo; - } - - public void writing(List list) { - - Map itemMap = new HashMap(); - for (int i = 0; i < list.size(); i++) { - Object ob = list.get(i); - JSONObject json = (JSONObject) JSONObject.toJSON(ob); - if (!StrUtil.isEmpty(json.getString("value"))) { - String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + json.getString("code"); - itemMap.put(to_param, json.getString("value")); - } - } - logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); - try { - this.checkcontrol(itemMap); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - - /** - * 请求指令 - */ - public synchronized boolean instruction_require() { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_require_time = date; - //判断是否存在起点相同 任务状态就绪的任务 - TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); - if (!ObjectUtil.isEmpty(taskdto)) { - //需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建 - Instruction inst = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()); - if (ObjectUtil.isNotEmpty(inst)) { - List list = new ArrayList(); - Map map2 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", inst.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "1"); - list.add(map3); - this.writing(list); - requireSucess = true; - while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , inst.getInstruction_code())) { - this.writing(list); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))) { - requireSucess = false; - return false; - } - } - message = "申请任务成功"; - requireSucess = true; - return true; - } - String taskid = taskdto.getTask_id(); - String taskcode = taskdto.getTask_code(); - String vehiclecode = taskdto.getVehicle_code(); - String priority = taskdto.getPriority(); - String start_point_code = taskdto.getStart_point_code(); - String start_device_code = taskdto.getStart_device_code(); - String route_plan_code = taskdto.getRoute_plan_code(); - String next_device_code = ""; - - /** - * 开始平均分配 - */ - String this_coevice_code = taskserver.queryAssignedByDevice(device_code, taskdto.getNext_device_code()); - if (StrUtil.isEmpty(this_coevice_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, taskdto.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - - List pathlist = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 1; - break; - } - } - next_device_code = pathlist.get(index); - } else { - next_device_code = this_coevice_code; - } - //校验路由关系 - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - if (ObjectUtils.isEmpty(shortPathsList)) { - throw new RuntimeException("路由不通!"); - } - - Device startdevice = deviceAppservice.findDeviceByCode(start_device_code); - Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); - String next_point_code; - if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) { - next_point_code = taskdto.getTo_x() + "-" + taskdto.getTo_y() + "-" + taskdto.getTo_z(); - } else { - next_point_code = next_device_code; - } - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(taskdto.getRemark()); - instdto.setMaterial(taskdto.getMaterial()); - instdto.setQuantity(taskdto.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by(SecurityUtils.getCurrentNickName()); - 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.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - try { - instructionService.create(instdto); - } catch (Exception e) { - e.printStackTrace(); - log.error("指令创建失败!", e.getMessage()); - return false; - } - //创建指令后修改任务状态 - taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskserver.update(taskdto); - requireSucess = true; - String next_addr = nextdevice.getExtraValue().get("address").toString(); - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_target"); - map.put("value", next_addr); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", instdto.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "1"); - list.add(map3); - this.writing(list); - requireSucess = true; - while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , instdto.getInstruction_code())) { - this.writing(list); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + inst.getInstruction_code() + "再次下发电气信号") - .build(); - logDto.setLog_level(3); - luceneExecuteLogService.deviceExecuteLog(logDto); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (ObjectUtil.isEmpty(taskserver.findByCode(taskdto.getTask_code()))) { - requireSucess = false; - return false; - } - } - } else { - //如果不存在则直接找对应指令 - Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); - if (ObjectUtil.isEmpty(inst)) { - return false; - } - - Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code()); - String next_addr = nextdevice.getExtraValue().get("address").toString(); - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_target"); - map.put("value", next_addr); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_task"); - map2.put("value", inst.getInstruction_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "1"); - list.add(map3); - this.writing(list); - requireSucess = true; - while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() - , inst.getInstruction_code())) { - this.writing(list); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + inst.getInstruction_code() + "再次下发电气信号") - .build(); - logDto.setLog_level(3); - luceneExecuteLogService.deviceExecuteLog(logDto); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (ObjectUtil.isEmpty(instructionService.findByDeviceCodeFromCache(this.device_code))) { - requireSucess = false; - return false; - } - } - } - return true; - } - } - - /** - * 更新指令状态 - */ - public synchronized void update_instruction_status() throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); - - } else { - this.instruction_update_time = date; - inst = checkInst(); - if (inst != null) { - inst_message = "当前指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); - vehicle_code = inst.getVehicle_code(); - task_code = inst.getTask_code(); - if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status("1"); - inst.setExecute_device_code(this.device_code); - instructionService.update(inst); - logServer.deviceExecuteLog(device_code, "", "", "纸箱入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task + ",载具号:" + inst.getVehicle_code()); - } - if (StrUtil.equals(inst.getInstruction_status(), "1") || StrUtil.equals(inst.getInstruction_status(), "0")) { - if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - vehicle_code = inst.getVehicle_code(); - inst.setExecute_device_code(this.device_code); - if (mode == 2) { - finish_instruction(); - } - logServer.deviceExecuteLog(device_code, "", "", "纸箱入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task + ",载具号:" + inst.getVehicle_code()); - } else { - - } - } - } else { -// message = "输送线任务反馈状态,查询不到指令号:" + task +"指令已完成"; - inst_message = null; - } - - } - } - - public Instruction checkInst() { - if (ObjectUtil.isNotEmpty(this.inst)) { - if (this.task > 0) { - if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { - return this.inst; - } else { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - return inst; - } - } - } else { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - return inst; - } - return null; - } -} 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 4260d0d..3393bd5 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 @@ -18,7 +18,7 @@ import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.device_driver.one_conveyor.box_subvolumes_conveyor.BoxSubvolumesConveyorDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.box_subvolumes_conveyor.BoxSubvolumesConveyorDeviceDriver; import org.nl.acs.device_driver.one_conveyor.manipulator_cache.ManipulatorCacheDeviceDriver; import org.nl.acs.history.ErrorUtil; import org.nl.acs.history.service.DeviceErrorLogService; 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 baa2534..5783e83 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,7 +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; import cn.hutool.core.util.StrUtil; @@ -10,18 +9,15 @@ import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.nl.acs.common.base.CommonFinalParam; import org.nl.acs.device.domain.Device; import org.nl.acs.device.service.DeviceExtraService; import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; -import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.belt_conveyor.BeltConveyorDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.device_driver.one_conveyor.box_subvolumes_conveyor.BoxSubvolumesConveyorDeviceDriver; import org.nl.acs.history.ErrorUtil; import org.nl.acs.history.service.DeviceErrorLogService; import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; 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 e9a4e90..c17fc6e 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,7 +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; import cn.hutool.core.util.StrUtil; @@ -10,19 +9,15 @@ import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.nl.acs.common.base.CommonFinalParam; import org.nl.acs.device.domain.Device; import org.nl.acs.device.service.DeviceExtraService; import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.box_manipulator_site.BoxManipulatorSiteDeviceDriver; -import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; -import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.belt_conveyor.BeltConveyorDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.device_driver.one_conveyor.box_storage_out_conveyor.BoxStorageOutConveyorDeviceDriver; import org.nl.acs.history.ErrorUtil; import org.nl.acs.history.service.DeviceErrorLogService; import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/ItemProtocol.java deleted file mode 100644 index 95d2147..0000000 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/ItemProtocol.java +++ /dev/null @@ -1,229 +0,0 @@ -package org.nl.acs.device_driver.one_manipulator.trapped_manipulator; - -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -@Data -public class ItemProtocol { - /** - * 心跳 - */ - public static String item_heartbeat = "heartbeat"; - /** - * 工作模式 - */ - public static String item_mode = "mode"; - /** - * 光电信号 - */ - public static String item_move = "move"; - /** - * 动作信号 - */ - public static String item_action = "action"; - - /** - * 任务号 - */ - public static String item_task = "task"; - /** - * 报警 - */ - public static String item_error = "error"; - - /** - * 行走列 - */ - public static String item_walk_y = "walk_y"; - - /** - * 行走列 - */ - public static String item_x = "x"; - - /** - * 行走层号 - */ - public static String item_y = "y"; - - - - - - /** - * 下发命令 - */ - public static String item_to_command = "to_command"; - /** - * 下发目标站 - */ - public static String item_to_target = "to_target"; - /** - * 下发任务号 - */ - public static String item_to_task = "to_task"; - - - /** - * 下发起始站 - */ - public static String item_to_onset = "to_onset"; - - /** - *木箱长度 - */ - public static String item_to_length = "to_length"; - /** - *木箱宽度 - */ - public static String item_to_width = "to_width"; - /** - *木箱高度 - */ - public static String item_to_height = "to_height"; - - - /** - *下发堆叠模板 - */ - public static String item_to_template = "to_template"; - - - /** - * 下发是否捆轧 - */ - public static String item_to_is_binding = "to_is_binding"; - - /** - * 下发木箱条码 - */ - public static String item_to_material = "to_material"; - - - private TrappedManipulatorManipulatorDeviceDriver driver; - - public float getX() { - return this.getOpcFloatValue(item_x); - } - - public float getY() { - return this.getOpcFloatValue(item_y); - } - public int getWalk_y() { - return this.getOpcIntegerValue(item_walk_y); - } - - - public ItemProtocol(TrappedManipulatorManipulatorDeviceDriver driver){ - this.driver=driver; - } - - public int getTo_onset() { - return this.getOpcIntegerValue(item_to_onset); - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getMove() { - return this.getOpcIntegerValue(item_move); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - - - - - public int getTo_task() { - return this.getOpcIntegerValue(item_to_task); - } - - - - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_target() { - return this.getOpcIntegerValue(item_to_target); - } - - - - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - } - - public float getOpcFloatValue(String protocol) { - Float value = this.driver.getDoubleValue(protocol); - if (value == null) { - // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList<>(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0")); - list.add(new ItemDto(item_mode, "工作模式", "DB1.B1")); - list.add(new ItemDto(item_move, "光电信号", "DB1.B2")); - list.add(new ItemDto(item_action, "动作信号", "DB1.B3")); - list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); - list.add(new ItemDto(item_task, "任务号", "DB1.D6")); - list.add(new ItemDto(item_x, "行走列号", "DB101.B10")); - list.add(new ItemDto(item_y, "行走层号", "DB101.B11")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList<>(); - list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); - list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); - list.add(new ItemDto(item_to_onset, "下发起始站", "DB2.W2")); - list.add(new ItemDto(item_to_length, "木箱长度", "DB601.W10")); - list.add(new ItemDto(item_to_width, "木箱宽度", "DB601.W12")); - list.add(new ItemDto(item_to_height, "木箱高度", "DB601.W14")); - list.add(new ItemDto(item_to_template, "堆叠模板", "DB601.W16")); - list.add(new ItemDto(item_to_is_binding, "下发是否捆轧", "DB601.D10")); - list.add(new ItemDto(item_to_material, "木箱条码", "DB601.D12")); - - return 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 deleted file mode 100644 index 03e7270..0000000 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java +++ /dev/null @@ -1,770 +0,0 @@ -package org.nl.acs.device_driver.one_manipulator.trapped_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; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.common.base.CommonFinalParam; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device.service.DeviceExtraService; -import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.FeedLmsRealFailed; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.history.ErrorUtil; -import org.nl.acs.history.service.DeviceErrorLogService; -import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; -import org.nl.acs.instruction.domain.Instruction; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.log.service.DeviceExecuteLogService; -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.route.service.impl.RouteLineServiceImpl; -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; -import org.nl.common.utils.SecurityUtils; -import org.nl.config.SpringContextHolder; -import org.nl.config.language.LangProcess; -import org.nl.config.lucene.service.LuceneExecuteLogService; -import org.nl.config.lucene.service.dto.LuceneLogDto; - -import java.util.*; -import java.util.stream.Collectors; - -/** - * 捆扎智能行架 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { - - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); - - DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); - - DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); - - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - - 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; - int to_barcode = 0; - int last_to_barcode = 0; - - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - private Date instruction_update_time = new Date(); - private int instruction_update_time_out = 1000; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - - private int instruction_require_time_out = 3000; - //行架机械手申请任务成功标识 - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - private String error_type = "hxhj_error_type"; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String device_code; - - //当前指令 - Instruction inst = null; - - //0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 - int now_steps_type = 0; - String notCreateTaskMessage = ""; - String notCreateInstMessage = ""; - String feedMessage = ""; - String inst_message; - - - List getDeviceCodeList = null; - - List putDeviceCodeList = null; - - - @Override - public Device getDevice() { - return this.device; - } - - @Override - public void execute() { - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - move = this.itemProtocol.getMove(); - action = this.itemProtocol.getAction(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - heartbeat = this.itemProtocol.getHeartbeat(); - to_command = this.itemProtocol.getTo_command(); - to_target = this.itemProtocol.getTo_target(); - to_onset = this.itemProtocol.getTo_onset(); - to_task = this.itemProtocol.getTo_task(); - - - if (mode != last_mode) { - requireSucess = false; - } - // 更新指令状态 - if (mode == 3 && task > 0) { - updateInstructionStatus(); - if (null != inst) { - inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code(); - } - } - if (mode == 0) { - this.setIsonline(false); - //有报警 - } else if (error != 0) { - this.setIserror(true); - message = "universal_message3"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - Instruction instruction = null; - List toInstructions; - - //行架机械手申请任务 - if (mode == 2 && move == 0 && task == 0 && !requireSucess) { - boolean res = applyTask(); - if (res) { - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - feedMessage = ""; - } - } else { - String remark = ""; - ; - if (mode != 2) { - remark = "universal_remark2"; - } - if (move != 0) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = "universal_remark4"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = "universal_remark5"; - } - this.setNotCreateInstMessage(remark); - //} - } - - } - - } catch (Exception var17) { - this.iserror = true; - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(this.device_code + "读取信号值时出现异常:" + Arrays.toString(var17.getStackTrace())) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - var17.printStackTrace(); - message = "universal_remark8"; - } - - - 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; - - } - - private void updateInstructionStatus() { - Date date = new Date(); - if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); - - } else { - this.instruction_update_time = date; - //更改指令状态 - if (task > 0) { - Instruction inst = checkInst(); - if (inst != null) { - if (StrUtil.equals(inst.getInstruction_status(), "0")) { - inst.setInstruction_status(CommonFinalParam.ONE); - inst.setExecute_device_code(this.device_code); - instructionService.update(inst); - } - } - } - - //放货完成 - if (action == 4 && move == 0) { - if (inst != null) { - try { - logServer.deviceExecuteLog(this.device_code, "", "", "放货完成"); - finish_instruction(inst); - Map map1 = new HashMap<>(); - List list = new ArrayList(); - map1.put("code", "to_command"); - map1.put("value", 5); - list.add(map1); - this.writing(list); - message = "universal_message1"; - } catch (Exception e) { - message = "universal_message2"; - e.printStackTrace(); - } - feedMessage = ""; - } else { - feedMessage = "universal_feedMessage5"; - if (mode != 3) { - feedMessage = "universal_feedMessage1"; - } - if (action != 8) { - feedMessage = "universal_feedMessage2"; - } - if (move != 0) { - feedMessage = "universal_feedMessage3"; - } - if (task == 0) { - feedMessage = "universal_feedMessage4"; - } - } - } - } - } - - public synchronized boolean applyTask() { - Date date = new Date(); - if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - boolean flag = true; - this.instruction_require_time = date; - //抓取工位 - if (ObjectUtil.isEmpty(getDeviceCodeList)) { - getDeviceCodeList = this.getExtraDeviceCodes("get_device_code"); - } - //放货工位 - if (ObjectUtil.isEmpty(putDeviceCodeList)) { - putDeviceCodeList = this.getExtraDeviceCodes("put_device_code"); - } - //先查指令 - List instructionList = instructionService.findReadyIns(); - if (CollUtil.isNotEmpty(instructionList)) { - List instructionsReady = new ArrayList<>(); - Instruction instructionReady = null; - for (Instruction instruction : instructionList) { - if (getDeviceCodeList.contains(instruction.getStart_device_code())) { - instructionsReady.add(instruction); - } - } - if (CollUtil.isNotEmpty(instructionsReady)) { - List instructions = instructionsReady.stream().sorted(Comparator.comparing(Instruction::getCreate_time)).collect(Collectors.toList()); - instructionReady = instructions.get(0); - } - if (ObjectUtil.isNotEmpty(instructionReady)) { - TaskDto byTaskCode = taskserver.findByTaskCode(instructionReady.getTask_code()); - String interactionJson = byTaskCode.getInteraction_json(); - if (StrUtil.isNotEmpty(interactionJson)) { - InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); - String start_device_code = byTaskCode.getStart_device_code(); - String next_device_code = byTaskCode.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)) { - notCreateInstMessage = "universal_notCreateInstMessage1"; - throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); - } - if (ObjectUtil.isEmpty(next_addr)) { - notCreateInstMessage = "universal_notCreateInstMessage1"; - 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<>(); - Map map10 = new HashMap<>(); - Map map11 = new HashMap<>(); - try { - pushPLC(map1, map2, next_addr, map3, start_addr, map4, instructionReady.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9, map10, map11, instructionReady.getVehicle_code()); - } catch (Exception e) { - logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" - + instructionReady.getInstruction_code() + ",指令起点:" + instructionReady.getStart_device_code() - + ",指令终点:" + instructionReady.getNext_device_code() + ",交互参数:" + interactionJsonDTO.toString() + ",指令执行失败:" + e.getMessage()); - this.setRequireSucess(true); - return false; - } - this.setRequireSucess(true); - return true; - } - } - } else { - List taskDtos = taskserver.findByTrappedManipulatorReady(); - List taskDtosReady = new ArrayList<>(); - TaskDto taskDto = null; - if (CollUtil.isNotEmpty(taskDtos)) { - for (TaskDto taskDto1 : taskDtos) { - if (getDeviceCodeList.contains(taskDto1.getStart_device_code())) { - taskDtosReady.add(taskDto1); - } - } - } - if (CollUtil.isNotEmpty(taskDtosReady)) { - for (TaskDto dto : taskDtosReady) { - String start_device_code = dto.getStart_device_code(); - String next_device_code = dto.getNext_device_code(); - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - BeltConveyorDeviceDriver beltConveyorDeviceDriverStart; - BeltConveyorDeviceDriver beltConveyorDeviceDriverEnd; - - if (startDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - beltConveyorDeviceDriverStart = (BeltConveyorDeviceDriver) startDevice.getDeviceDriver(); - if (beltConveyorDeviceDriverStart.getMove() != 1) { - notCreateInstMessage = "universal_notCreateInstMessage2"; - continue; - } - } - if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - beltConveyorDeviceDriverEnd = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver(); - if (beltConveyorDeviceDriverEnd.getMove() == 1 && beltConveyorDeviceDriverEnd.getMode() == 2) { - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("当前任务号:" + dto.getTask_code() + " " + next_device_code + "当前move值为:" + beltConveyorDeviceDriverEnd.getMove() + ",当前mode值为:"+beltConveyorDeviceDriverEnd.getMode()) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - taskDto = dto; - }else { -// forceMove(nextDevice); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("当前任务号:" + dto.getTask_code() + " " + next_device_code + "当前move值为:" + beltConveyorDeviceDriverEnd.getMove() + ",当前mode值为:"+beltConveyorDeviceDriverEnd.getMode()) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - notCreateInstMessage = "universal_notCreateInstMessage2"; - continue; - } - } - if (ObjectUtil.isNotEmpty(taskDto)){ - break; - } - } - } - if (ObjectUtil.isNotEmpty(taskDto)) { - 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)) { - notCreateInstMessage = "universal_notCreateInstMessage1"; - throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); - } - if (ObjectUtil.isEmpty(next_addr)) { - notCreateInstMessage = "universal_notCreateInstMessage1"; - throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); - } - - - 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 { - instructionService.create(instdto); - } catch (Exception e) { - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + "创建指令时出现异常:" + e.getMessage()) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - return false; - } - //创建指令后修改任务状态 - taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskserver.update(taskDto); - - 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<>(); - Map map10 = new HashMap<>(); - Map map11 = new HashMap<>(); - try { - pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8, map9, map10, map11, taskDto.getVehicle_code()); - } catch (Exception e) { - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + "创建指令时出现异常:" + e.getMessage()) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - return false; - } - this.setRequireSucess(true); - return true; - } else { - notCreateInstMessage = "universal_notCreateInstMessage"; - } - } - return false; - } - } - - private void forceMove( Device nextDevice) { - BeltConveyorDeviceDriver beltConveyorDeviceDriverNext; - BeltConveyorDeviceDriver beltConveyorDeviceDriverLink; - beltConveyorDeviceDriverNext = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver(); - if (beltConveyorDeviceDriverNext.getMode() == 3) { - List deviceCodes = beltConveyorDeviceDriverNext.getExtraDeviceCodes("link_device_code"); - if (ObjectUtil.isNotEmpty(deviceCodes)) { - Device linkDevice = deviceAppService.findDeviceByCode(deviceCodes.get(0)); - if (linkDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - beltConveyorDeviceDriverLink = (BeltConveyorDeviceDriver) linkDevice.getDeviceDriver(); - if (beltConveyorDeviceDriverLink.getMove() == 1 && beltConveyorDeviceDriverLink.getMode() == 2) { - //查看是否存在到2022的行架任务 - Instruction byStartCodeAndReadyAndRun = instructionService.findByNextCodeAndReadyAndRun(deviceCodes.get(0)); - //申请上位强制离开 - if (ObjectUtil.isEmpty(byStartCodeAndReadyAndRun)) { - JSONObject param = new JSONObject(); - param.put("deviceCode", deviceCodes.get(0)); - String response = acsToWmsService.forceMove(param); - JSONObject jo = JSON.parseObject(response); - if (jo.getInteger("code") == 200) { - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("强行离开,参数,接口返回:" + jo) - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - } - }else { - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("无法强制离开,存在到CK2022的行架任务"+byStartCodeAndReadyAndRun.getInstruction_code()) - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - } - } - } - } - } - } - - - 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, Map map10, Map map11, String vehicleCode) { - - 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_width"); - 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_is_leave"); - map9.put("value", interactionJsonDTO.getIsLeave()); - list.add(map9); - } - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getIsBinding())) { - map10.put("code", "to_is_binding"); - map10.put("value", interactionJsonDTO.getIsBinding()); - list.add(map10); - } - if (ObjectUtil.isNotEmpty(vehicleCode)) { - map11.put("code", "to_material"); - map11.put("value", vehicleCode); - list.add(map11); - } - Map map12 = new HashMap<>(); - if (ObjectUtil.isNotEmpty(interactionJsonDTO.getBindingTimes())) { - map12.put("code", "to_binding_times"); - map12.put("value", interactionJsonDTO.getBindingTimes()); - list.add(map12); - } - } - - 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(SecurityUtils.getCurrentNickName()); - 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 - * @return - * @throws Exception - */ - public synchronized boolean finish_instruction(Instruction inst) throws Exception { - instructionService.finish(inst); - return true; - } - - /** - * 下发信号 - * - * @param list - */ - public void writing(List list) { - - Map itemMap = new HashMap(); - for (int i = 0; i < list.size(); i++) { - Object ob = list.get(i); - JSONObject json = (JSONObject) JSONObject.toJSON(ob); - if (!StrUtil.isEmpty(json.getString("value"))) { - String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + json.getString("code"); - itemMap.put(to_param, json.getString("value")); - } - } - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("下发多个电气信号" + itemMap) - .build(); - logDto.setLog_level(3); - luceneExecuteLogService.deviceExecuteLog(logDto); - logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); - try { - this.checkcontrol(itemMap); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - /** - * 抽取统一下发电气信号前缀 - * - * @return - */ - 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(); - String mode = ""; - String move = ""; - String action = ""; - String walk_y = ""; - if (this.getMode() == 0) { - mode = LangProcess.msg("universal_off-line"); - } else if (this.getMode() == 1) { - mode = LangProcess.msg("universal_stand-alone"); - } else if (this.getMode() == 2) { - mode = LangProcess.msg("universal_standby"); - } else if (this.getMode() == 3) { - mode = LangProcess.msg("universal_operation"); - } - - if (this.getMove() == 0) { - move = LangProcess.msg("universal_no"); - } else if (this.getMove() == 1) { - move = LangProcess.msg("universal_yes"); - } - - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = "1"; - } - jo.put("requireSucess", requireSucess); - if (this.getAction() == 1) { - action = LangProcess.msg("universal_delivery"); - } else if (this.getAction() == 2) { - action = LangProcess.msg("universal_completed"); - } else if (this.getAction() == 3) { - action = LangProcess.msg("universal_releasing"); - } else if (this.getAction() == 4) { - action = LangProcess.msg("universal_releasing_completed"); - } - - - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("action", action); - jo.put("task", task); - jo.put("isOnline", this.getIsonline()); - jo.put("error", ErrorUtil.getDictDetail("mxddhj_error_type", String.valueOf(this.getError()))); - jo.put("isError", this.getIserror()); - jo.put("message", LangProcess.msg(message)); - jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); - jo.put("feedMessage", LangProcess.msg(feedMessage)); - jo.put("driver_type", "siemens_conveyor"); - jo.put("is_click", true); - jo.put("inst_message", this.inst_message); - 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, "1")) { - this.requireSucess = true; - } - } - - @Override - public JSONObject feedLmsRealFailedInfo() { - JSONObject jo = new JSONObject(); - jo.put("device_code", this.getDevice().getDevice_code()); - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("fault_code", String.valueOf(error)); - jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); - jo.put("fault_type", error_type); - return jo; - } - - - public Instruction checkInst() { - if (ObjectUtil.isNotEmpty(this.inst)) { - if (this.task > 0) { - if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { - return this.inst; - } else { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - return inst; - } - } - } else { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - return inst; - } - return null; - } -} 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 82ea2ef..02ef265 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 @@ -16,7 +16,7 @@ import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.belt_conveyor.BeltConveyorDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.device_driver.one_conveyor.manipulator_cache.ManipulatorCacheDeviceDriver; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java index 0677998..cf3e022 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java @@ -1,367 +1,113 @@ package org.nl.acs.device_driver.stacker.standard_stacker; -import lombok.Data; -import lombok.extern.slf4j.Slf4j; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device_driver.lk_manipulator.open_close_manipulator.OpenCloseManipulatorDeviceDriver; import java.util.ArrayList; import java.util.List; -@Slf4j -@Data -public class ItemProtocol { +public enum ItemProtocol { - /** - * 心跳 - */ - public static String item_heartbeat = "heartbeat"; + HEARTBEAT("heartbeat", "心跳", "DB101.B0"), + DEVICECODE("deviceCode", "堆垛机号", "DB101.B1"), + MODE("mode", "工作模式", "DB101.B2"), + COMMAND("command", "作业状态", "DB101.B31"), + TASK("task", "任务号", "DB101.B32"), + ERROR("error", "Y轴报警(载货台)", "DB101.B36"), + X("x", "行走列号", "DB101.B38"), + Y("y", "行走层号", "DB101.B39"), + Z("z", "行走排号", "DB101.B40"), + CARGOMOVE("cargoMove", "载货台开关信号", "DB101.B41"), + ACTION("action", "行走动作信号", "DB101.B5"), + DISTANCEX("distancex", "行走激光数值", "DB101.D16"), + DISTANCEY("distancey", "启升激光数值", "DB101.D44"), + CARGOERROR("cargoError", "载货台超限信号", "DB101.B43"), + FORKCARGO("forkCargo", "货叉探货信号", "DB101.B48"), + SPECIAL1("special1", "特殊开关量1", "DB101.B10"), + SPECIAL2("special2", "特殊开关量2", "DB101.B11"), + STORAGECACHE("storage_cache", "水箱和消防缓存位有货", "DB101.B50"), + STACKER_RPM("stacker_rpm", "速度(转/分钟)", "DB101.W52"), + STACKER_ELECTRICCURRENT("stacker_electric_current", "电流", "DB101.W54"), + STACKER_RUNING_TIME("stacker_runing_time", "轴运行次数", "DB101.D60"), + TO_HEARTBEAT("to_heartbeat", "下发心跳", "DB100.B0"), + TO_DEVICE_CODE("to_device_code", "下发堆垛机号", "DB100.B1"), + TO_COMMAND("to_command", "下发作业命令", "DB100.B2"), + TO_TYPE("to_type", "下发物料类型", "DB100.B3"), + TO_TASK("to_task", "下发任务号", "DB100.D10"), + TO_Z("to_z", "作业排", "DB100.B6"), + TO_X("to_x", "作业列", "DB100.B7"), + TO_Y("to_y", "作业层", "DB100.B8"); - /** - * 堆垛机号 - */ - public static String item_deviceCode = "deviceCode"; + private final String key; + private final String description; + private final String address; - /** - * 工作模式 - */ - public static String item_mode = "mode"; - - /** - * 作业状态 - */ - public static String item_command = "command"; - - /** - * 任务号 - */ - public static String item_task = "task"; - - /** - * y轴报警(载货台) - */ - public static String item_error = "Error"; - - /** - * 行走排号 - */ - public static String item_z = "z"; - - /** - * 行走列 - */ - public static String item_x = "x"; - - /** - * 行走层号 - */ - public static String item_y = "y"; - - - - /** - * 载货台开关信号 - */ - public static String item_cargoMove = "cargoMove"; - - /** - * 行走动作信号 - */ - public static String item_action = "action"; - - /** - * 行走激光数值 - */ - public static String item_distancex = "distancex"; - - /** - * 起升激光数值 - */ - public static String item_distancey = "distancey"; - - /** - * 载货台超限信号 - */ - public static String item_cargoError = "cargoError"; - - /** - * 货叉探货信号 - */ - public static String item_forkCargo = "forkCargo"; - - - - - /** - * 特殊开关量1 - */ - public static String item_special1 = "special1"; - /** - * 特殊开关量2 - */ - public static String item_special2 = "special2"; - - /** - * 水箱和消防缓存位有无货 - */ - public static String item_storage_cache = "storage_cache"; - /** - * 速度(转/分钟) - */ - public static String item_stacker_rpm = "stacker_rpm"; - /** - * 电流 - */ - public static String item_stacker_electricCurrent = "stacker_electric Current"; - - /** - * 轴运行次数 - */ - public static String item_stacker_runing_time = "stacker_runing time"; - - - - - - /** - * 心跳 - */ - public static String item_to_heartbeat = "to_heartbeat"; - - /** - * 堆垛机号 - */ - public static String item_to_device_code = "to_device_code"; - /** - * 轴运行次数 - */ - public static String item_to_command = "to_command"; - /** - * 物料类型 - */ - public static String item_to_type = "to_type"; - /** - * 任务号 - */ - public static String item_to_task = "to_task"; - /** - * 作业排 - */ - public static String item_to_z = "to_z"; - /** - * 作业列 - */ - public static String item_to_x = "to_x"; - /** - * 作业层 - */ - public static String item_to_y = "to_y"; - - - - Boolean isonline; - - private StandardStackerDeviceDriver driver; - - public ItemProtocol(StandardStackerDeviceDriver driver) { - this.driver = driver; + ItemProtocol(String key, String description, String address) { + this.key = key; + this.description = description; + this.address = address; } - public Integer getItem_heartbeat() { - return this.getOpcIntegerValue(item_heartbeat); + public String getKey() { + return this.key; } - public Integer getItem_deviceCode() { - return this.getOpcIntegerValue(item_deviceCode); + public String getDescription() { + return description; } - public Integer getItem_mode() { - return this.getOpcIntegerValue(item_mode); + public String getAddress() { + return address; } - ; - - public Integer getItem_command() { - return this.getOpcIntegerValue(item_command); - } - - public Integer getItem_task() { - return this.getOpcIntegerValue(item_task); - } - - public Integer getItem_error() { - return this.getOpcIntegerValue(item_error); - } - - public Integer getItem_z() { - return this.getOpcIntegerValue(item_z); - } - - public Integer getItem_x() { - return this.getOpcIntegerValue(item_x); - } - - public Integer getItem_y() { - return this.getOpcIntegerValue(item_y); - } - - - public float getItem_cargoMove() { - return this.getOpcFloatValue(item_cargoMove); - } - - public float getItem_action() { - return this.getOpcFloatValue(item_action); - } - - public Integer getItem_distancex() { - return this.getOpcIntegerValue(item_distancex); - } - - public Integer getItem_distancey() { - return this.getOpcIntegerValue(item_distancey); - } - - public float getItem_cargoError() { - return this.getOpcFloatValue(item_cargoError); - } - - public float getItem_forkCargo() { - return this.getOpcFloatValue(item_forkCargo); - } - - - - - public float getItem_special1() { - return this.getOpcFloatValue(item_special1); - } - - public float getItem_special2() { - return this.getOpcFloatValue(item_special2); - } - - - public float getItem_storage_cache() { - return this.getOpcFloatValue(item_storage_cache); - } - - public Integer getItem_stacker_rpm() { - return this.getOpcIntegerValue(item_stacker_rpm); - } - - public Integer getItem_stacker_electricCurrent() { - return this.getOpcIntegerValue(item_stacker_electricCurrent); - } - - - - public Integer getItem_stacker_runing_time() { - return this.getOpcIntegerValue(item_stacker_runing_time); - } - - - - - - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); + // 获取 Integer 类型的值 + public Integer getIntegerValue(StandardStackerDeviceDriver driver) { + Integer value = driver.getIntegerValue(this.getKey()); if (value == null) { - setIsonline(false); + driver.setIsOnline(false); } else { - setIsonline(true); + driver.setIsOnline(true); return value; } return 0; } - public String getOpcStringValue(String protocol) { - String value = this.driver.getStringValue(protocol); + // 获取 Float 类型的值 + public Float getFloatValue(StandardStackerDeviceDriver driver) { + Float value = driver.getFloatValue(this.getKey()); if (value == null) { - setIsonline(false); -// return ""; + driver.setIsOnline(false); } else { - setIsonline(true); + driver.setIsOnline(true); return value; } - return ""; + return 0.00f; } - public int[] getOpcIntegerArrayValue(String protocol) { - int[] value = this.driver.getIntegerArrayValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return new int[20]; - } - - public float getOpcFloatValue(String protocol) { - Float value = this.driver.getDoubleValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - } - - - public Long getOpcLongValue(String protocol) { - Long value = this.driver.getLongValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0L; + public String getStringValue(StandardStackerDeviceDriver driver) { + return driver.getStringValue(this.getKey()); } public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB101.BO")); - list.add(new ItemDto(item_deviceCode, "堆垛机号", "DB101.B1")); - list.add(new ItemDto(item_mode, "工作模式", "DB101.B2")); - list.add(new ItemDto(item_command, "作业状态", "DB101.B31")); - list.add(new ItemDto(item_task, "任务号", "DB101.D32")); - list.add(new ItemDto(item_error, "Y轴报警(载货台)", "DB101.B36")); - list.add(new ItemDto(item_z, "行走排号", "DB101.B38")); - list.add(new ItemDto(item_x, "行走列号", "DB101.B39")); - list.add(new ItemDto(item_y, "行走层号", "DB101.B40")); - list.add(new ItemDto(item_cargoMove, "载货台开关信号", "DB101.B41")); - list.add(new ItemDto(item_action, "行走动作信号", "DB101.B5")); - list.add(new ItemDto(item_distancex, "行走激光数值", "DB101.D16")); - list.add(new ItemDto(item_distancey, "起升激光数值", "DB101.D44")); - list.add(new ItemDto(item_cargoError, "载货台超限信号", "DB101.B43")); - list.add(new ItemDto(item_forkCargo, "货叉探货信号", "DB101.B48")); - list.add(new ItemDto(item_special1, "特殊开关量1", "DB101.B10")); - list.add(new ItemDto(item_special2, "特殊开关量2", "DB101.B11")); - list.add(new ItemDto(item_storage_cache, "水箱和消防缓存位有无货", "DB101.B50")); - list.add(new ItemDto(item_stacker_rpm, "速度(转/分钟)", "DB101.W52")); - list.add(new ItemDto(item_stacker_electricCurrent, "电流", "DB101.W54")); - list.add(new ItemDto(item_stacker_runing_time, "轴运行次数", "DB101.D60")); + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (!prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } return list; } public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_heartbeat, "心跳", "DB100.B0")); - list.add(new ItemDto(item_to_device_code, "堆垛机号", "DB100.B1")); - list.add(new ItemDto(item_to_command, "作业命令", "DB100.B2")); - list.add(new ItemDto(item_to_type, "物料类型", "DB100.B3")); - list.add(new ItemDto(item_to_task, "任务号", "DB100.D10")); - list.add(new ItemDto(item_to_z, "作业排", "DB100.B6")); - list.add(new ItemDto(item_to_x, "作业列", "DB100.B7")); - list.add(new ItemDto(item_to_y, "作业层", "DB100.B8")); + List list = new ArrayList<>(); + for (ItemProtocol prop : values()) { + if (prop.getKey().startsWith("to")) { + list.add(new ItemDto(prop.getKey(), prop.getDescription(), prop.getAddress())); + } + } return list; } - @Override public String toString() { return ""; 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 6a5be63..7b136ef 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 @@ -1,7 +1,6 @@ package org.nl.acs.device_driver.stacker.standard_stacker; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; @@ -14,17 +13,17 @@ import org.nl.acs.common.base.CommonFinalParam; import org.nl.acs.custompolicy.CustomerStragetyCacheService; import org.nl.acs.custompolicy.StackerInstruction; import org.nl.acs.custompolicy.StackerStrategyDto; +import org.nl.acs.custompolicy.server.enums.CustomPolicyTaskTypeEnum; import org.nl.acs.device.domain.Device; import org.nl.acs.device.enums.DeviceType; import org.nl.acs.device.service.DeviceExtraService; import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.device_driver.stacker.standard_stacker.enums.CustomPolicyTaskTypeEnum; +import org.nl.acs.device_driver.lk_conveyor.belt_conveyor.BeltConveyorDeviceDriver; import org.nl.acs.device_driver.storage.standard_storage.StandardStorageDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; @@ -46,13 +45,10 @@ import org.nl.acs.task.domain.Task; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.common.exception.BadRequestException; -import org.nl.common.utils.RedisUtils; import org.nl.config.SpringContextHolder; import org.nl.config.language.LangProcess; import org.nl.config.lucene.service.LuceneExecuteLogService; import org.nl.config.lucene.service.dto.LuceneLogDto; -import org.springframework.beans.factory.annotation.Autowired; - import java.util.*; import java.util.concurrent.LinkedBlockingQueue; import java.util.regex.Pattern; @@ -65,34 +61,17 @@ import java.util.stream.Collectors; @Data @RequiredArgsConstructor public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); - @Autowired - DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); - @Autowired - DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - - LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); - - public static final String REDIS_MOVE_BOX = "MOVE:MOVE_TASK"; - - @Autowired - private RedisUtils redisUtils; - - - private CustomerStragetyCacheService customerStragetyCacheService = SpringContextHolder.getBean(CustomerStragetyCacheService.class); - ; + private final DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + private final TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + private final InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + private final DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + private final RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); + private final DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); + private final DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); + private final LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); + private final CustomerStragetyCacheService customerStragetyCacheService = SpringContextHolder.getBean(CustomerStragetyCacheService.class); /** * 禁止入库 @@ -106,226 +85,219 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme * 停止接收任务 */ private boolean stopReceiveTask = false; - - /** * 异常处理请求标示位 */ private boolean error_request = false; - /** * 心跳 */ - Integer heartbeat = 0; - Integer last_heartbeat = 0; + private Integer heartbeat = 0; + private Integer last_heartbeat = 0; /** * 堆垛机号 */ - Integer item_deviceCode = 0; - Integer last_item_deviceCode = 0; + private Integer stackerDeviceCode = 0; + private Integer lastStackerDeviceCode = 0; /** * 工作模式 */ - Integer mode = 0; - Integer last_mode = 0; + private Integer mode = 0; + private Integer last_mode = 0; /** * 作业状态 */ - Integer command = 0; - Integer last_command = 0; + private Integer command = 0; + private Integer last_command = 0; /** * 任务号 */ - Integer task = 0; - Integer last_task = 0; + private Integer task = 0; + private Integer last_task = 0; /** * y轴报警(载货台) */ - Integer error = 0; - Integer last_error = 0; + private Integer error = 0; + private Integer last_error = 0; /** * 行走排号 */ - Integer z = 0; - Integer last_z = 0; + private Integer z = 0; + private Integer last_z = 0; /** * 行走列 */ - Integer x = null; - Integer last_x = null; + private Integer x = null; + private Integer last_x = null; /** * 行走层号 */ - Integer y = 0; - Integer last_y = 0; + private Integer y = 0; + private Integer last_y = 0; /** * 行走开关信号 */ - Float move = 0F; - Float last_move = 0F; + private Float move = 0F; + private Float last_move = 0F; /** * 载货台开关信号 */ - Float cargoMove = 0F; - Float last_cargoMove = 0F; + private Float cargoMove = 0F; + private Float last_cargoMove = 0F; /** * 行走动作信号 */ - Float action = 0F; - Float last_action = 0F; + private Float action = 0F; + private Float last_action = 0F; /** * 行走激光数值 */ - Integer distancex = 0; - Integer last_distancex = 0; + private Integer distancex = 0; + private Integer last_distancex = 0; /** * 起升激光数值 */ - Integer distancey = 0; - Integer last_distancey = 0; + private Integer distancey = 0; + private Integer last_distancey = 0; /** * 载货台超限信号 */ - Float cargoError = 0F; - Float last_cargoError = 0F; + private Float cargoError = 0F; + private Float last_cargoError = 0F; /** * 货叉探货信号 */ - Float forkCargo = 0F; - Float last_forkCargo = 0F; - + private Float forkCargo = 0F; + private Float last_forkCargo = 0F; /** * 货叉动作信号 */ - Float forkAction = 0F; - Float last_forkAction = 0F; + private Float forkAction = 0F; + private Float last_forkAction = 0F; /** * 特殊开关量1 */ - Float special1 = 0F; - Float last_special1 = 0F; + private Float special1 = 0F; + private Float last_special1 = 0F; /** * 特殊开关量2 */ - Float special2 = 0F; - Float last_special2 = 0F; - + private Float special2 = 0F; + private Float last_special2 = 0F; /** * 水箱和消防缓存位有无货 */ - Float storage_cache = 0F; - Float last_storage_cache = 0F; + private Float storage_cache = 0F; + private Float last_storage_cache = 0F; /** * 速度(转/分钟) */ - Integer stacker_rpm = 0; - Integer last_stacker_rpm = 0; + private Integer stacker_rpm = 0; + private Integer last_stacker_rpm = 0; /** * 电流 */ - Integer stacker_electricCurrent = 0; - Integer last_stacker_electricCurrent = 0; + private Integer stacker_electricCurrent = 0; + private Integer last_stacker_electricCurrent = 0; /** * 轴运行次数 */ - Integer stacker_runing_time = 0; - Integer last_stacker_runing_time = 0; + private Integer stacker_runing_time = 0; + private Integer last_stacker_runing_time = 0; /** * 轴工作时间(小时) */ - Integer stacker_workingHours = 0; - Integer last_stacker_workingHours = 0; + private Integer stacker_workingHours = 0; + private Integer last_stacker_workingHours = 0; /** * 载货台速度(转/分钟) */ - Integer cargo_rpm = 0; - Integer last_cargo_rpm = 0; + private Integer cargo_rpm = 0; + private Integer last_cargo_rpm = 0; /** * 载货台电流 */ - Integer cargo_electric_Current = 0; - Integer last_cargo_electric_Current = 0; + private Integer cargo_electric_Current = 0; + private Integer last_cargo_electric_Current = 0; /** * 载货台轴工作小时数 */ - Integer cargo_workingHour = 0; - Integer last_cargo_workingHour = 0; + private Integer cargo_workingHour = 0; + private Integer last_cargo_workingHour = 0; /** * 载货台轴运行次数 */ - Integer cargo_runingTimes = 0; - Integer last_cargo_runingTimes = 0; + private Integer cargo_runingTimes = 0; + private Integer last_cargo_runingTimes = 0; /** * 货叉速度(转/分钟 */ - Integer fork_rpm = 0; - Integer last_fork_rpm = 0; + private Integer fork_rpm = 0; + private Integer last_fork_rpm = 0; /** * 货叉电流 */ - Integer fork_electric_Current = 0; - Integer last_fork_electric_Current = 0; + private Integer fork_electric_Current = 0; + private Integer last_fork_electric_Current = 0; /** * 货叉轴工作时间(小时 */ - Integer fork_workingHours = 0; - Integer last_fork_workingHours = 0; + private Integer fork_workingHours = 0; + private Integer last_fork_workingHours = 0; /** * 货叉轴运行次数 */ - Integer fork_runingTimes = 0; - Integer last_fork_runingTimes = 0; - - String message = null; - - String device_code = null; - - String notCreateInstMessage = null; - + private Integer fork_runingTimes = 0; + private Integer last_fork_runingTimes = 0; + private String message = null; + private String currentDeviceCode = null; + private String notCreateInstMessage = null; private int instruction_require_time_out = 1000; private int instruction_update_time_out = 1000; private int update_point_require_time_out = 3000; private Date instruction_require_time = new Date(); private Date update_point_require_time = new Date(); private Date instruction_update_time = new Date(); - List getDeviceCodeList = null; - List putDeviceCodeList = null; - + private List getDeviceCodeList = null; + private List putDeviceCodeList = null; /** * 请求成功标记 */ - Boolean requireSucess = false; - + private Boolean requireSucess = false; /** * 满入空出成功标记 */ - Boolean errorRequireSucess = false; + private Boolean errorRequireSucess = false; + + /** + * 在线状态 + */ + private Boolean isOnline = false; /** * 当前指令 */ - Instruction inst = null; + private Instruction inst = null; /** * 同排移库后的出库指令 */ - Instruction errorInst = null; + private Instruction errorInst = null; /** * 入库异常错误限制 */ - Integer count = 0; - Boolean isonline = true; + private Integer count = 0; - Boolean iserror = false; + private Boolean isError = false; - String inst_message; + private String inst_message; - String vehicle_code2; + private String vehicle_code2; //阻塞队列,保证指令顺序执行 - LinkedBlockingQueue tackerInstructionQueue = new LinkedBlockingQueue<>(); + private LinkedBlockingQueue tackerInstructionQueue = new LinkedBlockingQueue<>(); @Override public Device getDevice() { @@ -336,25 +308,28 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme public void execute() throws Exception { try { - device_code = this.getDeviceCode(); - heartbeat = this.itemProtocol.getItem_heartbeat(); - item_deviceCode = this.itemProtocol.getItem_deviceCode(); - mode = this.itemProtocol.getItem_mode(); - command = this.itemProtocol.getItem_command(); - task = this.itemProtocol.getItem_task(); - error = this.itemProtocol.getItem_error(); - z = this.itemProtocol.getItem_z(); - x = this.itemProtocol.getItem_x(); - y = this.itemProtocol.getItem_y(); - cargoMove = this.itemProtocol.getItem_cargoMove(); - action = this.itemProtocol.getItem_action(); - distancex = this.itemProtocol.getItem_distancex(); - distancey = this.itemProtocol.getItem_distancey(); - cargoError = this.itemProtocol.getItem_cargoError(); - forkCargo = this.itemProtocol.getItem_forkCargo(); - special1 = this.itemProtocol.getItem_special1(); - special2 = this.itemProtocol.getItem_special2(); - storage_cache = this.itemProtocol.getItem_storage_cache(); + currentDeviceCode = this.getDevice().getDevice_code(); + heartbeat = ItemProtocol.HEARTBEAT.getIntegerValue(this); + stackerDeviceCode = ItemProtocol.DEVICECODE.getIntegerValue(this); + mode = ItemProtocol.MODE.getIntegerValue(this); + command = ItemProtocol.COMMAND.getIntegerValue(this); + task = ItemProtocol.TASK.getIntegerValue(this); + error = ItemProtocol.ERROR.getIntegerValue(this); + x = ItemProtocol.X.getIntegerValue(this); + y = ItemProtocol.Y.getIntegerValue(this); + z = ItemProtocol.Z.getIntegerValue(this); + cargoMove = ItemProtocol.CARGOMOVE.getFloatValue(this); + action = ItemProtocol.ACTION.getFloatValue(this); + distancex = ItemProtocol.DISTANCEX.getIntegerValue(this); + distancey = ItemProtocol.DISTANCEY.getIntegerValue(this); + cargoError = ItemProtocol.CARGOERROR.getFloatValue(this); + forkCargo = ItemProtocol.FORKCARGO.getFloatValue(this); + special1 = ItemProtocol.SPECIAL1.getFloatValue(this); + special2 = ItemProtocol.SPECIAL2.getFloatValue(this); + storage_cache = ItemProtocol.STORAGECACHE.getFloatValue(this); + stacker_rpm = ItemProtocol.STACKER_RPM.getIntegerValue(this); + stacker_electricCurrent = ItemProtocol.STACKER_ELECTRICCURRENT.getIntegerValue(this); + stacker_runing_time = ItemProtocol.STACKER_RUNING_TIME.getIntegerValue(this); if (!command.equals(last_command)) { requireSucess = false; @@ -383,7 +358,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme if (inst != null) { if (StrUtil.equals(inst.getInstruction_status(), "0")) { inst.setInstruction_status(CommonFinalParam.ONE); - inst.setExecute_device_code(this.device_code); + inst.setExecute_device_code(this.currentDeviceCode); instructionService.update(inst); } } @@ -392,21 +367,21 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } //不同任务限制清零 if (!Objects.equals(task, last_task)) { - this.isonline = true; + this.isOnline = true; count = 0; } if (mode == 0 || command == 9) { - this.setIsonline(false); + this.setIsOnline(false); message = "universal_off-line"; } else { - this.setIsonline(true); + this.setIsOnline(true); } if (error != 0) { - this.setIserror(true); + this.setIsError(true); message = "universal_message3"; } else { - this.setIserror(false); + this.setIsError(false); } if (mode != 3 || requireSucess) { message = "one_message7"; @@ -571,10 +546,10 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } } catch (Exception var17) { - this.iserror = true; + this.isError = true; LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(this.device_code + "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null") + .device_code(currentDeviceCode) + .content(this.currentDeviceCode + "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null") .build(); logDto.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto); @@ -582,10 +557,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme var17.printStackTrace(); } - - last_heartbeat = heartbeat; - last_item_deviceCode = item_deviceCode; + lastStackerDeviceCode = stackerDeviceCode; last_mode = mode; last_command = command; last_task = task; @@ -604,8 +577,6 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme last_special1 = special1; last_special2 = special2; last_storage_cache = storage_cache; - - } private void updateEXcuteMessage(String excuteMessage) { @@ -717,7 +688,6 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme Date date = new Date(); if (date.getTime() - this.update_point_require_time.getTime() < (long) this.update_point_require_time_out) { log.trace("触发时间因为小于{}毫秒,而被无视", this.update_point_require_time_out); - return; } else { this.update_point_require_time = new Date(); Instruction instruction = checkInst(); @@ -730,7 +700,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme param.put("task_id", instruction.getTask_id()); param.put("type", type); LuceneLogDto logDto1 = LuceneLogDto.builder() - .device_code(device_code) + .device_code(currentDeviceCode) .content("申请更新点位,参数:" + param) .build(); logDto1.setLog_level(4); @@ -739,11 +709,11 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme JSONObject jo = JSON.parseObject(response); if (jo.getInteger("status") == 200) { try { - verifyPoint(type,jo); + verifyPoint(type, jo); //清警 cleanErro(); LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) + .device_code(currentDeviceCode) .content("申请更新点位,参数,接口返回:" + jo) .build(); logDto2.setLog_level(4); @@ -787,7 +757,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } else { this.errorRequireSucess = false; LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) + .device_code(currentDeviceCode) .content("申请更新点位,返回参数:" + jo) .build(); logDto2.setLog_level(4); @@ -818,7 +788,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme param.put("task_id", instruction.getTask_id()); param.put("type", type); LuceneLogDto logDto1 = LuceneLogDto.builder() - .device_code(device_code) + .device_code(currentDeviceCode) .content("申请更新点位,参数:" + param) .build(); logDto1.setLog_level(4); @@ -827,11 +797,11 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme JSONObject jo = JSON.parseObject(response); if (jo.getInteger("status") == 200) { try { - verifyPoint(type,jo); + verifyPoint(type, jo); //清警 cleanErro(); LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) + .device_code(currentDeviceCode) .content("申请更新点位,参数,接口返回:" + jo) .build(); logDto2.setLog_level(4); @@ -879,7 +849,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme cleanErro(); this.errorRequireSucess = false; LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) + .device_code(currentDeviceCode) .content("申请更新点位,返回参数:" + jo) .build(); logDto2.setLog_level(4); @@ -890,32 +860,33 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme /** * 校验点位是否存在路由 + * * @param jo */ - private void verifyPoint(String type,JSONObject jo) { + private void verifyPoint(String type, JSONObject jo) { Instruction instruction = checkInst(); String point_code = jo.getString("point_code"); String[] split = point_code.split("-"); if (type.equals(StandarStirageErroEnum.BLOCK_IN.getType()) || type.equals(StandarStirageErroEnum.FILL.getType())) { List routeLineDtos = routeLineService.getShortPathLines(instruction.getStart_device_code(), split[0], instruction.getRoute_plan_code()); - if(CollUtil.isEmpty(routeLineDtos)){ + if (CollUtil.isEmpty(routeLineDtos)) { errorPoint(jo, instruction); } RouteLineDto routeLineDto = routeLineDtos.get(0); String[] path = routeLineDto.getPath().split("->"); - if(CollUtil.isEmpty(Arrays.asList(path)) || path.length != 3){ + if (CollUtil.isEmpty(Arrays.asList(path)) || path.length != 3) { errorPoint(jo, instruction); } - } else if(type.equals(StandarStirageErroEnum.VOIDANCE.getType())){ - List routeLineDtos = routeLineService.getShortPathLines(split[0],instruction.getNext_device_code(), - instruction.getRoute_plan_code()); - if(CollUtil.isEmpty(routeLineDtos)){ + } else if (type.equals(StandarStirageErroEnum.VOIDANCE.getType())) { + List routeLineDtos = routeLineService.getShortPathLines(split[0], instruction.getNext_device_code(), + instruction.getRoute_plan_code()); + if (CollUtil.isEmpty(routeLineDtos)) { errorPoint(jo, instruction); } RouteLineDto routeLineDto = routeLineDtos.get(0); String[] path = routeLineDto.getPath().split("->"); - if(CollUtil.isEmpty(Arrays.asList(path)) || path.length != 3){ + if (CollUtil.isEmpty(Arrays.asList(path)) || path.length != 3) { errorPoint(jo, instruction); } } @@ -923,13 +894,13 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme private void errorPoint(JSONObject jo, Instruction instruction) { LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("申请更新点位,点位路由不存在:" + jo + ",指令号:"+ instruction.getInstruction_code()) + .device_code(currentDeviceCode) + .content("申请更新点位,点位路由不存在:" + jo + ",指令号:" + instruction.getInstruction_code()) .build(); logDto2.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto2); errorRequireSucess = true; - notCreateInstMessage = "申请更新点位,点位路由不存在:" + jo + ",指令号:"+ instruction.getInstruction_code(); + notCreateInstMessage = "申请更新点位,点位路由不存在:" + jo + ",指令号:" + instruction.getInstruction_code(); throw new BadRequestException("路由不存在!"); } @@ -1127,8 +1098,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme List routeLineDtos = routeLineService.selectDeviceCodeList(instruction.getStart_device_code()); if (CollUtil.isEmpty(routeLineDtos) || routeLineDtos.size() < 1) { message = "one_message6"; - logServer.deviceExecuteLog(this.device_code, "", "", "没有" + instruction.getStart_device_code() + "->" - + this.device_code + "的路由"); + logServer.deviceExecuteLog(this.currentDeviceCode, "", "", "没有" + instruction.getStart_device_code() + "->" + + this.currentDeviceCode + "的路由"); continue; } for (RouteLineDto routeLineDto : routeLineDtos) { @@ -1136,8 +1107,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme List routeLineDtoList = routeLineService.selectDeviceCodeList(this.getDeviceCode()); if (CollUtil.isEmpty(routeLineDtos) || routeLineDtos.size() < 1) { message = "one_message6"; - logServer.deviceExecuteLog(this.device_code, "", "", "没有" + instruction.getStart_device_code() + "->" - + this.device_code + "的路由"); + logServer.deviceExecuteLog(this.currentDeviceCode, "", "", "没有" + instruction.getStart_device_code() + "->" + + this.currentDeviceCode + "的路由"); continue; } for (RouteLineDto routeLinedto : routeLineDtoList) { @@ -1156,7 +1127,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme instructionList = this.sortInst(instructionList); //堆垛机策略 - StackerStrategyDto stragety = customerStragetyCacheService.getStragety(device_code); + StackerStrategyDto stragety = customerStragetyCacheService.getStragety(currentDeviceCode); List instructionStragetyList = new ArrayList<>(); if (ObjectUtil.isNotEmpty(stragety)) { //根据筛选指令,指令中包含策略起点终点的指令 @@ -1180,7 +1151,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme if (startDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) startDevice.getDeviceDriver(); if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 0) { - notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + beltConveyorDeviceDriver.getDevice_code() + + notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + beltConveyorDeviceDriver.getCurrentDeviceCode() + "无货或未联机,无法下发指令!指令号:" + inst.getInstruction_code(); return false; } @@ -1188,7 +1159,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver(); if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() != 0) { - notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + beltConveyorDeviceDriver.getDevice_code() + + notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + beltConveyorDeviceDriver.getCurrentDeviceCode() + "有货或未联机,无法下发指令!指令号:" + inst.getInstruction_code(); return false; } @@ -1385,7 +1356,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme if (inst != null) { if (StrUtil.equals(inst.getInstruction_status(), "0")) { inst.setInstruction_status(CommonFinalParam.ONE); - inst.setExecute_device_code(this.device_code); + inst.setExecute_device_code(this.currentDeviceCode); instructionService.update(inst); } } @@ -1507,8 +1478,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme jo.put("stopReceiveTask", this.stopReceiveTask); jo.put("requireSucess", requireSucess); jo.put("driver_type", "standard_stacker"); - jo.put("isOnline", this.getIsonline()); - jo.put("isError", this.getIserror()); + jo.put("isOnline", this.getIsOnline()); + jo.put("isError", this.getIsError()); jo.put("notCreateInstMessage", notCreateInstMessage); jo.put("inst_message", this.inst_message); jo.put("vehicle_code2", this.vehicle_code2); @@ -1556,12 +1527,12 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } } LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) + .device_code(currentDeviceCode) .content("下发电气信号:" + itemMap) .build(); logDto.setLog_level(3); luceneExecuteLogService.deviceExecuteLog(logDto); - logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); + logServer.deviceExecuteLog(currentDeviceCode, "", "", "下发电气信号:" + itemMap); try { this.checkcontrol(itemMap); } catch (Exception e) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/enums/CustomPolicyTaskTypeEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/enums/CustomPolicyTaskTypeEnum.java deleted file mode 100644 index 67b9090..0000000 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/enums/CustomPolicyTaskTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @author ls - * @date 2023/11/20 13:33 - */ -package org.nl.acs.device_driver.stacker.standard_stacker.enums; - -import lombok.AllArgsConstructor; -import lombok.Getter; - - -@Getter -@AllArgsConstructor -public enum CustomPolicyTaskTypeEnum { - /** - * 入库 - */ - OUT(1, "入库"), - /** - * 出库 - */ - IN(2, "出库"), - /** - * 移库 - */ - MOVE(3, "移库"); - - Integer code; - String status; - - public static String getStatus(Integer code) { - for (CustomPolicyTaskTypeEnum value : values()) { - if (value.code.equals(code)) { - return value.status; - } - } - return null; - } -} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/manipulator_agv_station/ToCommandControl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/manipulator_agv_station/ToCommandControl.java index 989812f..4793a2d 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/manipulator_agv_station/ToCommandControl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/manipulator_agv_station/ToCommandControl.java @@ -1,11 +1,5 @@ package org.nl.acs.device_driver.two_conveyor.manipulator_agv_station; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.device_driver.driver.ItemValue; -import org.nl.acs.device_driver.stacker.standard_stacker.ItemProtocol; -import org.nl.acs.device_driver.stacker.standard_stacker.StandardStackerDeviceDriver; import org.nl.config.SpringContextHolder; import org.nl.config.lucene.service.LuceneExecuteLogService; import org.nl.config.lucene.service.dto.LuceneLogDto; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/StorageTypeEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/StorageTypeEnum.java index 0dd843f..12c334c 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/StorageTypeEnum.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/enums/StorageTypeEnum.java @@ -8,7 +8,7 @@ import lombok.Getter; @Getter @AllArgsConstructor public enum StorageTypeEnum { - STORAGE("1", "装箱入库任务"), + STORAGE("1", "装箱入库任务"), DISKS_IN("2", "空盘入库"), @@ -18,7 +18,11 @@ public enum StorageTypeEnum { BOX_IN("5", "木箱入库"), - BOX_RETURN("6", "退货入库"); + BOX_RETURN("6", "退货入库"), + + BOX_RETURN_HJ("7", "退货异常申请行架任务"), + + PACK_ERROR("8", "装箱异常申请任务"); /** * 索引 */ diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index 3d5ad9e..ef4eec1 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -10,22 +10,18 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; -import lombok.Builder; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.nl.acs.AcsConfig; import org.nl.acs.device.domain.Device; -import org.nl.acs.device.enums.DeviceType; -import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.agv.ndctwo.AgvNdcTwoDeviceDriver; -import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.belt_conveyor.BeltConveyorDeviceDriver; import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver; import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.one_conveyor.box_subvolumes_conveyor.BoxSubvolumesConveyorDeviceDriver; -import org.nl.acs.device_driver.one_conveyor.fold_disc_site.FoldDiscSiteDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.box_subvolumes_conveyor.BoxSubvolumesConveyorDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.fold_disc_site.FoldDiscSiteDeviceDriver; import org.nl.acs.device_driver.one_manipulator.box_package_manipulator.BoxPackageManipulatorDeviceDriver; import org.nl.acs.device_driver.conveyor.box_palletizing_manipulator.BoxPalletizingManipulatorDeviceDriver; -import org.nl.acs.device_driver.one_manipulator.trapped_manipulator.TrappedManipulatorManipulatorDeviceDriver; +import org.nl.acs.device_driver.lk_manipulator.trapped_manipulator.TrappedManipulatorManipulatorDeviceDriver; import org.nl.acs.device_driver.paper_tube_device2.PaperTubeConveyor2DeviceDriver; import org.nl.acs.device_driver.paper_tube_pick_site.PaperTubePickSiteDeviceDriver; import org.nl.acs.device_driver.two_conveyor.blank_manipulator.BlankManipulatorDeviceDriver; @@ -39,7 +35,6 @@ import org.nl.acs.device_driver.two_conveyor.subvolume_weighing_station.Subvolum import org.nl.acs.device_driver.two_conveyor.waste_foil_weighing_station.WasteFoilWeighingStationDriver; import org.nl.acs.ext.wms.data.*; -import org.nl.acs.ext.wms.liKuData.Resp; import org.nl.acs.ext.wms.service.AcsToLiKuService; import org.nl.acs.ext.wms.service.WmsToAcsService; @@ -50,12 +45,10 @@ import org.nl.acs.storage_cell.domain.StorageCell; import org.nl.acs.storage_cell.service.mapper.StorageCellMapper; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; -import org.nl.common.enums.LogTypeEnum; 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 org.nl.config.lucene.service.impl.LuceneExecuteLogServiceImpl; import org.nl.system.service.param.ISysParamService; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; @@ -581,20 +574,20 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { Device mxddhj1 = deviceAppService.findDeviceByCode("MXDDHJ1"); trappedManipulatorManipulatorDeviceDriver = (TrappedManipulatorManipulatorDeviceDriver) mxddhj1.getDeviceDriver(); if (StrUtil.equals(device_code, "CK2020")) { - Map map1 = new HashMap<>(); - List list = new ArrayList(); - map1.put("code", "to_command"); - map1.put("value", 2020); - list.add(map1); - trappedManipulatorManipulatorDeviceDriver.writing(list); +// Map map1 = new HashMap<>(); +// List list = new ArrayList(); +// map1.put("code", "to_command"); +// map1.put("value", 2020); +// list.add(map1); +// trappedManipulatorManipulatorDeviceDriver.writing(list); } if (StrUtil.equals(device_code, "CK2022")) { - Map map2 = new HashMap<>(); - List list = new ArrayList(); - map2.put("code", "to_command"); - map2.put("value", 2022); - list.add(map2); - trappedManipulatorManipulatorDeviceDriver.writing(list); +// Map map2 = new HashMap<>(); +// List list = new ArrayList(); +// map2.put("code", "to_command"); +// map2.put("value", 2022); +// list.add(map2); +// trappedManipulatorManipulatorDeviceDriver.writing(list); } } if (device.getDeviceDriver() instanceof InflatableShaftLibraryDeviceDriver) { @@ -603,12 +596,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { } if (device.getDeviceDriver() instanceof FoldDiscSiteDeviceDriver) { foldDiscSiteDeviceDriver = (FoldDiscSiteDeviceDriver) device.getDeviceDriver(); - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", code); - map.put("value", value); - list.add(map); - foldDiscSiteDeviceDriver.writing(list); + foldDiscSiteDeviceDriver.writing(code,value); } if (device.getDeviceDriver() instanceof WasteFoilWeighingStationDriver) { wasteFoilWeighingStationDriver = (WasteFoilWeighingStationDriver) device.getDeviceDriver(); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java index 75a9c70..4d6ba10 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java @@ -186,8 +186,6 @@ public interface InstructionService extends CommonService { void create(Instruction dto) throws Exception; - - /** * 创建2 * @@ -367,6 +365,7 @@ public interface InstructionService extends CommonService { /** * 根据终点查询指令 + * * @param devicecode * @return */ @@ -495,13 +494,28 @@ public interface InstructionService extends CommonService { */ Boolean querySameNextDeviceCodeInstByOut(String nextDeviceCode); - List findByCodeAndExcute(String nextDeviceCode); + List findByCodeAndExcute(String nextDeviceCode); List findByNextCode(String nextDeviceCode); List findReadyIns(); + List findReadyIns2(); Instruction findByStarCodeAndExcute(String deviceCode); + + Instruction findByStartAndNextDeviceCode(String deviceCode); + + Instruction findByStartDeviceCode(String deviceCode); + + Instruction findByNextDeviceCode(String deviceCode); + + void cancelInstAndTask(String instruction_id) throws Exception; + + void cancelInstAndTaskNoSendWms(String instruction_id); + + Instruction findByTaskCodeFromCache(String task_code); + + Instruction findReadyInstByEnd(String deviceCode); } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index b240290..e36276e 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -2,7 +2,6 @@ package org.nl.acs.instruction.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; @@ -19,8 +18,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; -import org.nl.acs.AcsConfig; -import org.nl.acs.agv.server.MagicAgvService; import org.nl.acs.agv.server.NDCAgvService; import org.nl.acs.agv.server.XianGongAgvService; import org.nl.acs.auto.initial.ApplicationAutoInitial; @@ -31,7 +28,7 @@ import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.impl.DeviceServiceImpl; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.belt_conveyor.BeltConveyorDeviceDriver; import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver; import org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; import org.nl.acs.device_driver.conveyor.standard_inspect_site.StandardInspectSiteDeviceDriver; @@ -84,11 +81,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Pageable; import javax.servlet.http.HttpServletResponse; -import java.io.DataInputStream; -import java.io.DataOutputStream; import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.Socket; import java.util.*; import java.util.concurrent.CopyOnWriteArrayList; import java.util.regex.Pattern; @@ -2096,6 +2089,30 @@ public class InstructionServiceImpl extends CommonServiceImpl optionalInstruction = instructions.stream() + .filter(instruction -> StrUtil.equals(instruction.getStart_device_code(), deviceCode) + || StrUtil.equals(instruction.getNext_device_code(), deviceCode)) + .findFirst(); + return optionalInstruction.orElse(null); + } + + @Override + public Instruction findByStartDeviceCode(String deviceCode) { + Optional optionalInstruction = instructions.stream() + .filter(instruction -> StrUtil.equals(instruction.getStart_device_code(), deviceCode)) + .findFirst(); + return optionalInstruction.orElse(null); + } + + @Override + public Instruction findByNextDeviceCode(String deviceCode) { + Optional optionalInstruction = instructions.stream() + .filter(instruction -> StrUtil.equals(instruction.getNext_device_code(), deviceCode)) + .findFirst(); + return optionalInstruction.orElse(null); + } public List findReadyInstructions() { @@ -2190,5 +2207,57 @@ public class InstructionServiceImpl extends CommonServiceImpl()) + .stream() + .filter(inst -> StrUtil.equals(inst.getTask_code(), task_code)) + .findFirst() + .orElse(null); + } + + @Override + public Instruction findReadyInstByEnd(String next_device_code) { + return Optional.ofNullable(this.instructions) + .orElse(new CopyOnWriteArrayList<>()) + .stream() + .filter(inst -> inst.getInstruction_status().equals(InstructionStatusEnum.READY.getIndex())) + .filter(inst -> inst.getNext_device_code().equals(next_device_code)) + .findFirst().orElse(null); + } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java index febe698..7781c52 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java @@ -93,10 +93,10 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable { for (int i = 0; !OpcStartTag.is_run; ++i) { log.info("设备执行线程等待opc同步线程..."); Thread.sleep(1000L); - if (i > 60) { + if (i > 1) { UnifiedDataAccessor accessor_value = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key); if (accessor_value.getAllKey().size() < 1) { - autoRunService.startThread("DeviceOpcSynchronizeAutoRun"); + //autoRunService.startThread("DeviceOpcSynchronizeAutoRun"); } log.info("设备执行线程放弃等待opc同步线程..."); break; 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 3a25867..a718ce5 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 @@ -586,4 +586,10 @@ public interface TaskService extends CommonService { TaskDto findByTaskCode(String task_code); List queryAllHJReadyTask(); + + void cancelNoSendWms(String task_id); + + List findInstsByNextDeviceCode(String deviceCode); + + TaskDto findReadyTaskByNextDeviceCode(String deviceCode, List checkoutStartDeviceCode); } 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 2c2ff48..22dbc5c 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 @@ -74,6 +74,8 @@ import org.springframework.data.domain.Pageable; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CopyOnWriteArrayList; @@ -130,8 +132,6 @@ public class TaskServiceImpl extends CommonServiceImpl impleme private static final String BQHJ_TYPE = "6"; - - @Override public PageInfo queryAll(TaskQueryParam query, Pageable pageable) { IPage queryPage = PageUtil.toMybatisPage(pageable); @@ -439,7 +439,7 @@ public class TaskServiceImpl extends CommonServiceImpl impleme public TaskDto findByBarcodeFromCache(String barcode) { Task task = new LambdaQueryChainWrapper<>(taskMapper) .eq(Task::getVehicle_code, barcode) - .eq(Task::getTask_status,TaskStatusEnum.READY.getIndex()) + .eq(Task::getTask_status, TaskStatusEnum.READY.getIndex()) .one(); return ConvertUtil.convert(task, TaskDto.class); } @@ -491,10 +491,10 @@ public class TaskServiceImpl extends CommonServiceImpl impleme && StrUtil.equals(task.getTask_status(), TaskStatusEnum.BUSY.getIndex())) .filter(task -> instructionService.findByTaskcodeAndStatus(task.getTask_code()) != null) .collect(Collectors.toList()); - if(CollUtil.isEmpty(collect)){ + if (CollUtil.isEmpty(collect)) { tasks.forEach( - task ->{ - if(TASK_TYPE.equals(task.getTask_type()) && StrUtil.isNotEmpty(task.getPut_device_code())){ + task -> { + if (TASK_TYPE.equals(task.getTask_type()) && 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)) { @@ -521,10 +521,10 @@ public class TaskServiceImpl extends CommonServiceImpl impleme && StrUtil.equals(task.getTask_status(), TaskStatusEnum.BUSY.getIndex())) .filter(task -> instructionService.findByTaskcodeAndStatus(task.getTask_code()) != null) .collect(Collectors.toList()); - if(CollUtil.isEmpty(collect)){ + if (CollUtil.isEmpty(collect)) { tasks.forEach( - task ->{ - if(BQHJ_TYPE.equals(task.getTask_type()) && StrUtil.isNotEmpty(task.getPut_device_code())){ + task -> { + if (BQHJ_TYPE.equals(task.getTask_type()) && 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)) { @@ -933,7 +933,7 @@ public class TaskServiceImpl extends CommonServiceImpl impleme //反馈上位系统任务状态 this.feedWmsTaskStatus(entity); //关闭仙工运单序列 - if(StrUtil.equals(task.getTask_type(),TaskTypeEnum.Standard_AGV_Task.getCode()) && (StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.One_NDC_System_Type.getCode())||StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.XG_System_Type.getCode()))) { + if (StrUtil.equals(task.getTask_type(), TaskTypeEnum.Standard_AGV_Task.getCode()) && (StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.One_NDC_System_Type.getCode()) || StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.XG_System_Type.getCode()))) { this.markComplete(entity); } } @@ -965,7 +965,7 @@ public class TaskServiceImpl extends CommonServiceImpl impleme //反馈上位系统任务状态 // this.feedWmsTaskStatus(entity); //关闭仙工运单序列 - if(StrUtil.equals(task.getTask_type(),TaskTypeEnum.Standard_AGV_Task.getCode()) && (StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.One_NDC_System_Type.getCode())||StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.XG_System_Type.getCode()))) { + if (StrUtil.equals(task.getTask_type(), TaskTypeEnum.Standard_AGV_Task.getCode()) && (StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.One_NDC_System_Type.getCode()) || StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.XG_System_Type.getCode()))) { this.markComplete(entity); } } @@ -997,7 +997,7 @@ public class TaskServiceImpl extends CommonServiceImpl impleme //反馈上位系统任务状态 this.feedWmsTaskStatus(entity); //关闭仙工运单序列 - if(StrUtil.equals(task.getTask_type(),TaskTypeEnum.Standard_AGV_Task.getCode()) && (StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.One_NDC_System_Type.getCode())||StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.XG_System_Type.getCode()))) { + if (StrUtil.equals(task.getTask_type(), TaskTypeEnum.Standard_AGV_Task.getCode()) && (StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.One_NDC_System_Type.getCode()) || StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.XG_System_Type.getCode()))) { this.markComplete(entity); } } @@ -1052,9 +1052,9 @@ public class TaskServiceImpl extends CommonServiceImpl impleme for (int m = 0; m < pathlist.size(); m++) { if (pathlist.get(m).equals(start_device_code)) { //起点为货架跳过堆垛机 - if (startDevice.getDeviceDriver() instanceof StandardStorageDeviceDriver ) { + if (startDevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) { index = m + 2; - }else { + } else { index = m + 1; } break; @@ -1273,13 +1273,12 @@ public class TaskServiceImpl extends CommonServiceImpl impleme public TaskDto findByStarCodeAndExcute(String start_code) { Optional optionalTask = tasks.stream() .filter(task -> StrUtil.equals(task.getStart_device_code(), start_code) - && (StrUtil.equals(task.getTask_status(), TaskStatusEnum.BUSY.getIndex())||StrUtil.equals(task.getTask_status(), TaskStatusEnum.READY.getIndex()))) + && (StrUtil.equals(task.getTask_status(), TaskStatusEnum.BUSY.getIndex()) || StrUtil.equals(task.getTask_status(), TaskStatusEnum.READY.getIndex()))) .findFirst(); return optionalTask.orElse(null); } - @Override public TaskDto findByEndCodeAndReady(String device_code) { Optional optionalTask = tasks.stream() @@ -1826,4 +1825,69 @@ public class TaskServiceImpl extends CommonServiceImpl impleme } + @Override + public void cancelNoSendWms(String task_id) { + TaskDto entity = this.findById(task_id); + if (entity == null) { + throw new BadRequestException(LangProcess.msg("error_sysAuth")); + } + InstructionDto instdto = instructionService.findByTaskid(task_id, "instruction_status <2 "); + if (instdto != null) { + throw new BadRequestException(LangProcess.msg("task_insRun")); + } + taskMapper.deleteById(task_id); + //移除任务缓存信息 + this.removeByCodeFromCache(entity.getTask_code()); + } + + @Override + public List findInstsByNextDeviceCode(String deviceCode) { + return Optional.ofNullable(this.tasks) + .orElse(new CopyOnWriteArrayList<>()) + .stream() + .filter(taskDto -> taskDto.getNext_device_code().equals(deviceCode)) + .filter(taskDto -> taskDto.getTask_status().equals(TaskStatusEnum.BUSY.getIndex())) + .collect(Collectors.toList()); + } + + @Override + public TaskDto findReadyTaskByNextDeviceCode(String next_device_code, List checkoutStartDeviceCode) { + return Optional.ofNullable(this.tasks) + .orElse(new CopyOnWriteArrayList<>()) + .stream() + .filter(taskDto -> TaskStatusEnum.READY.getIndex().equals(taskDto.getTask_status())) + .filter(taskDto -> taskDto.getNext_device_code().equals(next_device_code)) + .filter(taskDto -> !checkoutStartDeviceCode.contains(taskDto.getStart_device_code())) + .sorted( + Comparator + .comparingInt((TaskDto taskDto) -> + taskDto.getPriority() != null && !taskDto.getPriority().isEmpty() ? + Integer.parseInt(taskDto.getPriority()) : + 1) + .reversed() + .thenComparing(taskDto -> LocalDateTime.parse(taskDto.getCreate_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))) + .thenComparing(taskDto -> { + String startDeviceCode = taskDto.getStart_device_code(); + String numericPart = getNumericPart(startDeviceCode); + int location = Integer.parseInt(numericPart); + if (location % 4 == 2 || location % 4 == 3) { + return 0; + } else { + return 1; + } + }) + ) + .findFirst() + .orElse(null); + } + + private String getNumericPart(String device_c0de) { + Pattern pattern = Pattern.compile("\\d+"); + Matcher matcher = pattern.matcher(device_c0de); + if (matcher.find()) { + return matcher.group(); + } + return "0"; + } + } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/taskscreen/service/impl/TaskScreenServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/taskscreen/service/impl/TaskScreenServiceImpl.java index 5df32fb..8d5c627 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/taskscreen/service/impl/TaskScreenServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/taskscreen/service/impl/TaskScreenServiceImpl.java @@ -17,8 +17,8 @@ import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.dto.DeviceDto; import org.nl.acs.device.service.mapper.DeviceExtraMapper; import org.nl.acs.device.service.mapper.DeviceMapper; -import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; -import org.nl.acs.device_driver.one_conveyor.scanner_weight_conveyor.ConveyorWithScannerWeightDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.belt_conveyor.BeltConveyorDeviceDriver; +import org.nl.acs.device_driver.lk_conveyor.scanner_weight_conveyor.ConveyorWithScannerWeightDeviceDriver; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.taskscreen.mapper.TaskScreenMapper; import org.nl.acs.taskscreen.service.TaskScreenService; @@ -97,7 +97,7 @@ public class TaskScreenServiceImpl extends CommonServiceImpl byCodeAndExcute = instructionService.findByNextCode(next_device_code); if (CollUtil.isNotEmpty(byCodeAndExcute)){ - ((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("有DDJ对接位为终点的指令"); + // ((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("有DDJ对接位为终点的指令"); continue; } instdto.setInstruction_type(task_type); @@ -323,7 +321,7 @@ public class CreateDDJInst { //判断有没有DDJ对接位出入库的指令,只判断终点 List byCodeAndExcute = instructionService.findByNextCode(next_device_code); if (CollUtil.isNotEmpty(byCodeAndExcute)){ - ((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("有DDJ对接位为终点的指令"); + // ((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("有DDJ对接位为终点的指令"); continue; } instdto.setInstruction_type(task_type); 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 4d06b06..4b7b8e5 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 @@ -3,18 +3,18 @@ server: #配置数据源 spring: messages: - basename: language/login/login,language/error/error,language/buss/buss + basename: language/login/login,language/error/error,language/buss/buss,language/monitor/universal/universal datasource: druid: 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:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true + url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:ynhl_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true username: ${DB_USER:root} # password: ${DB_PWD:Root.123456} - password: ${DB_PWD:123456} + password: ${DB_PWD:password} # 初始连接数 initial-size: 5 # 最小连接数 diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/config/application.yml b/acs2/nladmin-system/nlsso-server/src/main/resources/config/application.yml index d0a0b34..38da9c6 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/config/application.yml +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/config/application.yml @@ -6,7 +6,7 @@ spring: freemarker: check-template-location: false profiles: - active: prod + active: dev jackson: time-zone: GMT+8 data: @@ -116,7 +116,7 @@ rsa: private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A== logging: file: - path: C:\log\wms + path: /Users/onepiece/logs/acs_logs config: classpath:logback-spring.xml # sa-token白名单配置 security: diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal.properties b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal.properties index 392bdda..592da4f 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal.properties +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal.properties @@ -71,6 +71,191 @@ universal_actionMessage6=\u5141\u8BB8\u53D6 universal_actionMessage7=\u5141\u8BB8\u653E universal_directives=\u6307\u4EE4 +#\u5927\u5C4F\u5C55\u793A\u901A\u7528\u4FE1\u606F +1001=\u662F +1002=\u5426 +1003=\u6267\u884C\u4E2D +1004=\u5DF2\u7ED3\u675F +1005=\u8BBE\u5907\u7EBF\u7A0B\u6267\u884C\u62A5\u9519, \u9519\u8BEF\u8BE6\u60C5\u8BF7\u67E5\u770B\u8BBE\u5907\u65E5\u5FD7\u3002 +1006=\u521B\u5EFA\u6307\u4EE4\u65F6\u51FA\u73B0\u5F02\u5E38, \u9519\u8BEF\u8BE6\u60C5\u8BF7\u67E5\u770B\u8BBE\u5907\u65E5\u5FD7\u3002 +1007=\u53C2\u6570\u957F\u5EA6\u4E0D\u4E00\u81F4,\u4E0D\u5141\u8BB8\u4E0B\u53D1\u3002 +1008=\u8BBE\u5907\u4FE1\u606F\u672A\u914D\u7F6E\u3002 +1009=\u8DEF\u7531\u4E0D\u901A\u3002 +1010=\u672A\u77E5 +#\u5806\u579B\u673A\u4FE1\u606F\u5C55\u793A +#\u5806\u579B\u673A\u8BBE\u5907\u8FD0\u884C\u4FE1\u606F +100000=\u8BBE\u5907\u79BB\u7EBF +100001=\u7EF4\u4FEE +100002=\u624B\u52A8 +100003=\u5355\u673A\u81EA\u52A8 +100004=\u8054\u673A\u81EA\u52A8 +100005=\u4E0D\u660E +100006=\u8BBE\u5907\u672A\u8054\u673A +#\u5806\u579B\u673A\u8BBE\u5907\u62A5\u8B66\u4FE1\u606F +200000=\u8BBE\u5907\u62A5\u8B66\uFF1A\u65E0\u6545\u969C\u3002 +200001=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D27\u4F4D\u8D85\u9650\u3002 +200002=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5806\u579B\u673A\u672A\u505C\u51C6\u3002 +200003=\u8BBE\u5907\u62A5\u8B66\uFF1A\u4E0E\u8F93\u9001\u7EBF\u901A\u8BAF\u6545\u969C\u3002 +200004=\u8BBE\u5907\u62A5\u8B66\uFF1A\u4F20\u9001\u5730\u5740\u9519\u8BEF\u3002 +200005=\u8BBE\u5907\u62A5\u8B66\uFF1A\u6EE1\u5165\u3002 +200006=\u8BBE\u5907\u62A5\u8B66\uFF1A\u7A7A\u51FA\u3002 +200007=\u8BBE\u5907\u62A5\u8B66\uFF1A\u884C\u8D70\u53D8\u9891\u5668\u62A5\u8B66\u3002 +200008=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5347\u964D\u53D8\u9891\u5668\u62A5\u8B66\u3002 +200009=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D27\u53C9\u53D8\u9891\u5668\u62A5\u8B66\u3002 +200010=\u8BBE\u5907\u62A5\u8B66\uFF1A\u884C\u8D70\u8D85\u65F6\u3002 +200011=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5347\u964D\u8D85\u65F6\u3002 +200012=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D27\u53C9\u8D85\u65F6\u3002 +200013=\u8BBE\u5907\u62A5\u8B66\uFF1A\u6C34\u5E73\u6D4B\u8DDD\u51FA\u9519\u3002 +200014=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5782\u76F4\u6D4B\u8DDD\u51FA\u9519\u3002 +200015=\u8BBE\u5907\u62A5\u8B66\uFF1A\u653E\u8D27\u5F02\u5E38\u3002 +200016=\u8BBE\u5907\u62A5\u8B66\uFF1A\u963B\u6321/\u6D45\u8D27\u4F4D\u6709\u8D27\u3002 +200017=\u8BBE\u5907\u62A5\u8B66\uFF1A\u70DF\u611F\u62A5\u8B66\u3002 +200018=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D27\u53C9\u6570\u636E\u51FA\u9519\u3002 +200019=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D27\u53C9\u5DE6\u8D85\u9650\u3002 +200020=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D27\u53C9\u53F3\u8D85\u9650\u3002 +200021=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D27\u53C9\u4F38\u53C9\u53D7\u963B\u3002 +200022=\u8BBE\u5907\u62A5\u8B66\uFF1A\u4F4E\u4F4D\u4E0A\u5347\u8FC7\u5934\u62A5\u8B66\u3002 +200023=\u8BBE\u5907\u62A5\u8B66\uFF1A\u9AD8\u4F4D\u4E0B\u964D\u8FC7\u5934\u62A5\u8B66\u3002 +200024=\u8BBE\u5907\u62A5\u8B66\uFF1A\u677E\u7EF3\u4FDD\u62A4\u3002 +200025=\u8BBE\u5907\u62A5\u8B66\uFF1A\u6025\u505C\u89E6\u53D1\u3002 +200026=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5B89\u5168\u95E8\u6253\u5F00\u3002 +200027=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5DE6\u7EA2\u5916\u6E29\u611F\u62A5\u8B66\u3002 +200028=\u8BBE\u5907\u62A5\u8B66\uFF1A\u53F3\u7EA2\u5916\u6E29\u611F\u63A2\u6D4B\u3002 +200029=\u8BBE\u5907\u62A5\u8B66\uFF1A\u6267\u884C\u70DF\u611F\u63A2\u6D4B\u3002 +200030=\u8BBE\u5907\u62A5\u8B66\uFF1A\u653E\u8D27\u5B8C\u6210\u786E\u8BA4\u8D85\u65F6\u3002 +200031=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5BF9\u63A5\u8BBE\u5907\u4E0D\u5141\u8BB8\u53D6/\u653E\u8D27\u3002 +200032=\u8BBE\u5907\u62A5\u8B66\uFF1A\u672A\u63A2\u6D4B\u5230\u68C0\u6D4B\u67DC\u3002 +200033=\u8BBE\u5907\u62A5\u8B66\uFF1A\u884C\u8D70\u8D85\u901F\u5EA6\u4FDD\u62A4\u89E6\u53D1\u3002 +200034=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5347\u964D\u8D85\u901F\u5EA6\u4FDD\u62A4\u89E6\u53D1\u3002 +200035=\u8BBE\u5907\u62A5\u8B66\uFF1A\u51CF\u901F\u5F00\u5173\u4FE1\u53F7\u5F02\u5E38\u3002 +200036=\u8BBE\u5907\u62A5\u8B66\uFF1A\u9632\u649E\u5F00\u5173\u88AB\u89E6\u78B0\u3002 +200037=\u8BBE\u5907\u62A5\u8B66\uFF1A\u9632\u649E\u6FC0\u5149\u88AB\u906E\u6321\u3002 +200038=\u8BBE\u5907\u62A5\u8B66\uFF1A\u9AD8\u8D27\u7269\u7981\u6B62\u653E\u5165\u77EE\u5E93\u4F4D\u3002 +200040=\u8BBE\u5907\u62A5\u8B66\uFF1A\u6C34\u5E73\u5B9A\u4F4D\u66F2\u7EBF\u6545\u969C\u3002 +200041=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D77\u5347\u5B9A\u4F4D\u66F2\u7EBF\u6545\u969C\u3002 +#\u5806\u579B\u673A\u8BBE\u5907\u672A\u6267\u884C\u4EFB\u52A1\u539F\u56E0 +300001=\u524D\u53C9\u548C\u540E\u53C9\u4EFB\u52A1\u53F7\u76F8\u540C, \u4E0D\u6267\u884C\u540E\u7EED\u547D\u4EE4\u3002 +300002=\u8BE5\u5806\u579B\u673A\u8BBE\u5907\u5DF2\u8BBE\u7F6E\u4E3A\u505C\u6B62\u63A5\u6536\u4EFB\u52A1, \u5982\u9700\u5F00\u59CB\u63A5\u6536\u4EFB\u52A1, \u8BF7\u5728\u76D1\u63A7\u5927\u5C4F\u4E0A\u5173\u95ED\u505C\u6B62\u63A5\u6536\u4EFB\u52A1\u3002 +300004=\u672A\u6267\u884C\u53D6\u8D27\u539F\u56E0, \u5806\u579B\u673A\u4E0A\u62A5\u4EFB\u52A1\u53F7\u4E0D\u5B58\u5728\u3002 +300005=\u672A\u6267\u884C\u653E\u8D27\u539F\u56E0, \u5806\u579B\u673A\u4E0A\u62A5\u4EFB\u52A1\u53F7\u4E0D\u5B58\u5728\u3002 +300006=\u6EE1\u5165\u6267\u884C\u5931\u8D25, \u5931\u8D25\u8BE6\u60C5\u8BF7\u67E5\u770B\u63A5\u53E3\u65E5\u5FD7\u3002 +300007=\u7A7A\u51FA\u6267\u884C\u5931\u8D25, \u5931\u8D25\u8BE6\u60C5\u8BF7\u67E5\u770B\u63A5\u53E3\u65E5\u5FD7\u3002 +300008=\u53D6\u8D27\u65F6\u6D45\u8D27\u4F4D\u6709\u8D27\u6267\u884C\u5931\u8D25, \u5931\u8D25\u8BE6\u60C5\u8BF7\u67E5\u770B\u63A5\u53E3\u65E5\u5FD7\u3002 +300009=\u653E\u8D27\u65F6\u6D45\u8D27\u4F4D\u6709\u8D27\u6267\u884C\u5931\u8D25, \u5931\u8D25\u8BE6\u60C5\u8BF7\u67E5\u770B\u63A5\u53E3\u65E5\u5FD7\u3002 +#\u5806\u579B\u673A\u52A8\u4F5C\u4FE1\u606F +400001=\u5F85\u673A +400002=\u53D6\u8D27\u4E2D +400003=\u53D6\u8D27\u5B8C\u6210 +400004=\u653E\u8D27\u4E2D +400005=\u8BF7\u6C42\u5378\u8D27 +400006=\u5378\u8D27\u5B8C\u6210 +400007=\u53D6\u8D27\u51C6\u5907 +400008=\u53EC\u56DE +400009=\u6025\u505C +400010=\u4E0D\u660E +400011=\u76D8\u5E93\u4E2D +400012=\u76D8\u5E93\u5B8C\u6210 +#\u5806\u579B\u673A\u6267\u884C\u7B56\u7565 +500001=\u5165\u5E93\u4F18\u5148 +500002=\u51FA\u5E93\u4F18\u5148 +500003=\u4E00\u8FDB\u4E00\u51FA(\u4F18\u5148\u7EA7->\u65F6\u95F4) +500004=\u672A\u77E5\u7B56\u7565 +#\u8F93\u9001\u7EBF\u5DE5\u4F5C\u6A21\u5F0F +110000=\u8131\u673A +110001=\u5F03\u7528(\u7559\u4F5C\u517C\u5BB9) +110002=\u5F85\u673A +110003=\u8FD0\u884C\u4E2D +110004=\u7533\u8BF7\u5165\u5E93 +110005=\u7533\u8BF7\u8D34\u6807 +110006=\u7533\u8BF7\u6728\u7BB1\u88C5\u7BB1 +110007=\u7533\u8BF7\u5B50\u5377\u5165\u5E93 +110008=\u547C\u53EB\u7A7A\u6258\u76D8 +110009=\u7533\u8BF7\u7A7A\u76D8\u5165\u5E93 +110010=\u7533\u8BF7\u6346\u624E\u8D34\u6807\u4FE1\u606F +110011=\u672A\u77E5 +110012=\u7533\u8BF7\u8D34\u6807(\u672A\u8D34\u6807) +110013=\u7533\u8BF7\u6346\u624E\u8D34\u6807\u4FE1\u606F(\u672A\u6346\u624E) +110014=\u7533\u8BF7\u6346\u624E\u8D34\u6807\u4FE1\u606F(\u672A\u8D34\u6807) +110015=\u7533\u8BF7\u5F00\u76D6 +110016=\u7533\u8BF7\u6346\u624E\u8D34\u6807\u4FE1\u606F(\u672A\u6346\u624E\u3001\u672A\u8D34\u6807) +110017=\u7533\u8BF7\u8BD5\u6559\u8D34\u6807\u5B8C\u6210 +110018=\u7533\u8BF7\u9000\u8D27\u5165\u5E93 +110019=\u7533\u8BF7AGV\u4EFB\u52A1 +110020=\u672A\u77E5 +110021=\u672A\u77E5 +110022=\u672A\u77E5 +110023=\u7533\u8BF7\u9AD8\u5EA6\u7C7B\u578B +110024=\u9000\u8D27\u5F02\u5E38\u7533\u8BF7\u6841\u67B6\u4EFB\u52A1 +110025=\u88C5\u7BB1\u5F02\u5E38\u7533\u8BF7\u4EFB\u52A1 +#\u8F93\u9001\u7EBF\u62A5\u8B66\u4FE1\u606F +210000=\u65E0\u62A5\u8B66 +210001=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210002=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210003=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210004=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210005=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210006=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210007=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210008=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210009=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210010=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210011=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210012=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210013=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210014=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210015=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210016=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210017=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210018=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210019=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210020=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +#\u8F93\u9001\u7EBF\u672A\u6267\u884C\u4EFB\u52A1\u539F\u56E0 +310001=\u6258\u76D8\u7C7B\u578B\u4E3A\u7A7A +310002=\u4EFB\u52A1\u7533\u8BF7\u5931\u8D25,\u5931\u8D25\u8BE6\u60C5\u8BF7\u67E5\u770B\u63A5\u53E3\u65E5\u5FD7 +310003=\u67E5\u8BE2\u5230\u5C31\u7EEA\u6307\u4EE4, \u4F46\u6307\u4EE4\u7EC8\u70B9\u4E0D\u53EF\u8FBE +310004=\u67E5\u627E\u5230\u5BF9\u5E94\u7684\u4EFB\u52A1\u4FE1\u606F,\u6307\u4EE4\u6240\u5BF9\u5E94\u7684\u7EC8\u70B9\u662F\u53CC\u5411\u70B9\u4F4D\uFF0C\u5DF2\u7ECF\u5B58\u5728\u8BE5\u70B9\u4F4D\u7684\u53CD\u65B9\u5411\u4EFB\u52A1\uFF0C\u6240\u4EE5\u4E0D\u751F\u6210\u6307\u4EE4\uFF0C\u7A0D\u540E\u518D\u8BD5 +310005=\u8BE5\u8F93\u9001\u70B9\u4F4D, \u4E0D\u5141\u8BB8\u6839\u636E\u8D77\u70B9\u67E5\u627E\u4EFB\u52A1\u521B\u5EFA\u6307\u4EE4\u4FE1\u606F. +310006=\u67E5\u8BE2\u5230\u5C31\u7EEA\u4EFB\u52A1, \u751F\u6210\u6307\u4EE4\u65F6,\u6307\u4EE4\u7EC8\u70B9\u4E0D\u53EF\u8FBE +310007=\u7269\u6599\u6761\u7801\u4E3A\u7A7A +310008=\u672A\u5F00\u542F\u7533\u8BF7AGV\u4EFB\u52A1, \u5DF2\u81EA\u52A8\u53CD\u9988 +310009=\u5F53\u524D\u7535\u6C14\u4E0A\u62A5\u6307\u4EE4\u53F7\u6709\u8BEF\uFF0C\u9700\u8865\u7801\u91CD\u65B0\u7533\u8BF7\u6346\u624E\u8D34\u6807 +310010=\u624B\u8865\u6761\u7801\u5BF9\u5E94\u7684\u6307\u4EE4\u4FE1\u606F\u4E0D\u5B58\u5728 +310011=\u6307\u4EE4\u4FE1\u606F\u4E2D\u6258\u76D8\u7801\u4E3A\u7A7A +310012=\u6258\u76D8\u6761\u7801\u4E3A\u7A7A\u3001\u6216\u8005\u5B50\u5377\u7801\u4E3A\u7A7A +310013=\u624B\u8865\u6761\u7801\u548CPLC\u4E0A\u62A5\u6761\u7801\u90FD\u4E3A\u7A7A,\u4EFB\u52A1\u67E5\u627E\u7ED3\u675F +310014=\u6307\u4EE4\u5BF9\u5E94\u7684\u8F7D\u5177\u53F7\u4E3A\u7A7A,\u4E0D\u5141\u8BB8\u5F00\u76D6\u7533\u8BF7 +310015=\u7533\u8BF7\u5F00\u76D6\u65F6\u6307\u4EE4\u5B8C\u6210\u5931\u8D25 +#\u6841\u67B6\u8BBE\u5907\u8FD0\u884C\u4FE1\u606F +120000=\u8131\u673A +120001=\u5F03\u7528(\u7559\u4F5C\u517C\u5BB9) +120002=\u5F85\u673A +120003=\u8FD0\u884C\u4E2D +#\u6841\u67B6\u62A5\u8B66\u4FE1\u606F +220000=\u65E0\u62A5\u8B66 +#\u672A\u6267\u884C\u4EFB\u52A1\u539F\u56E0 +320001=\u6841\u67B6\u4E0A\u62A5\u6307\u4EE4\u5DF2\u5728\u6267\u884C, \u4E0D\u5141\u8BB8\u4E0B\u53D1\u65B0\u7684\u6307\u4EE4\u4FE1\u606F! +320002=\u6307\u4EE4\u4FE1\u606F\u5BF9\u5E94\u7684\u4EFB\u52A1\u4FE1\u606F\u672A\u67E5\u627E\u5230 +320003=\u6841\u67B6\u672A\u914D\u7F6E\u53D6\u8D27\u70B9 +320004=\u6841\u67B6\u672A\u914D\u7F6E\u653E\u8D27\u70B9 +320005=\u672A\u67E5\u627E\u5230\u5C31\u7EEA\u4EFB\u52A1\u6307\u4EE4\u6216\u4EFB\u52A1\u4FE1\u606F +320006= +320007= +320008= +320009= +320010= +#\u52A8\u4F5C\u4FE1\u53F7 +420000=\u65E0\u52A8\u4F5C +420001=\u53D6\u8D27\u4E2D +420002=\u53D6\u8D27\u5B8C\u6210 +420003=\u653E\u8D27\u4E2D +420004=\u653E\u8D27\u5B8C\u6210 +420005=\u5F00\u76D6 +420006=\u5408\u76D6 +420007=\u5438\u5C18 +420008=\u653E\u5E72\u71E5\u5242 +420009=\u53E0\u6258\u76D8 +420010=\u8D34\u6807 +420011=\u6253\u9489 diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_en_US.properties b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_en_US.properties index 0cdab73..2c22e72 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_en_US.properties +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_en_US.properties @@ -69,5 +69,91 @@ universal_actionMessage7=\u5141\u8BB8\u653E universal_notCreateInstMessage7=ray type is empty! universal_notCreateInstMessage8=The barcode is blank\uFF01 universal_directives=Directives +#Universal Display Information +1001=Yes +1002=No +1003=In Progress +1004=Completed +#Stacker Crane Information Display +#Stacker Crane Operating Status +100000=Device Offline +100001=Maintenance +100002=Manual +100003=Standalone Auto +100004=Online Auto +100005=Unknown +100006=Device Not Connected +#Stacker Crane Alarm Information +200000=Alarm: No faults. +200001=Alarm: Location overflow. +200002=Alarm: Stacker misalignment. +200003=Alarm: Communication failure with conveyor. +200004=Alarm: Transfer address error. +200005=Alarm: Full-in error. +200006=Alarm: Empty-out error. +200007=Alarm: Travel inverter alarm. +200008=Alarm: Lift inverter alarm. +200009=Alarm: Fork inverter alarm. +200010=Alarm: Travel timeout. +200011=Alarm: Lift timeout. +200012=Alarm: Fork timeout. +200013=Alarm: Horizontal distance error. +200014=Alarm: Vertical distance error. +200015=Alarm: Discharge error. +200016=Alarm: Blocked or shallow location occupied. +200017=Alarm: Smoke detector alarm. +200018=Alarm: Fork data error. +200019=Alarm: Fork left limit exceeded. +200020=Alarm: Fork right limit exceeded. +200021=Alarm: Fork extension obstructed. +200022=Alarm: Over-rise at low position. +200023=Alarm: Over-drop at high position. +200024=Alarm: Loose rope protection. +200025=Alarm: Emergency stop triggered. +200026=Alarm: Safety door opened. +200027=Alarm: Left infrared temperature alarm. +200028=Alarm: Right infrared temperature detection. +200029=Alarm: Smoke detector triggered. +200030=Alarm: Discharge confirmation timeout. +200031=Alarm: Docking equipment not ready for load/unload. +200032=Alarm: Detection cabinet not found. +200033=Alarm: Travel overspeed protection triggered. +200034=Alarm: Lift overspeed protection triggered. +200035=Alarm: Deceleration switch error. +200036=Alarm: Anti-collision switch triggered. +200037=Alarm: Anti-collision laser blocked. +200038=Alarm: High cargo cannot be placed in low bay. +200040=Alarm: Horizontal positioning curve failure. +200041=Alarm: Lift positioning curve failure. +#Reasons Why the Stacker Crane Did Not Execute the Task +300001=Front and rear fork task numbers are the same, no further command executed. +300002=This stacker is set to stop receiving tasks. To resume, disable the stop mode on the monitoring screen. +300003=Error occurred while creating instruction. See logs for details. +300004=Pickup not executed: reported task number not found. +300005=Discharge not executed: reported task number not found. +300006=Full-in failed. See interface logs for details. +300007=Empty-out failed. See interface logs for details. +300008=Pickup failed due to shallow location occupied. See logs. +300009=Discharge failed due to shallow location occupied. See logs. +300010=Execution thread error. Check device logs for details. +#Stacker Crane Action Information +400001 = Standby +400002 = Picking +400003 = Pick Completed +400004 = Placing +400005 = Request Unload +400006 = Unload Completed +400007 = Pick Preparation +400008 = Recall +400009 = Emergency Stop +400010 = Unknown +400011 = Inventory Check in Progress +400012 = Inventory Check Completed +#Stacker Crane Execution Strategy +500001=Inbound Priority +500002=Outbound Priority +500003=One In, One Out (Priority \u2192 Time) +500004=Unknown Strategy + diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_in_ID.properties b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_in_ID.properties index e7b7df0..f6faecd 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_in_ID.properties +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_in_ID.properties @@ -69,3 +69,88 @@ universal_actionMessage7=\u5141\u8BB8\u653E universal_notCreateInstMessage7=ponypianmereka yang kosong! universal_notCreateInstMessage8=Kode batang kosong! universal_directives=Arahan +#Informasi Tampilan Umum +1001=Ya +1002=Tidak +1003=Sedang Berjalan +1004=Selesai +#Tampilan Informasi Stacker Crane +#Status Operasi Perangkat Stacker Crane +100000=Perangkat Offline +100001=Pemeliharaan +100002=Manual +100003=Otomatis Mandiri +100004=Otomatis Terhubung +100005=Tidak Diketahui +100006=Perangkat Belum Terhubung +#Informasi Alarm Perangkat Stacker Crane +200000=Alarm: Tidak ada kesalahan. +200001=Alarm: Posisi melebihi batas. +200002=Alarm: Posisi stacker tidak tepat. +200003=Alarm: Gangguan komunikasi dengan konveyor. +200004=Alarm: Kesalahan alamat pengiriman. +200005=Alarm: Gagal saat penuh masuk. +200006=Alarm: Gagal saat kosong keluar. +200007=Alarm: Alarm inverter perjalanan. +200008=Alarm: Alarm inverter pengangkatan. +200009=Alarm: Alarm inverter garpu. +200010=Alarm: Timeout perjalanan. +200011=Alarm: Timeout pengangkatan. +200012=Alarm: Timeout garpu. +200013=Alarm: Kesalahan pengukuran horizontal. +200014=Alarm: Kesalahan pengukuran vertikal. +200015=Alarm: Kesalahan saat meletakkan barang. +200016=Alarm: Terhalang atau lokasi dangkal terisi. +200017=Alarm: Alarm deteksi asap. +200018=Alarm: Kesalahan data garpu. +200019=Alarm: Batas kiri garpu terlampaui. +200020=Alarm: Batas kanan garpu terlampaui. +200021=Alarm: Ekstensi garpu terhalang. +200022=Alarm: Naik berlebih pada posisi rendah. +200023=Alarm: Turun berlebih pada posisi tinggi. +200024=Alarm: Perlindungan tali kendur. +200025=Alarm: Tombol darurat aktif. +200026=Alarm: Pintu pengaman terbuka. +200027=Alarm: Alarm suhu inframerah kiri. +200028=Alarm: Deteksi suhu inframerah kanan. +200029=Alarm: Deteksi asap aktif. +200030=Alarm: Timeout konfirmasi pelepasan barang. +200031=Alarm: Peralatan docking tidak mengizinkan muat/bongkar. +200032=Alarm: Lemari deteksi tidak ditemukan. +200033=Alarm: Perlindungan kecepatan berlebih perjalanan aktif. +200034=Alarm: Perlindungan kecepatan berlebih pengangkatan aktif. +200035=Alarm: Kesalahan sinyal saklar perlambatan. +200036=Alarm: Saklar anti-tabrakan aktif. +200037=Alarm: Laser anti-tabrakan terhalang. +200038=Alarm: Barang tinggi dilarang ditempatkan di rak rendah. +200040=Alarm: Kegagalan kurva posisi horizontal. +200041=Alarm: Kegagalan kurva posisi pengangkatan. +#Alasan Mengapa Stacker Crane Tidak Menjalankan Tugas +300001=Nomor tugas garpu depan dan belakang sama, perintah berikutnya tidak dijalankan. +300002=Perangkat ini disetel untuk berhenti menerima tugas. Untuk melanjutkan, nonaktifkan mode berhenti di layar pemantauan. +300003=Terjadi kesalahan saat membuat perintah. Lihat log perangkat untuk detailnya. +300004=Gagal mengambil barang: nomor tugas yang dilaporkan tidak ditemukan. +300005=Gagal meletakkan barang: nomor tugas yang dilaporkan tidak ditemukan. +300006=Gagal eksekusi penuh masuk. Lihat log antarmuka untuk detail. +300007=Gagal eksekusi kosong keluar. Lihat log antarmuka untuk detail. +300008=Gagal mengambil barang karena lokasi dangkal terisi. Lihat log. +300009=Gagal meletakkan barang karena lokasi dangkal terisi. Lihat log. +300010=Kesalahan pada thread eksekusi. Periksa log perangkat untuk detail. +#Informasi Aksi Stacker Crane +400001=Siaga +400002=Mengambil Barang +400003=Pengambilan Selesai +400004=Menempatkan Barang +400005=Permintaan Bongkar +400006=Pembongkaran Selesai +400007=Persiapan Pengambilan +400008=Panggilan Ulang +400009=Henti Darurat +400010=Tidak Diketahui +400011=Pemeriksaan Inventaris Sedang Berlangsung +400012=Pemeriksaan Inventaris Selesai +#Strategi Eksekusi Stacker Crane +500001=Prioritas Masuk +500002=Prioritas Keluar +500003=Satu Masuk, Satu Keluar (Prioritas \u2192 Waktu) +500004=Strategi Tidak Diketahui diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_zh_CN.properties b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_zh_CN.properties index 8684130..73de01a 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_zh_CN.properties +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/language/monitor/universal/universal_zh_CN.properties @@ -23,7 +23,6 @@ universal_remark5=\u53F3\u51FB\u8BE5\u56FE\u6807,\u5C06\u8BF7\u6C42\u4EFB\u52A1\ universal_remark6=\u524D\u5DE5\u4F4D\u6709\u8D27 universal_remark7=\u540E\u5DE5\u4F4D\u6709\u8D27 universal_remark8=\u8BFB\u53D6\u4FE1\u53F7\u503C\u65F6\u51FA\u73B0\u5F02\u5E38 - universal_message1=\u653E\u8D27\u5B8C\u6210 universal_message2=\u653E\u8D27\u5931\u8D25 universal_message3=\u6709\u62A5\u8B66 @@ -70,5 +69,196 @@ universal_notCreateInstMessage12=\u63D2\u62D4\u8F74\u5DE5\u4F4Daction!=1\uFF0C\u universal_notCreateInstMessage7=\u6258\u76D8\u7C7B\u578B\u4E3A\u7A7A! universal_notCreateInstMessage8=\u6761\u7801\u4E3A\u7A7A! universal_directives=\u6307\u4EE4 +#\u5927\u5C4F\u5C55\u793A\u901A\u7528\u4FE1\u606F +1001=\u662F +1002=\u5426 +1003=\u6267\u884C\u4E2D +1004=\u5DF2\u7ED3\u675F +1005=\u8BBE\u5907\u7EBF\u7A0B\u6267\u884C\u62A5\u9519, \u9519\u8BEF\u8BE6\u60C5\u8BF7\u67E5\u770B\u8BBE\u5907\u65E5\u5FD7\u3002 +1006=\u521B\u5EFA\u6307\u4EE4\u65F6\u51FA\u73B0\u5F02\u5E38, \u9519\u8BEF\u8BE6\u60C5\u8BF7\u67E5\u770B\u8BBE\u5907\u65E5\u5FD7\u3002 +1007=\u53C2\u6570\u957F\u5EA6\u4E0D\u4E00\u81F4,\u4E0D\u5141\u8BB8\u4E0B\u53D1\u3002 +1008=\u8BBE\u5907\u4FE1\u606F\u672A\u914D\u7F6E\u3002 +1009=\u8DEF\u7531\u4E0D\u901A\u3002 +1010=\u672A\u77E5 +1011=\u6709\u8D27 +1012=\u65E0\u8D27 +1013=\u4E0D\u5141\u8BB8\u53D6\u653E +1014=\u5141\u8BB8\u53D6\u653E +1015=\u5C0F\u6258\u76D8 +1016=\u5927\u6258\u76D8 +#\u5806\u579B\u673A\u4FE1\u606F\u5C55\u793A +#\u5806\u579B\u673A\u8BBE\u5907\u8FD0\u884C\u4FE1\u606F +100000=\u8BBE\u5907\u79BB\u7EBF +100001=\u7EF4\u4FEE +100002=\u624B\u52A8 +100003=\u5355\u673A\u81EA\u52A8 +100004=\u8054\u673A\u81EA\u52A8 +100005=\u4E0D\u660E +100006=\u8BBE\u5907\u672A\u8054\u673A +#\u5806\u579B\u673A\u8BBE\u5907\u62A5\u8B66\u4FE1\u606F +200000=\u8BBE\u5907\u62A5\u8B66\uFF1A\u65E0\u6545\u969C\u3002 +200001=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D27\u4F4D\u8D85\u9650\u3002 +200002=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5806\u579B\u673A\u672A\u505C\u51C6\u3002 +200003=\u8BBE\u5907\u62A5\u8B66\uFF1A\u4E0E\u8F93\u9001\u7EBF\u901A\u8BAF\u6545\u969C\u3002 +200004=\u8BBE\u5907\u62A5\u8B66\uFF1A\u4F20\u9001\u5730\u5740\u9519\u8BEF\u3002 +200005=\u8BBE\u5907\u62A5\u8B66\uFF1A\u6EE1\u5165\u3002 +200006=\u8BBE\u5907\u62A5\u8B66\uFF1A\u7A7A\u51FA\u3002 +200007=\u8BBE\u5907\u62A5\u8B66\uFF1A\u884C\u8D70\u53D8\u9891\u5668\u62A5\u8B66\u3002 +200008=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5347\u964D\u53D8\u9891\u5668\u62A5\u8B66\u3002 +200009=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D27\u53C9\u53D8\u9891\u5668\u62A5\u8B66\u3002 +200010=\u8BBE\u5907\u62A5\u8B66\uFF1A\u884C\u8D70\u8D85\u65F6\u3002 +200011=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5347\u964D\u8D85\u65F6\u3002 +200012=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D27\u53C9\u8D85\u65F6\u3002 +200013=\u8BBE\u5907\u62A5\u8B66\uFF1A\u6C34\u5E73\u6D4B\u8DDD\u51FA\u9519\u3002 +200014=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5782\u76F4\u6D4B\u8DDD\u51FA\u9519\u3002 +200015=\u8BBE\u5907\u62A5\u8B66\uFF1A\u653E\u8D27\u5F02\u5E38\u3002 +200016=\u8BBE\u5907\u62A5\u8B66\uFF1A\u963B\u6321/\u6D45\u8D27\u4F4D\u6709\u8D27\u3002 +200017=\u8BBE\u5907\u62A5\u8B66\uFF1A\u70DF\u611F\u62A5\u8B66\u3002 +200018=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D27\u53C9\u6570\u636E\u51FA\u9519\u3002 +200019=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D27\u53C9\u5DE6\u8D85\u9650\u3002 +200020=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D27\u53C9\u53F3\u8D85\u9650\u3002 +200021=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D27\u53C9\u4F38\u53C9\u53D7\u963B\u3002 +200022=\u8BBE\u5907\u62A5\u8B66\uFF1A\u4F4E\u4F4D\u4E0A\u5347\u8FC7\u5934\u62A5\u8B66\u3002 +200023=\u8BBE\u5907\u62A5\u8B66\uFF1A\u9AD8\u4F4D\u4E0B\u964D\u8FC7\u5934\u62A5\u8B66\u3002 +200024=\u8BBE\u5907\u62A5\u8B66\uFF1A\u677E\u7EF3\u4FDD\u62A4\u3002 +200025=\u8BBE\u5907\u62A5\u8B66\uFF1A\u6025\u505C\u89E6\u53D1\u3002 +200026=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5B89\u5168\u95E8\u6253\u5F00\u3002 +200027=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5DE6\u7EA2\u5916\u6E29\u611F\u62A5\u8B66\u3002 +200028=\u8BBE\u5907\u62A5\u8B66\uFF1A\u53F3\u7EA2\u5916\u6E29\u611F\u63A2\u6D4B\u3002 +200029=\u8BBE\u5907\u62A5\u8B66\uFF1A\u6267\u884C\u70DF\u611F\u63A2\u6D4B\u3002 +200030=\u8BBE\u5907\u62A5\u8B66\uFF1A\u653E\u8D27\u5B8C\u6210\u786E\u8BA4\u8D85\u65F6\u3002 +200031=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5BF9\u63A5\u8BBE\u5907\u4E0D\u5141\u8BB8\u53D6/\u653E\u8D27\u3002 +200032=\u8BBE\u5907\u62A5\u8B66\uFF1A\u672A\u63A2\u6D4B\u5230\u68C0\u6D4B\u67DC\u3002 +200033=\u8BBE\u5907\u62A5\u8B66\uFF1A\u884C\u8D70\u8D85\u901F\u5EA6\u4FDD\u62A4\u89E6\u53D1\u3002 +200034=\u8BBE\u5907\u62A5\u8B66\uFF1A\u5347\u964D\u8D85\u901F\u5EA6\u4FDD\u62A4\u89E6\u53D1\u3002 +200035=\u8BBE\u5907\u62A5\u8B66\uFF1A\u51CF\u901F\u5F00\u5173\u4FE1\u53F7\u5F02\u5E38\u3002 +200036=\u8BBE\u5907\u62A5\u8B66\uFF1A\u9632\u649E\u5F00\u5173\u88AB\u89E6\u78B0\u3002 +200037=\u8BBE\u5907\u62A5\u8B66\uFF1A\u9632\u649E\u6FC0\u5149\u88AB\u906E\u6321\u3002 +200038=\u8BBE\u5907\u62A5\u8B66\uFF1A\u9AD8\u8D27\u7269\u7981\u6B62\u653E\u5165\u77EE\u5E93\u4F4D\u3002 +200040=\u8BBE\u5907\u62A5\u8B66\uFF1A\u6C34\u5E73\u5B9A\u4F4D\u66F2\u7EBF\u6545\u969C\u3002 +200041=\u8BBE\u5907\u62A5\u8B66\uFF1A\u8D77\u5347\u5B9A\u4F4D\u66F2\u7EBF\u6545\u969C\u3002 +#\u5806\u579B\u673A\u8BBE\u5907\u672A\u6267\u884C\u4EFB\u52A1\u539F\u56E0 +300001=\u524D\u53C9\u548C\u540E\u53C9\u4EFB\u52A1\u53F7\u76F8\u540C, \u4E0D\u6267\u884C\u540E\u7EED\u547D\u4EE4\u3002 +300002=\u8BE5\u5806\u579B\u673A\u8BBE\u5907\u5DF2\u8BBE\u7F6E\u4E3A\u505C\u6B62\u63A5\u6536\u4EFB\u52A1, \u5982\u9700\u5F00\u59CB\u63A5\u6536\u4EFB\u52A1, \u8BF7\u5728\u76D1\u63A7\u5927\u5C4F\u4E0A\u5173\u95ED\u505C\u6B62\u63A5\u6536\u4EFB\u52A1\u3002 +300004=\u672A\u6267\u884C\u53D6\u8D27\u539F\u56E0, \u5806\u579B\u673A\u4E0A\u62A5\u4EFB\u52A1\u53F7\u4E0D\u5B58\u5728\u3002 +300005=\u672A\u6267\u884C\u653E\u8D27\u539F\u56E0, \u5806\u579B\u673A\u4E0A\u62A5\u4EFB\u52A1\u53F7\u4E0D\u5B58\u5728\u3002 +300006=\u6EE1\u5165\u6267\u884C\u5931\u8D25, \u5931\u8D25\u8BE6\u60C5\u8BF7\u67E5\u770B\u63A5\u53E3\u65E5\u5FD7\u3002 +300007=\u7A7A\u51FA\u6267\u884C\u5931\u8D25, \u5931\u8D25\u8BE6\u60C5\u8BF7\u67E5\u770B\u63A5\u53E3\u65E5\u5FD7\u3002 +300008=\u53D6\u8D27\u65F6\u6D45\u8D27\u4F4D\u6709\u8D27\u6267\u884C\u5931\u8D25, \u5931\u8D25\u8BE6\u60C5\u8BF7\u67E5\u770B\u63A5\u53E3\u65E5\u5FD7\u3002 +300009=\u653E\u8D27\u65F6\u6D45\u8D27\u4F4D\u6709\u8D27\u6267\u884C\u5931\u8D25, \u5931\u8D25\u8BE6\u60C5\u8BF7\u67E5\u770B\u63A5\u53E3\u65E5\u5FD7\u3002 +#\u5806\u579B\u673A\u52A8\u4F5C\u4FE1\u606F +400001=\u5F85\u673A +400002=\u53D6\u8D27\u4E2D +400003=\u53D6\u8D27\u5B8C\u6210 +400004=\u653E\u8D27\u4E2D +400005=\u8BF7\u6C42\u5378\u8D27 +400006=\u5378\u8D27\u5B8C\u6210 +400007=\u53D6\u8D27\u51C6\u5907 +400008=\u53EC\u56DE +400009=\u6025\u505C +400010=\u4E0D\u660E +400011=\u76D8\u5E93\u4E2D +400012=\u76D8\u5E93\u5B8C\u6210 +#\u5806\u579B\u673A\u6267\u884C\u7B56\u7565 +500001=\u5165\u5E93\u4F18\u5148 +500002=\u51FA\u5E93\u4F18\u5148 +500003=\u4E00\u8FDB\u4E00\u51FA(\u4F18\u5148\u7EA7->\u65F6\u95F4) +500004=\u672A\u77E5\u7B56\u7565 +#\u8F93\u9001\u7EBF\u5DE5\u4F5C\u6A21\u5F0F +110000=\u8131\u673A +110001=\u5F03\u7528(\u7559\u4F5C\u517C\u5BB9) +110002=\u5F85\u673A +110003=\u8FD0\u884C\u4E2D +110004=\u7533\u8BF7\u5165\u5E93 +110005=\u7533\u8BF7\u8D34\u6807 +110006=\u7533\u8BF7\u6728\u7BB1\u88C5\u7BB1 +110007=\u7533\u8BF7\u5B50\u5377\u5165\u5E93 +110008=\u547C\u53EB\u7A7A\u6258\u76D8 +110009=\u7533\u8BF7\u7A7A\u76D8\u5165\u5E93 +110010=\u7533\u8BF7\u6346\u624E\u8D34\u6807\u4FE1\u606F +110011=\u672A\u77E5 +110012=\u7533\u8BF7\u8D34\u6807(\u672A\u8D34\u6807) +110013=\u7533\u8BF7\u6346\u624E\u8D34\u6807\u4FE1\u606F(\u672A\u6346\u624E) +110014=\u7533\u8BF7\u6346\u624E\u8D34\u6807\u4FE1\u606F(\u672A\u8D34\u6807) +110015=\u7533\u8BF7\u5F00\u76D6 +110016=\u7533\u8BF7\u6346\u624E\u8D34\u6807\u4FE1\u606F(\u672A\u6346\u624E\u3001\u672A\u8D34\u6807) +110017=\u7533\u8BF7\u8BD5\u6559\u8D34\u6807\u5B8C\u6210 +110018=\u7533\u8BF7\u9000\u8D27\u5165\u5E93 +110019=\u7533\u8BF7AGV\u4EFB\u52A1 +110020=\u672A\u77E5 +110021=\u672A\u77E5 +110022=\u672A\u77E5 +110023=\u7533\u8BF7\u9AD8\u5EA6\u7C7B\u578B +110024=\u9000\u8D27\u5F02\u5E38\u7533\u8BF7\u6841\u67B6\u4EFB\u52A1 +110025=\u88C5\u7BB1\u5F02\u5E38\u7533\u8BF7\u4EFB\u52A1 +#\u8F93\u9001\u7EBF\u62A5\u8B66\u4FE1\u606F +210000=\u65E0\u62A5\u8B66 +210001=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210002=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210003=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210004=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210005=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210006=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210007=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210008=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210009=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210010=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210011=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210012=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210013=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210014=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210015=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210016=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210017=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210018=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210019=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +210020=\u8BBE\u5907\u62A5\u8B66:\u672A\u77E5 +#\u8F93\u9001\u7EBF\u672A\u6267\u884C\u4EFB\u52A1\u539F\u56E0 +310001=\u6258\u76D8\u7C7B\u578B\u4E3A\u7A7A +310002=\u4EFB\u52A1\u7533\u8BF7\u5931\u8D25,\u5931\u8D25\u8BE6\u60C5\u8BF7\u67E5\u770B\u63A5\u53E3\u65E5\u5FD7 +310003=\u67E5\u8BE2\u5230\u5C31\u7EEA\u6307\u4EE4, \u4F46\u6307\u4EE4\u7EC8\u70B9\u4E0D\u53EF\u8FBE +310004=\u67E5\u627E\u5230\u5BF9\u5E94\u7684\u4EFB\u52A1\u4FE1\u606F,\u6307\u4EE4\u6240\u5BF9\u5E94\u7684\u7EC8\u70B9\u662F\u53CC\u5411\u70B9\u4F4D\uFF0C\u5DF2\u7ECF\u5B58\u5728\u8BE5\u70B9\u4F4D\u7684\u53CD\u65B9\u5411\u4EFB\u52A1\uFF0C\u6240\u4EE5\u4E0D\u751F\u6210\u6307\u4EE4\uFF0C\u7A0D\u540E\u518D\u8BD5 +310005=\u8BE5\u8F93\u9001\u70B9\u4F4D, \u4E0D\u5141\u8BB8\u6839\u636E\u8D77\u70B9\u67E5\u627E\u4EFB\u52A1\u521B\u5EFA\u6307\u4EE4\u4FE1\u606F. +310006=\u67E5\u8BE2\u5230\u5C31\u7EEA\u4EFB\u52A1, \u751F\u6210\u6307\u4EE4\u65F6,\u6307\u4EE4\u7EC8\u70B9\u4E0D\u53EF\u8FBE +310007=\u7269\u6599\u6761\u7801\u4E3A\u7A7A +310008=\u672A\u5F00\u542F\u7533\u8BF7AGV\u4EFB\u52A1, \u5DF2\u81EA\u52A8\u53CD\u9988 +310009=\u5F53\u524D\u7535\u6C14\u4E0A\u62A5\u6307\u4EE4\u53F7\u6709\u8BEF\uFF0C\u9700\u8865\u7801\u91CD\u65B0\u7533\u8BF7\u6346\u624E\u8D34\u6807 +310010=\u624B\u8865\u6761\u7801\u5BF9\u5E94\u7684\u6307\u4EE4\u4FE1\u606F\u4E0D\u5B58\u5728 +310011=\u6307\u4EE4\u4FE1\u606F\u4E2D\u6258\u76D8\u7801\u4E3A\u7A7A +310012=\u6258\u76D8\u6761\u7801\u4E3A\u7A7A\u3001\u6216\u8005\u5B50\u5377\u7801\u4E3A\u7A7A +310013=\u624B\u8865\u6761\u7801\u548CPLC\u4E0A\u62A5\u6761\u7801\u90FD\u4E3A\u7A7A,\u4EFB\u52A1\u67E5\u627E\u7ED3\u675F +310014=\u6307\u4EE4\u5BF9\u5E94\u7684\u8F7D\u5177\u53F7\u4E3A\u7A7A,\u4E0D\u5141\u8BB8\u5F00\u76D6\u7533\u8BF7 +310015=\u7533\u8BF7\u5F00\u76D6\u65F6\u6307\u4EE4\u5B8C\u6210\u5931\u8D25 +310016="\u67E5\u8BE2\u51FA\u5E93\u4EFB\u52A1\u65F6,\u6307\u4EE4\u6570\u91CF\u5927\u4E8E\u8BBE\u5B9A\u6700\u5927\u503C,\u4E0D\u5141\u8BB8\u751F\u6210\u6307\u4EE4 +310017=\u8BE5\u70B9\u4F4D\u5B58\u5728\u5165\u5E93\u4EFB\u52A1,\u4E0D\u5141\u8BB8\u6267\u884C\u51FA\u5E93\u4EFB\u52A1 +#\u6841\u67B6\u8BBE\u5907\u8FD0\u884C\u4FE1\u606F +120000=\u8131\u673A +120001=\u5F03\u7528(\u7559\u4F5C\u517C\u5BB9) +120002=\u5F85\u673A +120003=\u8FD0\u884C\u4E2D +#\u6841\u67B6\u62A5\u8B66\u4FE1\u606F +220000=\u65E0\u62A5\u8B66 +#\u672A\u6267\u884C\u4EFB\u52A1\u539F\u56E0 +320001=\u6841\u67B6\u4E0A\u62A5\u6307\u4EE4\u5DF2\u5728\u6267\u884C, \u4E0D\u5141\u8BB8\u4E0B\u53D1\u65B0\u7684\u6307\u4EE4\u4FE1\u606F! +320002=\u6307\u4EE4\u4FE1\u606F\u5BF9\u5E94\u7684\u4EFB\u52A1\u4FE1\u606F\u672A\u67E5\u627E\u5230 +320003=\u6841\u67B6\u672A\u914D\u7F6E\u53D6\u8D27\u70B9 +320004=\u6841\u67B6\u672A\u914D\u7F6E\u653E\u8D27\u70B9 +320005=\u672A\u67E5\u627E\u5230\u5C31\u7EEA\u4EFB\u52A1\u6307\u4EE4\u6216\u4EFB\u52A1\u4FE1\u606F +#\u52A8\u4F5C\u4FE1\u53F7 +420000=\u65E0\u52A8\u4F5C +420001=\u53D6\u8D27\u4E2D +420002=\u53D6\u8D27\u5B8C\u6210 +420003=\u653E\u8D27\u4E2D +420004=\u653E\u8D27\u5B8C\u6210 +420005=\u5F00\u76D6 +420006=\u5408\u76D6 +420007=\u5438\u5C18 +420008=\u653E\u5E72\u71E5\u5242 +420009=\u53E0\u6258\u76D8 +420010=\u8D34\u6807 +420011=\u6253\u9489 + + + diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml b/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml index 427aaa5..5546166 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml @@ -46,7 +46,7 @@ https://juejin.cn/post/6844903775631572999 20GB - + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n ${log.charset} @@ -68,11 +68,11 @@ https://juejin.cn/post/6844903775631572999 - - + + - + @@ -114,7 +114,7 @@ https://juejin.cn/post/6844903775631572999 - + diff --git a/acs2/nladmin-system/package-lock.json b/acs2/nladmin-system/package-lock.json new file mode 100644 index 0000000..7e4a82b --- /dev/null +++ b/acs2/nladmin-system/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "nladmin-system", + "lockfileVersion": 2, + "requires": true, + "packages": {} +} diff --git a/acs2/nladmin-ui/.env.development b/acs2/nladmin-ui/.env.development index e37a9a4..8998791 100644 --- a/acs2/nladmin-ui/.env.development +++ b/acs2/nladmin-ui/.env.development @@ -1,8 +1,8 @@ ENV = 'development' # 接口地址 -VUE_APP_BASE_API = 'http://localhost:8011' -VUE_APP_WS_API = 'ws://localhost:8011' +VUE_APP_BASE_API = 'http://localhost:8019' +VUE_APP_WS_API = 'ws://localhost:8019' # 是否启用 babel-plugin-dynamic-import-node插件 VUE_CLI_BABEL_TRANSPILE_MODULES = true diff --git a/acs2/nladmin-ui/src/i18n/langs/monitor/zh.js b/acs2/nladmin-ui/src/i18n/langs/monitor/zh.js index 8c2667e..8b720b1 100644 --- a/acs2/nladmin-ui/src/i18n/langs/monitor/zh.js +++ b/acs2/nladmin-ui/src/i18n/langs/monitor/zh.js @@ -142,7 +142,9 @@ export default { 'Complement_information': '补码信息', 'agv_task_type': '任务类型', 'vehicle_code2': '木箱号', - 'volume_code': '子卷号' + 'volume_code': '子卷号', + 'container_type': '托盘类型', + 'unExecutedMessage': '未执行任务原因', } } } diff --git a/acs2/nladmin-ui/src/views/acs/device/config.vue b/acs2/nladmin-ui/src/views/acs/device/config.vue index db94c04..50733b1 100644 --- a/acs2/nladmin-ui/src/views/acs/device/config.vue +++ b/acs2/nladmin-ui/src/views/acs/device/config.vue @@ -63,7 +63,9 @@ - + + + @@ -83,6 +85,7 @@ import standard_conveyor_control_with_scanner from '@/views/acs/device/driver/st import standard_conveyor_control from '@/views/acs/device/driver/standard_conveyor_control' import standard_conveyor_monitor from '@/views/acs/device/driver/standard_conveyor_monitor' import double_station_stacker from '@/views/acs/device/driver/double_station_stacker' +import standard_stacker_device from '@/views/acs/device/driver/standard_stacker_device' // import hailiang_smart_plc_test from '@/views/acs/device/driver/hailiang_smart_plc_test' // import paint_conveyor from '@/views/acs/device/driver/paint_conveyor' import standard_stacker from '@/views/acs/device/driver/standard_stacker' @@ -200,7 +203,8 @@ export default { paper_tube_pick_size, one_rgv, die_manipulator, - raster + raster, + standard_stacker_device }, dicts: ['device_type'], mixins: [crud], diff --git a/acs2/nladmin-ui/src/views/acs/device/driver/belt_conveyor.vue b/acs2/nladmin-ui/src/views/acs/device/driver/belt_conveyor.vue index 3022c52..9c38f8b 100644 --- a/acs2/nladmin-ui/src/views/acs/device/driver/belt_conveyor.vue +++ b/acs2/nladmin-ui/src/views/acs/device/driver/belt_conveyor.vue @@ -1,62 +1,155 @@ - -
- + +
+
+
保存
-
@@ -250,9 +291,9 @@ import { testRead, testwrite } from '@/api/acs/device/driverConfig' -import { selectOpcList } from '@/api/acs/device/opc' -import { selectPlcList } from '@/api/acs/device/opcPlc' -import { selectListByOpcID } from '@/api/acs/device/opcPlc' +import {selectOpcList} from '@/api/acs/device/opc' +import {selectPlcList} from '@/api/acs/device/opcPlc' +import {selectListByOpcID} from '@/api/acs/device/opcPlc' import crud from '@/mixins/crud' import deviceCrud from '@/api/acs/device/device' @@ -285,13 +326,19 @@ export default { inspect_in_stocck: true, ignore_pickup_check: false, ignore_release_check: true, - apply_task: true, + targetDeviceCode: null, + apply_task: false, link_three_lamp: '', manual_create_task: true, is_pickup: true, is_release: true, link_device_code: [], - ship_device_update: true + checkoutStartDeviceCode: null, + ship_device_update: true, + isTwoWayPoint: false, + isCreateInst: false, + cacheDeviceCode: null, + maxInstNum: null }, rules: {} } @@ -598,4 +645,81 @@ export default { diff --git a/acs2/nladmin-ui/src/views/acs/device/driver/box_manipulator.vue b/acs2/nladmin-ui/src/views/acs/device/driver/box_manipulator.vue index 39174d2..a887c7b 100644 --- a/acs2/nladmin-ui/src/views/acs/device/driver/box_manipulator.vue +++ b/acs2/nladmin-ui/src/views/acs/device/driver/box_manipulator.vue @@ -66,7 +66,7 @@ - + @@ -84,7 +84,7 @@ - + @@ -93,53 +93,16 @@ - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + +
diff --git a/acs2/nladmin-ui/src/views/acs/device/driver/conveyor_with_scanner_weight.vue b/acs2/nladmin-ui/src/views/acs/device/driver/conveyor_with_scanner_weight.vue index d32028d..6e28b93 100644 --- a/acs2/nladmin-ui/src/views/acs/device/driver/conveyor_with_scanner_weight.vue +++ b/acs2/nladmin-ui/src/views/acs/device/driver/conveyor_with_scanner_weight.vue @@ -43,6 +43,42 @@ + +
+ 开关: +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -93,11 +129,16 @@ + + + + + - + - - - - - + @@ -188,6 +225,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -372,9 +477,15 @@ export default { link_three_lamp: '', link_scanner: '', manual_create_task: true, + checkoutStartDeviceCode: null, is_pickup: true, is_release: true, - link_device_code: [] + link_device_code: [], + isTwoWayPoint: false, + isCreateInst: false, + targetDeviceCode: null, + cacheDeviceCode: null, + maxInstNum: null }, rules: {} } diff --git a/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/box_subvolumes_conveyor.vue b/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/box_subvolumes_conveyor.vue index aca9143..4423901 100644 --- a/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/box_subvolumes_conveyor.vue +++ b/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/box_subvolumes_conveyor.vue @@ -43,6 +43,42 @@ + +
+ 开关: +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -82,6 +118,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -248,13 +375,19 @@ export default { inspect_in_stocck: true, ignore_pickup_check: true, ignore_release_check: true, - apply_task: true, + apply_task: false, link_three_lamp: '', manual_create_task: true, + targetDeviceCode: null, + checkoutStartDeviceCode: null, is_pickup: true, is_release: true, link_device_code: [], - ship_device_update: true + ship_device_update: true, + isTwoWayPoint: false, + isCreateInst: false, + cacheDeviceCode: null, + maxInstNum: null }, rules: {} } diff --git a/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/finished_product_out_with_bind_lable_conveyor.vue b/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/finished_product_out_with_bind_lable_conveyor.vue index 5536822..ad495df 100644 --- a/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/finished_product_out_with_bind_lable_conveyor.vue +++ b/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/finished_product_out_with_bind_lable_conveyor.vue @@ -44,6 +44,43 @@ + +
+ 开关: +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
输送系统: @@ -82,6 +119,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -254,7 +382,13 @@ export default { is_pickup: true, is_release: true, link_device_code: [], - ship_device_update: true + ship_device_update: true, + checkoutStartDeviceCode: null, + isTwoWayPoint: false, + isCreateInst: false, + targetDeviceCode: null, + cacheDeviceCode: null, + maxInstNum: null }, rules: {} } diff --git a/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/fold_disc_site.vue b/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/fold_disc_site.vue index 8c0e12a..c2b0cc7 100644 --- a/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/fold_disc_site.vue +++ b/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/fold_disc_site.vue @@ -43,7 +43,42 @@ - + +
+ 开关: +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
输送系统: @@ -82,6 +117,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -254,7 +380,13 @@ export default { is_pickup: true, is_release: true, link_device_code: [], - ship_device_update: true + checkoutStartDeviceCode: null, + ship_device_update: true, + isTwoWayPoint: false, + isCreateInst: false, + targetDeviceCode: null, + cacheDeviceCode: null, + maxInstNum: null }, rules: {} } diff --git a/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/un_box_lable_conveyor.vue b/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/un_box_lable_conveyor.vue index 41eeb16..9367eee 100644 --- a/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/un_box_lable_conveyor.vue +++ b/acs2/nladmin-ui/src/views/acs/device/driver/one_conveyor/un_box_lable_conveyor.vue @@ -43,6 +43,42 @@ + +
+ 开关: +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -82,6 +118,66 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -254,7 +350,11 @@ export default { is_pickup: true, is_release: true, link_device_code: [], - ship_device_update: true + checkoutStartDeviceCode: null, + ship_device_update: true, + isTwoWayPoint: false, + isCreateInst: false, + targetDeviceCode: null }, rules: {} } diff --git a/acs2/nladmin-ui/src/views/acs/device/driver/one_manipulator/trapped_manipulator.vue b/acs2/nladmin-ui/src/views/acs/device/driver/one_manipulator/trapped_manipulator.vue index eff2a15..7fecceb 100644 --- a/acs2/nladmin-ui/src/views/acs/device/driver/one_manipulator/trapped_manipulator.vue +++ b/acs2/nladmin-ui/src/views/acs/device/driver/one_manipulator/trapped_manipulator.vue @@ -103,17 +103,17 @@ - + - + - + @@ -121,62 +121,25 @@ - + - + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/acs2/nladmin-ui/src/views/acs/device/driver/standard_stacker_device.vue b/acs2/nladmin-ui/src/views/acs/device/driver/standard_stacker_device.vue new file mode 100644 index 0000000..8d66f78 --- /dev/null +++ b/acs2/nladmin-ui/src/views/acs/device/driver/standard_stacker_device.vue @@ -0,0 +1,835 @@ + + + + + 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 de72714..e0f6d74 100644 --- a/acs2/nladmin-ui/src/views/system/monitor/device/index.vue +++ b/acs2/nladmin-ui/src/views/system/monitor/device/index.vue @@ -237,10 +237,10 @@ - - - {{ $t('auto.common.false') }} - {{ $t('auto.common.true') }} + + + {{ $t('auto.common.false') }} + {{ $t('auto.common.true') }} @@ -249,6 +249,45 @@ {{ $t('auto.common.Confirm') }}
+ + + + + + + + + {{ $t('auto.common.false') }} + {{ $t('auto.common.true') }} + + + + + + + + + + + + + + + + + {{ $t('auto.common.false') }} + {{ $t('auto.common.true') }} + + + + +
@@ -256,13 +295,13 @@ import crudStage from '@/api/logicflow/stage' import bgMonitor from '@/assets/images/bg_monitor.jpg' import deviceCrud from '@/api/acs/device/device' -import { getDeviceByCodes } from '@/api/acs/device/deviceStageMonitor' +import {getDeviceByCodes} from '@/api/acs/device/deviceStageMonitor' import '@logicflow/core/dist/style/index.css' import '@logicflow/extension/lib/style/index.css' -import { LogicFlow } from '@logicflow/core' -import { registerCustomElement } from '@/views/system/logicflow/editor/components/node' +import {LogicFlow} from '@logicflow/core' +import {registerCustomElement} from '@/views/system/logicflow/editor/components/node' import i18n from '@/i18n' -import { selectStageList } from '@/api/acs/stage/stage' +import {selectStageList} from '@/api/acs/stage/stage' let data = {} let lf = '' @@ -287,6 +326,8 @@ export default { dialogFormVisible8: false, dialogFormVisible9: false, dialogFormVisible10: false, + dialogFormVisible11: false, + dialogFormVisible12: false, Stages: [], stage_code: 'stage_code', stage_name: '二楼监控', @@ -305,7 +346,8 @@ export default { toCommand: null, prohibitInWarehouse: false, prohibitOutWarehouse: false, - stopReceiveTask: false + stopReceiveTask: false, + requireSuccess: false }, allDeviceMsg: [], msgTop: '200px', @@ -358,10 +400,10 @@ export default { }) lf.setTheme( { - baseEdge: { strokeWidth: 1 }, - baseNode: { strokeWidth: 1 }, - nodeText: { overflowMode: 'autoWrap', lineHeight: 1.5 }, - edgeText: { overflowMode: 'autoWrap', lineHeight: 1.5 } + baseEdge: {strokeWidth: 1}, + baseNode: {strokeWidth: 1}, + nodeText: {overflowMode: 'autoWrap', lineHeight: 1.5}, + edgeText: {overflowMode: 'autoWrap', lineHeight: 1.5} } ) // 注册自定义元素 @@ -481,6 +523,10 @@ export default { this.dialogFormVisible9 = true } else if (clickObj.data.driver_type === 'conveyor_with_scanner_weight') { this.dialogFormVisible10 = true + } else if (clickObj.data.driver_type === 'belt_conveyor') { + this.dialogFormVisible11 = true + } else if (clickObj.data.driver_type === 'box_subvolumes_conveyor') { + this.dialogFormVisible12 = true } else { this.dialogFormVisible = true } @@ -500,6 +546,7 @@ export default { this.form.prohibitOutWarehouse = clickObj.data.prohibitOutWarehouse this.form.stopReceiveTask = clickObj.data.stopReceiveTask this.form.toCommand = null + this.form.requireSuccess = clickObj.data.requireSuccess }, moveShow(nodeData) { // 点击之后显示出来的数据----只需要设备信息 let item = '' @@ -523,8 +570,8 @@ export default { tempDeviceName = item.data.in_device_name } */ this.arr = [ - { name: i18n.t('monitor.click.equipment_number'), value: item.device_code }, - { name: i18n.t('monitor.click.device_name'), value: item.device_name } + {name: i18n.t('monitor.click.equipment_number'), value: item.device_code}, + {name: i18n.t('monitor.click.device_name'), value: item.device_name} ] const data = item.data for (const val in data) { @@ -532,251 +579,254 @@ export default { continue } if (val === 'message' && data.isError === true) { - const obj = { name: i18n.t('monitor.click.device_information'), value: data[val] } + const obj = {name: i18n.t('monitor.click.device_information'), value: data[val]} this.arr.push(obj) } if (val === 'message' && data.isError === 'false') { - const obj = { name: i18n.t('monitor.click.exception_message'), value: data[val] } + const obj = {name: i18n.t('monitor.click.exception_message'), value: data[val]} this.arr.push(obj) } if (val === 'move') { - const obj = { name: i18n.t('monitor.click.photoelectric_signal'), value: data[val] } + const obj = {name: i18n.t('monitor.click.photoelectric_signal'), value: data[val]} this.arr.push(obj) } else if (val === 'mode') { - const obj = { name: i18n.t('monitor.click.mode'), value: data[val] } + const obj = {name: i18n.t('monitor.click.mode'), value: data[val]} this.arr.push(obj) } else if (val === 'error') { - const obj = { name: i18n.t('monitor.click.alarm'), value: data[val] } + const obj = {name: i18n.t('monitor.click.alarm'), value: data[val]} this.arr.push(obj) } else if (val === 'ip') { - const obj = { name: 'IP', value: data[val] } + const obj = {name: 'IP', value: data[val]} this.arr.push(obj) } else if (val === 'number') { - const obj = { name: i18n.t('monitor.click.pallet_quantity'), value: data[val] } + const obj = {name: i18n.t('monitor.click.pallet_quantity'), value: data[val]} this.arr.push(obj) } else if (val === 'inst_message') { - const obj = { name: i18n.t('monitor.click.instruction_information'), value: data[val] } + const obj = {name: i18n.t('monitor.click.instruction_information'), value: data[val]} this.arr.push(obj) } else if (val === 'message') { - const obj = { name: i18n.t('monitor.click.note_information'), value: data[val] } + const obj = {name: i18n.t('monitor.click.note_information'), value: data[val]} this.arr.push(obj) } else if (val === 'inst_message') { - const obj = { name: i18n.t('monitor.click.current_instruction_message'), value: data[val] } + const obj = {name: i18n.t('monitor.click.current_instruction_message'), value: data[val]} this.arr.push(obj) } else if (val === 'last_inst_message') { - const obj = { name: i18n.t('monitor.click.last_instruction_message'), value: data[val] } + const obj = {name: i18n.t('monitor.click.last_instruction_message'), value: data[val]} this.arr.push(obj) } else if (val === 'container_type') { - const obj = { name: i18n.t('monitor.click.pallet_type'), value: data[val] } + const obj = {name: i18n.t('monitor.click.pallet_type'), value: data[val]} this.arr.push(obj) } else if (val === 'barcode') { - const obj = { name: i18n.t('monitor.click.barcode'), value: data[val] } + const obj = {name: i18n.t('monitor.click.barcode'), value: data[val]} this.arr.push(obj) } else if (val === 'barcode_length') { - const obj = { name: i18n.t('monitor.click.barcode_length'), value: data[val] } + const obj = {name: i18n.t('monitor.click.barcode_length'), value: data[val]} this.arr.push(obj) } else if (val === 'last_container') { - const obj = { name: i18n.t('monitor.click.last_container'), value: data[val] } + const obj = {name: i18n.t('monitor.click.last_container'), value: data[val]} this.arr.push(obj) } else if (val === 'instruction_code') { - const obj = { name: i18n.t('monitor.click.current_instruction_message'), value: data[val] } + const obj = {name: i18n.t('monitor.click.current_instruction_message'), value: data[val]} this.arr.push(obj) } else if (val === 'task_code') { - const obj = { name: i18n.t('monitor.click.task_number'), value: data[val] } + const obj = {name: i18n.t('monitor.click.task_number'), value: data[val]} this.arr.push(obj) } else if (val === 'last_instruction_code') { - const obj = { name: i18n.t('monitor.click.last_instruction_message'), value: data[val] } + const obj = {name: i18n.t('monitor.click.last_instruction_message'), value: data[val]} this.arr.push(obj) } else if (val === 'action') { - const obj = { name: i18n.t('monitor.click.action_signal'), value: data[val] } + const obj = {name: i18n.t('monitor.click.action_signal'), value: data[val]} this.arr.push(obj) } else if (val === 'io_action') { - const obj = { name: i18n.t('monitor.click.clearance_signal'), value: data[val] } + const obj = {name: i18n.t('monitor.click.clearance_signal'), value: data[val]} this.arr.push(obj) } else if (val === 'material') { - const obj = { name: i18n.t('monitor.click.materiel'), value: data[val] } + const obj = {name: i18n.t('monitor.click.materiel'), value: data[val]} this.arr.push(obj) } else if (val === 'batch') { - const obj = { name: i18n.t('monitor.click.lot'), value: data[val] } + const obj = {name: i18n.t('monitor.click.lot'), value: data[val]} this.arr.push(obj) } else if (val === 'requestSucess') { - const obj = { name: i18n.t('monitor.click.request_task'), value: data[val] } + const obj = {name: i18n.t('monitor.click.request_task'), value: data[val]} this.arr.push(obj) } else if (val === 'applySucess') { - const obj = { name: i18n.t('monitor.click.request_order'), value: data[val] } + const obj = {name: i18n.t('monitor.click.request_order'), value: data[val]} this.arr.push(obj) } else if (val === 'requireApplyLabelingSuccess') { - const obj = { name: i18n.t('monitor.click.apply_labeling'), value: data[val] } + const obj = {name: i18n.t('monitor.click.apply_labeling'), value: data[val]} this.arr.push(obj) } else if (val === 'requireApplyLaStrangulationSuccess') { - const obj = { name: i18n.t('monitor.click.apply_for_bundling'), value: data[val] } + const obj = {name: i18n.t('monitor.click.apply_for_bundling'), value: data[val]} this.arr.push(obj) } else if (val === 'status') { - const obj = { name: i18n.t('monitor.click.device_status'), value: data[val] } + const obj = {name: i18n.t('monitor.click.device_status'), value: data[val]} this.arr.push(obj) } else if (val === 'weight') { - const obj = { name: i18n.t('monitor.click.weight'), value: data[val] } + const obj = {name: i18n.t('monitor.click.weight'), value: data[val]} this.arr.push(obj) } else if (val === 'move_1') { - const obj = { name: i18n.t('monitor.click.front_station_photoelectric_signal'), value: data[val] } + const obj = {name: i18n.t('monitor.click.front_station_photoelectric_signal'), value: data[val]} this.arr.push(obj) } else if (val === 'open') { - const obj = { name: i18n.t('monitor.click.open'), value: data[val] } + const obj = {name: i18n.t('monitor.click.open'), value: data[val]} this.arr.push(obj) } else if (val === 'close') { - const obj = { name: i18n.t('monitor.click.close'), value: data[val] } + const obj = {name: i18n.t('monitor.click.close'), value: data[val]} this.arr.push(obj) } else if (val === 'phase') { - const obj = { name: i18n.t('monitor.click.AGV_phase'), value: data[val] } + const obj = {name: i18n.t('monitor.click.AGV_phase'), value: data[val]} this.arr.push(obj) } else if (val === 'phase_name') { - const obj = { name: i18n.t('monitor.click.description_of_the_AGV_phase'), value: data[val] } + const obj = {name: i18n.t('monitor.click.description_of_the_AGV_phase'), value: data[val]} this.arr.push(obj) } else if (val === 'option') { - const obj = { name: i18n.t('monitor.click.AGV_action'), value: data[val] } + const obj = {name: i18n.t('monitor.click.AGV_action'), value: data[val]} this.arr.push(obj) } else if (val === 'agv_power') { - const obj = { name: i18n.t('monitor.click.AGV_power'), value: data[val] } + const obj = {name: i18n.t('monitor.click.AGV_power'), value: data[val]} this.arr.push(obj) } else if (val === 'move_2') { - const obj = { name: i18n.t('monitor.click.post-station_photoelectric_signal'), value: data[val] } + const obj = {name: i18n.t('monitor.click.post-station_photoelectric_signal'), value: data[val]} this.arr.push(obj) } else if (val === 'action_1') { - const obj = { name: i18n.t('monitor.click.front_station_action_signal'), value: data[val] } + const obj = {name: i18n.t('monitor.click.front_station_action_signal'), value: data[val]} this.arr.push(obj) } else if (val === 'action_2') { - const obj = { name: i18n.t('monitor.click.back_station_action_signal'), value: data[val] } + const obj = {name: i18n.t('monitor.click.back_station_action_signal'), value: data[val]} this.arr.push(obj) } else if (val === 'walk_y') { - const obj = { name: i18n.t('monitor.click.walk_y'), value: data[val] } + const obj = {name: i18n.t('monitor.click.walk_y'), value: data[val]} this.arr.push(obj) } else if (val === 'task1') { - const obj = { name: i18n.t('monitor.click.previous_station_task'), value: data[val] } + const obj = {name: i18n.t('monitor.click.previous_station_task'), value: data[val]} this.arr.push(obj) } else if (val === 'task2') { - const obj = { name: i18n.t('monitor.click.back_station_task'), value: data[val] } + const obj = {name: i18n.t('monitor.click.back_station_task'), value: data[val]} this.arr.push(obj) } else if (val === 'task') { - const obj = { name: i18n.t('monitor.click.task_number'), value: data[val] } + const obj = {name: i18n.t('monitor.click.task_number'), value: data[val]} this.arr.push(obj) } else if (val === 'last_task') { - const obj = { name: i18n.t('monitor.click.last_mission_number'), value: data[val] } + const obj = {name: i18n.t('monitor.click.last_mission_number'), value: data[val]} this.arr.push(obj) } else if (val === 'is_disable') { - const obj = { name: i18n.t('monitor.click.disable'), value: data[val] } + const obj = {name: i18n.t('monitor.click.disable'), value: data[val]} this.arr.push(obj) } else if (val === 'temperature') { - const obj = { name: i18n.t('monitor.click.current_temperature'), value: data[val] } + const obj = {name: i18n.t('monitor.click.current_temperature'), value: data[val]} this.arr.push(obj) } else if (val === 'finish') { - const obj = { name: i18n.t('monitor.click.oven_finish'), value: data[val] } + const obj = {name: i18n.t('monitor.click.oven_finish'), value: data[val]} this.arr.push(obj) } else if (val === 'countdown_house') { - const obj = { name: i18n.t('monitor.click.house'), value: data[val] } + const obj = {name: i18n.t('monitor.click.house'), value: data[val]} this.arr.push(obj) } else if (val === 'countdown_min') { - const obj = { name: i18n.t('monitor.click.minutes'), value: data[val] } + const obj = {name: i18n.t('monitor.click.minutes'), value: data[val]} this.arr.push(obj) } else if (val === 'countdown_sec') { - const obj = { name: i18n.t('monitor.click.seconds'), value: data[val] } + const obj = {name: i18n.t('monitor.click.seconds'), value: data[val]} this.arr.push(obj) } else if (val === 'door') { - const obj = { name: i18n.t('monitor.click.gate_state'), value: data[val] } + const obj = {name: i18n.t('monitor.click.gate_state'), value: data[val]} this.arr.push(obj) } else if (val === 'notCreateTaskMessage') { - const obj = { name: i18n.t('monitor.click.task_creation_failure'), value: data[val] } + const obj = {name: i18n.t('monitor.click.task_creation_failure'), value: data[val]} this.arr.push(obj) } else if (val === 'notCreateInstMessage') { - const obj = { name: i18n.t('monitor.click.failed_to_create_instruction'), value: data[val] } + const obj = {name: i18n.t('monitor.click.failed_to_create_instruction'), value: data[val]} this.arr.push(obj) } else if (val === 'feedMessage') { - const obj = { name: i18n.t('monitor.click.no_electrical_signal_feedback_cause'), value: data[val] } + const obj = {name: i18n.t('monitor.click.no_electrical_signal_feedback_cause'), value: data[val]} this.arr.push(obj) } else if (val === 'requireSucess') { - const obj = { name: i18n.t('monitor.click.request_success_flag'), value: data[val] } + const obj = {name: i18n.t('monitor.click.request_success_flag'), value: data[val]} this.arr.push(obj) } else if (val === 'requireActionSucess') { - const obj = { name: i18n.t('monitor.click.request_success_flag'), value: data[val] } + const obj = {name: i18n.t('monitor.click.request_success_flag'), value: data[val]} this.arr.push(obj) } else if (val === 'applySucess') { - const obj = { name: 'applySucess', value: data[val] } + const obj = {name: 'applySucess', value: data[val]} this.arr.push(obj) } else if (val === 'out_finish') { - const obj = { name: i18n.t('monitor.click.delivery_completed'), value: data[val] } + const obj = {name: i18n.t('monitor.click.delivery_completed'), value: data[val]} this.arr.push(obj) } else if (val === 'inventory_qty') { - const obj = { name: i18n.t('monitor.click.inventory_quantity'), value: data[val] } + const obj = {name: i18n.t('monitor.click.inventory_quantity'), value: data[val]} this.arr.push(obj) } else if (val === 'hand_barcode') { - const obj = { name: i18n.t('monitor.click.Complement_information'), value: data[val] } + const obj = {name: i18n.t('monitor.click.Complement_information'), value: data[val]} this.arr.push(obj) } else if (val === 'hand_barcode1') { - const obj = { name: i18n.t('monitor.click.the_subvolume_number'), value: data[val] } + const obj = {name: i18n.t('monitor.click.the_subvolume_number'), value: data[val]} this.arr.push(obj) } else if (val === 'x') { - const obj = { name: 'X', value: data[val] } + const obj = {name: 'X', value: data[val]} this.arr.push(obj) } else if (val === 'y') { - const obj = { name: 'Y', value: data[val] } + const obj = {name: 'Y', value: data[val]} this.arr.push(obj) } else if (val === 'angle') { - const obj = { name: i18n.t('monitor.click.angle'), value: data[val] } + const obj = {name: i18n.t('monitor.click.angle'), value: data[val]} this.arr.push(obj) } else if (val === 'electricity') { - const obj = { name: i18n.t('monitor.click.electric_quantity'), value: data[val] } + const obj = {name: i18n.t('monitor.click.electric_quantity'), value: data[val]} this.arr.push(obj) } else if (val === 'status_name') { - const obj = { name: i18n.t('monitor.click.status'), value: data[val] } + const obj = {name: i18n.t('monitor.click.status'), value: data[val]} this.arr.push(obj) } else if (val === 'fault') { - const obj = { name: i18n.t('monitor.click.abnormal'), value: data[val] } + const obj = {name: i18n.t('monitor.click.abnormal'), value: data[val]} this.arr.push(obj) } else if (val === 'map_id') { - const obj = { name: i18n.t('monitor.click.floor'), value: data[val] } + const obj = {name: i18n.t('monitor.click.floor'), value: data[val]} this.arr.push(obj) } else if (val === 'power') { - const obj = { name: i18n.t('monitor.click.electric_quantity'), value: data[val] } + const obj = {name: i18n.t('monitor.click.electric_quantity'), value: data[val]} this.arr.push(obj) } else if (val === 'pallet') { - const obj = { name: i18n.t('monitor.click.tray'), value: data[val] } + const obj = {name: i18n.t('monitor.click.tray'), value: data[val]} this.arr.push(obj) } else if (val === 'load') { - const obj = { name: i18n.t('monitor.click.loading_or_not'), value: data[val] } + const obj = {name: i18n.t('monitor.click.loading_or_not'), value: data[val]} this.arr.push(obj) } else if (val === 'alarm') { - const obj = { name: i18n.t('monitor.click.alarm'), value: data[val] } + const obj = {name: i18n.t('monitor.click.alarm'), value: data[val]} this.arr.push(obj) } else if (val === 'task_id') { - const obj = { name: i18n.t('monitor.click.task_number'), value: data[val] } + const obj = {name: i18n.t('monitor.click.task_number'), value: data[val]} this.arr.push(obj) } else if (val === 'command') { - const obj = { name: i18n.t('monitor.click.command'), value: data[val] } + const obj = {name: i18n.t('monitor.click.command'), value: data[val]} this.arr.push(obj) } else if (val === 'material_barcode') { - const obj = { name: i18n.t('monitor.click.the_subvolume_number'), value: data[val] } + const obj = {name: i18n.t('monitor.click.the_subvolume_number'), value: data[val]} + this.arr.push(obj) + } else if (val === 'material_code') { + const obj = {name: i18n.t('monitor.click.material_code'), value: data[val]} this.arr.push(obj) } else if (val === 'inst_message') { - const obj = { name: i18n.t('monitor.click.Current_command_information'), value: data[val] } + const obj = {name: i18n.t('monitor.click.Current_command_information'), value: data[val]} this.arr.push(obj) } else if (val === 'errors') { - const obj = { name: i18n.t('monitor.click.Core_error_identifier'), value: data[val] } + const obj = {name: i18n.t('monitor.click.Core_error_identifier'), value: data[val]} this.arr.push(obj) } else if (val === 'upload_scene_status') { - const obj = { name: i18n.t('monitor.click.Whether_to_push_the_scenario_waybill'), value: data[val] } + const obj = {name: i18n.t('monitor.click.Whether_to_push_the_scenario_waybill'), value: data[val]} this.arr.push(obj) } else if (val === 'procBusiness') { - const obj = { name: i18n.t('monitor.click.Whether_it_is_being_executed'), value: data[val] } + const obj = {name: i18n.t('monitor.click.Whether_it_is_being_executed'), value: data[val]} this.arr.push(obj) } else if (val === 'connection_status') { - const obj = { name: i18n.t('monitor.click.Connection_status'), value: data[val] } + const obj = {name: i18n.t('monitor.click.Connection_status'), value: data[val]} this.arr.push(obj) } else if (val === 'dispatchable_status') { - const obj = { name: i18n.t('monitor.click.Whether_the_order_can_be_accepted'), value: data[val] } + const obj = {name: i18n.t('monitor.click.Whether_the_order_can_be_accepted'), value: data[val]} this.arr.push(obj) } else if (val === 'current_map_invalid') { - const obj = { name: i18n.t('monitor.click.Whether_or_not_in_the_scene'), value: data[val] } + const obj = {name: i18n.t('monitor.click.Whether_or_not_in_the_scene'), value: data[val]} this.arr.push(obj) } else if (val === 'disconnect') { const obj = { @@ -785,31 +835,34 @@ export default { } this.arr.push(obj) } else if (val === 'low_battery') { - const obj = { name: i18n.t('monitor.click.The_state_of_the_robots_battery_level'), value: data[val] } + const obj = {name: i18n.t('monitor.click.The_state_of_the_robots_battery_level'), value: data[val]} this.arr.push(obj) } else if (val === 'suspended') { - const obj = { name: i18n.t('monitor.click.The_status_of_the_waybill'), value: data[val] } + const obj = {name: i18n.t('monitor.click.The_status_of_the_waybill'), value: data[val]} this.arr.push(obj) } else if (val === 'unconfirmed_reloc') { - const obj = { name: i18n.t('monitor.click.positioning_confirmation'), value: data[val] } + const obj = {name: i18n.t('monitor.click.positioning_confirmation'), value: data[val]} this.arr.push(obj) } else if (val === 'unlock') { - const obj = { name: i18n.t('monitor.click.control'), value: data[val] } + const obj = {name: i18n.t('monitor.click.control'), value: data[val]} this.arr.push(obj) } else if (val === 'qty') { - const obj = { name: i18n.t('monitor.click.number_of_air_shafts'), value: data[val] } + const obj = {name: i18n.t('monitor.click.number_of_air_shafts'), value: data[val]} this.arr.push(obj) - } else if (val === 'type') { - const obj = { name: i18n.t('opc.table_title.type'), value: data[val] } + } else if (val === 'container_type') { + const obj = {name: i18n.t('monitor.click.container_type'), value: data[val]} this.arr.push(obj) } else if (val === 'agv_task_type') { - const obj = { name: i18n.t('monitor.click.agv_task_type'), value: data[val] } + const obj = {name: i18n.t('monitor.click.agv_task_type'), value: data[val]} this.arr.push(obj) } else if (val === 'vehicle_code2') { - const obj = { name: i18n.t('monitor.click.vehicle_code2'), value: data[val] } + const obj = {name: i18n.t('monitor.click.vehicle_code2'), value: data[val]} this.arr.push(obj) } else if (val === 'volume_code') { - const obj = { name: i18n.t('monitor.click.volume_code'), value: data[val] } + const obj = {name: i18n.t('monitor.click.volume_code'), value: data[val]} + this.arr.push(obj) + } else if (val === 'unExecutedMessage') { + const obj = {name: i18n.t('monitor.click.unExecutedMessage'), value: data[val]} this.arr.push(obj) } } @@ -818,7 +871,7 @@ export default { }, initStatus() { // 初始化所有节点的设备信息,通过节点id对应设备编号 let resion = {} - resion = lf.getGraphData().nodes.map(item => ({ id: item.id, device_code: item.properties.device })) + resion = lf.getGraphData().nodes.map(item => ({id: item.id, device_code: item.properties.device})) getDeviceByCodes(resion).then(res => { console.log(res) this.allDeviceMsg = res // 拿到所有节点的设备数据 @@ -844,7 +897,7 @@ export default { } } // 设置动态实时显示设备信息 - const { nodes } = lf.getSelectElements() // 获取选中的节点 + const {nodes} = lf.getSelectElements() // 获取选中的节点 // console.log(nodes) if (nodes.length === 1) { // 因为是定时器,没有选中则不用实时更新显示数据 this.moveShow(nodes[0]) // 监控模式下不可能托选,因此就只有一个数据 @@ -853,7 +906,7 @@ export default { }, dialogSave() { deviceCrud.changeDeviceStatus(this.form).then(() => { - this.$notify({ title: '操作成功', message: '', type: 'success' }) + this.$notify({title: '操作成功', message: '', type: 'success'}) this.dialogFormVisible = false this.dialogFormVisible3 = false this.dialogFormVisible4 = false @@ -863,6 +916,8 @@ export default { this.dialogFormVisible8 = false this.dialogFormVisible9 = false this.dialogFormVisible10 = false + this.dialogFormVisible11 = false + this.dialogFormVisible12 = false this.initStageData() }).catch(err => { this.dialogFormVisible = false @@ -873,6 +928,8 @@ export default { this.dialogFormVisible8 = false this.dialogFormVisible9 = false this.dialogFormVisible10 = false + this.dialogFormVisible11 = false + this.dialogFormVisible12 = false console.log(err.response.data.message) }) },