From 8b5e871bd5e07e4f02fa2b1d37ce14fe5b7dd261 Mon Sep 17 00:00:00 2001 From: limju Date: Wed, 1 Nov 2023 18:15:32 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20post=20plus=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kr/xit/ens/pplus/mapper/IPplusMapper.java | 2 + .../xit/ens/pplus/service/PplusService.java | 76 ++++-- .../java/kr/xit/ens/pplus/web/ApiExample.java | 251 +++++++++--------- .../kr/xit/ens/pplus/web/PplusController.java | 4 +- .../config/db/PrimaryMybatisConfig.java | 1 + 5 files changed, 178 insertions(+), 156 deletions(-) diff --git a/mens-api/src/main/java/kr/xit/ens/pplus/mapper/IPplusMapper.java b/mens-api/src/main/java/kr/xit/ens/pplus/mapper/IPplusMapper.java index e5af71e..ef4d0d7 100644 --- a/mens-api/src/main/java/kr/xit/ens/pplus/mapper/IPplusMapper.java +++ b/mens-api/src/main/java/kr/xit/ens/pplus/mapper/IPplusMapper.java @@ -3,6 +3,7 @@ package kr.xit.ens.pplus.mapper; import java.util.List; import kr.xit.biz.ens.model.cmm.SndngMssageParam; import kr.xit.biz.ens.model.pplus.PplusDTO.BatchAcceptRequest; +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; /** *
@@ -19,6 +20,7 @@ import kr.xit.biz.ens.model.pplus.PplusDTO.BatchAcceptRequest;
  *
  * 
*/ +@Mapper public interface IPplusMapper { List selectPostPlusSendTgts(final SndngMssageParam dto); } diff --git a/mens-api/src/main/java/kr/xit/ens/pplus/service/PplusService.java b/mens-api/src/main/java/kr/xit/ens/pplus/service/PplusService.java index 20da183..100fc1f 100644 --- a/mens-api/src/main/java/kr/xit/ens/pplus/service/PplusService.java +++ b/mens-api/src/main/java/kr/xit/ens/pplus/service/PplusService.java @@ -16,7 +16,6 @@ import kr.xit.biz.ens.model.pplus.PplusDTO.PpAcceptRequestStruct; import kr.xit.biz.ens.model.pplus.PplusDTO.PpCommonResponse; import kr.xit.biz.ens.model.pplus.PplusDTO.PpStatusRequest; import kr.xit.biz.ens.model.pplus.PplusDTO.PpStatusResponse; -import kr.xit.core.spring.annotation.TraceLogging; import kr.xit.core.spring.util.ApiWebClientUtil; import kr.xit.core.support.utils.FileUtil; import kr.xit.core.support.utils.JsonUtils; @@ -68,36 +67,61 @@ public class PplusService extends EgovAbstractServiceImpl implements IPplusServi private String STATUS; private final ApiWebClientUtil webClient; - private IPplusMapper mapper; + private final IPplusMapper mapper; @Override - @TraceLogging + //@TraceLogging public PpCommonResponse sendBulks(final SndngMssageParam reqDTO) { final List tgtList = mapper.selectPostPlusSendTgts(reqDTO); - - return null; + if(!tgtList.isEmpty()){ + String dtlCols = String.join(",", tgtList.stream() + .map(BatchAcceptRequest::getDetailCols) + .toList()); + String dtlRows = String.join(",", tgtList.stream() + .map(BatchAcceptRequest::getDetailRows) + .toList()); + + PpAcceptRequestStruct reqDataDTO = PpAcceptRequestStruct.builder() + .master(PpAcceptReqDataStruct.builder() + .cols(tgtList.get(0).getMasterCols()) + .rows(tgtList.get(0).getMasterRows()) + .build()) + .detail(PpAcceptReqDataStruct.builder() + .cols(dtlCols) + .rows(dtlRows) + .build()) + .build(); + + return accept(reqDTO, reqDataDTO); + } + return accept(null, null); } - @TraceLogging - private PpCommonResponse accept(PpAcceptRequest reqDTO) { - final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); - reqDTO.setApiKey(ktMnsInfo.getPplusApiKey()); - JSONObject mstJson = makePpAcceptMstData(); - JSONObject dtlJson = makePpAcceptDtlData(); - - PpAcceptRequestStruct reqDataDTO = PpAcceptRequestStruct.builder() - .master(PpAcceptReqDataStruct.builder() - .cols(JsonUtils.toJson(mstJson.get("cols"))) - .rows(JsonUtils.toJson(mstJson.get("rows"))) - .build()) - .detail(PpAcceptReqDataStruct.builder() - .cols(JsonUtils.toJson(dtlJson.get("cols"))) - .rows(JsonUtils.toJson(dtlJson.get("rows"))) - .build()) + //@TraceLogging + private PpCommonResponse accept(final SndngMssageParam paramDTO, final PpAcceptRequestStruct reqDataStruct) { + //final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(paramDTO.getSignguCode(), paramDTO.getFfnlgCode()); + PpAcceptRequest reqDTO = PpAcceptRequest.builder() + //.apiKey(ktMnsInfo.getPplusApiKey()) + .apiKey("00197D16F7FE4A84E9C97F55033339FBE07FB374D7C8C94EE4C96BA7D997297AC1E9CB5F1FC50CC3C63F5285923FDAB73679A011D40CA00CE589C98858AEFFE7F64E8E0FCF59EF0DC52B548C13D16FC2BB4") .build(); - String reqDataJsonStr = JsonUtils.toJson(reqDataDTO); + //String reqDataJsonStr = JsonUtils.toJson(reqDataStruct); + String reqDataJsonStr = """ + { + "master":{ + "cols":["버전","테스트여부","서비스","연계식별키","봉투","봉투창","흑백칼라","단면양면","배달","템플릿코드","템플릿출력여부","수취인수","여백생성유무","주소페이지유무","맞춤자제유무","메일머지유무","발송인명","발송인우편번호","발송인주소","발송인상세주소","발송인전화번호"], + "rows":["v1.10","Y","PST","SISUL_20231101_01","소봉투","이중창","칼라","단면","등기","SISUL_TRAFFIC","Y","1","N","Y","N","Y","서울시설공단 교통시설운영처","04566","서울특별시 마장로 22","DDP패션몰","02-3405-4015"] + }, + "detail":{ + "cols":["순번","이름","우편번호","주소","상세주소","전화번호","고지서구분명","고지서명","고지서상세명","QR바코드","부과대상","기관번호","세목","납세년월기","과세번호","부과내역1","부과내역2","납부금액명1","납부금액상세명1","납부금액상세명2","납부금액상세명3","납기구분1","납기구분2","납기내기한","납기내금액1","납기내금액2","납기내금액3","납기내금액4","납기내합계액","출력일자","담당자","우리가상계좌","신한가상계좌","하나가상계좌"], + "rows":[ + ["1","캄 앤 컴폴트","04566","서울특별시 마장로 22","DDP 패션몰 3층 98호","02-3405-1111","정기분","공유재산사용료","2023년 08월","00004733921280820230822431111","부과대상 테스트","0000473","39212808","2023082","2431111","사용료$&$분납이자$&$사용료V.A.T$&$변상금$&$전기료$&$관리비V.A.T$&$전력기금$&$수도료$&$청소비$&$청소용품비$&$경비비용$&$소독료$&$오물수거료$&$정화조청소료$&$화재보험료$&$위탁관리비$&$기타관리비$&$TV수신료","0$&$0$&$0$&$0$&$137,462$&$15,209$&$5,085$&$5,106$&$83,062$&$18,453$&$108,294$&$0$&$0$&$0$&$558$&$0$&$0$&$0","납부금액","부가가치세","연체료","","납부기한","납기후 수납가능","20230831","0","0","0","","387,860","20230908","홍길동 02-3405-4018","997-167429-99-092","562-000-97162222","137-899999-22345"] + ] + } + } + """; + log.debug(reqDataJsonStr); @@ -111,12 +135,10 @@ public class PplusService extends EgovAbstractServiceImpl implements IPplusServi CmmEnsUtils.validate(reqDTO); final Map headerMap = new HashMap<>(); + //headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE); headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE); -// headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); -// headerMap.put("client-id", "client-id"); -// headerMap.put("client-tp", "10"); -// headerMap.put(HttpHeaders.AUTHORIZATION, String.format("%s %s", AUTH_TYPE_BEARER, "access-token")); - + //headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); + //headerMap.put("apiKey", reqDTO.getApiKey()); return webClient.exchangeFileData( HOST + ACCEPT, diff --git a/mens-api/src/main/java/kr/xit/ens/pplus/web/ApiExample.java b/mens-api/src/main/java/kr/xit/ens/pplus/web/ApiExample.java index ef8c06e..f89c450 100644 --- a/mens-api/src/main/java/kr/xit/ens/pplus/web/ApiExample.java +++ b/mens-api/src/main/java/kr/xit/ens/pplus/web/ApiExample.java @@ -5,7 +5,6 @@ import io.swagger.v3.oas.annotations.tags.Tag; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; -import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; @@ -18,8 +17,6 @@ import java.net.URLConnection; import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.model.ApiResponseDTO; import kr.xit.core.model.IApiResponse; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -39,134 +36,134 @@ public class ApiExample { @PostMapping(value = "/apiExample", produces = MediaType.APPLICATION_JSON_VALUE) public IApiResponse apiExample() { - // master - JSONArray masterCols = new JSONArray(); - masterCols.add("버전"); - masterCols.add("테스트여부"); - masterCols.add("서비스"); - masterCols.add("연계식별키"); - masterCols.add("봉투"); - masterCols.add("봉투창"); - masterCols.add("흑백칼라"); - masterCols.add("단면양면"); - masterCols.add("배달"); - masterCols.add("템플릿코드"); - masterCols.add("템플릿출력여부"); - masterCols.add("수취인수"); - masterCols.add("여백생성유무"); - masterCols.add("주소페이지유무"); - masterCols.add("맞춤자제유무"); - masterCols.add("메일머지유무"); - masterCols.add("동봉물유무"); - masterCols.add("반송여부"); - masterCols.add("스테이플러유무"); - masterCols.add("로고파일"); - masterCols.add("발송인명"); - masterCols.add("발송인우편번호"); - masterCols.add("발송인주소"); - masterCols.add("발송인상세주소"); - masterCols.add("발송인전화번호"); - - JSONArray masterRows = new JSONArray(); - masterRows.add("v1.10"); // 버전 - masterRows.add("Y"); // 테스트여부 - masterRows.add("PST"); // 서비스 - masterRows.add("POST20230428_000001"); // 연계식별키 - masterRows.add("소봉투"); // 봉투 - masterRows.add("이중창"); // 봉투창 - masterRows.add("흑백"); // 흑백칼라 - masterRows.add("단면"); // 단면양면 - masterRows.add("일반"); // 배달 - masterRows.add(""); // 템플릿코드 - masterRows.add("N"); // 템플릿출력여부 - masterRows.add(2); // 수취인수 - masterRows.add("N"); // 여백생성유무 - masterRows.add("N"); // 주소페이지유무 - masterRows.add("N"); // 맞춤자제유무 - masterRows.add("N"); // 메일머지유무 - masterRows.add("N"); // 동봉물유무 - masterRows.add("N"); // 반송여부 - masterRows.add("N"); // 스테이플러유무 - masterRows.add("N"); // 로고파일 - masterRows.add("포스토피아"); // 발송인명 - masterRows.add("05048"); // 발송인우편번호 - masterRows.add("서울특별시 광진구 강변역로2"); // 발송인주소 - masterRows.add("서울광진우체국 B동 4층"); // 발송인상세주소 - masterRows.add("1577-8114"); // 발송인전화번호 - - JSONObject master = new JSONObject(); - master.put("cols", masterCols); - master.put("rows", masterRows); - - - // detail - JSONArray detailCols = new JSONArray(); - detailCols.add("순번"); - detailCols.add("이름"); - detailCols.add("우편번호"); - detailCols.add("주소"); - detailCols.add("상세주소"); - detailCols.add("전화번호"); - detailCols.add("첨부파일"); - detailCols.add("가변1"); - detailCols.add("가변2"); - detailCols.add("가변3"); - detailCols.add("가변4"); - - JSONArray detailRows1 = new JSONArray(); - detailRows1.add("1"); - detailRows1.add("홍길동1"); - detailRows1.add("31010"); - detailRows1.add("서울특별시 광진구 강변역로2"); - detailRows1.add("서울광진우체국 B동 1층"); - detailRows1.add("01012341234"); - detailRows1.add("pstFile.pdf"); - detailRows1.add("24926737"); - detailRows1.add("2021-09-02"); - detailRows1.add("대출(고정)"); - detailRows1.add("31,000,000"); - - JSONArray detailRows2 = new JSONArray(); - detailRows2.add("2"); - detailRows2.add("홍길동2"); - detailRows2.add("08394"); - detailRows2.add("서울특별시 광진구 강변역로2"); - detailRows2.add("서울광진우체국 B동 2층"); - detailRows2.add("01012341234"); - detailRows2.add("pstFile.pdf"); - detailRows2.add("25685047"); - detailRows2.add("2021-09-02"); - detailRows2.add("대출B(변동)"); - detailRows2.add("421,000,000"); - - JSONArray detailRows = new JSONArray(); - detailRows.add(detailRows1); - detailRows.add(detailRows2); - - JSONObject detail = new JSONObject(); - detail.put("cols", detailCols); - detail.put("rows", detailRows); - - JSONObject pst = new JSONObject(); - pst.put("master", master); - pst.put("detail", detail); - - // 파일생성 & 저장 - try { - FileWriter pstFile = new FileWriter("d:/data/temp/pstFile2.json"); - pstFile.write(pst.toJSONString()); - pstFile.flush(); - pstFile.close(); - } catch (IOException e) { - e.printStackTrace(); - } +// // master +// JSONArray masterCols = new JSONArray(); +// masterCols.add("버전"); +// masterCols.add("테스트여부"); +// masterCols.add("서비스"); +// masterCols.add("연계식별키"); +// masterCols.add("봉투"); +// masterCols.add("봉투창"); +// masterCols.add("흑백칼라"); +// masterCols.add("단면양면"); +// masterCols.add("배달"); +// masterCols.add("템플릿코드"); +// masterCols.add("템플릿출력여부"); +// masterCols.add("수취인수"); +// masterCols.add("여백생성유무"); +// masterCols.add("주소페이지유무"); +// masterCols.add("맞춤자제유무"); +// masterCols.add("메일머지유무"); +// masterCols.add("동봉물유무"); +// masterCols.add("반송여부"); +// masterCols.add("스테이플러유무"); +// masterCols.add("로고파일"); +// masterCols.add("발송인명"); +// masterCols.add("발송인우편번호"); +// masterCols.add("발송인주소"); +// masterCols.add("발송인상세주소"); +// masterCols.add("발송인전화번호"); +// +// JSONArray masterRows = new JSONArray(); +// masterRows.add("v1.10"); // 버전 +// masterRows.add("Y"); // 테스트여부 +// masterRows.add("PST"); // 서비스 +// masterRows.add("POST20230428_000001"); // 연계식별키 +// masterRows.add("소봉투"); // 봉투 +// masterRows.add("이중창"); // 봉투창 +// masterRows.add("흑백"); // 흑백칼라 +// masterRows.add("단면"); // 단면양면 +// masterRows.add("일반"); // 배달 +// masterRows.add(""); // 템플릿코드 +// masterRows.add("N"); // 템플릿출력여부 +// masterRows.add(2); // 수취인수 +// masterRows.add("N"); // 여백생성유무 +// masterRows.add("N"); // 주소페이지유무 +// masterRows.add("N"); // 맞춤자제유무 +// masterRows.add("N"); // 메일머지유무 +// masterRows.add("N"); // 동봉물유무 +// masterRows.add("N"); // 반송여부 +// masterRows.add("N"); // 스테이플러유무 +// masterRows.add("N"); // 로고파일 +// masterRows.add("포스토피아"); // 발송인명 +// masterRows.add("05048"); // 발송인우편번호 +// masterRows.add("서울특별시 광진구 강변역로2"); // 발송인주소 +// masterRows.add("서울광진우체국 B동 4층"); // 발송인상세주소 +// masterRows.add("1577-8114"); // 발송인전화번호 +// +// JSONObject master = new JSONObject(); +// master.put("cols", masterCols); +// master.put("rows", masterRows); +// +// +// // detail +// JSONArray detailCols = new JSONArray(); +// detailCols.add("순번"); +// detailCols.add("이름"); +// detailCols.add("우편번호"); +// detailCols.add("주소"); +// detailCols.add("상세주소"); +// detailCols.add("전화번호"); +// detailCols.add("첨부파일"); +// detailCols.add("가변1"); +// detailCols.add("가변2"); +// detailCols.add("가변3"); +// detailCols.add("가변4"); +// +// JSONArray detailRows1 = new JSONArray(); +// detailRows1.add("1"); +// detailRows1.add("홍길동1"); +// detailRows1.add("31010"); +// detailRows1.add("서울특별시 광진구 강변역로2"); +// detailRows1.add("서울광진우체국 B동 1층"); +// detailRows1.add("01012341234"); +// detailRows1.add("pstFile.pdf"); +// detailRows1.add("24926737"); +// detailRows1.add("2021-09-02"); +// detailRows1.add("대출(고정)"); +// detailRows1.add("31,000,000"); +// +// JSONArray detailRows2 = new JSONArray(); +// detailRows2.add("2"); +// detailRows2.add("홍길동2"); +// detailRows2.add("08394"); +// detailRows2.add("서울특별시 광진구 강변역로2"); +// detailRows2.add("서울광진우체국 B동 2층"); +// detailRows2.add("01012341234"); +// detailRows2.add("pstFile.pdf"); +// detailRows2.add("25685047"); +// detailRows2.add("2021-09-02"); +// detailRows2.add("대출B(변동)"); +// detailRows2.add("421,000,000"); +// +// JSONArray detailRows = new JSONArray(); +// detailRows.add(detailRows1); +// detailRows.add(detailRows2); +// +// JSONObject detail = new JSONObject(); +// detail.put("cols", detailCols); +// detail.put("rows", detailRows); +// +// JSONObject pst = new JSONObject(); +// pst.put("master", master); +// pst.put("detail", detail); +// +// // 파일생성 & 저장 +// try { +// FileWriter pstFile = new FileWriter("d:/data/temp/pstFile2.json"); +// pstFile.write(pst.toJSONString()); +// pstFile.flush(); +// pstFile.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } // API 전송 URL url = null; HttpURLConnection conn; try { - //url = new URL("https://t.postplus.co.kr/po/api/postplusPstMsrApi.do"); - url = new URL("http://localhost:8081/api/ens/pplus/v1/accept2"); + url = new URL("https://t.postplus.co.kr/po/api/postplusPstMsrApi.do"); + //url = new URL("http://localhost:8081/api/ens/pplus/v1/accept2"); //url = new URL("http://localhost:8081/api/ens/pplus/v1/accept3"); conn = (HttpURLConnection) url.openConnection(); conn.setUseCaches(false); @@ -188,7 +185,7 @@ public class ApiExample { File pstFile = new File("d:/data/temp/pstFile2.json"); //File attchFile = new File("c:/Temp/pstFile.pdf"); - addParam(writer, "apiKey", "apiKey"); + addParam(writer, "apiKey", "00197D16F7FE4A84E9C97F55033339FBE07FB374D7C8C94EE4C96BA7D997297AC1E9CB5F1FC50CC3C63F5285923FDAB73679A011D40CA00CE589C98858AEFFE7F64E8E0FCF59EF0DC52B548C13D16FC2BB4"); addFile(writer, ops, "pstFile", pstFile); //addFile(writer, ops, "pstFile", attchFile); diff --git a/mens-api/src/main/java/kr/xit/ens/pplus/web/PplusController.java b/mens-api/src/main/java/kr/xit/ens/pplus/web/PplusController.java index 464fbd2..27e84da 100644 --- a/mens-api/src/main/java/kr/xit/ens/pplus/web/PplusController.java +++ b/mens-api/src/main/java/kr/xit/ens/pplus/web/PplusController.java @@ -61,8 +61,8 @@ public class PplusController { }) })*/ @Operation(summary = "우편제작접수", description = "우편제작접수 요청
우편제작접수") - @PostMapping(value = "/accept", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - //@PostMapping(value = "/accept", produces = MediaType.APPLICATION_JSON_VALUE) + //@PostMapping(value = "/accept", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(value = "/accept", produces = MediaType.APPLICATION_JSON_VALUE) public IApiResponse send(@ModelAttribute final SndngMssageParam paramDTO) { return ApiResponseDTO.success(service.sendBulks(paramDTO)); } diff --git a/mens-core/src/main/java/kr/xit/core/spring/config/db/PrimaryMybatisConfig.java b/mens-core/src/main/java/kr/xit/core/spring/config/db/PrimaryMybatisConfig.java index 7f97479..2f353a5 100644 --- a/mens-core/src/main/java/kr/xit/core/spring/config/db/PrimaryMybatisConfig.java +++ b/mens-core/src/main/java/kr/xit/core/spring/config/db/PrimaryMybatisConfig.java @@ -39,6 +39,7 @@ import org.springframework.jdbc.support.lob.DefaultLobHandler; basePackages = { "kr.xit.core.**.mapper", "kr.xit.biz.**.mapper", + "kr.xit.ens.**.mapper", }, sqlSessionFactoryRef = Constants.PRIMARY_SQL_SESSION )