فهرست منبع

完成opc事件驱动报表的机制

zhoupeng 2 سال پیش
والد
کامیت
5737f2410e

+ 2 - 1
chaunyi_opc/opc_common/src/main/java/com/example/opc_common/enums/OpcDaDriverEnum.java

@@ -4,7 +4,8 @@ public enum OpcDaDriverEnum {
     KEPSERVER("7BC0CC8E-482C-47CA-ABDC-0FE7F9C6E729"),
     OPCIFIX("3C5702A2-EB8E-11D4-83A4-00105A984CBD"),
     WINCC("75D00BBB-DDA5-11D1-B944-9E614D000000"),
-    SCADA("04524449-C6B2-4D62-8471-C64FA1DDF64F");
+    SCADA("04524449-C6B2-4D62-8471-C64FA1DDF64F"),
+    YOKOGAWA("E6C32641-F1CF-11D0-B0E4-080009CCD384");
 
     private String value;
 

+ 3 - 0
chaunyi_opc/opc_common/src/main/java/com/example/opc_common/util/ConstantStr.java

@@ -68,6 +68,9 @@ public class ConstantStr {
     public static final String DATA_VALUE = "dataValue";
     public static final String DATA_VALUE_TIME = "dataValueTime";
     public static final String VALUE_BELONG_TIME = "valueBelongTime";
+
+    public static final String EVENT_DATA_VALUE = "eventDataValue";
+    public static final String EVENT_DATA_VALUE_TIME = "eventDataValueTime";
     public static final String DATA_SOURCE_TREE = "dataSourceTree";
 
     //t_raw_data水平分表的个数

+ 1 - 0
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/ItemGroupServiceImpl.java

@@ -161,6 +161,7 @@ public class ItemGroupServiceImpl implements ItemGroupService {
                 if (Blank.isEmpty(dataSource.getIpAddress(), dataSource.getIpUserName(), dataSource.getIpPassword())) {
                     throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "ip地址,帐户,密码都不能为空");
                 }
+                redisUtil.set(ConstantStr.ITEM_GROUP + id, true);
                 Boolean flage = false;
                 //获取组中所有标签的数据模型,并转换为map<itemName,DataModel>
                 List<Item> allItemList = itemGroupDao.getItemListByGroupId(id);

+ 5 - 0
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/task/OpcAsyncTask.java

@@ -173,4 +173,9 @@ public class OpcAsyncTask {
             reportTableDao.updateReportTable(reportTable);
         }
     }
+
+    public void addEventTable(Integer tableReportId,List<BigDecimal> eventDataValueList, List<String> eventDataValueTimeList){
+
+    }
+
 }

+ 545 - 39
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/task/OpcDaTask.java

@@ -182,11 +182,23 @@ public class OpcDaTask extends TimerTask {
                                                 BigDecimal bigEventValue = new BigDecimal(eventValue);
                                                 if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
                                                     if (dmData.compareTo(bigEventValue) == 1) {
-                                                        opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        eventDataValueList.add(dmData);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                        eventDataValueTimeList.add(currentYmdhmss);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                                     }
                                                 } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
                                                     if (dmData.compareTo(bigEventValue) == -1) {
-                                                        opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        eventDataValueList.add(dmData);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                        eventDataValueTimeList.add(currentYmdhmss);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                                     }
                                                 }
                                             }
@@ -219,11 +231,39 @@ public class OpcDaTask extends TimerTask {
                                                     BigDecimal bigEventValue = new BigDecimal(eventValue);
                                                     if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
                                                         if (dmData.compareTo(bigEventValue) == 1) {
-                                                            opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                            }
+                                                            eventDataValueList.add(dmData);
+                                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                            }
+                                                            eventDataValueTimeList.add(currentYmdhmss);
+                                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                                         }
                                                     } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
                                                         if (dmData.compareTo(bigEventValue) == -1) {
-                                                            opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                            }
+                                                            eventDataValueList.add(dmData);
+                                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                            }
+                                                            eventDataValueTimeList.add(currentYmdhmss);
+                                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                                         }
                                                     }
                                                 }
@@ -279,13 +319,47 @@ public class OpcDaTask extends TimerTask {
                                                 if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
                                                     BigDecimal bigEventValue = new BigDecimal(eventValue);
                                                     if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                        }
+
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                        }
+                                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                                        eventDataValueList = new ArrayList<>();
+                                                        eventDataValueTimeList = new ArrayList<>();
                                                         if (dmData.compareTo(bigEventValue) == 1) {
-                                                            opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                                            eventDataValueList.add(dmData);
+                                                            eventDataValueTimeList.add(currentYmdhmss);
                                                         }
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                                     } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
-                                                        if (dmData.compareTo(bigEventValue) == -1) {
-                                                            opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
                                                         }
+
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                        }
+                                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                                        eventDataValueList = new ArrayList<>();
+                                                        eventDataValueTimeList = new ArrayList<>();
+                                                        if (dmData.compareTo(bigEventValue) == 1) {
+                                                            eventDataValueList.add(dmData);
+                                                            eventDataValueTimeList.add(currentYmdhmss);
+                                                        }
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                                     }
                                                 }
                                                 redisUtil.set(ConstantStr.DATA_VALUE + id + itemId, dataValueList, ConstantStr.TWO_HOUR);
@@ -359,6 +433,24 @@ public class OpcDaTask extends TimerTask {
                                                 String.valueOf(valueBelongTime),
                                                 new Date());
                                         opcAsyncTask.addRawData(id, rawData);
