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 | 76 ++++++++++++++++++++++++++++++++++++- 1 files changed, 73 insertions(+), 3 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 1d5f7ab..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; @@ -25,6 +26,75 @@ private IDaParamCollectionService daParamCollectionService = BeanUtils.getBean(IDaParamCollectionService.class); private IDaPassingStationCollectionService daPassingStationCollectionService = BeanUtils.getBean(IDaPassingStationCollectionService.class); public void Transit(String Node, String value) throws Exception { + //log.info(Node+":"+value); + String[] parts = Node.split("[.]"); + ClientHandler clientHandler=new ClientHandler(); + switch (value) { + case "0": //鍒濆 + NodeEntity node= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("0").type("short").build(); + Boolean out=clientHandler.write(node); + log.info("鑺傜偣:{},鍝嶅簲缁撴灉:{}", node.getIdentifier(),out); + break; + case "1": //璇锋眰涓嬪彂杩涚珯鐘舵�� + NodeEntity node1= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("11").type("short").build(); + Boolean out1=clientHandler.write(node1); + log.info("鑺傜偣:{},鍝嶅簲缁撴灉:{}", node1.getIdentifier(),out1); + break; + case "2": //璇锋眰璁板綍宸ヤ綅鏁版嵁 + NodeEntity SN_node= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".SNCode").value("").type("").build(); + String SNCode=clientHandler.read(SN_node); + if(SNCode==null){ + NodeEntity node2= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("22").type("short").build(); + Boolean out2=clientHandler.write(node2); + break; + } + List<DaCollectionParamConf> b; + DaCollectionParamConf daCollectionParamConf=new DaCollectionParamConf(); + daCollectionParamConf.setGatherAddress(parts[0]+"."+parts[1]); + b=collectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf); + 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(); + PassingStationCollection.setSfcCode(SNCode); + PassingStationCollection.setLocationCode(parts[1]); + PassingStationCollection.setInboundTime(new Date()); + PassingStationCollection.setOutboundTime(new Date()); + PassingStationCollection.setCollectionTime(new Date()); + PassingStationCollection.setBeatTime("56"); + daPassingStationCollectionService.insertDaPassingStationCollection(PassingStationCollection); + //鏇存柊PLC鑺傜偣鐘舵�� + NodeEntity node2= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("21").type("short").build(); + Boolean out2=clientHandler.write(node2); + log.info("鑺傜偣:{},鍝嶅簲缁撴灉:{}", node2.getIdentifier(),out2); + break; + default: + break; + } + } + + public void Transit2(String Node, String value) throws Exception { log.info(Node+":"+value); String[] parts = Node.split("[.]"); ClientHandler clientHandler=new ClientHandler(); @@ -33,12 +103,12 @@ log.info("璇诲彇鑺傜偣:{},缁撴灉:{}", SN_node.getIdentifier(),SNCode); switch (value) { case "0": //鍒濆 - NodeEntity node= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".RecordDataDone").value("0").type("short").build(); + NodeEntity node= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("0").type("short").build(); Boolean out=clientHandler.write(node); log.info("鑺傜偣:{},鍝嶅簲缁撴灉:{}", node.getIdentifier(),out); break; case "1": //璇锋眰涓嬪彂杩涚珯鐘舵�� - NodeEntity node1= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".RecordDataDone").value("11").type("short").build(); + NodeEntity node1= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("11").type("short").build(); Boolean out1=clientHandler.write(node1); DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection(); PassingStationCollection.setSfcCode(SNCode); @@ -80,7 +150,7 @@ daPassingStationCollectionService.updateDaPassingStationCollection(LPSC.get(0)); } //鏇存柊PLC鑺傜偣鐘舵�� - NodeEntity node2= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".RecordDataDone").value("21").type("short").build(); + NodeEntity node2= NodeEntity.builder().index(2).identifier(parts[0]+"."+parts[1]+".MesRecordDataDone").value("21").type("short").build(); Boolean out2=clientHandler.write(node2); log.info("鑺傜偣:{},鍝嶅簲缁撴灉:{}", node2.getIdentifier(),out2); break; -- Gitblit v1.9.3