提交 | 用户 | 时间
|
e6c837
|
1 |
package com.jcdm.main.plcserver.sub; |
A |
2 |
|
|
3 |
|
|
4 |
import cn.hutool.core.collection.CollUtil; |
09ef66
|
5 |
import cn.hutool.core.util.ObjectUtil; |
e6c837
|
6 |
import cn.hutool.core.util.StrUtil; |
A |
7 |
import cn.hutool.json.JSONObject; |
|
8 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
9 |
import com.jcdm.framework.websocket.WebSocketUsers; |
|
10 |
import com.jcdm.main.constant.Constants; |
|
11 |
import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf; |
|
12 |
import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; |
|
13 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
|
14 |
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; |
|
15 |
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
09ef66
|
16 |
import com.jcdm.main.da.passingStationCollection.query.ProductOrderChild; |
W |
17 |
import com.jcdm.main.da.passingStationCollection.query.ProductOrderQuery; |
|
18 |
import com.jcdm.main.da.passingStationCollection.query.ProductOrderVO; |
e6c837
|
19 |
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; |
A |
20 |
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; |
|
21 |
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; |
|
22 |
import com.jcdm.main.plcserver.util.TimeUtil; |
|
23 |
import com.jcdm.main.restful.factoryMes.service.RestfulService; |
09ef66
|
24 |
import com.jcdm.main.work.domain.KeyCodeRelation; |
W |
25 |
import com.jcdm.main.work.domain.WorkOrder; |
|
26 |
import com.jcdm.main.work.service.KeyCodeCheckService; |
|
27 |
import com.jcdm.main.work.service.KeyCodeRelationService; |
|
28 |
import com.jcdm.main.work.service.WorkOrderService; |
e6c837
|
29 |
import com.kangaroohy.milo.model.ReadWriteEntity; |
A |
30 |
import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
|
31 |
import com.kangaroohy.milo.service.MiloService; |
09ef66
|
32 |
import lombok.extern.slf4j.Slf4j; |
e6c837
|
33 |
import org.springframework.stereotype.Component; |
A |
34 |
|
|
35 |
import javax.websocket.Session; |
|
36 |
import java.text.SimpleDateFormat; |
|
37 |
import java.util.*; |
|
38 |
import java.util.stream.Collectors; |
|
39 |
|
|
40 |
|
09ef66
|
41 |
@Slf4j |
e6c837
|
42 |
@Component |
A |
43 |
public class OPCUaSubscription implements SubscriptionCallback { |
|
44 |
|
|
45 |
public SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
46 |
|
|
47 |
//新自动工站 |
|
48 |
public List<String> automaticList = Arrays.asList("OP280","OP310A","OP310B", "OP300A","OP300B", "OP320A","OP320B", "OP340A","OP340B", "OP350A","OP350B", "OP360","OP365","OP370", "OP390", "OP470"); |
|
49 |
|
|
50 |
//采集模组工位 ModuleCode |
|
51 |
public List<String> moduleCodeList = Arrays.asList("OP300A","OP300B","OP320A","OP320B","OP340A","OP340B","OP365", "OP350A", "OP350B", "OP330"); |
|
52 |
|
|
53 |
//区分模组型号工位 |
|
54 |
public List<String> distinguishingModules = Arrays.asList("OP300","OP310", "OP340", "OP350", "OP330"); |
|
55 |
|
|
56 |
//区分小车码 |
|
57 |
public List<String> agvId = Arrays.asList("OP360", "OP390", "OP470","OP280"); |
|
58 |
|
|
59 |
|
|
60 |
//区分pack型号的工位 |
|
61 |
public List<String> packIdList = Arrays.asList("OP280","OP360","OP390","OP470"); |
|
62 |
|
|
63 |
//测试设备手动工位 |
|
64 |
public List<String> testList = Arrays.asList("OP430-1","OP430-2","OP430-3","OP430-4","OP480-1","OP480-2","OP480-3","OP440"); |
|
65 |
|
|
66 |
|
|
67 |
//空的 |
|
68 |
public List<String> nullList = Arrays.asList("OP250","OP260"); |
|
69 |
|
|
70 |
|
|
71 |
public static MiloService miloService; |
|
72 |
|
|
73 |
Map<String, Session> map = WebSocketUsers.getUsers(); |
|
74 |
|
|
75 |
public IDaPassingStationCollectionService daPassingStationCollectionService; |
|
76 |
|
|
77 |
public static IDaCollectionParamConfService collectionParamConfService; |
|
78 |
|
|
79 |
public static IDaParamCollectionService daParamCollectionService; |
|
80 |
|
|
81 |
public static IOmProductionOrdeInfoService omProductionOrdeInfoService; |
09ef66
|
82 |
public static WorkOrderService workOrderService; |
W |
83 |
public static KeyCodeCheckService keyCodeCheckService; |
|
84 |
public static KeyCodeRelationService keyCodeRelationService; |
e6c837
|
85 |
|
A |
86 |
public OPCUaSubscription(MiloService miloService, |
|
87 |
IDaPassingStationCollectionService daPassingStationCollectionService, |
|
88 |
IDaCollectionParamConfService collectionParamConfService, |
|
89 |
IDaParamCollectionService daParamCollectionService, |
09ef66
|
90 |
IOmProductionOrdeInfoService omProductionOrdeInfoService, |
W |
91 |
WorkOrderService workOrderService, |
|
92 |
KeyCodeCheckService keyCodeCheckService, |
|
93 |
KeyCodeRelationService keyCodeRelationService) { |
e6c837
|
94 |
OPCUaSubscription.miloService = miloService; |
A |
95 |
this.daPassingStationCollectionService = daPassingStationCollectionService; |
|
96 |
OPCUaSubscription.collectionParamConfService = collectionParamConfService; |
|
97 |
OPCUaSubscription.daParamCollectionService = daParamCollectionService; |
|
98 |
OPCUaSubscription.omProductionOrdeInfoService = omProductionOrdeInfoService; |
09ef66
|
99 |
OPCUaSubscription.workOrderService = workOrderService; |
W |
100 |
OPCUaSubscription.keyCodeCheckService = keyCodeCheckService; |
|
101 |
OPCUaSubscription.keyCodeRelationService = keyCodeRelationService; |
|
102 |
|
e6c837
|
103 |
} |
A |
104 |
|
|
105 |
|
|
106 |
@Override |
|
107 |
public void onSubscribe(String identifier, Object value) { |
|
108 |
|
|
109 |
try { |
09ef66
|
110 |
if(null != value && !Constants.ZERO.equals(value.toString())) { |
e6c837
|
111 |
String[] nodes = identifier.split("[.]"); |
A |
112 |
String thoroughfare = nodes[0];//通道 |
|
113 |
String device = nodes[1];//设备 |
|
114 |
String tab = nodes[2];//标记 |
09ef66
|
115 |
String valueString = value.toString();//地址值 |
W |
116 |
if (Constants.RECORD_CHECK_CODE.equals(tab)){ |
|
117 |
if (Constants.ONE.equals(valueString)){ |
|
118 |
Integer scanResult = 11; |
|
119 |
if (Constants.OP010.equals(device) || Constants.OP030.equals(device)){ |
|
120 |
//OP010工位电芯条码校验||OP030工位电芯条码校验 |
|
121 |
Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".Scaner").getValue(); |
|
122 |
if (ObjectUtil.isNotNull(value1)){ |
|
123 |
String keyCode = value1.toString(); |
|
124 |
log.info("读取到工位{}的Scaner数据:{}",device,keyCode); |
|
125 |
//仅校验长度是否合格 |
|
126 |
// List<KeyCodeCheck> collect = keyCodeCheckService.list().stream().filter(x -> x.getKeyCode().contains(keyCode)).collect(Collectors.toList()); |
|
127 |
// if (CollUtil.isNotEmpty(collect)){ |
|
128 |
// scanResult = 11; |
|
129 |
// } |
e6c837
|
130 |
} |
A |
131 |
} |
09ef66
|
132 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult1").value(scanResult).build()); |
W |
133 |
log.info("写入到工位{}的ScanerResult1数据:{}",device,scanResult); |
e6c837
|
134 |
} |
09ef66
|
135 |
}else if (Constants.RECORD_DATA.equals(tab)){ |
W |
136 |
if (Constants.ONE.equals(valueString)){ |
|
137 |
//1:告知MES托盘已到站,请求下发进站状态 |
|
138 |
if (Constants.OP030.equals(device)){ |
|
139 |
//反馈电芯ocv检测结果 |
|
140 |
boolean b = OCVResultFeedBack(thoroughfare, device); |
|
141 |
if (b){ |
|
142 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); |
|
143 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,11); |
|
144 |
}else { |
|
145 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); |
|
146 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,12); |
|
147 |
} |
|
148 |
} else { |
|
149 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); |
|
150 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,11); |
e6c837
|
151 |
} |
09ef66
|
152 |
}else if (Constants.TWO.equals(valueString)){ |
W |
153 |
//分段010-065段 |
|
154 |
List<String> PART1 = new ArrayList<>(); |
|
155 |
PART1.add(Constants.OP020); |
|
156 |
PART1.add(Constants.OP030); |
|
157 |
PART1.add(Constants.OP040); |
|
158 |
PART1.add(Constants.OP050); |
|
159 |
PART1.add(Constants.OP060); |
|
160 |
PART1.add(Constants.OP065); |
|
161 |
if (Constants.OP010.equals(device)){ |
|
162 |
//010工位无过站记录,只给放行信号 |
|
163 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build()); |
|
164 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,21); |
|
165 |
}else if (PART1.contains(device)){ |
|
166 |
//020工位保存过站记录+参数数据 |
|
167 |
List<DaPassingStationCollection> passingList = getDaPassingStationCollections(thoroughfare, device); |
|
168 |
if (CollUtil.isNotEmpty(passingList)){ |
|
169 |
daPassingStationCollectionService.insertBatch(passingList); |
|
170 |
} |
|
171 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build()); |
|
172 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,21); |
|
173 |
} else if (Constants.OP100_1.equals(device) || Constants.OP100_2.equals(device)){ |
|
174 |
//下发刻码信息-为模组码 |
|
175 |
ProductOrderQuery query = new ProductOrderQuery(); |
|
176 |
query.setSiteCode("3983"); |
|
177 |
query.setStationCode(device); |
|
178 |
List<WorkOrder> collect = workOrderService.list().stream() |
|
179 |
.sorted(Comparator.comparing(WorkOrder::getCreateTime).reversed()) |
|
180 |
.collect(Collectors.toList()); |
|
181 |
if (CollUtil.isNotEmpty(collect)){ |
|
182 |
query.setProductNum(collect.get(0).getProductNum()); |
|
183 |
} |
|
184 |
ProductOrderVO vo = daPassingStationCollectionService.queryMessFromLine(query); |
|
185 |
if (Constants.SUCCESS.equals(vo.getCode())){ |
|
186 |
WorkOrder workOrder = new WorkOrder(); |
|
187 |
ProductOrderChild data = vo.getData(); |
|
188 |
workOrder.setProductNum(data.getProductNum()); |
|
189 |
workOrder.setProductionOrderNum(data.getProductionOrderNum()); |
|
190 |
workOrder.setStationCode(data.getStationCode()); |
|
191 |
workOrder.setMaterialCode(data.getMaterialCode()); |
|
192 |
workOrder.setModel(data.getModel()); |
|
193 |
workOrderService.save(workOrder); |
|
194 |
//写入模组码、工单号、产品型号到plc |
|
195 |
log.info("写入模组码、工单号、产品型号到plc"); |
|
196 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ModuleCode").value(data.getModel()).build()); |
|
197 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderNumber").value(data.getProductionOrderNum()).build()); |
|
198 |
//这里plc录入的产品型号类型是int类型,工厂mes返回数据不是int类型,可能会出现问题 |
|
199 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ProductType").value(data.getProductNum()).build()); |
|
200 |
//绑定模组码和电芯码数据 |
|
201 |
List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
|
202 |
.eq(DaCollectionParamConf::getProcessesCode, device) |
|
203 |
.eq(DaCollectionParamConf::getRemarks,Constants.ONE)); |
|
204 |
List<String> collect3 = list.stream().filter(x -> Constants.INT_ZERO.equals(x.getKeyNum())).map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
205 |
List<String> collect1 = list.stream().filter(x -> Constants.INT_ONE.equals(x.getKeyNum())|| Constants.INT_TWO.equals(x.getKeyNum())) |
|
206 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
207 |
// List<String> collect2 = list.stream().filter(x -> Constants.INT_TWO.equals(x.getKeyNum())) |
|
208 |
// .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
209 |
List<ReadWriteEntity> paramCollectionList1 = miloService.readFromOpcUa(collect1); |
|
210 |
List<ReadWriteEntity> paramCollectionList3 = miloService.readFromOpcUa(collect3); |
|
211 |
if (CollUtil.isNotEmpty(paramCollectionList1)){ |
|
212 |
List<KeyCodeRelation> relationList = new ArrayList<>(); |
|
213 |
for (ReadWriteEntity readWriteEntity : paramCollectionList1) { |
|
214 |
if (ObjectUtil.isNotNull(readWriteEntity.getValue())){ |
|
215 |
KeyCodeRelation keyCodeRelation = new KeyCodeRelation(); |
|
216 |
keyCodeRelation.setModuleCode(data.getModel()); |
|
217 |
keyCodeRelation.setKeyCode(readWriteEntity.getValue().toString()); |
|
218 |
keyCodeRelation.setProductionOrderNum(data.getProductionOrderNum()); |
|
219 |
keyCodeRelation.setProductNum(data.getProductNum()); |
|
220 |
keyCodeRelation.setCreateTime(new Date()); |
|
221 |
relationList.add(keyCodeRelation); |
|
222 |
} |
|
223 |
} |
|
224 |
if (CollUtil.isNotEmpty(relationList)){ |
|
225 |
keyCodeRelationService.insertBatch(relationList); |
|
226 |
} |
|
227 |
} |
|
228 |
if (CollUtil.isNotEmpty(paramCollectionList3)){ |
|
229 |
QueryPLCData(device,thoroughfare,collect3); |
|
230 |
} |
|
231 |
//保存过站记录 |
|
232 |
DaPassingStationCollection passingStationCollection = new DaPassingStationCollection(); |
|
233 |
passingStationCollection.setModuleCode(data.getModel()); |
|
234 |
|
|
235 |
passingStationCollection.setLocationCode(device); |
|
236 |
passingStationCollection.setInboundTime(new Date()); |
|
237 |
String stationStatus = Constants.PASS; |
|
238 |
ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus"); |
|
239 |
if (ObjectUtil.isNotNull(stationStatusRead.getValue())){ |
|
240 |
String string = stationStatusRead.getValue().toString(); |
|
241 |
log.info("读取工位{}StationStatus:{}",device,string); |
|
242 |
if (Constants.TWO.equals(string)){ |
|
243 |
stationStatus = Constants.UN_PASS; |
|
244 |
} |
|
245 |
} |
|
246 |
passingStationCollection.setOutRsSign(stationStatus); |
|
247 |
passingStationCollection.setCreateTime(new Date()); |
|
248 |
daPassingStationCollectionService.save(passingStationCollection); |
|
249 |
} |
|
250 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build()); |
|
251 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,21); |
|
252 |
} else { |
|
253 |
//2:告知MES工位工作完成,请求记录工位数据 |
|
254 |
//保存参数采集记录 |
|
255 |
saveParamPassingData(device,thoroughfare); |
|
256 |
//保存过站记录 |
|
257 |
DaPassingStationCollection passingStationCollection = new DaPassingStationCollection(); |
|
258 |
Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); |
|
259 |
String moduleCode = null; |
|
260 |
if (ObjectUtil.isNotNull(value1)){ |
|
261 |
moduleCode = value1.toString(); |
|
262 |
log.info("读取工位{}的ModuleCode数据:{}",device,moduleCode); |
|
263 |
} |
|
264 |
passingStationCollection.setModuleCode(moduleCode); |
|
265 |
passingStationCollection.setLocationCode(device); |
|
266 |
passingStationCollection.setInboundTime(new Date()); |
|
267 |
String stationStatus = Constants.PASS; |
|
268 |
ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus"); |
|
269 |
if (ObjectUtil.isNotNull(stationStatusRead.getValue())){ |
|
270 |
String string = stationStatusRead.getValue().toString(); |
|
271 |
if (Constants.TWO.equals(string)){ |
|
272 |
stationStatus = Constants.UN_PASS; |
|
273 |
} |
|
274 |
} |
|
275 |
passingStationCollection.setOutRsSign(stationStatus); |
|
276 |
passingStationCollection.setCreateTime(new Date()); |
|
277 |
daPassingStationCollectionService.save(passingStationCollection); |
|
278 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build()); |
|
279 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,21); |
|
280 |
} |
|
281 |
} |
|
282 |
} else if (Constants.RECORD_SN.equals(tab)){ |
|
283 |
if (Constants.ONE.equals(valueString)){ |
|
284 |
if (Constants.OP070.equals(device)){ |
|
285 |
//OP070下发产品模组码 |
|
286 |
String string = UUID.randomUUID().toString(); |
|
287 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ModuleCode").value(string).build()); |
|
288 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build()); |
|
289 |
} |
|
290 |
} |
|
291 |
} else if (Constants.RECORD_CHECK_CODE_1.equals(tab)) { |
|
292 |
if (Constants.OP100_1.equals(device)){ |
|
293 |
//钢带条码校验--发送给工厂mes |
|
294 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult11").value(11).build()); |
|
295 |
} else if (Constants.OP100_2.equals(device)) { |
|
296 |
//PET带条码校验--发送给工厂mes |
|
297 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult12").value(11).build()); |
e6c837
|
298 |
} |
A |
299 |
} |
|
300 |
} |
|
301 |
} catch (Exception e) { |
09ef66
|
302 |
System.out.println(e.getMessage()); |
W |
303 |
log.info(e.getMessage()); |
|
304 |
} |
|
305 |
} |
|
306 |
|
|
307 |
/** |
|
308 |
* 保存电芯过站记录 |
|
309 |
* @param thoroughfare 通道 |
|
310 |
* @param device 工位 |
|
311 |
* @return list |
|
312 |
* @throws Exception e |
|
313 |
*/ |
|
314 |
private static List<DaPassingStationCollection> getDaPassingStationCollections(String thoroughfare, String device) throws Exception { |
|
315 |
List<String> readList = new ArrayList<>(); |
|
316 |
readList.add(thoroughfare + "." + device +".CellCode_1"); |
|
317 |
readList.add(thoroughfare + "." + device +".CellCode_2"); |
|
318 |
readList.add(thoroughfare + "." + device +".CellCode_3"); |
|
319 |
readList.add(thoroughfare + "." + device +".CellCode_4"); |
|
320 |
List<String> keyCodeList = new ArrayList<>(); |
|
321 |
List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(readList); |
|
322 |
List<DaPassingStationCollection> passingList = new ArrayList<>(); |
|
323 |
for (ReadWriteEntity readWriteEntity : readWriteEntityList) { |
|
324 |
DaPassingStationCollection passingStationCollection = new DaPassingStationCollection(); |
|
325 |
passingStationCollection.setLocationCode(device); |
|
326 |
passingStationCollection.setInboundTime(new Date()); |
|
327 |
if (ObjectUtil.isNotNull(readWriteEntity.getValue())){ |
|
328 |
passingStationCollection.setKeyCode(readWriteEntity.getValue().toString()); |
|
329 |
keyCodeList.add(readWriteEntity.getValue().toString()); |
|
330 |
} |
|
331 |
String stationStatus = Constants.PASS; |
|
332 |
ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus"); |
|
333 |
if (ObjectUtil.isNotNull(stationStatusRead.getValue())){ |
|
334 |
String string = stationStatusRead.getValue().toString(); |
|
335 |
if (Constants.TWO.equals(string)){ |
|
336 |
stationStatus = Constants.UN_PASS; |
|
337 |
} |
|
338 |
} |
|
339 |
passingStationCollection.setOutRsSign(stationStatus); |
|
340 |
passingStationCollection.setCreateTime(new Date()); |
|
341 |
passingList.add(passingStationCollection); |
|
342 |
} |
|
343 |
//参数采集 |
|
344 |
//保存参数采集数据 |
|
345 |
List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
|
346 |
.eq(DaCollectionParamConf::getProcessesCode, device) |
|
347 |
.eq(DaCollectionParamConf::getRemarks, Constants.ONE)); |
|
348 |
if (CollUtil.isNotEmpty(list)){ |
|
349 |
List<DaParamCollection> saveParamList = new ArrayList<>(); |
|
350 |
List<String> collect1 = list.stream().filter(x -> Constants.INT_ONE.equals(x.getKeyNum())) |
|
351 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
352 |
List<ReadWriteEntity> paramCollectionList1 = miloService.readFromOpcUa(collect1); |
|
353 |
List<String> collect2 = list.stream().filter(x -> Constants.INT_TWO.equals(x.getKeyNum())) |
|
354 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
355 |
List<ReadWriteEntity> paramCollectionList2 = miloService.readFromOpcUa(collect2); |
|
356 |
List<String> collect3 = list.stream().filter(x -> Constants.INT_THREE.equals(x.getKeyNum())) |
|
357 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
358 |
List<ReadWriteEntity> paramCollectionList3 = miloService.readFromOpcUa(collect3); |
|
359 |
List<String> collect4 = list.stream().filter(x -> Constants.INT_FOUR.equals(x.getKeyNum())) |
|
360 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
361 |
List<ReadWriteEntity> paramCollectionList4 = miloService.readFromOpcUa(collect4); |
|
362 |
List<String> collect0 = list.stream().filter(x -> Constants.INT_ZERO.equals(x.getKeyNum())) |
|
363 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
364 |
List<ReadWriteEntity> paramCollectionList0 = miloService.readFromOpcUa(collect0); |
|
365 |
if (CollUtil.isNotEmpty(paramCollectionList1)){ |
|
366 |
for (int i = 0; i < paramCollectionList1.size(); i++) { |
|
367 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
368 |
if (CollUtil.isNotEmpty(keyCodeList) && keyCodeList.size() == 4){ |
|
369 |
daParamCollection.setKeyCode(keyCodeList.get(0)); |
|
370 |
} |
|
371 |
|
|
372 |
daParamCollection.setParamCode(paramCollectionList1.get(i).getIdentifier()); |
|
373 |
String paramValue = ""; |
|
374 |
if (ObjectUtil.isNotNull(paramCollectionList1.get(i).getValue())){ |
|
375 |
paramValue = paramCollectionList1.get(i).getValue().toString(); |
|
376 |
} |
|
377 |
daParamCollection.setParamValue(paramValue); |
|
378 |
daParamCollection.setLocationCode(device); |
|
379 |
daParamCollection.setCollectionTime(new Date()); |
|
380 |
saveParamList.add(daParamCollection); |
|
381 |
} |
|
382 |
} |
|
383 |
if (CollUtil.isNotEmpty(paramCollectionList2)){ |
|
384 |
for (int i = 0; i < paramCollectionList2.size(); i++) { |
|
385 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
386 |
if (CollUtil.isNotEmpty(keyCodeList) && keyCodeList.size() == 4){ |
|
387 |
daParamCollection.setKeyCode(keyCodeList.get(1)); |
|
388 |
} |
|
389 |
|
|
390 |
daParamCollection.setParamCode(paramCollectionList2.get(i).getIdentifier()); |
|
391 |
String paramValue = ""; |
|
392 |
if (ObjectUtil.isNotNull(paramCollectionList2.get(i).getValue())){ |
|
393 |
paramValue = paramCollectionList2.get(i).getValue().toString(); |
|
394 |
} |
|
395 |
daParamCollection.setParamValue(paramValue); |
|
396 |
daParamCollection.setLocationCode(device); |
|
397 |
daParamCollection.setCollectionTime(new Date()); |
|
398 |
saveParamList.add(daParamCollection); |
|
399 |
} |
|
400 |
} |
|
401 |
if (CollUtil.isNotEmpty(paramCollectionList3)){ |
|
402 |
for (int i = 0; i < paramCollectionList3.size(); i++) { |
|
403 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
404 |
if (CollUtil.isNotEmpty(keyCodeList) && keyCodeList.size() == 4){ |
|
405 |
daParamCollection.setKeyCode(keyCodeList.get(2)); |
|
406 |
} |
|
407 |
|
|
408 |
daParamCollection.setParamCode(paramCollectionList3.get(i).getIdentifier()); |
|
409 |
String paramValue = ""; |
|
410 |
if (ObjectUtil.isNotNull(paramCollectionList3.get(i).getValue())){ |
|
411 |
paramValue = paramCollectionList3.get(i).getValue().toString(); |
|
412 |
} |
|
413 |
daParamCollection.setParamValue(paramValue); |
|
414 |
daParamCollection.setLocationCode(device); |
|
415 |
daParamCollection.setCollectionTime(new Date()); |
|
416 |
saveParamList.add(daParamCollection); |
|
417 |
} |
|
418 |
} |
|
419 |
if (CollUtil.isNotEmpty(paramCollectionList4)){ |
|
420 |
for (int i = 0; i < paramCollectionList4.size(); i++) { |
|
421 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
422 |
if (CollUtil.isNotEmpty(keyCodeList) && keyCodeList.size() == 4){ |
|
423 |
daParamCollection.setKeyCode(keyCodeList.get(3)); |
|
424 |
} |
|
425 |
|
|
426 |
daParamCollection.setParamCode(paramCollectionList4.get(i).getIdentifier()); |
|
427 |
String paramValue = ""; |
|
428 |
if (ObjectUtil.isNotNull(paramCollectionList4.get(i).getValue())){ |
|
429 |
paramValue = paramCollectionList4.get(i).getValue().toString(); |
|
430 |
} |
|
431 |
daParamCollection.setParamValue(paramValue); |
|
432 |
daParamCollection.setLocationCode(device); |
|
433 |
daParamCollection.setCollectionTime(new Date()); |
|
434 |
saveParamList.add(daParamCollection); |
|
435 |
} |
|
436 |
} |
|
437 |
if (CollUtil.isNotEmpty(paramCollectionList0)){ |
|
438 |
for (int i = 0; i < paramCollectionList0.size(); i++) { |
|
439 |
if (CollUtil.isNotEmpty(keyCodeList) && keyCodeList.size() == 4){ |
|
440 |
for (String s : keyCodeList) { |
|
441 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
442 |
daParamCollection.setKeyCode(s); |
|
443 |
daParamCollection.setParamCode(paramCollectionList0.get(i).getIdentifier()); |
|
444 |
String paramValue = ""; |
|
445 |
if (ObjectUtil.isNotNull(paramCollectionList0.get(i).getValue())){ |
|
446 |
paramValue = paramCollectionList0.get(i).getValue().toString(); |
|
447 |
} |
|
448 |
daParamCollection.setParamValue(paramValue); |
|
449 |
daParamCollection.setLocationCode(device); |
|
450 |
daParamCollection.setCollectionTime(new Date()); |
|
451 |
saveParamList.add(daParamCollection); |
|
452 |
} |
|
453 |
} |
|
454 |
} |
|
455 |
} |
|
456 |
daParamCollectionService.insertBatch(saveParamList); |
|
457 |
} |
|
458 |
return passingList; |
|
459 |
} |
|
460 |
|
|
461 |
/** |
|
462 |
* 030工位返回ocv测试结果 |
|
463 |
* @param thoroughfare |
|
464 |
* @param device |
|
465 |
* @throws Exception |
|
466 |
*/ |
|
467 |
private boolean OCVResultFeedBack(String thoroughfare, String device) throws Exception { |
|
468 |
boolean flag = true; |
|
469 |
Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_1").getValue(); |
|
470 |
if (ObjectUtil.isNotNull(value1)){ |
|
471 |
String string = value1.toString(); |
|
472 |
List<DaParamCollection> list = daParamCollectionService.list(new LambdaQueryWrapper<DaParamCollection>() |
|
473 |
.eq(DaParamCollection::getKeyCode, string)); |
|
474 |
if (CollUtil.isNotEmpty(list)){ |
|
475 |
DaParamCollection daParamCollection = list.get(0); |
|
476 |
if (Constants.ONE.equals(daParamCollection.getState())){ |
|
477 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(1).build()); |
|
478 |
}else { |
|
479 |
flag = false; |
|
480 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); |
|
481 |
} |
|
482 |
} |
|
483 |
} |
|
484 |
Object value2 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_2").getValue(); |
|
485 |
if (ObjectUtil.isNotNull(value2)){ |
|
486 |
String string = value2.toString(); |
|
487 |
List<DaParamCollection> list = daParamCollectionService.list(new LambdaQueryWrapper<DaParamCollection>() |
|
488 |
.eq(DaParamCollection::getKeyCode, string)); |
|
489 |
if (CollUtil.isNotEmpty(list)){ |
|
490 |
DaParamCollection paramCollection = list.get(0); |
|
491 |
if (Constants.ONE.equals(paramCollection.getState())){ |
|
492 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(1).build()); |
|
493 |
}else { |
|
494 |
flag = false; |
|
495 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(2).build()); |
|
496 |
} |
|
497 |
} |
|
498 |
} |
|
499 |
Object value3 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_3").getValue(); |
|
500 |
if (ObjectUtil.isNotNull(value3)){ |
|
501 |
String string = value3.toString(); |
|
502 |
List<DaParamCollection> list = daParamCollectionService.list(new LambdaQueryWrapper<DaParamCollection>() |
|
503 |
.eq(DaParamCollection::getKeyCode, string)); |
|
504 |
if (CollUtil.isNotEmpty(list)){ |
|
505 |
DaParamCollection paramCollection = list.get(0); |
|
506 |
if (Constants.ONE.equals(paramCollection.getState())){ |
|
507 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(1).build()); |
|
508 |
}else { |
|
509 |
flag = false; |
|
510 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(2).build()); |
|
511 |
} |
|
512 |
} |
|
513 |
} |
|
514 |
Object value4 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_4").getValue(); |
|
515 |
if (ObjectUtil.isNotNull(value4)){ |
|
516 |
String string = value4.toString(); |
|
517 |
List<DaParamCollection> list = daParamCollectionService.list(new LambdaQueryWrapper<DaParamCollection>() |
|
518 |
.eq(DaParamCollection::getKeyCode, string)); |
|
519 |
if (CollUtil.isNotEmpty(list)){ |
|
520 |
DaParamCollection paramCollection = list.get(0); |
|
521 |
if (Constants.ONE.equals(paramCollection.getState())){ |
|
522 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(1).build()); |
|
523 |
}else { |
|
524 |
flag = false; |
|
525 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(2).build()); |
|
526 |
} |
|
527 |
} |
|
528 |
} |
|
529 |
return flag; |
|
530 |
} |
|
531 |
|
|
532 |
/** |
|
533 |
* 保存过站数据和参数保存数据 |
|
534 |
* @param device 工位号 |
|
535 |
* @throws Exception |
|
536 |
*/ |
|
537 |
private void saveParamPassingData(String device,String thoroughfare) throws Exception { |
|
538 |
|
|
539 |
//保存参数采集数据 |
|
540 |
List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
|
541 |
.eq(DaCollectionParamConf::getProcessesCode, device) |
|
542 |
.eq(DaCollectionParamConf::getRemarks, Constants.ONE)); |
|
543 |
if (CollUtil.isNotEmpty(list)){ |
|
544 |
List<String> collect = list.stream().map(DaCollectionParamConf::getGatherAddress) |
|
545 |
.filter(Objects::nonNull).distinct() |
|
546 |
.collect(Collectors.toList()); |
|
547 |
QueryPLCData(device,thoroughfare,collect); |
e6c837
|
548 |
|
A |
549 |
} |
|
550 |
} |
|
551 |
|
09ef66
|
552 |
/** |
W |
553 |
* 批量查询plc站点数据 |
|
554 |
* @param device 站点 |
|
555 |
* @param collect 点位 |
|
556 |
* @throws Exception |
|
557 |
*/ |
|
558 |
private static void QueryPLCData(String device,String thoroughfare,List<String> collect) throws Exception { |
|
559 |
List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(collect); |
|
560 |
|
|
561 |
if (CollUtil.isNotEmpty(readWriteEntityList)){ |
|
562 |
List<DaParamCollection> collectionList = new ArrayList<>(); |
|
563 |
Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); |
|
564 |
String moduleCode = null; |
|
565 |
if (ObjectUtil.isNotNull(value1)){ |
|
566 |
moduleCode = value1.toString(); |
|
567 |
} |
|
568 |
for (int i = 0; i < readWriteEntityList.size(); i++) { |
|
569 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
570 |
if (StrUtil.isNotBlank(moduleCode)){ |
|
571 |
daParamCollection.setModuleCode(moduleCode); |
|
572 |
} |
|
573 |
daParamCollection.setParamCode(collect.get(i)); |
|
574 |
String paramValue = ""; |
|
575 |
if (ObjectUtil.isNotNull(readWriteEntityList.get(i).getValue())){ |
|
576 |
paramValue = readWriteEntityList.get(i).getValue().toString(); |
|
577 |
} |
|
578 |
daParamCollection.setParamValue(paramValue); |
|
579 |
daParamCollection.setLocationCode(device); |
|
580 |
daParamCollection.setCollectionTime(new Date()); |
|
581 |
collectionList.add(daParamCollection); |
|
582 |
} |
|
583 |
daParamCollectionService.insertBatch(collectionList); |
|
584 |
} |
|
585 |
} |
e6c837
|
586 |
} |