+
+                                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED) ||
+                                                    eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                }
+
+                                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                }
+                                                opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                            }
+                                        }
                                     } catch (Exception e1) {
                                         List<String> dataValueList = new ArrayList<>();
                                         Object dataValueObject = redisUtil.get(ConstantStr.DATA_VALUE + id + itemId);
@@ -403,6 +495,9 @@ public class OpcDaTask extends TimerTask {
                         //存已经存入redis中的数据
                         for (com.example.opc_common.entity.Item item : itemList) {
                             String itemId = item.getItemReadName();
+                            Integer eventMode = item.getEventMode();
+                            Integer eventValue = item.getEventValue();
+                            Integer tableReportId = item.getTableReportId();
                             String valueBelongTime = String.valueOf(redisUtil.get(ConstantStr.VALUE_BELONG_TIME + id + itemId));
 
                             List<String> dataValueTimeList = new ArrayList<>();
@@ -443,6 +538,24 @@ public class OpcDaTask extends TimerTask {
                                             String.valueOf(valueBelongTime),
                                             new Date());
                                     opcAsyncTask.addRawData(id, rawData);
+
+                                    if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                        if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED) ||
+                                                eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                            }
+
+                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                            }
+                                            opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                        }
+                                    }
                                 } catch (Exception e1) {
                                     List<String> dataValueList = new ArrayList<>();
                                     Object dataValueObject = redisUtil.get(ConstantStr.DATA_VALUE + id + itemId);
@@ -532,11 +645,23 @@ public class OpcDaTask extends TimerTask {
                                                 BigDecimal bigEventValue = new BigDecimal(eventValue);
                                                 if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
                                                     if (dmData.compareTo(bigEventValue) == 1) {
-                                                        opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        eventDataValueList.add(dmData);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                        eventDataValueTimeList.add(currentYmdhmss);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                                     }
                                                 } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
                                                     if (dmData.compareTo(bigEventValue) == -1) {
-                                                        opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        eventDataValueList.add(dmData);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                        eventDataValueTimeList.add(currentYmdhmss);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                                     }
                                                 }
                                             }
@@ -575,11 +700,39 @@ public class OpcDaTask extends TimerTask {
                                                         BigDecimal bigEventValue = new BigDecimal(eventValue);
                                                         if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
                                                             if (dmData.compareTo(bigEventValue) == 1) {
-                                                                opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                                }
+                                                                eventDataValueList.add(dmData);
+                                                                redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                                }
+                                                                eventDataValueTimeList.add(currentYmdhmss);
+                                                                redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                                             }
                                                         } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
                                                             if (dmData.compareTo(bigEventValue) == -1) {
-                                                                opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                                }
+                                                                eventDataValueList.add(dmData);
+                                                                redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                                }
+                                                                eventDataValueTimeList.add(currentYmdhmss);
+                                                                redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                                             }
                                                         }
                                                     }
@@ -657,13 +810,47 @@ public class OpcDaTask extends TimerTask {
                                                 if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
                                                     BigDecimal bigEventValue = new BigDecimal(eventValue);
                                                     if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                        }
+
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                        }
+                                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                                        eventDataValueList = new ArrayList<>();
+                                                        eventDataValueTimeList = new ArrayList<>();
                                                         if (dmData.compareTo(bigEventValue) == 1) {
-                                                            opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                                            eventDataValueList.add(dmData);
+                                                            eventDataValueTimeList.add(currentYmdhmss);
                                                         }
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                                     } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
-                                                        if (dmData.compareTo(bigEventValue) == -1) {
-                                                            opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
                                                         }
+
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                        }
+                                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                                        eventDataValueList = new ArrayList<>();
+                                                        eventDataValueTimeList = new ArrayList<>();
+                                                        if (dmData.compareTo(bigEventValue) == 1) {
+                                                            eventDataValueList.add(dmData);
+                                                            eventDataValueTimeList.add(currentYmdhmss);
+                                                        }
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                                     }
                                                 }
                                                 redisUtil.set(ConstantStr.DATA_VALUE + id + itemId, dataValueList, ConstantStr.TWO_HOUR);
@@ -736,6 +923,24 @@ public class OpcDaTask extends TimerTask {
                                                 String.valueOf(valueBelongTime),
                                                 new Date());
                                         opcAsyncTask.addRawData(id, rawData);
