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