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