+
+                                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED) ||
+                                                    eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                }
+
+                                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                }
+                                                opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                            }
+                                        }
                                     } catch (Exception e1) {
                                         List<String> dataValueList = new ArrayList<>();
                                         Object dataValueObject = redisUtil.get(ConstantStr.DATA_VALUE + id + itemId);
@@ -782,6 +987,9 @@ public class OpcDaTask extends TimerTask {
                         //存已经存入redis中的数据
                         for (com.example.opc_common.entity.Item item : itemList) {
                             String itemId = item.getItemReadName();
+                            Integer eventMode = item.getEventMode();
+                            Integer eventValue = item.getEventValue();
+                            Integer tableReportId = item.getTableReportId();
                             String valueBelongTime = String.valueOf(redisUtil.get(ConstantStr.VALUE_BELONG_TIME + id + itemId));
 
                             List<String> dataValueTimeList = new ArrayList<>();
@@ -822,6 +1030,24 @@ public class OpcDaTask extends TimerTask {
                                             String.valueOf(valueBelongTime),
                                             new Date());
                                     opcAsyncTask.addRawData(id, rawData);
+
+                                    if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                        if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED) ||
+                                                eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                            }
+
+                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                            }
+                                            opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                        }
+                                    }
                                 } catch (Exception e1) {
                                     List<String> dataValueList = new ArrayList<>();
                                     Object dataValueObject = redisUtil.get(ConstantStr.DATA_VALUE + id + itemId);
@@ -894,18 +1120,6 @@ public class OpcDaTask extends TimerTask {
                                     try {
                                         BigDecimal bigDecimal = JSON.parseObject(value.toString(), BigDecimal.class);
                                         BigDecimal dmData = Blank.isNotEmpty(dm) ? MathUtil.quadricOperation(dm.getMathParameter(), dm.getOperationRule(), bigDecimal) : bigDecimal;
-                                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
-                                            BigDecimal bigEventValue = new BigDecimal(eventValue);
-                                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
-                                                if (dmData.compareTo(bigEventValue) == 1) {
-                                                    opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
-                                                }
-                                            } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
-                                                if (dmData.compareTo(bigEventValue) == -1) {
-                                                    opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
-                                                }
-                                            }
-                                        }
                                         if (Blank.isEmpty(storageYmdh)) {
                                             if (dmData.compareTo(bigModeValue) == 1) {
                                                 redisUtil.set(ConstantStr.VALUE_BELONG_TIME + id + itemId, currentYmdh, ConstantStr.TWO_HOUR);
@@ -918,11 +1132,35 @@ public class OpcDaTask extends TimerTask {
                                                 dataValueTimeList.add(currentYmdhmss);
                                                 redisUtil.set(ConstantStr.DATA_VALUE_TIME + id + itemId, dataValueTimeList, ConstantStr.TWO_HOUR);
                                             }
+                                            if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                                BigDecimal bigEventValue = new BigDecimal(eventValue);
+                                                if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                                    if (dmData.compareTo(bigEventValue) == 1) {
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        eventDataValueList.add(dmData);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        eventDataValueTimeList.add(currentYmdhmss);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                                    }
+                                                } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                                    if (dmData.compareTo(bigEventValue) == -1) {
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        eventDataValueList.add(dmData);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        eventDataValueTimeList.add(currentYmdhmss);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                                    }
+                                                }
+                                            }
                                         } else {
                                             if (DateUtil.strChangeDate(storageYmdh, timeFormat).getTime() == DateUtil.strChangeDate(currentYmdh, timeFormat).getTime()) {
                                                 if (dmData.compareTo(bigModeValue) == 1) {
-                                                    Object dataValueObject = redisUtil.get(ConstantStr.DATA_VALUE + id + itemId);
                                                     List<BigDecimal> dataValueList = new ArrayList<>();
+                                                    Object dataValueObject = redisUtil.get(ConstantStr.DATA_VALUE + id + itemId);
                                                     if (Blank.isNotEmpty(dataValueObject)) {
                                                         dataValueList = JavaTypeUtil.objChangeListBig(dataValueObject);
                                                     }
@@ -937,6 +1175,47 @@ public class OpcDaTask extends TimerTask {
                                                     dataValueTimeList.add(currentYmdhmss);
                                                     redisUtil.set(ConstantStr.DATA_VALUE_TIME + id + itemId, dataValueTimeList, ConstantStr.TWO_HOUR);
                                                 }
+
+                                                if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                                    BigDecimal bigEventValue = new BigDecimal(eventValue);
+                                                    if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                                        if (dmData.compareTo(bigEventValue) == 1) {
+                                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                            }
+                                                            eventDataValueList.add(dmData);
+                                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                            }
+                                                            eventDataValueTimeList.add(currentYmdhmss);
+                                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                                        }
+                                                    } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                                        if (dmData.compareTo(bigEventValue) == -1) {
+                                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                            }
+                                                            eventDataValueList.add(dmData);
+                                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                            }
+                                                            eventDataValueTimeList.add(currentYmdhmss);
+                                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                                        }
+                                                    }
+                                                }
                                             } else {
                                                 String valueBelongTime = String.valueOf(redisUtil.get(ConstantStr.VALUE_BELONG_TIME + id + itemId));
 
@@ -961,6 +1240,53 @@ public class OpcDaTask extends TimerTask {
                                                         new Date());
                                                 opcAsyncTask.addRawData(id, rawData);
 
+                                                if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                                    BigDecimal bigEventValue = new BigDecimal(eventValue);
+                                                    if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                        }
+
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                        }
+                                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                                        eventDataValueList = new ArrayList<>();
+                                                        eventDataValueTimeList = new ArrayList<>();
+                                                        if (dmData.compareTo(bigEventValue) == 1) {
+                                                            eventDataValueList.add(dmData);
+                                                            eventDataValueTimeList.add(currentYmdhmss);
+                                                        }
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                                    } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                        }
+
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                        }
+                                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                                        eventDataValueList = new ArrayList<>();
+                                                        eventDataValueTimeList = new ArrayList<>();
+                                                        if (dmData.compareTo(bigEventValue) == -1) {
+                                                            eventDataValueList.add(dmData);
+                                                            eventDataValueTimeList.add(currentYmdhmss);
+                                                        }
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                                    }
+                                                }
+
                                                 dataValueList = new ArrayList<>();
                                                 dataValueTimeList = new ArrayList<>();
                                                 if (dmData.compareTo(bigModeValue) == 1) {
@@ -1003,6 +1329,24 @@ public class OpcDaTask extends TimerTask {
                                                 String.valueOf(valueBelongTime),
                                                 new Date());
                                         opcAsyncTask.addRawData(id, rawData);
+
+                                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED) ||
+                                                    eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                }
+
+                                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                }
+                                                opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                            }
+                                        }
                                     } catch (Exception e1) {
 
                                     }
@@ -1036,6 +1380,9 @@ public class OpcDaTask extends TimerTask {
                         //存已经存入redis中的数据
                         for (com.example.opc_common.entity.Item item : itemList) {
                             String itemId = item.getItemReadName();
+                            Integer eventMode = item.getEventMode();
+                            Integer eventValue = item.getEventValue();
+                            Integer tableReportId = item.getTableReportId();
                             String valueBelongTime = String.valueOf(redisUtil.get(ConstantStr.VALUE_BELONG_TIME + id + itemId));
 
                             List<String> dataValueTimeList = new ArrayList<>();
@@ -1061,6 +1408,24 @@ public class OpcDaTask extends TimerTask {
                                             String.valueOf(valueBelongTime),
                                             new Date());
                                     opcAsyncTask.addRawData(id, rawData);
+
+                                    if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                        if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED) ||
+                                                eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                            }
+
+                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                            }
+                                            opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                        }
+                                    }
                                 } catch (Exception e1) {
 
                                 }
