| | |
| | | private ProgramAnnotationService programAnnotationService; |
| | | |
| | | protected AnnotationProperties annotationProperties; |
| | | @Override |
| | | public InputStream putSendPathAnnotation(String sendPath, InputStream inputStream,List<DictBiz> annoDicts) throws IOException{ |
| | | InputStream finishedStream; |
| | | try(inputStream){ |
| | | ByteArrayInputStream byteInputStream = new ByteArrayInputStream(IOUtils.toByteArray(inputStream)); |
| | | |
| | | //1加入发送路径的注释 |
| | | String sendPathAnnotation = AnnotationUtil.generateAnnotation(sendPath,getControlSystem(),annoDicts);//加了注释之后的文本 |
| | | |
| | | String sendDirLine = FileContentUtil.readLineAt(byteInputStream,annotationProperties.getSendPathLineIndex());//第2行是发送路径 |
| | | byteInputStream.reset(); |
| | | |
| | | if(AnnotationUtil.isAnnotation(sendDirLine,getControlSystem(),annoDicts)){ |
| | | finishedStream = FileContentUtil.replaceAtLine(byteInputStream,annotationProperties.getSendPathLineIndex(),sendPathAnnotation); |
| | | }else{ |
| | | finishedStream = FileContentUtil.insertLine(byteInputStream,annotationProperties.getSendPathLineIndex(),sendPathAnnotation); |
| | | } |
| | | finishedStream.reset(); |
| | | } |
| | | |
| | | return finishedStream; |
| | | |
| | | } |
| | | @Override |
| | | public InputStream putFilenameAnnotation(String fileName, InputStream inputStream) throws IOException { |
| | | List<DictBiz> annoDicts = programAnnotationService.getAnnotionDictList(); |
| | |
| | | ByteArrayInputStream byteInputStream = new ByteArrayInputStream(IOUtils.toByteArray(inputStream)); |
| | | |
| | | //1加入发送路径的注释 |
| | | /* |
| | | String sendPathAnnotation = AnnotationUtil.generateAnnotation(annoData.getSendPath(),getControlSystem(),annoDicts);//加了注释之后的文本 |
| | | |
| | | String sendDirLine = FileContentUtil.readLineAt(byteInputStream,annotationProperties.getSendPathLineIndex());//第2行是发送路径 |
| | |
| | | } |
| | | |
| | | insAfterSetSendDir.reset(); |
| | | */ |
| | | |
| | | InputStream insAfterSetSendDir = putSendPathAnnotation(annoData.getSendPath(),byteInputStream,annoDicts); |
| | | |
| | | String statusLine = FileContentUtil.readLineAt(insAfterSetSendDir,annotationProperties.getStatusLineIndex());//状态注释 |
| | | insAfterSetSendDir.reset(); |
| | | |
| | | //加入状态注释行 |
| | | String statusAnnotation = AnnotationUtil.generateAnnotation(annoData.getProgramStatus(),getControlSystem(),annoDicts);//注释后的状态文本 |
| | | if(AnnotationUtil.isAnnotation(statusLine,getControlSystem(),annoDicts)){ |