春风项目四线(合箱线、总装线)
yyt
2024-02-21 a9406b6b18ee5a8e29cad3248f46320a36ac9749
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();