@@ -1120,18 +1485,6 @@ public class OpcDaTask extends TimerTask {
                                     try {
                                         BigDecimal bigDecimal = JSON.parseObject(value.toString(), BigDecimal.class);
                                         BigDecimal dmData = Blank.isNotEmpty(dm) ? MathUtil.quadricOperation(dm.getMathParameter(), dm.getOperationRule(), bigDecimal) : bigDecimal;
-                                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
-                                            BigDecimal bigEventValue = new BigDecimal(eventValue);
-                                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
-                                                if (dmData.compareTo(bigEventValue) == 1) {
-                                                    opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
-                                                }
-                                            } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
-                                                if (dmData.compareTo(bigEventValue) == -1) {
-                                                    opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
-                                                }
-                                            }
-                                        }
                                         if (Blank.isEmpty(storageYmdh)) {
                                             if (dmData.compareTo(bigModeValue) == -1) {
                                                 redisUtil.set(ConstantStr.VALUE_BELONG_TIME + id + itemId, currentYmdh, ConstantStr.TWO_HOUR);
@@ -1144,6 +1497,30 @@ public class OpcDaTask extends TimerTask {
                                                 dataValueTimeList.add(currentYmdhmss);
                                                 redisUtil.set(ConstantStr.DATA_VALUE_TIME + id + itemId, dataValueTimeList, ConstantStr.TWO_HOUR);
                                             }
+                                            if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                                BigDecimal bigEventValue = new BigDecimal(eventValue);
+                                                if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                                    if (dmData.compareTo(bigEventValue) == 1) {
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        eventDataValueList.add(dmData);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        eventDataValueTimeList.add(currentYmdhmss);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                                    }
+                                                } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                                    if (dmData.compareTo(bigEventValue) == -1) {
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        eventDataValueList.add(dmData);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        eventDataValueTimeList.add(currentYmdhmss);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                                    }
+                                                }
+                                            }
                                         } else {
                                             if (DateUtil.strChangeDate(storageYmdh, timeFormat).getTime() == DateUtil.strChangeDate(currentYmdh, timeFormat).getTime()) {
                                                 if (dmData.compareTo(bigModeValue) == -1) {
@@ -1163,6 +1540,47 @@ public class OpcDaTask extends TimerTask {
                                                     dataValueTimeList.add(currentYmdhmss);
                                                     redisUtil.set(ConstantStr.DATA_VALUE_TIME + id + itemId, dataValueTimeList, ConstantStr.TWO_HOUR);
                                                 }
+
+                                                if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                                    BigDecimal bigEventValue = new BigDecimal(eventValue);
+                                                    if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                                        if (dmData.compareTo(bigEventValue) == 1) {
+                                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                            }
+                                                            eventDataValueList.add(dmData);
+                                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                            }
+                                                            eventDataValueTimeList.add(currentYmdhmss);
+                                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                                        }
+                                                    } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                                        if (dmData.compareTo(bigEventValue) == -1) {
+                                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                            }
+                                                            eventDataValueList.add(dmData);
+                                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                            }
+                                                            eventDataValueTimeList.add(currentYmdhmss);
+                                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                                        }
+                                                    }
+                                                }
                                             } else {
                                                 String valueBelongTime = String.valueOf(redisUtil.get(ConstantStr.VALUE_BELONG_TIME + id + itemId));
 
@@ -1187,6 +1605,53 @@ public class OpcDaTask extends TimerTask {
                                                         new Date());
                                                 opcAsyncTask.addRawData(id, rawData);
 
+                                                if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                                    BigDecimal bigEventValue = new BigDecimal(eventValue);
+                                                    if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                        }
+
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                        }
+                                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                                        eventDataValueList = new ArrayList<>();
+                                                        eventDataValueTimeList = new ArrayList<>();
+                                                        if (dmData.compareTo(bigEventValue) == 1) {
+                                                            eventDataValueList.add(dmData);
+                                                            eventDataValueTimeList.add(currentYmdhmss);
+                                                        }
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                                    } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                        }
+
+                                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                        }
+                                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                                        eventDataValueList = new ArrayList<>();
+                                                        eventDataValueTimeList = new ArrayList<>();
+                                                        if (dmData.compareTo(bigEventValue) == -1) {
+                                                            eventDataValueList.add(dmData);
+                                                            eventDataValueTimeList.add(currentYmdhmss);
+                                                        }
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                                    }
+                                                }
+
                                                 dataValueList = new ArrayList<>();
                                                 dataValueTimeList = new ArrayList<>();
                                                 if (dmData.compareTo(bigModeValue) == -1) {
@@ -1229,6 +1694,25 @@ public class OpcDaTask extends TimerTask {
                                                 String.valueOf(valueBelongTime),
                                                 new Date());
                                         opcAsyncTask.addRawData(id, rawData);
+
+                                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                            BigDecimal bigEventValue = new BigDecimal(eventValue);
+                                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)||
+                                                    eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                }
+
+                                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                }
+                                                opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                            }
+                                        }
                                     } catch (Exception e1) {
 
                                     }
@@ -1262,6 +1746,9 @@ public class OpcDaTask extends TimerTask {
                         //存已经存入redis中的数据
                         for (com.example.opc_common.entity.Item item : itemList) {
                             String itemId = item.getItemReadName();
+                            Integer eventMode = item.getEventMode();
+                            Integer eventValue = item.getEventValue();
+                            Integer tableReportId = item.getTableReportId();
                             String valueBelongTime = String.valueOf(redisUtil.get(ConstantStr.VALUE_BELONG_TIME + id + itemId));
 
                             List<String> dataValueTimeList = new ArrayList<>();
@@ -1287,6 +1774,25 @@ public class OpcDaTask extends TimerTask {
                                             String.valueOf(valueBelongTime),
                                             new Date());
                                     opcAsyncTask.addRawData(id, rawData);
+
+                                    if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                        BigDecimal bigEventValue = new BigDecimal(eventValue);
+                                        if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)||
+                                                eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                            }
+
+                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                            }
+                                            opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                        }
+                                    }
                                 } catch (Exception e1) {
 
                                 }

+ 2 - 1
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/util/OpcDaUtil.java

@@ -108,7 +108,8 @@ public class OpcDaUtil {
             }
             if (OPCSERVERSTATE.OPC_STATUS_RUNNING == server.getServerState().getServerState()) {
                 if (dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.KEPSERVER.getValue()) ||
-                        dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.OPCIFIX.getValue())) {
+                        dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.OPCIFIX.getValue())||
+                        dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.YOKOGAWA.getValue())) {
                     List<JSONObject> jsonObjectList = generServerTree(server);
                     return Result.ok(jsonObjectList);
                 } else if (dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.WINCC.getValue()) ||

