From a9406b6b18ee5a8e29cad3248f46320a36ac9749 Mon Sep 17 00:00:00 2001 From: yyt <306727702@qq.com> Date: 星期三, 21 二月 2024 00:19:44 +0800 Subject: [PATCH] 批量数据采集方法更新 --- jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/MethodName.java | 39 +++++++++++++++++++++++---------------- 1 files changed, 23 insertions(+), 16 deletions(-) diff --git a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/MethodName.java b/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/MethodName.java index 290c19a..26111de 100644 --- a/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/MethodName.java +++ b/jcdm-main/src/main/java/com/jcdm/main/da/opcuaconfig/cert/MethodName.java @@ -1,5 +1,6 @@ package com.jcdm.main.da.opcuaconfig.cert; +import cn.hutool.core.date.StopWatch; import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf; import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; import com.jcdm.main.da.opcuaconfig.client.ClientHandler; @@ -51,22 +52,28 @@ DaCollectionParamConf daCollectionParamConf=new DaCollectionParamConf(); daCollectionParamConf.setGatherAddress(parts[0]+"."+parts[1]); b=collectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf); - - List<NodeId> nodeId = b.stream().map(info -> { - NodeId nodeid = new NodeId(2,info.getGatherAddress()); - return nodeid; - }).collect(Collectors.toList()); - List<DataValue> s=readValues(nodeId); - //淇濆瓨PLC閲囬泦鏁版嵁 - for(int i=0;i<nodeId.size();i++) - { - DaParamCollection Config=new DaParamCollection(); - Config.setParamCode(nodeId.get(i).getIdentifier().toString().split("[.]")[2]); - Config.setLocationCode(nodeId.get(i).getIdentifier().toString().split("[.]")[1]); - Config.setParamValue(s.get(i).getValue().getValue().toString()); - Config.setSfcCode(SNCode); - Config.setParamName(b.get(i).getGatherAddress()); - daParamCollectionService.insertDaParamCollection(Config); + if(b!=null&&b.size()>0){ + List<NodeId> nodeId = b.stream().map(info -> { + NodeId nodeid = new NodeId(2,info.getGatherAddress()); + return nodeid; + }).collect(Collectors.toList()); + List<DataValue> s=readValues(nodeId); + //淇濆瓨PLC閲囬泦鏁版嵁 +// StopWatch stopWatch = new StopWatch(); +// stopWatch.start(); + List<DaParamCollection> DaParamCollectionlist = new ArrayList<>(); + for(int i=0;i<nodeId.size();i++){ + DaParamCollection ParamCollection = new DaParamCollection(); + ParamCollection.setParamCode(nodeId.get(i).getIdentifier().toString().split("[.]")[2]); + ParamCollection.setLocationCode(nodeId.get(i).getIdentifier().toString().split("[.]")[1]); + ParamCollection.setParamValue(s.get(i).getValue().getValue().toString()); + ParamCollection.setSfcCode(SNCode); + ParamCollection.setParamName(b.get(i).getGatherAddress()); + DaParamCollectionlist.add(ParamCollection); + } + daParamCollectionService.saveBeachDaParamCollection(DaParamCollectionlist); +// stopWatch.stop(); +// System.out.println("浣跨敤sqlSessionFactory瀹炵幇鎵归噺鎻掑叆鑰楁椂锛�" + stopWatch.getTotalTimeMillis()); } //璁板綍杩囩珯锛屽苟璁$畻鑺傛媿銆� DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection(); -- Gitblit v1.9.3