From 273e104268bd49398b9b663880f5f7c1874de782 Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Wed, 17 Jul 2024 17:38:57 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=ED=8F=90=EA=B8=B0=EB=B3=B4=EA=B3=A0?= =?UTF-8?q?=20=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 --- .../java/cokr/xit/adds/cmm/model/ApiUtil.java | 13 ++++- .../xit/adds/cmm/model/NimsApiRequest.java | 13 +++++ .../xit/adds/nims/web/AddsNimsController.java | 58 +++++++++++++++++++ src/main/resources/application.yml | 7 ++- .../WEB-INF/jsp/adds/nims/dsuseDoc-main.jsp | 18 +++--- 5 files changed, 95 insertions(+), 14 deletions(-) diff --git a/src/main/java/cokr/xit/adds/cmm/model/ApiUtil.java b/src/main/java/cokr/xit/adds/cmm/model/ApiUtil.java index 4eac526..0089c39 100644 --- a/src/main/java/cokr/xit/adds/cmm/model/ApiUtil.java +++ b/src/main/java/cokr/xit/adds/cmm/model/ApiUtil.java @@ -1,6 +1,7 @@ package cokr.xit.adds.cmm.model; import java.net.http.HttpResponse; +import java.util.List; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -39,6 +40,7 @@ public class ApiUtil { request.contentType(WebClient.Request.ContentType.FORM); request.uri(uri); toData(request, cls); + System.out.println("request : " + request); }); return rslt.body(); } @@ -68,8 +70,15 @@ public class ApiUtil { JSONObject jsonObj = toObjByObj(obj, JSONObject.class); for (Object key : jsonObj.keySet()) { - // API 호출 시 필요없는 파라메터 제외 - request.data((String) key, ObjectUtils.isEmpty(jsonObj.get(key))? StringUtils.EMPTY: jsonObj.get(key)); + Object value = jsonObj.get(key); + + if (value instanceof List) { + // List를 쉼표로 구분된 문자열로 변환 + String listAsString = String.join(",", (List) value); + request.data((String) key, listAsString); + } else { + request.data((String) key, ObjectUtils.isEmpty(value) ? StringUtils.EMPTY : value.toString()); + } } } diff --git a/src/main/java/cokr/xit/adds/cmm/model/NimsApiRequest.java b/src/main/java/cokr/xit/adds/cmm/model/NimsApiRequest.java index 57246db..7012315 100644 --- a/src/main/java/cokr/xit/adds/cmm/model/NimsApiRequest.java +++ b/src/main/java/cokr/xit/adds/cmm/model/NimsApiRequest.java @@ -1,5 +1,7 @@ package cokr.xit.adds.cmm.model; +import java.util.List; + import org.apache.commons.lang3.StringUtils; import lombok.Data; @@ -363,4 +365,15 @@ public class NimsApiRequest { */ private String userId; } + + @Data + public static class DsuseMgtInqReq { + private List dscdmngIds; + + private String adds12; + + private String userId; + + + } } 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 dd2a393..e605eb3 100644 --- a/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java +++ b/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java @@ -78,6 +78,9 @@ public class AddsNimsController extends ApplicationController { @Value("${app.inf.nims.api.prdMnfSeqInfoOfBarcode}") private String prdMnfSeqInfoOfBarcodeEndpoint; + @Value("${app.inf.nims.api.dsuseMgtListForRptDoc}") + private String dsuseMgtListForRptDocEndpoint; + @Resource(name="sigunguDepartmentService") private SigunguDepartmentService sggDeptService; @@ -621,4 +624,59 @@ public class AddsNimsController extends ApplicationController { String rslt = ApiUtil.callNimsApi(apiHost + productAndseqInfoEndpoint, dto); return json.parse(rslt, new TypeReference<>() {}); } + + @RequestMapping(value = "/getDsuseMgtListForRptDoc.do", name="보고문서 출력 상세 목록 조회", produces = "application/json;charset=UTF-8") + public @ResponseBody ApiBaseResponse> getDsuseMgtListForRptDoc(@ModelAttribute NimsApiRequest.DsuseMgtInqReq dto) { + String rslt = ApiUtil.callNimsApi(apiHost + dsuseMgtListForRptDocEndpoint, dto); + ApiBaseResponse> parse = json.parse(rslt, new TypeReference<>() {}); + + + + + + + + + + + return parse; + } } + + +/* + +for(let dsuseMgtMaster of respData){ + dsuseMgtMaster.dsuseMgtDtls.map((dtl) => { + keys = Object.keys(dsuseMgtMaster); + for(let key of keys){ + if(key == "dsuseMgtDtls"){ + continue; + } + + if(key == "bsshNm" || key == "bsshCd"){ + dtl[key+"0"] = dsuseMgtMaster[key]; + } else if(dtl[key] == undefined){ + dtl[key] = dsuseMgtMaster[key]; + } + } + return dtl; + }); + } + + let dtls = []; + for(let i=0; i < respData.length; i++){ + dtls = dtls.concat(respData[i].dsuseMgtDtls); + } + + let url = ""; + if(ADDS12 == "01"){ + url = wctx.url("/adds/nims/makeDisposeResultReportHwp.do"); + } else if(ADDS12 == "02"){ + url = wctx.url("/adds/nims/makeDisposeProcessDetailsHwp.do"); + } else { + return; + } + + + */ diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 6d12e36..13a80cc 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,7 +1,7 @@ server: shutdown: graceful port: 9077 - max-http-header-size: 100KB + max-http-header-size: 48KB servlet: context-path: / @@ -68,9 +68,10 @@ app: jurisdictionGovInfo: /api/biz/nims/v1/getNimsJurisdictionGovInfo # 폐기보고 조회 nimsDsuseRptInfo: /api/biz/nims/v1/getNimsDsuseRptInfo - + # 바코드 조회 prdMnfSeqInfoOfBarcode: /api/biz/nims/v1/getPrdMnfSeqInfoOfBarcode - + # 보고문서 정보 목록 조회 + dsuseMgtListForRptDoc: /api/biz/nims/v1/getDsuseMgtListForRptDoc logging: file: 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 eb3b22c..dd3a1ec 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 @@ -374,16 +374,16 @@ alert("체크된 자료가 없습니다."); return; } - - ajax.post({ - url: '', + + ajax.get({ + url: wctx.url("/adds/nims/getDsuseMgtListForRptDoc.do"), contentType : "application/json; charset=utf-8", - - data: JSON.stringify({ - "dscdmngIds" : dscdmngIds, - "userId" : "${currentUser.account}", - "deptCd": "${currentUser.deptCode}" - }), + data: { + dscdmngIds : dscdmngIds, + userId : "${currentUser.account}", + deptCd: "${currentUser.deptCode}", + adds12: ADDS12 + }, success:resp => { if(!resp.success){ dialog.alert({ From 0b665277ed853441046e52f47f08afadffdc647b Mon Sep 17 00:00:00 2001 From: leebj Date: Wed, 17 Jul 2024 18:18:37 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=EC=BB=A4=EB=B0=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xit/adds/nims/web/AddsNimsController.java | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 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 e605eb3..3a5f7f9 100644 --- a/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java +++ b/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java @@ -260,6 +260,12 @@ public class AddsNimsController extends ApplicationController { return setCollectionInfo(new ModelAndView("jsonView"), dsuseMgtDocService.getDsuseMgtDocList(query),"",""); } + @RequestMapping(value = "/getHwpForRptDoc.do", name="보고문서 출력 상세 목록 조회", produces = "application/json;charset=UTF-8") + public ModelAndView getHwpForRptDoc(@ModelAttribute NimsApiRequest.DsuseMgtInqReq dto) { + return null; + + } + @RequestMapping(value="/makeDisposeResultReportHwp.do", name="폐기결과보고서 HWP파일 생성") public ModelAndView makeDisposeResultReportHwp(String dtls) { ModelAndView mav = new ModelAndView(); @@ -631,13 +637,27 @@ public class AddsNimsController extends ApplicationController { ApiBaseResponse> parse = json.parse(rslt, new TypeReference<>() {}); + List respData = parse.getData(); + List dataForRptdoc = new ArrayList<>(); + for(JSONObject mgtMaster : respData) { + List mgtDetails = (List)mgtMaster.get("dsuseMgtDtls"); + String[] keys = mgtMaster.keySet().toArray(new String[mgtMaster.keySet().size()]); + mgtDetails.stream().map((detail)->{ + for(String key : keys) { + if(key.equals("dsuseMgtDtls")) { + continue; + } + if(key.equals("bsshNm") || key.equals("bsshCd")){ + detail.put(key+"0", mgtMaster.get(key)); + } + } + return detail; + }).toList(); - - - - + dataForRptdoc.addAll(mgtDetails); + } return parse; } From cbcda15fbb7070585c675b9142aa6d2a863447cc Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Wed, 17 Jul 2024 20:42:30 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=ED=8F=90=EA=B8=B0=EB=B3=B4=EA=B3=A0?= =?UTF-8?q?=20=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 | 117 ++++++------------ src/main/resources/application.yml | 2 - .../WEB-INF/jsp/adds/nims/dsuseDoc-main.jsp | 63 +--------- 3 files changed, 44 insertions(+), 138 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 3a5f7f9..b989e98 100644 --- a/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java +++ b/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java @@ -6,11 +6,13 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.IntStream; import javax.annotation.Resource; +import org.json.simple.JSONObject; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; @@ -19,8 +21,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; -import net.minidev.json.JSONObject; - import com.fasterxml.jackson.core.type.TypeReference; import cokr.xit.adds.cmm.model.ApiBaseResponse; @@ -260,8 +260,44 @@ public class AddsNimsController extends ApplicationController { return setCollectionInfo(new ModelAndView("jsonView"), dsuseMgtDocService.getDsuseMgtDocList(query),"",""); } - @RequestMapping(value = "/getHwpForRptDoc.do", name="보고문서 출력 상세 목록 조회", produces = "application/json;charset=UTF-8") + @RequestMapping(value = "/getHwpForRptDoc.do", name="보고문서 출력") public ModelAndView getHwpForRptDoc(@ModelAttribute NimsApiRequest.DsuseMgtInqReq dto) { + String rslt = ApiUtil.callNimsApi(apiHost + dsuseMgtListForRptDocEndpoint, dto); + ApiBaseResponse> parse = json.parse(rslt, new TypeReference<>() {}); + + + List respData = parse.getData(); + List dataForRptdoc = new ArrayList<>(); + + for(JSONObject mgtMaster : respData) { + List mgtDetails = json.parse(json.stringify(mgtMaster.get("dsuseMgtDtls")), new TypeReference<>() {}); + Set keys = mgtMaster.keySet(); + List updatedDetails = mgtDetails.stream().map((detail) -> { + for (String key : keys) { + if (key.equals("dsuseMgtDtls")) { + continue; + } + + if (key.equals("bsshNm") || key.equals("bsshCd")) { + detail.put(key + "0", mgtMaster.get(key)); + } else if (!detail.containsKey(key)) { + detail.put(key, mgtMaster.get(key)); + } + + } + return detail; + }).toList(); + dataForRptdoc.addAll(updatedDetails); + } + + if("01".equals(dto.getAdds12())){ + return makeDisposeResultReportHwp(json.stringify(dataForRptdoc)); + }else if("02".equals(dto.getAdds12())) { + return makeDisposeProcessDetailsHwp(json.stringify(dataForRptdoc)); + }else{ + + } + return null; } @@ -624,79 +660,4 @@ public class AddsNimsController extends ApplicationController { return json.parse(rslt, new TypeReference<>() {}); } - - @RequestMapping(value = "/getNimsProductInfoKdAndMnfSeqInfo.do", name="제품 & 시리얼번호 검색", produces = "application/json;charset=UTF-8") - public @ResponseBody ApiBaseResponse> getNimsProductInfoKdAndMnfSeqInfo(@ModelAttribute NimsApiRequest.ProductInfoReq dto) { - String rslt = ApiUtil.callNimsApi(apiHost + productAndseqInfoEndpoint, dto); - return json.parse(rslt, new TypeReference<>() {}); - } - - @RequestMapping(value = "/getDsuseMgtListForRptDoc.do", name="보고문서 출력 상세 목록 조회", produces = "application/json;charset=UTF-8") - public @ResponseBody ApiBaseResponse> getDsuseMgtListForRptDoc(@ModelAttribute NimsApiRequest.DsuseMgtInqReq dto) { - String rslt = ApiUtil.callNimsApi(apiHost + dsuseMgtListForRptDocEndpoint, dto); - ApiBaseResponse> parse = json.parse(rslt, new TypeReference<>() {}); - - - List respData = parse.getData(); - List dataForRptdoc = new ArrayList<>(); - - for(JSONObject mgtMaster : respData) { - List mgtDetails = (List)mgtMaster.get("dsuseMgtDtls"); - String[] keys = mgtMaster.keySet().toArray(new String[mgtMaster.keySet().size()]); - - mgtDetails.stream().map((detail)->{ - for(String key : keys) { - if(key.equals("dsuseMgtDtls")) { - continue; - } - if(key.equals("bsshNm") || key.equals("bsshCd")){ - detail.put(key+"0", mgtMaster.get(key)); - } - } - return detail; - }).toList(); - - dataForRptdoc.addAll(mgtDetails); - } - - return parse; - } } - - -/* - -for(let dsuseMgtMaster of respData){ - dsuseMgtMaster.dsuseMgtDtls.map((dtl) => { - keys = Object.keys(dsuseMgtMaster); - for(let key of keys){ - if(key == "dsuseMgtDtls"){ - continue; - } - - if(key == "bsshNm" || key == "bsshCd"){ - dtl[key+"0"] = dsuseMgtMaster[key]; - } else if(dtl[key] == undefined){ - dtl[key] = dsuseMgtMaster[key]; - } - } - return dtl; - }); - } - - let dtls = []; - for(let i=0; i < respData.length; i++){ - dtls = dtls.concat(respData[i].dsuseMgtDtls); - } - - let url = ""; - if(ADDS12 == "01"){ - url = wctx.url("/adds/nims/makeDisposeResultReportHwp.do"); - } else if(ADDS12 == "02"){ - url = wctx.url("/adds/nims/makeDisposeProcessDetailsHwp.do"); - } else { - return; - } - - - */ diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 13a80cc..04c67b1 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -60,8 +60,6 @@ app: bsshInfo: /api/biz/nims/v1/getNimsBsshInfoSt # 제품 조회 productInfo: /api/biz/nims/v1/getNimsProductInfoKd - # 제품 & 시리얼 번호 조회 - productAndseqInfo: /api/biz/nims/v1/getNimsProductInfoKdAndMnfSeqInfo # 제품 시리얼 번호 조회 seqInfo: /api/biz/nims/v1/getNimsMnfSeqInfo # 관할관청 조회 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 dd3a1ec..15af103 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 @@ -360,81 +360,28 @@ content: "선택한 폐기관리 정보로 "+ docName+" 파일을 생성 하시겠습니까?" , init: () => { setDialogZindex(); } , onOK: () => { - $P.getDataForDocument(ADDS12); + $P.fnCreateDoc(ADDS12); } }); }; - //한글문서파일 생성을 위한 데이터 조회 - $P.getDataForDocument = (ADDS12) => { - + //한글문서파일 생성 요청 + $P.fnCreateDoc = (ADDS12) => { let dscdmngIds = $P.control.dataset.getKeys("selected"); if(dscdmngIds.length < 1){ alert("체크된 자료가 없습니다."); return; } - ajax.get({ - url: wctx.url("/adds/nims/getDsuseMgtListForRptDoc.do"), - contentType : "application/json; charset=utf-8", + $.ajax({ + url: wctx.url("/adds/nims/getHwpForRptDoc.do"), data: { dscdmngIds : dscdmngIds, userId : "${currentUser.account}", deptCd: "${currentUser.deptCode}", adds12: ADDS12 }, - success:resp => { - if(!resp.success){ - dialog.alert({ - content: resp.message - }); - return; - } - $P.fnCreateDoc(resp.data, ADDS12); - } - }); - - }; - - //한글문서파일 생성 요청 - $P.fnCreateDoc = (respData, ADDS12) => { - - for(let dsuseMgtMaster of respData){ - dsuseMgtMaster.dsuseMgtDtls.map((dtl) => { - keys = Object.keys(dsuseMgtMaster); - for(let key of keys){ - if(key == "dsuseMgtDtls"){ - continue; - } - - if(key == "bsshNm" || key == "bsshCd"){ - dtl[key+"0"] = dsuseMgtMaster[key]; - } else if(dtl[key] == undefined){ - dtl[key] = dsuseMgtMaster[key]; - } - } - return dtl; - }); - } - - let dtls = []; - for(let i=0; i < respData.length; i++){ - dtls = dtls.concat(respData[i].dsuseMgtDtls); - } - - let url = ""; - if(ADDS12 == "01"){ - url = wctx.url("/adds/nims/makeDisposeResultReportHwp.do"); - } else if(ADDS12 == "02"){ - url = wctx.url("/adds/nims/makeDisposeProcessDetailsHwp.do"); - } else { - return; - } - - $.ajax({ - url: url, - data: { dtls : JSON.stringify(dtls) }, xhrFields: { responseType: 'blob' }, success:(blob, status, xhr) => { let disposition = xhr.getResponseHeader('Content-Disposition');