+ 1 - 1
chaunyi_opc/opc_ua/src/main/java/com/example/opc_ua/service/impl/ItemGroupServiceImpl.java

@@ -133,7 +133,6 @@ public class ItemGroupServiceImpl implements ItemGroupService {
             if (itemGroup.getRunState().equals(ConstantStr.START_UP)) {
                 return Result.ok("此数据组已处于运行中");
             }
-            redisUtil.set(ConstantStr.ITEM_GROUP + id, true);
             if (dataSourceType.getDataSourceTypeKey().equals(DataSourceTypeEnum.OPC_UA_REAL.getValue()) ||
                     dataSourceType.getDataSourceTypeKey().equals(DataSourceTypeEnum.OPC_UA_HISTORY.getValue())) {
                 if (Blank.isEmpty(dataSource.getIpAddress(), dataSource.getIpPort(), dataSource.getIsAnonymous())) {
@@ -144,6 +143,7 @@ public class ItemGroupServiceImpl implements ItemGroupService {
                         throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "选择不匿名方式,需要填写帐户和密码");
                     }
                 }
+                redisUtil.set(ConstantStr.ITEM_GROUP + id, true);
                 Timer timer = new Timer();
                 List<Item> itemList = itemGroupDao.getItemListByGroupId(id);
                 //异步读取opcUA数据并保存

+ 4 - 0
chaunyi_opc/opc_ua/src/main/java/com/example/opc_ua/task/OpcAsyncTask.java

@@ -97,4 +97,8 @@ public class OpcAsyncTask {
     public void eventTable(Integer tableReportId, BigDecimal value, String currentDate) {
         ReportTable reportTable = reportTableDao.getReportTableById(tableReportId);
     }
+
+    public void addEventTable(Integer tableReportId,List<BigDecimal> eventDataValueList, List<String> eventDataValueTimeList){
+
+    }
 }

+ 120 - 7
chaunyi_opc/opc_ua/src/main/java/com/example/opc_ua/task/OpcUaChangeTask.java

@@ -183,11 +183,23 @@ public class OpcUaChangeTask extends TimerTask {
                                 BigDecimal bigEventValue = new BigDecimal(eventValue);
                                 if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
                                     if (dmData.compareTo(bigEventValue) == 1) {
-                                        opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                        eventDataValueList.add(dmData);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                        eventDataValueTimeList.add(currentYmdhmss);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                     }
                                 } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
                                     if (dmData.compareTo(bigEventValue) == -1) {
-                                        opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                        eventDataValueList.add(dmData);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                        eventDataValueTimeList.add(currentYmdhmss);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                     }
                                 }
                             }
@@ -225,11 +237,39 @@ public class OpcUaChangeTask extends TimerTask {
                                         BigDecimal bigEventValue = new BigDecimal(eventValue);
                                         if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
                                             if (dmData.compareTo(bigEventValue) == 1) {
-                                                opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                }
+                                                eventDataValueList.add(dmData);
+                                                redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                }
+                                                eventDataValueTimeList.add(currentYmdhmss);
+                                                redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                             }
                                         } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
                                             if (dmData.compareTo(bigEventValue) == -1) {
-                                                opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                                }
+                                                eventDataValueList.add(dmData);
+                                                redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                                }
+                                                eventDataValueTimeList.add(currentYmdhmss);
+                                                redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                             }
                                         }
                                     }
@@ -298,13 +338,47 @@ public class OpcUaChangeTask extends TimerTask {
                                 if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
                                     BigDecimal bigEventValue = new BigDecimal(eventValue);
                                     if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                        }
+
+                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                        }
+                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                        eventDataValueList = new ArrayList<>();
+                                        eventDataValueTimeList = new ArrayList<>();
                                         if (dmData.compareTo(bigEventValue) == 1) {
-                                            opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                            eventDataValueList.add(dmData);
+                                            eventDataValueTimeList.add(currentYmdhmss);
                                         }
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                     } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
-                                        if (dmData.compareTo(bigEventValue) == -1) {
-                                            opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
                                         }
+
+                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                        }
+                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                        eventDataValueList = new ArrayList<>();
+                                        eventDataValueTimeList = new ArrayList<>();
+                                        if (dmData.compareTo(bigEventValue) == 1) {
+                                            eventDataValueList.add(dmData);
+                                            eventDataValueTimeList.add(currentYmdhmss);
+                                        }
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                     }
                                 }
                                 redisUtil.set(ConstantStr.DATA_VALUE + id + itemId, dataValueList, ConstantStr.TWO_HOUR);
@@ -381,6 +455,24 @@ public class OpcUaChangeTask extends TimerTask {
                                 String.valueOf(valueBelongTime),
                                 new Date());
                         opcAsyncTask.addRawData(id, rawData);
