From 9a824161a3d8c5e98a58c6acbee3954fdf70aaad Mon Sep 17 00:00:00 2001 From: zhoujj <1549112868@qq.com> Date: Fri, 3 Jan 2025 17:49:01 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E8=AF=BB=E5=8F=96kep=E5=92=8C=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/nl/acs/AcsConfig.java | 124 +- .../nl/acs/agv/rest/MagicAgvController.java | 39 - .../nl/acs/agv/server/MagicAgvService.java | 125 -- .../agv/server/impl/MagicAgvServiceImpl.java | 839 ----------- .../agv/server/impl/ZheDaAgvServiceImpl.java | 494 ------- .../run/OneNDCSocketConnectionAutoRun.java | 8 +- ...ardCoveyorControlWithPlcScannerDevice.java | 33 - ...andardCoveyorControlWithScannerDevice.java | 33 - .../acs/common/StandardInspectSiteDevice.java | 24 - .../common/StandardOrdinarySiteDevice.java | 33 - .../service/impl/DeviceServiceImpl.java | 518 +------ .../agv/magic_agv/MagicAgvDefination.java | 49 - .../agv/magic_agv/MagicAgvDeviceDriver.java | 32 - .../agv/ndcone/AgvNdcOneDefination.java | 49 - .../agv/ndcone/AgvNdcOneDeviceDriver.java | 558 -------- .../agv/ndctwo/AgvNdcTwoDefination.java | 49 - .../agv/ndctwo/AgvNdcTwoDeviceDriver.java | 489 ------- .../nl/acs/device_driver/agv/utils/IAgv.java | 10 - .../device_driver/agv/utils/OneAgvPhase.java | 34 - .../device_driver/agv/utils/TwoAgvPhase.java | 56 - .../agv/xg_agv/ItemProtocol.java | 391 ------ .../agv/xg_agv/XgagvDefination.java | 60 - .../agv/xg_agv/XgagvDeviceDriver.java | 651 --------- .../belt_conveyor/BeltConveyorDefination.java | 61 - .../BeltConveyorDeviceDriver.java | 738 ---------- .../conveyor/belt_conveyor/ItemProtocol.java | 205 --- .../conveyor/belt_conveyor/Paper.java | 21 - .../CartonLabelingMachineDeviceDriver.java | 470 ++++--- .../DoubleStationStackerDefination.java | 57 - .../DoubleStationStackerDeviceDriver.java | 1024 -------------- .../double_station_stacker/ItemProtocol.java | 623 -------- .../enums/CommandEnum.java | 39 - .../enums/SortEnum.java | 21 - .../conveyor/primary_device/ItemProtocol.java | 2 +- .../PrimaryDeviceConveyorDeviceDriver.java | 80 +- .../siemens_conveyor/ItemProtocol.java | 164 --- .../SiemensConveyorDefination.java | 62 - .../SiemensConveyorDeviceDriver.java | 979 ------------- .../siemens_conveyor_ckk/ItemProtocol.java | 160 --- .../SiemensConveyorCkkDefination.java | 62 - .../SiemensConveyorCkkDeviceDriver.java | 947 ------------- .../ItemProtocol.java | 164 --- .../SiemensConveyorLabelingDefination.java | 62 - .../SiemensConveyorLabelingDeviceDriver.java | 977 ------------- .../ItemProtocol.java | 123 -- .../StandardConveyorControlDefination.java | 63 - .../StandardCoveyorControlDeviceDriver.java | 510 ------- .../ItemProtocol.java | 164 --- ...nveyorControlWithPlcScannerDefination.java | 62 - .../StandardConveyorWithPlcScannerConfig.java | 12 - ...eyorControlWithPlcScannerDeviceDriver.java | 925 ------------ .../ItemProtocol.java | 181 --- ...dConveyorControlWithScannerDefination.java | 62 - .../StandardConveyorWithScannerConfig.java | 12 - ...CoveyorControlWithScannerDeviceDriver.java | 888 ------------ .../standard_inspect_site/ItemProtocol.java | 114 -- .../StandardInspectSiteDefination.java | 62 - .../StandardInspectSiteDeviceDriver.java | 464 ------ .../StandardOrdinarySiteDefination.java | 49 - .../StandardOrdinarySiteDeviceDriver.java | 257 ---- .../driver/ExecutableDeviceDriver.java | 24 +- .../paper_tube_pick_site/ItemProtocol.java | 159 --- .../PaperTubePickSiteDefination.java | 61 - .../PaperTubePickSiteDeviceDriver.java | 238 ---- .../StandardScannerDefination.java | 49 - .../StandardScannerDeviceDriver.java | 85 -- .../standard_stacker/ItemProtocol.java | 470 ------- .../StandardStackerDefination.java | 57 - .../StandardStackerDeviceDriver.java | 962 ------------- .../BlankManipulatorDefination.java | 59 - .../BlankManipulatorDeviceDriver.java | 623 -------- .../blank_manipulator/ItemProtocol.java | 148 -- .../BlankingButtonDefination.java | 60 - .../blanking_button/BlankingButtonDriver.java | 327 ----- .../blanking_button/ItemProtocol.java | 94 -- .../GreenFoilMachineButtonDefination.java | 60 - .../GreenFoilMachineButtonDriver.java | 286 ---- .../ItemProtocol.java | 94 -- .../HongXiangStationDefination.java | 60 - .../HongXiangStationDeviceDriver.java | 211 --- .../hongxiang_conveyor/ItemProtocol.java | 61 - .../HongXiangConveyorDefination.java | 60 - .../HongXiangConveyorDeviceDriver.java | 342 ----- .../hongxiang_device/ItemProtocol.java | 196 --- .../InflatableShaftLibraryDefination.java | 59 - .../InflatableShaftLibraryDeviceDriver.java | 174 --- .../ItemProtocol.java | 102 -- .../lamp_three_color/ItemProtocol.java | 48 - .../LampThreecolorDefination.java | 63 - .../LampThreecolorDeviceDriver.java | 109 -- .../oven_manipulator/ItemProtocol.java | 166 --- .../OvenGantryManipulatorDefination.java | 63 - .../OvenGantryManipulatorDeviceDriver.java | 1027 -------------- .../plug_pull_device_site/ItemProtocol.java | 187 --- .../PlugPullDeviceSiteDefination.java | 60 - .../PlugPullDeviceSiteDeviceDriver.java | 472 ------- .../pull_head_manipulator/ItemProtocol.java | 211 --- .../PullHeadManipulatorDefination.java | 59 - .../PullHeadManipulatorDeviceDriver.java | 661 --------- .../pull_tail_manipulator/ItemProtocol.java | 168 --- .../PullTailManipulatorDefination.java | 59 - .../PullTailManipulatorDeviceDriver.java | 664 --------- .../slit_two_manipulator/ItemProtocol.java | 193 --- .../SlitTwoManipulatorDefination.java | 61 - .../SlitTwoManipulatorDeviceDriver.java | 1248 ----------------- .../ItemProtocol.java | 99 -- .../SubvolumeWeighingStationDefination.java | 60 - .../SubvolumeWeighingStationDriver.java | 146 -- .../ItemProtocol.java | 104 -- .../WasteFoilWeighingStationDefination.java | 60 - .../WasteFoilWeighingStationDriver.java | 222 --- .../service/impl/LiKuToAcsServiceImpl.java | 40 +- .../wms/service/impl/WmsToAcsServiceImpl.java | 162 +-- .../service/impl/InstructionServiceImpl.java | 37 - .../org/nl/acs/opc/DeviceExecuteAutoRun.java | 6 +- .../nl/acs/opc/DeviceOpcProtocolRunable.java | 110 +- .../acs/opc/DeviceOpcSynchronizeAutoRun.java | 24 +- .../service/impl/TaskScreenServiceImpl.java | 27 +- .../org/nl/acs/udw/UnifiedDataAccessor.java | 6 + .../service/impl/UnifiedDataAccessorImpl.java | 5 + .../common/mnt/websocket/SendPrintSocket.java | 6 +- .../controller/tickets/TicketsController.java | 4 +- .../service/lucene/dto/LuceneLogDto.java | 18 +- .../service/tickets/TicketsService.java | 2 +- .../system/service/tickets/dto/Tickets.java | 4 + .../service/tickets/dto/TicketsDto.java | 4 + .../tickets/dto/mapper/TicketsMapper.xml | 5 +- .../tickets/impl/TicketsServiceImpl.java | 24 +- acs/nladmin-ui/src/api/acs/order/order.js | 4 +- acs/nladmin-ui/src/views/acs/order/index.vue | 120 +- .../src/views/acs/order/template.vue | 2 +- 131 files changed, 567 insertions(+), 26938 deletions(-) delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/rest/MagicAgvController.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/MagicAgvService.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/MagicAgvServiceImpl.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/ZheDaAgvServiceImpl.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardCoveyorControlWithPlcScannerDevice.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardCoveyorControlWithScannerDevice.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardInspectSiteDevice.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardOrdinarySiteDevice.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/magic_agv/MagicAgvDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/magic_agv/MagicAgvDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/IAgv.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/OneAgvPhase.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/TwoAgvPhase.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/XgagvDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/XgagvDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/Paper.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/enums/CommandEnum.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/enums/SortEnum.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor/SiemensConveyorDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor/SiemensConveyorDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/SiemensConveyorCkkDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/SiemensConveyorLabelingDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/SiemensConveyorLabelingDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control/StandardConveyorControlDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/StandardConveyorControlWithPlcScannerDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/StandardConveyorWithPlcScannerConfig.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/StandardCoveyorControlWithPlcScannerDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/StandardConveyorControlWithScannerDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/StandardConveyorWithScannerConfig.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/scanner/standard_scanner/StandardScannerDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/scanner/standard_scanner/StandardScannerDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/BlankingButtonDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/BlankingButtonDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/HongXiangStationDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/HongXiangStationDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/SubvolumeWeighingStationDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/SubvolumeWeighingStationDriver.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/ItemProtocol.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/WasteFoilWeighingStationDefination.java delete mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/WasteFoilWeighingStationDriver.java diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/AcsConfig.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/AcsConfig.java index 1a4212b..9f0445c 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/AcsConfig.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/AcsConfig.java @@ -1,120 +1,66 @@ package org.nl.acs; -/** - * @author 20220102CG\noblelift - */ public interface AcsConfig { - /** - * 指令下发agv - */ + //指令下发agv String FORKAGV = "forkagv"; - /** - * 单工指令下发agv - */ + //单工指令下发agv String ONEFORKAGV = "oneforkagv"; - /** - * 同一站点运行最大任务数 - */ + //同一站点运行最大任务数 String ONEPOINTMAXTASK = "onePointMaxTask"; - /** - * 同一任务创建最大指令数 - */ + //同一任务创建最大指令数 String MAXINSTNUMBER = "maxInstNumber"; - /** - * 创建任务检查 - */ + //创建任务检查 String CREATETASKCHECK = "createTaskCheck"; - /** - * 撤销任务检查 - */ + //撤销任务检查 String CANCELTASKCHECK = "cancelTaskCheck"; - /** - * 一楼agv系统接口地址 - */ + //agv系统接口地址 String AGVURL = "agvurl"; - /** - * AGV系统端口 - */ + //AGV系统端口 String AGVPORT = "agvport"; - /** - * 二楼1区agv系统接口地址 - */ - String AGVURL2 = "agvurl2"; - /** - * 二楼1区AGV系统端口 - */ - String AGVPORT2 = "agvport2"; - /** - * 二楼2区agv系统接口地址 - */ - String AGVURL22 = "agvurl22"; - /** - * 二楼2区AGV系统端口 - */ - String AGVPORT22 = "agvport22"; - /** - * 指定AGV系统 - */ + //rgv系统接口地址 + String RGVURL = "rgvurl"; + //RGV系统端口 + String RGVPORT = "rgvport"; + //指定AGV系统 String AGVTYPE = "agvType"; - /** - * WMS系统接口地址 - */ + //WMS系统接口地址 String WMSURL = "wmsurl"; - /** - * MES系统接口地址 - */ - String MESURL = "mesurl"; - /** - * WCS系统接口地址 - */ + //WCS系统接口地址 String WCSURL = "wcsurl"; String HASOTHERSYSTEM = "hasOtherSystem"; String ERPURL = "erpurl"; - /** - * 是否存在wms系统 - */ + //是否存在wms系统 String HASWMS = "hasWms"; - /** - * lucene日志索引目录 - */ + + // + String MESURL= "mesurl"; + //lucene日志索引目录 String LUCENEURL = "luceneUrl"; - /** - * 路由选择 - */ + //路由选择 String ROUTE = "route"; - /** - * 忽略取放货校验 - */ + //忽略取放货校验 String IGNOREHASGOODS = "ignoreHasGoods"; - /** - * 项目类型 - */ + //项目类型 String BUSINESSTYPE = "businessType"; - /** - * 海亮贴标设备ip - */ + //海亮贴标设备ip String LETTERINGURL = "letteringUrl"; - /** - * 海亮贴标设备 - */ + //海亮贴标设备 String LETTERINGPORT = "letteringPort"; - /** - * NDC断线重连reconnection - */ + //NDC断线重连reconnection String NDC_RECONNECTION = "NDC_reconnection"; - /** - * 自动清理日志保留时间 - */ + //自动清理日志保留时间 String AutoCleanDays = "AutoCleanDays"; - /** - * 最大任务下发时间 - */ + //最大任务下发时间 String MAXSENDTASKTIME = "maxSendTaskTime"; - /** - * 指令下发立库 - */ + //指令下发立库 String INSTSENDLK = "instSendLk"; + /** + * 日志级别 + */ + String LOGLEVEL = "log_level"; + + String ELECTRIC ="electric"; } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/rest/MagicAgvController.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/rest/MagicAgvController.java deleted file mode 100644 index 13176a6..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/rest/MagicAgvController.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.nl.acs.agv.rest; - - - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.MagicAgvService; -import org.nl.common.logging.annotation.Log; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author 20220102CG\noblelift - */ -@RestController -@RequiredArgsConstructor - -@RequestMapping("/api/magic") -@Slf4j -public class MagicAgvController { - private final MagicAgvService magicAgvService; - - /** - * 设备请求离开 - * @PreAuthorize("@el.check('routePlan:list')") - * @param device - * @return - */ - @PostMapping("/agvack/{device}") - @Log("AGV请求离开") - /** AGV请求离开 */ - public ResponseEntity requestAck(@PathVariable String device) { - return new ResponseEntity<>(magicAgvService.requestAck(device), HttpStatus.OK); - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/MagicAgvService.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/MagicAgvService.java deleted file mode 100644 index 1c7439f..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/MagicAgvService.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.nl.acs.agv.server; - -import cn.hutool.http.HttpResponse; -import org.nl.acs.agv.server.dto.AgvDto; -import org.nl.acs.instruction.domain.Instruction; - -import java.util.Map; - -/** - * @Author: lyd - * @Description: - * @Date: 2022-08-15 - */ -public interface MagicAgvService { - - /** - * 查询所有AGV - * - * @return - */ - Map findAllAgvFromCache(); - - /** - * 查询自动门状态 - * - * @param device - * @return - */ - public String queryDoorStatus(String device); - - /** - * 根据指令号查询AGV指令状态 - * - * @param instCode - * @return - */ - public HttpResponse queryAgvInstStatus(String instCode); - - /** - * 下发agv任务 - * @param inst - * @return - * @throws Exception - */ - public HttpResponse sendAgvInstToMagic(Instruction inst) throws Exception; - - - /** - * 根据code下发agv任务 - * @param code - * @return - * @throws Exception - */ - public HttpResponse sendAgvInstToMagic(String code) throws Exception; - - - /** - * 查询AGV状态,故障、充电等 - * @return - */ - public HttpResponse queryMagicAgvDeviceStatus(); - - /** - * 删除magic任务 - * - * @param instCode - * @return - */ - public HttpResponse deleteAgvInst(String instCode); - - - /** - * 查询Magic AGV任务状态调用 - * - * @param jobno - * @param type - * @param address - * @param action - * @param processingVehicle - * @return - */ - public String process(String jobno, String type, String address, String action, String processingVehicle); - - - /** - * Magic AGV 请求离开调用 - * - * @param device - * @return - */ - public String requestAck(String device); - - - /** - * magic 全部暂停车辆 - * @return - * @throws Exception - */ - public HttpResponse pause() throws Exception; - - /** - * magic 暂停指定车辆 - * @param device_code - * @return - * @throws Exception - */ - public HttpResponse pause(String device_code) throws Exception; - - /** - * magic 全部恢复车辆 - * @return - * @throws Exception - */ - public HttpResponse resume() throws Exception; - - /** - * magic 恢复指定车辆 - * @param device_code - * @return - * @throws Exception - */ - public HttpResponse resume(String device_code) throws Exception; - - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/MagicAgvServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/MagicAgvServiceImpl.java deleted file mode 100644 index 9990569..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/MagicAgvServiceImpl.java +++ /dev/null @@ -1,839 +0,0 @@ -package org.nl.acs.agv.server.impl; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpRequest; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.AcsConfig; -import org.nl.acs.agv.AgvUtil; -import org.nl.acs.agv.server.MagicAgvService; -import org.nl.acs.agv.server.dto.AgvDto; -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_driver.conveyor.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.storage.standard_storage.StandardStorageDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.instruction.domain.Instruction; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.log.LokiLog; -import org.nl.acs.log.LokiLogType; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.common.exception.BadRequestException; -import org.nl.config.SpringContextHolder; -import org.nl.config.language.LangProcess; -import org.nl.system.service.param.ISysParamService; -import org.springframework.stereotype.Service; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author 20220102CG\noblelift - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class MagicAgvServiceImpl implements MagicAgvService { - - private final DeviceAppService deviceAppService; - private final ISysParamService paramService; - private final AcsToWmsService acsToWmsService; - - - - Map AGVDeviceStatus = new HashMap(); - /** - * 进入离开等待 - */ - private static final String ONE = "1"; - /** - * 进入等待 离开不等待 - */ - private static final String TWO = "2"; - /** - * 进入不等待 离开等待 - */ - private static final String THREE = "3"; - /** - * 不等待 - */ - private static final String FOUR = "4"; - private static final String FIVE = "5"; - - /** - * 1请求取货 - */ - private static final String INST_ONE = "1"; - /** - * 2取货完成离开 - */ - private static final String INST_TWO = "2"; - /** - * 3请求放货 - */ - private static final String INST_THREE = "3"; - /** - * 4放货完成离开 - */ - private static final String INST_FOUR = "4"; - - /** - * 请求进入 - */ - private static final String ON_ENTRY = "onEntry"; - /** - * 请求取货 - */ - private static final String LOAD = "load"; - /** - * 请求放货 - */ - private static final String UNLOAD = "Unload"; - /** - * 取货放货完成 - */ - private static final String ON_STATION = "onStation"; - /** - * 取货完成离开 - */ - private static final int PICKUP_COMPLETE_TWO = 2; - /** - * 放货完成离开 - */ - private static final int DELIVERY_COMPLETE_FOUR = 4; - - - - @LokiLog(type = LokiLogType.AGV) - @Override - public HttpResponse sendAgvInstToMagic(String instcode) throws Exception { - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - Instruction inst = instructionService.findByCodeFromCache(instcode); - HttpResponse result = this.sendAgvInstToMagic(inst); - return result; - } - - @LokiLog(type = LokiLogType.AGV) - @Override - public HttpResponse queryAgvInstStatus(String instCode) { - if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) { - String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); - String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - - agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + instCode; - - HttpResponse result = HttpRequest.get(agvurl) - //超时,毫秒 - .timeout(20000) - .execute(); - log.info("查询agv指令数据:" + result.body()); - return result; - } else { - return null; - } - - } - - @LokiLog(type = LokiLogType.AGV) - @Override - public HttpResponse sendAgvInstToMagic(Instruction inst) throws Exception { - - JSONArray ja = new JSONArray(); - JSONObject orderjo = new JSONObject(); - String instno = inst.getInstruction_code(); - String compound_inst_data = inst.getCompound_inst_data(); - String[] str = null; - List pathlist = null; - - if (StrUtil.equals(CommonFinalParam.TWO, inst.getInstruction_type()) && !StrUtil.isEmpty(compound_inst_data)) { - str = compound_inst_data.split("->"); - pathlist = Arrays.asList(str); - - for (int i = 0; i < pathlist.size(); i++) { - String device_code = pathlist.get(i); - Device device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device)) { - throw new BadRequestException(LangProcess.msg("device_checkNull", device_code)); - } - if (i == 0) { - ja.add(destination(device_code, "Load", CommonFinalParam.ONE, CommonFinalParam.ONE)); - } else if (i == pathlist.size() - 1) { - ja.add(destination(device_code, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE)); - } else { - ja.add(destination(device_code, "NOP", CommonFinalParam.ONE, "5")); - } - - } - - //指定agv车号 暂时不用 设置任务最终时间 - //orderjo.put("intendedVehicle", ""); - orderjo.put("deadline", AgvUtil.getNextDay(1)); - - orderjo.put("destinations", ja); - - JSONObject prijo = new JSONObject(); - prijo.put("key", "priority"); - prijo.put("value", inst.getPriority()); - - JSONArray prija = new JSONArray(); - prija.add(prijo); - orderjo.put("properties", prija); - - - } else { - - String startAddress = inst.getStart_point_code(); - String nextAddress = inst.getNext_point_code(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device nextdevice = appService.findDeviceByCode(nextAddress); - Device startdevice = appService.findDeviceByCode(startAddress); - //指定agv车号 暂时不用 - //orderjo.put("intendedVehicle", ""); - //设置任务最终时间 - orderjo.put("deadline", AgvUtil.getNextDay(1)); - //拼接起点子任务动作,待完善,动作码需要从数据库取值 - ja.add(destination(startAddress, "Load", CommonFinalParam.ONE, CommonFinalParam.ONE)); - //拼接终点子任务动作,待完善,动作码需要从数据库取值 - ja.add(destination(nextAddress, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE)); - - orderjo.put("destinations", ja); - - JSONObject prijo = new JSONObject(); - prijo.put("key", "priority"); - prijo.put("value", inst.getPriority()); - - JSONArray prija = new JSONArray(); - prija.add(prijo); - orderjo.put("properties", prija); - - } - - if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) { - String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); - String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - - agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + instno; - - log.info("下发agv指令参数:{}", orderjo.toString()); - - HttpResponse result = null; - try { - result = HttpRequest.post(agvurl) - //表单内容 - .body(String.valueOf(orderjo)) - //超时,毫秒 - .timeout(20000) - .execute(); - } catch (Exception e) { - throw new RuntimeException("下发agv失败!"); - } - return result; - } else { - return null; - } - - } - - /** - * 返回一个点位操作子任务 - * - * @param locationName 点位 - * @param operation 点位操作 - * @param propertiesType 子任务类型 - * @param pro 子任务参数 - * 调用demo:destination("sh15p", "Spin", CommonFinalParam.TWO, "3.14") - * demo:destination("cz14", "JackUnload", CommonFinalParam.THREE, "") - * @return - */ - public static JSONObject destination(String locationName, String operation, String propertiesType, String pro) { - //新增业务订单 - JSONObject destinationOrder = new JSONObject(); - //目标工作站 - destinationOrder.put("locationName", locationName); - //机器人在工作站要执行的操作 - destinationOrder.put("operation", operation); - //取货前等待、取货后等待 - if (CommonFinalParam.ONE.equals(propertiesType)) { - - //pro 1 进入离开等待 - if (ONE.equals(pro)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "EntryRequired"); - pro1.put("value", "True"); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "PauseOnStation"); - pro2.put("value", "True"); - properties.add(pro2); - destinationOrder.put("properties", properties); - //进入等待 离开不等待 - } else if (TWO.equals(pro)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "EntryRequired"); - pro1.put("value", "True"); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "PauseOnStation"); - pro2.put("value", "False"); - properties.add(pro2); - destinationOrder.put("properties", properties); - //进入不等待 离开等待 - } else if (THREE.equals(pro)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "EntryRequired"); - pro1.put("value", "False"); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "PauseOnStation"); - pro2.put("value", "True"); - properties.add(pro2); - destinationOrder.put("properties", properties); - //不等待 - } else if (FOUR.equals(pro)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "EntryRequired"); - pro1.put("value", "False"); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "PauseOnStation"); - pro2.put("value", "False"); - properties.add(pro2); - destinationOrder.put("properties", properties); - } else if (FIVE.equals(pro)) { - JSONArray properties = new JSONArray(); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "PauseOnStation"); - pro2.put("value", "True"); - properties.add(pro2); - destinationOrder.put("properties", properties); - } - //Spin转动 - } else if (CommonFinalParam.TWO.equals(propertiesType)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - //坐标系类型,global_spin_angle为全局坐标系 - pro1.put("key", "global_spin_angle"); - //弧度值,如3.14 - pro1.put("value", pro); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - //固定值 - pro2.put("key", "spin_direction"); - //弧度值,如0 - pro2.put("value", "0"); - properties.add(pro2); - destinationOrder.put("properties", properties); - //JackUnload,Jackload不操作 - } else if (CommonFinalParam.THREE.equals(propertiesType)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - //固定值 - pro1.put("key", "recognize"); - //固定值 - pro1.put("value", "false"); - properties.add(pro1); - destinationOrder.put("properties", properties); - } else if (CommonFinalParam.FOUR.equals(propertiesType)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - //坐标系类型,robot_spin_angle为机器人坐标系 - pro1.put("key", "robot_spin_angle"); - //弧度值,如3.14 - pro1.put("value", pro); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - //固定值 - pro2.put("key", "spin_direction"); - //弧度值,如0 - pro2.put("value", "0"); - properties.add(pro2); - destinationOrder.put("properties", properties); - } - return destinationOrder; - } - - @LokiLog(type = LokiLogType.AGV) - @Override - public HttpResponse queryMagicAgvDeviceStatus() { - if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) { - String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); - String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - agvurl = agvurl + ":" + agvport + "/v1/vehicles"; - HttpResponse result = HttpRequest.get(agvurl) - //超时,毫秒 - .timeout(20000) - .execute(); - log.info("查询agv状态数据:{}", result.body()); - if (result.getStatus() == CommonFinalParam.STATUS_OPEN) { - JSONArray ja = (JSONArray) JSONArray.parse(result.body()); - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = (JSONObject) ja.get(i); - String name = jo.getString("name"); - String state = jo.getString("state"); - String energyLevel = jo.getString("energyLevel"); - String transportOrder = jo.getString("transportOrder"); - String positionAngle = jo.getString("positionAngle"); - String positionX = jo.getString("positionX"); - String positionY = jo.getString("positionY"); - AgvDto dto = new AgvDto(); - dto.setName(name); - dto.setEnergyLevel(energyLevel); - dto.setState(state); - dto.setPositionAngle(positionAngle); - dto.setPositionX(positionX); - dto.setPositionY(positionY); - dto.setTransportOrder(transportOrder); - - if (AGVDeviceStatus.containsKey(name)) { - AGVDeviceStatus.remove(name); - AGVDeviceStatus.put(name, dto); - } else { - AGVDeviceStatus.put(name, dto); - } - } - } - return result; - } else { - return null; - } - - - } - - @LokiLog(type = LokiLogType.AGV) - @Override - public HttpResponse deleteAgvInst(String instCode) { - if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) { - String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); - String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - - agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + instCode + "/withdrawal"; - log.info("删除agv指令请求agvurl:{}", agvurl); - - HttpResponse result = null; - try { - result = HttpRequest.post(agvurl) - //超时,毫秒 - .timeout(20000) - .execute(); - log.info("删除agv指令请求反馈:{}", result); - } catch (Exception e) { - throw new RuntimeException("下发agv失败!"); - } - return result; - } else { - return null; - } - - } - - /** - * 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - * @param jobno - * @param type - * @param address - * @param action - * @param processingVehicle - * @return - */ - @LokiLog(type = LokiLogType.AGV) - @Override - public synchronized String process(String jobno, String type, String address, String action, String processingVehicle) { - log.info("查询到AGV请求参数,jobno:{},address:{}", jobno + ",address:" + address + ",type:" + type + ",action:" + action); - boolean is_feedback = false; - String str = ""; - String backaddress = address; - if (address.indexOf(CommonFinalParam.DOT) > 0) { - str = address.substring(address.indexOf(CommonFinalParam.DOT), address.length()); - address = address.substring(0, address.indexOf(CommonFinalParam.DOT)); - } else if (address.indexOf(CommonFinalParam.HYPHEN_) > 0) { - address = address.substring(0, address.indexOf("-")); - } - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - Instruction inst = instructionService.findByCodeFromCache(jobno); - - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device addressdevice = appService.findDeviceByCode(address); - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - //请求进入 - if (ON_ENTRY.equals(type)) { - - if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver(); - //请求取货 - if (LOAD.equals(action)) { - if (standardInspectSiteDeviceDriver.getMode() == CommonFinalParam.DEVICE_MODE_TWO && standardInspectSiteDeviceDriver.getMove() > CommonFinalParam.DEVICE_MOVE_ZERO) { - inst.setExecute_status(INST_ONE); - is_feedback = true; - } - //请求放货 - } else if (UNLOAD.equals(action)) { - if (standardInspectSiteDeviceDriver.getMode() == CommonFinalParam.DEVICE_MODE_TWO && standardInspectSiteDeviceDriver.getMove() == CommonFinalParam.DEVICE_MOVE_ZERO) { - inst.setExecute_status(INST_THREE); - is_feedback = true; - } - } - } - - - if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver(); - //请求取货 - if (LOAD.equals(action)) { - if (addressdevice.getHas_goods() > 0) { - inst.setExecute_status(INST_ONE); - is_feedback = true; - } - //请求放货 - } else if (UNLOAD.equals(action)) { - if (addressdevice.getHas_goods() == 0) { - inst.setExecute_status(INST_THREE); - is_feedback = true; - } - } - } - - if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - //请求取货 - if (LOAD.equals(action)) { - inst.setExecute_status(INST_ONE); - is_feedback = true; - //请求放货 - } else if (UNLOAD.equals(action)) { - inst.setExecute_status(INST_THREE); - is_feedback = true; - } - } - - //取放货完成 - } else if (ON_STATION.equals(type)) { - System.out.println("取放货完成"); - if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver(); - //取货完成 - if (LOAD.equals(action)) { - if (standardInspectSiteDeviceDriver.getMode() == CommonFinalParam.DEVICE_MODE_TWO && standardInspectSiteDeviceDriver.getMove() == CommonFinalParam.DEVICE_MOVE_ZERO) { - inst.setExecute_device_code(processingVehicle); - inst.setExecute_status(INST_TWO); - is_feedback = true; - } - //放货完成 - } else if (UNLOAD.equals(action)) { - if (standardInspectSiteDeviceDriver.getMode() == CommonFinalParam.DEVICE_MODE_TWO && standardInspectSiteDeviceDriver.getMove() > CommonFinalParam.DEVICE_MOVE_ZERO) { - inst.setExecute_device_code(address); - inst.setExecute_status(INST_FOUR); - is_feedback = true; - } - } - } - - - if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver(); - //取货完成 - if (LOAD.equals(action)) { - inst.setExecute_device_code(processingVehicle); - inst.setExecute_status(CommonFinalParam.TWO); - is_feedback = true; - //放货完成 - } else if (UNLOAD.equals(action)) { - inst.setExecute_device_code(address); - inst.setExecute_status(INST_FOUR); - is_feedback = true; - } - - } - - if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - //取货完成 - if (LOAD.equals(action)) { - inst.setExecute_device_code(processingVehicle); - inst.setExecute_status(CommonFinalParam.TWO); - is_feedback = true; - //放货完成 - } else if (UNLOAD.equals(action)) { - inst.setExecute_device_code(processingVehicle); - inst.setExecute_status(INST_FOUR); - is_feedback = true; - } - } - } - - JSONObject requestjo = new JSONObject(); - JSONArray ja = new JSONArray(); - if (is_feedback) { - String param = ""; - JSONObject jo = new JSONObject(); - if (str.length() > 0) { - backaddress = backaddress + str; - } - if (ON_STATION.equals(type)) { - param = "EntryPermitted-" + backaddress + action; - } else if (ON_STATION.equals(type)) { - param = "ContinueOnStation-" + backaddress + action; - } - - jo.put("key", param); - jo.put("value", "False"); - ja.add(jo); - requestjo.put("properties", ja); - log.info("反馈AGV请求数据:{}", requestjo); - System.out.println("back agv:" + requestjo); - - String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); - String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - - agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + jobno + "/interact"; - - HttpResponse result = HttpRequest.post(agvurl) - .body(String.valueOf(requestjo)) - //超时,毫秒 - .timeout(20000) - .execute(); - } - is_feedback = false; - return requestjo.toString(); - - } - - @LokiLog(type = LokiLogType.AGV) - @Override - public String requestAck(String address) { - log.info("AGV请求离开参数:{}", address); - boolean flag = false; - - if (address.indexOf(CommonFinalParam.DOT) > 0) { - address = address.substring(0, address.indexOf(".")); - } - if (address.indexOf(CommonFinalParam.HYPHEN_) > 0) { - address = address.substring(0, address.indexOf("-")); - } - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device addressdevice = appService.findDeviceByCode(address); - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - StandardStorageDeviceDriver standardStorageDeviceDriver; - - //mes = AgvClientXZ.mes(zlbh, device, type); - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - if ((addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver)) { - flag = true; - } - - if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver(); - flag = true; - log.info("agvstatus:" + standardInspectSiteDeviceDriver.getFlag() + ""); - //取货完成离开 - if (standardInspectSiteDeviceDriver.getFlag() == PICKUP_COMPLETE_TWO) { - if (standardInspectSiteDeviceDriver.getMove() == 0) { - flag = true; - standardInspectSiteDeviceDriver.setFlag(5); - } - } - //放货完成离开 - if (standardInspectSiteDeviceDriver.getFlag() == DELIVERY_COMPLETE_FOUR) { - if (standardInspectSiteDeviceDriver.getMove() == 1) { - flag = true; - standardInspectSiteDeviceDriver.setFlag(6); - } - } - } - - - if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver(); - flag = true; - log.info("agvstatus:" + standardOrdinarySiteDeviceDriver.getFlag() + ""); - - //取货完成离开 - if (standardOrdinarySiteDeviceDriver.getFlag() == PICKUP_COMPLETE_TWO) { - flag = true; - standardOrdinarySiteDeviceDriver.setFlag(5); - } - //放货完成离开 - if (standardOrdinarySiteDeviceDriver.getFlag() == DELIVERY_COMPLETE_FOUR) { - flag = true; - standardOrdinarySiteDeviceDriver.setFlag(6); - } - } - - if (flag) { - log.info("AGV请求离开,反馈成功:{}", address); - System.out.println("AGV请求离开,反馈成功 " + address); - return "OK"; - } else { - log.info("AGV请求离开,反馈失败{}", address); - System.out.println("AGV请求离开,反馈失败 " + address); - throw new RuntimeException("AGV请求离开,反馈失败 " + address); - } - - } - - @LokiLog(type = LokiLogType.AGV) - @Override - public HttpResponse pause() throws Exception { - if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) { - String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); - String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - - agvurl = agvurl + ":" + agvport + "/v1/vehicles/pause"; - log.info("暂停所有agv请求:{}", agvurl); - - HttpResponse result = HttpRequest.post(agvurl) - //超时,毫秒 - .timeout(20000) - .execute(); - log.info("暂停所有agv请求反馈:{}", result); - String type = ""; - if (result.getStatus() == CommonFinalParam.STATUS_OPEN) { - type = "info"; - } else { - type = "error"; - } - return result; - } else { - return null; - } - } - - - @LokiLog(type = LokiLogType.AGV) - @Override - public HttpResponse pause(String device_code) throws Exception { - if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) { - String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); - String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - - agvurl = agvurl + ":" + agvport + "/v1/vehicles/" + device_code + "/pause"; - log.info("暂停{} agv请求:{}", device_code, agvurl); - - HttpResponse result = HttpRequest.post(agvurl) - //超时,毫秒 - .timeout(20000) - .execute(); - log.info("暂停{} agv请求反馈:{}", device_code, result); - String type = ""; - return result; - } else { - return null; - } - - } - - - @LokiLog(type = LokiLogType.AGV) - @Override - public HttpResponse resume() throws Exception { - if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) { - String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); - String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - - agvurl = agvurl + ":" + agvport + "/v1/vehicles/resume"; - log.info("恢复所有agv请求:{}", agvurl); - - HttpResponse result = HttpRequest.post(agvurl) - //超时,毫秒 - .timeout(20000) - .execute(); - log.info("恢复所有agv请求反馈:{}", result); - String type = ""; - if (result.getStatus() == CommonFinalParam.STATUS_OPEN) { - type = "info"; - } else { - type = "error"; - } - return result; - } else { - return null; - } - - - } - - @LokiLog(type = LokiLogType.AGV) - @Override - public HttpResponse resume(String device_code) throws Exception { - if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) { - String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); - String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - - agvurl = agvurl + ":" + agvport + "/v1/vehicles/" + device_code + "/resume"; - log.info("恢复{} agv请求:{}", device_code, agvurl); - - HttpResponse result = HttpRequest.post(agvurl) - //超时,毫秒 - .timeout(20000) - .execute(); - log.info("恢复{} agv请求反馈:{}", device_code, result); - - return result; - } else { - return null; - } - } - - @LokiLog(type = LokiLogType.AGV) - @Override - public String queryDoorStatus(String device) { - log.info("AGV查询自动门状态,参数:{}", device); - int type = Integer.parseInt(paramService.findByCode(AcsConfig.BUSINESSTYPE).getValue()); - switch (type) { - case 4: - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASOTHERSYSTEM).getValue(), CommonFinalParam.ONE)) { - String result = acsToWmsService.queryDoorsStatus().body(); - JSONArray ja = JSONArray.parseArray(result); - log.info("AGV查询自动门状态,反馈:{}", ja.toString()); - return ja.toString(); - } - return null; - default: - if (StrUtil.equals(CommonFinalParam.DOORS, device)) { - List list = deviceAppService.findDevice(DeviceType.autodoor); - JSONArray ja = new JSONArray(); - for (int i = 0; i < list.size(); i++) { - Device doordevice = deviceAppService.findDeviceByCode(list.get(i).getDevice_code()); - if (ObjectUtil.isEmpty(doordevice)) { - throw new BadRequestException(LangProcess.msg("device_checkNull", list.get(i).getDevice_code())); - } - String mes = null; - - } - log.info("AGV查询自动门状态,反馈:{}", ja.toString()); - return ja.toString(); - - } else { - Device doordevice = deviceAppService.findDeviceByCode(device); - if (ObjectUtil.isEmpty(doordevice)) { - throw new BadRequestException(LangProcess.msg("device_checkNull", device)); - } - String mes = null; - JSONObject jo = JSONObject.parseObject(mes); - log.info("AGV查询自动门状态,反馈:{}", jo.toString()); - return jo.toString(); - } - } - } - - @Override - public Map findAllAgvFromCache() { - return AGVDeviceStatus; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/ZheDaAgvServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/ZheDaAgvServiceImpl.java deleted file mode 100644 index 6f24cd8..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/ZheDaAgvServiceImpl.java +++ /dev/null @@ -1,494 +0,0 @@ -package org.nl.acs.agv.server.impl; - -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpRequest; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.AcsConfig; -import org.nl.acs.agv.AgvUtil; -import org.nl.acs.agv.server.ZheDaAgvService; -import org.nl.acs.common.base.CommonFinalParam; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device_driver.two_conveyor.hongxiang_device.HongXiangConveyorDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.instruction.domain.Instruction; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.log.LokiLog; -import org.nl.acs.log.LokiLogType; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.config.SpringContextHolder; -import org.nl.system.service.param.ISysParamService; -import org.springframework.stereotype.Service; - -/** - * @author 20220102CG\noblelift - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class ZheDaAgvServiceImpl implements ZheDaAgvService { - private final ISysParamService paramService; - - /** - * 判断是否追加任务 - */ - private static final String THREE = "3"; - private static final String FOUR = "4"; - private static final String FIVE = "5"; - /** - * 取货的进入前等待和离开等待 - */ - private static final String LOAD = "load"; - /** - * 取货的进入前等待和离开等待 - */ - private static final String ENTRY_REQUIRED = "EntryRequired"; - private static final String ENTRYREQUIRED = "entryRequired"; - private static final String PAUSE_ON_STATION = "PauseOnStation"; - /** - * 等待点等待 - */ - private static final String WAIT = "Wait"; - /** - * 放货的进入前等待和离开等待 - */ - private static final String UNLOAD = "Unload"; - - @LokiLog(type = LokiLogType.AGV) - @Override - public HttpResponse sendAgvInstToAgv(Instruction inst) throws Exception { - JSONObject jo = new JSONObject(); - String start_point_code = inst.getStart_point_code(); - String next_point_code = inst.getNext_point_code(); - //1楼AGV普通任务 - //2楼AGV普通任务 - //2楼AGV起点追加任务 - //2楼AGV终点追加任务 - String task_type = inst.getInstruction_type(); - jo.put("deadline", AgvUtil.getNextDay(1)); - //判断是否追加任务 - if (THREE.equals(task_type) || FOUR.equals(task_type)) { - jo.put("complete", "false"); - } else { - jo.put("complete", "true"); - } - jo.put("task_code", inst.getInstruction_code()); - //根据任务,下发指令类型 - JSONArray destinations = new JSONArray(); - if (THREE.equals(task_type)) { - destinations.add(destination(start_point_code, "Wait", "5", CommonFinalParam.ONE)); - } else if (FOUR.equals(task_type)) { - destinations.add(destination(start_point_code, "Load", CommonFinalParam.ONE, CommonFinalParam.ONE)); - destinations.add(destination(next_point_code, "Wait", "5", CommonFinalParam.ONE)); - } else { - destinations.add(destination(start_point_code, "Load", CommonFinalParam.ONE, CommonFinalParam.ONE)); - destinations.add(destination(next_point_code, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE)); - } - - jo.put("destinations", destinations); - - if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) { - String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); - String agvurl2 = paramService.findByCode(AcsConfig.AGVURL2).getValue(); - String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - String agvport2 = paramService.findByCode(AcsConfig.AGVPORT2).getValue(); - - - //不同楼层下发不同的agv系统 - if (CommonFinalParam.ONE.equals(task_type)) { - agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + inst.getInstruction_code(); - } else { - agvurl = agvurl2 + ":" + agvport2 + "/v1/transportOrders/" + inst.getInstruction_code(); - } - log.info("下发agv任务请求:{}", agvurl); - - HttpResponse result = HttpRequest.post(agvurl) - //表单内容 - .body(String.valueOf(jo)) - //超时,毫秒 - .timeout(20000) - .execute(); - log.info("下发agv任务请求反馈:{}", result); - return result; - } else { - return null; - } - } - - /** - * ZDAGV - * @param type - * @return - */ - @LokiLog(type = LokiLogType.AGV) - @Override - public HttpResponse queryAgvInstStatus(String type) { - if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) { - String agvurl = ""; - String agvport = ""; - if (CommonFinalParam.ONE.equals(type)) { - agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); - agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - } - if (CommonFinalParam.TWO.equals(type)) { - agvurl = paramService.findByCode(AcsConfig.AGVURL2).getValue(); - agvport = paramService.findByCode(AcsConfig.AGVPORT2).getValue(); - } - - agvurl = agvurl + ":" + agvport + "/v1/transportOrders"; - HttpResponse result = HttpRequest.get(agvurl) - //超时,毫秒 - .timeout(20000) - .execute(); - System.out.println("查询agv指令数据:" + result.body()); - - return result; - } else { - return null; - } - } - - /** - * 处理AGV指令 ZDAGV - * - * @param jobno - * @param type - * @param address - * @param action - * @param processingVehicle - * @return - */ - @LokiLog(type = LokiLogType.AGV) - @Override - public synchronized String process(String jobno, String type, String address, String action, String processingVehicle) { - log.info("查询到AGV请求参数,jobno:{},address:{}", jobno + ",address:" + address + ",type:" + type + ",action:" + action); - //释放AGV资源,继续后续动作 - boolean is_feedback = false; - String str = ""; - String backaddress = address; - if (address.indexOf(CommonFinalParam.DOT) > 0) { - str = address.substring(address.indexOf(".") + 1, address.length()); - address = address.substring(0, address.indexOf(".")); - } else if (address.indexOf(CommonFinalParam.HYPHEN_) > 0) { - address = address.substring(0, address.indexOf("-")); - } - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); - AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); - - Instruction inst = instructionService.findByCodeFromCache(jobno); - TaskDto task = taskService.findByCode(inst.getTask_code()); - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device addressdevice = appService.findDeviceByCode(address); - - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - - //取货的进入前等待和离开等待 - if (LOAD.equals(action)) { - if (ENTRY_REQUIRED.equals(type)) { - - //豪凯自动线对接位 - if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver(); - if ((hongXiangConveyorDeviceDriver.getAction() == CommonFinalParam.ACTION_ONE || hongXiangConveyorDeviceDriver.getAction() == CommonFinalParam.ACTION_THREE)) { - if(hongXiangConveyorDeviceDriver.getMove() == 1){ - inst.setExecute_status(CommonFinalParam.ONE); - is_feedback = true; - } - } - } - } - if (PAUSE_ON_STATION.equals(type)) { - - if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver(); - inst.setExecute_status(CommonFinalParam.TWO); - hongXiangConveyorDeviceDriver.writing(2); - is_feedback = true; - } - - - } - } - //等待点等待 - if (WAIT.equals(action)) { - if (WAIT.equals(type)) { - JSONObject jo = new JSONObject(); - jo.put("task_code", inst.getInstruction_code()); - JSONArray destinations = new JSONArray(); - String inst_type = inst.getInstruction_type(); - //如果任务类型为1,在点位进行等待,则查询当前叠盘位的数量,取当前数量的层数进行追加任务 -// if (CommonFinalParam.ONE.equals(inst_type)) { -// emptyVehicleStackingPositionDeviceDriver = (EmptyVehicleStackingPositionDeviceDriver) addressdevice.getDeviceDriver(); -// int current_num = emptyVehicleStackingPositionDeviceDriver.getNumber(); -// if (current_num > 12) { -// log.info("当前叠盘架:" + jobno + "已放满!"); -// return null; -// } -// String start_point_code = inst.getStart_point_code(); -// String next_point_code = inst.getNext_point_code(); -// start_point_code = start_point_code + "." + (current_num + 1); -// destinations.add(destination(start_point_code, "Load", CommonFinalParam.ONE, CommonFinalParam.ONE)); -// destinations.add(destination(next_point_code, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE)); -// -// } - - String resp = acsToWmsService.requestTaskAgain(address, task.getExt_task_id(), inst.getVehicle_code()); - JSONObject respjson = JSONObject.parseObject(resp); - - if (StrUtil.equals(inst.getInstruction_type(), THREE)) { - //2楼AGV起点追加任务 - String start_device_code = respjson.getString("device_code"); - String next_device_code = inst.getNext_device_code(); - destinations.add(destination(start_device_code, "load", CommonFinalParam.ONE, CommonFinalParam.ONE)); - destinations.add(destination(next_device_code, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE)); - - } else if (StrUtil.equals(inst.getInstruction_type(), FOUR)) { - //2楼AGV终点追加任务 - String next_device_code = respjson.getString("device_code"); - destinations.add(destination(next_device_code, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE)); - } - - jo.put("destinations", destinations); - - String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); - String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - - String url = agvurl + ":" + agvport + "/addDestinations"; - log.info("下发agv任务请求:{}", url); - - HttpResponse result = HttpRequest.post(url) - //表单内容 - .body(String.valueOf(jo)) - //超时,毫秒 - .timeout(20000) - .execute(); - log.info("下发agv任务请求反馈:{}", result); - - //对任务进行封口 - JSONObject complete = new JSONObject(); - complete.put("task_code", inst.getInstruction_code()); - - String url2 = agvurl + ":" + agvport + "markComplete"; - log.info("下发agv任务请求:{}", url2); - - HttpResponse result2 = HttpRequest.post(url2) - //表单内容 - .body(String.valueOf(complete)) - //超时,毫秒 - .timeout(20000) - .execute(); - log.info("下发agv任务请求反馈:{}", result2); - } - } - //放货的进入前等待和离开等待 - if (UNLOAD.equals(action)) { - if (ENTRY_REQUIRED.equals(type)) { - if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver(); - if ((hongXiangConveyorDeviceDriver.getAction() == CommonFinalParam.ACTION_TWO || hongXiangConveyorDeviceDriver.getAction() == CommonFinalParam.ACTION_THREE)) { - if(hongXiangConveyorDeviceDriver.getMove() == 0){ - inst.setExecute_status("3"); - is_feedback = true; - } - } - } - } - if (PAUSE_ON_STATION.equals(type)) { - if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver(); - inst.setExecute_status(CommonFinalParam.FOUR); - hongXiangConveyorDeviceDriver.writing(3); - is_feedback = true; - } - } - } - JSONObject requestjo = new JSONObject(); - if (is_feedback) { - requestjo.put("task_code", jobno); - requestjo.put("operation", action); - if (ENTRYREQUIRED.equals(type) || ENTRY_REQUIRED.equals(type)) { - requestjo.put("entryRequired", "true"); - } else { - requestjo.put("pauseOnStation", "true"); - } - log.info("反馈AGV请求数据:{}", requestjo); - System.out.println("back agv:" + requestjo); - - String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); - String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - - if (FOUR.equals(inst.getInstruction_type())) { - agvurl = paramService.findByCode(AcsConfig.AGVURL2).getValue(); - } - agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + jobno + "/interact"; - - HttpResponse result = HttpRequest.post(agvurl) - .body(String.valueOf(requestjo)) - //超时,毫秒 - .timeout(20000) - .execute(); - } - return requestjo.toString(); - - } - - @LokiLog(type = LokiLogType.AGV) - @Override - public HttpResponse markComplete(String code) { - - if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) { - String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); - String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - - agvurl = agvurl + ":" + agvport + "/v1/" + code + "/markComplete"; - log.info("关闭agv运单序列请求:{}", agvurl); - - HttpResponse result = HttpRequest.post(agvurl) - //.body(String.valueOf(orderjo))//表单内容 - //超时,毫秒 - .timeout(20000) - .execute(); - log.info("关闭agv运单序列请求反馈:{}", result); - - return result; - } else { - return null; - } - - } - - - /** - * 返回一个点位操作子任务 ZDAGV - * - * @param locationName 点位 - * @param operation 点位操作 - * @param propertiesType 子任务类型 - * @param pro 子任务参数 - * 调用demo:destination("sh15p", "Spin", CommonFinalParam.TWO, "3.14") - * demo:destination("cz14", "JackUnload", "3", "") - * @return - */ - @LokiLog(type = LokiLogType.AGV) - public static JSONObject destination(String locationName, String operation, String propertiesType, String pro) { - //新增业务订单 - JSONObject destinationOrder = new JSONObject(); - //目标工作站 - destinationOrder.put("locationName", locationName); - //机器人在工作站要执行的操作 - destinationOrder.put("operation", operation); - //取货前等待、取货后等待 - if (CommonFinalParam.ONE.equals(propertiesType)) { - - //pro 1 进入离开等待 - if (CommonFinalParam.ONE.equals(pro)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "EntryRequired"); - pro1.put("value", "True"); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "PauseOnStation"); - pro2.put("value", "True"); - properties.add(pro2); - destinationOrder.put("properties", properties); - //进入等待 离开不等待 - } else if (CommonFinalParam.TWO.equals(pro)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "EntryRequired"); - pro1.put("value", "True"); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "PauseOnStation"); - pro2.put("value", "False"); - properties.add(pro2); - destinationOrder.put("properties", properties); - //进入不等待 离开等待 - } else if (THREE.equals(pro)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "EntryRequired"); - pro1.put("value", "False"); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "PauseOnStation"); - pro2.put("value", "True"); - properties.add(pro2); - destinationOrder.put("properties", properties); - //不等待 - } else { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "EntryRequired"); - pro1.put("value", "False"); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "PauseOnStation"); - pro2.put("value", "False"); - properties.add(pro2); - destinationOrder.put("properties", properties); - } - //Spin转动 - } else if (CommonFinalParam.TWO.equals(propertiesType)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - //坐标系类型,global_spin_angle为全局坐标系 - pro1.put("key", "global_spin_angle"); - //弧度值,如3.14 - pro1.put("value", pro); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - //固定值 - pro2.put("key", "spin_direction"); - //弧度值,如0 - pro2.put("value", "0"); - properties.add(pro2); - destinationOrder.put("properties", properties); - //JackUnload,Jackload不操作 - } else if (THREE.equals(propertiesType)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - //固定值 - pro1.put("key", "recognize"); - //固定值 - pro1.put("value", "false"); - properties.add(pro1); - destinationOrder.put("properties", properties); - } else if (FOUR.equals(propertiesType)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - //坐标系类型,robot_spin_angle为机器人坐标系 - pro1.put("key", "robot_spin_angle"); - //弧度值,如3.14 - pro1.put("value", pro); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - //固定值 - pro2.put("key", "spin_direction"); - //弧度值,如0 - pro2.put("value", "0"); - properties.add(pro2); - destinationOrder.put("properties", properties); - //在该点进行等待 - } else if (FIVE.equals(propertiesType)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "Wait"); - pro1.put("value", "True"); - properties.add(pro1); - destinationOrder.put("properties", properties); - } - return destinationOrder; - } - - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java index 95abe54..2bf2959 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java @@ -7,7 +7,6 @@ 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.agv.ndcone.AgvNdcOneDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; import org.nl.acs.instruction.domain.Instruction; @@ -157,7 +156,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { // - AgvNdcOneDeviceDriver agvNdcOneDeviceDriver; + //开始任务/上报订单号 if (phase == 0x01) { @@ -205,10 +204,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { device = deviceAppService.findDeviceByCode(Integer.toString(arr[20])); } if (ObjectUtil.isNotEmpty(device)) { - if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { - agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver(); - agvNdcOneDeviceDriver.processSocket(arr); - } + } } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardCoveyorControlWithPlcScannerDevice.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardCoveyorControlWithPlcScannerDevice.java deleted file mode 100644 index d0b27a7..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardCoveyorControlWithPlcScannerDevice.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.nl.acs.common; - -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_plcscanner.StandardCoveyorControlWithPlcScannerDeviceDriver; -import org.springframework.stereotype.Service; - -/** - * @author geng by - * 输送机-控制点-PLC扫码器 - */ -@Service("standard_conveyor_control_with_plcscanner") -public class StandardCoveyorControlWithPlcScannerDevice extends AbstractDriverService { - @Override - public JSONObject getDeviceInfo(Device device) { - StandardCoveyorControlWithPlcScannerDeviceDriver standardCoveyorControlWithPlcScannerDeviceDriver = (StandardCoveyorControlWithPlcScannerDeviceDriver) device.getDeviceDriver(); - JSONObject jo = super.getCommonDeviceInfo(standardCoveyorControlWithPlcScannerDeviceDriver, 0, 0); - jo.put("error", standardCoveyorControlWithPlcScannerDeviceDriver.getError()); - jo.put("isError", standardCoveyorControlWithPlcScannerDeviceDriver.getIserror()); - jo.put("height", standardCoveyorControlWithPlcScannerDeviceDriver.getHeight()); - jo.put("operation_type", standardCoveyorControlWithPlcScannerDeviceDriver.getOperation_type()); - jo.put("direction", standardCoveyorControlWithPlcScannerDeviceDriver.getDirection()); - jo.put("action", standardCoveyorControlWithPlcScannerDeviceDriver.getAction()); - jo.put("ioaction", standardCoveyorControlWithPlcScannerDeviceDriver.getIoaction()); - jo.put("container", StrUtil.isEmpty(standardCoveyorControlWithPlcScannerDeviceDriver.getBarcode()) ? "" : standardCoveyorControlWithPlcScannerDeviceDriver.getBarcode()); - jo.put("message", StrUtil.isEmpty(standardCoveyorControlWithPlcScannerDeviceDriver.getMessage()) ? "" : standardCoveyorControlWithPlcScannerDeviceDriver.getMessage()); - jo.put("requestSucess", standardCoveyorControlWithPlcScannerDeviceDriver.getRequireSucess().toString()); - jo.put("applySucess", standardCoveyorControlWithPlcScannerDeviceDriver.getApplySucess().toString()); - jo.put("instruction_message", standardCoveyorControlWithPlcScannerDeviceDriver.getInst_message()); - return jo; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardCoveyorControlWithScannerDevice.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardCoveyorControlWithScannerDevice.java deleted file mode 100644 index 0f09ae0..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardCoveyorControlWithScannerDevice.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.nl.acs.common; - -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; -import org.springframework.stereotype.Service; - -/** - * @author geng by - * 输送机控制点-带扫描驱动 - */ -@Service("standard_conveyor_control_with_scanner") -public class StandardCoveyorControlWithScannerDevice extends AbstractDriverService { - - @Override - public JSONObject getDeviceInfo(Device device) { - StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver(); - JSONObject jo = super.getCommonDeviceInfo(standardCoveyorControlWithScannerDeviceDriver, 0, 0); - jo.put("error", standardCoveyorControlWithScannerDeviceDriver.getError()); - jo.put("isError", standardCoveyorControlWithScannerDeviceDriver.getIserror()); - jo.put("action", standardCoveyorControlWithScannerDeviceDriver.getAction()); - try { - jo.put("container", StrUtil.isEmpty(standardCoveyorControlWithScannerDeviceDriver.barcode()) ? "" : standardCoveyorControlWithScannerDeviceDriver.barcode()); - } catch (Exception e) { - e.printStackTrace(); - } - jo.put("message", StrUtil.equals(standardCoveyorControlWithScannerDeviceDriver.getMessage(), "null") ? "" : standardCoveyorControlWithScannerDeviceDriver.getMessage()); - jo.put("requestSucess", standardCoveyorControlWithScannerDeviceDriver.getRequireSucess().toString()); - jo.put("applySucess", standardCoveyorControlWithScannerDeviceDriver.getApplySucess().toString()); - return jo; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardInspectSiteDevice.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardInspectSiteDevice.java deleted file mode 100644 index b419359..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardInspectSiteDevice.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.nl.acs.common; - -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device_driver.conveyor.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.springframework.stereotype.Service; - -/** - * @author geng by - * 检测站点 - */ -@Service("standard_inspect_site") -public class StandardInspectSiteDevice extends AbstractDriverService { - @Override - public JSONObject getDeviceInfo(Device device) { - StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - JSONObject jo = super.getCommonDeviceInfo(standardInspectSiteDevicedriver, 0, 0); - jo.put("error", standardInspectSiteDevicedriver.getError()); - jo.put("isError", standardInspectSiteDevicedriver.getIserror()); - jo.put("container", standardInspectSiteDevicedriver.getContainer()); - jo.put("message", standardInspectSiteDevicedriver.getMessage()); - return jo; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardOrdinarySiteDevice.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardOrdinarySiteDevice.java deleted file mode 100644 index fddd360..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/common/StandardOrdinarySiteDevice.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.nl.acs.common; - -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; -import org.springframework.stereotype.Service; - -/** - * @author geng by - * 普通站点 - */ -@Service("standard_ordinary_site") -public class StandardOrdinarySiteDevice extends AbstractDriverService { - - @Override - public JSONObject getDeviceInfo(Device device) { - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - JSONObject jo = new JSONObject(); - jo.put("container", standardOrdinarySiteDeviceDriver.getContainer()); - jo.put("hasGoods", standardOrdinarySiteDeviceDriver.getHasGoods()); - jo.put("isOnline", true); - //点击弹出 - jo.put("is_click", true); - jo.put("device_type", device.getDevice_type()); - jo.put("error", standardOrdinarySiteDeviceDriver.getError()); - jo.put("isError", standardOrdinarySiteDeviceDriver.getIserror()); - jo.put("container", standardOrdinarySiteDeviceDriver.getContainer()); - jo.put("message", standardOrdinarySiteDeviceDriver.getMessage()); - jo.put("material", standardOrdinarySiteDeviceDriver.getMaterial()); - jo.put("batch", standardOrdinarySiteDeviceDriver.getBatch()); - return jo; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index 2dc3821..e5ea2b1 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -37,16 +37,7 @@ import org.nl.acs.device.service.mapper.DeviceMapper; import org.nl.acs.device.service.mapper.DeviceRunpointMapper; import org.nl.acs.device_driver.DeviceDriverDefination; import org.nl.acs.device_driver.ScannerDeviceDriver; -import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver; -import org.nl.acs.device_driver.conveyor.siemens_conveyor_ckk.SiemensConveyorCkkDeviceDriver; -import org.nl.acs.device_driver.conveyor.siemens_conveyor_labeling.SiemensConveyorLabelingDeviceDriver; -import org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; -import org.nl.acs.device_driver.conveyor.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.device_driver.scanner.standard_scanner.StandardScannerDeviceDriver; -import org.nl.acs.device_driver.two_conveyor.oven_manipulator.OvenGantryManipulatorDeviceDriver; -import org.nl.acs.device_driver.two_conveyor.slit_two_manipulator.SlitTwoManipulatorDeviceDriver; import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; @@ -560,280 +551,22 @@ public class DeviceServiceImpl extends CommonServiceImpl i @Override public JSONArray selectDeviceListOne() { - //设备基础信息表【acs_device】 - List deviceList = new LambdaQueryChainWrapper<>(deviceMapper) - .apply("is_delete= '0' AND is_active= '1' AND region = '1'") - .orderByAsc(Device::getSeq_num) - .list(); - JSONArray arr = JSONArray.parseArray(JSON.toJSONString(deviceList)); - - //acs_device_extra - JSONArray result = new JSONArray(); - for (int i = 0; i < arr.size(); i++) { - JSONObject obj = arr.getJSONObject(i); - JSONObject json = new JSONObject(); - json.put("device_id", obj.getString("device_id")); - json.put("device_code", obj.getString("device_code")); - json.put("checked", false); - json.put("device_name", obj.getString("device_name")); - Device device = deviceAppService.findDeviceByCode(obj.getString("device_code")); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - json.put("quantity", standardOrdinarySiteDeviceDriver.getQty()); - json.put("material_type", standardOrdinarySiteDeviceDriver.getMaterial()); - json.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); - } - List deviceExtraList = new LambdaQueryChainWrapper<>(deviceExtraMapper) - .eq(DeviceExtra::getDevice_id, obj.getString("device_id")) - .list(); - JSONArray extraArr = JSONArray.parseArray(JSON.toJSONString(deviceExtraList)); - - for (int m = 0; m < extraArr.size(); m++) { - JSONObject jsonObject = extraArr.getJSONObject(m); - String extra_code = jsonObject.getString("extra_code"); - //定点作业:自动创建任务 - if ("auto_create_task".equals(extra_code)) { - json.put("auto_create_task", jsonObject.getBoolean("extra_value")); - } - //呼叫 - if ("apply_task".equals(extra_code)) { - json.put("apply_task", jsonObject.getBoolean("extra_value")); - } - //响应 - if ("manual_create_task".equals(extra_code)) { - json.put("manual_create_task", jsonObject.getBoolean("extra_value")); - } - //清除 - if ("auto_clean_task".equals(extra_code)) { - json.put("auto_clean_task", jsonObject.getBoolean("extra_value")); - } - - } - result.add(json); - } - return result; + return null; } @Override public JSONArray selectDeviceListTwo() { - //设备基础信息表【acs_device】 -// JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' AND region = '2'", "seq_num").getResultJSONArray(0); - List deviceList = new LambdaQueryChainWrapper<>(deviceMapper) - .apply("is_delete= '0' AND is_active= '1' AND region = '2'") - .orderByAsc(Device::getSeq_num) - .list(); - JSONArray arr = JSONArray.parseArray(JSON.toJSONString(deviceList)); - //acs_device_extra -// WQLObject extraTab = WQLObject.getWQLObject("acs_device_extra"); - JSONArray result = new JSONArray(); - for (int i = 0; i < arr.size(); i++) { - JSONObject obj = arr.getJSONObject(i); - JSONObject json = new JSONObject(); - json.put("device_id", obj.getString("device_id")); - json.put("checked", false); - json.put("device_code", obj.getString("device_code")); - json.put("device_name", obj.getString("device_name")); - Device device = deviceAppService.findDeviceByCode(obj.getString("device_code")); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - json.put("quantity", standardOrdinarySiteDeviceDriver.getQty()); - json.put("material_type", standardOrdinarySiteDeviceDriver.getMaterial()); - json.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); - } -// JSONArray extraArr = extraTab.query("device_id = '" + obj.getString("device_id") + "'").getResultJSONArray(0); - List deviceExtraList = new LambdaQueryChainWrapper<>(deviceExtraMapper) - .eq(DeviceExtra::getDevice_id, obj.getString("device_id")) - .list(); - JSONArray extraArr = JSONArray.parseArray(JSON.toJSONString(deviceExtraList)); - for (int m = 0; m < extraArr.size(); m++) { - JSONObject jsonObject = extraArr.getJSONObject(m); - String extra_code = jsonObject.getString("extra_code"); - //定点作业:自动创建任务 - if ("auto_create_task".equals(extra_code)) { - json.put("auto_create_task", jsonObject.getBoolean("extra_value")); - } - //呼叫 - if ("apply_task".equals(extra_code)) { - json.put("apply_task", jsonObject.getBoolean("extra_value")); - } - //响应 - if ("manual_create_task".equals(extra_code)) { - json.put("manual_create_task", jsonObject.getBoolean("extra_value")); - } - //清除 - if ("auto_clean_task".equals(extra_code)) { - json.put("auto_clean_task", jsonObject.getBoolean("extra_value")); - } - - } - result.add(json); - } - return result; + return null; } @Override public JSONArray selectDeviceListThree() { - //设备基础信息表【acs_device】 -// JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' AND region = '3'", "seq_num").getResultJSONArray(0); - List deviceList = new LambdaQueryChainWrapper<>(deviceMapper) - .apply("is_delete= '0' AND is_active= '1' AND region = '3'") - .orderByAsc(Device::getSeq_num) - .list(); - JSONArray arr = JSONArray.parseArray(JSON.toJSONString(deviceList)); - //acs_device_extra -// WQLObject extraTab = WQLObject.getWQLObject("acs_device_extra"); - JSONArray result = new JSONArray(); - for (int i = 0; i < arr.size(); i++) { - JSONObject obj = arr.getJSONObject(i); - JSONObject json = new JSONObject(); - json.put("device_id", obj.getString("device_id")); - json.put("device_code", obj.getString("device_code")); - json.put("checked", false); - json.put("device_name", obj.getString("device_name")); - Device device = deviceAppService.findDeviceByCode(obj.getString("device_code")); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - json.put("quantity", standardOrdinarySiteDeviceDriver.getQty()); - json.put("material_type", standardOrdinarySiteDeviceDriver.getMaterial()); - json.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); - } -// JSONArray extraArr = extraTab.query("device_id = '" + obj.getString("device_id") + "'").getResultJSONArray(0); - List deviceExtraList = new LambdaQueryChainWrapper<>(deviceExtraMapper) - .eq(DeviceExtra::getDevice_id, obj.getString("device_id")) - .list(); - JSONArray extraArr = JSONArray.parseArray(JSON.toJSONString(deviceExtraList)); - for (int m = 0; m < extraArr.size(); m++) { - JSONObject jsonObject = extraArr.getJSONObject(m); - String extra_code = jsonObject.getString("extra_code"); - //定点作业:自动创建任务 - if ("auto_create_task".equals(extra_code)) { - json.put("auto_create_task", jsonObject.getBoolean("extra_value")); - } - //呼叫 - if ("apply_task".equals(extra_code)) { - json.put("apply_task", jsonObject.getBoolean("extra_value")); - } - //响应 - if ("manual_create_task".equals(extra_code)) { - json.put("manual_create_task", jsonObject.getBoolean("extra_value")); - } - //清除 - if ("auto_clean_task".equals(extra_code)) { - json.put("auto_clean_task", jsonObject.getBoolean("extra_value")); - } - - } - result.add(json); - } - return result; + return null; } @Override public JSONArray selectDeviceDevicerInfo(String status) { - - JSONArray deviceInfo = new JSONArray(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; -// JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' and region != '' and is_config= 'true' ").getResultJSONArray(0); - List deviceList = new LambdaQueryChainWrapper<>(deviceMapper) - .apply("is_delete= '0' AND is_active= '1' and region != '' and is_config= 'true' ") - .list(); - JSONArray arr = JSONArray.parseArray(JSON.toJSONString(deviceList)); - JSONArray result = new JSONArray(); - - // status=2 代表查询请求的设备 =3代表查询相应的设备 - if (status.equals("2")) { - for (int i = 0; i < arr.size(); i++) { - JSONObject devicejo = new JSONObject(); - JSONObject obj = arr.getJSONObject(i); - String region = obj.getString("region"); - String device_code = obj.getString("device_code"); - Device device = appService.findDeviceByCode(device_code); - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - int branchProtocol = standardOrdinarySiteDeviceDriver.getBranchProtocol(); - if (branchProtocol == 2) { - devicejo.put("device_code", device_code); - devicejo.put("branchProtocol", branchProtocol); - devicejo.put("region", region); - devicejo.put("qty", standardOrdinarySiteDeviceDriver.getQty()); - devicejo.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); - devicejo.put("material", standardOrdinarySiteDeviceDriver.getMaterial()); - devicejo.put("status", standardOrdinarySiteDeviceDriver.isRequireSucess()); - deviceInfo.add(devicejo); - } - } - } - } else if (status.equals("3")) { - for (int i = 0; i < arr.size(); i++) { - JSONObject devicejo = new JSONObject(); - JSONObject obj = arr.getJSONObject(i); - String region = obj.getString("region"); - String device_code = obj.getString("device_code"); - Device device = appService.findDeviceByCode(device_code); - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - int branchProtocol = standardOrdinarySiteDeviceDriver.getBranchProtocol(); - if (branchProtocol == 3) { - devicejo.put("device_code", device_code); - devicejo.put("branchProtocol", branchProtocol); - devicejo.put("region", region); - devicejo.put("qty", standardOrdinarySiteDeviceDriver.getQty()); - devicejo.put("material", standardOrdinarySiteDeviceDriver.getMaterial()); - devicejo.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); - devicejo.put("status", standardOrdinarySiteDeviceDriver.isRequireSucess()); - deviceInfo.add(devicejo); - } - } - } - } else { - for (int i = 0; i < arr.size(); i++) { - JSONObject devicejo = new JSONObject(); - JSONObject obj = arr.getJSONObject(i); - String region = obj.getString("region"); - String device_code = obj.getString("device_code"); - Device device = appService.findDeviceByCode(device_code); - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - int branchProtocol = standardOrdinarySiteDeviceDriver.getBranchProtocol(); - devicejo.put("device_code", device_code); - devicejo.put("branchProtocol", branchProtocol); - devicejo.put("region", region); - devicejo.put("qty", standardOrdinarySiteDeviceDriver.getQty()); - devicejo.put("material", standardOrdinarySiteDeviceDriver.getMaterial()); - devicejo.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); - devicejo.put("status", standardOrdinarySiteDeviceDriver.isRequireSucess()); - deviceInfo.add(devicejo); - } - } - } - - -// for(int i=0; i i @Override - public void changeDeviceStatus(JSONObject form) { - String device_code = form.getString("device_code"); - if (StrUtil.contains(device_code, "-") && StrUtil.count(device_code, "-") == 2) { - String[] point = device_code.split("-"); - device_code = point[0]; - } - //需要数量 - String hasGoodStatus = form.getString("hasGoodStatus"); - if (StrUtil.isEmpty(hasGoodStatus)) { - hasGoodStatus = "0"; - } - String batch = form.getString("batch"); - String material_type = form.getString("material_type"); - String quantity = form.getString("quantity"); - String remark = form.getString("remark"); - String vehicle_code = form.getString("vehicle_code"); - String islock = form.getString("islock"); - String requireSucess = form.getString("requireSucess"); - String fullrequireSucess = form.getString("fullrequireSucess"); - if (device_code.indexOf(".") != -1) { - device_code = device_code.substring(0, device_code.indexOf(".")); - } - Device device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device)) { - throw new BadRequestException(LangProcess.msg("error_isNull", device_code)); - } - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - SlitTwoManipulatorDeviceDriver slitTwoManipulatorDeviceDriver; - //检测站点 - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (!StrUtil.isEmpty(hasGoodStatus)) { - standardOrdinarySiteDeviceDriver.setHasGoods(Integer.parseInt(hasGoodStatus)); - device.setHas_goods(Integer.parseInt(hasGoodStatus)); - } - if (StrUtil.isNotEmpty(material_type)) { - standardOrdinarySiteDeviceDriver.setMaterial(material_type); - device.setMaterial_type(material_type); - } else { - standardOrdinarySiteDeviceDriver.setMaterial(""); - device.setMaterial_type(""); - } - if (StrUtil.isNotEmpty(quantity)) { - standardOrdinarySiteDeviceDriver.setQty(quantity); - device.setQuantity(quantity); - } else { - standardOrdinarySiteDeviceDriver.setQty(""); - device.setQuantity(""); - } - if (StrUtil.isNotEmpty(remark)) { - standardOrdinarySiteDeviceDriver.setRemark(remark); - device.setRemark(remark); - } else { - standardOrdinarySiteDeviceDriver.setRemark(""); - device.setRemark(""); - } - if (StrUtil.isNotEmpty(batch)) { - standardOrdinarySiteDeviceDriver.setBatch(batch); - device.setBatch(batch); - } else { - standardOrdinarySiteDeviceDriver.setBatch(""); - device.setBatch(""); - } -// WQLObject runpointwo = WQLObject.getWQLObject("acs_device_runpoint"); -// JSONObject json = runpointwo.query("device_code ='" + device_code + "'").uniqueResult(0); - DeviceRunpoint deviceRunpoint = new LambdaQueryChainWrapper<>(deviceRunpointMapper) - .eq(DeviceRunpoint::getDevice_code, device_code) - .one(); - if (!ObjectUtil.isEmpty(deviceRunpoint)) { -// DeviceRunpointDto obj = json.toJavaObject(DeviceRunpointDto.class); - deviceRunpoint.setHasgoods(hasGoodStatus); - deviceRunpoint.setMaterial_type(material_type); - deviceRunpoint.setBatch(batch); - device.setHas_goods(Integer.parseInt(hasGoodStatus)); - device.setMaterial_type(material_type); - device.setRemark(remark); - device.setQuantity(quantity); - device.setBatch(batch); - device.setIslock(islock); -// JSONObject updatejson = (JSONObject) JSONObject.toJSON(obj); -// runpointwo.update(updatejson, "device_code = '" + device_code + "'"); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(DeviceRunpoint::getDevice_code, device_code); - deviceRunpointMapper.delete(wrapper); - } - } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - standardInspectSiteDeviceDriver.setMaterial(material_type); - standardInspectSiteDeviceDriver.setBatch(batch); - device.setMaterial_type(material_type); - device.setBatch(batch); - } else if (device.getDeviceDriver() instanceof SlitTwoManipulatorDeviceDriver) { - slitTwoManipulatorDeviceDriver = (SlitTwoManipulatorDeviceDriver) device.getDeviceDriver(); - slitTwoManipulatorDeviceDriver.setDeviceStatus(form); - } else if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - SiemensConveyorDeviceDriver siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); - siemensConveyorDeviceDriver.setDeviceStatus(form); - } else if (device.getDeviceDriver() instanceof SiemensConveyorLabelingDeviceDriver) { - SiemensConveyorLabelingDeviceDriver siemensConveyorLabelingDeviceDriver = (SiemensConveyorLabelingDeviceDriver) device.getDeviceDriver(); - siemensConveyorLabelingDeviceDriver.setDeviceStatus(form); - } else if (device.getDeviceDriver() instanceof OvenGantryManipulatorDeviceDriver) { - OvenGantryManipulatorDeviceDriver ovenGantryManipulatorDeviceDriver = (OvenGantryManipulatorDeviceDriver) device.getDeviceDriver(); - ovenGantryManipulatorDeviceDriver.setDeviceStatus(form); - } else if (device.getDeviceDriver() instanceof SiemensConveyorCkkDeviceDriver) { - SiemensConveyorCkkDeviceDriver siemensConveyorCkkDeviceDriver = (SiemensConveyorCkkDeviceDriver) device.getDeviceDriver(); - siemensConveyorCkkDeviceDriver.setDeviceStatus(form); - } else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { - StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver - = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver(); - standardCoveyorControlWithScannerDeviceDriver.setDeviceStatus(form); - } else if (device.getDeviceDriver() instanceof DeviceStageMonitor) { - DeviceStageMonitor deviceStageMonitor = (DeviceStageMonitor) device.getDeviceDriver(); - deviceStageMonitor.setDeviceStatus(form); - } - } + public void changeDeviceStatus(JSONObject form) {} @Override public void changeFenceStatus(JSONObject form) { @@ -1210,59 +828,11 @@ public class DeviceServiceImpl extends CommonServiceImpl i @Override public void callAgv(JSONObject form) { - String device_code = form.getString("device_code"); - //需要数量 - String quantity = form.getString("quantity"); - //物料类型 - String material_type = form.getString("material_type"); - String remark = form.getString("remark"); - if (StrUtil.isEmpty(quantity) || StrUtil.isEmpty(material_type)) { - throw new BadRequestException(LangProcess.msg("error_checkNull", "quantity or material_type")); - } - Device device = deviceAppService.findDeviceByCode(device_code); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (standardOrdinarySiteDeviceDriver.getBranchProtocol() == 2) { - throw new BadRequestException(LangProcess.msg("device_checkStatus")); - } else { - standardOrdinarySiteDeviceDriver.setBranchProtocol(2); - standardOrdinarySiteDeviceDriver.setQty(quantity); - standardOrdinarySiteDeviceDriver.setMaterial(material_type); - standardOrdinarySiteDeviceDriver.setRemark(remark); - } - } - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - standardInspectSiteDeviceDriver.setBranchProtocol(2); - standardInspectSiteDeviceDriver.setQty(quantity); - standardInspectSiteDeviceDriver.setMaterial(material_type); - standardInspectSiteDeviceDriver.setRemark(remark); - } } @Override public void addMaterial(JSONObject form) { - String device_code = form.getString("device_code"); - //需要数量 - String quantity = form.getString("quantity"); - //物料类型 - String material_type = form.getString("material_type"); - String remark = form.getString("remark"); - - Device device = deviceAppService.findDeviceByCode(device_code); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setQty(quantity); - standardOrdinarySiteDeviceDriver.setMaterial(material_type); - standardOrdinarySiteDeviceDriver.setRemark(remark); - device.setMaterial_type(material_type); - device.setQuantity(quantity); - device.setRemark(remark); - } } @@ -1280,33 +850,10 @@ public class DeviceServiceImpl extends CommonServiceImpl i String remark = form.getString("remark"); Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (startDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) startDevice.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setBranchProtocol(3); - standardOrdinarySiteDeviceDriver.setQty(quantity); - standardOrdinarySiteDeviceDriver.setMaterial(material_type); - standardOrdinarySiteDeviceDriver.setRemark(remark); - standardOrdinarySiteDeviceDriver.setPurpose(next_device_code); - } } @Override - public void autoCreateTask(JSONObject form) { - //起始设备 - String start_device_code = form.getString("start_device_code"); - String material_type = form.getString("material_type"); - String batch = form.getString("batch"); - - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (startDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) startDevice.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setBranchProtocol(4); - standardOrdinarySiteDeviceDriver.setMaterial(material_type); - standardOrdinarySiteDeviceDriver.setBatch(batch); - } - } + public void autoCreateTask(JSONObject form) {} @Override public void unlock(List deviceCodes) { @@ -1317,44 +864,11 @@ public class DeviceServiceImpl extends CommonServiceImpl i } @Override - public void cleanTask(JSONObject json) { - //起始设备 - String start_device_code = json.getString("start_device_code"); - - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (startDevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) startDevice.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setHasGoods(0); - JSONObject jsonjo = new JSONObject(); - jsonjo.put("device_code", start_device_code); - jsonjo.put("hasGoodStatus", "0"); - changeDeviceStatus(jsonjo); - } - } + public void cleanTask(JSONObject json) {} @Override public void cleanMaterial(JSONObject json) { - String device_code = json.getString("device_code"); - //需要数量 - String quantity = json.getString("quantity"); - //物料类型 - String material_type = json.getString("material_type"); - String remark = json.getString("remark"); - Device device = deviceAppService.findDeviceByCode(device_code); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setHasGoods(0); - standardOrdinarySiteDeviceDriver.setQty(""); - standardOrdinarySiteDeviceDriver.setMaterial(""); - standardOrdinarySiteDeviceDriver.setRemark(""); - JSONObject jsonjo = new JSONObject(); - jsonjo.put("device_code", device_code); - jsonjo.put("hasGoodStatus", "0"); - changeDeviceStatus(jsonjo); - } } @Override @@ -1778,14 +1292,7 @@ public class DeviceServiceImpl extends CommonServiceImpl i @Override public String queryScannerByCode(String device_code) throws Exception { - Device device = deviceAppService.findDeviceByCode(device_code); - StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver = null; - String str = null; - if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { - standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver(); - str = standardCoveyorControlWithScannerDeviceDriver.barcode(); - } - return str; + return null; } @Override @@ -1845,15 +1352,6 @@ public class DeviceServiceImpl extends CommonServiceImpl i @Override public void updateBarcode(JSONObject json) throws Exception { - String device_code = json.getString("device_code"); - String barcode = json.getString("barcode"); - Device device = deviceAppService.findDeviceByCode(device_code); - StandardScannerDeviceDriver standardScannerDeviceDriver; - if (device.getDeviceDriver() instanceof ScannerDeviceDriver) { - standardScannerDeviceDriver = (StandardScannerDeviceDriver) device.getDeviceDriver(); - standardScannerDeviceDriver.writeBarcode(barcode); - } - } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/magic_agv/MagicAgvDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/magic_agv/MagicAgvDefination.java deleted file mode 100644 index 5c2a2c3..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/magic_agv/MagicAgvDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.agv.magic_agv; - -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.DeviceDriverDefination; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 普通站点定义 - */ -@Service -public class MagicAgvDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "magic_agv"; - } - - @Override - public String getDriverName() { - return "标准版-MagicAgv"; - } - - @Override - public String getDriverDescription() { - return "标准版-MagicAgv"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new MagicAgvDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return MagicAgvDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.agv); - return types; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/magic_agv/MagicAgvDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/magic_agv/MagicAgvDeviceDriver.java deleted file mode 100644 index 2ccc733..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/magic_agv/MagicAgvDeviceDriver.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.nl.acs.device_driver.agv.magic_agv; - -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.DeviceDriverDefination; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; -import org.springframework.stereotype.Service; - -/** - * 普通站点 - */ -@Slf4j -@Service -public class MagicAgvDeviceDriver extends AbstractDeviceDriver implements DeviceDriver { - @Override - public Device getDevice() { - return null; - } - - @Override - public DeviceDriverDefination getDriverDefination() { - return null; - } - - @Override - public DeviceDriver setDriverDefination(DeviceDriverDefination var1) { - return null; - } - - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDefination.java deleted file mode 100644 index 68913dc..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.agv.ndcone; - -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.DeviceDriverDefination; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * NDC单工位AGV - */ -@Service -public class AgvNdcOneDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "agv_ndc_one"; - } - - @Override - public String getDriverName() { - return "NDC1楼AGV"; - } - - @Override - public String getDriverDescription() { - return "NDC1楼AGV"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new AgvNdcOneDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return AgvNdcOneDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.agv); - return types; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDeviceDriver.java deleted file mode 100644 index 18fc379..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndcone/AgvNdcOneDeviceDriver.java +++ /dev/null @@ -1,558 +0,0 @@ -package org.nl.acs.device_driver.agv.ndcone; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.NDCAgvService; -import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun; -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.agv.utils.OneAgvPhase; -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.driver.AbstractDeviceDriver; -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; -import org.nl.acs.instruction.domain.Instruction; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.impl.InstructionServiceImpl; -import org.nl.acs.log.service.DeviceExecuteLogService; -import org.nl.acs.monitor.DeviceStageMonitor; -import org.nl.acs.opc.DeviceAppService; -import org.nl.config.SpringContextHolder; -import org.nl.system.service.param.ISysParamService; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * NDC单工位AGV - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { - - ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); - InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class); - DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); -// DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - - OneAgvPhase oneAgvPhase = new OneAgvPhase(); - - int agvaddr = 0; - int agvaddr_copy = 0; - int weight = 0; - String device_code = ""; - - String message = null; - - int phase = 0; - String error_type = "agv_error_type"; - String error_code = "0"; - /** - * x坐标 - */ - int x = 0; - /** - * y坐标 - */ - int y = 0; - /** - * 角度 - */ - int angle = 0; - /** - * 电量 - */ - int electric_qty = 0; - /** - * 三色灯状态 - */ - int status = 0; - /** - * 三色灯状态 - */ - int last_status = 0; - int error = 0; - int last_error = 0; - String error_message = ""; - - private synchronized void setErrorInfo(int error, String error_code, String error_message) { - this.error = error; - this.error_code = error_code; - this.error_message = error_message; - } - - private Instruction instruction; - - int mode = 2; - - public synchronized void processSocket(int[] arr) throws Exception { - device_code = this.getDeviceCode(); - byte[] data = null; - phase = arr[16] * 256 + arr[17]; - // agv任务号 - int index = arr[12] * 256 + arr[13]; - /** - * 任务号 - */ - int ikey = arr[26] * 256 + arr[27]; - //站点号 - agvaddr = arr[18] * 256 + arr[19]; - //车号 - int carno = arr[20]; - log.info(this.device_code, "", "", "接收agv上报信息:" + "phase--" + phase + " index--" + index + " 指令号--" + ikey + " 站点号--" + agvaddr + " 车号--" + carno); - Instruction link_inst = null; - List insts = null; - Instruction inst = null; - boolean link_flag = false; - Device agv_device = null; - if (carno != 0) { - agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); - } - if (ikey != 0) { - if (phase != 0x67 && phase != 0x71 && phase != 0x72 && phase != 0x73 && phase != 0x74 && phase != 0x75) { - inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); - this.instruction = inst; - } -// if (ObjectUtil.isEmpty(inst)){ -// inst = instructionService.findByCode(String.valueOf(ikey)); -// } - } - if (!ObjectUtil.isEmpty(link_inst)) { - link_flag = true; - } - - Device device = null; - String old_device_code = null; - String emptyNum = null; - String device_code = null; - -// if (phase == 0x67) { -// //故障信息 -// if (arr[18] * 256 + arr[19] == 0) { -// -// } -// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); -// } - - //普通站点 - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - //货架 - StandardStorageDeviceDriver standardStorageDeviceDriver; - // - SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; - - //分配 车id - //(不需要WCS反馈) - if (phase == 0x02) { - inst.setCarno(String.valueOf(carno)); - instructionService.update(inst); - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈车号:" + carno + ",指令号:" + ikey); - - //到达取货点 - //(需要WCS反馈) - } else if (phase == 0x03) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); - return; - } - CommonFinalParam commonFinalParam = new CommonFinalParam(); - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { - String[] point = old_device_code.split(commonFinalParam.getBARRE()); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - logServer.deviceExecuteLog(this.device_code, "", "", agvaddr + "对应设备号为空"); - return; - } - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到编号{}对应的指令", ikey); - logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey); - return; - } - - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setAgvphase(phase); - standardOrdinarySiteDeviceDriver.setIndex(index); - standardOrdinarySiteDeviceDriver.setInst(inst); - } - - if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); - if (siemensConveyorDeviceDriver.getMove() == 1) { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - } else { - message = siemensConveyorDeviceDriver.getDevice_code() + "请求取货条件不满足待机有货"; - log.info("请求取货条件不满足待机有货"); - } - } - - if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); - if (siemensConveyorDeviceDriver.getMove() == 1) { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - } else { - message = siemensConveyorDeviceDriver.getDevice_code() + "请求取货条件不满足待机有货"; - log.info("请求取货条件不满足待机有货"); - } - } - - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - } - //取货完毕 - //(需要WCS反馈) - } else if (phase == 0x05) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); - return; - } - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - CommonFinalParam commonFinalParam = new CommonFinalParam(); - if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { - String[] point = old_device_code.split(commonFinalParam.getBARRE()); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - device = deviceAppService.findDeviceByCode(device_code); - - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - logServer.deviceExecuteLog(this.device_code, "", "", "对应设备号为空" + device_code); - return; - } - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey); - return; - } - - if (StrUtil.equals(inst.getStart_device_code(), device_code)) { - - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setAgvphase(phase); - standardOrdinarySiteDeviceDriver.setIndex(index); - standardOrdinarySiteDeviceDriver.setInst(inst); - } - - if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); - if (siemensConveyorDeviceDriver.getTo_command() == 2) { - log.info("取货完成请求离开,当前输送to_command:" + siemensConveyorDeviceDriver.getTo_command()); - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - } else { - log.info("取货完成请求离开下发输送信号,当前输送to_command:" + siemensConveyorDeviceDriver.getTo_command()); - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", CommonFinalParam.TWO); - list.add(map); - try { - siemensConveyorDeviceDriver.writing(list); - siemensConveyorDeviceDriver.writing(list); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - } - - } - if (ObjectUtil.isNotEmpty(data)) { - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + Bytes2HexString(data)); - } - //到达放货点 - //(需要WCS反馈) - } else if (phase == 0x07) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); - return; - } - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - CommonFinalParam commonFinalParam = new CommonFinalParam(); - if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { - String[] point = old_device_code.split(commonFinalParam.getBARRE()); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到关联编号{}对应的指令", ikey); - return; - } - if (StrUtil.equals(inst.getNext_device_code(), device_code)) { - - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - } - - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - } - - } - //放货完毕 - //(需要WCS反馈) - } else if (phase == 0x09) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); - return; - } - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - CommonFinalParam commonFinalParam = new CommonFinalParam(); - if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { - String[] point = old_device_code.split(commonFinalParam.getBARRE()); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - //校验agv上报站点编号与指令起始点相同 - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到编号{}对应的指令", ikey); - return; - } - if (StrUtil.equals(inst.getNext_device_code(), device_code)) { - - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - } - - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - } - - } - } - //到达位置点 - //(需要WCS反馈) - //param,agv货位id待定 - else if (phase == 0x64) { - //1、根据货位id找到对应三工位设备,赋给agv属性地址对应的满料位设备 - agvaddr = arr[18] * 256 + arr[19]; - agvaddr_copy = agvaddr; - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - //进入交通灯区域 - } else if (phase == 0x50) { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - //离开交通灯区域 - } else if (phase == 0x51) { - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - //agv异常 - } else if (phase == 0x67) { -// if (ikey == 0) { -// this.setErrorInfo(ikey, "0", "正常"); -// } else { -// Map error = ErrorUtil.getAgvErrorMsg(ikey); -// String code = error.get("code"); -// String info = error.get("info"); -// this.setErrorInfo(ikey, code, info); -// } - - if (error != last_error) { -// DeviceErrorLogDto dto = new DeviceErrorLogDto(); -// dto.setDevice_code(this.getDevice().getDevice_code()); -// dto.setError_code(String.valueOf(error_code)); -// dto.setError_info(error_message); -// deviceErrorLogService.create(dto); - - JSONObject param = new JSONObject(); - param.put("device_code", this.device_code); - param.put("error", error); - param.put("error_msg", error == 0 ? "" : this.getError_message()); - param.put("device_name", this.getDevice().getDevice_name()); - param.put("device_type", "4"); - param.put("product_area", paramService.findByCode("productArea").getValue()); -// acsToWmsService.sendDeviceStatus(param); - } - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); - last_error = error; - } else if (phase == 0x70) { - //x坐标 - x = ikey; - } else if (phase == 0x71) { - //y坐标 - y = ikey; - } else if (phase == 0x72) { - //车辆角度 - angle = ikey; - } else if (phase == 0x73) { - //agv电量 - electric_qty = ikey; - } else if (phase == 0x74) { - //三色灯状态 - status = ikey; - - if (status != last_status && status != 6 && status != 7) { - boolean flag = true; - JSONObject param = new JSONObject(); - param.put("device_code", this.device_code); - if (status == 1) { - param.put("mode", 0); - } else if (status == 2) { - param.put("mode", 3); - } else if ("345".contains(String.valueOf(status))) { - param.put("mode", 2); - } else { - flag = false; - } - - if (flag) { -// param.put("device_name", this.getDevice().getDevice_name()); -// param.put("device_type", "4"); -// param.put("product_area", paramService.findByCode("productArea").getValue()); -// acsToWmsService.sendDeviceStatus(param); - } - } - - last_status = status; - } - if (!ObjectUtil.isEmpty(data)) { - phase = 0; - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + Bytes2HexString(data)); - OneNDCSocketConnectionAutoRun.write(data); - } - - } - - public static String Bytes2HexString(byte[] b) { - String ret = ""; - for (int i = 0; i < b.length; i++) { - String hex = Integer.toHexString(b[i] & 0xFF); - if (hex.length() == 1) { - hex = '0' + hex; - } - ret += hex.toUpperCase(); - } - return ret; - } - - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - //agv编码 - jo.put("car_no", this.getDevice().getDevice_code()); - //agv名称 - jo.put("device_name", this.getDevice().getDevice_name()); - //x坐标 - jo.put("x", this.getX()); - //y坐标 - jo.put("y", this.getY()); - //角度 - jo.put("angle", this.getAngle()); - jo.put("phase", phase); - jo.put("phase_name", oneAgvPhase.getPhaseName(phase)); - //电量 - jo.put("electricity", this.getElectric_qty()); - String status_name = this.status == 1 ? "关机" : this.status == 2 ? "工作中" : this.status == 3 ? "交通管制" : this.status == 4 ? "任务等待" : this.status == 5 ? "充电中" : this.status == 6 ? "故障中" : this.status == 7 ? "电量低" : "正常"; - //agv状态 - jo.put("status_name", status_name); - /** - * 任务号 - */ - jo.put("task_code", ObjectUtil.isEmpty(instruction) ? "0" : instruction.getTask_code()); - //异常 - jo.put("fault", this.getError_message()); - jo.put("message", this.getMessage()); - return jo; - } - - @Override - public void setDeviceStatus(JSONObject data) { - - } - - @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", error_code); - jo.put("fault_info", error_message); - jo.put("fault_type", error_type); - return jo; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDefination.java deleted file mode 100644 index 2fc507b..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.agv.ndctwo; - -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.DeviceDriverDefination; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * NDC双工位AGV - */ -@Service -public class AgvNdcTwoDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "agv_ndc_two"; - } - - @Override - public String getDriverName() { - return "NDC双工位AGV"; - } - - @Override - public String getDriverDescription() { - return "NDC双工位AGV"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new AgvNdcTwoDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return AgvNdcTwoDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.agv); - return types; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java deleted file mode 100644 index 8405ff1..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java +++ /dev/null @@ -1,489 +0,0 @@ -package org.nl.acs.device_driver.agv.ndctwo; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -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.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; -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; -import org.nl.acs.instruction.domain.Instruction; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.impl.InstructionServiceImpl; -import org.nl.acs.log.LokiLog; -import org.nl.acs.log.LokiLogType; -import org.nl.acs.log.service.DeviceExecuteLogService; -import org.nl.acs.opc.DeviceAppService; -import org.nl.config.SpringContextHolder; -import org.nl.system.service.param.ISysParamService; - - -/** - * NDC双工位AGV - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements DeviceDriver { - - ISysParamService ISysParamService = SpringContextHolder.getBean(ISysParamService.class); - InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); - DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); - int agvaddr = 0; - int agvaddr_copy = 0; - int weight = 0; - int agv_power = 0; - String device_code = ""; - int phase = 0; - int region = 0; - - @LokiLog(type = LokiLogType.ACS_TO_LMS) - public synchronized void processSocket(int[] arr) throws Exception { - device_code = this.getDeviceCode(); - byte[] data = null; - phase = arr[16] * 256 + arr[17]; - // agv任务号 - int index = arr[12] * 256 + arr[13]; - /** - * 任务号 - */ - int ikey = arr[26] * 256 + arr[27]; - //站点号 - agvaddr = arr[18] * 256 + arr[19]; - //车号 - int carno = arr[20]; - Instruction inst = null; - Device agv_device = null; - if (carno != 0) { - agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); - } - if (ikey != 0) { - inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); - } - - - Device device = null; - String old_device_code = null; - String emptyNum = null; - String device_code = null; - - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - CommonFinalParam commonFinalParam = new CommonFinalParam(); - if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { - String[] point = old_device_code.split(commonFinalParam.getBARRE()); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - device = deviceAppService.findDeviceByCode(device_code); - - //普通站点 - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - //货架 - StandardStorageDeviceDriver standardStorageDeviceDriver; - - if (phase == 0x02) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - return; - } - inst.setCarno(String.valueOf(carno)); - instructionService.update(inst); - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + "反馈:" + data); - } - //到达取货点 - //(Itype=1/2/3,需要WCS反馈Phase) - else if (phase == 0x03) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); - return; - } - device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - CommonFinalParam commonFinalParam = new CommonFinalParam(); - if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { - String[] point = old_device_code.split(commonFinalParam.getBARRE()); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - logServer.deviceExecuteLog(this.device_code, "", "", agvaddr + "对应设备号为空"); - return; - } - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - return; - } - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); - } - // 取货完毕 - //(Itype=1/2/3,需要WCS反馈Phase) - else if (phase == 0x05) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); - return; - } - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - CommonFinalParam commonFinalParam = new CommonFinalParam(); - if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { - String[] point = old_device_code.split(commonFinalParam.getBARRE()); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - device = deviceAppService.findDeviceByCode(device_code); - - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - logServer.deviceExecuteLog(this.device_code, "", "", "对应设备号为空" + device_code); - return; - } - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - return; - } - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); - } - //到达取货点(Itype=1、3,需要WCS反馈) - else if (phase == 0x08) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); - return; - } - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - CommonFinalParam commonFinalParam = new CommonFinalParam(); - if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { - String[] point = old_device_code.split(commonFinalParam.getBARRE()); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - return; - } - String agv_inst_type = inst.getAgv_inst_type(); - if (StrUtil.equals(agv_inst_type, CommonFinalParam.ONE) || StrUtil.equals(agv_inst_type, "3")) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); - } - } - // 取货完毕 - //(Itype=1、3,需要WCS反馈) - else if (phase == 0x0A) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); - return; - } - if (agvaddr != 0) { - CommonFinalParam commonFinalParam = new CommonFinalParam(); - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { - String[] point = old_device_code.split(commonFinalParam.getBARRE()); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - return; - } - String agv_inst_type = inst.getAgv_inst_type(); - if (StrUtil.equals(agv_inst_type, CommonFinalParam.ONE) || StrUtil.equals(agv_inst_type, "3")) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); - } - - } - //(Itype=1,上传称重数据) - else if (phase == 0x64) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - return; - } - String instruction_type = inst.getInstruction_type(); - //上传称重数据 - if (StrUtil.equals(instruction_type, CommonFinalParam.ONE)) { - weight = agvaddr; -// inst.setWeight(String.valueOf(weight)); -// instructionService.update(inst); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); - } - } - // 到达放货点 - //(Itype=1/2/3,需要WCS反馈) - else if (phase == 0x0C) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); - return; - } - if (agvaddr != 0) { - CommonFinalParam commonFinalParam = new CommonFinalParam(); - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { - String[] point = old_device_code.split(commonFinalParam.getBARRE()); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - return; - } - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); - } - //放货完成 - //(Itype=1/2/3,需要WCS反馈) - else if (phase == 0x0E) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); - return; - } - if (agvaddr != 0) { - CommonFinalParam commonFinalParam = new CommonFinalParam(); - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { - String[] point = old_device_code.split(commonFinalParam.getBARRE()); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - return; - } - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); - } - //到达放货点 - //(Itype=1、3,需要WCS反馈) - else if (phase == 0x10) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); - return; - } - if (agvaddr != 0) { - CommonFinalParam commonFinalParam = new CommonFinalParam(); - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { - String[] point = old_device_code.split(commonFinalParam.getBARRE()); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - return; - } - String agv_inst_type = inst.getAgv_inst_type(); - if (StrUtil.equals(agv_inst_type, CommonFinalParam.ONE) || StrUtil.equals(agv_inst_type, "3")) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); - } - } - //放货完成 - //(Itype=1、3,需要WCS反馈) - else if (phase == 0x12) { - if (agvaddr == 0) { - agvaddr = agvaddr_copy; - } - if (agvaddr < 1) { - logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); - return; - } - if (agvaddr != 0) { - CommonFinalParam commonFinalParam = new CommonFinalParam(); - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, commonFinalParam.getBARRE())) { - String[] point = old_device_code.split(commonFinalParam.getBARRE()); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, commonFinalParam.getPOINT())) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - } - - device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device_code)) { - log.info(agvaddr + "对应设备号为空!"); - return; - } - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - return; - } - String agv_inst_type = inst.getAgv_inst_type(); - if (StrUtil.equals(agv_inst_type, CommonFinalParam.ONE) || StrUtil.equals(agv_inst_type, "3")) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); - } - } - //上传AGV电量 - else if (phase == 0x73) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - return; - } - agv_power = ikey; - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); - - } //进入区域(phase值) - else if (phase == 0x50) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - return; - } - region = agvaddr; - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); - - } - //离开区域(phase值) - else if (phase == 0x51) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - return; - } - region = agvaddr; - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); - - } - //上报异常信息 - //(不需要WCS反馈) - else if (phase == 0x67) { - //故障信息 - if (agvaddr == 0) { - - } - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); - } - if (!ObjectUtil.isEmpty(data)) { - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); -// if (StrUtil.equals(inst.getAgv_system_type(), "2")) { -// TwoNDCSocketConnectionAutoRun.write(data); -// } else if (StrUtil.equals(inst.getAgv_system_type(), "3")) { -// TwoNDC2SocketConnectionAutoRun.write(data); -// } - } - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/IAgv.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/IAgv.java deleted file mode 100644 index 87efc38..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/IAgv.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.nl.acs.device_driver.agv.utils; - -public interface IAgv { - /** - * 获取phase名称 - * @param phase - * @return - */ - String getPhaseName(Integer phase); -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/OneAgvPhase.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/OneAgvPhase.java deleted file mode 100644 index d611d3f..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/OneAgvPhase.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.nl.acs.device_driver.agv.utils; - -import org.springframework.stereotype.Service; - -@Service -public class OneAgvPhase implements IAgv { - @Override - public String getPhaseName(Integer phase) { - if (phase == 0x01) { - return "开始任务/上报订单号"; - } else if (phase == 0x02) { - return "分配车id"; - } else if (phase == 0x03) { - return "到达取货点"; - } else if (phase == 0x05) { - return "取货完毕"; - } else if (phase == 0x07) { - return "到达放货点"; - } else if (phase == 0x09) { - return "放货完毕"; - } else if (phase == 0x0A) { - return "任务完毕"; - } else if (phase == 0x30) { - return "请求删除任务"; - } else if (phase == 0xFF) { - return "任务删除确认"; - } else if (phase == 0x64) { - return "到达位置点"; - } else if (phase == 0x65) { - return "称重就绪"; - } - return null; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/TwoAgvPhase.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/TwoAgvPhase.java deleted file mode 100644 index 0050427..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/utils/TwoAgvPhase.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.nl.acs.device_driver.agv.utils; - -import org.springframework.stereotype.Service; - -@Service -public class TwoAgvPhase implements IAgv { - @Override - public String getPhaseName(Integer phase) { - if (phase == 0x01) { - return "开始任务/上报订单号"; - } else if (phase == 0x02) { - return "分配车id"; - } else if (phase == 0x03) { - return "到达取货点1"; - } else if (phase == 0x05) { - return "取货点1取货完毕"; - } else if (phase == 0x07) { - return "到达取货点2"; - } else if (phase == 0x09) { - return "取货点2取货完毕"; - } else if (phase == 0x0A) { - return "自动缓存线--到达送满框1"; - } else if (phase == 0x0B) { - return "到达倒料点1"; - } else if (phase == 0x0C) { - return "自动缓存线--送满框完毕1"; - } else if (phase == 0x0D) { - return "倒料点1倒料完毕"; - } else if (phase == 0x0E) { - return "自动缓存线--到达取空框1"; - } else if (phase == 0x0F) { - return "到达倒料点2"; - } else if (phase == 0x11) { - return "倒料点2倒料完毕"; - } else if (phase == 0x13) { - return "到达送箱点1"; - } else if (phase == 0x15) { - return "送箱点1送箱完毕"; - } else if (phase == 0x17) { - return "到达送箱点2"; - } else if (phase == 0x19) { - return "送箱完毕/送空框完毕2"; - } else if (phase == 0x30) { - return "请求删除任务"; - } else if (phase == 0xFF) { - return "任务删除确认"; - } else if (phase == 0x64) { - return "取货完毕/取满框完毕1/点对点取货完毕"; - } else if (phase == 0x65) { - return "称重就绪"; - } else if (phase == 0x1A) { - return "任务完毕"; - } - return null; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/ItemProtocol.java deleted file mode 100644 index 18fe2fc..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/ItemProtocol.java +++ /dev/null @@ -1,391 +0,0 @@ -package org.nl.acs.device_driver.agv.xg_agv; - -import cn.hutool.core.util.ObjectUtil; -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 class ItemProtocol { - public static String is_charging = "is_charging"; - public static String stop = "stop"; - public static String DI0 = "DI0"; - public static String DI1 = "DI1"; - public static String DI2 = "DI2"; - public static String DI3 = "DI3"; - public static String DI4 = "DI4"; - public static String DI11 = "DI12"; - public static String DI12 = "DI12"; - public static String DO0 = "DO0"; - public static String DO1 = "DO1"; - public static String DO2 = "DO2"; - public static String x = "x"; - public static String y = "y"; - public static String angle = "angle"; - /** - * 站点的 id 号, 0 表示无导航站点 - */ - public static String navigation_address = "navigation_address"; - /** - * 0 = 定位失败, 1 = 定位正确, 2 = 正在重定位, 3 = 定位完成;机器人刚启动后,定位状态为 2, - * 当定位状态变为 3 时,可以用 [0x]00003 地址位确认定位正确,确认后定位状态将变为 1 - */ - public static String positioning_status = "positioning_status"; - - - /** - * 0 = 无, 1 = 等待执行导航, 2 = 正在执行导航, 3 = 导航暂停, 4 = 到达, 5 = 失败, 6 = 取消, 7 = 超时 - */ - public static String navigation_status = "navigation_status"; - - - /** - * 0 = 没有导航, 1 = 自由导航到任意点, 2 = 自由导航到站点, 3 = 路径导航到站点, 7 = 平动转动, 100 = 其他 - */ - public static String navigation_type = "navigation_type"; - /** - * 范围为 0 ~ 1 - */ - public static String electricity = "electricity"; - public static String address = "address"; - public static String next_address = "next_address"; - public static String home_relocation = "home_relocation"; - /** - * 确认定位正确 - */ - public static String locate_correct = "locate_correct"; - public static String pause_navigation = "pause_navigation"; - public static String continue_navigation = "continue_navigation"; - public static String cancle_navigation = "cancle_navigation"; - /** - * 滚筒运行状态 - */ - public static String drum_run_status = "drum_run_status"; - - - public static String to_home_relocation = "to_home_relocation"; - /** - * 确认定位正确 - */ - public static String to_locate_correct = "to_locate_correct"; - public static String to_pause_navigation = "to_pause_navigation"; - public static String to_continue_navigation = "to_continue_navigation"; - public static String to_cancle_navigation = "to_cancle_navigation"; - public static String to_DO0_height = "to_DO0_height"; - public static String to_DO0_low = "to_DO0_low"; - public static String to_DO1_height = "to_DO1_height"; - public static String to_DO1_low = "to_DO1_low"; - public static String to_DO2_low = "to_DO2_low"; - public static String to_DO8_low = "to_DO8_low"; - public static String to_DO9_low = "to_DO9_low"; - - public static String to_address = "to_address"; - public static String to_clear_error = "to_clear_error"; - /** - * 虚拟高电平写 - */ - public static String to_di_height = "to_di_height"; - /** - * 虚拟低电平写 - */ - public static String to_di_low = "to_di_low"; - /** - * 下发任务链 - */ - public static String to_line = "to_line"; - - - public int getIs_charging() { - return this.getOpcIntegerValue(is_charging); - } - - public int getStop() { - return this.getOpcIntegerValue(stop); - } - - public int getDI0() { - return this.getOpcIntegerValue(DI0); - } - - public int getDI1() { - return this.getOpcIntegerValue(DI1); - } - - public int getDI2() { - return this.getOpcIntegerValue(DI2); - } - - public int getDI3() { - return this.getOpcIntegerValue(DI3); - } - - public int getDI4() { - return this.getOpcIntegerValue(DI4); - - } - - public int getDI11() { - return this.getOpcIntegerValue(DI11); - - } - - public int getDI12() { - return this.getOpcIntegerValue(DI12); - - } - - public int getDO0() { - return this.getOpcIntegerValue(DO0); - - } - - public int getDO1() { - return this.getOpcIntegerValue(DO1); - - } - - public int getDO2() { - return this.getOpcIntegerValue(DO2); - - } - - public Float getX() { - return this.getOpcFloatValue(x); - - } - - public Float getY() { - return this.getOpcFloatValue(y); - - } - - public Float getAngle() { - return this.getOpcFloatValue(angle); - - } - - public short getNavigation_address() { - return this.getOpcShortValue(navigation_address); - - } - - public short getPositioning_status() { - return this.getOpcShortValue(positioning_status); - } - - public short getNavigation_status() { - return this.getOpcShortValue(navigation_status); - } - - public short getNavigation_type() { - return this.getOpcShortValue(navigation_type); - - } - - public int getElectricity() { - return this.getOpcIntegerValue(electricity); - - } - - public int getAddress() { - return this.getOpcIntegerValue(address); - - } - - public short getNext_address() { - return this.getOpcShortValue(next_address); - } - - public int getHome_relocation() { - return this.getOpcIntegerValue(home_relocation); - - } - - public int getLocate_correct() { - return this.getOpcIntegerValue(locate_correct); - - } - - public int getPause_navigation() { - return this.getOpcIntegerValue(pause_navigation); - - } - - public int getContinue_navigation() { - return this.getOpcIntegerValue(continue_navigation); - - } - - public int getCancle_navigation() { - return this.getOpcIntegerValue(cancle_navigation); - } - - public short getDrum_run_status() { - return this.getOpcShortValue(drum_run_status); - } - - public static void setTo_home_relocation(String to_home_relocation) { - ItemProtocol.to_home_relocation = to_home_relocation; - } - - public static void setTo_locate_correct(String to_locate_correct) { - ItemProtocol.to_locate_correct = to_locate_correct; - } - - public static void setTo_pause_navigation(String to_pause_navigation) { - ItemProtocol.to_pause_navigation = to_pause_navigation; - } - - public static void setTo_continue_navigation(String to_continue_navigation) { - ItemProtocol.to_continue_navigation = to_continue_navigation; - } - - public static void setTo_cancle_navigation(String to_cancle_navigation) { - ItemProtocol.to_cancle_navigation = to_cancle_navigation; - } - - public static void setTo_DO0_height(String to_DO0_height) { - ItemProtocol.to_DO0_height = to_DO0_height; - } - - public static void setTo_DO0_low(String to_DO0_low) { - ItemProtocol.to_DO0_low = to_DO0_low; - } - - public static void setTo_DO1_height(String to_DO1_height) { - ItemProtocol.to_DO1_height = to_DO1_height; - } - - public static void setTo_DO1_low(String to_DO1_low) { - ItemProtocol.to_DO1_low = to_DO1_low; - } - - public static void setTo_DO8_low(String to_DO8_low) { - ItemProtocol.to_DO8_low = to_DO8_low; - } - - public static void setTo_DO9_low(String to_DO9_low) { - ItemProtocol.to_DO9_low = to_DO9_low; - } - - - public static void setTo_address(String to_address) { - ItemProtocol.to_address = to_address; - } - - public static void setTo_clear_error(String to_clear_error) { - ItemProtocol.to_clear_error = to_clear_error; - } - - public static void setTo_di_height(String to_di_height) { - ItemProtocol.to_di_height = to_di_height; - } - - public static void setTo_di_low(String to_di_low) { - ItemProtocol.to_di_low = to_di_low; - } - - private XgagvDeviceDriver driver; - - public ItemProtocol(XgagvDeviceDriver driver) { - this.driver = driver; - } - - public ItemProtocol() { - - } - - - public Float getOpcFloatValue(String protocol) { - Float value = this.driver.getFloatValue(protocol); - if (ObjectUtil.isEmpty(value)) { - - } else { - return value; - } - return 0.0f; - } - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegerValue(protocol); - if (value == null) { - - } else { - return value; - } - return 0; - - } - - public short getOpcShortValue(String protocol) { - Short value = this.driver.getShortValue(protocol); - if (value == null) { - - } else { - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(is_charging, "是否充电", "10003")); - list.add(new ItemDto(DI0, "DI0", "10020")); - list.add(new ItemDto(DI1, "DI1", "10021")); - list.add(new ItemDto(DI2, "DI2", "10022")); - list.add(new ItemDto(DI3, "DI3", "10023")); - list.add(new ItemDto(DI4, "DI4", "10024")); - list.add(new ItemDto(DO1, "DO1", "10061")); - list.add(new ItemDto(DO2, "DO2", "10062")); - list.add(new ItemDto(DI11, "DI11", "10031")); - list.add(new ItemDto(DI12, "DI12", "10032")); - list.add(new ItemDto(x, "x", "30001")); - list.add(new ItemDto(y, "y", "30003")); - list.add(new ItemDto(angle, "angle", "30005")); - list.add(new ItemDto(navigation_address, "当前导航站点", "30007")); - list.add(new ItemDto(positioning_status, "定位状态", "30008")); - list.add(new ItemDto(navigation_status, "当前导航状态", "30009")); - list.add(new ItemDto(navigation_type, "当前导航类型", "30010")); - list.add(new ItemDto(electricity, "电量", "30013")); - list.add(new ItemDto(address, "当前所在站点", "30034")); - list.add(new ItemDto(next_address, "下一个要经过的站点", "30036")); - list.add(new ItemDto(home_relocation, "在Home点重定位", "00002")); - list.add(new ItemDto(locate_correct, "确认定位正确", "00003")); - list.add(new ItemDto(pause_navigation, "暂停导航", "00004")); - list.add(new ItemDto(continue_navigation, "继续导航", "00005")); - list.add(new ItemDto(cancle_navigation, "取消导航", "00006")); - list.add(new ItemDto(drum_run_status, "滚筒运行状态", "30062")); - list.add(new ItemDto(stop, "车子停止", "10019")); - - - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(to_home_relocation, "to_在Home点重定位", "00002")); - list.add(new ItemDto(to_locate_correct, "to_确认定位正确", "00003")); - list.add(new ItemDto(to_pause_navigation, "to_暂停导航", "00004")); - list.add(new ItemDto(to_continue_navigation, "to_继续导航", "00005")); - list.add(new ItemDto(to_cancle_navigation, "to_取消导航", "00006")); - list.add(new ItemDto(to_DO0_height, "to_DO0置为高电平", "00061")); - list.add(new ItemDto(to_DO0_low, "to_DO0置为低电平", "00020")); - list.add(new ItemDto(to_DO1_height, "to_DO1置为高电平", "00062")); - list.add(new ItemDto(to_DO1_low, "to_DO1置为低电平", "00021")); - list.add(new ItemDto(to_DO2_low, "to_DO2置为低电平", "00022")); - list.add(new ItemDto(to_DO8_low, "to_DO8置为低电平", "00028")); - list.add(new ItemDto(to_DO9_low, "to_DO9置为低电平", "00029")); - list.add(new ItemDto(to_address, "to_address", "40001")); - list.add(new ItemDto(to_clear_error, "to_clear_error", "40090")); - list.add(new ItemDto(to_di_height, "虚拟高电平写", "40063")); - list.add(new ItemDto(to_di_low, "虚拟低电平写", "40064")); - list.add(new ItemDto(to_line, "to_line", "40043")); - - return list; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/XgagvDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/XgagvDefination.java deleted file mode 100644 index 1ce3a1a..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/XgagvDefination.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.nl.acs.device_driver.agv.xg_agv; - -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; - -/** - * magic3.0 - */ -@Service -public class XgagvDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "xg_agv"; - } - - @Override - public String getDriverName() { - return "仙工AGV"; - } - - @Override - public String getDriverDescription() { - return "仙工AGV"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new XgagvDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return XgagvDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.agv); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/XgagvDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/XgagvDeviceDriver.java deleted file mode 100644 index 933d209..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/xg_agv/XgagvDeviceDriver.java +++ /dev/null @@ -1,651 +0,0 @@ -package org.nl.acs.device_driver.agv.xg_agv; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSONArray; -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_driver.DeviceDriver; -import org.nl.acs.device_driver.conveyor.standard_inspect_site.StandardInspectSiteDeviceDriver; -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.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.acs.utils.ReadUtil; -import org.nl.config.SpringContextHolder; -import org.nl.system.service.lucene.LuceneExecuteLogService; -import org.nl.system.service.lucene.dto.LuceneLogDto; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - -/** - * 仙工agv - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, DeviceStageMonitor { - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceAppService deviceAppService = SpringContextHolder.getBean("deviceAppServiceImpl"); - @Autowired - LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); - ; - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); - /** - * 车辆ip 0-未知;1-需充电;2-可执行任务;3-充满电 - */ - String agv_mode = "0"; - - String last_mode = "0"; - private Date instruction_require_time = new Date(); - private int instruction_require_time_out = 3000; - int is_charging = 0; - int stop = 0; - int DI0 = 0; - int DI1 = 0; - int DI2 = 0; - int DI3 = 0; - int DI4 = 0; - int DI11 = 0; - int DI12 = 0; - int DO0 = 0; - int DO1 = 0; - int DO2 = 0; - Float x = 0f; - Float y = 0f; - Float angle = 0f; - int navigation_address = 0; - int positioning_status = 0; - int navigation_status = 0; - int navigation_type = 0; - int electricity = 0; - int address = 0; - int next_address = 0; - int home_relocation = 0; - int locate_correct = 0; - int pause_navigation = 0; - int continue_navigation = 0; - int cancle_navigation = 0; - int drum_run_status = 0; - - int last_is_charging = 0; - int last_stop = 0; - int last_DI0 = 0; - int last_DI1 = 0; - int last_DI2 = 0; - int last_DI3 = 0; - int last_DI4 = 0; - int last_DI11 = 0; - int last_DI12 = 0; - int last_DO0 = 0; - int last_DO1 = 0; - int last_DO2 = 0; - Float last_x = 0f; - Float last_y = 0f; - Float last_angle = 0f; - int last_navigation_address = 0; - int last_positioning_status = 0; - int last_navigation_status = 0; - int last_navigation_type = 0; - int last_electricity = 0; - int last_address = 0; - int last_next_address = 0; - int last_home_relocation = 0; - int last_locate_correct = 0; - int last_pause_navigation = 0; - int last_continue_navigation = 0; - int last_cancle_navigation = 0; - int last_drum_run_status = 0; - String message = null; - String device_code; - Instruction inst = null; - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - /** - * 最小电量 - */ - double min_electric = 0.0; - /** - * 最大电量 - */ - double cancle_electric = 0.0; - /** - * 执行任务电量 - */ - double task_electric = 0.0; - /** - * 休息点 - */ - int relax_point = 0; - /** - * 充电点 - */ - int charge_point = 0; - - @Override - public Device getDevice() { - return this.device; - } - - @Override - public void execute() throws Exception { - - device_code = this.getDeviceCode(); - is_charging = this.itemProtocol.getIs_charging(); - DI0 = this.itemProtocol.getDI0(); - DI1 = this.itemProtocol.getDI1(); - DI2 = this.itemProtocol.getDI2(); - DI3 = this.itemProtocol.getDI3(); - DI4 = this.itemProtocol.getDI4(); - DI11 = this.itemProtocol.getDI11(); - DI12 = this.itemProtocol.getDI12(); - DO0 = this.itemProtocol.getDO0(); - DO1 = this.itemProtocol.getDO1(); - DO2 = this.itemProtocol.getDO2(); - x = this.itemProtocol.getX(); - y = this.itemProtocol.getY(); - navigation_address = this.itemProtocol.getNavigation_address(); - positioning_status = this.itemProtocol.getPositioning_status(); - navigation_status = this.itemProtocol.getNavigation_status(); - navigation_type = this.itemProtocol.getNavigation_type(); - electricity = this.itemProtocol.getElectricity(); - address = this.itemProtocol.getAddress(); - next_address = this.itemProtocol.getNext_address(); - home_relocation = this.itemProtocol.getHome_relocation(); - locate_correct = this.itemProtocol.getLocate_correct(); - pause_navigation = this.itemProtocol.getPause_navigation(); - continue_navigation = this.itemProtocol.getContinue_navigation(); - cancle_navigation = this.itemProtocol.getCancle_navigation(); - drum_run_status = this.itemProtocol.getDrum_run_status(); - stop = this.itemProtocol.getStop(); - if (home_relocation != last_home_relocation) { -// luceneExecuteLogService.deviceExecuteLog( -// new LuceneLogDto(this.getDevice().getOpc_server_code(), this.getDevice().getOpc_plc_code(), this.device_code, ItemProtocol.to_home_relocation, this.last_home_relocation, this.home_relocation)); - } - - if (stop != last_stop) { - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.stop + "变更从" + this.last_stop + "->" + this.stop) - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto); - } - - if (address != last_address) { - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.address + this.last_address + "->" + this.address) - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto); - } - - if (electricity != last_electricity) { - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.electricity + this.last_electricity + "->" + this.electricity) - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto); - } - - //获取最小电量 - if (ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("min_electric"))) { - message = "未配置最小电量"; - return; - } - min_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("min_electric")); - //获取最大电量 - if (ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("cancle_electric"))) { - message = "未配置最大电量"; - return; - } - cancle_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("cancle_electric")); - //可执行任务电量 - if (ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("task_electric"))) { - message = "未配置可执行任务电量"; - return; - } - task_electric = Double.parseDouble((String) this.getDevice().getExtraValue().get("task_electric")); - //休息点 - if (ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("relax_point"))) { - message = "未配置休息点"; - return; - } - Device relax_point_device = deviceAppService.findDeviceByCode((String) this.getDevice().getExtraValue().get("relax_point")); - relax_point = Integer.parseInt(relax_point_device.getAddress()); - //充电点 - if (ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("charge_point"))) { - message = "未配置充电点"; - return; - } - Device charge_point_device = deviceAppService.findDeviceByCode((String) this.getDevice().getExtraValue().get("charge_point")); - charge_point = Integer.parseInt(charge_point_device.getAddress()); - List instList = instructionService.findAllInstFromCache(); - - if (instList.size() > 0) { - for (int i = 0; i < instList.size(); i++) { - inst = instList.get(i); - if (ObjectUtil.equal(inst.getInstruction_type(), CommonFinalParam.ONE)) { - continue; - } - } - if (ObjectUtil.isEmpty(inst)) { - message = "未找到对应指令"; - return; - } - } - //先判断当前有无指令 - if (ObjectUtil.isEmpty(inst)) { - if (electricity != 0 && electricity < min_electric && address != charge_point && (navigation_status == 0 || navigation_status == 4)) { - log.info("下发充电:{}", charge_point); - feedAgvTaskStatus(inst, "5"); - } - if (electricity != 0 && electricity > cancle_electric && address == charge_point && (navigation_status == 0 || navigation_status == 4)) { - log.info("下发回休息点:{}", relax_point); - - } - } else { - TaskDto task = taskserver.findByCodeFromCache(inst.getTask_code()); - Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); - Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); - int start_device_code = Integer.parseInt(start_device.getAddress()); - int next_device_code = Integer.parseInt(next_device.getAddress()); - - - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - //指令状态就绪 - if (StrUtil.equals(InstructionStatusEnum.READY.getIndex(), inst.getInstruction_status())) { - log.info("下发指令号{},起点{}", inst.getInstruction_code(), start_device); - //判断指令起点与任务起点是否相同 - feedAgvTaskStatus(inst, CommonFinalParam.ONE); - } - - //取货完成请求离开 - if (StrUtil.equals(InstructionStatusEnum.BUSY.getIndex(), inst.getInstruction_status()) && address == 5 && stop == 1 && StrUtil.equals(inst.getExecute_status(), CommonFinalParam.ONE)) { - //请求wms是否允许从取货点离开 - feedAgvTaskStatus(inst, "2"); - } - - //请求放货 - if (StrUtil.equals(InstructionStatusEnum.BUSY.getIndex(), inst.getInstruction_status()) && address == 2 && stop == 1 && StrUtil.equals(inst.getExecute_status(), "2")) { - //请求wms是否允许进入放货 - feedAgvTaskStatus(inst, "3"); - - } - //放货完成 完成任务回休息点 - if (StrUtil.equals(InstructionStatusEnum.BUSY.getIndex(), inst.getInstruction_status()) && address == 1 && stop == 1 && StrUtil.equals(inst.getExecute_status(), "3")) { - feedAgvTaskStatus(inst, "4"); - } - - } - - //请求开门 - if ((address == 3 || address == 11) && stop == 1) { - feedAgvAction("5"); - } - - //请求关门 - if ((address == 9 || address == 10) && stop == 1) { - feedAgvAction("6"); - } - - //请求充电 - if (address == 4 && stop == 1) { - feedAgvAction("7"); - } - last_home_relocation = home_relocation; - last_address = address; - last_next_address = next_address; - last_electricity = electricity; - last_stop = stop; - } - - - public void writing(String key, int value) { - String to_command = 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_command, value); - LuceneLogDto resplogDto = LuceneLogDto.builder() - .device_code(device_code) - .content("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + key + "value:" + value) - .build(); - - ReadUtil.write(itemMap, server); - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("message", this.getMessage()); - jo.put("is_click", true); - jo.put("address", address); - jo.put("stop", stop); - jo.put("electricity", electricity); - jo.put("is_charging", is_charging); - - return jo; - } - - @Override - public void setDeviceStatus(JSONObject data) { - - - } - - /** - * 反馈wms动作状态 - * - * @param type - * @return - */ - public boolean feedAgvTaskStatus(Instruction inst, String type) throws Exception { - 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 { - - //请求WMS允许取货 - if (StrUtil.equals(type, CommonFinalParam.ONE)) { - Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); - Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); - int start_device_code = Integer.parseInt(start_device.getAddress()); - int next_device_code = Integer.parseInt(next_device.getAddress()); - JSONArray ja = new JSONArray(); - JSONObject jo = new JSONObject(); - jo.put("vehicle_code", inst.getVehicle_code()); - jo.put("status", CommonFinalParam.ONE); - jo.put("device_code", this.device_code); - jo.put("task_code", inst.getTask_code()); - ja.add(jo); - LuceneLogDto reqlogDto = LuceneLogDto.builder() - .device_code(device_code) - .content("请求参数:" + jo) - .requestparam("请求参数:" + jo) - .method("feedAgvTaskStatus") - .build(); - luceneExecuteLogService.deviceExecuteLog(reqlogDto); - HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); - LuceneLogDto resplogDto = LuceneLogDto.builder() - .device_code(device_code) - .content("返回参数:" + resp.body()) - .responseparam("返回参数:" + resp.body()) - .method("feedAgvTaskStatus") - .status_code(String.valueOf(resp.getStatus())) - .build(); - luceneExecuteLogService.deviceExecuteLog(resplogDto); - - if (resp.getStatus() == 200) { - - inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - inst.setExecute_status(CommonFinalParam.ONE); - instructionService.update(inst); - writing("to_line", 1); - - } else { - writing("to_line", 1); - - } - //取货完成请求离开 - } else if (StrUtil.equals(type, "2")) { - Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); - Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); - int start_device_code = Integer.parseInt(start_device.getAddress()); - int next_device_code = Integer.parseInt(next_device.getAddress()); - JSONArray ja = new JSONArray(); - JSONObject jo = new JSONObject(); - jo.put("vehicle_code", inst.getVehicle_code()); - jo.put("status", "2"); - jo.put("device_code", this.device_code); - jo.put("task_code", inst.getTask_code()); - ja.add(jo); - LuceneLogDto reqlogDto = LuceneLogDto.builder() - .device_code(device_code) - .content("请求参数:" + jo) - .requestparam("请求参数:" + jo) - .method("feedAgvTaskStatus") - .build(); - luceneExecuteLogService.deviceExecuteLog(reqlogDto); - HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); - LuceneLogDto resplogDto = LuceneLogDto.builder() - .device_code(device_code) - .content("返回参数:" + resp.body()) - .responseparam("返回参数:" + resp.body()) - .method("feedAgvTaskStatus") - .status_code(String.valueOf(resp.getStatus())) - .build(); - luceneExecuteLogService.deviceExecuteLog(resplogDto); - if (resp.getStatus() == 200) { - - inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - inst.setExecute_status("2"); - instructionService.update(inst); - } else { - - } - //请求放货 - } else if (StrUtil.equals(type, "3")) { - Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); - Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); - int start_device_code = Integer.parseInt(start_device.getAddress()); - int next_device_code = Integer.parseInt(next_device.getAddress()); - JSONArray ja = new JSONArray(); - JSONObject jo = new JSONObject(); - jo.put("vehicle_code", inst.getVehicle_code()); - jo.put("status", "3"); - jo.put("device_code", this.device_code); - jo.put("task_code", inst.getTask_code()); - ja.add(jo); - LuceneLogDto reqlogDto = LuceneLogDto.builder() - .device_code(device_code) - .content("请求参数:" + jo) - .requestparam("请求参数:" + jo) - .method("feedAgvTaskStatus") - .build(); - luceneExecuteLogService.deviceExecuteLog(reqlogDto); - HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); - LuceneLogDto resplogDto = LuceneLogDto.builder() - .device_code(device_code) - .content("返回参数:" + resp.body()) - .responseparam("返回参数:" + resp.body()) - .method("feedAgvTaskStatus") - .status_code(String.valueOf(resp.getStatus())) - .build(); - luceneExecuteLogService.deviceExecuteLog(resplogDto); - if (resp.getStatus() == 200) { - inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - inst.setExecute_status("3"); - instructionService.update(inst); - } else { - - } - } else if (StrUtil.equals(type, "4")) { - Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); - Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); - int start_device_code = Integer.parseInt(start_device.getAddress()); - int next_device_code = Integer.parseInt(next_device.getAddress()); - JSONArray ja = new JSONArray(); - JSONObject jo = new JSONObject(); - jo.put("vehicle_code", inst.getVehicle_code()); - jo.put("status", "4"); - jo.put("device_code", this.device_code); - jo.put("task_code", inst.getTask_code()); - ja.add(jo); - LuceneLogDto reqlogDto = LuceneLogDto.builder() - .device_code(device_code) - .content("请求参数:" + jo) - .requestparam("请求参数:" + jo) - .method("feedAgvTaskStatus") - .build(); - luceneExecuteLogService.deviceExecuteLog(reqlogDto); - HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); - LuceneLogDto resplogDto = LuceneLogDto.builder() - .device_code(device_code) - .content("返回参数:" + resp.body()) - .responseparam("返回参数:" + resp.body()) - .method("feedAgvTaskStatus") - .status_code(String.valueOf(resp.getStatus())) - .build(); - luceneExecuteLogService.deviceExecuteLog(resplogDto); - if (resp.getStatus() == 200) { - writing("to_line", 2); - inst.setInstruction_status(InstructionStatusEnum.FINISHED.getIndex()); - inst.setExecute_status("4"); - instructionService.finish(inst); - } else { - - } - } else if (StrUtil.equals(type, "5")) { - JSONArray ja = new JSONArray(); - JSONObject jo = new JSONObject(); - jo.put("status", "5"); - jo.put("device_code", this.address); - ja.add(jo); - LuceneLogDto reqlogDto = LuceneLogDto.builder() - .device_code(device_code) - .content("请求参数:" + jo) - .requestparam("请求参数:" + jo) - .method("feedAgvTaskStatus") - .build(); - luceneExecuteLogService.deviceExecuteLog(reqlogDto); - HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); - LuceneLogDto resplogDto = LuceneLogDto.builder() - .device_code(device_code) - .content("返回参数:" + resp.body()) - .responseparam("返回参数:" + resp.body()) - .method("feedAgvTaskStatus") - .status_code(String.valueOf(resp.getStatus())) - .build(); - luceneExecuteLogService.deviceExecuteLog(resplogDto); - if (resp.getStatus() == 200) { - writing("to_di_low", 0); - writing("to_di_height", 0); - } else { - - } - } else if (StrUtil.equals(type, "6")) { - JSONArray ja = new JSONArray(); - JSONObject jo = new JSONObject(); - jo.put("status", "6"); - jo.put("device_code", this.device_code); - ja.add(jo); - HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); - if (resp.getStatus() == 200) { - writing("to_di_height", 0); - writing("to_di_low", 0); - } else { - - } - } else if (StrUtil.equals(type, "7")) { - JSONArray ja = new JSONArray(); - JSONObject jo = new JSONObject(); - jo.put("status", "7"); - jo.put("device_code", this.device_code); - ja.add(jo); - HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); - if (resp.getStatus() == 200) { - writing("to_di_low", 0); - } else { - - } - } - } - return true; - } - - public boolean feedAgvAction(String type) throws Exception { - 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 { - if (StrUtil.equals(type, "5")) { - JSONArray ja = new JSONArray(); - JSONObject jo = new JSONObject(); - jo.put("status", "5"); - jo.put("device_code", "A4"); - ja.add(jo); - LuceneLogDto reqlogDto = LuceneLogDto.builder() - .device_code(device_code) - .content("请求参数:" + jo) - .requestparam("请求参数:" + jo) - .method("feedAgvTaskStatus") - .build(); - luceneExecuteLogService.deviceExecuteLog(reqlogDto); - HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); - LuceneLogDto resplogDto = LuceneLogDto.builder() - .device_code(device_code) - .content("返回参数:" + resp.body()) - .responseparam("返回参数:" + resp.body()) - .method("feedAgvTaskStatus") - .status_code(String.valueOf(resp.getStatus())) - .build(); - luceneExecuteLogService.deviceExecuteLog(resplogDto); - if (resp.getStatus() == 200) { - writing("to_di_low", 0); - writing("to_di_height", 0); - } else { - writing("to_di_low", 0); - writing("to_di_height", 0); - } - } else if (StrUtil.equals(type, "6")) { - JSONArray ja = new JSONArray(); - JSONObject jo = new JSONObject(); - jo.put("status", "6"); - jo.put("device_code", "A4"); - ja.add(jo); - HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); - if (resp.getStatus() == 200) { - writing("to_di_height", 0); - writing("to_di_low", 0); - } else { - writing("to_di_height", 0); - writing("to_di_low", 0); - } - } else if (StrUtil.equals(type, "7")) { - JSONArray ja = new JSONArray(); - JSONObject jo = new JSONObject(); - jo.put("status", "7"); - jo.put("device_code", "A4"); - ja.add(jo); - HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); - if (resp.getStatus() == 200) { - writing("to_di_height", 0); - } else { - writing("to_di_height", 0); - } - } - } - return true; - } -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDefination.java deleted file mode 100644 index 0008a24..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDefination.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.nl.acs.device_driver.conveyor.belt_conveyor; - -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 BeltConveyorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "belt_conveyor"; - } - - @Override - public String getDriverName() { - return "标准版-输送机"; - } - - @Override - public String getDriverDescription() { - return "标准版-输送机"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new BeltConveyorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return BeltConveyorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java deleted file mode 100644 index ce38041..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java +++ /dev/null @@ -1,738 +0,0 @@ -package org.nl.acs.device_driver.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 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.AgvService; -import org.nl.acs.common.base.CommonFinalParam; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device.enums.ErrorType; -import org.nl.acs.device.service.DeviceService; -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.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.dto.DeviceErrorLogDto; -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.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.config.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -import static redis.clients.jedis.HostAndPort.localhost; - -/** - * 输送线 - */ -@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); - - 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; - - /** - * 心跳 - */ - 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; - /** - * 下发命令 - */ - 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_no = 0; - int last_to_container_no = 0; - /** - * 下发托盘类型 - */ - int to_container_type = 0; - int last_to_container_type = 0; - - - /** - * 当前指令 - */ - Instruction inst = null; - - String material = null; - - 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; - - /** - * 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(); - container_no = this.itemProtocol.getContainer_no(); - to_command = this.itemProtocol.getTo_command(); - to_target = this.itemProtocol.getTotarget(); - to_task = this.itemProtocol.getTo_task(); - to_container_no = this.itemProtocol.getContainer_direction(); - to_container_type = this.itemProtocol.getContainer_no(); - - 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) { - logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (container_direction != last_container_direction) { - logServer.deviceItemValue(this.device_code, "carrier_direction", String.valueOf(container_direction)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号container_direction:" + last_container_direction + "->" + container_direction); - } - if (container_type != last_container_type) { - logServer.deviceItemValue(this.device_code, "container_type", String.valueOf(container_type)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号container_type:" + last_container_type + "->" + container_type); - } - if (container_no != last_container_no) { - logServer.deviceItemValue(this.device_code, "container_no", String.valueOf(container_no)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号container_no:" + last_container_no + "->" + container_no); - } - if (action != last_action) { - logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); - } - if (to_command != last_to_command) { - logServer.deviceItemValue(this.device_code, "to_command", String.valueOf(to_command)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); - } - if (to_target != last_to_target) { - logServer.deviceItemValue(this.device_code, "to_target", String.valueOf(to_target)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); - } - if (to_task != last_to_task) { - logServer.deviceItemValue(this.device_code, "to_task", String.valueOf(to_task)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); - } - if (to_container_no != last_to_container_no) { - logServer.deviceItemValue(this.device_code, "to_container_no", String.valueOf(to_container_no)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_container_no:" + last_to_container_no + "->" + to_container_no); - } - if (to_container_type != last_to_container_type) { - logServer.deviceItemValue(this.device_code, "to_container_type", String.valueOf(to_container_type)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_container_type:" + last_to_container_type + "->" + to_container_type); - } - if (error != last_error) { - if (error != 0) { - DeviceErrorLogDto acsDeviceErrorLog = new DeviceErrorLogDto(); - acsDeviceErrorLog.setDevice_code(this.device_code); - acsDeviceErrorLog.setError_code(String.valueOf(error)); - String errorInfo = ErrorUtil.getDictDetail(ErrorType.CONVEYOR_ERROR.getErrorType(), String.valueOf(error)); - acsDeviceErrorLog.setError_info(errorInfo); - errorLogServer.create(acsDeviceErrorLog); - } - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (task != last_task) { - logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); - } - - - if (move != 0 && task > 0) { - update_instruction_status(); - } - - } catch (Exception var17) { - var17.printStackTrace(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); - } - - - 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(); - } - break; - case 3: - log.info("运行中"); - break; - case 4: - //申请出货 - if (move == 1 && !requireSucess) { - //request_for_shipment(String.valueOf(mode), item_out_seq_arr, item_out_qty_arr); - } - break; - default: - break; - } - } - 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 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.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; - - Map itemMap = new HashMap(); - this.control(itemMap); - } - - - public void writing(Map map) { - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - Map itemMap = new LinkedHashMap<>(); - map.forEach((key, value) -> { - if (ObjectUtil.isNotEmpty(value)) { - itemMap.put(getToParam() + key, value); - } - }); - if (ObjectUtil.isNotEmpty(itemMap)) { - this.control(itemMap); - logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); - } - } - - - /*public synchronized void request_for_shipment(String mode, String item_out_seq_arr, int[] item_out_qty_arr) { - 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); - } else { - this.require_apply_strangulation_time = date; - ApplyPaperActionRequest applyPaperActionRequest = new ApplyPaperActionRequest(); - applyPaperActionRequest.setDevice_code(this.device_code); - applyPaperActionRequest.setType(CommonFinalParam.ONE); - applyPaperActionRequest.setTask_code(String.valueOf(task)); - //获取出库顺序 - boolean contains = item_out_seq_arr.contains(","); - boolean contains1 = item_out_seq_arr.contains(","); - - if (contains) { - String[] split = item_out_seq_arr.split(","); - applyPaperActionRequest.setMaterial1(split[0]); - applyPaperActionRequest.setMaterial1(split[1]); - } else if (contains1) { - String[] split = item_out_seq_arr.split(","); - applyPaperActionRequest.setMaterial1(split[0]); - applyPaperActionRequest.setMaterial1(split[1]); - } else { - applyPaperActionRequest.setMaterial1(item_out_seq_arr); - } - if (item_out_qty_arr.length >= 1 && item_out_qty_arr.length < 4) { - applyPaperActionRequest.setQty1(String.valueOf(item_out_qty_arr[0])); - applyPaperActionRequest.setQty2(String.valueOf(item_out_qty_arr[1])); - } - ApplyPaperActionResponse applyPaperActionResponse = acsToWmsService.applyPaperActionRequest(applyPaperActionRequest); - if (ObjectUtil.isNull(applyPaperActionResponse)) { - message = "请求失败"; - requireSucess = false; - return; - } - Map map3 = new HashMap(); - if (applyPaperActionResponse.getstatus() == 200) { - map3.put("to_command", "4"); - this.writing(map3); - requireSucess = true; - logServer.deviceExecuteLog(this.device_code, "", "", "申请出纸管,返回参数:" + applyPaperActionResponse); - message = "申请出货成功"; - } else { - message = applyPaperActionResponse.getMessage(); - map3.put("to_command", "5"); - this.writing(map3); - requireSucess = false; - message = "出库顺序错误"; - logServer.deviceExecuteLog(this.device_code, "", "", "申请出纸管,返回参数:" + applyPaperActionResponse); - } - } - } -*/ - - /** - * 申请任务 - */ - 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.findByDeviceCodeFromCache(this.device_code); - if (ObjectUtil.isNotNull(inst) && CommonFinalParam.ONE.equals(inst.getInstruction_type())) { - 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; - } - Map map = new LinkedHashMap<>(); - map.put("to_target", next_addr); - map.put("to_task", inst.getInstruction_code()); - map.put("to_command", CommonFinalParam.ONE); - map.put("to_container_type", CommonFinalParam.ONE); - map.put("to_container_no", CommonFinalParam.ONE); - this.writing(map); - led_message = getLedMessage(inst); - requireSucess = true; - return true; - } else { - //判断是否有相同起点的,任务状态就绪的任务 - TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); - if (ObjectUtil.isNull(taskdto)) { - return false; - } - if (ObjectUtil.isNotNull(taskdto) && CommonFinalParam.ONE.equals(taskdto.getTask_type())) { - //判断指令的起点和当前的设备号相同 - if (!taskdto.getStart_device_code().equals(device_code)) { - return false; - } - //判断当前任务号是否存在指令 - 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 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) || 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; - } - 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); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - log.error("=================================,{}", instdto.getCreate_by()); - try { - instructionService.create(instdto); - } catch (Exception e) { - e.printStackTrace(); - log.error("指令创建失败!,{}", e.getMessage()); - return false; - } - taskdto.setTask_status(CommonFinalParam.ONE); - taskserver.update(taskdto); - requireSucess = true; - Map map = new LinkedHashMap<>(); - String next_addr = nextdevice.getExtraValue().get("address").toString(); - map.put("to_target", next_addr); - map.put("to_task", instdto.getInstruction_code()); - map.put("to_command", CommonFinalParam.ONE); - map.put("to_container_type", CommonFinalParam.ONE); - map.put("to_container_no", CommonFinalParam.ONE); - this.writing(map); - led_message = getLedMessage(instdto); - requireSucess = true; - return true; - } - } - return false; - } - } - - 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")); - } - } - logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); - try { - this.checkcontrol(itemMap); - } catch (Exception e) { - e.printStackTrace(); - try { - this.checkcontrol(itemMap); - } catch (Exception e1) { - e1.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() - + "." + param; - //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); - } - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - - if (this.getMode() == 0) { - mode = "未联机"; - } else if (this.getMode() == 1) { - mode = "单机"; - } else if (this.getMode() == 2) { - mode = "联机"; - } else if (this.getMode() == 3) { - mode = "入库中"; - } else if (this.getMode() == 4) { - mode = "出库中"; - } - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); - //jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError()))); - jo.put("inventory_qty", inventory_qty); - jo.put("out_finish", out_finish); - jo.put("material", material); - jo.put("isOnline", this.getIsonline()); - - return jo; - } - - /** - * 获取任务信息 - */ - 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()); - json.put("ip", localhost); - return json; - } - - - /** - * 更新指令状态 - */ - 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(), CommonFinalParam.ONE) || 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) { - - } - - 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/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java deleted file mode 100644 index 40fd0a0..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java +++ /dev/null @@ -1,205 +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_container_no = "container_no"; - - /** - * 下发命令 - */ - public static String item_to_command = "to_command"; - /** - * 下发托盘类型 - */ - public static String item_to_container_type = "to_container_type"; - /** - * 下发接纯数字托盘号 - */ - public static String item_to_container_no = "to_container_no"; - /** - * 下发任务号 - */ - 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 getContainer_no() { - return this.getOpcIntegerValue(item_container_no); - } - - 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 getTotarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_container_type() { - return this.getOpcIntegerValue(item_to_container_type); - } - - public int getTo_container_no() { - return this.getOpcIntegerValue(item_to_container_no); - } - - 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)) { - - } else { - return value; - } - return "0"; - } - - 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_container_no, "纯数字托盘号", "DB101.D7")); - 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_no, "下发接纯数字托盘号", "DB102.D3")); - list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB102.B5")); - return list; - } - - @Override - public String toString() { - return ""; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/Paper.java b/acs/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/acs/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/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/carton_labeling_machine/CartonLabelingMachineDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/carton_labeling_machine/CartonLabelingMachineDeviceDriver.java index 12a9100..52a70c7 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/carton_labeling_machine/CartonLabelingMachineDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/carton_labeling_machine/CartonLabelingMachineDeviceDriver.java @@ -28,6 +28,7 @@ import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.task.service.TaskService; +import org.nl.common.exception.BadRequestException; import org.nl.common.mnt.websocket.SendPrintSocket; import org.nl.config.SpringContextHolder; import org.nl.system.service.lucene.LuceneExecuteLogService; @@ -136,6 +137,7 @@ public class CartonLabelingMachineDeviceDriver extends AbstractOpcDeviceDriver i String message; float weight = 0; + String weight1=""; float last_weight = 0; @Override @@ -154,6 +156,10 @@ public class CartonLabelingMachineDeviceDriver extends AbstractOpcDeviceDriver i error = this.itemProtocol.getError(); move = this.itemProtocol.getMove(); weight = this.itemProtocol.getWeight(); + weight1=Float.toString(weight); + if(hasTwoDecimalPlaces(weight)){ + weight1=weight+"0"; + } if (mode != last_mode) { requireSucess = false; } @@ -176,240 +182,264 @@ public class CartonLabelingMachineDeviceDriver extends AbstractOpcDeviceDriver i message = ""; Instruction instruction = null; List toInstructions; - - if (mode == 8 && move == 1 && !requireSucess) { - //TODO:将贴标信息下发,并反馈200 - JSONObject template = ticketsMapper.template(); - String jsonString = template.toString(); - Tickets tickets = ticketsMapper.ticket(); - //客户 - String customer = tickets.getCustomer(); - //纸箱装瓶数量 - String carton_qty = tickets.getCarton_qty(); - //计划数量 - String planned_quantity = tickets.getPlanned_quantity(); - //晶科每罐重量 - String bottle_weight=null; - Integer bottle_weight1=0; - //当前纸箱完成数量 - String fcarton_number = tickets.getFcarton_number(); - Integer fcarton_number1 = Integer.parseInt(fcarton_number); - Integer planned_quantity1 = Integer.parseInt(planned_quantity); - Integer carton_qty1=Integer.parseInt(carton_qty); + try { + if (mode == 8 && move == 1 && !requireSucess) { + //TODO:将贴标信息下发,并反馈200 + JSONObject template = ticketsMapper.template(); + String jsonString = template.toString(); + Tickets tickets = ticketsMapper.ticket(); + //客户 + String customer = tickets.getCustomer(); + //晶科送货单 + String shdnumber=tickets.getShdnumber(); + //纸箱装瓶数量 + String carton_qty = tickets.getCarton_qty(); + //计划数量 + String planned_quantity = tickets.getPlanned_quantity(); + //晶科每罐重量 + String bottle_weight = null; + Integer bottle_weight1 = 0; + //当前纸箱完成数量 + String fcarton_number = tickets.getFcarton_number(); + Integer fcarton_number1 = Integer.parseInt(fcarton_number); + Integer planned_quantity1 = Integer.parseInt(planned_quantity); + Integer carton_qty1 = Integer.parseInt(carton_qty); // Float carton_qty1 = Float.parseFloat(carton_qty); - //总纸箱数 - Integer sum_carton1 = (planned_quantity1+carton_qty1-1)/carton_qty1; - //总纸箱数(Integer) - //纸箱号 - String carton_number = tickets.getCarton_number(); - //瓶盖号 - String bottle_number = tickets.getBottle_number(); - //物料条码(瓶盖数据去掉后四位) - String material_number = null; - //纸箱前18位 - String first_number = null; - //纸箱后2位 - String last_number = null; - String zx1= ""; - String zx2= ""; - Integer last_number1 = 0; - //当前箱数 - Integer real_carton = fcarton_number1; - if (customer.contains("晶科")) { - bottle_weight=tickets.getBottle_weight(); - // - String last_number5=""; - bottle_weight1=Integer.parseInt(bottle_weight); + //总纸箱数 + Integer sum_carton1 = (planned_quantity1 + carton_qty1 - 1) / carton_qty1; + //总纸箱数(Integer) + //纸箱号 + String carton_number = tickets.getCarton_number(); + //瓶盖号 + String bottle_number = tickets.getBottle_number(); //物料条码(瓶盖数据去掉后四位) - material_number = bottle_number.substring(0, 19); - first_number = carton_number.substring(0, 18); - zx1=carton_number.substring(18, 20); - zx2=carton_number.substring(20, 31); - last_number = carton_number.substring(31, 33); - last_number1 = Integer.parseInt(last_number); - last_number1 = last_number1 - fcarton_number1; - log.info("当前纸箱尾数{}",last_number1); - if (last_number1 > 9) { - last_number5 = String.valueOf(last_number1); - } else { - last_number5 = "0" + String.valueOf(last_number1); + String material_number = null; + //纸箱前18位 + String first_number = null; + //纸箱后2位 + String last_number = null; + String zx1 = ""; + String zx2 = ""; + Integer last_number1 = 0; + //当前箱数 + Integer real_carton = fcarton_number1; + if (fcarton_number1 >= sum_carton1) { + log.info("当前纸箱数已达最大值"); + throw new BadRequestException("当前纸箱数已达最大值"); } - last_number=last_number5; - } - //晶澳纸箱数据 - String janumber = ""; - if (customer.contains("晶澳")) { - //纸箱前16位 - first_number = carton_number.substring(0, 16); - //纸箱后3位 - last_number = carton_number.substring(16, 19); - if (fcarton_number1 == 0) { - Integer sum_number = sum_carton1 * carton_qty1; - Integer last1_number1 = carton_qty1 - (sum_number - planned_quantity1); + if (customer.contains("晶科")) { + bottle_weight = tickets.getBottle_weight(); + shdnumber=tickets.getShdnumber(); + // + String last_number5 = ""; + bottle_weight1 = Integer.parseInt(bottle_weight); + //物料条码(瓶盖数据去掉后四位) + material_number = bottle_number.substring(0, 19); + first_number = carton_number.substring(0, 18); + zx1 = carton_number.substring(18, 20); + zx2 = carton_number.substring(20, 31); + last_number = carton_number.substring(31, 33); + last_number1 = Integer.parseInt(last_number); + last_number1 = last_number1 - fcarton_number1; + log.info("当前纸箱尾数{}", last_number1); + if (last_number1 > 9) { + last_number5 = String.valueOf(last_number1); + } else { + last_number5 = "0" + String.valueOf(last_number1); + } + last_number = last_number5; + } + //晶澳纸箱数据 + String janumber = ""; + if (customer.contains("晶澳")) { + //纸箱前16位 + first_number = carton_number.substring(0, 16); + //纸箱后3位 + last_number = carton_number.substring(16, 19); + if (fcarton_number1 == 0) { + Integer sum_number = sum_carton1 * carton_qty1; + Integer last1_number1 = carton_qty1 - (sum_number - planned_quantity1); // Integer last1_number1 = Integer.valueOf(String.valueOf(last1_number)); - for (Integer i = 0; i < last1_number1; i++) { - Integer last_number2 = 0; - last_number2 = Integer.parseInt(last_number); - String last_number3 = String.valueOf(last_number2); - if (last_number2 > 100) { - last_number2 = (last_number2 - carton_qty1*1) + i+2; - last_number3 = String.valueOf(last_number2); - last_number3 = last_number3 + String.valueOf(last_number2) + ",2;"; - janumber=janumber+first_number+last_number3; - } else if (last_number2 > 10) { - last_number2 = (last_number2 - carton_qty1*1) + i+2; - last_number3 = last_number3 + "0" + String.valueOf(last_number2) + ",2;"; - janumber=janumber+first_number+last_number3; - } else if (last_number2 > 0) { - last_number2 = (last_number2 - carton_qty1*1) + i+2; - last_number3 = last_number3 + "00" + String.valueOf(last_number2) + ",2;"; - janumber=janumber+first_number+last_number3; + for (Integer i = 0; i < last1_number1; i++) { + Integer last_number2 = 0; + last_number2 = Integer.parseInt(last_number); + String last_number3 = String.valueOf(last_number2); + if (last_number2 > 100) { + last_number2 = (last_number2 - carton_qty1 * 1) + (carton_qty1 - last1_number1) + i + 1; + last_number3 = String.valueOf(last_number2) + ",2;"; + janumber = janumber + first_number + last_number3; + } else if (last_number2 > 10) { + last_number2 = (last_number2 - carton_qty1 * 1) + (carton_qty1 - last1_number1) + i + 1; + last_number3 = "0" + String.valueOf(last_number2) + ",2;"; + janumber = janumber + first_number + last_number3; + } else if (last_number2 > 0) { + last_number2 = (last_number2 - carton_qty1 * 1) + (carton_qty1 - last1_number1) + i + 1; + last_number3 = "00" + String.valueOf(last_number2) + ",2;"; + janumber = janumber + first_number + last_number3; + } } - } - } else { - for (Integer i = 0; i < carton_qty1; i++) { - Integer last_number2 = Integer.parseInt(last_number); - last_number2=(sum_carton1-real_carton-1)*10+i+1; - String last_number3 = String.valueOf(last_number2); - if (last_number2 > 100) { - last_number3 = last_number3 + String.valueOf(last_number2) + ",2;"; - janumber=janumber+first_number+last_number3; - }else if (last_number2 > 10) { - last_number3 = last_number3 + "0" + String.valueOf(last_number2) + ",2;"; - janumber=janumber+first_number+last_number3; - } else if (last_number2 > 0) { - last_number3 = last_number3 + "00" + String.valueOf(last_number2) + ",2;"; - janumber=janumber+first_number+last_number3; + } else { + for (Integer i = 0; i < carton_qty1; i++) { + Integer last_number2 = Integer.parseInt(last_number); + last_number2 = (sum_carton1 - real_carton - 1) * 10 + i + 1; + String last_number3 = String.valueOf(last_number2); + if (last_number2 > 100) { + last_number3 = String.valueOf(last_number2) + ",2;"; + janumber = janumber + first_number + last_number3; + } else if (last_number2 > 10) { + last_number3 = "0" + String.valueOf(last_number2) + ",2;"; + janumber = janumber + first_number + last_number3; + } else if (last_number2 > 0) { + last_number3 = "00" + String.valueOf(last_number2) + ",2;"; + janumber = janumber + first_number + last_number3; + } } } } - } // String sum_carton1=String.valueOf(sum_carton); // String real_carton1=String.valueOf(real_carton); - ObjectMapper objectMapper = new ObjectMapper(); - // 解析外部 JSON 字符串,获取 "template" 字段的值 - JsonNode rootNode = objectMapper.readTree(jsonString); - String templateJson = rootNode.get("template").asText(); - // 解析嵌套的 "template" 字符串为 JSON 对象 - JsonNode templateNode = objectMapper.readTree(templateJson); - // 输出 panels 数据 - JSONObject jsonObject = JSONObject.parseObject(templateNode.toString()); - // 获取 panels 数组 - JSONArray panels = jsonObject.getJSONArray("panels"); - JSONObject panel = panels.getJSONObject(0); - // 获取 printElements 数组 - JSONArray printElements = panel.getJSONArray("printElements"); - for (int i = 0; i < printElements.size(); i++) { - JSONObject printElement = printElements.getJSONObject(i); - JSONObject options = printElement.getJSONObject("options"); - if (options.containsKey("testData")) { - if (options.get("testData").equals("date")) { - LocalDate currentDate = LocalDate.now(); - options.put("title", "日期: " + currentDate); - printElement.put("options", options); - } - if (options.get("testData").equals("weight")) { - options.put("title", "重量: " + weight + "kg"); - printElement.put("options", options); - } - if (options.get("testData").equals("number")) { - real_carton=real_carton+1; - options.put("title", sum_carton1 + "——" + real_carton); - printElement.put("options", options); - } - if (options.get("testData").equals("纸箱号")) { - log.info("纸箱号{}{}", first_number, last_number); - String number=""; - if(fcarton_number1==0){ - number = first_number + zx1+zx2+last_number; - }else{ - number = first_number +bottle_weight1*carton_qty1 +zx2+last_number; + ObjectMapper objectMapper = new ObjectMapper(); + // 解析外部 JSON 字符串,获取 "template" 字段的值 + JsonNode rootNode = objectMapper.readTree(jsonString); + String templateJson = rootNode.get("template").asText(); + // 解析嵌套的 "template" 字符串为 JSON 对象 + JsonNode templateNode = objectMapper.readTree(templateJson); + // 输出 panels 数据 + JSONObject jsonObject = JSONObject.parseObject(templateNode.toString()); + // 获取 panels 数组 + JSONArray panels = jsonObject.getJSONArray("panels"); + JSONObject panel = panels.getJSONObject(0); + // 获取 printElements 数组 + JSONArray printElements = panel.getJSONArray("printElements"); + for (int i = 0; i < printElements.size(); i++) { + JSONObject printElement = printElements.getJSONObject(i); + JSONObject options = printElement.getJSONObject("options"); + if (options.containsKey("testData")) { + if (options.get("testData").equals("date")) { + LocalDate currentDate = LocalDate.now(); + options.put("title", "日期: " + currentDate); + printElement.put("options", options); } - options.put("title", number); - options.put("testData", number); - printElement.put("options", options); - } - if (options.get("testData").equals("晶澳纸箱号")) { - log.info("晶澳纸箱号{}{}",janumber); - String number = janumber; - options.put("testData", number); - printElement.put("options", options); - } - if (options.get("testData").equals("物料号")) { - log.info("物料号{}", material_number); - options.put("title", material_number); - options.put("testData", material_number); - printElement.put("options", options); - } - if (options.get("testData").equals("time")) { - LocalTime currentTime = LocalTime.now(); - String minute=""; - String second=""; - if(currentTime.getMinute()<10){ - minute="0"+currentTime.getMinute(); - }else{ - minute=String.valueOf(currentTime.getMinute()); + if (options.get("testData").equals("weight")) { + options.put("title", "重量: " + weight1 + "kg"); + printElement.put("options", options); } - if(currentTime.getSecond()<10){ - second="0"+currentTime.getSecond(); - }else{ - second=String.valueOf(currentTime.getSecond()); + if (options.get("testData").equals("number")) { + real_carton = sum_carton1 - (real_carton + 1) + 1; + options.put("title", "箱号: " + sum_carton1 + "——" + real_carton); + printElement.put("options", options); } - options.put("title", "时间: " + currentTime.getHour() + ":" + minute + ":" + second); - printElement.put("options", options); + if (options.get("testData").equals("纸箱号")) { + log.info("纸箱号{}{}", first_number, last_number); + String number = ""; + if (fcarton_number1 == 0) { + number = first_number + zx1 + zx2 + last_number; + } else { + if (bottle_weight1 * carton_qty1 > 9) { + number = first_number + bottle_weight1 * carton_qty1 + zx2 + last_number; + } else { + number = first_number + "0" + bottle_weight1 * carton_qty1 + zx2 + last_number; + } + } + options.put("title", number); + options.put("testData", number); + printElement.put("options", options); + } + if (options.get("testData").equals("晶澳纸箱号")) { + log.info("晶澳纸箱号{}{}", janumber); + String number = janumber; + options.put("testData", number); + printElement.put("options", options); + } + if (options.get("testData").equals("晶科送货单")) { + options.put("title", "送货单: " +shdnumber); + printElement.put("options", options); + } + if (options.get("testData").equals("物料号")) { + log.info("物料号{}", material_number); + options.put("title", material_number); + options.put("testData", material_number); + printElement.put("options", options); + } + if (options.get("testData").equals("time")) { + LocalTime currentTime = LocalTime.now(); + String minute = ""; + String second = ""; + if (currentTime.getMinute() < 10) { + minute = "0" + currentTime.getMinute(); + } else { + minute = String.valueOf(currentTime.getMinute()); + } + if (currentTime.getSecond() < 10) { + second = "0" + currentTime.getSecond(); + } else { + second = String.valueOf(currentTime.getSecond()); + } + options.put("title", "时间: " + currentTime.getHour() + ":" + minute + ":" + second); + printElement.put("options", options); + } + } else { + continue; } - } else { - continue; } + jsonObject.put("type", 2); + requireSucess = true; + log.info("纸箱打印数据: " + jsonObject.toString()); + Integer fcarton_number2 = fcarton_number1 + 1; + String fcarton_number3 = String.valueOf(fcarton_number2); + tickets.setFcarton_number(fcarton_number3); + ticketsMapper.updateById(tickets); + SendPrintSocket.sendPrint(jsonObject.toString()); + Map map = new HashMap(); + map.put("to_command", 200); + this.writing(map); + } else { + message = "无请求"; } - jsonObject.put("type", 2); - requireSucess = true; - log.info("纸箱打印数据: " + jsonObject.toString()); - Integer fcarton_number2 = fcarton_number1 + 1; - String fcarton_number3 = String.valueOf(fcarton_number2); - tickets.setFcarton_number(fcarton_number3); - ticketsMapper.updateById(tickets); - SendPrintSocket.sendPrint(jsonObject.toString()); + }catch (Exception var17){ Map map = new HashMap(); - map.put("to_command", 200); + map.put("to_command", 400); this.writing(map); - } else { - message = "无请求"; } - if (mode == 7 && move == 1 && !requireSucess) { - //TODO:将贴标信息下发,并反馈200 - JSONObject template = ticketsMapper.template1(); - Tickets tickets = ticketsMapper.ticket(); - String customer = tickets.getCustomer(); - String bottle_number = tickets.getBottle_number(); - String fbottle_number = tickets.getFbottle_number(); - Integer fbottle_number1 = Integer.parseInt(fbottle_number); - String plan_qty=tickets.getPlanned_quantity(); - Integer plan_qty1=Integer.parseInt(plan_qty); - String psletters = null; - String psdigits = null; - Integer psdigits1 = 0; - if (customer.contains("晶科")) { - psletters = bottle_number.substring(0, 18); - psdigits = bottle_number.substring(18, 23); - psdigits1 = Integer.parseInt(psdigits) - fbottle_number1; - - } - if (customer.contains("晶澳")) { - psletters = bottle_number.substring(0, bottle_number.length()-5); - psdigits = bottle_number.substring(bottle_number.length()-5, bottle_number.length()-2); - if (Integer.parseInt(psdigits) >= 100) { - psdigits1 = Integer.parseInt(psdigits) - fbottle_number1-plan_qty1; - psdigits = String.valueOf(psdigits1); - } else if (Integer.parseInt(psdigits) >= 10) { - psdigits1 = Integer.parseInt(psdigits) - fbottle_number1-plan_qty1; - psdigits = "0" + String.valueOf(psdigits1); - } else if (Integer.parseInt(psdigits) >= 0) { - psdigits1 = Integer.parseInt(psdigits) - fbottle_number1-plan_qty1; - psdigits = "00" + String.valueOf(psdigits1); + try { + if (mode == 7 && move == 1 && !requireSucess) { + //TODO:将贴标信息下发,并反馈200 + JSONObject template = ticketsMapper.template1(); + Tickets tickets = ticketsMapper.ticket(); + String customer = tickets.getCustomer(); + String bottle_number = tickets.getBottle_number(); + String fbottle_number = tickets.getFbottle_number(); + Integer fbottle_number1 = Integer.parseInt(fbottle_number); + String plan_qty = tickets.getPlanned_quantity(); + Integer plan_qty1 = Integer.parseInt(plan_qty); + if (fbottle_number1 >=plan_qty1) { + log.info("当前瓶盖数已达最大值"); + throw new BadRequestException("当前瓶盖数已达最大值"); + } + String psletters = null; + String psdigits = null; + Integer psdigits1 = 0; + if (customer.contains("晶科")) { + psletters = bottle_number.substring(0, 18); + psdigits = bottle_number.substring(18, 23); + psdigits1 = Integer.parseInt(psdigits) - fbottle_number1; + + } + if (customer.contains("晶澳")) { + psletters = bottle_number.substring(0, bottle_number.length() - 5); + psdigits = bottle_number.substring(bottle_number.length() - 5, bottle_number.length() - 2); + if (Integer.parseInt(psdigits) >= 100) { + psdigits1 = Integer.parseInt(psdigits) - fbottle_number1 - plan_qty1; + psdigits = String.valueOf(psdigits1); + } else if (Integer.parseInt(psdigits) >= 10) { + psdigits1 = Integer.parseInt(psdigits) - fbottle_number1 - plan_qty1; + psdigits = "0" + String.valueOf(psdigits1); + } else if (Integer.parseInt(psdigits) >= 0) { + psdigits1 = Integer.parseInt(psdigits) - fbottle_number1 - plan_qty1; + psdigits = "00" + String.valueOf(psdigits1); + } } - } String jsonString = template.toString(); ObjectMapper objectMapper = new ObjectMapper(); // 解析外部 JSON 字符串,获取 "template" 字段的值 @@ -451,8 +481,8 @@ public class CartonLabelingMachineDeviceDriver extends AbstractOpcDeviceDriver i // 输出 panels 数据 SendPrintSocket.sendPrint(jsonObject.toString()); log.info("瓶盖打印数据: " + jsonObject.toString()); - fbottle_number1 = fbottle_number1 + 1; - String fbottle_number2 = String.valueOf(fbottle_number1); + fbottle_number1 = fbottle_number1 + 1; + String fbottle_number2 = String.valueOf(fbottle_number1); tickets.setFbottle_number(fbottle_number2); ticketsMapper.updateById(tickets); Map map = new HashMap(); @@ -462,7 +492,12 @@ public class CartonLabelingMachineDeviceDriver extends AbstractOpcDeviceDriver i } else { message = "无请求"; } + }catch (Exception var17){ + Map map = new HashMap(); + map.put("to_command", 400); + this.writing(map); } + } last_mode = mode; last_error = error; @@ -472,7 +507,10 @@ public class CartonLabelingMachineDeviceDriver extends AbstractOpcDeviceDriver i } - + public static boolean hasTwoDecimalPlaces(double weight) { + // 乘以 100 然后取整再除以 100,看结果是否和原数一样 + return Math.round(weight * 100) / 100.0f == weight; + } public boolean exe_error() { if (this.error == 0) { return true; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDefination.java deleted file mode 100644 index d02180f..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDefination.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.nl.acs.device_driver.conveyor.double_station_stacker; - -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 DoubleStationStackerDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "double_station_stacker"; - } - - @Override - public String getDriverName() { - return "标准版-双工位堆垛机"; - } - - @Override - public String getDriverDescription() { - return "标准版-双工位堆垛机"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new DoubleStationStackerDeviceDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return DoubleStationStackerDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.stacker); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDeviceDriver.java deleted file mode 100644 index 77cb7bf..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDeviceDriver.java +++ /dev/null @@ -1,1024 +0,0 @@ -package org.nl.acs.device_driver.conveyor.double_station_stacker; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; -import org.nl.acs.common.base.CommonFinalParam; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device.domain.DeviceExtra; -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.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; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -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.service.TaskService; -import org.nl.config.SpringContextHolder; - -import java.util.*; -import java.util.stream.Collectors; - -/** - * 双工位堆垛机驱动 - */ -@EqualsAndHashCode(callSuper = true) -@Slf4j -@Data -@RequiredArgsConstructor -public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - - TaskService takeover = 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); - - public static final Integer MAX_Y = 6; - public static final Integer MIN_Y = 1; - - /** - * 心跳 - */ - Integer heartbeat = 0; - Integer lastHeartbeat = 0; - /** - * 堆垛机号 - */ - Integer itemDeviceCode = 0; - Integer lastItemDeviceCode = 0; - /** - * 工作模式 - */ - Integer mode = 0; - Integer lastMode = 0; - - /** - * 行走开关信号 - */ - Float move = 0F; - Float lastMove = 0F; - /** - * 行走动作信号 - */ - Float action = 0F; - Float lastAction = 0F; - /** - * 前叉作业状态 - */ - Integer frontCommand = 0; - Integer lastFrontCommand = 0; - /** - * 前叉任务号 - */ - Integer frontTask = 0; - Integer lastFrontTask = 0; - - /** - * 行走激光数值 - */ - Integer distanceX = 0; - Integer lastDistanceX = 0; - - /** - * 特殊开关量1 - */ - Float special1 = 0F; - Float lastSpecial1 = 0F; - /** - * 特殊开关量2 - */ - Float special2 = 0F; - Float lastSpecial2 = 0F; - - /** - * 水箱和消防缓存位有无货 - */ - Float storageCache = 0F; - Float lastStorageCache = 0F; - - - /** - * 后叉作业状态 - */ - Integer backCommand = 0; - Integer lastBackCommand = 0; - /** - * 后叉任务号 - */ - Integer backTask = 0; - Integer lastBackTask = 0; - - /** - * 前叉Z轴报警(货叉) - */ - Integer frontZerror = 0; - Integer lastFrontZerror = 0; - /** - * 后叉Z轴报警(货叉) - */ - Integer backZerror = 0; - Integer lastBackZerror = 0; - - /** - * 前叉行走排号 - */ - Integer frontZ = 0; - Integer lastFrontZ = 0; - /** - * 前行走列号 - */ - Integer frontX = 0; - Integer lastFrontX = 0; - /** - * 前行走层号 - */ - Integer frontY = 0; - Integer lastFrontY = 0; - /** - * 后叉行走排号 - */ - Integer backZ = 0; - Integer lastBackZ = 0; - /** - * 后行走列号 - */ - Integer backX = 0; - Integer lastBackX = 0; - /** - * 后行走层号 - */ - Integer backY = 0; - Integer lastBackY = 0; - - /** - * 前货叉探货信号 - */ - Float frontForkCargo = 0F; - Float lastFrontForkCargo = 0F; - - /** - * 后货叉探货信号 - */ - Float backForkCargo = 0F; - Float lastBackForkCargo = 0F; - - - /** - * 前货叉位置信号 - */ - Float frontForkLocation = 0F; - Float lastFrontForkLocation = 0F; - /** - * 后货叉位置信号 - */ - Float backForkLocation = 0F; - Float lastBackForkLocation = 0F; - - /** - * 前货叉动作信号 - */ - Float frontForkAction = 0F; - Float lastFrontForkAction = 0F; - /** - * 后货叉动作信号 - */ - Float backForkAction = 0F; - Float lastBackForkAction = 0F; - - - String message = null; - - String device_code = null; - - String notCreateInstMessage = null; - - private int instructionRequireTimeOut = 3000; - private int instructionUpdateTimeOut = 3000; - private Date instructionRequireTime = new Date(); - private Date instructionUpdateTime = new Date(); - List getDeviceCodeList = null; - List putDeviceCodeList = null; - - /** - * 请求成功标记 - */ - Boolean requireSucess = false; - - /** - * 禁止入库 - */ - private boolean prohibitInWarehouse = false; - /** - * 禁止出库 - */ - private boolean prohibitOutWarehouse = false; - /** - * 停止接收任务 - */ - private boolean stopReceiveTask = false; - - - @Override - public Device getDevice() { - return this.device; - } - - @Override - public void execute() { - try { - //设置参数 - setData(); - - //记录日志 - setLog(); - - //更新指令状态 - updateAllstatues(); - - } catch (Exception var17) { - var17.printStackTrace(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); - } - if (mode != 3) { - message = "未联机"; - } else if (frontZerror != 0 || backZerror != 0) { - message = "有报警"; - } else { - Map map = new LinkedHashMap<>(); - if (CommandEnum.STANDY.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.STANDY.getStatus())) { - applyTask(); - requireSucess = true; - } - if (CommandEnum.PICKUP.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.PICKUP.getStatus())) { - message = "取货中"; - } - if (CommandEnum.PICKUP_COMPLETE.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.PICKUP_COMPLETE.getStatus())) { - message = "取货完成"; - LinkedList inst = new LinkedList<>(); - getIns(inst); - if (CollectionUtil.isNotEmpty(inst) && ObjectUtil.isNotEmpty(inst.get(0))) { - String startDeviceCode = inst.get(0).getStart_device_code(); - Device startDevice = deviceAppService.findDeviceByCode(startDeviceCode); - writeStorageOrConveyor(inst, startDeviceCode, startDevice, map); - } - if (CollectionUtil.isNotEmpty(inst) && ObjectUtil.isEmpty(inst.get(0))) { - String startDeviceCode = inst.get(1).getStart_device_code(); - Device startDevice = deviceAppService.findDeviceByCode(startDeviceCode); - writeStorageOrConveyor(inst, startDeviceCode, startDevice, map); - } - map.put("to_command", CommandEnum.PICKUP_COMPLETE.getStatus()); - requireSucess = true; - } - if (CommandEnum.RELEASE.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.RELEASE.getStatus())) { - message = "放货中"; - } - if (CommandEnum.UNLOAD.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.UNLOAD.getStatus())) { - message = "请求卸货(申请卸货)"; - LinkedList inst = new LinkedList<>(); - getIns(inst); - if (CollectionUtil.isNotEmpty(inst) && ObjectUtil.isNotEmpty(inst.get(0))) { - String nextDeviceCode = inst.get(0).getNext_device_code(); - Device nextDevice = deviceAppService.findDeviceByCode(nextDeviceCode); - //指令为执行 - if (unloadCheck(nextDevice)) { - return; - } - map.put("to_command", 3); - requireSucess = true; - } - if (CollectionUtil.isNotEmpty(inst) && ObjectUtil.isEmpty(inst.get(0))) { - String nextDeviceCode = inst.get(1).getNext_device_code(); - Device nextDevice = deviceAppService.findDeviceByCode(nextDeviceCode); - if (unloadCheck(nextDevice)) { - return; - } - map.put("to_command", 3); - requireSucess = true; - } - } - if (CommandEnum.UNLOAD_COMPLETE.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.UNLOAD_COMPLETE.getStatus())) { - message = "放货完成"; - map.put("to_command", 5); - LinkedList inst = new LinkedList<>(); - getIns(inst); - try { - if (CollectionUtil.isNotEmpty(inst)) { - for (Instruction instruction : inst) { - finishInstruction(instruction); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - requireSucess = true; - - } - - if (CommandEnum.PICKUP_PREPARATION.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.PICKUP_PREPARATION.getStatus())) { - message = "取货准备(会库位台)"; - map.put("to_command", 6); - requireSucess = true; - } - if (CommandEnum.RECALL.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.RECALL.getStatus())) { - message = "召回"; - map.put("to_command", 7); - requireSucess = true; - } - if (CommandEnum.STOP.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.STOP.getStatus())) { - message = "急停"; - map.put("to_command", 8); - requireSucess = true; - } - if (ObjectUtil.isNotNull(map)) { - this.writing(map); - } - } - lastHeartbeat = heartbeat; - lastItemDeviceCode = itemDeviceCode; - lastMode = mode; - lastFrontCommand = frontCommand; - lastBackCommand = backCommand; - lastFrontTask = frontTask; - lastBackTask = backTask; - lastMove = move; - lastFrontZerror = frontZerror; - lastBackZerror = backZerror; - lastFrontZ = frontZ; - lastBackZ = backZ; - lastFrontX = frontX; - lastBackX = backX; - lastFrontY = frontY; - lastBackY = backY; - lastAction = action; - lastDistanceX = distanceX; - lastFrontForkCargo = frontForkCargo; - lastBackForkCargo = backForkCargo; - lastFrontForkLocation = frontForkLocation; - lastBackForkLocation = backForkLocation; - lastFrontForkAction = frontForkAction; - lastBackForkAction = backForkAction; - lastSpecial1 = special1; - lastSpecial2 = special2; - lastStorageCache = storageCache; - - } - - private boolean unloadCheck(Device nextDevice) { - SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; - if (nextDevice.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) nextDevice.getDeviceDriver(); - if (siemensConveyorDeviceDriver.getMode() != 2 || siemensConveyorDeviceDriver.getMove() == 1) { - notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + siemensConveyorDeviceDriver.getDeviceCode() + - "有货或未联机,无法下发指令!指令号:"; - return true; - } - } - return false; - } - - private void getIns(LinkedList inst) { - if (ObjectUtil.isNotEmpty(this.frontTask)) { - Instruction instructionFront = instructionService.findByCodeFromCache(String.valueOf(frontTask)); - if (ObjectUtil.isNotEmpty(instructionFront)) { - inst.add(instructionFront); - } - } - if (ObjectUtil.isNotEmpty(this.backTask)) { - Instruction instructionBack = instructionService.findByCodeFromCache(String.valueOf(backTask)); - if (CollectionUtil.isNotEmpty(inst) && ObjectUtil.isNotEmpty(instructionBack)) { - inst.add(instructionBack); - } - if (CollectionUtil.isEmpty(inst) && ObjectUtil.isNotEmpty(instructionBack)) { - inst.add(null); - inst.add(instructionBack); - } - } - - } - - private void updateAllstatues() { - if (mode == 3 && frontTask > 0) { - Date date = new Date(); - if (date.getTime() - this.instructionUpdateTime.getTime() < (long) this.instructionUpdateTimeOut) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instructionUpdateTimeOut); - - } else { - this.instructionUpdateTime = date; - updateInstructionStatus(frontTask); - } - } - if (mode == 3 && backTask > 0) { - Date date = new Date(); - if (date.getTime() - this.instructionUpdateTime.getTime() < (long) this.instructionUpdateTimeOut) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instructionUpdateTimeOut); - - } else { - this.instructionUpdateTime = date; - //更改指令状态 - updateInstructionStatus(backTask); - } - } - if (mode == 3 && backTask > 0 && frontTask > 0) { - Date date = new Date(); - if (date.getTime() - this.instructionUpdateTime.getTime() < (long) this.instructionUpdateTimeOut) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instructionUpdateTimeOut); - - } else { - this.instructionUpdateTime = date; - //更改指令状态 - updateInstructionStatus(frontTask); - updateInstructionStatus(backTask); - } - } - } - - private void updateInstructionStatus(Integer task) { - if (task > 0) { - Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst != null) { - if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { - inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - inst.setExecute_device_code(this.device_code); - instructionService.update(inst); - } - } - } - } - - /** - * 申请任务 - */ - public synchronized boolean applyTask() { - Date date = new Date(); - if (date.getTime() - this.instructionRequireTime.getTime() < (long) this.instructionRequireTimeOut) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instructionRequireTimeOut); - return false; - } else { - this.instructionRequireTime = date; - //输入:指令类型多种\ 指令状态多种\ - Instruction instruction1 = new Instruction(); - instruction1.setInstruction_status(InstructionStatusEnum.READY.getIndex()); - List instructions = instructionService.findByDeviceCodes(instruction1, false); - List instructionList = new ArrayList<>(); - //根据路由过滤指令 - if (checkRute(instructions, instructionList)) { - return false; - } - if (CollUtil.isEmpty(instructionList) || instructionList.size() < 1) { - return false; - } - this.sortInst(instructionList); - - Instruction inst = instructionList.get(0); - LinkedList instructionsAll = new LinkedList<>(); - instructionsAll.add(inst); - //找出有相邻的列的指令,如果没有按照单叉走,有按照双叉走 - if (findInstruction(instructionList, inst, instructionsAll)) { - return false; - } - - - //写信号 - if (wirteData(instructionsAll)) { - return false; - } - - - } - return false; - } - - private boolean checkRute(List instructions, List instructionList) { - if (CollUtil.isEmpty(instructions) || instructions.size() < 1) { - return true; - } - for (Instruction instruction : instructions) { - List routeLines = routeLineService.selectDeviceCodeList(instruction.getStart_device_code()); - if (CollUtil.isEmpty(routeLines) || routeLines.size() < 1) { - message = "没有输送线到堆垛机的路由"; - logServer.deviceExecuteLog(this.device_code, "", "", "没有" + instruction.getStart_device_code() + "->" - + this.device_code + "的路由"); - continue; - } - for (RouteLineDto routeLineDto : routeLines) { - if (this.getDeviceCode().equals(routeLineDto.getNext_device_code())) { - List routeLineDtoList = routeLineService.selectDeviceCodeList(this.getDeviceCode()); - if (CollUtil.isEmpty(routeLines) || routeLines.size() < 1) { - message = "没有输送线到堆垛机的路由"; - logServer.deviceExecuteLog(this.device_code, "", "", "没有" + instruction.getStart_device_code() + "->" - + this.device_code + "的路由"); - continue; - } - for (RouteLineDto routeLinedto : routeLineDtoList) { - if (instruction.getNext_device_code().equals(routeLinedto.getNext_device_code())) { - instructionList.add(instruction); - } - } - } - } - } - return false; - } - - private boolean wirteData(LinkedList inst) { - List list = new ArrayList<>(); - if (StrUtil.equals(inst.get(0).getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { - String startDeviceCode = inst.get(0).getStart_device_code(); - Device startDevice = deviceAppService.findDeviceByCode(startDeviceCode); - BeltConveyorDeviceDriver beltConveyorDeviceDriver; - if (startDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) startDevice.getDeviceDriver(); - if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 0) { - notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + beltConveyorDeviceDriver.getDevice_code() + - "无货或未联机,无法下发指令!指令号:" + inst.get(0).getInstruction_code(); - return true; - } - } - //前叉信号写入 - HashMap map = new HashMap<>(); - if (inst.size() == 1 && ObjectUtil.isNotEmpty(inst.get(0))) { - map.put("to_device_code", this.getDevice().getAddress()); - map.put("to_command", CommandEnum.PICKUP.getStatus().toString()); - map.put("to_front_task", inst.get(0).getInstruction_code()); - - } else if (inst.size() > 1 && ObjectUtil.isEmpty(inst.get(1))) { - map.put("to_device_code", this.getDevice().getAddress()); - map.put("to_command", CommandEnum.PICKUP.getStatus().toString()); - map.put("to_back_task", inst.get(1).getInstruction_code()); - } else { - map.put("to_device_code", this.getDevice().getAddress()); - map.put("to_command", CommandEnum.PICKUP.getStatus().toString()); - map.put("to_front_task", inst.get(0).getInstruction_code()); - map.put("to_back_task", inst.get(1).getInstruction_code()); - } - writeStorageOrConveyor(inst, startDeviceCode, startDevice, map); - list.add(map); - this.writing(list); - } - return false; - } - - private void writeStorageOrConveyor(LinkedList inst, String startDeviceCode, Device startDevice, Map map) { - if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name())) { - List list = deviceExtraService.list(Wrappers.lambdaQuery(DeviceExtra.class).eq(DeviceExtra::getDevice_code, startDeviceCode)); - for (DeviceExtra deviceExtra : list) { - if ("x".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())) { - map.put("to_x", deviceExtra.getExtra_value()); - } - if ("z".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())) { - map.put("to_z", deviceExtra.getExtra_value()); - } - if ("y".equals(deviceExtra.getExtra_code()) && StrUtil.isNotEmpty(deviceExtra.getExtra_value())) { - map.put("to_y", deviceExtra.getExtra_value()); - } - } - } - if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.storage.name())) { - if (ObjectUtil.isNotEmpty(inst.get(0))) { - map.put("to_y", inst.get(0).getFrom_z()); - if (inst.get(0).getFrom_x().length() > 1) { - String substring = inst.get(0).getFrom_x().substring(1); - map.put("to_z", substring); - } else { - map.put("to_z", inst.get(0).getFrom_x()); - } - map.put("to_x", inst.get(0).getFrom_y()); - } else { - //只存在后叉的情况 - map.put("to_y", Integer.parseInt(inst.get(0).getFrom_z()) + 1); - if (inst.get(0).getFrom_x().length() > 1) { - String substring = inst.get(0).getFrom_x().substring(1); - map.put("to_z", Integer.parseInt(substring) + 1); - } else { - map.put("to_z", Integer.parseInt(inst.get(0).getFrom_x()) + 1); - } - map.put("to_x", Integer.parseInt(inst.get(0).getFrom_y()) + 1); - } - } - } - - private boolean findInstruction(List instructionList, Instruction inst, LinkedList instructionsAll) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - CommonFinalParam commonFinalParam = new CommonFinalParam(); - wrapper.in(DeviceExtra::getExtra_name, "no_front_y", "no_front_x", "no_back_y", "no_back_x", "sort"); - List deviceExtras = deviceExtraMapper.selectList(wrapper); - //默认第一条指令为前叉判断是否符合 - if (StringUtils.isEmpty(inst.getNext_point_code()) && !StringUtils.contains(inst.getNext_point_code(), commonFinalParam.getBARRE())) { - - return true; - - } else { - String[] splitFront = inst.getNext_point_code().split(commonFinalParam.getBARRE()); - List frontY = deviceExtras.stream().filter(item -> "no_front_y".equals(item.getExtra_name())).collect(Collectors.toList()); - List frontX = deviceExtras.stream().filter(item -> "no_front_x".equals(item.getExtra_name())).collect(Collectors.toList()); - List backY = deviceExtras.stream().filter(item -> "no_back_y".equals(item.getExtra_name())).collect(Collectors.toList()); - List backX = deviceExtras.stream().filter(item -> "no_back_x".equals(item.getExtra_name())).collect(Collectors.toList()); - List sort = deviceExtras.stream().filter(item -> "sort".equals(item.getExtra_name())).collect(Collectors.toList()); - //存在配置的禁止前排列 - if (checkY(splitFront, frontY)) { - return true; - } - if (checkX(splitFront, frontX)) { - return true; - } - - if (Integer.valueOf(splitFront[1]).equals(MIN_Y)) { - return true; - } - String x1; - String x2; - if (Integer.parseInt(splitFront[1]) < 10) { - x1 = "0" + (Integer.parseInt(splitFront[1]) - 1); - x2 = "0" + (Integer.parseInt(splitFront[1]) + 1); - } else { - x1 = "" + (Integer.parseInt(splitFront[1]) - 1); - x2 = "" + (Integer.parseInt(splitFront[1]) + 1); - } - //根据排序进行加减 - String nextPointCodeDown = splitFront[0] + commonFinalParam.getBARRE() + x1 + commonFinalParam.getBARRE() + splitFront[2]; - String nextPointCodeUp = splitFront[0] + commonFinalParam.getBARRE() + x2 + commonFinalParam.getBARRE() + splitFront[2]; - if (CollectionUtil.isNotEmpty(sort) && SortEnum.BACK.getCode().equals(sort.get(0).getExtra_value())) { - nextPointCodeDown = splitFront[0] + commonFinalParam.getBARRE() + x2 + commonFinalParam.getBARRE() + splitFront[2]; - nextPointCodeUp = splitFront[0] + commonFinalParam.getBARRE() + x1 + commonFinalParam.getBARRE() + splitFront[2]; - } - - if (Integer.valueOf(splitFront[1]).equals(MAX_Y)) { - String finalNextPointCodeDown = nextPointCodeDown; - List instructionNextPointList = instructionList.stream().filter(item -> item.getNext_point_code().equals(finalNextPointCodeDown)).collect(Collectors.toList()); - if (instructionNextPointList.size() > 0) { - String[] splitBack = instructionNextPointList.get(0).getNext_point_code().split(commonFinalParam.getBARRE()); - if (checkY(splitBack, backY)) { - return true; - } - if (checkX(splitBack, backX)) { - return true; - } - instructionsAll.add(instructionNextPointList.get(0)); - } - } else { - String finalNextPointCodeDown1 = nextPointCodeDown; - List instructionNextPointList1 = instructionList.stream().filter(item -> item.getNext_point_code().equals(finalNextPointCodeDown1)).collect(Collectors.toList()); - String finalNextPointCodeUp = nextPointCodeUp; - List instructionNextPointList2 = instructionList.stream().filter(item -> item.getNext_point_code().equals(finalNextPointCodeUp)).collect(Collectors.toList()); - - if (instructionNextPointList1.size() > 0) { - String[] splitBack = instructionNextPointList1.get(0).getNext_point_code().split(commonFinalParam.getBARRE()); - if (checkY(splitBack, backY)) { - return true; - } - if (checkX(splitBack, backX)) { - return true; - } - instructionsAll.add(instructionNextPointList1.get(0)); - return false; - } - if (instructionNextPointList2.size() > 0) { - //前叉的上一列有指令,此时前叉变成后叉,重新校验 - String[] splitBack = instructionNextPointList2.get(0).getNext_point_code().split(commonFinalParam.getBARRE()); - if (checkY(splitBack, frontY)) { - return true; - } - if (checkX(splitBack, frontX)) { - return true; - } - instructionsAll.addFirst(null); - if (checkY(splitFront, backY)) { - return true; - } - if (checkX(splitFront, backX)) { - return true; - } - instructionsAll.removeFirst(); - instructionsAll.addFirst(instructionNextPointList2.get(0)); - return false; - } - } - - } - return false; - } - - private boolean checkX(String[] split, List x) { - if (x.size() != 0 && StringUtils.isNotEmpty(x.get(0).getExtra_value())) { - String[] splitValue = x.get(0).getExtra_value().split(","); - Set set = new HashSet<>(Arrays.asList(splitValue)); - return set.contains(split[0]); - } - return false; - } - - private boolean checkY(String[] split, List y) { - if (y.size() != 0 && StringUtils.isNotEmpty(y.get(0).getExtra_value())) { - String[] splitValue = y.get(0).getExtra_value().split(","); - Set set = new HashSet<>(Arrays.asList(splitValue)); - return set.contains(split[1]); - } - return false; - } - - - /** - * 将指令根据优先级和创建时间排序 - * - * @param instructions - */ - private void sortInst(List instructions) { - instructions.sort((t1, t2) -> { - //优先级从大到小 - int i = t2.getPriority().compareTo(t1.getPriority()); - //如果优先级相等 - if (i == 0) { - //时间从早到晚 - i = t1.getCreate_time().compareTo(t2.getCreate_time()); - } - return i; - }); - } - - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("prohibitInWarehouse", this.prohibitInWarehouse); - jo.put("prohibitOutWarehouse", this.prohibitOutWarehouse); - jo.put("stopReceiveTask", this.stopReceiveTask); - jo.put("is_click", true); - jo.put("driver_type", "double_station_stacker"); - return jo; - } - - @Override - public void setDeviceStatus(JSONObject data) { - if (ObjectUtil.isNotEmpty(data)) { - //监控大屏下发作业命令清警-5、召回-7、急停-8 - Integer toCommand = data.getInteger("toCommand"); - if (toCommand != null) { - Map map = new HashMap<>(); - map.put("to_command", toCommand); - this.writing(map); - } - //ACS监控大屏设置禁止入库、禁止出库、停止接收任务 - Boolean prohibitInWarehouse = data.getBoolean("prohibitInWarehouse"); - this.prohibitInWarehouse = prohibitInWarehouse; - Boolean prohibitOutWarehouse = data.getBoolean("prohibitOutWarehouse"); - this.prohibitOutWarehouse = prohibitOutWarehouse; - Boolean stopReceiveTask = data.getBoolean("stopReceiveTask"); - this.stopReceiveTask = stopReceiveTask; - } - } - - - /** - * 完成指令 - * - * @param inst - * @throws Exception - */ - public synchronized boolean finishInstruction(Instruction inst) throws Exception { - instructionService.finish(inst); - return true; - } - - 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")); - } - } - logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); - try { - this.checkcontrol(itemMap); - } catch (Exception e) { - e.printStackTrace(); - try { - this.checkcontrol(itemMap); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - } - - public void writing(Map map) { - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - Map itemMap = new LinkedHashMap<>(); - map.forEach((key, value) -> { - if (ObjectUtil.isNotEmpty(value)) { - itemMap.put(getToParam() + key, value); - } - }); - if (ObjectUtil.isNotEmpty(itemMap)) { - this.control(itemMap); - logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); - } - } - - - /** - * 将扩展表中的字符串数据转换成集合 - * - * @param extraName - * @return - */ - @Override - public List getExtraDeviceCodes(String extraName) { - String extraValue = (String) this.getDevice().getExtraValue().get(extraName); - if (StrUtil.isEmpty(extraValue)) { - return new ArrayList<>(); - } - String devicesString = extraValue.substring(1, extraValue.length() - 1); - List devicesList = new ArrayList<>(); - String[] devices = devicesString.split(","); - for (String value : devices) { - String s = value.replace("\"", "").replace("\"", ""); - devicesList.add(s); - } - return devicesList; - } - - private void setData() { - device_code = this.getDeviceCode(); - heartbeat = this.itemProtocol.getItem_heartbeat(); - itemDeviceCode = this.itemProtocol.getItem_device_Code(); - mode = this.itemProtocol.getItem_mode(); - move = this.itemProtocol.getItem_move(); - frontCommand = this.itemProtocol.getItem_front_command(); - backCommand = this.itemProtocol.getItem_back_command(); - frontTask = this.itemProtocol.getItem_front_task(); - frontZerror = this.itemProtocol.getItem_front_ZError(); - backZerror = this.itemProtocol.getItem_back_ZError(); - frontZ = this.itemProtocol.getItem_front_z(); - frontX = this.itemProtocol.getItem_front_x(); - frontY = this.itemProtocol.getItem_front_y(); - backZ = this.itemProtocol.getItem_back_z(); - backX = this.itemProtocol.getItem_back_x(); - backY = this.itemProtocol.getItem_back_y(); - frontForkCargo = this.itemProtocol.getItem_front_forkCargo(); - backForkCargo = this.itemProtocol.getItem_back_forkCargo(); - frontForkLocation = this.itemProtocol.getItem_front_forkLocation(); - backForkLocation = this.itemProtocol.getItem_back_forkLocation(); - backForkAction = this.itemProtocol.getItem_back_forkAction(); - frontForkAction = this.itemProtocol.getItem_front_forkAction(); - special1 = this.itemProtocol.getItem_special1(); - special2 = this.itemProtocol.getItem_special2(); - storageCache = this.itemProtocol.getItem_storage_cache(); - } - - private void setLog() { - if (!itemDeviceCode.equals(lastItemDeviceCode)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(itemDeviceCode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号item_device_code:" + lastItemDeviceCode + "->" + itemDeviceCode); - } - if (!mode.equals(lastMode)) { - requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + lastMode + "->" + mode); - } - if (!frontCommand.equals(lastFrontCommand)) { - requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontCommand)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_command:" + lastFrontCommand + "->" + frontCommand); - } - if (!backCommand.equals(lastBackCommand)) { - requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backCommand)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_command:" + lastBackCommand + "->" + backCommand); - } - if (!frontTask.equals(lastFrontTask)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontTask)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_task:" + lastFrontTask + "->" + frontTask); - } - if (!backTask.equals(lastBackTask)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backTask)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_task:" + lastBackTask + "->" + backTask); - } - if (!frontZerror.equals(lastFrontZerror)) { - if (0 != frontZerror) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontZerror)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_ZError:" + lastFrontZerror + "->" + frontZerror); - } - } - if (!backZerror.equals(lastBackZerror)) { - if (0 != backZerror) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backZerror)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_ZError:" + lastBackZerror + "->" + backZerror); - } - } - if (!backZ.equals(lastBackZ)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backZ)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_z:" + lastBackZ + "->" + backZ); - } - if (!backX.equals(lastBackX)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backX)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_x:" + lastBackX + "->" + backX); - } - if (!backY.equals(lastBackY)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backY)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_y:" + lastBackY + "->" + backY); - } - if (!frontZ.equals(lastFrontZ)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontZ)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_z:" + lastFrontZ + "->" + frontZ); - } - if (!frontX.equals(lastFrontX)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontX)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_x:" + lastFrontX + "->" + frontX); - } - if (!frontY.equals(lastFrontY)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontY)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_y:" + lastFrontY + "->" + frontY); - } - if (!move.equals(lastMove)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + lastMove + "->" + move); - } - if (!action.equals(lastAction)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(action)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + lastAction + "->" + action); - } - if (!distanceX.equals(lastDistanceX)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(distanceX)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号distancex:" + lastDistanceX + "->" + distanceX); - } - - if (!frontForkCargo.equals(lastFrontForkCargo)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontForkCargo)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_forkCargo:" + lastFrontForkCargo + "->" + frontForkCargo); - } - if (!frontForkLocation.equals(lastFrontForkLocation)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontForkLocation)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_forkLocation:" + lastFrontForkLocation + "->" + frontForkLocation); - } - if (!frontForkAction.equals(lastFrontForkAction)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(frontForkAction)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号front_forkAction:" + lastFrontForkAction + "->" + frontForkAction); - } - if (!backForkCargo.equals(lastBackForkCargo)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backForkCargo)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_forkCargo:" + lastBackForkCargo + "->" + backForkCargo); - } - if (!backForkLocation.equals(lastBackForkLocation)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backForkLocation)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_forkLocation:" + lastBackForkLocation + "->" + backForkLocation); - } - if (!backForkAction.equals(lastBackForkAction)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(backForkAction)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号back_forkAction:" + lastBackForkAction + "->" + backForkAction); - } - if (!special1.equals(lastSpecial1)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(special1)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号special1:" + lastSpecial1 + "->" + special1); - } - if (!special2.equals(lastSpecial2)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(special2)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号special2:" + lastSpecial2 + "->" + special2); - } - if (!storageCache.equals(lastStorageCache)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(storageCache)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号storage_cache:" + lastStorageCache + "->" + storageCache); - } - } - - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/ItemProtocol.java deleted file mode 100644 index a70f38f..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/ItemProtocol.java +++ /dev/null @@ -1,623 +0,0 @@ -package org.nl.acs.device_driver.conveyor.double_station_stacker; - -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_deviceCode = "deviceCode"; - - /** - * 工作模式 - */ - public static String item_mode = "mode"; - - /** - * 行走动作信号 - */ - public static String item_action = "action"; - - - /** - * 前叉行走排号 - */ - public static String item_front_z = "front_z"; - /** - * 前叉行走列号 - */ - public static String item_front_x = "front_x"; - /** - * 前叉行走层号 - */ - public static String item_front_y = "front_y"; - - /** - * 后叉行走排号 - */ - public static String item_back_z = "back_z"; - - /** - * 后叉行走列号 - */ - public static String item_back_x = "back_x"; - - /** - * 后叉行走层号 - */ - public static String item_back_y = "back_y"; - - /** - * 行走开关信号 - */ - public static String item_move = "move"; - - - /** - * 行走激光数值 - */ - public static String item_distancex = "distancex"; - - - /** - * 特殊开关量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_electricCurrent"; - /** - * 轴工作时间(小时) - */ - public static String item_stacker_workingHours = "stacker_workingHours"; - /** - * 轴运行次数 - */ - public static String item_stacker_runingTime = "stacker_runingTime"; - - /** - * 心跳 - */ - 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"; - /** - * 托盘号 - */ - public static String item_to_trayCode = "to_trayCode"; - - - /** - * 堆垛机主体报警 - */ - public static String item_stacker_error = "stackerError"; - - /** - * 前叉作业状态 - */ - public static String item_front_command = "front_command"; - - /** - * 前叉任务号 - */ - public static String item_front_task = "front_task"; - - /** - * 前叉Y轴报警(载货台) - */ - public static String item_front_YError = "front_YError"; - /** - * 前叉Z轴报警(货叉) - */ - public static String item_front_ZError = "front_ZError"; - - /** - * 前叉载货台开关信号 - */ - public static String item_front_cargoMove = "front_cargoMove"; - - /** - * 前叉载货台升降动作信号 - */ - public static String item_front_action = "front_action"; - /** - * 前叉载货台超限信号 - */ - public static String item_front_cargoError = "front_cargoError"; - /** - * 前叉载货台起升激光值 - */ - public static String item_front_distanceY = "front_distanceY"; - /** - * 前叉货叉探货信号 - */ - public static String item_front_forkCargo = "front_forkCargo"; - - /** - * 前叉货叉位置信号 - */ - public static String item_front_forkLocation = "front_forkLocation"; - /** - * 前叉货叉动作信号 - */ - public static String item_front_forkAction = "front_forkAction"; - /** - * 前叉托盘条码 - */ - public static String item_front_trayCode = "front_trayCode"; - /** - * 前叉载货台速度(转/分钟) - */ - public static String item_front_y_rpm = "front_y_rpm"; - /** - * 前叉载货台电流 - */ - public static String item_front_y_electricCurrent = "front_y_electricCurrent"; - /** - * 前叉载货台轴工作小时数 - */ - public static String item_front_y_workingHours = "front_y_workingHours"; - /** - * 前叉载货台轴运行次数 - */ - public static String item_front_y_runingTimes = "front_y_runingTimes"; - /** - * 前叉货叉速度(转/分钟) - */ - public static String item_front_z_rpm = "front_z_rpm"; - /** - * 前叉货叉电流 - */ - public static String item_front_z_electricCurrent = "front_z_electricCurrent"; - /** - * 前叉货叉轴工作时间(小时) - */ - public static String item_front_z_workingHours = "item_front_z_workingHours"; - /** - * 前叉货叉轴运行次数 - */ - public static String item_front_z_runingTimes = "front_front_z_runingTimes"; - /** - * 后叉作业状态 - */ - public static String item_back_command = "back_command"; - /** - * 后叉任务号 - */ - public static String item_back_task = "back_task"; - /** - * 后叉Y轴报警(载货台) - */ - public static String item_back_YError = "back_YError"; - /** - * 后叉Z轴报警(货叉) - */ - public static String item_back_ZError = "back_ZError"; - /** - * 后叉载货台开关信号 - */ - public static String item_back_cargoMove = "back_cargoMove"; - - /** - * 后叉载货台升降动作信号 - */ - public static String item_back_action = "back_action"; - - /** - * 后叉载货台超限信号 - */ - public static String item_back_cargoError = "back_cargoError"; - - /** - * 后叉载货台起升激光值 - */ - public static String item_back_distanceY = "back_distanceY"; - - /** - * 后叉货叉探货信号 - */ - public static String item_back_forkCargo = "back_forkCargo"; - - /** - * 后叉货叉位置信号 - */ - public static String item_back_forkLocation = "back_forkLocation"; - - /** - * 后叉货叉动作信号 - */ - public static String item_back_forkAction = "back_forkAction"; - - /** - * 后叉载货台开关信号 - */ - public static String item_back_trayCode = "back_trayCode"; - - /** - * 后叉载货台速度(转/分钟) - */ - public static String item_back_y_rpm = "back_y_rpm"; - - /** - * 后叉载货台电流 - */ - public static String item_back_y_electricCurrent = "back_y_electricCurrent"; - - /** - * 后叉载货台轴工作小时数 - */ - public static String item_back_y_workingHours = "back_y_workingHours"; - - /** - * 后叉载货台轴运行次数 - */ - public static String item_back_y_runingTimes = "back_y_runingTimes"; - - /** - * 后叉货叉速度(转/分钟) - */ - public static String item_back_z_rpm = "back_z_rpm"; - - /** - * 后叉货叉电流 - */ - public static String item_back_z_electricCurrent = "back_z_electricCurrent"; - - /** - * 后叉货叉轴工作时间(小时) - */ - public static String item_back_z_workingHours = "back_z_workingHours"; - - /** - * 后叉货叉轴运行次数 - */ - public static String item_back_z_runingTimes = "back_z_runingTimes"; - - /** - * 托盘类型 - */ - public static String item_to_container_type = "to_container_type"; - - /** - * 货叉选择 - */ - public static String item_to_chooseFork = "to_chooseFork"; - - /** - * 前叉任务号 - */ - public static String item_to_front_task = "to_front_task"; - - /** - * 前叉托盘号 - */ - public static String item_to_front_trayCode = "to_front_trayCode"; - - /** - * 后叉任务号 - */ - public static String item_to_back_task = "to_back_task"; - - /** - * 后叉托盘号 - */ - public static String item_to_back_trayCode = "to_back_trayCode"; - - - Boolean isonline; - - private DoubleStationStackerDeviceDriver driver; - - public ItemProtocol(DoubleStationStackerDeviceDriver driver) { - this.driver = driver; - } - - public Integer getItem_heartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - public Integer getItem_device_Code(){ - return this.getOpcIntegerValue(item_deviceCode); - } - public Integer getItem_mode(){ - return this.getOpcIntegerValue(item_mode); - } - - ; - - public float getItem_move() { - return this.getOpcFloatValue(item_move); - } - - - public Integer getItem_front_command(){ - return this.getOpcIntegerValue(item_front_command); - } - - public Integer getItem_back_command(){ - return this.getOpcIntegerValue(item_back_command); - } - - public Integer getItem_front_task(){ - return this.getOpcIntegerValue(item_front_task); - } - - public Integer getItem_front_ZError(){ - return this.getOpcIntegerValue(item_front_ZError); - } - - - public Integer getItem_back_ZError(){ - return this.getOpcIntegerValue(item_back_ZError); - } - - - - public Integer getItem_front_z(){ - return this.getOpcIntegerValue(item_front_z); - } - - - public Integer getItem_front_x(){ - return this.getOpcIntegerValue(item_front_x); - } - - public Integer getItem_front_y(){ - return this.getOpcIntegerValue(item_front_y); - } - - public Integer getItem_back_z(){ - return this.getOpcIntegerValue(item_front_z); - } - - - public Integer getItem_back_x(){ - return this.getOpcIntegerValue(item_front_x); - } - - public Integer getItem_back_y(){ - return this.getOpcIntegerValue(item_front_y); - } - public float getItem_special1(){ - return this.getOpcFloatValue(item_special1); - } - - public float getItem_front_forkCargo(){ - return this.getOpcFloatValue(item_front_forkCargo); - } - public float getItem_back_forkCargo(){ - return this.getOpcFloatValue(item_back_forkCargo); - } - - public float getItem_front_forkLocation(){ - return this.getOpcFloatValue(item_front_forkLocation); - } - - public float getItem_back_forkLocation(){ - return this.getOpcFloatValue(item_back_forkLocation); - } - public float getItem_front_forkAction(){ - return this.getOpcFloatValue(item_front_forkAction); - } - - public float getItem_back_forkAction(){ - return this.getOpcFloatValue(item_back_forkAction); - } - - 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_workingHours(){ - return this.getOpcIntegerValue(item_stacker_workingHours); - } - public Integer getItem_stacker_runingTime(){ - return this.getOpcIntegerValue(item_stacker_runingTime); - } - - - 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 (value == null) { - setIsonline(false); - return "0"; - } else { - setIsonline(true); - return value; - } - } - - 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 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_stacker_error, "堆垛机主体报警", "DB101.B3")); - list.add(new ItemDto(item_move, "行走开关信号", "DB101.D4")); - list.add(new ItemDto(item_action, "行走动作信号", "DB101.B5")); - list.add(new ItemDto(item_distancex, "行走激光数值", "DB101.D6")); - list.add(new ItemDto(item_special1, "特殊开关量1", "DB101.B10")); - list.add(new ItemDto(item_special2, "特殊开关量2", "DB101.B11")); - list.add(new ItemDto(item_stacker_rpm, "速度(转/分钟)", "DB101.W12")); - list.add(new ItemDto(item_stacker_electricCurrent, "电流", "DB101.W14")); - list.add(new ItemDto(item_stacker_workingHours, "轴工作时间(小时)", "DB101.D16")); - list.add(new ItemDto(item_stacker_runingTime, "轴运行次数", "DB101.D20")); - list.add(new ItemDto(item_storage_cache, "水箱和消防缓存位有无货", "DB101.B24")); - list.add(new ItemDto(item_front_command, "前叉作业状态", "DB101.B31")); - list.add(new ItemDto(item_front_task, "前叉任务号", "DB101.D32")); - list.add(new ItemDto(item_front_YError, "前叉Y轴报警(载货台)", "DB101.B36")); - list.add(new ItemDto(item_front_ZError, "前叉Z轴报警(货叉)", "DB101.B37")); - list.add(new ItemDto(item_front_z, "前叉行走排号", "DB101.B38")); - list.add(new ItemDto(item_front_x, "前叉行走列号", "DB101.B39")); - list.add(new ItemDto(item_front_y, "前叉行走层号", "DB101.B40")); - list.add(new ItemDto(item_front_cargoMove, "前叉载货台开关信号", "DB101.B41")); - list.add(new ItemDto(item_front_action, "前叉载货台升降动作信号", "DB101.B42")); - list.add(new ItemDto(item_front_cargoError, "前叉载货台超限信号", "DB101.B43")); - list.add(new ItemDto(item_front_distanceY, "前叉载货台起升激光值", "DB101.D44")); - list.add(new ItemDto(item_front_forkCargo, "前叉货叉探货信号", "DB101.B48")); - list.add(new ItemDto(item_front_forkLocation, "前叉货叉位置信号", "DB101.B49")); - list.add(new ItemDto(item_front_forkAction, "前叉货叉动作信号", "DB101.B50")); - list.add(new ItemDto(item_front_trayCode, "前叉托盘条码", "DB101.B51.20")); - list.add(new ItemDto(item_front_y_rpm, "前叉载货台速度(转/分钟)", "DB101.W72")); - list.add(new ItemDto(item_front_y_electricCurrent, "前叉载货台电流", "DB101.W74")); - list.add(new ItemDto(item_front_y_workingHours, "前叉载货台轴工作小时数", "DB101.D76")); - list.add(new ItemDto(item_front_y_runingTimes, "前叉载货台轴运行次数", "DB101.B80")); - list.add(new ItemDto(item_front_z_rpm, "前叉货叉速度(转/分钟)", "DB101.W84")); - list.add(new ItemDto(item_front_z_electricCurrent, "前叉货叉电流", "DB101.W86")); - list.add(new ItemDto(item_front_z_workingHours, "前叉货叉轴工作时间(小时)", "DB101.D88")); - list.add(new ItemDto(item_front_z_runingTimes, "前叉货叉轴运行次数", "DB101.D92")); - list.add(new ItemDto(item_back_command, "后叉作业状态", "DB101.B101")); - list.add(new ItemDto(item_back_task, "后叉任务号", "DB101.D102")); - list.add(new ItemDto(item_back_YError, "后叉Y轴报警(载货台)", "DB101.B106")); - list.add(new ItemDto(item_back_ZError, "后叉Z轴报警(货叉)", "DB101.B107")); - list.add(new ItemDto(item_back_z, "后叉行走排号", "DB101.B108")); - list.add(new ItemDto(item_back_x, "后叉行走列号", "DB101.B109")); - list.add(new ItemDto(item_back_y, "后叉行走层号", "DB101.B110")); - list.add(new ItemDto(item_back_cargoMove, "后叉载货台开关信号", "DB101.B111")); - list.add(new ItemDto(item_back_action, "后叉载货台升降动作信号", "DB101.B112")); - list.add(new ItemDto(item_back_cargoError, "后叉载货台超限信号", "DB101.B113")); - list.add(new ItemDto(item_back_distanceY, "后叉载货台起升激光值", "DB101.D114")); - list.add(new ItemDto(item_back_forkCargo, "后叉货叉探货信号", "DB101.B118")); - list.add(new ItemDto(item_back_forkLocation, "后叉货叉位置信号", "DB101.B119")); - list.add(new ItemDto(item_back_forkAction, "后叉货叉动作信号", "DB101.B120")); - list.add(new ItemDto(item_back_y_rpm, "后叉载货台速度(转/分钟)", "DB101.W142")); - list.add(new ItemDto(item_back_y_electricCurrent, "后叉载货台电流", "DB101.W144")); - list.add(new ItemDto(item_back_y_runingTimes, "后叉载货台轴运行次数", "DB101.D150")); - list.add(new ItemDto(item_back_z_rpm, "后叉货叉速度(转/分钟)", "DB101.W154")); - list.add(new ItemDto(item_back_z_electricCurrent, "后叉货叉电流", "DB101.W156")); - list.add(new ItemDto(item_back_z_workingHours, "后叉货叉轴工作时间(小时)", "DB101.D158")); - list.add(new ItemDto(item_back_z_runingTimes, "后叉货叉轴运行次数", "DB101.D162")); - 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_container_type, "托盘类型", "DB100.B3")); - list.add(new ItemDto(item_to_chooseFork, "货叉选择", "DB100.W4")); - list.add(new ItemDto(item_to_z, "作业排", "DB100.B6")); - list.add(new ItemDto(item_to_x, "作业列", "DN100.B7")); - list.add(new ItemDto(item_to_y, "作业层", "DB100.B8")); - list.add(new ItemDto(item_to_front_task, "前叉任务号", "DB100.D10")); - list.add(new ItemDto(item_to_front_trayCode, "前叉托盘号", "DB100.B14.20")); - list.add(new ItemDto(item_to_back_task, "后叉任务号", "DB100.D34")); - list.add(new ItemDto(item_to_back_trayCode, "后叉托盘号", "DB100.B38.20")); - return list; - } - - - @Override - public String toString() { - return ""; - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/enums/CommandEnum.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/enums/CommandEnum.java deleted file mode 100644 index cd0cd3d..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/enums/CommandEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @author ls - * @date 2023/12/4 13:42 - */ -package org.nl.acs.device_driver.conveyor.double_station_stacker.enums; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum CommandEnum { - /** - * 动作信号 - */ - STANDY(0,"待机"), - PICKUP(1,"取货中"), - PICKUP_COMPLETE(2,"取货完成"), - RELEASE(3,"放货中"), - UNLOAD(4,"请求卸货"), - UNLOAD_COMPLETE(5,"卸货完成"), - PICKUP_PREPARATION(6,"取货准备"), - RECALL(7,"召回"), - STOP(8,"急停"); - - private Integer status; - private String desc; - - public static String getDesc(Integer status) { - for (CommandEnum c : CommandEnum.values()) { - if (c.getStatus().equals(status)) { - return c.getDesc(); - } - } - return null; - } - - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/enums/SortEnum.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/enums/SortEnum.java deleted file mode 100644 index dedae92..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/enums/SortEnum.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @author ls - * @date 2023/12/4 17:43 - */ -package org.nl.acs.device_driver.conveyor.double_station_stacker.enums; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum SortEnum { - /** - * 排序 - */ - PRONT("1","正序"), - BACK("2","倒序"); - - private String code; - private String desc; -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/primary_device/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/primary_device/ItemProtocol.java index 438ba50..cba925c 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/primary_device/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/primary_device/ItemProtocol.java @@ -215,7 +215,7 @@ public class ItemProtocol { list.add(new ItemDto(item_to_order_No, "工单号", "DB601.W4")); list.add(new ItemDto(item_to_qty, "生产数量", "DB601.W6")); list.add(new ItemDto(item_to_material_code, "下发物料编号", "DB601.D8")); - list.add(new ItemDto(item_to_labeling, "人工贴标(前贴标位)", "DB601.D8")); + list.add(new ItemDto(item_to_labeling, "每箱数量", "DB601.D8")); list.add(new ItemDto(item_to_labeling1, "人工贴标1(后贴标位)", "DB601.D8")); list.add(new ItemDto(item_to_ice, "加冰", "DB601.D8")); list.add(new ItemDto(item_to_weight, "生产重量", "DB601.D8")); diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/primary_device/PrimaryDeviceConveyorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/primary_device/PrimaryDeviceConveyorDeviceDriver.java index 3dcf5e3..cb7e388 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/primary_device/PrimaryDeviceConveyorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/primary_device/PrimaryDeviceConveyorDeviceDriver.java @@ -29,6 +29,7 @@ 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.service.TaskService; @@ -38,7 +39,9 @@ import org.nl.config.thread.ThreadPoolExecutorUtil; import org.nl.system.service.lucene.LuceneExecuteLogService; import org.nl.system.service.lucene.dto.LuceneLogDto; import org.nl.system.service.tickets.dto.Tickets; +import org.nl.system.service.tickets.dto.mapper.TicketsMapper; import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; import java.util.*; import java.util.concurrent.ThreadPoolExecutor; @@ -75,8 +78,12 @@ public class PrimaryDeviceConveyorDeviceDriver extends AbstractOpcDeviceDriver i DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); AcsToMesService mesService = SpringContextHolder.getBean(AcsToMesServiceImpl.class); - //当前指令 - Instruction inst = null; + + TicketsMapper ticketsMapper=SpringContextHolder.getBean("ticketsMapper"); + + DeviceAppService deviceAppService=SpringContextHolder.getBean(DeviceAppServiceImpl.class); + + private String error_type = "ssx_error_type"; @@ -196,18 +203,25 @@ public class PrimaryDeviceConveyorDeviceDriver extends AbstractOpcDeviceDriver i Instruction instruction = null; List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 5: - if (!requireSucess) { - //工单完成 - orderSuccee(); - break; - } - default: - break; + /** + * 工单完成 + */ + if(mode == 3 && !requireSucess) { + Tickets entity=ticketsMapper.ticket(); + Device device = deviceAppService.findDeviceByCode("ZPLC"); + if(device.getDeviceDriver() instanceof PrimaryDeviceConveyorDeviceDriver) { + PrimaryDeviceConveyorDeviceDriver primary = (PrimaryDeviceConveyorDeviceDriver) device.getDeviceDriver(); + Map map = new LinkedHashMap<>(); + map.put("to_order_No",0); + map.put("to_command",101); + primary.writing(map); + log.info("工单完成"); + } + Tickets tickets=ticketsMapper.selectById(entity.getTicket_id()); + tickets.setTicket_status("2"); + tickets.setActual_end_time(DateUtil.now()); + ticketsMapper.updateById(tickets); + requireSucess = true; } } @@ -240,38 +254,7 @@ public class PrimaryDeviceConveyorDeviceDriver extends AbstractOpcDeviceDriver i } - /** - * 工单完成 - */ - private void orderSuccee() { - 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); - return; - } else { - this.instruction_require_time = date; - List list = new ArrayList<>(); - Map map = new HashMap(); - putAction(list,map, "to_command", "200"); - Map map1 = new HashMap(); - putAction(list,map1, "order_No", "0"); - Map map2 = new HashMap(); - putAction(list,map2, "to_qty", "0"); - Map map3 = new HashMap(); - putAction(list,map3, "to_material_code", "0"); - Map map4 = new HashMap(); - putAction(list,map4, "to_labeling", "0"); - Map map5 = new HashMap(); - putAction(list,map5, "to_labeling1", "0"); - Map map6 = new HashMap(); - putAction(list,map6, "to_ice", "0"); - Map map7 = new HashMap(); - putAction(list,map7, "to_weight", "0"); - this.writing(list); - //TODO: 工单回传 - mesService.ticketPostbacks(new Tickets()); - } - } + public boolean exe_error() { @@ -288,10 +271,7 @@ public class PrimaryDeviceConveyorDeviceDriver extends AbstractOpcDeviceDriver i return true; } - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } + protected void thingToNothing() throws Exception { diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor/ItemProtocol.java deleted file mode 100644 index 1704fd6..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor/ItemProtocol.java +++ /dev/null @@ -1,164 +0,0 @@ -package org.nl.acs.device_driver.conveyor.siemens_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_carrier_direction = "carrier_direction"; - /** - * 报警 - */ - public static String item_error = "error"; - /** - * 任务号 - */ - public static String item_task = "task"; - - /** - * 行走列 - */ - 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_strap_times = "to_strap_times"; - /** - *木箱长度 - */ - public static String item_to_length = "to_length"; - /** - *木箱宽度 - */ - public static String item_to_weight = "to_weight"; - /** - *木箱高度 - */ - public static String item_to_height = "to_height"; - - - private SiemensConveyorDeviceDriver driver; - - public ItemProtocol(SiemensConveyorDeviceDriver 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_carrier_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); - } - - - 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 "0"; - } - - 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_carrier_direction, "托盘方向", "DB600.B4")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_task, "任务号", "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_strap_times, "困扎次数", "DB601.W12")); - list.add(new ItemDto(item_to_length, "木箱长度", "DB601.W14")); - list.add(new ItemDto(item_to_weight, "木箱宽度", "DB601.W16")); - list.add(new ItemDto(item_to_height, "木箱高度", "DB601.W18")); - return list; - } - - @Override - public String toString() { - return ""; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor/SiemensConveyorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor/SiemensConveyorDefination.java deleted file mode 100644 index 8693443..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor/SiemensConveyorDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.conveyor.siemens_conveyor; - -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 SiemensConveyorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "siemens_conveyor"; - } - - @Override - public String getDriverName() { - return "西门子-输送机驱动"; - } - - @Override - public String getDriverDescription() { - return "西门子-输送机驱动"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new SiemensConveyorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return SiemensConveyorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor/SiemensConveyorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor/SiemensConveyorDeviceDriver.java deleted file mode 100644 index 3609fbf..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor/SiemensConveyorDeviceDriver.java +++ /dev/null @@ -1,979 +0,0 @@ -package org.nl.acs.device_driver.conveyor.siemens_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.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; -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.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingRequest; -import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingResponse; -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.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.domain.StorageCell; -import org.nl.acs.storage_cell.service.mapper.StorageCellMapper; -import org.nl.acs.task.enums.TaskStatusEnum; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.config.SpringContextHolder; -import org.nl.system.service.param.ISysParamService; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 西门子-输送机驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); - @Autowired - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - @Autowired - NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class); - - private StorageCellMapper storageCellMapper; - - /** - * 当前指令 - */ - Instruction inst = null; - - /** - * 工作模式 - */ - 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 phase = 0; - int index = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - Integer heartbeat_tag; - 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 requireApplyLabelingSuccess = false; - boolean requireApplyLaStrangulationSuccess = false; - boolean requireEmptyInSuccess = false; - boolean requireEmptyOutSuccess = false; - boolean requiresShipDeviceUpdate = true; - private int instruction_finished_time_out; - - int branchProtocol = 0; - String inst_message; - String last_inst_message; - - /** - * 当前指令 - */ - - /** - * 暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - */ - int flag; - - String device_code; - - String vehicle_code; - String last_vehicle_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.getCarrier_direction(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - to_command = this.itemProtocol.getTo_command(); - if (mode != last_mode) { - if (mode == 2) { - requireSucess = false; - requireApplyLabelingSuccess = false; - requireApplyLaStrangulationSuccess = false; - requireEmptyInSuccess = false; - requireEmptyOutSuccess = false; - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记"); - } - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - message = null; - if (move == 0) { - inst_message = null; -// this.clearWrite(); - } - if (move == 0 && last_move == 1) { - last_vehicle_code = vehicle_code; - last_inst_message = inst_message; - if ("true".equals(this.device.getExtraValue().get("ship_device_update"))) { - this.requiresShipDeviceUpdate = false; - } - } - logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (carrier_direction != last_carrier_direction) { - logServer.deviceItemValue(this.device_code, "carrier_direction", String.valueOf(carrier_direction)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号carrier_direction:" + last_carrier_direction + "->" + carrier_direction); - } - if (error != last_error) { - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (task != last_task) { - logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); - } - - if (move != 0 && task > 0) { -// logServer.deviceExecuteLog(device_code, "", "", "输送线任务开始反馈任务状态,指令号:" + task); - //inst_message - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - 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(), InstructionStatusEnum.READY.getIndex()) && 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); - } - if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex())) { - if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - vehicle_code = inst.getVehicle_code(); - inst.setExecute_device_code(this.device_code); - finish_instruction(); - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task); - } else { -// if (!StrUtil.equals(inst.getExecute_code(), this.device_code)) { -// inst.setExecute_device_code(this.device_code); -// instructionService.update(inst); -// } - } - - } - } else { -// logServer.deviceExecuteLog(device_code, "", "", "输送线任务开始反馈任务状态,反馈失败,查询不到指令号:" + task); - message = "输送线任务反馈状态,查询不到指令号:" + task + "指令已完成"; - inst_message = null; - } - } - - } catch (Exception var17) { - inst_message = var17.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "读取信号值时出现异常:" + var17.getMessage()); - } - -// if (!this.itemProtocol.getIsonline()) { -// this.setIsonline(false); -// this.setIserror(true); -// message = "信号量同步异常"; -// //未联机 -// } else - if (mode == 0) { - this.setIsonline(false); - message = "未联机"; - //有报警 -// } else if (error != 0) { -// this.setIsonline(false); -// this.setIserror(true); -// message = "有报警"; -// //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - if (error != 0) { - this.setIserror(true); - message = "有报警"; - } - - Instruction instruction = null; - List toInstructions; - - -// if (mode == 2 && move != 0 && task > 0) { -// //inst_message -// inst = instructionService.findByCodeFromCache(String.valueOf(task)); -// if (inst != null) { -// inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); -// if (StrUtil.equals(inst.getInstruction_status(), CommonFinalParam.ONE) && StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { -// finish_instruction(); -// } -// if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { -// inst.setInstruction_status(CommonFinalParam.ONE); -// instructionService.update(inst); -// } -// } -// } - - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - //申请任务 - if (move > 0 && !requireSucess) { - instruction_require(); - } - if (!requiresShipDeviceUpdate && move == 0) { - this.shipDeviceUpdate(); - } else { - this.requiresShipDeviceUpdate = true; - } - break; - case 4: - /** - * 申请捆扎 - */ - if (move > 0) { - applyLaStrangulation(); - } - break; - case 5: - /** - * 申请贴标 - */ - if (move > 0 && !requireSucess) { - applyLabeling(); - - } - break; - case 6: - //空托盘满垛入库申请 - if (move > 0 && !requireEmptyInSuccess) { - emptyIn(); - } - if (move > 0 && !requireSucess) { - instruction_require(); - } - break; - case 7: - //空盘出库申请 - if (move == 0 && !requireSucess) { - emptyOut(); - } - break; - case 8: - //申请AGV任务 - if (move == 1 && !requireSucess) { - applyAgvTask(); - } - break; - - } - } - last_mode = mode; - last_move = move; - last_carrier_direction = carrier_direction; - last_error = error; - last_task = task; - } - - private void shipDeviceUpdate() { - JSONObject param = new JSONObject() {{ - put("device_code", device_code); - }}; - - HttpResponse response = acsToWmsService.shipDeviceUpdate(param); - if (response == null || response.getStatus() == 200) { - this.requiresShipDeviceUpdate = true; - } - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - 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 map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "0"); - list.add(map3); - Map map4 = new HashMap(); - map4.put("code", "to_strap_times"); - map4.put("value", "0"); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_length"); - map5.put("value", "0"); - list.add(map5); - Map map6 = new HashMap(); - map6.put("code", "to_weight"); - map6.put("value", "0"); - list.add(map6); - Map map7 = new HashMap(); - map7.put("code", "to_height"); - map7.put("value", "0"); - list.add(map7); - this.writing(list); - message = null; - vehicle_code = null; - } - - public boolean exe_business() { - return true; - } - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); -// requireSucess = false; - return true; - } - - - protected void thingToNothing() throws Exception { - requireSucess = false; - } - - - public void executing(Server server, Map itemMap) { - this.control(itemMap); - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String move = ""; - String carrier_direction = ""; - if (this.getMode() == 0) { - mode = "脱机"; - } else if (this.getMode() == 1) { - mode = "单机"; - } else if (this.getMode() == 2) { - mode = "待机"; - } else if (this.getMode() == 3) { - mode = "运行中"; - } else if (this.getMode() == 4) { - mode = "申请捆扎中"; - } else if (this.getMode() == 5) { - mode = "申请贴标中"; - } else if (this.getMode() == 6) { - mode = "申请空盘入库中"; - } else if (this.getMode() == 7) { - mode = "申请空盘出库中"; - } else if (this.getMode() == 8) { - mode = "申请AGV任务中"; - } - - if (this.getMove() == 0) { - move = "无货"; - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = "有货"; - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = "有托盘有货"; - jo.put("hasGoods", true); - } - - if (this.carrier_direction == 1) { - carrier_direction = "正转"; - } else if (this.carrier_direction == 2) { - carrier_direction = "反转"; - } - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = CommonFinalParam.ONE; - } - 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("barcode", barcode); -// jo.put("last_task", last_task); - jo.put("inst_message", this.inst_message); - jo.put("last_inst_message", this.last_inst_message); - jo.put("isOnline", this.getIsonline()); - jo.put("error", this.getError()); - jo.put("isError", this.getIserror()); - jo.put("message", this.getMessage()); - jo.put("is_click", true); - jo.put("requireSucess", requireSucess); - jo.put("driver_type", "siemens_conveyor"); - return jo; - } - - @Override - public void setDeviceStatus(JSONObject data) { - String requestSucess = data.getString("requireSucess"); - if (StrUtil.equals(requestSucess, "0")) { - this.requireSucess = false; - } else if (StrUtil.equals(requestSucess, CommonFinalParam.ONE)) { - this.requireSucess = true; - } - } - - 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(); - try{ - this.checkcontrol(itemMap); - } catch (Exception e1){ - e1.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)) { -// if (!ObjectUtils.isEmpty(instructionService.findByBarcodeFromCache(container_code))) { -// return false; -// } - //需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建 - Instruction inst = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()); - if (ObjectUtil.isNotEmpty(inst)) { - List list = new ArrayList(); - Map map = new HashMap(); - - if (StrUtil.isNotEmpty(taskdto.getTo_z())) { - if (StrUtil.equals(taskdto.getTo_z(), "01")) { - map.put("code", "to_target"); - map.put("value", "102"); - } else if (StrUtil.equals(taskdto.getTo_z(), "02")) { - map.put("code", "to_target"); - map.put("value", "201"); - } else if (StrUtil.equals(taskdto.getTo_z(), "03")) { - map.put("code", "to_target"); - map.put("value", "301"); - } - } - 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", CommonFinalParam.ONE); - list.add(map3); - this.writing(list); - message = "下发电气任务号成功"; - requireSucess = true; - return true; - } - - // type 5 输送任务 - if (!StrUtil.equals(taskdto.getTask_type(), "5")) { - return false; - } - 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("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); - 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", CommonFinalParam.ONE); - list.add(map3); - this.writing(list); - } else { - //如果不存在则直接找对应指令 - Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); - if (ObjectUtil.isEmpty(inst)) { - return false; - } - //当起点为行架任务的时候不需要请求下发 - if (StrUtil.equals(inst.getInstruction_type(), "6")) { - 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", CommonFinalParam.ONE); - list.add(map3); - this.writing(list); - } - return true; - } - } - - /** - * 申请贴标 - */ - public synchronized void applyLabeling() { - Date date = new Date(); - if (date.getTime() - this.require_apply_labeling_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_apply_labeling_time = date; - String vehicle_code = ""; - if (task > 0) { - Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task)); - vehicle_code = instruction.getVehicle_code(); - } else { - logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "异常"); - message = "申请贴标电气设备任务号:" + task + "异常"; - throw new RuntimeException("任务号为空!"); - } - if (StrUtil.isEmpty(vehicle_code)) { - logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "未找到载具号"); - message = "申请贴标电气设备任务号:" + task + "未找到载具号"; - throw new RuntimeException("载具号为空!"); - } - ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = - new ApplyLabelingAndBindingRequest(); -// JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0); - StorageCell storageCell = new LambdaQueryChainWrapper<>(storageCellMapper) - .eq(StorageCell::getStorage_code, this.device_code) - .one(); - String start_point_code = null; - if (!ObjectUtil.isEmpty(storageCell)) { -// start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code"); - start_point_code = (String) storageCell.getParent_storage_code() == null ? this.device_code : (String) storageCell.getParent_storage_code(); - } - applyLabelingAndBindingRequest.setDevice_code(start_point_code); - applyLabelingAndBindingRequest.setType(CommonFinalParam.ONE); - applyLabelingAndBindingRequest.setVehicle_code(vehicle_code); - ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest); - - if (applyLabelingAndBindingResponse.getstatus() == 200) { - message = "申请贴标成功"; - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", "5"); - list.add(map); - this.writing(list); - this.writing(list); - message = "申请贴标下发电气信号成功"; - requireApplyLabelingSuccess = true; - } else { - message = "申请贴标失败," + applyLabelingAndBindingResponse.getMessage(); - } - } - } - - /** - * 申请捆扎 - */ - @SneakyThrows - public synchronized void applyLaStrangulation() { - 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 = ""; - if (task > 0) { - Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task)); - if (ObjectUtil.isEmpty(instruction)) { - message = "申请捆扎电气设备任务号:" + task + "未找到对应指令"; - return; -// throw new RuntimeException("该电气任务号未找到对应指令!"); - } - vehicle_code = instruction.getVehicle_code(); - } else { - logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:" + task + "异常"); - message = "申请捆扎电气设备任务号:" + task + "异常"; - return; -// throw new RuntimeException("任务号为空!"); - } - if (StrUtil.isEmpty(vehicle_code)) { - logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:" + task + "未找到载具号"); - message = "申请捆扎电气设备任务号:" + task + "未找到载具号"; - return; -// throw new RuntimeException("载具号为空!"); - } - ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = - new ApplyLabelingAndBindingRequest(); -// JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0); - StorageCell storageCell = new LambdaQueryChainWrapper<>(storageCellMapper) - .eq(StorageCell::getStorage_code, this.device_code) - .one(); - String start_point_code = null; - if (!ObjectUtil.isEmpty(storageCell)) { -// start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code"); - start_point_code = (String) storageCell.getParent_storage_code() == null ? this.device_code : (String) storageCell.getParent_storage_code(); - } - applyLabelingAndBindingRequest.setDevice_code(start_point_code); - applyLabelingAndBindingRequest.setType("2"); - applyLabelingAndBindingRequest.setVehicle_code(vehicle_code); - ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest); - if (applyLabelingAndBindingResponse.getstatus() == 200) { - if (ObjectUtil.isNotEmpty(applyLabelingAndBindingResponse.getData())) { - Map datas = applyLabelingAndBindingResponse.getData(); - String length = datas.get("box_length").toString(); - String width = datas.get("box_width").toString(); - String box_high = datas.get("box_high").toString(); - String bundle_times = datas.get("bundle_times").toString(); - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_length"); - map.put("value", length); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_weight"); - map2.put("value", width); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_height"); - map3.put("value", box_high); - list.add(map3); - Map map4 = new HashMap(); - map4.put("code", "to_strap_times"); - map4.put("value", bundle_times); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_command"); - map5.put("value", "4"); - list.add(map5); - this.writing(list); - message = "申请捆扎成功"; - requireSucess = true; - } else { - message = "未返回尺寸信息"; - } - - } else { - message = applyLabelingAndBindingResponse.getMessage(); - } - - } - } - - public synchronized void emptyIn() { - Date date = new Date(); - if (date.getTime() - this.require_empty_in_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_empty_in_time = date; - - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { - message = "申请空盘入库任务中..."; - - if (taskserver.querySameOriginTask(this.device_code) > 0) { - message = "已存在空盘出库任务不再请求"; - return; - } - - JSONObject apply = new JSONObject(); - apply.put("device_code", device_code); - apply.put("type", "2"); - String str = acsToWmsService.applyTaskToWms(apply); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "申请空盘入库接口不通"; - requireEmptyInSuccess = true; - } else { - if (jo.getInteger("status") == 200) { - message = "申请空盘入库成功"; - requireEmptyInSuccess = true; - } else { - requireEmptyInSuccess = true; - message = "申请空盘入库失败," + jo.get("message").toString(); - } - } - - } - } - } - - 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 { - this.instruction_require_time = date; - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { - Instruction instruction = instructionService.findByCode(String.valueOf(task)); - if (ObjectUtil.isEmpty(instruction)) { - message = "指令号" + task + "未找到对应指令"; - return; - } - if (StrUtil.isEmpty(instruction.getVehicle_code())) { - message = "指令号" + task + "未找到对应木箱号"; - return; - } - message = "申请AGV搬运任务中..."; - JSONObject apply = new JSONObject(); - apply.put("device_code", device_code); - apply.put("type", "4"); - apply.put("vehicle_code", instruction.getVehicle_code()); - String str = acsToWmsService.applyTaskToWms(apply); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "申请AGV搬运任务接口不通"; - requireSucess = true; - } else { - if (jo.getInteger("status") == 200) { - message = "申请AGV搬运任务成功"; - requireSucess = true; - } else { - requireSucess = true; - message = "申请AGV搬运任务失败," + jo.get("message").toString(); - } - } - - } - } - } - - public synchronized void emptyOut() { - Date date = new Date(); - if (date.getTime() - this.require_empty_out_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_empty_out_time = date; - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { - if (taskserver.querySameDestinationTask(this.device_code) > 0) { - message = "已存在空盘出库任务不再请求"; - return; - } - message = "申请空盘出库任务中..."; - JSONObject apply = new JSONObject(); - apply.put("device_code", device_code); - apply.put("type", "3"); - String str = acsToWmsService.applyTaskToWms(apply); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "申请空盘出库接口不通"; - requireSucess = true; - } else { - if (jo.getInteger("status") == 200) { - message = "申请空盘出库成功"; - requireSucess = true; - } else { - requireSucess = true; - message = "申请空盘出库失败," + jo.get("message").toString(); - } - } - - } - } - } - - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/ItemProtocol.java deleted file mode 100644 index a517649..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/ItemProtocol.java +++ /dev/null @@ -1,160 +0,0 @@ -package org.nl.acs.device_driver.conveyor.siemens_conveyor_ckk; - -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_carrier_direction = "carrier_direction"; - /** - * 报警 - */ - public static String item_error = "error"; - /** - * 任务号 - */ - public static String item_task = "task"; - - /** - * 行走列 - */ - 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_strap_times = "to_strap_times"; - /** - *木箱长度 - */ - public static String item_to_length = "to_length"; - /** - *木箱宽度 - */ - public static String item_to_weight = "to_weight"; - /** - *木箱高度 - */ - public static String item_to_height = "to_height"; - - - private SiemensConveyorCkkDeviceDriver driver; - - public ItemProtocol(SiemensConveyorCkkDeviceDriver 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_carrier_direction); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - - 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 "0"; - } - - 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_carrier_direction, "托盘方向", "DB600.B4")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_task, "任务号", "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_strap_times, "困扎次数", "DB601.W12")); - list.add(new ItemDto(item_to_length, "木箱长度", "DB601.W14")); - list.add(new ItemDto(item_to_weight, "木箱宽度", "DB601.W16")); - list.add(new ItemDto(item_to_height, "木箱高度", "DB601.W18")); - return list; - } - - @Override - public String toString() { - return ""; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/SiemensConveyorCkkDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/SiemensConveyorCkkDefination.java deleted file mode 100644 index ab91920..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/SiemensConveyorCkkDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.conveyor.siemens_conveyor_ckk; - -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 SiemensConveyorCkkDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "siemens_conveyor_ckk"; - } - - @Override - public String getDriverName() { - return "西门子-输送机驱动-出库口"; - } - - @Override - public String getDriverDescription() { - return "西门子-输送机驱动-出库口"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new SiemensConveyorCkkDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return SiemensConveyorCkkDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.station); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java deleted file mode 100644 index fe8948e..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_ckk/SiemensConveyorCkkDeviceDriver.java +++ /dev/null @@ -1,947 +0,0 @@ -package org.nl.acs.device_driver.conveyor.siemens_conveyor_ckk; - -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.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; -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.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingRequest; -import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingResponse; -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.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.domain.StorageCell; -import org.nl.acs.storage_cell.service.mapper.StorageCellMapper; -import org.nl.acs.task.enums.TaskStatusEnum; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.config.SpringContextHolder; -import org.nl.system.service.param.ISysParamService; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 西门子-输送机驱动-出库口 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); - @Autowired - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - @Autowired - NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class); - @Autowired - StorageCellMapper storageCellMapper; - - /** - * 当前指令 - */ - Instruction inst = null; - - /** - * 工作模式 - */ - 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 phase = 0; - int index = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - Integer heartbeat_tag; - 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 requireApplyLabelingSuccess = false; - boolean requireApplyLaStrangulationSuccess = false; - boolean requireEmptyInSuccess = false; - boolean requireEmptyOutSuccess = false; - boolean requiresShipDeviceUpdate = true; - private int instruction_finished_time_out; - - int branchProtocol = 0; - String inst_message; - String last_inst_message; - - /** - * 当前指令 - */ - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String device_code; - - String vehicle_code; - String last_vehicle_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.getCarrier_direction(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - if (mode != last_mode) { - if (mode == 2) { - requireSucess = false; - requireApplyLabelingSuccess = false; - requireApplyLaStrangulationSuccess = false; - requireEmptyInSuccess = false; - requireEmptyOutSuccess = false; - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记"); - } - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - message = null; - if (move == 0) { - inst_message = null; - requireSucess = false; - this.clearWrite(); - } - logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (carrier_direction != last_carrier_direction) { - logServer.deviceItemValue(this.device_code, "carrier_direction", String.valueOf(carrier_direction)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号carrier_direction:" + last_carrier_direction + "->" + carrier_direction); - } - if (error != last_error) { - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (task != last_task) { - logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); - } - - if (move != 0 && task > 0) { - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - 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(), InstructionStatusEnum.READY.getIndex()) && 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); - } - if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex())) { - if (!StrUtil.equals(inst.getExecute_code(), this.device_code)) { - inst.setExecute_device_code(this.device_code); - instructionService.update(inst); - } - } - } else { -// logServer.deviceExecuteLog(device_code, "", "", "输送线任务开始反馈任务状态,反馈失败,查询不到指令号:" + task); - message = "输送线任务反馈状态,查询不到指令号:" + task + "指令已完成"; - inst_message = null; - } - } - - } catch (Exception var17) { - inst_message = var17.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "读取信号值时出现异常:" + var17.getMessage()); - } - -// if (!this.itemProtocol.getIsonline()) { -// this.setIsonline(false); -// this.setIserror(true); -// message = "信号量同步异常"; -// //未联机 -// } else - 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) { - try { - instruction_require(); - } catch (Exception e) { - e.printStackTrace(); - } - } - break; - case 4: - break; - case 5: - break; - case 6: - break; - case 7: - break; - case 8: - break; - default: - break; - - } - } - last_mode = mode; - last_move = move; - last_carrier_direction = carrier_direction; - last_error = error; - last_task = task; - } - - private void shipDeviceUpdate() { - JSONObject param = new JSONObject() {{ - put("device_code", device_code); - }}; - - HttpResponse response = acsToWmsService.shipDeviceUpdate(param); - if (response == null || response.getStatus() == 200) { - this.requiresShipDeviceUpdate = true; - } - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - 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 map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "0"); - list.add(map3); - Map map4 = new HashMap(); - map4.put("code", "to_strap_times"); - map4.put("value", "0"); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_length"); - map5.put("value", "0"); - list.add(map5); - Map map6 = new HashMap(); - map6.put("code", "to_weight"); - map6.put("value", "0"); - list.add(map6); - Map map7 = new HashMap(); - map7.put("code", "to_height"); - map7.put("value", "0"); - list.add(map7); - this.writing(list); - message = null; - vehicle_code = null; - } - - public boolean exe_business() { - return true; - } - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); -// requireSucess = false; - return true; - } - - - protected void thingToNothing() throws Exception { - requireSucess = false; - } - - - 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; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - - itemMap.put(to_param, Integer.parseInt(value)); -// itemMap.put(to_param, Integer.parseInt(value)); - this.control(itemMap); - logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value); - } - - public void executing(Server server, Map itemMap) { - this.control(itemMap); - } - - public void writing(int command) { - - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - 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 = "脱机"; - } else if (this.getMode() == 1) { - mode = "单机"; - } else if (this.getMode() == 2) { - mode = "待机"; - } else if (this.getMode() == 3) { - mode = "运行中"; - } else if (this.getMode() == 4) { - mode = "申请捆扎中"; - } else if (this.getMode() == 5) { - mode = "申请贴标中"; - } else if (this.getMode() == 6) { - mode = "申请空盘入库中"; - } else if (this.getMode() == 7) { - mode = "申请空盘出库中"; - } else if (this.getMode() == 8) { - mode = "申请AGV任务中"; - } - - if (this.getMove() == 0) { - move = "无货"; - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = "有货"; - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = "有托盘有货"; - jo.put("hasGoods", true); - } - - if (this.carrier_direction == 1) { - carrier_direction = "正转"; - } else if (this.carrier_direction == 2) { - carrier_direction = "反转"; - } - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = CommonFinalParam.ONE; - } - 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("barcode", barcode); -// jo.put("last_task", last_task); - jo.put("inst_message", this.inst_message); - jo.put("last_inst_message", this.last_inst_message); - jo.put("isOnline", this.getIsonline()); - jo.put("error", this.getError()); - jo.put("isError", this.getIserror()); - jo.put("message", this.getMessage()); - jo.put("is_click", true); - jo.put("requireSucess", requireSucess); - jo.put("driver_type", "siemens_conveyor"); - return jo; - } - - @Override - public void setDeviceStatus(JSONObject data) { - String requestSucess = data.getString("requireSucess"); - if (StrUtil.equals(requestSucess, "0")) { - this.requireSucess = false; - } else if (StrUtil.equals(requestSucess, CommonFinalParam.ONE)) { - this.requireSucess = true; - } - } - - public void writing(List list) { - -// String opcservcerid = this.getDevice().getOpc_server_id(); -// Server server = ReadUtil.getServer(opcservcerid); - 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); - this.control(itemMap); - - } - - - /** - * 请求指令 - */ - 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 (task > 0) { - Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task)); - if (ObjectUtil.isEmpty(instruction)) { - //instruction = instructionService.findByCode(String.valueOf(task)); - message = "任务号:" + task + "未找到对应立库指令,请检查"; - return false; - } - if (StrUtil.equals(instruction.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex())) { - if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - vehicle_code = inst.getVehicle_code(); - inst.setExecute_device_code(this.device_code); - try { - finish_instruction(); - } catch (Exception e) { - e.printStackTrace(); - } - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task); - } - } - } else { - logServer.deviceExecuteLog(device_code, "", "", "申请输送任务电气设备任务号:" + task + "异常"); - message = "申请输送任务电气设备任务号:" + task + "异常"; - return false; - } - - //判断是否存在起点相同 任务状态就绪的任务 - TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); - if (!ObjectUtil.isEmpty(taskdto)) { -// if (!ObjectUtils.isEmpty(instructionService.findByBarcodeFromCache(container_code))) { -// return false; -// } - //需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建 - Instruction inst = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()); - if (ObjectUtil.isNotEmpty(inst)) { - List list = new ArrayList(); - Map map = new HashMap(); - - if (StrUtil.isNotEmpty(taskdto.getTo_z())) { - if (StrUtil.equals(taskdto.getTo_z(), "01")) { - map.put("code", "to_target"); - map.put("value", "102"); - } else if (StrUtil.equals(taskdto.getTo_z(), "02")) { - map.put("code", "to_target"); - map.put("value", "201"); - } else if (StrUtil.equals(taskdto.getTo_z(), "03")) { - map.put("code", "to_target"); - map.put("value", "301"); - } - } - 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", CommonFinalParam.ONE); - list.add(map3); - this.writing(list); - if (task != Integer.parseInt(inst.getInstruction_code())) { - this.writing(list); - message = "重新下发电气信号"; - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); - } - message = "下发电气任务号成功"; - requireSucess = true; - return true; - } - - // type 5 输送任务 - if (!StrUtil.equals(taskdto.getTask_type(), "5")) { - return false; - } - 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("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); - 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", CommonFinalParam.ONE); - list.add(map3); - this.writing(list); - if (task != Integer.parseInt(inst.getInstruction_code())) { - this.writing(list); - message = "重新下发电气信号"; - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); - } - } 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", CommonFinalParam.ONE); - list.add(map3); - this.writing(list); - if (task != Integer.parseInt(inst.getInstruction_code())) { - this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); - } - requireSucess = true; - } - return true; - } - } - - /** - * 申请贴标 - */ - public synchronized void applyLabeling() { - Date date = new Date(); - if (date.getTime() - this.require_apply_labeling_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_apply_labeling_time = date; - String vehicle_code = ""; - if (task > 0) { - Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task)); - vehicle_code = instruction.getVehicle_code(); - } else { - logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "异常"); - message = "申请贴标电气设备任务号:" + task + "异常"; - throw new RuntimeException("任务号为空!"); - } - if (StrUtil.isEmpty(vehicle_code)) { - logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "未找到载具号"); - message = "申请贴标电气设备任务号:" + task + "未找到载具号"; - throw new RuntimeException("载具号为空!"); - } - ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = - new ApplyLabelingAndBindingRequest(); -// JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0); - StorageCell storageCell = new LambdaQueryChainWrapper<>(storageCellMapper).eq(StorageCell::getStorage_code, this.device_code).one(); - String start_point_code = null; - if (!ObjectUtil.isEmpty(storageCell)) { - start_point_code = (String) storageCell.getParent_storage_code() == null ? this.device_code : (String) storageCell.getParent_storage_code(); - } - applyLabelingAndBindingRequest.setDevice_code(start_point_code); - applyLabelingAndBindingRequest.setType(CommonFinalParam.ONE); - applyLabelingAndBindingRequest.setVehicle_code(vehicle_code); - ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest); - - if (applyLabelingAndBindingResponse.getstatus() == 200) { - message = "申请贴标成功"; - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", "5"); - list.add(map); - this.writing(list); - this.writing(list); - message = "申请贴标下发电气信号成功"; - requireApplyLabelingSuccess = true; - } else { - message = "申请贴标失败," + applyLabelingAndBindingResponse.getMessage(); - } - } - } - - /** - * 申请捆扎 - */ - @SneakyThrows - public synchronized void applyLaStrangulation() { - 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 = ""; - if (task > 0) { - Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task)); - if (ObjectUtil.isEmpty(instruction)) { - message = "申请捆扎电气设备任务号:" + task + "未找到对应指令"; - throw new RuntimeException("该电气任务号未找到对应指令!"); - } - vehicle_code = instruction.getVehicle_code(); - } else { - logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:" + task + "异常"); - message = "申请捆扎电气设备任务号:" + task + "异常"; - throw new RuntimeException("任务号为空!"); - } - if (StrUtil.isEmpty(vehicle_code)) { - logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:" + task + "未找到载具号"); - message = "申请捆扎电气设备任务号:" + task + "未找到载具号"; - throw new RuntimeException("载具号为空!"); - } - ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = - new ApplyLabelingAndBindingRequest(); -// JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0); - StorageCell storageCell = new LambdaQueryChainWrapper<>(storageCellMapper).eq(StorageCell::getStorage_code, this.device_code).one(); - String start_point_code = null; - if (!ObjectUtil.isEmpty(storageCell)) { - start_point_code = (String) storageCell.getParent_storage_code() == null ? this.device_code : (String) storageCell.getParent_storage_code(); - } - applyLabelingAndBindingRequest.setDevice_code(start_point_code); - applyLabelingAndBindingRequest.setType("2"); - applyLabelingAndBindingRequest.setVehicle_code(vehicle_code); - ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest); - if (applyLabelingAndBindingResponse.getstatus() == 200) { - if (ObjectUtil.isNotEmpty(applyLabelingAndBindingResponse.getData())) { - Map datas = applyLabelingAndBindingResponse.getData(); - String length = datas.get("box_length").toString(); - String width = datas.get("box_width").toString(); - String box_high = datas.get("box_high").toString(); - String bundle_times = datas.get("bundle_times").toString(); - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_length"); - map.put("value", length); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_weight"); - map2.put("value", width); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_height"); - map3.put("value", box_high); - list.add(map3); - Map map4 = new HashMap(); - map4.put("code", "to_strap_times"); - map4.put("value", bundle_times); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_command"); - map5.put("value", "4"); - list.add(map5); - this.writing(list); -// this.writing(list); - - message = "申请捆扎成功"; - requireSucess = true; - } else { - message = "未返回尺寸信息"; - } - - } else { - message = applyLabelingAndBindingResponse.getMessage(); - } - - } - } - - public synchronized void emptyIn() { - Date date = new Date(); - if (date.getTime() - this.require_empty_in_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_empty_in_time = date; - - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { - message = "申请空盘入库任务中..."; - JSONObject apply = new JSONObject(); - apply.put("device_code", device_code); - apply.put("type", "2"); - String str = acsToWmsService.applyTaskToWms(apply); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "申请空盘入库接口不通"; - requireEmptyInSuccess = true; - } else { - if (jo.getInteger("status") == 200) { - message = "申请空盘入库成功"; - requireEmptyInSuccess = true; - } else { - requireEmptyInSuccess = true; - message = "申请空盘入库失败," + jo.get("message").toString(); - } - } - - } - } - } - - 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 { - this.instruction_require_time = date; - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { - Instruction instruction = instructionService.findByCode(String.valueOf(task)); - if (ObjectUtil.isEmpty(instruction)) { - message = "指令号" + task + "未找到对应指令"; - return; - } - message = "申请AGV搬运任务中..."; - JSONObject apply = new JSONObject(); - apply.put("device_code", device_code); - apply.put("type", "4"); - apply.put("vehicle_code", instruction.getVehicle_code()); - String str = acsToWmsService.applyTaskToWms(apply); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "申请AGV搬运任务接口不通"; - requireSucess = true; - } else { - if (jo.getInteger("status") == 200) { - message = "申请AGV搬运任务成功"; - requireSucess = true; - } else { - requireSucess = true; - message = "申请AGV搬运任务失败," + jo.get("message").toString(); - } - } - - } - } - } - - public synchronized void emptyOut() { - Date date = new Date(); - if (date.getTime() - this.require_empty_out_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_empty_out_time = date; - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { - message = "申请空盘出库任务中..."; - JSONObject apply = new JSONObject(); - apply.put("device_code", device_code); - apply.put("type", "3"); - String str = acsToWmsService.applyTaskToWms(apply); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "申请空盘出库接口不通"; - requireSucess = true; - } else { - if (jo.getInteger("status") == 200) { - message = "申请空盘出库成功"; - requireSucess = true; - } else { - requireSucess = true; - message = "申请空盘出库失败," + jo.get("message").toString(); - } - } - - } - } - } - - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/ItemProtocol.java deleted file mode 100644 index fe4a874..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/ItemProtocol.java +++ /dev/null @@ -1,164 +0,0 @@ -package org.nl.acs.device_driver.conveyor.siemens_conveyor_labeling; - -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_carrier_direction = "carrier_direction"; - /** - * 报警 - */ - public static String item_error = "error"; - /** - * 任务号 - */ - public static String item_task = "task"; - /** - *重量 - */ - 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_container_type = "to_container_type"; - /** - * 下发任务号 - */ - public static String item_to_task = "to_task"; - /** - * 困扎次数 - */ - public static String item_to_strap_times = "to_strap_times"; - /** - *木箱长度 - */ - public static String item_to_length = "to_length"; - /** - *木箱宽度 - */ - public static String item_to_weight = "to_weight"; - /** - *木箱高度 - */ - public static String item_to_height = "to_height"; - - - private SiemensConveyorLabelingDeviceDriver driver; - - public ItemProtocol(SiemensConveyorLabelingDeviceDriver 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_carrier_direction); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getWeight() { - return this.getOpcIntegerValue(item_weight); - } - - - 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 "0"; - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB101.B0")); - list.add(new ItemDto(item_mode, "工作模式", "DB101.B152")); - list.add(new ItemDto(item_move, "光电信号", "DB101.B153")); - list.add(new ItemDto(item_carrier_direction, "托盘方向", "DB101.B154")); - list.add(new ItemDto(item_error, "报警信号", "DB101.B156")); - list.add(new ItemDto(item_task, "任务号", "DB101.D160")); - list.add(new ItemDto(item_weight, "重量", "DB101.D160")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "DB102.W152")); - list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W154")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB102.D158")); - return list; - } - - @Override - public String toString() { - return ""; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/SiemensConveyorLabelingDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/SiemensConveyorLabelingDefination.java deleted file mode 100644 index 9af2b87..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/SiemensConveyorLabelingDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.conveyor.siemens_conveyor_labeling; - -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 SiemensConveyorLabelingDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "siemens_conveyor_labeling"; - } - - @Override - public String getDriverName() { - return "西门子-输送机驱动-贴标"; - } - - @Override - public String getDriverDescription() { - return "西门子-输送机驱动-贴标"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new SiemensConveyorLabelingDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return SiemensConveyorLabelingDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.station); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/SiemensConveyorLabelingDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/SiemensConveyorLabelingDeviceDriver.java deleted file mode 100644 index 5da53d2..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/siemens_conveyor_labeling/SiemensConveyorLabelingDeviceDriver.java +++ /dev/null @@ -1,977 +0,0 @@ -package org.nl.acs.device_driver.conveyor.siemens_conveyor_labeling; - -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.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; -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.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingRequest; -import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingResponse; -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.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.domain.StorageCell; -import org.nl.acs.storage_cell.service.mapper.StorageCellMapper; -import org.nl.acs.task.enums.TaskStatusEnum; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.config.SpringContextHolder; -import org.nl.system.service.param.ISysParamService; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 西门子-输送机驱动-贴标 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver - implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - - @Autowired - ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); - - @Autowired - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - - @Autowired - NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class); - - @Autowired - StorageCellMapper storageCellMapper; - /** - * 当前指令 - */ - Instruction inst = null; - - /** - * 工作模式 - */ - 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 weight = 0; - int last_task = 0; - int agvphase = 0; - - int phase = 0; - int index = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - Integer heartbeat_tag; - 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; - /** - * 行架机械手申请任务成功标识 - */ - boolean requireSucess = false; - boolean requireApplyLabelingSuccess = false; - boolean requireApplyLaStrangulationSuccess = false; - boolean requireEmptyInSuccess = false; - boolean requireEmptyOutSuccess = false; - private int instruction_finished_time_out; - - int branchProtocol = 0; - String inst_message; - - /** - * 当前指令 - */ - - /** - * 暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - */ - int flag; - - String device_code; - - String vehicle_code; - - @Override - public Device getDevice() { - return this.device; - } - - @Override - public void execute() { - String message = null; - 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(); - weight = this.itemProtocol.getWeight(); - if (mode != last_mode) { - if (mode == 2) { - requireSucess = false; - requireApplyLabelingSuccess = false; - requireApplyLaStrangulationSuccess = false; - requireEmptyInSuccess = false; - requireEmptyOutSuccess = false; - logServer.deviceExecuteLog(this.device_code, "", "", "复位请求标记成功!"); - } - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - if (move == 0 && mode == 2) { - this.clearWrite(); - } - logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (carrier_direction != last_carrier_direction) { - logServer.deviceItemValue( - this.device_code, "carrier_direction", String.valueOf(carrier_direction)); - logServer.deviceExecuteLog( - this.device_code, - "", - "", - "信号carrier_direction:" + last_carrier_direction + "->" + carrier_direction); - } - if (error != last_error) { - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog( - this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (task != last_task) { - logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); - } - - if (mode == 2 && move != 0 && task > 0) { - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈任务状态,指令号:" + task); - // inst_message - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst != null) { - inst_message = - "指令号:" - + inst.getInstruction_code() - + " " - + inst.getStart_point_code() - + "->" - + inst.getNext_point_code() - + " 载具号:" - + inst.getVehicle_code(); - if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex()) - && StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - vehicle_code = inst.getVehicle_code(); - finish_instruction(); - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task); - } else if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex()) - && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - instructionService.update(inst); - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task); - } else { - logServer.deviceExecuteLog( - device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈失败任务状态不为就绪或者执行中状态,指令号:" + task); - } - } else { - logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈任务状态,反馈失败,查询不到指令号:" + task); - } - } - - } catch (Exception var17) { - inst_message = var17.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "读取信号值时出现异常:" + var17.getMessage()); - // return; - } - - // if (!this.itemProtocol.getIsonline()) { - // this.setIsonline(false); - // this.setIserror(true); - // message = "信号量同步异常"; - // //未联机 - // } else - if (mode == 0) { - this.setIsonline(false); - message = "未联机"; - // 有报警 - // } else if (error != 0) { - // this.setIsonline(false); - // this.setIserror(true); - // message = "有报警"; - // //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - if (error != 0) { - this.setIserror(true); - message = "有报警"; - } - message = ""; - Instruction instruction = null; - List toInstructions; - - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - // 申请任务 - if (move > 0 && !requireSucess) { - instruction_require(); - } - break; - case 4: - // 申请捆扎 - if (move > 0 && !requireSucess) { - applyLaStrangulation(); - } - break; - case 5: - /** - * 申请贴标 - */ - if (move > 0 && !requireSucess) { - applyLabeling(); - } - break; - case 6: - // 空托盘满垛入库申请 - if (move > 0 && !requireEmptyInSuccess) { - emptyIn(); - } - if (move > 0 && !requireSucess) { - instruction_require(); - } - break; - case 7: - // 空盘出库申请 - if (move == 0 && !requireEmptyOutSuccess) { - emptyOut(); - } - break; - case 8: - // 申请AGV任务 - if (move == 0 && !requireSucess) { - applyAgvTask(); - } - break; - default: - break; - } - } - last_mode = mode; - last_move = move; - last_carrier_direction = carrier_direction; - last_error = error; - last_task = task; - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - 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 map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "0"); - list.add(map3); - Map map4 = new HashMap(); - map4.put("code", "to_strap_times"); - map4.put("value", "0"); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_length"); - map5.put("value", "0"); - list.add(map5); - Map map6 = new HashMap(); - map6.put("code", "to_weight"); - map6.put("value", "0"); - list.add(map6); - Map map7 = new HashMap(); - map7.put("code", "to_height"); - map7.put("value", "0"); - list.add(map7); - this.writing(list); - message = null; - vehicle_code = null; - } - - public boolean exe_business() { - return true; - } - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - // requireSucess = false; - return true; - } - - protected void thingToNothing() throws Exception { - requireSucess = false; - } - - 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; - // String opcservcerid = this.getDevice().getOpc_server_id(); - // Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - - itemMap.put(to_param, Integer.parseInt(value)); - // itemMap.put(to_param, Integer.parseInt(value)); - this.control(itemMap); - logServer.deviceExecuteLog( - device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value); - } - - public void executing(Server server, Map itemMap) { - this.control(itemMap); - } - - public void writing(int command) { - - // String opcservcerid = this.getDevice().getOpc_server_id(); - // Server server = ReadUtil.getServer(opcservcerid); - 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 = "脱机"; - } else if (this.getMode() == 1) { - mode = "单机"; - } else if (this.getMode() == 2) { - mode = "待机"; - } else if (this.getMode() == 3) { - mode = "运行中"; - } else if (this.getMode() == 4) { - mode = "申请捆扎中"; - } else if (this.getMode() == 5) { - mode = "申请贴标中"; - } else if (this.getMode() == 6) { - mode = "申请空盘入库中"; - } else if (this.getMode() == 7) { - mode = "申请空盘出库中"; - } else if (this.getMode() == 8) { - mode = "申请AGV任务中"; - } - - if (this.getMove() == 0) { - move = "无货"; - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = "有货"; - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = "有托盘有货"; - jo.put("hasGoods", true); - } - String requireApplyLabelingSuccess = "0"; - if (this.requireApplyLabelingSuccess) { - requireApplyLabelingSuccess = CommonFinalParam.ONE; - } - String requireApplyLaStrangulationSuccess = "0"; - if (this.requireApplyLaStrangulationSuccess) { - requireApplyLaStrangulationSuccess = CommonFinalParam.ONE; - } - jo.put("requireApplyLabelingSuccess", requireApplyLabelingSuccess); - jo.put("requireApplyLaStrangulationSuccess", requireApplyLaStrangulationSuccess); - - if (this.carrier_direction == 1) { - carrier_direction = "正转"; - } else if (this.carrier_direction == 2) { - carrier_direction = "反转"; - } - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = CommonFinalParam.ONE; - } - - 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("isOnline", this.getIsonline()); - jo.put("error", this.getError()); - jo.put("isError", this.getIserror()); - jo.put("message", this.getMessage()); - jo.put("is_click", true); - jo.put("requireSucess", requireSucess); - jo.put("driver_type", "siemens_conveyor"); - return jo; - } - - @Override - public void setDeviceStatus(JSONObject data) { - String requestSucess = data.getString("requireSucess"); - if (StrUtil.equals(requestSucess, "0")) { - this.requireSucess = false; - } else if (StrUtil.equals(requestSucess, CommonFinalParam.ONE)) { - this.requireSucess = true; - } - } - - public void writing(List list) { - - // String opcservcerid = this.getDevice().getOpc_server_id(); - // Server server = ReadUtil.getServer(opcservcerid); - 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); - this.control(itemMap); - } - - /** - * 请求指令 - */ - 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)) { - // if - // (!ObjectUtils.isEmpty(instructionService.findByBarcodeFromCache(container_code))) { - // return false; - // } - // 需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建 - Instruction inst = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()); - if (ObjectUtil.isNotEmpty(inst)) { - List list = new ArrayList(); - Map map = new HashMap(); - - if (StrUtil.isNotEmpty(taskdto.getTo_z())) { - if (StrUtil.equals(taskdto.getTo_z(), "01")) { - map.put("code", "to_target"); - map.put("value", "102"); - } else if (StrUtil.equals(taskdto.getTo_z(), "02")) { - map.put("code", "to_target"); - map.put("value", "201"); - } else if (StrUtil.equals(taskdto.getTo_z(), "03")) { - map.put("code", "to_target"); - map.put("value", "301"); - } - } - 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", CommonFinalParam.ONE); - list.add(map3); - this.writing(list); - if (task != Integer.parseInt(inst.getInstruction_code())) { - this.writing(list); - logServer.deviceExecuteLog( - device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); - } - message = "下发电气任务号成功"; - requireSucess = true; - return true; - } - - // type 5 输送任务 - if (!StrUtil.equals(taskdto.getTask_type(), "5")) { - return false; - } - 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("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); - instdto.setExecute_device_code(start_point_code); - try { - instructionService.create(instdto); - } catch (Exception e) { - e.printStackTrace(); - log.error("指令创建异常!"); - 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", CommonFinalParam.ONE); - list.add(map3); - this.writing(list); - if (task != Integer.parseInt(inst.getInstruction_code())) { - this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); - } - } else { - // 如果不存在则直接找对应指令 - Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); - if (ObjectUtil.isEmpty(inst)) { - return false; - } - // 当起点为行架任务的时候不需要请求下发 - if (StrUtil.equals(inst.getInstruction_type(), "6")) { - 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", CommonFinalParam.ONE); - list.add(map3); - this.writing(list); - if (task != Integer.parseInt(inst.getInstruction_code())) { - this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号"); - } - } - return true; - } - } - - /** - * 申请贴标 - */ - public synchronized void applyLabeling() { - Date date = new Date(); - if (date.getTime() - this.require_apply_labeling_time.getTime() - < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_apply_labeling_time = date; - String vehicle_code = ""; - if (weight == 0) { - logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备重量:" + weight + "异常"); - message = "申请贴标电气设备重量:" + weight + "异常"; - throw new RuntimeException("重量为空!"); - } - if (task > 0) { - Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task)); - if (ObjectUtil.isEmpty(instruction)) { - instruction = instructionService.findByCode(String.valueOf(task)); - } - vehicle_code = instruction.getVehicle_code(); - } else { - logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "异常"); - message = "申请贴标电气设备任务号:" + task + "异常"; - throw new RuntimeException("任务号为空!"); - } - if (StrUtil.isEmpty(vehicle_code)) { - logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "未找到载具号"); - message = "申请贴标电气设备任务号:" + task + "未找到载具号"; - throw new RuntimeException("载具号为空!"); - } - ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = - new ApplyLabelingAndBindingRequest(); -// JSONObject device_json = -// WQLObject.getWQLObject("acs_storage_cell") -// .query("storage_code ='" + this.device_code + "'") -// .uniqueResult(0); - - StorageCell storageCell = new LambdaQueryChainWrapper<>(storageCellMapper).eq(StorageCell::getStorage_code, this.device_code).one(); - String start_point_code = null; - if (!ObjectUtil.isEmpty(storageCell)) { - start_point_code = - (String) storageCell.getParent_storage_code() == null - ? this.device_code - : (String) storageCell.getParent_storage_code(); - } - applyLabelingAndBindingRequest.setDevice_code(start_point_code); - applyLabelingAndBindingRequest.setType(CommonFinalParam.ONE); - applyLabelingAndBindingRequest.setVehicle_code(vehicle_code); - applyLabelingAndBindingRequest.setWeight(String.valueOf((float) weight / 100)); - ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = - acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest); - - if (applyLabelingAndBindingResponse.getstatus() == 200) { - message = "申请贴标成功"; - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", "5"); - list.add(map); - this.writing(list); - this.writing(list); - message = "申请贴标下发电气信号成功"; - requireSucess = true; - } else { - message = "申请贴标失败," + applyLabelingAndBindingResponse.getMessage(); - } - } - } - - /** - * 申请捆扎 - */ - public synchronized void applyLaStrangulation() { - 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 = ""; - if (task > 0) { - Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task)); - vehicle_code = instruction.getVehicle_code(); - } else { - logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:" + task + "异常"); - message = "申请捆扎电气设备任务号:" + task + "异常"; - throw new RuntimeException("任务号为空!"); - } - if (StrUtil.isEmpty(vehicle_code)) { - logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:" + task + "未找到载具号"); - message = "申请捆扎电气设备任务号:" + task + "未找到载具号"; - throw new RuntimeException("载具号为空!"); - } - ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = - new ApplyLabelingAndBindingRequest(); -// JSONObject device_json = -// WQLObject.getWQLObject("acs_storage_cell") -// .query("storage_code ='" + this.device_code + "'") -// .uniqueResult(0); - StorageCell storageCell = new LambdaQueryChainWrapper<>(storageCellMapper).eq(StorageCell::getStorage_code, this.device_code).one(); - String start_point_code = null; - if (!ObjectUtil.isEmpty(storageCell)) { - start_point_code = - (String) storageCell.getParent_storage_code() == null - ? this.device_code - : (String) storageCell.getParent_storage_code(); - } - applyLabelingAndBindingRequest.setDevice_code(start_point_code); - applyLabelingAndBindingRequest.setType("2"); - applyLabelingAndBindingRequest.setVehicle_code(vehicle_code); - ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = - acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest); - if (applyLabelingAndBindingResponse.getstatus() == 200) { - if (ObjectUtil.isNotEmpty(applyLabelingAndBindingResponse.getData())) { - Map datas = applyLabelingAndBindingResponse.getData(); - String length = datas.get("box_length").toString(); - String width = datas.get("box_width").toString(); - String box_high = datas.get("box_high").toString(); - String bundle_times = datas.get("bundle_times").toString(); - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_length"); - map.put("value", length); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_weight"); - map2.put("value", width); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_height"); - map3.put("value", box_high); - list.add(map3); - Map map4 = new HashMap(); - map4.put("code", "to_strap_times"); - map4.put("value", bundle_times); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_command"); - map5.put("value", "4"); - list.add(map5); - this.writing(list); - this.writing(list); - message = "申请贴标成功"; - requireSucess = true; - } else { - message = "未返回尺寸信息"; - } - - } else { - message = applyLabelingAndBindingResponse.getMessage(); - } - } - } - - public synchronized void emptyIn() { - Date date = new Date(); - if (date.getTime() - this.require_empty_in_time.getTime() - < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_empty_in_time = date; - - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { - message = "申请空盘入库任务中..."; - JSONObject apply = new JSONObject(); - apply.put("device_code", device_code); - apply.put("type", "2"); - String str = acsToWmsService.applyTaskToWms(apply); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "申请空盘入库接口不通"; - } else { - if (jo.getInteger("status") == 200) { - message = "申请空盘入库成功"; - requireEmptyInSuccess = true; - } else { - requireEmptyInSuccess = false; - message = "申请空盘入库失败," + jo.get("message").toString(); - } - } - } - } - } - - 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 { - this.instruction_require_time = date; - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { - message = "申请AGV搬运任务中..."; - JSONObject apply = new JSONObject(); - apply.put("device_code", device_code); - apply.put("type", CommonFinalParam.ONE); - String str = acsToWmsService.applyTaskToWms(apply); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "申请AGV搬运任务接口不通"; - } else { - if (jo.getInteger("status") == 200) { - message = "申请AGV搬运任务成功"; - requireEmptyOutSuccess = true; - } else { - requireEmptyOutSuccess = false; - message = "申请AGV搬运任务失败," + jo.get("message").toString(); - } - } - } - } - } - - public synchronized void emptyOut() { - Date date = new Date(); - if (date.getTime() - this.require_empty_out_time.getTime() - < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return; - } else { - this.require_empty_out_time = date; - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { - message = "申请空盘出库任务中..."; - JSONObject apply = new JSONObject(); - apply.put("device_code", device_code); - apply.put("type", "3"); - String str = acsToWmsService.applyTaskToWms(apply); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "申请空盘出库接口不通"; - } else { - if (jo.getInteger("status") == 200) { - message = "申请空盘出库成功"; - requireEmptyOutSuccess = true; - } else { - requireEmptyOutSuccess = false; - message = "申请空盘出库失败," + jo.get("message").toString(); - } - } - } - } - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control/ItemProtocol.java deleted file mode 100644 index f209573..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control/ItemProtocol.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_conveyor_control; - -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_ioaction = "ioaction"; - public static String item_height = "height"; - public static String item_error = "error"; - public static String item_direction = "direction"; - public static String item_operation_type = "operation_type"; - public static String item_task = "task"; - - 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_weight = "weight"; - - private StandardCoveyorControlDeviceDriver driver; - - public ItemProtocol(StandardCoveyorControlDeviceDriver 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 getOperation_type() { - return this.getOpcIntegerValue(item_operation_type); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - - /** - *是否有货 - */ - public int hasGoods(int move) { - return move; - } - - 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 static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(item_action, "取放信号", "DB600.B3")); - list.add(new ItemDto(item_ioaction, "进出类型", "DB600.B4")); - list.add(new ItemDto(item_height, "高度类型", "DB600.B5")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_direction, "电机方向", "DB600.B7")); - list.add(new ItemDto(item_operation_type, "作业类型", "DB600.B8")); - list.add(new ItemDto(item_task, "任务号", "DB600.D22")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); - return list; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control/StandardConveyorControlDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control/StandardConveyorControlDefination.java deleted file mode 100644 index 51bfd56..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control/StandardConveyorControlDefination.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_conveyor_control; - -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 StandardConveyorControlDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_conveyor_control"; - } - - @Override - public String getDriverName() { - return "标准版-输送机-控制点"; - } - - @Override - public String getDriverDescription() { - return "标准版-输送机-控制点"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardCoveyorControlDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardCoveyorControlDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java deleted file mode 100644 index 75dfdbd..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java +++ /dev/null @@ -1,510 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_conveyor_control; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.custompolicy.WaitingInstructionDeque; -import org.nl.acs.custompolicy.server.CustomPolicyService; -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.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.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.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.domain.Task; -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.acs.task.service.mapper.TaskMapper; -import org.nl.acs.utils.ConvertUtil; -import org.nl.common.utils.CodeUtil; -import org.nl.config.SpringContextHolder; -import org.nl.system.service.param.ISysParamService; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 输送机-控制点驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardCoveyorControlDeviceDriver 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("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); - - @Autowired - CustomPolicyService customPolicyService = SpringContextHolder.getBean(CustomPolicyService.class); - - - @Autowired - TaskMapper taskMapper; - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - int mode = 0; - int error = 0; - int move = 0; - int task = 0; - //出入库模式 - int operation_type = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - 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; - /** - * 请求成功标记 - */ - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - String inst_message; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - /** - * 数量 - */ - String qty; - //物料 - String material; - /** - * 当前指令 - */ - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag = 0; - - String device_code; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); - hasGoods = this.itemProtocol.getMove(); - operation_type = this.itemProtocol.getOperation_type(); - if (mode != last_mode) { - } - if (move != last_move) { - if (move == 0) { - thingToNothing(); - } - this.setRequireSucess(false); - - } - if (error != last_error) { - } - - if (mode == 2 && move != 0 && task > 0) { - //inst_message - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst != null) { - inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); - if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex()) && StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - finish_instruction(); - } - if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex()) && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - instructionService.update(inst); - } - } - } - WaitingInstructionDeque deque = null; -// deque = instructionService.findByStategy(this.getDeviceCode(), "deviceCustomerDequeStrategy"); - - - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - 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 (!StrUtil.isEmpty(material) && !StrUtil.isEmpty(qty) && material.length() > 0 && qty.length() > 0 && !requireSucess) { - this.instruction_require(container); - } - break; - case 3: - - break; - case 4: - //叫料 - - break; - case 5: - //申请空盘 - if (move == 0 && !requireSucess) { - apply_OutEmpty(); - } - break; - case 6: - //申请入库 - if (move != 0 && !applySucess) { - instruction_apply(); - } - if (move != 0 && !requireSucess) { - apply_InEmpty(); - } - break; - default: - break; - } - - - switch (flag) { - //取货完成 - case 1: - writing(2); - break; - //放货完成 - case 2: - writing(3); - break; - default: - break; - } - - } - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.setRequireSucess(false); - this.setApplySucess(false); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - this.control(itemMap); - - } - - 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() - + "." + ItemProtocol.item_to_command; - - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - this.control(itemMap); - - } - - public void writing(int command, int target, int task) { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - itemMap.put(to_target, target); - itemMap.put(to_task, task); - this.control(itemMap); - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_target, command); - - } else if (type == 3) { - itemMap.put(to_task, command); - } - this.control(itemMap); - - } - - public boolean instruction_apply() { - return false; - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status(TaskStatusEnum.READY.getIndex()); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - -// WQLObject wo = WQLObject.getWQLObject("acs_task"); -// JSONObject json = (JSONObject) JSONObject.toJSON(dto); -// -// wo.insert(json); - Task entity = ConvertUtil.convert(dto, Task.class); - taskMapper.insert(entity); - - requireSucess = false; - return true; - } - } - - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - public void apply_OutEmpty() { - - } - - public synchronized boolean apply_InEmpty() { - return false; - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String action = ""; - String move = ""; - if (this.getMode() == 0) { - mode = "未联机"; - } else if (this.getMode() == 1) { - mode = "单机"; - } else if (this.getMode() == 2) { - mode = "联机"; - } else if (this.getMode() == 3) { - mode = "运行中"; - } - - if (this.getMove() == 0) { - move = "无货"; - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = "有货"; - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = "有托盘有货"; - jo.put("hasGoods", true); - } - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("action", action); - jo.put("isOnline", this.getIsonline()); - jo.put("error", this.getError()); - jo.put("isError", this.getIserror()); - jo.put("task", this.getTask()); - return jo; - } - - @Override - public void setDeviceStatus(JSONObject data) { - - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/ItemProtocol.java deleted file mode 100644 index e8e748f..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/ItemProtocol.java +++ /dev/null @@ -1,164 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_plcscanner; - -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_ioaction = "ioaction"; - public static String item_height = "height"; - public static String item_error = "error"; - public static String item_direction = "direction"; - public static String item_operation_type = "operation_type"; - public static String item_barcode = "barcode"; - public static String item_weight = "weight"; - public static String item_task = "task"; - - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - - private StandardCoveyorControlWithPlcScannerDeviceDriver driver; - - public ItemProtocol(StandardCoveyorControlWithPlcScannerDeviceDriver 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 String getBarcode() { - return this.getOpcStringValue(item_barcode); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getIoAction() { - return this.getOpcIntegerValue(item_ioaction); - } - - public int getHeight() { - return this.getOpcIntegerValue(item_height); - } - - public int getDirection() { - return this.getOpcIntegerValue(item_direction); - } - - public int getOperation_type() { - return this.getOpcIntegerValue(item_operation_type); - } - - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - /** - *是否有货 - */ - public int hasGoods(int move) { - return move; - } - - 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 int[] getOpcIntegerArrayValue(String protocol) { - int[] value = this.driver.getIntegeregerArrayValue(protocol); - if (value == null) { - //throw new BusinessException("{} : {}", new Object[]{protocol, DeviceErrorProtocol.getMessage(10000)}); - } else { - return value; - } - return value; - } - - - public String getOpcStringValue(String protocol) { - String value = this.driver.getStringValue(protocol); - if (value == null) { - //throw new BusinessException("{} : {}", new Object[]{protocol, DeviceErrorProtocol.getMessage(10000)}); - - } else { - return value; - } - return "0"; - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(item_action, "取放信号", "DB600.B3")); - list.add(new ItemDto(item_ioaction, "进出类型", "DB600.B4")); - list.add(new ItemDto(item_height, "高度类型", "DB600.B5")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_direction, "电机方向", "DB600.B7")); - list.add(new ItemDto(item_operation_type, "作业类型", "DB600.B8")); - list.add(new ItemDto(item_task, "任务号", "DB600.D22")); - list.add(new ItemDto(item_barcode, "托盘号", "DB600.S26")); - - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); - return list; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/StandardConveyorControlWithPlcScannerDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/StandardConveyorControlWithPlcScannerDefination.java deleted file mode 100644 index 032e03d..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/StandardConveyorControlWithPlcScannerDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_plcscanner; - -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; - -/** - * 输送机-控制点-PLC扫码器驱动定义 - */ -@Service -public class StandardConveyorControlWithPlcScannerDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_conveyor_control_with_plcscanner"; - } - - @Override - public String getDriverName() { - return "标准版-输送机-控制点-PLC扫码器"; - } - - @Override - public String getDriverDescription() { - return "标准版-输送机-控制点-PLC扫码器"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardCoveyorControlWithPlcScannerDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardCoveyorControlWithPlcScannerDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/StandardConveyorWithPlcScannerConfig.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/StandardConveyorWithPlcScannerConfig.java deleted file mode 100644 index a3ed588..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/StandardConveyorWithPlcScannerConfig.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_plcscanner; - -public class StandardConveyorWithPlcScannerConfig { - public static String relation_scanner = "link_scanner"; - public static String ignoreInstructionCheck = "ignoreInstructionCheck"; - public static String empty_tray_in = "emptyTrayIn"; - public static String empty_tray_out = "emptyTrayOut"; - public static String execute_time_out = "executeTimeOut"; - - public StandardConveyorWithPlcScannerConfig() { - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/StandardCoveyorControlWithPlcScannerDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/StandardCoveyorControlWithPlcScannerDeviceDriver.java deleted file mode 100644 index cfd8b27..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_plcscanner/StandardCoveyorControlWithPlcScannerDeviceDriver.java +++ /dev/null @@ -1,925 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_plcscanner; - -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.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.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.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.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.domain.Task; -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.acs.task.service.mapper.TaskMapper; -import org.nl.acs.utils.ConvertUtil; -import org.nl.config.SpringContextHolder; -import org.nl.system.service.param.ISysParamService; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; - -/** - * 输送机控制点-带扫描驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardCoveyorControlWithPlcScannerDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); - ; - - @Autowired - TaskMapper taskMapper; - - String barcode = null; - String formatcode = null; - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - int mode = 0; - int error = 0; - int move = 0; - int task = 0; - int height = 0; - int action = 0; - int ioaction = 0; - int direction = 0; - int operation_type = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - String foramteBarcode = null; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - String str = null; - String inst_message; - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - 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; - /** - * 请求成功标记 - */ - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - /** - * 数量 - */ - String qty; - //物料 - String material; - /** - * 当前指令 - */ - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - //暂定 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(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); - action = this.itemProtocol.getAction(); - ioaction = this.itemProtocol.getIoAction(); - height = this.itemProtocol.getHeight(); - operation_type = this.itemProtocol.getOperation_type(); - direction = this.itemProtocol.getDirection(); - hasGoods = this.itemProtocol.getMove(); - barcode = this.itemProtocol.getBarcode(); - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - if (move == 0) { - thingToNothing(); - } - } - if (error != last_error) { - } - if (mode == 2 && move != 0 && task > 0) { - //inst_message - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst != null) { - inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); - if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex()) && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - instructionService.update(inst); - } - if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex()) && StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - finish_instruction(); - } - } - } - - if (!StrUtil.equals(this.getBarcode(), "0")) { - message = this.getBarcode(); - } - } catch (Exception var17) { - return; - } - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - 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 (hasGoods > 0 && !StrUtil.equals("0", barcode) && height > 0 && !requireSucess) { - instruction_require(barcode); - } - if (hasGoods > 0 && !StrUtil.equals("0", barcode) && height > 0 && !applySucess) { - instruction_apply(barcode); - } - break; - default: - break; - } - switch (flag) { - //取货完成 - case 1: - writing(2); - break; - //放货完成 - case 2: - writing(3); - break; - default: - break; - } - } - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - } - - private void forametPlcBarcode(int[] plcbarcode) { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < plcbarcode.length; i++) { - int a = plcbarcode[i]; - sb.append(stringToascii(a)); - } - foramteBarcode = sb.toString(); - } - - public String stringToascii(int num) { - String str = ""; - switch (num) { - case 48: - str = "0"; - break; - case 49: - str = "1"; - break; - case 50: - str = "2"; - break; - case 51: - str = "3"; - break; - case 52: - str = "4"; - break; - case 53: - str = "5"; - break; - case 54: - str = "6"; - break; - case 55: - str = "7"; - break; - case 56: - str = "8"; - break; - case 57: - str = "9"; - break; - case 65: - str = "A"; - break; - case 66: - str = "B"; - break; - case 67: - str = "C"; - break; - case 68: - str = "D"; - break; - case 69: - str = "E"; - break; - case 70: - str = "F"; - break; - case 71: - str = "G"; - break; - case 72: - str = "H"; - break; - case 73: - str = "I"; - break; - case 74: - str = "J"; - break; - case 75: - str = "K"; - break; - case 76: - str = "L"; - break; - case 77: - str = "M"; - break; - case 78: - str = "N"; - break; - case 79: - str = "O"; - break; - case 80: - str = "P"; - break; - case 81: - str = "Q"; - break; - case 82: - str = "R"; - break; - case 83: - str = "S"; - break; - case 84: - str = "T"; - break; - case 85: - str = "U"; - break; - case 86: - str = "V"; - break; - case 87: - str = "W"; - break; - case 88: - str = "X"; - break; - case 89: - str = "Y"; - break; - case 90: - str = "Z"; - break; - - case 97: - str = "a"; - break; - case 98: - str = "b"; - break; - case 99: - str = "c"; - break; - case 100: - str = "d"; - break; - case 101: - str = "e"; - break; - case 102: - str = "f"; - break; - case 103: - str = "g"; - break; - case 104: - str = "h"; - break; - case 105: - str = "i"; - break; - case 106: - str = "j"; - break; - case 107: - str = "k"; - break; - case 108: - str = "l"; - break; - case 109: - str = "m"; - break; - case 110: - str = "n"; - break; - case 111: - str = "o"; - break; - case 112: - str = "p"; - break; - case 113: - str = "q"; - break; - case 114: - str = "r"; - break; - case 115: - str = "s"; - break; - case 116: - str = "t"; - break; - case 117: - str = "u"; - break; - case 118: - str = "v"; - break; - case 119: - str = "w"; - break; - case 120: - str = "x"; - break; - case 121: - str = "y"; - break; - case 122: - str = "z"; - break; - - case 40: - str = "("; - break; - case 41: - str = ")"; - break; - case 43: - str = "+"; - break; - case 45: - str = "-"; - break; - case 47: - str = "/"; - break; - case 91: - str = "["; - break; - case 93: - str = "]"; - break; - case 95: - str = "_"; - break; - default: - str = ""; - } - - return str; - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - protected void thingToNothing() throws Exception { - this.setBarcode(null); - this.setRequireSucess(false); - this.setApplySucess(false); - writing(1, 0); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - this.control(itemMap); - - } - - public void executing(Server server, Map itemMap) { - this.control(itemMap); - } - - public void writing() { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_target, deviceAppservice.findDeviceByCode(inst.getNext_device_code()).getAddress()); - itemMap.put(to_task, inst.getInstruction_code()); - this.control(itemMap); - } - - public void writing(int command, int target, int task) { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - itemMap.put(to_target, target); - itemMap.put(to_task, task); - - this.control(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() - + "." + ItemProtocol.item_to_command; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - this.control(itemMap); - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_target, command); - - } else if (type == 3) { - itemMap.put(to_task, command); - } - - this.control(itemMap); - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - @Transactional(rollbackFor = Exception.class) - public synchronized boolean instruction_apply(String container_code) { - Date date = new Date(); - if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_apply_time = date; - //container_code - TaskDto task = taskserver.findByContainer(container_code); - if (!ObjectUtil.isEmpty(task) && StrUtil.equals(task.getTask_status(), TaskStatusEnum.READY.getIndex())) { - String taskid = task.getTask_id(); - String taskcode = task.getTask_code(); - String vehiclecode = task.getVehicle_code(); - String priority = task.getPriority(); - String start_point_code = task.getStart_point_code(); - String start_device_code = task.getStart_device_code(); - String route_plan_code = task.getRoute_plan_code(); - String next_device_code = ""; - - /** - * 开始平均分配 - */ - String this_coevice_code = taskserver.queryAssignedByDevice(device_code, task.getNext_device_code()); - if (StrUtil.isEmpty(this_coevice_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, task.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - if (!StrUtil.equals(type, "0")) { - return false; - } - 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 = task.getTo_x() + "-" + task.getTo_y() + "-" + task.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(task.getRemark()); - instdto.setMaterial(task.getMaterial()); - instdto.setQuantity(task.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); - instdto.setExecute_device_code(start_point_code); - try { - instructionService.create(instdto); - } catch (Exception e) { - task.setRemark("指令创建失败:" + e); - taskserver.updateByCodeFromCache(task); - throw new RuntimeException("指令创建失败:" + e); - } - //创建指令后修改任务状态 -// WQLObject taskwo = WQLObject.getWQLObject("acs_task"); - task.setTask_status(TaskStatusEnum.BUSY.getIndex()); - task.setRemark(null); -// JSONObject json = (JSONObject) JSONObject.toJSON(task); -// taskwo.update(json); - - Task entity = ConvertUtil.convert(task, Task.class); - taskMapper.updateById(entity); - - applySucess = true; - } else { - log.info("未找到载具号{}对应任务", barcode); - } - } - return true; - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - @Transactional(rollbackFor = Exception.class) - public synchronized boolean instruction_require(String container_code, String container_type) { - 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; - //container_code - TaskDto task = taskserver.findByContainer(container_code); - if (!ObjectUtil.isEmpty(task) && StrUtil.equals(task.getTask_status(), TaskStatusEnum.READY.getIndex())) { - String taskid = task.getTask_id(); - String taskcode = task.getTask_code(); - String vehiclecode = task.getVehicle_code(); - String priority = task.getPriority(); - String start_point_code = task.getStart_point_code(); - String start_device_code = task.getStart_device_code(); - String route_plan_code = task.getRoute_plan_code(); - String next_device_code = ""; - - /** - * 开始平均分配 - */ - String this_coevice_code = taskserver.queryAssignedByDevice(device_code, task.getNext_device_code()); - if (StrUtil.isEmpty(this_coevice_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, task.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - if (!StrUtil.equals(type, "0")) { - return false; - } - 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 = task.getTo_x() + "-" + task.getTo_y() + "-" + task.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(task.getRemark()); - instdto.setMaterial(task.getMaterial()); - instdto.setQuantity(task.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); - instdto.setExecute_device_code(start_point_code); - try { - instructionService.create(instdto); - } catch (Exception e) { - task.setRemark("指令创建失败:" + e); - taskserver.updateByCodeFromCache(task); - throw new RuntimeException("指令创建失败:" + e); - } - //创建指令后修改任务状态 -// WQLObject taskwo = WQLObject.getWQLObject("acs_task"); - task.setTask_status(TaskStatusEnum.BUSY.getIndex()); - task.setRemark(null); -// JSONObject json = (JSONObject) JSONObject.toJSON(task); -// taskwo.update(json); - - Task entity = ConvertUtil.convert(task, Task.class); - taskMapper.updateById(entity); - requireSucess = true; - applySucess = true; - } else { - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { - //String str = acsToWmsService.applyTaskToWms(this.getDeviceCode(), container_code, height, 0); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "接口不通"; - } else { - if (jo.getInteger("status") == 200) { - requireSucess = true; - } else { - requireSucess = false; - } - } - - } - } - return true; - } - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String action = ""; - String move = ""; - if (this.getMode() == 0) { - mode = "未联机"; - } else if (this.getMode() == 1) { - mode = "单机"; - } else if (this.getMode() == 2) { - mode = "联机"; - } else if (this.getMode() == 3) { - mode = "运行中"; - } - - if (this.getMove() == 0) { - move = "无货"; - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = "有货"; - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = "有托盘有货"; - jo.put("hasGoods", true); - } - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = CommonFinalParam.ONE; - } - String applySucess = "0"; - if (this.applySucess) { - applySucess = CommonFinalParam.ONE; - } - jo.put("requireSucess", requireSucess); - jo.put("applySucess", applySucess); - jo.put("driver_type", "standard_conveyor_control_with_scanner"); - jo.put("is_click", true); - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("action", action); - jo.put("isOnline", this.getIsonline()); - jo.put("error", this.getError()); - jo.put("isError", this.getIserror()); - jo.put("task", this.getTask()); - return jo; - } - - @Override - public void setDeviceStatus(JSONObject data) { - String requestSucess = data.getString("requireSucess"); - if (StrUtil.equals(requestSucess, "0")) { - this.requireSucess = false; - } else if (StrUtil.equals(requestSucess, CommonFinalParam.ONE)) { - this.requireSucess = true; - } - } - - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/ItemProtocol.java deleted file mode 100644 index 6cee0a0..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/ItemProtocol.java +++ /dev/null @@ -1,181 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_scanner; - -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_carrier_direction = "carrier_direction"; - /** - * 报警 - */ - public static String item_error = "error"; - /** - * 任务号 - */ - public static String item_task = "task"; - /** - * 条码长度 - */ - public static String item_barcode_length = "barcode_length"; - /** - * 条码 - */ - public static String item_barcode = "barcode"; - - - /** - * 行走列 - */ - 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_strap_times = "to_strap_times"; - /** - *木箱长度 - */ - public static String item_to_length = "to_length"; - /** - *木箱宽度 - */ - public static String item_to_weight = "to_weight"; - /** - *木箱高度 - */ - public static String item_to_height = "to_height"; - - - private StandardCoveyorControlWithScannerDeviceDriver driver; - - public ItemProtocol(StandardCoveyorControlWithScannerDeviceDriver 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_carrier_direction); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getBarCode_length() { - return this.getOpcIntegerValue(item_barcode_length); - } - - public String getplcBarCode() { - return this.getOpcStringValue(item_barcode); - } - - - 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 "0"; - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB101.B0")); - list.add(new ItemDto(item_mode, "工作模式", "DB101.B252")); - list.add(new ItemDto(item_move, "光电信号", "DB101.B253")); - list.add(new ItemDto(item_carrier_direction, "托盘方向", "DB101.B254")); - list.add(new ItemDto(item_error, "报警信号", "DB101.B256")); - list.add(new ItemDto(item_task, "任务号", "DB101.D260")); - list.add(new ItemDto(item_barcode_length, "条码长度", "DB101.B800")); - list.add(new ItemDto(item_barcode, "条码", "DB101.STRING802.50")); - - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "DB102.W252")); - list.add(new ItemDto(item_to_target, "下发目标站", "DB102.W254")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB102.D258")); -// list.add(new ItemDto(item_to_strap_times, "捆扎次数", "DB102.W12")); -// list.add(new ItemDto(item_to_length, "木箱长度", "DB102.W14")); -// list.add(new ItemDto(item_to_weight, "木箱宽度", "DB102.W16")); -// list.add(new ItemDto(item_to_height, "木箱高度", "DB102.W18")); - return list; - } - - - @Override - public String toString() { - return ""; - } - - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/StandardConveyorControlWithScannerDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/StandardConveyorControlWithScannerDefination.java deleted file mode 100644 index 059adc3..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/StandardConveyorControlWithScannerDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_scanner; - -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 StandardConveyorControlWithScannerDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_conveyor_control_with_scanner"; - } - - @Override - public String getDriverName() { - return "标准版-输送机-控制点-关联扫码"; - } - - @Override - public String getDriverDescription() { - return "标准版-输送机-控制点-关联扫码"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardCoveyorControlWithScannerDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardCoveyorControlWithScannerDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/StandardConveyorWithScannerConfig.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/StandardConveyorWithScannerConfig.java deleted file mode 100644 index 43a939f..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/StandardConveyorWithScannerConfig.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_scanner; - -public class StandardConveyorWithScannerConfig { - public static String relation_scanner = "link_scanner"; - public static String ignoreInstructionCheck = "ignoreInstructionCheck"; - public static String empty_tray_in = "emptyTrayIn"; - public static String empty_tray_out = "emptyTrayOut"; - public static String execute_time_out = "executeTimeOut"; - - public StandardConveyorWithScannerConfig() { - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java deleted file mode 100644 index 55cb4ab..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java +++ /dev/null @@ -1,888 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_scanner; - -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.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.RouteableDeviceDriver; -import org.nl.acs.device_driver.ScannerDeviceDriver; -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.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.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.enums.TaskStatusEnum; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.config.SpringContextHolder; -import org.nl.system.service.param.ISysParamService; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 输送机控制点-带扫描驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); - - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); - - @Autowired - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - String container; - - protected String barcode = null; - protected String formatcode = null; - - 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; - /** - * 当前指令 - */ - Instruction inst = null; - int heartbeat = 0; - int mode = 0; - int move = 0; - int action = 0; - int error = 0; - int task = 0; - String plcbarcode = null; - String last_plcbarcode = null; - int plcbarcode_length = 0; - int last_plcbarcode_length = 0; - - Boolean isonline = true; - - Boolean iserror = false; - - /** - * 1-执行任务;2-取货完成;3-放货完成; - */ - int flag; - - int last_mode = 0; - int last_move = 0; - int last_error = 0; - int last_task = 0; - String last_container; - String inst_message; - String device_code; - - String message; - - /** - * 请求成功标记 - */ - Boolean requireSucess = false; - - /** - * 申请成功标记 - */ - Boolean applySucess = false; - - public boolean exe_declaration() { - try { - this.barcode = this.barcode(); - this.formatcode = this.formatBarcode(); - return true; - } catch (Exception var3) { - String message = "获取条码异常"; - return false; - } - } - - public String formatBarcode() throws Exception { - String barcode = this.barcode(); - if (!StrUtil.isEmpty(barcode)) { - barcode = barcode.trim(); - } - - return barcode; - } - - public String barcode() { - ScannerDeviceDriver scanner = this.getScanner(); - return scanner.readBarcode(); - } - - public void clearBarcode() { - ScannerDeviceDriver scanner = this.getScanner(); - scanner.cleanBarcode(); - logServer.deviceExecuteLog(this.device_code, "", "", "清理条码"); - } - - public synchronized boolean finish_instruction() { - try { - instructionService.finish(inst); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - return true; - } - - private ScannerDeviceDriver getScanner() { - String scanner_code = (String) this.getDevice().getExtraValue().get(StandardConveyorWithScannerConfig.relation_scanner); - if (StrUtil.isEmpty(scanner_code)) { - log.error("未配置读码器"); -// throw new Exception("未配置读码器"); - } else { - Device device = deviceAppservice.findDeviceByCode(scanner_code); - if (device == null) { -// throw new Exception("无设备:" + scanner_code); - log.error("无设备:" + scanner_code); - } else { - DeviceDriver deviceDriver = device.getDeviceDriver(); - if (!(deviceDriver instanceof ScannerDeviceDriver)) { -// throw new Exception("扫码器类型不对,不是ScannerDeviceDriver"); - log.error("扫码器类型不对,不是ScannerDeviceDriver"); - } else { - ScannerDeviceDriver driver = (ScannerDeviceDriver) deviceDriver; - return driver; - } - } - } - return null; - } - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - try { - device_code = this.getDeviceCode(); - heartbeat = this.itemProtocol.getHeartbeat(); - mode = this.itemProtocol.getMode(); - move = this.itemProtocol.getMove(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - plcbarcode = this.itemProtocol.getplcBarCode(); - plcbarcode_length = this.itemProtocol.getBarCode_length(); - - if (mode != last_mode) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记"); - if (mode == 2) { - this.setRequireSucess(false); - this.setApplySucess(false); - message = null; - } - } - if (move != last_move) { - if (move == 0) { - message = null; - inst_message = null; - clearBarcode(); - thingToNothing(); - } - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (error != last_error) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (plcbarcode_length != last_plcbarcode_length) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号plcbarcode_length:" + last_plcbarcode_length + "->" + plcbarcode_length); - } - if (!StrUtil.equals(plcbarcode, last_plcbarcode)) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号plcbarcode:" + last_plcbarcode + "->" + plcbarcode); - } - - if (task != last_task) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); - } - if (mode == 2 && move != 0 && task > 0) { - //inst_message - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst != null) { - inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); - if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex()) && StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - inst.setExecute_device_code(this.device_code); - finish_instruction(); - } - if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex()) && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - inst.setExecute_device_code(this.device_code); - instructionService.update(inst); - } - } - } - - } catch (Exception var17) { - return; - } - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - 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: - //申请任务 - String newBarcode = null; - - if (!StrUtil.isEmpty(barcode())) { - newBarcode = barcode(); - } else { - // - if (plcbarcode_length > 2) { - newBarcode = plcbarcode; - } else { - break; - } - } - - if (move > 0 && !StrUtil.isEmpty(newBarcode) && !requireSucess) { - instruction_require(newBarcode.trim()); - } - if (move > 0 && !StrUtil.isEmpty(newBarcode) && !applySucess) { - instruction_apply(newBarcode.trim()); - } - default: - break; - } - switch (flag) { - //取货完成 - case 1: - writing(2); - break; - //放货完成 - case 2: - writing(3); - break; - default: - break; - } - } - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - last_plcbarcode_length = plcbarcode_length; - last_plcbarcode = plcbarcode; - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() throws Exception { - this.setBarcode(null); - this.setRequireSucess(false); - this.setApplySucess(false); - applySucess = false; - clearBarcode(); - this.set_last_container(container); - 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 map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", "0"); - list.add(map3); - Map map4 = new HashMap(); - map4.put("code", "to_strap_times"); - map4.put("value", "0"); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_length"); - map5.put("value", "0"); - list.add(map5); - Map map6 = new HashMap(); - map6.put("code", "to_weight"); - map6.put("value", "0"); - list.add(map6); - Map map7 = new HashMap(); - map7.put("code", "to_height"); - map7.put("value", "0"); - list.add(map7); - this.writing(list); - message = null; - } - - public void set_last_container(String barcode) { - this.setContainer(null); - } - - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - public void executing(Server server, Map itemMap) { - this.control(itemMap); - } - - public void writing(int command, int target, int task) { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - itemMap.put(to_target, target); - itemMap.put(to_task, task); - - 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() - + "." + ItemProtocol.item_to_command; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - this.control(itemMap); - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_target, command); - - } else if (type == 3) { - itemMap.put(to_task, command); - } - - - this.control(itemMap); - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - public synchronized boolean instruction_apply(String container_code) { - Date date = new Date(); - if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_apply_time = date; - //container_code - TaskDto task = taskserver.findByContainer(container_code); - if (!ObjectUtil.isEmpty(task)) { - Instruction instdto = instructionService.findByTaskcodeAndStatus(task.getTask_code()); - if (!StrUtil.equals(instdto.getStart_device_code(), this.device_code)) { - message = "当前载具号" + container_code + "查找对应指令起点与当前设备不符"; -// this.setIserror(true); - return false; - } - if (ObjectUtil.isNotEmpty(instdto)) { - List list = new ArrayList(); - Map map = new HashMap(); - - if (StrUtil.isNotEmpty(task.getTo_z())) { - if (StrUtil.equals(task.getTo_z(), "01")) { - map.put("code", "to_target"); - map.put("value", "102"); - } else if (StrUtil.equals(task.getTo_z(), "02")) { - map.put("code", "to_target"); - map.put("value", "201"); - } else if (StrUtil.equals(task.getTo_z(), "03")) { - map.put("code", "to_target"); - map.put("value", "301"); - } - } - 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", CommonFinalParam.ONE); - list.add(map3); - this.writing(list); - message = "下发电气任务号成功"; - requireSucess = true; - applySucess = true; - } else { - message = "任务号:" + task.getTask_code() + "未找到指令"; - } - - } else { - log.info("未找到载具号{}对应任务", container_code); - } - } - return true; - } - - /** - * 请求指令 - * 定点任务时请求这里 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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; - //container_code - TaskDto taskdto = taskserver.findByContainer(container_code); - if (!ObjectUtil.isEmpty(taskdto)) { - if (!ObjectUtils.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))) { - logServer.deviceExecuteLog(this.device_code, "", "", "申请任务时该载具号" + container_code - + "已存在对应任务,不再请求"); - Instruction instdto = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()); - if (!StrUtil.equals(instdto.getStart_device_code(), this.device_code)) { - message = "当前载具号" + container_code + "查找对应指令起点与当前设备不符"; - logServer.deviceExecuteLog(this.device_code, "", "", "申请任务" - + "当前载具号" + container_code + "查找对应指令起点与当前设备不符"); -// this.setIserror(true); -// List list = new ArrayList(); -// Map map = new HashMap(); -// map.put("code","to_target"); -// map.put("value","1011"); -// list.add(map); -// Map map2 = new HashMap(); -// map2.put("code","to_command"); -// map2.put("value",CommonFinalParam.ONE); -// Map map3 = new HashMap(); -// map3.put("code","to_task"); -// map3.put("value","0"); -// list.add(map3); -// this.writing(list); -// this.setRequireSucess(true); -// this.setApplySucess(true); - return false; - } - this.setIserror(false); - if (ObjectUtil.isNotEmpty(instdto)) { - List list = new ArrayList(); - Map map = new HashMap(); - - if (StrUtil.isNotEmpty(taskdto.getTo_z())) { - if (StrUtil.equals(taskdto.getTo_z(), "01")) { - map.put("code", "to_target"); - map.put("value", "102"); - } else if (StrUtil.equals(taskdto.getTo_z(), "02")) { - map.put("code", "to_target"); - map.put("value", "201"); - } else if (StrUtil.equals(taskdto.getTo_z(), "03")) { - map.put("code", "to_target"); - map.put("value", "301"); - } - } - 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", CommonFinalParam.ONE); - list.add(map3); - this.writing(list); - message = "下发电气任务号成功"; - logServer.deviceExecuteLog(this.device_code, "", "", "申请任务时该载具号" + container_code - + "已存在对应任务,下发电气信号"); -// if(task != Integer.parseInt(instdto.getInstruction_code()) ){ -// this.writing(list); -// logServer.deviceExecuteLog(device_code, "", "", instdto.getInstruction_code() + "再次下发电气信号"); -// } - requireSucess = true; - applySucess = true; - } else { - message = "任务号:" + taskdto.getTask_code() + "未找到指令"; - } - 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("->"); -// if (!StrUtil.equals(type, "0")) { -// return false; -// } - 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; - } - - if (!StrUtil.equals(taskdto.getStart_device_code(), this.device_code)) { - message = "当前载具号" + container_code + "查找对应指令起点与当前设备不符"; -// List list = new ArrayList(); -// Map map = new HashMap(); -// map.put("code","to_target"); -// map.put("value","1011"); -// list.add(map); -// Map map2 = new HashMap(); -// map2.put("code","to_command"); -// map2.put("value",CommonFinalParam.ONE); -// Map map3 = new HashMap(); -// map3.put("code","to_task"); -// map3.put("value","0"); -// list.add(map3); -// this.writing(list); -// this.setRequireSucess(true); -// this.setApplySucess(true); - return false; - } - 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("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); - 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); - - - List list = new ArrayList(); - Map map = new HashMap(); - - if (StrUtil.isNotEmpty(taskdto.getTo_z())) { - if (StrUtil.equals(taskdto.getTo_z(), "01")) { - map.put("code", "to_target"); - map.put("value", "102"); - } else if (StrUtil.equals(taskdto.getTo_z(), "02")) { - map.put("code", "to_target"); - map.put("value", "201"); - } else if (StrUtil.equals(taskdto.getTo_z(), "03")) { - map.put("code", "to_target"); - map.put("value", "301"); - } - } - 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", CommonFinalParam.ONE); - list.add(map3); - this.writing(list); -// if(task != Integer.parseInt(instdto.getInstruction_code()) ){ -// this.writing(list); -// logServer.deviceExecuteLog(device_code, "", "", instdto.getInstruction_code() + "再次下发电气信号"); -// } - requireSucess = true; - applySucess = true; - } else { - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { - message = "申请任务中..."; - JSONObject apply = new JSONObject(); - apply.put("vehicle_code", container_code); - apply.put("device_code", device_code); - apply.put("type", CommonFinalParam.ONE); - String str = acsToWmsService.applyTaskToWms(apply); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "接口不通"; - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_target"); - map.put("value", "1011"); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_command"); - map2.put("value", CommonFinalParam.ONE); - Map map3 = new HashMap(); - map3.put("code", "to_task"); - map3.put("value", "0"); - list.add(map3); - this.writing(list); - message = "申请任务失败接口不通下发退回"; - } else { - if (jo.getInteger("status") == 200) { - message = "申请任务成功"; - requireSucess = true; - applySucess = false; - } else { - if (jo.get("message") != null) { - message = jo.get("message").toString(); - } - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_target"); - map.put("value", "1011"); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_command"); - map2.put("value", CommonFinalParam.ONE); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_task"); - map3.put("value", "0"); - list.add(map3); - this.writing(list); - message = "申请任务失败下发退回," + message; - requireSucess = true; - - } - } -// requireSucess = true; -// message = "申请任务成功"; - } - } - return true; - } - } - - - 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; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - - itemMap.put(to_param, Integer.parseInt(value)); -// itemMap.put(to_param, Integer.parseInt(value)); - this.control(itemMap); - - } - - public void writing(List list) { - -// String opcservcerid = this.getDevice().getOpc_server_id(); -// Server server = ReadUtil.getServer(opcservcerid); - 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); - this.control(itemMap); - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String action = ""; - String move = ""; - if (this.getMode() == 0) { - mode = "未联机"; - } else if (this.getMode() == 1) { - mode = "单机"; - } else if (this.getMode() == 2) { - mode = "联机"; - } else if (this.getMode() == 3) { - mode = "运行中"; - } - if (this.getAction() == 0) { - action = "禁止取放"; - } else if (this.getAction() == 1) { - action = "允许取货"; - } else if (this.getAction() == 2) { - action = "允许放货"; - } else if (this.getAction() == 3) { - action = "允许取放"; - } - if (this.getMove() == 0) { - move = "无货"; - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = "有货"; - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = "有托盘有货"; - jo.put("hasGoods", true); - } - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("driver_type", "standard_conveyor_control_with_scanner"); - jo.put("mode", mode); - jo.put("move", move); - jo.put("action", action); - jo.put("is_click", true); - jo.put("isOnline", this.getIsonline()); - jo.put("error", this.getError()); - jo.put("isError", this.getIserror()); - jo.put("message", this.getMessage()); - jo.put("inst_message", this.inst_message); - jo.put("task", this.getTask()); - jo.put("barcode", plcbarcode); - jo.put("barcode_length", plcbarcode_length); - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = CommonFinalParam.ONE; - } - jo.put("requireSucess", requireSucess); - String applySucess = "0"; - if (this.applySucess) { - applySucess = CommonFinalParam.ONE; - } - jo.put("applySucess", applySucess); - - return jo; - } - - @Override - public void setDeviceStatus(JSONObject data) { - String requestSucess = data.getString("requireSucess"); - System.out.println(requestSucess); - if (StrUtil.equals(requestSucess, "0")) { - this.requireSucess = false; - } else if (StrUtil.equals(requestSucess, CommonFinalParam.ONE)) { - this.requireSucess = true; - } - String applySucess = data.getString("applySucess"); - if (StrUtil.equals(applySucess, "0")) { - this.applySucess = false; - } else if (StrUtil.equals(applySucess, CommonFinalParam.ONE)) { - this.applySucess = true; - } - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/ItemProtocol.java deleted file mode 100644 index cb14d82..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/ItemProtocol.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_inspect_site; - -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_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - public static String item_weight = "weight"; - public static String item_material_type = "material_type"; - public static String item_barcode = "barcode"; - - private StandardInspectSiteDeviceDriver driver; - - public ItemProtocol(StandardInspectSiteDeviceDriver 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 getMaterialType() { - return this.getOpcIntegerValue(item_material_type); - } - - public int getBarcode() { - return this.getOpcIntegerValue(item_barcode); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - /** - *是否有货 - */ - public int hasGoods(int move) { - return move; - } - - 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 static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB600.B3")); - list.add(new ItemDto(item_action, "取放信号", "DB600.B4")); - list.add(new ItemDto(item_material_type, "物料类型", "DB600.D6")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B7")); - list.add(new ItemDto(item_barcode, "条码", "DB600.D8")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - return list; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDefination.java deleted file mode 100644 index 6836e0b..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_inspect_site; - -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 StandardInspectSiteDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_inspect_site"; - } - - @Override - public String getDriverName() { - return "标准版-检测站点"; - } - - @Override - public String getDriverDescription() { - return "标准版-检测站点"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardInspectSiteDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardInspectSiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java deleted file mode 100644 index f863371..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java +++ /dev/null @@ -1,464 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_inspect_site; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -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.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.instruction.domain.Instruction; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.monitor.DeviceStageMonitor; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.domain.Task; -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.acs.task.service.mapper.TaskMapper; -import org.nl.acs.utils.ConvertUtil; -import org.nl.common.utils.CodeUtil; -import org.nl.config.SpringContextHolder; -import org.openscada.opc.lib.da.Server; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 检测站点驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - TaskMapper taskMapper; - - AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - /** - * 放货准备锁 - */ - String putReadyLock = null; - /** - * 有货标记 - */ - protected boolean has_goods_tag = false; - - private Date time = new Date(); - - int mode = 0; - int error = 0; - int move = 0; - int task = 0; - int action = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - int io_action = 0; - int last_io_action = 0; - int material_type = 0; - int last_material_type = 0; - int barcode = 0; - int last_barcode = 0; - - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - /** - * 备注 - */ - String remark; - /** - * 数量 - */ - String qty; - /** - * 物料 - */ - String material; - /** - * 批次 - */ - String batch; - /** - * 当前指令 - */ - Instruction inst = null; - /** - * 上次指令 - */ - Instruction last_inst = null; - - /** - * 触摸屏手动触发任务 - */ - private Boolean is_has_task = false; - - /** - * 满盅入库请求标记 - */ - boolean Sucess = false; - - /** - * 暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - */ - int flag; - - String devicecode; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - devicecode = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - hasGoods = this.itemProtocol.getMove(); - action = this.itemProtocol.getAction(); - material_type = this.itemProtocol.getMaterialType(); - barcode = this.itemProtocol.getBarcode(); - if (mode != last_mode) { - this.setRequireSucess(false); - if (mode == 2) { - this.writing(0); - } - } - if (move != last_move) { - } - if (error != last_error) { - } - - - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - break; - case 4: - //叫料 - if (move == 0 && !requireSucess) { - apply(4); - } - break; - case 5: - //满料出库 - if (move == 1 && !requireSucess) { - apply(5); - } - break; - case 6: - //申请空盘 - if (move == 0 && !requireSucess) { - apply(6); - } - break; - case 7: - //空托盘出库 - if (move == 1 && !requireSucess) { - apply(7); - } - break; - default: - break; - } - - switch (flag) { - //取货完成 - case 1: - writing(2); - return; - //放货完成 - case 2: - writing(3); - return; - default: - break; - } - - } - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - last_material_type = material_type; - last_barcode = barcode; - - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - this.control(itemMap); - - } - - 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() - + "." + ItemProtocol.item_to_command; - - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - this.control(itemMap); - - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_target, command); - - } else if (type == 3) { - itemMap.put(to_task, command); - } - this.control(itemMap); - - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status(TaskStatusEnum.READY.getIndex()); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - -// WQLObject wo = WQLObject.getWQLObject("acs_task"); -// JSONObject json = (JSONObject) JSONObject.toJSON(dto); -// -// wo.insert(json); - - Task entity = ConvertUtil.convert(dto, Task.class); - taskMapper.insert(entity); - requireSucess = false; - return true; - } - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String action = ""; - String move = ""; - if (this.getMode() == 0) { - mode = "未联机"; - } else if (this.getMode() == 1) { - mode = "单机"; - } else if (this.getMode() == 2) { - mode = "联机"; - } else if (this.getMode() == 3) { - mode = "运行中"; - } - - if (this.getMove() == 0) { - move = "无货"; - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = "有货"; - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = "有托盘有货"; - jo.put("hasGoods", true); - } - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("action", action); - jo.put("isOnline", this.getIsonline()); - jo.put("error", this.getError()); - jo.put("isError", this.getIserror()); - jo.put("task", this.getTask()); - return jo; - } - - @Override - public void setDeviceStatus(JSONObject data) { - - } - - /** - * lms申请任务 - * - * @param - */ - public synchronized boolean apply(Integer type) { - return false; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDefination.java deleted file mode 100644 index d43e874..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_ordinary_site; - -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.DeviceDriverDefination; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 普通站点定义 - */ -@Service -public class StandardOrdinarySiteDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_ordinary_site"; - } - - @Override - public String getDriverName() { - return "标准版-无光电普通站点"; - } - - @Override - public String getDriverDescription() { - return "标准版-无光电普通站点"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardOrdinarySiteDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardOrdinarySiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java deleted file mode 100644 index 6347845..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java +++ /dev/null @@ -1,257 +0,0 @@ -package org.nl.acs.device_driver.conveyor.standard_ordinary_site; - -import cn.hutool.core.util.ObjectUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.NDCAgvService; -import org.nl.acs.common.base.CommonFinalParam; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; -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.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.task.service.TaskService; -import org.nl.config.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; - - -/** - * 普通站点 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); - @Autowired - NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class); - - - Integer hasGoods = 0; - int error = 0; - Boolean iserror = false; - Boolean islock = false; - - int branchProtocol = 0; - int last_branchProtocol = 0; - /** - * 是否需要输入物料 - */ - String input_material = "0"; - /** - * 备注 - */ - String remark = ""; - /** - * 数量 - */ - String qty = ""; - /** - * 批次 - */ - String batch = ""; - /** - * 物料 - */ - String material = ""; - /** - * 目标点位 - */ - String purpose = ""; - /** - * 当前指令 - */ - Instruction inst = null; - /** - * 上次指令 - */ - Instruction last_inst = null; - - boolean requireSucess = false; - - /** - * 触摸屏手动触发任务 - */ - private Boolean is_has_task = false; - - /** - * 申请搬运任务 - */ - private Boolean apply_handling = false; - /** - * 申请物料 - */ - private Boolean apply_material = false; - - /** - * 1取货完成 2放货完成 3进入区域 4离开区域 - */ - private int flag; - - /** - * 人工确认信号 默认0 agv到达后请求置1 等人工确认后变为2 反馈agv后继续为0 - */ - private int manua_confirm = 0; - - String device_code = null; - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - - String message; - - // 1 上位系统允许进入 2 上位系统允许离开 - int status = 0; - - int agvphase = 0; - int index = 0; - - int mode = 2; - - int move; - - @Override - public void execute() { - hasGoods = this.getDevice().getHas_goods(); - batch = this.getDevice().getBatch(); - device_code = this.getDeviceCode(); - - if (agvphase == 0x03) { - if (ObjectUtil.isNotEmpty(inst)) { - inst.setExecute_status(CommonFinalParam.ONE); - instructionService.update(inst); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0, 0, 0, 0, 0); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈"); - - } - } - - if (agvphase == 0x05) { - if (ObjectUtil.isNotEmpty(inst)) { - inst.setExecute_status("2"); - instructionService.update(inst); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0, 0, 0, 0, 0); -// OneNDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈"); - - } - } - - if (agvphase == 0x07) { - if (ObjectUtil.isNotEmpty(inst)) { - inst.setExecute_status("5"); - instructionService.update(inst); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0, 0, 0, 0, 0); -// OneNDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈"); - } - } - - if (agvphase == 0x09) { - if (ObjectUtil.isNotEmpty(inst)) { - inst.setExecute_status("6"); - instructionService.update(inst); - byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0, 0, 0, 0, 0); -// OneNDCSocketConnectionAutoRun.write(data); - agvphase = 0; - index = 0; - inst = null; - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "反馈成功"); - } else { - logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + agvphase + "等待反馈"); - - } - } - - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String action = ""; - String move = ""; - if (this.getMode() == 0) { - mode = "未联机"; - } else if (this.getMode() == 1) { - mode = "单机"; - } else if (this.getMode() == 2) { - mode = "联机"; - } else if (this.getMode() == 3) { - mode = "运行中"; - } - - if (this.getMove() == 0) { - move = "无货"; - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = "有货"; - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = "有托盘有货"; - jo.put("hasGoods", true); - } - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("action", action); - jo.put("isOnline", true); - jo.put("error", this.getError()); - jo.put("isError", this.getIserror()); - return jo; - } - - - @Override - public void setDeviceStatus(JSONObject data) { - - } -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java index d5f3ec3..e8510fa 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/ExecutableDeviceDriver.java @@ -3,25 +3,15 @@ package org.nl.acs.device_driver.driver; import org.nl.acs.device_driver.DeviceDriver; public interface ExecutableDeviceDriver extends DeviceDriver { - /** - * executeAuto - * @throws Exception - */ - default void executeAuto() throws Exception { -// try { -// this.execute(); -// } catch (Throwable var6) { -// String message = "线程调用异常:" + var6.getMessage(); -// Log.error(message); -// } finally { -// } - this.execute(); + default void executeAuto() { + try { + this.execute(); + } catch (Throwable var6) { + String message = "线程调用异常:" + var6.getMessage(); + } finally { + } } - /** - * execute - * @throws Exception - */ void execute() throws Exception; } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/ItemProtocol.java deleted file mode 100644 index 680130d..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/ItemProtocol.java +++ /dev/null @@ -1,159 +0,0 @@ -package org.nl.acs.device_driver.paper_tube_pick_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_error = "error"; - //物料 - public static String item_material = "material"; - //物料直径 - public static String item_size = "size"; - //物料长度 - public static String item_len = "len"; - //明细数量 - public static String item_Itemized_qty = "Itemized_qty"; - - //下发命令 - public static String item_to_command = "to_command"; - //下发物料类型 - public static String item_to_material = "to_material"; - //下发命令 - public static String item_to_size = "to_size"; - //下发命令 - public static String item_to_len = "to_len"; - //下发命令 - public static String item_to_qty = "to_qty"; - - private PaperTubePickSiteDeviceDriver driver; - - public ItemProtocol(PaperTubePickSiteDeviceDriver 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 getQty() { - return this.getOpcIntegerValue(item_qty); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public String getMaterial() { - return this.getOpcStringValue(item_material); - } - - public int getSize() { - return this.getOpcIntegerValue(item_size); - } - - public int getLen() { - return this.getOpcIntegerValue(item_len); - } - - public int getItemized_qty() { - return this.getOpcIntegerValue(item_Itemized_qty); - } - - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public String getTo_material() { - return this.getOpcStringValue(item_to_material); - } - - public int getTo_size() { - return this.getOpcIntegerValue(item_to_size); - } - - public int getTo_len() { - return this.getOpcIntegerValue(item_to_len); - } - - public int getTo_qty() { - return this.getOpcIntegerValue(item_to_qty); - } - - 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)) { - - } else { - 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, "报警", "DB1001.B4")); - list.add(new ItemDto(item_qty, "总数量", "DB1001.B5")); - list.add(new ItemDto(item_material, "物料类型", "DB1.B6")); - list.add(new ItemDto(item_size, "物料直径", "DB1.B7")); - list.add(new ItemDto(item_len, "物料长度", "DB1.B8")); - list.add(new ItemDto(item_Itemized_qty, "物料明细数量", "DB1.B9")); - 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_material, "下发物料类型", "DB2.W2")); - list.add(new ItemDto(item_to_size, "下发物料直径", "DB2.W4")); - list.add(new ItemDto(item_to_len, "下发物料长度", "DB2.W6")); - list.add(new ItemDto(item_to_qty, "下发物料数量", "DB2.W8")); - return list; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDefination.java deleted file mode 100644 index 7908f8c..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDefination.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.nl.acs.device_driver.paper_tube_pick_site; - -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.nl.acs.device_driver.two_conveyor.pull_head_manipulator.ItemProtocol; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -@Service -public class PaperTubePickSiteDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "paper_tube_pick_size"; - } - - @Override - public String getDriverName() { - return "纸管抓取位"; - } - - @Override - public String getDriverDescription() { - return "纸管抓取位"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new PaperTubePickSiteDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return PaperTubePickSiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDeviceDriver.java deleted file mode 100644 index cd0105a..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDeviceDriver.java +++ /dev/null @@ -1,238 +0,0 @@ -package org.nl.acs.device_driver.paper_tube_pick_site; - -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -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.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -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.service.TaskService; -import org.nl.config.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class PaperTubePickSiteDeviceDriver 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); - - 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; - - //工作模式 - int mode = 0; - int last_mode = 0; - //光电信号 - int move = 0; - int last_move = 0; - //动作信号 - int action = 0; - int last_action = 0; - //总数量 - int qty = 0; - int last_qty = 0; - //物料类型 - String material = null; - String last_material = null; - //物料直径 - int size =0; - int last_size =0; - //物料长度 - int len = 0; - int last_len = 0; - //物料明细数量 - int Itemized_qty = 0; - int last_Itemized_qty = 0; - //报警信号 - int error = 0; - int last_error = 0; - int heartbeat = 0; - int last_heartbeat = 0; - - - int to_command = 0; - int last_to_command = 0; - //下发物料类型 - String to_material =null; - String last_to_material =null; - //下发物料直径 - int to_size = 0; - int last_to_size = 0; - //下发物料长度 - int to_len=0; - int last_to_len=0; - //下发物料数量 - int to_qty=0; - int last_to_qty=0; - - - Boolean isonline = true; - - Boolean iserror = false; - - /** - * 1-执行任务;2-取货完成;3-放货完成; - */ - int flag; - - String device_code; - - @Override - public Device getDevice() { - return this.device; - } - - /** - * 请求成功标记 - */ - Boolean requireSucess = false; - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - action = this.itemProtocol.getAction(); - if (mode != last_mode) { - this.setRequireSucess(false); - if (mode == 2) { - this.writing(0); - } - } - if (move != last_move) { - } - if (error != last_error) { - } - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - break; - case 3: - break; - default: - break; - } - - switch (flag) { - //取货完成 - case 1: - writing(3); - return; - //放货完成 - case 2: - writing(5); - return; - default: - break; - } - - } - - } - - protected void thingToNothing() { - this.setRequireSucess(false); - } - - 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; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - this.control(itemMap); - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String action = ""; - String move = ""; - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", "联机"); - jo.put("action", action); - jo.put("isOnline", true); - jo.put("error", this.getError()); - jo.put("isError", this.getIserror()); - return jo; - } - - @Override - public void setDeviceStatus(JSONObject data) { - - } - - - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/scanner/standard_scanner/StandardScannerDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/scanner/standard_scanner/StandardScannerDefination.java deleted file mode 100644 index e37eb35..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/scanner/standard_scanner/StandardScannerDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.scanner.standard_scanner; - -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.DeviceDriverDefination; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 扫码器 - */ -@Service -public class StandardScannerDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_scanner"; - } - - @Override - public String getDriverName() { - return "标准版-扫码器"; - } - - @Override - public String getDriverDescription() { - return "标准版-扫码器"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardScannerDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardScannerDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.scanner); - return types; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/scanner/standard_scanner/StandardScannerDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/scanner/standard_scanner/StandardScannerDeviceDriver.java deleted file mode 100644 index fe793d8..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/scanner/standard_scanner/StandardScannerDeviceDriver.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.nl.acs.device_driver.scanner.standard_scanner; - -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.ScannerDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; -import org.nl.acs.monitor.DeviceStageMonitor; -import org.nl.acs.socket.SocketConfig; -import org.nl.acs.udw.UnifiedDataAccessor; -import org.nl.acs.udw.UnifiedDataAccessorFactory; - -/** - * 标准版扫码器 - */ -@Slf4j -@Data -public class StandardScannerDeviceDriver extends AbstractDeviceDriver - implements ScannerDeviceDriver, DeviceDriver, DeviceStageMonitor { - - UnifiedDataAccessor accessor_value; - - public StandardScannerDeviceDriver() { - this.accessor_value = UnifiedDataAccessorFactory.getAccessor(SocketConfig.udw_unit_key); - } - - public String getIp() { - String ip = (String) this.getDevice().getExtraValue().get("scannerIP"); - return StrUtil.isEmpty(ip) ? null : ip; - } - - @Override - public String readBarcode() { - String ip = this.getIp(); - if (StrUtil.isEmpty(ip)) { - // throw new Exception("ip未配置"); - log.error("ip未配置"); - } else { - String result = (String) this.accessor_value.getValue(this.getIp()); - return result; - } - return null; - } - - @Override - public void writeBarcode(String barcode) { - String ip = this.getIp(); - if (StrUtil.isEmpty(ip)) { - // throw new Exception("ip未配置"); - log.error("ip未配置"); - } else { - this.accessor_value.setValueWithPersistence(this.getIp(), barcode); - } - } - - @Override - public void cleanBarcode() { - String ip = this.getIp(); - if (StrUtil.isEmpty(ip)) { - log.error("ip未配置"); - // throw new Exception("ip未配置"); - } else { - this.accessor_value.setValueWithPersistence(this.getIp(), (Object) null); - } - } - - @Override - public JSONObject getDeviceStatusName() throws Exception { - JSONObject jo = new JSONObject(); - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("isOnline", true); - jo.put("device_type", device.getDevice_type()); - // 点击弹出 - jo.put("is_click", true); - jo.put("ip", this.getIp()); - jo.put("container", StrUtil.isEmpty(this.readBarcode()) ? "" : this.readBarcode()); - return jo; - } - - @Override - public void setDeviceStatus(JSONObject data) { - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java deleted file mode 100644 index 1fbee0e..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java +++ /dev/null @@ -1,470 +0,0 @@ -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 java.util.ArrayList; -import java.util.List; - -@Slf4j -@Data -public class ItemProtocol { - - /** - * 心跳 - */ - public static String item_heartbeat = "heartbeat"; - - /** - * 堆垛机号 - */ - public static String item_deviceCode = "deviceCode"; - - /** - * 工作模式 - */ - 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_move = "move"; - - /** - * 载货台开关信号 - */ - 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"; - - /** - * 货叉位置信号 - */ - public static String item_forkLocation = "forkLocation"; - - /** - * 货叉动作信号 - */ - public static String item_forkAction = "forkAction"; - /** - * 特殊开关量1 - */ - public static String item_special1 = "special1"; - /** - * 特殊开关量2 - */ - public static String item_special2 = "special2"; - /** - * 托盘条码 - */ - public static String item_trayCode = "trayCode"; - /** - * 水箱和消防缓存位有无货 - */ - 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_stacker_workingHours = "stacker_workingHours"; - /** - * 载货台速度(转/分钟) - */ - public static String item_cargo_rpm = "cargo_rpm"; - /** - * 载货台电流 - */ - public static String item_cargo_electric_Current = "cargo_electric Current"; - /** - * 载货台轴工作小时数 - */ - public static String item_cargo_workingHours = "cargo_workingHours"; - /** - * 载货台轴运行次数 - */ - public static String item_cargo_runingTimes = "cargo_runingTimes"; - /** - * 货叉速度(转/分钟 - */ - public static String item_fork_rpm = "fork_rpm"; - /** - * 货叉电流 - */ - public static String item_fork_electric_Current = "fork_electric Current"; - - /** - * 货叉轴工作时间(小时 - */ - public static String item_fork_workingHours = "fork_workingHours"; - /** - * 货叉轴运行次数 - */ - public static String item_fork_runingTimes = "fork_runingTimes"; - - /** - * 心跳 - */ - 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"; - /** - * 托盘号 - */ - public static String item_to_trayCode = "to_trayCode"; - - - Boolean isonline; - - private StandardStackerDeviceDriver driver; - - public ItemProtocol(StandardStackerDeviceDriver driver) { - this.driver = driver; - } - - public Integer getItem_heartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public Integer getItem_deviceCode() { - return this.getOpcIntegerValue(item_deviceCode); - } - - public Integer getItem_mode() { - return this.getOpcIntegerValue(item_mode); - } - - ; - - 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_move() { - return this.getOpcFloatValue(item_move); - } - - 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_forkLocation() { - return this.getOpcFloatValue(item_forkLocation); - } - - public float getItem_forkAction() { - return this.getOpcFloatValue(item_forkAction); - } - - public float getItem_special1() { - return this.getOpcFloatValue(item_special1); - } - - public float getItem_special2() { - return this.getOpcFloatValue(item_special2); - } - - public int[] getItem_trayCode() { - return this.getOpcIntegerArrayValue(item_trayCode); - } - - 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_workingHours() { - return this.getOpcIntegerValue(item_stacker_workingHours); - } - - public Integer getItem_stacker_runing_time() { - return this.getOpcIntegerValue(item_stacker_runing_time); - } - - public Integer getItem_cargo_rpm() { - return this.getOpcIntegerValue(item_cargo_rpm); - } - - public Integer getItem_cargo_electric_Current() { - return this.getOpcIntegerValue(item_cargo_electric_Current); - } - - public Integer getItem_cargo_workingHours() { - return this.getOpcIntegerValue(item_cargo_workingHours); - } - - public Integer getItem_cargo_runingTimes() { - return this.getOpcIntegerValue(item_cargo_runingTimes); - } - - public Integer getItem_fork_rpm() { - return this.getOpcIntegerValue(item_fork_rpm); - } - - public Integer getItem_fork_electric_Current() { - return this.getOpcIntegerValue(item_fork_electric_Current); - } - - public Integer getItem_fork_workingHours() { - return this.getOpcIntegerValue(item_fork_workingHours); - } - - public Integer getItem_fork_runingTimes() { - return this.getOpcIntegerValue(item_fork_runingTimes); - } - - - 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 (value == null) { - setIsonline(false); - return "0"; - } else { - setIsonline(true); - return value; - } - } - - 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 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.B3")); - list.add(new ItemDto(item_task, "任务号", "DB101.D4")); - list.add(new ItemDto(item_error, "Y轴报警(载货台)", "DB101.B8")); - list.add(new ItemDto(item_z, "行走排号", "DB101.B9")); - list.add(new ItemDto(item_x, "行走列号", "DB101.B10")); - list.add(new ItemDto(item_y, "行走层号", "DB101.B11")); - list.add(new ItemDto(item_move, "行走开关信号", "DB101.B12")); - list.add(new ItemDto(item_cargoMove, "载货台开关信号", "DB101.B13")); - list.add(new ItemDto(item_action, "行走动作信号", "DB101.B14")); - list.add(new ItemDto(item_distancex, "行走激光数值", "DB101.D16")); - list.add(new ItemDto(item_distancey, "起升激光数值", "DB101.D20")); - list.add(new ItemDto(item_cargoError, "载货台超限信号", "DB101.B24")); - list.add(new ItemDto(item_forkCargo, "货叉探货信号", "DB101.B25")); - list.add(new ItemDto(item_forkLocation, "货叉位置信号", "DB101.B26")); - list.add(new ItemDto(item_forkAction, "货叉动作信号", "DB101.B27")); - list.add(new ItemDto(item_special1, "特殊开关量1", "DB101.B28")); - list.add(new ItemDto(item_special2, "特殊开关量2", "DB101.B29")); - list.add(new ItemDto(item_trayCode, "托盘条码", "DB101.B30.20")); - 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_workingHours, "轴工作时间(小时)", "DB101.D56")); - list.add(new ItemDto(item_stacker_runing_time, "轴运行次数", "DB101.D60")); - list.add(new ItemDto(item_cargo_rpm, "载货台速度(转/分钟)", "DB101.W64")); - list.add(new ItemDto(item_cargo_electric_Current, "载货台电流", "DB101.W66")); - list.add(new ItemDto(item_cargo_workingHours, "载货台轴工作小时数", "DB101.D68")); - list.add(new ItemDto(item_cargo_runingTimes, "载货台轴运行次数", "DB101.D72")); - list.add(new ItemDto(item_fork_rpm, "货叉速度(转/分钟)", "DB101.W76")); - list.add(new ItemDto(item_fork_electric_Current, "货叉电流", "DB101.W78")); - list.add(new ItemDto(item_fork_workingHours, "货叉轴工作时间(小时)", "DB101.D80")); - list.add(new ItemDto(item_fork_runingTimes, "货叉轴运行次数", "DB101.D84")); - 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.D4")); - list.add(new ItemDto(item_to_z, "作业排", "DB100.B8")); - list.add(new ItemDto(item_to_x, "作业列", "DN100.B9")); - list.add(new ItemDto(item_to_y, "作业层", "DB100.B10")); - list.add(new ItemDto(item_to_trayCode, "托盘号", "DB100.B11.20")); - return list; - } - - - @Override - public String toString() { - return ""; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDefination.java deleted file mode 100644 index cbd46bf..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDefination.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.nl.acs.device_driver.stacker.standard_stacker; - -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 StandardStackerDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_stacker"; - } - - @Override - public String getDriverName() { - return "标准版-单工位堆垛机"; - } - - @Override - public String getDriverDescription() { - return "标准版-单工位堆垛机"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardStackerDeviceDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return StandardStackerDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.stacker); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java deleted file mode 100644 index f739f12..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java +++ /dev/null @@ -1,962 +0,0 @@ -package org.nl.acs.device_driver.stacker.standard_stacker; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -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.enums.DeviceType; -import org.nl.acs.device.enums.ErrorType; -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.history.ErrorUtil; -import org.nl.acs.history.service.DeviceErrorLogService; -import org.nl.acs.history.service.dto.DeviceErrorLogDto; -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.route.service.impl.RouteLineServiceImpl; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.config.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; -import java.util.regex.Pattern; - -/** - * 单工位堆垛机驱动 - */ -@Slf4j -@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); - - /** - * 心跳 - */ - Integer heartbeat = 0; - Integer last_heartbeat = 0; - /** - * 堆垛机号 - */ - Integer item_deviceCode = 0; - Integer last_item_deviceCode = 0; - /** - * 工作模式 - */ - Integer mode = 0; - Integer last_mode = 0; - /** - *作业状态 - */ - Integer command = 0; - Integer last_command = 0; - /** - * 任务号 - */ - Integer task = 0; - Integer last_task = 0; - /** - * y轴报警(载货台) - */ - Integer error = 0; - Integer last_error = 0; - /** - * 行走排号 - */ - Integer z = 0; - Integer last_z = 0; - /** - * 行走列 - */ - Integer x = null; - Integer last_x = null; - /** - * 行走层号 - */ - Integer y = 0; - Integer last_y = 0; - /** - * 行走开关信号 - */ - Float move = 0F; - Float last_move = 0F; - /** - * 载货台开关信号 - */ - Float cargoMove = 0F; - Float last_cargoMove = 0F; - /** - * 行走动作信号 - */ - Float action = 0F; - Float last_action = 0F; - /** - * 行走激光数值 - */ - Integer distancex = 0; - Integer last_distancex = 0; - /** - * 起升激光数值 - */ - Integer distancey = 0; - Integer last_distancey = 0; - /** - *载货台超限信号 - */ - Float cargoError = 0F; - Float last_cargoError = 0F; - /** - *货叉探货信号 - */ - Float forkCargo = 0F; - Float last_forkCargo = 0F; - /** - *货叉位置信号 - */ - Float forkLocation = 0F; - Float last_forkLocation = 0F; - /** - *货叉动作信号 - */ - Float forkAction = 0F; - Float last_forkAction = 0F; - /** - * 特殊开关量1 - */ - Float special1 = 0F; - Float last_special1 = 0F; - /** - * 特殊开关量2 - */ - Float special2 = 0F; - Float last_special2 = 0F; - /** - *托盘条码 - */ - int[] trayCode; - int[] last_trayCode; - /** - * 水箱和消防缓存位有无货 - */ - Float storage_cache = 0F; - Float last_storage_cache = 0F; - /** - * 速度(转/分钟) - */ - Integer stacker_rpm = 0; - Integer last_stacker_rpm = 0; - /** - * 电流 - */ - Integer stacker_electricCurrent = 0; - Integer last_stacker_electricCurrent = 0; - /** - * 轴运行次数 - */ - Integer stacker_runing_time = 0; - Integer last_stacker_runing_time = 0; - /** - * 轴工作时间(小时) - */ - Integer stacker_workingHours = 0; - Integer last_stacker_workingHours = 0; - /** - *载货台速度(转/分钟) - */ - Integer cargo_rpm = 0; - Integer last_cargo_rpm = 0; - /** - *载货台电流 - */ - Integer cargo_electric_Current = 0; - Integer last_cargo_electric_Current = 0; - /** - *载货台轴工作小时数 - */ - Integer cargo_workingHour = 0; - Integer last_cargo_workingHour = 0; - /** - *载货台轴运行次数 - */ - Integer cargo_runingTimes = 0; - Integer last_cargo_runingTimes = 0; - /** - *货叉速度(转/分钟 - */ - Integer fork_rpm = 0; - Integer last_fork_rpm = 0; - /** - *货叉电流 - */ - Integer fork_electric_Current = 0; - Integer last_fork_electric_Current = 0; - /** - *货叉轴工作时间(小时 - */ - Integer fork_workingHours = 0; - Integer last_fork_workingHours = 0; - /** - *货叉轴运行次数 - */ - Integer fork_runingTimes = 0; - Integer last_fork_runingTimes = 0; - - String message = null; - - String device_code = null; - - String notCreateInstMessage = null; - - private int instruction_require_time_out = 3000; - private int instruction_update_time_out = 3000; - private Date instruction_require_time = new Date(); - private Date instruction_update_time = new Date(); - List getDeviceCodeList = null; - List putDeviceCodeList = null; - - /** - * 请求成功标记 - */ - Boolean requireSucess = false; - - /** - * 当前指令 - */ - Instruction inst = null; - - - @Override - public Device getDevice() { - return this.device; - } - - @Override - 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(); - move = this.itemProtocol.getItem_move(); - 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(); - forkLocation = this.itemProtocol.getItem_forkLocation(); - forkAction = this.itemProtocol.getItem_forkAction(); - special1 = this.itemProtocol.getItem_special1(); - special2 = this.itemProtocol.getItem_special2(); - trayCode = this.itemProtocol.getItem_trayCode(); - storage_cache = this.itemProtocol.getItem_storage_cache(); - /*stacker_rpm = this.itemProtocol.getstacker_rpm(); - stacker_electricCurrent = this.itemProtocol.getstacker_electricCurrent(); - stacker_runing_time = this.itemProtocol.getstacker_runing_time(); - stacker_workingHours = this.itemProtocol.getstacker_workingHours(); - cargo_rpm = this.itemProtocol.getcargo_rpm(); - cargo_electric_Current = this.itemProtocol.getcargo_electric_Current(); - cargo_workingHour = this.itemProtocol.getcargo_workingHours(); - cargo_runingTimes = this.itemProtocol.getcargo_runingTimes(); - fork_rpm = this.itemProtocol.getfork_rpm(); - fork_electric_Current = this.itemProtocol.getfork_electric_Current(); - fork_workingHours = this.itemProtocol.getfork_workingHours(); - fork_runingTimes = this.itemProtocol.getfork_runingTimes();*/ - - if (!item_deviceCode.equals(last_item_deviceCode)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(item_deviceCode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_item_deviceCode + "->" + item_deviceCode); - } - if (!mode.equals(last_mode)) { - requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (!command.equals(last_command)) { - requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(command)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号command:" + last_command + "->" + command); - } - if (!task.equals(last_task)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); - } - if (!error.equals(last_error)) { - if (0 != error) { - DeviceErrorLogDto acsDeviceErrorLog = new DeviceErrorLogDto(); - acsDeviceErrorLog.setDevice_code(this.device_code); - acsDeviceErrorLog.setError_code(String.valueOf(error)); - String errorInfo = ErrorUtil.getDictDetail(ErrorType.STACKER_ERROR.getErrorType(), String.valueOf(error)); - acsDeviceErrorLog.setError_info(errorInfo); - errorLogServer.create(acsDeviceErrorLog); - } - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (!z.equals(last_z)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(z)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号z:" + last_z + "->" + z); - } - if (!x.equals(last_x)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(x)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号z:" + last_x + "->" + x); - } - if (!y.equals(last_y)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(y)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号y:" + last_y + "->" + y); - } - if (!move.equals(last_move)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (!cargoMove.equals(last_cargoMove)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(cargoMove)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号cargoMove:" + last_cargoMove + "->" + cargoMove); - } - if (!action.equals(last_action)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(action)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); - } - if (!distancex.equals(last_distancex)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(distancex)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号distancex:" + last_distancex + "->" + distancex); - } - if (!distancey.equals(last_distancey)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(distancey)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号distancey:" + last_distancey + "->" + distancey); - } - if (!cargoError.equals(last_cargoError)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(cargoError)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号cargoError:" + last_cargoError + "->" + cargoError); - } - if (!forkCargo.equals(last_forkCargo)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(forkCargo)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号forkCargo:" + last_forkCargo + "->" + forkCargo); - } - if (!forkLocation.equals(last_forkLocation)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(forkLocation)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号forkLocation:" + last_forkLocation + "->" + forkLocation); - } - if (!forkAction.equals(last_forkAction)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(forkAction)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号forkAction:" + last_forkAction + "->" + forkAction); - } - if (!special1.equals(last_special1)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(special1)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号special1:" + last_special1 + "->" + special1); - } - if (!special2.equals(last_special2)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(special2)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号special2:" + last_special2 + "->" + special2); - } - if (!Arrays.equals(trayCode, last_trayCode)) { - logServer.deviceItemValue(this.device_code, "mode", Arrays.toString(trayCode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号trayCode:" + Arrays.toString(last_trayCode) + "->" + Arrays.toString(trayCode)); - } - if (!storage_cache.equals(last_storage_cache)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(storage_cache)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号storage_cache:" + last_storage_cache + "->" + storage_cache); - } - /*if (!stacker_rpm.equals(last_stacker_rpm)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(stacker_rpm)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_stacker_rpm + "->" + stacker_rpm); - } - if (!stacker_electricCurrent.equals(last_stacker_electricCurrent)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(stacker_electricCurrent)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_stacker_electricCurrent + "->" + stacker_electricCurrent); - } - if (!stacker_runing_time.equals(last_stacker_runing_time)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(stacker_runing_time)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_stacker_runing_time + "->" + stacker_runing_time); - } - if (!stacker_workingHours.equals(last_stacker_workingHours)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(stacker_workingHours)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_stacker_workingHours + "->" + stacker_workingHours); - } - if (!cargo_rpm.equals(last_cargo_rpm)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(stacker_workingHours)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_cargo_rpm + "->" + cargo_rpm); - } - if (!cargo_electric_Current.equals(last_cargo_electric_Current)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(cargo_electric_Current)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_cargo_electric_Current + "->" + cargo_electric_Current); - } - if (!cargo_workingHour.equals(last_cargo_workingHour)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(cargo_workingHour)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_cargo_workingHour + "->" + cargo_workingHour); - } - if (!cargo_runingTimes.equals(last_cargo_runingTimes)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(cargo_runingTimes)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_cargo_runingTimes + "->" + cargo_runingTimes); - } - if (!fork_rpm.equals(last_fork_rpm)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(fork_rpm)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_fork_rpm + "->" + fork_rpm); - } - if (!fork_electric_Current.equals(last_fork_electric_Current)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(fork_electric_Current)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_fork_electric_Current + "->" + fork_electric_Current); - } - if (!fork_workingHours.equals(last_fork_workingHours)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(fork_workingHours)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_fork_workingHours + "->" + fork_workingHours); - } - if (!fork_runingTimes.equals(last_fork_runingTimes)) { - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(fork_runingTimes)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_fork_runingTimes + "->" + fork_runingTimes); - }*/ - - // 更新指令状态 - if (mode == 3 && task > 0) { - 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); - } - } - } - } - } - - } catch (Exception var17) { - var17.printStackTrace(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); - } - - - if (mode != 3 || requireSucess) { - message = "未联机或已修改"; - - } else if (error != 0) { - message = "有报警"; - //指定库位满入 - if (error == 5) { - - } - //空出 - if (error == 6) { - - } - //浅货位有货 - if (error == 16) { - //放货 - if (cargoMove == 1) { - - } else if (cargoMove == 0) { - //取货 - } - - - } - } else { - Map map = new LinkedHashMap<>(); - switch (command) { - case 0: - boolean b = applyTask(); - if (b) { - requireSucess = true; - } - break; - case 1: - message = "取货中"; - break; - case 2: - message = "取货完成"; - Instruction instruction = checkInst(); - String next_device_code = instruction.getNext_device_code(); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - if (StrUtil.equals(nextDevice.getDevice_type(), DeviceType.conveyor.name())) { - if (ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("z"))) { - map.put("to_x", nextDevice.getExtraValue().get("z")); - } - if (ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("x"))) { - map.put("to_z", nextDevice.getExtraValue().get("x")); - } - if (ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("y"))) { - map.put("to_y", nextDevice.getExtraValue().get("y")); - } - } - if (StrUtil.equals(nextDevice.getDevice_type(), DeviceType.storage.name())) { - String pattern = "\\d+"; - Pattern compile = Pattern.compile(pattern); - map.put("to_y", inst.getTo_z()); - if (inst.getTo_x().length() > 1 && !compile.matcher(inst.getTo_x()).matches()) { - String substring = inst.getTo_x().substring(1); - map.put("to_z", substring); - } else { - map.put("to_z", inst.getTo_x()); - } - map.put("to_x", inst.getTo_y()); - } - map.put("to_command", 2); - requireSucess = true; - break; - case 3: - message = "放货中"; - break; - case 4: - message = "请求卸货(申请卸货)"; - Instruction instruction1 = checkInst(); - String next_device_code1 = instruction1.getNext_device_code(); - Device nextDevice1 = deviceAppService.findDeviceByCode(next_device_code1); - if (ObjectUtil.isNotNull(instruction1)) { - //指令为执行 - SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; - if (nextDevice1.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) nextDevice1.getDeviceDriver(); - if (siemensConveyorDeviceDriver.getMode() != 2 || siemensConveyorDeviceDriver.getMove() == 1) { - notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + siemensConveyorDeviceDriver.getDevice_code() + - "有货或未联机,无法下发指令!指令号:" + inst.getInstruction_code(); - return; - } - } - map.put("to_command", 3); - } - requireSucess = true; - break; - case 5: - message = "放货完成"; - map.put("to_command", 5); - Instruction inst = checkInst(); - try { - finish_instruction(inst); - } catch (Exception e) { - e.printStackTrace(); - } - requireSucess = true; - break; - case 6: - message = "取货准备(会库位台)"; - map.put("to_command", 6); - requireSucess = true; - break; - case 7: - message = "召回"; - map.put("to_command", 7); - requireSucess = true; - break; - case 8: - message = "急停"; - map.put("to_command", 8); - requireSucess = true; - break; - default: - message = "不明"; - requireSucess = true; - break; - } - if (ObjectUtil.isNotNull(map)) { - this.writing(map); - } - - } - last_heartbeat = heartbeat; - last_item_deviceCode = item_deviceCode; - last_mode = mode; - last_command = command; - last_task = task; - last_error = error; - last_z = z; - last_x = x; - last_y = y; - last_move = move; - last_cargoMove = cargoMove; - last_action = action; - last_distancex = distancex; - last_distancey = distancey; - last_cargoError = cargoError; - last_forkCargo = forkCargo; - last_forkLocation = forkLocation; - last_forkAction = forkAction; - last_special1 = special1; - last_special2 = special2; - last_trayCode = trayCode; - last_storage_cache = storage_cache; - /*last_stacker_rpm = stacker_rpm; - last_stacker_electricCurrent = stacker_electricCurrent; - last_stacker_runing_time = stacker_runing_time; - last_stacker_workingHours = stacker_workingHours; - last_cargo_rpm = cargo_rpm; - last_cargo_electric_Current = cargo_electric_Current; - last_cargo_workingHour = cargo_workingHour; - last_cargo_runingTimes = cargo_runingTimes; - last_fork_rpm = fork_rpm; - last_fork_electric_Current = fork_electric_Current; - last_fork_workingHours = fork_workingHours; - last_fork_runingTimes = fork_runingTimes;*/ - } - - - /** - * 申请任务 - * - * @param - */ - 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 { - this.instruction_require_time = date; - //输入:指令类型多种\ 指令状态多种\ - Instruction instruction1 = new Instruction(); - instruction1.setInstruction_status("0"); - List instructions = instructionService.findByDeviceCodes(instruction1, false); - if (CollUtil.isEmpty(instructions) || instructions.size() < 1) { - return false; - } - List instructionList = new ArrayList<>(); - for (Instruction instruction : instructions) { - List routeLineDtos = routeLineService.selectDeviceCodeList(instruction.getStart_device_code()); - if (CollUtil.isEmpty(routeLineDtos) || routeLineDtos.size() < 1) { - message = "没有输送线到堆垛机的路由"; - logServer.deviceExecuteLog(this.device_code, "", "", "没有" + instruction.getStart_device_code() + "->" - + this.device_code + "的路由"); - continue; - } - for (RouteLineDto routeLineDto : routeLineDtos) { - if (this.getDeviceCode().equals(routeLineDto.getNext_device_code())) { - List routeLineDtoList = routeLineService.selectDeviceCodeList(this.getDeviceCode()); - if (CollUtil.isEmpty(routeLineDtos) || routeLineDtos.size() < 1) { - message = "没有输送线到堆垛机的路由"; - logServer.deviceExecuteLog(this.device_code, "", "", "没有" + instruction.getStart_device_code() + "->" - + this.device_code + "的路由"); - continue; - } - for (RouteLineDto routeLinedto : routeLineDtoList) { - if (instruction.getNext_device_code().equals(routeLinedto.getNext_device_code())) { - instructionList.add(instruction); - } - } - } - } - } - if (CollUtil.isEmpty(instructionList) || instructionList.size() < 1) { - return false; - } - instructionList = this.sortInst(instructionList); - inst = instructionList.get(0); - //指令未执行 - if (StrUtil.equals(inst.getInstruction_status(), "0")) { - String start_device_code = inst.getStart_device_code(); - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - BeltConveyorDeviceDriver beltConveyorDeviceDriver; - if (startDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) startDevice.getDeviceDriver(); - if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 0) { - notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + beltConveyorDeviceDriver.getDevice_code() + - "无货或未联机,无法下发指令!指令号:" + inst.getInstruction_code(); - return false; - } - } - List list = new ArrayList(); - HashMap map = new HashMap(); - map.put("to_device_code", this.getDevice().getAddress()); - map.put("to_command", 1); -// map.put("to_type", inst.getMaterial()); - map.put("to_task", inst.getInstruction_code()); - - if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name())) { - if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("z"))) { - map.put("to_x", startDevice.getExtraValue().get("z")); - } - if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("x"))) { - map.put("to_z", startDevice.getExtraValue().get("x")); - } - if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("y"))) { - map.put("to_y", startDevice.getExtraValue().get("y")); - } - } - if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.storage.name())) { - map.put("to_y", inst.getFrom_z()); - if (inst.getFrom_x().length() > 1) { - String substring = inst.getFrom_x().substring(1); - map.put("to_z", substring); - } else { - map.put("to_z", inst.getFrom_x()); - } - map.put("to_x", inst.getFrom_y()); - } - if(ObjectUtil.isNotEmpty(map)){ - list.add(map); - this.writing(list); - } - - } - } - return true; - } - - /** - * 将指令根据优先级和创建时间排序 - * - * @param instructions - * @return - */ - private List sortInst(List instructions) { - Collections.sort(instructions, (t1, t2) -> { - //优先级从大到小 - int i = t2.getPriority().compareTo(t1.getPriority()); - //如果优先级相等 - if (i == 0) { - //时间从早到晚 - i = t1.getCreate_time().compareTo(t2.getCreate_time()); - } - return i; - }); - return instructions; - } - - /** - * 更新指令状态 - */ - 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; - //更改指令状态 - if (task > 0) { - //inst_message - 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); - } - } - } - List list = new ArrayList(); - HashMap map = new HashMap(); - //取货完成 - if (command == 2) { - map.put("to_command", 2); - } - //请求卸货(申请卸货) - if (command == 4) { - Instruction instruction = checkInst(); - if (ObjectUtil.isNotNull(instruction)) { - //指令为执行 - String next_device_code = instruction.getNext_device_code(); - Device startDevice = deviceAppService.findDeviceByCode(next_device_code); - SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; - if (startDevice.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) startDevice.getDeviceDriver(); - if (siemensConveyorDeviceDriver.getMode() != 2 || siemensConveyorDeviceDriver.getMove() == 1) { - notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + siemensConveyorDeviceDriver.getDevice_code() + - "有货或未联机,无法下发指令!指令号:" + inst.getInstruction_code(); - return; - } - } - map.put("to_command", 3); - } - } - //放货完成 - if (command == 5) { - map.put("to_command", 5); - try { - finish_instruction(inst); - } catch (Exception e) { - e.printStackTrace(); - } - } - //取货准备(回库台位) - if (command == 6) { - map.put("to_command", 6); - } - //召回 - if (command == 7) { - map.put("to_command", 7); - } - //急停 - if (command == 8) { - map.put("to_command", 8); - } - if(ObjectUtil.isNotEmpty(map)){ - list.add(map); - this.writing(list); - } - } - - } - - - @Override - public JSONObject getDeviceStatusName() throws Exception { - return null; - } - - @Override - public void setDeviceStatus(JSONObject data) { - - } - - - 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(); - try { - this.checkcontrol(itemMap); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - - } - /** - * 完成指令 - * - * @param inst - * @return - * @throws Exception - */ - public synchronized boolean finish_instruction(Instruction inst) throws Exception { - instructionService.finish(inst); - return true; - } - - public String getToParam() { - return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; - } - - /** - * 多个信号一起下发电气 - * - * @param map - */ - public void writing(Map map) { - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - Map itemMap = new LinkedHashMap<>(); - map.forEach((key, value) -> { - if (ObjectUtil.isNotEmpty(value)) { - itemMap.put(getToParam() + key, value); - } - }); - if (ObjectUtil.isNotEmpty(itemMap)) { - this.control(itemMap); - logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); - } - } - - public List sortTask(List taskDtos) { - Collections.sort(taskDtos, new Comparator() { - @Override - public int compare(TaskDto t1, TaskDto t2) { - //优先级从大到小 - int i = t2.getPriority().compareTo(t1.getPriority()); - //如果优先级相等 - if (i == 0) { - //时间从早到晚 - i = t1.getCreate_time().compareTo(t2.getCreate_time()); - } - return i; - } - }); - return taskDtos; - } - - - /** - * 将扩展表中的字符串数据转换成集合 - */ - @Override - public List getExtraDeviceCodes(String extraName) { - String extraValue = (String) this.getDevice().getExtraValue().get(extraName); - if (StrUtil.isEmpty(extraValue)) { - return new ArrayList<>(); - } - String devicesString = extraValue.substring(1, extraValue.length() - 1); - List devicesList = new ArrayList<>(); - String[] devices = devicesString.split(","); - for (int i = 0; i < devices.length; i++) { - String s = devices[i].replace("\"", "").replace("\"", ""); - devicesList.add(s); - } - return devicesList; - } - - 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/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDefination.java deleted file mode 100644 index d9e8e19..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDefination.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.blank_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 BlankManipulatorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "blank_manipulator"; - } - - @Override - public String getDriverName() { - return "表处下料-行架机械手"; - } - - @Override - public String getDriverDescription() { - return "表处下料-行架机械手"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new BlankManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return BlankManipulatorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.station); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDeviceDriver.java deleted file mode 100644 index 5e43e0b..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDeviceDriver.java +++ /dev/null @@ -1,623 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.blank_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 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.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -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.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.config.SpringContextHolder; -import org.nl.config.language.LangProcess; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 表处下料-行架机械手 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class BlankManipulatorDeviceDriver 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); - - //工作模式 - int mode = 0; - int last_mode = 0; - //光电信号 - int move = 0; - int last_move = 0; - //动作信号 - int action = 0; - int last_action = 0; - //行走列 - int walk_y = 0; - int last_walk_y = 0; - //报警信号 - int error = 0; - int last_error = 0; - //任务号 - int task = 0; - int last_task = 0; - - //重量 - int weight = 0; - int last_weight = 0; - - //条码 - int barcode = 0; - int last_barcode = 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_onset = 0; - int last_to_onset = 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; - - String notCreateTaskMessage = ""; - String notCreateInstMessage = ""; - String feedMessage = ""; - - - List getDeviceCodeList = null; - - List putDeviceCodeList = null; - - - @Override - public Device getDevice() { - return this.device; - } - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - move = this.itemProtocol.getMove(); - action = this.itemProtocol.getAction(); - walk_y = this.itemProtocol.getWalk_y(); - 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_onset = this.itemProtocol.getTo_onset(); - weight = this.itemProtocol.getWeight(); - barcode = this.itemProtocol.getBarcode(); - - if (to_onset != last_to_onset) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset:" + last_to_onset + "->" + to_onset); - } - if (to_command != last_to_command) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); - } - if (to_target != last_to_target) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); - } - if (to_task != last_to_task) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); - } - if (weight != last_weight) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号weight:" + last_weight + "->" + weight); - } - if (barcode != last_barcode) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号barcode:" + last_barcode + "->" + barcode); - } - if (mode != last_mode) { - requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (action != last_action) { - logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); - } - if (error != last_error) { - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (walk_y != last_walk_y) { - logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); - } - if (task != last_task) { - logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); - } - - // 更新指令状态 - if (mode == 3 && task > 0) { - 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 (mode == 3 && action == 5 && move == 1 && task > 0) { - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); - if (ObjectUtil.isNotEmpty(inst2)) { - Map map = new LinkedHashMap<>(); - //todo:反馈重量、条码 - map.put("to_command", "5"); - this.writing(map); - } else { - logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许取货(now_steps_type!=3)"); - } - } else { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "mode不为运行中状态,"; - } - if (action != 5) { - feedMessage = feedMessage + "action不为反馈重量状态,"; - } - if (move != 1) { - feedMessage = feedMessage + "move不为有货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "task为0。"; - } - } - - //任务完成 - if (mode == 3 && action == 6 && move == 0 && task > 0) { - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst2 != null) { - if (StrUtil.equals(inst2.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex())) { - try { - finish_instruction(inst2); - Map map = new LinkedHashMap<>(); - map.put("to_command", "6"); - this.writing(map); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } - - - } catch (Exception var17) { - var17.printStackTrace(); - feedMessage = var17.getMessage(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); - - } - - 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 == 2 && move == 0 && task == 0 && !requireSucess) { - boolean res = applyTask(); - if (res) { - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - feedMessage = ""; - } - } else { - if (mode == 2) { - //if (!requireSucess) { - String remark = "未查找任务原因为:"; - if (mode != 2) { - remark = remark + "工作模式(mode)不是待机状态,"; - } - if (move != 0) { - remark = remark + "光电信号(move)为有货状态,"; - } - if (task != 0) { - remark = remark + "当前上报任务号(task)应该为0,"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = remark + "请右击该图标,将请求任务复位标记(requireSucess)改为否。"; - } - this.setNotCreateTaskMessage(remark); - //} - } - } - - } - last_mode = mode; - last_move = move; - last_action = action; - last_walk_y = walk_y; - 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_onset = to_onset; - last_weight = weight; - last_barcode = barcode; - } - - - /** - * // * 申请任务 - * // * - * // * @param - * // - */ - 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 { - this.instruction_require_time = date; - //抓取工位 - List getDeviceCodeList = this.getExtraDeviceCodes("get_device_code"); - //放货工位 - List putDeviceCodeList = this.getExtraDeviceCodes("put_device_code"); - TaskDto task = null; - for (int i = 0; i < getDeviceCodeList.size(); i++) { - String startDeviceCode = getDeviceCodeList.get(i); - List taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtos)) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtos = this.sortTask(taskDtos); - TaskDto taskDto = taskDtos.get(0); - Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code()); - String start_device_code = instruction.getStart_device_code(); - String next_device_code = instruction.getNext_device_code(); - instruction.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - instruction.setUpdate_time(DateUtil.now()); - instructionService.update(instruction); - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { - throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice.getDevice_code())); - } - if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { - throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice.getDevice_code())); - } - String start_addr = startDevice.getExtraValue().get("address").toString(); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - Map map = new LinkedHashMap<>(); - map.put("to_command", CommonFinalParam.ONE); - map.put("to_onset", start_addr); - map.put("to_task", instruction.getInstruction_code()); - map.put("to_target", next_addr); - this.writing(map); - this.setRequireSucess(true); - return true; - } else { - List taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtoList)) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtoList = this.sortTask(taskDtoList); - task = taskDtoList.get(0); - } - if (ObjectUtil.isNotEmpty(task)) { - break; - } - } - } - if (!ObjectUtil.isEmpty(task)) { - String taskid = task.getTask_id(); - String taskcode = task.getTask_code(); - String vehiclecode = task.getVehicle_code(); - String priority = task.getPriority(); - String start_point_code = task.getStart_point_code(); - String start_device_code = task.getStart_device_code(); - String route_plan_code = task.getRoute_plan_code(); - String next_point_code = task.getNext_point_code(); - String next_device_code = task.getNext_device_code(); - - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(task.getRemark()); - instdto.setMaterial(task.getMaterial()); - instdto.setQuantity(task.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); - instdto.setExecute_device_code(start_point_code); - - try { - instructionService.create(instdto); - } catch (Exception e) { - notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); - return false; - } - //创建指令后修改任务状态 - task.setTask_status(TaskStatusEnum.BUSY.getIndex()); - task.setUpdate_time(DateUtil.now()); - taskserver.update(task); - - Device startDevice = deviceAppService.findDeviceByCode(instdto.getStart_device_code()); - Device nextDevice = deviceAppService.findDeviceByCode(instdto.getNext_device_code()); - if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { - notCreateInstMessage = "设备:" + startDevice.getDevice_code() + "未设置电气调度号!"; - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); - throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice.getDevice_code())); - } - if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { - notCreateInstMessage = "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"; - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); - throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice.getDevice_code())); - - } - String start_addr = startDevice.getExtraValue().get("address").toString(); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - Map map = new LinkedHashMap<>(); - map.put("to_command", CommonFinalParam.ONE); - map.put("to_onset", start_addr); - map.put("to_task", instdto.getInstruction_code()); - map.put("to_target", next_addr); - this.writing(map); - this.setRequireSucess(true); - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - } else { - notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; - } - return true; - } - } - - - public synchronized boolean finish_instruction(Instruction inst) throws Exception { - instructionService.finish(inst); - return true; - } - - public String getToParam() { - return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; - } - - /** - * 多个信号一起下发电气 - * - * @param map - */ - public void writing(Map map) { - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - Map itemMap = new LinkedHashMap<>(); - map.forEach((key, value) -> { - if (ObjectUtil.isNotEmpty(value)) { - itemMap.put(getToParam() + key, value); - } - }); - if (ObjectUtil.isNotEmpty(itemMap)) { - this.control(itemMap); - logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); - } - } - - public List sortTask(List taskDtos) { - Collections.sort(taskDtos, new Comparator() { - @Override - public int compare(TaskDto t1, TaskDto t2) { - //优先级从大到小 - int i = t2.getPriority().compareTo(t1.getPriority()); - //如果优先级相等 - if (i == 0) { - //时间从早到晚 - i = t1.getCreate_time().compareTo(t2.getCreate_time()); - } - return i; - } - }); - return taskDtos; - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String move = ""; - String action = ""; - String walk_y = ""; - if (this.getMode() == 0) { - mode = "脱机"; - } else if (this.getMode() == 1) { - mode = "单机"; - } else if (this.getMode() == 2) { - mode = "待机"; - } else if (this.getMode() == 3) { - mode = "运行中"; - } - - if (this.getMove() == 0) { - move = "无货"; - } else if (this.getMove() == 1) { - move = "有货"; - } - - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = "1"; - } - jo.put("requireSucess", requireSucess); - if (this.getAction() == 1) { - action = "取货中"; - } else if (this.getAction() == 2) { - action = "取货完成"; - } else if (this.getAction() == 3) { - action = "放货中"; - } else if (this.getAction() == 4) { - action = "放货完成"; - } - - 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("walk_y", walk_y); - jo.put("isOnline", this.getIsonline()); - jo.put("error", ErrorUtil.getDictDetail("hxhj_error_type", String.valueOf(this.getError()))); - jo.put("isError", this.getIserror()); - jo.put("message", this.getMessage()); - jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); - jo.put("feedMessage", feedMessage); - 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; - } - } - - @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/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/ItemProtocol.java deleted file mode 100644 index 673a89c..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/ItemProtocol.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.blank_manipulator; - -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_task = "task"; - //报警 - public static String item_error = "error"; - //行走列 - public static String item_walk_y = "walk_y"; - //条码 - public static String item_barcode = "barcode"; - //重量 - public static String item_weight = "weight"; - - - //下发命令 - public static String item_to_command = "to_command"; - //下发起始站 - public static String item_to_onset = "to_onset"; - //下发目标站 - public static String item_to_target = "to_target"; - //下发任务号 - public static String item_to_task = "to_task"; - - private BlankManipulatorDeviceDriver driver; - - public ItemProtocol(BlankManipulatorDeviceDriver 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 getWalk_y() { - return this.getOpcIntegerValue(item_walk_y); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getBarcode(){ - return this.getOpcIntegerValue(item_barcode); - } - - public int getWeight(){ - return this.getOpcIntegerValue(item_weight); - } - - public int getTo_task() { - return this.getOpcIntegerValue(item_to_task); - } - - public int getTo_onset() { - return this.getOpcIntegerValue(item_to_onset); - } - - 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) { - // 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 "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_walk_y, "行走列", "DB1.B4")); - list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); - list.add(new ItemDto(item_task, "任务号", "DB1.D6")); - list.add(new ItemDto(item_weight, "重量", "DB1.B7")); - list.add(new ItemDto(item_barcode, "条码", "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_onset, "下发起始站", "DB2.W2")); - list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); - return list; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/BlankingButtonDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/BlankingButtonDefination.java deleted file mode 100644 index 71c6130..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/BlankingButtonDefination.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.blanking_button; - -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 BlankingButtonDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "green_foil_machine_button"; - } - - @Override - public String getDriverName() { - return "下料按钮"; - } - - @Override - public String getDriverDescription() { - return "下料按钮"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new BlankingButtonDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return BlankingButtonDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/BlankingButtonDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/BlankingButtonDriver.java deleted file mode 100644 index 86e0438..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/BlankingButtonDriver.java +++ /dev/null @@ -1,327 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.blanking_button; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.AcsConfig; -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.data.BlankingButtonRequest; -import org.nl.acs.ext.wms.data.BlankingButtonResponse; -import org.nl.acs.ext.wms.service.AcsToWmsService; -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.task.service.TaskService; -import org.nl.config.SpringContextHolder; -import org.nl.system.service.param.ISysParamService; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 下料按钮 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class BlankingButtonDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - - @Autowired - ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); - - DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - - DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); - - private String error_type = "hx_error_type"; - - 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; - - public int heartbeat = 0; - public int mode = 0; - public int move = 0; - public int action = 0; - public int error = 0; - - public int last_heartbeat = 0; - public int last_mode = 0; - public int last_move = 0; - public int last_action = 0; - public int last_error = 0; - - Boolean isonline = true; - - Boolean iserror = false; - - - String device_code; - - String message = null; - - - @Override - public Device getDevice() { - return this.device; - } - - //请求成功标记 - Boolean requireSucess = false; - - @Override - public void execute() { - - device_code = this.getDeviceCode(); - heartbeat = this.itemProtocol.getItem_heartbeat(); - mode = this.itemProtocol.getItem_mode(); - move = this.itemProtocol.getItem_move(); - action = this.itemProtocol.getItem_action(); - error = this.itemProtocol.getItem_error(); - - if (mode != last_mode) { - requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (action != last_action) { - logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); - } - if (error != last_error) { - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - - - if (mode == 0) { - this.setIsonline(false); - message = "未联机"; - // 有报警 - // } else if (error != 0) { - // this.setIsonline(false); - // this.setIserror(true); - // message = "有报警"; - // //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - if (error != 0) { - this.setIserror(true); - message = "有报警"; - } - message = ""; - Instruction instruction = null; - List toInstructions; - - switch (mode) { - case 2: - log.debug("设备运转模式:等待工作"); - break; - case 3: - log.debug("设备运转模式:等待工作"); - break; - case 9: - // 表处下满料请求 - if (move > 0 && !requireSucess) { - applyTakeFullVolume(); - } - break; - case 10: - //表处上空轴请求 - if (move > 0 && !requireSucess) { - applyTakeEmptyShaft(); - } - break; - case 11: - // 取消任务 - if (move > 0 && !requireSucess) { - cancelTask(); - } - break; - default: - break; - } - } - - - last_mode = mode; - last_move = move; - last_action = action; - last_error = error; - - } - - /** - * 表处下满料请求 - */ - public synchronized void applyTakeFullVolume() { - 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 { - this.instruction_require_time = date; - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { - message = "申请下满料请求中..."; - BlankingButtonRequest blankingButtonRequest = new BlankingButtonRequest(); - blankingButtonRequest.setDevice_code(device_code); - blankingButtonRequest.setType("1"); - BlankingButtonResponse response = acsToWmsService.applyBlankButtonTask(blankingButtonRequest); - if (ObjectUtil.isEmpty(response)) { - message = "申请下满料任务接口不通"; - } else { - if (response.getCode()== 200) { - this.writing("to_command","9"); - message = "申请下满料任务成功"; - requireSucess = true; - } else { - requireSucess = false; - message = "申请下满料任务失败," + response.getMessage(); - this.writing("to_command","99"); - } - } - } - } - } - - /** - * 申请取消任务 - */ - public synchronized void applyTakeEmptyShaft() { - 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 { - this.instruction_require_time = date; - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { - message = "申请取消任务中..."; - BlankingButtonRequest blankingButtonRequest = new BlankingButtonRequest(); - blankingButtonRequest.setDevice_code(device_code); - blankingButtonRequest.setType("2"); - BlankingButtonResponse response = acsToWmsService.applyBlankButtonTask(blankingButtonRequest); - if (ObjectUtil.isEmpty(response)) { - message = "申请取消任务接口不通"; - } else { - if (response.getCode()== 200) { - this.writing("to_command","10"); - message = "申请取消任务成功"; - requireSucess = true; - } else { - requireSucess = false; - message = "申请取消任务失败," + response.getMessage(); - this.writing("to_command","99"); - } - } - } - } - } - - /** - * 取消任务 - */ - public synchronized void cancelTask() { - 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 { - this.instruction_require_time = date; - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { - message = "申请取消任务中..."; - BlankingButtonRequest blankingButtonRequest = new BlankingButtonRequest(); - blankingButtonRequest.setDevice_code(device_code); - blankingButtonRequest.setType("2"); - BlankingButtonResponse response = acsToWmsService.applyBlankButtonTask(blankingButtonRequest); - if (ObjectUtil.isEmpty(response)) { - message = "申请AGV搬运任务接口不通"; - } else { - if (response.getCode()== 200) { - this.writing("to_command","10"); - message = "申请AGV搬运任务成功"; - requireSucess = true; - } else { - requireSucess = false; - message = "申请AGV搬运任务失败," + response.getMessage(); - this.writing("to_command","99"); - } - } - } - } - } - - 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); - } - - - @Override - public JSONObject feedLmsRealFailedInfo() { - return null; - } - - @Override - public JSONObject getDeviceStatusName() throws Exception { - return null; - } - - @Override - public void setDeviceStatus(JSONObject data) { - - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/ItemProtocol.java deleted file mode 100644 index 2bb83e2..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/ItemProtocol.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.blanking_button; - -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_to_command = "to_command"; - - - private BlankingButtonDriver driver; - - public ItemProtocol(BlankingButtonDriver driver) { - this.driver = driver; - } - - public int getItem_heartbeat(){ - return this.getOpcIntegerValue(item_heartbeat); - } ; - public int getItem_mode(){ - return this.getOpcIntegerValue(item_mode); - } ; - public int getItem_move(){ - return this.getOpcIntegerValue(item_move); - } ; - public int getItem_action(){ - return this.getOpcIntegerValue(item_action); - }; - public int getItem_error(){ - return this.getOpcIntegerValue(item_error); - } ; - - 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) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0L; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "251")); - list.add(new ItemDto(item_mode, "工作模式", "7990")); - list.add(new ItemDto(item_move, "光电信号", "550")); - list.add(new ItemDto(item_action, "取放信号", "450")); - list.add(new ItemDto(item_error, "故障", "8055")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "40226")); - return list; - } - - @Override - public String toString() { - return ""; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDefination.java deleted file mode 100644 index 6503a8d..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDefination.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.green_foil_machine_button; - -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 GreenFoilMachineButtonDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "green_foil_machine_button"; - } - - @Override - public String getDriverName() { - return "生箔机按钮协议"; - } - - @Override - public String getDriverDescription() { - return "生箔机按钮协议"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new GreenFoilMachineButtonDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return GreenFoilMachineButtonDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDriver.java deleted file mode 100644 index 909f570..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDriver.java +++ /dev/null @@ -1,286 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.green_foil_machine_button; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.AcsConfig; -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.data.ApplyGreenFoilButtonRequest; -import org.nl.acs.ext.wms.data.ApplyGreenFoilButtonResponse; -import org.nl.acs.ext.wms.service.AcsToWmsService; -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.task.service.TaskService; -import org.nl.config.SpringContextHolder; -import org.nl.system.service.param.ISysParamService; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 生箔机按钮 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - - @Autowired - ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); - - DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - - DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); - - private String error_type = "hx_error_type"; - - 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; - - public int heartbeat = 0; - public int mode = 0; - public int move = 0; - public int action = 0; - public int error = 0; - - public int last_heartbeat = 0; - public int last_mode = 0; - public int last_move = 0; - public int last_action = 0; - public int last_error = 0; - - Boolean isonline = true; - - Boolean iserror = false; - - - String device_code; - - String message = null; - - - @Override - public Device getDevice() { - return this.device; - } - - //请求成功标记 - Boolean requireSucess = false; - - @Override - public void execute() { - - device_code = this.getDeviceCode(); - heartbeat = this.itemProtocol.getItem_heartbeat(); - mode = this.itemProtocol.getItem_mode(); - move = this.itemProtocol.getItem_move(); - action = this.itemProtocol.getItem_action(); - error = this.itemProtocol.getItem_error(); - if (mode != last_mode) { - requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (action != last_action) { - logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); - } - if (error != last_error) { - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - - if (mode == 0) { - this.setIsonline(false); - message = "未联机"; - // 有报警 - // } else if (error != 0) { - // this.setIsonline(false); - // this.setIserror(true); - // message = "有报警"; - // //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - if (error != 0) { - this.setIserror(true); - message = "有报警"; - } - message = ""; - Instruction instruction = null; - List toInstructions; - - switch (mode) { - case 2: - log.debug("设备运转模式:等待工作"); - break; - case 3: - log.debug("设备运转模式:等待工作"); - break; - case 4: - // 申请AGV取空取满放空放满任务 - if (move > 0 && !requireSucess) { - applyAgvTask(mode); - } - break; - case 5: - /** - * 申请AGV取空放空的任务 - */ - if (move > 0 && !requireSucess) { - applyAgvTask(mode); - } - break; - case 6: - // 申请取满放满任务 - if (move > 0 && !requireSucess) { - applyAgvTask(mode); - } - break; - case 7: - // 允许AGV进入 - if (move == 0 && !requireSucess) { - applyAgvTask(mode); - } - break; - case 8: - // 允许AGV离开 - if (move == 0 && !requireSucess) { - applyAgvTask(mode); - } - break; - case 9: - // 取消任务 - if (move == 0 && !requireSucess) { - applyAgvTask(mode); - } - break; - default: - break; - } - } - - - - last_mode = mode; - last_move = move; - last_action = action; - last_error = error; - - } - - /** - * 申请AGV任务 - */ - public synchronized void applyAgvTask(int mode) { - 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 { - this.instruction_require_time = date; - if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { - message = "申请AGV搬运任务中..."; - ApplyGreenFoilButtonRequest applyGreenFoilButtonRequest = new ApplyGreenFoilButtonRequest(); - applyGreenFoilButtonRequest.setDevice_code(device_code); - applyGreenFoilButtonRequest.setType(String.valueOf(mode)); - ApplyGreenFoilButtonResponse response = acsToWmsService.applyGreenFoilButtonTask(applyGreenFoilButtonRequest); - if (ObjectUtil.isEmpty(response)) { - message = "申请AGV搬运任务接口不通"; - } else { - if (response.getCode()== 200) { - if (mode==4){ - this.writing("to_command","4"); - }else if (mode==5){ - this.writing("to_command","5"); - }else if (mode==9){ - this.writing("to_command","9"); - } - message = "申请AGV搬运任务成功"; - requireSucess = true; - } else { - requireSucess = false; - message = "申请AGV搬运任务失败," + response.getMessage(); - this.writing("to_command","99"); - } - } - } - } - } - - - - - 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); - } - - - @Override - public JSONObject feedLmsRealFailedInfo() { - return null; - } - - @Override - public JSONObject getDeviceStatusName() throws Exception { - return null; - } - - @Override - public void setDeviceStatus(JSONObject data) { - - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/ItemProtocol.java deleted file mode 100644 index 4dfd566..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/ItemProtocol.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.green_foil_machine_button; - -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_to_command = "to_command"; - - - private GreenFoilMachineButtonDriver driver; - - public ItemProtocol(GreenFoilMachineButtonDriver driver) { - this.driver = driver; - } - - public int getItem_heartbeat(){ - return this.getOpcIntegerValue(item_heartbeat); - } ; - public int getItem_mode(){ - return this.getOpcIntegerValue(item_mode); - } ; - public int getItem_move(){ - return this.getOpcIntegerValue(item_move); - } ; - public int getItem_action(){ - return this.getOpcIntegerValue(item_action); - }; - public int getItem_error(){ - return this.getOpcIntegerValue(item_error); - } ; - - 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) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0L; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "251")); - list.add(new ItemDto(item_mode, "工作模式", "7990")); - list.add(new ItemDto(item_move, "光电信号", "550")); - list.add(new ItemDto(item_action, "取放信号", "450")); - list.add(new ItemDto(item_error, "故障", "8055")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "40226")); - return list; - } - - @Override - public String toString() { - return ""; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/HongXiangStationDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/HongXiangStationDefination.java deleted file mode 100644 index 96587d5..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/HongXiangStationDefination.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.hongxiang_conveyor; - -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 HongXiangStationDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hongxiang_conveyor"; - } - - @Override - public String getDriverName() { - return "烘箱设备对接位"; - } - - @Override - public String getDriverDescription() { - return "烘箱设备对接位"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HongXiangStationDeviceDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return HongXiangStationDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/HongXiangStationDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/HongXiangStationDeviceDriver.java deleted file mode 100644 index c2e5aa1..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/HongXiangStationDeviceDriver.java +++ /dev/null @@ -1,211 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.hongxiang_conveyor; - -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -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.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.ext.wms.service.impl.AcsToWmsServiceImpl; -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.task.service.TaskService; -import org.nl.config.SpringContextHolder; -import org.nl.system.service.param.ISysParamService; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 烘箱对接位 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HongXiangStationDeviceDriver 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 - ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); - @Autowired - DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); - @Autowired - AgvService agvService = SpringContextHolder.getBean(AgvService.class); - - 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; - - public int heartbeat = 0; - public int mode = 0; - public int move = 0; - public int action = 0; - public int error = 0; - public int door = 0; - public int temperature = 0; - public int countdown = 0; - public int finish = 0; - public int task = 0; - public int error1 = 0; - public int material = 0; - public int consumption = 0; - public int voltageA = 0; - public int voltageB = 0; - public int voltageC = 0; - public int currentA = 0; - public int currentB = 0; - public int currentC = 0; - - public int last_heartbeat = 0; - public int last_mode = 0; - public int last_move = 0; - public int last_action = 0; - public int last_error = 0; - public int last_door = 0; - public int last_temperature = 0; - public int last_countdown = 0; - public int last_finish = 0; - public int last_task = 0; - public int last_error1 = 0; - public int last_material = 0; - public int last_consumption = 0; - public int last_voltageA = 0; - public int last_voltageB = 0; - public int last_voltageC = 0; - public int last_currentA = 0; - public int last_currentB = 0; - public int last_currentC = 0; - - Boolean isonline = true; - - Boolean iserror = false; - - /** - * 1-执行任务;2-取货完成;3-放货完成; - */ - int flag; - - String device_code; - - @Override - public Device getDevice() { - return this.device; - } - - /** - * 请求成功标记 - */ - Boolean requireSucess = false; - - @Override - public void execute() { - String message = null; - - device_code = this.getDeviceCode(); - - } - - - public synchronized boolean instruction_apply(String container_code) throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_apply_time = date; - requireSucess = true; - return true; - } - } - - protected void thingToNothing() { - this.setRequireSucess(false); - } - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - this.control(itemMap); - } - - /** - * 将扩展表中的字符串数据转换成集合 - */ - @Override - public List getExtraDeviceCodes(String extraName) { - String extraValue = (String) this.getDevice().getExtraValue().get(extraName); - if (StrUtil.isEmpty(extraValue)) { - return new ArrayList<>(); - } - String devicesString = extraValue.substring(1, extraValue.length() - 1); - List devicesList = new ArrayList<>(); - String[] devices = devicesString.split(","); - for (int i = 0; i < devices.length; i++) { - String s = devices[i].replace("\"", "").replace("\"", ""); - devicesList.add(s); - } - return devicesList; - } - - 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; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - - itemMap.put(to_param, value); -// itemMap.put(to_param, Integer.parseInt(value)); - this.control(itemMap); - } - - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String action = ""; - String move = ""; - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", "联机"); - jo.put("action", action); - jo.put("isOnline", true); - jo.put("error", this.getError()); - jo.put("isError", this.getIserror()); - jo.put("task", this.getTask()); - return jo; - } - - @Override - public void setDeviceStatus(JSONObject data) { - - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/ItemProtocol.java deleted file mode 100644 index 72992cc..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/ItemProtocol.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.hongxiang_conveyor; - -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_action = "action"; - - public static String item_to_command = "to_command"; - - private HongXiangStationDeviceDriver driver; - - public ItemProtocol(HongXiangStationDeviceDriver driver) { - this.driver = driver; - } - - - public int getItem_action() { - return this.getOpcIntegerValue(item_action); - } - - ; - - 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 static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - - list.add(new ItemDto(item_action, "动作信号", "450")); - - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "226")); - return list; - } - - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDefination.java deleted file mode 100644 index 0615adc..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDefination.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.hongxiang_device; - -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 HongXiangConveyorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "hongxiang_device"; - } - - @Override - public String getDriverName() { - return "烘箱工位"; - } - - @Override - public String getDriverDescription() { - return "烘箱工位"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new HongXiangConveyorDeviceDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return HongXiangConveyorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDeviceDriver.java deleted file mode 100644 index a65a8b9..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDeviceDriver.java +++ /dev/null @@ -1,342 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.hongxiang_device; - -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -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.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.history.ErrorUtil; -import org.nl.acs.history.service.DeviceErrorLogService; -import org.nl.acs.history.service.dto.DeviceErrorLogDto; -import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; -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.task.service.TaskService; -import org.nl.config.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 烘箱工位 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { - 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 deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - - private String error_type = "hx_error_type"; - - 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; - - public int heartbeat = 0; - public int mode = 0; - public int move = 0; - public int action = 0; - public int error = 0; - public int door = 0; - public int temperature = 0; - public int to_temperature = 0; - public int countdown_house = 0; - public int countdown_min = 0; - public int countdown_sec = 0; - public int finish = 0; - public int task = 0; - public int error1 = 0; - public int material = 0; - public int consumption = 0; - public float voltageA = 0; - public float voltageB = 0; - public float voltageC = 0; - public float currentA = 0; - public float currentB = 0; - public float currentC = 0; - - public int last_heartbeat = 0; - public int last_mode = 0; - public int last_move = 0; - public int last_action = 0; - public int last_error = 0; - public int last_door = 0; - public int last_temperature = 0; - public int last_countdown_house = 0; - public int last_countdown_min = 0; - public int last_countdown_sec = 0; - public int last_finish = 0; - public int last_task = 0; - public int last_error1 = 0; - public int last_material = 0; - public int last_consumption = 0; - public float last_voltageA = 0; - public float last_voltageB = 0; - public float last_voltageC = 0; - public float last_currentA = 0; - public float last_currentB = 0; - public float last_currentC = 0; - - Boolean isonline = true; - - Boolean iserror = false; - - //1-执行任务;2-取货完成;3-放货完成; - int flag; - - String device_code; - - String message = null; - - - @Override - public Device getDevice() { - return this.device; - } - - //请求成功标记 - Boolean requireSucess = false; - - @Override - public void execute() { - - device_code = this.getDeviceCode(); - heartbeat = this.itemProtocol.getItem_heartbeat(); - mode = this.itemProtocol.getItem_mode(); - move = this.itemProtocol.getItem_move(); - action = this.itemProtocol.getItem_action(); - error = this.itemProtocol.getItem_error(); - door = this.itemProtocol.getItem_door(); - temperature = this.itemProtocol.getItem_temperature(); - countdown_house = this.itemProtocol.getItem_countdown_house(); - countdown_min = this.itemProtocol.getItem_countdown_min(); - countdown_sec = this.itemProtocol.getItem_countdown_sec(); - finish = this.itemProtocol.getItem_finish(); - task = this.itemProtocol.getItem_task(); - error1 = this.itemProtocol.getItem_error1(); - material = this.itemProtocol.getItem_material(); - consumption = this.itemProtocol.getItem_consumption(); - voltageA = this.itemProtocol.getItem_voltageA(); - voltageB = this.itemProtocol.getItem_voltageB(); - voltageC = this.itemProtocol.getItem_voltageC(); - currentA = this.itemProtocol.getItem_currentA(); - currentB = this.itemProtocol.getItem_currentB(); - currentC = this.itemProtocol.getItem_currentC(); - to_temperature = this.itemProtocol.getItem_to_temperature(); - if (door != last_door) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号door:" + last_door + "->" + door); - } - if (mode != last_mode) { - //this.setRequireSucess(false); - } - if (move != last_move) { - if (move == 0) { - thingToNothing(); - } - } - if (error != last_error) { - if (error != 0) { - DeviceErrorLogDto dto = new DeviceErrorLogDto(); - dto.setDevice_code(device_code); - dto.setError_code(String.valueOf(error)); - dto.setError_info(ErrorUtil.getDictDetail("hx_error_type", String.valueOf(error))); - deviceErrorLogService.create(dto); - } - } - if (finish != last_finish) { - if (finish == 1) { - logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为requireSucess:" + requireSucess); - requireSucess = false; - logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为requireSucess:" + requireSucess); - } - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_finish + "->" + finish); - } - if (mode == 0) { - this.setIsonline(false); - message = "有报警"; - //无报警 - } else if (error != 0) { - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - if (move == 0 && last_move == 1) { - //requireSucess = false; - } - - if (finish == 1 && !requireSucess) { - //烘箱完成反馈LMS -// apply_finish(); - } - } - - last_mode = mode; - last_move = move; - last_action = action; - last_error = error; - last_door = door; - last_temperature = temperature; - last_countdown_house = countdown_house; - last_countdown_min = countdown_min; - last_countdown_sec = countdown_sec; - last_finish = finish; - last_task = task; - last_error1 = error1; - last_material = material; - last_consumption = consumption; - last_voltageA = voltageA; - last_voltageB = voltageB; - last_voltageC = voltageC; - last_currentA = currentA; - last_currentB = currentB; - last_currentC = currentC; - } - - - protected void thingToNothing() { - //this.setRequireSucess(false); - } - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - this.control(itemMap); - } - - //将扩展表中的字符串数据转换成集合 - public List getExtraDeviceCodes(String extraName) { - String extraValue = (String) this.getDevice().getExtraValue().get(extraName); - if (StrUtil.isEmpty(extraValue)) { - return new ArrayList<>(); - } - String devicesString = extraValue.substring(1, extraValue.length() - 1); - List devicesList = new ArrayList<>(); - String[] devices = devicesString.split(","); - for (int i = 0; i < devices.length; i++) { - String s = devices[i].replace("\"", "").replace("\"", ""); - devicesList.add(s); - } - return devicesList; - } - - 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); - } - - - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String action = ""; - String move = ""; - if (this.getMode() == 0) { - mode = "未联机"; - } else if (this.getMode() == 1) { - mode = "联机"; - } else if (this.getMode() == 2) { - mode = "联机"; - } - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = "1"; - } - jo.put("requireSucess", requireSucess); - - if (this.getMove() == 0) { - move = "无货"; - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = "有货"; - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = "有托盘有货"; - jo.put("hasGoods", true); - } - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("temperature", temperature); - jo.put("finish", finish); - jo.put("isOnline", this.getIsonline()); - jo.put("error", ErrorUtil.getDictDetail("hx_error_type", String.valueOf(this.getError()))); - jo.put("isError", this.getIserror()); - jo.put("countdown_house", countdown_house); - jo.put("countdown_min", countdown_min); - jo.put("countdown_sec", countdown_sec); - jo.put("door", door); - jo.put("mode", mode); - jo.put("move", move); - jo.put("action", action); -// jo.put("isOnline", this.getIsonline()); -// jo.put("error", this.getError()); -// jo.put("isError", this.getIserror()); - jo.put("task", this.getTask()); - return jo; - } - - @Override - public void setDeviceStatus(JSONObject data) { - - } - - @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; - } - - - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/ItemProtocol.java deleted file mode 100644 index 5db6a4c..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/ItemProtocol.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.hongxiang_device; - -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_door = "door"; - public static String item_temperature = "temperature"; - //恒温倒计时 - public static String item_countdown_house = "countdown_house"; - public static String item_countdown_min = "countdown_min"; - public static String item_countdown_sec = "countdown_sec"; - - public static String item_finish = "finish"; - public static String item_task = "task"; - public static String item_error1 = "error1"; - public static String item_material = "material"; - public static String item_consumption = "consumption"; - public static String item_voltageA = "voltageA"; - public static String item_voltageB = "voltageB"; - public static String item_voltageC = "voltageC"; - public static String item_currentA = "currentA"; - public static String item_currentB = "currentB"; - public static String item_currentC = "currentC"; - - - public static String item_to_command = "to_command"; - public static String item_to_open_door = "to_open_door"; - public static String item_to_close_door = "to_close_door"; - public static String item_to_temperature = "to_temperature"; - public static String item_to_material = "to_material"; - public static String item_to_time_house = "to_time_house"; - public static String item_to_time_min = "to_time_min"; - public static String item_to_time_sec = "to_time_sec"; - - public static String item_to_task = "to_task"; - - - private HongXiangConveyorDeviceDriver driver; - - public ItemProtocol(HongXiangConveyorDeviceDriver driver) { - this.driver = driver; - } - - public int getItem_heartbeat(){ - return this.getOpcIntegerValue(item_heartbeat); - } ; - public int getItem_mode(){ - return this.getOpcIntegerValue(item_mode); - } ; - public int getItem_move(){ - return this.getOpcIntegerValue(item_move); - } ; - public int getItem_action(){ - return this.getOpcIntegerValue(item_action); - }; - public int getItem_error(){ - return this.getOpcIntegerValue(item_error); - } ; - public int getItem_door(){ - return this.getOpcIntegerValue(item_door); - } ; - public int getItem_temperature(){ - return this.getOpcIntegerValue(item_temperature); - } ; - public int getItem_countdown_house(){ - return this.getOpcIntegerValue(item_countdown_house); - } ; - public int getItem_countdown_min(){ - return this.getOpcIntegerValue(item_countdown_min); - } ; - public int getItem_countdown_sec(){ - return this.getOpcIntegerValue(item_countdown_sec); - } ; - public int getItem_finish(){ - return this.getOpcIntegerValue(item_finish); - } ; - public int getItem_task(){ - return this.getOpcIntegerValue(item_task); - } ; - public int getItem_error1(){ - return this.getOpcIntegerValue(item_error1); - } ; - public int getItem_material(){ - return this.getOpcIntegerValue(item_material); - } ; - public int getItem_consumption(){ - return this.getOpcIntegerValue(item_consumption); - } ; - public float getItem_voltageA(){ - return this.getOpcFloatValue(item_voltageA); - } ; - public float getItem_voltageB(){ - return this.getOpcFloatValue(item_voltageB); - } ; - public float getItem_voltageC(){ - return this.getOpcFloatValue(item_voltageC); - } ; - public float getItem_currentA(){ - return this.getOpcFloatValue(item_currentA); - } ; - public float getItem_currentB(){ - return this.getOpcFloatValue(item_currentB); - } ; - public float getItem_currentC(){ - return this.getOpcFloatValue(item_currentC); - } ; - - public int getItem_to_temperature(){ - return this.getOpcIntegerValue(item_to_temperature); - } ; - - 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) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0L; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "251")); - list.add(new ItemDto(item_mode, "工作模式", "7990")); - list.add(new ItemDto(item_move, "光电信号", "550")); - list.add(new ItemDto(item_door, "门状态", "450")); - list.add(new ItemDto(item_temperature, "工位温度", "7991")); - list.add(new ItemDto(item_countdown_house, "恒温倒计时(时)", "80500")); - list.add(new ItemDto(item_countdown_min, "恒温倒计时(分)", "80502")); - list.add(new ItemDto(item_countdown_sec, "恒温倒计时(秒)", "80504")); - list.add(new ItemDto(item_finish, "烘干完成", "8025")); - list.add(new ItemDto(item_action, "取放信号", "450")); - list.add(new ItemDto(item_task, "任务号", "220")); - list.add(new ItemDto(item_error, "故障", "8055")); - list.add(new ItemDto(item_error1, "故障1", "216")); - list.add(new ItemDto(item_material, "物料", "223")); - list.add(new ItemDto(item_consumption, "电能耗", "8092")); - list.add(new ItemDto(item_voltageA, "A相电压", "8080")); - list.add(new ItemDto(item_voltageB, "B相电压", "8082")); - list.add(new ItemDto(item_voltageC, "C相电压", "8084")); - list.add(new ItemDto(item_currentA, "A相电流", "8086")); - list.add(new ItemDto(item_currentB, "B相电流", "8088")); - list.add(new ItemDto(item_currentC, "C相电流", "8090")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "40226")); - list.add(new ItemDto(item_to_open_door, "开门", "00111")); - list.add(new ItemDto(item_to_close_door, "关门", "00112")); - list.add(new ItemDto(item_to_temperature, "生产温度", "48100")); - list.add(new ItemDto(item_to_material, "生产物料", "40229")); - list.add(new ItemDto(item_to_time_house, "生产时间(时)", "48771")); - list.add(new ItemDto(item_to_time_min, "生产时间(分)", "48770")); - list.add(new ItemDto(item_to_task, "任务号", "40232")); - return list; - } - - @Override - public String toString() { - return ""; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDefination.java deleted file mode 100644 index 2b3997d..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDefination.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.inflatable_shaft_library; - -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 InflatableShaftLibraryDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "inflatable_shaft_library"; - } - - @Override - public String getDriverName() { - return "气涨轴缓存库"; - } - - @Override - public String getDriverDescription() { - return "气涨轴缓存库"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new InflatableShaftLibraryDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return InflatableShaftLibraryDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDeviceDriver.java deleted file mode 100644 index 655b06d..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDeviceDriver.java +++ /dev/null @@ -1,174 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.inflatable_shaft_library; - -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -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.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.history.service.DeviceErrorLogService; -import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; -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.service.TaskService; -import org.nl.config.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.HashMap; -import java.util.Map; - -/** - * 气涨轴缓存库 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class InflatableShaftLibraryDeviceDriver 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); - - //心跳 - public int heartbeat = 0; - public int last_heartbeat = 0; - //工作模式 - 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 qty = 0; - int last_qty = 0; - //类型 - int type = 0; - int last_type = 0; - - int to_command = 0; - int last_to_command = 0; - - Boolean isonline = true; - - Boolean iserror = false; - - - String device_code; - - String message = null; - - @Override - public Device getDevice() { - return this.device; - } - - //请求成功标记 - Boolean requireSucess = false; - - @Override - public void execute() { - - device_code = this.getDeviceCode(); - heartbeat = this.itemProtocol.getItem_heartbeat(); - mode = this.itemProtocol.getItem_mode(); - move = this.itemProtocol.getItem_move(); - action = this.itemProtocol.getItem_action(); - error = this.itemProtocol.getItem_error(); - qty = this.itemProtocol.getItem_qty(); - type = this.itemProtocol.getItem_type(); - if (mode != last_mode) { - requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (action != last_action) { - logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); - } - if (error != last_error) { - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (qty != last_qty) { - logServer.deviceItemValue(this.device_code, "weight", String.valueOf(qty)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号qty:" + last_qty + "->" + qty); - } - if (type != last_type) { - logServer.deviceItemValue(this.device_code, "weight", String.valueOf(type)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号type:" + last_type + "->" + type); - } - - if (move==1&&!requireSucess){ - this.writing("to_command","1"); - } - - - last_mode = mode; - last_move = move; - last_action = action; - last_error = error; - last_qty = qty; - last_type = type; - } - - - 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); - } - - - @Override - public JSONObject feedLmsRealFailedInfo() { - return null; - } - - @Override - public JSONObject getDeviceStatusName() throws Exception { - return null; - } - - @Override - public void setDeviceStatus(JSONObject data) { - - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java deleted file mode 100644 index 30d6e19..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.inflatable_shaft_library; - -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_qty = "qty"; - public static String item_type = "type"; - - public static String item_to_command = "to_command"; - - private InflatableShaftLibraryDeviceDriver driver; - - public ItemProtocol(InflatableShaftLibraryDeviceDriver driver){ - this.driver=driver; - } - - - public int getItem_heartbeat(){ - return this.getOpcIntegerValue(item_heartbeat); - } ; - public int getItem_mode(){ - return this.getOpcIntegerValue(item_mode); - } ; - public int getItem_move(){ - return this.getOpcIntegerValue(item_move); - } ; - public int getItem_action(){ - return this.getOpcIntegerValue(item_action); - }; - public int getItem_error(){ - return this.getOpcIntegerValue(item_error); - } - public int getItem_qty(){ - return this.getOpcIntegerValue(item_qty); - } - public int getItem_type(){ - return this.getItem_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 float getOpcFloatValue(String protocol) { - Float value = this.driver.getDoubleValue(protocol); - if (value == null) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0L; - - } - - 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_qty, "数量", "DB1.B4")); - list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); - list.add(new ItemDto(item_type, "类型", "DB1.B6")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList<>(); - list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); - return list; - } - - @Override - public String toString() { - return ""; - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/ItemProtocol.java deleted file mode 100644 index cd262b0..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/ItemProtocol.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.lamp_three_color; - -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 class ItemProtocol { - - public static String item_to_command = "to_command"; - - - private LampThreecolorDeviceDriver driver; - - public ItemProtocol(LampThreecolorDeviceDriver driver) { - this.driver = driver; - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - } else { - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "08011")); - return list; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDefination.java deleted file mode 100644 index 97cf318..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDefination.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.lamp_three_color; - -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 LampThreecolorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lamp_three_color"; - } - - @Override - public String getDriverName() { - return "标准版-三色灯"; - } - - @Override - public String getDriverDescription() { - return "标准版-三色灯"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LampThreecolorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return LampThreecolorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDeviceDriver.java deleted file mode 100644 index 562eafb..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDeviceDriver.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.lamp_three_color; - -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.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.log.service.DeviceExecuteLogService; -import org.nl.config.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * 标准版-三色灯 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - @Autowired - DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - /** - * 放货准备锁 - */ - String putReadyLock = null; - /** - * 有货标记 - */ - protected boolean has_goods_tag = false; - String devicecode; - int mode = 0; - int action = 0; - int error = 0; - int move = 0; - int task = 0; - int last_action = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - protected boolean hasGoods = false; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - - String device_code = null; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - device_code = this.getDevice().getDevice_code(); - - } - - 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); - } - - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/ItemProtocol.java deleted file mode 100644 index 9c623ff..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/ItemProtocol.java +++ /dev/null @@ -1,166 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.oven_manipulator; - -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_walk_y = "walk_y"; - //任务号 - public static String item_task = "task"; - //报警 - public static String item_error = "error"; - //x轴坐标 - public static String item_x_position = "x_position"; - //y轴坐标 - public static String item_y_position = "y_position"; - - //下发命令 - public static String item_to_command = "to_command"; - //下发起始站 - public static String item_to_onset = "to_onset"; - //下发目标站 - public static String item_to_target = "to_target"; - //下发任务号 - public static String item_to_task = "to_task"; - - private OvenGantryManipulatorDeviceDriver driver; - - public ItemProtocol(OvenGantryManipulatorDeviceDriver 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 getWalk_y() { - return this.getOpcIntegerValue(item_walk_y); - } - - 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 getTo_onset() { - return this.getOpcIntegerValue(item_to_onset); - } - - public float getX_position() { - return this.getOpcFloatValue(item_x_position); - } - - public float getY_position() { - return this.getOpcFloatValue(item_y_position); - } - - - 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 "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_walk_y, "行走列", "DB1.B4")); - list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); - list.add(new ItemDto(item_task, "任务号", "DB1.D6")); - list.add(new ItemDto(item_x_position, "x坐标", "DB1.REAL10")); - list.add(new ItemDto(item_y_position, "y坐标", "DB1.REAL14")); - 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_onset, "下发起始站", "DB2.W2")); - list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); - return list; - } - - @Override - public String toString() { - return ""; - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDefination.java deleted file mode 100644 index 51c5d15..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDefination.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.oven_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 OvenGantryManipulatorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "oven_manipulator"; - } - - @Override - public String getDriverName() { - return "烘箱-行架机械手"; - } - - @Override - public String getDriverDescription() { - return "烘箱-行架机械手"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new OvenGantryManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return OvenGantryManipulatorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.station); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java deleted file mode 100644 index 27c3790..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java +++ /dev/null @@ -1,1027 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.oven_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 lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -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.conveyor.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.device_driver.two_conveyor.hongxiang_device.HongXiangConveyorDeviceDriver; -import org.nl.acs.device_driver.two_conveyor.lamp_three_color.LampThreecolorDeviceDriver; -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.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.common.exception.BadRequestException; -import org.nl.config.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 烘箱-行架机械手 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - @Autowired - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); - @Autowired - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - @Autowired - DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - - //工作模式 - int mode = 0; - int last_mode = 0; - //光电信号 - int move = 0; - int last_move = 0; - //动作信号 - int action = 0; - int last_action = 0; - //行走列 - int walk_y = 0; - int last_walk_y = 0; - //报警信号 - int error = 0; - int last_error = 0; - //任务号 - int task = 0; - int last_task = 0; - // x坐标 - float x_position = 0; - float last_x_position = 0; - // y坐标 - float y_position = 0; - float last_y_position = 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_onset = 0; - int last_to_onset = 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 = ""; - - - List getDeviceCodeList = null; - - List putDeviceCodeList = null; - - - @Override - public Device getDevice() { - return this.device; - } - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - move = this.itemProtocol.getMove(); - action = this.itemProtocol.getAction(); - walk_y = this.itemProtocol.getWalk_y(); - 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_onset = this.itemProtocol.getTo_onset(); - x_position = this.itemProtocol.getX_position(); - y_position = this.itemProtocol.getY_position(); - - if (to_onset != last_to_onset) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset:" + last_to_onset + "->" + to_onset); - } - if (to_command != last_to_command) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); - } - if (to_target != last_to_target) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); - } - if (to_task != last_to_task) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); - } - if (mode != last_mode) { - requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (action != last_action) { - logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); - } - if (error != last_error) { - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (walk_y != last_walk_y) { - logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); - } - if (task != last_task) { - logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); - } - if (x_position != last_x_position) { - logServer.deviceItemValue(this.device_code, "x_position", String.valueOf(x_position)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号x_position:" + last_x_position + "->" + x_position); - } - if (y_position != last_y_position) { - logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position:" + last_y_position + "->" + y_position); - } - update_instruction_status(); - - } catch (Exception var17) { - var17.printStackTrace(); - feedMessage = var17.getMessage(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); - - } - - 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 == 2 && move == 0 && task == 0 && !requireSucess) { - boolean res = applyTask(); - if (res) { - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - feedMessage = ""; - } - } else { - if (mode == 2) { - //if (!requireSucess) { - String remark = "未查找任务原因为:"; - if (mode != 2) { - remark = remark + "工作模式(mode)不是待机状态,"; - } - if (move != 0) { - remark = remark + "光电信号(move)为有货状态,"; - } - if (task != 0) { - remark = remark + "当前上报任务号(task)应该为0,"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = remark + "请右击该图标,将请求任务复位标记(requireSucess)改为否。"; - } - this.setNotCreateTaskMessage(remark); - //} - } - } - - } - last_mode = mode; - last_move = move; - last_action = action; - last_walk_y = walk_y; - 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_onset = to_onset; - last_x_position = x_position; - last_y_position = y_position; - } - - public List sortTask(List taskDtos) { - Collections.sort(taskDtos, new Comparator() { - @Override - public int compare(TaskDto t1, TaskDto t2) { - //优先级从大到小 - int i = t2.getPriority().compareTo(t1.getPriority()); - //如果优先级相等 - if (i == 0) { - //时间从早到晚 - i = t1.getCreate_time().compareTo(t2.getCreate_time()); - } - return i; - } - }); - return taskDtos; - } - - /** - * 申请任务 - * - * @param - */ - 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 { - 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"); - } - - TaskDto task = null; - for (int i = 0; i < getDeviceCodeList.size(); i++) { - String startDeviceCode = getDeviceCodeList.get(i); - List taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtos)) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtos = this.sortTask(taskDtos); - TaskDto taskDto = taskDtos.get(0); - - //存在行架->暂存的AGV任务 需要过滤 - // 6 行架任务 8烘箱任务 - if (!StrUtil.equals(taskDto.getTask_type(), "6") && !StrUtil.equals(taskDto.getTask_type(), "8")) { - taskDto = null; - continue; - } - - Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDto.getTask_code()); - String start_device_code = instruction.getStart_device_code(); - String next_device_code = instruction.getNext_device_code(); - Device nextdevice = deviceAppService.findDeviceByCode(next_device_code); - Device startdevice = deviceAppService.findDeviceByCode(start_device_code); -// PhotoelectricInspectionSiteDeviceDriver photoelectricInspectionSiteDeviceDriver; - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; -// if (startdevice.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver) { -// photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) startdevice.getDeviceDriver(); -// if (photoelectricInspectionSiteDeviceDriver.getMove() != 1) { -// notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱对接位:" + photoelectricInspectionSiteDeviceDriver.getDevice_code() + "无货,无法下发指令!指令号:" + instruction.getInstruction_code(); -// return false; -// } -// } - if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() != 1) { - notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "无货,无法下发指令!指令号:" + instruction.getInstruction_code(); - return false; - } - } - if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver(); - if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 0) { - notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或无货,无法下发指令!指令号:" + instruction.getInstruction_code(); - return false; - } - } - - if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() != 0) { - notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "有货,无法下发指令!指令号:" + instruction.getInstruction_code(); - return false; - } - } - if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver(); - if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 1) { - notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或者有货,无法下发指令!指令号:" + instruction.getInstruction_code(); - return false; - } - } - //判断关联的同一列烘箱设备是否都关门 都关门返回false,有一个不关门就返回true - boolean isCloseDoor = this.judgeCloseDoor(start_device_code, next_device_code); - //未关门结束 - if (isCloseDoor) { - notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + start_device_code + ",放货位:" + next_device_code + ",存在关联的同一列烘箱设备未关门!指令号:" + instruction.getInstruction_code(); - return false; - } - instruction.setInstruction_status("1"); - instruction.setUpdate_time(DateUtil.now()); - instructionService.update(instruction); - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { - throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); - } - if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { - throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); - } - String start_addr = startDevice.getExtraValue().get("address").toString(); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" - + instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code() - + ",指令终点:" + instruction.getNext_device_code()); - this.writing("to_onset", start_addr); - this.writing("to_target", next_addr); - this.writing("to_task", instruction.getInstruction_code()); - this.writing("to_command", "1"); - if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); - } - if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); - } - this.setNow_steps_type(2); - this.setRequireSucess(true); - return true; - } else { - List taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtoList)) { - for (int j = 0; j < taskDtoList.size(); j++) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtoList = this.sortTask(taskDtoList); - task = taskDtoList.get(j); - // 6 行架任务 8烘箱任务 - if (!StrUtil.equals(task.getTask_type(), "6") && !StrUtil.equals(task.getTask_type(), "8")) { - task = null; - continue; - } - if (ObjectUtil.isNotEmpty(task)) { - break; - } - } - } - } - } - if (!ObjectUtil.isEmpty(task)) { - Device nextdevice = deviceAppService.findDeviceByCode(task.getNext_device_code()); - Device startdevice = deviceAppService.findDeviceByCode(task.getStart_device_code()); -// PhotoelectricInspectionSiteDeviceDriver photoelectricInspectionSiteDeviceDriver; - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; -// if (startdevice.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver) { -// photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) startdevice.getDeviceDriver(); -// if (photoelectricInspectionSiteDeviceDriver.getMove() != 1) { -// notCreateInstMessage = "就绪任务未创建指令原因->取货位-烘箱对接位:" + photoelectricInspectionSiteDeviceDriver.getDevice_code() + "光电无货,无法生成指令!"; -// return false; -// } -// } - if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() != 1) { - notCreateInstMessage = "就绪任务未创建指令原因->取货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "光电无货,无法生成指令!"; - return false; - } - } - if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver(); - if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 0) { - notCreateInstMessage = "就绪任务未创建指令原因->取货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "光电无货,无法生成指令!"; - return false; - } - } - - if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver(); - if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 1) { - notCreateInstMessage = "就绪任务未创建指令原因->放货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "光电有货,无法生成指令!"; - return false; - } - } -// if (nextdevice.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver) { -// photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) nextdevice.getDeviceDriver(); -// if (photoelectricInspectionSiteDeviceDriver.getMove() != 0) { -// notCreateInstMessage = "就绪任务未创建指令原因->放货位-烘箱对接位:" + photoelectricInspectionSiteDeviceDriver.getDevice_code() + "光电有货,无法生成指令!"; -// return false; -// } -// } - if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() != 0) { - notCreateInstMessage = "就绪任务未创建指令原因->放货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "光电有货,无法生成指令!"; - return false; - } - } - String taskid = task.getTask_id(); - String taskcode = task.getTask_code(); - String vehiclecode = task.getVehicle_code(); - String priority = task.getPriority(); - String start_point_code = task.getStart_point_code(); - String start_device_code = task.getStart_device_code(); - String route_plan_code = task.getRoute_plan_code(); - String next_point_code = task.getNext_point_code(); - String next_device_code = task.getNext_device_code(); - - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(task.getRemark()); - instdto.setMaterial(task.getMaterial()); - instdto.setQuantity(task.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - - //判断关联的同一列烘箱设备是否都关门 都关门返回false,有一个不关门就返回true - boolean isCloseDoor = this.judgeCloseDoor(instdto.getStart_device_code(), instdto.getNext_device_code()); - //如果未关门结束 - if (isCloseDoor) { - return false; - } - - try { - instructionService.create(instdto); - } catch (Exception e) { - notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); - return false; - } - //创建指令后修改任务状态 - task.setTask_status("1"); - task.setUpdate_time(DateUtil.now()); - taskserver.update(task); - - Device startDevice = deviceAppService.findDeviceByCode(instdto.getStart_device_code()); - Device nextDevice = deviceAppService.findDeviceByCode(instdto.getNext_device_code()); - if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { - notCreateInstMessage = "设备:" + startDevice.getDevice_code() + "未设置电气调度号!"; - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); - throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); - } - if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { - notCreateInstMessage = "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"; - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); - throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); - } - String start_addr = startDevice.getExtraValue().get("address").toString(); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" - + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() - + ",指令终点:" + instdto.getNext_device_code()); - this.writing("to_onset", start_addr); - this.writing("to_target", next_addr); - this.writing("to_task", instdto.getInstruction_code()); - this.writing("to_command", "1"); - //HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); - hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); - } - if (startDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startDevice.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); - hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); - } - this.setNow_steps_type(2); - this.setRequireSucess(true); - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - } else { - notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; - } - return true; - } - } - - //判断取货位或放货位为烘箱设备时关联的同一列烘箱设备是否有开门 - public boolean judgeCloseDoor(String start_device_code, String next_device_code) { - Boolean isClose = false; - - try { - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - if (ObjectUtil.isEmpty(startDevice)) { - throw new BadRequestException("设备号:" + start_device_code + "不存在!"); - } - if (startDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startDevice.getDeviceDriver(); - List deviceCodes = hongXiangConveyorDeviceDriver.getExtraDeviceCodes("link_device_code"); - if (ObjectUtil.isNotEmpty(deviceCodes)) { - for (String deviceCode : deviceCodes) { - Device linkDevice = deviceAppService.findDeviceByCode(deviceCode); - if (ObjectUtil.isEmpty(linkDevice)) { - throw new BadRequestException("设备:" + start_device_code + "关联设备->" + deviceCode + "为空!"); - } - if (linkDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) linkDevice.getDeviceDriver(); - //判断关联设备是否开门 - if (hongXiangConveyorDeviceDriver.getDoor() == 1) { - isClose = true; - notCreateInstMessage = start_device_code + "关联设备->" + deviceCode + "烘箱门未关闭!"; - break; - } - } - } - return isClose; - } - } - if (ObjectUtil.isEmpty(nextDevice)) { - throw new BadRequestException("设备号:" + next_device_code + "不存在!"); - } - if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); - List deviceCodes = hongXiangConveyorDeviceDriver.getExtraDeviceCodes("link_device_code"); - if (ObjectUtil.isNotEmpty(deviceCodes)) { - for (String deviceCode : deviceCodes) { - Device linkDevice = deviceAppService.findDeviceByCode(deviceCode); - if (ObjectUtil.isEmpty(linkDevice)) { - throw new BadRequestException("设备:" + next_device_code + "关联设备->" + deviceCode + "为空!"); - } - if (linkDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) linkDevice.getDeviceDriver(); - //判断关联设备是否开门 - if (hongXiangConveyorDeviceDriver.getDoor() == 1) { - isClose = true; - notCreateInstMessage = next_device_code + "关联设备->" + deviceCode + "烘箱门未关闭!"; - break; - } - } - } - return isClose; - } - } - } catch (Exception e) { - isClose = true; - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "检查烘箱是否关门时出现异常:" + e.getMessage()); - notCreateInstMessage = "检查烘箱是否关门时出现异常:" + e.getMessage(); - } - return isClose; - } - - - 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; - //更改任务状态 - if (task > 0) { - //inst_message - Instruction inst1 = checkInst(); - if (inst1 != null) { - if (StrUtil.equals(inst1.getInstruction_status(), "0")) { - inst1.setInstruction_status("1"); - inst1.setExecute_device_code(this.device_code); - instructionService.update(inst1); - } - } - } - - //申请取货 - if (mode == 3 && action == 1 && move == 0 && task > 0) { - Instruction inst2 = checkInst(); - if (ObjectUtil.isNotEmpty(inst2)) { - String start_device_code = inst2.getStart_device_code(); - Device device = deviceAppService.findDeviceByCode(start_device_code); - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); - int mode = hongXiangConveyorDeviceDriver.getMode(); - int door = hongXiangConveyorDeviceDriver.getDoor(); - int action = hongXiangConveyorDeviceDriver.getAction(); - int error1 = hongXiangConveyorDeviceDriver.getError1(); - int move = hongXiangConveyorDeviceDriver.getMove(); - if (mode == 1 && door == 1 && action == 1 && error1 == 0 && move == 1) { - if (this.getNow_steps_type() == 2) { - this.writing("to_command", "2"); - this.setNow_steps_type(3); - } else { - //logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为下发电气信号(now_steps_type!=2)"); - } - } else { - if (this.getNow_steps_type() == 2) { - feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code(); - if (mode != 1) { - feedMessage = feedMessage + "工作模式(mode)信号未联机,"; - } - if (door != 1) { - feedMessage = feedMessage + "门状态(door)信号未开门,"; - } - if (action != 1) { - feedMessage = feedMessage + "允许取放(action)信号未允许取放,"; - } - if (move != 1) { - feedMessage = feedMessage + "取货位光电信号(move)不应该为无货状态,"; - } - if (error1 != 0) { - feedMessage = feedMessage + "故障(error1)信号出现故障,故障值:" + error1 + "。"; - } - } - } - } else { - if (this.getNow_steps_type() == 2) { - this.writing("to_command", "2"); - this.setNow_steps_type(3); - } else { - //logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为下发电气信号(now_steps_type!=2)\")"); - } - } - } - } else { - if (this.getNow_steps_type() == 2) { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; - } - if (action != 1) { - feedMessage = feedMessage + "动作信号(action)不为取货中状态,"; - } - if (move != 0) { - feedMessage = feedMessage + "光电信号(move)不为无货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; - } - } - } - - //取货完成关闭烘箱门 - if (mode == 3 && action == 2 && move == 1 && task > 0) { - Instruction inst2 = checkInst(); - if (ObjectUtil.isNotEmpty(inst2)) { - String start_device_code = inst2.getStart_device_code(); - Device device = deviceAppService.findDeviceByCode(start_device_code); - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); - } - if (this.getNow_steps_type() == 3) { - this.writing("to_command", "3"); - this.setNow_steps_type(4); - } else { - //logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许取货(now_steps_type!=3)"); - } - } - } else { - if (this.getNow_steps_type() == 3) { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; - } - if (action != 2) { - feedMessage = feedMessage + "动作信号(action)不为取货完成状态,"; - } - if (move != 1) { - feedMessage = feedMessage + "光电信号(move)不为有货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; - } - } - } - - //申请放货 - if (mode == 3 && action == 3 && move == 1 && task > 0) { - Instruction instructionDto = checkInst(); - String next_device_code = instructionDto.getNext_device_code(); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); - int mode = hongXiangConveyorDeviceDriver.getMode(); - int door = hongXiangConveyorDeviceDriver.getDoor(); - int action = hongXiangConveyorDeviceDriver.getAction(); - int error1 = hongXiangConveyorDeviceDriver.getError1(); - int move = hongXiangConveyorDeviceDriver.getMove(); - if (mode == 1 && door == 1 && action == 1 && error1 == 0 && move == 0) { - if (this.getNow_steps_type() == 4) { - this.writing("to_command", "4"); - this.setNow_steps_type(5); - } else { - feedMessage = "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)"; - } - } else { - if (this.getNow_steps_type() == 4) { - feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code(); - if (mode != 1) { - feedMessage = feedMessage + "工作模式(mode)信号未联机,"; - } - if (door != 1) { - feedMessage = feedMessage + "门状态(door)信号未开门,"; - } - if (action != 1) { - feedMessage = feedMessage + "允许取放(action)信号未允许取放,"; - } - if (move != 0) { - feedMessage = feedMessage + "放货位光电信号不应该为有货状态"; - } - if (error1 != 0) { - feedMessage = feedMessage + "故障(error1)信号出现故障。"; - } - } - } - } else { - if (this.getNow_steps_type() == 4) { - this.writing("to_command", "4"); - this.setNow_steps_type(5); - } else { - //logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)"); - } - - } - } else { - if (this.getNow_steps_type() == 4) { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; - } - if (action != 3) { - feedMessage = feedMessage + "动作信号(action)不为放货中状态,"; - } - if (move != 1) { - feedMessage = feedMessage + "光电信号(move)不为有货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; - } - } - } - - //放货完成 - if (mode == 3 && action == 4 && move == 0 && task > 0) { - Instruction inst2 = checkInst(); - if (inst2 != null) { - if (StrUtil.equals(inst2.getInstruction_status(), "1")) { - - TaskDto taskDto = taskserver.findByCode(inst2.getTask_code()); - - String next_device_code = inst2.getNext_device_code(); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; - if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); - if (StrUtil.isNotEmpty(taskDto.getOven_time())) { - //下发烘箱时间 - int time = Integer.parseInt(taskDto.getOven_time()); - int hours = (time % (60 * 60 * 24)) / (60 * 60); - int minutes = (time % (60 * 60)) / 60; - hongXiangConveyorDeviceDriver.writing("to_time_house", String.valueOf(hours)); - hongXiangConveyorDeviceDriver.writing("to_time_min", String.valueOf(minutes)); - } - } - - if (nextDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextDevice.getDeviceDriver(); - if (!StrUtil.startWith(taskDto.getTask_code(), "-")) { - if (ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("link_three_lamp"))) { - String lamp = nextDevice.getExtraValue().get("link_three_lamp").toString(); - Device lampDevice = deviceAppService.findDeviceByCode(lamp); - if (ObjectUtil.isEmpty(lampDevice)) { - return; - } - if (lampDevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lampDevice.getDeviceDriver(); - logServer.deviceExecuteLog(lampDevice.getDeviceDriver().getDeviceCode(), "", "", "下发报警灯" + lamp + "报警信号"); - lampThreecolorDeviceDriver.writing("to_command", "1"); - } - } - } - - } - this.writing("to_command", "5"); - this.setNow_steps_type(6); - this.setNow_steps_type(0); - try { - finish_instruction(inst2); - } catch (Exception e) { - e.printStackTrace(); - } - feedMessage = ""; - } - } - } else { - if (this.getNow_steps_type() == 5) { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; - } - if (action != 4) { - feedMessage = feedMessage + "动作信号(action)不为放货完成状态,"; - } - if (move != 0) { - feedMessage = feedMessage + "光电信号(move)不为无货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; - } - } - } - } - } - - public synchronized boolean finish_instruction(Instruction inst) 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 = "脱机"; - } else if (this.getMode() == 1) { - mode = "单机"; - } else if (this.getMode() == 2) { - mode = "待机"; - } else if (this.getMode() == 3) { - mode = "运行中"; - } - - if (this.getMove() == 0) { - move = "无货"; - } else if (this.getMove() == 1) { - move = "有货"; - } - - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = "1"; - } - jo.put("requireSucess", requireSucess); - if (this.getAction() == 1) { - action = "取货中"; - } else if (this.getAction() == 2) { - action = "取货完成"; - } else if (this.getAction() == 3) { - action = "放货中"; - } else if (this.getAction() == 4) { - action = "放货完成"; - } - - 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("walk_y", walk_y); - jo.put("isOnline", this.getIsonline()); - jo.put("error", ErrorUtil.getDictDetail("hxhj_error_type", String.valueOf(this.getError()))); - jo.put("isError", this.getIserror()); - jo.put("message", this.getMessage()); - jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); - jo.put("feedMessage", feedMessage); - jo.put("driver_type", "siemens_conveyor"); - jo.put("is_click", true); - jo.put("x", x_position); - jo.put("y", y_position); - 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 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); - } - - @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/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/ItemProtocol.java deleted file mode 100644 index 09015c4..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/ItemProtocol.java +++ /dev/null @@ -1,187 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.plug_pull_device_site; - -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_barcode = "barcode"; - //纸管1重量 - public static String item_weight1 = "weight1"; - //纸管1规格 - public static String item_material1 = "material1"; - //纸管2重量 - public static String item_weight2 = "weight2"; - //纸管2规格 - public static String item_material2 = "material2"; - - //下发命令 - public static String item_to_command = "to_command"; - //纸管1规格 - public static String item_to_material1 = "to_material1"; - //纸管2规格 - public static String item_to_material2 = "to_material2"; - //纸管数量 - public static String item_to_qty = "to_qty"; - //气涨轴类型 - public static String item_to_qzz_type = "to_qzz_type"; - //是否换轴 - public static String item_to_is_changeShaft = "to_is_changeShaft"; - //尺寸 - public static String item_to_size = "to_size"; - //存储位置 - public static String item_to_location = "to_location"; - - private PlugPullDeviceSiteDeviceDriver driver; - - public ItemProtocol(PlugPullDeviceSiteDeviceDriver 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 getBarcode(){ return this.getOpcIntegerValue(item_barcode);} - - public int getWeight1(){ return this.getOpcIntegerValue(item_weight1);} - - public int getMaterial1(){ return this.getOpcIntegerValue(item_material1);} - - public int getWeight2(){ return this.getOpcIntegerValue(item_weight2);} - - public int getMaterial2(){ return this.getOpcIntegerValue(item_material2);} - - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_material1() { - return this.getOpcIntegerValue(item_to_material1); - } - - public int getTo_material2() { - return this.getOpcIntegerValue(item_to_material2); - } - - public int getTo_qty() { - return this.getOpcIntegerValue(item_to_qty); - } - - public int getTo_qzz_type() { - return this.getOpcIntegerValue(item_to_qzz_type); - } - - public int getTo_is_changeShaft() { - return this.getOpcIntegerValue(item_to_is_changeShaft); - } - - public int getTo_size() { - return this.getOpcIntegerValue(item_to_size); - } - - public int getTo_location() { - return this.getOpcIntegerValue(item_to_location); - } - 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) { - 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_barcode, "气胀轴条码", "DB1.B4")); - list.add(new ItemDto(item_weight1, "纸管1重量", "DB1.B4")); - list.add(new ItemDto(item_material1, "纸管1规格", "DB1.B4")); - list.add(new ItemDto(item_weight2, "纸管2重量", "DB1.B4")); - list.add(new ItemDto(item_material2, "纸管2规格", "DB1.B4")); - list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); - list.add(new ItemDto(item_task, "任务号", "DB1.D6")); - 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_material1, "纸管1规格", "DB2.W2")); - list.add(new ItemDto(item_to_material2, "纸管2规格", "DB2.W4")); - list.add(new ItemDto(item_to_qty, "纸管数量", "DB2.W6")); - list.add(new ItemDto(item_to_qzz_type, "气胀轴类型", "DB2.W8")); - list.add(new ItemDto(item_to_is_changeShaft, "是否换轴", "DB2.W")); - list.add(new ItemDto(item_to_location, "存储位置", "DB2.W10")); - list.add(new ItemDto(item_to_size, "尺寸", "DB2.W12")); - return list; - } - - @Override - public String toString() { - return ""; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDefination.java deleted file mode 100644 index e41f56d..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDefination.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.plug_pull_device_site; - -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 PlugPullDeviceSiteDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "plug_pull_device_site"; - } - - @Override - public String getDriverName() { - return "插拔轴工位"; - } - - @Override - public String getDriverDescription() { - return "插拔轴工位"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new PlugPullDeviceSiteDeviceDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return PlugPullDeviceSiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java deleted file mode 100644 index 99bc66e..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java +++ /dev/null @@ -1,472 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.plug_pull_device_site; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -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.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.ext.wms.service.impl.AcsToWmsServiceImpl; -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.task.service.TaskService; -import org.nl.config.SpringContextHolder; -import org.nl.system.service.param.ISysParamService; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 插拔轴工位 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class PlugPullDeviceSiteDeviceDriver 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 - ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); - @Autowired - DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); - @Autowired - AgvService agvService = SpringContextHolder.getBean(AgvService.class); - - 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; - - //工作模式 - 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 barcode =0; - int last_barcode =0; - //纸管1重量 - int weight1 =0; - int last_weight1 =0; - //纸管1规格 - int material1 =0; - int last_material1 =0; - //纸管2重量 - int weight2 =0; - int last_weight2 =0; - //纸管2规格 - int material2 =0; - int last_material2 =0; - - int to_size = 0; - int last_to_size = 0; - - int to_material1 = 0; - int last_to_material1 = 0; - - int to_material2 = 0; - int last_to_material2 = 0; - - int to_qty = 0; - int last_to_qty = 0; - - int to_qzz_type = 0; - int last_to_qzz_type = 0; - - int to_is_changeShaft = 0; - int last_to_is_changeShaft = 0; - - int to_location = 0; - int last_to_location = 0; - - - Boolean isonline = true; - - Boolean iserror = false; - //当前指令 - Instruction inst = null; - - /** - * 1-执行任务;2-取货完成;3-放货完成; - */ - int flag; - - String device_code; - - String message = null; - - @Override - public Device getDevice() { - return this.device; - } - - /** - * 请求成功标记 - */ - Boolean requireSucess = false; - String feedMessage = ""; - - @Override - public void execute() { - String message = null; - 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(); - barcode = this.itemProtocol.getBarcode(); - weight1 = this.itemProtocol.getWeight1(); - material1 = this.itemProtocol.getMaterial1(); - weight2 = this.itemProtocol.getWeight2(); - material2 = this.itemProtocol.getMaterial2(); - to_command = this.itemProtocol.getTo_command(); - to_material1 = this.itemProtocol.getTo_material1(); - to_material2 = this.itemProtocol.getTo_material2(); - to_qty = this.itemProtocol.getTo_qty(); - to_qzz_type=this.itemProtocol.getTo_qzz_type(); - to_is_changeShaft=this.itemProtocol.getTo_is_changeShaft(); - to_location=this.itemProtocol.getTo_location(); - to_size = this.itemProtocol.getTo_size(); - - if (mode != last_mode) { - requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (action != last_action) { - logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); - } - if (error != last_error) { - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (barcode != last_barcode) { - logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(barcode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号barcode:" + last_barcode + "->" + barcode); - } - if (weight1 != last_weight1) { - logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(weight1)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号weight1:" + last_weight1 + "->" + weight1); - } - if (material1 != last_material1) { - logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(material1)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号material1:" + last_material1 + "->" + material1); - } - if (weight2 != last_weight2) { - logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(weight2)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号weight2:" + last_weight2 + "->" + weight2); - } - if (material2 != last_material2) { - logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(material2)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号material2:" + last_material2 + "->" + material2); - } - if (task != last_task) { - logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); - } - if (to_command != last_to_command) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); - } - if (to_material1 != last_to_material1) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_material1:" + last_to_material1 + "->" + to_material1); - } - if (to_material2 != last_to_material2) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_material2:" + last_to_material2 + "->" + to_material2); - } - if (to_qty != last_to_qty) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_qty:" + last_to_qty + "->" + to_qty); - } - if (to_qzz_type != last_to_qzz_type) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_qzz_type:" + last_to_qzz_type + "->" + to_qzz_type); - } - if (to_is_changeShaft != last_to_is_changeShaft) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_is_changeShaft:" + last_to_is_changeShaft + "->" + to_is_changeShaft); - } - if (to_location != last_to_location) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_location:" + last_to_location + "->" + to_location); - } - if (to_size != last_to_size) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_size:" + last_to_size + "->" + to_size); - } - - - - 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: - log.info("待机"); - break; - case 3: - log.info("运行中"); - break; - case 4: - if (move == 1 && !requireSucess && task > 0) { - //申请套管 - apply_casing(mode); - } - break; - case 5: - if (!requireSucess && task > 0) { - //套管完成 - bushingSucess(mode); - } - break; - case 6: - if (!requireSucess && task > 0) { - //拔轴完成 - pullShaftSucess(mode); - } - break; - case 7: - if (!requireSucess && task > 0) { - //套管失败无库存 - //todo - } - break; - case 8: - if (!requireSucess && task > 0) { - //缓存线已满,申请行架任务 -// applyTask(); - } - break; - default: - log.info("未知模式"); - break; - } - } - last_mode = mode; - last_move = move; - last_action = action; - last_error = error; - last_task = task; - last_heartbeat = heartbeat; - last_barcode =barcode; - last_weight1=weight1; - last_weight2=weight2; - last_material1=material1; - last_material2=material2; - last_to_command = to_command; - last_to_material1 =to_material1; - last_to_material2 = to_material2; - last_to_qty=to_qty; - last_to_qzz_type=to_qzz_type; - last_to_is_changeShaft = to_is_changeShaft; - last_to_location=to_location; - last_to_size = to_size; - } - - /** - * 申请套管 - */ - private synchronized void apply_casing(int mode) { - this.writeSignal(mode); - logServer.deviceExecuteLog(this.device_code, "", "", "申请套管,返回参数:" + "applyResponse"); - message = "申请套管成功"; - } - - /** - * 套管完成 - */ - private synchronized void bushingSucess(int mode) { - this.writeSignal(mode); - logServer.deviceExecuteLog(this.device_code, "", "", "反馈套管完成,返回参数:" + "applyResponse"); - message = "套管完成成功"; - } - - /** - * 拔轴完成 - */ - private synchronized void pullShaftSucess(int mode) { - this.writeSignal(mode); - logServer.deviceExecuteLog(this.device_code, "", "", "申请拔轴,返回参数:" + "applyResponse"); - message = "拔轴完成成功"; - } - - public void writeSignal(int mode){ - Map map = new LinkedHashMap<>(); - map.put("to_command", mode); - this.writing(map); - requireSucess = true; - } - - - protected void thingToNothing() { - //this.setRequireSucess(false); - } - - public void writing(List list) { - - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - 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); - this.control(itemMap); - } - - public void writing(Map map) { - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - Map itemMap = new LinkedHashMap<>(); - map.forEach((key, value) -> { - if (ObjectUtil.isNotEmpty(value)) { - itemMap.put(getToParam() + key, value); - } - }); - if (ObjectUtil.isNotEmpty(itemMap)) { - this.control(itemMap); - logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); - } - } - - public String getToParam() { - return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; - } - - /** - * 将扩展表中的字符串数据转换成集合 - */ - @Override - public List getExtraDeviceCodes(String extraName) { - String extraValue = (String) this.getDevice().getExtraValue().get(extraName); - if (StrUtil.isEmpty(extraValue)) { - return new ArrayList<>(); - } - String devicesString = extraValue.substring(1, extraValue.length() - 1); - List devicesList = new ArrayList<>(); - String[] devices = devicesString.split(","); - for (int i = 0; i < devices.length; i++) { - String s = devices[i].replace("\"", "").replace("\"", ""); - devicesList.add(s); - } - return devicesList; - } - - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String action = ""; - String move = ""; - if (this.getMode() == 0) { - mode = "未联机"; - } else if (this.getMode() == 1) { - mode = "单机"; - } else if (this.getMode() == 2) { - mode = "联机"; - } else if (this.getMode() == 3) { - mode = "运行中"; - } - - if (this.getMove() == 0) { - move = "无货"; - jo.put("hasGoods", false); - } else if (this.getMove() == 1) { - move = "有货"; - jo.put("hasGoods", true); - } else if (this.getMove() == 2) { - move = "有托盘有货"; - jo.put("hasGoods", true); - } - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("action", action); - jo.put("isOnline", this.getIsonline()); - jo.put("isError", this.getIserror()); - return jo; - } - - @Override - public void setDeviceStatus(JSONObject data) { - - } - - 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; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - - itemMap.put(to_param, value); -// itemMap.put(to_param, Integer.parseInt(value)); - this.control(itemMap); - } - - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/ItemProtocol.java deleted file mode 100644 index 207c653..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/ItemProtocol.java +++ /dev/null @@ -1,211 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.pull_head_manipulator; - -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_walk_y = "walk_y"; - //任务号 - public static String item_task = "task"; - //报警 - public static String item_error = "error"; - //x轴坐标 - public static String item_x_position = "x_position"; - //y轴坐标 - public static String item_y_position = "y_position"; - - //下发命令 - public static String item_to_command = "to_command"; - //下发起始站 - public static String item_to_onset = "to_onset"; - //下发目标站 - public static String item_to_target = "to_target"; - //下发任务号 - public static String item_to_task = "to_task"; - //是否拔轴 - public static String item_to_pull = "to_pull"; - //是否套轴 - public static String item_to_sleeve = "to_sleeve"; - //尺寸 - public static String item_to_size = "to_size"; - //代数 - public static String item_to_version = "to_version"; - //子卷数量 - public static String item_to_qty = "to_qty"; - //子卷1长度 - public static String item_to_length1 = "to_length1"; - //子卷2长度 - public static String item_to_length2 = "to_length2"; - - - private PullHeadManipulatorDeviceDriver driver; - - public ItemProtocol(PullHeadManipulatorDeviceDriver 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 getWalk_y() { - return this.getOpcIntegerValue(item_walk_y); - } - - 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_pull() { - return this.getOpcIntegerValue(item_to_pull); - } - - public int getTo_sleeve() { - return this.getOpcIntegerValue(item_to_sleeve); - } - - public int getTo_size() { - return this.getOpcIntegerValue(item_to_size); - } - - public int getTo_version() { - return this.getOpcIntegerValue(item_to_version); - } - - public int getTo_qty() { - return this.getOpcIntegerValue(item_to_qty); - } - - public int getTo_onset() { - return this.getOpcIntegerValue(item_to_onset); - } - - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_target() { - return this.getOpcIntegerValue(item_to_target); - } - - public float getX_position() { - return this.getOpcFloatValue(item_x_position); - } - - public float getY_position() { - return this.getOpcFloatValue(item_y_position); - } - - public float getTo_length1() { - return this.getOpcFloatValue(item_to_length1); - } - - public float getTo_length2() { - return this.getOpcFloatValue(item_to_length2); - } - - 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)) { - setIsonline(false); - } else { - 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_walk_y, "行走列", "DB1.B4")); - list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); - list.add(new ItemDto(item_task, "任务号", "DB1.D6")); - list.add(new ItemDto(item_x_position, "x坐标", "DB1.REAL10")); - list.add(new ItemDto(item_y_position, "y坐标", "DB1.REAL14")); - 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_onset, "下发起始站", "DB2.W2")); - list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); - list.add(new ItemDto(item_to_pull, "是否拔轴", "DB2.W8")); - list.add(new ItemDto(item_to_sleeve, "是否套轴", "DB2.W10")); - list.add(new ItemDto(item_to_size, "尺寸", "DB2.W12")); - list.add(new ItemDto(item_to_version, "代数", "DB2.W14")); - list.add(new ItemDto(item_to_qty, "子卷数量", "DB2.W16")); - list.add(new ItemDto(item_to_length1, "子卷1长度", "DB2.W18")); - list.add(new ItemDto(item_to_length2, "子卷2长度", "DB2.W20")); - return list; - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDefination.java deleted file mode 100644 index aad3c1d..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDefination.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.pull_head_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 PullHeadManipulatorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "pull_head_manipulator"; - } - - @Override - public String getDriverName() { - return "拔前行架机械手"; - } - - @Override - public String getDriverDescription() { - return "拔前行架机械手"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new PullHeadManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return PullHeadManipulatorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.station); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java deleted file mode 100644 index b24bd19..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java +++ /dev/null @@ -1,661 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.pull_head_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 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.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -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.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.config.SpringContextHolder; -import org.nl.config.language.LangProcess; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - - -/** - * 拔前行架机械手 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class PullHeadManipulatorDeviceDriver 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); - - //工作模式 - int mode = 0; - int last_mode = 0; - //光电信号 - int move = 0; - int last_move = 0; - //动作信号 - int action = 0; - int last_action = 0; - //行走列 - int walk_y = 0; - int last_walk_y = 0; - //报警信号 - int error = 0; - int last_error = 0; - //任务号 - int task = 0; - int last_task = 0; - // x坐标 - float x_position = 0; - float last_x_position = 0; - // y坐标 - float y_position = 0; - float last_y_position = 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_onset = 0; - int last_to_onset = 0; - - int to_pull = 0; - int last_to_pull = 0; - - int to_sleeve = 0; - int last_to_sleeve = 0; - - int to_size = 0; - int last_to_size = 0; - - int to_version = 0; - int last_to_version = 0; - - int to_qty = 0; - int last_to_qty = 0; - - // 子卷1长度 - float to_length1 = 0; - float last_to_length1 = 0; - // y坐标 - float to_length2 = 0; - float last_to_length2 = 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 = ""; - - - List getDeviceCodeList = null; - - List putDeviceCodeList = null; - - - @Override - public Device getDevice() { - return this.device; - } - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - move = this.itemProtocol.getMove(); - action = this.itemProtocol.getAction(); - walk_y = this.itemProtocol.getWalk_y(); - 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_pull = this.itemProtocol.getTo_pull(); - to_sleeve = this.itemProtocol.getTo_sleeve(); - to_size = this.itemProtocol.getTo_size(); - to_qty = this.itemProtocol.getTo_qty(); - to_version = this.itemProtocol.getTo_version(); - to_length1 = this.itemProtocol.getTo_length1(); - to_length2 = this.itemProtocol.getTo_length2(); - to_onset = this.itemProtocol.getTo_onset(); - x_position = this.itemProtocol.getX_position(); - y_position = this.itemProtocol.getY_position(); - - if (to_onset != last_to_onset) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset:" + last_to_onset + "->" + to_onset); - } - if (to_command != last_to_command) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); - } - if (to_target != last_to_target) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); - } - if (to_task != last_to_task) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); - } - if (to_pull != last_to_pull) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_pull:" + last_to_pull + "->" + to_pull); - } - if (to_sleeve != last_to_sleeve) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_sleeve:" + last_to_sleeve + "->" + to_sleeve); - } - if (to_size != last_to_size) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_size:" + last_to_size + "->" + to_size); - } - if (to_version != last_to_version) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_version:" + last_to_version + "->" + to_version); - } - if (to_qty != last_to_qty) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_qty:" + last_to_qty + "->" + to_qty); - } - if (to_length1 != last_to_length1) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_length1:" + last_to_length1 + "->" + to_length1); - } - if (to_length2 != last_to_length2) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_length2:" + last_to_length2 + "->" + to_length2); - } - if (mode != last_mode) { - requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (action != last_action) { - logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); - } - if (error != last_error) { - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (walk_y != last_walk_y) { - logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); - } - if (task != last_task) { - logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); - } - if (x_position != last_x_position) { - logServer.deviceItemValue(this.device_code, "x_position", String.valueOf(x_position)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号x_position:" + last_x_position + "->" + x_position); - } - if (y_position != last_y_position) { - logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position:" + last_y_position + "->" + y_position); - } - - // 更新指令状态 - if (mode == 3 && task > 0) { - 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 (mode == 3 && action == 4 && move == 0 && task > 0) { - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst2 != null) { - if (StrUtil.equals(inst2.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex())) { - try { - finish_instruction(inst2); - Map map = new LinkedHashMap<>(); - map.put("to_command", "5"); - this.writing(map); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } - - - - } catch (Exception var17) { - var17.printStackTrace(); - feedMessage = var17.getMessage(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); - - } - - 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 == 2 && move == 0 && task == 0 && !requireSucess) { - boolean res = applyTask(); - if (res) { - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - feedMessage = ""; - } - } else { - if (mode == 2) { - //if (!requireSucess) { - String remark = "未查找任务原因为:"; - if (mode != 2) { - remark = remark + "工作模式(mode)不是待机状态,"; - } - if (move != 0) { - remark = remark + "光电信号(move)为有货状态,"; - } - if (task != 0) { - remark = remark + "当前上报任务号(task)应该为0,"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = remark + "请右击该图标,将请求任务复位标记(requireSucess)改为否。"; - } - this.setNotCreateTaskMessage(remark); - //} - } - } - - } - last_mode = mode; - last_move = move; - last_action = action; - last_walk_y = walk_y; - 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_onset = to_onset; - last_x_position = x_position; - last_y_position = y_position; - last_to_pull = to_pull; - last_to_sleeve = to_sleeve; - last_to_size = to_size; - last_to_version = to_version; - last_to_qty = to_qty; - last_to_length1 = to_length1; - last_to_length2 = to_length2; - } - - /** - * // * 申请任务 - * // * - * // * @param - * // - */ - 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 { - this.instruction_require_time = date; - //抓取工位 - List getDeviceCodeList = this.getExtraDeviceCodes("get_device_code"); - //放货工位 - List putDeviceCodeList = this.getExtraDeviceCodes("put_device_code"); - TaskDto task = null; - for (int i = 0; i < getDeviceCodeList.size(); i++) { - String startDeviceCode = getDeviceCodeList.get(i); - List taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtos)) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtos = this.sortTask(taskDtos); - TaskDto taskDto = taskDtos.get(0); - Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code()); - String start_device_code = instruction.getStart_device_code(); - String next_device_code = instruction.getNext_device_code(); - instruction.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - instruction.setUpdate_time(DateUtil.now()); - instructionService.update(instruction); - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { - throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice.getDevice_code())); - } - if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { - throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice.getDevice_code())); - } - String start_addr = startDevice.getExtraValue().get("address").toString(); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - Map map = new LinkedHashMap<>(); - map.put("to_command", CommonFinalParam.ONE); - map.put("to_onset", start_addr); - map.put("to_task", instruction.getInstruction_code()); - map.put("to_target", next_addr); - this.writing(map); - this.setRequireSucess(true); - return true; - } else { - List taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtoList)) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtoList = this.sortTask(taskDtoList); - task = taskDtoList.get(0); - } - if (ObjectUtil.isNotEmpty(task)) { - break; - } - } - } - if (!ObjectUtil.isEmpty(task)) { - String taskid = task.getTask_id(); - String taskcode = task.getTask_code(); - String vehiclecode = task.getVehicle_code(); - String priority = task.getPriority(); - String start_point_code = task.getStart_point_code(); - String start_device_code = task.getStart_device_code(); - String route_plan_code = task.getRoute_plan_code(); - String next_point_code = task.getNext_point_code(); - String next_device_code = task.getNext_device_code(); - - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(task.getRemark()); - instdto.setMaterial(task.getMaterial()); - instdto.setQuantity(task.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); - instdto.setExecute_device_code(start_point_code); - - try { - instructionService.create(instdto); - } catch (Exception e) { - notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); - return false; - } - //创建指令后修改任务状态 - task.setTask_status(TaskStatusEnum.BUSY.getIndex()); - task.setUpdate_time(DateUtil.now()); - taskserver.update(task); - - Device startDevice = deviceAppService.findDeviceByCode(instdto.getStart_device_code()); - Device nextDevice = deviceAppService.findDeviceByCode(instdto.getNext_device_code()); - if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { - notCreateInstMessage = "设备:" + startDevice.getDevice_code() + "未设置电气调度号!"; - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); - throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice.getDevice_code())); - } - if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { - notCreateInstMessage = "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"; - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); - throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice.getDevice_code())); - - } - String start_addr = startDevice.getExtraValue().get("address").toString(); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - Map map = new LinkedHashMap<>(); - map.put("to_command", CommonFinalParam.ONE); - map.put("to_onset", start_addr); - map.put("to_task", instdto.getInstruction_code()); - map.put("to_target", next_addr); - this.writing(map); - this.setRequireSucess(true); - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - } else { - notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; - } - return true; - } - } - - public synchronized boolean finish_instruction(Instruction inst) throws Exception { - instructionService.finish(inst); - return true; - } - - public String getToParam() { - return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; - } - - /** - * 多个信号一起下发电气 - * - * @param map - */ - public void writing(Map map) { - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - Map itemMap = new LinkedHashMap<>(); - map.forEach((key, value) -> { - if (ObjectUtil.isNotEmpty(value)) { - itemMap.put(getToParam() + key, value); - } - }); - if (ObjectUtil.isNotEmpty(itemMap)) { - this.control(itemMap); - logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); - } - } - - public List sortTask(List taskDtos) { - Collections.sort(taskDtos, new Comparator() { - @Override - public int compare(TaskDto t1, TaskDto t2) { - //优先级从大到小 - int i = t2.getPriority().compareTo(t1.getPriority()); - //如果优先级相等 - if (i == 0) { - //时间从早到晚 - i = t1.getCreate_time().compareTo(t2.getCreate_time()); - } - return i; - } - }); - return taskDtos; - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String move = ""; - String action = ""; - String walk_y = ""; - if (this.getMode() == 0) { - mode = "脱机"; - } else if (this.getMode() == 1) { - mode = "单机"; - } else if (this.getMode() == 2) { - mode = "待机"; - } else if (this.getMode() == 3) { - mode = "运行中"; - } - - if (this.getMove() == 0) { - move = "无货"; - } else if (this.getMove() == 1) { - move = "有货"; - } - - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = "1"; - } - jo.put("requireSucess", requireSucess); - if (this.getAction() == 1) { - action = "取货中"; - } else if (this.getAction() == 2) { - action = "取货完成"; - } else if (this.getAction() == 3) { - action = "放货中"; - } else if (this.getAction() == 4) { - action = "放货完成"; - } - - 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("walk_y", walk_y); - jo.put("isOnline", this.getIsonline()); - jo.put("error", this.getError()); - jo.put("isError", this.getIserror()); - jo.put("message", this.getMessage()); - jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); - jo.put("feedMessage", feedMessage); - jo.put("driver_type", "siemens_conveyor"); - jo.put("is_click", true); - jo.put("x", x_position); - jo.put("y", y_position); - 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/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/ItemProtocol.java deleted file mode 100644 index fcd35a5..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/ItemProtocol.java +++ /dev/null @@ -1,168 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.pull_tail_manipulator; - -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_walk_y = "walk_y"; - //任务号 - public static String item_task = "task"; - //报警 - public static String item_error = "error"; - //x轴坐标 - public static String item_x_position = "x_position"; - //y轴坐标 - public static String item_y_position = "y_position"; - //重量 - public static String item_weight = "weight"; - - //下发命令 - public static String item_to_command = "to_command"; - //下发起始站 - public static String item_to_onset = "to_onset"; - //下发目标站 - public static String item_to_target = "to_target"; - //下发任务号 - public static String item_to_task = "to_task"; - - private PullTailManipulatorDeviceDriver driver; - - public ItemProtocol(PullTailManipulatorDeviceDriver 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 getWalk_y() { - return this.getOpcIntegerValue(item_walk_y); - } - - 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_onset() { - return this.getOpcIntegerValue(item_to_onset); - } - - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_target() { - return this.getOpcIntegerValue(item_to_target); - } - - public float getX_position() { - return this.getOpcFloatValue(item_x_position); - } - - public float getY_position() { - return this.getOpcFloatValue(item_y_position); - } - - public float getWeight() { - return this.getOpcFloatValue(item_weight); - } - - 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)) { - setIsonline(false); - } else { - 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_walk_y, "行走列", "DB1.B4")); - list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); - list.add(new ItemDto(item_task, "任务号", "DB1.D6")); - list.add(new ItemDto(item_x_position, "x坐标", "DB1.REAL10")); - list.add(new ItemDto(item_y_position, "y坐标", "DB1.REAL14")); - list.add(new ItemDto(item_weight, "重量", "DB1.REAL16")); - 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_onset, "下发起始站", "DB2.W2")); - list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); - return list; - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDefination.java deleted file mode 100644 index 936d8a5..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDefination.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.pull_tail_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 PullTailManipulatorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "pull_tail_manipulator"; - } - - @Override - public String getDriverName() { - return "拔后行架机械手"; - } - - @Override - public String getDriverDescription() { - return "拔后行架机械手"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new PullTailManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return PullTailManipulatorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.station); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDeviceDriver.java deleted file mode 100644 index 090099c..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDeviceDriver.java +++ /dev/null @@ -1,664 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.pull_tail_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 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.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -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.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.config.SpringContextHolder; -import org.nl.config.language.LangProcess; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 拔后行架机械手 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class PullTailManipulatorDeviceDriver 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); - - //工作模式 - int mode = 0; - int last_mode = 0; - //光电信号 - int move = 0; - int last_move = 0; - //动作信号 - int action = 0; - int last_action = 0; - //行走列 - int walk_y = 0; - int last_walk_y = 0; - //报警信号 - int error = 0; - int last_error = 0; - //任务号 - int task = 0; - int last_task = 0; - // x坐标 - float x_position = 0; - float last_x_position = 0; - // y坐标 - float y_position = 0; - float last_y_position = 0; - - //重量 - float weight = 0; - float last_weight = 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_onset = 0; - int last_to_onset = 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 = ""; - - - List getDeviceCodeList = null; - - List putDeviceCodeList = null; - - - @Override - public Device getDevice() { - return this.device; - } - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - move = this.itemProtocol.getMove(); - action = this.itemProtocol.getAction(); - walk_y = this.itemProtocol.getWalk_y(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - heartbeat = this.itemProtocol.getHeartbeat(); - weight = this.itemProtocol.getWeight(); - to_command = this.itemProtocol.getTo_command(); - to_target = this.itemProtocol.getTo_target(); - to_task = this.itemProtocol.getTo_task(); - to_onset = this.itemProtocol.getTo_onset(); - x_position = this.itemProtocol.getX_position(); - y_position = this.itemProtocol.getY_position(); - - if (to_onset != last_to_onset) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset:" + last_to_onset + "->" + to_onset); - } - if (to_command != last_to_command) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); - } - if (to_target != last_to_target) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); - } - if (to_task != last_to_task) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); - } - if (mode != last_mode) { - requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (action != last_action) { - logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); - } - if (error != last_error) { - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (walk_y != last_walk_y) { - logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); - } - if (task != last_task) { - logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); - } - if (x_position != last_x_position) { - logServer.deviceItemValue(this.device_code, "x_position", String.valueOf(x_position)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号x_position:" + last_x_position + "->" + x_position); - } - if (y_position != last_y_position) { - logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position:" + last_y_position + "->" + y_position); - } - if (weight != last_weight) { - logServer.deviceItemValue(this.device_code, "weight", String.valueOf(weight)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号weight:" + last_weight + "->" + weight); - } - - // 更新指令状态 - if (mode == 3 && task > 0) { - 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 (mode == 3 && action == 5 && move == 0 && task > 0 && !requireSucess) { - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); - if (ObjectUtil.isNotEmpty(inst2)) { - Map map = new LinkedHashMap<>(); - //todo:反馈重量 - map.put("to_command", "5"); - this.writing(map); - this.requireSucess = true; - } else { - logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许取货(now_steps_type!=3)"); - } - } else { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "mode不为运行中状态,"; - } - if (action != 5) { - feedMessage = feedMessage + "action不为反馈重量状态,"; - } - if (move != 1) { - feedMessage = feedMessage + "move不为有货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "task为0。"; - } - } - - //任务完成 - if (mode == 3 && action == 6 && move == 0 && task > 0 && !requireSucess) { - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst2 != null) { - if (StrUtil.equals(inst2.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex())) { - try { - finish_instruction(inst2); - Map map = new LinkedHashMap<>(); - map.put("to_command", "6"); - this.writing(map); - this.requireSucess = true; - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } - - } catch (Exception var17) { - var17.printStackTrace(); - feedMessage = var17.getMessage(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); - - } - - 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 == 2 && move == 0 && task == 0 && !requireSucess) { - boolean res = applyTask(); - if (res) { - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - feedMessage = ""; - } - } else { - if (mode == 2) { - //if (!requireSucess) { - String remark = "未查找任务原因为:"; - if (mode != 2) { - remark = remark + "工作模式(mode)不是待机状态,"; - } - if (move != 0) { - remark = remark + "光电信号(move)为有货状态,"; - } - if (task != 0) { - remark = remark + "当前上报任务号(task)应该为0,"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = remark + "请右击该图标,将请求任务复位标记(requireSucess)改为否。"; - } - this.setNotCreateTaskMessage(remark); - //} - } - - switch (action) { - case 1: - //取货中 - break; - case 2: - //取货完成 - /*if (move > 0 && !requireSucess) { - instruction_require(); - }*/ - break; - case 3: - //放货中 - break; - case 4: - //放货完成 - if (move == 1 && !requireSucess && task > 0) { - //申请套管校验 -// apply_for_casing_inspection(material1, material2); -// bushingSucess(); - } - break; - default: - log.info("未知模式"); - break; - } - } - - } - last_mode = mode; - last_move = move; - last_action = action; - last_walk_y = walk_y; - last_error = error; - last_task = task; - last_weight = weight; - last_heartbeat = heartbeat; - last_to_task = to_task; - last_to_command = to_command; - last_to_target = to_target; - last_to_onset = to_onset; - last_x_position = x_position; - last_y_position = y_position; - } - - /** - * // * 申请任务 - * // * - * // * @param - * // - */ - 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 { - this.instruction_require_time = date; - //抓取工位 - List getDeviceCodeList = this.getExtraDeviceCodes("get_device_code"); - //放货工位 - List putDeviceCodeList = this.getExtraDeviceCodes("put_device_code"); - TaskDto task = null; - for (int i = 0; i < getDeviceCodeList.size(); i++) { - String startDeviceCode = getDeviceCodeList.get(i); - List taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtos)) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtos = this.sortTask(taskDtos); - TaskDto taskDto = taskDtos.get(0); - Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code()); - String start_device_code = instruction.getStart_device_code(); - String next_device_code = instruction.getNext_device_code(); - instruction.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - instruction.setUpdate_time(DateUtil.now()); - instructionService.update(instruction); - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { - throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice.getDevice_code())); - } - if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { - throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice.getDevice_code())); - } - String start_addr = startDevice.getExtraValue().get("address").toString(); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - Map map = new LinkedHashMap<>(); - map.put("to_command", CommonFinalParam.ONE); - map.put("to_onset", start_addr); - map.put("to_task", instruction.getInstruction_code()); - map.put("to_target", next_addr); - this.writing(map); - this.setRequireSucess(true); - return true; - } else { - List taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtoList)) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtoList = this.sortTask(taskDtoList); - task = taskDtoList.get(0); - } - if (ObjectUtil.isNotEmpty(task)) { - break; - } - } - } - if (!ObjectUtil.isEmpty(task)) { - String taskid = task.getTask_id(); - String taskcode = task.getTask_code(); - String vehiclecode = task.getVehicle_code(); - String priority = task.getPriority(); - String start_point_code = task.getStart_point_code(); - String start_device_code = task.getStart_device_code(); - String route_plan_code = task.getRoute_plan_code(); - String next_point_code = task.getNext_point_code(); - String next_device_code = task.getNext_device_code(); - - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(task.getRemark()); - instdto.setMaterial(task.getMaterial()); - instdto.setQuantity(task.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); - instdto.setExecute_device_code(start_point_code); - - try { - instructionService.create(instdto); - } catch (Exception e) { - notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); - return false; - } - //创建指令后修改任务状态 - task.setTask_status(TaskStatusEnum.BUSY.getIndex()); - task.setUpdate_time(DateUtil.now()); - taskserver.update(task); - - Device startDevice = deviceAppService.findDeviceByCode(instdto.getStart_device_code()); - Device nextDevice = deviceAppService.findDeviceByCode(instdto.getNext_device_code()); - if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { - notCreateInstMessage = "设备:" + startDevice.getDevice_code() + "未设置电气调度号!"; - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); - throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice.getDevice_code())); - } - if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { - notCreateInstMessage = "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"; - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); - throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice.getDevice_code())); - - } - String start_addr = startDevice.getExtraValue().get("address").toString(); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - Map map = new LinkedHashMap<>(); - map.put("to_command", CommonFinalParam.ONE); - map.put("to_onset", start_addr); - map.put("to_task", instdto.getInstruction_code()); - map.put("to_target", next_addr); - this.writing(map); - this.setRequireSucess(true); - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - } else { - notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; - } - return true; - } - } - - public synchronized boolean finish_instruction(Instruction inst) throws Exception { - instructionService.finish(inst); - return true; - } - - public String getToParam() { - return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; - } - - /** - * 多个信号一起下发电气 - * - * @param map - */ - public void writing(Map map) { - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - Map itemMap = new LinkedHashMap<>(); - map.forEach((key, value) -> { - if (ObjectUtil.isNotEmpty(value)) { - itemMap.put(getToParam() + key, value); - } - }); - if (ObjectUtil.isNotEmpty(itemMap)) { - this.control(itemMap); - logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); - } - } - - public List sortTask(List taskDtos) { - Collections.sort(taskDtos, new Comparator() { - @Override - public int compare(TaskDto t1, TaskDto t2) { - //优先级从大到小 - int i = t2.getPriority().compareTo(t1.getPriority()); - //如果优先级相等 - if (i == 0) { - //时间从早到晚 - i = t1.getCreate_time().compareTo(t2.getCreate_time()); - } - return i; - } - }); - return taskDtos; - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String mode = ""; - String move = ""; - String action = ""; - String walk_y = ""; - if (this.getMode() == 0) { - mode = "脱机"; - } else if (this.getMode() == 1) { - mode = "单机"; - } else if (this.getMode() == 2) { - mode = "待机"; - } else if (this.getMode() == 3) { - mode = "运行中"; - } - - if (this.getMove() == 0) { - move = "无货"; - } else if (this.getMove() == 1) { - move = "有货"; - } - - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = "1"; - } - jo.put("requireSucess", requireSucess); - if (this.getAction() == 1) { - action = "取货中"; - } else if (this.getAction() == 2) { - action = "取货完成"; - } else if (this.getAction() == 3) { - action = "放货中"; - } else if (this.getAction() == 4) { - action = "放货完成"; - } - - 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("walk_y", walk_y); - jo.put("isOnline", this.getIsonline()); - jo.put("error", this.getError()); - jo.put("isError", this.getIserror()); - jo.put("message", this.getMessage()); - jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); - jo.put("feedMessage", feedMessage); - jo.put("driver_type", "siemens_conveyor"); - jo.put("is_click", true); - jo.put("x", x_position); - jo.put("y", y_position); - 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/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/ItemProtocol.java deleted file mode 100644 index 44a78f0..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/ItemProtocol.java +++ /dev/null @@ -1,193 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.slit_two_manipulator; - -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_status = "status"; - //前工位光电信号 - public static String item_move1 = "move1"; - //后工位光电信号 - public static String item_move2 = "move2"; - //前工位动作信号 - public static String item_action1 = "action1"; - //后工位动作信号 - public static String item_action2 = "action2"; - /** - * 行走列 - */ - public static String item_walk_y = "walk_y"; - /** - * 报警 - */ - public static String item_error = "error"; - //任务类型 - public static String item_type = "type"; - //前工位任务号 - public static String item_task1 = "task1"; - //后工位任务号 - public static String item_task2 = "task2"; - - - //前工位下发命令 - public static String item_to_command1 = "to_command1"; - //前工位下发起始站 - public static String item_to_onset1 = "to_onset1"; - //前工位下发目标站 - public static String item_to_target1 = "to_target1"; - //前工位下发任务号 - public static String item_to_task1 = "to_task1"; - //后工位下发命令 - public static String item_to_command2 = "to_command2"; - //后工位下发起始站 - public static String item_to_onset2 = "to_onset2"; - //后工位下发目标站 - public static String item_to_target2 = "to_target2"; - //后工位下发任务号 - public static String item_to_task2 = "to_task2"; - //任务类型 1前工位 2后工位 3双工位 - public static String item_to_type = "to_type"; - - - private SlitTwoManipulatorDeviceDriver driver; - - public ItemProtocol(SlitTwoManipulatorDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getMove1() { - return this.getOpcIntegerValue(item_move1); - } - - public int getMove2() { - return this.getOpcIntegerValue(item_move2); - } - - public int getAction1() { - return this.getOpcIntegerValue(item_action1); - } - - public int getAction2() { - return this.getOpcIntegerValue(item_action2); - } - - public int getWalk_y() { - return this.getOpcIntegerValue(item_walk_y); - } - - public int getType() { - return this.getOpcIntegerValue(item_type); - } - - public int getTask1() { - return this.getOpcIntegerValue(item_task1); - } - - public int getTask2() { - return this.getOpcIntegerValue(item_task2); - } - - - /** - *是否有货 - */ - public int hasGoods(int move) { - return move; - } - - 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 "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_status, "设备状态", "DB1.B2")); - list.add(new ItemDto(item_move1, "前工位光电信号", "DB1.B3")); - list.add(new ItemDto(item_move2, "后工位光电信号", "DB1.B4")); - list.add(new ItemDto(item_action1, "前工位动作信号", "DB1.B5")); - list.add(new ItemDto(item_action2, "后工位动作信号", "DB2.B6")); - list.add(new ItemDto(item_walk_y, "行走列", "DB1.B7")); - list.add(new ItemDto(item_error, "报警信号", "DB1.B8")); - list.add(new ItemDto(item_type, "任务类型", "DB1.B9")); - list.add(new ItemDto(item_task1, "前工位任务号", "DB1.D10")); - list.add(new ItemDto(item_task2, "后工位任务号", "DB1.D14")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command1, "前工位下发命令", "DB2.W0")); - list.add(new ItemDto(item_to_onset1, "前工位下发起始站", "DB2.W2")); - list.add(new ItemDto(item_to_target1, "前工位下发目标站", "DB2.W4")); - list.add(new ItemDto(item_to_task1, "前工位下发任务号", "DB2.D6")); - list.add(new ItemDto(item_to_command2, "后工位下发命令", "DB2.W10")); - list.add(new ItemDto(item_to_onset2, "后工位下发起始站", "DB2.W12")); - list.add(new ItemDto(item_to_target2, "后工位下发目标站", "DB2.W14")); - list.add(new ItemDto(item_to_task2, "后工位下发任务号", "DB2.D16")); - list.add(new ItemDto(item_to_type, "下发任务类型", "DB2.W20")); - return list; - } - - @Override - public String toString() { - return ""; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDefination.java deleted file mode 100644 index ec7e7e9..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDefination.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.slit_two_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 SlitTwoManipulatorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "slit_two_manipulator"; - } - - @Override - public String getDriverName() { - return "分切双工位-行架机械手"; - } - - @Override - public String getDriverDescription() { - return "分切双工位-行架机械手"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new SlitTwoManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return SlitTwoManipulatorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.station); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java deleted file mode 100644 index acc05e9..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java +++ /dev/null @@ -1,1248 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.slit_two_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 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.DeviceService; -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.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.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.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.config.SpringContextHolder; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 分切双工位行架机械手 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - - //分切行架机械手是否禁用 0否 1是 - private int is_disable = 0; - - /** - * 工作模式 - */ - int mode = 0; - int last_mode = 0; - //设备状态 - int status = 0; - int last_status = 0; - //前后工位光电信号 - int move1 = 0; - int last_move1 = 0; - int move2 = 0; - int last_move2 = 0; - //前后工位动作信号 - int action1 = 0; - int last_action1 = 0; - int action2 = 0; - int last_action2 = 0; - /** - * 报警 - */ - int error = 0; - int last_error = 0; - /** - * 行走列 - */ - int walk_y = 0; - int last_walk_y = 0; - //任务类型 - int type = 0; - int last_type = 0; - //前后工位任务号 - int task1 = 0; - int last_task1 = 0; - int task2 = 0; - int last_task2 = 0; - - - Boolean isonline = true; - //前工位申请任务请求标记 - Boolean requireSucess = false; - - int hasGoods = 0; - String message = null; - Boolean iserror = false; - private Date instruction_update_time = new Date(); - private int instruction_update_time_out = 500; - - int branchProtocol = 0; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - //前工位任务执行当前步骤 - //0未执行 1更改指令状态 2下发电气任务信息 3前工位允许取货 4前工位取货完成 5前工位允许放货 6放货完成 - int now_steps_type1 = 0; - //后工位当前执行步骤 - //0未执行 1更改指令状态 2下发电气任务信息 3后工位允许取货4后工位取货完成 5后工位允许放货 6放货完成 - int now_steps_type2 = 0; - //双工位任务当前执行步骤 - //0未执行 1更改指令状态 2下发电气任务信息 3后工位允许取货 4后工位取货完成 5前工位允许取货 6前工位取货完成 7后工位允许放货 8后工位放货完成 9前工位允许放货 10前工位放货完成 - int now_steps_type3 = 0; - - String device_code; - - - //请求超时时间 - private int instruction_require_time_out = 3000; - - - //后工位申请任务请求时间 - private Date instruction_require_time = new Date(); - //前工位申请任务请求时间 - private Date instruction_head_time = new Date(); - - String notCreateTaskMessage = ""; - String notCreateInstMessage = ""; - String feedMessage = ""; - - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public synchronized void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - status = this.itemProtocol.getStatus(); - move1 = this.itemProtocol.getMove1(); - move2 = this.itemProtocol.getMove2(); - action1 = this.itemProtocol.getAction1(); - action2 = this.itemProtocol.getAction2(); - walk_y = this.itemProtocol.getWalk_y(); - error = this.itemProtocol.getError(); - type = this.itemProtocol.getType(); - task1 = this.itemProtocol.getTask1(); - task2 = this.itemProtocol.getTask2(); - - if (mode != last_mode) { - if (mode == 2) { - logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为:" + requireSucess); - requireSucess = false; - logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为:" + requireSucess); - } - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (type != last_type) { - logServer.deviceItemValue(this.device_code, "type", String.valueOf(type)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号type:" + last_type + "->" + type); - } - if (error != last_error) { - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (status != last_status) { - logServer.deviceItemValue(this.device_code, "status", String.valueOf(status)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + "->" + status); - } - if (move1 != last_move1) { - logServer.deviceItemValue(this.device_code, "move1", String.valueOf(move1)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move1:" + last_move1 + "->" + move1); - } - if (move2 != last_move2) { - logServer.deviceItemValue(this.device_code, "move2", String.valueOf(move2)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move2:" + last_move2 + "->" + move2); - } - if (action1 != last_action1) { - logServer.deviceItemValue(this.device_code, "action1", String.valueOf(action1)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action1:" + last_action1 + "->" + action1); - } - if (action2 != last_action2) { - logServer.deviceItemValue(this.device_code, "action2", String.valueOf(action2)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action2:" + last_action2 + "->" + action2); - } - if (walk_y != last_walk_y) { - logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); - } - if (task1 != last_task1) { - logServer.deviceItemValue(this.device_code, "task1", String.valueOf(task1)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号task1:" + last_task1 + "->" + task1); - } - if (task2 != last_task2) { - logServer.deviceItemValue(this.device_code, "task2", String.valueOf(task2)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号task2:" + last_task2 + "->" + task2); - } - - if (task1 > 0 && task2 > 0 && !requireSucess) { - update_instruction_status1(); - } - - - } catch (Exception var17) { - feedMessage = var17.getMessage(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage()); -// return; - } - -// if (!this.itemProtocol.getIsonline()) { -// this.setIsonline(false); -// this.setIserror(true); -// message = "信号量同步异常"; -// //未联机 -// } else - if (mode == 0) { - this.setIsonline(false); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - //申请任务 - if (move1 == 0 && move2 == 0 && action1 == 0 && action2 == 0 && task1 == 0 && task2 == 0 && !requireSucess) { - //获取关联设备驱动信息 判断关联设备是否禁用 - String link_device_code = String.valueOf(this.getDevice().getExtraValue().get("link_device_code")); - Device device = deviceAppservice.findDeviceByCode(link_device_code); - SlitTwoManipulatorDeviceDriver slitTwoManipulatorDeviceDriver; - if (device.getDeviceDriver() instanceof SlitTwoManipulatorDeviceDriver) { - slitTwoManipulatorDeviceDriver = (SlitTwoManipulatorDeviceDriver) device.getDeviceDriver(); - //如果禁用 - if (slitTwoManipulatorDeviceDriver.getIs_disable() == 1) { - boolean flag = false; - try { - //就去走关联设备异常取放货工位的任务 任务生成成功返回true 就不会走下面正常生成任务的逻辑 - flag = instruction_require2(); - } catch (Exception e) { - flag = false; - } - if (flag) { - break; - } - } - } - //没有生成异常取放货工位的任务 就生成正常关联取放货工位的任务 - boolean res = applyTask(); - if (res) { - feedMessage = ""; - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - logServer.deviceExecuteLog(device_code, "", String.valueOf(task1), "move2:" + move2 + ",action2:" + action2 + ",move1:" + move1 + ",action1:" + action1 + ",requireSucess:" + requireSucess); - } - } else { -// if (!requireSucess) { -// remark = remark + "请求标记为true,请检查mode是否由其他值变为2!"; -// } - if (!requireSucess) { - String remark = ""; - if (mode != 2) { - remark = remark + "行架工作模式不为待机(mode != 2),"; - } - if (move1 != 0) { - remark = remark + "前工位有货(move1 != 0),"; - } - if (move2 != 0) { - remark = remark + "后工位有货(move2 != 0),"; - } - if (action1 != 0) { - remark = remark + "前工位动作信号不为0(action1 != 0),"; - } - if (action2 != 0) { - remark = remark + "后工位动作信号不为0(action2 != 0),"; - } - if (task1 != 0) { - remark = remark + "前工位存在任务(task1 != 0),"; - } - if (task2 != 0) { - remark = remark + "后工位存在任务(task2 != 0),"; - } - this.setNotCreateTaskMessage(remark); - } - } - break; - case 3: - break; - default: - break; - } - - } - last_mode = mode; - last_error = error; - last_status = status; - last_move1 = move1; - last_move2 = move2; - last_action1 = action1; - last_action2 = action2; - last_walk_y = walk_y; - last_type = type; - last_task1 = task1; - last_task2 = task2; - } - - - /** - * 更新分切机下双卷指令状态 - */ - public synchronized void update_instruction_status1() 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; - //单任务 前工位任务更新指令状态 - if (task1 > 0 && type == 1) { - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); - if (inst1 != null) { - if (StrUtil.equals(inst1.getInstruction_status(), "0")) { - //当前执行步骤为更新任务状态 - inst1.setInstruction_status("1"); - inst1.setExecute_device_code(this.getDevice_code()); - instructionService.update(inst1); - } - } - } - -// if (mode = 3 && move1 = 0 && move2 = 0 && action1 = 5 && action2 = 5) { -// -// } - } - } - - //关联设备异常申请任务 - public synchronized boolean instruction_require2() { - Boolean flag = false; - Date date = new Date(); - if (date.getTime() - this.instruction_head_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_head_time); - return false; - } else { - this.instruction_head_time = date; - //前工位取货关联设备 - List getDeviceCodeList = this.getExtraDeviceCodes("error_head_get_device_code"); - //后工位取货关联设备 - List backGetDeviceCodeList = this.getExtraDeviceCodes("error_back_get_device_code"); - TaskDto taskDto = null; - //遍历前工位取货点设备 - for (String getDeviceCode : getDeviceCodeList) { - //去任务表中查询是否有前工位关联设备的重新创建指令的任务 - List taskDtos = taskserver.queryTaskByStartAndIntStatus(getDeviceCode); - //如果有 - if (ObjectUtil.isNotEmpty(taskDtos)) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtos = this.sortTask(taskDtos); - taskDto = taskDtos.get(0); - flag = this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); - return flag; - } else { - //去任务表中查询是否有前工位关联设备的就绪状态下的任务 - taskDtos = taskserver.queryTaskByStartDeviceCode(getDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtos)) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtos = this.sortTask(taskDtos); - taskDto = taskDtos.get(0); - break; - } - } - } - //如果任务表中起点1或起点2中 无前工位取货点关联设备 - //就去查询任务表中查找起点1或起点2为后工位取货点关联设备的任务 - if (ObjectUtil.isEmpty(taskDto)) { - for (String backGetDeviceCode : backGetDeviceCodeList) { - //去任务表中查询是否有前工位关联设备的重新创建指令的任务 - List taskDtos = taskserver.queryTaskByNextAndIntStatus(backGetDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtos)) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtos = this.sortTask(taskDtos); - taskDto = taskDtos.get(0); - flag = this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); - return flag; - } else { - //去任务表中查询是否有后工位关联设备的就绪状态下的任务 - taskDtos = taskserver.queryTaskByBackDeviceCode(backGetDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtos)) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtos = this.sortTask(taskDtos); - taskDto = taskDtos.get(0); - break; - } - } - } - } - if (!ObjectUtil.isEmpty(taskDto)) { - flag = this.executeReadyBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); - if (flag) { - notCreateInstMessage = ""; - } - } else { - notCreateTaskMessage = ""; - notCreateInstMessage = "未找到关联设备禁用的任务!"; - } - } - return flag; - } - - //正常申请任务 - public synchronized boolean applyTask() { - boolean flag = false; - Date date = new Date(); - if (date.getTime() - this.instruction_head_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_head_time); - return false; - } else { - this.instruction_head_time = date; - //前工位取货关联设备 - List getDeviceCodeList = this.getExtraDeviceCodes("head_get_device_code"); - //后工位取货关联设备 - List backGetDeviceCodeList = this.getExtraDeviceCodes("back_get_device_code"); - TaskDto taskDto = null; - //遍历前工位取货点设备 - for (String getDeviceCode : getDeviceCodeList) { - //去任务表中查询是否有前工位关联设备的重新创建指令的任务 - List taskDtos = taskserver.queryTaskByStartAndIntStatus(getDeviceCode); - //如果有 - if (ObjectUtil.isNotEmpty(taskDtos)) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtos = this.sortTask(taskDtos); - taskDto = taskDtos.get(0); - //分切机出双卷任务 - if (StrUtil.equals(taskDto.getTruss_type(), "1")) { - inst_require1(taskDto, getDeviceCodeList, backGetDeviceCodeList); - } - //分切机出上卷-行架取单轴 - else if (StrUtil.equals(taskDto.getTruss_type(), "2")) { -// inst_require2(taskDto, getDeviceCodeList, backGetDeviceCodeList); - } - //分切机出下卷-行架取单轴 - else if (StrUtil.equals(taskDto.getTruss_type(), "3")) { -// inst_require3(taskDto, getDeviceCodeList, backGetDeviceCodeList); - } - flag = this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); - return flag; - } else { - //去任务表中查询是否有前工位关联设备的就绪状态下的任务 - taskDtos = taskserver.queryTaskByStartDeviceCode(getDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtos)) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtos = this.sortTask(taskDtos); - taskDto = taskDtos.get(0); - break; - } - } - } - //如果任务表中起点1或起点2中 无前工位取货点关联设备 - //就去查询任务表中查找起点1或起点2为后工位取货点关联设备的任务 - if (ObjectUtil.isEmpty(taskDto)) { - for (String backGetDeviceCode : backGetDeviceCodeList) { - //去任务表中查询是否有前工位关联设备的重新创建指令的任务 - List taskDtos = taskserver.queryTaskByNextAndIntStatus(backGetDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtos)) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtos = this.sortTask(taskDtos); - taskDto = taskDtos.get(0); - flag = this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); - return flag; - } else { - //去任务表中查询是否有后工位关联设备的就绪状态下的任务 - taskDtos = taskserver.queryTaskByBackDeviceCode(backGetDeviceCode); - if (ObjectUtil.isNotEmpty(taskDtos)) { - //按照优先级排序 优先级相等按照创建时间排序 - taskDtos = this.sortTask(taskDtos); - taskDto = taskDtos.get(0); - break; - } - } - } - } - - if (!ObjectUtil.isEmpty(taskDto)) { - flag = this.executeReadyBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); - if (flag) { - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - } - } else { - notCreateTaskMessage = ""; - notCreateInstMessage = "未找到正常关联设备的任务!"; - } - } - return flag; - } - - //执行重新生成分切机出双卷的任务 - public synchronized boolean inst_require1(TaskDto taskDto, List getDeviceCodeList, List backGetDeviceCodeList) { - boolean flag = false; - //获取指令信息 - Instruction instructionDto = instructionService.findByTaskcodeAndStatus(taskDto.getTask_code()); - //获取指令表中的取货点1 - String start_device_code = instructionDto.getStart_device_code(); - //获取指令表中的取货点2 - String start_device_code2 = instructionDto.getStart_device_code2(); - //获取指令表中的放货点1 - String next_device_code = instructionDto.getNext_device_code(); - //获取指令表中的放货点2 - String next_device_code2 = instructionDto.getNext_device_code2(); - //判断任务点位是否配置电气信号 - Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); - Device startDevice2 = deviceAppservice.findDeviceByCode(start_device_code2); - Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); - Device nextDevice2 = deviceAppservice.findDeviceByCode(next_device_code2); - this.isSetAddress(startDevice); - this.isSetAddress(nextDevice); - this.isSetAddress(startDevice2); - this.isSetAddress(nextDevice2); - - //修改指令状态 - instructionDto.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - instructionDto.setUpdate_time(DateUtil.now()); - instructionService.update(instructionDto); - flag = true; - //下发电气信号 - this.sendSignal(instructionDto, taskDto); - //请求任务成功 - requireSucess = true; - return flag; - } - - //下发电气信号 - public synchronized void sendSignal(Instruction dto, TaskDto taskDto) { - logServer.deviceExecuteLog(this.getDeviceCode(), "", "", "开始下发电气信号,即下发电气指令信息为:" - + dto.toString()); - 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); - String start_addr = startDevice.getExtraValue().get("address").toString(); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - - String start_device_code2 = dto.getStart_device_code2(); - String next_device_code2 = dto.getNext_device_code2(); - Device startDevice2 = deviceAppservice.findDeviceByCode(start_device_code2); - Device nextDevice2 = deviceAppservice.findDeviceByCode(next_device_code2); - String start_addr2 = startDevice2.getExtraValue().get("address").toString(); - String next_addr2 = nextDevice2.getExtraValue().get("address").toString(); - - Map map = new LinkedHashMap<>(); - map.put("to_onset1", start_addr2); - map.put("to_target1", next_addr2); - map.put("to_task1", dto.getInstruction_code()); - map.put("to_onset2", start_addr); - map.put("to_target2", next_addr); - map.put("to_task2", dto.getInstruction_code()); - map.put("to_type", taskDto.getTruss_type()); - map.put("to_command1", CommonFinalParam.ONE); - map.put("to_command2", CommonFinalParam.ONE); - this.writing(map); - logServer.deviceExecuteLog(device_code, "", "", dto.getInstruction_code() + "下发分切机出双卷任务"); - this.setNow_steps_type3(2); - } - - - //执行重新生成指令的任务 - public synchronized boolean executeBusiness(TaskDto taskDto, List getDeviceCodeList, List backGetDeviceCodeList) { - boolean flag = false; - //任务类型 1.前工位任务 2.后工位任务 3.双工位任务 - String type = ""; - //获取指令信息 - Instruction instructionDto = instructionService.findByTaskcodeAndStatus(taskDto.getTask_code()); - //获取指令表中的取货点1 - String start_device_code = instructionDto.getStart_device_code(); - //获取指令表中的取货点2 - String start_device_code2 = instructionDto.getStart_device_code2(); - //获取指令表中的放货点1 - String next_device_code = instructionDto.getNext_device_code(); - //获取指令表中的放货点2 - String next_device_code2 = instructionDto.getNext_device_code2(); - //判断任务点位是否配置电气信号 - Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); - Device startDevice2 = deviceAppservice.findDeviceByCode(start_device_code2); - Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); - Device nextDevice2 = deviceAppservice.findDeviceByCode(next_device_code2); - //如果指令表中的取货点1和取货点2 都不为空 则说明时下双工位任务 - if (StrUtil.isNotEmpty(start_device_code2) && StrUtil.isNotEmpty(start_device_code)) { - this.isSetAddress(startDevice); - this.isSetAddress(nextDevice); - this.isSetAddress(startDevice2); - this.isSetAddress(nextDevice2); - type = "3"; - } else { - //判断指令表中的起点1 是否是前工位/后工位取货点的关联设备 - int headGetIndex = getDeviceCodeList.indexOf(start_device_code); - int backGetIndex = backGetDeviceCodeList.indexOf(start_device_code); - if (headGetIndex != -1) { - //前工位 - type = CommonFinalParam.ONE; - } else if (backGetIndex != -1) { - //后工位 - type = "2"; - } - this.isSetAddress(startDevice); - this.isSetAddress(nextDevice); - } - - //修改指令状态 - instructionDto.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - instructionDto.setUpdate_time(DateUtil.now()); - try { - instructionService.update(instructionDto); - if (StrUtil.equals(type, CommonFinalParam.ONE)) { - this.setNow_steps_type1(1); - } - if (StrUtil.equals(type, "2")) { - this.setNow_steps_type2(1); - } - if (StrUtil.equals(type, "3")) { - this.setNow_steps_type3(1); - } - flag = true; - } catch (Exception e) { - logServer.deviceExecuteLog(device_code, "", instructionDto.getInstruction_code(), "执行重新生成指令的任务失败,原因->" + e.getMessage()); - } - - //下发电气信号 - this.sendSignalType(instructionDto, type); - - //请求任务成功 - requireSucess = true; - return flag; - } - - //执行就绪状态下的任务 - public synchronized boolean executeReadyBusiness(TaskDto taskDto, List getDeviceCodeList, List backGetDeviceCodeList) { - boolean flag = false; - //任务类型 1.前工位任务 2.后工位任务 3.双工位任务 - String type = ""; - //获取任务表中的取货点1 - String start_device_code = taskDto.getStart_device_code(); - //获取任务表中的取货点2 - String start_device_code2 = taskDto.getStart_device_code2(); - //获取任务表中的放货点1 - String next_device_code = taskDto.getNext_device_code(); - //获取任务表中的放货点2 - String next_device_code2 = taskDto.getNext_device_code2(); - //判断任务点位是否配置电气信号 - Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); - Device startDevice2 = deviceAppservice.findDeviceByCode(start_device_code2); - Device nextDevice2 = deviceAppservice.findDeviceByCode(next_device_code2); - logServer.deviceExecuteLog(this.getDeviceCode(), "", "", "" + - "执行就绪状态下的任务生成指令时:起点1为:" + start_device_code + "起点2为:" + start_device_code2 + ",任务信息为:" + taskDto.toString()); - //如果指令表中的取货点1和取货点2 都不为空 则说明时下双工位任务 - if (StrUtil.isNotEmpty(start_device_code2) && StrUtil.isNotEmpty(start_device_code)) { - type = "3"; - logServer.deviceExecuteLog(this.getDeviceCode(), "", "", "" + - "执行就绪状态下的任务生成指令时:起点1为:" + start_device_code + "起点2为:" + start_device_code2 + - "type值为:" + type + ",任务信息为:" + taskDto.toString()); - //判断四个点位是否都设置电气值 - this.isSetAddress(startDevice); - this.isSetAddress(nextDevice); - this.isSetAddress(startDevice2); - this.isSetAddress(nextDevice2); - } else { - //判断指令表中的起点1 是否是前工位/后工位取货点的关联设备 - int headGetIndex = getDeviceCodeList.indexOf(start_device_code); - int backGetIndex = backGetDeviceCodeList.indexOf(start_device_code); - if (headGetIndex != -1) { - //前工位 - type = CommonFinalParam.ONE; - } else if (backGetIndex != -1) { - //后工位 - type = "2"; - } - logServer.deviceExecuteLog(this.getDeviceCode(), "", "", "" + - "执行就绪状态下的任务生成指令时:起点1为:" + start_device_code + "起点2为:" + start_device_code2 - + "type值为:" + type + ",任务信息为:" + taskDto.toString()); - //判断单任务下的两个点位是否都设置电气值 - this.isSetAddress(startDevice); - this.isSetAddress(nextDevice); - } - - 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 next_point_code = taskDto.getNext_point_code(); - String start_point_code2 = taskDto.getStart_point_code2(); - String next_point_code2 = taskDto.getNext_point_code2(); - String route_plan_code = taskDto.getRoute_plan_code(); - String remark = taskDto.getRemark(); - String material = taskDto.getMaterial(); - String quantity = taskDto.getQuantity(); - - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(remark); - instdto.setMaterial(material); - instdto.setQuantity(quantity); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); - instdto.setExecute_device_code(start_point_code); - instdto.setStart_device_code2(start_device_code2); - instdto.setStart_point_code2(start_point_code2); - instdto.setNext_device_code2(next_device_code2); - instdto.setNext_point_code2(next_point_code2); - - try { - logServer.deviceExecuteLog(this.getDeviceCode(), "", "", "" + - "执行就绪状态下的任务生成指令时:起点1为:" + start_device_code + "起点2为:" + start_device_code2 - + "type值为:" + type + ",创建指令信息为:" + instdto.toString()); - instructionService.create(instdto); - flag = true; - } catch (Exception e) { - notCreateInstMessage = e.getMessage(); - logServer.deviceExecuteLog(device_code, "", instdto.getInstruction_code(), "指令创建失败,原因->" + e.getMessage()); - } - - //创建指令后修改任务状态 - taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskDto.setUpdate_time(DateUtil.now()); - taskserver.update(taskDto); - - //下发电气信号 - this.sendSignalType(instdto, type); - - //请求任务成功 - requireSucess = true; - return flag; - } - - //下发电气信号 - public synchronized void sendSignalType(Instruction dto, String type) { - logServer.deviceExecuteLog(this.getDeviceCode(), "", "", "开始下发电气信号,即下发电气指令信息为:" - + dto.toString() + ",type = " + type); - 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); - String start_addr = startDevice.getExtraValue().get("address").toString(); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - List list = new ArrayList(); - if (StrUtil.equals(type, CommonFinalParam.ONE)) { - Map map1 = new HashMap(); - map1.put("code", "to_onset1"); - map1.put("value", start_addr); - list.add(map1); - Map map2 = new HashMap(); - map2.put("code", "to_target1"); - map2.put("value", next_addr); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_task1"); - map3.put("value", dto.getInstruction_code()); - list.add(map3); - Map map4 = new HashMap(); - map4.put("code", "to_type"); - map4.put("value", CommonFinalParam.ONE); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_command1"); - map5.put("value", CommonFinalParam.ONE); - list.add(map5); - HashMap map6 = new HashMap() {{ - put("code", "to_command2"); - put("value", "0"); - }}; - list.add(map6); - this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", dto.getInstruction_code() + "下发前工位任务"); - -// this.writing("to_onset1", start_addr); -// this.writing("to_target1", next_addr); -// this.writing("to_task1", dto.getInstruction_code()); -// this.writing("to_command1", CommonFinalParam.ONE); -// this.writing("to_type", CommonFinalParam.ONE); - this.setNow_steps_type1(2); - } else if (StrUtil.equals(type, "2")) { - Map map1 = new HashMap(); - map1.put("code", "to_onset2"); - map1.put("value", start_addr); - list.add(map1); - Map map2 = new HashMap(); - map2.put("code", "to_target2"); - map2.put("value", next_addr); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_task2"); - map3.put("value", dto.getInstruction_code()); - list.add(map3); - Map map4 = new HashMap(); - map4.put("code", "to_type"); - map4.put("value", "2"); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_command2"); - map5.put("value", CommonFinalParam.ONE); - list.add(map5); - HashMap map6 = new HashMap() {{ - put("code", "to_command1"); - put("value", "0"); - }}; - list.add(map6); - this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", dto.getInstruction_code() + "下发后工位任务"); - -// this.writing("to_onset2", start_addr); -// this.writing("to_target2", next_addr); -// this.writing("to_task2", dto.getInstruction_code()); -// this.writing("to_command2", CommonFinalParam.ONE); -// this.writing("to_type", "2"); - this.setNow_steps_type2(2); - } else if (StrUtil.equals(type, "3")) { - String start_device_code2 = dto.getStart_device_code2(); - String next_device_code2 = dto.getNext_device_code2(); - Device startDevice2 = deviceAppservice.findDeviceByCode(start_device_code2); - Device nextDevice2 = deviceAppservice.findDeviceByCode(next_device_code2); - String start_addr2 = startDevice2.getExtraValue().get("address").toString(); - String next_addr2 = nextDevice2.getExtraValue().get("address").toString(); - - - Map map1 = new HashMap(); - map1.put("code", "to_onset1"); - map1.put("value", start_addr2); - list.add(map1); - Map map2 = new HashMap(); - map2.put("code", "to_target1"); - map2.put("value", next_addr2); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_task1"); - map3.put("value", dto.getInstruction_code()); - list.add(map3); - Map map4 = new HashMap(); - map4.put("code", "to_onset2"); - map4.put("value", start_addr); - list.add(map4); - Map map5 = new HashMap(); - map5.put("code", "to_target2"); - map5.put("value", next_addr); - list.add(map5); - Map map6 = new HashMap(); - map6.put("code", "to_task2"); - map6.put("value", dto.getInstruction_code()); - list.add(map6); - Map map7 = new HashMap(); - map7.put("code", "to_type"); - map7.put("value", "3"); - list.add(map7); - Map map8 = new HashMap(); - map8.put("code", "to_command1"); - map8.put("value", CommonFinalParam.ONE); - list.add(map8); - Map map9 = new HashMap(); - map9.put("code", "to_command2"); - map9.put("value", CommonFinalParam.ONE); - list.add(map9); - this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", dto.getInstruction_code() + "下发双工位任务"); - - -// this.writing("to_onset1", start_addr2); -// this.writing("to_target1", next_addr2); -// this.writing("to_task1", dto.getInstruction_code()); -// this.writing("to_command1", CommonFinalParam.ONE); -// this.writing("to_onset2", start_addr); -// this.writing("to_target2", next_addr); -// this.writing("to_task2", dto.getInstruction_code()); -// this.writing("to_command2", CommonFinalParam.ONE); -// this.writing("to_type", "3"); - this.setNow_steps_type3(2); - } - - if (task1 != Integer.parseInt(dto.getInstruction_code()) || task2 != Integer.parseInt(dto.getInstruction_code())) { - this.writing(list); - logServer.deviceExecuteLog(device_code, "", "", dto.getInstruction_code() + "再次下发电气信号"); - } - - } - - //判断点位是否设置电气值 - public void isSetAddress(Device device) { - if (ObjectUtil.isEmpty(device.getExtraValue().get("address"))) { - logServer.deviceExecuteLog(device_code, "", "task1:" + task1 + ",task2:" + task2, "设备:" + device.getDevice_code() + "未设置电气调度号!"); - notCreateInstMessage = "设备:" + device.getDevice_code() + "未设置电气调度号!"; - throw new BadRequestException("设备:" + device.getDevice_code() + "未设置电气调度号!"); - } - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - 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; - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_param, Integer.parseInt(value)); - - this.control(itemMap); - logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value); - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - this.control(itemMap); - - } - - - public synchronized boolean finish_instruction(Instruction inst) throws Exception { - instructionService.finish(inst); - return true; - } - - - public void executing(Server server, Map itemMap) { - this.control(itemMap); - } - - public void writing1(int command) { - String to_command1 = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command1; - - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command1, command); - this.control(itemMap); - - } - - public void writing2(int command) { - String to_command2 = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command2; - - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command2, command); - this.control(itemMap); - - } - - public void writing(int type, int command) { - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - this.control(itemMap); - } - - public void writing(List list) { - -// String opcservcerid = this.getDevice().getOpc_server_id(); -// Server server = ReadUtil.getServer(opcservcerid); - 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); - this.control(itemMap); - } - - - //将扩展表中的字符串数组数据转换成集合 - @Override - public List getExtraDeviceCodes(String extraName) { - String extraValue = (String) this.getDevice().getExtraValue().get(extraName); - if (StrUtil.isEmpty(extraValue)) { - return new ArrayList<>(); - } - String devicesString = extraValue.substring(1, extraValue.length() - 1); - List devicesList = new ArrayList<>(); - String[] devices = devicesString.split(","); - for (int i = 0; i < devices.length; i++) { - String s = devices[i].replace("\"", "").replace("\"", ""); - devicesList.add(s); - } - return devicesList; - } - - public List sortTask(List taskDtos) { - Collections.sort(taskDtos, new Comparator() { - @Override - public int compare(TaskDto t1, TaskDto t2) { - //优先级从大到小 - int i = t2.getPriority().compareTo(t1.getPriority()); - //如果优先级相等 - if (i == 0) { - //时间从早到晚 - i = t1.getCreate_time().compareTo(t2.getCreate_time()); - } - return i; - } - }); - return taskDtos; - } - - @Override - public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String move_1 = ""; - String move_2 = ""; - String action1 = ""; - String action2 = ""; - String walk_y = ""; - String mode = ""; - String status = ""; - String is_disable = ""; - - - if (this.getMode() == 0) { - mode = "脱机"; - } else if (this.getMode() == 1) { - mode = "单机"; - } else if (this.getMode() == 2) { - mode = "待机"; - } else if (this.getMode() == 3) { - mode = "运行中"; - } - - if (this.getStatus() == 0) { - status = "0"; - } else if (this.getStatus() == 1) { - status = "待机"; - } else if (this.getStatus() == 2) { - status = "生产中"; - } else if (this.getStatus() == 3) { - status = "故障"; - } - - if (this.getMove1() == 0) { - move_1 = "无货"; - } else if (this.getMove1() == 1) { - move_1 = "有货"; - } - - if (this.getMove2() == 0) { - move_2 = "无货"; - } else if (this.getMove2() == 1) { - move_2 = "有货"; - } - - if (this.getAction1() == 1) { - action1 = "取货中"; - } else if (this.getAction1() == 2) { - action1 = "取货完成"; - } else if (this.getAction1() == 3) { - action1 = "放货中"; - } else if (this.getAction1() == 4) { - action1 = "放货完成"; - } - - if (this.getAction2() == 1) { - action2 = "取货中"; - } else if (this.getAction2() == 2) { - action2 = "取货完成"; - } else if (this.getAction2() == 3) { - action2 = "放货中"; - } else if (this.getAction2() == 4) { - action2 = "放货完成"; - } - - if (this.getWalk_y() == 0) { - walk_y = "原位"; - } else if (this.getWalk_y() == 2) { - walk_y = "非原位"; - } - - if (this.getIs_disable() == 0) { - is_disable = "正常"; - } else if (this.getIs_disable() == 1) { - is_disable = "禁用"; - } - - String requireSucess = "0"; - if (this.requireSucess) { - requireSucess = CommonFinalParam.ONE; - } - jo.put("requireSucess", requireSucess); - - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("status", status); - jo.put("move_1", move_1); - jo.put("move_2", move_2); - jo.put("action_1", action1); - jo.put("action_2", action2); - jo.put("walk_y", walk_y); - jo.put("error", this.getError()); - jo.put("task1", this.getTask1()); - jo.put("task2", this.getTask2()); - jo.put("isOnline", this.getIsonline()); - jo.put("isError", this.getIserror()); - jo.put("is_disable1", this.getIs_disable()); - jo.put("is_disable", is_disable); - jo.put("message", this.messageInfo(type)); - jo.put("is_click", true); - jo.put("driver_type", "slit_two_manipulator"); - jo.put("notCreateTaskMessage", notCreateTaskMessage); - jo.put("notCreateInstMessage", notCreateInstMessage); - jo.put("feedMessage", feedMessage); - return jo; - } - - public String messageInfo(int type) { - String set_type = ""; - JSONObject map = new JSONObject(); - if (type == 1) { - set_type = String.valueOf(now_steps_type1); - map.put("0", "前工位单任务未执行"); - map.put(CommonFinalParam.ONE, "前工位单任务改变指令状态"); - map.put("2", "前工位单任务下发电气任务信息"); - map.put("3", "单任务前工位允许取货"); - map.put("4", "单任务前工位取货完成"); - map.put("5", "单任务前工位允许放货"); - map.put("6", "单任务前工位放货完成"); - } else if (type == 2) { - set_type = String.valueOf(now_steps_type2); - map.put("0", "后工位单任务未执行"); - map.put(CommonFinalParam.ONE, "后工位单任务改变指令状态"); - map.put("2", "后工位单任务下发电气任务信息"); - map.put("3", "单任务后工位允许取货"); - map.put("4", "单任务后工位取货完成"); - map.put("5", "单任务后工位允许放货"); - map.put("6", "单任务后工位放货完成"); - } else if (type == 3) { - set_type = String.valueOf(now_steps_type3); - map.put("0", "双任务未执行"); - map.put(CommonFinalParam.ONE, "双任务改变指令状态"); - map.put("2", "双任务下发电气任务信息"); - map.put("3", "双任务后工位允许取货"); - map.put("4", "双任务后工位取货完成"); - map.put("5", "双任务前工位允许取货"); - map.put("6", "双任务前工位取货完成"); - map.put("7", "双任务后工位允许放货"); - map.put("8", "双任务后工位放货完成"); - map.put("9", "双任务前工位允许放货"); - map.put("10", "双任务前工位放货完成"); - } else { - return "未执行任务"; - } - return map.getString(set_type); - } - - @Override - public void setDeviceStatus(JSONObject data) { - String is_disable = data.getString("is_disable"); - if (StrUtil.isNotEmpty(is_disable)) { - this.setIs_disable(Integer.parseInt(is_disable)); - } - String requestSucess = data.getString("requireSucess"); - if (StrUtil.equals(requestSucess, "0")) { - this.requireSucess = false; - } else if (StrUtil.equals(requestSucess, CommonFinalParam.ONE)) { - this.requireSucess = true; - } - } - - /** - * 抽取统一下发电气信号前缀 - * - * @return - */ - public String getToParam() { - return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; - } - - /** - * 多个信号一起下发电气 - * - * @param map - */ - public void writing(Map map) { - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - Map itemMap = new LinkedHashMap<>(); - map.forEach((key, value) -> { - if (ObjectUtil.isNotEmpty(value)) { - itemMap.put(getToParam() + key, value); - } - }); - if (ObjectUtil.isNotEmpty(itemMap)) { - this.control(itemMap); - logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); - } - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/ItemProtocol.java deleted file mode 100644 index b276ae9..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/ItemProtocol.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.subvolume_weighing_station; - -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_weight = "weight"; - - - public static String item_to_command = "to_command"; - - - private SubvolumeWeighingStationDriver driver; - - public ItemProtocol(SubvolumeWeighingStationDriver driver) { - this.driver = driver; - } - - public int getItem_heartbeat(){ - return this.getOpcIntegerValue(item_heartbeat); - } ; - public int getItem_mode(){ - return this.getOpcIntegerValue(item_mode); - } ; - public int getItem_move(){ - return this.getOpcIntegerValue(item_move); - } ; - public int getItem_action(){ - return this.getOpcIntegerValue(item_action); - }; - public int getItem_error(){ - return this.getOpcIntegerValue(item_error); - } ; - public float getItem_weight(){ - return this.getOpcFloatValue(item_weight); - } ; - - 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) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0L; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "251")); - list.add(new ItemDto(item_mode, "工作模式", "7990")); - list.add(new ItemDto(item_move, "光电信号", "550")); - list.add(new ItemDto(item_action, "取放信号", "450")); - list.add(new ItemDto(item_error, "故障", "8055")); - list.add(new ItemDto(item_weight, "重量", "8055")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "40226")); - return list; - } - - @Override - public String toString() { - return ""; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/SubvolumeWeighingStationDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/SubvolumeWeighingStationDefination.java deleted file mode 100644 index 4eb38d2..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/SubvolumeWeighingStationDefination.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.subvolume_weighing_station; - -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 SubvolumeWeighingStationDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "subvolume_weighing_station"; - } - - @Override - public String getDriverName() { - return "子卷称重位"; - } - - @Override - public String getDriverDescription() { - return "子卷称重位"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new SubvolumeWeighingStationDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return SubvolumeWeighingStationDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.station); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/SubvolumeWeighingStationDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/SubvolumeWeighingStationDriver.java deleted file mode 100644 index 1ae9182..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/SubvolumeWeighingStationDriver.java +++ /dev/null @@ -1,146 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.subvolume_weighing_station; - -import com.alibaba.fastjson.JSONObject; -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.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.history.service.DeviceErrorLogService; -import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; -import org.nl.acs.log.service.DeviceExecuteLogService; -import org.nl.acs.monitor.DeviceStageMonitor; -import org.nl.config.SpringContextHolder; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * 子卷称重位 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class SubvolumeWeighingStationDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - - DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - - DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); - - private String error_type = "hx_error_type"; - - 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; - - public int heartbeat = 0; - public int mode = 0; - public int move = 0; - public int action = 0; - public int error = 0; - public Float weight = 0f; - - public int last_heartbeat = 0; - public int last_mode = 0; - public int last_move = 0; - public int last_action = 0; - public int last_error = 0; - public float last_weight = 0f; - - Boolean isonline = true; - - Boolean iserror = false; - - - String device_code; - - String message = null; - - - @Override - public Device getDevice() { - return this.device; - } - - //请求成功标记 - Boolean requireSucess = false; - - @Override - public void execute() { - - device_code = this.getDeviceCode(); - heartbeat = this.itemProtocol.getItem_heartbeat(); - mode = this.itemProtocol.getItem_mode(); - move = this.itemProtocol.getItem_move(); - action = this.itemProtocol.getItem_action(); - error = this.itemProtocol.getItem_error(); - weight = this.itemProtocol.getItem_weight(); - if (mode != last_mode) { - requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (action != last_action) { - logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); - } - if (error != last_error) { - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (weight != last_weight) { - logServer.deviceItemValue(this.device_code, "weight", String.valueOf(weight)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号weight:" + last_weight + "->" + weight); - } - - - last_mode = mode; - last_move = move; - last_action = action; - last_error = error; - - } - - - - - 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); - } - - - @Override - public JSONObject feedLmsRealFailedInfo() { - return null; - } - - @Override - public JSONObject getDeviceStatusName() throws Exception { - return null; - } - - @Override - public void setDeviceStatus(JSONObject data) { - - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/ItemProtocol.java deleted file mode 100644 index 3a3d254..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/ItemProtocol.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.waste_foil_weighing_station; - -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_weight = "weight"; - public static String item_old_weight = "old_weight"; - - - public static String item_to_command = "to_command"; - - - private WasteFoilWeighingStationDriver driver; - - public ItemProtocol(WasteFoilWeighingStationDriver driver) { - this.driver = driver; - } - - public int getItem_heartbeat(){ - return this.getOpcIntegerValue(item_heartbeat); - } ; - public int getItem_mode(){ - return this.getOpcIntegerValue(item_mode); - } ; - public int getItem_move(){ - return this.getOpcIntegerValue(item_move); - } ; - public int getItem_action(){ - return this.getOpcIntegerValue(item_action); - }; - public int getItem_error(){ - return this.getOpcIntegerValue(item_error); - } ; - public float getItem_weight(){ - return this.getOpcFloatValue(item_weight); - } ; - public float getItem_old_weight(){ - return this.getOpcFloatValue(item_old_weight); - } ; - - 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) { - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0L; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "251")); - list.add(new ItemDto(item_mode, "工作模式", "7990")); - list.add(new ItemDto(item_move, "光电信号", "550")); - list.add(new ItemDto(item_action, "取放信号", "450")); - list.add(new ItemDto(item_error, "故障", "8055")); - list.add(new ItemDto(item_weight, "重量", "8055")); - list.add(new ItemDto(item_old_weight, "上次重量", "8055")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "40226")); - return list; - } - - @Override - public String toString() { - return ""; - } - -} - diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/WasteFoilWeighingStationDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/WasteFoilWeighingStationDefination.java deleted file mode 100644 index 7a15d6c..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/WasteFoilWeighingStationDefination.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.waste_foil_weighing_station; - -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 WasteFoilWeighingStationDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "waste_foil_weighing_station"; - } - - @Override - public String getDriverName() { - return "废箔称重位"; - } - - @Override - public String getDriverDescription() { - return "废箔称重位"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new WasteFoilWeighingStationDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return WasteFoilWeighingStationDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.station); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/WasteFoilWeighingStationDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/WasteFoilWeighingStationDriver.java deleted file mode 100644 index beaac4f..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/WasteFoilWeighingStationDriver.java +++ /dev/null @@ -1,222 +0,0 @@ -package org.nl.acs.device_driver.two_conveyor.waste_foil_weighing_station; - -import cn.hutool.core.util.ObjectUtil; -import com.alibaba.fastjson.JSONObject; -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.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.history.service.DeviceErrorLogService; -import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; -import org.nl.acs.instruction.domain.Instruction; -import org.nl.acs.log.service.DeviceExecuteLogService; -import org.nl.acs.monitor.DeviceStageMonitor; -import org.nl.config.SpringContextHolder; - -import java.util.*; - -/** - * 废箔称重 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class WasteFoilWeighingStationDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - - DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - - DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); - - private String error_type = "hx_error_type"; - - 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; - - public int heartbeat = 0; - public int mode = 0; - public int move = 0; - public int action = 0; - public int error = 0; - public Float weight = 0f; - public Float old_weight = 0f; - - public int last_heartbeat = 0; - public int last_mode = 0; - public int last_move = 0; - public int last_action = 0; - public int last_error = 0; - public float last_weight = 0f; - public float last_old_weight = 0f; - - Boolean isonline = true; - - Boolean iserror = false; - - - String device_code; - - String message = null; - - - @Override - public Device getDevice() { - return this.device; - } - - //请求成功标记 - Boolean requireSucess = false; - - @Override - public void execute() { - - device_code = this.getDeviceCode(); - heartbeat = this.itemProtocol.getItem_heartbeat(); - mode = this.itemProtocol.getItem_mode(); - move = this.itemProtocol.getItem_move(); - action = this.itemProtocol.getItem_action(); - error = this.itemProtocol.getItem_error(); - weight = this.itemProtocol.getItem_weight(); - old_weight = this.itemProtocol.getItem_old_weight(); - if (mode != last_mode) { - requireSucess = false; - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (action != last_action) { - logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); - } - if (error != last_error) { - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (weight != last_weight) { - logServer.deviceItemValue(this.device_code, "weight", String.valueOf(weight)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号weight:" + last_weight + "->" + weight); - } - if (old_weight != last_old_weight) { - logServer.deviceItemValue(this.device_code, "old_weight", String.valueOf(old_weight)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号old_weight:" + last_old_weight + "->" + old_weight); - } - - if (mode == 0) { - this.setIsonline(false); - message = "未联机"; - // 有报警 - // } else if (error != 0) { - // this.setIsonline(false); - // this.setIserror(true); - // message = "有报警"; - // //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - if (error != 0) { - this.setIserror(true); - message = "有报警"; - } - message = ""; - Instruction instruction = null; - List toInstructions; - - switch (mode) { - case 2: - log.debug("设备运转模式:等待工作"); - break; - case 3: - log.debug("设备运转模式:等待工作"); - break; - case 7: - // 称重确认完成 - if (move > 0 && !requireSucess) { - weightConfirmSuccess(); - } - break; - default: - break; - } - } - - last_mode = mode; - last_move = move; - last_action = action; - last_error = error; - - } - - /** - * 称重确认完成 - */ - public synchronized void weightConfirmSuccess() { - Map map = new LinkedHashMap<>(); - map.put("to_command", "7"); - this.writing(map); - } - - - - - 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); - } - - public String getToParam() { - return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; - } - - /** - * 多个信号一起下发电气 - * - * @param map - */ - public void writing(Map map) { - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - Map itemMap = new LinkedHashMap<>(); - map.forEach((key, value) -> { - if (ObjectUtil.isNotEmpty(value)) { - itemMap.put(getToParam() + key, value); - } - }); - if (ObjectUtil.isNotEmpty(itemMap)) { - this.control(itemMap); - logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); - } - } - - - @Override - public JSONObject feedLmsRealFailedInfo() { - return null; - } - - @Override - public JSONObject getDeviceStatusName() throws Exception { - return null; - } - - @Override - public void setDeviceStatus(JSONObject data) { - - } -} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java index cac2530..c7bfd68 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/LiKuToAcsServiceImpl.java @@ -9,7 +9,6 @@ import lombok.extern.slf4j.Slf4j; import org.nl.acs.address.service.AddressService; import org.nl.acs.common.base.CommonFinalParam; import org.nl.acs.device.domain.Device; -import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver; import org.nl.acs.ext.wms.RespUtil; import org.nl.acs.ext.wms.liKuData.*; import org.nl.acs.ext.wms.service.AcsToLiKuService; @@ -279,44 +278,7 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService { */ @Override public Resp putEmptyPallet(putEmptyPalletRequest requestParam) throws Exception { - try { - MDC.put(log_file_type, log_type); - log.info("请求放空盘-----输入参数{}", JSON.toJSONString(requestParam)); - String device_code = requestParam.getDeviceId(); - String type = requestParam.getType(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device device = appService.findDeviceByCode(device_code); - SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; - JSONObject result = new JSONObject(); - result.put("code", "0"); - if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(type, CommonFinalParam.ONE)) { - if ((siemensConveyorDeviceDriver.getMode() == 2 || siemensConveyorDeviceDriver.getMode() == 7) && siemensConveyorDeviceDriver.getMove() == 0) { - result.put("result", "true"); - result.put("comment", ""); - } else { - result.put("result", "false"); - result.put("comment", "当前设备光电信号:" + siemensConveyorDeviceDriver.getMove() + ",工作模式:" + siemensConveyorDeviceDriver.getMode()); - } - } else if (StrUtil.equals(type, "2")) { - List list = new ArrayList(); - Map map = new HashMap(); - map.put("to_command", "3"); - list.add(map); - siemensConveyorDeviceDriver.writing(list); - - result.put("result", "true"); - result.put("comment", ""); - } - - } - log.info("请求放空盘-----输出参数{}", result); - return RespUtil.getResp(result.toString(), new DeviceStatusResponse()); - } finally { - MDC.remove(log_file_type); - } - + return null; } } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index 1a816c7..cb169fd 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -13,12 +13,6 @@ import org.nl.acs.device.domain.Device; import org.nl.acs.device_driver.conveyor.box_palletizing_manipulator.BoxPalletizingManipulatorDeviceDriver; import org.nl.acs.device_driver.conveyor.primary_device.PrimaryDeviceConveyorDeviceDriver; import org.nl.acs.device_driver.one_manipulator.box_package_manipulator.BoxPackageManipulatorDeviceDriver; -import org.nl.acs.device_driver.paper_tube_device2.PaperTubeConveyor2DeviceDriver; -import org.nl.acs.device_driver.two_conveyor.blank_manipulator.BlankManipulatorDeviceDriver; -import org.nl.acs.device_driver.two_conveyor.oven_manipulator.OvenGantryManipulatorDeviceDriver; -import org.nl.acs.device_driver.two_conveyor.plug_pull_device_site.PlugPullDeviceSiteDeviceDriver; -import org.nl.acs.device_driver.two_conveyor.subvolume_weighing_station.SubvolumeWeighingStationDriver; -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.service.WmsToAcsService; import org.nl.acs.opc.DeviceAppService; @@ -131,161 +125,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { @Override public Map queryDevice(String jsonObject) throws Exception { - try { - MDC.put(log_file_type, log_type); - JSONArray backja = new JSONArray(); - JSONArray datas = JSONArray.parseArray(jsonObject); - //表处下料行架机械手 - BlankManipulatorDeviceDriver blankManipulatorDeviceDriver; - //烘箱行架机械手 - OvenGantryManipulatorDeviceDriver ovenGantryManipulatorDeviceDriver; - //装箱行架机械手 - BoxPackageManipulatorDeviceDriver boxManipulatorDeviceDriver; - //木箱码垛机械手 - BoxPalletizingManipulatorDeviceDriver boxPalletizingManipulatorDeviceDriver; - //纸管库2 - PaperTubeConveyor2DeviceDriver paperTubeConveyor2DeviceDriver; - //废箔称重位 - WasteFoilWeighingStationDriver wasteFoilWeighingStationDriver; - //子卷称重位 - SubvolumeWeighingStationDriver subvolumeWeighingStationDriver; - - PlugPullDeviceSiteDeviceDriver plugPullDeviceSiteDeviceDriver; - if (datas.size() == 0) { - throw new BadRequestException("缺少输入参数!"); - } - for (int i = 0; i < datas.size(); i++) { - JSONObject jo = new JSONObject(); - JSONObject data = datas.getJSONObject(i); - String parent_device_code = data.getString("device_code"); - String device_code = ""; - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.like(StringUtils.isNotBlank(parent_device_code), StorageCell::getParent_storage_code, parent_device_code); - StorageCell storageCell = storageCellMapper.selectOne(wrapper); - final JSONObject device_json = (JSONObject) JSON.toJSON(storageCell); - if (!ObjectUtil.isEmpty(device_json)) { - device_code = device_json.get("parent_storage_code") == null ? parent_device_code : (String) device_json.get("storage_code"); - } else { - device_code = parent_device_code; - } - Device device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device)) { - throw new Exception("未找到对应设备:" + parent_device_code); - } - if (device.getDeviceDriver() instanceof BlankManipulatorDeviceDriver) { - blankManipulatorDeviceDriver = (BlankManipulatorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", blankManipulatorDeviceDriver.getDevice().getDevice_code()); - jo.put("device_name", blankManipulatorDeviceDriver.getDevice().getDevice_name()); - jo.put("status", Math.min(3, blankManipulatorDeviceDriver.getMode())); - jo.put("move", Math.min(3, blankManipulatorDeviceDriver.getMove())); - jo.put("action", Math.min(3, blankManipulatorDeviceDriver.getAction())); - jo.put("task", Math.min(3, blankManipulatorDeviceDriver.getTask())); - jo.put("error", blankManipulatorDeviceDriver.getError()); - } else if (device.getDeviceDriver() instanceof OvenGantryManipulatorDeviceDriver) { - ovenGantryManipulatorDeviceDriver = (OvenGantryManipulatorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", ovenGantryManipulatorDeviceDriver.getDevice().getDevice_code()); - jo.put("device_name", ovenGantryManipulatorDeviceDriver.getDevice().getDevice_name()); - jo.put("status", Math.min(3, ovenGantryManipulatorDeviceDriver.getMode())); - jo.put("x", ovenGantryManipulatorDeviceDriver.getX_position()); - jo.put("y", ovenGantryManipulatorDeviceDriver.getY_position()); - jo.put("mode", ovenGantryManipulatorDeviceDriver.getMode()); - jo.put("move", ovenGantryManipulatorDeviceDriver.getMove()); - jo.put("action", ovenGantryManipulatorDeviceDriver.getAction()); - jo.put("walk_y", ovenGantryManipulatorDeviceDriver.getWalk_y()); - jo.put("task", ovenGantryManipulatorDeviceDriver.getTask()); - jo.put("error", ovenGantryManipulatorDeviceDriver.getError()); - } else if (device.getDeviceDriver() instanceof BoxPackageManipulatorDeviceDriver) { - boxManipulatorDeviceDriver = (BoxPackageManipulatorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", boxManipulatorDeviceDriver.getDevice().getDevice_code()); - jo.put("device_name", boxManipulatorDeviceDriver.getDevice().getDevice_name()); - jo.put("status", Math.min(3, boxManipulatorDeviceDriver.getMode())); - jo.put("x", boxManipulatorDeviceDriver.getX_position()); - jo.put("y", boxManipulatorDeviceDriver.getY_position()); - jo.put("mode", boxManipulatorDeviceDriver.getMode()); - jo.put("move", boxManipulatorDeviceDriver.getMove()); - jo.put("action", boxManipulatorDeviceDriver.getAction()); - jo.put("walk_y", boxManipulatorDeviceDriver.getWalk_y()); - jo.put("task", boxManipulatorDeviceDriver.getTask()); - jo.put("error", boxManipulatorDeviceDriver.getError()); - } else if (device.getDeviceDriver() instanceof BoxPalletizingManipulatorDeviceDriver) { - boxPalletizingManipulatorDeviceDriver = (BoxPalletizingManipulatorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", boxPalletizingManipulatorDeviceDriver.getDevice().getDevice_code()); - jo.put("device_name", boxPalletizingManipulatorDeviceDriver.getDevice().getDevice_name()); - jo.put("status", Math.min(3, boxPalletizingManipulatorDeviceDriver.getMode())); - jo.put("x", boxPalletizingManipulatorDeviceDriver.getX_position()); - jo.put("y", boxPalletizingManipulatorDeviceDriver.getY_position()); - jo.put("mode", boxPalletizingManipulatorDeviceDriver.getMode()); - jo.put("move", boxPalletizingManipulatorDeviceDriver.getMove()); - jo.put("action", boxPalletizingManipulatorDeviceDriver.getAction()); - jo.put("walk_y", boxPalletizingManipulatorDeviceDriver.getWalk_y()); - jo.put("task", boxPalletizingManipulatorDeviceDriver.getTask()); - jo.put("error", boxPalletizingManipulatorDeviceDriver.getError()); - } else if (device.getDeviceDriver() instanceof PaperTubeConveyor2DeviceDriver) { - paperTubeConveyor2DeviceDriver = (PaperTubeConveyor2DeviceDriver) device.getDeviceDriver(); - jo.put("device_code", parent_device_code); - jo.put("heartbeat", paperTubeConveyor2DeviceDriver.getHeartbeat()); - jo.put("mode", paperTubeConveyor2DeviceDriver.getMode()); - jo.put("move", paperTubeConveyor2DeviceDriver.getMove()); - jo.put("carrier_direction", paperTubeConveyor2DeviceDriver.getCarrier_direction()); - jo.put("error", paperTubeConveyor2DeviceDriver.getError()); - jo.put("task", paperTubeConveyor2DeviceDriver.getTask()); - jo.put("out_seq_arr", paperTubeConveyor2DeviceDriver.getItem_out_seq_arr()); - jo.put("out_qty_arr", paperTubeConveyor2DeviceDriver.getItem_out_qty_arr()); - jo.put("material1", paperTubeConveyor2DeviceDriver.getItem_material1()); - jo.put("qty1", paperTubeConveyor2DeviceDriver.getItem_qty1()); - jo.put("material2", paperTubeConveyor2DeviceDriver.getItem_material2()); - jo.put("qty2", paperTubeConveyor2DeviceDriver.getItem_qty2()); - jo.put("material3", paperTubeConveyor2DeviceDriver.getItem_material3()); - jo.put("qty3", paperTubeConveyor2DeviceDriver.getItem_qty3()); - jo.put("material4", paperTubeConveyor2DeviceDriver.getItem_material4()); - jo.put("qty4", paperTubeConveyor2DeviceDriver.getItem_qty4()); - jo.put("material5", paperTubeConveyor2DeviceDriver.getItem_material5()); - jo.put("qty5", paperTubeConveyor2DeviceDriver.getItem_qty5()); - jo.put("material6", paperTubeConveyor2DeviceDriver.getItem_material6()); - jo.put("qty6", paperTubeConveyor2DeviceDriver.getItem_qty6()); - jo.put("material7", paperTubeConveyor2DeviceDriver.getItem_material7()); - jo.put("qty7", paperTubeConveyor2DeviceDriver.getItem_qty7()); - jo.put("material8", paperTubeConveyor2DeviceDriver.getItem_material8()); - jo.put("qty8", paperTubeConveyor2DeviceDriver.getItem_qty8()); - jo.put("material9", paperTubeConveyor2DeviceDriver.getItem_material9()); - jo.put("qty9", paperTubeConveyor2DeviceDriver.getItem_qty9()); - jo.put("material10", paperTubeConveyor2DeviceDriver.getItem_material10()); - jo.put("qty10", paperTubeConveyor2DeviceDriver.getItem_qty10()); - jo.put("material11", paperTubeConveyor2DeviceDriver.getItem_material11()); - jo.put("qty11", paperTubeConveyor2DeviceDriver.getItem_qty11()); - jo.put("material12", paperTubeConveyor2DeviceDriver.getItem_material12()); - jo.put("qty12", paperTubeConveyor2DeviceDriver.getItem_qty12()); - - } else if (device.getDeviceDriver() instanceof WasteFoilWeighingStationDriver) { - wasteFoilWeighingStationDriver = (WasteFoilWeighingStationDriver) device.getDeviceDriver(); - jo.put("device_code", parent_device_code); - jo.put("move", wasteFoilWeighingStationDriver.getMove()); - jo.put("mode", wasteFoilWeighingStationDriver.getMode()); - jo.put("action", wasteFoilWeighingStationDriver.getAction()); - jo.put("weight", wasteFoilWeighingStationDriver.getWeight()); - jo.put("old_weight", wasteFoilWeighingStationDriver.getOld_weight()); - jo.put("error", wasteFoilWeighingStationDriver.getError()); - } else if (device.getDeviceDriver() instanceof SubvolumeWeighingStationDriver) { - subvolumeWeighingStationDriver = (SubvolumeWeighingStationDriver) device.getDeviceDriver(); - jo.put("device_code", parent_device_code); - jo.put("move", subvolumeWeighingStationDriver.getMove()); - jo.put("mode", subvolumeWeighingStationDriver.getMode()); - jo.put("action", subvolumeWeighingStationDriver.getAction()); - jo.put("weight", subvolumeWeighingStationDriver.getWeight()); - jo.put("error", subvolumeWeighingStationDriver.getError()); - } else { - jo.put("device_code", parent_device_code); - } - backja.add(jo); - } - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK.value()); - resultJson.put("message", "操作成功"); - resultJson.put("data", backja); - return resultJson; - } finally { - MDC.remove(log_file_type); - } + return null; } @Override diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 9dabeb8..a7d79b4 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -17,7 +17,6 @@ import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapp 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,10 +30,6 @@ 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.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; -import org.nl.acs.device_driver.two_conveyor.hongxiang_device.HongXiangConveyorDeviceDriver; import org.nl.acs.ext.wms.liKuData.*; import org.nl.acs.ext.wms.service.AcsToLiKuService; import org.nl.acs.instruction.domain.Instruction; @@ -409,8 +404,6 @@ public class InstructionServiceImpl extends CommonServiceImpl> list = new ArrayList<>(); - Map map = new HashMap<>(); - map.put("code", "to_target"); - map.put("value", nextDevice.getExtraValue().get("address").toString()); - 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", CommonFinalParam.ONE); - list.add(map3); - ((SiemensConveyorDeviceDriver) startDeviceDriver).writing(list); - } } @Override diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java index 7acb57b..7b775be 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java @@ -10,9 +10,6 @@ import org.springframework.stereotype.Component; import java.util.*; import java.util.concurrent.*; -/** - * @author 20220102CG\noblelift - */ @Component @Slf4j public class DeviceExecuteAutoRun extends AbstractAutoRunnable { @@ -86,6 +83,7 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable { } } + Thread.sleep(10000L); log.info("设备执行线程开始..."); while (true) { @@ -99,7 +97,7 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable { if (!this.runs.keySet().contains(deviceDriver.getDeviceCode())) { BlockedRunable runnable = new BlockedRunable() { @Override - public void subRun() throws Exception { + public void subRun() { deviceDriver.executeAuto(); } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java index 62b48e3..274d3a0 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java @@ -3,22 +3,25 @@ package org.nl.acs.opc; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; import lombok.extern.slf4j.Slf4j; +import org.nl.acs.AcsConfig; +import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.opc.service.dto.OpcServerManageDto; import org.nl.acs.udw.UnifiedDataAccessor; import org.nl.acs.udw.UnifiedDataAccessorFactory; import org.nl.acs.udw.UnifiedDataAppService; +import org.nl.common.enums.LogTypeEnum; import org.nl.config.SpringContextHolder; +import org.nl.system.service.lucene.dto.LuceneLogDto; +import org.nl.system.service.param.ISysParamService; import org.openscada.opc.lib.da.*; -import org.springframework.stereotype.Service; import java.util.*; +import java.util.regex.Pattern; + -/** - * @author 20220102CG\noblelift - */ @Slf4j -@Service public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerConnectionStateListener { List protocols; OpcServerManageDto OpcServer; @@ -31,9 +34,6 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC private int all_null; private Map itemSearchCache; -// @Autowired -// OpcServerService opcServerService; - public DeviceOpcProtocolRunable() { this.error_num = 0; @@ -90,6 +90,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC private void runOld() { + OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerService .class); while (true) { start: try { @@ -102,11 +103,9 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC server.disconnect(); log.trace("清理server..."); } - OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerService.class); - group = opcServerService.getServer(this.getOpcServer().getOpc_code()); -// this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain()); -// this.server.addStateListener(this); -// group = this.server.addGroup(); + this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain()); + this.server.addStateListener(this); + group = this.server.addGroup(); List itemsString = new ArrayList(); Iterator var3 = this.protocols.iterator(); @@ -196,7 +195,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC Object his = accessor_value.getValue(itemId); if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) { log.warn("opc 值不健康 item: {}, 状态: {}", itemId, itemState.getQuality()); - valueAllNotNull = true; + valueAllNotNull = false; } if (!UnifiedDataAppService.isEquals(value, his)) { @@ -204,9 +203,12 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC if (true) { this.logItemChanged(itemId, accessor_value, value, itemDto); } - if (!ObjectUtil.isEmpty(value)) { + if(!ObjectUtil.isEmpty(value) || "".equals(value)){ accessor_value.setValue(itemId, value); } + if(ObjectUtil.isEmpty(value) && !"".equals(value)){ + accessor_value.removeValue(itemId); + } } } @@ -227,33 +229,32 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC random *= 1000; if (this.all_null < 3) { if (log.isWarnEnabled()) { - log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null, 5000 + random); + log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null,3); } - ThreadUtl.sleep((long) (5000 + random)); + ThreadUtl.sleep( 3000); + break start; } else if (this.all_null < 6) { if (log.isWarnEnabled()) { log.warn(tag + "重新创建server"); - log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null, 30000 + random); + log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null,3); } -// ThreadUtl.sleep((long) (30000 + random)); - ThreadUtl.sleep((long) ((new Random()).nextInt(3) + 1) * 1000); + ThreadUtl.sleep(3000); break start; } else if (this.all_null < 12) { if (log.isWarnEnabled()) { - log.warn("{} 所有内容都为空, all_null:{} ,暂定{}ms", tag, all_null, '\uea60' + random); + log.warn(tag + "重新创建server"); + log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null,3); } - - ThreadUtl.sleep((long) ('\uea60' + random)); + ThreadUtl.sleep(3000); + break start; } else { if (log.isWarnEnabled()) { - log.warn("{} 所有内容都为空, all_null:{} ,暂定{}ms", tag, all_null, 120000 + random); + log.warn("{} 所有内容都为空, all_null:{} ,暂定{}ms", tag, all_null, 5000); } - - ThreadUtl.sleep((long) (120000 + random)); + ThreadUtl.sleep((long) (5000)); + break start; } - - ++this.all_null; } else { this.all_null = 0; } @@ -292,6 +293,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC } + private void runNew() { Async20Access accessor = null; @@ -389,20 +391,8 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC Object value = OpcUtl.getValue(item, itemState); UnifiedDataAccessor accessor_value = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key); accessor_value.setValue(itemId, value); - -// if (value != null) { -// if (log.isTraceEnabled()) { -// log.trace("Item {} new value: {}, Timestamp: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime()}); -// } -// } else if (log.isInfoEnabled()) { -// log.info("Item {} new value: {}, Timestamp: {}, Quality: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime(), itemState.getQuality()}); -// } log.trace("Item {} new value: {}, Timestamp: {}", new Object[]{itemId, itemState.getValue(), itemState.getTimestamp().getTime()}); - OpcItemDto itemDto = this.getItem(itemId); -// if (Boolean.TRUE.equals(itemDto.getNeed_log())) { -// this.logItemChanged(itemId, accessor_value, value, itemDto); -// } this.logItemChanged(itemId, accessor_value, value, itemDto); } catch (Exception var7) { @@ -412,6 +402,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC } private void logItemChanged(String itemId, UnifiedDataAccessor accessor_value, Object value, OpcItemDto itemDto) { + ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); Object his = accessor_value.getValue(itemId); List relate_items = itemDto.getRelate_items(); if (relate_items != null && !relate_items.isEmpty()) { @@ -423,22 +414,35 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC Object obj = accessor_value.getValue(relate); sb.append("key:" + relate + "value:" + obj + ";"); } - log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value, sb}); -// this.businessLogger.setResource(itemDto.getDevice_code(), itemDto.getDevice_name()).log("信号{}变更从{}->{};信号快照:{}", new Object[]{itemId, his, value, sb}); - } else { - if(his instanceof int[]){ - if(!Arrays.equals((long[]) his, (long[]) value)){ - log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value}); + if (!itemDto.getItem_code().endsWith("heartbeat") && !itemDto.getItem_code().endsWith("time") && !itemDto.getItem_code().endsWith("consumption")) { + // 存在上次点位值为null情况 则不记录日志 + if(!(his instanceof Float) && !(value instanceof Float)){ + LuceneLogDto luceneLogDto = new LuceneLogDto(itemDto.getOpc_server_code(), itemDto.getOpc_plc_code(),4, itemDto.getDevice_code(), itemDto.getItem_code().substring(itemDto.getItem_code().lastIndexOf(".") + 1), + String.valueOf(his), String.valueOf(value)); + luceneLogDto.setLogType(LogTypeEnum.DEVICE_LOG.getDesc()); + String logLevel = paramService.findByCode(AcsConfig.LOGLEVEL).getValue(); + if(StrUtil.isNotEmpty(logLevel) && isNumeric(logLevel) && (luceneLogDto.getLog_level() >= Integer.parseInt(logLevel))){ + log.info("{}", JSON.toJSONString(luceneLogDto)); + } + } + } + } else { + if (!itemDto.getItem_code().endsWith("heartbeat") && !itemDto.getItem_code().endsWith("time") && !itemDto.getItem_code().endsWith("consumption")) { + if(!(his instanceof Float) && !(value instanceof Float)){ + LuceneLogDto luceneLogDto = new LuceneLogDto(itemDto.getOpc_server_code(), itemDto.getOpc_plc_code(),4, itemDto.getDevice_code(), itemDto.getItem_code().substring(itemDto.getItem_code().lastIndexOf(".") + 1), + String.valueOf(his), String.valueOf(value)); + luceneLogDto.setLogType(LogTypeEnum.DEVICE_LOG.getDesc()); + String logLevel = paramService.findByCode(AcsConfig.LOGLEVEL).getValue(); + if(StrUtil.isNotEmpty(logLevel) && isNumeric(logLevel) && (luceneLogDto.getLog_level() >= Integer.parseInt(logLevel))){ + log.info("{}", JSON.toJSONString(luceneLogDto)); + } } - } else if(his instanceof String){ - if(!StrUtil.equals((CharSequence) his, (CharSequence) value)){ - log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value}); - } - } else { - log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value}); } -// this.businessLogger.setResource(itemDto.getDevice_code(), itemDto.getDevice_name()).log("信号{}变更从{}->{}", new Object[]{itemId, his, value}); } } + public static boolean isNumeric(String str) { + return Pattern.compile("^[0-9]+$").matcher(str).matches(); + } + } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceOpcSynchronizeAutoRun.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceOpcSynchronizeAutoRun.java index 2aff28f..013c003 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceOpcSynchronizeAutoRun.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceOpcSynchronizeAutoRun.java @@ -1,23 +1,29 @@ package org.nl.acs.opc; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.lucene.util.NamedThreadFactory; import org.nl.acs.auto.run.AbstractAutoRunnable; import org.nl.acs.opc.service.dto.OpcServerManageDto; +import org.nl.acs.udw.UnifiedDataAccessor; +import org.nl.acs.udw.UnifiedDataAccessorFactory; +import org.nl.acs.udw.UnifiedDataAppService; +import org.openscada.opc.lib.da.Group; +import org.openscada.opc.lib.da.Item; +import org.openscada.opc.lib.da.ItemState; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.*; /** * OPC设备同步启动 - * @author 20220102CG\noblelift */ @Component +@Slf4j public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable { public static boolean isRun = false; @@ -44,10 +50,10 @@ public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable { Map servers = this.opcServerManageService.queryAllServerMap(); Map>> pros; - do { + do{ Thread.sleep(1000L); pros = this.deviceAppService.findAllFormatProtocolFromDriver(); - } while (ObjectUtil.isEmpty(pros)); + }while (ObjectUtil.isEmpty(pros)); Set keys = pros.keySet(); Iterator var4 = keys.iterator(); //代码执行一次 diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/taskscreen/service/impl/TaskScreenServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/taskscreen/service/impl/TaskScreenServiceImpl.java index 4292dcb..02a6491 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/taskscreen/service/impl/TaskScreenServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/taskscreen/service/impl/TaskScreenServiceImpl.java @@ -17,7 +17,6 @@ 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.opc.DeviceAppService; import org.nl.acs.taskscreen.mapper.TaskScreenMapper; import org.nl.acs.taskscreen.service.TaskScreenService; @@ -71,31 +70,7 @@ public class TaskScreenServiceImpl extends CommonServiceImpl extraDeviceCodes = getExtraDeviceCodes(extraValue); - if (CollUtil.isEmpty(extraDeviceCodes) || extraDeviceCodes.size() < 0) { - throw new BadRequestException("没有查询到数据"); - } - String deviceCode1 = extraDeviceCodes.get(0); - DeviceDto linkDevice = deviceService.findByCode(deviceCode1); - String linkDeviceCode = linkDevice.getDevice_code(); - Device device = deviceAppservice.findDeviceByCode(linkDeviceCode); - if (device.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - BeltConveyorDeviceDriver beltConveyorDeviceDriver; - beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) device.getDeviceDriver(); - if (ObjectUtil.isNotEmpty(beltConveyorDeviceDriver.getLed_message())) { - json = beltConveyorDeviceDriver.getLed_message(); - } - } - return json; + return null; } public List getExtraDeviceCodes(String extraValue) { diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/udw/UnifiedDataAccessor.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/udw/UnifiedDataAccessor.java index a23fcab..0a8d2ac 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/udw/UnifiedDataAccessor.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/udw/UnifiedDataAccessor.java @@ -29,6 +29,12 @@ public interface UnifiedDataAccessor { */ void setValue(String key, Object value); + /** + * 删除值 + * @param key + */ + void removeValue(String key); + /** * 获取统一数据 * diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/udw/service/impl/UnifiedDataAccessorImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/udw/service/impl/UnifiedDataAccessorImpl.java index 02680ae..090712b 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/udw/service/impl/UnifiedDataAccessorImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/udw/service/impl/UnifiedDataAccessorImpl.java @@ -39,6 +39,11 @@ public class UnifiedDataAccessorImpl implements UnifiedDataAccessor { this.unifiedDataAppService.setValue(this.unified_key, key, value); } + @Override + public void removeValue(String key) { + + } + @Override public void setValueWithPersistence(String key, Object value) { this.unifiedDataAppService.setValueWithPersistence(this.unified_key, key, value); diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/common/mnt/websocket/SendPrintSocket.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/common/mnt/websocket/SendPrintSocket.java index 092cf8e..87db4a6 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/common/mnt/websocket/SendPrintSocket.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/common/mnt/websocket/SendPrintSocket.java @@ -101,9 +101,9 @@ public class SendPrintSocket { ex.printStackTrace(); } } -// else { -// throw new BadRequestException("当前打印系统未连接"); -// } + else { + throw new BadRequestException("当前打印系统未连接"); + } } } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/tickets/TicketsController.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/tickets/TicketsController.java index 710755b..834342a 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/tickets/TicketsController.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/tickets/TicketsController.java @@ -61,8 +61,8 @@ public class TicketsController { } @PutMapping @Log("修改工单") - public ResponseEntity update(@RequestBody TicketsDto ticketsDto) { - ticketsService.update(ticketsDto); + public ResponseEntity update(@RequestBody Tickets entity) { + ticketsService.update(entity); return new ResponseEntity<>(HttpStatus.OK); } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/lucene/dto/LuceneLogDto.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/lucene/dto/LuceneLogDto.java index edacda4..f8f604d 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/lucene/dto/LuceneLogDto.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/lucene/dto/LuceneLogDto.java @@ -37,6 +37,10 @@ public class LuceneLogDto { /* 日志类型 */ private String log_type; + /** + * 日志级别 + */ + private Integer log_level; /* 方法 */ private String method; @@ -69,11 +73,12 @@ public class LuceneLogDto { private String update_time; - public LuceneLogDto(final String opc_server_code, final String opc_plc_code, + public LuceneLogDto(final String opc_server_code, final String opc_plc_code,final Integer log_level, final String device_code, final String to_home, final String last_home, final String home) { super(); this.device_code = device_code; + this.log_level = log_level; this.content = "信号 [" + opc_server_code + "." + opc_plc_code + "." @@ -83,6 +88,17 @@ public class LuceneLogDto { + home; } + public LuceneLogDto(final Integer log_level,final String method, final String status, + final String requestparam, final String responseparam, final String content) { + super(); + this.log_level = log_level; + this.method = method; + this.status_code = status; + this.requestparam = requestparam; + this.responseparam = responseparam; + this.content = content; + } + public LuceneLogDto(final String device_code, final String remark) { super(); this.device_code = device_code; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/TicketsService.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/TicketsService.java index f630727..cf14583 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/TicketsService.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/TicketsService.java @@ -52,7 +52,7 @@ public interface TicketsService extends IService { * 修改工单 * @param ticketsDto */ - void update(TicketsDto ticketsDto); + void update(Tickets entity); /** * 根据工单号查询工单 diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/dto/Tickets.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/dto/Tickets.java index 3d8cf57..265decf 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/dto/Tickets.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/dto/Tickets.java @@ -37,6 +37,10 @@ public class Tickets { * 生产批次 */ private String actual_batch; + /** + * 送货单号 + */ + private String shdnumber; /** * 生产物料 */ diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/dto/TicketsDto.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/dto/TicketsDto.java index 484df76..43e9b09 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/dto/TicketsDto.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/dto/TicketsDto.java @@ -15,6 +15,8 @@ public class TicketsDto { private String ticket_status; + private String ticket_code; + private String device_code; private String actual_batch; @@ -52,4 +54,6 @@ public class TicketsDto { private String fcarton_number; private String bottle_weight; + + private String shdnumber; } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/dto/mapper/TicketsMapper.xml b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/dto/mapper/TicketsMapper.xml index b97e48b..a9ba8cb 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/dto/mapper/TicketsMapper.xml +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/dto/mapper/TicketsMapper.xml @@ -19,14 +19,15 @@ diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/impl/TicketsServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/impl/TicketsServiceImpl.java index 9fdf0ae..f415190 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/impl/TicketsServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/tickets/impl/TicketsServiceImpl.java @@ -100,6 +100,17 @@ public class TicketsServiceImpl extends ServiceImpl impl String small_model=(String)param.get("small_model"); String bottle_board=(String)param.get("bottle_board"); String carton_board=(String)param.get("carton_board"); + String bottle_weight=(String)param.get("bottle_weight"); + String shdnumber=(String)param.get("shdnumber"); + if(!StrUtil.isNotBlank(planned_quantity)){ + throw new BadRequestException("未填写计划数量"); + } + if(!StrUtil.isNotBlank(carton_board)){ + throw new BadRequestException("未填写纸箱关联标签模板"); + } + if(!StrUtil.isNotBlank(carton_qty)){ + throw new BadRequestException("未填写每箱装瓶数量"); + } if(customer.contains("晶科")){ if(bottle_number.length()!=23){ throw new BadRequestException("瓶盖号不对"); @@ -107,6 +118,12 @@ public class TicketsServiceImpl extends ServiceImpl impl if(carton_number.length()!=33){ throw new BadRequestException("纸箱号不对"); } + if(!StrUtil.isNotBlank(bottle_weight)){ + throw new BadRequestException("未填晶科每罐重量"); + }if(!StrUtil.isNotBlank(shdnumber)){ + throw new BadRequestException("未填送货单"); + } + } Tickets tickets = BeanUtil.copyProperties(param, Tickets.class); // DateTime parse = DateUtil.parse(tickets.getStart_time()); @@ -142,7 +159,8 @@ public class TicketsServiceImpl extends ServiceImpl impl Map map = new LinkedHashMap<>(); map.put("to_order_No", entity.getTicket_id()); map.put("to_ice",entity.getIs_ice()); - map.put("to_qty",entity.getPlanned_quantity()); + map.put("to_labeling",entity.getCarton_qty()); + map.put("to_qty",entity.getPlanned_quantity()); if(StrUtil.isBlank(entity.getBottle_board())){ map.put("is_printbottle",0); }else{ @@ -177,8 +195,8 @@ public class TicketsServiceImpl extends ServiceImpl impl ticketsMapper.updateById(tickets); } @Override - public void update(TicketsDto ticketsDto) { - Tickets tickets = BeanUtil.copyProperties(ticketsDto, Tickets.class); + public void update(Tickets entity) { + Tickets tickets = BeanUtil.copyProperties(entity, Tickets.class); //TODO:强制结束是否需要将工单回传 tickets.setUpdate_by(SecurityUtils.getCurrentUsername()); tickets.setUpdate_time(DateUtil.now()); diff --git a/acs/nladmin-ui/src/api/acs/order/order.js b/acs/nladmin-ui/src/api/acs/order/order.js index 6d7c1e5..3b125b2 100644 --- a/acs/nladmin-ui/src/api/acs/order/order.js +++ b/acs/nladmin-ui/src/api/acs/order/order.js @@ -16,7 +16,7 @@ export function del(ids) { }) } -export function edit(data) { +export function update(data) { return request({ url: 'api/tickets', method: 'put', @@ -46,4 +46,4 @@ export function submits(param) { }) } -export default { add, del, edit, query, submits, finishorder } \ No newline at end of file +export default { add, del, update, query, submits, finishorder } \ No newline at end of file diff --git a/acs/nladmin-ui/src/views/acs/order/index.vue b/acs/nladmin-ui/src/views/acs/order/index.vue index b59ca84..eae7bca 100644 --- a/acs/nladmin-ui/src/views/acs/order/index.vue +++ b/acs/nladmin-ui/src/views/acs/order/index.vue @@ -40,7 +40,7 @@ class="filter-item" size="mini" type="primary" @@ -56,7 +56,7 @@ size="mini" type="primary" icon="el-icon-plus" - @click="formDias=true" + @click="editBtn(scope.row.ticket_id)" > {{ $t('auto.common.Update') }} --> @@ -84,15 +84,18 @@ - + - + + + +
- + @@ -170,17 +173,53 @@ - + - + + + + + + + - + + + {{ item.template_name }} + {{ item.bottle_board }} + + - + + + {{ item.template_name }} + {{ item.carton_board }} + + @@ -196,7 +235,7 @@ @@ -238,13 +277,14 @@ @@ -279,7 +319,7 @@ export default { optShow: { add: false, edit: false, - del: true, + del: false, reset: false, download: true }, @@ -329,6 +369,7 @@ export default { ticket_id: null, batch_number: null, bottle_weight: null, + shdnumber: null, device_code: null, production_orders: null, production_materials: null, @@ -353,6 +394,7 @@ export default { ticket_id: null, batch_number: null, bottle_weight: null, + shdnumber: null, device_code: null, production_orders: null, production_materials: null, @@ -493,6 +535,7 @@ export default { this.form.bottle_number=row.bottle_number this.form.carton_number=row.carton_number this.form.carton_qty=row.carton_qty + this.form.shdnumber=row.shdnumber } }, handleDateTimeChange() { @@ -541,23 +584,26 @@ export default { }, queryBtn(ticket) { // 禁用按钮 + console.log(ticket) + this.form=ticket this.isDisabled = true - crudTask.query(ticket).then(res => { - // 请求完成后启用按钮 - this.isDisabled = false - this.form = res - this.crud.toQuery() - this.formDia = true - if (this.form1.weight_ok) { - const parts = this.form1.weight_ok.split(',') - this.input3 = parts[0] || '' // 如果没有值,则为空字符串 - this.input4 = parts[1] || '' // 如果没有第二个值,则为空字符串 - } - }) - // 设置定时器,等待一定时间后再次允许请求 - setTimeout(() => { - this.isDisabled = false // 可根据具体需求进行调整 - }, 1000) // 5000 毫秒,即 5 秒钟 + this.formDias = true + // crudTask.update(this.form).then(res => { + // // 请求完成后启用按钮 + // this.isDisabled = false + // this.form = res + // this.crud.toQuery() + // this.formDia = true + // if (this.form1.weight_ok) { + // const parts = this.form1.weight_ok.split(',') + // this.input3 = parts[0] || '' // 如果没有值,则为空字符串 + // this.input4 = parts[1] || '' // 如果没有第二个值,则为空字符串 + // } + // }) + // // 设置定时器,等待一定时间后再次允许请求 + // setTimeout(() => { + // this.isDisabled = false // 可根据具体需求进行调整 + // }, 1000) // 5000 毫秒,即 5 秒钟 }, saveBtn() { // 禁用按钮 @@ -573,6 +619,7 @@ export default { device_code: null, batch_number: null, bottle_weight: null, + shdnumber: null, production_orders: null, production_materials: null, planned_quantity: null, @@ -602,13 +649,13 @@ export default { }, 1000) // 5000 毫秒,即 5 秒钟 }, editBtn() { - if (!this.isFormChanged) { - // 如果表单没有变化,不进行提交 - return - } - 禁用按钮 + // this.form=crudTask.query(ticket.ticket_id) this.isDisabled = true - crudTask.edit(this.form1).then(res => { + // if (!this.isFormChanged) { + // // 如果表单没有变化,不进行提交 + // return + // } + crudTask.update(this.form).then(res => { // 请求完成后启用按钮 this.isDisabled = false this.crud.toQuery() @@ -617,6 +664,7 @@ export default { this.originalForm = JSON.parse(JSON.stringify(this.form)) console.log(JSON.parse(JSON.stringify(this.form))) this.isFormChanged = false + this.form={} }) this.extension = [{ name: '', diff --git a/acs/nladmin-ui/src/views/acs/order/template.vue b/acs/nladmin-ui/src/views/acs/order/template.vue index e45030a..cd60529 100644 --- a/acs/nladmin-ui/src/views/acs/order/template.vue +++ b/acs/nladmin-ui/src/views/acs/order/template.vue @@ -367,7 +367,7 @@ export default { duration: 0 }) } - const wsUri = window.g.dev.VUE_APP_BASE_API.replace('http', 'ws') + '/webSocket/sendPrint/' + uuidv1() + const wsUri = window.g.prod.VUE_APP_BASE_API.replace('http', 'ws') + '/webSocket/sendPrint/' + uuidv1() this.websock = new WebSocket(wsUri) this.websock.onmessage = this.webSocketOnMessage },