발송 진행중
This commit is contained in:
parent
b7fe16bddf
commit
8dd8e23af1
@ -1,13 +1,19 @@
|
||||
package itn.com.cmm.util;
|
||||
|
||||
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.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import itn.let.mail.service.StatusResponse;
|
||||
import itn.let.mjo.msg.service.MjonMsgVO;
|
||||
import itn.let.mjo.msgdata.service.ReplacementListsVO;
|
||||
import itn.let.module.base.PriceAndPoint;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
@ -24,7 +30,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
public final class MsgSendUtils {
|
||||
|
||||
|
||||
@ -103,51 +108,29 @@ public final class MsgSendUtils {
|
||||
* @return
|
||||
*/
|
||||
public static float determinePriceByMsgType(MjonMsgVO mjonMsgVO, float shortPrice, float longPrice,
|
||||
float picturePrice, float picture2Price, float picture3Price) {
|
||||
float price = 0;
|
||||
String msgType = mjonMsgVO.getMsgType();
|
||||
|
||||
if ("4".equals(msgType)) {
|
||||
price = shortPrice;
|
||||
} else if ("6".equals(msgType)) {
|
||||
// 파일 첨부 여부에 따라 장문 단가 설정
|
||||
if (mjonMsgVO.getFileName3() != null) {
|
||||
price = picture3Price;
|
||||
} else if (mjonMsgVO.getFileName2() != null) {
|
||||
price = picture2Price;
|
||||
} else if (mjonMsgVO.getFileName1() != null) {
|
||||
price = picturePrice;
|
||||
} else {
|
||||
price = longPrice;
|
||||
}
|
||||
}
|
||||
return price;
|
||||
float picturePrice, float picture2Price, float picture3Price) {
|
||||
float price = 0;
|
||||
String msgType = mjonMsgVO.getMsgType();
|
||||
|
||||
if ("4".equals(msgType)) {
|
||||
price = shortPrice;
|
||||
} else if ("6".equals(msgType)) {
|
||||
// 파일 첨부 여부에 따라 장문 단가 설정
|
||||
if (mjonMsgVO.getFileName3() != null) {
|
||||
price = picture3Price;
|
||||
} else if (mjonMsgVO.getFileName2() != null) {
|
||||
price = picture2Price;
|
||||
} else if (mjonMsgVO.getFileName1() != null) {
|
||||
price = picturePrice;
|
||||
} else {
|
||||
price = longPrice;
|
||||
}
|
||||
}
|
||||
return price;
|
||||
}
|
||||
|
||||
public static boolean isReplacementRequired(MjonMsgVO mjonMsgVO) {
|
||||
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;
|
||||
return "Y".equals(mjonMsgVO.getTxtReplYn());
|
||||
}
|
||||
|
||||
public static ReplacementListsVO createReplacementLists(MjonMsgVO mjonMsgVO) throws UnsupportedEncodingException {
|
||||
@ -168,99 +151,90 @@ public final class MsgSendUtils {
|
||||
* @return
|
||||
* @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[] phone = mjonMsgVO.getCallToList();
|
||||
String[] rep1 = mjonMsgVO.getRep1List();
|
||||
String[] rep2 = mjonMsgVO.getRep2List();
|
||||
String[] rep3 = mjonMsgVO.getRep3List();
|
||||
String[] rep4 = mjonMsgVO.getRep4List();
|
||||
String smsTxt = mjonMsgVO.getSmsTxt();
|
||||
int fileCount = Integer.parseInt(mjonMsgVO.getFileCnt());
|
||||
|
||||
// 이름 치환
|
||||
String[] nameList = mjonMsgVO.getNameList();
|
||||
String[] phone = mjonMsgVO.getCallToList();
|
||||
String[] rep1 = mjonMsgVO.getRep1List();
|
||||
String[] rep2 = mjonMsgVO.getRep2List();
|
||||
String[] rep3 = mjonMsgVO.getRep3List();
|
||||
String[] rep4 = mjonMsgVO.getRep4List();
|
||||
String smsTxt = mjonMsgVO.getSmsTxt();
|
||||
int fileCount = Integer.parseInt(mjonMsgVO.getFileCnt());
|
||||
|
||||
// 이름 치환
|
||||
int shortCnt = 0;
|
||||
int longCnt = 0;
|
||||
int imgCnt = 0;
|
||||
for (int i = 0; i < phone.length; i++) {
|
||||
|
||||
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("\\[\\*이름\\*\\]", "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < phone.length; i++) {
|
||||
|
||||
smsTxt = smsTxt.replaceAll(String.valueOf((char) 13), "");
|
||||
|
||||
|
||||
// 문자 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*]")) {
|
||||
if (rep2.length > i && StringUtil.isNotEmpty(rep2[i])) {
|
||||
smsTxt = smsTxt.replaceAll("\\[\\*2\\*\\]", StringUtil.getString(rep2[i].replaceAll("§", ",")));
|
||||
} else {
|
||||
smsTxt = smsTxt.replaceAll("\\[\\*2\\*\\]", "");
|
||||
}
|
||||
}
|
||||
|
||||
// 문자 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\\*\\]", "");
|
||||
}
|
||||
}
|
||||
// 이름 및 치환 문자 처리
|
||||
smsTxt = replacePlaceholder(smsTxt, "[*이름*]", nameList, i);
|
||||
smsTxt = replacePlaceholder(smsTxt, "[*1*]", rep1, i);
|
||||
smsTxt = replacePlaceholder(smsTxt, "[*2*]", rep2, i);
|
||||
smsTxt = replacePlaceholder(smsTxt, "[*3*]", rep3, i);
|
||||
smsTxt = replacePlaceholder(smsTxt, "[*4*]", rep4, i);
|
||||
|
||||
|
||||
try {
|
||||
int bytes = getSmsTxtBytes(smsTxt);
|
||||
|
||||
if(bytes < 2000) {
|
||||
if(fileCount > 0) {
|
||||
populateImgLists(lists, nameList, phone, rep1, rep2, rep3, rep4, smsTxt, i);
|
||||
imgCnt++;
|
||||
|
||||
populateImgLists(lists, nameList, phone, rep1, rep2, rep3, rep4, smsTxt, i);
|
||||
imgCnt++;
|
||||
|
||||
}else if(bytes > 90) {//장문문자 리스트 만들기
|
||||
populateLongLists(lists, nameList, phone, rep1, rep2, rep3, rep4, smsTxt, i);
|
||||
longCnt++;
|
||||
} else {//단문문자 리스트 만들기
|
||||
populateShortLists(lists, nameList, phone, rep1, rep2, rep3, rep4, smsTxt, i);
|
||||
shortCnt++;
|
||||
}
|
||||
populateLongLists(lists, nameList, phone, rep1, rep2, rep3, rep4, smsTxt, i);
|
||||
longCnt++;
|
||||
} else {//단문문자 리스트 만들기
|
||||
populateShortLists(lists, nameList, phone, rep1, rep2, rep3, rep4, smsTxt, i);
|
||||
shortCnt++;
|
||||
}
|
||||
}else {
|
||||
statusResponseSet(statusResponse, HttpStatus.BAD_REQUEST, "문자 치환 후 전송 문자 길이를 초과하였습니다.");
|
||||
return false;
|
||||
}
|
||||
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
statusResponseSet(statusResponse, HttpStatus.BAD_REQUEST, "전송 중 오류가 발생하였습니다.");
|
||||
statusResponseSet(statusResponse, HttpStatus.BAD_REQUEST, "문자 치환 중 오류가 발생하였습니다.");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lists.setShortCnt(shortCnt);
|
||||
lists.setLongCnt(longCnt);
|
||||
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,
|
||||
String[] rep2, String[] rep3, String[] rep4, String smsTxt, int i) {
|
||||
@ -410,17 +384,38 @@ 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 : 이호영
|
||||
* @date : 2024.09.25
|
||||
* @description : 치환문자가 사용될 때 데이터가 올바른지 확인하는 메서드
|
||||
* @param mjonMsgVO
|
||||
* @param modelAndView
|
||||
* @param statusResponse
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean checkReplacementDataValidity(MjonMsgVO mjonMsgVO, StatusResponse statusResponse) {
|
||||
public static boolean validateReplacementData(MjonMsgVO mjonMsgVO, StatusResponse statusResponse) {
|
||||
String[] nameList = mjonMsgVO.getNameList();
|
||||
String[] phone = mjonMsgVO.getCallToList();
|
||||
String[] rep1 = mjonMsgVO.getRep1List();
|
||||
@ -428,9 +423,19 @@ public final class MsgSendUtils {
|
||||
String[] rep3 = mjonMsgVO.getRep3List();
|
||||
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;
|
||||
|
||||
// 치환 문자 전체 필수 체크
|
||||
if (mjonMsgVO.getSmsTxt().contains("[*이름*]") && nameList.length != phone.length) {
|
||||
isRepCountOk = false;
|
||||
}
|
||||
@ -447,21 +452,18 @@ public final class MsgSendUtils {
|
||||
isRepCountOk = false;
|
||||
}
|
||||
|
||||
// 검증 결과가 false인 경우 에러 메시지 반환
|
||||
// 필드 개수가 일치하지 않는 경우 에러 메시지 반환
|
||||
if (!isRepCountOk) {
|
||||
|
||||
statusResponseSet(statusResponse, HttpStatus.BAD_REQUEST, "특정문구 일괄변환 치환문자 데이터가 없습니다.");
|
||||
statusResponseSet(statusResponse, HttpStatus.BAD_REQUEST, "특정문구 일괄변환 치환문자 데이터가 일치하지 않습니다.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true; // 모든 유효성 검사를 통과한 경우
|
||||
}
|
||||
|
||||
|
||||
private static void statusResponseSet (StatusResponse statusResponse, HttpStatus httpStatus, String msg ) {
|
||||
statusResponse.setStatus(httpStatus);
|
||||
statusResponse.setMessage(msg);
|
||||
|
||||
// 배열이 비어있는지 확인하는 메서드
|
||||
public static boolean isEmpty(String[] array) {
|
||||
return array == null || array.length == 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1057,7 +1057,7 @@ public class MjonMsgServiceImpl extends EgovAbstractServiceImpl implements MjonM
|
||||
public List<MjonMsgStatVO> selectAgentSmsCountStatList(MjonMsgStatVO mjonMsgStatVO) throws Exception {
|
||||
|
||||
List<MjonMsgStatVO> list = mjonMsgDAO.selectAgentSmsCountStatList(mjonMsgStatVO);
|
||||
|
||||
System.out.println("??????++++++++++++++++++++++++");
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@ -184,6 +184,7 @@ public interface MjonMsgDataService {
|
||||
public List<MjonMsgVO> selectPayUserSumFaxList(MjonMsgVO mjonMsgVO) 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"?>
|
||||
<!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" -->
|
||||
<!-- "http://www.ibatis.com/dtd/sql-map-config-2.dtd"> -->
|
||||
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
|
||||
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
|
||||
<sqlMapConfig>
|
||||
<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 -->
|
||||
|
||||
@ -3,7 +3,9 @@
|
||||
========= ======= =================================================
|
||||
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">
|
||||
<typeAlias alias="msgHolidayVO" type="itn.let.mjo.msgholiday.service.MsgHolidayVO"/>
|
||||
<typeAlias alias="msgAlarmSetVO" type="itn.let.mjo.msgholiday.service.MsgAlarmSetVO"/>
|
||||
|
||||
@ -2787,7 +2787,7 @@ function loadAddrList(){
|
||||
*/
|
||||
var data = $("#searchAddrGrpForm").serialize();
|
||||
|
||||
var url = "/web/mjon/msgdata/selectMsgAddrListAjax_advc.do";
|
||||
var url = "/web/mjon/msgdata/selectMsgAddrListAjax.do";
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
|
||||
@ -1133,7 +1133,7 @@ function fn_sendMsgData(){
|
||||
//수신번호 리스트 체크하기
|
||||
var numCnt = 0;
|
||||
var nameList = []; //치환문자 이름
|
||||
var phoneNum = []; //받는사람
|
||||
var phoneNum = []; //받는사람
|
||||
var rep1List = []; //치환문자1
|
||||
var rep2List = []; //치환문자2
|
||||
var rep3List = []; //치환문자3
|
||||
|
||||
Loading…
Reference in New Issue
Block a user