提交 | 用户 | 时间
|
3e03af
|
1 |
package com.jcdm.main.plcserver.sub; |
C |
2 |
|
|
3 |
|
9e6d86
|
4 |
import cn.hutool.core.collection.CollUtil; |
W |
5 |
import cn.hutool.core.util.ObjectUtil; |
|
6 |
import cn.hutool.core.util.StrUtil; |
|
7 |
import com.jcdm.main.bs.domain.BsTechnologyRouteChildInfo; |
|
8 |
import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling; |
|
9 |
import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService; |
|
10 |
import com.jcdm.main.bs.technologyRouteChild.service.IBsTechnologyRouteChildInfoService; |
3e03af
|
11 |
import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf; |
C |
12 |
import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; |
059083
|
13 |
import com.jcdm.main.da.opcuaconfig.domain.DaOpcuaConfig; |
3e03af
|
14 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
C |
15 |
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; |
059083
|
16 |
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
W |
17 |
import com.jcdm.main.da.passingStationCollection.service.impl.DaPassingStationCollectionServiceImpl; |
3e03af
|
18 |
import com.jcdm.main.plcserver.conf.OPCElement; |
9e6d86
|
19 |
import com.jcdm.main.rm.repairRecord.domain.RmRepairRecord; |
W |
20 |
import com.jcdm.main.rm.repairRecord.service.IRmRepairRecordService; |
3e03af
|
21 |
import com.kangaroohy.milo.model.ReadWriteEntity; |
C |
22 |
import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
|
23 |
import com.kangaroohy.milo.service.MiloService; |
c76a3f
|
24 |
import javafx.animation.Timeline; |
059083
|
25 |
import lombok.extern.slf4j.Slf4j; |
3e03af
|
26 |
import org.springframework.stereotype.Component; |
C |
27 |
|
9f6314
|
28 |
import java.math.BigDecimal; |
c76a3f
|
29 |
import java.sql.Time; |
9e6d86
|
30 |
import java.time.LocalDateTime; |
c76a3f
|
31 |
import java.util.*; |
W |
32 |
import java.util.concurrent.TimeUnit; |
3e03af
|
33 |
import java.util.stream.Collectors; |
C |
34 |
|
|
35 |
|
059083
|
36 |
@Slf4j |
3e03af
|
37 |
@Component |
C |
38 |
public class OPCUaSubscription implements SubscriptionCallback { |
|
39 |
|
|
40 |
public static MiloService miloService; |
|
41 |
|
|
42 |
public IDaCollectionParamConfService collectionParamConfService; |
|
43 |
|
|
44 |
public IDaParamCollectionService daParamCollectionService; |
|
45 |
|
059083
|
46 |
public DaPassingStationCollectionServiceImpl passingStationCollectionServiceImpl; |
W |
47 |
|
|
48 |
public List<DaOpcuaConfig> lists; |
|
49 |
|
|
50 |
public static final HashMap<String,Integer> map = new HashMap<>(); |
|
51 |
|
9e6d86
|
52 |
public IBsOrderSchedulingService bsOrderSchedulingService; |
W |
53 |
|
|
54 |
public IRmRepairRecordService rmRepairRecordService; |
|
55 |
|
|
56 |
public IBsTechnologyRouteChildInfoService bsTechnologyRouteChildInfoService; |
|
57 |
|
c76a3f
|
58 |
public HashMap<String,List<DaCollectionParamConf>> allCollectParamList = new HashMap<>(); |
W |
59 |
|
3e03af
|
60 |
public OPCUaSubscription(MiloService miloService, |
C |
61 |
IDaCollectionParamConfService collectionParamConfService, |
059083
|
62 |
IDaParamCollectionService daParamCollectionService, |
W |
63 |
DaPassingStationCollectionServiceImpl passingStationCollectionServiceImpl, |
9e6d86
|
64 |
IBsOrderSchedulingService bsOrderSchedulingService, |
W |
65 |
List<DaOpcuaConfig> lists, |
|
66 |
IRmRepairRecordService rmRepairRecordService, |
|
67 |
IBsTechnologyRouteChildInfoService bsTechnologyRouteChildInfoService) { |
3e03af
|
68 |
OPCUaSubscription.miloService = miloService; |
C |
69 |
this.collectionParamConfService = collectionParamConfService; |
|
70 |
this.daParamCollectionService = daParamCollectionService; |
059083
|
71 |
this.passingStationCollectionServiceImpl = passingStationCollectionServiceImpl; |
9e6d86
|
72 |
this.bsOrderSchedulingService = bsOrderSchedulingService; |
059083
|
73 |
this.lists = lists; |
9e6d86
|
74 |
this.rmRepairRecordService = rmRepairRecordService; |
W |
75 |
this.bsTechnologyRouteChildInfoService = bsTechnologyRouteChildInfoService; |
c76a3f
|
76 |
|
W |
77 |
|
3e03af
|
78 |
} |
C |
79 |
@Override |
|
80 |
public void onSubscribe(String identifier, Object value) { |
|
81 |
String ecpStr = "";//异常记录标记 |
|
82 |
try { |
9e6d86
|
83 |
if(null != value && "1".equals(value.toString())) { |
c76a3f
|
84 |
// if (OPCElement.OP121_ZZ_CODE_CHECK.equals(identifier)){ |
W |
85 |
// rework("2V91Y RD25D080",identifier); |
|
86 |
// } |
059083
|
87 |
//1、检索SN号 |
W |
88 |
//2、过站参数采集 |
|
89 |
//3、扫码枪数据回传 |
|
90 |
List<String> collect1 = lists.stream().filter(x -> OPCElement.SN_CHECK.equals(x.getrFunction())) |
|
91 |
.map(DaOpcuaConfig::getNode).collect(Collectors.toList()); |
|
92 |
List<String> collect2 = lists.stream().filter(x -> OPCElement.SAVE_DATA.equals(x.getrFunction())) |
|
93 |
.map(DaOpcuaConfig::getNode).collect(Collectors.toList()); |
|
94 |
if (collect1.contains(identifier)){ |
c76a3f
|
95 |
log.info("-------监听到,{}的CODE_CHECK的信号",identifier); |
W |
96 |
log.info("-------time--------------,{}",LocalDateTime.now()); |
059083
|
97 |
//sn |
W |
98 |
this.SNRetrieval(identifier,value.toString()); |
|
99 |
if (identifier.equals(OPCElement.OP120_ZZ_CODE_CHECK) && "1".equals(value.toString())){ |
|
100 |
//总装上线扫码传输数据 |
|
101 |
log.info("-------监听到,{}的扫码枪扫码的CODE_CHECK的信号",identifier); |
9e6d86
|
102 |
scannerGunMessage(); |
W |
103 |
} |
|
104 |
} |
|
105 |
if (collect2.contains(identifier)){ |
|
106 |
if ("1".equals(value.toString())){ |
c76a3f
|
107 |
log.info("-------监听到,{}的SAVE_REQUEST_LAST的信号",identifier); |
W |
108 |
log.info("-------time--------------,{}",LocalDateTime.now()); |
9e6d86
|
109 |
//save |
W |
110 |
this.SaveData(identifier); |
c76a3f
|
111 |
|
059083
|
112 |
} |
W |
113 |
} |
|
114 |
|
3e03af
|
115 |
} |
C |
116 |
} catch (Exception e) { |
9e6d86
|
117 |
System.out.println(e.getMessage()); |
3e03af
|
118 |
} finally { |
C |
119 |
if (!"".equals(ecpStr)) { |
|
120 |
System.out.println(ecpStr + "\r\n"); |
|
121 |
} |
9e6d86
|
122 |
} |
W |
123 |
} |
|
124 |
|
|
125 |
private void scannerGunMessage() throws Exception { |
|
126 |
String[] parts = OPCElement.OP120_ZZ_CODE_CHECK.split("[.]"); |
|
127 |
Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code1").getValue(); |
3946f8
|
128 |
if (null == SNCodeObject){ |
W |
129 |
SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code").getValue(); |
|
130 |
} |
9e6d86
|
131 |
if (null != SNCodeObject){ |
W |
132 |
String SNCode = SNCodeObject.toString(); |
|
133 |
passingStationCollectionServiceImpl.sendMessage(SNCode); |
3e03af
|
134 |
} |
C |
135 |
} |
|
136 |
|
059083
|
137 |
public void SNRetrieval(String Node, String value) throws Exception { |
W |
138 |
String[] parts = Node.split("[.]"); |
|
139 |
if(value.equals("1")) { |
|
140 |
//SN号检索 |
|
141 |
Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code").getValue(); |
|
142 |
if(null != SNCodeObject) { |
|
143 |
String SNCode=SNCodeObject.toString(); |
929bdc
|
144 |
// String a=passingStationCollectionServiceImpl.SelectSN(SNCode,parts[1]); |
W |
145 |
String a; |
|
146 |
BsOrderScheduling bsOrderSchedulingQuery = new BsOrderScheduling(); |
|
147 |
bsOrderSchedulingQuery.setEngineNo(SNCode); |
|
148 |
List<BsOrderScheduling> queryOrderList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderSchedulingQuery); |
|
149 |
if (CollUtil.isNotEmpty(queryOrderList)){ |
|
150 |
a = "1"; |
|
151 |
}else { |
0e3cac
|
152 |
a = "4"; |
929bdc
|
153 |
} |
W |
154 |
//如果是返修工位需要传输返修工位号 |
0e3cac
|
155 |
List<DaPassingStationCollection> daPassingStationCollections = new ArrayList<>(); |
W |
156 |
List<RmRepairRecord> rmRepairRecords = new ArrayList<>(); |
929bdc
|
157 |
if (OPCElement.OP465_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP355_ZZ_CODE_CHECK.equals(Node) |
W |
158 |
|| OPCElement.OP695_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP755_ZZ_CODE_CHECK.equals(Node)){ |
|
159 |
//过站记录 |
|
160 |
DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection(); |
|
161 |
PassingStationCollection.setSfcCode(SNCode); |
0e3cac
|
162 |
daPassingStationCollections = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(PassingStationCollection); |
929bdc
|
163 |
if (CollUtil.isNotEmpty(daPassingStationCollections)){ |
W |
164 |
DaPassingStationCollection lastOne = daPassingStationCollections.get(daPassingStationCollections.size() - 1); |
|
165 |
String outRsSign = lastOne.getOutRsSign(); |
|
166 |
if ("合格".equals(outRsSign)){ |
|
167 |
a = "1"; |
|
168 |
}else { |
|
169 |
a = "2"; |
|
170 |
} |
|
171 |
} |
0e3cac
|
172 |
RmRepairRecord rmRepairRecord = new RmRepairRecord(); |
W |
173 |
rmRepairRecord.setBoxCode(SNCode); |
|
174 |
rmRepairRecords = rmRepairRecordService.selectRmRepairRecordList(rmRepairRecord); |
|
175 |
if (CollUtil.isNotEmpty(rmRepairRecords)){ |
|
176 |
a = "1"; |
|
177 |
} |
|
178 |
|
929bdc
|
179 |
} |
c76a3f
|
180 |
log.info("-----返回codeCheckFeed-----,{}",a); |
3946f8
|
181 |
// String a="1"; |
059083
|
182 |
// 1:OK可生产 2:NG不可生产 3:NG可返工 4:PC检索失败(无记录)5:PC检索失败(软件) |
9e6d86
|
183 |
if (StrUtil.isNotBlank(a)){ |
W |
184 |
int input = Integer.parseInt(a); |
|
185 |
ReadWriteEntity entity = new ReadWriteEntity(parts[0]+"."+parts[1]+".CodeCheckFeed", input); |
|
186 |
log.info("-------监听到,{}的CodeCheck的信号",Node); |
cffac1
|
187 |
miloService.writeToOpcByte(entity); |
W |
188 |
log.info("监听到返回codecheckfeed信号,{}",entity); |
9e6d86
|
189 |
//首站传输订单号 |
W |
190 |
if (OPCElement.OP050_HX_CODE_CHECK.equals(Node)){ |
|
191 |
//查询订单号 |
|
192 |
BsOrderScheduling bsOrderScheduling = new BsOrderScheduling(); |
|
193 |
bsOrderScheduling.setEngineNo(SNCode); |
|
194 |
List<BsOrderScheduling> tempList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling); |
|
195 |
String orderNum = ""; |
|
196 |
if (CollUtil.isNotEmpty(tempList)){ |
|
197 |
BsOrderScheduling bsOrderScheduling1 = tempList.get(0); |
|
198 |
orderNum = bsOrderScheduling1.getOrderNo(); |
|
199 |
} |
|
200 |
|
|
201 |
ReadWriteEntity entity2 = new ReadWriteEntity(parts[0]+"."+parts[1]+".OrderNumber", orderNum); |
2b59de
|
202 |
miloService.writeToOpcUa(entity2); |
9e6d86
|
203 |
} |
W |
204 |
//如果是返修工位需要传输返修工位号 |
3946f8
|
205 |
if (OPCElement.OP465_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP355_ZZ_CODE_CHECK.equals(Node) |
W |
206 |
|| OPCElement.OP695_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP755_ZZ_CODE_CHECK.equals(Node)){ |
929bdc
|
207 |
|
0e3cac
|
208 |
rework(SNCode,Node,daPassingStationCollections,rmRepairRecords); |
9e6d86
|
209 |
} |
3946f8
|
210 |
System.out.println(entity); |
cffac1
|
211 |
|
9e6d86
|
212 |
} |
W |
213 |
|
059083
|
214 |
} |
9e6d86
|
215 |
} |
W |
216 |
} |
|
217 |
|
0e3cac
|
218 |
private void rework(String SNCode,String Node,List<DaPassingStationCollection> daPassingStationCollections,List<RmRepairRecord> rmRepairRecords) throws Exception{ |
9e6d86
|
219 |
BsOrderScheduling bsOrderScheduling = new BsOrderScheduling(); |
W |
220 |
bsOrderScheduling.setEngineNo(SNCode); |
|
221 |
List<String> allProcessCoed = new ArrayList<>(); |
929bdc
|
222 |
List<BsTechnologyRouteChildInfo> bsTechnologyRouteChildInfos = new ArrayList<>(); |
9e6d86
|
223 |
List<String> collect = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling).stream().map(BsOrderScheduling::getModel).collect(Collectors.toList()); |
W |
224 |
if (CollUtil.isNotEmpty(collect)){ |
|
225 |
String s = collect.get(0); |
|
226 |
//查找次机型的完整工序 |
929bdc
|
227 |
bsTechnologyRouteChildInfos = bsTechnologyRouteChildInfoService.selectAllTechnologyRouteByProductCode(s); |
9e6d86
|
228 |
if (CollUtil.isNotEmpty(bsTechnologyRouteChildInfos)){ |
W |
229 |
allProcessCoed = bsTechnologyRouteChildInfos.stream().map(BsTechnologyRouteChildInfo::getProcessesCode).collect(Collectors.toList()); |
|
230 |
} |
|
231 |
} |
0e3cac
|
232 |
// RmRepairRecord rmRepairRecord = new RmRepairRecord(); |
W |
233 |
// rmRepairRecord.setBoxCode(SNCode); |
9e6d86
|
234 |
List<ReadWriteEntity> writeList = new ArrayList<>(); |
0e3cac
|
235 |
// List<RmRepairRecord> rmRepairRecords = rmRepairRecordService.selectRmRepairRecordList(rmRepairRecord); |
3946f8
|
236 |
//过站记录 |
0e3cac
|
237 |
// DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection(); |
W |
238 |
// PassingStationCollection.setSfcCode(SNCode); |
3946f8
|
239 |
//过站记录 |
0e3cac
|
240 |
// List<DaPassingStationCollection> daPassingStationCollections = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(PassingStationCollection); |
3946f8
|
241 |
|
9e6d86
|
242 |
//所有反工工位 |
W |
243 |
List<String> collect1 = rmRepairRecords.stream().map(RmRepairRecord::getProcessesCode).collect(Collectors.toList()); |
3946f8
|
244 |
if (CollUtil.isNotEmpty(collect1)){ |
929bdc
|
245 |
//查询出所有需要返修工位的最小op块 |
W |
246 |
Integer minOP = 0; |
|
247 |
if (CollUtil.isNotEmpty(collect1)){ |
3946f8
|
248 |
|
929bdc
|
249 |
List<Integer> sortList = new ArrayList<>(); |
W |
250 |
collect1.stream().forEach(x ->{ |
|
251 |
String op = x.replace("OP", ""); |
|
252 |
if (StrUtil.isNotBlank(op)){ |
|
253 |
int i = Integer.parseInt(op); |
|
254 |
sortList.add(i); |
|
255 |
} |
|
256 |
}); |
|
257 |
if (CollUtil.isNotEmpty(sortList)){ |
|
258 |
List<Integer> collect2 = sortList.stream().filter(Objects::nonNull).sorted().collect(Collectors.toList()); |
|
259 |
minOP = collect2.get(0); |
3946f8
|
260 |
} |
W |
261 |
} |
929bdc
|
262 |
//获取过站记录的最大工位 |
W |
263 |
String maxCode = null; |
|
264 |
if (CollUtil.isNotEmpty(daPassingStationCollections)){ |
|
265 |
DaPassingStationCollection lastOne = daPassingStationCollections.get(daPassingStationCollections.size() - 1); |
|
266 |
maxCode = lastOne.getLocationCode(); |
28860f
|
267 |
} |
W |
268 |
|
|
269 |
|
929bdc
|
270 |
//所有放行工位 |
W |
271 |
List<String> passStation = new ArrayList<>(); |
|
272 |
//所有生产工位 |
|
273 |
List<String> productStation = new ArrayList<>(); |
|
274 |
//最大工位编号 |
|
275 |
Integer maxCodeNum = 0; |
|
276 |
if (StrUtil.isNotEmpty(maxCode)){ |
|
277 |
String finalMaxCode = maxCode; |
|
278 |
//获取当前工位对应工步号 |
|
279 |
List<String> collect2 = bsTechnologyRouteChildInfos.stream() |
|
280 |
.filter(x -> x.getProcessesCode().equals(finalMaxCode)) |
|
281 |
.map(BsTechnologyRouteChildInfo::getStepNo).collect(Collectors.toList()); |
|
282 |
if (CollUtil.isNotEmpty(collect2)){ |
|
283 |
String s = collect2.get(0); |
|
284 |
if (StrUtil.isNotBlank(s)){ |
|
285 |
maxCodeNum = Integer.parseInt(s); |
|
286 |
} |
|
287 |
} |
|
288 |
if (CollUtil.isNotEmpty(bsTechnologyRouteChildInfos)){ |
|
289 |
bsTechnologyRouteChildInfos.forEach(x -> { |
|
290 |
x.setStepNoNum(Integer.parseInt(x.getStepNo())); |
|
291 |
}); |
|
292 |
Integer finalMaxCodeNum = maxCodeNum; |
|
293 |
//勾选的返修工位中最大的工位之后的工位----1 |
|
294 |
List<BsTechnologyRouteChildInfo> collect3 = bsTechnologyRouteChildInfos.stream() |
|
295 |
.filter(x -> x.getStepNoNum() >= finalMaxCodeNum).collect(Collectors.toList()); |
|
296 |
if (CollUtil.isNotEmpty(collect3)){ |
|
297 |
//需要生产 |
|
298 |
productStation.addAll(collect3.stream().map(BsTechnologyRouteChildInfo::getProcessesCode).collect(Collectors.toList())); |
|
299 |
} |
|
300 |
//从第一个工位到返修的最大工位之间, |
|
301 |
//勾选了返修标记的需要生产---1,未勾选的不生产---2 |
|
302 |
productStation.addAll(collect1); |
|
303 |
} |
|
304 |
} |
|
305 |
if (CollUtil.isNotEmpty(productStation)){ |
|
306 |
List<String> collect2 = allProcessCoed.stream().filter(x -> !productStation.contains(x)).collect(Collectors.toList()); |
|
307 |
passStation.addAll(collect2); |
|
308 |
} |
|
309 |
String[] parts = Node.split("[.]"); |
|
310 |
String par = parts[0]+"."+parts[1]; |
|
311 |
if (CollUtil.isNotEmpty(passStation)){ |
|
312 |
passStation.forEach(x -> { |
|
313 |
ReadWriteEntity readWriteEntity = new ReadWriteEntity(); |
|
314 |
readWriteEntity.setIdentifier(par+"."+x); |
|
315 |
readWriteEntity.setValue(2); |
|
316 |
writeList.add(readWriteEntity); |
|
317 |
}); |
|
318 |
} |
|
319 |
if (CollUtil.isNotEmpty(productStation)){ |
|
320 |
productStation.forEach(x -> { |
|
321 |
ReadWriteEntity readWriteEntity = new ReadWriteEntity(); |
|
322 |
readWriteEntity.setIdentifier(par+"."+x); |
|
323 |
readWriteEntity.setValue(1); |
|
324 |
writeList.add(readWriteEntity); |
|
325 |
}); |
|
326 |
} |
|
327 |
ReadWriteEntity readWriteEntity = new ReadWriteEntity(); |
|
328 |
readWriteEntity.setIdentifier(parts[0]+"."+parts[1]+".Repair_sign"); |
|
329 |
readWriteEntity.setValue(minOP); |
|
330 |
miloService.writeToOpcShort(readWriteEntity); |
|
331 |
miloService.writeToOpcByte(writeList); |
|
332 |
log.info("返修写入:,{}",writeList); |
|
333 |
} |
|
334 |
|
059083
|
335 |
} |
W |
336 |
|
|
337 |
|
3e03af
|
338 |
public void SaveData(String Node) throws Exception { |
28860f
|
339 |
|
059083
|
340 |
String[] parts = Node.split("[.]"); |
3e03af
|
341 |
Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code1").getValue(); |
3946f8
|
342 |
if (null == SNCodeObject){ |
W |
343 |
SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code").getValue(); |
|
344 |
} |
3e03af
|
345 |
if(null != SNCodeObject) |
C |
346 |
{ |
|
347 |
String SNCode = SNCodeObject.toString(); |
c76a3f
|
348 |
Object object = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Runtime").getValue(); |
W |
349 |
String gatherAddress = parts[0] + "." + parts[1]; |
|
350 |
List<DaCollectionParamConf> list = new ArrayList<>(); |
|
351 |
if (allCollectParamList.containsKey(gatherAddress)){ |
|
352 |
list = allCollectParamList.get(gatherAddress); |
|
353 |
}else { |
|
354 |
DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf(); |
|
355 |
daCollectionParamConf.setGatherAddress(gatherAddress); |
|
356 |
daCollectionParamConf.setRemarks("1"); |
|
357 |
list = collectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf); |
|
358 |
if (CollUtil.isNotEmpty(list)){ |
|
359 |
//加入hashmap |
|
360 |
allCollectParamList.put(gatherAddress,list); |
|
361 |
} |
|
362 |
} |
3e03af
|
363 |
|
C |
364 |
List<String> nodeIdList = list.stream().map(info -> { |
|
365 |
String nodeid = info.getGatherAddress(); |
|
366 |
return nodeid; |
|
367 |
}).collect(Collectors.toList()); |
|
368 |
|
f4cb4d
|
369 |
List<ReadWriteEntity> readWriteEntityList = new ArrayList<>(); |
W |
370 |
if(CollUtil.isNotEmpty(nodeIdList)){ |
c76a3f
|
371 |
long time1 = new Date().getTime(); |
f4cb4d
|
372 |
readWriteEntityList = miloService.readFromOpcUa(nodeIdList); |
c76a3f
|
373 |
long time2 = new Date().getTime(); |
W |
374 |
log.info("读取点位花费时间:{},",time2-time1); |
f4cb4d
|
375 |
} |
c76a3f
|
376 |
//返回plc保存成功 |
W |
377 |
if (parts.length==3){ |
|
378 |
if ("SaveRequest".equals(parts[2])){ |
|
379 |
ReadWriteEntity entity = new ReadWriteEntity(parts[0] + "." + parts[1] + ".SaveFeed", 1); |
|
380 |
miloService.writeToOpcByte(entity); |
|
381 |
}else if ("SaveRequestLast".equals(parts[2])){ |
|
382 |
ReadWriteEntity entity = new ReadWriteEntity(parts[0] + "." + parts[1] + ".SaveFeedLast", 1); |
|
383 |
miloService.writeToOpcByte(entity); |
|
384 |
} |
|
385 |
log.info("-------请求返回,{}的SaveFeedLast的信号",Node); |
|
386 |
log.info("-------请求返回-----,{}",LocalDateTime.now()); |
|
387 |
} |
3e03af
|
388 |
List<DaParamCollection> daParamCollectionlist = new ArrayList<>(); |
f4cb4d
|
389 |
if (CollUtil.isNotEmpty(nodeIdList)){ |
W |
390 |
for(int i=0;i<nodeIdList.size();i++){ |
|
391 |
if(!readWriteEntityList.get(i).getValue().toString().equals("0.0")){ |
|
392 |
DaParamCollection ParamCollection = new DaParamCollection(); |
|
393 |
ParamCollection.setParamCode(readWriteEntityList.get(i).getIdentifier().toString().split("[.]")[2]); |
|
394 |
ParamCollection.setLocationCode(parts[1]); |
|
395 |
if (readWriteEntityList.get(i) == null){ |
|
396 |
ParamCollection.setParamValue("0"); |
|
397 |
}else { |
|
398 |
ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString()); |
|
399 |
} |
|
400 |
ParamCollection.setSfcCode(SNCode); |
|
401 |
ParamCollection.setParamName(list.get(i).getCollectParameterName()); |
|
402 |
ParamCollection.setParamUpper(list.get(i).getParamUpper()); |
|
403 |
ParamCollection.setParamLower(list.get(i).getParamLower()); |
|
404 |
ParamCollection.setUnit(list.get(i).getCollectParameterUnit()); |
|
405 |
ParamCollection.setState("合格"); |
|
406 |
ParamCollection.setType(list.get(i).getCollectParameterType()); |
|
407 |
ParamCollection.setCollectionTime(new Date()); |
|
408 |
daParamCollectionlist.add(ParamCollection); |
c6aaad
|
409 |
} |
3e03af
|
410 |
} |
f4cb4d
|
411 |
daParamCollectionService.saveBeachDaParamCollection(daParamCollectionlist); |
W |
412 |
log.info("-------保存数据完成---------"); |
3e03af
|
413 |
} |
f4cb4d
|
414 |
|
W |
415 |
|
9e6d86
|
416 |
|
c76a3f
|
417 |
|
9e6d86
|
418 |
Long beatTime = 0L; |
W |
419 |
if (ObjectUtil.isNotEmpty(object)){ |
9f6314
|
420 |
String str = object.toString(); |
W |
421 |
beatTime = Float.valueOf(str).longValue(); |
9e6d86
|
422 |
} |
W |
423 |
DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection(); |
|
424 |
PassingStationCollection.setSfcCode(SNCode); |
|
425 |
PassingStationCollection.setLocationCode(parts[1]); |
|
426 |
PassingStationCollection.setOutboundTime(new Date()); |
|
427 |
PassingStationCollection.setInboundTime(new Date(new Date().getTime()-beatTime*1000)); |
|
428 |
PassingStationCollection.setCollectionTime(new Date()); |
|
429 |
PassingStationCollection.setCreateTime(new Date()); |
|
430 |
PassingStationCollection.setBeatTime(beatTime.toString()); |
|
431 |
PassingStationCollection.setOutRsSign("合格"); |
|
432 |
passingStationCollectionServiceImpl.insertDaPassingStationCollection(PassingStationCollection); |
c76a3f
|
433 |
log.info("-------保存过站记录数据完成---------"); |
W |
434 |
|
059083
|
435 |
} |
3e03af
|
436 |
} |
C |
437 |
} |