문자발송 연계 최초커밋

main
이범준 4 days ago
parent a0ee472c43
commit 513aa55119

3
.gitignore vendored

@ -10,6 +10,9 @@ local.properties
.settings/ .settings/
.loadpath .loadpath
.recommenders .recommenders
.classpath
.project
target/
# External tool builders # External tool builders
.externalToolBuilders/ .externalToolBuilders/

@ -1,3 +0,0 @@
# xit-mms
모바일 메시지 서비스

@ -0,0 +1,227 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cokr.xit.interfaces</groupId>
<artifactId>xit-mms</artifactId>
<version>1.0.0-SNAPSHOT</version>
<description>모바일 문자전송 서비스(mobile message service)</description>
<packaging>jar</packaging>
<name>xit-mms</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>mvn2s</id>
<url>https://repo1.maven.org/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>egovframe</id>
<url>https://maven.egovframe.go.kr/maven/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>maven-public</id>
<url>https://nas.xit.co.kr:8888/repository/maven-public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>maven-public</id>
<url>https://nas.xit.co.kr:8888/repository/maven-public/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.egovframe.rte</groupId>
<artifactId>org.egovframe.psl.dataaccess</artifactId>
<exclusions>
<exclusion>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>cokr.xit.base</groupId>
<artifactId>xit-foundation</artifactId>
<version>23.04.01-SNAPSHOT</version>
</dependency>
<!-- 마리아DB -->
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.7.2</version>
<scope>runtime</scope>
</dependency>
<!-- json -->
<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<version>2.4.11</version>
</dependency>
<!-- 앱 지원 -->
<dependency>
<groupId>cokr.xit.app</groupId>
<artifactId>app-support-java</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<directory>${basedir}/target</directory>
<finalName>${project.artifactId}-${project.version}</finalName>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource><directory>${basedir}/src/test/resources</directory></testResource>
<testResource><directory>${basedir}/src/main/resources</directory></testResource>
</testResources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<includeEmptyDirs>true</includeEmptyDirs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- EMMA -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-alpha-3</version>
</plugin>
<!-- PMD manven plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<includes>
<include>**/*.*</include>
</includes>
</configuration>
</plugin>
<!-- EMMA -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<skipTests>true</skipTests>
<reportFormat>xml</reportFormat>
<excludes>
<exclude>**/Abstract*.java</exclude>
<exclude>**/*Suite.java</exclude>
</excludes>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<inherited>true</inherited>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
</plugin>
</plugins>
</build>
<!-- Nexus deploy -->
<distributionManagement>
<snapshotRepository>
<id>maven-snapshot</id>
<url>https://nas.xit.co.kr:8888/repository/maven-snapshots/</url>
</snapshotRepository>
<repository>
<id>maven-release</id>
<url>https://nas.xit.co.kr:8888/repository/maven-releases/</url>
</repository>
</distributionManagement>
<!-- Nexus deploy -->
</project>

@ -0,0 +1,415 @@
package cokr.xit.interfaces.message;
import java.util.Arrays;
import cokr.xit.foundation.AbstractEntity;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class MessageEntity extends AbstractEntity {
/**
*
*/
private String msgKey;
/**
* G/W
*/
private String subId;
/**
*
*/
private String userKey;
/**
*
*/
private String userGroup;
/**
*
*/
private String userId;
/**
* JOB
*/
private String userJobid;
/**
* ( )
*/
private String centerKey;
/**
* ( )
*/
private String msgPriority;
/**
*
*/
private String msgState;
/**
* (DB )
*/
private String inputDate;
/**
*
*/
private String resDate;
/**
*
*/
private String queDate;
/**
*
*/
private String sentDate;
/**
*
*/
private String rsltDate;
/**
* G/W
*/
private String reportDate;
/**
*
*/
private String rsltCode;
/**
*
*/
private String rsltNet;
/**
*
*/
private String rsltType;
/**
*
*/
private String sentCount;
/**
*
*/
private String historyMsgType;
/**
*
*/
private String historyRsltCode;
/**
*
*/
private String identifier;
/**
*
*/
private String phone;
/**
*
*/
private String callback;
/**
* 1
*/
private String msgType1;
/**
* 1
*/
private String contentsType1;
/**
* 1
*/
private String queDate1;
/**
* 1
*/
private String sentDate1;
/**
* 2
*/
private String msgType2;
/**
* 2
*/
private String contentsType2;
/**
* 2
*/
private String queDate2;
/**
* 2
*/
private String sentDate2;
/**
* 3
*/
private String msgType3;
/**
* 3
*/
private String contentsType3;
/**
* 3
*/
private String queDate3;
/**
* 3
*/
private String sentDate3;
/**
* XMS
*/
private String xmsRsltCode;
/**
* XMS
*/
private String xmsRsltNet;
/**
* XMS
*/
private String xmsRsltDate;
/**
* XMS G/W
*/
private String xmsReportDate;
/**
* ALT
*/
private String altRsltCode;
/**
* ALT
*/
private String altRsltNet;
/**
* ALT
*/
private String altRsltDate;
/**
* ALT G/W
*/
private String altReportDate;
/**
* RCS
*/
private String rcsRsltCode;
/**
* RCS
*/
private String rcsRsltNet;
/**
* RCS
*/
private String rcsRsltDate;
/**
* RCS G/W
*/
private String rcsReportDate;
/**
* (LMS/MMS)
*/
private String xmsSubject;
/**
* (SMS/LMS/MMS)
*/
private String xmsText;
/**
* 1(MMS)
*/
private String xmsFileName1;
/**
* 2(MMS)
*/
private String xmsFileName2;
/**
* 3(MMS)
*/
private String xmsFileName3;
/**
* ALT (ALT,ALI)
*/
private String altCountryCode;
/**
* ALT (ALT,ALI)
*/
private String altSenderKey;
/**
* ALT 릿 (ALT,ALI)
*/
private String altTemplateCode;
/**
* (ALT,ALI)
*/
private String altJson;
/**
* RCS
*/
private String rcsBrandKey;
/**
* RCS
*/
private String rcsMassageBaseId;
/**
* (RCS)
*/
private String rcsJson;
/**
*
*/
private String failRsn;
/**
* 1,2,3
*/
public void configMsgTypes(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 configContentsTypeN(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 findContentsTypeOfRCS() {
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 findContentsTypeOfALT() {
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 findContentsTypeOfXMS() {
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;
}
}

@ -0,0 +1,57 @@
package cokr.xit.interfaces.message;
import cokr.xit.foundation.component.QueryRequest;
public class MessageQuery extends QueryRequest {
private static final long serialVersionUID = 1L;
private String sggCd;
private String schInputYmdFrom;
private String schInputYmdTo;
private String stngInfoType; //설정정보유형(01:게이트웨이ID,02:송신전화번호,03:서비스사용자ID,04:템플릿)
private String msgPrps; //고장신고,사전알림,주차신고민원,기타민원
private String msgDtlPrps;
private String callback;
private String phone;
private String msgState;
public String getSggCd() {
return ifEmpty(sggCd, () -> null);
}
public <T extends QueryRequest> T setSggCd(String sggCd) {
this.sggCd = sggCd;
return self();
}
public String getSchInputYmdFrom() {
return ifEmpty(schInputYmdFrom, () -> null);
}
public <T extends QueryRequest> T setSchInputYmdFrom(String schInputYmdFrom) {
this.schInputYmdFrom = schInputYmdFrom;
return self();
}
public String getSchInputYmdTo() {
return ifEmpty(schInputYmdTo, () -> null);
}
public <T extends QueryRequest> T setSchInputYmdTo(String schInputYmdTo) {
this.schInputYmdTo = schInputYmdTo;
return self();
}
public String getStngInfoType() {
return ifEmpty(stngInfoType, () -> null);
}
public <T extends QueryRequest> T setStngInfoType(String stngInfoType) {
this.stngInfoType = stngInfoType;
return self();
}
}

@ -0,0 +1,20 @@
package cokr.xit.interfaces.message.dao;
import java.util.List;
import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
import cokr.xit.foundation.component.AbstractMapper;
import cokr.xit.foundation.data.DataObject;
import cokr.xit.interfaces.message.MessageEntity;
import cokr.xit.interfaces.message.MessageQuery;
@Mapper("messageMapper")
public interface MessageMapper extends AbstractMapper {
int insert(MessageEntity messageEntity);
DataObject selectStng(MessageQuery messageQuery);
List<DataObject> selectList(MessageQuery messageQuery);
}

@ -0,0 +1,16 @@
package cokr.xit.interfaces.message.service;
import java.util.List;
import java.util.Map;
import cokr.xit.foundation.data.DataObject;
import cokr.xit.interfaces.message.MessageEntity;
import cokr.xit.interfaces.message.MessageQuery;
public interface MessageService {
Map<String,Object> regist(List<MessageEntity> messageEntity);
List<DataObject> getList(MessageQuery messageQuery);
}

@ -0,0 +1,33 @@
package cokr.xit.interfaces.message.service.bean;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import cokr.xit.foundation.component.AbstractBean;
import cokr.xit.foundation.data.DataObject;
import cokr.xit.interfaces.message.MessageEntity;
import cokr.xit.interfaces.message.MessageQuery;
import cokr.xit.interfaces.message.dao.MessageMapper;
@Component("messageBean")
public class MessageBean extends AbstractBean {
@Resource(name="messageMapper")
private MessageMapper messageMapper;
public boolean regist(MessageEntity messageEntity) {
int result = messageMapper.insert(messageEntity);
return result == 1 ? true : false;
}
public List<DataObject> getList(MessageQuery messageQuery) {
if(ifEmpty(messageQuery.getOrderBy(), ()->"").equals("")) {
messageQuery.setOrderBy("MSG_KEY");
}
return messageMapper.selectList(messageQuery);
}
}

@ -0,0 +1,177 @@
package cokr.xit.interfaces.message.service.bean;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.sql.DataSource;
import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
import org.egovframe.rte.fdl.string.EgovStringUtil;
import org.springframework.stereotype.Service;
import cokr.xit.applib.AppCmmnUtil;
import cokr.xit.applib.Hangul;
import cokr.xit.foundation.component.AbstractServiceBean;
import cokr.xit.foundation.data.DataObject;
import cokr.xit.interfaces.message.MessageEntity;
import cokr.xit.interfaces.message.MessageQuery;
import cokr.xit.interfaces.message.service.MessageService;
@Service("messageService")
public class MessageServiceBean extends AbstractServiceBean implements MessageService {
@Resource(name="databaseIdProvider")
private VendorDatabaseIdProvider databaseIdProvider;
@Resource(name="dataSource")
private DataSource dataSource;
@Resource(name="messageBean")
private MessageBean messageBean;
@Override
public Map<String,Object> regist(List<MessageEntity> messageEntityList) {
Map<String,Object> resultMap = new HashMap<String,Object>();
List<MessageEntity> successList = new ArrayList<MessageEntity>();
List<MessageEntity> failList = new ArrayList<MessageEntity>();
String databaseId = databaseIdProvider.getDatabaseId(dataSource);
for(MessageEntity messageEntity : messageEntityList) {
boolean isSuccess = false;
//발신전화 검증
if(ifEmpty(messageEntity.getCallback(), ()->"").equals("")) {
isSuccess = false;
messageEntity.setFailRsn("발신 전화번호 없음");
failList.add(messageEntity);
continue;
}
if(!AppCmmnUtil.isTelno(messageEntity.getCallback())) {
isSuccess = false;
messageEntity.setFailRsn("발신 가능한 전화번호 형식이 아님");
failList.add(messageEntity);
continue;
}
//수신전화 검증
if(ifEmpty(messageEntity.getPhone(), ()->"").equals("")) {
isSuccess = false;
messageEntity.setFailRsn("수신 전화번호 없음");
failList.add(messageEntity);
continue;
}
if(!AppCmmnUtil.isReceivePhone(messageEntity.getPhone())) {
isSuccess = false;
messageEntity.setFailRsn("수신 가능한 전화번호 형식이 아님");
failList.add(messageEntity);
continue;
}
//발송예약일시 검증
if(!ifEmpty(messageEntity.getResDate(), ()->"").equals("")) {
if(!AppCmmnUtil.isDateTimeDigitPattern(messageEntity.getResDate())) {
isSuccess = false;
messageEntity.setFailRsn("발송예약일시가 연월일시분초 형식이 아님");
failList.add(messageEntity);
continue;
}
}
Hangul hangul = new Hangul(2);
//알림톡 검증
if(!EgovStringUtil.null2void(messageEntity.getAltSenderKey()).equals("")) {
String altJson = messageEntity.getAltJson();
if(altJson.length() > 1000) {
isSuccess = false;
messageEntity.setFailRsn("알림톡 글자수(1000자) 초과");
failList.add(messageEntity);
continue;
}
}
//RCS 검증
if(!EgovStringUtil.null2void(messageEntity.getRcsBrandKey()).equals("")) {
String rcsJson = messageEntity.getRcsJson();
//
}
//XMS 제목 바이트 수
int xmsSubjectByteCnt = hangul.getByteLength(messageEntity.getXmsSubject());
//XMS 내용 바이트 수
int xmsContentByteCnt = hangul.getByteLength(messageEntity.getXmsText());
//XMS 내용 바이트 수 보정(줄바꿈문자)
if(databaseId.equals("mariadb") || databaseId.equals("mysql")) {
int lineChageCount = this.countLineChangeForNuri2Maria(messageEntity.getXmsText());
xmsContentByteCnt = xmsContentByteCnt - (lineChageCount*3);
} else {
int lineChageCount = this.countLineChangeForNuri2Oracle(messageEntity.getXmsText());
xmsContentByteCnt = xmsContentByteCnt - lineChageCount;
}
String contentsTypeOfXMS = messageEntity.findContentsTypeOfXMS();
//XMS 검증
if("SMS".equals(contentsTypeOfXMS) && xmsContentByteCnt > 90) {
isSuccess = false;
messageEntity.setFailRsn("SMS 최대 바이트 수(90byte) 초과");
failList.add(messageEntity);
continue;
}
if("LMS".equals(contentsTypeOfXMS)) {
if(xmsSubjectByteCnt > 30) {
isSuccess = false;
messageEntity.setFailRsn("LMS 제목 최대 바이트 수(30byte) 초과");
failList.add(messageEntity);
continue;
}
if(xmsContentByteCnt > 2000) {
isSuccess = false;
messageEntity.setFailRsn("LMS 내용 최대 바이트 수(2000byte) 초과");
failList.add(messageEntity);
continue;
}
}
isSuccess = messageBean.regist(messageEntity);
if(isSuccess) {
successList.add(messageEntity);
} else {
failList.add(messageEntity);
}
}
resultMap.put("successList", successList);
resultMap.put("failList", failList);
return resultMap;
}
public int countLineChangeForNuri2Oracle(String str) {
if(str == null || str.equals("")) {
return 0;
}
return str.split("\r\n",-1).length - 1;
}
public int countLineChangeForNuri2Maria(String str) {
if(str == null || str.equals("")) {
return 0;
}
return str.split("\\\\r\\\\n",-1).length - 1;
}
@Override
public List<DataObject> getList(MessageQuery messageQuery) {
return messageBean.getList(messageQuery);
}
}

@ -0,0 +1,29 @@
package cokr.xit.interfaces.message.web;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;
import cokr.xit.foundation.data.DataObject;
import cokr.xit.foundation.web.AbstractController;
import cokr.xit.interfaces.message.MessageQuery;
import cokr.xit.interfaces.message.service.MessageService;
@Controller
public class MessageController extends AbstractController {
@Resource(name="messageService")
private MessageService messageService;
public ModelAndView list(MessageQuery messageQuery) {
ModelAndView mav = new ModelAndView("jsonView");
List<DataObject> list = messageService.getList(messageQuery);
return setPagingInfo(mav, list, "");
}
}

@ -0,0 +1,196 @@
package cokr.xit.interfaces.message.web;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.sql.DataSource;
import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
import org.egovframe.rte.fdl.string.EgovStringUtil;
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.foundation.web.AbstractController;
import cokr.xit.interfaces.message.MessageEntity;
import cokr.xit.interfaces.message.MessageQuery;
import cokr.xit.interfaces.message.dao.MessageMapper;
import cokr.xit.interfaces.message.service.MessageService;
import net.minidev.json.JSONObject;
@Controller("messageInterfaceController")
@RequestMapping(value = "/intf/message", name = "메시지 연계")
public class MessageInterfaceController extends AbstractController {
@Resource(name="databaseIdProvider")
private VendorDatabaseIdProvider databaseIdProvider;
@Resource(name="dataSource")
private DataSource dataSource;
@Resource(name="messageService")
private MessageService messageService;
@Resource(name="messageMapper")
private MessageMapper messageMapper;
public final static String[] m_b_d = {
"{\"msg\":{\"body\":\"{description\":",
"},},}"
};
public final static String[] t = {
"{\"text\":",
"}"
};
@PostMapping(name="문자전송 요청 등록", value="/regist")
public ModelAndView regist(@RequestBody JSONObject apiSpec) {
ModelAndView mav = new ModelAndView("jsonView");
//누리2모듈 아이디 찾기
MessageQuery messageQuery = new MessageQuery();
messageQuery.setStngInfoType("01");
messageQuery.setSggCd(System.getProperty("sgg"));
String nuri2Id = messageMapper.selectStng(messageQuery).string("MODULE_ID");
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", "요청시스템이 없습니다.");
mav.addObject("saved", false);
return mav;
}
String msgPrps = (String) apiSpec.get("msgPrps"); //목적(고장신고,사전알림,주차신고민원,기타민원)
if(EgovStringUtil.null2void(msgPrps).equals("")) {
mav.addObject("failRsn", "메시지 발송 목적이 없습니다.");
mav.addObject("saved", false);
return mav;
}
String msgDtlPrps = (String) apiSpec.get("msgDtlPrps"); //상세목적
String sggCd = (String) apiSpec.get("sggCd"); //시군구코드
String databaseId = databaseIdProvider.getDatabaseId(dataSource);
List<MessageEntity> messageEntityList = new ArrayList<MessageEntity>();
List<Map> reqs = (List<Map>) apiSpec.get("reqs");
for(Map req : reqs) {
MessageEntity messageEntity = new MessageEntity();
messageEntity.setSubId(nuri2Id);
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 = this.replaceLineChangeForNuri2Maria(mssageCn);
} else {
mssageCn = this.replaceLineChangeForNuri2Oracle(mssageCn);
}
if(!EgovStringUtil.null2void(resDate).equals("")) {
messageEntity.setResDate(resDate);
}
boolean able_kko = false; //알림톡 가능 여부
boolean able_rcs = false; //RCS 가능 여부
if(able_kko && able_rcs) { // 알림톡+RCS+XMS
messageEntity.configMsgTypes(new String[]{"ALT","RCS","MMS"});
messageEntity.configContentsTypeN("ALT");
messageEntity.configContentsTypeN("RCL");
messageEntity.configContentsTypeN("LMS");
} else if(able_kko && !able_rcs) { // 알림톡+XMS
messageEntity.configMsgTypes(new String[]{"ALT","MMS"});
messageEntity.configContentsTypeN("ALT");
messageEntity.configContentsTypeN("LMS");
messageEntity.setXmsText(mssageCn);
} else if(!able_kko && able_rcs){ // RCS+XMS
messageEntity.configMsgTypes(new String[]{"RCS","MMS"});
messageEntity.configContentsTypeN("RCL");
messageEntity.configContentsTypeN("LMS");
messageEntity.setXmsText(mssageCn);
} else {// XMS
messageEntity.configMsgTypes(new String[]{"MMS"});
messageEntity.configContentsTypeN("LMS");
}
messageEntity.setXmsText(mssageCn);
if(able_kko) {
String json = t[0] + mssageCn + t[1];
messageEntity.setAltSenderKey("신청한센더키");
messageEntity.setAltTemplateCode("신청한템플릿코드");
messageEntity.setAltJson(json);
}
if(able_rcs) {
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 발급 필요
//RLT //RCT의 오타
//RCD,RCF //baseId 발급 필요,mgov예제에 없는 형식
//RCM,RIT //baseId 발급 필요,필요하지 않는 형식(미디어 첨부)
}
json = m_b_d[0] + mssageCn + m_b_d[1];
messageEntity.setRcsJson(json);
}
messageEntityList.add(messageEntity);
}
//
Map<String,Object> resultMap = messageService.regist(messageEntityList);
mav.addObject("resultMap", resultMap);
mav.addObject("saved",true);
return mav;
}
public String replaceLineChangeForNuri2Oracle(String str) {
String result = "";
result = str.replaceAll("\r","");
result = result.replaceAll("\n","\r\n");
return result;
}
public String replaceLineChangeForNuri2Maria(String str) {
String result = "";
result = str.replaceAll("\r","");
result = result.replaceAll("\n", "\\\\r\\\\n");
return result;
}
}

