발송 진행중
This commit is contained in:
parent
b7fe16bddf
commit
8dd8e23af1
@ -1,13 +1,19 @@
|
|||||||
package itn.com.cmm.util;
|
package itn.com.cmm.util;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
import itn.let.mail.service.StatusResponse;
|
import itn.let.mail.service.StatusResponse;
|
||||||
import itn.let.mjo.msg.service.MjonMsgVO;
|
import itn.let.mjo.msg.service.MjonMsgVO;
|
||||||
import itn.let.mjo.msgdata.service.ReplacementListsVO;
|
import itn.let.mjo.msgdata.service.ReplacementListsVO;
|
||||||
|
import itn.let.module.base.PriceAndPoint;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,7 +30,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
public final class MsgSendUtils {
|
public final class MsgSendUtils {
|
||||||
|
|
||||||
|
|
||||||
@ -128,28 +133,6 @@ public final class MsgSendUtils {
|
|||||||
return "Y".equals(mjonMsgVO.getTxtReplYn());
|
return "Y".equals(mjonMsgVO.getTxtReplYn());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isReplacementDataValid(MjonMsgVO mjonMsgVO) {
|
|
||||||
String[] nameList = mjonMsgVO.getNameList();
|
|
||||||
String[] rep1 = mjonMsgVO.getRep1List();
|
|
||||||
String[] rep2 = mjonMsgVO.getRep2List();
|
|
||||||
String[] rep3 = mjonMsgVO.getRep3List();
|
|
||||||
String[] rep4 = mjonMsgVO.getRep4List();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 치환 문자 리스트가 유효한지 확인
|
|
||||||
return !(isEmpty(nameList)
|
|
||||||
&& isEmpty(rep1)
|
|
||||||
&& isEmpty(rep2)
|
|
||||||
&& isEmpty(rep3)
|
|
||||||
&& isEmpty(rep4));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 배열이 비어있는지 확인하는 메서드
|
|
||||||
public static boolean isEmpty(String[] array) {
|
|
||||||
return array == null || array.length == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ReplacementListsVO createReplacementLists(MjonMsgVO mjonMsgVO) throws UnsupportedEncodingException {
|
public static ReplacementListsVO createReplacementLists(MjonMsgVO mjonMsgVO) throws UnsupportedEncodingException {
|
||||||
ReplacementListsVO lists = new ReplacementListsVO();
|
ReplacementListsVO lists = new ReplacementListsVO();
|
||||||
lists.initializeLists(mjonMsgVO); // 배열을 초기화합니다.
|
lists.initializeLists(mjonMsgVO); // 배열을 초기화합니다.
|
||||||
@ -168,7 +151,7 @@ public final class MsgSendUtils {
|
|||||||
* @return
|
* @return
|
||||||
* @throws UnsupportedEncodingException
|
* @throws UnsupportedEncodingException
|
||||||
*/
|
*/
|
||||||
public static void populateReplacementLists(MjonMsgVO mjonMsgVO, ReplacementListsVO lists, StatusResponse statusResponse){
|
public static Boolean populateReplacementLists(MjonMsgVO mjonMsgVO, ReplacementListsVO lists, StatusResponse statusResponse){
|
||||||
|
|
||||||
|
|
||||||
String[] nameList = mjonMsgVO.getNameList();
|
String[] nameList = mjonMsgVO.getNameList();
|
||||||
@ -184,56 +167,23 @@ public final class MsgSendUtils {
|
|||||||
int shortCnt = 0;
|
int shortCnt = 0;
|
||||||
int longCnt = 0;
|
int longCnt = 0;
|
||||||
int imgCnt = 0;
|
int imgCnt = 0;
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < phone.length; i++) {
|
for (int i = 0; i < phone.length; i++) {
|
||||||
|
|
||||||
smsTxt = smsTxt.replaceAll(String.valueOf((char) 13), "");
|
smsTxt = smsTxt.replaceAll(String.valueOf((char) 13), "");
|
||||||
if (smsTxt.contains("[*이름*]")) {
|
|
||||||
if (nameList.length > i && StringUtil.isNotEmpty(nameList[i])) {
|
|
||||||
smsTxt = smsTxt.replaceAll("\\[\\*이름\\*\\]", StringUtil.getString(nameList[i].replaceAll("§", ",")));
|
|
||||||
} else {
|
|
||||||
smsTxt = smsTxt.replaceAll("\\[\\*이름\\*\\]", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 문자 1 치환
|
|
||||||
if (smsTxt.contains("[*1*]")) {
|
|
||||||
if (rep1.length > i && StringUtil.isNotEmpty(rep1[i])) {
|
|
||||||
smsTxt = smsTxt.replaceAll("\\[\\*1\\*\\]", StringUtil.getString(rep1[i].replaceAll("§", ",")));
|
|
||||||
} else {
|
|
||||||
smsTxt = smsTxt.replaceAll("\\[\\*1\\*\\]", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 문자 2 치환
|
// 이름 및 치환 문자 처리
|
||||||
if (smsTxt.contains("[*2*]")) {
|
smsTxt = replacePlaceholder(smsTxt, "[*이름*]", nameList, i);
|
||||||
if (rep2.length > i && StringUtil.isNotEmpty(rep2[i])) {
|
smsTxt = replacePlaceholder(smsTxt, "[*1*]", rep1, i);
|
||||||
smsTxt = smsTxt.replaceAll("\\[\\*2\\*\\]", StringUtil.getString(rep2[i].replaceAll("§", ",")));
|
smsTxt = replacePlaceholder(smsTxt, "[*2*]", rep2, i);
|
||||||
} else {
|
smsTxt = replacePlaceholder(smsTxt, "[*3*]", rep3, i);
|
||||||
smsTxt = smsTxt.replaceAll("\\[\\*2\\*\\]", "");
|
smsTxt = replacePlaceholder(smsTxt, "[*4*]", rep4, i);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 문자 3 치환
|
|
||||||
if (smsTxt.contains("[*3*]")) {
|
|
||||||
if (rep3.length > i && StringUtil.isNotEmpty(rep3[i])) {
|
|
||||||
smsTxt = smsTxt.replaceAll("\\[\\*3\\*\\]", StringUtil.getString(rep3[i].replaceAll("§", ",")));
|
|
||||||
} else {
|
|
||||||
smsTxt = smsTxt.replaceAll("\\[\\*3\\*\\]", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 문자 4 치환
|
|
||||||
if (smsTxt.contains("[*4*]")) {
|
|
||||||
if (rep4.length > i && StringUtil.isNotEmpty(rep4[i])) {
|
|
||||||
smsTxt = smsTxt.replaceAll("\\[\\*4\\*\\]", StringUtil.getString(rep4[i].replaceAll("§", ",")));
|
|
||||||
} else {
|
|
||||||
smsTxt = smsTxt.replaceAll("\\[\\*4\\*\\]", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int bytes = getSmsTxtBytes(smsTxt);
|
int bytes = getSmsTxtBytes(smsTxt);
|
||||||
|
|
||||||
if(bytes < 2000) {
|
if(bytes < 2000) {
|
||||||
if(fileCount > 0) {
|
if(fileCount > 0) {
|
||||||
populateImgLists(lists, nameList, phone, rep1, rep2, rep3, rep4, smsTxt, i);
|
populateImgLists(lists, nameList, phone, rep1, rep2, rep3, rep4, smsTxt, i);
|
||||||
@ -248,11 +198,13 @@ public final class MsgSendUtils {
|
|||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
statusResponseSet(statusResponse, HttpStatus.BAD_REQUEST, "문자 치환 후 전송 문자 길이를 초과하였습니다.");
|
statusResponseSet(statusResponse, HttpStatus.BAD_REQUEST, "문자 치환 후 전송 문자 길이를 초과하였습니다.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
statusResponseSet(statusResponse, HttpStatus.BAD_REQUEST, "전송 중 오류가 발생하였습니다.");
|
statusResponseSet(statusResponse, HttpStatus.BAD_REQUEST, "문자 치환 중 오류가 발생하였습니다.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,6 +212,28 @@ public final class MsgSendUtils {
|
|||||||
lists.setLongCnt(longCnt);
|
lists.setLongCnt(longCnt);
|
||||||
lists.setImgCnt(imgCnt);
|
lists.setImgCnt(imgCnt);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 특정 플레이스홀더를 리스트에서 가져온 값으로 치환합니다.
|
||||||
|
*
|
||||||
|
* @param smsTxt 문자 내용
|
||||||
|
* @param placeholder 치환할 플레이스홀더 (예: [*이름*])
|
||||||
|
* @param list 치환할 데이터 리스트
|
||||||
|
* @param index 현재 인덱스
|
||||||
|
* @return 치환된 문자 내용
|
||||||
|
*/
|
||||||
|
private static String replacePlaceholder(String smsTxt, String placeholder, String[] list, int index) {
|
||||||
|
if (smsTxt.contains(placeholder)) {
|
||||||
|
if (list.length > index && StringUtil.isNotEmpty(list[index])) {
|
||||||
|
smsTxt = smsTxt.replaceAll(placeholder, StringUtil.getString(list[index].replaceAll("§", ",")));
|
||||||
|
} else {
|
||||||
|
smsTxt = smsTxt.replaceAll(placeholder, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return smsTxt;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void populateShortLists(ReplacementListsVO lists, String[] nameList, String[] phone, String[] rep1,
|
private static void populateShortLists(ReplacementListsVO lists, String[] nameList, String[] phone, String[] rep1,
|
||||||
@ -411,16 +385,37 @@ public final class MsgSendUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static void statusResponseSet (StatusResponse statusResponse, HttpStatus httpStatus, String msg ) {
|
||||||
|
statusResponse.setStatus(httpStatus);
|
||||||
|
statusResponse.setMessage(msg);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StatusResponse validateFilesForMessageSending(int fileCount, MjonMsgVO mjonMsgVO) {
|
||||||
|
if (fileCount > 0) {
|
||||||
|
boolean allFilesAreNull = Stream
|
||||||
|
.of(mjonMsgVO.getFileName1(), mjonMsgVO.getFileName2(), mjonMsgVO.getFileName3())
|
||||||
|
.allMatch(Objects::isNull);
|
||||||
|
|
||||||
|
if (allFilesAreNull) {
|
||||||
|
return new StatusResponse(HttpStatus.NO_CONTENT, "문자 메세지 이미지 추가에 오류가 발생하여 문자 발송이 취소 되었습니다.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null; // 유효성 검사를 통과한 경우
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @methodName : checkReplacementDataValidity
|
* @methodName : validateReplacementData
|
||||||
* @author : 이호영
|
* @author : 이호영
|
||||||
* @date : 2024.09.25
|
* @date : 2024.09.25
|
||||||
* @description : 치환문자가 사용될 때 데이터가 올바른지 확인하는 메서드
|
* @description : 치환문자가 사용될 때 데이터가 올바른지 확인하는 메서드
|
||||||
* @param mjonMsgVO
|
* @param mjonMsgVO
|
||||||
* @param modelAndView
|
* @param statusResponse
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static boolean checkReplacementDataValidity(MjonMsgVO mjonMsgVO, StatusResponse statusResponse) {
|
public static boolean validateReplacementData(MjonMsgVO mjonMsgVO, StatusResponse statusResponse) {
|
||||||
String[] nameList = mjonMsgVO.getNameList();
|
String[] nameList = mjonMsgVO.getNameList();
|
||||||
String[] phone = mjonMsgVO.getCallToList();
|
String[] phone = mjonMsgVO.getCallToList();
|
||||||
String[] rep1 = mjonMsgVO.getRep1List();
|
String[] rep1 = mjonMsgVO.getRep1List();
|
||||||
@ -428,9 +423,19 @@ public final class MsgSendUtils {
|
|||||||
String[] rep3 = mjonMsgVO.getRep3List();
|
String[] rep3 = mjonMsgVO.getRep3List();
|
||||||
String[] rep4 = mjonMsgVO.getRep4List();
|
String[] rep4 = mjonMsgVO.getRep4List();
|
||||||
|
|
||||||
|
// 치환 문자 리스트가 모두 비어있는지 확인
|
||||||
|
if (isEmpty(nameList)
|
||||||
|
&& isEmpty(rep1)
|
||||||
|
&& isEmpty(rep2)
|
||||||
|
&& isEmpty(rep3)
|
||||||
|
&& isEmpty(rep4)) {
|
||||||
|
statusResponseSet(statusResponse, HttpStatus.BAD_REQUEST, "특정문구 일괄변환 치환문자 데이터가 없습니다.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 치환 문자 필드 개수와 전화번호 개수가 일치하는지 확인
|
||||||
boolean isRepCountOk = true;
|
boolean isRepCountOk = true;
|
||||||
|
|
||||||
// 치환 문자 전체 필수 체크
|
|
||||||
if (mjonMsgVO.getSmsTxt().contains("[*이름*]") && nameList.length != phone.length) {
|
if (mjonMsgVO.getSmsTxt().contains("[*이름*]") && nameList.length != phone.length) {
|
||||||
isRepCountOk = false;
|
isRepCountOk = false;
|
||||||
}
|
}
|
||||||
@ -447,21 +452,18 @@ public final class MsgSendUtils {
|
|||||||
isRepCountOk = false;
|
isRepCountOk = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 검증 결과가 false인 경우 에러 메시지 반환
|
// 필드 개수가 일치하지 않는 경우 에러 메시지 반환
|
||||||
if (!isRepCountOk) {
|
if (!isRepCountOk) {
|
||||||
|
statusResponseSet(statusResponse, HttpStatus.BAD_REQUEST, "특정문구 일괄변환 치환문자 데이터가 일치하지 않습니다.");
|
||||||
statusResponseSet(statusResponse, HttpStatus.BAD_REQUEST, "특정문구 일괄변환 치환문자 데이터가 없습니다.");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true; // 모든 유효성 검사를 통과한 경우
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 배열이 비어있는지 확인하는 메서드
|
||||||
private static void statusResponseSet (StatusResponse statusResponse, HttpStatus httpStatus, String msg ) {
|
public static boolean isEmpty(String[] array) {
|
||||||
statusResponse.setStatus(httpStatus);
|
return array == null || array.length == 0;
|
||||||
statusResponse.setMessage(msg);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1057,7 +1057,7 @@ public class MjonMsgServiceImpl extends EgovAbstractServiceImpl implements MjonM
|
|||||||
public List<MjonMsgStatVO> selectAgentSmsCountStatList(MjonMsgStatVO mjonMsgStatVO) throws Exception {
|
public List<MjonMsgStatVO> selectAgentSmsCountStatList(MjonMsgStatVO mjonMsgStatVO) throws Exception {
|
||||||
|
|
||||||
List<MjonMsgStatVO> list = mjonMsgDAO.selectAgentSmsCountStatList(mjonMsgStatVO);
|
List<MjonMsgStatVO> list = mjonMsgDAO.selectAgentSmsCountStatList(mjonMsgStatVO);
|
||||||
|
System.out.println("??????++++++++++++++++++++++++");
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -186,4 +186,5 @@ public interface MjonMsgDataService {
|
|||||||
public StatusResponse sendMsgData_advc(MjonMsgVO mjonMsgVO, HttpServletRequest request) throws Exception;
|
public StatusResponse sendMsgData_advc(MjonMsgVO mjonMsgVO, HttpServletRequest request) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- <!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" -->
|
||||||
|
<!-- "http://www.ibatis.com/dtd/sql-map-config-2.dtd"> -->
|
||||||
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
|
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
|
||||||
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">
|
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
|
||||||
<sqlMapConfig>
|
<sqlMapConfig>
|
||||||
<sqlMap resource="egovframework/sqlmap/let/mjo/apikey/ApiKeyMng_SQL_Mysql.xml"/> <!-- api key list -->
|
<sqlMap resource="egovframework/sqlmap/let/mjo/apikey/ApiKeyMng_SQL_Mysql.xml"/> <!-- api key list -->
|
||||||
<sqlMap resource="egovframework/sqlmap/let/mjo/apikey/ApiCallInfoMng_SQL_Mysql.xml"/> <!-- api call info -->
|
<sqlMap resource="egovframework/sqlmap/let/mjo/apikey/ApiCallInfoMng_SQL_Mysql.xml"/> <!-- api call info -->
|
||||||
|
|||||||
@ -3,7 +3,9 @@
|
|||||||
========= ======= =================================================
|
========= ======= =================================================
|
||||||
2024.07.29 우영두
|
2024.07.29 우영두
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
|
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
|
||||||
|
|
||||||
|
|
||||||
<sqlMap namespace="Holiday">
|
<sqlMap namespace="Holiday">
|
||||||
<typeAlias alias="msgHolidayVO" type="itn.let.mjo.msgholiday.service.MsgHolidayVO"/>
|
<typeAlias alias="msgHolidayVO" type="itn.let.mjo.msgholiday.service.MsgHolidayVO"/>
|
||||||
<typeAlias alias="msgAlarmSetVO" type="itn.let.mjo.msgholiday.service.MsgAlarmSetVO"/>
|
<typeAlias alias="msgAlarmSetVO" type="itn.let.mjo.msgholiday.service.MsgAlarmSetVO"/>
|
||||||
|
|||||||
@ -2787,7 +2787,7 @@ function loadAddrList(){
|
|||||||
*/
|
*/
|
||||||
var data = $("#searchAddrGrpForm").serialize();
|
var data = $("#searchAddrGrpForm").serialize();
|
||||||
|
|
||||||
var url = "/web/mjon/msgdata/selectMsgAddrListAjax_advc.do";
|
var url = "/web/mjon/msgdata/selectMsgAddrListAjax.do";
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user