春风项目四线(合箱线、总装线)
yyt
2024-05-20 d4f4376ab5aef071cb841de0f9a9b7f6cb16c651
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.jcdm.main.plcserver;
 
 
import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService;
import com.jcdm.main.bs.technologyRouteChild.service.IBsTechnologyRouteChildInfoService;
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.impl.DaPassingStationCollectionServiceImpl;
import com.jcdm.main.plcserver.sub.OPCUaSubscription;
import com.jcdm.main.rm.repairRecord.service.IRmRepairRecordService;
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 javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
 
@Component
public class CustomRunner implements ApplicationRunner {
 
    @Autowired
    public MiloService miloService;
 
    @Autowired
    public IDaCollectionParamConfService collectionParamConfService;
 
    @Autowired
    public IDaParamCollectionService daParamCollectionService;
 
    @Resource
    private DaPassingStationCollectionServiceImpl passingStationCollectionServiceImpl;
 
    @Resource
    private IDaOpcuaConfigService iDaOpcuaConfigService;
 
    @Resource
    private IBsOrderSchedulingService bsOrderSchedulingService;
 
    @Resource
    private IRmRepairRecordService rmRepairRecordService;
 
    @Resource
    private IBsTechnologyRouteChildInfoService bsTechnologyRouteChildInfoService;
 
    @Override
    public void run(ApplicationArguments args) throws Exception {
 
        List<DaOpcuaConfig> lists = getSubList();
        List<String> collect = lists.stream().map(DaOpcuaConfig::getNode).collect(Collectors.toList());
        OPCUaSubscription opcUaSubscription = new OPCUaSubscription(
                miloService,
                collectionParamConfService,
                daParamCollectionService,
                passingStationCollectionServiceImpl,
                bsOrderSchedulingService,
                lists,
                rmRepairRecordService,
                bsTechnologyRouteChildInfoService);
 
 
        miloService.subscriptionFromOpcUa(collect,opcUaSubscription);
 
    }
 
    /**
     * 订阅内容
     */
    public List<DaOpcuaConfig> getSubList(){
        DaOpcuaConfig config = new DaOpcuaConfig();
        config.setState(0);
        List<DaOpcuaConfig> list = iDaOpcuaConfigService.selectDaOpcuaConfigList(config);
//        List<String> lists = new ArrayList<>();
//        if (CollUtil.isNotEmpty(list)){
//            lists = list.stream().map(DaOpcuaConfig::getNode).distinct().collect(Collectors.toList());
//        }
//        List<String> lists = new ArrayList<>();
////        lists.add(OPCElement.OP010_SaveRequest);//请求保存
////        lists.add(OPCElement.OP010_CodeCheck);//请求检索条码
////        lists.add(OPCElement.OP020_SaveRequest);//请求保存
//        lists.add(OPCElement.OP120_SaveRequestLast);//请求保存
//        lists.add(OPCElement.OP120_ZZ_CODE_CHECK);//请求保存
        return list;
    }
}