From a54285d28fd0c0d322163b3aa65e90a4bd2c547b Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Wed, 17 Jul 2024 20:52:03 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=8F=90=EA=B8=B0=EB=B3=B4=EA=B3=A0=20?= =?UTF-8?q?=EC=84=9C=EB=B2=84=20=ED=98=B8=EC=B6=9C=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xit/adds/nims/web/AddsNimsController.java | 432 +++++++++--------- 1 file changed, 215 insertions(+), 217 deletions(-) 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 7b024f1..8dc3b63 100644 --- a/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java +++ b/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java @@ -73,9 +73,6 @@ public class AddsNimsController extends ApplicationController { @Value("${app.inf.nims.api.seqInfo}") private String productSeqInfoEndpoint; - @Value("${app.inf.nims.api.productAndseqInfo}") - private String productAndseqInfoEndpoint; - @Value("${app.inf.nims.api.prdMnfSeqInfoOfBarcode}") private String prdMnfSeqInfoOfBarcodeEndpoint; @@ -324,210 +321,6 @@ public class AddsNimsController extends ApplicationController { return null; } - - @RequestMapping(value="/makeDisposeResultReportHwp.do", name="폐기결과보고서 HWP파일 생성") - public ModelAndView makeDisposeResultReportHwp(String dtls) { - ModelAndView mav = new ModelAndView(); - mav.setViewName("downloadView"); - - List dataForDoc = fromJson(dtls, new TypeReference>() {}); - - //출력일시,출력작업자 - Print print = new Print(); - print.setPrintRequestUserInfo(currentUser()); - print.setTempPathConfig(fileRootPath); - - //개인정보표시여부,기관장 등 - PrintOption printOption = new PrintOption(); - Map globalVariable = new HashMap(); - printOption.setGlobalVariable(globalVariable); - - - for(DataObject data : dataForDoc) { - String infKey = data.string("dscdmngId"); - String subType = data.string("dscdmngSn"); - - List fileinfo = fileService.getFileList( - new FileQuery().setInfoKeys(infKey).setInfoType("100").setBy("SUB_TYPE").setTerm(subType) - ); - if(fileinfo == null) { fileinfo = new ArrayList(); } - fileinfo = fileinfo.stream() - .filter((item) -> item.string("USE_YN").equals("Y")) - .sorted((item1, item2) -> item1.string("FILE_ID").compareTo(item2.string("FILE_ID"))) - .toList(); - - if(fileinfo.isEmpty()) { - data.put("filePath", ""); - } else { - data.put("filePath", fileinfo.get(fileinfo.size()-1).string("FILE_PATH")); - } - - } - - //1.한글문서파일 데이터 입력 - DisposeResultReport form = new DisposeResultReport(print, printOption, dataForDoc); - //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("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(); - } - } - } - //4.다운로드 - HashMap result = form.andDownload(); - mav.addAllObjects(result); - return mav; - } - - - - @RequestMapping(value="/makeDisposeProcessDetailsHwp.do", name="폐기 처리 내역 및 사진 HWP파일 생성") - public ModelAndView makeDisposeProcessDetailsHwp(String dtls) { - ModelAndView mav = new ModelAndView(); - mav.setViewName("downloadView"); - - List dataForDoc = fromJson(dtls, new TypeReference>() {}); - - //출력일시,출력작업자 - Print print = new Print(); - print.setPrintRequestUserInfo(currentUser()); - print.setTempPathConfig(fileRootPath); - - //개인정보표시여부,기관장 등 - PrintOption printOption = new PrintOption(); - Map globalVariable = new HashMap(); - printOption.setGlobalVariable(globalVariable); - - - //제품사진 - for(DataObject data : dataForDoc) { - String infKey = data.string("dscdmngId"); - String subType = data.string("dscdmngSn"); - - List fileinfo = fileService.getFileList( - new FileQuery().setInfoKeys(infKey).setInfoType("100").setBy("SUB_TYPE").setTerm(subType) - ); - if(fileinfo == null) { fileinfo = new ArrayList(); } - fileinfo = fileinfo.stream() - .filter((item) -> item.string("USE_YN").equals("Y")) - .sorted((item1, item2) -> item1.string("FILE_ID").compareTo(item2.string("FILE_ID"))) - .toList(); - - if(fileinfo.isEmpty()) { - data.put("filePath", ""); - } else { - data.put("filePath", fileinfo.get(fileinfo.size()-1).string("FILE_PATH")); - } - - } - - //폐기증거사진 - 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; - 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")); - - 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(); - - if(dsuseimgs.isEmpty()) { - continue; - } - - List dsuseimgPaths = new ArrayList(); - for(DataObject dsuseimg : dsuseimgs) { - dsuseimgPaths.add(dsuseimg.string("FILE_PATH")); - } - partition.set("dsuseimgPaths", dsuseimgPaths); - - partitions.add(partition); - } - - } - return partitions; - } - //------------------------------------------------------------------------------------------------- // 보고 문서 관리 //------------------------------------------------------------------------------------------------- @@ -640,17 +433,8 @@ public class AddsNimsController extends ApplicationController { //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- - // private method - //------------------------------------------------------------------------------------------------- - private void setCmmCode(String grpCode, ModelAndView mav){ - Map> commonCodes = getCodesOf(grpCode); - mav.addObject(grpCode, commonCodes.get(grpCode)); - } - //------------------------------------------------------------------------------------------------- - // private method + // API server call //------------------------------------------------------------------------------------------------- - - //TODO : 서버통신으로 변경 할것 @RequestMapping(value = "/getNimsBsshInfoSt.do", name="업체(마약류취급자) 검색", produces = "application/json;charset=UTF-8") public @ResponseBody ApiBaseResponse> getNimsBsshInfoSt(@ModelAttribute NimsApiRequest.BsshInfoReq dto) { String rslt = ApiUtil.callNimsApi(apiHost + bsshInfoEndpoint, dto); @@ -683,4 +467,218 @@ public class AddsNimsController extends ApplicationController { return json.parse(rslt, new TypeReference<>() {}); } + //------------------------------------------------------------------------------------------------- + // API server call + //------------------------------------------------------------------------------------------------- + + + //------------------------------------------------------------------------------------------------- + // private method + //------------------------------------------------------------------------------------------------- + private void setCmmCode(String grpCode, ModelAndView mav){ + Map> commonCodes = getCodesOf(grpCode); + mav.addObject(grpCode, commonCodes.get(grpCode)); + } + + private ModelAndView makeDisposeResultReportHwp(String dtls) { + ModelAndView mav = new ModelAndView(); + mav.setViewName("downloadView"); + + List dataForDoc = fromJson(dtls, new TypeReference>() {}); + + //출력일시,출력작업자 + Print print = new Print(); + print.setPrintRequestUserInfo(currentUser()); + print.setTempPathConfig(fileRootPath); + + //개인정보표시여부,기관장 등 + PrintOption printOption = new PrintOption(); + Map globalVariable = new HashMap(); + printOption.setGlobalVariable(globalVariable); + + + for(DataObject data : dataForDoc) { + String infKey = data.string("dscdmngId"); + String subType = data.string("dscdmngSn"); + + List fileinfo = fileService.getFileList( + new FileQuery().setInfoKeys(infKey).setInfoType("100").setBy("SUB_TYPE").setTerm(subType) + ); + if(fileinfo == null) { fileinfo = new ArrayList(); } + fileinfo = fileinfo.stream() + .filter((item) -> item.string("USE_YN").equals("Y")) + .sorted((item1, item2) -> item1.string("FILE_ID").compareTo(item2.string("FILE_ID"))) + .toList(); + + if(fileinfo.isEmpty()) { + data.put("filePath", ""); + } else { + data.put("filePath", fileinfo.get(fileinfo.size()-1).string("FILE_PATH")); + } + + } + + //1.한글문서파일 데이터 입력 + DisposeResultReport form = new DisposeResultReport(print, printOption, dataForDoc); + //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("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(); + } + } + } + //4.다운로드 + HashMap result = form.andDownload(); + mav.addAllObjects(result); + return mav; + } + + private ModelAndView makeDisposeProcessDetailsHwp(String dtls) { + ModelAndView mav = new ModelAndView(); + mav.setViewName("downloadView"); + + List dataForDoc = fromJson(dtls, new TypeReference>() {}); + + //출력일시,출력작업자 + Print print = new Print(); + print.setPrintRequestUserInfo(currentUser()); + print.setTempPathConfig(fileRootPath); + + //개인정보표시여부,기관장 등 + PrintOption printOption = new PrintOption(); + Map globalVariable = new HashMap(); + printOption.setGlobalVariable(globalVariable); + + + //제품사진 + for(DataObject data : dataForDoc) { + String infKey = data.string("dscdmngId"); + String subType = data.string("dscdmngSn"); + + List fileinfo = fileService.getFileList( + new FileQuery().setInfoKeys(infKey).setInfoType("100").setBy("SUB_TYPE").setTerm(subType) + ); + if(fileinfo == null) { fileinfo = new ArrayList(); } + fileinfo = fileinfo.stream() + .filter((item) -> item.string("USE_YN").equals("Y")) + .sorted((item1, item2) -> item1.string("FILE_ID").compareTo(item2.string("FILE_ID"))) + .toList(); + + if(fileinfo.isEmpty()) { + data.put("filePath", ""); + } else { + data.put("filePath", fileinfo.get(fileinfo.size()-1).string("FILE_PATH")); + } + + } + + //폐기증거사진 + 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; + 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")); + + 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(); + + if(dsuseimgs.isEmpty()) { + continue; + } + + List dsuseimgPaths = new ArrayList(); + for(DataObject dsuseimg : dsuseimgs) { + dsuseimgPaths.add(dsuseimg.string("FILE_PATH")); + } + partition.set("dsuseimgPaths", dsuseimgPaths); + + partitions.add(partition); + } + + } + return partitions; + } + //------------------------------------------------------------------------------------------------- + // private method + //------------------------------------------------------------------------------------------------- }