diff --git a/src/main/webapp/WEB-INF/jsp/web/kakao/msgdata/at/KakaoAlimtalkMsgDataView.jsp b/src/main/webapp/WEB-INF/jsp/web/kakao/msgdata/at/KakaoAlimtalkMsgDataView.jsp index c21ea04b..754529ff 100644 --- a/src/main/webapp/WEB-INF/jsp/web/kakao/msgdata/at/KakaoAlimtalkMsgDataView.jsp +++ b/src/main/webapp/WEB-INF/jsp/web/kakao/msgdata/at/KakaoAlimtalkMsgDataView.jsp @@ -700,7 +700,7 @@ function sendTemplateInfo(){ success: function (data) { console.log('data : ', data); - /* var status = data.status; + var status = data.status; if("OK" == status){ var resultSts = data.object.resultSts; var reserYn = data.object.reserYn; @@ -715,7 +715,7 @@ function sendTemplateInfo(){ }else{ alert(data.message); return false; - } */ + } // if(data == 'success'){ @@ -762,7 +762,7 @@ function sendTemplateInfo(){ // $('.loading_layer').removeClass('active'); // 프로그래스 바 종료 - progressComplete();; + progressComplete(); } ,error: function (e) { console.log("ERROR : ", e); diff --git a/src/main/webapp/WEB-INF/jsp/web/kakao/msgdata/ft/KakaoFriendsTalkMsgDataView.jsp b/src/main/webapp/WEB-INF/jsp/web/kakao/msgdata/ft/KakaoFriendsTalkMsgDataView.jsp index 52ea868b..d6a9e43d 100644 --- a/src/main/webapp/WEB-INF/jsp/web/kakao/msgdata/ft/KakaoFriendsTalkMsgDataView.jsp +++ b/src/main/webapp/WEB-INF/jsp/web/kakao/msgdata/ft/KakaoFriendsTalkMsgDataView.jsp @@ -962,7 +962,9 @@ function fn_sendMsgData(){ // JSON 데이터 확인 console.log("최종 formData:", JSON.stringify(formData)); - + + // 프로그래스파 시간을 위한 계산 + var estimtedTime = calculateEstimatedTime(tableL.getRows().length); $.ajax({ @@ -971,10 +973,25 @@ function fn_sendMsgData(){ , data: JSON.stringify(formData) , contentType: 'application/json' , dataType: 'json' - , success: function (returnData) { - - console.log('returnData : ', returnData); - + , success: function (data) { + console.log('data : ', data); + + var status = data.status; + if("OK" == status){ + var resultSts = data.object.resultSts; + var reserYn = data.object.reserYn; + var resText = (reserYn === 'Y') ? '예약' : '발송'; + + $('.pop_msg_success').css({'display':'block','opacity':'1','left':'50%','top':'50%','transform':'translate(-50%,-50%)'}); + $('.pop_msg_success .msg_text').html(resText+" 성공 : "+ resultSts + "건의
친구톡이 " + resText + " 되었습니다."); + + }else if("UNAUTHORIZED" == status){ + alert(data.message); + location.reload(); + }else{ + alert(data.message); + return false; + } /* if(status == 'success'){ @@ -1012,11 +1029,13 @@ function fn_sendMsgData(){ } ,beforeSend : function(xmlHttpRequest) { //로딩창 show - $('.loading_layer').addClass('active'); +// $('.loading_layer').addClass('active'); + progressStart(estimtedTime); } ,complete : function(xhr, textStatus) { //로딩창 hide - $('.loading_layer').removeClass('active'); +// $('.loading_layer').removeClass('active'); + progressComplete(); } ,error: function (e) { console.log("ERROR : ", e); @@ -1026,6 +1045,74 @@ function fn_sendMsgData(){ } +//프로그레스바 +var start, change; +var progressInterval = null; // 전역 변수로 타이머 ID 관리 +function progressStart(time) { + // 기존 타이머 정지 및 초기화 + if (progressInterval !== null) { + clearInterval(progressInterval); // 이전 타이머 정지 + progressInterval = null; // 타이머 ID 초기화 + } + resetProgressBar(); // 프로그레스바 초기화 + + // 프로그레스바 보이기 + $(".progress_bar_wrap").css("display", "flex"); + + // 프로그레스바 요소 가져오기 + var timeText = document.querySelector(".time_text"); + var bar = document.querySelector(".change_bar"); + + // 초기 상태 설정 + var width = 1; + var totalTime = time * 1000; // 총 실행 시간 (밀리초) + var cmpWid = totalTime / 100; // width 증가 간격 (밀리초) + + // 새 타이머 시작 + progressInterval = setInterval(changeWidth, cmpWid); + + function changeWidth() { + if (width >= 100) { + // 프로그레스바 100% 도달 + clearInterval(progressInterval); // 타이머 종료 + progressInterval = null; // 타이머 ID 초기화 + + timeText.innerHTML = "100%"; + + setTimeout(function () { + // 100% 표시 후 "잠시만 기다려주세요" 변경 + timeText.innerHTML = "잠시만 기다려주세요..."; + $(".time_text").addClass("animation"); + }, 1000); + } else { + // 프로그레스바 진행 + width++; + bar.style.width = width + "%"; + timeText.innerHTML = width + "%"; + } + } +} + +//선택된 데이터의 길이에 따라 예상 시간 계산 함수 +function calculateEstimatedTime(selectedCount) { + //기준값 + // const processTimePerBatch = 130; // 130초 + + + // 30만건 기준 10분으로 기준을 잡아서 + // 시간계산함 + const processTimePerBatch = 600; + const batchSize = 300000; + + // 1건당 처리 시간 + const timePerRecord = processTimePerBatch / batchSize; + + // 예상 시간 계산 + const estimatedTimeInSeconds = selectedCount * timePerRecord; + + return estimatedTimeInSeconds.toFixed(2); +} + //빈 값이나 null 값을 제거하는 함수 function removeEmptyValues(obj) { Object.keys(obj).forEach(function(key) { @@ -1247,13 +1334,7 @@ function goToKakaoTestPopUp(){ function msgResultLink(){ var reserYn = $("input[name=reserYn]:checked").val(); // 예약 발송 여부 확인 - if(reserYn == 'Y'){ - - location.href="/web/mjon/reservmsg/selectReservKaKaoView.do"; - - }else{ - location.href="/web/kakao/sent/selectKakaoSentView.do"; - } + location.href="/web/kakao/sent/selectKakaoSentView.do"; } function updateButtons(){ @@ -1270,6 +1351,19 @@ function updateButtons(){ + +
+
+

0%

+
+ +
+
+
+
+ +
+