package com.jcdm.main.da.opcuaconfig.init; import com.jcdm.main.da.opcuaconfig.domain.DaOpcuaConfig; import com.jcdm.main.da.opcuaconfig.service.IDaOpcuaConfigService; import com.kangaroohy.milo.configuration.MiloProperties; import com.kangaroohy.milo.model.ReadWriteEntity; import com.kangaroohy.milo.pool.MiloConnectPool; import com.kangaroohy.milo.service.MiloService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @Component @Slf4j public class CustomRunner implements ApplicationRunner { @Autowired public MiloService miloService; private IDaOpcuaConfigService daOpcuaConfigService = BeanUtils.getBean(IDaOpcuaConfigService.class); private List b=null; @Override public void run(ApplicationArguments args) throws Exception { sub(); } private void sub() throws Exception { DaOpcuaConfig daOpcuaConfig=new DaOpcuaConfig(); daOpcuaConfig.setSubscribe(1L); b=daOpcuaConfigService.selectDaOpcuaConfigList(daOpcuaConfig); List ids = b.stream().map(e -> e.getNode()).collect(Collectors.toList()); TestCallback testCallback = new TestCallback(); miloService.subscriptionFromOpcUa(ids,testCallback); } }