From 03d8d12c9af5a2cd65a2e8b269e6dd885686d959 Mon Sep 17 00:00:00 2001 From: leebj Date: Fri, 8 Nov 2024 13:16:12 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AC=B8=EC=9E=90=EC=A0=84=EC=86=A1=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cokr/xit/fims/mngt/MsgEntity.java | 103 ++++++++++ .../java/cokr/xit/fims/mngt/MsgQuery.java | 31 ++- .../cokr/xit/fims/mngt/dao/MsgMapper.java | 1 + .../mngt/service/bean/MsgServiceBean.java | 82 ++++++++ .../xit/fims/mngt/web/Mngt03Controller.java | 25 +-- .../mngt/web/RentInterfaceController.java | 150 +++++++++++++++ .../sql/mapper/fims/mngt/msg-mapper.xml | 180 ++++++++---------- 7 files changed, 439 insertions(+), 133 deletions(-) create mode 100644 src/main/java/cokr/xit/fims/mngt/web/RentInterfaceController.java diff --git a/src/main/java/cokr/xit/fims/mngt/MsgEntity.java b/src/main/java/cokr/xit/fims/mngt/MsgEntity.java index 46bf50fe..57483533 100644 --- a/src/main/java/cokr/xit/fims/mngt/MsgEntity.java +++ b/src/main/java/cokr/xit/fims/mngt/MsgEntity.java @@ -1,5 +1,7 @@ package cokr.xit.fims.mngt; +import org.assertj.core.util.Arrays; + import cokr.xit.foundation.AbstractEntity; import lombok.Getter; import lombok.Setter; @@ -307,4 +309,105 @@ public class MsgEntity extends AbstractEntity { */ private String rcsJson; + /** + * 실패 사유 + */ + private String failRsn; + + /** + * 1차,2차,3차 메시지 유형 설정 + */ + public void setMsgTypes(String[] types) { + if(types != null) { + if(types.length == 1) { + this.setMsgType1(types[0]); + this.setMsgType2(null); + this.setMsgType3(null); + } else if(types.length == 2) { + this.setMsgType1(types[0]); + this.setMsgType2(types[1]); + this.setMsgType3(null); + } else if(types.length == 3) { + this.setMsgType1(types[0]); + this.setMsgType2(types[1]); + this.setMsgType3(types[2]); + } + } + } + + /** + * 메시지 유형별 콘텐츠 유형 + */ + public static String[] SMS = {"SMS"}; + public static String[] MMS = {"LMS","MMS"}; + public static String[] ALT = {"ALT","ALI","FRT","FRI","FRW"}; + public static String[] RCS = {"RCS","RCL","RCM","RCT","RCD","RCF","RIT"}; + + /** + * (1차,2차,3차 메시지 유형 설정 후)콘텐츠 유형 설정 + */ + public void setContentsTypeN(String contentsType) { + + String msgType = ""; + if(Arrays.asList(SMS).contains(contentsType)) { + msgType = "SMS"; + } else if(Arrays.asList(MMS).contains(contentsType)){ + msgType = "MMS"; + } else if(Arrays.asList(ALT).contains(contentsType)) { + msgType = "ALT"; + } else if(Arrays.asList(RCS).contains(contentsType)) { + msgType = "RCS"; + } + + if(msgType.equals(this.msgType1)) { + this.contentsType1 = contentsType; + } else if(msgType.equals(this.msgType2)) { + this.contentsType2 = contentsType; + } else if(msgType.equals(this.msgType3)) { + this.contentsType3 = contentsType; + } + + } + + /** + * 현재 메시지 엔티티의 RCS의 콘텐츠 유형 반환 + */ + public String getContentsTypeOfRCS() { + if("RCS".equals(this.msgType1)) { + return this.contentsType1; + } else if("RCS".equals(this.msgType2)){ + return this.contentsType2; + } else if("RCS".equals(this.msgType3)){ + return this.contentsType3; + } + return null; + } + + /** + * 현재 메시지 엔티티의 알림톡의 콘텐츠 유형 반환 + */ + public String getContentsTypeOfALT() { + if("ALT".equals(this.msgType1)) { + return this.contentsType1; + } else if("ALT".equals(this.msgType2)){ + return this.contentsType2; + } else if("ALT".equals(this.msgType3)){ + return this.contentsType3; + } + return null; + } + + /** + * 현재 메시지 엔티티의 XMS의 콘텐츠 유형 반환 + */ + public String getContentsTypeOfXMS() { + if("SMS".equals(this.msgType1) || "MMS".equals(this.msgType1)) { + return this.contentsType1; + } else if("SMS".equals(this.msgType2) || "MMS".equals(this.msgType2)) { + return this.contentsType2; + } else if("SMS".equals(this.msgType3) || "MMS".equals(this.msgType3)) { + return this.contentsType3; + } + return null; + } } diff --git a/src/main/java/cokr/xit/fims/mngt/MsgQuery.java b/src/main/java/cokr/xit/fims/mngt/MsgQuery.java index 830cafcf..1c1d9c76 100644 --- a/src/main/java/cokr/xit/fims/mngt/MsgQuery.java +++ b/src/main/java/cokr/xit/fims/mngt/MsgQuery.java @@ -6,9 +6,10 @@ public class MsgQuery extends CmmnQuery { private static final long serialVersionUID = 1L; - private String schInputDateFrom; + private String schInputYmdFrom; + private String schInputYmdTo; - private String schInputDateTo; + private String stngInfoType; //설정정보유형(01:게이트웨이ID,02:송신전화번호,03:서비스사용자ID,04:템플릿) private String msgPrps; //고장신고,사전알림,주차신고민원,기타민원 private String msgDtlPrps; @@ -17,21 +18,31 @@ public class MsgQuery extends CmmnQuery { private String phone; private String msgState; - public String getSchInputDateFrom() { - return ifEmpty(schInputDateFrom, () -> null); + public String getSchInputYmdFrom() { + return ifEmpty(schInputYmdFrom, () -> null); } - public T setSchInputDateFrom(String schInputDateFrom) { - this.schInputDateFrom = schInputDateFrom; + public T setSchInputYmdFrom(String schInputYmdFrom) { + this.schInputYmdFrom = schInputYmdFrom; return self(); } - public String getSchInputDateTo() { - return ifEmpty(schInputDateTo, () -> null); + public String getSchInputYmdTo() { + return ifEmpty(schInputYmdTo, () -> null); } - public T setSchInputDateTo(String schInputDateTo) { - this.schInputDateTo = schInputDateTo; + public T setSchInputYmdTo(String schInputYmdTo) { + this.schInputYmdTo = schInputYmdTo; return self(); } + + public String getStngInfoType() { + return ifEmpty(stngInfoType, () -> null); + } + + public T setStngInfoType(String stngInfoType) { + this.stngInfoType = stngInfoType; + return self(); + } + } diff --git a/src/main/java/cokr/xit/fims/mngt/dao/MsgMapper.java b/src/main/java/cokr/xit/fims/mngt/dao/MsgMapper.java index cfed0354..e7a7afe2 100644 --- a/src/main/java/cokr/xit/fims/mngt/dao/MsgMapper.java +++ b/src/main/java/cokr/xit/fims/mngt/dao/MsgMapper.java @@ -16,4 +16,5 @@ public interface MsgMapper extends AbstractMapper { int insert(MsgEntity msgEntity); + DataObject selectStng(MsgQuery msgQuery); } diff --git a/src/main/java/cokr/xit/fims/mngt/service/bean/MsgServiceBean.java b/src/main/java/cokr/xit/fims/mngt/service/bean/MsgServiceBean.java index a45c273e..23ad2d73 100644 --- a/src/main/java/cokr/xit/fims/mngt/service/bean/MsgServiceBean.java +++ b/src/main/java/cokr/xit/fims/mngt/service/bean/MsgServiceBean.java @@ -7,8 +7,11 @@ import java.util.Map; import javax.annotation.Resource; +import org.egovframe.rte.fdl.string.EgovStringUtil; import org.springframework.stereotype.Service; +import cokr.xit.fims.cmmn.CmmnUtil; +import cokr.xit.fims.cmmn.Hangul; import cokr.xit.fims.mngt.MsgEntity; import cokr.xit.fims.mngt.MsgQuery; import cokr.xit.fims.mngt.service.MsgService; @@ -35,6 +38,85 @@ public class MsgServiceBean extends AbstractServiceBean implements MsgService { for(MsgEntity msgEntity : msgEntityList) { + boolean isSuccess = false; + + //발신전화 + if(ifEmpty(msgEntity.getCallback(), ()->"").equals("")) { + isSuccess = false; + msgEntity.setFailRsn("발신 전화번호 없음"); + failList.add(msgEntity); + continue; + } + if(!CmmnUtil.isTelno(msgEntity.getCallback())) { + isSuccess = false; + msgEntity.setFailRsn("발신 가능한 전화번호 형식이 아님"); + failList.add(msgEntity); + continue; + } + //수신전화 + if(ifEmpty(msgEntity.getPhone(), ()->"").equals("")) { + isSuccess = false; + msgEntity.setFailRsn("수신 전화번호 없음"); + failList.add(msgEntity); + continue; + } + if(!CmmnUtil.isReceivePhone(msgEntity.getPhone())) { + isSuccess = false; + msgEntity.setFailRsn("수신 가능한 전화번호 형식이 아님"); + failList.add(msgEntity); + continue; + } + + Hangul hangul = new Hangul(2); + + //알림톡 + if(!EgovStringUtil.null2void(msgEntity.getAltSenderKey()).equals("")) { + String altJson = msgEntity.getAltJson(); + if(altJson.length() > 1000) { + isSuccess = false; + msgEntity.setFailRsn("알림톡 글자수(1000자) 초과"); + failList.add(msgEntity); + continue; + } + } + + //RCS + if(!EgovStringUtil.null2void(msgEntity.getRcsBrandKey()).equals("")) { + String rcsJson = msgEntity.getRcsJson(); + // + } + + int xmlSubjectByteCnt = hangul.getByteLength(msgEntity.getXmsSubject()); + int xmlContentByteCnt = hangul.getByteLength(msgEntity.getXmsText()); + String contentsTypeOfXMS = msgEntity.getContentsTypeOfXMS(); + + if("SMS".equals(contentsTypeOfXMS) && xmlContentByteCnt > 90) { + isSuccess = false; + msgEntity.setFailRsn("SMS 최대 바이트 수(90byte) 초과"); + failList.add(msgEntity); + continue; + } + if("LMS".equals(contentsTypeOfXMS)) { + if(xmlSubjectByteCnt > 30) { + isSuccess = false; + msgEntity.setFailRsn("LMS 제목 최대 바이트 수(30byte) 초과"); + failList.add(msgEntity); + continue; + } + if(xmlContentByteCnt > 2000) { + isSuccess = false; + msgEntity.setFailRsn("LMS 내용 최대 바이트 수(2000byte) 초과"); + failList.add(msgEntity); + continue; + } + } + + isSuccess = msgBean.regist(msgEntity); + if(isSuccess) { + successList.add(msgEntity); + } else { + failList.add(msgEntity); + } } resultMap.put("successList", successList); diff --git a/src/main/java/cokr/xit/fims/mngt/web/Mngt03Controller.java b/src/main/java/cokr/xit/fims/mngt/web/Mngt03Controller.java index 90816a16..457a4266 100644 --- a/src/main/java/cokr/xit/fims/mngt/web/Mngt03Controller.java +++ b/src/main/java/cokr/xit/fims/mngt/web/Mngt03Controller.java @@ -1,22 +1,18 @@ package cokr.xit.fims.mngt.web; -import java.util.ArrayList; import java.util.List; -import java.util.Map; import javax.annotation.Resource; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import cokr.xit.base.web.ApplicationController; -import cokr.xit.fims.mngt.MsgEntity; import cokr.xit.fims.mngt.MsgQuery; +import cokr.xit.fims.mngt.dao.MsgMapper; import cokr.xit.fims.mngt.service.MsgService; import cokr.xit.foundation.data.DataObject; -import net.minidev.json.JSONObject; @Controller @RequestMapping(name="문자전송 관리", value=Mngt03Controller.CLASS_URL) @@ -28,13 +24,16 @@ public class Mngt03Controller extends ApplicationController { public static final String main = "/010/main.do" // 문자전송 현황 메인 화면 , list = "/010/list.do" // 문자전송 현황 목록 조회 - , regist = "/010/regist.do" // 문자전송 요청 등록 ; } @Resource(name="msgService") private MsgService msgService; + @Resource(name="msgMapper") + private MsgMapper msgMapper; + + @RequestMapping(name="문자전송 현황 메인", value=METHOD_URL.main) public ModelAndView main() { ModelAndView mav = new ModelAndView(); @@ -53,21 +52,7 @@ public class Mngt03Controller extends ApplicationController { return setPagingInfo(mav, list, ""); } - @RequestMapping(name="문자전송 요청 등록", value=METHOD_URL.regist) - public ModelAndView regist(@RequestBody JSONObject spec) { - ModelAndView mav = new ModelAndView("jsonView"); - - List msgEntityList = new ArrayList(); - // - MsgEntity msgEntity = new MsgEntity(); - msgEntityList.add(msgEntity); - // - Map resultMap = msgService.regist(msgEntityList); - mav.addObject("resultMap", resultMap); - mav.addObject("saved",true); - return mav; - } } diff --git a/src/main/java/cokr/xit/fims/mngt/web/RentInterfaceController.java b/src/main/java/cokr/xit/fims/mngt/web/RentInterfaceController.java new file mode 100644 index 00000000..31bd12a9 --- /dev/null +++ b/src/main/java/cokr/xit/fims/mngt/web/RentInterfaceController.java @@ -0,0 +1,150 @@ +package cokr.xit.fims.mngt.web; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.annotation.Resource; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +import cokr.xit.base.web.ApplicationController; +import cokr.xit.fims.mngt.MsgEntity; +import cokr.xit.fims.mngt.MsgQuery; +import cokr.xit.fims.mngt.dao.MsgMapper; +import cokr.xit.fims.mngt.service.MsgService; +import net.minidev.json.JSONObject; + +@Controller("rentInterface") +@RequestMapping(value = "/intf/rent", name = "렌트카 관련 연계") +public class RentInterfaceController extends ApplicationController { + + @Resource(name="msgService") + private MsgService msgService; + + @Resource(name="msgMapper") + private MsgMapper msgMapper; + + public final static String[] m_b_d = { + "{\"msg\":{\"body\":\"{description\":", + "},},}" + }; + public final static String[] t = { + "{\"text\":", + "}" + }; + + @PostMapping(name="문자전송 요청 등록", value="message/regist") + public ModelAndView regist(@RequestBody JSONObject apiSpec) { + ModelAndView mav = new ModelAndView("jsonView"); + + List msgEntityList = new ArrayList(); + + String reqSys = (String) apiSpec.get("reqSys"); //요청시스템(이노,진우,엑스아이티) + + String msgPrps = (String) apiSpec.get("msgPrps"); //목적(고장신고,사전알림,주차신고민원,기타민원) + String msgDtlPrps = (String) apiSpec.get("msgDtlPrps"); //상세목적 + + String sggCd = (String) apiSpec.get("sggCd"); //시군구코드 + + + //누리2모듈 아이디 찾기 + MsgQuery msgQuery = new MsgQuery(); + msgQuery.setStngInfoType("01"); + msgQuery.setSggCd(System.getProperty("sgg")); + String nuri2Id = msgMapper.selectStng(msgQuery).string("MODULE_ID"); + if(ifEmpty(nuri2Id, ()->"").equals("")) { + mav.addObject("saved", false); + } + + List reqs = (List) apiSpec.get("reqs"); + for(Map req : reqs) { + MsgEntity msgEntity = new MsgEntity(); + msgEntity.setMsgSubId(nuri2Id); + + + String trnsmisNo = (String) req.get("trnsmisNo"); + String recptnNo = (String) req.get("recptnNo"); + String mssageCn = (String) req.get("mssageCn"); + + msgEntity.setCallback(trnsmisNo); + msgEntity.setPhone(recptnNo); + + boolean able_kko = false; //알림톡 가능 여부 + boolean able_rcs = false; //RCS 가능 여부 + + if(able_kko && able_rcs) { // 알림톡+RCS+XMS + msgEntity.setMsgTypes(new String[]{"ALT","RCS","MMS"}); + msgEntity.setContentsTypeN("ALT"); + msgEntity.setContentsTypeN("RCL"); + msgEntity.setContentsTypeN("LMS"); + } else if(able_kko && !able_rcs) { // 알림톡+XMS + msgEntity.setMsgTypes(new String[]{"ALT","MMS"}); + msgEntity.setContentsTypeN("ALT"); + msgEntity.setContentsTypeN("LMS"); + msgEntity.setXmsText(mssageCn); + } else if(!able_kko && able_rcs){ // RCS+XMS + msgEntity.setMsgTypes(new String[]{"RCS","MMS"}); + msgEntity.setContentsTypeN("RCL"); + msgEntity.setContentsTypeN("LMS"); + msgEntity.setXmsText(mssageCn); + } else {// XMS + msgEntity.setMsgTypes(new String[]{"MMS"}); + msgEntity.setContentsTypeN("LMS"); + } + msgEntity.setXmsText(mssageCn); + + + + + if(able_kko) { + String json = t[0] + mssageCn + t[1]; + + msgEntity.setAltSenderKey("신청한센더키"); + msgEntity.setAltTemplateCode("신청한템플릿코드"); + + msgEntity.setAltJson(json); + + + } + + if(able_rcs) { + + msgEntity.setRcsBrandKey("신청한브랜드키"); + + String json = ""; + String contentsTypeOfRCS = msgEntity.getContentsTypeOfRCS(); + + if("RCS".equals(contentsTypeOfRCS)) { + msgEntity.setRcsMassageBaseId("SS000000"); + } else if("RCL".equals(contentsTypeOfRCS)) { + msgEntity.setRcsMassageBaseId("SL000000"); + } else { + + throw new RuntimeException(""); + //RCT //baseid 발급 필요 + //RLT //RCT의 오타 + //RCD,RCF //baseId 발급 필요,mgov예제에 없는 형식 + //RCM,RIT //baseId 발급 필요,필요하지 않는 형식(미디어 첨부) + } + + json = m_b_d[0] + mssageCn + m_b_d[1]; + + msgEntity.setRcsJson(json); + } + msgEntityList.add(msgEntity); + } + + // + + Map resultMap = msgService.regist(msgEntityList); + + mav.addObject("resultMap", resultMap); + mav.addObject("saved",true); + return mav; + } +} diff --git a/src/main/resources/sql/mapper/fims/mngt/msg-mapper.xml b/src/main/resources/sql/mapper/fims/mngt/msg-mapper.xml index f6bc9b52..078e7a62 100644 --- a/src/main/resources/sql/mapper/fims/mngt/msg-mapper.xml +++ b/src/main/resources/sql/mapper/fims/mngt/msg-mapper.xml @@ -6,7 +6,7 @@ /* 문자전송 목록(msgMapper.selectList) */ SELECT MSG_KEY - , MSG_SUB_ID + , SUB_ID , USER_KEY , USER_GROUP , USER_ID @@ -16,7 +16,9 @@ SELECT MSG_KEY , MSG_STATE , GET_CODE_NM('MSG001',MSG_STATE) AS MSG_STATE_NM , INPUT_DATE + , INPUT_DT , RES_DATE + , RES_DT , QUE_DATE , SENT_DATE , RSLT_DATE @@ -68,8 +70,8 @@ SELECT MSG_KEY , RCS_JSON FROM NURI2_NRMSG_DATA WHERE 1=1 - AND REG_YMD =]]> #{schInputDateFrom} - AND REG_YMD #{schInputDateTo} + AND INPUT_DT =]]> CONCAT(#{schInputYmdFrom},'000000') + AND INPUT_DT CONCAT(#{schInputYmdTo},'235959') @@ -79,130 +81,102 @@ SELECT MSG_KEY INSERT INTO NURI2_NRMSG_DATA ( MSG_KEY - , MSG_SUB_ID - , USER_KEY - , USER_GROUP - , USER_ID - , USER_JOBID - , CENTER_KEY - , MSG_PRIORITY - , MSG_STATE - , INPUT_DATE - , INPUT_YMD - , RES_DATE - , QUE_DATE - , SENT_DATE - , RSLT_DATE - , REPORT_DATE - , RSLT_CODE - , RSLT_NET - , RSLT_TYPE - , SENT_COUNT - , HISTORY_MSG_TYPE - , HISTORY_RSLT_CODE + , SUB_ID + , USER_KEY, USER_GROUP, USER_ID, USER_JOBID + , INPUT_DATE + , INPUT_DT + , RES_DATE + , RES_DT , IDENTIFIER - , PHONE - , CALLBACK - , MSG_TYPE_1 - , CONTENTS_TYPE_1 - , QUE_DATE_1 - , SENT_DATE_1 - , MSG_TYPE_2 - , CONTENTS_TYPE_2 - , QUE_DATE_2 - , SENT_DATE_2 - , MSG_TYPE_3 - , CONTENTS_TYPE_3 - , QUE_DATE_3 - , SENT_DATE_3 - , XMS_RSLT_CODE - , XMS_RSLT_NET - , XMS_RSLT_DATE - , XMS_REPORT_DATE - , ALT_RSLT_CODE - , ALT_RSLT_NET - , ALT_RSLT_DATE - , ALT_REPORT_DATE - , RCS_RSLT_CODE - , RCS_RSLT_NET - , RCS_RSLT_DATE - , RCS_REPORT_DATE + , PHONE, CALLBACK + , MSG_TYPE_1, CONTENTS_TYPE_1 + , MSG_TYPE_2, CONTENTS_TYPE_2 + , MSG_TYPE_3, CONTENTS_TYPE_3 , XMS_SUBJECT , XMS_TEXT - , XMS_FILE_NAME_1 - , XMS_FILE_NAME_2 - , XMS_FILE_NAME_3 + , ALT_COUNTRY_CODE , ALT_SENDER_KEY , ALT_TEMPLATE_CODE , ALT_JSON + + , RCS_BRAND_KEY , RCS_MASSAGE_BASE_ID , RCS_JSON + + + + + + + + + + + + ) VALUES ( nextval_msg() , #{msgSubId} - , #{userKey} - , #{userGroup} - , #{userId} - , #{userJobid} - , #{centerKey} - , #{msgPriority} - , #{msgState} - , CURRENT_TIMESTAMP - , - , CURRENT_TIMESTAMP - , #{queDate} - , #{sentDate} - , #{rsltDate} - , #{reportDate} - , #{rsltCode} - , #{rsltNet} - , #{rsltType} - , #{sentCount} - , #{historyMsgType} - , #{historyRsltCode} + , #{userKey}, #{userGroup}, #{userId}, #{userJobid} + , CURRENT_TIMESTAMP + , + , CURRENT_TIMESTAMP + , , #{identifier} - , #{phone} - , #{callback} - , #{msgType1} - , #{contentsType1} - , #{queDate1} - , #{sentDate1} - , #{msgType2} - , #{contentsType2} - , #{queDate2} - , #{sentDate2} - , #{msgType3} - , #{contentsType3} - , #{queDate3} - , #{sentDate3} - , #{xmsRsltCode} - , #{xmsRsltNet} - , #{xmsRsltDate} - , #{xmsReportDate} - , #{altRsltCode} - , #{altRsltNet} - , #{altRsltDate} - , #{altReportDate} - , #{rcsRsltCode} - , #{rcsRsltNet} - , #{rcsRsltDate} - , #{rcsReportDate} + , #{phone}, #{callback} + , #{msgType1}, #{contentsType1} + , #{msgType2}, #{contentsType2} + , #{msgType3}, #{contentsType3} , #{xmsSubject} , #{xmsText} - , #{xmsFileName1} - , #{xmsFileName2} - , #{xmsFileName3} - , #{altCountryCode} + + , '82' , #{altSenderKey} , #{altTemplateCode} , #{altJson} + + , #{rcsBrandKey} , #{rcsMassageBaseId} , #{rcsJson} + + + + + + + + + + + + ) + + \ No newline at end of file