From 78b2032a0c3975d82072eeb52e997061d7cee560 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Mon, 28 Oct 2024 14:46:25 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AF=BC=EC=9B=90=20=EB=AA=A9=EB=A1=9D/?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cokr/xit/interfaces/saeol/SOHNN00004.java | 2 +- .../xit/interfaces/saeol/SaeolMessage.java | 9 ++++ .../saeol/service/SaeolService.java | 3 +- .../saeol/service/bean/MinwonBean.java | 45 ++++++++++++------- .../saeol/service/bean/SaeolServiceBean.java | 5 ++- .../interfaces/saeol/web/SaeolController.java | 5 ++- src/main/resources/intf-conf/xit-saeol.conf | 4 +- src/main/sql/xit-saeol-mariadb.sql | 18 +++++++- 8 files changed, 65 insertions(+), 26 deletions(-) diff --git a/src/main/java/cokr/xit/interfaces/saeol/SOHNN00004.java b/src/main/java/cokr/xit/interfaces/saeol/SOHNN00004.java index c9c6880..f6fe8e3 100644 --- a/src/main/java/cokr/xit/interfaces/saeol/SOHNN00004.java +++ b/src/main/java/cokr/xit/interfaces/saeol/SOHNN00004.java @@ -98,7 +98,7 @@ public class SOHNN00004 extends SaeolMessage { NONE = "none"; private String msg_key; /** 순번 */ - private String row_no; + private int row_no; /** 민원접수번호 */ private String cnsl_qna_no; /** 글제목 */ diff --git a/src/main/java/cokr/xit/interfaces/saeol/SaeolMessage.java b/src/main/java/cokr/xit/interfaces/saeol/SaeolMessage.java index cae8107..5b8786f 100644 --- a/src/main/java/cokr/xit/interfaces/saeol/SaeolMessage.java +++ b/src/main/java/cokr/xit/interfaces/saeol/SaeolMessage.java @@ -2,6 +2,7 @@ package cokr.xit.interfaces.saeol; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Map; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; @@ -217,5 +218,13 @@ public abstract class SaeolMessage extends AbstractComponent { } private String faultcode; private String faultstring; + + public Map toMap() { + return Map.of( + "success", false, + "faultCode", faultcode, + "faultstring", faultstring + ); + } } } \ No newline at end of file diff --git a/src/main/java/cokr/xit/interfaces/saeol/service/SaeolService.java b/src/main/java/cokr/xit/interfaces/saeol/service/SaeolService.java index 9a95e6e..53a064d 100644 --- a/src/main/java/cokr/xit/interfaces/saeol/service/SaeolService.java +++ b/src/main/java/cokr/xit/interfaces/saeol/service/SaeolService.java @@ -1,11 +1,12 @@ package cokr.xit.interfaces.saeol.service; import java.util.List; +import java.util.Map; import cokr.xit.interfaces.saeol.SOINN00050; public interface SaeolService { - void getMinwons(String deptCode, String fromDate, String toDate); + Map getMinwons(String deptCode, String fromDate, String toDate); void getMinwons(); diff --git a/src/main/java/cokr/xit/interfaces/saeol/service/bean/MinwonBean.java b/src/main/java/cokr/xit/interfaces/saeol/service/bean/MinwonBean.java index c58f60e..a2fb368 100644 --- a/src/main/java/cokr/xit/interfaces/saeol/service/bean/MinwonBean.java +++ b/src/main/java/cokr/xit/interfaces/saeol/service/bean/MinwonBean.java @@ -2,7 +2,9 @@ package cokr.xit.interfaces.saeol.service.bean; import java.io.File; import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import javax.annotation.Resource; @@ -19,18 +21,27 @@ public class MinwonBean extends SaeolBean { @Resource(name = "fileBean") private FileBean fileBean; - public void getMinwons(String deptCode, String startDate, String endDate) { + public Map getMinwons(String deptCode, String startDate, String endDate) { log().debug("Getting minwons: '{}', {} ~ {}", deptCode, startDate, endDate); SOHNN00004.Req00004 req00004 = new SOHNN00004.Req00004(); req00004.setDep_code(deptCode); req00004.setStart_reg_ymd(startDate); req00004.setEnd_reg_ymd(endDate); SOHNN00004.Resp00004 resp00004 = getSOHNN00004(req00004).getResponse(); - if (resp00004.error()) return; + if (resp00004.error()) + return resp00004.getFault().toMap(); + + LinkedHashMap result = new LinkedHashMap<>(); + result.put("success", true); + result.put("minwonsReceived", resp00004.getResult().size()); for (SOHNN00004.Item item: resp00004.getResult()) { - getSOHNN00011(item.getCnsl_qna_no(), item.getDetail()); + String cnsl_qna_no = item.getCnsl_qna_no(); + SOHNN00011 sohnn00011 = getSOHNN00011(cnsl_qna_no, item.getDetail()); + result.put(cnsl_qna_no, !sohnn00011.getResponse().error() ? "success" : "fail"); } + + return result; } public SOHNN00004 getSOHNN00004(SOHNN00004.Req00004 req) { @@ -40,16 +51,17 @@ public class MinwonBean extends SaeolBean { req.setLink_yn("y"); SOHNN00004 msg = new SOHNN00004(); SOHNN00004.Resp00004 resp = sendMessage(msg.setRequest(req)); - if (!resp.error()) { - log(msg); - save(resp); - } + if (!resp.error()) + save(msg); + return msg; } - SOHNN00004.Resp00004 save(SOHNN00004.Resp00004 resp) { - if (!resp.error()) - saeolMapper.insert(resp); + SOHNN00004.Resp00004 save(SOHNN00004 msg) { + SOHNN00004.Resp00004 resp = msg.getResponse(); + int affected = saeolMapper.insert(resp); + if (affected > 0) + log(msg); return resp; } @@ -62,20 +74,21 @@ public class MinwonBean extends SaeolBean { req.setCnsl_qna_no(cnsl_qna_no); SOHNN00011 msg = new SOHNN00011(); SOHNN00011.Resp00011 resp = sendMessage(msg.setRequest(req)); - if (!resp.error()) { - log(msg); - save(resp, detail); - } + if (!resp.error()) + save(msg, detail); return msg; } - SOHNN00011.Resp00011 save(SOHNN00011.Resp00011 resp, String detail) { + SOHNN00011.Resp00011 save(SOHNN00011 msg, String detail) { + SOHNN00011.Resp00011 resp = msg.getResponse(); SOHNN00011.Item result = resp.getResult(); if (result == null) return resp; - saeolMapper.insert(resp, detail); + int affected = saeolMapper.insert(resp, detail); + if (affected > 0) + log(msg); if (SOHNN00004.Item.GET.equals(detail)) { String phoneNo = ifEmpty(result.getTelno_m(), result::getHpno_m); diff --git a/src/main/java/cokr/xit/interfaces/saeol/service/bean/SaeolServiceBean.java b/src/main/java/cokr/xit/interfaces/saeol/service/bean/SaeolServiceBean.java index fbaf561..37a1c80 100644 --- a/src/main/java/cokr/xit/interfaces/saeol/service/bean/SaeolServiceBean.java +++ b/src/main/java/cokr/xit/interfaces/saeol/service/bean/SaeolServiceBean.java @@ -3,6 +3,7 @@ package cokr.xit.interfaces.saeol.service.bean; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; +import java.util.Map; import javax.annotation.Resource; @@ -20,8 +21,8 @@ public class SaeolServiceBean extends ScheduledServiceBean implements SaeolServi private AnswerBean answerBean; @Override - public void getMinwons(String deptCode, String fromDate, String toDate) { - minwonBean.getMinwons(deptCode, toDate, toDate); + public Map getMinwons(String deptCode, String fromDate, String toDate) { + return minwonBean.getMinwons(deptCode, toDate, toDate); } private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyyMMdd"); diff --git a/src/main/java/cokr/xit/interfaces/saeol/web/SaeolController.java b/src/main/java/cokr/xit/interfaces/saeol/web/SaeolController.java index 18c8ece..0f19eb8 100644 --- a/src/main/java/cokr/xit/interfaces/saeol/web/SaeolController.java +++ b/src/main/java/cokr/xit/interfaces/saeol/web/SaeolController.java @@ -1,6 +1,7 @@ package cokr.xit.interfaces.saeol.web; import java.util.List; +import java.util.Map; import javax.annotation.Resource; @@ -24,8 +25,8 @@ public class SaeolController extends AbstractController { @PostMapping("/minwons") @Operation(summary = "민원 목록/상세 조회", tags = "민원 목록/상세") - public void getMinwons(@RequestParam(required = false) String deptCode, String fromDate, String toDate) { - saeolService.getMinwons(deptCode, fromDate, toDate); + public Map getMinwons(@RequestParam(required = false) String deptCode, String fromDate, String toDate) { + return saeolService.getMinwons(deptCode, fromDate, toDate); } @PostMapping("/sohnn00004/update") diff --git a/src/main/resources/intf-conf/xit-saeol.conf b/src/main/resources/intf-conf/xit-saeol.conf index 529cca5..d37d514 100644 --- a/src/main/resources/intf-conf/xit-saeol.conf +++ b/src/main/resources/intf-conf/xit-saeol.conf @@ -3,9 +3,9 @@ "sido": "", /* 시도코드 */ "sigungu": "", /* 시군구 코드 */ - "deptCodes": [], /* 부서코드 */ + "deptCodes": ["부서코드"], /* 부서코드 */ - "logXml": "files/xml/{date}/{interfaceID}/{msgKey}.xml", /* xml 로그파일 이름 패턴 */ + "logXml": "files/xml/{date}/{interfaceID}/{msgKey}.xml", /* xml 로그파일 이름 패턴, 로그파일을 남기지 않으려면 제거할 것 */ "logToDatabase": true, /* 전문 데이터베이스 사용 여부 */ "attachmentDir": "files/attachment/{date}", /* 첨부파일 디렉토리 경로 패턴, 전문 데이터베이스를 사용하지 않을 경우에만 유효 */ diff --git a/src/main/sql/xit-saeol-mariadb.sql b/src/main/sql/xit-saeol-mariadb.sql index 07c0d43..de58444 100644 --- a/src/main/sql/xit-saeol-mariadb.sql +++ b/src/main/sql/xit-saeol-mariadb.sql @@ -1,7 +1,7 @@ CREATE OR REPLACE TABLE TB_SOHNN00004 ( CNSL_QNA_NO CHAR(18) COMMENT '민원접수번호', MSG_KEY VARCHAR(25) COMMENT '메시지 키', - ROW_NO VARCHAR(4) COMMENT '순번', + ROW_NO INT COMMENT '순번', MW_CNSL_SJ VARCHAR(500) COMMENT '글제목', REG_DT VARCHAR(14) COMMENT '접수일자', @@ -170,4 +170,18 @@ CREATE OR REPLACE TABLE TB_SOINN00050 ( PRIMARY KEY (MSG_ID), INDEX (CNSL_QNA_NO) -) COMMENT '답변등록/추가답변'; \ No newline at end of file +) COMMENT '답변등록/추가답변'; + +/* +DELIMITER $$ +CREATE FUNCTION NVL(IP_DATA VARCHAR(100), IP_CONVERT VARCHAR(100)) RETURNS VARCHAR(100) +BEGIN + DECLARE RTN_DATA VARCHAR(100); + + SET RTN_DATA := IFNULL(IP_DATA, IP_CONVERT); + + RETURN RTN_DATA; +END $$ + +DELIMITER ; +*/ \ No newline at end of file