提交 | 用户 | 时间
|
61c519
|
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; |
|
7 |
import cn.hutool.http.HttpRequest; |
|
8 |
import cn.hutool.http.HttpResponse; |
|
9 |
import cn.hutool.json.JSONObject; |
|
10 |
import cn.hutool.json.JSONUtil; |
|
11 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
4162bc
|
12 |
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
61c519
|
13 |
import com.jcdm.common.core.domain.AjaxResult; |
A |
14 |
import com.jcdm.framework.websocket.WebSocketUsers; |
|
15 |
import com.jcdm.main.constant.Constants; |
|
16 |
import com.jcdm.main.da.cellData.domain.DaCellData; |
|
17 |
import com.jcdm.main.da.cellData.service.IDaCellDataService; |
|
18 |
import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf; |
|
19 |
import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; |
|
20 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
|
21 |
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; |
|
22 |
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
|
23 |
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; |
4162bc
|
24 |
import com.jcdm.main.da.psConf.domain.DaPsConf; |
C |
25 |
import com.jcdm.main.da.psConf.service.IDaPsConfService; |
61c519
|
26 |
import com.jcdm.main.da.testDeviceInterfaceTemp.domain.DaTestDeviceInterfaceTemp; |
A |
27 |
import com.jcdm.main.da.testDeviceInterfaceTemp.service.IDaTestDeviceInterfaceTempService; |
|
28 |
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; |
|
29 |
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; |
|
30 |
import com.jcdm.main.plcserver.util.TimeUtil; |
|
31 |
import com.jcdm.main.restful.factoryMes.service.RestfulService; |
|
32 |
import com.jcdm.main.restful.qingYan.doman.ChildVO; |
|
33 |
import com.jcdm.main.restful.qingYan.doman.ParentVO; |
|
34 |
import com.kangaroohy.milo.model.ReadWriteEntity; |
|
35 |
import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
|
36 |
import com.kangaroohy.milo.service.MiloService; |
|
37 |
import lombok.extern.slf4j.Slf4j; |
4162bc
|
38 |
import org.apache.commons.lang3.StringUtils; |
61c519
|
39 |
import org.springframework.beans.factory.annotation.Value; |
A |
40 |
import org.springframework.stereotype.Component; |
|
41 |
import org.springframework.web.bind.annotation.GetMapping; |
|
42 |
|
|
43 |
import javax.websocket.Session; |
|
44 |
import java.text.SimpleDateFormat; |
4162bc
|
45 |
import java.time.LocalDate; |
61c519
|
46 |
import java.util.*; |
A |
47 |
import java.util.concurrent.CompletableFuture; |
|
48 |
import java.util.stream.Collectors; |
|
49 |
|
|
50 |
|
|
51 |
@Slf4j |
|
52 |
@Component |
|
53 |
public class OPCUaSubscription implements SubscriptionCallback { |
|
54 |
|
|
55 |
public static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
56 |
|
|
57 |
|
|
58 |
Map<String, Session> map = WebSocketUsers.getUsers(); |
|
59 |
public static MiloService miloService; |
|
60 |
|
|
61 |
|
|
62 |
public static IDaPassingStationCollectionService daPassingStationCollectionService; |
|
63 |
|
|
64 |
public static IDaCollectionParamConfService collectionParamConfService; |
|
65 |
|
|
66 |
public static IDaParamCollectionService daParamCollectionService; |
|
67 |
|
|
68 |
public static IOmProductionOrdeInfoService omProductionOrdeInfoService; |
|
69 |
|
|
70 |
public static IDaTestDeviceInterfaceTempService daTestDeviceInterfaceTempService; |
|
71 |
|
|
72 |
public static IDaCellDataService daCellDataService; |
4162bc
|
73 |
public static IDaPsConfService daPsConfService; |
61c519
|
74 |
/* @Value("${orderLineUrl}") |
A |
75 |
private static String orderLineUrl;*/ |
|
76 |
|
|
77 |
public OPCUaSubscription(MiloService miloService, |
|
78 |
IDaPassingStationCollectionService daPassingStationCollectionService, |
|
79 |
IDaCollectionParamConfService collectionParamConfService, |
|
80 |
IDaParamCollectionService daParamCollectionService, |
|
81 |
IOmProductionOrdeInfoService omProductionOrdeInfoService, |
|
82 |
IDaTestDeviceInterfaceTempService daTestDeviceInterfaceTempService, |
4162bc
|
83 |
IDaCellDataService daCellDataService, |
C |
84 |
IDaPsConfService daPsConfService) { |
61c519
|
85 |
OPCUaSubscription.miloService = miloService; |
A |
86 |
OPCUaSubscription.daPassingStationCollectionService = daPassingStationCollectionService; |
|
87 |
OPCUaSubscription.collectionParamConfService = collectionParamConfService; |
|
88 |
OPCUaSubscription.daParamCollectionService = daParamCollectionService; |
|
89 |
OPCUaSubscription.omProductionOrdeInfoService = omProductionOrdeInfoService; |
|
90 |
OPCUaSubscription.daTestDeviceInterfaceTempService = daTestDeviceInterfaceTempService; |
|
91 |
OPCUaSubscription.daCellDataService = daCellDataService; |
4162bc
|
92 |
OPCUaSubscription.daPsConfService = daPsConfService; |
61c519
|
93 |
} |
A |
94 |
|
|
95 |
|
|
96 |
@Override |
|
97 |
public void onSubscribe(String identifier, Object value) { |
|
98 |
log.info("地址:"+identifier+"值:"+value); |
|
99 |
try { |
|
100 |
if(null != value && !Constants.ZERO.equals(value.toString())) { |
|
101 |
String[] nodes = identifier.split("[.]"); |
|
102 |
String thoroughfare = nodes[0];//通道 |
|
103 |
String device = nodes[1];//设备 |
|
104 |
String tab = nodes[2];//标记 |
|
105 |
String valueString = value.toString();//地址值 |
|
106 |
|
|
107 |
CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
|
108 |
subHandle(thoroughfare,device,tab,valueString); |
|
109 |
}); |
|
110 |
|
|
111 |
} |
|
112 |
} catch (Exception e) { |
|
113 |
log.error(e.getMessage()); |
|
114 |
} |
|
115 |
} |
|
116 |
|
|
117 |
public void subHandle(String thoroughfare,String device,String tab,String valueString){ |
|
118 |
try{ |
|
119 |
if (Constants.RECORD_CHECK_CODE.equals(tab)){//电芯校验 |
|
120 |
if (Constants.ONE.equals(valueString)){ |
|
121 |
Integer scanResult = 11; |
|
122 |
if (Constants.OP010.equals(device)){ |
|
123 |
//OP010工位电芯条码校验||OP030工位电芯条码校验 |
|
124 |
Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".Scaner").getValue(); |
|
125 |
if (ObjectUtil.isNotNull(value1)){ |
|
126 |
String keyCode = value1.toString(); |
|
127 |
log.info("读取到工位{}的Scaner数据:{}",device,keyCode); |
|
128 |
//仅校验长度是否合格 |
|
129 |
// List<KeyCodeCheck> collect = keyCodeCheckService.list().stream().filter(x -> x.getKeyCode().contains(keyCode)).collect(Collectors.toList()); |
|
130 |
// if (CollUtil.isNotEmpty(collect)){ |
|
131 |
// scanResult = 11; |
|
132 |
// } |
|
133 |
} |
|
134 |
}else if(Constants.OP030.equals(device)){ |
|
135 |
Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".Scaner").getValue();//电芯码 |
|
136 |
if (ObjectUtil.isNotNull(value1)){ |
8cc77a
|
137 |
/*String cellCode = value1.toString();*/ |
61c519
|
138 |
scanResult = 11; |
8cc77a
|
139 |
/* //反馈电芯ocv检测结果,这里不用再进行检测,只要码没问题就可以了 |
61c519
|
140 |
boolean b = OCVResultFeedBack(thoroughfare, device,cellCode);//对替换电芯校验 |
A |
141 |
//四个电芯的状态 |
|
142 |
if (b){ |
|
143 |
scanResult = 11; |
|
144 |
}else { |
|
145 |
scanResult = 12; |
8cc77a
|
146 |
}*/ |
61c519
|
147 |
}else { |
A |
148 |
scanResult = 12; |
|
149 |
} |
|
150 |
} |
|
151 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ScanerResult1").value(scanResult).build()); |
|
152 |
log.info("写入到工位{}的ScanerResult1数据:{}",device,scanResult); |
|
153 |
} |
|
154 |
}else if (Constants.RECORD_SN.equals(tab)){//求下发模组码请9 |
|
155 |
if (Constants.ONE.equals(valueString)){ |
|
156 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build());//没有要生产的工单 |
|
157 |
} |
|
158 |
}else if (Constants.RECORD_DATA.equals(tab)){//出入站 |
|
159 |
if (Constants.ONE.equals(valueString)){//入站 //1:告知MES托盘已到站,请求下发进站状态 |
|
160 |
|
|
161 |
//OP020 电芯挡位校验 |
|
162 |
if (Constants.OP020.equals(device)){ |
|
163 |
Integer result = 11; |
|
164 |
Object cellGearObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellGear").getValue(); |
|
165 |
if (ObjectUtil.isNull(cellGearObjcet)){ |
|
166 |
result = 16;//电芯挡位为空 |
|
167 |
}else{ |
|
168 |
String cellGear = cellGearObjcet.toString(); |
4ab63d
|
169 |
/* List<String> cellCodeList = readCellCodeList(thoroughfare, device); |
e8571a
|
170 |
result = checkCellGear(thoroughfare, device,cellCodeList,cellGear);//校验电芯挡位和组别*/ |
61c519
|
171 |
} |
A |
172 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build()); |
|
173 |
|
|
174 |
}else if (Constants.OP030.equals(device)){ |
|
175 |
//反馈电芯ocv检测结果 |
|
176 |
boolean b = OCVResultFeedBack(thoroughfare, device);//进站对4个电芯校验 |
|
177 |
//四个电芯的状态 |
|
178 |
if (b){ |
|
179 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); |
|
180 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,11); |
|
181 |
}else { |
|
182 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); |
|
183 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,12); |
|
184 |
} |
|
185 |
} else if(Constants.OP100_1.equals(device) || Constants.OP100_2.equals(device)){ |
|
186 |
//1、进站PLC给产品类型,MES读取产品类型 |
|
187 |
Object productTypeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ProductType").getValue();//产品类型 |
|
188 |
if (ObjectUtil.isNotNull(productTypeObjcet)){ |
|
189 |
String productType = productTypeObjcet.toString();//产品类型 |
|
190 |
String materialCode = Constants.materialMap.get(productType); |
|
191 |
//接收工单,保存到数据库,并且将工单传给PLC |
|
192 |
CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
|
193 |
receivingWorkOrders(thoroughfare, device,materialCode); |
|
194 |
}); |
|
195 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); |
|
196 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,11); |
|
197 |
}else{ |
|
198 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); |
|
199 |
} |
|
200 |
|
|
201 |
}else if (Constants.OP150.contains(device)){//人工工位 |
|
202 |
Object modulCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); |
|
203 |
if (ObjectUtil.isNull(modulCodeObjcet)){ |
|
204 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); |
|
205 |
}else{ |
|
206 |
String productNum = modulCodeObjcet.toString(); |
|
207 |
//将产品SN发送到前台 |
|
208 |
productNum = "productNum,"+ productNum; |
|
209 |
WebSocketUsers.sendMessageToUserByText(map.get(device), productNum); |
|
210 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); |
|
211 |
} |
|
212 |
}else if (Constants.ModuleList.contains(device)){//有模组码的工位 |
|
213 |
Object modulCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); |
|
214 |
if (ObjectUtil.isNull(modulCodeObjcet)){ |
|
215 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); |
|
216 |
}else{ |
|
217 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); |
|
218 |
} |
|
219 |
} |
|
220 |
else { |
|
221 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); |
|
222 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,11); |
|
223 |
} |
|
224 |
}else if (Constants.TWO.equals(valueString)){//出站 |
|
225 |
//分段010-065段 |
|
226 |
if (Constants.OP010.equals(device)){ |
|
227 |
//010工位无过站记录,只给放行信号 |
|
228 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build()); |
|
229 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,21); |
|
230 |
}else if (Constants.OP020_OP090.contains(device)){ |
|
231 |
Integer result = 21; |
|
232 |
//读取电芯码 |
|
233 |
List<String> cellCodeList = readCellCodeList(thoroughfare, device); |
|
234 |
if(ObjectUtil.isNull(cellCodeList) || cellCodeList.size() != 4 ){ |
|
235 |
result = 23; |
|
236 |
}else{ |
|
237 |
String cellCode1 = cellCodeList.get(0); |
|
238 |
String cellCode2 = cellCodeList.get(1); |
|
239 |
String cellCode3 = cellCodeList.get(2); |
|
240 |
String cellCode4 = cellCodeList.get(3); |
|
241 |
if ((!cellCode1.isEmpty() && cellCode2.isEmpty()) || (cellCode1.isEmpty() && !cellCode2.isEmpty()) |
|
242 |
|| (!cellCode3.isEmpty() && cellCode4.isEmpty()) || (!cellCode4.isEmpty() && cellCode3.isEmpty())) { |
|
243 |
result = 23; |
|
244 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build()); |
|
245 |
return; |
|
246 |
} |
|
247 |
|
|
248 |
result = savePassingStation(thoroughfare, device,cellCodeList);//保存过站 |
|
249 |
if(result == 21) { |
|
250 |
if(Constants.OP020.contains(device)){ |
|
251 |
if(!cellCode1.isEmpty()){ |
|
252 |
daCellDataService.deleteDaCellDataByGbCellCode(cellCode1); |
|
253 |
} |
|
254 |
if(!cellCode2.isEmpty()){ |
|
255 |
daCellDataService.deleteDaCellDataByGbCellCode(cellCode2); |
|
256 |
} |
|
257 |
if(!cellCode3.isEmpty()){ |
|
258 |
daCellDataService.deleteDaCellDataByGbCellCode(cellCode3); |
|
259 |
} |
|
260 |
if(!cellCode4.isEmpty()){ |
|
261 |
daCellDataService.deleteDaCellDataByGbCellCode(cellCode4); |
|
262 |
} |
|
263 |
}else if(Constants.OP030.contains(device)){ |
|
264 |
if(!cellCode1.isEmpty()){ |
|
265 |
daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode1); |
|
266 |
} |
|
267 |
if(!cellCode2.isEmpty()){ |
|
268 |
daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode2); |
|
269 |
} |
|
270 |
if(!cellCode3.isEmpty()){ |
|
271 |
daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode3); |
|
272 |
} |
|
273 |
if(!cellCode4.isEmpty()) { |
|
274 |
daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode4); |
|
275 |
} |
|
276 |
} |
|
277 |
result = saveParamCollection(device,cellCodeList);//保存参数,发送工厂MES |
|
278 |
} |
|
279 |
|
|
280 |
} |
|
281 |
|
|
282 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build()); |
|
283 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,result); |
|
284 |
} else if (Constants.OP100_OP150.contains(device)){//人工工位 |
|
285 |
WebSocketUsers.sendMessageToUserByText(map.get(device), "END"); |
|
286 |
} else { |
|
287 |
Integer result = 21; |
|
288 |
//Object productTypeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ProductType").getValue();//产品类型 |
|
289 |
Object modulCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); |
|
290 |
if (ObjectUtil.isNull(modulCodeObjcet)){ |
|
291 |
result = 23; |
|
292 |
}else{ |
|
293 |
String moduleCode = modulCodeObjcet.toString(); |
|
294 |
Object stationStatusObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus").getValue();//站状态地址 |
|
295 |
if (ObjectUtil.isNotNull(stationStatusObjcet)){ |
|
296 |
String stationStatus = stationStatusObjcet.toString(); |
|
297 |
result = savePassingStation(thoroughfare, device,moduleCode,stationStatus);//保存过站 |
|
298 |
if(result == 21) { |
|
299 |
result = saveParamCollection(device,moduleCode,stationStatus);//保存参数,发送工厂MES |
|
300 |
} |
|
301 |
}else{ |
|
302 |
result = 23; |
|
303 |
log.info("读取到工位{}StationStatus数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result); |
|
304 |
} |
|
305 |
|
|
306 |
} |
|
307 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build()); |
|
308 |
log.info("写入到工位{}的RecordDataDone数据:{}",device,result); |
|
309 |
} |
|
310 |
} |
|
311 |
} |
|
312 |
}catch (Exception e) { |
|
313 |
log.error(e.getMessage()); |
|
314 |
} |
|
315 |
} |
|
316 |
|
|
317 |
public synchronized void receivingWorkOrders(String thoroughfare ,String device ,String materialCode) |
|
318 |
{ |
|
319 |
try { |
8cc77a
|
320 |
//先查询表中是否有剩余工单 |
C |
321 |
List<OmProductionOrdeInfo> orderList = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>() |
|
322 |
.eq(OmProductionOrdeInfo::getOrderStatus, Constants.ONE) |
|
323 |
.eq(OmProductionOrdeInfo::getStationCode,device)//工位 |
|
324 |
.eq(OmProductionOrdeInfo::getProductCode,materialCode));//产品类型 |
|
325 |
if (CollUtil.isNotEmpty(orderList)){ |
|
326 |
Long id = orderList.get(0).getId(); |
|
327 |
String productNum = orderList.get(0).getProductNum();//模组码 |
|
328 |
String orderNum = orderList.get(0).getWorkOrderNo(); |
61c519
|
329 |
|
A |
330 |
|
|
331 |
//下发产品模组码 |
|
332 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ModuleCode").value(productNum).build()); |
|
333 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderNumber").value(orderNum).build()); |
|
334 |
|
|
335 |
//将产品SN发送到前台 |
|
336 |
productNum = "productNum,"+ productNum; |
|
337 |
WebSocketUsers.sendMessageToUserByText(map.get(device), productNum); |
8cc77a
|
338 |
}else { |
C |
339 |
// 查询最新的工单信息 |
|
340 |
OmProductionOrdeInfo lastOrder = omProductionOrdeInfoService.getLastOrder(); |
61c519
|
341 |
|
8cc77a
|
342 |
log.info("请求工厂MES工单:入参device{},materialCode:{}", device, materialCode); |
C |
343 |
String orderJsonString = RestfulService.getProductionWorkOrderRequest(lastOrder.getProductNum(), "M2OP100", materialCode); |
|
344 |
log.info("请求工厂MES工单:出参pack:{}", orderJsonString); |
|
345 |
JSONObject jsonObject = new JSONObject(orderJsonString); |
|
346 |
// 从JSONObject中获取data对象 |
|
347 |
JSONObject dataObject = jsonObject.getJSONObject("data"); |
|
348 |
String code = jsonObject.getStr("code"); |
|
349 |
// 判断接单是否成功 |
|
350 |
if (code.equals("success")) { |
|
351 |
|
|
352 |
OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo(); |
|
353 |
omProductionOrdeInfo.setWorkOrderNo(dataObject.getStr("productionOrderNum")); |
|
354 |
omProductionOrdeInfo.setProductNum(dataObject.getStr("productNum")); |
|
355 |
omProductionOrdeInfo.setStationCode(device); |
|
356 |
omProductionOrdeInfo.setProductCode(dataObject.getStr("materialCode")); |
|
357 |
omProductionOrdeInfo.setPlanQty(Long.valueOf(dataObject.getStr("plannedQuantity"))); |
|
358 |
omProductionOrdeInfo.setOnlineCompletionMark("0"); |
|
359 |
omProductionOrdeInfo.setSfResult("0"); |
|
360 |
omProductionOrdeInfo.setProductModel(dataObject.getStr("model")); |
|
361 |
omProductionOrdeInfo.setCreateTime(new Date()); |
|
362 |
omProductionOrdeInfo.setCreateUser("工厂MES"); |
|
363 |
omProductionOrdeInfoService.save(omProductionOrdeInfo); |
|
364 |
|
|
365 |
String productNum = dataObject.getStr("productNum"); |
|
366 |
String orderNum = dataObject.getStr("productionOrderNum"); |
|
367 |
//下发产品模组码 |
|
368 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ModuleCode").value(productNum).build()); |
|
369 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderNumber").value(orderNum).build()); |
|
370 |
|
|
371 |
//将产品SN发送到前台 |
|
372 |
productNum = "productNum," + productNum; |
|
373 |
WebSocketUsers.sendMessageToUserByText(map.get(device), productNum); |
|
374 |
|
|
375 |
} |
61c519
|
376 |
} |
A |
377 |
} catch (Exception e) { |
|
378 |
throw new RuntimeException(e); |
|
379 |
} |
|
380 |
} |
|
381 |
|
|
382 |
/** |
|
383 |
* 读取电芯码 |
|
384 |
* @param thoroughfare 通道 |
|
385 |
* @param device 工位 |
|
386 |
* @return list |
|
387 |
* @throws Exception e |
|
388 |
*/ |
|
389 |
private static List<String> readCellCodeList(String thoroughfare, String device){ |
|
390 |
List<String> cellCodeList = new ArrayList<>(); |
|
391 |
Map map = new HashMap(); |
|
392 |
//电芯码地址 |
|
393 |
List<String> readList = new ArrayList<>(); |
|
394 |
readList.add(thoroughfare + "." + device +".CellCode_1"); |
|
395 |
readList.add(thoroughfare + "." + device +".CellCode_2"); |
|
396 |
readList.add(thoroughfare + "." + device +".CellCode_3"); |
|
397 |
readList.add(thoroughfare + "." + device +".CellCode_4"); |
|
398 |
try { |
|
399 |
List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(readList);//电芯码 |
|
400 |
for (ReadWriteEntity readWriteEntity : readWriteEntityList) { |
|
401 |
if (ObjectUtil.isNotNull(readWriteEntity.getValue()) && !readWriteEntity.getValue().toString().trim().isEmpty()){ |
|
402 |
cellCodeList.add(readWriteEntity.getValue().toString());//封装电芯码 |
|
403 |
}else{ |
|
404 |
cellCodeList.add("");//封装电芯码 |
|
405 |
} |
|
406 |
} |
|
407 |
|
|
408 |
} catch (Exception e) { |
|
409 |
throw new RuntimeException(e); |
|
410 |
} |
|
411 |
return cellCodeList; |
|
412 |
} |
|
413 |
|
|
414 |
|
|
415 |
/** |
|
416 |
* 保存过站数据 |
|
417 |
* @param thoroughfare 通道 |
|
418 |
* @param device 工位 |
|
419 |
* @param moduleCode 模组号 |
|
420 |
* @param stationStatus 站状态 |
|
421 |
* @return list |
|
422 |
* @throws Exception e |
|
423 |
*/ |
|
424 |
private static Integer savePassingStation(String thoroughfare, String device,String moduleCode,String stationStatus){ |
|
425 |
Integer result = 21; |
|
426 |
|
|
427 |
try { |
|
428 |
//读进站时间 |
|
429 |
Date startTime = new Date(); |
|
430 |
ReadWriteEntity startTimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StartTime");//进站时间 |
|
431 |
if (ObjectUtil.isNotNull(startTimeRead.getValue())){ |
|
432 |
startTime = format.parse(TimeUtil.test(TimeUtil.stringProcessing(startTimeRead.getValue().toString()))); |
|
433 |
}else{ |
|
434 |
result = 23; |
|
435 |
log.info("读取到工位{}的StartTime数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result); |
|
436 |
return result; |
|
437 |
} |
|
438 |
|
|
439 |
DaPassingStationCollection passingStationCollection = new DaPassingStationCollection(); |
|
440 |
passingStationCollection.setSfcCode(moduleCode);//电芯码 |
|
441 |
passingStationCollection.setLocationCode(device);//工位 |
|
442 |
passingStationCollection.setInboundTime(startTime);//进站时间 |
|
443 |
passingStationCollection.setOutboundTime(new Date());//出站时间 |
|
444 |
passingStationCollection.setOutRsSign(stationStatus);//站状态值 |
|
445 |
passingStationCollection.setCollectionTime(new Date());//采集时间 |
|
446 |
daPassingStationCollectionService.save(passingStationCollection); |
|
447 |
|
|
448 |
} catch (Exception e) { |
|
449 |
throw new RuntimeException(e); |
|
450 |
} |
|
451 |
|
|
452 |
return result; |
|
453 |
} |
|
454 |
|
|
455 |
/** |
|
456 |
* 保存过站数据 |
|
457 |
* @param thoroughfare 通道 |
|
458 |
* @param device 工位 |
|
459 |
* @param cellCodeList 电芯码集合 |
|
460 |
* @return list |
|
461 |
* @throws Exception e |
|
462 |
*/ |
|
463 |
private static Integer savePassingStation(String thoroughfare, String device,List<String> cellCodeList){ |
|
464 |
Integer result = 21; |
|
465 |
|
|
466 |
try { |
|
467 |
//读进站时间 |
|
468 |
Date startTime = new Date(); |
|
469 |
ReadWriteEntity startTimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StartTime");//进站时间 |
|
470 |
if (ObjectUtil.isNotNull(startTimeRead.getValue())){ |
|
471 |
startTime = format.parse(TimeUtil.test(TimeUtil.stringProcessing(startTimeRead.getValue().toString()))); |
|
472 |
}else{ |
|
473 |
result = 23; |
|
474 |
log.info("读取到工位{}的StartTime数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result); |
|
475 |
return result; |
|
476 |
} |
|
477 |
|
|
478 |
//读工站状态 |
|
479 |
String stationStatus = Constants.PASS; |
|
480 |
ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus");//站状态地址 |
|
481 |
if (ObjectUtil.isNotNull(stationStatusRead.getValue())){ |
|
482 |
String string = stationStatusRead.getValue().toString(); |
|
483 |
if (Constants.TWO.equals(string)){ |
|
484 |
stationStatus = Constants.UN_PASS; |
|
485 |
} |
|
486 |
}else{ |
|
487 |
result = 23; |
|
488 |
log.info("读取到工位{}StationStatus数据:{},返回RecordDataDone的值为{}",device,"IS NULL!",result); |
|
489 |
return result; |
|
490 |
} |
|
491 |
|
|
492 |
List<DaPassingStationCollection> passingList = new ArrayList<>(); |
|
493 |
for (String cellCode : cellCodeList) { |
|
494 |
DaPassingStationCollection passingStationCollection = new DaPassingStationCollection(); |
|
495 |
if (ObjectUtil.isNotNull(cellCode) && !cellCode.isEmpty()){ |
|
496 |
passingStationCollection.setSfcCode(cellCode);//电芯码 |
|
497 |
passingStationCollection.setLocationCode(device);//工位 |
|
498 |
passingStationCollection.setInboundTime(startTime);//进站时间 |
|
499 |
passingStationCollection.setOutboundTime(new Date());//出站时间 |
|
500 |
passingStationCollection.setOutRsSign(stationStatus);//站状态值 |
|
501 |
passingStationCollection.setCollectionTime(new Date());//采集时间 |
|
502 |
passingList.add(passingStationCollection); |
|
503 |
} |
|
504 |
} |
|
505 |
|
|
506 |
if (CollUtil.isNotEmpty(passingList)){ |
|
507 |
daPassingStationCollectionService.insertBatch(passingList);//存储过站采集数据 |
|
508 |
} |
|
509 |
|
|
510 |
} catch (Exception e) { |
|
511 |
throw new RuntimeException(e); |
|
512 |
} |
|
513 |
|
|
514 |
return result; |
|
515 |
} |
|
516 |
|
|
517 |
|
|
518 |
/** |
|
519 |
* 保存参数数据和发送工厂MES |
|
520 |
* @param device 工位 |
|
521 |
* @param moduleCode 模组号 |
|
522 |
* @param stationStatus 站状态 |
|
523 |
* @return list |
|
524 |
* @throws Exception e |
|
525 |
*/ |
|
526 |
private static Integer saveParamCollection(String device,String moduleCode,String stationStatus){ |
|
527 |
Integer result = 21;//返回结果 |
|
528 |
String sendMes = ""; |
|
529 |
|
|
530 |
try { |
|
531 |
//查询参数配置表 |
|
532 |
List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
|
533 |
.eq(DaCollectionParamConf::getProcessesCode, device)//工位 |
|
534 |
.eq(DaCollectionParamConf::getWhetherToCollect, Constants.ONE)//是否采集 |
|
535 |
); |
|
536 |
if (CollUtil.isNotEmpty(list)){ |
|
537 |
|
|
538 |
List<String> collect = list.stream() |
|
539 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
540 |
List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(collect); |
|
541 |
|
|
542 |
List<DaParamCollection> collectionList = new ArrayList<>(); |
|
543 |
List<ChildVO> mesList = new ArrayList<>(); |
|
544 |
for (int i = 0; i < readWriteEntityList.size(); i++) { |
|
545 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
546 |
daParamCollection.setSfcCode(moduleCode);//模组码 |
|
547 |
daParamCollection.setParamCode(list.get(i).getCollectParameterId());//参数编码 |
|
548 |
daParamCollection.setParamName(list.get(i).getCollectParameterName());//参数名称 |
|
549 |
String paramValue = ""; |
|
550 |
if (ObjectUtil.isNotNull(readWriteEntityList.get(i).getValue())){ |
|
551 |
paramValue = readWriteEntityList.get(i).getValue().toString();//参数值 |
|
552 |
if("DATE".equals(list.get(i).getCollectParameterType()) && !paramValue.isEmpty()){ |
|
553 |
paramValue = format.parse(TimeUtil.test(TimeUtil.stringProcessing(paramValue))).toString(); |
|
554 |
}else if("MODEL".equals(list.get(i).getCollectParameterType()) && !paramValue.isEmpty()){ |
|
555 |
paramValue = Constants.materialMap.get(paramValue); |
|
556 |
} |
|
557 |
} |
|
558 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
559 |
daParamCollection.setLocationCode(device);//工位 |
|
560 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
561 |
collectionList.add(daParamCollection);//封装参数采集list |
|
562 |
|
|
563 |
//发送给工厂mes参数封装 |
|
564 |
ChildVO childVO = new ChildVO(); |
|
565 |
childVO.setItemCode(list.get(i).getCollectParameterId());//参数编码 |
|
566 |
childVO.setItemType(list.get(i).getItemType()); |
|
567 |
childVO.setItemValue(paramValue);//参数值 |
|
568 |
childVO.setItemText(list.get(i).getCollectParameterName()); |
|
569 |
childVO.setCheckResult("1"); |
|
570 |
childVO.setCheckTime(format.format(new Date())); |
|
571 |
mesList.add(childVO); |
|
572 |
} |
|
573 |
|
|
574 |
CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
|
575 |
//插入参数采集表 |
|
576 |
daParamCollectionService.insertBatch(collectionList); |
|
577 |
|
|
578 |
//如果220工位,进行报工,因为上层系统只支持6位,所有报工工位修改为M2P220 |
|
579 |
if(Constants.OP220.equals(device)) { |
|
580 |
getWorkReportResultFeedback(moduleCode, "M2P220", format.format(new Date())); |
|
581 |
} |
|
582 |
|
|
583 |
//上传到工厂mes |
|
584 |
ParentVO parentVO = new ParentVO(); |
|
585 |
parentVO.setStationCode(device);//工位 |
|
586 |
parentVO.setSiteCode("3983"); |
|
587 |
|
|
588 |
parentVO.setRecordId(UUID.randomUUID().toString()); |
|
589 |
if("2".equals(stationStatus)){//工站状态 |
|
590 |
parentVO.setTotalResult("0"); |
|
591 |
}else { |
|
592 |
parentVO.setTotalResult("1"); |
|
593 |
} |
|
594 |
parentVO.setProductNum(moduleCode); |
|
595 |
|
|
596 |
//添加基础数据 |
|
597 |
List<ChildVO> basicList = getCollectParamBasicData(device,moduleCode); |
|
598 |
mesList.addAll(basicList); |
|
599 |
|
|
600 |
parentVO.setCheckList(mesList); |
|
601 |
|
|
602 |
log.info("执行工厂MES方法start,工位号{} 传入数据:{}",device ,parentVO); |
|
603 |
HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_GET_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute(); |
|
604 |
log.info("执行工厂MES方法end,工位号{} 返回数据:{}",device,execute.body()); |
|
605 |
|
|
606 |
}); |
|
607 |
} |
|
608 |
}catch (Exception e) { |
|
609 |
throw new RuntimeException(e); |
|
610 |
} |
|
611 |
return result; |
|
612 |
} |
|
613 |
|
|
614 |
/** |
|
615 |
* 保存参数数据和发送工厂MES |
|
616 |
* @param device 工位 |
|
617 |
* @param cellCodeList 电芯码集合 |
|
618 |
* @return list |
|
619 |
* @throws Exception e |
|
620 |
*/ |
|
621 |
private static Integer saveParamCollection(String device,List<String> cellCodeList){ |
|
622 |
Integer result = 21;//返回结果 |
|
623 |
List<ChildVO> mesChildList1 = new ArrayList<>();//封装给工厂MES发送的childlist1 |
|
624 |
List<ChildVO> mesChildList2 = new ArrayList<>();//封装给工厂MES发送的childlist2 |
|
625 |
List<ChildVO> mesChildList3 = new ArrayList<>();//封装给工厂MES发送的childlist3 |
|
626 |
List<ChildVO> mesChildList4 = new ArrayList<>();//封装给工厂MES发送的childlist4 |
|
627 |
List<ChildVO> mesChildList0 = new ArrayList<>();//封装给工厂MES发送的childlist4 |
|
628 |
try { |
|
629 |
//查询参数配置表 |
|
630 |
List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
|
631 |
.eq(DaCollectionParamConf::getProcessesCode, device)//工位 |
|
632 |
.eq(DaCollectionParamConf::getWhetherToCollect, Constants.ONE)//是否采集 |
|
633 |
);//类型 |
|
634 |
if (CollUtil.isNotEmpty(list)) { |
|
635 |
List<DaParamCollection> saveParamList = new ArrayList<>();//封装参数采集list |
|
636 |
List<DaCollectionParamConf> confColl1 = list.stream().filter(x -> Constants.INT_ONE.equals(x.getKeyNum())).collect(Collectors.toList()); |
|
637 |
List<DaCollectionParamConf> confColl2 = list.stream().filter(x -> Constants.INT_TWO.equals(x.getKeyNum())).collect(Collectors.toList()); |
|
638 |
List<DaCollectionParamConf> confColl3 = list.stream().filter(x -> Constants.INT_THREE.equals(x.getKeyNum())).collect(Collectors.toList()); |
|
639 |
List<DaCollectionParamConf> confColl4 = list.stream().filter(x -> Constants.INT_FOUR.equals(x.getKeyNum())).collect(Collectors.toList()); |
|
640 |
List<DaCollectionParamConf> confColl0 = list.stream().filter(x -> Constants.INT_ZERO.equals(x.getKeyNum())).collect(Collectors.toList()); |
|
641 |
|
|
642 |
List<String> collect1 = confColl1.stream() |
|
643 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
644 |
List<ReadWriteEntity> paramCollectionList1 = miloService.readFromOpcUa(collect1);//电芯1 参数值 |
|
645 |
|
|
646 |
List<String> collect2 = confColl2.stream() |
|
647 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
648 |
List<ReadWriteEntity> paramCollectionList2 = miloService.readFromOpcUa(collect2);//电芯2 参数值 |
|
649 |
|
|
650 |
List<String> collect3 = confColl3.stream() |
|
651 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
652 |
List<ReadWriteEntity> paramCollectionList3 = miloService.readFromOpcUa(collect3);//电芯3 参数值 |
|
653 |
|
|
654 |
List<String> collect4 = confColl4.stream() |
|
655 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
656 |
List<ReadWriteEntity> paramCollectionList4 = miloService.readFromOpcUa(collect4);//电芯4 参数值 |
|
657 |
|
|
658 |
List<String> collect0 = confColl0.stream() |
|
659 |
.map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
|
660 |
List<ReadWriteEntity> paramCollectionList0 = miloService.readFromOpcUa(collect0);//电芯 参数值 |
|
661 |
|
|
662 |
//第一个电芯的数据 |
|
663 |
if (CollUtil.isNotEmpty(paramCollectionList1) && !cellCodeList.get(0).isEmpty()) { |
|
664 |
for (int i = 0; i < paramCollectionList1.size(); i++) { |
|
665 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
666 |
daParamCollection.setSfcCode(cellCodeList.get(0));//电芯码 |
|
667 |
daParamCollection.setParamCode(confColl1.get(i).getCollectParameterId());//参数编码 |
|
668 |
daParamCollection.setParamName(confColl1.get(i).getCollectParameterName());//参数名称 |
|
669 |
String paramValue = ""; |
|
670 |
if (ObjectUtil.isNotNull(paramCollectionList1.get(i).getValue())) { |
|
671 |
paramValue = paramCollectionList1.get(i).getValue().toString();//参数值 |
|
672 |
} |
|
673 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
674 |
daParamCollection.setLocationCode(device);//工位 |
|
675 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
676 |
saveParamList.add(daParamCollection);//封装参数采集list |
|
677 |
|
|
678 |
//发送给工厂mes参数封装 |
|
679 |
ChildVO childVO = new ChildVO(); |
|
680 |
childVO.setItemCode(confColl1.get(i).getCollectParameterId());//参数 |
|
681 |
childVO.setItemType(confColl1.get(i).getItemType()); |
|
682 |
childVO.setItemValue(paramValue);//参数值 |
|
683 |
childVO.setItemText(confColl1.get(i).getCollectParameterName()); |
|
684 |
childVO.setCheckResult("1"); |
|
685 |
childVO.setCheckTime(format.format(new Date())); |
|
686 |
mesChildList1.add(childVO); |
|
687 |
} |
|
688 |
|
|
689 |
} |
|
690 |
if (CollUtil.isNotEmpty(paramCollectionList2) && !cellCodeList.get(1).isEmpty()) { |
|
691 |
|
|
692 |
for (int i = 0; i < paramCollectionList2.size(); i++) { |
|
693 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
694 |
daParamCollection.setSfcCode(cellCodeList.get(1));//电芯码 |
|
695 |
daParamCollection.setParamCode(confColl2.get(i).getCollectParameterId());//参数编码 |
|
696 |
daParamCollection.setParamName(confColl2.get(i).getCollectParameterName());//参数名称 |
|
697 |
String paramValue = ""; |
|
698 |
if (ObjectUtil.isNotNull(paramCollectionList2.get(i).getValue())) { |
|
699 |
paramValue = paramCollectionList2.get(i).getValue().toString();//参数值 |
|
700 |
} |
|
701 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
702 |
daParamCollection.setLocationCode(device);//工位 |
|
703 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
704 |
saveParamList.add(daParamCollection);//封装参数采集list |
|
705 |
|
|
706 |
//发送给工厂mes参数封装 |
|
707 |
ChildVO childVO = new ChildVO(); |
|
708 |
childVO.setItemCode(confColl2.get(i).getCollectParameterId());//参数 |
|
709 |
childVO.setItemType(confColl2.get(i).getItemType()); |
|
710 |
childVO.setItemValue(paramValue);//参数值 |
|
711 |
childVO.setItemText(confColl2.get(i).getCollectParameterName()); |
|
712 |
childVO.setCheckResult("1"); |
|
713 |
childVO.setCheckTime(format.format(new Date())); |
|
714 |
mesChildList2.add(childVO); |
|
715 |
} |
|
716 |
} |
|
717 |
if (CollUtil.isNotEmpty(paramCollectionList3) && !cellCodeList.get(2).isEmpty()) { |
|
718 |
for (int i = 0; i < paramCollectionList3.size(); i++) { |
|
719 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
720 |
daParamCollection.setSfcCode(cellCodeList.get(2));//电芯码 |
|
721 |
daParamCollection.setParamCode(confColl3.get(i).getCollectParameterId());//参数编码 |
|
722 |
daParamCollection.setParamName(confColl3.get(i).getCollectParameterName());//参数名称 |
|
723 |
String paramValue = ""; |
|
724 |
if (ObjectUtil.isNotNull(paramCollectionList3.get(i).getValue())) { |
|
725 |
paramValue = paramCollectionList3.get(i).getValue().toString();//参数值 |
|
726 |
} |
|
727 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
728 |
daParamCollection.setLocationCode(device);//工位 |
|
729 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
730 |
saveParamList.add(daParamCollection);//封装参数采集list |
|
731 |
|
|
732 |
//发送给工厂mes参数封装 |
|
733 |
ChildVO childVO = new ChildVO(); |
|
734 |
childVO.setItemCode(confColl3.get(i).getCollectParameterId());//参数 |
|
735 |
childVO.setItemType(confColl3.get(i).getItemType()); |
|
736 |
childVO.setItemValue(paramValue);//参数值 |
|
737 |
childVO.setItemText(confColl3.get(i).getCollectParameterName()); |
|
738 |
childVO.setCheckResult("1"); |
|
739 |
childVO.setCheckTime(format.format(new Date())); |
|
740 |
mesChildList3.add(childVO); |
|
741 |
} |
|
742 |
} |
|
743 |
if (CollUtil.isNotEmpty(paramCollectionList4)&& !cellCodeList.get(3).isEmpty()) { |
|
744 |
for (int i = 0; i < paramCollectionList4.size(); i++) { |
|
745 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
746 |
daParamCollection.setSfcCode(cellCodeList.get(3));//电芯码 |
|
747 |
daParamCollection.setParamCode(confColl4.get(i).getCollectParameterId());//参数编码 |
|
748 |
daParamCollection.setParamName(confColl4.get(i).getCollectParameterName());//参数名称 |
|
749 |
String paramValue = ""; |
|
750 |
if (ObjectUtil.isNotNull(paramCollectionList4.get(i).getValue())) { |
|
751 |
paramValue = paramCollectionList4.get(i).getValue().toString();//参数值 |
|
752 |
} |
|
753 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
754 |
daParamCollection.setLocationCode(device);//工位 |
|
755 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
756 |
saveParamList.add(daParamCollection);//封装参数采集list |
|
757 |
|
|
758 |
//发送给工厂mes参数封装 |
|
759 |
ChildVO childVO = new ChildVO(); |
|
760 |
childVO.setItemCode(confColl4.get(i).getCollectParameterId());//参数 |
|
761 |
childVO.setItemType(confColl4.get(i).getItemType()); |
|
762 |
childVO.setItemValue(paramValue);//参数值 |
|
763 |
childVO.setItemText(confColl4.get(i).getCollectParameterName()); |
|
764 |
childVO.setCheckResult("1"); |
|
765 |
childVO.setCheckTime(format.format(new Date())); |
|
766 |
mesChildList4.add(childVO); |
|
767 |
} |
|
768 |
} |
|
769 |
|
|
770 |
//公共参数 |
|
771 |
if (CollUtil.isNotEmpty(paramCollectionList0)) { |
|
772 |
for (int i = 0; i < cellCodeList.size(); i++) {//循环4个电芯 |
|
773 |
if(!cellCodeList.get(i).isEmpty()){ |
|
774 |
for (int j = 0; j < paramCollectionList0.size(); j++) { |
|
775 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
776 |
daParamCollection.setSfcCode(cellCodeList.get(i));//电芯码 |
|
777 |
daParamCollection.setParamCode(confColl0.get(j).getCollectParameterId());//参数编码 |
|
778 |
daParamCollection.setParamName(confColl0.get(j).getCollectParameterName());//参数名称 |
|
779 |
String paramValue = ""; |
|
780 |
if (ObjectUtil.isNotNull(paramCollectionList0.get(j).getValue())) { |
|
781 |
paramValue = paramCollectionList0.get(j).getValue().toString();//参数值 |
|
782 |
if("DATE".equals(confColl0.get(j).getCollectParameterType()) && !paramValue.isEmpty()){ |
|
783 |
paramValue = TimeUtil.test(TimeUtil.stringProcessing(paramValue)); |
|
784 |
} |
|
785 |
} |
|
786 |
daParamCollection.setParamValue(paramValue);//参数值 |
|
787 |
daParamCollection.setLocationCode(device);//工位 |
|
788 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
789 |
saveParamList.add(daParamCollection); |
|
790 |
|
|
791 |
//发送给工厂mes参数封装 |
|
792 |
ChildVO childVO = new ChildVO(); |
|
793 |
childVO.setItemCode(confColl0.get(j).getCollectParameterId());//参数 |
|
794 |
childVO.setItemType(confColl0.get(j).getItemType()); |
|
795 |
childVO.setItemValue(paramValue);//参数值 |
|
796 |
childVO.setItemText(confColl0.get(j).getCollectParameterName()); |
|
797 |
childVO.setCheckResult("1"); |
|
798 |
childVO.setCheckTime(format.format(new Date())); |
|
799 |
mesChildList0.add(childVO); |
|
800 |
} |
|
801 |
} |
|
802 |
|
|
803 |
//mesList.get(i).addAll(mesChildList0); |
|
804 |
|
|
805 |
} |
|
806 |
|
|
807 |
} |
|
808 |
|
|
809 |
CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
|
810 |
//插入参数采集表 |
|
811 |
daParamCollectionService.insertBatch(saveParamList); |
|
812 |
//上传到工厂mes |
|
813 |
ParentVO parentVO = new ParentVO(); |
|
814 |
parentVO.setStationCode(device);//工位 |
|
815 |
parentVO.setSiteCode("3983"); |
|
816 |
for (int i = 0; i < cellCodeList.size(); i++) {//循环4个电芯 |
|
817 |
if(!cellCodeList.get(i).isEmpty()){ |
|
818 |
parentVO.setRecordId(UUID.randomUUID().toString()); |
|
819 |
parentVO.setTotalResult("1"); |
|
820 |
parentVO.setProductNum(cellCodeList.get(i));//电芯码 |
|
821 |
//封装给工厂MES发送的childlist4 |
|
822 |
List<ChildVO> mesChildList = new ArrayList<>(mesChildList0); |
|
823 |
switch (i) { |
|
824 |
case 0 : |
|
825 |
mesChildList.addAll(mesChildList1); |
|
826 |
break; |
|
827 |
case 1 : |
|
828 |
mesChildList.addAll(mesChildList2); |
|
829 |
break; |
|
830 |
case 2 : |
|
831 |
mesChildList.addAll(mesChildList3); |
|
832 |
break; |
|
833 |
case 3 : |
|
834 |
mesChildList.addAll(mesChildList4); |
|
835 |
break; |
|
836 |
|
|
837 |
} |
|
838 |
|
|
839 |
//添加基础数据 |
|
840 |
List<ChildVO> basicList = getCollectParamBasicData(device,cellCodeList.get(i)); |
|
841 |
mesChildList.addAll(basicList); |
|
842 |
|
|
843 |
parentVO.setCheckList(mesChildList);//参数 |
|
844 |
//CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
|
845 |
log.info("执行工厂MES方法start,传入数据:{}",parentVO); |
|
846 |
HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_GET_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute(); |
|
847 |
log.info("执行工厂MES方法end,返回数据:{}",execute.body()); |
|
848 |
} |
|
849 |
} |
|
850 |
}); |
|
851 |
} |
|
852 |
}catch (Exception e) { |
|
853 |
log.error(e.getMessage()); |
|
854 |
throw new RuntimeException(e); |
|
855 |
} |
|
856 |
return result; |
|
857 |
} |
|
858 |
|
|
859 |
/** |
|
860 |
* OP020校验电芯挡位 |
|
861 |
* @param thoroughfare |
|
862 |
* @param device |
|
863 |
* @throws Exception |
|
864 |
*/ |
|
865 |
private Integer checkCellGear(String thoroughfare, String device,List<String> cellCodeList,String cellGear) throws Exception { |
|
866 |
Integer result = 11; |
|
867 |
|
|
868 |
for(int i = 0; i < cellCodeList.size(); i ++){ |
|
869 |
Integer cellStatus = 1; |
|
870 |
String cellCode = cellCodeList.get(i); |
|
871 |
if(!cellCode.isEmpty()){ |
|
872 |
List<DaCellData> list = daCellDataService.list(new LambdaQueryWrapper<DaCellData>() |
|
873 |
.eq(DaCellData::getGbCellCode,cellCode)); |
|
874 |
if(CollUtil.isNotEmpty(list)){ |
|
875 |
DaCellData daCellData = list.get(0); |
|
876 |
String cellValue = daCellData.getCellValue();//数据库中电芯挡位 |
|
877 |
String cellSerial = daCellData.getCellSerial();//数据库中电芯组别 |
|
878 |
if(!cellValue.isEmpty() && cellValue.equals(cellGear)){ |
|
879 |
cellStatus = 1; |
|
880 |
}else { |
|
881 |
cellStatus = 2; |
4ab63d
|
882 |
result = 16;//挡位校验不合格 |
61c519
|
883 |
} |
4ab63d
|
884 |
}/*else { |
61c519
|
885 |
cellStatus = 2; |
A |
886 |
result = 17;//查不到要校验的挡位 |
4ab63d
|
887 |
}*/ |
61c519
|
888 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_"+(i+1)).value(cellStatus).build()); |
A |
889 |
} |
|
890 |
} |
|
891 |
return result; |
|
892 |
} |
|
893 |
|
|
894 |
/** |
|
895 |
* 030工位返回ocv测试结果 |
|
896 |
* @param thoroughfare |
|
897 |
* @param device |
|
898 |
* @param cellCode |
|
899 |
* @throws Exception |
|
900 |
*/ |
|
901 |
private boolean OCVResultFeedBack(String thoroughfare, String device,String cellCode) throws Exception { |
|
902 |
boolean flag = true; |
|
903 |
List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() |
|
904 |
.eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode) |
|
905 |
.orderByDesc(DaTestDeviceInterfaceTemp::getCreateTime) |
|
906 |
); |
|
907 |
if (CollUtil.isNotEmpty(list)){ |
|
908 |
DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(0); |
|
909 |
if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ |
|
910 |
flag = true; |
|
911 |
}else { |
|
912 |
flag = false; |
|
913 |
} |
|
914 |
//daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); |
|
915 |
}else { |
|
916 |
flag = false; |
|
917 |
log.info("读取到工位{},测试设备返回的数据查询不到,电芯码为:{}",device,cellCode); |
|
918 |
} |
|
919 |
return flag; |
|
920 |
} |
|
921 |
/** |
|
922 |
* 030工位返回ocv测试结果 |
|
923 |
* @param thoroughfare |
|
924 |
* @param device |
|
925 |
* @throws Exception |
|
926 |
*/ |
|
927 |
private boolean OCVResultFeedBack(String thoroughfare, String device) throws Exception { |
|
928 |
boolean flag = true; |
|
929 |
Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_1").getValue(); |
|
930 |
if (ObjectUtil.isNotNull(value1)){ |
|
931 |
String cellCode = value1.toString(); |
|
932 |
List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() |
|
933 |
.eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode) |
|
934 |
.orderByDesc(DaTestDeviceInterfaceTemp::getCreateTime) |
|
935 |
); |
|
936 |
if (CollUtil.isNotEmpty(list)){ |
|
937 |
DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(0); |
|
938 |
if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ |
|
939 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(1).build()); |
|
940 |
}else { |
|
941 |
flag = false; |
|
942 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); |
|
943 |
} |
|
944 |
//daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); |
|
945 |
}else { |
|
946 |
flag = false; |
|
947 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(5).build()); |
|
948 |
log.info("读取到工位{},OP020工位没有给测试结果",device); |
|
949 |
} |
|
950 |
}else { |
|
951 |
flag = false; |
|
952 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(5).build()); |
|
953 |
log.info("读取到工位{},PLC没有给电芯码",device); |
|
954 |
} |
|
955 |
Object value2 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_2").getValue(); |
|
956 |
if (ObjectUtil.isNotNull(value2)){ |
|
957 |
String cellCode = value2.toString(); |
|
958 |
List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() |
|
959 |
.eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode) |
|
960 |
.orderByDesc(DaTestDeviceInterfaceTemp::getCreateTime) |
|
961 |
); |
|
962 |
if (CollUtil.isNotEmpty(list)){ |
|
963 |
DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(0); |
|
964 |
if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ |
|
965 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(1).build()); |
|
966 |
}else { |
|
967 |
flag = false; |
|
968 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(2).build()); |
|
969 |
} |
|
970 |
//daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); |
|
971 |
}else { |
|
972 |
flag = false; |
|
973 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(5).build()); |
|
974 |
log.info("读取到工位{},OP020工位没有给测试结果",device); |
|
975 |
} |
|
976 |
}else { |
|
977 |
flag = false; |
|
978 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(5).build()); |
|
979 |
log.info("读取到工位{},PLC没有给电芯码",device); |
|
980 |
} |
|
981 |
|
|
982 |
Object value3 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_3").getValue(); |
|
983 |
if (ObjectUtil.isNotNull(value3)){ |
|
984 |
String cellCode = value3.toString(); |
|
985 |
List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() |
|
986 |
.eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode) |
|
987 |
.orderByDesc(DaTestDeviceInterfaceTemp::getCreateTime) |
|
988 |
); |
|
989 |
if (CollUtil.isNotEmpty(list)){ |
|
990 |
DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(0); |
|
991 |
if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ |
|
992 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(1).build()); |
|
993 |
}else { |
|
994 |
flag = false; |
|
995 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(2).build()); |
|
996 |
} |
|
997 |
//daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); |
|
998 |
}else { |
|
999 |
flag = false; |
|
1000 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(5).build()); |
|
1001 |
log.info("读取到工位{},OP020工位没有给测试结果",device); |
|
1002 |
} |
|
1003 |
}else { |
|
1004 |
flag = false; |
|
1005 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(5).build()); |
|
1006 |
log.info("读取到工位{},PLC没有给电芯码",device); |
|
1007 |
} |
|
1008 |
|
|
1009 |
Object value4 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_4").getValue(); |
|
1010 |
if (ObjectUtil.isNotNull(value4)){ |
|
1011 |
String cellCode = value4.toString(); |
|
1012 |
List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() |
|
1013 |
.eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode) |
|
1014 |
.orderByDesc(DaTestDeviceInterfaceTemp::getCreateTime) |
|
1015 |
); |
|
1016 |
if (CollUtil.isNotEmpty(list)){ |
|
1017 |
DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(0); |
|
1018 |
if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ |
|
1019 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(1).build()); |
|
1020 |
}else { |
|
1021 |
flag = false; |
|
1022 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(2).build()); |
|
1023 |
} |
|
1024 |
//daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); |
|
1025 |
}else { |
|
1026 |
flag = false; |
|
1027 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(5).build()); |
|
1028 |
log.info("读取到工位{},OP020工位没有给测试结果",device); |
|
1029 |
} |
|
1030 |
}else { |
|
1031 |
flag = false; |
|
1032 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(5).build()); |
|
1033 |
log.info("读取到工位{},PLC没有给电芯码",device); |
|
1034 |
} |
|
1035 |
|
|
1036 |
return flag; |
|
1037 |
} |
|
1038 |
|
|
1039 |
/** |
|
1040 |
* AMES报工结果回传 |
|
1041 |
* @param productNum |
|
1042 |
* @param stationCode |
|
1043 |
* @param confirmTime |
|
1044 |
* @return |
|
1045 |
*/ |
|
1046 |
//{"code":"success","data":{"productNum":"LCV123456P0600036","stationCode":"1HZ01","resultCode":"S","resultText":"报工成功"},"message":"API调用成功"} |
|
1047 |
public static String getWorkReportResultFeedback(String productNum,String stationCode,String confirmTime) |
|
1048 |
{ |
|
1049 |
String result = ""; |
|
1050 |
try { |
|
1051 |
String url = Constants.FACTORY_EMS_UAT_GET_RUL + "workReportResultFeedback?siteCode="+Constants.FACTORY_EMS_SITE_CODE+"&stationCode="+stationCode+"&productNum="+productNum+"&confirmTime="+confirmTime; |
|
1052 |
HttpResponse response = HttpRequest.get(url).execute(); |
|
1053 |
HttpRequest httpRequest = HttpRequest.get(url); |
|
1054 |
result = response.body(); |
|
1055 |
}catch (Exception e){ |
|
1056 |
throw new RuntimeException(e); |
|
1057 |
}finally { |
|
1058 |
return result; |
|
1059 |
} |
|
1060 |
} |
|
1061 |
|
|
1062 |
|
|
1063 |
/** |
|
1064 |
* 获取采集参数基础数据 |
|
1065 |
* @param stationCode |
|
1066 |
* @param sfcCode |
|
1067 |
* @return list |
|
1068 |
*/ |
|
1069 |
public static List<ChildVO> getCollectParamBasicData(String stationCode,String sfcCode) { |
|
1070 |
List<ChildVO> basicList = new ArrayList<>(); |
|
1071 |
List<DaParamCollection> collectionList = new ArrayList<>(); |
|
1072 |
try { |
|
1073 |
//查询参数配置表 |
|
1074 |
List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
|
1075 |
.eq(DaCollectionParamConf::getProcessesCode, stationCode)//工位 |
|
1076 |
.eq(DaCollectionParamConf::getCollectParameterType, "BASIC")//采集参数类型 |
|
1077 |
); |
|
1078 |
if (CollUtil.isNotEmpty(list)){ |
|
1079 |
for(DaCollectionParamConf conf:list){ |
4162bc
|
1080 |
//1P1S生成 |
1ad632
|
1081 |
if("1P1S".equals(conf.getCollectParameterId())){ |
4162bc
|
1082 |
String result = get1P1S(sfcCode); |
C |
1083 |
conf.setParamCentral(result); |
|
1084 |
} |
61c519
|
1085 |
ChildVO childVO = new ChildVO(); |
A |
1086 |
childVO.setItemCode(conf.getCollectParameterId());//参数 |
|
1087 |
childVO.setItemType(conf.getItemType()); |
|
1088 |
childVO.setItemValue(conf.getParamCentral());//参数值 |
|
1089 |
childVO.setItemText(conf.getCollectParameterName()); |
|
1090 |
childVO.setCheckResult("1"); |
|
1091 |
childVO.setCheckTime(format.format(new Date())); |
|
1092 |
basicList.add(childVO); |
|
1093 |
|
|
1094 |
DaParamCollection daParamCollection = new DaParamCollection(); |
|
1095 |
daParamCollection.setSfcCode(sfcCode);//模组码 |
|
1096 |
daParamCollection.setParamCode(conf.getCollectParameterId());//参数编码 |
|
1097 |
daParamCollection.setParamName(conf.getCollectParameterName());//参数名称 |
|
1098 |
|
|
1099 |
daParamCollection.setParamValue(conf.getParamCentral());//参数值 |
|
1100 |
daParamCollection.setLocationCode(stationCode);//工位 |
|
1101 |
daParamCollection.setCollectionTime(new Date());//采集时间 |
|
1102 |
collectionList.add(daParamCollection);//封装参数采集list |
|
1103 |
} |
|
1104 |
daParamCollectionService.insertBatch(collectionList); |
|
1105 |
} |
|
1106 |
return basicList; |
|
1107 |
}catch (Exception e) { |
|
1108 |
throw new RuntimeException(e); |
|
1109 |
} |
|
1110 |
} |
4162bc
|
1111 |
/** |
C |
1112 |
* 生成1P1S码 |
|
1113 |
* @param sfcCode |
|
1114 |
* @return list |
|
1115 |
*/ |
|
1116 |
public static String get1P1S(String sfcCode) { |
|
1117 |
String result = ""; |
|
1118 |
LocalDate now = LocalDate.now(); |
|
1119 |
String supplierCode = sfcCode.substring(0,3); |
|
1120 |
try { |
|
1121 |
List<DaPsConf> list = daPsConfService.list(new LambdaQueryWrapper<DaPsConf>() |
|
1122 |
.eq(DaPsConf::getSpareField1, supplierCode)//供应商识别码 |
|
1123 |
.eq(DaPsConf::getState,"1"));//状态 |
|
1124 |
if(!list.isEmpty()){ |
|
1125 |
String mfCode = list.get(0).getMfCode();//厂商代码 |
|
1126 |
String proTypeCode = list.get(0).getProTypeCode();//产品类型代码 |
|
1127 |
String batteryTypeCode = list.get(0).getBatteryTypeCode();//电池类型代码 |
|
1128 |
String specificationsCode = list.get(0).getSpecificationsCode();//规格代码 |
|
1129 |
String traceInfoCode = list.get(0).getTraceInfoCode();//追溯信息代码 |
b42c5d
|
1130 |
String oldDateCode = list.get(0).getProDateCode(); |
4162bc
|
1131 |
String proDateCode = Constants.YEARSMAP.get(now.getYear()) |
C |
1132 |
+ Constants.MONTHSMAP.get(now.getMonthValue()) |
|
1133 |
+ Constants.DAYMAP.get(now.getDayOfMonth());//生产日期 |
|
1134 |
|
b42c5d
|
1135 |
String code = ""; |
C |
1136 |
if(oldDateCode.equals(proDateCode)){ |
|
1137 |
code = list.get(0).getSfcCode();//序列号 |
|
1138 |
}else { |
|
1139 |
code = "0"; |
|
1140 |
} |
4162bc
|
1141 |
code = StringUtils.leftPad(String.valueOf(Integer.valueOf(code)+1),7, "0");;//序列号 |
C |
1142 |
result = mfCode+proTypeCode+batteryTypeCode+specificationsCode+traceInfoCode+proDateCode+code; |
|
1143 |
|
|
1144 |
log.info("读取到电芯码为:{},1P1S码为:{}",sfcCode,result); |
|
1145 |
|
|
1146 |
//更新日期和序列号 |
|
1147 |
LambdaUpdateWrapper<DaPsConf> lambdaUpdateWrapper = new LambdaUpdateWrapper<DaPsConf>(); |
|
1148 |
lambdaUpdateWrapper.set(DaPsConf::getProDateCode,proDateCode);//生产日期 |
|
1149 |
lambdaUpdateWrapper.set(DaPsConf::getSfcCode,code);//序列号 |
|
1150 |
lambdaUpdateWrapper.eq(DaPsConf::getSpareField1,supplierCode);//供应商识别码 |
|
1151 |
lambdaUpdateWrapper.eq(DaPsConf::getState,"1");//状态 |
|
1152 |
daPsConfService.update(lambdaUpdateWrapper); |
|
1153 |
|
|
1154 |
}else{ |
|
1155 |
log.info("请先去1P1S配置页面配置规则!"); |
|
1156 |
} |
|
1157 |
return result; |
|
1158 |
}catch (Exception e) { |
|
1159 |
throw new RuntimeException(e); |
|
1160 |
} |
|
1161 |
} |
61c519
|
1162 |
|
A |
1163 |
|
|
1164 |
} |