cl
2024-07-03 5c62de89d218b7dbb06eee67f10f746eb5ce1667
提交 | 用户 | 时间
0ca254 1 package com.jcdm.main.plcserver;
A 2
3
109e2f 4 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
C 5 import com.jcdm.main.constant.Constants;
0ca254 6 import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService;
109e2f 7 import com.jcdm.main.da.opcuaconfig.domain.DaOpcuaConfig;
C 8 import com.jcdm.main.da.opcuaconfig.service.IDaOpcuaConfigService;
0ca254 9 import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
A 10 import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService;
11 import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService;
12 import com.jcdm.main.plcserver.sub.OPCUaSubscription;
13 import com.kangaroohy.milo.service.MiloService;
14 import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.boot.ApplicationArguments;
16 import org.springframework.boot.ApplicationRunner;
17 import org.springframework.stereotype.Component;
18
19 import java.util.List;
109e2f 20 import java.util.stream.Collectors;
0ca254 21
A 22 @Component
23 public class CustomRunner implements ApplicationRunner {
24
25     @Autowired
26     private MiloService miloService;
27
28     @Autowired
29     private IDaPassingStationCollectionService daPassingStationCollectionService;
30
31     @Autowired
32     private IDaCollectionParamConfService collectionParamConfService;
33
34     @Autowired
35     private IDaParamCollectionService daParamCollectionService;
36
37
38     @Autowired
39     private IOmProductionOrdeInfoService omProductionOrdeInfoService;
40
109e2f 41
2de856 42     @Autowired
109e2f 43     private IDaOpcuaConfigService daOpcuaConfigService;
C 44
45
0ca254 46
A 47     @Override
48     public void run(ApplicationArguments args) throws Exception {
109e2f 49         //分段010-065段
C 50         Constants.OP020_OP065.add(Constants.OP020);
51         Constants.OP020_OP065.add(Constants.OP030);
52         Constants.OP020_OP065.add(Constants.OP040);
53         Constants.OP020_OP065.add(Constants.OP050);
54         Constants.OP020_OP065.add(Constants.OP060);
55         Constants.OP020_OP065.add(Constants.OP065);
0ca254 56
A 57         OPCUaSubscription opcUaSubscription = new OPCUaSubscription(
58                 miloService,
59                 daPassingStationCollectionService,
60                 collectionParamConfService,
61                 daParamCollectionService,
109e2f 62                 omProductionOrdeInfoService);
0ca254 63
A 64         List<String> lists = getSubList();
65         System.out.println("订阅内容:"+lists);
66         miloService.subscriptionFromOpcUa(lists,50,opcUaSubscription);
109e2f 67
0ca254 68     }
A 69
70     /**
71      * 订阅内容
72      */
73     public List<String> getSubList(){
109e2f 74         List<String> lists = daOpcuaConfigService.list(new LambdaQueryWrapper<DaOpcuaConfig>()
C 75                         .eq(DaOpcuaConfig::getState, Constants.USE_ING))
76                 .stream().map(DaOpcuaConfig::getNode).collect(Collectors.toList());
0ca254 77         return lists;
A 78     }
79 }
80