+
+                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED) ||
+                                    eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                }
+
+                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                }
+                                opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                            }
+                        }
                     } catch (Exception e1) {
                         List<String> dataValueList = new ArrayList<>();
                         Object dataValueObject = redisUtil.get(ConstantStr.DATA_VALUE + id + itemId);
@@ -418,6 +510,9 @@ public class OpcUaChangeTask extends TimerTask {
         if (!flage) {
             for (Item item : itemList) {
                 String itemId = item.getItemReadName();
+                Integer eventMode = item.getEventMode();
+                Integer eventValue = item.getEventValue();
+                Integer tableReportId = item.getTableReportId();
                 String valueBelongTime = String.valueOf(redisUtil.get(ConstantStr.VALUE_BELONG_TIME + id + itemId));
 
                 List<String> dataValueTimeList = new ArrayList<>();
@@ -458,6 +553,24 @@ public class OpcUaChangeTask extends TimerTask {
                                 String.valueOf(valueBelongTime),
                                 new Date());
                         opcAsyncTask.addRawData(id, rawData);
+
+                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED) ||
+                                    eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                }
+
+                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                }
+                                opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                            }
+                        }
                     } catch (Exception e1) {
                         List<String> dataValueList = new ArrayList<>();
                         Object dataValueObject = redisUtil.get(ConstantStr.DATA_VALUE + id + itemId);

+ 151 - 12
chaunyi_opc/opc_ua/src/main/java/com/example/opc_ua/task/OpcUaExceedTask.java

@@ -95,18 +95,6 @@ public class OpcUaExceedTask extends TimerTask {
                         BigDecimal dmData = Blank.isNotEmpty(dm) ?
                                 MathUtil.quadricOperation(dm.getMathParameter(), dm.getOperationRule(), bigDecimal) :
                                 bigDecimal;
-                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
-                            BigDecimal bigEventValue = new BigDecimal(eventValue);
-                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
-                                if (dmData.compareTo(bigEventValue) == 1) {
-                                    opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
-                                }
-                            } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
-                                if (dmData.compareTo(bigEventValue) == -1) {
-                                    opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
-                                }
-                            }
-                        }
                         if (Blank.isEmpty(storageYmdh)) {
                             if (dmData.compareTo(bigModeValue) == 1) {
                                 redisUtil.set(ConstantStr.VALUE_BELONG_TIME + id + itemId, currentYmdh, ConstantStr.TWO_HOUR);
@@ -119,6 +107,30 @@ public class OpcUaExceedTask extends TimerTask {
                                 dataValueTimeList.add(currentYmdhmss);
                                 redisUtil.set(ConstantStr.DATA_VALUE_TIME + id + itemId, dataValueTimeList, ConstantStr.TWO_HOUR);
                             }
+                            if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                BigDecimal bigEventValue = new BigDecimal(eventValue);
+                                if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                    if (dmData.compareTo(bigEventValue) == 1) {
+                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                        eventDataValueList.add(dmData);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                        eventDataValueTimeList.add(currentYmdhmss);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                    }
+                                } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                    if (dmData.compareTo(bigEventValue) == -1) {
+                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                        eventDataValueList.add(dmData);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                        eventDataValueTimeList.add(currentYmdhmss);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                    }
+                                }
+                            }
                         } else {
                             if (DateUtil.strChangeDate(storageYmdh, timeFormat).getTime() == DateUtil.strChangeDate(currentYmdh, timeFormat).getTime()) {
                                 if (dmData.compareTo(bigModeValue) == 1) {
@@ -138,6 +150,47 @@ public class OpcUaExceedTask extends TimerTask {
                                     dataValueTimeList.add(currentYmdhmss);
                                     redisUtil.set(ConstantStr.DATA_VALUE_TIME + id + itemId, dataValueTimeList, ConstantStr.TWO_HOUR);
                                 }
+
+                                if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                    BigDecimal bigEventValue = new BigDecimal(eventValue);
+                                    if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                        if (dmData.compareTo(bigEventValue) == 1) {
+                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                            }
+                                            eventDataValueList.add(dmData);
+                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                            }
+                                            eventDataValueTimeList.add(currentYmdhmss);
+                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                        }
+                                    } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                        if (dmData.compareTo(bigEventValue) == -1) {
+                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                            }
+                                            eventDataValueList.add(dmData);
+                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                            }
+                                            eventDataValueTimeList.add(currentYmdhmss);
+                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                        }
+                                    }
+                                }
                             } else {
                                 String valueBelongTime = String.valueOf(redisUtil.get(ConstantStr.VALUE_BELONG_TIME + id + itemId));
 
@@ -157,6 +210,53 @@ public class OpcUaExceedTask extends TimerTask {
                                 RawData rawData = new RawData(dataSourceId, itemId, javaType, JSON.toJSONString(dataValueList), String.valueOf(dataValueTimeList), String.valueOf(valueBelongTime), new Date());
                                 opcAsyncTask.addRawData(id, rawData);
 
+                                if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                    BigDecimal bigEventValue = new BigDecimal(eventValue);
+                                    if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                        }
+
+                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                        }
+                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                        eventDataValueList = new ArrayList<>();
+                                        eventDataValueTimeList = new ArrayList<>();
+                                        if (dmData.compareTo(bigEventValue) == 1) {
+                                            eventDataValueList.add(dmData);
+                                            eventDataValueTimeList.add(currentYmdhmss);
+                                        }
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                    } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                        }
+
+                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                        }
+                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                        eventDataValueList = new ArrayList<>();
+                                        eventDataValueTimeList = new ArrayList<>();
+                                        if (dmData.compareTo(bigEventValue) == -1) {
+                                            eventDataValueList.add(dmData);
+                                            eventDataValueTimeList.add(currentYmdhmss);
+                                        }
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                    }
+                                }
+
                                 dataValueList = new ArrayList<>();
                                 dataValueTimeList = new ArrayList<>();
                                 if (dmData.compareTo(bigModeValue) == 1) {
@@ -199,6 +299,24 @@ public class OpcUaExceedTask extends TimerTask {
                                 String.valueOf(valueBelongTime),
                                 new Date());
                         opcAsyncTask.addRawData(id, rawData);
+
+                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED) ||
+                                    eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                }
+
+                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                }
+                                opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                            }
+                        }
                     } catch (Exception e1) {
 
                     }
@@ -224,6 +342,9 @@ public class OpcUaExceedTask extends TimerTask {
         if (!flage) {
             for (Item item : itemList) {
                 String itemId = item.getItemReadName();
+                Integer eventMode = item.getEventMode();
+                Integer eventValue = item.getEventValue();
+                Integer tableReportId = item.getTableReportId();
                 String valueBelongTime = String.valueOf(redisUtil.get(ConstantStr.VALUE_BELONG_TIME + id + itemId));
 
                 List<String> dataValueTimeList = new ArrayList<>();
@@ -249,6 +370,24 @@ public class OpcUaExceedTask extends TimerTask {
                                 String.valueOf(valueBelongTime),
                                 new Date());
                         opcAsyncTask.addRawData(id, rawData);
+
+                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED) ||
+                                    eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                }
+
+                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                }
+                                opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                            }
+                        }
                     } catch (Exception e1) {
 
                     }

