| | |
| | | } |
| | | public abstract String getControlSystem(); |
| | | |
| | | @Override |
| | | public AnnotationData readAnnotationData(InputStream inputStream) { |
| | | AnnotationData data = new AnnotationData(); |
| | | |
| | | int maxLineIndex = maxAnnotationLineIndex(); |
| | | try { |
| | | int lineCount = maxLineIndex+1; |
| | | List<String> lines = FileContentUtil.readFirstNLines(inputStream,lineCount); |
| | | fixLine(lines,lineCount); |
| | | |
| | | String programNameLine = lines.get(this.getAnnotationProperties().getProgramNameLineIndex()); |
| | | String sendPathLine = lines.get(this.getAnnotationProperties().getSendPathLineIndex()); |
| | | String statusLine = lines.get(this.getAnnotationProperties().getStatusLineIndex()); |
| | | String devLine = lines.get(this.getAnnotationProperties().getDeviationLineIndex()); |
| | | |
| | | List<DictBiz> annoDictList= this.programAnnotationService.getAnnotionDictList(); |
| | | data.setFilename(AnnotationUtil.removeAnnotation(this.getControlSystem(),programNameLine,annoDictList)); |
| | | data.setSendPath(AnnotationUtil.removeAnnotation(this.getControlSystem(),sendPathLine,annoDictList)); |
| | | |
| | | String statusText = AnnotationUtil.removeAnnotation(this.getControlSystem(),statusLine,annoDictList); |
| | | if(AnnotationUtil.isStatusContent(statusText)){ |
| | | data.setProgramStatus(statusText); |
| | | } |
| | | |
| | | data.setDeviation(AnnotationUtil.removeAnnotation(this.getControlSystem(),devLine,annoDictList)); |
| | | |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | return data; |
| | | } |
| | | |
| | | /** |
| | | * 没有的行填充未空串 |
| | | * @param lines |
| | | * @return |
| | | */ |
| | | void fixLine(List<String> lines,int fixLineCount){ |
| | | int needFix = fixLineCount - lines.size(); |
| | | if(needFix > 0){ |
| | | for(int i = 0 ; i < needFix ; i++){ |
| | | lines.add(StringUtils.EMPTY); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private int maxAnnotationLineIndex(){ |
| | | int max = this.getAnnotationProperties().getDeviationLineIndex(); |
| | | if(max < this.getAnnotationProperties().getStatusLineIndex()){ |
| | | max = this.getAnnotationProperties().getStatusLineIndex(); |
| | | } |
| | | |
| | | if(max < this.getAnnotationProperties().getSendPathLineIndex()){ |
| | | max = this.getAnnotationProperties().getSendPathLineIndex(); |
| | | } |
| | | if(max < this.getAnnotationProperties().getProgramNameLineIndex()){ |
| | | max = this.getAnnotationProperties().getProgramNameLineIndex(); |
| | | } |
| | | return max; |
| | | } |
| | | } |