cl
2024-01-22 314bc7a1733856bd82c9d99bdfa27b34a4a762c3
提交 | 用户 | 时间
d43481 1 package cn.stylefeng.guns.plcserver.init;
C 2
3 import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService;
4 import cn.stylefeng.guns.modular.bs.equipmentInfo.model.params.EquipmentInfoParam;
5 import cn.stylefeng.guns.modular.bs.equipmentInfo.model.result.EquipmentInfoResult;
6 import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService;
7 import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService;
8 import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService;
9 import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService;
10 import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService;
11 import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService;
12 import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService;
13 import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService;
14 import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService;
15 import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService;
16 import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService;
17 import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService;
18 import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService;
19 import cn.stylefeng.guns.plcserver.callback.*;
20 import cn.stylefeng.guns.plcserver.opc.GlobalVariable;
21 import cn.stylefeng.guns.plcserver.opc.OPCElement;
22 import com.kangaroohy.milo.service.MiloService;
23 import lombok.extern.slf4j.Slf4j;
24 import org.openscada.opc.lib.da.Item;
25 import org.springframework.beans.factory.annotation.Autowired;
26 import org.springframework.boot.ApplicationArguments;
27 import org.springframework.boot.ApplicationRunner;
28 import org.springframework.stereotype.Component;
29
30 import java.util.ArrayList;
31 import java.util.List;
32 import java.util.concurrent.ExecutorService;
33 import java.util.concurrent.Executors;
34
35 @Component
36 @Slf4j
37 public class CustomRunner implements ApplicationRunner {
38
39     @Autowired
40     public MiloService miloService;
41
42     @Autowired
43     public ProductionOrdeInfoService productionOrdeInfoService;
44     @Autowired
45     public PassingStationCollectionService passingStationCollectionService;
46     @Autowired
47     public ParamCollectionService paramCollectionService;
48     @Autowired
49     public CollectionParamConfService collectionParamConfService;
50     @Autowired
51     public SerialNumbersConfService serialNumbersConfService;
52     @Autowired
53     private EquipmentStatusService equipmentStatusService;
54
55     @Autowired
56     private EquipmentAlarmService equipmentAlarmService;
57     @Autowired
58     private MaterialTraceabilityService materialTraceabilityService;
59     @Autowired
60     private EquipmentInfoService equipmentInfoService;
61     @Autowired
62     private RepairManageInfoService repairManageInfoService;
63
64     @Autowired
65     private LocationInfoService locationInfoService;
66
67     @Autowired
68     private GreaseManageService greaseManageService;
69
70     @Autowired
71     private ProductionOrderRecordsService productionOrderRecordsService;
72
73     @Autowired
74     private ProductionOrderBatchInfoService productionOrderBatchInfoService;
75
76     private List stateLists = null;
77     @Override
78     public void run(ApplicationArguments args) throws Exception {
79
80         GlobalVariable.PRODUCT_TYPE_MAP.put("12980500000198","1");//C1 36V
81         GlobalVariable.PRODUCT_TYPE_MAP.put("12980500000174","2");//C1 48V
82         GlobalVariable.PRODUCT_TYPE_MAP.put("12980500000194","3");//T1 36V
83         GlobalVariable.PRODUCT_TYPE_MAP.put("12980500000201","4");//T1 48V
84
85         GlobalVariable.PRODUCT_CODE_MAP.put("1","12980500000198");
86         GlobalVariable.PRODUCT_CODE_MAP.put("2","12980500000174");
87         GlobalVariable.PRODUCT_CODE_MAP.put("3","12980500000194");
88         GlobalVariable.PRODUCT_CODE_MAP.put("4","12980500000201");
89
90         InitCallback InitCallback = new InitCallback(miloService,productionOrdeInfoService,
91                 passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService,
92                 equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService,
93                 repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService,
94                 productionOrderBatchInfoService);
95
314bc7 96         System.out.println("start run^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
d43481 97         List<String> lists = getList();
C 98         miloService.subscriptionFromOpcUa(lists,InitCallback);
314bc7 99         System.out.println("end run^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
d43481 100
C 101     }
102
103     public List<String> getList(){
104         List<String> lists = new ArrayList<>();
105
106         lists.add(OPCElement.COP010_F_HEART_BEAT);
107         lists.add(OPCElement.COP010_J_PLC_START);
108         lists.add(OPCElement.COP010_J_PLC_FINISH);
109
110         lists.add(OPCElement.COP020_F_HEART_BEAT);
111         lists.add(OPCElement.COP020_J_PLC_START);
112         lists.add(OPCElement.COP020_J_PLC_FINISH);
113
114         lists.add(OPCElement.COP030_F_HEART_BEAT);
115         lists.add(OPCElement.COP030_J_PLC_START);
116         lists.add(OPCElement.COP030_J_PLC_FINISH);
117
118         lists.add(OPCElement.BOP010_F_HEART_BEAT);
119         lists.add(OPCElement.BOP010_J_PLC_START);
120         lists.add(OPCElement.BOP010_J_PLC_FINISH);
121
122         lists.add(OPCElement.BOP020_F_HEART_BEAT);
123         lists.add(OPCElement.BOP020_J_PLC_START);
124         lists.add(OPCElement.BOP020_J_PLC_FINISH);
125
126         lists.add(OPCElement.BOP030_F_HEART_BEAT);
127         lists.add(OPCElement.BOP030_J_PLC_START);
128         lists.add(OPCElement.BOP030_J_PLC_FINISH);
129
130         lists.add(OPCElement.BOP030B_F_HEART_BEAT);
131         lists.add(OPCElement.BOP030B_J_PLC_START);
132         lists.add(OPCElement.BOP030B_J_PLC_FINISH);
133
134         lists.add(OPCElement.BOP040_F_HEART_BEAT);
135         lists.add(OPCElement.BOP040_J_PLC_START);
136         lists.add(OPCElement.BOP040_J_PLC_FINISH);
137
138         lists.add(OPCElement.BOP040B_F_HEART_BEAT);
139         lists.add(OPCElement.BOP040B_J_PLC_START);
140         lists.add(OPCElement.BOP040B_J_PLC_FINISH);
141
142         lists.add(OPCElement.DOP010_F_HEART_BEAT);
143         lists.add(OPCElement.DOP010_J_PLC_START);
144         lists.add(OPCElement.DOP010_J_PLC_FINISH);
145
146     /*    lists.add(OPCElement.DOP020_F_HEART_BEAT);
147         lists.add(OPCElement.DOP020_J_PLC_START);
148         lists.add(OPCElement.DOP020_J_PLC_FINISH);*/
149
150         lists.add(OPCElement.EOP010_F_HEART_BEAT);
151         lists.add(OPCElement.EOP010_J_PLC_START);
152         lists.add(OPCElement.EOP010_J_PLC_FINISH);
153
154         lists.add(OPCElement.EOP020_F_HEART_BEAT);
155         lists.add(OPCElement.EOP020_J_PLC_START);
156         lists.add(OPCElement.EOP020_J_PLC_FINISH);
157
158         lists.add(OPCElement.EOP030_F_HEART_BEAT);
159         lists.add(OPCElement.EOP030_J_PLC_START);
160         lists.add(OPCElement.EOP030_J_PLC_FINISH);
161
162         lists.add(OPCElement.EOP040_F_HEART_BEAT);
163         lists.add(OPCElement.EOP040_J_PLC_START);
164         lists.add(OPCElement.EOP040_J_PLC_FINISH);
165
166         lists.add(OPCElement.EOP050_F_HEART_BEAT);
167         lists.add(OPCElement.EOP050_J_PLC_START);
168         lists.add(OPCElement.EOP050_J_PLC_FINISH);
169
170         lists.add(OPCElement.EOP060_F_HEART_BEAT);
171         lists.add(OPCElement.EOP060_J_PLC_START);
172         lists.add(OPCElement.EOP060_J_PLC_FINISH);
173
174         lists.add(OPCElement.EOP070_F_HEART_BEAT);
175         lists.add(OPCElement.EOP070_J_PLC_START);
176         lists.add(OPCElement.EOP070_J_PLC_FINISH);
177
178         lists.add(OPCElement.EOP070_F_HEART_BEAT);
179         lists.add(OPCElement.EOP070_J_PLC_START);
180         lists.add(OPCElement.EOP070_J_PLC_FINISH);
181
182         lists.add(OPCElement.EOP090_F_HEART_BEAT);
183         lists.add(OPCElement.EOP090_J_PLC_START);
184         lists.add(OPCElement.EOP090_J_PLC_FINISH);
185
186         lists.add(OPCElement.EOP090B_F_HEART_BEAT);
187         lists.add(OPCElement.EOP090B_J_PLC_START);
188         lists.add(OPCElement.EOP090B_J_PLC_FINISH);
189
190         lists.add(OPCElement.OP010_F_HEART_BEAT);
191         lists.add(OPCElement.OP010_J_PLC_START);
192         lists.add(OPCElement.OP010_J_PLC_FINISH);
193
194         lists.add(OPCElement.OP020_F_HEART_BEAT);
195         lists.add(OPCElement.OP020_J_PLC_START);
196         lists.add(OPCElement.OP020_J_PLC_FINISH);
197
198         lists.add(OPCElement.OP030_F_HEART_BEAT);
199         lists.add(OPCElement.OP030_J_PLC_START);
200         lists.add(OPCElement.OP030_J_PLC_FINISH);
201
202         lists.add(OPCElement.OP040_F_HEART_BEAT);
203         lists.add(OPCElement.OP040_J_PLC_START);
204         lists.add(OPCElement.OP040_J_PLC_FINISH);
205
206         lists.add(OPCElement.OP050_F_HEART_BEAT);
207         lists.add(OPCElement.OP050_J_PLC_START);
208         lists.add(OPCElement.OP050_J_PLC_FINISH);
209
210         lists.add(OPCElement.OP070_F_HEART_BEAT);
211         lists.add(OPCElement.OP070_J_PLC_START);
212         lists.add(OPCElement.OP070_J_PLC_FINISH);
213
214         lists.add(OPCElement.OP080_F_HEART_BEAT);
215         lists.add(OPCElement.OP080_J_PLC_START);
216         lists.add(OPCElement.OP080_J_PLC_FINISH);
217
218         lists.add(OPCElement.OP090_F_HEART_BEAT);
219         lists.add(OPCElement.OP090_J_PLC_START);
220         lists.add(OPCElement.OP090_J_PLC_FINISH);
221
222         lists.add(OPCElement.OP100_F_HEART_BEAT);
223         lists.add(OPCElement.OP100_J_PLC_START);
224         lists.add(OPCElement.OP100_J_PLC_FINISH);
225
226         lists.add(OPCElement.OP110_F_HEART_BEAT);
227         lists.add(OPCElement.OP110_J_PLC_START);
228         lists.add(OPCElement.OP110_J_PLC_FINISH);
229
230         lists.add(OPCElement.OP120_F_HEART_BEAT);
231         lists.add(OPCElement.OP120_J_PLC_START);
232         lists.add(OPCElement.OP120_J_PLC_FINISH);
233
234         lists.add(OPCElement.OP120B_F_HEART_BEAT);
235         lists.add(OPCElement.OP120B_J_PLC_START);
236         lists.add(OPCElement.OP120B_J_PLC_FINISH);
237
238         lists.add(OPCElement.OP130_F_HEART_BEAT);
239         lists.add(OPCElement.OP130_J_PLC_START);
240         lists.add(OPCElement.OP130_J_PLC_FINISH);
241
242         lists.add(OPCElement.OP130B_F_HEART_BEAT);
243         lists.add(OPCElement.OP130B_J_PLC_START);
244         lists.add(OPCElement.OP130B_J_PLC_FINISH);
245
246         lists.add(OPCElement.OP140_F_HEART_BEAT);
247         lists.add(OPCElement.OP140_J_PLC_START);
248         lists.add(OPCElement.OP140_J_PLC_FINISH);
249
250      /*   lists.add(OPCElement.OP150_F_HEART_BEAT);
251         lists.add(OPCElement.OP150_J_PLC_START);
252         lists.add(OPCElement.OP150_J_PLC_FINISH);*/
253
254         lists.add(OPCElement.OP160_F_HEART_BEAT);
255         lists.add(OPCElement.OP160_J_PLC_START);
256         lists.add(OPCElement.OP160_J_PLC_FINISH);
257
258         lists.add(OPCElement.OP170_F_HEART_BEAT);
259         lists.add(OPCElement.OP170_J_PLC_START);
260         lists.add(OPCElement.OP170_J_PLC_FINISH);
261
262         if(null == stateLists ){
263             EquipmentInfoParam equipmentInfoParam = new EquipmentInfoParam();
264             stateLists = equipmentInfoService.findListBySpec(equipmentInfoParam);
265         }
266
267         if(!stateLists.isEmpty()){
268             for(int i=0;i<stateLists.size();i++) {
269                 EquipmentInfoResult result = (EquipmentInfoResult) stateLists.get(i);
270                 if(null != result.getSpareField1()){
271                     lists.add(result.getSpareField1());
272                 }
273             }
274         }
275         return lists;
276     }
277 }
278