이호영 이호영 2024-12-02
문자발송 프록그래스바 적용 중
@9e50e999b24c8a5224b542c68db9831e75751cca
src/main/java/itn/let/mjo/msgdata/service/impl/MjonMsgDataServiceImpl.java
--- src/main/java/itn/let/mjo/msgdata/service/impl/MjonMsgDataServiceImpl.java
+++ src/main/java/itn/let/mjo/msgdata/service/impl/MjonMsgDataServiceImpl.java
@@ -4226,48 +4226,16 @@
 
 		
 		
-		/*
-		 * // 1건 이상 발송이 있는 경우만 캐쉬를 차감 시킨다.
-		if (resultCnt > 0) {
-
-			int totSendCnt = mjonMsgVO.getTotalCallCnt();
-			Float eachPrice = Float.parseFloat(mjonMsgVO.getEachPrice());
-			Float totPrice = eachPrice * resultCnt;
-			String strTotPrice = String.format("%.1f", totPrice);
-
-			mjonMsgVO.setTotPrice(strTotPrice);// 현재 합산 금액 셋팅
-			mjonPayVO.setCashId(idgenMjonCashId.getNextStringId());
-			mjonPayVO.setUserId(mjonMsgVO.getUserId());
-			mjonPayVO.setCash(-Float.parseFloat(strTotPrice));
-			mjonPayVO.setFrstRegisterId(mjonMsgVO.getUserId());
-			mjonPayVO.setMemo("SMS 문자 총 " + totSendCnt + "건 중 " + resultCnt + "건 발송");
-			mjonPayVO.setMsgGroupId(mjonMsgVO.getMsgGroupId());
-
-			mjonPayService.insertCash(mjonPayVO); // 캐시차감
-			mjonPayService.updateMemberCash(mjonPayVO); // 회원정보 업데이트
-		}
-		 	*/
-			
 
 		//////////////////////////////////
 		//////////////////////////////////
 		//////////////////////////////////
 
-		// 강제로 IllegalArgumentException 발생시키기
-//		if (true) {
-//		    throw new IllegalArgumentException("강제로 발생한 오류입니다.");
-//		}
 		//////////////////////////////////
 		//////////////////////////////////
 		//////////////////////////////////
 
 		
-			// 발송 처리
-//			statusResponse = processMessageSending(mjonMsgVO, intiLists, statusResponse);
-//		} else {
-//			// 일반 문자 발송
-//			statusResponse = fncSendMsg(mjonMsgVO);
-//		}
 		statusResponse.setStatus(HttpStatus.OK);
 		statusResponse.setObject(returnMap);
 		return statusResponse;
src/main/webapp/WEB-INF/jsp/web/msgdata/MsgDataView.jsp
--- src/main/webapp/WEB-INF/jsp/web/msgdata/MsgDataView.jsp
+++ src/main/webapp/WEB-INF/jsp/web/msgdata/MsgDataView.jsp
@@ -1724,6 +1724,22 @@
 //END
 </script>
 
+
+
+    <div class="progress_bar_wrap">
+        <div class="progress_box">
+            <p class="time_text">0%</p>
+            <div class="bar">
+                <span class="change_bar"></span>
+            </div>
+        </div>
+        <div class="btn_wrap">
+            <!-- <button type="button" class="btnType btnType2" style="margin:50px 0;" onclick="progressStart(10,'완료되었습니다.');">시작</button>
+            <button type="button" class="btnType btnType2" style="margin:50px 0;" onclick="progressComplete('완료되었습니다.');return false;">멈춤</button> -->
+        </div>
+
+    </div>
+
 	<div class="tooltip-wrap">
 		<!-- 문자발송 성공 레이어팝업 -->
 		<div class="popup-com pop_msg_success">
src/main/webapp/publish/js/content.js
--- src/main/webapp/publish/js/content.js
+++ src/main/webapp/publish/js/content.js
@@ -1581,10 +1581,78 @@
 }
 
 
+
+
+
+
 // 프로그레스바 
 var start, change;
+let progressInterval = null; // 전역 변수로 타이머 ID 관리
 
