| | |
| | | DecimalFormat df = new DecimalFormat("0000000000"); |
| | | return df.format(program.getId()); |
| | | } |
| | | /** |
| | | * 删除一个程序 |
| | | * @param id 程序id |
| | | */ |
| | | public String getFileContent(Long id) { |
| | | String result =""; |
| | | |
| | | NcProgram prog = this.getById(id); |
| | | if(prog.getIsTextFile()!=null && prog.getIsTextFile()){ |
| | | String fileName = prog.getOssName(); |
| | | try (InputStream inputStream = ossTemplate.statFileStream(fileName)) { |
| | | result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | }else{ |
| | | result = "非文本格式文件"; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 获取文件内饿哦那个 |
| | | * @param ncNodeId 节点id |
| | | */ |
| | | public String getFileContentByNodeId(Long ncNodeId) { |
| | | String result =""; |
| | | NcNode node = this.nodeService.getById(ncNodeId); |
| | | LambdaQueryWrapper<NcProgram> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(NcProgram::getBindNcNodeId, ncNodeId); |
| | | wrapper.eq(NcProgram::getIsLastEdition,1); |
| | | NcProgram prog = this.getOne(wrapper); |
| | | if(prog.getIsTextFile()!=null && prog.getIsTextFile()){ |
| | | String fileName = prog.getOssName(); |
| | | try (InputStream inputStream = ossTemplate.statFileStream(fileName)) { |
| | | result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | }else{ |
| | | result = "非文本格式文件"; |
| | | } |
| | | return result; |
| | | } |
| | | /** |
| | | * 删除一个程序 |
| | | * @param id |