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