|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package cokr.xit.interfaces.message.web;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@ -41,36 +42,28 @@ public class MessageInterfaceController extends AbstractController {
|
|
|
|
|
private MessageMapper messageMapper;
|
|
|
|
|
|
|
|
|
|
public final static String[] m_b_d = {
|
|
|
|
|
"{\"msg\":{\"body\":\"{description\":",
|
|
|
|
|
"},},}"
|
|
|
|
|
"{\"msg\":{\"body\":{\"description\":\"",
|
|
|
|
|
"\"},},}"
|
|
|
|
|
};
|
|
|
|
|
public final static String[] t = {
|
|
|
|
|
"{\"text\":",
|
|
|
|
|
"}"
|
|
|
|
|
"{\"text\":\"",
|
|
|
|
|
"\"}"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@PostMapping(name="문자전송 요청 등록", value="/regist")
|
|
|
|
|
public ModelAndView regist(@RequestBody JSONObject apiSpec) {
|
|
|
|
|
ModelAndView mav = new ModelAndView("jsonView");
|
|
|
|
|
MessageUtil messageUtil = new MessageUtil("C");
|
|
|
|
|
|
|
|
|
|
//누리2모듈 아이디 찾기
|
|
|
|
|
MessageQuery messageQuery = new MessageQuery();
|
|
|
|
|
messageQuery.setStngInfoType("01");
|
|
|
|
|
messageQuery.setSggCd(System.getProperty("sgg"));
|
|
|
|
|
MessageUtil forPlainText = new MessageUtil("C");
|
|
|
|
|
MessageUtil forJsonText = new MessageUtil("D");
|
|
|
|
|
|
|
|
|
|
DataObject stng = messageMapper.selectStng(messageQuery);
|
|
|
|
|
String nuri2Id = "";
|
|
|
|
|
if(stng != null && !stng.isEmpty()) {
|
|
|
|
|
nuri2Id = stng.string("MODULE_ID");
|
|
|
|
|
String sggCd = (String) apiSpec.get("sggCd"); //시군구코드
|
|
|
|
|
if(EgovStringUtil.null2void(sggCd).equals("")) {
|
|
|
|
|
mav.addObject("failRsn", "시군구코드가 없습니다.");
|
|
|
|
|
mav.addObject("saved", false);
|
|
|
|
|
return mav;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if(ifEmpty(nuri2Id, ()->"").equals("")) {
|
|
|
|
|
//mav.addObject("failRsn", "문자발송모듈아이디 찾기 실패");
|
|
|
|
|
//mav.addObject("saved", false);
|
|
|
|
|
//return mav;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
String reqSys = (String) apiSpec.get("reqSys"); //요청시스템(이노,진우,엑스아이티)
|
|
|
|
|
if(EgovStringUtil.null2void(reqSys).equals("")) {
|
|
|
|
|
mav.addObject("failRsn", "요청시스템이 없습니다.");
|
|
|
|
|
@ -85,6 +78,65 @@ public class MessageInterfaceController extends AbstractController {
|
|
|
|
|
return mav;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String systemSgg = System.getProperty("sgg");
|
|
|
|
|
|
|
|
|
|
//누리2모듈 관리 아이디 찾기
|
|
|
|
|
String nuri2Id = "";
|
|
|
|
|
MessageQuery messageQuery = new MessageQuery().setSggCd(systemSgg).setStngInfoType("01");
|
|
|
|
|
DataObject stng = messageMapper.selectStng(messageQuery);
|
|
|
|
|
if(stng != null && !stng.isEmpty()) {
|
|
|
|
|
nuri2Id = stng.string("MODULE_ID");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//XMS템플릿 찾기
|
|
|
|
|
String xmsTemplate = "";
|
|
|
|
|
messageQuery = new MessageQuery().setSggCd(systemSgg).setStngInfoType("02").setMsgPrps(msgPrps).setSvcType("XMS");
|
|
|
|
|
stng = messageMapper.selectStng(messageQuery);
|
|
|
|
|
if(stng == null || stng.isEmpty()) {
|
|
|
|
|
mav.addObject("failRsn", "XMS 템플릿 조회 실패");
|
|
|
|
|
mav.addObject("saved", false);
|
|
|
|
|
return mav;
|
|
|
|
|
} else {
|
|
|
|
|
xmsTemplate = stng.string("TMPLT_CN");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//카카오프로필키 찾기
|
|
|
|
|
String kkoSenderKey = "";
|
|
|
|
|
String kkoTemplateKey = "";
|
|
|
|
|
String kkoTemplate = "";
|
|
|
|
|
messageQuery = new MessageQuery().setSggCd(systemSgg).setStngInfoType("03").setSvcType("ALT");
|
|
|
|
|
stng = messageMapper.selectStng(messageQuery);
|
|
|
|
|
if(stng != null && !stng.isEmpty()) {
|
|
|
|
|
kkoSenderKey = stng.string("SVC_USER_ID");
|
|
|
|
|
if(!kkoSenderKey.equals("")) {
|
|
|
|
|
//알림톡템플릿찾기
|
|
|
|
|
messageQuery = new MessageQuery().setSggCd(systemSgg).setStngInfoType("02").setMsgPrps(msgPrps).setSvcType("ALT");
|
|
|
|
|
stng = messageMapper.selectStng(messageQuery);
|
|
|
|
|
if(stng != null && !stng.isEmpty()) {
|
|
|
|
|
kkoTemplateKey = stng.string("TMPLAT_ID");
|
|
|
|
|
kkoTemplate = stng.string("TMPLT_CN");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//RCS브랜드아이디 찾기
|
|
|
|
|
String rcsBrandKey = "";
|
|
|
|
|
String rcsTemplate = "";
|
|
|
|
|
messageQuery = new MessageQuery().setSggCd(systemSgg).setStngInfoType("03").setSvcType("RCS");
|
|
|
|
|
stng = messageMapper.selectStng(messageQuery);
|
|
|
|
|
if(stng != null && !stng.isEmpty()) {
|
|
|
|
|
rcsBrandKey = stng.string("SVC_USER_ID");
|
|
|
|
|
if(!EgovStringUtil.null2void(rcsBrandKey).equals("")) {
|
|
|
|
|
//RCS템플릿찾기
|
|
|
|
|
messageQuery = new MessageQuery().setSggCd(systemSgg).setStngInfoType("02").setMsgPrps(msgPrps).setSvcType("RCS");
|
|
|
|
|
stng = messageMapper.selectStng(messageQuery);
|
|
|
|
|
if(stng != null && !stng.isEmpty()) {
|
|
|
|
|
rcsTemplate = stng.string("TMPLT_CN");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String msgDtlPrps = (String) apiSpec.get("msgDtlPrps"); //상세목적
|
|
|
|
|
if(msgDtlPrps == null) {
|
|
|
|
|
msgDtlPrps = "";
|
|
|
|
|
@ -95,13 +147,6 @@ public class MessageInterfaceController extends AbstractController {
|
|
|
|
|
taskSeCd = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String sggCd = (String) apiSpec.get("sggCd"); //시군구코드
|
|
|
|
|
if(EgovStringUtil.null2void(sggCd).equals("")) {
|
|
|
|
|
mav.addObject("failRsn", "시군구코드가 없습니다.");
|
|
|
|
|
mav.addObject("saved", false);
|
|
|
|
|
return mav;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String databaseId = databaseIdProvider.getDatabaseId(dataSource);
|
|
|
|
|
|
|
|
|
|
List<MessageEntity> messageEntityList = new ArrayList<MessageEntity>();
|
|
|
|
|
@ -118,26 +163,115 @@ public class MessageInterfaceController extends AbstractController {
|
|
|
|
|
|
|
|
|
|
String trnsmisNo = (String) req.get("trnsmisNo");
|
|
|
|
|
String recptnNo = (String) req.get("recptnNo");
|
|
|
|
|
String mssageCn = (String) req.get("mssageCn");
|
|
|
|
|
|
|
|
|
|
String resDate = (String) req.get("resDate");
|
|
|
|
|
|
|
|
|
|
messageEntity.setCallback(trnsmisNo);
|
|
|
|
|
messageEntity.setPhone(recptnNo);
|
|
|
|
|
|
|
|
|
|
if(databaseId.equals("mariadb") || databaseId.equals("mysql")){
|
|
|
|
|
mssageCn = messageUtil.replaceLineChangeForNuri2Maria(mssageCn);
|
|
|
|
|
} else {
|
|
|
|
|
mssageCn = messageUtil.replaceLineChangeForNuri2Oracle(mssageCn);
|
|
|
|
|
List<HashMap<String, String>> args = (List<HashMap<String, String>>) req.get("args");
|
|
|
|
|
if(args == null) {
|
|
|
|
|
args = new ArrayList<HashMap<String, String>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//예약발송일시
|
|
|
|
|
if(!EgovStringUtil.null2void(resDate).equals("")) {
|
|
|
|
|
messageEntity.setResDate(resDate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
String XMS_msgType = "";
|
|
|
|
|
String XMS_contentsType = "";
|
|
|
|
|
int xmsByteCount = messageUtil.countBytes(mssageCn,2,databaseId);
|
|
|
|
|
String xmsPlainComplete = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String altJsonComplete = "";
|
|
|
|
|
boolean able_kko = false; //알림톡 가능 여부
|
|
|
|
|
|
|
|
|
|
if(!kkoTemplateKey.equals("") && !kkoTemplate.equals("")) {
|
|
|
|
|
|
|
|
|
|
altJsonComplete = kkoTemplate;
|
|
|
|
|
|
|
|
|
|
//변수매핑하기
|
|
|
|
|
//altJsonComplete = t[0] + messageCn_json + t[1];
|
|
|
|
|
for(HashMap arg : args) {
|
|
|
|
|
String argName = (String)arg.get("argName");
|
|
|
|
|
String argValue = (String)arg.get("argValue");
|
|
|
|
|
String lineChangeReplaced = "";
|
|
|
|
|
|
|
|
|
|
if(databaseId.equals("mariadb") || databaseId.equals("mysql")){
|
|
|
|
|
lineChangeReplaced = forJsonText.replaceLineChangeForNuri2Maria(argValue);
|
|
|
|
|
} else {
|
|
|
|
|
lineChangeReplaced = forJsonText.replaceLineChangeForNuri2Oracle(argValue);
|
|
|
|
|
}
|
|
|
|
|
altJsonComplete = altJsonComplete.replace("{{"+argName+"}}", lineChangeReplaced);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO : description부 구하기
|
|
|
|
|
//TODO : description부 글자수 계산하기
|
|
|
|
|
|
|
|
|
|
able_kko = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String RCS_contentsType = "";
|
|
|
|
|
String rcsJsonComplete = "";
|
|
|
|
|
boolean able_rcs = false; //RCS 가능 여부
|
|
|
|
|
String rcsBaseId = "";
|
|
|
|
|
|
|
|
|
|
if(!EgovStringUtil.null2void(rcsTemplate).equals("")) {
|
|
|
|
|
|
|
|
|
|
rcsJsonComplete = rcsTemplate;
|
|
|
|
|
|
|
|
|
|
//변수매핑하기
|
|
|
|
|
for(HashMap arg : args) {
|
|
|
|
|
String argName = (String)arg.get("argName");
|
|
|
|
|
String argValue = (String)arg.get("argValue");
|
|
|
|
|
String lineChangeReplaced = "";
|
|
|
|
|
|
|
|
|
|
if(databaseId.equals("mariadb") || databaseId.equals("mysql")){
|
|
|
|
|
lineChangeReplaced = forJsonText.replaceLineChangeForNuri2Maria(argValue);
|
|
|
|
|
} else {
|
|
|
|
|
lineChangeReplaced = forJsonText.replaceLineChangeForNuri2Oracle(argValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
altJsonComplete = altJsonComplete.replace("{{"+argName+"}}", lineChangeReplaced);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO : description부 구하기
|
|
|
|
|
//TODO : description부 글자수 계산하기
|
|
|
|
|
int rcsCharCount = altJsonComplete.length();
|
|
|
|
|
|
|
|
|
|
if(rcsCharCount <= 100) {
|
|
|
|
|
RCS_contentsType = "RCS";
|
|
|
|
|
rcsBaseId = "SS000000";
|
|
|
|
|
} else {
|
|
|
|
|
RCS_contentsType = "RCL";
|
|
|
|
|
rcsBaseId = "SL000000";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
able_rcs = true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xmsPlainComplete = xmsTemplate;
|
|
|
|
|
for(HashMap arg : args) {
|
|
|
|
|
String argName = (String)arg.get("argName");
|
|
|
|
|
String argValue = (String)arg.get("argValue");
|
|
|
|
|
String lineChangeReplaced = "";
|
|
|
|
|
|
|
|
|
|
if(databaseId.equals("mariadb") || databaseId.equals("mysql")){
|
|
|
|
|
lineChangeReplaced = forPlainText.replaceLineChangeForNuri2Maria(argValue);
|
|
|
|
|
} else {
|
|
|
|
|
lineChangeReplaced = forPlainText.replaceLineChangeForNuri2Oracle(argValue);
|
|
|
|
|
}
|
|
|
|
|
xmsPlainComplete = xmsPlainComplete.replace("{{"+argName+"}}", lineChangeReplaced);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//글자수 계산
|
|
|
|
|
int xmsByteCount = forPlainText.countBytes(xmsPlainComplete,2,databaseId);
|
|
|
|
|
if(xmsByteCount <= 90) {
|
|
|
|
|
XMS_msgType = "SMS";
|
|
|
|
|
XMS_contentsType = "SMS";
|
|
|
|
|
@ -146,70 +280,46 @@ public class MessageInterfaceController extends AbstractController {
|
|
|
|
|
XMS_contentsType = "LMS";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean able_kko = false; //알림톡 가능 여부
|
|
|
|
|
boolean able_rcs = false; //RCS 가능 여부
|
|
|
|
|
|
|
|
|
|
if(able_kko && able_rcs) { // 알림톡+RCS+XMS
|
|
|
|
|
messageEntity.configMsgTypes(new String[]{"ALT","RCS",XMS_msgType});
|
|
|
|
|
messageEntity.configContentsTypeN("ALT");
|
|
|
|
|
messageEntity.configContentsTypeN("RCS");
|
|
|
|
|
messageEntity.configContentsTypeN(RCS_contentsType);
|
|
|
|
|
messageEntity.configContentsTypeN(XMS_contentsType);
|
|
|
|
|
} else if(able_kko && !able_rcs) { // 알림톡+XMS
|
|
|
|
|
messageEntity.configMsgTypes(new String[]{"ALT",XMS_msgType});
|
|
|
|
|
messageEntity.configContentsTypeN("ALT");
|
|
|
|
|
messageEntity.configContentsTypeN(XMS_contentsType);
|
|
|
|
|
messageEntity.setXmsText(mssageCn);
|
|
|
|
|
} else if(!able_kko && able_rcs){ // RCS+XMS
|
|
|
|
|
messageEntity.configMsgTypes(new String[]{"RCS",XMS_msgType});
|
|
|
|
|
messageEntity.configContentsTypeN("RCS");
|
|
|
|
|
messageEntity.configContentsTypeN(RCS_contentsType);
|
|
|
|
|
messageEntity.configContentsTypeN(XMS_contentsType);
|
|
|
|
|
messageEntity.setXmsText(mssageCn);
|
|
|
|
|
} else {// XMS
|
|
|
|
|
messageEntity.configMsgTypes(new String[]{XMS_msgType});
|
|
|
|
|
messageEntity.configContentsTypeN(XMS_contentsType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
messageEntity.setXmsText(mssageCn);
|
|
|
|
|
|
|
|
|
|
if(XMS_msgType.equals("MMS")) {
|
|
|
|
|
messageEntity.setXmsSubject("민원 처리결과 알림");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(able_kko) {
|
|
|
|
|
String json = t[0] + mssageCn + t[1];
|
|
|
|
|
|
|
|
|
|
messageEntity.setAltSenderKey("신청한센더키");
|
|
|
|
|
messageEntity.setAltTemplateCode("신청한템플릿코드");
|
|
|
|
|
|
|
|
|
|
messageEntity.setAltJson(json);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageEntity.setAltSenderKey(kkoSenderKey);
|
|
|
|
|
messageEntity.setAltTemplateCode(kkoTemplateKey);
|
|
|
|
|
messageEntity.setAltJson(altJsonComplete);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(able_rcs) {
|
|
|
|
|
messageEntity.setRcsBrandKey(rcsBrandKey);
|
|
|
|
|
messageEntity.setRcsMassageBaseId(rcsBaseId);
|
|
|
|
|
messageEntity.setRcsJson(rcsJsonComplete);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
messageEntity.setRcsBrandKey("신청한브랜드키");
|
|
|
|
|
|
|
|
|
|
String json = "";
|
|
|
|
|
String contentsTypeOfRCS = messageEntity.findContentsTypeOfRCS();
|
|
|
|
|
|
|
|
|
|
if("RCS".equals(contentsTypeOfRCS)) {
|
|
|
|
|
messageEntity.setRcsMassageBaseId("SS000000");
|
|
|
|
|
} else if("RCL".equals(contentsTypeOfRCS)) {
|
|
|
|
|
messageEntity.setRcsMassageBaseId("SL000000");
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
throw new RuntimeException("");
|
|
|
|
|
//RCT //baseid 발급 필요
|
|
|
|
|
//RCD,RCF //baseId 발급 필요,mgov예제에 없는 형식
|
|
|
|
|
//RCM,RIT //baseId 발급 필요,필요하지 않는 형식(미디어 첨부)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
json = m_b_d[0] + mssageCn + m_b_d[1];
|
|
|
|
|
messageEntity.setXmsText(xmsPlainComplete);
|
|
|
|
|
|
|
|
|
|
messageEntity.setRcsJson(json);
|
|
|
|
|
if(XMS_msgType.equals("MMS")) {
|
|
|
|
|
messageEntity.setXmsSubject("알림");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
messageEntityList.add(messageEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|