提交 | 用户 | 时间
|
0ca254
|
1 |
package com.jcdm.main.plcserver.sub; |
A |
2 |
|
|
3 |
|
|
4 |
import cn.hutool.core.collection.CollUtil; |
|
5 |
import cn.hutool.core.util.ObjectUtil; |
|
6 |
import cn.hutool.core.util.StrUtil; |
109e2f
|
7 |
import cn.hutool.http.HttpRequest; |
C |
8 |
import cn.hutool.http.HttpResponse; |
ef58b9
|
9 |
import cn.hutool.json.JSONObject; |
109e2f
|
10 |
import cn.hutool.json.JSONUtil; |
0ca254
|
11 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
ef58b9
|
12 |
import com.jcdm.common.core.domain.AjaxResult; |
0ca254
|
13 |
import com.jcdm.framework.websocket.WebSocketUsers; |
A |
14 |
import com.jcdm.main.constant.Constants; |
|
15 |
import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf; |
|
16 |
import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; |
|
17 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
|
18 |
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; |
|
19 |
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
|
20 |
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; |
5b755f
|
21 |
import com.jcdm.main.da.testDeviceInterfaceTemp.domain.DaTestDeviceInterfaceTemp; |
C |
22 |
import com.jcdm.main.da.testDeviceInterfaceTemp.service.IDaTestDeviceInterfaceTempService; |
8c5c9c
|
23 |
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; |
0ca254
|
24 |
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; |
8c5c9c
|
25 |
import com.jcdm.main.plcserver.util.TimeUtil; |
ef58b9
|
26 |
import com.jcdm.main.restful.factoryMes.service.RestfulService; |
0ca254
|
27 |
import com.jcdm.main.restful.qingYan.doman.ChildVO; |
A |
28 |
import com.jcdm.main.restful.qingYan.doman.ParentVO; |
|
29 |
import com.kangaroohy.milo.model.ReadWriteEntity; |
|
30 |
import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
|
31 |
import com.kangaroohy.milo.service.MiloService; |
|
32 |
import lombok.extern.slf4j.Slf4j; |
109e2f
|
33 |
import org.springframework.beans.factory.annotation.Value; |
0ca254
|
34 |
import org.springframework.stereotype.Component; |
ef58b9
|
35 |
import org.springframework.web.bind.annotation.GetMapping; |
0ca254
|
36 |
|
A |
37 |
import javax.websocket.Session; |
|
38 |
import java.text.SimpleDateFormat; |
|
39 |
import java.util.*; |
109e2f
|
40 |
import java.util.concurrent.CompletableFuture; |
0ca254
|
41 |
import java.util.stream.Collectors; |
109e2f
|
42 |
|
0ca254
|
43 |
|
A |
44 |
@Slf4j |
|
45 |
@Component |
|
46 |
public class OPCUaSubscription implements SubscriptionCallback { |
|
47 |
|
8c5c9c
|
48 |
public static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
0ca254
|
49 |
|
A |
50 |
|
8c5c9c
|
51 |
Map<String, Session> map = WebSocketUsers.getUsers(); |
0ca254
|
52 |
public static MiloService miloService; |
A |
53 |
|
|
54 |
|
109e2f
|
55 |
public static IDaPassingStationCollectionService daPassingStationCollectionService; |
0ca254
|
56 |
|
A |
57 |
public static IDaCollectionParamConfService collectionParamConfService; |
|
58 |
|
|
59 |
public static IDaParamCollectionService daParamCollectionService; |
|
60 |
|
|
61 |
public static IOmProductionOrdeInfoService omProductionOrdeInfoService; |
|
62 |
|
5b755f
|
63 |
public static IDaTestDeviceInterfaceTempService daTestDeviceInterfaceTempService; |
C |
64 |
|
0d7433
|
65 |
/* @Value("${orderLineUrl}") |
C |
66 |
private static String orderLineUrl;*/ |
0ca254
|
67 |
|
A |
68 |
public OPCUaSubscription(MiloService miloService, |
|
69 |
IDaPassingStationCollectionService daPassingStationCollectionService, |
|
70 |
IDaCollectionParamConfService collectionParamConfService, |
|
71 |
IDaParamCollectionService daParamCollectionService, |
5b755f
|
72 |
IOmProductionOrdeInfoService omProductionOrdeInfoService, |
C |
73 |
IDaTestDeviceInterfaceTempService daTestDeviceInterfaceTempService) { |
0ca254
|
74 |
OPCUaSubscription.miloService = miloService; |
109e2f
|
75 |
OPCUaSubscription.daPassingStationCollectionService = daPassingStationCollectionService; |
0ca254
|
76 |
OPCUaSubscription.collectionParamConfService = collectionParamConfService; |
A |
77 |
OPCUaSubscription.daParamCollectionService = daParamCollectionService; |
|
78 |
OPCUaSubscription.omProductionOrdeInfoService = omProductionOrdeInfoService; |
5b755f
|
79 |
OPCUaSubscription.daTestDeviceInterfaceTempService = daTestDeviceInterfaceTempService; |
0ca254
|
80 |
} |
A |
81 |
|
|
82 |
|
|
83 |
@Override |
|
84 |
public void onSubscribe(String identifier, Object value) { |
109e2f
|
85 |
log.info("地址:"+identifier+"值:"+value); |
0ca254
|
86 |
try { |
109e2f
|
87 |
if(null != value && !Constants.ZERO.equals(value.toString())) { |
0ca254
|
88 |
String[] nodes = identifier.split("[.]"); |
A |
89 |
String thoroughfare = nodes[0];//通道 |
|
90 |
String device = nodes[1];//设备 |
|
91 |
String tab = nodes[2];//标记 |
109e2f
|
92 |
String valueString = value.toString();//地址值 |
C |
93 |
if (Constants.RECORD_CHECK_CODE.equals(tab)){//电芯校验 |
|
94 |
if (Constants.ONE.equals(valueString)){ |
|
95 |
Integer scanResult = 11; |
ec7e2a
|
96 |
if (Constants.OP010.equals(device)){ |
109e2f
|
97 |
//OP010工位电芯条码校验||OP030工位电芯条码校验 |
C |
98 |
Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".Scaner").getValue(); |
|
99 |
if (ObjectUtil.isNotNull(value1)){ |
|
100 |
String keyCode = value1.toString(); |
|
101 |
log.info("读取到工位{}的Scaner数据:{}",device,keyCode); |
|
102 |
//仅校验长度是否合格 |
|
103 |
// List<KeyCodeCheck> collect = keyCodeCheckService.list().stream().filter(x -> x.getKeyCode().contains(keyCode)).collect(Collectors.toList()); |
|
104 |
// if (CollUtil.isNotEmpty(collect)){ |
|
105 |
// scanResult = 11; |
0ca254
|
106 |
// } |
A |
107 |
} |
ec7e2a
|
108 |
}else if(Constants.OP030.equals(device)){ |
C |
109 |
Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".Scaner").getValue(); |
|
110 |
if (ObjectUtil.isNotNull(value1)){ |
|
111 |
String cellCode = value1.toString(); |
|
112 |
//反馈电芯ocv检测结果 |
|
113 |
boolean b = OCVResultFeedBack(thoroughfare, device,cellCode); |
|
114 |
//四个电芯的状态 |
|
115 |
if (b){ |
|
116 |
scanResult = 11; |
|
117 |
}else { |
|
118 |
scanResult = 12; |
|
119 |
} |
|
120 |
}else { |
|
121 |
scanResult = 12; |
|
122 |
} |
|
123 |
|
0ca254
|
124 |
} |
109e2f
|
125 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult1").value(scanResult).build()); |
C |
126 |
log.info("写入到工位{}的ScanerResult1数据:{}",device,scanResult); |
0ca254
|
127 |
} |
109e2f
|
128 |
}else if (Constants.RECORD_SN.equals(tab)){//求下发模组码请9 |
C |
129 |
if (Constants.ONE.equals(valueString)){ |
ec7e2a
|
130 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build());//没有要生产的工单 |
109e2f
|
131 |
} |
C |
132 |
}else if (Constants.RECORD_DATA.equals(tab)){//出入站 |
|
133 |
if (Constants.ONE.equals(valueString)){//入站 |
|
134 |
//1:告知MES托盘已到站,请求下发进站状态 |
|
135 |
if (Constants.OP030.equals(device)){ |
|
136 |
//反馈电芯ocv检测结果 |
5b755f
|
137 |
boolean b = OCVResultFeedBack(thoroughfare, device); |
2de856
|
138 |
//四个电芯的状态 |
109e2f
|
139 |
if (b){ |
C |
140 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); |
|
141 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,11); |
|
142 |
}else { |
|
143 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); |
|
144 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,12); |
|
145 |
} |
ef58b9
|
146 |
} else if(Constants.OP100_1.equals(device) || Constants.OP100_2.equals(device)){ |
C |
147 |
//1、进站PLC给产品类型,MES读取产品类型 |
aa8ab9
|
148 |
ReadWriteEntity productTypeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".ProductType");//产品类型 |
ef58b9
|
149 |
if (ObjectUtil.isNotNull(productTypeRead.getValue())){ |
C |
150 |
String productType = productTypeRead.getValue().toString(); |
|
151 |
|
|
152 |
CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
4878fe
|
153 |
//调用工厂MES,保存到数据库,并且将工单传给PLC (目前临时用该方法) |
ef58b9
|
154 |
receivingWorkOrders(thoroughfare, device); |
C |
155 |
}); |
|
156 |
|
|
157 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); |
|
158 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,11); |
|
159 |
|
|
160 |
}else{ |
|
161 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); |
|
162 |
} |
|
163 |
|
|
164 |
}else { |
109e2f
|
165 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); |
C |
166 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,11); |
|
167 |
} |
|
168 |
}else if (Constants.TWO.equals(valueString)){//出站 |
|
169 |
//分段010-065段 |
|
170 |
if (Constants.OP010.equals(device)){ |
|
171 |
//010工位无过站记录,只给放行信号 |
|
172 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build()); |
|
173 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,21); |
aa8ab9
|
174 |
}else if (Constants.OP020_OP090.contains(device)){ |
109e2f
|
175 |
Integer result = 21; |
C |
176 |
//读取电芯码 |
|
177 |
List<String> cellCodeList = readCellCodeList(thoroughfare, device); |
8c5c9c
|
178 |
if(ObjectUtil.isNull(cellCodeList) || cellCodeList.size() != 4){ |
109e2f
|
179 |
result = 23; |
C |
180 |
}else{ |
|
181 |
result = savePassingStation(thoroughfare, device,cellCodeList);//保存过站 |
2de856
|
182 |
if(result == 21) { |
109e2f
|
183 |
result = saveParamCollection(thoroughfare, device,cellCodeList);//保存参数,发送工厂MES |
C |
184 |
} |
|
185 |
} |
|
186 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build()); |
|
187 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,result); |
|
188 |
} else if (Constants.OP100_1.equals(device) || Constants.OP100_2.equals(device)){ |
8c5c9c
|
189 |
|
2de856
|
190 |
WebSocketUsers.sendMessageToUserByText(map.get(device), "END"); |
109e2f
|
191 |
} else { |
2de856
|
192 |
Integer result = 21; |
C |
193 |
Object modulCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); |
|
194 |
if (ObjectUtil.isNull(modulCodeObjcet) && modulCodeObjcet.toString().trim().isEmpty()){ |
|
195 |
result = 23; |
|
196 |
}else{ |
|
197 |
String moduleCode = modulCodeObjcet.toString(); |
|
198 |
result = savePassingStation(thoroughfare, device,moduleCode);//保存过站 |
|
199 |
if(result == 21) { |
|
200 |
result = saveParamCollection(thoroughfare, device,moduleCode);//保存参数,发送工厂MES |
109e2f
|
201 |
} |
C |
202 |
} |
2de856
|
203 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build()); |
C |
204 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,result); |
0ca254
|
205 |
} |
109e2f
|
206 |
} |
8c5c9c
|
207 |
} /*else if (Constants.RECORD_CHECK_CODE_1.equals(tab)) { |
109e2f
|
208 |
if (Constants.OP100_1.equals(device)){ |
C |
209 |
//钢带条码校验--发送给工厂mes |
|
210 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult11").value(11).build()); |
|
211 |
} else if (Constants.OP100_2.equals(device)) { |
|
212 |
//PET带条码校验--发送给工厂mes |
|
213 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult12").value(11).build()); |
0ca254
|
214 |
} |
8c5c9c
|
215 |
}*/ |
0ca254
|
216 |
} |
A |
217 |
} catch (Exception e) { |
8c5c9c
|
218 |
log.error(e.getMessage()); |
109e2f
|
219 |
System.out.println(e.getMessage()); |
C |
220 |
log.info(e.getMessage()); |
0ca254
|
221 |
} |
A |
222 |
} |
|
223 |
|
ef58b9
|
224 |
public void receivingWorkOrders(String thoroughfare ,String device) |
4878fe
|
225 |
{ |
C |
226 |
String paramProductNum = ""; |
|
227 |
try { |
|
228 |
|
|
229 |
List<OmProductionOrdeInfo> orderList = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>() |
|
230 |
.eq(OmProductionOrdeInfo::getOrderStatus, Constants.ONE));//工单状态 |
|
231 |
|
|
232 |
if (CollUtil.isNotEmpty(orderList)){ |
|
233 |
Long id = orderList.get(0).getId(); |
|
234 |
String productNum = orderList.get(0).getProductNum();//模组码 |
|
235 |
//下发产品模组码 |
|
236 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MES_ModuleCode").value(productNum).build()); |
|
237 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MES_WorkOrderNumber").value(productNum).build()); |
|
238 |
//miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build()); |
|
239 |
|
|
240 |
//更新工单状态为执行中 |
|
241 |
OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo(); |
|
242 |
omProductionOrdeInfo.setId(id); |
|
243 |
omProductionOrdeInfo.setOrderStatus("3"); |
|
244 |
omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo); |
|
245 |
|
|
246 |
//将产品SN发送到前台 |
|
247 |
productNum = "productNum,"+ productNum; |
|
248 |
WebSocketUsers.sendMessageToUserByText(map.get(device), productNum); |
|
249 |
}/*else{ |
|
250 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(2).build());//没有要生产的工单 |
|
251 |
}*/ |
|
252 |
} catch (Exception e) { |
|
253 |
throw new RuntimeException(e); |
|
254 |
} |
|
255 |
} |
|
256 |
|
|
257 |
/* public void receivingWorkOrders(String thoroughfare ,String device) |
ef58b9
|
258 |
{ |
C |
259 |
String paramProductNum = ""; |
|
260 |
try { |
|
261 |
// 查询最新的工单信息 |
22c9e0
|
262 |
OmProductionOrdeInfo lastOrder = omProductionOrdeInfoService.getLastOrder(); |
4878fe
|
263 |
String orderJsonString = RestfulService.getProductionWorkOrderRequest(lastOrder.getProductNum(), "M1OP100"); |
ef58b9
|
264 |
JSONObject jsonObject = new JSONObject(orderJsonString); |
C |
265 |
// 从JSONObject中获取data对象 |
|
266 |
JSONObject dataObject = jsonObject.getJSONObject("data"); |
|
267 |
String code = jsonObject.getStr("code"); |
|
268 |
// 判断接单是否成功 |
|
269 |
if(code.equals("success")) { |
|
270 |
log.info("请求工厂MES工单:入参pack{}出参pack:{}", paramProductNum, dataObject.getStr("productNum")); |
|
271 |
OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo(); |
|
272 |
omProductionOrdeInfo.setWorkOrderNo(dataObject.getStr("productionOrderNum")); |
|
273 |
omProductionOrdeInfo.setProductNum(dataObject.getStr("productNum")); |
|
274 |
omProductionOrdeInfo.setStationCode(dataObject.getStr("stationCode")); |
|
275 |
omProductionOrdeInfo.setMaterialCode(dataObject.getStr("materialCode")); |
|
276 |
omProductionOrdeInfo.setOnlineCompletionMark("0"); |
|
277 |
omProductionOrdeInfo.setSfResult("0"); |
|
278 |
omProductionOrdeInfo.setProductCode(dataObject.getStr("model")); |
|
279 |
omProductionOrdeInfo.setCreateTime(new Date()); |
|
280 |
omProductionOrdeInfo.setCreateUser("工厂MES"); |
|
281 |
omProductionOrdeInfoService.save(omProductionOrdeInfo); |
|
282 |
|
|
283 |
//发送给前台 |
|
284 |
WebSocketUsers.sendMessageToUserByText(map.get(device), dataObject.getStr("productNum")); |
|
285 |
|
|
286 |
//写PLC |
|
287 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MES_ModuleCode").value(dataObject.getStr("productNum")).build()); |
|
288 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MES_WorkOrderNumber").value(dataObject.getStr("productionOrderNum")).build()); |
|
289 |
|
|
290 |
} |
|
291 |
} catch (Exception e) { |
|
292 |
throw new RuntimeException(e); |
|
293 |
} |
4878fe
|
294 |
}*/ |
0ca254
|
295 |
|
A |
296 |
/** |
109e2f
|
297 |
* 读取电芯码 |
C |
298 |
* @param thoroughfare 通道 |
|
299 |
* @param device 工位 |
|
300 |
* @return list |
|
301 |
* @throws Exception e |
0ca254
|
302 |
*/ |
109e2f
|
303 |
private static List<String> readCellCodeList(String thoroughfare, String device){ |
C |
304 |
List<String> cellCodeList = new ArrayList<>(); |
2de856
|
305 |
Map map = new HashMap(); |
109e2f
|
306 |
//电芯码地址 |
C |
307 |
List<String> readList = new ArrayList<>(); |
|
308 |
readList.add(thoroughfare + "." + device +".CellCode_1"); |
|
309 |
readList.add(thoroughfare + "." + device +".CellCode_2"); |
|
310 |
readList.add(thoroughfare + "." + device +".CellCode_3"); |
|
311 |
readList.add(thoroughfare + "." + device +".CellCode_4"); |
0ca254
|
312 |
try { |
109e2f
|
313 |
List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(readList);//电芯码 |
C |
314 |
for (ReadWriteEntity readWriteEntity : readWriteEntityList) { |
2de856
|
315 |
if (ObjectUtil.isNotNull(readWriteEntity.getValue()) && !"".equals(readWriteEntity.getValue().toString().trim())){ |
C |
316 |
cellCodeList.add(readWriteEntity.getValue().toString());//封装电芯码 |
18b39c
|
317 |
}/*else{ |
2de856
|
318 |
cellCodeList.add("");//封装电芯码 |
18b39c
|
319 |
}*/ |
0ca254
|
320 |
} |
2de856
|
321 |
|
0ca254
|
322 |
} catch (Exception e) { |
A |
323 |
throw new RuntimeException(e); |
|
324 |
} |
109e2f
|
325 |
return cellCodeList; |
2de856
|
326 |
} |
C |
327 |
|
|
328 |
|
|
329 |
/** |
|
330 |
* 保存过站数据 |
|
331 |
* @param thoroughfare 通道 |
|
332 |
* @param device 工位 |
|
333 |
* @param moduleCode 模组号 |
|
334 |
* @return list |
|
335 |
* @throws Exception e |
|
336 |
*/ |
|
337 |
private static Integer savePassingStation(String thoroughfare, String device,String moduleCode){ |
|
338 |
Integer result = 21; |
|
339 |
|
|
340 |
try { |
|
341 |
//读进站时间 |
|
342 |
Date startTime = new Date(); |
|
343 |
ReadWriteEntity startTimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StartTime");//进站时间 |
|
344 |
if (ObjectUtil.isNotNull(startTimeRead.getValue())){ |
|
345 |
startTime = format.parse(TimeUtil.test(TimeUtil.stringProcessing(startTimeRead.getValue().toString()))); |
|
346 |
}else{ |
|
347 |
result = 23; |
|
348 |
log.info("读取到工位{}的StartTime数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result); |
|
349 |
return result; |
|
350 |
} |
|
351 |
|
|
352 |
//读工站状态 |
|
353 |
String stationStatus = Constants.PASS; |
|
354 |
ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus");//站状态地址 |
|
355 |
if (ObjectUtil.isNotNull(stationStatusRead.getValue())){ |
|
356 |
String string = stationStatusRead.getValue().toString(); |
|
357 |
if (Constants.TWO.equals(string)){ |
|
358 |
stationStatus = Constants.UN_PASS; |
|
359 |
} |
|
360 |
}else{ |
|
361 |
result = 23; |
|
362 |
log.info("读取到工位{}StationStatus数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result); |
|
363 |
return result; |
|
364 |
} |
|
365 |
|
|
366 |
DaPassingStationCollection passingStationCollection = new DaPassingStationCollection(); |
|
367 |
passingStationCollection.setSfcCode(moduleCode);//电芯码 |
|
368 |
passingStationCollection.setLocationCode(device);//工位 |
|
369 |
passingStationCollection.setInboundTime(startTime);//进站时间 |
|
370 |
passingStationCollection.setOutboundTime(new Date());//出站时间 |
|
371 |
passingStationCollection.setOutRsSign(stationStatus);//站状态值 |
|
372 |
passingStationCollection.setCollectionTime(new Date());//采集时间 |
|
373 |
daPassingStationCollectionService.save(passingStationCollection); |
|
374 |
|
|
375 |
} catch (Exception e) { |
|
376 |
throw new RuntimeException(e); |
|
377 |
} |
|
378 |
|
|
379 |
return result; |
0ca254
|
380 |
} |
A |
381 |
|
109e2f
|
382 |
/** |
C |
383 |
* 保存过站数据 |
|
384 |
* @param thoroughfare 通道 |
|
385 |
* @param device 工位 |
|
386 |
* @param cellCodeList 电芯码集合 |
|
387 |
* @return list |
|
388 |
* @throws Exception e |
|
389 |
*/ |
|
390 |
private static Integer savePassingStation(String thoroughfare, String device,List<String> cellCodeList){ |
|
391 |
Integer result = 21; |
|
392 |
|
|
393 |
try { |
|
394 |
//读进站时间 |
|
395 |
Date startTime = new Date(); |
|
396 |
ReadWriteEntity startTimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StartTime");//进站时间 |
|
397 |
if (ObjectUtil.isNotNull(startTimeRead.getValue())){ |
8c5c9c
|
398 |
startTime = format.parse(TimeUtil.test(TimeUtil.stringProcessing(startTimeRead.getValue().toString()))); |
109e2f
|
399 |
}else{ |
C |
400 |
result = 23; |
|
401 |
log.info("读取到工位{}的StartTime数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result); |
2de856
|
402 |
return result; |
109e2f
|
403 |
} |
C |
404 |
|
|
405 |
//读工站状态 |
|
406 |
String stationStatus = Constants.PASS; |
|
407 |
ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus");//站状态地址 |
|
408 |
if (ObjectUtil.isNotNull(stationStatusRead.getValue())){ |
|
409 |
String string = stationStatusRead.getValue().toString(); |
|
410 |
if (Constants.TWO.equals(string)){ |
|
411 |
stationStatus = Constants.UN_PASS; |
|
412 |
} |
|
413 |
}else{ |
|
414 |
result = 23; |
2de856
|
415 |
log.info("读取到工位{}StationStatus数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result); |
C |
416 |
return result; |
109e2f
|
417 |
} |
C |
418 |
|
|
419 |
List<DaPassingStationCollection> passingList = new ArrayList<>(); |
|
420 |
for (String cellCode : cellCodeList) { |
|
421 |
DaPassingStationCollection passingStationCollection = new DaPassingStationCollection(); |
2de856
|
422 |
if (ObjectUtil.isNotNull(cellCode) && !cellCode.isEmpty()){ |
109e2f
|
423 |
passingStationCollection.setSfcCode(cellCode);//电芯码 |
C |
424 |
passingStationCollection.setLocationCode(device);//工位 |
|
425 |
passingStationCollection.setInboundTime(startTime);//进站时间 |
|
426 |
passingStationCollection.setOutboundTime(new Date());//出站时间 |
|
427 |
passingStationCollection.setOutRsSign(stationStatus);//站状态值 |
|
428 |
passingStationCollection.setCollectionTime(new Date());//采集时间 |
|
429 |
passingList.add(passingStationCollection); |
|
430 |
} |
|
431 |
} |
|
432 |
|
|
433 |
if (CollUtil.isNotEmpty(passingList)){ |
|
434 |
daPassingStationCollectionService.insertBatch(passingList);//存储过站采集数据 |
|
435 |
} |
|
436 |
|
|
437 |
} catch (Exception e) { |
|
438 |
throw new RuntimeException(e); |
|
439 |
} |
|
440 |
|
|
441 |
return result; |
|
442 |
} |
|
443 |
|
2de856
|
444 |
|
109e2f
|
445 |
/** |
2de856
|
446 |
* 保存参数数据和发送工厂MES |
C |
447 |
* @param thoroughfare 通道 |
|
448 |
* @param device 工位 |
|
449 |
* @param moduleCode 模组号 |
|
450 |
* @return list |
|
451 |
* @throws Exception e |
|
452 |
*/ |
|
453 |
private static Integer saveParamCollection(String thoroughfare, String device,String moduleCode){ |
|
454 |
Integer result = 21;//返回结果 |
5c62de
|
455 |
String sendMes = ""; |
2de856
|
456 |
|
C |
457 |
try { |
|
458 |
//查询参数配置表 |
|
459 |
List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
|
460 |
.eq(DaCollectionParamConf::getProcessesCode, device)//工位 |
|
461 |
.eq(DaCollectionParamConf::getWhetherToCollect, Constants.ONE)//是否采集 |
|
462 |
); |
|
463 |
if (CollUtil.isNotEmpty(list)){ |
|
464 |
|
|
465 |
List<String> collect = list.stream() |
|
466 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
467 |
List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(collect); |
|
468 |
|
|
469 |
List<DaParamCollection> collectionList = new ArrayList<>(); |
|
470 |
List<ChildVO> mesList = new ArrayList<>(); |
|
471 |
for (int i = 0; i < readWriteEntityList.size(); i++) { |
|
472 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
473 |
daParamCollection.setSfcCode(moduleCode);//模组码 |
|
474 |
daParamCollection.setParamCode(list.get(i).getCollectParameterId());//参数编码 |
|
475 |
daParamCollection.setParamName(list.get(i).getCollectParameterName());//参数名称 |
|
476 |
String paramValue = ""; |
|
477 |
if (ObjectUtil.isNotNull(readWriteEntityList.get(i).getValue())){ |
|
478 |
paramValue = readWriteEntityList.get(i).getValue().toString();//参数值 |
|
479 |
} |
|
480 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
481 |
daParamCollection.setLocationCode(device);//工位 |
|
482 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
483 |
collectionList.add(daParamCollection);//封装参数采集list |
|
484 |
|
|
485 |
//发送给工厂mes参数封装 |
|
486 |
ChildVO childVO = new ChildVO(); |
|
487 |
childVO.setItemCode(list.get(i).getCollectParameterId());//参数编码 |
|
488 |
childVO.setItemType(list.get(i).getItemType()); |
|
489 |
childVO.setItemValue(paramValue);//参数值 |
|
490 |
childVO.setItemText(list.get(i).getCollectParameterName()); |
|
491 |
childVO.setCheckResult("1"); |
|
492 |
childVO.setCheckTime(new Date().toString()); |
|
493 |
mesList.add(childVO); |
|
494 |
} |
|
495 |
|
|
496 |
CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
|
497 |
//插入参数采集表 |
|
498 |
daParamCollectionService.insertBatch(collectionList); |
|
499 |
//上传到工厂mes |
|
500 |
ParentVO parentVO = new ParentVO(); |
|
501 |
parentVO.setStationCode(device);//工位 |
|
502 |
parentVO.setSiteCode("3983"); |
|
503 |
|
|
504 |
parentVO.setRecordId(UUID.randomUUID().toString()); |
|
505 |
parentVO.setTotalResult("1"); |
|
506 |
parentVO.setProductNum(moduleCode); |
|
507 |
parentVO.setCheckList(mesList); |
|
508 |
|
|
509 |
log.info("执行工厂MES方法start,传入数据:{}",parentVO); |
20635f
|
510 |
HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute(); |
2de856
|
511 |
log.info("执行工厂MES方法end,返回数据:{}",execute.body()); |
C |
512 |
|
|
513 |
}); |
|
514 |
} |
|
515 |
}catch (Exception e) { |
|
516 |
throw new RuntimeException(e); |
|
517 |
} |
|
518 |
return result; |
|
519 |
} |
|
520 |
|
|
521 |
/** |
|
522 |
* 保存参数数据和发送工厂MES |
109e2f
|
523 |
* @param thoroughfare 通道 |
C |
524 |
* @param device 工位 |
|
525 |
* @param cellCodeList 电芯码集合 |
|
526 |
* @return list |
|
527 |
* @throws Exception e |
|
528 |
*/ |
|
529 |
private static Integer saveParamCollection(String thoroughfare, String device,List<String> cellCodeList){ |
|
530 |
Integer result = 21;//返回结果 |
743e2e
|
531 |
List<ChildVO> mesChildList1 = new ArrayList<>();//封装给工厂MES发送的childlist1 |
C |
532 |
List<ChildVO> mesChildList2 = new ArrayList<>();//封装给工厂MES发送的childlist2 |
|
533 |
List<ChildVO> mesChildList3 = new ArrayList<>();//封装给工厂MES发送的childlist3 |
|
534 |
List<ChildVO> mesChildList4 = new ArrayList<>();//封装给工厂MES发送的childlist4 |
|
535 |
List<ChildVO> mesChildList0 = new ArrayList<>();//封装给工厂MES发送的childlist4 |
109e2f
|
536 |
try { |
C |
537 |
//查询参数配置表 |
|
538 |
List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
|
539 |
.eq(DaCollectionParamConf::getProcessesCode, device)//工位 |
8c5c9c
|
540 |
.eq(DaCollectionParamConf::getWhetherToCollect, Constants.ONE)//是否采集 |
2de856
|
541 |
);//类型 |
109e2f
|
542 |
if (CollUtil.isNotEmpty(list)) { |
C |
543 |
List<DaParamCollection> saveParamList = new ArrayList<>();//封装参数采集list |
|
544 |
List<DaCollectionParamConf> confColl1 = list.stream().filter(x -> Constants.INT_ONE.equals(x.getKeyNum())).collect(Collectors.toList()); |
|
545 |
List<DaCollectionParamConf> confColl2 = list.stream().filter(x -> Constants.INT_TWO.equals(x.getKeyNum())).collect(Collectors.toList()); |
|
546 |
List<DaCollectionParamConf> confColl3 = list.stream().filter(x -> Constants.INT_THREE.equals(x.getKeyNum())).collect(Collectors.toList()); |
|
547 |
List<DaCollectionParamConf> confColl4 = list.stream().filter(x -> Constants.INT_FOUR.equals(x.getKeyNum())).collect(Collectors.toList()); |
|
548 |
List<DaCollectionParamConf> confColl0 = list.stream().filter(x -> Constants.INT_ZERO.equals(x.getKeyNum())).collect(Collectors.toList()); |
|
549 |
|
|
550 |
List<String> collect1 = confColl1.stream() |
|
551 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
552 |
List<ReadWriteEntity> paramCollectionList1 = miloService.readFromOpcUa(collect1);//电芯1 参数值 |
|
553 |
|
|
554 |
List<String> collect2 = confColl2.stream() |
|
555 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
556 |
List<ReadWriteEntity> paramCollectionList2 = miloService.readFromOpcUa(collect2);//电芯2 参数值 |
|
557 |
|
|
558 |
List<String> collect3 = confColl3.stream() |
|
559 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
560 |
List<ReadWriteEntity> paramCollectionList3 = miloService.readFromOpcUa(collect3);//电芯3 参数值 |
|
561 |
|
|
562 |
List<String> collect4 = confColl4.stream() |
|
563 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
564 |
List<ReadWriteEntity> paramCollectionList4 = miloService.readFromOpcUa(collect4);//电芯4 参数值 |
|
565 |
|
|
566 |
List<String> collect0 = confColl0.stream() |
|
567 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
568 |
List<ReadWriteEntity> paramCollectionList0 = miloService.readFromOpcUa(collect0);//电芯 参数值 |
|
569 |
|
|
570 |
//第一个电芯的数据 |
2de856
|
571 |
if (CollUtil.isNotEmpty(paramCollectionList1) && !cellCodeList.get(0).isEmpty()) { |
109e2f
|
572 |
for (int i = 0; i < paramCollectionList1.size(); i++) { |
C |
573 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
574 |
daParamCollection.setSfcCode(cellCodeList.get(0));//电芯码 |
|
575 |
daParamCollection.setParamCode(confColl1.get(i).getCollectParameterId());//参数编码 |
|
576 |
daParamCollection.setParamName(confColl1.get(i).getCollectParameterName());//参数名称 |
|
577 |
String paramValue = ""; |
|
578 |
if (ObjectUtil.isNotNull(paramCollectionList1.get(i).getValue())) { |
|
579 |
paramValue = paramCollectionList1.get(i).getValue().toString();//参数值 |
|
580 |
} |
|
581 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
582 |
daParamCollection.setLocationCode(device);//工位 |
|
583 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
584 |
saveParamList.add(daParamCollection);//封装参数采集list |
|
585 |
|
|
586 |
//发送给工厂mes参数封装 |
|
587 |
ChildVO childVO = new ChildVO(); |
|
588 |
childVO.setItemCode(confColl1.get(i).getCollectParameterName());//参数 |
|
589 |
childVO.setItemType(confColl1.get(i).getItemType()); |
|
590 |
childVO.setItemValue(paramValue);//参数值 |
|
591 |
childVO.setItemText(confColl1.get(i).getParameterSetName()); |
|
592 |
childVO.setCheckResult("1"); |
|
593 |
childVO.setCheckTime(new Date().toString()); |
|
594 |
mesChildList1.add(childVO); |
|
595 |
} |
743e2e
|
596 |
|
109e2f
|
597 |
} |
2de856
|
598 |
if (CollUtil.isNotEmpty(paramCollectionList2) && !cellCodeList.get(1).isEmpty()) { |
109e2f
|
599 |
|
C |
600 |
for (int i = 0; i < paramCollectionList2.size(); i++) { |
|
601 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
602 |
daParamCollection.setSfcCode(cellCodeList.get(1));//电芯码 |
|
603 |
daParamCollection.setParamCode(confColl2.get(i).getCollectParameterId());//参数编码 |
|
604 |
daParamCollection.setParamName(confColl2.get(i).getCollectParameterName());//参数名称 |
|
605 |
String paramValue = ""; |
|
606 |
if (ObjectUtil.isNotNull(paramCollectionList2.get(i).getValue())) { |
|
607 |
paramValue = paramCollectionList2.get(i).getValue().toString();//参数值 |
|
608 |
} |
|
609 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
610 |
daParamCollection.setLocationCode(device);//工位 |
|
611 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
612 |
saveParamList.add(daParamCollection);//封装参数采集list |
|
613 |
|
|
614 |
//发送给工厂mes参数封装 |
|
615 |
ChildVO childVO = new ChildVO(); |
|
616 |
childVO.setItemCode(confColl2.get(i).getCollectParameterName());//参数 |
|
617 |
childVO.setItemType(confColl2.get(i).getItemType()); |
|
618 |
childVO.setItemValue(paramValue);//参数值 |
|
619 |
childVO.setItemText(confColl2.get(i).getParameterSetName()); |
|
620 |
childVO.setCheckResult("1"); |
|
621 |
childVO.setCheckTime(new Date().toString()); |
|
622 |
mesChildList2.add(childVO); |
|
623 |
} |
|
624 |
} |
2de856
|
625 |
if (CollUtil.isNotEmpty(paramCollectionList3) && !cellCodeList.get(2).isEmpty()) { |
109e2f
|
626 |
for (int i = 0; i < paramCollectionList3.size(); i++) { |
C |
627 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
628 |
daParamCollection.setSfcCode(cellCodeList.get(2));//电芯码 |
|
629 |
daParamCollection.setParamCode(confColl3.get(i).getCollectParameterId());//参数编码 |
|
630 |
daParamCollection.setParamName(confColl3.get(i).getCollectParameterName());//参数名称 |
|
631 |
String paramValue = ""; |
|
632 |
if (ObjectUtil.isNotNull(paramCollectionList3.get(i).getValue())) { |
|
633 |
paramValue = paramCollectionList3.get(i).getValue().toString();//参数值 |
|
634 |
} |
|
635 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
636 |
daParamCollection.setLocationCode(device);//工位 |
|
637 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
638 |
saveParamList.add(daParamCollection);//封装参数采集list |
|
639 |
|
|
640 |
//发送给工厂mes参数封装 |
|
641 |
ChildVO childVO = new ChildVO(); |
|
642 |
childVO.setItemCode(confColl3.get(i).getCollectParameterName());//参数 |
|
643 |
childVO.setItemType(confColl3.get(i).getItemType()); |
|
644 |
childVO.setItemValue(paramValue);//参数值 |
|
645 |
childVO.setItemText(confColl3.get(i).getParameterSetName()); |
|
646 |
childVO.setCheckResult("1"); |
|
647 |
childVO.setCheckTime(new Date().toString()); |
|
648 |
mesChildList3.add(childVO); |
|
649 |
} |
|
650 |
} |
2de856
|
651 |
if (CollUtil.isNotEmpty(paramCollectionList4)&& !cellCodeList.get(3).isEmpty()) { |
109e2f
|
652 |
for (int i = 0; i < paramCollectionList4.size(); i++) { |
C |
653 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
654 |
daParamCollection.setSfcCode(cellCodeList.get(3));//电芯码 |
|
655 |
daParamCollection.setParamCode(confColl4.get(i).getCollectParameterId());//参数编码 |
|
656 |
daParamCollection.setParamName(confColl4.get(i).getCollectParameterName());//参数名称 |
|
657 |
String paramValue = ""; |
|
658 |
if (ObjectUtil.isNotNull(paramCollectionList4.get(i).getValue())) { |
|
659 |
paramValue = paramCollectionList4.get(i).getValue().toString();//参数值 |
|
660 |
} |
|
661 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
662 |
daParamCollection.setLocationCode(device);//工位 |
|
663 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
664 |
saveParamList.add(daParamCollection);//封装参数采集list |
|
665 |
|
|
666 |
//发送给工厂mes参数封装 |
|
667 |
ChildVO childVO = new ChildVO(); |
|
668 |
childVO.setItemCode(confColl4.get(i).getCollectParameterName());//参数 |
|
669 |
childVO.setItemType(confColl4.get(i).getItemType()); |
|
670 |
childVO.setItemValue(paramValue);//参数值 |
|
671 |
childVO.setItemText(confColl4.get(i).getParameterSetName()); |
|
672 |
childVO.setCheckResult("1"); |
|
673 |
childVO.setCheckTime(new Date().toString()); |
|
674 |
mesChildList4.add(childVO); |
|
675 |
} |
|
676 |
} |
|
677 |
|
|
678 |
//公共参数 |
|
679 |
if (CollUtil.isNotEmpty(paramCollectionList0)) { |
|
680 |
for (int i = 0; i < cellCodeList.size(); i++) {//循环4个电芯 |
2de856
|
681 |
if(!cellCodeList.get(i).isEmpty()){ |
C |
682 |
for (int j = 0; j < paramCollectionList0.size(); j++) { |
|
683 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
684 |
daParamCollection.setSfcCode(cellCodeList.get(i));//电芯码 |
|
685 |
daParamCollection.setParamCode(confColl0.get(j).getCollectParameterId());//参数编码 |
|
686 |
daParamCollection.setParamName(confColl0.get(j).getCollectParameterName());//参数名称 |
|
687 |
String paramValue = ""; |
|
688 |
if (ObjectUtil.isNotNull(paramCollectionList0.get(j).getValue())) { |
|
689 |
paramValue = paramCollectionList0.get(j).getValue().toString();//参数值 |
|
690 |
} |
|
691 |
if(confColl0.get(j).getCollectParameterName().contains("时间") && !"".equals(paramValue)){ |
|
692 |
paramValue = format.parse(TimeUtil.test(TimeUtil.stringProcessing(paramValue))).toString(); |
|
693 |
} |
|
694 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
695 |
daParamCollection.setLocationCode(device);//工位 |
|
696 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
697 |
saveParamList.add(daParamCollection); |
109e2f
|
698 |
|
2de856
|
699 |
//发送给工厂mes参数封装 |
C |
700 |
ChildVO childVO = new ChildVO(); |
|
701 |
childVO.setItemCode(confColl0.get(j).getCollectParameterName());//参数 |
|
702 |
childVO.setItemType(confColl0.get(j).getItemType()); |
|
703 |
childVO.setItemValue(paramValue);//参数值 |
|
704 |
childVO.setItemText(confColl0.get(j).getParameterSetName()); |
|
705 |
childVO.setCheckResult("1"); |
|
706 |
childVO.setCheckTime(new Date().toString()); |
|
707 |
mesChildList0.add(childVO); |
|
708 |
} |
109e2f
|
709 |
} |
2de856
|
710 |
|
C |
711 |
//mesList.get(i).addAll(mesChildList0); |
|
712 |
|
109e2f
|
713 |
} |
C |
714 |
|
|
715 |
} |
|
716 |
|
|
717 |
CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
|
718 |
//插入参数采集表 |
|
719 |
daParamCollectionService.insertBatch(saveParamList); |
|
720 |
//上传到工厂mes |
|
721 |
ParentVO parentVO = new ParentVO(); |
|
722 |
parentVO.setStationCode(device);//工位 |
|
723 |
parentVO.setSiteCode("3983"); |
|
724 |
|
|
725 |
parentVO.setRecordId(UUID.randomUUID().toString()); |
|
726 |
parentVO.setTotalResult("1"); |
|
727 |
for (int i = 0; i < cellCodeList.size(); i++) {//循环4个电芯 |
2de856
|
728 |
if(!cellCodeList.get(i).isEmpty()){ |
C |
729 |
parentVO.setProductNum(cellCodeList.get(i));//电芯码 |
743e2e
|
730 |
//封装给工厂MES发送的childlist4 |
C |
731 |
List<ChildVO> mesChildList = new ArrayList<>(mesChildList0); |
|
732 |
switch (i) { |
|
733 |
case 0 : |
|
734 |
mesChildList.addAll(mesChildList1); |
|
735 |
break; |
|
736 |
case 1 : |
|
737 |
mesChildList.addAll(mesChildList2); |
|
738 |
break; |
|
739 |
case 2 : |
|
740 |
mesChildList.addAll(mesChildList3); |
|
741 |
break; |
|
742 |
case 3 : |
|
743 |
mesChildList.addAll(mesChildList4); |
|
744 |
break; |
|
745 |
|
|
746 |
} |
|
747 |
parentVO.setCheckList(mesChildList);//参数 |
2de856
|
748 |
//CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
C |
749 |
log.info("执行工厂MES方法start,传入数据:{}",parentVO); |
20635f
|
750 |
HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute(); |
2de856
|
751 |
log.info("执行工厂MES方法end,返回数据:{}",execute.body()); |
C |
752 |
} |
109e2f
|
753 |
} |
C |
754 |
}); |
|
755 |
} |
|
756 |
}catch (Exception e) { |
743e2e
|
757 |
log.error(e.getMessage()); |
109e2f
|
758 |
throw new RuntimeException(e); |
C |
759 |
} |
|
760 |
return result; |
|
761 |
} |
|
762 |
|
|
763 |
/** |
2de856
|
764 |
* 030工位返回ocv测试结果 |
C |
765 |
* @param thoroughfare |
|
766 |
* @param device |
ec7e2a
|
767 |
* @param cellCode |
C |
768 |
* @throws Exception |
|
769 |
*/ |
|
770 |
private boolean OCVResultFeedBack(String thoroughfare, String device,String cellCode) throws Exception { |
|
771 |
boolean flag = true; |
|
772 |
|
|
773 |
List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() |
|
774 |
.eq(DaTestDeviceInterfaceTemp::getStationCode, device) |
|
775 |
.eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); |
|
776 |
if (CollUtil.isNotEmpty(list)){ |
d8e6a5
|
777 |
DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); |
ec7e2a
|
778 |
if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ |
C |
779 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(1).build()); |
|
780 |
}else { |
|
781 |
flag = false; |
|
782 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); |
|
783 |
} |
d8e6a5
|
784 |
daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); |
f18ebf
|
785 |
}else { |
C |
786 |
flag = false; |
|
787 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); |
|
788 |
log.info("读取到工位{},测试设备返回的数据查询不到,电芯码为:{}",device,cellCode); |
ec7e2a
|
789 |
} |
C |
790 |
return flag; |
|
791 |
} |
|
792 |
/** |
|
793 |
* 030工位返回ocv测试结果 |
|
794 |
* @param thoroughfare |
|
795 |
* @param device |
109e2f
|
796 |
* @throws Exception |
C |
797 |
*/ |
2de856
|
798 |
private boolean OCVResultFeedBack(String thoroughfare, String device) throws Exception { |
C |
799 |
boolean flag = true; |
|
800 |
Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_1").getValue(); |
5b755f
|
801 |
if (ObjectUtil.isNotNull(value1)){ |
C |
802 |
String cellCode = value1.toString(); |
|
803 |
List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() |
|
804 |
.eq(DaTestDeviceInterfaceTemp::getStationCode, device) |
|
805 |
.eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); |
2de856
|
806 |
if (CollUtil.isNotEmpty(list)){ |
18b39c
|
807 |
DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); |
5b755f
|
808 |
if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ |
2de856
|
809 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(1).build()); |
C |
810 |
}else { |
|
811 |
flag = false; |
|
812 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); |
|
813 |
} |
18b39c
|
814 |
daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); |
2de856
|
815 |
} |
f18ebf
|
816 |
}else { |
C |
817 |
flag = false; |
|
818 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); |
|
819 |
log.info("读取到工位{},PLC没有给电芯码",device); |
5b755f
|
820 |
} |
2de856
|
821 |
Object value2 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_2").getValue(); |
5b755f
|
822 |
if (ObjectUtil.isNotNull(value2)){ |
C |
823 |
String cellCode = value2.toString(); |
|
824 |
List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() |
|
825 |
.eq(DaTestDeviceInterfaceTemp::getStationCode, device) |
|
826 |
.eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); |
2de856
|
827 |
if (CollUtil.isNotEmpty(list)){ |
18b39c
|
828 |
DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); |
5b755f
|
829 |
if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ |
2de856
|
830 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(1).build()); |
C |
831 |
}else { |
|
832 |
flag = false; |
|
833 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(2).build()); |
|
834 |
} |
18b39c
|
835 |
daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); |
2de856
|
836 |
} |
f18ebf
|
837 |
}else { |
C |
838 |
flag = false; |
|
839 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(2).build()); |
|
840 |
log.info("读取到工位{},PLC没有给电芯码",device); |
5b755f
|
841 |
} |
C |
842 |
|
2de856
|
843 |
Object value3 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_3").getValue(); |
5b755f
|
844 |
if (ObjectUtil.isNotNull(value3)){ |
C |
845 |
String cellCode = value3.toString(); |
|
846 |
List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() |
|
847 |
.eq(DaTestDeviceInterfaceTemp::getStationCode, device) |
|
848 |
.eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); |
2de856
|
849 |
if (CollUtil.isNotEmpty(list)){ |
18b39c
|
850 |
DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); |
5b755f
|
851 |
if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ |
2de856
|
852 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(1).build()); |
C |
853 |
}else { |
|
854 |
flag = false; |
|
855 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(2).build()); |
|
856 |
} |
18b39c
|
857 |
daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); |
2de856
|
858 |
} |
f18ebf
|
859 |
}else { |
C |
860 |
flag = false; |
|
861 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(2).build()); |
|
862 |
log.info("读取到工位{},PLC没有给电芯码",device); |
5b755f
|
863 |
} |
C |
864 |
|
2de856
|
865 |
Object value4 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_4").getValue(); |
5b755f
|
866 |
if (ObjectUtil.isNotNull(value4)){ |
C |
867 |
String cellCode = value4.toString(); |
|
868 |
List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() |
|
869 |
.eq(DaTestDeviceInterfaceTemp::getStationCode, device) |
|
870 |
.eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); |
2de856
|
871 |
if (CollUtil.isNotEmpty(list)){ |
18b39c
|
872 |
DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); |
5b755f
|
873 |
if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ |
2de856
|
874 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(1).build()); |
C |
875 |
}else { |
|
876 |
flag = false; |
|
877 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(2).build()); |
|
878 |
} |
18b39c
|
879 |
daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); |
2de856
|
880 |
} |
f18ebf
|
881 |
}else { |
C |
882 |
flag = false; |
|
883 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(2).build()); |
|
884 |
log.info("读取到工位{},PLC没有给电芯码",device); |
5b755f
|
885 |
} |
C |
886 |
|
2de856
|
887 |
return flag; |
109e2f
|
888 |
} |
C |
889 |
|
|
890 |
|
0ca254
|
891 |
} |