admin
2025-04-09 9a0334b6e46d9503246d99be0a3a79945dee7919
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package com.jcdm.main.plcserver;
 
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jcdm.common.core.domain.entity.SysDictData;
import com.jcdm.main.constant.Constants;
import com.jcdm.main.da.cellData.service.IDaCellDataService;
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.jcdm.system.service.ISysDictDataService;
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.HashMap;
import java.util.List;
import java.util.Map;
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;
 
    @Autowired
    private IDaCellDataService daCellDataService;
 
    @Autowired
    private ISysDictDataService sysDictDataService;
 
    @Override
    public void run(ApplicationArguments args) throws Exception {
 
        //PLC到MES物料转换
        materialInit();
//        Constants.materialMap.put("1","9900200461");//微卡电驱动系统总成(9999276636)//9900200461
//        Constants.materialMap.put("2","9900207783");//微面电驱动系统总成(9999276639)//9900207783
//
//        Constants.facMaterialMap.put("9900200461","9999276636");//生产物料转工厂物料请求工单
//        Constants.facMaterialMap.put("9900207783","9999276639");//生产物料转工厂物料请求工单
 
        //通道
        Constants.thoroughfareMap.put(Constants.OP010,"JCDM035-1");
 
        Constants.thoroughfareMap.put(Constants.OP020,"JCDM035-2");
        Constants.thoroughfareMap.put(Constants.OP030,"JCDM035-2");
        Constants.thoroughfareMap.put(Constants.OP120_2,"JCDM035-2");
        Constants.thoroughfareMap.put(Constants.OP130,"JCDM035-2");
        Constants.thoroughfareMap.put(Constants.OP140,"JCDM035-2");
        Constants.thoroughfareMap.put(Constants.OP150,"JCDM035-2");
        Constants.thoroughfareMap.put(Constants.OP160,"JCDM035-2");
        Constants.thoroughfareMap.put(Constants.OP165,"JCDM035-2");
 
        Constants.thoroughfareMap.put(Constants.OP040,"JCDM035-3");
        Constants.thoroughfareMap.put(Constants.OP050,"JCDM035-3");
        Constants.thoroughfareMap.put(Constants.OP060,"JCDM035-3");
        Constants.thoroughfareMap.put(Constants.OP070,"JCDM035-3");
        Constants.thoroughfareMap.put(Constants.OP080,"JCDM035-3");
        Constants.thoroughfareMap.put(Constants.OP090,"JCDM035-3");
        Constants.thoroughfareMap.put(Constants.OP100,"JCDM035-3");
        Constants.thoroughfareMap.put(Constants.OP110,"JCDM035-3");
 
        Constants.thoroughfareMap.put(Constants.OP170,"JCDM035-4");
        Constants.thoroughfareMap.put(Constants.OP180,"JCDM035-4");
        Constants.thoroughfareMap.put(Constants.OP190,"JCDM035-4");
        Constants.thoroughfareMap.put(Constants.OP200,"JCDM035-4");
        Constants.thoroughfareMap.put(Constants.OP210,"JCDM035-4");
        Constants.thoroughfareMap.put(Constants.OP220,"JCDM035-4");
        Constants.thoroughfareMap.put(Constants.OP230,"JCDM035-4");
 
        //主线人工工位
        Constants.OP040_OP160.add(Constants.OP040);
        Constants.OP040_OP160.add(Constants.OP080);
        Constants.OP040_OP160.add(Constants.OP070);
        Constants.OP040_OP160.add(Constants.OP100);
        Constants.OP040_OP160.add(Constants.OP120_2);
        Constants.OP040_OP160.add(Constants.OP165);
 
        //环线人工工位
        Constants.OP0170_OP220.add(Constants.OP170);
        Constants.OP0170_OP220.add(Constants.OP180);
        Constants.OP0170_OP220.add(Constants.OP190);
        Constants.OP0170_OP220.add(Constants.OP200);
        Constants.OP0170_OP220.add(Constants.OP210);
        Constants.OP0170_OP220.add(Constants.OP220);
 
        OPCUaSubscription opcUaSubscription = new OPCUaSubscription(
                miloService,
                daPassingStationCollectionService,
                collectionParamConfService,
                daParamCollectionService,
                omProductionOrdeInfoService,
                daTestDeviceInterfaceTempService,
                daCellDataService);
 
        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)
                        .eq(DaOpcuaConfig::getSubscribe,Constants.YES))
                .stream().map(DaOpcuaConfig::getNode).collect(Collectors.toList());
        return lists;
    }
 
    public void materialInit(){
        SysDictData plcMesData = new SysDictData();
        plcMesData.setDictType("plc_mes");
 
        SysDictData imesGeelyMesData = new SysDictData();
        imesGeelyMesData.setDictType("imes_geely_mes");
 
        List<SysDictData> plcMesList = sysDictDataService.selectDictDataList(plcMesData);
        List<SysDictData> imesGeelyMesList = sysDictDataService.selectDictDataList(imesGeelyMesData);
 
        for (SysDictData sysDictData : plcMesList) {
            Constants.materialMap.put(sysDictData.getDictLabel(),sysDictData.getDictValue());
        }
 
        for (SysDictData sysDictData : imesGeelyMesList) {
            Constants.facMaterialMap.put(sysDictData.getDictLabel(),sysDictData.getDictValue());
        }
        System.out.println("物料初始化"+Constants.materialMap+"---"+Constants.facMaterialMap);
    }
}