+ 118 - 8
chaunyi_opc/opc_ua/src/main/java/com/example/opc_ua/task/OpcUaFrequencyTask.java

@@ -173,13 +173,23 @@ public class OpcUaFrequencyTask extends TimerTask {
                             dataValueList.add(dmData);
                             if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
                                 BigDecimal bigEventValue = new BigDecimal(eventValue);
+                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                List<String> eventDataValueTimeList = new ArrayList<>();
                                 if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
                                     if (dmData.compareTo(bigEventValue) == 1) {
-                                        opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                        eventDataValueList.add(dmData);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                        eventDataValueTimeList.add(currentYmdhmss);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                     }
                                 } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
                                     if (dmData.compareTo(bigEventValue) == -1) {
-                                        opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                        eventDataValueList.add(dmData);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                        eventDataValueTimeList.add(currentYmdhmss);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                     }
                                 }
                             }
@@ -212,11 +222,39 @@ public class OpcUaFrequencyTask extends TimerTask {
                                     BigDecimal bigEventValue = new BigDecimal(eventValue);
                                     if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
                                         if (dmData.compareTo(bigEventValue) == 1) {
-                                            opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                            }
+                                            eventDataValueList.add(dmData);
+                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                            }
+                                            eventDataValueTimeList.add(currentYmdhmss);
+                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                         }
                                     } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
                                         if (dmData.compareTo(bigEventValue) == -1) {
-                                            opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                            }
+                                            eventDataValueList.add(dmData);
+                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                            }
+                                            eventDataValueTimeList.add(currentYmdhmss);
+                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                         }
                                     }
                                 }
@@ -272,17 +310,50 @@ public class OpcUaFrequencyTask extends TimerTask {
                                 if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
                                     BigDecimal bigEventValue = new BigDecimal(eventValue);
                                     if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                        }
+
+                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                        }
+                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                        eventDataValueList = new ArrayList<>();
+                                        eventDataValueTimeList = new ArrayList<>();
                                         if (dmData.compareTo(bigEventValue) == 1) {
-                                            opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                            eventDataValueList.add(dmData);
+                                            eventDataValueTimeList.add(currentYmdhmss);
                                         }
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                     } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
-                                        if (dmData.compareTo(bigEventValue) == -1) {
-                                            opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
+                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
                                         }
+
+                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                        }
+                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                        eventDataValueList = new ArrayList<>();
+                                        eventDataValueTimeList = new ArrayList<>();
+                                        if (dmData.compareTo(bigEventValue) == 1) {
+                                            eventDataValueList.add(dmData);
+                                            eventDataValueTimeList.add(currentYmdhmss);
+                                        }
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
                                     }
                                 }
                                 redisUtil.set(ConstantStr.DATA_VALUE + id + itemId, dataValueList, ConstantStr.TWO_HOUR);
