diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java index 1f9fbb1..110f76e 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java @@ -1,6 +1,7 @@ package org.nl.acs.device_driver.driver; import lombok.extern.slf4j.Slf4j; +import org.jinterop.dcom.common.JIException; import org.nl.acs.ext.wms.data.JsonUtl; import org.nl.acs.opc.*; import org.nl.acs.udw.UnifiedDataAccessor; @@ -64,79 +65,61 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc } } - public void checkControl(Map itemValues) { + public void checkControl(Map itemValues) { Group group = opcServerService.getServer(this.getOpcServer()); - Map readItems = new LinkedHashMap<>(); - List itemsString; - itemsString = new ArrayList<>(itemValues.keySet()); + Map write = new HashMap(); + Map readitems = new LinkedHashMap(); + List itemsString = new ArrayList(); + itemsString = new ArrayList<> (itemValues.keySet()); + Iterator is = itemsString.iterator(); - for (String string : itemsString) { + while (is.hasNext()) { + String string = (String) is.next(); try { - readItems.put(string, group.addItem(string)); + readitems.put(string, group.addItem(string)); } catch (Exception e) { - log.error("group add item error!", e); + e.printStackTrace(); } } int i = 0; while (true) { //下发信号 - try{ - if(i == 0){ - control( itemValues); - } else { - controlByNewConn( itemValues); - } - } catch (Exception e){ - log.error("check control error!", e); - } - - Map read = new HashMap<>(); - Map itemStatus; - boolean check = true; + control( itemValues); + Map read = new HashMap(); + Map itemStatus = null; try { - if (i > 0) { - group = opcServerService.getServer(this.getOpcServer()); - itemsString = new ArrayList<>(itemValues.keySet()); + itemStatus = group.read(true, (Item[])readitems.values().toArray(new Item[0])); + } catch (JIException e) { + throw new RuntimeException(e); + } + Set items = itemStatus.keySet(); + Iterator var15 = items.iterator(); - for (String string : itemsString) { - try { - readItems.put(string, group.addItem(string)); - } catch (Exception e) { - log.error("group add item error!", e); - } - } - itemStatus = group.read(true, readItems.values().toArray(new Item[0])); - - } else { - itemStatus = group.read(true, readItems.values().toArray(new Item[0])); - } - Set items = itemStatus.keySet(); - for (Item item : items) { - ItemState itemState = itemStatus.get(item); - Object value = OpcUtl.getValue(item, itemState); - read.put(item.getId(), value); - } - - for (String itemString : itemsString) { - if (!ObjectUtl.isEquals(itemValues.get(itemString), JsonUtl.parse(read.get(itemString)))) { - check = false; - } - } - } catch (Exception e) { - log.error("check control error!", e); - check = false; + while(var15.hasNext()) { + Item item = (Item)var15.next(); + ItemState itemState = (ItemState)itemStatus.get(item); + Object value = OpcUtl.getValue(item, itemState); + read.put(item.getId(), value); } + boolean check = true; + Iterator var24 = itemsString.iterator(); + + while(var24.hasNext()) { + String itemString = (String)var24.next(); + if (!ObjectUtl.isEquals(itemValues.get(itemString), JsonUtl.parse(read.get(itemString)))) { + check = false; + } + } if (check) { return; } if (i > 0) { - ThreadUtl.sleep(300L); + ThreadUtl.sleep(1000L); } if (i > 3) { - log.info("写入次数超过3次而失败"); throw new WDKException("写入次数超过3次而失败"); } ++i; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_manipulator/HfKilnManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_manipulator/HfKilnManipulatorDeviceDriver.java index 673d938..304fab7 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_manipulator/HfKilnManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_manipulator/HfKilnManipulatorDeviceDriver.java @@ -340,7 +340,7 @@ public class HfKilnManipulatorDeviceDriver extends AbstractOpcDeviceDriver imple Map itemMap = new HashMap<>(); itemMap.put(to_param, value); - this.checkControl(itemMap); + this.control(itemMap); logServer.writeLog("下发电气信号", this.getDevice_code(), "下发信号:" + to_param + "信号值:" + value); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_truss/HfKilnTrussDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_truss/HfKilnTrussDeviceDriver.java index 22caecb..9fe1cde 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_truss/HfKilnTrussDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_truss/HfKilnTrussDeviceDriver.java @@ -293,7 +293,7 @@ public class HfKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implements Map itemMap = new HashMap<>(); itemMap.put(to_command, command); - this.checkControl(itemMap); + this.control(itemMap); logServer.writeLog("下发电气信号", this.getDevice_code(), "下发信号:" + to_command + "信号值:" + command); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_manipulator/HfGantryManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_manipulator/HfGantryManipulatorDeviceDriver.java index 82dd777..a7ab14d 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_manipulator/HfGantryManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_manipulator/HfGantryManipulatorDeviceDriver.java @@ -405,7 +405,7 @@ public class HfGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp Map itemMap = new HashMap<>(); itemMap.put(to_param, value); - this.checkControl(itemMap); + this.control(itemMap); logServer.writeLog("下发电气信号", this.getDevice_code(), "下发信号:" + to_param + "信号值:" + value); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/HfRGVTwoDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/HfRGVTwoDeviceDriver.java index 8911b01..07e3da7 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/HfRGVTwoDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/HfRGVTwoDeviceDriver.java @@ -580,7 +580,7 @@ public class HfRGVTwoDeviceDriver extends AbstractOpcDeviceDriver implements Dev Map itemMap = new HashMap<>(); itemMap.put(to_param, value); - this.checkControl(itemMap); + this.control(itemMap); logServer.writeLog("下发电气信号", this.getDevice_code(), "下发信号:" + to_param + "信号值:" + value); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station/HfStationDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station/HfStationDeviceDriver.java index 30a7f16..c9ccc74 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station/HfStationDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station/HfStationDeviceDriver.java @@ -667,7 +667,7 @@ public class HfStationDeviceDriver extends AbstractOpcDeviceDriver implements De Map itemMap = new HashMap<>(); itemMap.put(to_command, command); - this.checkControl(itemMap); + this.control(itemMap); logServer.writeLog("下发电气信号", this.getDevice_code(), "下发信号:" + to_command + "信号值:" + command); } @@ -677,7 +677,7 @@ public class HfStationDeviceDriver extends AbstractOpcDeviceDriver implements De Map itemMap = new HashMap<>(); itemMap.put(to_param, value); - this.checkControl(itemMap); + this.control(itemMap); logServer.writeLog("下发电气信号", this.getDevice_code(), "下发信号:" + to_param + "信号值:" + value); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station_two/HfStationTwoDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station_two/HfStationTwoDeviceDriver.java index bf9144f..c4ea451 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station_two/HfStationTwoDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station_two/HfStationTwoDeviceDriver.java @@ -519,7 +519,7 @@ public class HfStationTwoDeviceDriver extends AbstractOpcDeviceDriver implements Map itemMap = new HashMap<>(); itemMap.put(to_command, command); - this.checkControl(itemMap); + this.control(itemMap); logServer.writeLog("下发电气信号", this.getDevice_code(), "下发信号:" + to_command + "信号值:" + command); } @@ -529,7 +529,7 @@ public class HfStationTwoDeviceDriver extends AbstractOpcDeviceDriver implements Map itemMap = new HashMap<>(); itemMap.put(to_param, value); - this.checkControl(itemMap); + this.control(itemMap); logServer.writeLog("下发电气信号", this.getDevice_code(), "下发信号:" + to_param + "信号值:" + value); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java index bcf757c..70bcc2b 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java @@ -139,9 +139,9 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A if (device.getDeviceDriver() instanceof HfStationDeviceDriver) { hfStationDeviceDriver = (HfStationDeviceDriver) device.getDeviceDriver(); - if (StrUtil.isNotBlank(hfStationDeviceDriver.getOrder())) { - throw new BadRequestException("设备正在生产"); - } +// if (StrUtil.isNotBlank(hfStationDeviceDriver.getOrder())) { +// throw new BadRequestException("设备正在生产"); +// } // if (hfStationDeviceDriver.getStatus() != 2) { // throw new BadRequestException("设备状态不为自动"); // } @@ -167,7 +167,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A hfStationTwoDeviceDriver.writing("to_b", dto.getB()); hfStationTwoDeviceDriver.writing("to_h", dto.getH()); hfStationTwoDeviceDriver.writing("to_w", dto.getW()); - hfStationTwoDeviceDriver.writing("to_number", dto.getNumber()); + hfStationTwoDeviceDriver.writing("to_number", ObjectUtil.isNotEmpty(dto.getNumber())?dto.getNumber():"0"); hfStationTwoDeviceDriver.writing("to_product_code", dto.getProduct_code()); hfStationTwoDeviceDriver.writing("to_order", dto.getOrder_code()); hfStationTwoDeviceDriver.writing("to_order_num", String.valueOf(dto.getQty())); @@ -176,7 +176,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A hfStationTwoDeviceDriver.writing("to_b", dto.getB()); hfStationTwoDeviceDriver.writing("to_h", dto.getH()); hfStationTwoDeviceDriver.writing("to_w", dto.getW()); - hfStationTwoDeviceDriver.writing("to_number", dto.getNumber()); + hfStationTwoDeviceDriver.writing("to_number", ObjectUtil.isNotEmpty(dto.getNumber())?dto.getNumber():"0"); hfStationTwoDeviceDriver.writing("to_product_code", dto.getProduct_code()); hfStationTwoDeviceDriver.writing("to_material_code", dto.getMaterial_code()); hfStationTwoDeviceDriver.writing("to_command", "1"); @@ -194,7 +194,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A hfStationTwoDeviceDriver.writing("to_b", dto.getB()); hfStationTwoDeviceDriver.writing("to_h", dto.getH()); hfStationTwoDeviceDriver.writing("to_w", dto.getW()); - hfStationTwoDeviceDriver.writing("to_number", dto.getNumber()); + hfStationTwoDeviceDriver.writing("to_number", ObjectUtil.isNotEmpty(dto.getNumber())?dto.getNumber():"0"); hfStationTwoDeviceDriver.writing("to_product_code", dto.getProduct_code()); hfStationTwoDeviceDriver.writing("to_order", dto.getOrder_code()); hfStationTwoDeviceDriver.writing("to_order_num", String.valueOf(dto.getQty())); @@ -203,7 +203,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A hfStationTwoDeviceDriver.writing("to_b", dto.getB()); hfStationTwoDeviceDriver.writing("to_h", dto.getH()); hfStationTwoDeviceDriver.writing("to_w", dto.getW()); - hfStationTwoDeviceDriver.writing("to_number", dto.getNumber()); + hfStationTwoDeviceDriver.writing("to_number", ObjectUtil.isNotEmpty(dto.getNumber())?dto.getNumber():"0"); hfStationTwoDeviceDriver.writing("to_product_code", dto.getProduct_code()); hfStationTwoDeviceDriver.writing("to_command", "1"); hfStationTwoDeviceDriver.writing("to_command", "1"); @@ -353,13 +353,13 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A if (device.getDeviceDriver() instanceof HfStationDeviceDriver) { hfStationDeviceDriver = (HfStationDeviceDriver) device.getDeviceDriver(); String order = hfStationDeviceDriver.getOrder(); - if (StrUtil.isNotBlank(order)){ - throw new BadRequestException("设备正在生产"); - } - hfStationDeviceDriver = (HfStationDeviceDriver) device.getDeviceDriver(); - if (hfStationDeviceDriver.getStatus() != 2) { - throw new BadRequestException("设备状态不为自动"); - } +// if (StrUtil.isNotBlank(order)){ +// throw new BadRequestException("设备正在生产"); +// } +// hfStationDeviceDriver = (HfStationDeviceDriver) device.getDeviceDriver(); +// if (hfStationDeviceDriver.getStatus() != 2) { +// throw new BadRequestException("设备状态不为自动"); +// } hfStationDeviceDriver.writing("to_order", produceshiftorderDto.getOrder_code()); hfStationDeviceDriver.writing("to_order_num", String.valueOf(produceshiftorderDto.getQty())); hfStationDeviceDriver.writing("to_product_number", produceshiftorderDto.getMaterial_code()); @@ -373,9 +373,9 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A Device linkDevice = deviceAppService.findDeviceByCode(link_device_code); if (linkDevice.getDeviceDriver() instanceof HfStationTwoDeviceDriver) { HfStationTwoDeviceDriver hfStationTwoDeviceDriver = (HfStationTwoDeviceDriver) linkDevice.getDeviceDriver(); - if (StrUtil.isNotBlank(hfStationTwoDeviceDriver.getOrder())) { - throw new BadRequestException("设备正在生产"); - } +// if (StrUtil.isNotBlank(hfStationTwoDeviceDriver.getOrder())) { +// throw new BadRequestException("设备正在生产"); +// } hfStationTwoDeviceDriver.writing("to_order", produceshiftorderDto.getOrder_code()); hfStationTwoDeviceDriver.writing("to_order_num", String.valueOf(produceshiftorderDto.getQty())); hfStationTwoDeviceDriver.writing("to_material_code", produceshiftorderDto.getMaterial_code()); @@ -398,9 +398,9 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A hfStationTwoDeviceDriver.writing("to_command", "3"); }else if (linkDevice.getDeviceDriver() instanceof HfStationTwoDeviceDriver) { HfStationTwoDeviceDriver hfStationTwoDeviceDriver = (HfStationTwoDeviceDriver) linkDevice.getDeviceDriver(); - if (StrUtil.isNotBlank(hfStationTwoDeviceDriver.getOrder())) { - throw new BadRequestException("设备正在生产"); - } +// if (StrUtil.isNotBlank(hfStationTwoDeviceDriver.getOrder())) { +// throw new BadRequestException("设备正在生产"); +// } hfStationTwoDeviceDriver.writing("to_order", produceshiftorderDto.getOrder_code()); hfStationTwoDeviceDriver.writing("to_order_num", String.valueOf(produceshiftorderDto.getQty())); hfStationTwoDeviceDriver.writing("to_material_code", produceshiftorderDto.getMaterial_code()); @@ -424,9 +424,9 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A } } if (device.getDeviceDriver() instanceof HfStationTwoDeviceDriver) { HfStationTwoDeviceDriver hfStationTwoDeviceDriver = (HfStationTwoDeviceDriver) device.getDeviceDriver(); - if (StrUtil.isNotBlank(hfStationTwoDeviceDriver.getOrder())) { - throw new BadRequestException("设备正在生产"); - } +// if (StrUtil.isNotBlank(hfStationTwoDeviceDriver.getOrder())) { +// throw new BadRequestException("设备正在生产"); +// } hfStationTwoDeviceDriver.writing("to_order", produceshiftorderDto.getOrder_code()); hfStationTwoDeviceDriver.writing("to_order_num", String.valueOf(produceshiftorderDto.getQty())); hfStationTwoDeviceDriver.writing("to_material_code", produceshiftorderDto.getMaterial_code());