문자 개별단가별 그룹화하여 분리 발송
This commit is contained in:
parent
113d2fc25a
commit
eecd562d5e
@ -109,6 +109,13 @@ public class MjonMsgSendVO{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : event 여부 / group tb에 넣는 용도
|
||||||
|
*/
|
||||||
|
private String eventYn;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description : 개별단가
|
* @description : 개별단가
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -203,7 +203,7 @@ public final class MsgSendUtils {
|
|||||||
*/
|
*/
|
||||||
public static Boolean populateSendLists(MjonMsgVO mjonMsgVO, List<MjonMsgSendVO> mjonMsgSendListVO
|
public static Boolean populateSendLists(MjonMsgVO mjonMsgVO, List<MjonMsgSendVO> mjonMsgSendListVO
|
||||||
, StatusResponse statusResponse, List<String> resultSpamTxt
|
, StatusResponse statusResponse, List<String> resultSpamTxt
|
||||||
, Map<String, Integer> agentSendCounts, List<MjonMsgVO> sendRateList, String nextMsgGroupId) throws Exception{
|
, Map<String, Integer> agentSendCounts, List<MjonMsgVO> sendRateList) throws Exception{
|
||||||
|
|
||||||
log.info(" :: populateSendLists :: ");
|
log.info(" :: populateSendLists :: ");
|
||||||
|
|
||||||
@ -381,8 +381,6 @@ public final class MsgSendUtils {
|
|||||||
: mjonMsgVO.getAgentCode();
|
: mjonMsgVO.getAgentCode();
|
||||||
sendVO.setAgentCode(agentCode);
|
sendVO.setAgentCode(agentCode);
|
||||||
|
|
||||||
sendVO.setMsgGroupId(nextMsgGroupId);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// Group TB에 넣어줄 제목
|
// Group TB에 넣어줄 제목
|
||||||
// 치환안된 sms 데이터로 넣어야함
|
// 치환안된 sms 데이터로 넣어야함
|
||||||
@ -612,7 +610,6 @@ public final class MsgSendUtils {
|
|||||||
// 각 가격을 합산
|
// 각 가격을 합산
|
||||||
totalPrice += Float.parseFloat(eachPrice);
|
totalPrice += Float.parseFloat(eachPrice);
|
||||||
}
|
}
|
||||||
mjonMsgVO.setTotPrice(String.valueOf(totalPrice));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -724,6 +721,7 @@ public final class MsgSendUtils {
|
|||||||
if (sum + floatEachPrice <= targetCash) {
|
if (sum + floatEachPrice <= targetCash) {
|
||||||
sum += floatEachPrice;
|
sum += floatEachPrice;
|
||||||
msg.setEachPrice(eachPrice);
|
msg.setEachPrice(eachPrice);
|
||||||
|
msg.setEventYn("Y");
|
||||||
optimalList.add(msg);
|
optimalList.add(msg);
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -588,6 +588,7 @@ private int parseIntOrDefault(String value, int defaultValue) {
|
|||||||
if (eventMberInfo == null || "E".equals(eventMberInfo.getEventStatus())) {
|
if (eventMberInfo == null || "E".equals(eventMberInfo.getEventStatus())) {
|
||||||
return statusResponse; // 이벤트 상태가 종료인 경우 처리하지 않음
|
return statusResponse; // 이벤트 상태가 종료인 경우 처리하지 않음
|
||||||
}
|
}
|
||||||
|
log.info(" + 이벤트 진행 대상자 :: [{}]", userId);
|
||||||
|
|
||||||
// 최적화된 메시지 리스트 및 이벤트 정보 가져오기
|
// 최적화된 메시지 리스트 및 이벤트 정보 가져오기
|
||||||
OptimalMsgResultDTO result = MsgSendUtils.getOptimalMsgList(eventMberInfo, mjonMsgSendVOList);
|
OptimalMsgResultDTO result = MsgSendUtils.getOptimalMsgList(eventMberInfo, mjonMsgSendVOList);
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -4107,9 +4108,6 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
|||||||
|
|
||||||
// 스팸관련 키워드 select
|
// 스팸관련 키워드 select
|
||||||
List<String> resultSpamTxt = mjonMsgDataService.selectSpamKeywordList();
|
List<String> resultSpamTxt = mjonMsgDataService.selectSpamKeywordList();
|
||||||
// msgGroupId 생성
|
|
||||||
String nextMsgGroupId = idgenMjonMsgGroupId.getNextStringId();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @methodName : populateReplacementLists
|
* @methodName : populateReplacementLists
|
||||||
@ -4125,7 +4123,7 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
|||||||
* 7. 전송사 코드 셋팅
|
* 7. 전송사 코드 셋팅
|
||||||
*/
|
*/
|
||||||
if(!MsgSendUtils.populateSendLists(mjonMsgVO, mjonMsgSendVOList, statusResponse, resultSpamTxt
|
if(!MsgSendUtils.populateSendLists(mjonMsgVO, mjonMsgSendVOList, statusResponse, resultSpamTxt
|
||||||
, agentSendCounts, sendRateList, nextMsgGroupId)) {;
|
, agentSendCounts, sendRateList)) {;
|
||||||
//문자 치환 후 전송 문자 길이를 초과하였습니다.
|
//문자 치환 후 전송 문자 길이를 초과하였습니다.
|
||||||
//문자 치환 중 오류가 발생하였습니다.
|
//문자 치환 중 오류가 발생하였습니다.
|
||||||
return statusResponse;
|
return statusResponse;
|
||||||
@ -4161,15 +4159,11 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
|||||||
*/
|
*/
|
||||||
// mjonCommon 호출
|
// mjonCommon 호출
|
||||||
statusResponse = mjonCommon.processEventMessages(userId, mjonMsgVO, mjonMsgSendVOList);
|
statusResponse = mjonCommon.processEventMessages(userId, mjonMsgVO, mjonMsgSendVOList);
|
||||||
|
|
||||||
if (statusResponse.getStatus() != null && !statusResponse.getStatus().equals(HttpStatus.OK)) {
|
if (statusResponse.getStatus() != null && !statusResponse.getStatus().equals(HttpStatus.OK)) {
|
||||||
log.error("이벤트 처리 중 오류 발생: {}", statusResponse.getMessage());
|
log.error("이벤트 처리 중 오류 발생: {}", statusResponse.getMessage());
|
||||||
return statusResponse;
|
return statusResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
float totalPrice = MsgSendUtils.setPriceforVO(mjonMsgSendVOList);
|
|
||||||
mjonMsgVO.setTotPrice(String.valueOf(totalPrice));
|
|
||||||
|
|
||||||
|
|
||||||
if (!isCashSufficient(mjonMsgVO)) {
|
if (!isCashSufficient(mjonMsgVO)) {
|
||||||
log.error("Insufficient balance for message sending.");
|
log.error("Insufficient balance for message sending.");
|
||||||
@ -4184,6 +4178,49 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
|||||||
// log.info("mj_msg_data insert start [{}]", mjonMsgSendVOList.size());
|
// log.info("mj_msg_data insert start [{}]", mjonMsgSendVOList.size());
|
||||||
// 합산 금액을 String으로 변환하여 설정
|
// 합산 금액을 String으로 변환하여 설정
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Step 1: 메시지를 가격별로 그룹화
|
||||||
|
Map<String, List<MjonMsgSendVO>> priceGroupedMessages = mjonMsgSendVOList.stream()
|
||||||
|
.collect(Collectors.groupingBy(MjonMsgSendVO::getEachPrice));
|
||||||
|
|
||||||
|
int instTotalCnt = 0;
|
||||||
|
// Step 2: 그룹화 된 데이터를 그룹별로 insert 처리
|
||||||
|
for (Map.Entry<String, List<MjonMsgSendVO>> entry : priceGroupedMessages.entrySet()) {
|
||||||
|
String price = entry.getKey(); // 가격 (String)
|
||||||
|
List<MjonMsgSendVO> groupedMsgList = entry.getValue(); // 해당 가격의 메시지 리스트
|
||||||
|
|
||||||
|
// msgGroupId 생성
|
||||||
|
String nextMsgGroupId = idgenMjonMsgGroupId.getNextStringId();
|
||||||
|
groupedMsgList.forEach(t -> t.setMsgGroupId(nextMsgGroupId));
|
||||||
|
|
||||||
|
// 발송 데이터 삽입
|
||||||
|
int instCnt = this.insertMsgData_advc(groupedMsgList);
|
||||||
|
|
||||||
|
if(instCnt > 0) {
|
||||||
|
instTotalCnt += instCnt;
|
||||||
|
this.insertMsgGroupDataTb_advc(instCnt, mjonMsgVO, groupedMsgList);
|
||||||
|
|
||||||
|
// 금액 및 포인트 insert
|
||||||
|
priceAndPoint.insertCashAndPoint(
|
||||||
|
userId
|
||||||
|
, -Float.parseFloat(mjonMsgVO.getTotPrice())
|
||||||
|
, "SMS 문자 총 " + groupedMsgList.size() + "건 중 " + instCnt + "건 발송"
|
||||||
|
, mjonMsgVO.getMsgGroupId()
|
||||||
|
);
|
||||||
|
// spam 문자 저장
|
||||||
|
handleSpamMsg_advc(mjonMsgVO, groupedMsgList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 수신거부 목록 업데이트
|
||||||
|
// returnMap.put("resultSts", instCnt);
|
||||||
|
|
||||||
|
log.debug("가격 [{}]의 총 갯수: [{}]", price, groupedMsgList.size());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 분할 최대건수가 되면 디비에 입력하기
|
// 분할 최대건수가 되면 디비에 입력하기
|
||||||
// int instCnt = mjonMsgDataDAO.insertMsgDataInfo_advc(mjonMsgSendVOList);
|
// int instCnt = mjonMsgDataDAO.insertMsgDataInfo_advc(mjonMsgSendVOList);
|
||||||
@ -4192,34 +4229,31 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
|||||||
// Batch 시작 시간 측정
|
// Batch 시작 시간 측정
|
||||||
// 총 발송 건수 = DB insert
|
// 총 발송 건수 = DB insert
|
||||||
// int instCnt = 0;
|
// int instCnt = 0;
|
||||||
int instCnt = this.insertMsgData_advc(mjonMsgSendVOList);
|
// int instCnt = this.insertMsgData_advc(mjonMsgSendVOList);
|
||||||
|
|
||||||
// Batch 종료 시간 측정 및 실행 시간 계산
|
|
||||||
|
|
||||||
// 수신거부 목록
|
// 수신거부 목록
|
||||||
returnMap.put("resultSts", instCnt);
|
returnMap.put("resultSts", instTotalCnt);
|
||||||
|
|
||||||
log.debug("총 단가 합계: [{}]", mjonMsgVO.getTotPrice());
|
log.debug("총 단가 합계: [{}]", mjonMsgVO.getTotPrice());
|
||||||
//TODO: group 테이블에 저장
|
//TODO: group 테이블에 저장
|
||||||
if(instCnt > 0) {
|
// if(instCnt > 0) {
|
||||||
|
//
|
||||||
// Group TB insert
|
// // Group TB insert
|
||||||
mjonMsgVO.setMsgGroupCnt(Integer.toString(instCnt));
|
// mjonMsgVO.setMsgGroupCnt(Integer.toString(instCnt));
|
||||||
this.insertMsgGroupDataTb_advc(mjonMsgVO, mjonMsgSendVOList.get(0));
|
// this.insertMsgGroupDataTb_advc(mjonMsgVO, mjonMsgSendVOList.get(0));
|
||||||
|
//
|
||||||
// 금액 및 포인트 insert
|
// // 금액 및 포인트 insert
|
||||||
priceAndPoint.insertCashAndPoint(
|
// priceAndPoint.insertCashAndPoint(
|
||||||
userId
|
// userId
|
||||||
, -Float.parseFloat(mjonMsgVO.getTotPrice())
|
// , -Float.parseFloat(mjonMsgVO.getTotPrice())
|
||||||
, "SMS 문자 총 " + mjonMsgVO.getMjonMsgSendVOList().size() + "건 중 " + instCnt + "건 발송"
|
// , "SMS 문자 총 " + mjonMsgVO.getMjonMsgSendVOList().size() + "건 중 " + instCnt + "건 발송"
|
||||||
, mjonMsgVO.getMsgGroupId()
|
// , mjonMsgVO.getMsgGroupId()
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
// 스팸 데이터가 있으면 MJ_SPAM_MSG_GROUP_DATA 테이블에 insert
|
// // 스팸 데이터가 있으면 MJ_SPAM_MSG_GROUP_DATA 테이블에 insert
|
||||||
handleSpamMsg_advc(mjonMsgVO, mjonMsgSendVOList.get(0));
|
// handleSpamMsg_advc(mjonMsgVO, mjonMsgSendVOList.get(0));
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
|
||||||
// 스팸 및 스미싱 의심이면 slack 알림
|
// 스팸 및 스미싱 의심이면 slack 알림
|
||||||
boolean isNotified = mjonCommon.processUserAndCheckSms(mjonMsgVO, userId);
|
boolean isNotified = mjonCommon.processUserAndCheckSms(mjonMsgVO, userId);
|
||||||
@ -4248,10 +4282,24 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertMsgGroupDataTb_advc(MjonMsgVO mjonMsgVO, MjonMsgSendVO mjonMsgSendVO) throws Exception {
|
private void insertMsgGroupDataTb_advc(int instCnt, MjonMsgVO mjonMsgVO, List<MjonMsgSendVO> mjonMsgSendVOList) throws Exception {
|
||||||
|
|
||||||
mjonMsgVO.setAgentCode(mjonMsgSendVO.getAgentCode());// 전송사 코드 번호를 셋팅해 준다.
|
|
||||||
// 지연 유무 코드가 Null 인경우 체크
|
// insert 총 데이터
|
||||||
|
mjonMsgVO.setMsgGroupCnt(Integer.toString(instCnt));
|
||||||
|
|
||||||
|
// insert 총 금액
|
||||||
|
float totalPrice = MsgSendUtils.setPriceforVO(mjonMsgSendVOList);
|
||||||
|
mjonMsgVO.setTotPrice(String.valueOf(totalPrice));
|
||||||
|
|
||||||
|
|
||||||
|
MjonMsgSendVO mjonMsgSendVO = mjonMsgSendVOList.get(0);
|
||||||
|
|
||||||
|
// 개별단가
|
||||||
|
mjonMsgVO.setEachPrice(mjonMsgSendVO.getEachPrice());
|
||||||
|
|
||||||
|
// 전송사 코드 번호를 셋팅해 준다.
|
||||||
|
mjonMsgVO.setAgentCode(mjonMsgSendVO.getAgentCode());
|
||||||
|
|
||||||
mjonMsgVO.setBefCash(priceAndPoint.getBefCash(mjonMsgVO.getUserId()));
|
mjonMsgVO.setBefCash(priceAndPoint.getBefCash(mjonMsgVO.getUserId()));
|
||||||
mjonMsgVO.setBefPoint(priceAndPoint.getBefPoint(mjonMsgVO.getUserId()));
|
mjonMsgVO.setBefPoint(priceAndPoint.getBefPoint(mjonMsgVO.getUserId()));
|
||||||
|
|||||||
@ -2182,16 +2182,12 @@ function fnByteString(contents){
|
|||||||
$('.realtime').text(contents);
|
$('.realtime').text(contents);
|
||||||
|
|
||||||
// 2000byte 초과시 메세지 알림
|
// 2000byte 초과시 메세지 알림
|
||||||
// console.log('conLeng : ', conLeng);
|
|
||||||
if(conLeng > 2000){
|
if(conLeng > 2000){
|
||||||
|
|
||||||
var fullContents = adverYn != "N" ? adverTxt + denyTxt + contents : contents;
|
var fullContents = adverYn != "N" ? adverTxt + denyTxt + contents : contents;
|
||||||
var subUnderStr = strUnderLineSubstring(fullContents, 2000).replace(adverTxt, "").replace(denyTxt, "");
|
var subUnderStr = strUnderLineSubstring(fullContents, 2000).replace(adverTxt, "").replace(denyTxt, "");
|
||||||
|
|
||||||
|
|
||||||
// var subUnderStr = strUnderLineSubstring(adverTxt+denyTxt+contents, 2000);
|
|
||||||
subUnderStr = subUnderStr.replace(adverTxt,"").replace(denyTxt, "");
|
subUnderStr = subUnderStr.replace(adverTxt,"").replace(denyTxt, "");
|
||||||
console.log('subUnderStr : ', subUnderStr)
|
// console.log('subUnderStr : ', subUnderStr)
|
||||||
|
|
||||||
|
|
||||||
$('#smsTxtArea').val(subUnderStr);
|
$('#smsTxtArea').val(subUnderStr);
|
||||||
@ -2199,7 +2195,7 @@ function fnByteString(contents){
|
|||||||
var contentLeng = conByteLeng(subUnderStr);
|
var contentLeng = conByteLeng(subUnderStr);
|
||||||
var totalLeng = adverYn != "N" ? contentLeng + adTxtLeng + denyTxtLeng : contentLeng;
|
var totalLeng = adverYn != "N" ? contentLeng + adTxtLeng + denyTxtLeng : contentLeng;
|
||||||
|
|
||||||
console.log('contentLeng : ', totalLeng);
|
// console.log('contentLeng : ', totalLeng);
|
||||||
$('#msgLeng').text(totalLeng + " / ");
|
$('#msgLeng').text(totalLeng + " / ");
|
||||||
$('#smsLen').val(contentLeng);
|
$('#smsLen').val(contentLeng);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user