diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/HongXiangConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/HongXiangConveyorDeviceDriver.java index 39f29a9e8..279774b80 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/HongXiangConveyorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/HongXiangConveyorDeviceDriver.java @@ -74,6 +74,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple 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; @@ -120,6 +121,9 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple String device_code; + String message = null; + + @Override public Device getDevice() { return this.device; @@ -130,7 +134,6 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple @Override public void execute() { - String message = null; device_code = this.getDeviceCode(); heartbeat = this.itemProtocol.getItem_heartbeat(); @@ -154,7 +157,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple currentA = this.itemProtocol.getItem_currentA(); currentB = this.itemProtocol.getItem_currentB(); currentC = this.itemProtocol.getItem_currentC(); - + to_temperature = this.itemProtocol.getItem_to_temperature(); if (mode != last_mode) { //this.setRequireSucess(false); } @@ -187,6 +190,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple } if (finish == 1 && !requireSucess) { + message = "烘箱完成反馈LMS..."; logServer.deviceExecuteLog(this.getDevice_code(), "", "", "开始烘箱完成反馈lms~"); //烘箱完成反馈LMS apply_finish(); @@ -358,8 +362,10 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest); if (applyLabelingAndBindingResponse.getstatus() == 200) { requireSucess = true; + message = "烘箱完成反馈LMS成功..."; logServer.deviceExecuteLog(this.getDevice_code(), "", "", "烘箱完成反馈lms响应消息:" + String.valueOf(applyLabelingAndBindingResponse)); } else { + message = "烘箱完成反馈LMS失败,"+String.valueOf(applyLabelingAndBindingResponse); logServer.deviceExecuteLog(this.getDevice_code(), "", "", "烘箱完成反馈lms响应消息:" + String.valueOf(applyLabelingAndBindingResponse)); } return true; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/ItemProtocol.java index 03e42ab96..95e821503 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/ItemProtocol.java @@ -118,6 +118,10 @@ public class ItemProtocol { return this.getOpcFloatValue(item_currentC); } ; + public int getItem_to_temperature(){ + return this.getOpcIntegerValue(item_to_temperature); + } ; + Boolean isonline; public int getOpcIntegerValue(String protocol) { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index 15564de89..4f99defa4 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -232,7 +232,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { jo.put("countdown_min", hongXiangConveyorDeviceDriver.getCountdown_min()); jo.put("countdown_sec", hongXiangConveyorDeviceDriver.getCountdown_sec()); //温度需要除以10 - jo.put("temperature", hongXiangConveyorDeviceDriver.getTemperature()/10); + jo.put("temperature", hongXiangConveyorDeviceDriver.getTo_temperature()/10); + jo.put("now_temperature", hongXiangConveyorDeviceDriver.getTemperature()/10); + jo.put("door", hongXiangConveyorDeviceDriver.getDoor()); jo.put("finish", hongXiangConveyorDeviceDriver.getFinish()); jo.put("task", hongXiangConveyorDeviceDriver.getTask()); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java index 7b775bec7..9aaf6e918 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceExecuteAutoRun.java @@ -83,7 +83,7 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable { } } - Thread.sleep(10000L); +// Thread.sleep(10000L); log.info("设备执行线程开始..."); while (true) { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageServiceImpl.java index 3c673e1f7..c0f64d9f0 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import org.nl.modules.wql.core.bean.ResultBean; import org.nl.modules.wql.core.bean.WQLObject; import org.springframework.stereotype.Service; @@ -34,7 +35,12 @@ public class DeviceManageServiceImpl implements DeviceManageService { String opc_plc_id = json.getString("opc_plc_id"); if (StrUtil.isNotEmpty(opc_plc_id) && StrUtil.isNotEmpty(opc_server_id)) { //OPC表【acs_opc】 - String opc_code = opcTab.query("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").uniqueResult(0).getString("opc_code"); + JSONObject rb = opcTab.query("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").uniqueResult(0); + if(ObjectUtil.isEmpty(rb)){ + System.out.println(device.getDevice_code()); + continue; + } + String opc_code= rb.getString("opc_code"); device.setOpc_server_code(opc_code); if(ObjectUtil.isEmpty(plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0))) { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java index 174e204b1..2b62bd20c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java @@ -61,7 +61,11 @@ public class DeviceOpcProtocolRunable implements Runnable { 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(); +// 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(); @@ -110,11 +114,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("数据同步异常:"+itemsMap); + 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); @@ -125,6 +136,8 @@ public class DeviceOpcProtocolRunable implements Runnable { time_out = false; } + if(ObjectUtil.isEmpty(itemStatus)) continue label97; + Set items = itemStatus.keySet(); Iterator var18 = items.iterator(); @@ -151,7 +164,7 @@ public class DeviceOpcProtocolRunable implements Runnable { ItemState itemState = (ItemState) itemStatus.get(item); value = OpcUtl.getValue(item, itemState); his = accessor_value.getValue(item.getId()); - if (!ObjectUtil.equal(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) { + if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) { log.warn("opc 值不健康 item: {}, 状态: {}", item.getId(), itemState.getQuality()); } } while (ObjectUtil.equal(value, his));//如果两次的值相等,不走下面的代码 @@ -178,7 +191,7 @@ public class DeviceOpcProtocolRunable implements Runnable { } } } catch (Exception var30) { - String error_message = "设备信息同步异常"; + String error_message = "设备信息同步异常,"+var30; if (!StrUtil.equals(this.message, error_message)) { log.warn("", var30); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/ObjectUtl.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/ObjectUtl.java new file mode 100644 index 000000000..ce5a34127 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/ObjectUtl.java @@ -0,0 +1,78 @@ +package org.nl.acs.opc; + + +import org.nl.modules.wql.exception.WDKException; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +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/nladmin-system/src/main/java/org/nl/acs/opc/opcServerManageServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/opcServerManageServiceImpl.java index 6222371a7..05d4d38c5 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/opcServerManageServiceImpl.java +++ b/acs/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/nladmin-ui/src/views/acs/history/udwData/index.vue b/acs/nladmin-ui/src/views/acs/history/udwData/index.vue index 5be540e3d..17f53a1fd 100644 --- a/acs/nladmin-ui/src/views/acs/history/udwData/index.vue +++ b/acs/nladmin-ui/src/views/acs/history/udwData/index.vue @@ -45,9 +45,6 @@ - - - @@ -102,7 +104,7 @@ import crudOperation from '@crud/CRUD.operation' import { getDicts } from '@/api/system/dict' const defaultForm = { - unified_key: 'opc_value', + unified_key: '', key: null, value: null, last_modify_date: null @@ -142,7 +144,14 @@ export default { ], permission: { }, + dialogFormVisible: false, rules: { + }, + form: { + unified_key: 'opc_value', + key: null, + value: null, + last_modify_date: null } } }, @@ -155,26 +164,7 @@ export default { // 钩子:在获取表格数据之前执行,false 则代表不获取数据 [CRUD.HOOK.beforeRefresh]() { return true - }, - // https://www.cnblogs.com/jdWu-d/p/11898666.html - beforeHandleCommand(index, row, command) { - return { - 'index': index, - 'row': row, - 'command': command - } - }, - handleCommand(command) { - switch (command.command) { - case 'a':// 完成 - this.finish(command.index, command.row) - break - case 'b':// 取消 - this.cancel(command.index, command.row) - break - } } - } }