| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.base.BizServiceImpl; |
| | |
| | | private final FlowProgramFileService flowProgramFileService; |
| | | private final ProgramAnnotationService programAnnotationService; |
| | | |
| | | public static final String ANNOTATION_DICT = "machine_annotation"; |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query 查询参数 |
| | | * @return |
| | | */ |
| | | public IPage<DncSendBackData> dncSendBackPageQuery(Query query) { |
| | | return this.getBaseMapper().dncSendBackpageQuery(Condition.getPage(query),query); |
| | | } |
| | | |
| | | /** |
| | | * 导出dnc压缩包 |
| | |
| | | }else if(programPackageNode.hasCured()){ |
| | | status = "GH"; |
| | | } |
| | | long deviationSerial = -1;//偏离单序号 ,-1为非偏离单,不需要加入 |
| | | if(packageNode.isDeviationProgram()) { |
| | | deviationSerial = ncNodeService.getDeviationSerialForNode(packageNode); |
| | | } |
| | | |
| | | List<DictBiz> annotationDictList= programAnnotationService.getAnnotionList(); |
| | | for (NcNode node : programNodes) { |
| | | String filePathInZip = packageFolder + node.getName(); |
| | | String filePathInZip = genFilePathInZip(packageFolder,node,deviationSerial); |
| | | programFile = this.flowProgramFileService.getById(node.getFlowProgramFileId()); |
| | | if(programFile.isProgram()) {//程序文件,才会加入压缩包 |
| | | InputStream inputStream = ossTemplate.statFileStream(programFile.getOssName()); |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 加入机床下发路径和程序状态的注释 |
| | | * @param inputStream |
| | | * @return |
| | | * 生成在zip中的文件路径 |
| | | * @param packageFolder zip中的文件夹 |
| | | * @param programNode 程序节点 |
| | | * @param deviationSerial 偏离单序号 |
| | | * @return zip中的文件路径 |
| | | */ |
| | | /* |
| | | InputStream addSendDirAnnotation(InputStream inputStream,Machine machine,List<Dict> annotationList) throws IOException { |
| | | //检测第二行是否是路径 |
| | | String annotationText = programAnnotationService.generateAnnotation(machine.getProgSendDir()==null? StringUtil.EMPTY:machine.getProgSendDir(),machine.getMachineGroupCode(),annotationList); |
| | | String genFilePathInZip(String packageFolder,NcNode programNode,long deviationSerial){ |
| | | //为文件名增加偏离单号 |
| | | String filePathInZip; |
| | | |
| | | //TODO 改判断行内容 |
| | | return FileContentUtil.insertLine(inputStream,1,annotationText); |
| | | }*/ |
| | | if(deviationSerial != -1){ |
| | | //加入偏离单序号 |
| | | String ext = FilenameUtils.getExtension(programNode.getName()); |
| | | String dotExt = StringUtils.isNotBlank(ext)?"."+ext:ext;//带点的扩展名 |
| | | |
| | | /** |
| | | * 添加程序专改的注释 |
| | | * @param inputStream |
| | | * @param status 程序状态 |
| | | * @param machine |
| | | * @param annotationList 配置的注释字典列表 |
| | | * @return |
| | | * @throws IOException |
| | | */ |
| | | /* |
| | | InputStream addProgramStatusAnnotation(InputStream inputStream,String status,Machine machine,List<Dict> annotationList) throws IOException { |
| | | String annoText= programAnnotationService.generateAnnotation(status,machine.getMachineGroupCode(),annotationList); |
| | | |
| | | return FileContentUtil.insertLine(inputStream,2,annoText); |
| | | }*/ |
| | | |
| | | /** |
| | | * 判断一行文本是否是注释 |
| | | * @param line |
| | | * @param annotationList |
| | | * @return |
| | | */ |
| | | /* |
| | | boolean isAnnotation(String line,List<Dict> annotationList){ |
| | | boolean isAnno = false; |
| | | |
| | | return isAnno; |
| | | }*/ |
| | | |
| | | |
| | | /* |
| | | String generateAnnotation(String oriTest,String machineGroupCode,List<Dict> annotationList) { |
| | | R<List<Dict>> dictsResult = dictClient.getList(ANNOTATION_DICT); |
| | | String annotation = oriTest; |
| | | String begin = "("; |
| | | String end = ")"; |
| | | |
| | | Optional<Dict> dictOpt = dictsResult.getData().stream().filter(dict -> {return dict.getDictKey().equals(machineGroupCode);}).findFirst(); |
| | | String annotationSetting = "(,)"; |
| | | if(dictOpt.isPresent()) { |
| | | annotationSetting = dictOpt.get().getDictValue(); |
| | | String temp = programNode.getName(); |
| | | if(StringUtils.isNotBlank(ext)) { |
| | | temp = StringUtils.removeEnd(temp,dotExt); |
| | | } |
| | | filePathInZip = packageFolder + temp+"-P"+deviationSerial+dotExt; |
| | | }else{ |
| | | //非偏离单,直接使用原文件名 |
| | | filePathInZip = packageFolder + programNode.getName(); |
| | | } |
| | | String[] arr = annotationSetting.split(","); |
| | | if(arr.length == 2){ |
| | | begin = arr[0]; |
| | | end = arr[1]; |
| | | } |
| | | |
| | | annotation = begin + oriTest + end; |
| | | return annotation; |
| | | |
| | | return filePathInZip; |
| | | } |
| | | */ |
| | | |
| | | /** |
| | | * 将 输入流 中的内容写入zip |
| | | * @param zipOut zip输出流 |