package com.jcdm.main.plcserver;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.jcdm.main.constant.Constants;
|
import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService;
|
import com.jcdm.main.da.opcuaconfig.domain.DaOpcuaConfig;
|
import com.jcdm.main.da.opcuaconfig.service.IDaOpcuaConfigService;
|
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
|
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService;
|
import com.jcdm.main.da.testDeviceInterfaceTemp.service.IDaTestDeviceInterfaceTempService;
|
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService;
|
import com.jcdm.main.plcserver.sub.OPCUaSubscription;
|
import com.kangaroohy.milo.service.MiloService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.stereotype.Component;
|
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
@Component
|
public class CustomRunner implements ApplicationRunner {
|
|
@Autowired
|
private MiloService miloService;
|
|
@Autowired
|
private IDaPassingStationCollectionService daPassingStationCollectionService;
|
|
@Autowired
|
private IDaCollectionParamConfService collectionParamConfService;
|
|
@Autowired
|
private IDaParamCollectionService daParamCollectionService;
|
|
|
@Autowired
|
private IOmProductionOrdeInfoService omProductionOrdeInfoService;
|
|
|
@Autowired
|
private IDaOpcuaConfigService daOpcuaConfigService;
|
|
@Autowired
|
private IDaTestDeviceInterfaceTempService daTestDeviceInterfaceTempService;
|
|
@Override
|
public void run(ApplicationArguments args) throws Exception {
|
//分段010-065段
|
Constants.OP020_OP090.add(Constants.OP020);
|
Constants.OP020_OP090.add(Constants.OP030);
|
Constants.OP020_OP090.add(Constants.OP040);
|
Constants.OP020_OP090.add(Constants.OP050);
|
Constants.OP020_OP090.add(Constants.OP060);
|
Constants.OP020_OP090.add(Constants.OP090);
|
|
OPCUaSubscription opcUaSubscription = new OPCUaSubscription(
|
miloService,
|
daPassingStationCollectionService,
|
collectionParamConfService,
|
daParamCollectionService,
|
omProductionOrdeInfoService,
|
daTestDeviceInterfaceTempService);
|
|
List<String> lists = getSubList();
|
System.out.println("订阅内容:"+lists);
|
miloService.subscriptionFromOpcUa(lists,50,opcUaSubscription);
|
|
}
|
|
/**
|
* 订阅内容
|
*/
|
public List<String> getSubList(){
|
List<String> lists = daOpcuaConfigService.list(new LambdaQueryWrapper<DaOpcuaConfig>()
|
.eq(DaOpcuaConfig::getState, Constants.USE_ING))
|
.stream().map(DaOpcuaConfig::getNode).collect(Collectors.toList());
|
return lists;
|
}
|
}
|