@ -0,0 +1,192 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cokr.xit.interfaces.message.dao.MessageMapper">
<select id="selectList" parameterType="cokr.xit.interfaces.message.MessageQuery" resultType="dataObject">
/* 문자전송 목록(msgMapper.selectList) */
<include refid="utility.paging-prefix"/>
SELECT MSG_KEY
, SUB_ID
, USER_KEY
, USER_GROUP
, USER_ID
, USER_JOBID
, CENTER_KEY
, MSG_PRIORITY
, 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
, REPORT_DATE
, RSLT_CODE
, RSLT_NET
, RSLT_TYPE
, SENT_COUNT
, HISTORY_MSG_TYPE
, HISTORY_RSLT_CODE
, 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
, 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
FROM NURI2_NRMSG_DATA
WHERE 1=1
AND INPUT_DT <![CDATA[>=]]> CONCAT(#{schInputYmdFrom},'000000')
AND INPUT_DT <![CDATA[<=]]> CONCAT(#{schInputYmdTo},'235959')
<include refid="utility.sortBy" />
<include refid="utility.paging-suffix"/>
</select>
<insert id="insert" parameterType="cokr.xit.interfaces.message.MessageEntity">
/* 문자전송 요청 등록(msgMapper.insert) */
INSERT
INTO NURI2_NRMSG_DATA (
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
, MSG_TYPE_2, CONTENTS_TYPE_2
, MSG_TYPE_3, CONTENTS_TYPE_3
, XMS_SUBJECT
, XMS_TEXT
<if test="@org.egovframe.rte.fdl.string.EgovStringUtil@isNotEmpty(altSenderKey)">
, ALT_COUNTRY_CODE
, ALT_SENDER_KEY
, ALT_TEMPLATE_CODE
, ALT_JSON
</if>
<if test="@org.egovframe.rte.fdl.string.EgovStringUtil@isNotEmpty(rcsBrandKey)">
, RCS_BRAND_KEY
, RCS_MASSAGE_BASE_ID
, RCS_JSON
</if>
<!-- , CENTER_KEY, MSG_PRIORITY --><!-- 전송라인,우선순위 (추후 요구시 사용) -->
<!-- , MSG_STATE --><!-- 메시지 상태 값 -->
<!-- , QUE_DATE, SENT_DATE, RSLT_DATE, REPORT_DATE -->
<!-- , RSLT_CODE, RSLT_NET, RSLT_TYPE, SENT_COUNT, HISTORY_MSG_TYPE, HISTORY_RSLT_CODE -->
<!-- , QUE_DATE_1, SENT_DATE_1 -->
<!-- , QUE_DATE_2, SENT_DATE_2 -->
<!-- , 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 -->
<!-- , XMS_FILE_NAME_1, XMS_FILE_NAME_2, XMS_FILE_NAME_3 -->
)
VALUES (
#{subId}
, #{userKey}, #{userGroup}, #{userId}, #{userJobid}
, CURRENT_TIMESTAMP <!-- 메시지 입력 일시 -->
, <include refid="utility.now"/> <!-- 메시지 입력 일시(사용자정의컬럼) -->
<if test="resDate == null">
, CURRENT_TIMESTAMP <!-- 메시지 예약 일시 -->
, <include refid="utility.now"/> <!-- 메시지 예약 일시(사용자정의컬럼) -->
</if>
<if test="resDate != null">
<if test="_databaseId == 'mariadb'">
, STR_TO_DATE(#{resDate},'%Y%m%d%H%i%s') <!-- 메시지 예약 일시 -->
</if>
<if test="_databaseId == 'oracle'">
, TO_DATE(#{resDate},'YYYYMMDDHH24MISS') <!-- 메시지 예약 일시 -->
</if>
, #{resDate} <!-- 메시지 예약 일시(사용자정의컬럼) -->
</if>
, #{identifier}
, #{phone}, #{callback} <!-- 수신번호,발신번호 -->
, #{msgType1}, #{contentsType1}
, #{msgType2}, #{contentsType2}
, #{msgType3}, #{contentsType3}
, #{xmsSubject}
, #{xmsText}
<if test="@org.egovframe.rte.fdl.string.EgovStringUtil@isNotEmpty(altSenderKey)">
, '82'
, #{altSenderKey}
, #{altTemplateCode}
, #{altJson}
</if>
<if test="@org.egovframe.rte.fdl.string.EgovStringUtil@isNotEmpty(rcsBrandKey)">
, #{rcsBrandKey}
, #{rcsMassageBaseId}
, #{rcsJson}
</if>
<!-- , #{centerKey}, #{msgPriority} --><!-- 전송라인,우선순위 (추후 요구시 사용) -->
<!-- , #{msgState} --><!-- 메시지 상태 값 -->
<!-- , #{queDate}, #{sentDate}, #{rsltDate}, #{reportDate} -->
<!-- , #{rsltCode}, #{rsltNet}, #{rsltType}, #{sentCount}, #{historyMsgType}, #{historyRsltCode} -->
<!-- , #{queDate1}, #{sentDate1} -->
<!-- , #{queDate2}, #{sentDate2} -->
<!-- , #{queDate3}, #{sentDate3} -->
<!-- , #{xmsRsltCode}, #{xmsRsltNet}, #{xmsRsltDate}, #{xmsReportDate} -->
<!-- , #{altRsltCode}, #{altRsltNet}, #{altRsltDate}, #{altReportDate} -->
<!-- , #{rcsRsltCode}, #{rcsRsltNet}, #{rcsRsltDate}, #{rcsReportDate} -->
<!-- , #{xmsFileName1}, #{xmsFileName2}, #{xmsFileName3} -->
)
</insert>
<select id="selectStng" parameterType="cokr.xit.interfaces.message.MessageQuery">
/* 문자전송 설정 정보 조회(msgMapper.selectStng) */
SELECT MSG_STNG_ID
, SGG_CD
, STNG_INFO_TYPE
, TASK_TYPE
, TASK_SE_CD
, MODULE_ID
, TELNO
, SVC_TYPE
, SVC_USER_ID
, TMPLAT_ID
, TMPLT_CN
, USE_YN
FROM TB_MSG_STNG
WHERE STNG_INFO_TYPE = #{stngInfoType}
AND USE_YN = 'Y'
<if test="sggCd != null">
AND SGG_CD = #{sggCd}
</if>
</select>
</mapper>
Loading…
Cancel
Save