diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/ConveyorDevice.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/ConveyorDevice.java index f7bebe8..3a7dd6a 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/ConveyorDevice.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/ConveyorDevice.java @@ -46,14 +46,14 @@ public class ConveyorDevice { public void run() { System.out.println("test"); String MODE = "RD1.RD1." + id + ".mode"; - String code = OpcUtl.read(MODE); - if ("2".equals(code)) { - TaskService taskserver = SpringContextHolder.getBean(TaskServiceImpl.class); - TaskDto dto = new TaskDto(); - dto.setStart_point_code(id); - dto.setNext_point_code("1002"); - taskserver.create(dto); - } +// String code = OpcUtl.read(MODE); +// if ("2".equals(code)) { +// TaskService taskserver = SpringContextHolder.getBean(TaskServiceImpl.class); +// TaskDto dto = new TaskDto(); +// dto.setStart_point_code(id); +// dto.setNext_point_code("1002"); +// taskserver.create(dto); +// } } } } diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/ItemValue.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/ItemValue.java new file mode 100644 index 0000000..824c769 --- /dev/null +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/ItemValue.java @@ -0,0 +1,36 @@ +package org.nl.acs.device_driver.driver; + +/** + * @author ldjun + * @version 1.0 + * @date 2023年02月01日 11:21 + * @desc desc + */ +public class ItemValue { + private String item_code; + private Object item_value; + + public ItemValue() { + } + + public ItemValue(String item_code, Object item_value) { + this.item_code = item_code; + this.item_value = item_value; + } + + public String getItem_code() { + return this.item_code; + } + + public void setItem_code(String item_code) { + this.item_code = item_code; + } + + public Object getItem_value() { + return this.item_value; + } + + public void setItem_value(Object item_value) { + this.item_value = item_value; + } +} diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java index ebc6edf..e86d8cb 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java @@ -64,27 +64,27 @@ public interface OpcDeviceDriver extends DeviceDriver { } default Float getFloatValue(String protocol) { - RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class); - return (Float)redisUtils.get(this.getItem(protocol)); -// return (Float) this.getOpcValueAccessor().getValue(this.getItem(protocol)); +// RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class); +// return (Float)redisUtils.get(this.getItem(protocol)); + return (Float) this.getOpcValueAccessor().getValue(this.getItem(protocol)); } default int[] getIntegeregerArrayValue(String protocol) { -// return (int[]) this.getOpcValueAccessor().getValue(this.getItem(protocol)); - RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class); - return (int[])redisUtils.get(this.getItem(protocol)); + return (int[]) this.getOpcValueAccessor().getValue(this.getItem(protocol)); +// RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class); +// return (int[])redisUtils.get(this.getItem(protocol)); } default String getStringValue(String protocol) { -// return (String) this.getOpcValueAccessor().getValue(this.getItem(protocol)); - RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class); - return (String)redisUtils.get(this.getItem(protocol)); + return (String) this.getOpcValueAccessor().getValue(this.getItem(protocol)); +// RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class); +// return (String)redisUtils.get(this.getItem(protocol)); } default Object getValue(String protocol) { -// return this.getOpcValueAccessor().getValue(this.getItem(protocol)); - RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class); - return redisUtils.get(this.getItem(protocol)); + return this.getOpcValueAccessor().getValue(this.getItem(protocol)); +// RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class); +// return redisUtils.get(this.getItem(protocol)); } default String getItem(String item) { diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/ItemProtocol.java index 5cd9e71..e493489 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/ItemProtocol.java @@ -84,7 +84,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/LnshLaminatingMachineDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/LnshLaminatingMachineDeviceDriver.java index 771f8fd..6466a8f 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/LnshLaminatingMachineDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_Laminating_machine/LnshLaminatingMachineDeviceDriver.java @@ -161,12 +161,7 @@ public class LnshLaminatingMachineDeviceDriver extends AbstractOpcDeviceDriver i return; } - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { + if (mode == 0) { this.setIsonline(false); this.setIserror(true); message = "未联机"; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/ItemProtocol.java index 504a85f..596a810 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/ItemProtocol.java @@ -153,7 +153,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/LnshKilnLaneDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/LnshKilnLaneDeviceDriver.java index f0ad993..ac2e711 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/LnshKilnLaneDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/LnshKilnLaneDeviceDriver.java @@ -258,11 +258,7 @@ public class LnshKilnLaneDeviceDriver extends AbstractOpcDeviceDriver implements if (this.isStop()) { //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 + } else if (mode == 0) { this.setIsonline(false); this.setIserror(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/ItemProtocol.java index 8b2a281..69eb135 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/ItemProtocol.java @@ -82,7 +82,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/LnshLabelingMachineDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/LnshLabelingMachineDeviceDriver.java index 1dd0b10..0ff9b91 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/LnshLabelingMachineDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/LnshLabelingMachineDeviceDriver.java @@ -142,11 +142,6 @@ public class LnshLabelingMachineDeviceDriver extends AbstractOpcDeviceDriver imp if (this.isStop()) { //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 } else if (mode == 0) { this.setIsonline(false); this.setIserror(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_one_rgv/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_one_rgv/ItemProtocol.java index e78c329..7bbedf7 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_one_rgv/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_one_rgv/ItemProtocol.java @@ -114,7 +114,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_one_rgv/LnshOneRGVDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_one_rgv/LnshOneRGVDeviceDriver.java index b239a28..b26aaad 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_one_rgv/LnshOneRGVDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_one_rgv/LnshOneRGVDeviceDriver.java @@ -204,12 +204,7 @@ public class LnshOneRGVDeviceDriver extends AbstractOpcDeviceDriver implements D return; } - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { + if (mode == 0) { this.setIsonline(false); this.setIserror(true); message = "未联机"; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/ItemProtocol.java index 296cce8..2404010 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/ItemProtocol.java @@ -789,7 +789,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java index 908ba48..10ce332 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java @@ -664,12 +664,7 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD return; } - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { + if (mode == 0) { this.setIsonline(false); this.setIserror(true); message = "未联机"; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/ItemProtocol.java index 973f12a..1439d30 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/ItemProtocol.java @@ -193,7 +193,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); +// //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/LnshPalletizingManipulatorDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/LnshPalletizingManipulatorDeviceDriver.java index 2acfafe..3c68a69 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/LnshPalletizingManipulatorDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/LnshPalletizingManipulatorDeviceDriver.java @@ -258,11 +258,6 @@ public class LnshPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDri if (this.isStop()) { //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 } else if (mode == 0) { this.setIsonline(false); this.setIserror(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator_site/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator_site/ItemProtocol.java index c583d0a..efb04d1 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator_site/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator_site/ItemProtocol.java @@ -192,7 +192,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/ItemProtocol.java index 4f597a5..64e9478 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/ItemProtocol.java @@ -174,7 +174,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/ItemProtocol.java index 8fbe067..1418aef 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/ItemProtocol.java @@ -723,7 +723,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/ItemProtocol.java index 4a9e674..fecadb4 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/ItemProtocol.java @@ -117,7 +117,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java index d8196e4..478b82a 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java @@ -210,11 +210,6 @@ public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements if (this.isStop()) { //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 } else if (mode == 0) { this.setIsonline(false); this.setIserror(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/rljn_package_palletSplit_manipulator/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/rljn_package_palletSplit_manipulator/ItemProtocol.java index 63d1035..cd8c47c 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/rljn_package_palletSplit_manipulator/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/rljn_package_palletSplit_manipulator/ItemProtocol.java @@ -799,7 +799,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/ItemProtocol.java index 7d368cf..9cf2b56 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/ItemProtocol.java @@ -84,7 +84,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java index d4e15b0..138f0c9 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java @@ -180,12 +180,8 @@ public class StandardCoveyorControlDeviceDriver extends AbstractOpcDeviceDriver return; } - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { + + if (mode == 0) { this.setIsonline(false); this.setIserror(true); message = "未联机"; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/ItemProtocol.java index ca6f68e..911baff 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/ItemProtocol.java @@ -101,7 +101,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/ItemProtocol.java index dae1985..a10751a 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/ItemProtocol.java @@ -96,7 +96,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_monitor/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_monitor/ItemProtocol.java index c6f74ef..6d19e4b 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_monitor/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_monitor/ItemProtocol.java @@ -79,7 +79,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/ItemProtocol.java index 7f74f5d..bf7d6d9 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/ItemProtocol.java @@ -72,7 +72,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/StandardEmptyPalletSiteDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/StandardEmptyPalletSiteDeviceDriver.java index dee4d3d..d3aebe8 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/StandardEmptyPalletSiteDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/StandardEmptyPalletSiteDeviceDriver.java @@ -146,13 +146,6 @@ public class StandardEmptyPalletSiteDeviceDriver extends AbstractOpcDeviceDriver if (this.isStop()) { - //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - - //未联机 } else if (mode == 0) { this.setIsonline(false); this.setIserror(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java index 3b00ba5..d55eb22 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java @@ -74,7 +74,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java index b789295..2b3405e 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java @@ -209,12 +209,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp return; } - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { + if (mode == 0) { this.setIsonline(false); this.setIserror(true); message = "未联机"; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_rgv/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_rgv/ItemProtocol.java index cbd0060..03a78a1 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_rgv/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_rgv/ItemProtocol.java @@ -94,7 +94,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index 4fc82a5..d30e61d 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -309,12 +309,12 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { if (device.getDeviceDriver() instanceof LnshPalletizingManipulatorSiteDeviceDriver) { lnshPalletizingManipulatorSiteDeviceDriver = (LnshPalletizingManipulatorSiteDeviceDriver) device.getDeviceDriver(); - if (lnshPalletizingManipulatorSiteDeviceDriver.getIserror() - && !device_code.equals("MDJXS601") - && !device_code.equals("MDJXS201") - && !device_code.equals("MDJXS301")) { - throw new BadRequestException("设备状态异常,下发失败!"); - } +// if (lnshPalletizingManipulatorSiteDeviceDriver.getIserror() +// && !device_code.equals("MDJXS601") +// && !device_code.equals("MDJXS201") +// && !device_code.equals("MDJXS301")) { +// throw new BadRequestException("设备状态异常,下发失败!"); +// } if (StrUtil.isEmpty(qty)) { throw new WDKException("数量不能为空"); } @@ -329,10 +329,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { } if (device.getDeviceDriver() instanceof LnshPalletizingManipulatorDeviceDriver) { lnshPalletizingManipulatorDeviceDriver = (LnshPalletizingManipulatorDeviceDriver) device.getDeviceDriver(); - if (lnshPalletizingManipulatorDeviceDriver.getIserror() - && !device_code.equals("MDJXS601")) { - throw new BadRequestException("设备状态异常,下发失败!"); - } +// if (lnshPalletizingManipulatorDeviceDriver.getIserror() +// && !device_code.equals("MDJXS601")) { +// throw new BadRequestException("设备状态异常,下发失败!"); +// } if (StrUtil.isEmpty(qty)) { throw new WDKException("数量不能为空"); } @@ -347,9 +347,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { } if (device.getDeviceDriver() instanceof LnshSplitManipulatorDeviceDriver) { lnshSplitManipulatorDeviceDriver = (LnshSplitManipulatorDeviceDriver) device.getDeviceDriver(); - if (lnshSplitManipulatorDeviceDriver.getIserror()) { - throw new BadRequestException("设备状态异常,下发失败!"); - } +// if (lnshSplitManipulatorDeviceDriver.getIserror()) { +// throw new BadRequestException("设备状态异常,下发失败!"); +// } if (StrUtil.isEmpty(qty)) { throw new WDKException("数量不能为空"); } @@ -378,9 +378,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { } if (device.getDeviceDriver() instanceof LnshPackagePalletManipulatorDeviceDriver) { lnshPackagePalletManipulatorDeviceDriver = (LnshPackagePalletManipulatorDeviceDriver) device.getDeviceDriver(); - if (lnshPackagePalletManipulatorDeviceDriver.getIserror()) { - throw new BadRequestException("设备状态异常,下发失败!"); - } +// if (lnshPackagePalletManipulatorDeviceDriver.getIserror()) { +// throw new BadRequestException("设备状态异常,下发失败!"); +// } if (StrUtil.isEmpty(qty)) { throw new WDKException("数量不能为空"); } @@ -397,9 +397,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { if (device.getDeviceDriver() instanceof RljnPackagePalletSplitManipulatorDeviceDriver) { rljnPackagePalletSplitManipulatorDeviceDriver = (RljnPackagePalletSplitManipulatorDeviceDriver) device.getDeviceDriver(); - if (rljnPackagePalletSplitManipulatorDeviceDriver.getIserror()) { - throw new BadRequestException("设备状态异常,下发失败!"); - } +// if (rljnPackagePalletSplitManipulatorDeviceDriver.getIserror()) { +// throw new BadRequestException("设备状态异常,下发失败!"); +// } if (StrUtil.isEmpty(qty)) { throw new WDKException("数量不能为空"); } diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/AbstractAutoRunnable.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/AbstractAutoRunnable.java new file mode 100644 index 0000000..0d146c5 --- /dev/null +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/AbstractAutoRunnable.java @@ -0,0 +1,107 @@ +package org.nl.acs.opc; + +import lombok.extern.slf4j.Slf4j; +import org.nl.start.auto.run.ThreadStatusEnum; +import org.nl.start.auto.run.ThreadUsedStatusEnum; + +import java.util.Date; + +@Slf4j +public abstract class AbstractAutoRunnable implements Runnable { + private ThreadStatusEnum status; + private Date startTime; + private Date stopTime; + private String stopMessage; + private ThreadUsedStatusEnum usedStatus; + @Override + public void run() { + this.setStatus(ThreadStatusEnum.run); + this.setStartTime(new Date()); + this.setStopMessage(""); + String true_clear = "执行完毕"; + + try { + this.before(); + //子类该方法是个死循环 + this.autoRun(); + this.setStopMessage(true_clear); + } catch (Throwable arg5) { + log.warn("", arg5); + System.out.println(arg5.getMessage()); + // this.setStopMessage(ExceptionUtlEx.getSimpleTrace(arg5)); + } finally { + this.setStopTime(new Date()); + this.setStatus(ThreadStatusEnum.stop); + this.after(); + } + + } + + public void before() throws Exception { + } + + public void after() { + } + + public void stop() { + this.after(); + } + + public Boolean getForbidStop() { + return Boolean.valueOf(false); + } + + public Boolean getForbidDisable() { + return Boolean.valueOf(false); + } + + public abstract String getCode(); + + public abstract String getName(); + + public String getDescription() { + return this.getName(); + } + + public abstract void autoRun() throws Exception; + + public ThreadStatusEnum getStatus() { + return this.status; + } + + public void setStatus(ThreadStatusEnum status) { + this.status = status; + } + + public Date getStartTime() { + return this.startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getStopTime() { + return this.stopTime; + } + + public void setStopTime(Date stopTime) { + this.stopTime = stopTime; + } + + public String getStopMessage() { + return this.stopMessage; + } + + public void setStopMessage(String stopMessage) { + this.stopMessage = stopMessage; + } + + public ThreadUsedStatusEnum getUsedStatus() { + return this.usedStatus; + } + + public void setUsedStatus(ThreadUsedStatusEnum usedStatus) { + this.usedStatus = usedStatus; + } +} diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java index 5031423..7bd1259 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java @@ -6,8 +6,6 @@ import cn.hutool.core.util.StrUtil; import lombok.extern.slf4j.Slf4j; import org.nl.modules.udw.UnifiedDataAccessor; import org.nl.modules.udw.UnifiedDataAccessorFactory; -import org.nl.utils.RedisUtils; -import org.nl.utils.SpringContextHolder; import org.openscada.opc.lib.da.Group; import org.openscada.opc.lib.da.Item; import org.openscada.opc.lib.da.ItemState; @@ -21,10 +19,12 @@ public class DeviceOpcProtocolRunable implements Runnable { OpcServerManageDto OpcServer; int error_num; String message; + private Server server; public DeviceOpcProtocolRunable() { this.error_num = 0; this.message = null; + this.server = null; } public List getProtocols() { @@ -62,8 +62,12 @@ public class DeviceOpcProtocolRunable implements Runnable { public void run() { while (true) { try { - Server server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain()); - Group group = server.addGroup(); + this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain()); +// Group group = server.addGroup(this.OpcServer.getOpc_host()); + Group group = server.addGroup(this.OpcServer.getOpc_code()); + if(ObjectUtil.isEmpty(group)){ + log.info("group is null "); + } List itemsString = new ArrayList(); Iterator it = this.protocols.iterator(); @@ -112,11 +116,18 @@ public class DeviceOpcProtocolRunable implements Runnable { label97: while (true) { long begin = System.currentTimeMillis(); - Map itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0])); + Map itemStatus = null; + try { + itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0])); + } catch (Exception e){ + System.out.println("数据同步异常:"+ this.getOpcServer().getOpc_code()); + //e.printStackTrace(); + } long end = System.currentTimeMillis(); log.trace("{} 开始记时{}", tag, DateUtil.now()); long duration = end - begin; log.trace("{} 读取耗时:{}", tag, duration); + System.out.println("线程:"+tag + " 读取耗时:"+ duration); if (duration > 1000L) { if (!time_out) { log.warn("{} 读取超时 : {}", tag, duration); @@ -127,6 +138,8 @@ public class DeviceOpcProtocolRunable implements Runnable { time_out = false; } +// if(ObjectUtil.isEmpty(itemStatus)) continue label97; + Set items = itemStatus.keySet(); Iterator var18 = items.iterator(); @@ -152,11 +165,8 @@ public class DeviceOpcProtocolRunable implements Runnable { item = (Item) var18.next(); ItemState itemState = (ItemState) itemStatus.get(item); value = OpcUtl.getValue(item, itemState); -// his = accessor_value.getValue(item.getId()); - RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class); - his=redisUtils.get(item.getId()); - - if (!ObjectUtil.equal(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) { + his = accessor_value.getValue(item.getId()); + if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) { log.warn("opc 值不健康 item: {}, 状态: {}", item.getId(), itemState.getQuality()); } } while (ObjectUtil.equal(value, his));//如果两次的值相等,不走下面的代码 @@ -177,16 +187,24 @@ public class DeviceOpcProtocolRunable implements Runnable { log.info("信号{}变更从{}->{};信号快照:{}", new Object[]{item.getId(), his, value, sb}); } +// accessor_value.setValueWithPersistence(item.getId(),accessor_value.getValue(item.getId())); +// accessor_value.getHistoryUnifiedData(item.getId()); //设置值 - // accessor_value.setValue(item.getId(), value); - RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class); - redisUtils.set(item.getId(), value); - + accessor_value.setValue(item.getId(), value); } } } catch (Exception var30) { - String error_message = "设备信息同步异常"; + if (this.server != null) { + try { + this.server.disconnect(); + } catch (Exception var25) { + } + } + + this.server = null; + + String error_message = "设备信息同步异常,"+var30; if (!StrUtil.equals(this.message, error_message)) { log.warn("", var30); } @@ -195,6 +213,7 @@ public class DeviceOpcProtocolRunable implements Runnable { Thread.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000)); } catch (InterruptedException e) { e.printStackTrace(); +// Thread.currentThread().interrupt();不会真正停止线程 } ++this.error_num; if (this.error_num > 3 && !StrUtil.equals(this.message, error_message)) { diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/ObjectUtl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/ObjectUtl.java new file mode 100644 index 0000000..a23fe7d --- /dev/null +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/ObjectUtl.java @@ -0,0 +1,72 @@ +package org.nl.acs.opc; + + +import org.nl.exception.WDKException; + +import java.util.Arrays; +import java.util.Objects; + +public class ObjectUtl { + private ObjectUtl() { + } + + public static boolean isEquals(Object a, Object b) { + if (a == null && b == null) { + return true; + } else if (a != null && b != null) { + if (a.getClass().isArray()) { + if (a instanceof boolean[]) { + return Arrays.equals((boolean[]) ((boolean[]) a), (boolean[]) ((boolean[]) b)); + } else if (a instanceof byte[]) { + return Arrays.equals((byte[]) ((byte[]) a), (byte[]) ((byte[]) b)); + } else if (a instanceof int[]) { + return Arrays.equals((int[]) ((int[]) a), (int[]) ((int[]) b)); + } else if (a instanceof long[]) { + return Arrays.equals((long[]) ((long[]) a), (long[]) ((long[]) b)); + } else if (a instanceof double[]) { + return Arrays.equals((double[]) ((double[]) a), (double[]) ((double[]) b)); + } else if (a instanceof short[]) { + return Arrays.equals((short[]) ((short[]) a), (short[]) ((short[]) b)); + } else if (a instanceof char[]) { + return Arrays.equals((char[]) ((char[]) a), (char[]) ((char[]) b)); + } else if (a instanceof float[]) { + return Arrays.equals((float[]) ((float[]) a), (float[]) ((float[]) b)); + } else if (a instanceof Object[]) { + return Arrays.equals((Object[]) ((Object[]) a), (Object[]) ((Object[]) b)); + } else { + throw new WDKException("未实现"); + } + } else { + return Objects.equals(a, b); + } + } else { + return false; + } + } + + public static boolean isTrue(Boolean boolean_) { + return boolean_ != null && isEquals(boolean_, true); + } + + public static boolean isTrue(Boolean targetBoolean, boolean defaultBoolean) { + return targetBoolean == null ? defaultBoolean : targetBoolean; + } + + public static boolean isFalse(Boolean boolean_) { + return boolean_ != null && isEquals(boolean_, false); + } + + + + + + public static boolean isObject(Class clazz) { + if (clazz == null) { + return false; + } else if (clazz.getClass().isArray()) { + return false; + } else { + return Object.class.isAssignableFrom(clazz); + } + } +} \ No newline at end of file diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerService.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerService.java new file mode 100644 index 0000000..3e1f7a3 --- /dev/null +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerService.java @@ -0,0 +1,21 @@ +package org.nl.acs.opc; + +import org.nl.acs.device_driver.driver.ItemValue; +import org.openscada.opc.lib.da.Group; + +/** + * @author ldjun + * @version 1.0 + * @date 2023年02月01日 11:26 + * @desc desc + */ +public interface OpcServerService { + + void reload(); + + Group getServer(String var1); + + void writeInteger(String var1, ItemValue... var2); + + void clearServer(String var1); +} diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerServiceImpl.java new file mode 100644 index 0000000..8c24406 --- /dev/null +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerServiceImpl.java @@ -0,0 +1,154 @@ +package org.nl.acs.opc; + +import org.jinterop.dcom.common.JIException; +import org.nl.acs.device_driver.driver.ItemValue; +import org.nl.exception.WDKException; +import org.nl.start.auto.initial.ApplicationAutoInitial; +import org.openscada.opc.lib.common.NotConnectedException; +import org.openscada.opc.lib.da.Group; +import org.openscada.opc.lib.da.Server; +import org.openscada.opc.lib.da.UnknownGroupException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.net.UnknownHostException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +/** + * @author ldjun + * @version 1.0 + * @date 2023年02月01日 11:27 + * @desc desc + */ +@Service +public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoInitial { + + private static final Logger log = LoggerFactory.getLogger(OpcServerServiceImpl.class); + @Autowired OpcServerManageService opcServerManageService; + Map opcServerManageDtos = new HashMap(); + Map servers = Collections.synchronizedMap(new HashMap()); + Map groups = Collections.synchronizedMap(new HashMap()); + + public OpcServerServiceImpl() {} + + public void autoInitial() throws Exception { + this.reload(); + if (OpcConfig.auto_start_opc) { + Thread t = + new Thread() { + public void run() { + Iterator var1 = OpcServerServiceImpl.this.opcServerManageDtos.values().iterator(); + + while (var1.hasNext()) { + OpcServerManageDto dto = (OpcServerManageDto) var1.next(); + + try { + OpcServerServiceImpl.this.getServer(dto.getOpc_code()); + OpcServerServiceImpl.log.info("加载opc server {}", dto.getOpc_code()); + } catch (Exception var4) { + OpcServerServiceImpl.log.warn("启动无法载入servers", var4); + } + } + } + }; + t.start(); + } + } + + public synchronized void reload() { + this.opcServerManageDtos = this.opcServerManageService.queryAllServerMap(); + this.opcServerManageDtos = Collections.synchronizedMap(this.opcServerManageDtos); + } + + public synchronized Group getServer(String code) { + Group group = null; + group = (Group) this.groups.get(code); + if (group != null) { + try { + if (group.isActive()) { + return group; + } + } catch (JIException var9) { + var9.printStackTrace(); + } + } + + Server server = (Server) this.servers.get(code); + boolean needcreate = false; + if (server == null) { + needcreate = true; + } else { + try { + group = server.findGroup(OpcConfig.opc_server_default_group); + } catch (UnknownHostException + | JIException + | UnknownGroupException + | NotConnectedException + | IllegalArgumentException var8) { + var8.printStackTrace(); + needcreate = true; + } + } + + if (needcreate) { + OpcServerManageDto dto = (OpcServerManageDto) this.opcServerManageDtos.get(code); + if (dto == null) { + throw new WDKException("code 不存在"); + } + + server = OpcServerUtl.getServerWithOutException( + dto.getOpc_host(), + dto.getCls_id(), + dto.getUser(), + dto.getPassword(), + dto.getDomain()); + +// server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain()); + + + try { + group = server.addGroup(OpcConfig.opc_server_default_group); + } catch (Exception var7) { + throw new WDKException(var7); + } + + this.servers.put(code, server); + this.groups.put(code, group); + } + + return group; + } + + public synchronized void clearServer(String code) { + try { + Server server = (Server) this.servers.get(code); + if (server!=null){ + server.disconnect(); + } + + } catch (Exception e) { + e.printStackTrace(); + log.error("清理server异常,",e.getMessage()); + } + + this.servers.remove(code); + this.groups.remove(code); + } + + public void writeInteger(String code, ItemValue... values) { + try { + Group group = this.getServer(code); + OpcUtl.writeValue(group, values); + } catch (Exception var4) { + this.clearServer(code); + log.warn("写入出错opc server {} 重新加载", code, var4); + ThreadUtl.sleep(5000L); + throw var4; + } + } +} diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java index c386e1c..1bb427c 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java @@ -4,19 +4,28 @@ import cn.hutool.core.util.NumberUtil; import lombok.extern.slf4j.Slf4j; import org.jinterop.dcom.common.JIException; import org.jinterop.dcom.core.*; +import org.nl.acs.device_driver.driver.ItemValue; import org.nl.exception.BadRequestException; import org.nl.exception.WDKException; import org.openscada.opc.lib.common.ConnectionInformation; import org.openscada.opc.lib.da.*; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.concurrent.Executors; @Slf4j public class OpcUtl { - private static int timeout = 180000; + private static int timeout = 1*60*1000; private static String key = "rpc.socketTimeout"; + public static int successNum=0; + public static int errNum=0; + + static { + checkTimeout(); + } public static void checkTimeout() { if (Integer.getInteger(key, 0).intValue() != timeout) { @@ -26,9 +35,20 @@ public class OpcUtl { } - public static void writeValue(Group group, WriteRequest... requests) { + public static void writeValue(Group group, WriteRequest... requests) throws WDKException { try { - Map e = group.write(requests); + Map e=null; + try{ + e=group.write(requests); + group.write(requests); + }catch (Exception e1){ + try{ + e= group.write(requests); + }catch (Exception e2){ + e= group.write(requests); + } + } + boolean is_success = true; StringBuilder message = new StringBuilder(); Iterator arg4 = e.keySet().iterator(); @@ -50,9 +70,60 @@ public class OpcUtl { if (!is_success) { // throw new BusinessException(message.toString()); + System.out.println("下发信号失败:"+message.toString()); + System.out.println("下发信号失败原因:"+message.toString()); + log.info("下发信号失败:"+message.toString()); + throw new WDKException(message.toString()); } } catch (JIException arg7) { - // throw new BusinessException(arg7); + log.info("下发信号失败:"+arg7.getMessage()); + System.out.println("下发信号失败原因:"+arg7.getMessage()); + throw new WDKException(arg7); + } + } + + public static void writeValue(Group group, ItemValue... values) throws WDKException { + try { + if (values != null && values.length > 0) { + List ws = new ArrayList(); + ItemValue[] var3 = values; + int var4 = values.length; + + for(int var5 = 0; var5 < var4; ++var5) { + ItemValue value = var3[var5]; + Item item = group.addItem(value.getItem_code()); + ws.add(new WriteRequest(item, getVariant(value.getItem_value()))); + } + + writeValue(group, (WriteRequest[])ws.toArray(new WriteRequest[0])); + } + + } catch (AddFailedException | JIException var8) { + throw new WDKException(var8); + } + } + + public static JIVariant getVariant(Object object) { + if (object instanceof Integer) { + return getIntegerVariant((Integer)object); + } else if (object instanceof String) { + return getStringVariant((String)object); + } else if (object instanceof byte[]) { + return getByteArrayVariant((byte[])((byte[])object)); + } else if (object instanceof Byte[]) { + return getByteArrayVariant((Byte[])((Byte[])object)); + } else if (object instanceof Boolean) { + return new JIVariant((Boolean)object); + } else if (object instanceof int[]) { + return getByteArrayVariantxx((int[])((int[])object)); + } else if (object instanceof Integer[]) { + JIArray array = new JIArray((Integer)object, false); + JIVariant value = new JIVariant(array); + return value; + } else if (object instanceof JIVariant) { + return (JIVariant)object; + } else { + throw new WDKException("未实现目前支持是int,string,byte[]"); } } @@ -60,6 +131,7 @@ public class OpcUtl { if (NumberUtil.compare(itemState.getQuality(), Short.valueOf(QualityTypeValue.OPC_QUALITY_GOOD)) != 0) { if (item != null) { log.debug("value is not good {} : {}", item.getId(), itemState.getQuality()); +// throw new WDKException("值不健康进行重连!"); } else { log.debug("value is not good {}", itemState.getQuality()); } @@ -150,12 +222,28 @@ public class OpcUtl { server = new Server(getConnection(host, clsid, user, password, domain), Executors.newSingleThreadScheduledExecutor()); server.connect(); + successNum++; return server; } catch (Exception e) { - throw new WDKException(e); + errNum++; +// e.printStackTrace(); + System.out.println("server error:"+e.getMessage()); + throw new WDKException(e.getMessage()); + }finally{ + System.out.println("successNum:"+successNum); + System.out.println("errNum:"+errNum); } } + public static Server getAutoServer(String host, String clsid, String user, String password, String domain) throws WDKException { + checkTimeout(); + Server server = null; + server = new Server(getConnection(host, clsid, user, password, domain), Executors.newSingleThreadScheduledExecutor()); + AutoReconnectController autoReconnectController = new AutoReconnectController(server); + autoReconnectController.connect(); + return server; + } + public static ConnectionInformation getConnection(String host, String clsid, String user, String password, String domain) { ConnectionInformation connection = new ConnectionInformation(); @@ -167,31 +255,44 @@ public class OpcUtl { return connection; } - public static String read(String item) throws Exception { - System.out.println(item); - Server server = getServer("192.168.81.251", "7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729", "administrator", "Huawei@123", ""); -// String byteItemString = "RD1.RD1.1001.mode"; - Group group = server.addGroup(); - Item byteItem = group.addItem(item); - ItemState itemState = null; - JIVariant value = null; - itemState = byteItem.read(true); - value = itemState.getValue(); - String data = OpcUtl.getValue(byteItem, itemState) + ""; - return data; + public static JIVariant getByteArrayVariantxx(int[] bytes) { + Integer[] byte_Data = new Integer[bytes.length]; + + for(int i = 0; i < bytes.length; ++i) { + byte_Data[i] = bytes[i]; + } + + JIArray array = new JIArray(byte_Data, false); + JIVariant value = new JIVariant(array); + return value; } - public static void main(String[] args) throws Exception { - Server server = getServer("192.168.81.251", "7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729", "administrator", "Huawei@123", ""); - String byteItemString = "RD1.RD1.1001.mode"; - Group group = server.addGroup(); - Item byteItem = group.addItem(byteItemString); - ItemState itemState = null; - JIVariant value = null; - System.out.println(byteItem.getId()); - itemState = byteItem.read(true); - System.out.println(itemState.getQuality()); - System.out.println(getValue(byteItem, itemState)); + public static JIVariant getIntegerVariant(Integer integer) { + return new JIVariant(integer); } + + public static JIVariant getStringVariant(String string) { + return new JIVariant(string); + } + + public static JIVariant getByteArrayVariant(byte[] bytes) { + Byte[] byte_Data = new Byte[bytes.length]; + + for(int i = 0; i < bytes.length; ++i) { + byte_Data[i] = bytes[i]; + } + + JIArray array = new JIArray(byte_Data, false); + JIVariant value = new JIVariant(array); + return value; + } + + public static JIVariant getByteArrayVariant(Byte[] bytes) { + JIArray array = new JIArray(bytes, false); + JIVariant value = new JIVariant(array); + return value; + } + + } diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/ThreadUtl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/ThreadUtl.java new file mode 100644 index 0000000..c2e51c0 --- /dev/null +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/ThreadUtl.java @@ -0,0 +1,21 @@ +package org.nl.acs.opc; + +/** + * @author ldjun + * @version 1.0 + * @date 2023年02月01日 11:28 + * @desc desc + */ +public class ThreadUtl { + private ThreadUtl() { + } + + public static void sleep(long times) throws RuntimeException { + try { + Thread.sleep(times); + } catch (InterruptedException var3) { + throw new RuntimeException(var3); + } + } +} + diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/opcServerManageServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/opcServerManageServiceImpl.java index 6468fe5..c00fb8e 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/opcServerManageServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/opcServerManageServiceImpl.java @@ -29,7 +29,7 @@ public class opcServerManageServiceImpl implements OpcServerManageService { public List queryAll() { //return this.opcServerRepository.queryAll(OpcServerManageDto.class); //OPC表【acs_opc】 - JSONArray arr = WQLObject.getWQLObject("acs_opc").query().getResultJSONArray(0); + JSONArray arr = WQLObject.getWQLObject("acs_opc").query("is_active='1' and is_delete='0'").getResultJSONArray(0); return arr.toJavaList(OpcServerManageDto.class); } diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/modules/udw/UnifiedDataAccessorFactory.java b/acs/hd/nladmin-system/src/main/java/org/nl/modules/udw/UnifiedDataAccessorFactory.java index 51c5ed8..ad00d40 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/modules/udw/UnifiedDataAccessorFactory.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/modules/udw/UnifiedDataAccessorFactory.java @@ -1,5 +1,6 @@ package org.nl.modules.udw; +import org.nl.modules.udw.UnifiedDataAppService; import org.nl.modules.udw.service.impl.UnifiedDataAccessorImpl; import org.nl.modules.udw.service.impl.UnifiedDataAppServiceImpl; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/modules/udw/rest/UdwManagerController.java b/acs/hd/nladmin-system/src/main/java/org/nl/modules/udw/rest/UdwManagerController.java new file mode 100644 index 0000000..d624536 --- /dev/null +++ b/acs/hd/nladmin-system/src/main/java/org/nl/modules/udw/rest/UdwManagerController.java @@ -0,0 +1,43 @@ + +package org.nl.modules.udw.rest; + + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.modules.udw.service.UdwManageService; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +@RestController +@RequiredArgsConstructor +@Api(tags = "内存点位管理") +@RequestMapping("/api/udw") +@Slf4j +public class UdwManagerController { + + private final UdwManageService udwManageService; + +// @GetMapping +// @Log("查询内存点位") +// @ApiOperation("查询内存点位") +// @SaIgnore +// public ResponseEntity query(@RequestParam JSONObject whereJson) { +// return new ResponseEntity<>(udwManageService.queryByConditions(whereJson), HttpStatus.OK); +// } + + @GetMapping + @ApiOperation("查询内存点位") + //@PreAuthorize("@el.check('device:list')") + public ResponseEntity query(@RequestParam Map whereJson, Pageable page) { + return new ResponseEntity<>(udwManageService.queryAll(whereJson, page), HttpStatus.OK); + } +} diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/modules/udw/service/UdwManageService.java b/acs/hd/nladmin-system/src/main/java/org/nl/modules/udw/service/UdwManageService.java index b42195e..a830cb6 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/modules/udw/service/UdwManageService.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/modules/udw/service/UdwManageService.java @@ -2,8 +2,10 @@ package org.nl.modules.udw.service; import com.alibaba.fastjson.JSONObject; import org.nl.modules.udw.dto.UdwDto; +import org.springframework.data.domain.Pageable; import java.util.List; +import java.util.Map; public interface UdwManageService { /** @@ -13,4 +15,13 @@ public interface UdwManageService { * @return */ List queryByConditions(JSONObject where); + + /** + * 查询数据分页 + * + * @param whereJson 条件 + * @param page 分页参数 + * @return Map + */ + Map queryAll(Map whereJson, Pageable page); } diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/modules/udw/service/impl/UdwManagerServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/modules/udw/service/impl/UdwManagerServiceImpl.java index 64e0768..396a2c9 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/modules/udw/service/impl/UdwManagerServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/modules/udw/service/impl/UdwManagerServiceImpl.java @@ -1,11 +1,19 @@ package org.nl.modules.udw.service.impl; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; +import org.nl.modules.udw.UnifiedData; +import org.nl.modules.udw.UnifiedDataAccessorFactory; import org.nl.modules.udw.dto.UdwDto; import org.nl.modules.udw.service.UdwManageService; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; @Service public class UdwManagerServiceImpl implements UdwManageService { @@ -13,4 +21,89 @@ public class UdwManagerServiceImpl implements UdwManageService { public List queryByConditions(JSONObject where) { return null; } + + + + @Override + public Map queryAll(Map whereJson, Pageable page) { + + String unified_key = (String) whereJson.get("unified_key"); + String keys = (String) whereJson.get("code"); + if(StrUtil.isEmpty(unified_key)) + { + unified_key = "opc_value"; + } +// String unified_key = (String) whereJson.get("unified_key"); +// String code = (String) whereJson.get("code"); + +// unified_key = whereJson.get("key").toString(); +// keys = whereJson.get("value").toString(); + + + //[[{"column":"unified_key","value":"cached","compareType":"equals","columnType":"object"}]] + UnifiedDataUnit unifiedDataUnit = UnifiedDataAccessorFactory.getUnifiedDataAppService().getUnifiedDataUnit(unified_key); + if (unifiedDataUnit == null) { + return null; + } else { + String key; + UdwDto udwDto; + Map storage; + ArrayList udwDtos; + Iterator var14; + if (keys != null) { + storage = unifiedDataUnit.getStorage(); + udwDtos = new ArrayList(); + var14 = storage.keySet().iterator(); + + while(var14.hasNext()) { + key = (String)var14.next(); + if (key.indexOf(keys) != -1) { + udwDto = new UdwDto(); + udwDto.setUnified_key(unified_key); + udwDto.setKey(key); + udwDto.setValue(((UnifiedData)storage.get(key)).getValue()); + udwDtos.add(udwDto); + } + } + + Integer currentPageNumber = page.getPageNumber() + 1; + Integer pageMaxSize = page.getPageSize(); + + List orderbyDtoList = (List) udwDtos.stream().skip((currentPageNumber - 1) * pageMaxSize) + .limit(pageMaxSize) + .collect(Collectors.toList()); + + JSONObject jo = new JSONObject(); + jo.put("content", orderbyDtoList); + jo.put("totalElements", udwDtos.size()); + + return jo; + } else { + storage = unifiedDataUnit.getStorage(); + udwDtos = new ArrayList(); + var14 = storage.keySet().iterator(); + + while(var14.hasNext()) { + key = (String)var14.next(); + udwDto = new UdwDto(); + udwDto.setUnified_key(unified_key); + udwDto.setKey(key); + udwDto.setValue(((UnifiedData)storage.get(key)).getValue()); + udwDtos.add(udwDto); + } + Integer currentPageNumber = page.getPageNumber() + 1; + Integer pageMaxSize = page.getPageSize(); + + List orderbyDtoList = (List) udwDtos.stream().skip((currentPageNumber - 1) * pageMaxSize) + .limit(pageMaxSize) + .collect(Collectors.toList()); + + JSONObject jo = new JSONObject(); + jo.put("content", orderbyDtoList); + jo.put("totalElements", udwDtos.size()); + + return jo; + } + } + } } diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcSynchronizeAutoRun.java b/acs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/DeviceOpcSynchronizeAutoRun.java similarity index 86% rename from acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcSynchronizeAutoRun.java rename to acs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/DeviceOpcSynchronizeAutoRun.java index c703a1c..8edf283 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcSynchronizeAutoRun.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/DeviceOpcSynchronizeAutoRun.java @@ -1,7 +1,7 @@ -package org.nl.acs.opc; +package org.nl.start.auto.run; import cn.hutool.core.util.ObjectUtil; -import org.nl.start.auto.run.AbstractAutoRunnable; +import org.nl.acs.opc.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -17,6 +17,8 @@ import java.util.concurrent.Executors; */ @Component public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable { + + public static boolean isRun = false; ExecutorService executorService = Executors.newCachedThreadPool(); @Autowired private DeviceAppService deviceAppService; @@ -36,24 +38,22 @@ public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable { @Override public void autoRun() throws Exception { { + isRun = true; Map servers = this.opcServerManageService.queryAllServerMap(); Map>> pros; - do{ - Thread.sleep(1000L); - pros = this.deviceAppService.findAllFormatProtocolFromDriver(); - }while (ObjectUtil.isEmpty(pros)); + do{ + Thread.sleep(1000L); + pros = this.deviceAppService.findAllFormatProtocolFromDriver(); + }while (ObjectUtil.isEmpty(pros)); Set keys = pros.keySet(); Iterator var4 = keys.iterator(); - System.out.println("test:" + var4.hasNext()); //代码执行一次 while (var4.hasNext()) { String key = (String) var4.next(); List> list = (List) pros.get(key); OpcServerManageDto opcServer = (OpcServerManageDto) servers.get(key); Iterator var8 = list.iterator(); - System.out.println("test2:" + var8.hasNext()); - while (var8.hasNext()) { List groupProtols = (List) var8.next(); DeviceOpcProtocolRunable runable = new DeviceOpcProtocolRunable(); @@ -75,6 +75,7 @@ public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable { @Override public void after() { + isRun = false; this.executorService.shutdownNow(); this.executorService = Executors.newCachedThreadPool(); } diff --git a/acs/hd/nladmin-system/src/main/resources/config/application-dev.yml b/acs/hd/nladmin-system/src/main/resources/config/application-dev.yml index 1ecfff8..fbad515 100644 --- a/acs/hd/nladmin-system/src/main/resources/config/application-dev.yml +++ b/acs/hd/nladmin-system/src/main/resources/config/application-dev.yml @@ -1,5 +1,10 @@ server: port: 8010 + tomcat: + accept-count: 1000 + max-connections: 10000 + max-threads: 800 + min-spare-threads: 100 #配置数据源 spring: profiles: @@ -8,12 +13,12 @@ spring: druid: db-type: com.alibaba.druid.pool.DruidDataSource driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy - url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:rljn_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true + url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:jn_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true # url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:rljn_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true username: ${DB_USER:root} # password: ${DB_PWD:P@ssw0rd} - password: ${DB_PWD:Root.123456} -# password: ${DB_PWD:123456} +# password: ${DB_PWD:Root.123456} + password: ${DB_PWD:123456} # 初始连接数 initial-size: 5 # 最小连接数 diff --git a/acs/hd/nladmin-system/src/main/resources/config/application-prod.yml b/acs/hd/nladmin-system/src/main/resources/config/application-prod.yml index a156671..3c45978 100644 --- a/acs/hd/nladmin-system/src/main/resources/config/application-prod.yml +++ b/acs/hd/nladmin-system/src/main/resources/config/application-prod.yml @@ -1,5 +1,10 @@ server: port: 8010 + tomcat: + accept-count: 1000 + max-connections: 10000 + max-threads: 800 + min-spare-threads: 100 #配置数据源 spring: profiles: diff --git a/acs/hd/nladmin-system/src/main/resources/config/application.yml b/acs/hd/nladmin-system/src/main/resources/config/application.yml index 07d277e..8e1be36 100644 --- a/acs/hd/nladmin-system/src/main/resources/config/application.yml +++ b/acs/hd/nladmin-system/src/main/resources/config/application.yml @@ -2,7 +2,7 @@ spring: freemarker: check-template-location: false profiles: - active: dev + active: prod jackson: time-zone: GMT+8 data: diff --git a/acs/hd/nladmin-system/src/main/resources/log/WmsToAcs.xml b/acs/hd/nladmin-system/src/main/resources/log/WmsToAcs.xml index 85f952c..1af106d 100644 --- a/acs/hd/nladmin-system/src/main/resources/log/WmsToAcs.xml +++ b/acs/hd/nladmin-system/src/main/resources/log/WmsToAcs.xml @@ -1,30 +1,30 @@ - - - - - - - + + + + + + - - - - - - - - - - - - - - - - + + + 1000 + + ${LOKI_URL} + + + + + ${log.pattern} + + true + + - - - - - + + + + + diff --git a/acs/hd/nladmin-system/src/main/resources/logback-spring.xml b/acs/hd/nladmin-system/src/main/resources/logback-spring.xml index 3655081..6f59a42 100644 --- a/acs/hd/nladmin-system/src/main/resources/logback-spring.xml +++ b/acs/hd/nladmin-system/src/main/resources/logback-spring.xml @@ -21,7 +21,7 @@ https://juejin.cn/post/6844903775631572999 - + @@ -85,8 +85,9 @@ https://juejin.cn/post/6844903775631572999 - + +