-function progressStart(time, msg) {
+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 resetProgressBar() {
+    $(".time_text").text("0%");
+    $(".change_bar").css("width", "0%");
+    $(".time_text").removeClass("animation");
+    $(".progress_bar_wrap").hide();
+}
+
+
+
+
+/*
+function progressStart(time) {
+
+	// 초기셋팅   
+	$(".time_text").text("0%");
+	$(".change_bar").css("width", "0");
+	$(".time_text").removeClass("animation");
+
     $(".progress_bar_wrap").css("display", "flex");
     
     var timeText = document.querySelector(".time_text");
@@ -1608,10 +1676,6 @@
                 $(".time_text").addClass("animation");
             }, 1000)
 
-            // 메시지 있을 때 alert 띄움
-            if (msg !== "" && msg !== undefined && msg !== null) {
-                alert(msg);
-            } else {}
 
         } else {
         	// width 증가 및 text 변경
@@ -1620,30 +1684,74 @@
             timeText.innerHTML = width + "%";
         }
     }
-}
+}*/
 
 // 프로그레스바 완료
-function progressComplete(msg,time,backtime) {
+function progressComplete() {
+    // var width = parseInt($(".time_text").text().replace('%', '')) || 0; // 현재 width 가져오기
+
+	var widthText = $(".change_bar").attr("style");
+	var width = widthText.replace(/[width:%;overfloen]/ig, ""); // width 값 퍼센트로 가져오기
+    var currentText = $(".time_text").text().trim(); // 현재 텍스트 가져오기
+    console.log('width : ', width, 'currentText : ', currentText);
+
+    // 이미 "100%" 상태이고 "잠시만 기다려주세요" 메시지가 표시된 경우 즉시 종료
+    if (width >= 100 && currentText === "잠시만 기다려주세요...") {
+        console.log("이미 완료 상태입니다. 즉시 종료합니다.");
+        $(".progress_bar_wrap").hide();
+        return;
+    }
+
+    // 진행 중인 경우
+    change = setInterval(() => {
+        if (width >= 100) {
+            console.log('width : ', width);
+            $(".time_text").text("100%");
+            $(".change_bar").css("width", "100%");
+
+            setTimeout(function () {
+                clearInterval(change); // 인터벌 종료
+                
+                setTimeout(() => {
+                	// $(".time_text").text("잠시만 기다려주세요...");
+               		// $(".time_text").addClass("animation");
+                    $(".progress_bar_wrap").hide();
+                }, 10); // "잠시만 기다려주세요..." 1초 후 숨기기
+            }, 1000); // "100%" 표시 후 1초 대기
+
+        } else {
+            // width 증가 및 text 변경
+            width++;
+            $(".time_text").text(width + "%");
+            $(".change_bar").css("width", width + "%");
+        }
+    }, 10); // DOM 업데이트 간격 (10ms)
+}
+
+/*// 프로그레스바 완료
+function progressComplete() {
 	
     change = setInterval(changeText);
     var width = 1;
 
     function changeText() {
     	
-        var widthText = $(".change_bar").attr("style");
-        widthText = widthText.replace(/[width:%;overfloen]/ig, ""); // width 값 퍼센트로 가져오기
+        // var widthText = $(".change_bar").attr("style");
+        // widthText = widthText.replace(/[width:%;overfloen]/ig, ""); // width 값 퍼센트로 가져오기
         
         if (width >= 100) {
+			console.log('width : ', width);
             $(".time_text").text("100%");
             
-            if(backtime>=time){
+            // if(backtime>=time){
             	// 예상시간보다 먼저 처리됐을 경우
             	setTimeout(function () {
                     $(".time_text").text("잠시만 기다려주세요...");
                     $(".time_text").addClass("animation");
-                }, 10)
-            }else{}
-            
+                }, 1000)
+            // }else{}
+
+			$(".progress_bar_wrap").hide();
 
             setTimeout(function () {
                 clearInterval(change);
@@ -1656,15 +1764,7 @@
             $(".change_bar").css("width", width + "%");
         }
     }
-    
     clearInterval(start); // 프로그레스바 시작 멈추기
-    
-    // 메시지 있을 때 alert 띄움    
-    if (msg !== "" && msg !== undefined && msg !== null) {
-        setTimeout(function () {
-            alert(msg);
-        }, 0)
-    } else {}
 
 
-}
+}*/
src/main/webapp/publish/security_login_ajax.html
--- src/main/webapp/publish/security_login_ajax.html
+++ src/main/webapp/publish/security_login_ajax.html
@@ -30,10 +30,6 @@
 
         function fn_test() {
 
-            // 초기셋팅   
-            $(".time_text").text("0%");
-            $(".change_bar").css("width", "0");
-            $(".time_text").removeClass("animation");
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
             var url = "/web/mjon/test/ajaxTest.do";
 
@@ -63,7 +59,7 @@
                     if (data.status == 'OK') {
                     	// 성공 시 프로그레스바 100% 로 변경
                     	// 예상 성공시간 = time, 백단 성공시간 == params.sleep
-                        progressComplete(data.message,time,params.sleep);
+                        progressComplete(time);
                     } else if (data.status == 'BAD_REQUEST') {
                     	// 실패시 alert 띄우고 닫기.
                         alert(params.f_msg);
@@ -143,11 +139,6 @@
                 <span class="change_bar"></span>
             </div>
         </div>
-        <div class="btn_wrap">
-            <!-- <button type="button" class="btnType btnType2" style="margin:50px 0;" onclick="progressStart(10,'완료되었습니다.');">시작</button>
-            <button type="button" class="btnType btnType2" style="margin:50px 0;" onclick="progressComplete('완료되었습니다.');return false;">멈춤</button> -->
-        </div>
-
     </div>
 
     <!-- skip 메뉴  -->
Add a comment
List