| | |
| | | |
| | | import com.google.common.collect.Lists; |
| | | import com.jcdm.main.da.opcuaconfig.client.ClientHandler; |
| | | import com.jcdm.main.da.opcuaconfig.controller.DaOpcuaConfigController; |
| | | import com.jcdm.main.da.opcuaconfig.domain.DaOpcuaConfig; |
| | | import com.jcdm.main.da.opcuaconfig.domain.NodeEntity; |
| | | import com.jcdm.main.da.opcuaconfig.service.IDaOpcuaConfigService; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.CommandLineRunner; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | @Component |
| | | @Slf4j |
| | |
| | | public void run(String... args) throws Exception { |
| | | try { |
| | | DaOpcuaConfig daOpcuaConfig=new DaOpcuaConfig(); |
| | | daOpcuaConfig.setSubscribe("Y"); //设置查询条件,是否订阅状态为Y的所有数据. |
| | | daOpcuaConfig.setSubscribe("Y"); //设置查询条件,订阅状态的所有数据. |
| | | daOpcuaConfig.setState(Long.valueOf("0")); //设置查询条件,正常状态. |
| | | List<DaOpcuaConfig> nodeslist=daOpcuaConfigService.selectDaOpcuaConfigList(daOpcuaConfig); |
| | | clientHandler.connect(); |
| | | if (nodeslist != null && nodeslist.size() > 0) { |
| | |
| | | return nodeEntity; |
| | | }); |
| | | clientHandler.subscribe(NodeList); |
| | | log.info("初始化OPC订阅" + nodeslist.size() + "条!"); |
| | | } |
| | | log.info("系统提示,OPCUA订阅成功!"); |
| | | log.info("OPCUA初始化成功,并完成"+ nodeslist.size() +"个节点订阅"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.info("系统提示,OPCUA订阅失败!"); |