getSmsTxtBytes 모듈화

This commit is contained in:
hehihoho3@gmail.com 2025-03-12 11:56:17 +09:00
parent 01bc9c6a7d
commit e2a3d281a6
2 changed files with 23 additions and 22 deletions

View File

@ -23,6 +23,7 @@ import itn.com.cmm.MjonMsgSendVO;
import itn.com.cmm.OptimalMsgResultDTO;
import itn.let.mail.service.StatusResponse;
import itn.let.mjo.event.service.MjonEventVO;
import itn.let.mjo.mjocommon.MjonCommon;
import itn.let.mjo.msg.service.MjonMsgVO;
import itn.let.mjo.msgagent.service.MjonMsgAgentStsVO;
import itn.let.mjo.spammsg.web.ComGetSpamStringParser;
@ -55,26 +56,6 @@ public final class MsgSendUtils {
// 이벤트 최저 잔액
public static final double MIN_EVENT_REMAIN_CASH = 7.5; // 이벤트 최소 잔액
/**
* @methodName : getSmsTxtBytes
* @author : 이호영
* @date : 2024.09.23
* @description : sms 텍스트 바이트 계산 return;
* @param smsTxt
* @return
* @throws UnsupportedEncodingException
*/
public static int getSmsTxtBytes(String smsTxt) throws UnsupportedEncodingException { //문자열 길이 체크 해주기
int smsBytes = 0;
//문자 바이트 계산에 필요한 캐릭터 : 한글 2Byte로 계산
String charset = "euc-kr";
if(StringUtils.isNotEmpty(smsTxt)) {
String smsCont = smsTxt.replace("\r\n", "\n");
smsBytes = smsCont.getBytes(charset).length;
}
// log.info(" + smsBytes :: [{}]", smsBytes);
return smsBytes;
}
/**
* @methodName : getMsgType
@ -96,7 +77,7 @@ public final class MsgSendUtils {
// msgType = "4";
// }
int smsTxtByte = getSmsTxtBytes(p_smsTxt);
int smsTxtByte = MjonCommon.getSmsTxtBytes(p_smsTxt);
String msgType = SHORT_MSG_TYPE;
// 1. 2000 Byte 초과는 에러 처리

View File

@ -1,6 +1,7 @@
package itn.let.mjo.mjocommon;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
@ -712,7 +713,26 @@ private int parseIntOrDefault(String value, int defaultValue) {
}
/**
* @methodName : getSmsTxtBytes
* @author : 이호영
* @date : 2024.09.23
* @description : sms 텍스트 바이트 계산 return;
* @param smsTxt
* @return
* @throws UnsupportedEncodingException
*/
public static int getSmsTxtBytes(String smsTxt) throws UnsupportedEncodingException { //문자열 길이 체크 해주기
int smsBytes = 0;
//문자 바이트 계산에 필요한 캐릭터 : 한글 2Byte로 계산
String charset = "euc-kr";
if(org.apache.commons.lang3.StringUtils.isNotEmpty(smsTxt)) {
String smsCont = smsTxt.replace("\r\n", "\n");
smsBytes = smsCont.getBytes(charset).length;
}
// log.info(" + smsBytes :: [{}]", smsBytes);
return smsBytes;
}