提交 | 用户 | 时间
|
a5b351
|
1 |
package com.jcdm.main.plcserver.sub; |
C |
2 |
|
|
3 |
|
6a462f
|
4 |
import cn.hutool.core.collection.CollUtil; |
8f0f8d
|
5 |
import cn.hutool.core.date.DateUtil; |
6a462f
|
6 |
import cn.hutool.core.util.StrUtil; |
e70fb4
|
7 |
import cn.hutool.json.JSONObject; |
8f0f8d
|
8 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
懒 |
9 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
288790
|
10 |
import com.jcdm.common.utils.StringUtils; |
49c784
|
11 |
import com.jcdm.framework.websocket.WebSocketUsers; |
6a462f
|
12 |
import com.jcdm.main.constant.Constants; |
a5b351
|
13 |
import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf; |
C |
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; |
|
18 |
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; |
e70fb4
|
19 |
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; |
A |
20 |
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; |
a5b351
|
21 |
import com.jcdm.main.plcserver.conf.OPCElement; |
c5e9c5
|
22 |
import com.jcdm.main.plcserver.util.TimeUtil; |
e70fb4
|
23 |
import com.jcdm.main.restful.factoryMes.service.RestfulService; |
a5b351
|
24 |
import com.kangaroohy.milo.model.ReadWriteEntity; |
C |
25 |
import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
|
26 |
import com.kangaroohy.milo.service.MiloService; |
|
27 |
import org.springframework.beans.factory.annotation.Autowired; |
|
28 |
import org.springframework.stereotype.Component; |
|
29 |
|
49c784
|
30 |
import javax.websocket.Session; |
c5e9c5
|
31 |
import java.text.SimpleDateFormat; |
32483a
|
32 |
import java.util.*; |
a5b351
|
33 |
import java.util.stream.Collectors; |
C |
34 |
|
|
35 |
|
|
36 |
@Component |
|
37 |
public class OPCUaSubscription implements SubscriptionCallback { |
e70fb4
|
38 |
|
A |
39 |
public SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
32483a
|
40 |
|
5316c5
|
41 |
//新自动工站 |
d545f1
|
42 |
public List<String> automaticList = Arrays.asList("OP280","OP310A","OP310B", "OP300A","OP300B", "OP320A","OP320B", "OP340A","OP340B", "OP350A","OP350B", "OP360","OP365","OP370", "OP390", "OP470"); |
5316c5
|
43 |
|
7a0867
|
44 |
//采集模组工位 ModuleCode |
3581b1
|
45 |
public List<String> moduleCodeList = Arrays.asList("OP300A","OP300B","OP320A","OP320B","OP340A","OP340B","OP365", "OP350A", "OP350B", "OP330"); |
a5b351
|
46 |
|
7a0867
|
47 |
//区分模组型号工位 |
A |
48 |
public List<String> distinguishingModules = Arrays.asList("OP300","OP310", "OP340", "OP350", "OP330"); |
|
49 |
|
4a5f2a
|
50 |
//区分小车码 |
A |
51 |
public List<String> agvId = Arrays.asList("OP360", "OP390", "OP470","OP280"); |
|
52 |
|
5316c5
|
53 |
|
A |
54 |
//区分pack型号的工位 |
7a0867
|
55 |
public List<String> packIdList = Arrays.asList("OP280","OP360","OP390","OP470"); |
A |
56 |
|
288790
|
57 |
//测试设备手动工位 |
A |
58 |
public List<String> testList = Arrays.asList("OP430-1","OP430-2","OP430-3","OP430-4","OP480-1","OP480-2","OP480-3","OP440"); |
|
59 |
|
8f0f8d
|
60 |
|
63b254
|
61 |
//空的 |
8f0f8d
|
62 |
public List<String> nullList = Arrays.asList("OP250","OP260"); |
懒 |
63 |
|
|
64 |
|
a5b351
|
65 |
public static MiloService miloService; |
49c784
|
66 |
|
懒 |
67 |
Map<String, Session> map = WebSocketUsers.getUsers(); |
a5b351
|
68 |
|
C |
69 |
public IDaPassingStationCollectionService daPassingStationCollectionService; |
|
70 |
|
054a69
|
71 |
public static IDaCollectionParamConfService collectionParamConfService; |
a5b351
|
72 |
|
054a69
|
73 |
public static IDaParamCollectionService daParamCollectionService; |
a5b351
|
74 |
|
e70fb4
|
75 |
public static IOmProductionOrdeInfoService omProductionOrdeInfoService; |
A |
76 |
|
a5b351
|
77 |
public OPCUaSubscription(MiloService miloService, |
C |
78 |
IDaPassingStationCollectionService daPassingStationCollectionService, |
|
79 |
IDaCollectionParamConfService collectionParamConfService, |
e70fb4
|
80 |
IDaParamCollectionService daParamCollectionService, |
A |
81 |
IOmProductionOrdeInfoService omProductionOrdeInfoService) { |
a5b351
|
82 |
OPCUaSubscription.miloService = miloService; |
C |
83 |
this.daPassingStationCollectionService = daPassingStationCollectionService; |
8f0f8d
|
84 |
OPCUaSubscription.collectionParamConfService = collectionParamConfService; |
懒 |
85 |
OPCUaSubscription.daParamCollectionService = daParamCollectionService; |
e70fb4
|
86 |
OPCUaSubscription.omProductionOrdeInfoService = omProductionOrdeInfoService; |
a5b351
|
87 |
} |
C |
88 |
|
|
89 |
|
|
90 |
@Override |
|
91 |
public void onSubscribe(String identifier, Object value) { |
|
92 |
|
|
93 |
try { |
70cc26
|
94 |
if(null != value && Integer.valueOf(value.toString())!= 0) { |
a5b351
|
95 |
String[] nodes = identifier.split("[.]"); |
C |
96 |
String thoroughfare = nodes[0];//通道 |
|
97 |
String device = nodes[1];//设备 |
|
98 |
String tab = nodes[2];//标记 |
|
99 |
String tabVlaue = value.toString();//地址值 |
|
100 |
|
288790
|
101 |
if (("RecordData").equals(tab)) { |
a5b351
|
102 |
String recordDataDoneValue = ""; |
C |
103 |
|
|
104 |
if("1".equals(tabVlaue)){ |
89f416
|
105 |
|
e70fb4
|
106 |
//请求工单 |
A |
107 |
// if(device.equals("OP230")){ |
|
108 |
// getFactoryOrder("OP230"); |
|
109 |
// } |
|
110 |
|
|
111 |
//自动工位 |
5316c5
|
112 |
if(automaticList.stream().anyMatch(s -> s.equals(device))){ |
A |
113 |
//plc给我们一个模组码,拿模组码校验出型号 |
288790
|
114 |
if(moduleCodeList.stream().anyMatch(s -> s.equals(device))) { |
A |
115 |
String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; |
5316c5
|
116 |
//读模组码 |
288790
|
117 |
Object moduleCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); |
A |
118 |
|
|
119 |
if(moduleCode!=null){ |
06713a
|
120 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build()); |
288790
|
121 |
}else { |
A |
122 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(12).build()); |
|
123 |
} |
7a0867
|
124 |
}else { |
4a5f2a
|
125 |
if(agvId.stream().anyMatch(s -> s.equals(device))){ |
288790
|
126 |
Object agvIdObject = miloService.readFromOpcUa(thoroughfare + "." + device + ".AGVID").getValue(); |
A |
127 |
//agvId 小车码是否为空 |
|
128 |
if(agvIdObject!=null){ |
|
129 |
String PACKCode = thoroughfare + "." + device + ".MPACKCode"; |
|
130 |
OmProductionOrdeInfo one = omProductionOrdeInfoService.getOne(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getTrolleyYard, agvIdObject.toString())); |
|
131 |
//小车码查找工单是否为空 |
|
132 |
if(one!=null){ |
|
133 |
String packId = one.getProductNum(); |
|
134 |
miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(PACKCode).value(packId).build()); |
|
135 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); |
|
136 |
}else { |
|
137 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); |
|
138 |
} |
|
139 |
}else { |
4a5f2a
|
140 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); |
A |
141 |
} |
7a0867
|
142 |
|
288790
|
143 |
}else { |
A |
144 |
String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; |
|
145 |
Object packCodeObject = miloService.readFromOpcUa(thoroughfare + "." + device + ".PACKCode").getValue(); |
|
146 |
if(packCodeObject!=null){ |
|
147 |
//pack 如果区分型号的话就要处理 |
|
148 |
//记录数据完成 |
|
149 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build()); |
|
150 |
}else { |
|
151 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(12).build()); |
|
152 |
} |
|
153 |
|
|
154 |
} |
e70fb4
|
155 |
} |
A |
156 |
}else { |
|
157 |
//手动工位处理逻辑 |
288790
|
158 |
WebSocketUsers.sendMessageToUserByText(map.get(device), "IN"); |
e70fb4
|
159 |
String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; |
A |
160 |
|
|
161 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build()); |
32483a
|
162 |
} |
e70fb4
|
163 |
|
7bff29
|
164 |
|
a5b351
|
165 |
}else if("2".equals(tabVlaue)){ |
32483a
|
166 |
if(automaticList.stream().anyMatch(s -> s.equals(device))){ |
懒 |
167 |
//自动工位 |
|
168 |
//出站保存数据 |
|
169 |
recordDataDoneValue = outSaveDate(thoroughfare,device); |
|
170 |
//记录数据完成 |
|
171 |
String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; |
70cc26
|
172 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(Integer.valueOf(recordDataDoneValue)).build()); |
32483a
|
173 |
}else { |
懒 |
174 |
//手动工位 |
1c84ae
|
175 |
if(device.contains("OP330")){ |
A |
176 |
String str = device.substring(0,5); |
|
177 |
WebSocketUsers.sendMessageToUserByText(map.get(str), "END"); |
|
178 |
}else { |
|
179 |
WebSocketUsers.sendMessageToUserByText(map.get(device), "END"); |
288790
|
180 |
} |
A |
181 |
if(testList.stream().anyMatch(s -> s.equals(device))){ |
|
182 |
String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; |
|
183 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(21).build()); |
1c84ae
|
184 |
} |
32483a
|
185 |
} |
3c2299
|
186 |
}else { |
懒 |
187 |
System.out.println("^"); |
|
188 |
} |
|
189 |
} |
|
190 |
//保存拧紧数据 |
|
191 |
else if (("AngleResult").equals(tab)) { |
b5fcd8
|
192 |
if("1".equals(tabVlaue)||"2".equals(tabVlaue)){ |
32483a
|
193 |
List<String> list = new ArrayList<>(); |
0caf87
|
194 |
String[] suffixes = {"Torque", "Angle", "TorqueResult", "AngleResult"}; |
32483a
|
195 |
|
懒 |
196 |
for (String suffix : suffixes) { |
|
197 |
String string = thoroughfare + "." + device + "." + suffix; |
|
198 |
list.add(string); |
|
199 |
} |
49c784
|
200 |
List<ReadWriteEntity> list1 = miloService.readFromOpcUa(list); |
懒 |
201 |
List<Object> collect = list1.stream().map(ReadWriteEntity::getValue).collect(Collectors.toList()); |
|
202 |
String joinedString = String.join(",", collect.toString()); |
4a5f2a
|
203 |
WebSocketUsers.sendMessageToUserByText(map.get(device), TightenTheConversionOkNg(joinedString)); |
a5b351
|
204 |
} |
C |
205 |
} |
|
206 |
} |
|
207 |
} catch (Exception e) { |
|
208 |
|
|
209 |
} |
|
210 |
} |
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
/** |
|
215 |
* 获取SNCode |
|
216 |
*/ |
|
217 |
public String getSNCode(){ |
|
218 |
String SNCode = ""; |
|
219 |
return SNCode; |
|
220 |
} |
|
221 |
|
|
222 |
/** |
|
223 |
* 出站保存数据 |
|
224 |
*/ |
|
225 |
public String outSaveDate(String thoroughfare,String device) { |
8f0f8d
|
226 |
String snCode = ""; |
a5b351
|
227 |
String result = ""; |
8f0f8d
|
228 |
String read = thoroughfare + "." + device + "."; |
懒 |
229 |
|
a5b351
|
230 |
try { |
8f0f8d
|
231 |
if(nullList.stream().noneMatch(s -> s.equals(device))){ |
懒 |
232 |
if(moduleCodeList.stream().anyMatch(s -> s.equals(device))){ |
|
233 |
read = read + "ModuleCode"; |
|
234 |
}else { |
|
235 |
read = read + "PACKCode"; |
|
236 |
} |
|
237 |
} |
|
238 |
snCode = miloService.readFromOpcUa(read).getValue().toString(); |
|
239 |
|
|
240 |
if(null == snCode || "".equals(snCode)){ |
|
241 |
result = "22"; |
a5b351
|
242 |
}else{ |
8f0f8d
|
243 |
|
e70fb4
|
244 |
String workOrderNo = ""; |
A |
245 |
String productCode = ""; |
|
246 |
//2、保存过站采集数据 |
|
247 |
Object orderNumberObject = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "WorkOrderNumber").getValue(); |
|
248 |
if(orderNumberObject!=null){ |
|
249 |
workOrderNo = orderNumberObject.toString(); |
|
250 |
} |
|
251 |
|
|
252 |
Object productCodeObject = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "ProductType").getValue(); |
|
253 |
if(productCodeObject!=null){ |
|
254 |
productCode = productCodeObject.toString(); |
|
255 |
} |
89f416
|
256 |
|
8f0f8d
|
257 |
saveStationInfo(snCode,thoroughfare,device,workOrderNo,productCode); |
a5b351
|
258 |
//3、保存参数采集数据 |
8f0f8d
|
259 |
SaveParamData(snCode,thoroughfare,device,workOrderNo,productCode); |
e70fb4
|
260 |
|
A |
261 |
//如果是末尾工站要报工 |
|
262 |
if(device.equals("OP500")){ |
|
263 |
RestfulService.getWorkReportResultFeedback(snCode,device,format.format(new Date())); |
|
264 |
//1、更新工单信息 |
|
265 |
updateOrderInfo(snCode); |
|
266 |
} |
a5b351
|
267 |
|
C |
268 |
result = "21"; |
|
269 |
|
|
270 |
} |
|
271 |
|
|
272 |
}catch (Exception e) { |
8f0f8d
|
273 |
System.out.println(e.getMessage()); |
a5b351
|
274 |
} |
C |
275 |
return result; |
|
276 |
} |
|
277 |
|
8f0f8d
|
278 |
|
懒 |
279 |
// /** |
|
280 |
// * 出站保存数据 |
|
281 |
// */ |
|
282 |
// public String outSaveDate(String thoroughfare,String device) { |
|
283 |
// String result = ""; |
|
284 |
// try { |
|
285 |
// //读取SNCode |
|
286 |
// String PACKCode = thoroughfare + "." + device + ".PACKCode"; |
|
287 |
// Object PACKCodeObject = miloService.readFromOpcUa(PACKCode).getValue(); |
|
288 |
// if(null == PACKCodeObject || "".equals(PACKCodeObject)){ |
|
289 |
// result = "22"; |
|
290 |
// }else{ |
|
291 |
// String PACKCodeParam = PACKCodeObject.toString(); |
|
292 |
// //1、更新工单信息 |
|
293 |
// //updateOrderInfo(); |
|
294 |
// //2、保存过站采集数据 |
|
295 |
// saveStationInfo(PACKCodeParam,thoroughfare,device); |
|
296 |
// //3、保存参数采集数据 |
|
297 |
// SaveParamData(PACKCodeParam,thoroughfare,device,"",""); |
|
298 |
// |
|
299 |
// result = "21"; |
|
300 |
// |
|
301 |
// } |
|
302 |
// |
|
303 |
// }catch (Exception e) { |
|
304 |
// |
|
305 |
// } |
|
306 |
// return result; |
|
307 |
// } |
|
308 |
|
a5b351
|
309 |
/** |
C |
310 |
* 保存过站采集 |
|
311 |
*/ |
8f0f8d
|
312 |
public void saveStationInfo(String packCode,String thoroughfare,String device,String workOrderNo,String productCode) throws Exception { |
c5e9c5
|
313 |
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US); |
懒 |
314 |
sdf.setTimeZone(TimeZone.getTimeZone("GMT+8")); // CST通常表示中国标准时间,即东八区 |
32483a
|
315 |
String prefix = thoroughfare+"."+device+"."; |
c5e9c5
|
316 |
String startTime = miloService.readFromOpcUa(prefix + "StartTime").getValue().toString(); |
懒 |
317 |
String stopTime = miloService.readFromOpcUa(prefix + "StopTime").getValue().toString(); |
32483a
|
318 |
String stationStatus = miloService.readFromOpcUa(prefix + "StationStatus").getValue().toString(); |
懒 |
319 |
|
a5b351
|
320 |
DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); |
32483a
|
321 |
daPassingStationCollection.setSfcCode(packCode); |
懒 |
322 |
daPassingStationCollection.setWorkOrderNo(workOrderNo); |
8f0f8d
|
323 |
daPassingStationCollection.setProductCode(productCode); |
懒 |
324 |
daPassingStationCollection.setLocationCode(device); |
c5e9c5
|
325 |
String strt = TimeUtil.stringProcessing(startTime); |
懒 |
326 |
String end = TimeUtil.stringProcessing(stopTime); |
|
327 |
daPassingStationCollection.setInboundTime(sdf.parse(strt));//入站时间 |
|
328 |
daPassingStationCollection.setOutboundTime(sdf.parse(end));//出站时间 |
32483a
|
329 |
daPassingStationCollection.setOutRsSign(stationStatus);//出站是否合格 |
a5b351
|
330 |
daPassingStationCollectionService.insertDaPassingStationCollection(daPassingStationCollection); |
C |
331 |
} |
|
332 |
|
054a69
|
333 |
public static void SaveParamData(String packCode,String thoroughfare,String device,String workOrderNo,String productType) throws Exception { |
a5b351
|
334 |
List<DaCollectionParamConf> list; |
C |
335 |
DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf(); |
|
336 |
daCollectionParamConf.setGatherAddress(thoroughfare+ "." + device); |
|
337 |
list = collectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf); |
|
338 |
|
|
339 |
List<String> nodeIdList = list.stream().map(info -> { |
|
340 |
String nodeid = info.getGatherAddress(); |
|
341 |
return nodeid; |
|
342 |
}).collect(Collectors.toList()); |
|
343 |
|
|
344 |
if(!nodeIdList.isEmpty()){ |
|
345 |
List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(nodeIdList); |
e70fb4
|
346 |
for (int i = 0; i < readWriteEntityList.size(); i++) { |
A |
347 |
if(readWriteEntityList.get(i).getValue() == null){ |
|
348 |
readWriteEntityList.get(i).setValue(" "); |
|
349 |
} |
|
350 |
} |
a5b351
|
351 |
List<DaParamCollection> daParamCollectionlist = new ArrayList<>(); |
C |
352 |
for(int i=0;i<nodeIdList.size();i++){ |
|
353 |
if(!readWriteEntityList.get(i).getValue().toString().equals("0.0")){ |
c5e9c5
|
354 |
String tt = readWriteEntityList.get(i).getValue().toString(); |
32483a
|
355 |
DaParamCollection ParamCollection = new DaParamCollection(); |
懒 |
356 |
ParamCollection.setParamCode(list.get(i).getCollectParameterId()); |
a5b351
|
357 |
ParamCollection.setLocationCode(device); |
c5e9c5
|
358 |
if(tt.contains("Time")){ |
288790
|
359 |
// String str = TimeUtil.getTimestamp(TimeUtil.stringProcessing(tt)); |
A |
360 |
// ParamCollection.setParamValue(str); |
|
361 |
ParamCollection.setParamValue(TimeUtil.getYyyyDdMm(TimeUtil.stringProcessing(tt))); |
c5e9c5
|
362 |
}else { |
懒 |
363 |
ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString()); |
|
364 |
} |
32483a
|
365 |
ParamCollection.setSfcCode(packCode); |
288790
|
366 |
if(device.contains("OP360")){ |
A |
367 |
String node = nodeIdList.get(i); |
|
368 |
Object value = miloService.readFromOpcUa("PACK.OP360.ModuleSNCode"+node.charAt(node.length()-1)).getValue(); |
|
369 |
if(value!=null){ |
|
370 |
ParamCollection.setModuleCode(value.toString()); |
|
371 |
} |
|
372 |
} |
a5b351
|
373 |
ParamCollection.setParamName(list.get(i).getCollectParameterName()); |
C |
374 |
ParamCollection.setParamUpper(list.get(i).getParamUpper()); |
|
375 |
ParamCollection.setParamLower(list.get(i).getParamLower()); |
|
376 |
ParamCollection.setUnit(list.get(i).getCollectParameterUnit()); |
|
377 |
//ParamCollection.setState("合格"); |
|
378 |
ParamCollection.setType(list.get(i).getCollectParameterType()); |
|
379 |
ParamCollection.setCollectionTime(new Date()); |
054a69
|
380 |
ParamCollection.setWorkOrderNo(workOrderNo); |
懒 |
381 |
ParamCollection.setProductCode(productType); |
|
382 |
daParamCollectionlist.add(ParamCollection); |
|
383 |
// daParamCollectionService.insertDaParamCollection(ParamCollection); |
a5b351
|
384 |
} |
C |
385 |
} |
054a69
|
386 |
daParamCollectionService.saveBeachDaParamCollection(daParamCollectionlist); |
a5b351
|
387 |
} |
8f0f8d
|
388 |
addBaseData(workOrderNo,productType,device,packCode); |
a5b351
|
389 |
|
C |
390 |
} |
8f0f8d
|
391 |
|
懒 |
392 |
public static void addBaseData(String workOrderNo,String productCode,String locationCode,String packCode){ |
|
393 |
Map<String, String> map = new HashMap<>(); |
|
394 |
map.put("GC", "南浔工厂"); |
|
395 |
map.put("CXBH", "Pack线"); |
|
396 |
map.put("SBBH", "设备001"); |
|
397 |
map.put("YGBH", "员工001"); |
|
398 |
List<DaParamCollection> confList = new ArrayList<>(); |
|
399 |
map.forEach((key, value) -> { |
|
400 |
List<DaCollectionParamConf> daCollectionParamConfs = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
|
401 |
.eq(DaCollectionParamConf::getProcessesCode,locationCode) |
|
402 |
.like(DaCollectionParamConf::getCollectParameterId,key)); |
|
403 |
DaParamCollection saveData = new DaParamCollection(); |
|
404 |
saveData.setWorkOrderNo(workOrderNo); |
|
405 |
saveData.setProductCode(productCode); |
|
406 |
saveData.setLocationCode(locationCode); |
|
407 |
saveData.setSfcCode(packCode); |
|
408 |
saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId()); |
|
409 |
saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName()); |
|
410 |
saveData.setCollectionTime(new Date()); |
|
411 |
saveData.setParamValue(value); |
|
412 |
confList.add(saveData); |
|
413 |
}); |
|
414 |
daParamCollectionService.insertBatch(confList); |
|
415 |
} |
e70fb4
|
416 |
|
A |
417 |
public static void getFactoryOrder(String locationCode){ |
|
418 |
String productionWorkOrder = RestfulService.getProductionWorkOrderRequest("", locationCode); |
|
419 |
JSONObject jsonObject = new JSONObject(productionWorkOrder); |
|
420 |
JSONObject dataObject = jsonObject.getJSONObject("data"); |
|
421 |
|
|
422 |
String productNum = dataObject.getStr("productNum"); |
|
423 |
String stationCode = dataObject.getStr("stationCode"); |
|
424 |
String materialCode = dataObject.getStr("materialCode"); |
|
425 |
String productionOrderNum = dataObject.getStr("productionOrderNum"); |
|
426 |
|
|
427 |
OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo(); |
|
428 |
omProductionOrdeInfo.setProductNum(productNum); |
|
429 |
omProductionOrdeInfo.setWorkOrderNo(productionOrderNum); |
|
430 |
omProductionOrdeInfo.setStationCode(stationCode); |
|
431 |
omProductionOrdeInfo.setProductCode(materialCode); |
|
432 |
omProductionOrdeInfoService.save(omProductionOrdeInfo); |
|
433 |
} |
|
434 |
|
|
435 |
public static void updateOrderInfo(String packCode){ |
|
436 |
OmProductionOrdeInfo one = omProductionOrdeInfoService.getOne(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum, packCode)); |
|
437 |
one.setOrderStatus("5"); |
|
438 |
omProductionOrdeInfoService.saveOrUpdate(one); |
|
439 |
} |
|
440 |
|
4a5f2a
|
441 |
public static void avgFunction(){ |
A |
442 |
|
|
443 |
} |
|
444 |
|
|
445 |
public static String TightenTheConversionOkNg(String param){ |
|
446 |
// 去除首尾的方括号,然后按照逗号分割字符串 |
|
447 |
String[] parts = param.substring(1, param.length() - 1).split(","); |
|
448 |
|
|
449 |
// 创建一个新的StringBuilder来构建替换后的字符串 |
|
450 |
StringBuilder sb = new StringBuilder(); |
|
451 |
sb.append('['); // 添加左方括号 |
|
452 |
|
|
453 |
for (int i = 0; i < parts.length; i++) { |
|
454 |
String part = parts[i].trim(); // 去除可能的空格 |
|
455 |
float value; |
|
456 |
try { |
|
457 |
value = Float.parseFloat(part); // 尝试将字符串转换为浮点数 |
|
458 |
String replacement; |
|
459 |
if (value == 1f) { |
|
460 |
replacement = "OK"; |
|
461 |
} else if (value == 2f) { |
|
462 |
replacement = "NG"; |
|
463 |
} else { |
|
464 |
replacement = part; // 如果不是1或2,则保持不变 |
|
465 |
} |
|
466 |
sb.append(replacement); |
|
467 |
if (i < parts.length - 1) { |
|
468 |
sb.append(','); // 添加逗号(除了最后一个元素) |
|
469 |
} |
|
470 |
} catch (NumberFormatException e) { |
|
471 |
// 如果转换失败,则保持原样(或进行其他错误处理) |
|
472 |
sb.append(part); |
|
473 |
if (i < parts.length - 1) { |
|
474 |
sb.append(','); |
|
475 |
} |
|
476 |
} |
|
477 |
} |
|
478 |
sb.append(']'); // 添加右方括号 |
|
479 |
return sb.toString(); |
|
480 |
} |
|
481 |
|
6a462f
|
482 |
|
W |
483 |
/** |
|
484 |
* 校验是否存在NG |
|
485 |
* @param packCode sfcCode |
|
486 |
* @return boolean |
|
487 |
*/ |
|
488 |
public boolean checkIsNG(String packCode,String modelCode){ |
|
489 |
List<DaPassingStationCollection> list = daPassingStationCollectionService.list(new LambdaQueryWrapper<DaPassingStationCollection>() |
|
490 |
.eq(StrUtil.isNotBlank(packCode),DaPassingStationCollection::getSfcCode, packCode) |
|
491 |
.eq(DaPassingStationCollection::getOutRsSign, Constants.UN_PASS)); |
|
492 |
return CollUtil.isEmpty(list); |
|
493 |
} |
|
494 |
|
a5b351
|
495 |
} |