提交 | 用户 | 时间
|
e6c837
|
1 |
package com.jcdm.main.plcserver.sub; |
A |
2 |
|
|
3 |
|
|
4 |
import cn.hutool.core.collection.CollUtil; |
09ef66
|
5 |
import cn.hutool.core.util.ObjectUtil; |
e6c837
|
6 |
import cn.hutool.core.util.StrUtil; |
cd4452
|
7 |
import cn.hutool.http.HttpRequest; |
W |
8 |
import cn.hutool.http.HttpResponse; |
|
9 |
import cn.hutool.json.JSONUtil; |
e6c837
|
10 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
A |
11 |
import com.jcdm.framework.websocket.WebSocketUsers; |
|
12 |
import com.jcdm.main.constant.Constants; |
|
13 |
import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf; |
|
14 |
import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; |
|
15 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
|
16 |
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; |
|
17 |
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
09ef66
|
18 |
import com.jcdm.main.da.passingStationCollection.query.ProductOrderChild; |
W |
19 |
import com.jcdm.main.da.passingStationCollection.query.ProductOrderQuery; |
|
20 |
import com.jcdm.main.da.passingStationCollection.query.ProductOrderVO; |
e6c837
|
21 |
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; |
A |
22 |
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; |
cd4452
|
23 |
import com.jcdm.main.restful.qingYan.doman.ChildVO; |
W |
24 |
import com.jcdm.main.restful.qingYan.doman.ParentVO; |
09ef66
|
25 |
import com.jcdm.main.work.domain.KeyCodeRelation; |
cd4452
|
26 |
import com.jcdm.main.work.domain.QingYanTestInfo; |
W |
27 |
import com.jcdm.main.work.domain.SendFactoryMes; |
09ef66
|
28 |
import com.jcdm.main.work.domain.WorkOrder; |
cd4452
|
29 |
import com.jcdm.main.work.service.*; |
e6c837
|
30 |
import com.kangaroohy.milo.model.ReadWriteEntity; |
A |
31 |
import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
|
32 |
import com.kangaroohy.milo.service.MiloService; |
09ef66
|
33 |
import lombok.extern.slf4j.Slf4j; |
cd4452
|
34 |
import org.springframework.beans.factory.annotation.Value; |
e6c837
|
35 |
import org.springframework.stereotype.Component; |
A |
36 |
|
|
37 |
import javax.websocket.Session; |
|
38 |
import java.text.SimpleDateFormat; |
|
39 |
import java.util.*; |
cd4452
|
40 |
import java.util.concurrent.CompletableFuture; |
e6c837
|
41 |
import java.util.stream.Collectors; |
A |
42 |
|
|
43 |
|
09ef66
|
44 |
@Slf4j |
e6c837
|
45 |
@Component |
A |
46 |
public class OPCUaSubscription implements SubscriptionCallback { |
|
47 |
|
|
48 |
public SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
public static MiloService miloService; |
|
53 |
|
|
54 |
|
022e1e
|
55 |
public static IDaPassingStationCollectionService daPassingStationCollectionService; |
e6c837
|
56 |
|
A |
57 |
public static IDaCollectionParamConfService collectionParamConfService; |
|
58 |
|
|
59 |
public static IDaParamCollectionService daParamCollectionService; |
|
60 |
|
|
61 |
public static IOmProductionOrdeInfoService omProductionOrdeInfoService; |
09ef66
|
62 |
public static WorkOrderService workOrderService; |
W |
63 |
public static KeyCodeCheckService keyCodeCheckService; |
|
64 |
public static KeyCodeRelationService keyCodeRelationService; |
cd4452
|
65 |
public static QingYanTestInfoService qingYanTestInfoService; |
W |
66 |
public static SendFactoryMesService sendFactoryMesService; |
|
67 |
public static List<SendFactoryMes> sendFactoryMesList; |
|
68 |
|
|
69 |
@Value("${orderLineUrl}") |
|
70 |
private static String orderLineUrl; |
e6c837
|
71 |
|
A |
72 |
public OPCUaSubscription(MiloService miloService, |
|
73 |
IDaPassingStationCollectionService daPassingStationCollectionService, |
|
74 |
IDaCollectionParamConfService collectionParamConfService, |
|
75 |
IDaParamCollectionService daParamCollectionService, |
09ef66
|
76 |
IOmProductionOrdeInfoService omProductionOrdeInfoService, |
W |
77 |
WorkOrderService workOrderService, |
|
78 |
KeyCodeCheckService keyCodeCheckService, |
cd4452
|
79 |
KeyCodeRelationService keyCodeRelationService, |
W |
80 |
QingYanTestInfoService qingYanTestInfoService, |
|
81 |
List<SendFactoryMes> sendFactoryMesList) { |
e6c837
|
82 |
OPCUaSubscription.miloService = miloService; |
022e1e
|
83 |
OPCUaSubscription.daPassingStationCollectionService = daPassingStationCollectionService; |
e6c837
|
84 |
OPCUaSubscription.collectionParamConfService = collectionParamConfService; |
A |
85 |
OPCUaSubscription.daParamCollectionService = daParamCollectionService; |
|
86 |
OPCUaSubscription.omProductionOrdeInfoService = omProductionOrdeInfoService; |
09ef66
|
87 |
OPCUaSubscription.workOrderService = workOrderService; |
W |
88 |
OPCUaSubscription.keyCodeCheckService = keyCodeCheckService; |
|
89 |
OPCUaSubscription.keyCodeRelationService = keyCodeRelationService; |
cd4452
|
90 |
OPCUaSubscription.qingYanTestInfoService = qingYanTestInfoService; |
W |
91 |
OPCUaSubscription.sendFactoryMesList = sendFactoryMesList; |
09ef66
|
92 |
|
e6c837
|
93 |
} |
A |
94 |
|
|
95 |
|
|
96 |
@Override |
|
97 |
public void onSubscribe(String identifier, Object value) { |
|
98 |
|
|
99 |
try { |
09ef66
|
100 |
if(null != value && !Constants.ZERO.equals(value.toString())) { |
e6c837
|
101 |
String[] nodes = identifier.split("[.]"); |
A |
102 |
String thoroughfare = nodes[0];//通道 |
|
103 |
String device = nodes[1];//设备 |
|
104 |
String tab = nodes[2];//标记 |
09ef66
|
105 |
String valueString = value.toString();//地址值 |
022e1e
|
106 |
if (Constants.RECORD_CHECK_CODE.equals(tab)){//电芯校验 |
09ef66
|
107 |
if (Constants.ONE.equals(valueString)){ |
W |
108 |
Integer scanResult = 11; |
|
109 |
if (Constants.OP010.equals(device) || Constants.OP030.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 |
//仅校验长度是否合格 |
|
116 |
// List<KeyCodeCheck> collect = keyCodeCheckService.list().stream().filter(x -> x.getKeyCode().contains(keyCode)).collect(Collectors.toList()); |
|
117 |
// if (CollUtil.isNotEmpty(collect)){ |
|
118 |
// scanResult = 11; |
|
119 |
// } |
e6c837
|
120 |
} |
A |
121 |
} |
09ef66
|
122 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult1").value(scanResult).build()); |
W |
123 |
log.info("写入到工位{}的ScanerResult1数据:{}",device,scanResult); |
e6c837
|
124 |
} |
076112
|
125 |
}else if (Constants.RECORD_SN.equals(tab)){//请求下发模组码9 |
C |
126 |
if (Constants.ONE.equals(valueString)){ |
|
127 |
if (Constants.OP070.equals(device)){ |
|
128 |
List<WorkOrder> orderList = workOrderService.list().stream() |
|
129 |
.sorted(Comparator.comparing(WorkOrder::getCreateTime).reversed()) |
|
130 |
.collect(Collectors.toList()); |
|
131 |
if (CollUtil.isNotEmpty(orderList)){ |
|
132 |
String productNum = orderList.get(0).getProductNum();//模组码 |
|
133 |
//OP070下发产品模组码 |
|
134 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ModuleCode").value(productNum).build()); |
|
135 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build()); |
|
136 |
}else{ |
|
137 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(2).build());//没有要生产的工单 |
|
138 |
} |
|
139 |
} |
|
140 |
} |
022e1e
|
141 |
}else if (Constants.RECORD_DATA.equals(tab)){//出入站 |
C |
142 |
if (Constants.ONE.equals(valueString)){//入站 |
09ef66
|
143 |
//1:告知MES托盘已到站,请求下发进站状态 |
W |
144 |
if (Constants.OP030.equals(device)){ |
|
145 |
//反馈电芯ocv检测结果 |
|
146 |
boolean b = OCVResultFeedBack(thoroughfare, device); |
|
147 |
if (b){ |
|
148 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); |
|
149 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,11); |
|
150 |
}else { |
|
151 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); |
|
152 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,12); |
|
153 |
} |
|
154 |
} else { |
|
155 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); |
|
156 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,11); |
e6c837
|
157 |
} |
022e1e
|
158 |
}else if (Constants.TWO.equals(valueString)){//出站 |
09ef66
|
159 |
//分段010-065段 |
W |
160 |
if (Constants.OP010.equals(device)){ |
|
161 |
//010工位无过站记录,只给放行信号 |
022e1e
|
162 |
/*List<SendFactoryMes> collect = sendFactoryMesList.stream().filter(x -> device.equals(x.getLocationCode())).collect(Collectors.toList()); |
cd4452
|
163 |
if (CollUtil.isNotEmpty(collect)){ |
W |
164 |
for (SendFactoryMes sendFactoryMes : collect) { |
|
165 |
ChildVO childVO = new ChildVO(); |
|
166 |
childVO.setItemCode(sendFactoryMes.getItemCode()); |
|
167 |
childVO.setItemText(sendFactoryMes.getItemText()); |
|
168 |
childVO.setItemType(sendFactoryMes.getItemType()); |
|
169 |
} |
022e1e
|
170 |
}*/ |
09ef66
|
171 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build()); |
W |
172 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,21); |
022e1e
|
173 |
}else if (Constants.OP020_OP065.contains(device)){ |
076112
|
174 |
Integer result = 21; |
022e1e
|
175 |
//读取电芯码 |
C |
176 |
List<String> cellCodeList = readCellCodeList(thoroughfare, device); |
|
177 |
if(ObjectUtil.isNull(cellCodeList) && cellCodeList.size() != 4){ |
076112
|
178 |
result = 23; |
022e1e
|
179 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(23).build()); |
C |
180 |
}else{ |
|
181 |
result = savePassingStation(thoroughfare, device,cellCodeList);//保存过站 |
076112
|
182 |
if(result==21) { |
022e1e
|
183 |
result = saveParamCollection(thoroughfare, device,cellCodeList);//保存参数,发送工厂MES |
C |
184 |
} |
09ef66
|
185 |
} |
022e1e
|
186 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build()); |
C |
187 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,result); |
09ef66
|
188 |
} else if (Constants.OP100_1.equals(device) || Constants.OP100_2.equals(device)){ |
W |
189 |
//下发刻码信息-为模组码 |
076112
|
190 |
/*ProductOrderQuery query = new ProductOrderQuery(); |
09ef66
|
191 |
query.setSiteCode("3983"); |
076112
|
192 |
query.setStationCode(device);*/ |
09ef66
|
193 |
List<WorkOrder> collect = workOrderService.list().stream() |
W |
194 |
.sorted(Comparator.comparing(WorkOrder::getCreateTime).reversed()) |
|
195 |
.collect(Collectors.toList()); |
076112
|
196 |
/*if (CollUtil.isNotEmpty(collect)){ |
09ef66
|
197 |
query.setProductNum(collect.get(0).getProductNum()); |
076112
|
198 |
}*/ |
b26a2d
|
199 |
// ProductOrderVO vo = daPassingStationCollectionService.queryMessFromLine(query); |
W |
200 |
ProductOrderVO vo = new ProductOrderVO(); |
|
201 |
ProductOrderChild child = new ProductOrderChild(); |
|
202 |
child.setModel("modelCode123123123"); |
|
203 |
child.setStationCode("M1OP100-1"); |
|
204 |
child.setProductNum("productNum123113"); |
|
205 |
child.setMaterialCode("materialCode2323"); |
|
206 |
child.setProductionOrderNum("proOrderNum123"); |
|
207 |
vo.setData(child); |
|
208 |
vo.setCode(Constants.SUCCESS); |
09ef66
|
209 |
if (Constants.SUCCESS.equals(vo.getCode())){ |
W |
210 |
WorkOrder workOrder = new WorkOrder(); |
|
211 |
ProductOrderChild data = vo.getData(); |
b26a2d
|
212 |
workOrder.setId(123L); |
09ef66
|
213 |
workOrder.setProductNum(data.getProductNum()); |
W |
214 |
workOrder.setProductionOrderNum(data.getProductionOrderNum()); |
|
215 |
workOrder.setStationCode(data.getStationCode()); |
|
216 |
workOrder.setMaterialCode(data.getMaterialCode()); |
|
217 |
workOrder.setModel(data.getModel()); |
b26a2d
|
218 |
workOrder.setCreateTime(new Date()); |
09ef66
|
219 |
workOrderService.save(workOrder); |
W |
220 |
//写入模组码、工单号、产品型号到plc |
|
221 |
log.info("写入模组码、工单号、产品型号到plc"); |
|
222 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ModuleCode").value(data.getModel()).build()); |
|
223 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderNumber").value(data.getProductionOrderNum()).build()); |
|
224 |
//这里plc录入的产品型号类型是int类型,工厂mes返回数据不是int类型,可能会出现问题 |
|
225 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ProductType").value(data.getProductNum()).build()); |
|
226 |
//绑定模组码和电芯码数据 |
|
227 |
List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
|
228 |
.eq(DaCollectionParamConf::getProcessesCode, device) |
|
229 |
.eq(DaCollectionParamConf::getRemarks,Constants.ONE)); |
|
230 |
List<String> collect3 = list.stream().filter(x -> Constants.INT_ZERO.equals(x.getKeyNum())).map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
231 |
List<String> collect1 = list.stream().filter(x -> Constants.INT_ONE.equals(x.getKeyNum())|| Constants.INT_TWO.equals(x.getKeyNum())) |
|
232 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
233 |
// List<String> collect2 = list.stream().filter(x -> Constants.INT_TWO.equals(x.getKeyNum())) |
|
234 |
// .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
235 |
List<ReadWriteEntity> paramCollectionList1 = miloService.readFromOpcUa(collect1); |
|
236 |
List<ReadWriteEntity> paramCollectionList3 = miloService.readFromOpcUa(collect3); |
|
237 |
if (CollUtil.isNotEmpty(paramCollectionList1)){ |
|
238 |
List<KeyCodeRelation> relationList = new ArrayList<>(); |
|
239 |
for (ReadWriteEntity readWriteEntity : paramCollectionList1) { |
b26a2d
|
240 |
if (ObjectUtil.isNotNull(readWriteEntity.getValue()) && StrUtil.isNotBlank(readWriteEntity.getValue().toString())){ |
09ef66
|
241 |
KeyCodeRelation keyCodeRelation = new KeyCodeRelation(); |
W |
242 |
keyCodeRelation.setModuleCode(data.getModel()); |
|
243 |
keyCodeRelation.setKeyCode(readWriteEntity.getValue().toString()); |
|
244 |
keyCodeRelation.setProductionOrderNum(data.getProductionOrderNum()); |
|
245 |
keyCodeRelation.setProductNum(data.getProductNum()); |
|
246 |
keyCodeRelation.setCreateTime(new Date()); |
|
247 |
relationList.add(keyCodeRelation); |
|
248 |
} |
|
249 |
} |
|
250 |
if (CollUtil.isNotEmpty(relationList)){ |
|
251 |
keyCodeRelationService.insertBatch(relationList); |
|
252 |
} |
|
253 |
} |
|
254 |
if (CollUtil.isNotEmpty(paramCollectionList3)){ |
|
255 |
QueryPLCData(device,thoroughfare,collect3); |
|
256 |
} |
|
257 |
//保存过站记录 |
|
258 |
DaPassingStationCollection passingStationCollection = new DaPassingStationCollection(); |
|
259 |
passingStationCollection.setModuleCode(data.getModel()); |
|
260 |
|
|
261 |
passingStationCollection.setLocationCode(device); |
|
262 |
passingStationCollection.setInboundTime(new Date()); |
|
263 |
String stationStatus = Constants.PASS; |
|
264 |
ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus"); |
|
265 |
if (ObjectUtil.isNotNull(stationStatusRead.getValue())){ |
|
266 |
String string = stationStatusRead.getValue().toString(); |
|
267 |
log.info("读取工位{}StationStatus:{}",device,string); |
|
268 |
if (Constants.TWO.equals(string)){ |
|
269 |
stationStatus = Constants.UN_PASS; |
|
270 |
} |
|
271 |
} |
|
272 |
passingStationCollection.setOutRsSign(stationStatus); |
|
273 |
passingStationCollection.setCreateTime(new Date()); |
|
274 |
daPassingStationCollectionService.save(passingStationCollection); |
|
275 |
} |
|
276 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build()); |
|
277 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,21); |
|
278 |
} else { |
|
279 |
//2:告知MES工位工作完成,请求记录工位数据 |
|
280 |
//保存参数采集记录 |
|
281 |
saveParamPassingData(device,thoroughfare); |
|
282 |
//保存过站记录 |
|
283 |
DaPassingStationCollection passingStationCollection = new DaPassingStationCollection(); |
|
284 |
Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); |
|
285 |
String moduleCode = null; |
|
286 |
if (ObjectUtil.isNotNull(value1)){ |
|
287 |
moduleCode = value1.toString(); |
|
288 |
log.info("读取工位{}的ModuleCode数据:{}",device,moduleCode); |
|
289 |
} |
|
290 |
passingStationCollection.setModuleCode(moduleCode); |
|
291 |
passingStationCollection.setLocationCode(device); |
|
292 |
passingStationCollection.setInboundTime(new Date()); |
|
293 |
String stationStatus = Constants.PASS; |
|
294 |
ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus"); |
|
295 |
if (ObjectUtil.isNotNull(stationStatusRead.getValue())){ |
|
296 |
String string = stationStatusRead.getValue().toString(); |
|
297 |
if (Constants.TWO.equals(string)){ |
|
298 |
stationStatus = Constants.UN_PASS; |
|
299 |
} |
|
300 |
} |
|
301 |
passingStationCollection.setOutRsSign(stationStatus); |
|
302 |
passingStationCollection.setCreateTime(new Date()); |
|
303 |
daPassingStationCollectionService.save(passingStationCollection); |
|
304 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build()); |
|
305 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,21); |
|
306 |
} |
|
307 |
} |
076112
|
308 |
} else if (Constants.RECORD_CHECK_CODE_1.equals(tab)) { |
09ef66
|
309 |
if (Constants.OP100_1.equals(device)){ |
W |
310 |
//钢带条码校验--发送给工厂mes |
|
311 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult11").value(11).build()); |
|
312 |
} else if (Constants.OP100_2.equals(device)) { |
|
313 |
//PET带条码校验--发送给工厂mes |
|
314 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult12").value(11).build()); |
e6c837
|
315 |
} |
A |
316 |
} |
|
317 |
} |
|
318 |
} catch (Exception e) { |
09ef66
|
319 |
System.out.println(e.getMessage()); |
W |
320 |
log.info(e.getMessage()); |
|
321 |
} |
|
322 |
} |
|
323 |
|
022e1e
|
324 |
|
C |
325 |
|
09ef66
|
326 |
/** |
022e1e
|
327 |
* 读取电芯码 |
09ef66
|
328 |
* @param thoroughfare 通道 |
W |
329 |
* @param device 工位 |
|
330 |
* @return list |
|
331 |
* @throws Exception e |
|
332 |
*/ |
022e1e
|
333 |
private static List<String> readCellCodeList(String thoroughfare, String device){ |
C |
334 |
List<String> cellCodeList = new ArrayList<>(); |
|
335 |
//电芯码地址 |
09ef66
|
336 |
List<String> readList = new ArrayList<>(); |
W |
337 |
readList.add(thoroughfare + "." + device +".CellCode_1"); |
|
338 |
readList.add(thoroughfare + "." + device +".CellCode_2"); |
|
339 |
readList.add(thoroughfare + "." + device +".CellCode_3"); |
|
340 |
readList.add(thoroughfare + "." + device +".CellCode_4"); |
022e1e
|
341 |
try { |
C |
342 |
List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(readList);//电芯码 |
|
343 |
for (ReadWriteEntity readWriteEntity : readWriteEntityList) { |
|
344 |
if (ObjectUtil.isNotNull(readWriteEntity.getValue())){ |
|
345 |
cellCodeList.add(readWriteEntity.getValue().toString());//封装电芯码 |
|
346 |
} |
09ef66
|
347 |
} |
022e1e
|
348 |
} catch (Exception e) { |
C |
349 |
throw new RuntimeException(e); |
|
350 |
} |
|
351 |
return cellCodeList; |
|
352 |
} |
|
353 |
|
|
354 |
/** |
|
355 |
* 保存过站数据 |
|
356 |
* @param thoroughfare 通道 |
|
357 |
* @param device 工位 |
|
358 |
* @param cellCodeList 电芯码集合 |
|
359 |
* @return list |
|
360 |
* @throws Exception e |
|
361 |
*/ |
076112
|
362 |
private static Integer savePassingStation(String thoroughfare, String device,List<String> cellCodeList){ |
C |
363 |
Integer result = 21; |
022e1e
|
364 |
|
C |
365 |
try { |
|
366 |
//读进站时间 |
|
367 |
Date startTime = new Date(); |
|
368 |
ReadWriteEntity startTimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StartTime");//进站时间 |
|
369 |
if (ObjectUtil.isNotNull(startTimeRead.getValue())){ |
|
370 |
String stringStartTime = startTimeRead.getValue().toString(); |
|
371 |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); |
|
372 |
startTime = sdf.parse(stringStartTime); |
|
373 |
}else{ |
076112
|
374 |
result = 23; |
022e1e
|
375 |
log.info("读取到工位{}的StartTime数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result); |
C |
376 |
} |
|
377 |
|
|
378 |
//读工站状态 |
09ef66
|
379 |
String stationStatus = Constants.PASS; |
022e1e
|
380 |
ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus");//站状态地址 |
09ef66
|
381 |
if (ObjectUtil.isNotNull(stationStatusRead.getValue())){ |
W |
382 |
String string = stationStatusRead.getValue().toString(); |
|
383 |
if (Constants.TWO.equals(string)){ |
|
384 |
stationStatus = Constants.UN_PASS; |
|
385 |
} |
022e1e
|
386 |
}else{ |
076112
|
387 |
result = 23; |
022e1e
|
388 |
log.info("读取到工位{}StationStatuss数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result); |
09ef66
|
389 |
} |
022e1e
|
390 |
|
C |
391 |
List<DaPassingStationCollection> passingList = new ArrayList<>(); |
|
392 |
for (String cellCode : cellCodeList) { |
|
393 |
DaPassingStationCollection passingStationCollection = new DaPassingStationCollection(); |
|
394 |
if (ObjectUtil.isNotNull(cellCode)){ |
|
395 |
passingStationCollection.setKeyCode(cellCode);//电芯码 |
|
396 |
passingStationCollection.setLocationCode(device);//工位 |
|
397 |
passingStationCollection.setInboundTime(startTime);//进站时间 |
|
398 |
passingStationCollection.setOutboundTime(new Date());//出站时间 |
|
399 |
passingStationCollection.setOutRsSign(stationStatus);//站状态值 |
|
400 |
passingStationCollection.setCollectionTime(new Date());//采集时间 |
|
401 |
passingList.add(passingStationCollection); |
|
402 |
}else{ |
076112
|
403 |
result = 23; |
022e1e
|
404 |
log.info("读取到工位{}CellCode数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result); |
C |
405 |
} |
|
406 |
} |
|
407 |
|
|
408 |
if (CollUtil.isNotEmpty(passingList)){ |
|
409 |
daPassingStationCollectionService.insertBatch(passingList);//存储过站采集数据 |
|
410 |
} |
|
411 |
|
|
412 |
} catch (Exception e) { |
|
413 |
throw new RuntimeException(e); |
09ef66
|
414 |
} |
cd4452
|
415 |
|
022e1e
|
416 |
return result; |
C |
417 |
} |
cd4452
|
418 |
|
022e1e
|
419 |
/** |
C |
420 |
* 保存电芯过站记录 |
|
421 |
* @param thoroughfare 通道 |
|
422 |
* @param device 工位 |
|
423 |
* @param cellCodeList 电芯码集合 |
|
424 |
* @return list |
|
425 |
* @throws Exception e |
|
426 |
*/ |
076112
|
427 |
private static Integer saveParamCollection(String thoroughfare, String device,List<String> cellCodeList){ |
C |
428 |
Integer result = 21;//返回结果 |
022e1e
|
429 |
List<List<ChildVO>> mesList = new ArrayList<>();//存储4个电芯的发送给MES的值 |
09ef66
|
430 |
|
022e1e
|
431 |
try { |
C |
432 |
//查询参数配置表 |
|
433 |
List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
|
434 |
.eq(DaCollectionParamConf::getProcessesCode, device)//工位 |
|
435 |
.eq(DaCollectionParamConf::getRemarks, Constants.ONE));//类型 |
|
436 |
if (CollUtil.isNotEmpty(list)) { |
|
437 |
List<DaParamCollection> saveParamList = new ArrayList<>();//封装参数采集list |
|
438 |
List<DaCollectionParamConf> confColl1 = list.stream().filter(x -> Constants.INT_ONE.equals(x.getKeyNum())).collect(Collectors.toList()); |
|
439 |
List<DaCollectionParamConf> confColl2 = list.stream().filter(x -> Constants.INT_TWO.equals(x.getKeyNum())).collect(Collectors.toList()); |
|
440 |
List<DaCollectionParamConf> confColl3 = list.stream().filter(x -> Constants.INT_THREE.equals(x.getKeyNum())).collect(Collectors.toList()); |
|
441 |
List<DaCollectionParamConf> confColl4 = list.stream().filter(x -> Constants.INT_FOUR.equals(x.getKeyNum())).collect(Collectors.toList()); |
|
442 |
List<DaCollectionParamConf> confColl0 = list.stream().filter(x -> Constants.INT_ZERO.equals(x.getKeyNum())).collect(Collectors.toList()); |
09ef66
|
443 |
|
022e1e
|
444 |
List<String> collect1 = confColl1.stream() |
C |
445 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
446 |
List<ReadWriteEntity> paramCollectionList1 = miloService.readFromOpcUa(collect1);//电芯1 参数值 |
09ef66
|
447 |
|
022e1e
|
448 |
List<String> collect2 = confColl2.stream() |
C |
449 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
450 |
List<ReadWriteEntity> paramCollectionList2 = miloService.readFromOpcUa(collect2);//电芯2 参数值 |
09ef66
|
451 |
|
022e1e
|
452 |
List<String> collect3 = confColl3.stream() |
C |
453 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
454 |
List<ReadWriteEntity> paramCollectionList3 = miloService.readFromOpcUa(collect3);//电芯3 参数值 |
|
455 |
|
|
456 |
List<String> collect4 = confColl4.stream() |
|
457 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
458 |
List<ReadWriteEntity> paramCollectionList4 = miloService.readFromOpcUa(collect4);//电芯4 参数值 |
|
459 |
|
|
460 |
List<String> collect0 = confColl0.stream() |
|
461 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
462 |
List<ReadWriteEntity> paramCollectionList0 = miloService.readFromOpcUa(collect0);//电芯 参数值 |
|
463 |
|
|
464 |
//第一个电芯的数据 |
|
465 |
if (CollUtil.isNotEmpty(paramCollectionList1)) { |
|
466 |
List<ChildVO> mesChildList1 = new ArrayList<>();//封装给工厂MES发送的childlist1 |
|
467 |
for (int i = 0; i < paramCollectionList1.size(); i++) { |
|
468 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
469 |
daParamCollection.setSfcCode(cellCodeList.get(0));//电芯码 |
|
470 |
daParamCollection.setParamCode(confColl1.get(i).getCollectParameterId());//参数编码 |
|
471 |
daParamCollection.setParamName(confColl1.get(i).getCollectParameterName());//参数名称 |
|
472 |
String paramValue = ""; |
|
473 |
if (ObjectUtil.isNotNull(paramCollectionList1.get(i).getValue())) { |
|
474 |
paramValue = paramCollectionList1.get(i).getValue().toString();//参数值 |
09ef66
|
475 |
} |
022e1e
|
476 |
daParamCollection.setParamValue(paramValue);//参数值 |
C |
477 |
daParamCollection.setLocationCode(device);//工位 |
|
478 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
479 |
saveParamList.add(daParamCollection);//封装参数采集list |
|
480 |
|
|
481 |
//发送给工厂mes参数封装 |
|
482 |
ChildVO childVO = new ChildVO(); |
|
483 |
childVO.setItemCode(confColl1.get(i).getCollectParameterName());//参数 |
|
484 |
childVO.setItemType(confColl1.get(i).getItemType()); |
|
485 |
childVO.setItemValue(paramValue);//参数值 |
|
486 |
childVO.setItemText(confColl1.get(i).getParameterSetName()); |
|
487 |
childVO.setCheckResult("1"); |
|
488 |
childVO.setCheckTime(new Date().toString()); |
|
489 |
mesChildList1.add(childVO); |
|
490 |
mesList.add(0, mesChildList1); |
09ef66
|
491 |
} |
W |
492 |
} |
022e1e
|
493 |
if (CollUtil.isNotEmpty(paramCollectionList2)) { |
C |
494 |
List<ChildVO> mesChildList2 = new ArrayList<>();//封装给工厂MES发送的childlist2 |
|
495 |
|
|
496 |
for (int i = 0; i < paramCollectionList2.size(); i++) { |
|
497 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
498 |
daParamCollection.setSfcCode(cellCodeList.get(1));//电芯码 |
|
499 |
daParamCollection.setParamCode(confColl2.get(i).getCollectParameterId());//参数编码 |
|
500 |
daParamCollection.setParamName(confColl2.get(i).getCollectParameterName());//参数名称 |
|
501 |
String paramValue = ""; |
|
502 |
if (ObjectUtil.isNotNull(paramCollectionList2.get(i).getValue())) { |
|
503 |
paramValue = paramCollectionList2.get(i).getValue().toString();//参数值 |
|
504 |
} |
|
505 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
506 |
daParamCollection.setLocationCode(device);//工位 |
|
507 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
508 |
saveParamList.add(daParamCollection);//封装参数采集list |
|
509 |
|
|
510 |
//发送给工厂mes参数封装 |
|
511 |
ChildVO childVO = new ChildVO(); |
|
512 |
childVO.setItemCode(confColl2.get(i).getCollectParameterName());//参数 |
|
513 |
childVO.setItemType(confColl2.get(i).getItemType()); |
|
514 |
childVO.setItemValue(paramValue);//参数值 |
|
515 |
childVO.setItemText(confColl2.get(i).getParameterSetName()); |
|
516 |
childVO.setCheckResult("1"); |
|
517 |
childVO.setCheckTime(new Date().toString()); |
|
518 |
mesChildList2.add(childVO); |
|
519 |
mesList.add(1, mesChildList2); |
|
520 |
} |
|
521 |
} |
|
522 |
if (CollUtil.isNotEmpty(paramCollectionList3)) { |
|
523 |
List<ChildVO> mesChildList3 = new ArrayList<>();//封装给工厂MES发送的childlist3 |
|
524 |
for (int i = 0; i < paramCollectionList3.size(); i++) { |
|
525 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
526 |
daParamCollection.setSfcCode(cellCodeList.get(2));//电芯码 |
|
527 |
daParamCollection.setParamCode(confColl3.get(i).getCollectParameterId());//参数编码 |
|
528 |
daParamCollection.setParamName(confColl3.get(i).getCollectParameterName());//参数名称 |
|
529 |
String paramValue = ""; |
|
530 |
if (ObjectUtil.isNotNull(paramCollectionList3.get(i).getValue())) { |
|
531 |
paramValue = paramCollectionList3.get(i).getValue().toString();//参数值 |
|
532 |
} |
|
533 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
534 |
daParamCollection.setLocationCode(device);//工位 |
|
535 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
536 |
saveParamList.add(daParamCollection);//封装参数采集list |
|
537 |
|
|
538 |
//发送给工厂mes参数封装 |
|
539 |
ChildVO childVO = new ChildVO(); |
|
540 |
childVO.setItemCode(confColl3.get(i).getCollectParameterName());//参数 |
|
541 |
childVO.setItemType(confColl3.get(i).getItemType()); |
|
542 |
childVO.setItemValue(paramValue);//参数值 |
|
543 |
childVO.setItemText(confColl3.get(i).getParameterSetName()); |
|
544 |
childVO.setCheckResult("1"); |
|
545 |
childVO.setCheckTime(new Date().toString()); |
|
546 |
mesChildList3.add(childVO); |
|
547 |
mesList.add(2, mesChildList3); |
|
548 |
} |
|
549 |
} |
|
550 |
if (CollUtil.isNotEmpty(paramCollectionList4)) { |
|
551 |
List<ChildVO> mesChildList4 = new ArrayList<>();//封装给工厂MES发送的childlist4 |
|
552 |
for (int i = 0; i < paramCollectionList4.size(); i++) { |
|
553 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
554 |
daParamCollection.setSfcCode(cellCodeList.get(3));//电芯码 |
|
555 |
daParamCollection.setParamCode(confColl4.get(i).getCollectParameterId());//参数编码 |
|
556 |
daParamCollection.setParamName(confColl4.get(i).getCollectParameterName());//参数名称 |
|
557 |
String paramValue = ""; |
|
558 |
if (ObjectUtil.isNotNull(paramCollectionList4.get(i).getValue())) { |
|
559 |
paramValue = paramCollectionList4.get(i).getValue().toString();//参数值 |
|
560 |
} |
|
561 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
562 |
daParamCollection.setLocationCode(device);//工位 |
|
563 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
564 |
saveParamList.add(daParamCollection);//封装参数采集list |
|
565 |
|
|
566 |
//发送给工厂mes参数封装 |
|
567 |
ChildVO childVO = new ChildVO(); |
|
568 |
childVO.setItemCode(confColl4.get(i).getCollectParameterName());//参数 |
|
569 |
childVO.setItemType(confColl4.get(i).getItemType()); |
|
570 |
childVO.setItemValue(paramValue);//参数值 |
|
571 |
childVO.setItemText(confColl4.get(i).getParameterSetName()); |
|
572 |
childVO.setCheckResult("1"); |
|
573 |
childVO.setCheckTime(new Date().toString()); |
|
574 |
mesChildList4.add(childVO); |
|
575 |
mesList.add(3, mesChildList4); |
|
576 |
} |
|
577 |
} |
|
578 |
|
|
579 |
//公共参数 |
|
580 |
if (CollUtil.isNotEmpty(paramCollectionList0)) { |
|
581 |
for (int i = 0; i < cellCodeList.size(); i++) {//循环4个电芯 |
|
582 |
List<ChildVO> mesChildList0 = new ArrayList<>();//封装给工厂MES发送的childlist0 |
|
583 |
for (int j = 0; j < paramCollectionList0.size(); j++) { |
|
584 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
585 |
daParamCollection.setSfcCode(cellCodeList.get(i));//电芯码 |
|
586 |
daParamCollection.setParamCode(confColl0.get(j).getCollectParameterId());//参数编码 |
|
587 |
daParamCollection.setParamName(confColl0.get(j).getCollectParameterName());//参数名称 |
|
588 |
String paramValue = ""; |
|
589 |
if (ObjectUtil.isNotNull(paramCollectionList0.get(j).getValue())) { |
|
590 |
paramValue = paramCollectionList0.get(j).getValue().toString();//参数值 |
|
591 |
} |
|
592 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
593 |
daParamCollection.setLocationCode(device);//工位 |
|
594 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
595 |
saveParamList.add(daParamCollection); |
|
596 |
|
|
597 |
//发送给工厂mes参数封装 |
|
598 |
ChildVO childVO = new ChildVO(); |
|
599 |
childVO.setItemCode(confColl0.get(j).getCollectParameterName());//参数 |
|
600 |
childVO.setItemType(confColl0.get(j).getItemType()); |
|
601 |
childVO.setItemValue(paramValue);//参数值 |
|
602 |
childVO.setItemText(confColl0.get(j).getParameterSetName()); |
|
603 |
childVO.setCheckResult("1"); |
|
604 |
childVO.setCheckTime(new Date().toString()); |
|
605 |
mesChildList0.add(childVO); |
|
606 |
} |
|
607 |
mesList.get(i).addAll(mesChildList0); |
|
608 |
/* mesList.add(mesChildList0);*/ |
|
609 |
} |
|
610 |
|
|
611 |
} |
|
612 |
|
|
613 |
CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
|
614 |
//插入参数采集表 |
|
615 |
daParamCollectionService.insertBatch(saveParamList); |
|
616 |
//上传到工厂mes |
|
617 |
ParentVO parentVO = new ParentVO(); |
|
618 |
parentVO.setStationCode(device);//工位 |
|
619 |
parentVO.setSiteCode("3983"); |
|
620 |
|
|
621 |
parentVO.setRecordId(UUID.randomUUID().toString()); |
|
622 |
parentVO.setTotalResult("1"); |
|
623 |
for (int i = 0; i < cellCodeList.size(); i++) {//循环4个电芯 |
|
624 |
parentVO.setProductNum(cellCodeList.get(i));//电芯码 |
|
625 |
parentVO.setCheckList(mesList.get(i));//参数 |
|
626 |
//CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
|
627 |
log.info("执行工厂MES方法start,传入数据:{}",parentVO); |
|
628 |
HttpResponse execute = HttpRequest.post(orderLineUrl).body(JSONUtil.toJsonStr(parentVO)).execute(); |
|
629 |
log.info("执行工厂MES方法end,返回数据:{}",execute.body()); |
|
630 |
//}); |
|
631 |
} |
|
632 |
}); |
09ef66
|
633 |
} |
022e1e
|
634 |
}catch (Exception e) { |
C |
635 |
throw new RuntimeException(e); |
|
636 |
} |
|
637 |
return result; |
09ef66
|
638 |
} |
W |
639 |
|
|
640 |
/** |
|
641 |
* 030工位返回ocv测试结果 |
|
642 |
* @param thoroughfare |
|
643 |
* @param device |
|
644 |
* @throws Exception |
|
645 |
*/ |
|
646 |
private boolean OCVResultFeedBack(String thoroughfare, String device) throws Exception { |
|
647 |
boolean flag = true; |
|
648 |
Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_1").getValue(); |
|
649 |
if (ObjectUtil.isNotNull(value1)){ |
|
650 |
String string = value1.toString(); |
cd4452
|
651 |
List<QingYanTestInfo> list = qingYanTestInfoService.list(new LambdaQueryWrapper<QingYanTestInfo>() |
W |
652 |
.eq(QingYanTestInfo::getKeyCode, string)); |
09ef66
|
653 |
if (CollUtil.isNotEmpty(list)){ |
cd4452
|
654 |
QingYanTestInfo qingYanTestInfo = list.get(0); |
W |
655 |
if (Constants.ONE.equals(qingYanTestInfo.getStatus())){ |
09ef66
|
656 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(1).build()); |
W |
657 |
}else { |
|
658 |
flag = false; |
|
659 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); |
|
660 |
} |
|
661 |
} |
|
662 |
} |
|
663 |
Object value2 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_2").getValue(); |
|
664 |
if (ObjectUtil.isNotNull(value2)){ |
|
665 |
String string = value2.toString(); |
cd4452
|
666 |
List<QingYanTestInfo> list = qingYanTestInfoService.list(new LambdaQueryWrapper<QingYanTestInfo>() |
W |
667 |
.eq(QingYanTestInfo::getKeyCode, string)); |
09ef66
|
668 |
if (CollUtil.isNotEmpty(list)){ |
cd4452
|
669 |
QingYanTestInfo qingYanTestInfo = list.get(0); |
W |
670 |
if (Constants.ONE.equals(qingYanTestInfo.getStatus())){ |
09ef66
|
671 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(1).build()); |
W |
672 |
}else { |
|
673 |
flag = false; |
|
674 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(2).build()); |
|
675 |
} |
|
676 |
} |
|
677 |
} |
|
678 |
Object value3 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_3").getValue(); |
|
679 |
if (ObjectUtil.isNotNull(value3)){ |
|
680 |
String string = value3.toString(); |
cd4452
|
681 |
List<QingYanTestInfo> list = qingYanTestInfoService.list(new LambdaQueryWrapper<QingYanTestInfo>() |
W |
682 |
.eq(QingYanTestInfo::getKeyCode, string)); |
09ef66
|
683 |
if (CollUtil.isNotEmpty(list)){ |
cd4452
|
684 |
QingYanTestInfo qingYanTestInfo = list.get(0); |
W |
685 |
if (Constants.ONE.equals(qingYanTestInfo.getStatus())){ |
09ef66
|
686 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(1).build()); |
W |
687 |
}else { |
|
688 |
flag = false; |
|
689 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(2).build()); |
|
690 |
} |
|
691 |
} |
|
692 |
} |
|
693 |
Object value4 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_4").getValue(); |
|
694 |
if (ObjectUtil.isNotNull(value4)){ |
|
695 |
String string = value4.toString(); |
cd4452
|
696 |
List<QingYanTestInfo> list = qingYanTestInfoService.list(new LambdaQueryWrapper<QingYanTestInfo>() |
W |
697 |
.eq(QingYanTestInfo::getKeyCode, string)); |
09ef66
|
698 |
if (CollUtil.isNotEmpty(list)){ |
cd4452
|
699 |
QingYanTestInfo qingYanTestInfo = list.get(0); |
W |
700 |
if (Constants.ONE.equals(qingYanTestInfo.getStatus())){ |
09ef66
|
701 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(1).build()); |
W |
702 |
}else { |
|
703 |
flag = false; |
|
704 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(2).build()); |
|
705 |
} |
|
706 |
} |
|
707 |
} |
|
708 |
return flag; |
|
709 |
} |
|
710 |
|
|
711 |
/** |
|
712 |
* 保存过站数据和参数保存数据 |
|
713 |
* @param device 工位号 |
|
714 |
* @throws Exception |
|
715 |
*/ |
|
716 |
private void saveParamPassingData(String device,String thoroughfare) throws Exception { |
|
717 |
|
|
718 |
//保存参数采集数据 |
|
719 |
List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
|
720 |
.eq(DaCollectionParamConf::getProcessesCode, device) |
|
721 |
.eq(DaCollectionParamConf::getRemarks, Constants.ONE)); |
|
722 |
if (CollUtil.isNotEmpty(list)){ |
|
723 |
List<String> collect = list.stream().map(DaCollectionParamConf::getGatherAddress) |
|
724 |
.filter(Objects::nonNull).distinct() |
|
725 |
.collect(Collectors.toList()); |
|
726 |
QueryPLCData(device,thoroughfare,collect); |
e6c837
|
727 |
|
A |
728 |
} |
|
729 |
} |
|
730 |
|
09ef66
|
731 |
/** |
W |
732 |
* 批量查询plc站点数据 |
|
733 |
* @param device 站点 |
|
734 |
* @param collect 点位 |
|
735 |
* @throws Exception |
|
736 |
*/ |
|
737 |
private static void QueryPLCData(String device,String thoroughfare,List<String> collect) throws Exception { |
|
738 |
List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(collect); |
|
739 |
|
|
740 |
if (CollUtil.isNotEmpty(readWriteEntityList)){ |
|
741 |
List<DaParamCollection> collectionList = new ArrayList<>(); |
|
742 |
Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); |
|
743 |
String moduleCode = null; |
|
744 |
if (ObjectUtil.isNotNull(value1)){ |
|
745 |
moduleCode = value1.toString(); |
|
746 |
} |
|
747 |
for (int i = 0; i < readWriteEntityList.size(); i++) { |
|
748 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
749 |
if (StrUtil.isNotBlank(moduleCode)){ |
|
750 |
daParamCollection.setModuleCode(moduleCode); |
|
751 |
} |
|
752 |
daParamCollection.setParamCode(collect.get(i)); |
|
753 |
String paramValue = ""; |
|
754 |
if (ObjectUtil.isNotNull(readWriteEntityList.get(i).getValue())){ |
|
755 |
paramValue = readWriteEntityList.get(i).getValue().toString(); |
|
756 |
} |
|
757 |
daParamCollection.setParamValue(paramValue); |
|
758 |
daParamCollection.setLocationCode(device); |
|
759 |
daParamCollection.setCollectionTime(new Date()); |
|
760 |
collectionList.add(daParamCollection); |
|
761 |
} |
|
762 |
daParamCollectionService.insertBatch(collectionList); |
|
763 |
} |
|
764 |
} |
e6c837
|
765 |
} |