| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.*; |
| | | import java.lang.annotation.Annotation; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.nio.file.StandardOpenOption; |
| | | import java.time.Duration; |
| | | import java.util.*; |
| | | import java.util.regex.Pattern; |
| | | import java.util.zip.ZipEntry; |
| | | import java.util.zip.ZipFile; |
| | | |
| | |
| | | private final DncBackFileService dncBackFileService; |
| | | private final MachineService machineService; |
| | | private final ParamService paramService; |
| | | private final MachineAnnotationConfig machineAnnotationConfig; |
| | | |
| | | /** |
| | | * 偏离单文件末尾的模式:P+数字 |
| | |
| | | //目录列表,即程序包列表 |
| | | for(String entryName : dirEntryNameList){ |
| | | DncSendBackData progData = new DncSendBackData(); |
| | | String folderName = StringUtils.removeEnd(entryName,"/"); |
| | | |
| | | //PackageAndProcessEdition pkgAndEdition = parseProgramPackageFromFolderName(folderName); |
| | | String packageName = folderName;//pkgAndEdition.getProgramPackageName(); |
| | | //String processEdition = pkgAndEdition.getProcessEdition(); |
| | | /* |
| | | if(StringUtils.isBlank(packageName) || StringUtils.isBlank(processEdition)){ |
| | | throw new ServiceException("包内文件夹名格式错误,应该为[零组件号-工序号-工序版次]:"+folderName); |
| | | }*/ |
| | | String packageName = StringUtils.removeEnd(entryName,"/"); |
| | | |
| | | progData.setProgramName(packageName); |
| | | Optional<String> optFilename = fileEntryNameList.stream().filter(n -> n.startsWith(entryName)).findFirst(); |
| | |
| | | String sendPathLine = FileContentUtil.readLineAt(bais,defAnnoProperties.getSendPathLineIndex());//状态注释行 |
| | | bais.reset(); |
| | | |
| | | |
| | | if(statusLine.contains("GH")){ |
| | | //固化,不应回传,忽略 |
| | | log.warn("状态{},不应回传,忽略",statusLine); |
| | |
| | | throw new ServiceException("根据下发路径未找到程序对应的机床:"+sendPathLine); |
| | | } |
| | | |
| | | if(statusLine.contains("SQ")){ |
| | | if(statusLine.contains(AnnotationUtil.SQ)){ |
| | | //试切 |
| | | programPackageNode = ncNodeService.getLastEditionTryingProgramPackage(packageName);//TODO 还需根据机床组(如何获取?根据下发路径获取机床,进而获取),,processEdition |
| | | }else if(statusLine.contains("PL")){ |
| | | //偏离 |
| | | }else if(statusLine.contains(AnnotationUtil.LG)){ |
| | | //临时更改单 |
| | | programPackageNode =ncNodeService.getLastEditionDeviationProgramPackage(packageName); |
| | | }else{ |
| | | //查询是否车床/现场编制,是车床可以放过,按试切处理, |
| | | //TODO 现场编制的程序,打包时必须在文件中增加下发路径(加入后) |
| | | programPackageNode = ncNodeService.getLastEditionTryingProgramPackage(packageName); |
| | | if(programPackageNode!=null){ |
| | | String chechuangVal = paramService.turninngValue(); |
| | | if(StringUtils.equals(machine.getMachineSpec(),chechuangVal)){ |
| | | //车床 |
| | | ProgramAnnotation pa = AnnotationUtil.getProgramAnnotationFormat(machine.getControlSystem(),annotionDictList); |
| | | statusLine = pa.addAnnotation(ProgramAnnotationService.SQ); |
| | | } |
| | | } |
| | | throw new ServiceException("状态注释不在范围内:"+statusLine+",仅试切、临时更改单可以回传"); |
| | | } |
| | | |
| | | if(programPackageNode != null) { |
| | |
| | | //根据内部文件,读取和分析程序包和程序文件数据 |
| | | List<String> dirList = entryNameList.stream().filter(s -> s.endsWith("/")).toList(); |
| | | for(String dir : dirList){ |
| | | String folderName = StringUtils.removeEnd(dir,"/"); |
| | | |
| | | //PackageAndProcessEdition pkgAndEdition = folderName;//parseProgramPackageFromFolderName(folderName); |
| | | String programPackageName = folderName; //pkgAndEdition.getProgramPackageName(); |
| | | String programPackageName = StringUtils.removeEnd(dir,"/"); |
| | | |
| | | Optional<NcNode> optPackageNode = allAcceptPackages.stream().filter(node -> StringUtils.equals(node.getName(),programPackageName)).findFirst(); |
| | | |
| | |
| | | FlowProgramFile newFlowFile = new FlowProgramFile(); |
| | | newFlowFile.setProgramName(packageNode.getName()); |
| | | newFlowFile.setProcessInstanceId(null);//先置为空,启动流程后设置该值 |
| | | newFlowFile.setFileType("program"); |
| | | newFlowFile.setFileType(FlowProgramFile.TYPE_PROGRAM); |
| | | newFlowFile.setName(fileName); |
| | | InputStream ins = zipFile.getInputStream(zipFile.getEntry(entryName)); |
| | | BladeFile newOssFile = ossTemplate.putFile("mdm",fileName,ins); |