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