| | |
| | | private void scannerGunMessage() throws Exception { |
| | | String[] parts = OPCElement.OP120_ZZ_CODE_CHECK.split("[.]"); |
| | | Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code1").getValue(); |
| | | if (null == SNCodeObject){ |
| | | SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code").getValue(); |
| | | } |
| | | if (null != SNCodeObject){ |
| | | String SNCode = SNCodeObject.toString(); |
| | | passingStationCollectionServiceImpl.sendMessage(SNCode); |
| | |
| | | Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code").getValue(); |
| | | if(null != SNCodeObject) { |
| | | String SNCode=SNCodeObject.toString(); |
| | | // String a=passingStationCollectionServiceImpl.SelectSN(SNCode,parts[1]); |
| | | String a="1"; |
| | | String a=passingStationCollectionServiceImpl.SelectSN(SNCode,parts[1]); |
| | | System.out.println("codeCheckFeed:"+a); |
| | | // String a="1"; |
| | | // 1:OK可生产 2:NG不可生产 3:NG可返工 4:PC检索失败(无记录)5:PC检索失败(软件) |
| | | if (StrUtil.isNotBlank(a)){ |
| | | int input = Integer.parseInt(a); |
| | |
| | | miloService.writeToOpcUa(entity2); |
| | | } |
| | | //如果是返修工位需要传输返修工位号 |
| | | if (OPCElement.OP465_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP355_ZZ_CODE_CHECK.equals(Node)){ |
| | | rework(SNCode); |
| | | if (OPCElement.OP465_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP355_ZZ_CODE_CHECK.equals(Node) |
| | | || OPCElement.OP695_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP755_ZZ_CODE_CHECK.equals(Node)){ |
| | | rework(SNCode,Node); |
| | | } |
| | | System.out.println(entity); |
| | | miloService.writeToOpcByte(entity); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private void rework(String SNCode) throws Exception{ |
| | | private void rework(String SNCode,String Node) throws Exception{ |
| | | BsOrderScheduling bsOrderScheduling = new BsOrderScheduling(); |
| | | bsOrderScheduling.setEngineNo(SNCode); |
| | | List<String> allProcessCoed = new ArrayList<>(); |
| | |
| | | rmRepairRecord.setBoxCode(SNCode); |
| | | List<ReadWriteEntity> writeList = new ArrayList<>(); |
| | | List<RmRepairRecord> rmRepairRecords = rmRepairRecordService.selectRmRepairRecordList(rmRepairRecord); |
| | | //过站记录 |
| | | DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection(); |
| | | PassingStationCollection.setSfcCode(SNCode); |
| | | //过站记录 |
| | | List<DaPassingStationCollection> daPassingStationCollections = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(PassingStationCollection); |
| | | |
| | | //所有反工工位 |
| | | List<String> collect1 = rmRepairRecords.stream().map(RmRepairRecord::getProcessesCode).collect(Collectors.toList()); |
| | | //所有放行工位 |
| | | List<String> collect2 = allProcessCoed; |
| | | if (CollUtil.isNotEmpty(rmRepairRecords)){ |
| | | //数据库查询出的工位 |
| | | rmRepairRecords.forEach(x -> { |
| | | ReadWriteEntity readWriteEntity = new ReadWriteEntity(); |
| | | readWriteEntity.setIdentifier(x.getProcessesCode()); |
| | | readWriteEntity.setValue(1); |
| | | writeList.add(readWriteEntity); |
| | | //查询出所有需要返修工位的最小op块 |
| | | Integer minOP = 0; |
| | | if (CollUtil.isNotEmpty(collect1)){ |
| | | |
| | | List<Integer> sortList = new ArrayList<>(); |
| | | collect1.stream().forEach(x ->{ |
| | | String op = x.replace("OP", ""); |
| | | if (StrUtil.isNotBlank(op)){ |
| | | int i = Integer.parseInt(op); |
| | | sortList.add(i); |
| | | } |
| | | }); |
| | | collect2 = allProcessCoed.stream().filter(x -> !collect1.contains(x)).collect(Collectors.toList()); |
| | | if (CollUtil.isNotEmpty(sortList)){ |
| | | List<Integer> collect2 = sortList.stream().sorted().collect(Collectors.toList()); |
| | | minOP = collect2.get(0); |
| | | } |
| | | } |
| | | if (CollUtil.isNotEmpty(collect2)){ |
| | | collect2.forEach(x -> { |
| | | |
| | | //所有放行工位 |
| | | //过站记录除去返修记录就是传2,返修数据及后面占位数据传1 |
| | | List<String> collect3 = daPassingStationCollections.stream().map(DaPassingStationCollection::getLocationCode).collect(Collectors.toList()); |
| | | if (CollUtil.isNotEmpty(collect1)){ |
| | | collect3 = collect3.stream().filter(x -> !collect1.contains(x)).collect(Collectors.toList()); |
| | | } |
| | | if (CollUtil.isNotEmpty(collect3)){ |
| | | collect3.forEach(x -> { |
| | | ReadWriteEntity readWriteEntity = new ReadWriteEntity(); |
| | | readWriteEntity.setIdentifier(x); |
| | | readWriteEntity.setValue(2); |
| | | writeList.add(readWriteEntity); |
| | | }); |
| | | } |
| | | //需生产工位 |
| | | List<String> collect4 = allProcessCoed; |
| | | if (CollUtil.isNotEmpty(collect3)){ |
| | | List<String> finalCollect = collect3; |
| | | collect4 = allProcessCoed.stream().filter(x -> !finalCollect.contains(x)).collect(Collectors.toList()); |
| | | } |
| | | if (CollUtil.isNotEmpty(collect4)){ |
| | | //数据库查询出的工位 |
| | | collect4.forEach(x -> { |
| | | ReadWriteEntity readWriteEntity = new ReadWriteEntity(); |
| | | readWriteEntity.setIdentifier(x); |
| | | readWriteEntity.setValue(1); |
| | | writeList.add(readWriteEntity); |
| | | }); |
| | | } |
| | | // List<String> collect2 = allProcessCoed; |
| | | // if (CollUtil.isNotEmpty(rmRepairRecords)){ |
| | | // //数据库查询出的工位 |
| | | // rmRepairRecords.forEach(x -> { |
| | | // ReadWriteEntity readWriteEntity = new ReadWriteEntity(); |
| | | // readWriteEntity.setIdentifier(x.getProcessesCode()); |
| | | // readWriteEntity.setValue(1); |
| | | // writeList.add(readWriteEntity); |
| | | // }); |
| | | // collect2 = allProcessCoed.stream().filter(x -> !collect1.contains(x)).collect(Collectors.toList()); |
| | | // } |
| | | // if (CollUtil.isNotEmpty(collect2)){ |
| | | // collect2.forEach(x -> { |
| | | // ReadWriteEntity readWriteEntity = new ReadWriteEntity(); |
| | | // readWriteEntity.setIdentifier(x); |
| | | // readWriteEntity.setValue(2); |
| | | // writeList.add(readWriteEntity); |
| | | // }); |
| | | // } |
| | | ReadWriteEntity readWriteEntity = new ReadWriteEntity(); |
| | | readWriteEntity.setIdentifier("Repair_sign"); |
| | | readWriteEntity.setValue(1); |
| | | readWriteEntity.setValue(minOP); |
| | | writeList.add(readWriteEntity); |
| | | miloService.writeToOpcByte(writeList); |
| | | } |
| | |
| | | public void SaveData(String Node) throws Exception { |
| | | String[] parts = Node.split("[.]"); |
| | | Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code1").getValue(); |
| | | |
| | | if (null == SNCodeObject){ |
| | | SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code").getValue(); |
| | | } |
| | | if(null != SNCodeObject) |
| | | { |
| | | String SNCode = SNCodeObject.toString(); |