package com.jcdm.main.da.opcuaconfig.cert; import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf; import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; import com.jcdm.main.da.opcuaconfig.client.ClientHandler; import com.jcdm.main.da.opcuaconfig.domain.NodeEntity; import com.jcdm.main.da.opcuaconfig.init.BeanUtils; import com.jcdm.main.da.paramCollection.domain.DaParamCollection; import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; import lombok.extern.slf4j.Slf4j; import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import java.util.*; import java.util.stream.Collectors; import static com.jcdm.main.da.opcuaconfig.client.ClientHandler.readValues; @Slf4j public class MethodName { private IDaCollectionParamConfService collectionParamConfService = BeanUtils.getBean(IDaCollectionParamConfService.class); private IDaParamCollectionService daParamCollectionService = BeanUtils.getBean(IDaParamCollectionService.class); private List s=null; public void getSn(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]+".RecordDataDone").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(); Boolean out1=clientHandler.write(node1); log.info("节点:{},响应结果:{}", node1.getIdentifier(),out1); break; case "2": //请求记录工位数据 List b; DaCollectionParamConf daCollectionParamConf=new DaCollectionParamConf(); daCollectionParamConf.setCollectParameterId(parts[0]+"."+parts[1]); b=collectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf); List nodeId = b.stream().map(info -> { NodeId nodeid = new NodeId(2,info.getCollectParameterId()); return nodeid; }).collect(Collectors.toList()); List s=readValues(nodeId); for(int i=0;i