From f4cb4dab73beecc4c03a52f8d971e007c9c287f9 Mon Sep 17 00:00:00 2001
From: wujian <14790700720@163.com>
Date: 星期六, 27 四月 2024 18:01:01 +0800
Subject: [PATCH] change model3

---
 jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java |   52 ++++++++++++++++++++++++++++------------------------
 1 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
index c5cd563..c149c92 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
@@ -313,12 +313,13 @@
                 return nodeid;
             }).collect(Collectors.toList());
 
-            if(!nodeIdList.isEmpty()){
+            List<ReadWriteEntity> readWriteEntityList = new ArrayList<>();
+            if(CollUtil.isNotEmpty(nodeIdList)){
                 long time1 = new Date().getTime();
-                List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(nodeIdList);
+                readWriteEntityList = miloService.readFromOpcUa(nodeIdList);
                 long time2 = new Date().getTime();
                 log.info("璇诲彇鐐逛綅鑺辫垂鏃堕棿锛歿},",time2-time1);
-
+            }
                 //杩斿洖plc淇濆瓨鎴愬姛
                 if (parts.length==3){
                     if ("SaveRequest".equals(parts[2])){
@@ -332,30 +333,33 @@
                     log.info("-------璇锋眰杩斿洖-----,{}",LocalDateTime.now());
                 }
                 List<DaParamCollection> daParamCollectionlist = new ArrayList<>();
-                for(int i=0;i<nodeIdList.size();i++){
-                    if(!readWriteEntityList.get(i).getValue().toString().equals("0.0")){
-                        DaParamCollection ParamCollection = new DaParamCollection();
-                        ParamCollection.setParamCode(readWriteEntityList.get(i).getIdentifier().toString().split("[.]")[2]);
-                        ParamCollection.setLocationCode(parts[1]);
-                        if (readWriteEntityList.get(i) == null){
-                            ParamCollection.setParamValue("0");
-                        }else {
-                            ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString());
+                if (CollUtil.isNotEmpty(nodeIdList)){
+                    for(int i=0;i<nodeIdList.size();i++){
+                        if(!readWriteEntityList.get(i).getValue().toString().equals("0.0")){
+                            DaParamCollection ParamCollection = new DaParamCollection();
+                            ParamCollection.setParamCode(readWriteEntityList.get(i).getIdentifier().toString().split("[.]")[2]);
+                            ParamCollection.setLocationCode(parts[1]);
+                            if (readWriteEntityList.get(i) == null){
+                                ParamCollection.setParamValue("0");
+                            }else {
+                                ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString());
+                            }
+                            ParamCollection.setSfcCode(SNCode);
+                            ParamCollection.setParamName(list.get(i).getCollectParameterName());
+                            ParamCollection.setParamUpper(list.get(i).getParamUpper());
+                            ParamCollection.setParamLower(list.get(i).getParamLower());
+                            ParamCollection.setUnit(list.get(i).getCollectParameterUnit());
+                            ParamCollection.setState("鍚堟牸");
+                            ParamCollection.setType(list.get(i).getCollectParameterType());
+                            ParamCollection.setCollectionTime(new Date());
+                            daParamCollectionlist.add(ParamCollection);
                         }
-                        ParamCollection.setSfcCode(SNCode);
-                        ParamCollection.setParamName(list.get(i).getCollectParameterName());
-                        ParamCollection.setParamUpper(list.get(i).getParamUpper());
-                        ParamCollection.setParamLower(list.get(i).getParamLower());
-                        ParamCollection.setUnit(list.get(i).getCollectParameterUnit());
-                        ParamCollection.setState("鍚堟牸");
-                        ParamCollection.setType(list.get(i).getCollectParameterType());
-                        ParamCollection.setCollectionTime(new Date());
-                        daParamCollectionlist.add(ParamCollection);
                     }
+                    daParamCollectionService.saveBeachDaParamCollection(daParamCollectionlist);
+                    log.info("-------淇濆瓨鏁版嵁瀹屾垚---------");
                 }
-                daParamCollectionService.saveBeachDaParamCollection(daParamCollectionlist);
-                log.info("-------淇濆瓨鏁版嵁瀹屾垚---------");
-            }
+
+
 
 
             Long beatTime = 0L;

--
Gitblit v1.9.3