diff --git a/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java b/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java index 5be4166..c209c22 100644 --- a/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java +++ b/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java @@ -350,6 +350,46 @@ public class AddsNimsController extends ApplicationController { } //폐기증거사진 + List partitions = this.getPartitions(dataForDoc); + + //1.한글문서파일 데이터 입력 + DisposeProcessDetails form = new DisposeProcessDetails(print, printOption, dataForDoc, partitions); + //2.한글문서파일 생성 + form.makeFile(); + //3.DB 저장, 스토리지 저장 + List dscdmngIds = IntStream.rangeClosed(1, dataForDoc.size()).boxed().map(i -> { + return dataForDoc.get(i-1).string("dscdmngId"); + }).collect(Collectors.toList()); + boolean allEqual = dscdmngIds.stream().distinct().count() <= 1; + if(allEqual) { + String resultFilePath = form.andGetPath(); + File file = new File(resultFilePath); + String newFileId = ""; + String before = ""; + boolean changeDscdmngId = false; + for(DataObject data : dataForDoc) { + if(!before.equals(data.string("dscdmngId"))) { + changeDscdmngId = true; + } else { + changeDscdmngId = false; + } + if(changeDscdmngId) { + Relation rel = new Relation().setInfoType("200").setSubType("02").setInfoKey(data.string("dscdmngId")); + FileInfo fileInfo = new FileInfo.Factory().create(rel, file); + fileInfo.setName(print.getFormatKorName()+".hwp"); + int effected= fileService.create(fileInfo); + newFileId = fileInfo.getId(); + } + } + } + + //4.다운로드 + HashMap result = form.andDownload(); + mav.addAllObjects(result); + return mav; + } + + private List getPartitions(List dataForDoc){ List partitions = new ArrayList<>(); String before = ""; boolean changeDscdmngId = false; @@ -389,43 +429,9 @@ public class AddsNimsController extends ApplicationController { } } - - //1.한글문서파일 데이터 입력 - DisposeProcessDetails form = new DisposeProcessDetails(print, printOption, dataForDoc, partitions); - //2.한글문서파일 생성 - form.makeFile(); - //3.DB 저장, 스토리지 저장 - List dscdmngIds = IntStream.rangeClosed(1, dataForDoc.size()).boxed().map(i -> { - return dataForDoc.get(i-1).string("dscdmngId"); - }).collect(Collectors.toList()); - boolean allEqual = dscdmngIds.stream().distinct().count() <= 1; - if(allEqual) { - String resultFilePath = form.andGetPath(); - File file = new File(resultFilePath); - String newFileId = ""; - before = ""; - changeDscdmngId = false; - for(DataObject data : dataForDoc) { - if(!before.equals(data.string("dscdmngId"))) { - changeDscdmngId = true; - } else { - changeDscdmngId = false; - } - if(changeDscdmngId) { - Relation rel = new Relation().setInfoType("200").setSubType("02").setInfoKey(data.string("dscdmngId")); - FileInfo fileInfo = new FileInfo.Factory().create(rel, file); - fileInfo.setName(print.getFormatKorName()+".hwp"); - int effected= fileService.create(fileInfo); - newFileId = fileInfo.getId(); - } - } - } - - //4.다운로드 - HashMap result = form.andDownload(); - mav.addAllObjects(result); - return mav; + return partitions; } + //------------------------------------------------------------------------------------------------- // 보고 문서 관리 //-------------------------------------------------------------------------------------------------