| | |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | | import org.springblade.mdm.program.entity.NcProgramExchange; |
| | | import org.springblade.mdm.program.mapper.NcProgramExchangeMapper; |
| | | import org.springblade.mdm.program.service.programannotation.AnnotationProcessor; |
| | | import org.springblade.mdm.program.service.programannotation.DefaultProcessor; |
| | | import org.springblade.mdm.program.service.programannotation.FanucProcessor; |
| | | import org.springblade.mdm.program.service.programannotation.MachineAnnotationConfig; |
| | | import org.springblade.mdm.program.service.programannotation.*; |
| | | import org.springblade.mdm.program.vo.DncSendBackData; |
| | | import org.springblade.mdm.program.vo.DncSendBackFile; |
| | | import org.springblade.mdm.program.vo.ProgramAnnotation; |
| | |
| | | private final ParamService paramService; |
| | | private final MachineAnnotationConfig machineAnnotationConfig; |
| | | |
| | | private final FanucProcessor fanucProcessor; |
| | | private final DefaultProcessor defaultProcessor; |
| | | /** |
| | | * 偏离单文件末尾的模式:P+数字 |
| | | */ |
| | |
| | | }*/ |
| | | |
| | | progData.setProgramName(packageName); |
| | | String statusLine; |
| | | Optional<String> optFilename = fileEntryNameList.stream().filter(n -> n.startsWith(entryName)).findFirst(); |
| | | if(optFilename.isPresent()){ |
| | | entry = zipFile.getEntry(optFilename.get()); |
| | | InputStream ins = zipFile.getInputStream(entry); |
| | | ByteArrayInputStream bais = new ByteArrayInputStream(IOUtils.toByteArray(ins));; |
| | | progData.setFileBackTime(DateUtil.fromInstant(entry.getLastModifiedTime().toInstant())); |
| | | //machineAnnotationConfig.getConfigMap().get(machine.getcon) |
| | | Pattern fanucPattern = Pattern.compile("^[oO]\\d{4}"); |
| | | String testLine = FileContentUtil.readLineAt(bais,2);//TODO,fanuc这行是下发路径,其他机器是状态 |
| | | |
| | | AnnotationProperties defAnnoProperties =AnnotationProperties.getDefault(); |
| | | String statusLine = FileContentUtil.readLineAt(bais,defAnnoProperties.getStatusLineIndex());//状态注释行 |
| | | bais.reset(); |
| | | //boolean isFanuc = fanucPattern.matcher(testLine).matches(); |
| | | boolean isFanuc = !StringUtils.containsAny(testLine,"(SQ)","(GH)","(PL)"); |
| | | if(isFanuc){ |
| | | statusLine = FileContentUtil.readLineAt(bais,3);//fanuc的状态读第4行 |
| | | }else{ |
| | | statusLine = testLine; |
| | | String sendPathLine = FileContentUtil.readLineAt(bais,defAnnoProperties.getSendPathLineIndex());//状态注释行 |
| | | bais.reset(); |
| | | |
| | | |
| | | if(statusLine.contains("GH")){ |
| | | //固化,不应回传,忽略 |
| | | log.warn("状态{},不应回传,忽略",statusLine); |
| | | continue; |
| | | } |
| | | |
| | | Machine machine = this.machineService.getMachineBySendPathAnnotation(sendPathLine); |
| | | if(machine == null){ |
| | | throw new ServiceException("根据下发路径未找到程序对应的机床:"+sendPathLine); |
| | | } |
| | | |
| | | if(statusLine.contains("SQ")){ |
| | | //试切 |
| | | programPackageNode = ncNodeService.getLastEditionTryingProgramPackage(packageName);//,processEdition |
| | | }else if(statusLine.contains("GH")){ |
| | | //固化 |
| | | programPackageNode = ncNodeService.getLastEditionCuredProgramPackage(packageName); |
| | | programPackageNode = ncNodeService.getLastEditionTryingProgramPackage(packageName);//TODO 还需根据机床组(如何获取?根据下发路径获取机床,进而获取),,processEdition |
| | | }else if(statusLine.contains("PL")){ |
| | | //偏离 |
| | | programPackageNode =ncNodeService.getLastEditionDeviationProgramPackage(packageName); |
| | | }else{ |
| | | //查询是否车床,是车床可以放过,按试切处理 |
| | | //查询是否车床/现场编制,是车床可以放过,按试切处理, |
| | | //TODO 现场编制的程序,打包时必须在文件中增加下发路径(加入后) |
| | | programPackageNode = ncNodeService.getLastEditionTryingProgramPackage(packageName); |
| | | if(programPackageNode!=null){ |
| | | Machine machine = machineService.getByCode(programPackageNode.getMachineCode()); |
| | | String chechuangVal = paramService.turninngValue(); |
| | | if(StringUtils.equals(machine.getMachineSpec(),chechuangVal)){ |
| | | //车床 |
| | | ProgramAnnotation pa = programAnnotationService.getProgramAnnotationFormat(machine.getControlSystem(),annotionDictList); |
| | | ProgramAnnotation pa = AnnotationUtil.getProgramAnnotationFormat(machine.getControlSystem(),annotionDictList); |
| | | statusLine = pa.addAnnotation(ProgramAnnotationService.SQ); |
| | | } |
| | | } |