| | |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.FileUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.mdm.basesetting.machine.entity.Machine; |
| | | import org.springblade.mdm.basesetting.machine.service.MachineService; |
| | | import org.springblade.mdm.commons.service.ParamService; |
| | | import org.springblade.mdm.flow.entity.FlowProgramFile; |
| | | import org.springblade.mdm.flow.service.CureFlowService; |
| | | import org.springblade.mdm.flow.service.FlowCommonService; |
| | | import org.springblade.mdm.flow.service.FlowProgramFileService; |
| | | import org.springblade.mdm.program.entity.DncBackFile; |
| | | 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.vo.DncSendBackData; |
| | | import org.springblade.mdm.program.vo.DncSendBackFile; |
| | | import org.springblade.mdm.program.vo.ProgramAnnotation; |
| | | import org.springblade.mdm.utils.FileContentUtil; |
| | | import org.springblade.mdm.utils.ZipTextFileContentUtil; |
| | | import org.springblade.system.pojo.entity.DictBiz; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | @AllArgsConstructor |
| | | public class DNCSendBackService extends BizServiceImpl<NcProgramExchangeMapper, NcProgramExchange> { |
| | | private final CureFlowService cureFlowService; |
| | | private final FlowProgramFileService flowProgramFileService; |
| | | private final ProgramAnnotationService programAnnotationService; |
| | | private final NcNodeService ncNodeService; |
| | | private final OssTemplate ossTemplate; |
| | | private final BladeRedis bladeRedis; |
| | | private final FlowCommonService flowCommonService; |
| | | private final DncBackFileService dncBackFileService; |
| | | private final ProgramFlowStatusQueryService programFlowStatusQueryService; |
| | | |
| | | private final MachineService machineService; |
| | | private final ParamService paramService; |
| | | /** |
| | | * 偏离单文件末尾的模式:P+数字 |
| | | */ |
| | |
| | | } |
| | | } |
| | | |
| | | List<DictBiz> annotionDictList = programAnnotationService.getAnnotionDictList(); |
| | | NcNode programPackageNode; |
| | | //目录列表,即程序包列表 |
| | | for(String entryName : dirEntryNameList){ |
| | |
| | | } |
| | | |
| | | progData.setProgramName(packageName); |
| | | String statusLine = ""; |
| | | String statusLine; |
| | | Optional<String> optFilename = fileEntryNameList.stream().filter(n -> n.startsWith(entryName)).findFirst(); |
| | | if(optFilename.isPresent()){ |
| | | entry = zipFile.getEntry(optFilename.get()); |
| | |
| | | //偏离 |
| | | programPackageNode =ncNodeService.getLastEditionDeviationProgramPackage(packageName,processEdition); |
| | | }else{ |
| | | throw new ServiceException("未找到程序文件中的状态注释"); |
| | | //查询是否车床,是车床可以放过,按试切处理 |
| | | programPackageNode = ncNodeService.getLastEditionTryingProgramPackage(packageName,processEdition); |
| | | 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); |
| | | statusLine = pa.addAnnotation(ProgramAnnotationService.SQ); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(programPackageNode != null) { |
| | | progData.setId(programPackageNode.getId()); |
| | | progData.setProgramNo(programPackageNode.getProgramNo()); |
| | |
| | | progData.setFiles(programFiles); |
| | | list.add(progData); |
| | | }else{ |
| | | throw new ServiceException("找不到程序包名:"+packageName+statusLine); |
| | | throw new ServiceException("找不到程序包名:"+packageName); |
| | | } |
| | | }else{ |
| | | throw new ServiceException(entryName+"包下未找到文件"+statusLine); |
| | | throw new ServiceException(entryName+"包下未找到文件"); |
| | | } |
| | | |
| | | } |
| | |
| | | //根据内部文件,读取和分析程序包和程序文件数据 |
| | | List<String> dirList = entryNameList.stream().filter(s -> s.endsWith("/")).toList(); |
| | | for(String dir : dirList){ |
| | | //String programPackageName1 = StringUtils.removeEnd(dir,"/"); |
| | | String folderName = StringUtils.removeEnd(dir,"/"); |
| | | |
| | | PackageAndProcessEdition pkgAndEdition = parseProgramPackageFromFolderName(folderName); |
| | |
| | | String result = ""; |
| | | String zipFileName = bladeRedis.get(getFileKey()); |
| | | return ZipTextFileContentUtil.getTextContent(this.ossTemplate.statFileStream(zipFileName),entryName); |
| | | |
| | | |
| | | /* |
| | | try(InputStream inputStream = this.ossTemplate.statFileStream(zipFileName);){ |
| | | Path tempZipFile = createTempFile(inputStream); |