diff --git a/src/main/java/cokr/xit/adds/cmmn/hwp/format/DisposeProcessDetails.java b/src/main/java/cokr/xit/adds/cmmn/hwp/format/DisposeProcessDetails.java index 546e0b7..572675e 100644 --- a/src/main/java/cokr/xit/adds/cmmn/hwp/format/DisposeProcessDetails.java +++ b/src/main/java/cokr/xit/adds/cmmn/hwp/format/DisposeProcessDetails.java @@ -16,7 +16,8 @@ public class DisposeProcessDetails extends HWPFormat { private List data2 = null; //폐기전 사진 private List data3 = null; //폐기증거 사진 - public DisposeProcessDetails(Print print, PrintOption printOption, List dataObjectList, List afterPhotoPaths) { + public DisposeProcessDetails(Print print, PrintOption printOption, List dataObjectList + , List partitions) { super(print, printOption, dataObjectList); this.print.setFormatKorName("폐기처리내역및사진"); @@ -47,23 +48,35 @@ public class DisposeProcessDetails extends HWPFormat { } this.data3 = new ArrayList(); - for(int i=0;i photos = (List)partitionN.get("dsuseimgPaths"); + + for(int i=0;i dataForDoc = fromJson(dtls, new TypeReference>() {}); @@ -270,19 +268,32 @@ public class AddsNimsController extends ApplicationController { } + //1.한글문서파일 데이터 입력 DisposeResultReport form = new DisposeResultReport(print, printOption, dataForDoc); + //2.한글문서파일 생성 String resultFilePath = form.makeFile().andGetPath(); - File file = new File(resultFilePath); - Relation rel = new Relation().setInfoType("200").setSubType("01").setInfoKey(dataForDoc.get(0).string("dscdmngId")); - FileInfo fileInfo = new FileInfo.Factory().create(rel, file); - fileInfo.setName(print.getFormatKorName()+".hwp"); - int effected= fileService.create(fileInfo); - String fileId = fileInfo.getId(); + 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("01").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(); + } + } file.delete(); - mav.addObject("fileId",fileId); - mav.addObject("saved", true); + mav.addObject("fileId", newFileId); + mav.addObject("saved", true); return mav; } @@ -290,9 +301,8 @@ public class AddsNimsController extends ApplicationController { @RequestMapping(value="/makeDisposeProcessDetailsHwp.do", name="폐기 처리 내역 및 사진 HWP파일 생성") public ModelAndView makeDisposeProcessDetailsHwp(String dtls) { - ModelAndView mav = new ModelAndView(); - mav.setViewName("jsonView"); + mav.setViewName("jsonView"); List dataForDoc = fromJson(dtls, new TypeReference>() {}); @@ -306,25 +316,8 @@ public class AddsNimsController extends ApplicationController { Map globalVariable = new HashMap(); printOption.setGlobalVariable(globalVariable); - //폐기증거사진 - List dsuseimgs = fileService.getFileList( - new FileQuery().setInfoType("110").setInfoKeys(dataForDoc.get(0).string("dscdmngId")) - ); - if(dsuseimgs == null) { dsuseimgs = new ArrayList(); } - dsuseimgs = dsuseimgs.stream() - .filter((item) -> item.string("USE_YN").equals("Y")) - .sorted((item1, item2) -> { - int a = item1.number("SRT_ORD").intValue(); - int b = item2.number("SRT_ORD").intValue(); - return (a < b) ? -1 : ((a == b) ? 0 : 1); - }) - .toList(); - - List dsuseimgPaths = new ArrayList<>(); - for(DataObject dsuseimg : dsuseimgs) { - dsuseimgPaths.add(dsuseimg.string("FILE_PATH")); - } + //제품사진 for(DataObject data : dataForDoc) { String infKey = data.string("dscdmngId"); String subType = data.string("dscdmngSn"); @@ -346,19 +339,73 @@ public class AddsNimsController extends ApplicationController { } - DisposeProcessDetails form = new DisposeProcessDetails(print, printOption, dataForDoc, dsuseimgPaths); - String resultFilePath = form.makeFile().andGetPath(); + //폐기증거사진 + List partitions = new ArrayList<>(); + String before = ""; + boolean changeDscdmngId = false; + for(DataObject data : dataForDoc) { + if(!before.equals(data.string("dscdmngId"))) { + changeDscdmngId = true; + before = data.string("dscdmngId"); + } else { + changeDscdmngId = false; + } + + if(changeDscdmngId) { + DataObject partition = new DataObject(); + partition.set("dsuseMthNm", data.string("dsuseMthNm")); + partition.set("bsshNm0", data.string("bsshNm0")); + + List dsuseimgs = fileService.getFileList( + new FileQuery().setInfoType("110").setInfoKeys(data.string("dscdmngId")) + ); + if(dsuseimgs == null) { dsuseimgs = new ArrayList(); } + dsuseimgs = dsuseimgs.stream() + .filter((item) -> item.string("USE_YN").equals("Y")) + .sorted((item1, item2) -> { + int a = item1.number("SRT_ORD").intValue(); + int b = item2.number("SRT_ORD").intValue(); + return (a < b) ? -1 : ((a == b) ? 0 : 1); + }) + .toList(); + + List dsuseimgPaths = new ArrayList(); + for(DataObject dsuseimg : dsuseimgs) { + dsuseimgPaths.add(dsuseimg.string("FILE_PATH")); + } + partition.set("dsuseimgPaths", dsuseimgPaths); + + partitions.add(partition); + } + + } + //1.한글문서파일 데이터 입력 + DisposeProcessDetails form = new DisposeProcessDetails(print, printOption, dataForDoc, partitions); + //2.한글문서파일 생성 + String resultFilePath = form.makeFile().andGetPath(); File file = new File(resultFilePath); - Relation rel = new Relation().setInfoType("200").setSubType("02").setInfoKey(dataForDoc.get(0).string("dscdmngId")); - FileInfo fileInfo = new FileInfo.Factory().create(rel, file); - fileInfo.setName(print.getFormatKorName()+".hwp"); - int effected= fileService.create(fileInfo); - String fileId = fileInfo.getId(); + 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(); + } + } file.delete(); - mav.addObject("fileId",fileId); - mav.addObject("saved", true); + mav.addObject("fileId", newFileId); + mav.addObject("saved", true); return mav; } //------------------------------------------------------------------------------------------------- diff --git a/src/main/resources/template/hwp/photo_after_dispose.hwp b/src/main/resources/template/hwp/photo_after_dispose.hwp index be70b1c..74e52a5 100644 Binary files a/src/main/resources/template/hwp/photo_after_dispose.hwp and b/src/main/resources/template/hwp/photo_after_dispose.hwp differ diff --git a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseDoc-main.jsp b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseDoc-main.jsp index e7904a5..6b50cb0 100644 --- a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseDoc-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseDoc-main.jsp @@ -94,6 +94,10 @@ No. + + + 폐기관리번호 취급일자 폐기일자 @@ -113,6 +117,10 @@