-
                             } catch (Exception e) {
                                 List<String> dataValueList = new ArrayList<>();
                                 if (Blank.isNotEmpty(dataValueObject)) {
@@ -354,6 +425,24 @@ public class OpcUaFrequencyTask extends TimerTask {
                                 String.valueOf(valueBelongTime),
                                 new Date());
                         opcAsyncTask.addRawData(id, rawData);
+
+                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED) ||
+                                    eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                }
+
+                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                }
+                                opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                            }
+                        }
                     } catch (Exception e1) {
                         List<String> dataValueList = new ArrayList<>();
                         Object dataValueObject = redisUtil.get(ConstantStr.DATA_VALUE + id + itemId);
@@ -391,6 +480,9 @@ public class OpcUaFrequencyTask extends TimerTask {
         if (!flage) {
             for (Item item : itemList) {
                 String itemId = item.getItemReadName();
+                Integer eventMode = item.getEventMode();
+                Integer eventValue = item.getEventValue();
+                Integer tableReportId = item.getTableReportId();
                 String valueBelongTime = String.valueOf(redisUtil.get(ConstantStr.VALUE_BELONG_TIME + id + itemId));
 
                 List<String> dataValueTimeList = new ArrayList<>();
@@ -431,6 +523,24 @@ public class OpcUaFrequencyTask extends TimerTask {
                                 String.valueOf(valueBelongTime),
                                 new Date());
                         opcAsyncTask.addRawData(id, rawData);
+
+                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED) ||
+                                    eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                }
+
+                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                }
+                                opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                            }
+                        }
                     } catch (Exception e1) {
                         List<String> dataValueList = new ArrayList<>();
                         Object dataValueObject = redisUtil.get(ConstantStr.DATA_VALUE + id + itemId);

+ 153 - 12
chaunyi_opc/opc_ua/src/main/java/com/example/opc_ua/task/OpcUaLowerTask.java

@@ -94,18 +94,6 @@ public class OpcUaLowerTask extends TimerTask {
                         BigDecimal dmData = Blank.isNotEmpty(dm) ?
                                 MathUtil.quadricOperation(dm.getMathParameter(), dm.getOperationRule(), bigDecimal) :
                                 bigDecimal;
-                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
-                            BigDecimal bigEventValue = new BigDecimal(eventValue);
-                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
-                                if (dmData.compareTo(bigEventValue) == 1) {
-                                    opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
-                                }
-                            } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
-                                if (dmData.compareTo(bigEventValue) == -1) {
-                                    opcAsyncTask.eventTable(tableReportId, dmData, currentYmdhmss);
-                                }
-                            }
-                        }
                         if (Blank.isEmpty(storageYmdh)) {
                             if (dmData.compareTo(bigModeValue) == -1) {
                                 redisUtil.set(ConstantStr.VALUE_BELONG_TIME + id + itemId, currentYmdh, ConstantStr.TWO_HOUR);
@@ -118,6 +106,30 @@ public class OpcUaLowerTask extends TimerTask {
                                 dataValueTimeList.add(currentYmdhmss);
                                 redisUtil.set(ConstantStr.DATA_VALUE_TIME + id + itemId, dataValueTimeList, ConstantStr.TWO_HOUR);
                             }
+                            if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                BigDecimal bigEventValue = new BigDecimal(eventValue);
+                                if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                    if (dmData.compareTo(bigEventValue) == 1) {
+                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                        eventDataValueList.add(dmData);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                        eventDataValueTimeList.add(currentYmdhmss);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                    }
+                                } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                    if (dmData.compareTo(bigEventValue) == -1) {
+                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                        eventDataValueList.add(dmData);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                        eventDataValueTimeList.add(currentYmdhmss);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                    }
+                                }
+                            }
                         } else {
                             if (DateUtil.strChangeDate(storageYmdh, timeFormat).getTime() == DateUtil.strChangeDate(currentYmdh, timeFormat).getTime()) {
                                 if (dmData.compareTo(bigModeValue) == -1) {
@@ -137,6 +149,47 @@ public class OpcUaLowerTask extends TimerTask {
                                     dataValueTimeList.add(currentYmdhmss);
                                     redisUtil.set(ConstantStr.DATA_VALUE_TIME + id + itemId, dataValueTimeList, ConstantStr.TWO_HOUR);
                                 }
+
+                                if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                    BigDecimal bigEventValue = new BigDecimal(eventValue);
+                                    if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                        if (dmData.compareTo(bigEventValue) == 1) {
+                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                            }
+                                            eventDataValueList.add(dmData);
+                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                            }
+                                            eventDataValueTimeList.add(currentYmdhmss);
+                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                        }
+                                    } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                        if (dmData.compareTo(bigEventValue) == -1) {
+                                            List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                            Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueObject)) {
+                                                eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                            }
+                                            eventDataValueList.add(dmData);
+                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+
+                                            List<String> eventDataValueTimeList = new ArrayList<>();
+                                            Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                            if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                                eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                            }
+                                            eventDataValueTimeList.add(currentYmdhmss);
+                                            redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                        }
+                                    }
+                                }
                             } else {
                                 String valueBelongTime = String.valueOf(redisUtil.get(ConstantStr.VALUE_BELONG_TIME + id + itemId));
 
@@ -162,6 +215,53 @@ public class OpcUaLowerTask extends TimerTask {
                                         new Date());
                                 opcAsyncTask.addRawData(id, rawData);
 
+                                if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                                    BigDecimal bigEventValue = new BigDecimal(eventValue);
+                                    if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)) {
+                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                        }
+
+                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                        }
+                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                        eventDataValueList = new ArrayList<>();
+                                        eventDataValueTimeList = new ArrayList<>();
+                                        if (dmData.compareTo(bigEventValue) == 1) {
+                                            eventDataValueList.add(dmData);
+                                            eventDataValueTimeList.add(currentYmdhmss);
+                                        }
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                    } else if (eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                        List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                        Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueObject)) {
+                                            eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                        }
+
+                                        List<String> eventDataValueTimeList = new ArrayList<>();
+                                        Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                        if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                            eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                        }
+                                        opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                                        eventDataValueList = new ArrayList<>();
+                                        eventDataValueTimeList = new ArrayList<>();
+                                        if (dmData.compareTo(bigEventValue) == -1) {
+                                            eventDataValueList.add(dmData);
+                                            eventDataValueTimeList.add(currentYmdhmss);
+                                        }
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE + id + itemId, eventDataValueList, ConstantStr.TWO_HOUR);
+                                        redisUtil.set(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId, eventDataValueTimeList, ConstantStr.TWO_HOUR);
+                                    }
+                                }
+
                                 dataValueList = new ArrayList<>();
                                 dataValueTimeList = new ArrayList<>();
                                 if (dmData.compareTo(bigModeValue) == -1) {
@@ -204,6 +304,25 @@ public class OpcUaLowerTask extends TimerTask {
                                 String.valueOf(valueBelongTime),
                                 new Date());
                         opcAsyncTask.addRawData(id, rawData);
+
+                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                            BigDecimal bigEventValue = new BigDecimal(eventValue);
+                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)||
+                                    eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                }
+
+                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                }
+                                opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                            }
+                        }
                     } catch (Exception e1) {
 
                     }
@@ -229,6 +348,9 @@ public class OpcUaLowerTask extends TimerTask {
         if (!flage) {
             for (Item item : itemList) {
                 String itemId = item.getItemReadName();
+                Integer eventMode = item.getEventMode();
+                Integer eventValue = item.getEventValue();
+                Integer tableReportId = item.getTableReportId();
                 String valueBelongTime = String.valueOf(redisUtil.get(ConstantStr.VALUE_BELONG_TIME + id + itemId));
 
                 List<String> dataValueTimeList = new ArrayList<>();
@@ -254,6 +376,25 @@ public class OpcUaLowerTask extends TimerTask {
                                 String.valueOf(valueBelongTime),
                                 new Date());
                         opcAsyncTask.addRawData(id, rawData);
+
+                        if (Blank.isNotEmpty(eventMode) && Blank.isNotEmpty(eventValue) && Blank.isNotEmpty(tableReportId)) {
+                            BigDecimal bigEventValue = new BigDecimal(eventValue);
+                            if (eventMode.equals(ConstantStr.EVENT_MODEL_EXCEED)||
+                                    eventMode.equals(ConstantStr.EVENT_MODEL_LOWER)) {
+                                List<BigDecimal> eventDataValueList = new ArrayList<>();
+                                Object eventDataValueObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueObject)) {
+                                    eventDataValueList = JavaTypeUtil.objChangeListBig(eventDataValueObject);
+                                }
+
+                                List<String> eventDataValueTimeList = new ArrayList<>();
+                                Object eventDataValueTimeObject = redisUtil.get(ConstantStr.EVENT_DATA_VALUE_TIME + id + itemId);
+                                if (Blank.isNotEmpty(eventDataValueTimeObject)) {
+                                    eventDataValueTimeList = JavaTypeUtil.objChangeListStr(eventDataValueTimeObject);
+                                }
+                                opcAsyncTask.addEventTable(tableReportId, eventDataValueList, eventDataValueTimeList);
+                            }
+                        }
                     } catch (Exception e1) {
 
                     }