rosewiper 2023-12-08
선거문자 20건 기능 개선 2차 - 선거문자 발송 기능 추가 - 문자 발송 후 받는사람 리스트 상태값 변경 및 받는사람 목록 갱신 - 발송 결과 팝업 내용 수정 등
 - 선거문자 발송 기능 추가
 - 문자 발송 후 받는사람 리스트 상태값 변경 및 받는사람 목록 갱신
 - 발송 결과 팝업 내용 수정 등
@81fc60300186f8485c539c86805488ecf8adf686
src/main/java/itn/let/mjo/msgcampain/service/MjonCandidateService.java
--- src/main/java/itn/let/mjo/msgcampain/service/MjonCandidateService.java
+++ src/main/java/itn/let/mjo/msgcampain/service/MjonCandidateService.java
@@ -49,4 +49,7 @@
 		//선거문자 20건 마지막 번호 불러오기
 		public int selectMsgCallToSeqNum(String mberId) throws Exception;
 		
+		//선거문자 20건 전송 후 CallTo 상태값 전송 완료로 변경 처리
+		public int updateMsgTWCallToListSendFlag(MjonCandidateTWVO mjonCandidateTWVO) throws Exception;
+		
 }
src/main/java/itn/let/mjo/msgcampain/service/impl/MjonCandidateDAO.java
--- src/main/java/itn/let/mjo/msgcampain/service/impl/MjonCandidateDAO.java
+++ src/main/java/itn/let/mjo/msgcampain/service/impl/MjonCandidateDAO.java
@@ -173,4 +173,23 @@
 		return resultNum;
 		
 	}
+	
+	
+	//선거문자 20건 전송 후 CallTo 상태값 전송 완료로 변경 처리
+	public int updateMsgTWCallToListSendFlag(MjonCandidateTWVO mjonCandidateTWVO) throws Exception{
+		
+		int resultCnt = 0;
+		
+		try {
+			
+			resultCnt = update("mjonCandidateDAO.updateMsgTWCallToListSendFlag", mjonCandidateTWVO);
+			
+		} catch (Exception e) {
+			System.out.println("updateMsgTWCallToListSendFlag Service Imple Error!!! " + e);
+		}
+		
+		return resultCnt;
+		
+	}
+	
 }
src/main/java/itn/let/mjo/msgcampain/service/impl/MjonCandidateServiceImpl.java
--- src/main/java/itn/let/mjo/msgcampain/service/impl/MjonCandidateServiceImpl.java
+++ src/main/java/itn/let/mjo/msgcampain/service/impl/MjonCandidateServiceImpl.java
@@ -210,4 +210,23 @@
 		return resultNum;
 		
 	}
+	
+	
+	//선거문자 20건 전송 후 CallTo 상태값 전송 완료로 변경 처리
+	public int updateMsgTWCallToListSendFlag(MjonCandidateTWVO mjonCandidateTWVO) throws Exception{
+		
+		int resultCnt = 0;
+		
+		try {
+			
+			resultCnt = mjonCandidateDAO.updateMsgTWCallToListSendFlag(mjonCandidateTWVO);
+			
+		} catch (Exception e) {
+			System.out.println("updateMsgTWCallToListSendFlag Service Imple Error!!! " + e);
+		}
+		
+		return resultCnt;
+		
+	}
+	
 }
src/main/java/itn/let/mjo/msgcampain/web/MjonMsgCampainTWDataController.java
--- src/main/java/itn/let/mjo/msgcampain/web/MjonMsgCampainTWDataController.java
+++ src/main/java/itn/let/mjo/msgcampain/web/MjonMsgCampainTWDataController.java
@@ -6,6 +6,7 @@
 import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
@@ -25,6 +26,8 @@
 import org.apache.poi.xssf.usermodel.XSSFRow;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
@@ -59,12 +62,15 @@
 import itn.let.mjo.addr.service.AddrVO;
 import itn.let.mjo.event.service.MjonEventService;
 import itn.let.mjo.event.service.MjonEventVO;
+import itn.let.mjo.mjocommon.MjonCommon;
 import itn.let.mjo.msg.service.MjonMsgService;
+import itn.let.mjo.msg.service.MjonMsgVO;
 import itn.let.mjo.msgcampain.service.MjonCandidateService;
 import itn.let.mjo.msgcampain.service.MjonCandidateTWVO;
 import itn.let.mjo.msgcampain.service.MjonCandidateVO;
 import itn.let.mjo.msgdata.service.MjonMsgDataService;
 import itn.let.mjo.msgdata.service.MjonMsgDataVO;
+import itn.let.mjo.msgdata.service.MjonMsgReturnVO;
 import itn.let.mjo.msgdata.service.PhoneVO;
 import itn.let.mjo.pay.service.MjonPayService;
 import itn.let.mjo.spammsg.service.MjonSpamMsgService;
@@ -78,6 +84,7 @@
 import itn.let.uss.umt.service.EgovMberManageService;
 import itn.let.uss.umt.service.EgovUserManageService;
 import itn.let.uss.umt.service.MberManageVO;
+import itn.let.uss.umt.service.UserManageVO;
 import itn.let.utl.fcc.service.EgovCryptoUtil;
 
 @Controller
@@ -158,6 +165,8 @@
 	/** 등급제 관리 서비스 */
 	@Resource(name = "mberGrdService")
 	MberGrdService mberGrdService;
+	
+	 private static final Logger logger = LoggerFactory.getLogger(MjonMsgCampainTWDataController.class);
 	
     /**
      * 선거 문자 20건씩 발송 화면 
@@ -583,7 +592,7 @@
 		/** pageing */
 		PaginationInfo paginationInfo = new PaginationInfo();
 		paginationInfo.setCurrentPageNo(mjonCandidateTWVO.getPageIndex());
-		paginationInfo.setRecordCountPerPage(mjonCandidateTWVO.getPageUnit());
+		paginationInfo.setRecordCountPerPage(20);
 		paginationInfo.setPageSize(5);
 
 		mjonCandidateTWVO.setFirstIndex(paginationInfo.getFirstRecordIndex());
@@ -631,7 +640,6 @@
     		
     		for(String callTo : mjonCandidateTWVO.getCallToArr()) {
     			
-    			System.out.println("++++++++++++++ callTo ::: "+callTo);
     			callToList.add(callTo);
     			totRowDataCnt++;
     			
@@ -865,6 +873,1218 @@
     	return modelAndView;
 		
 	}
+	
+	
+	
+	/*
+	 * 선거문자 20건 발송 처리
+	 * 
+	 * */
+	
+	   /**
+     * 선거문자 20건 문자 발송 화면 
+     * @param searchVO
+     * @param model
+     * @return	"/web/mjon/msgcampain/sendMsgTWDataAjax.do"
+     * @throws Exception
+     */
+	@RequestMapping(value= {"/web/mjon/msgcampain/sendMsgTWDataAjax.do"})
+	public ModelAndView sendMsgTWData(@ModelAttribute("searchVO") MjonMsgVO mjonMsgVO, 
+			RedirectAttributes redirectAttributes, 
+			HttpServletRequest request,
+			ModelMap model) throws Exception{
+		
+		ModelAndView modelAndView = new ModelAndView();
+		modelAndView.setViewName("jsonView");
+		
+		//String resultSts = "0";
+		//String resultBlockSts = "0";
+		
+		int resultSts = 0;			//발송결과 건수
+		int resultBlockSts = 0;	//수신거부 등록번호로 발송을 안한 건수
+		String userId = "";
+		
+		try {
+			
+			LoginVO loginVO = EgovUserDetailsHelper.isAuthenticated()? (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser():null;
+	    	userId = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getId());
+	    	
+        	if(userId.equals("")) {
+        		
+        		modelAndView.addObject("message", "로그인 후 이용이 가능합니다.");
+    			modelAndView.addObject("result", "loginFail");
+    			modelAndView.addObject("resultSts", resultSts);
+    			return modelAndView;
+        		
+        	}else {
+        		
+        		mjonMsgVO.setUserId(userId);
+        		
+        		/**
+        		 * 회원 정지된 상태이면 문자 발송이 안되도록 처리함
+        		 * 현재 로그인 세션도 만료 처리함
+        		 * */
+        		boolean mberSttus = userManageService.selectUserStatusInfo(userId);
+        		
+        		if(!mberSttus) {
+        			
+        			modelAndView.addObject("message", "현재 고객님께서는 문자온 서비스 이용이 정지된 상태로 문자를 발송하실 수 없습니다. 이용정지 해제를 원하시면 고객센터로 연락주시기 바랍니다.");
+        			modelAndView.addObject("result", "statusFail");
+        			modelAndView.addObject("resultSts", resultSts);
+        			
+        			request.getSession().invalidate();
+        			
+        			return modelAndView;
+        			
+        		}
+        		
+        	}
+        	
+        	//회원정보에서 스미싱 회원 여부 정보 조회
+        	UserManageVO userManageVO = new UserManageVO();
+        	
+        	userManageVO.setMberId(userId);
+        	UserManageVO resultUserVO = userManageService.selectSmishingYnUserInfo(userManageVO);
+        	String smishingYn = resultUserVO.getSmishingYn();
+        	mjonMsgVO.setSmishingYn(smishingYn);
+        	
+        	String charset = "euc-kr"; 						//문자 바이트 계산에 필요한 캐릭터 셋 : 한글 2Byte로 계산
+        	String smsCont = mjonMsgVO.getSmsTxt().replace("\r\n", "\n");
+        	
+        	int FrBytes = smsCont.getBytes(charset).length;
+        	
+        	if(FrBytes > 2000) {
+        		
+        		modelAndView.addObject("message", "문자 내용은 2000Byte를 넘을 수 없습니다.");
+    			modelAndView.addObject("result", "smsLengFail");
+    			return modelAndView;
+        		
+        	}
+    		
+        	System.out.println("mjonMsgVO.getMsgType1() ::: "+mjonMsgVO.getMsgType());
+        	
+        	String msgType = mjonMsgVO.getMsgType();
+        	
+        	//내문자저장함에 저장후 문자를 발송하는경우 문자 타입이 숫자가 아닌 문자로 넘어와서 변경 처리함- 20220520 우영두
+        	if(msgType.equals("P") || msgType.equals("L")) {
+        		msgType = "6";
+        	}else if(msgType.equals("S")) {
+        		
+        		msgType = "4";
+        	}
+        	
+        	//메세지 타입이 단문이면 진짜 단문인지 한번더 확인해 준다.
+        	if(msgType.equals("4")) {
+        		
+        		//메세지 길이가 90Byte를초과 하거나, 그림 이미지가 있는경우 메세지 타입을 6으로 변경해준다.
+        		if(FrBytes > 90 || mjonMsgVO.getImgFilePath().length > 0) {
+        			
+        			msgType = "6";
+        			
+        		}
+        		
+        	}
+        	
+        	mjonMsgVO.setMsgType(msgType);
+        	
+        	//장문 메세지일 경우
+        	int fileCount = 0;
+        	if(msgType.equals("6")) {
+        		
+        		//그림 이미지가 첨부된 경우
+        		if(mjonMsgVO.getImgFilePath() != null || mjonMsgVO.getImgFilePath().length > 0) {
+        			
+        			String[] path = mjonMsgVO.getImgFilePath();
+        			String[] fileId = mjonMsgVO.getImgFileId();
+        			String[] templateYn = mjonMsgVO.getTemplateYn();
+        			
+            		for(int i=0; i<path.length; i++) {
+            			
+                		if("Y".equals(templateYn[i])) {
+            				//템플릿 사용누계 증가
+                			letterService.updateTemplateUseCount(fileId[i]);
+            			}
+                		
+                		String atchFileId = fileId[i];
+                		String imgFilePath = mjonMsgService.selectPhotoImgFileRealPath(atchFileId);
+                		
+                		// 아이하트, 현대퓨쳐넷 두 중계사는 이미지 경로는 풀패스 경로로 넘겨주면 됨
+                		if(i == 0) {
+                			
+                			mjonMsgVO.setFileName1(imgFilePath);
+                			
+                		}else if(i == 1) {
+                			
+                			mjonMsgVO.setFileName2(imgFilePath);
+                			
+                		}else {
+                			
+                			mjonMsgVO.setFileName3(imgFilePath);
+                			
+                		}
+                		fileCount ++;
+                	}
+                	
+                	//첨부파일 갯수 셋팅해주기
+                	mjonMsgVO.setFileCnt(Integer.toString(fileCount));
+        			
+        		}
+            	
+        	}
+        	
+        	//파일 갯수는 있는데 파일 경로가 없는 경우 문자발송이 안되도록 튕겨내도록 함 - 20220520 우영두
+        	if(fileCount > 0) {
+        		
+        		if(mjonMsgVO.getFileName1() == null && mjonMsgVO.getFileName2() == null && mjonMsgVO.getFileName3() == null) {
+        			
+        			modelAndView.addObject("message", "문자 메세지 이미지 추가에 오류가 발생하여 문자 발송이 취소 되었습니다.");
+    				modelAndView.addObject("result", "imgSourceFail");
+    				modelAndView.addObject("resultSts", "0");
+    				modelAndView.addObject("resultBlockSts", "0");
+    				
+    				return modelAndView; 
+        			
+        		}
+        		
+        	}
+        	
+        	/*
+        	 * 화면에서 넘어오는 단가 금액 및 총 결제 캐시 금액 체크 해주기
+        	 * 검증을 위해서 시스템 단가, 회원 협의 단가, 이벤트 단가 정보 조회
+        	 * 조회 단가를 이용하여 총 결제 캐시 금액 계산
+        	 * 파라미터로 넘어온 개별단가(eachPrice), 총 결제캐시(totPrice)를 비요하여 동일하지 않으면 컨트롤러에서 계산한 금액으로 입력해줌.
+        	 */
+        	MjonEventVO mjonEventVO = new MjonEventVO();
+    		mjonEventVO.setMberId(userId);
+    		MjonEventVO eventMberInfo = mjonEventService.selectEventMsgMberDefaultInfo(mjonEventVO);
+    		
+    		//1.시스템 기본 단가 정보 불러오기
+    		JoinSettingVO sysJoinSetVO = mjonMsgDataService.selectJoinSettingInfo();
+    		
+    		// 등급제 단가 추출 => 시스템 단가에 적용
+    		sysJoinSetVO = mberGrdService.selectMberGrdDefaultInfo(sysJoinSetVO, userId);
+    		
+    		//2.사용자 개인 단가 정보 불러오기
+    		MberManageVO mberManageVO = new MberManageVO(); 
+    		mberManageVO = mjonMsgDataService.selectMberManageInfo(userId);
+    			
+    		//3.사용자 개인단가 정보가 0이 아니면 개인단가 사용, 없으면 시스템 기본 단가 사용
+    		Float shortPrice = mberManageVO.getShortPrice();
+    		Float longPrice = mberManageVO.getLongPrice();
+    		Float picturePrice = mberManageVO.getPicturePrice();
+    		Float picture2Price = mberManageVO.getPicture2Price();
+    		Float picture3Price = mberManageVO.getPicture3Price();
+    		
+    		//기존 소수점 2째자리에서 반올림하였으나, 정책 변경으로 소수점 버림 처리함 20220623 
+    		boolean compareEndDate = false;
+    		float eventRemainCash = 0;
+    		float paramEachPrice = Float.parseFloat(mjonMsgVO.getEachPrice());
+    		
+    		if(eventMberInfo != null) {
+    			
+    			String eventEndDate = eventMberInfo.getEventEndDate();
+    			
+    			if(eventEndDate != null) {
+    				compareEndDate = MJUtil.getCompareDate(eventEndDate);
+    				eventRemainCash = (float) eventMberInfo.getEventRemainCash();
+    				
+    				//이벤트 금액 및 기간 체크
+    				if(!compareEndDate || eventRemainCash < paramEachPrice) {
+    					
+    					if(!eventMberInfo.getEventStatus().equals("E")) {
+    						
+    						//이벤트 상태값을 종료로 변경한다.
+    						mjonEventVO.setEventInfoId(eventMberInfo.getEventInfoId());
+    						mjonEventVO.setEventStatus("E");
+    						mjonEventVO.setEventMemo("발송 최소 금액("+ paramEachPrice +") 부족 혹은 이벤트 종료일 초과되어 이벤트 종료 시킴");
+    						mjonEventVO.setEventRemainCash(eventRemainCash);
+    						mjonEventService.updateEventEndStatus(mjonEventVO);
+    						eventMberInfo.setEventStatus("E");
+    						
+    					}
+    					
+    				}
+    			}
+    		}
+    		
+    		//이벤트 진행 회원의 발송 단가 처리해주기
+    		if(eventMberInfo != null && eventMberInfo.getEventStatus().equals("Y") && compareEndDate) {
+    			
+    			shortPrice = Float.parseFloat(eventMberInfo.getEventShortPrice());
+    			longPrice = Float.parseFloat(eventMberInfo.getEventLongPrice());
+    			picturePrice = Float.parseFloat(eventMberInfo.getEventPicturePrice());
+    			picture2Price = Float.parseFloat(eventMberInfo.getEventPicture2Price());
+    			picture3Price = Float.parseFloat(eventMberInfo.getEventPicture3Price());
+    			
+    		}else if(shortPrice < 1 || longPrice < 1 || picturePrice < 1) {//협의 단가가 없는 경우 시스템 단가 적용해 주기
+    			
+    			shortPrice = (float) sysJoinSetVO.getShortPrice();
+    			longPrice = (float) sysJoinSetVO.getLongPrice();
+    			picturePrice = (float) sysJoinSetVO.getPicturePrice();
+    			picture2Price = (float) sysJoinSetVO.getPicture2Price();
+    			picture3Price = (float) sysJoinSetVO.getPicture3Price();
+    			
+    		}
+    		
+    		// 토탈금액 "," 리플레이스 처리
+    		mjonMsgVO.setTotPrice(mjonMsgVO.getTotPrice().replaceAll(",", ""));
+
+        	float tmpOrgEachPrice = Float.parseFloat(mjonMsgVO.getEachPrice());
+        	float tmpOrgTotPrice = Float.parseFloat(mjonMsgVO.getTotPrice());
+        	
+        	System.out.println("mjonMsgVO.getMsgType2() ::: "+mjonMsgVO.getMsgType());
+        	
+        	// MSG_TYPE 다시계산 
+			if(mjonMsgVO.getFileName1() != null) {
+				mjonMsgVO.setMsgType("6");
+			}else {
+				if(FrBytes < 2000) {
+					if(FrBytes > 90) {// 90Byte 초과시 장문
+						mjonMsgVO.setMsgType("6");
+					}else {// 그외 단문
+						mjonMsgVO.setMsgType("4"); 
+					}
+				}
+			}
+			
+			System.out.println("mjonMsgVO.getMsgType3() ::: "+mjonMsgVO.getMsgType());
+			
+        	//각 문자 종류별 단가 셋팅해주기
+    		float tmpEachPrice = 0;
+    		if(mjonMsgVO.getMsgType().equals("4")) {
+    			mjonMsgVO.setEachPrice(shortPrice.toString());
+    			tmpEachPrice = shortPrice;
+    		}else if(mjonMsgVO.getMsgType().equals("6")) {
+    			
+    			if(mjonMsgVO.getFileName3() != null) {
+    				mjonMsgVO.setEachPrice(picture3Price.toString());
+    				tmpEachPrice = picture3Price;
+    			}else if(mjonMsgVO.getFileName2() != null) {
+    				mjonMsgVO.setEachPrice(picture2Price.toString());
+    				tmpEachPrice = picture2Price;
+    			}else if(mjonMsgVO.getFileName1() != null) {
+    				mjonMsgVO.setEachPrice(picturePrice.toString());
+    				tmpEachPrice = picturePrice;
+    			}else {
+    				mjonMsgVO.setEachPrice(longPrice.toString());
+    				tmpEachPrice = longPrice;
+    			}
+    			
+    		}
+    		
+    		//수신자 총 수 * 단가 를 통해 총 결제 금액 계산
+    		int tmpTotCallCnt = mjonMsgVO.getCallToList().length;
+    		float tmpTotPrice = tmpTotCallCnt * tmpEachPrice;
+    		
+    		
+    		//화면에서 넘어온 파라미터 개별 단가와 컨트롤러에서 계산한 단가를 비교하여 맞지 않으면 컨트롤러 계산 단가 입력
+    		if(tmpOrgEachPrice != tmpEachPrice) {
+    			mjonMsgVO.setEachPrice(Float.toString(tmpEachPrice));
+    			
+    			System.out.println("화면 : tmpOrgEachPrice ::: "+tmpOrgEachPrice);
+    			System.out.println("컨트롤러 : tmpEachPrice ::: "+tmpEachPrice);
+    		}else {
+    			System.out.println("tmpOrgEachPrice ::: "+tmpOrgEachPrice);
+    		}
+    		
+    		if(tmpOrgTotPrice != tmpTotPrice ) {
+    			mjonMsgVO.setTotPrice(Float.toString(tmpTotPrice));
+    			
+    			System.out.println("화면 : tmpOrgTotPrice ::: "+tmpOrgTotPrice);
+    			System.out.println("컨트롤러 : tmpTotPrice ::: "+tmpTotPrice);    			
+    		}else {
+    			System.out.println("tmpOrgTotPrice ::: "+tmpOrgTotPrice);
+    		}
+    		
+    		/*
+    		 * 개별단가 및  총결제 캐시 금액 체크 로직 종료
+    		 * 
+    		 * */
+        	
+        	//치환문자 체크 처리
+        	String txtReplYn = mjonMsgVO.getTxtReplYn();
+        	if(txtReplYn.equals("Y")) {
+        	
+        		int totListCnt = mjonMsgVO.getCallToList().length;
+        		String[] nameList = mjonMsgVO.getNameList();	//치환 이름 리스트
+        		String[] phone = mjonMsgVO.getCallToList();		//수신자 휴대폰 번호
+        		String[] rep1 = mjonMsgVO.getRep1List();		//치환 문자1 리스트
+        		String[] rep2 = mjonMsgVO.getRep2List();		//치환 문자2 리스트
+        		String[] rep3 = mjonMsgVO.getRep3List();		//치환 문자3 리스트
+        		String[] rep4 = mjonMsgVO.getRep4List();		//치환 문자4 리스트
+        		
+        		//이름, 휴대폰, 치환문자 데이터가 없으면 취소 처리
+        		if((nameList.length == 0 || nameList == null) 
+        				&& (rep1.length == 0 || rep1 == null)
+        				&& (rep2.length == 0 || rep2 == null)
+        				&& (rep3.length == 0 || rep3 == null)
+        				&& (rep4.length == 0 || rep4 == null)) {
+        			
+        			modelAndView.addObject("message", "특정문구 일괄변환 치환문자 데이터가 없습니다.");
+        			modelAndView.addObject("result", "fail");
+        			return modelAndView;
+        			
+        		}
+        		
+				// 치환문자 전체 필수체크 Start
+				boolean isRepCountOk = true;
+				if (mjonMsgVO.getSmsTxt().indexOf("[*이름*]") > -1) {
+					if(nameList.length != phone.length) {
+						isRepCountOk = false;
+					}
+    			}
+    			if (mjonMsgVO.getSmsTxt().indexOf("[*1*]") > -1) {
+					if(rep1.length != phone.length) {
+						isRepCountOk = false;
+					}
+    			}
+    			if (mjonMsgVO.getSmsTxt().indexOf("[*2*]") > -1) {
+					if(rep2.length != phone.length) {
+						isRepCountOk = false;
+					}
+    			}
+    			if (mjonMsgVO.getSmsTxt().indexOf("[*3*]") > -1) {
+					if(rep3.length != phone.length) {
+						isRepCountOk = false;
+					}
+    			}
+    			if (mjonMsgVO.getSmsTxt().indexOf("[*4*]") > -1) {
+					if(rep4.length != phone.length) {
+						isRepCountOk = false;
+					}
+    			}
+				
+				if (isRepCountOk == false) {
+					modelAndView.addObject("message", "특정문구 일괄변환 치환문자 데이터가 없습니다");
+					modelAndView.addObject("result", "fail");
+					return modelAndView;
+				}
+				// End
+				
+        		//---------------------------------------------------------------------------------------------------------------        		
+        		
+        		
+        		int msgLeng = 90;	//단문 문자열 길이
+        		
+        		if(msgType.equals("6")) {
+        			
+        			msgLeng = 2000;	//장문 문자열 길이
+        			
+        		}
+        		
+        		for(int i=0; i < totListCnt; i ++) {
+        			
+        			String smsTxt = mjonMsgVO.getSmsTxt();		//발송 문자 내용
+        			
+        			/**
+        			 * 본문 내용 - 치환 처리 후 문자 길이 초과 여부만 체크
+        			 * 치환 리스트 중 데이터가 없는 경우 데이터 밀림방지를 위하여 공백 하나를 추가해줌
+        			 * 공백처리를 안하는 경우 데이터가 밀려서 치환되는 오류가 있어서 처리해줌
+        			 * 
+        			 * */
+        			
+        			
+        			int repCnt = 0;
+        			smsTxt = smsTxt.replaceAll(String.valueOf((char)13), "");
+        			if (smsTxt.indexOf("[*이름*]") > -1) {
+        				if(nameList.length > i && StringUtil.isNotEmpty(nameList[i])) {
+        					smsTxt = smsTxt.replaceAll("\\[\\*이름\\*\\]", StringUtil.getString(nameList[i].replaceAll("§", ",")));
+        				}else {
+        					smsTxt = smsTxt.replaceAll("\\[\\*이름\\*\\]", "");
+        					nameList[i] = " ";
+        				}
+        				repCnt++;
+        			}
+        			if (smsTxt.indexOf("[*1*]") > -1) {
+        				if(rep1.length > i && StringUtil.isNotEmpty(rep1[i])) {
+        					smsTxt = smsTxt.replaceAll("\\[\\*1\\*\\]", StringUtil.getString(rep1[i].replaceAll("§", ",")));
+        				}else {
+        					smsTxt = smsTxt.replaceAll("\\[\\*1\\*\\]", "");
+        					rep1[i] = " ";
+        				}
+        				repCnt++;
+        			}
+        			if (smsTxt.indexOf("[*2*]") > -1) {
+        				if(rep2.length > i && StringUtil.isNotEmpty(rep2[i])) {
+        					smsTxt = smsTxt.replaceAll("\\[\\*2\\*\\]", StringUtil.getString(rep2[i].replaceAll("§", ",")));
+        				}else {
+        					smsTxt = smsTxt.replaceAll("\\[\\*2\\*\\]", "");
+        					rep2[i] = " ";
+        				}
+        				repCnt++;
+        			}
+        			if (smsTxt.indexOf("[*3*]") > -1) {
+        				if(rep3.length > i && StringUtil.isNotEmpty(rep3[i])) {
+        					smsTxt = smsTxt.replaceAll("\\[\\*3\\*\\]", StringUtil.getString(rep3[i].replaceAll("§", ",")));
+        				}else {
+        					smsTxt = smsTxt.replaceAll("\\[\\*3\\*\\]", "");
+        					rep3[i] = " ";
+        				}
+        				repCnt++;
+        			}
+        			if (smsTxt.indexOf("[*4*]") > -1) {
+        				if(rep4.length > i && StringUtil.isNotEmpty(rep4[i])) {
+        					smsTxt = smsTxt.replaceAll("\\[\\*4\\*\\]", StringUtil.getString(rep4[i].replaceAll("§", ",")));
+        				}else {
+        					smsTxt = smsTxt.replaceAll("\\[\\*4\\*\\]", "");
+        					rep4[i] = " ";
+        				}
+        				repCnt++;
+        			}
+        			
+        			//문자열 바이트 수 구하기(한글 2Byte로 계산)
+        			// 한글 3Byte로 하기 위해서는 StandardCharsets.UTF_8 로 변경하면 된다. 
+        			int bytes = smsTxt.getBytes(charset).length;
+        			if(repCnt > 0) {
+        				if(bytes > msgLeng) {	//전송 문자 길이를 초과한 경우 전송 취소 - 단문 작성 후 치환했을 때 장문으로 길이가 초과되는 경우 체크
+        					modelAndView.addObject("message", "문자 치환 후 전송 문자 길이를 초과하였습니다.");
+        					modelAndView.addObject("result", "fail");
+        					modelAndView.addObject("resultSts", "0");
+        					modelAndView.addObject("resultBlockSts", "0");
+        					return modelAndView; 
+        				}
+        			}
+        		}
+        		
+        		mjonMsgVO.setNameList(nameList);
+        		mjonMsgVO.setRep1List(rep1);
+        		mjonMsgVO.setRep2List(rep2);
+        		mjonMsgVO.setRep3List(rep3);
+        		mjonMsgVO.setRep4List(rep4);
+        		
+        	}
+        	
+        	//현재 고객의 보유 캐시가 문자 발송이 가능한 금액인지 체크
+        	String userMoney = mjonMsgDataService.selectBeforeCashData(mjonMsgVO);
+        	String userPoint = mjonMsgDataService.selectBeforePointData(mjonMsgVO);
+        	mjonMsgVO.setBefPoint(userPoint); //현재 보유 포인트 정보 저장
+        	String totPrice = mjonMsgVO.getTotPrice();
+        	String eachPrice = mjonMsgVO.getEachPrice();
+        	
+        	if(msgType.equals("6")) {//문자 mms, lms 단가 설정하기
+        		
+        		if(fileCount > 2) {//그림 이미지가 3개
+        			
+        			eachPrice = mjonMsgVO.getP3Price();
+        			
+        		}else if(fileCount > 1) {//그림 이미지가 2개
+        			
+        			eachPrice = mjonMsgVO.getP2Price();
+        			
+        		}else if(fileCount == 1) {//그림 이미지가 1개
+        			eachPrice = mjonMsgVO.getpPrice();
+        			
+        		}else {//장문 문자인 경우
+        			
+        			eachPrice = mjonMsgVO.getmPrice();
+        		}
+        		
+        	}
+        	
+        	BigDecimal befCash = new BigDecimal(userMoney).setScale(2, RoundingMode.HALF_EVEN);
+        	BigDecimal totMsgPrice = new BigDecimal(totPrice).setScale(2, RoundingMode.HALF_EVEN);
+        	
+        	
+        	//현재 보유 금액이 발송 문자 총 금액보다 클 경우만 문자 발송
+        	//BigDecimal 비교 연산
+        	// befCash(현재 보유금액) 값이 totMsgPrice(문자전송 금액) 보다 많으면 문자 전송	
+        	if(befCash.compareTo(totMsgPrice) != -1) { // -1 : befCash < totMsgPrice, 0 : befCash = totMsgPrice, 1 : befCash > totMsgPrice,
+        		
+        		mjonMsgVO.setBefCash(befCash.toString());
+        		
+        		//문자 전송 그룹아이디 생성
+	        	mjonMsgVO.setMsgGroupId(idgenMjonMsgGroupId.getNextStringId());
+	        	
+	        	String[] tempPhoneList = new String[200];				//임시 수신번호 리스트 저장용 배열
+	        	String[] tempNameList = new String[200];				//임시 이름 리스트 저장용 배열
+	    		String[] tempRep1List = new String[200];				//임시 치환문자1 리스트 저장용 배열
+	    		String[] tempRep2List = new String[200];				//임시 치환문자1 리스트 저장용 배열
+	    		String[] tempRep3List = new String[200];				//임시 치환문자1 리스트 저장용 배열
+	    		String[] tempRep4List = new String[200];				//임시 치환문자1 리스트 저장용 배열
+	    		
+	    		String[] phoneList = mjonMsgVO.getCallToList();
+	    		String[] nameList = mjonMsgVO.getNameList();
+	    		String[] rep1List = mjonMsgVO.getRep1List();
+	    		String[] rep2List = mjonMsgVO.getRep2List();
+	    		String[] rep3List = mjonMsgVO.getRep3List();
+	    		String[] rep4List = mjonMsgVO.getRep4List();
+	    		
+	    		int callToListCnt = mjonMsgVO.getCallToList().length;
+	    		mjonMsgVO.setTotalCallCnt(callToListCnt);
+	    		
+	    		/**
+	    		 * 예약 문자인 경우 시간 및 분할 시간 셋팅 해주기
+	    		 * 
+	    		 * 
+	    		 * */
+	
+	    		//분할문자 시간에 간격시간 더해주기
+	        	String dividDay = null;
+	        	Calendar cal = Calendar.getInstance();
+	        	
+	        	//예약시간 변환
+	        	SimpleDateFormat transFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+	        	
+	    		int turmMin = 0;
+	    		int totalCallCnt = 0;
+	    		int divideCnt = 0;
+	    		int count = 1;		//분할 카운트
+	    		
+	    		
+	    		if(!mjonMsgVO.getReserveYn().equals("N")) {//예약문자인 경우 시간 셋팅
+	    			
+	    	    	Date toDate = transFormat.parse(mjonMsgVO.getReqDate());
+	    	    	cal.setTime(toDate); 										//예약 시간 캘린터 변수에 입력
+	    	    	
+	    	    	//String 타입 시간 Int로 변환
+	    	    	turmMin = Integer.parseInt(mjonMsgVO.getDivideTime()); //분할발송 시간 간격
+	    	    	dividDay = transFormat.format(cal.getTime());
+	    	    	
+	    	    	totalCallCnt = mjonMsgVO.getCallToList().length; // 수신자 전체 갯수
+	    	    	divideCnt = Integer.parseInt(mjonMsgVO.getDivideCnt()); //분할 발송 갯수
+	    			
+	    		}
+	    		
+	    		//분할 예약 시간 저장 리스트 생성
+	    		List<String> dividDayList = new ArrayList<String>();
+	    		
+	    		//서비스 단으로 특정 문자 건수 이상으로 한번에 보내지 않기 위해서 처리함
+	    		//200건이 넘으면 200개씩 서비스로 넘기고
+	    		if(callToListCnt > 200) {
+	    			
+	    			int sendCnt = 0;
+	    			for(int i=0; i< callToListCnt; i++) {
+	    				
+	    				//분할 발송을 체크 한 경우
+						if(mjonMsgVO.getDivideChk() != null) {
+							
+							if(count > divideCnt) {
+		            			
+		            			count = 1;
+		            			
+		            			//분할 시간 간격을 증가시켜 준다.
+		            			cal.add(Calendar.MINUTE, turmMin);
+		            			dividDay = transFormat.format(cal.getTime());
+		                    	
+		            			dividDayList.add(dividDay);
+		            			//tempVO.setReqDate(dividDay); //분할 문자 예약 시간 입력해주기
+		                		count++;
+		                		
+		            		}else {
+		            			
+		            			dividDayList.add(dividDay);
+		            			//tempVO.setReqDate(dividDay); //분할 문자 예약 시간 입력해주기
+		            			count++;
+		            			
+		            		}
+							
+						}
+	    				
+	    				if((i < callToListCnt -1) && sendCnt == 199) {
+	    					
+	    					//sendCnt 200번째 값을 추가해준다.
+	    					tempPhoneList[sendCnt] = phoneList[i];
+	    					
+	    					if(nameList.length > 0) {
+	    						tempNameList[sendCnt] = nameList[i];
+	    					}
+	    					
+	    					if(rep1List.length > 0) {
+	    						tempRep1List[sendCnt] = rep1List[i];
+	    					}
+	    					
+	    					if(rep2List.length > 0) {
+	    						tempRep2List[sendCnt] = rep2List[i];
+	    					}
+	    					
+	    					if(rep3List.length > 0) {
+	    						tempRep3List[sendCnt] = rep3List[i];
+	    					}
+	    					
+	    					if(rep4List.length > 0) {
+	    						tempRep4List[sendCnt] = rep4List[i];
+	    					}
+	    					
+	    					List<String> arrPhoneList = new ArrayList<String>();
+	    					List<String> arrNameList = new ArrayList<String>();
+	    					List<String> arrRep1List = new ArrayList<String>();
+	    					List<String> arrRep2List = new ArrayList<String>();
+	    					List<String> arrRep3List = new ArrayList<String>();
+	    					List<String> arrRep4List = new ArrayList<String>();
+	    					
+	    					for(String temp : tempPhoneList) {
+	    						
+	    						if(temp != null) {
+	    							
+	    							arrPhoneList.add(temp);
+	    							
+	    						}
+	    						
+	    					}
+	    					
+	    					if(tempNameList.length > 0) {
+	    						for(String tmpName : tempNameList) {
+		    						
+		    						if(tmpName != null) {
+		    							
+		    							arrNameList.add(tmpName);
+		    							
+		    						}
+		    						
+		    					}
+	    						
+	    					}
+	    					
+	    					if(tempRep1List.length > 0) {
+	    						for(String tmpRep1 : tempRep1List) {
+	    							
+	    							if(tmpRep1 != null) {
+	    								
+	    								arrRep1List.add(tmpRep1);
+	    								
+	    							}
+	    							
+	    						}
+	    						
+	    					}
+	    					
+	    					if(tempRep2List.length > 0) {
+	    						for(String tmpRep2 : tempRep2List) {
+	    							
+	    							if(tmpRep2 != null) {
+	    								
+	    								arrRep2List.add(tmpRep2);
+	    								
+	    							}
+	    							
+	    						}
+	    						
+	    					}
+	    					
+	    					if(tempRep3List.length > 0) {
+	    						for(String tmpRep3 : tempRep3List) {
+	    							
+	    							if(tmpRep3 != null) {
+	    								
+	    								arrRep3List.add(tmpRep3);
+	    								
+	    							}
+	    							
+	    						}
+	    						
+	    					}
+	    					
+	    					if(tempRep4List.length > 0) {
+	    						for(String tmpRep4 : tempRep4List) {
+	    							
+	    							if(tmpRep4 != null) {
+	    								
+	    								arrRep4List.add(tmpRep4);
+	    								
+	    							}
+	    							
+	    						}
+	    						
+	    					}
+	    					
+	    					//리스트에 추가된 내용 만큼 임시 수신목록 배열에 넣어준다.
+	    					String[] sendPhoneList = new String[arrPhoneList.size()];
+	    					String[] sendNameList = new String[arrNameList.size()];
+	    					String[] sendRep1List = new String[arrRep1List.size()];
+	    					String[] sendRep2List = new String[arrRep2List.size()];
+	    					String[] sendRep3List = new String[arrRep3List.size()];
+	    					String[] sendRep4List = new String[arrRep4List.size()];
+	    					
+	    					for(int j=0; j< arrPhoneList.size(); j++) {
+	    						
+	    						sendPhoneList[j] = arrPhoneList.get(j);
+	    						
+	    					}
+	    					
+	    					for(int k=0; k< arrNameList.size(); k++) {
+	    						
+	    						sendNameList[k] = arrNameList.get(k);
+	    						
+	    					}
+	    					
+	    					for(int k=0; k< arrRep1List.size(); k++) {
+	    						
+	    						sendRep1List[k] = arrRep1List.get(k);
+	    						
+	    					}
+	    					
+	    					for(int k=0; k< arrRep2List.size(); k++) {
+	    						
+	    						sendRep2List[k] = arrRep2List.get(k);
+	    						
+	    					}
+	    					
+	    					for(int k=0; k< arrRep3List.size(); k++) {
+	    						
+	    						sendRep3List[k] = arrRep3List.get(k);
+	    						
+	    					}
+	    					
+	    					for(int k=0; k< arrRep4List.size(); k++) {
+	    						
+	    						sendRep4List[k] = arrRep4List.get(k);
+	    						
+	    					}
+	    					
+	    					mjonMsgVO.setCallToList(sendPhoneList);
+	    					
+	    					if(sendNameList.length > 0) {
+	    						mjonMsgVO.setNameList(sendNameList);
+	    					}
+	    					
+	    					if(sendRep1List.length > 0) {
+	    						mjonMsgVO.setRep1List(sendRep1List);
+	    					}
+
+	    					if(sendRep2List.length > 0) {
+	    						mjonMsgVO.setRep2List(sendRep2List);
+	    					}
+	    					
+	    					if(sendRep3List.length > 0) {
+	    						mjonMsgVO.setRep3List(sendRep3List);
+	    					}
+	    					
+	    					if(sendRep4List.length > 0) {
+	    						mjonMsgVO.setRep4List(sendRep4List);
+	    					}
+	    					sendCnt = 0;
+	    					
+	    					mjonMsgVO.setDividDay(dividDayList);
+	    					MjonMsgReturnVO returnVO = mjonMsgDataService.insertMsgDataInfo(mjonMsgVO);
+	    					mjonMsgVO.setAgentCode(returnVO.getAgentCode());
+	    					resultSts = resultSts + Integer.parseInt(returnVO.getSendMsgCnt());
+	    		    		resultBlockSts = resultBlockSts + Integer.parseInt(returnVO.getSendMsgBlockCnt());
+	    		    		
+	    		    		//발송 처리후 배열 초기화
+	    		    		Arrays.fill(tempPhoneList, null);
+	    		    		dividDayList.clear();
+	    					
+	    		    		
+	    		    		System.out.println("=========================================================================");
+	    		    		System.out.println("+++++++++++++++++++++++++++++++++++++++++++선거문자 ==> 199 resultSts ::: " + resultSts);
+	    		    		System.out.println("+++++++++++++++++++++++++++++++++++++++++++선거문자 ==> 199 resultBlockSts ::: " + resultBlockSts);
+	    		    		System.out.println("=========================================================================");
+	    		    		
+	    				}else if((i == callToListCnt -1) && sendCnt < 200){//수신목록 마지막이면서 200개 미만으로 남은 경우 발송 처리해준다.
+	    					
+	    					//마지막 리스트의 수신번호를 추가해 준다.
+	    					tempPhoneList[sendCnt] = phoneList[i];
+	    					if(nameList.length > 0) {
+	    						tempNameList[sendCnt] = nameList[i];
+	    					}
+
+	    					if(rep1List.length > 0) {
+	    						tempRep1List[sendCnt] = rep1List[i];
+	    					}
+	    					
+	    					if(rep2List.length > 0) {
+	    						tempRep2List[sendCnt] = rep2List[i];
+	    					}
+	    					
+	    					if(rep3List.length > 0) {
+	    						tempRep3List[sendCnt] = rep3List[i];
+	    					}
+	    					
+	    					if(rep4List.length > 0) {
+	    						tempRep4List[sendCnt] = rep4List[i];
+	    					}
+	    					
+	    					List<String> arrPhoneList2 = new ArrayList<String>();
+	    					List<String> arrNameList2 = new ArrayList<String>();
+	    					List<String> arrRep1List2 = new ArrayList<String>();
+	    					List<String> arrRep2List2 = new ArrayList<String>();
+	    					List<String> arrRep3List2 = new ArrayList<String>();
+	    					List<String> arrRep4List2 = new ArrayList<String>();
+	    					
+	    					for(String temp : tempPhoneList) {
+	    						
+	    						if(temp != null) {
+	    							
+	    							arrPhoneList2.add(temp);
+	    							
+	    						}
+	    						
+	    					}
+	    					
+	    					if(tempNameList.length > 0) {
+	    						for(String tmpName : tempNameList) {
+	    							
+	    							if(tmpName != null) {
+	    								
+	    								arrNameList2.add(tmpName);
+	    								
+	    							}
+	    							
+	    						}
+	    						
+	    					}
+	    					
+	    					if(tempRep1List.length > 0) {
+	    						for(String tmpRep1 : tempRep1List) {
+	    							
+	    							if(tmpRep1 != null) {
+	    								
+	    								arrRep1List2.add(tmpRep1);
+	    								
+	    							}
+	    							
+	    						}
+	    						
+	    					}
+	    					
+	    					
+	    					if(tempRep2List.length > 0) {
+	    						for(String tmpRep2 : tempRep2List) {
+	    							
+	    							if(tmpRep2 != null) {
+	    								
+	    								arrRep2List2.add(tmpRep2);
+	    								
+	    							}
+	    							
+	    						}
+	    						
+	    					}
+	    					
+	    					if(tempRep3List.length > 0) {
+	    						for(String tmpRep3 : tempRep3List) {
+	    							
+	    							if(tmpRep3 != null) {
+	    								
+	    								arrRep3List2.add(tmpRep3);
+	    								
+	    							}
+	    							
+	    						}
+	    						
+	    					}
+	    					
+	    					if(tempRep4List.length > 0) {
+	    						for(String tmpRep4 : tempRep4List) {
+	    							
+	    							if(tmpRep4 != null) {
+	    								
+	    								arrRep4List2.add(tmpRep4);
+	    								
+	    							}
+	    							
+	    						}
+	    						
+	    					}
+	    					
+	    					String[] sendPhoneList2 = new String[arrPhoneList2.size()];
+	    					String[] sendNameList2 = new String[arrNameList2.size()];
+	    					String[] sendRep1List2 = new String[arrRep1List2.size()];
+	    					String[] sendRep2List2 = new String[arrRep2List2.size()];
+	    					String[] sendRep3List2 = new String[arrRep3List2.size()];
+	    					String[] sendRep4List2 = new String[arrRep4List2.size()];
+	    					
+	    					for(int j=0; j< arrPhoneList2.size(); j++) {
+	    						
+	    						sendPhoneList2[j] = arrPhoneList2.get(j);
+	    						
+	    					}
+	    					
+	    					for(int j=0; j< arrNameList2.size(); j++) {
+	    						
+	    						sendNameList2[j] = arrNameList2.get(j);
+	    						
+	    					}
+	    					
+	    					for(int k=0; k< arrRep1List2.size(); k++) {
+	    						
+	    						sendRep1List2[k] = arrRep1List2.get(k);
+	    						
+	    					}
+	    					
+	    					for(int k=0; k< arrRep2List2.size(); k++) {
+	    						
+	    						sendRep2List2[k] = arrRep2List2.get(k);
+	    						
+	    					}
+	    					
+	    					for(int k=0; k< arrRep3List2.size(); k++) {
+	    						
+	    						sendRep3List2[k] = arrRep3List2.get(k);
+	    						
+	    					}
+	    					
+	    					for(int k=0; k< arrRep4List2.size(); k++) {
+	    						
+	    						sendRep4List2[k] = arrRep4List2.get(k);
+	    						
+	    					}
+	    					
+	    					mjonMsgVO.setCallToList(sendPhoneList2);
+	    					
+	    					if(sendNameList2.length > 0) {
+	    						mjonMsgVO.setNameList(sendNameList2);
+	    					}
+
+	    					if(sendRep1List2.length > 0) {
+	    						mjonMsgVO.setRep1List(sendRep1List2);
+	    					}
+	    					
+	    					if(sendRep2List2.length > 0) {
+	    						mjonMsgVO.setRep2List(sendRep2List2);
+	    					}
+	    					
+	    					if(sendRep3List2.length > 0) {
+	    						mjonMsgVO.setRep3List(sendRep3List2);
+	    					}
+	    					
+	    					if(sendRep4List2.length > 0) {
+	    						mjonMsgVO.setRep4List(sendRep4List2);
+	    					}
+	    					sendCnt = 0;
+	    					
+	    					mjonMsgVO.setDividDay(dividDayList);
+	    					MjonMsgReturnVO returnVO = mjonMsgDataService.insertMsgDataInfo(mjonMsgVO);
+	    					mjonMsgVO.setAgentCode(returnVO.getAgentCode());
+	    					resultSts = resultSts + Integer.parseInt(returnVO.getSendMsgCnt());
+	    		    		resultBlockSts = resultBlockSts + Integer.parseInt(returnVO.getSendMsgBlockCnt());
+	    		    		
+	    		    		System.out.println("=========================================================================");
+	    		    		System.out.println("+++++++++++++++++++++++++++++++++++++++++++선거문자 ==> 200 resultSts ::: " + resultSts);
+	    		    		System.out.println("+++++++++++++++++++++++++++++++++++++++++++선거문자 ==> 200 resultBlockSts ::: " + resultBlockSts);
+	    		    		System.out.println("=========================================================================");
+	    					
+	    				}else {
+	    					
+	    					tempPhoneList[sendCnt] = phoneList[i];
+	    					
+	    					if(nameList.length > 0) {//이름 치환문자가 있는 경우
+	    						tempNameList[sendCnt] = nameList[i];
+	    					}
+	    					
+	    					if(rep1List.length > 0) {//치환1 문자가 있는 경우
+	    						tempRep1List[sendCnt] = rep1List[i];
+	    					}
+	    					
+	    					if(rep2List.length > 0) {//치환2 문자가 있는 경우
+	    						tempRep2List[sendCnt] = rep2List[i];
+	    					}
+	    					
+	    					if(rep3List.length > 0) {//치환3 문자가 있는 경우
+	    						tempRep3List[sendCnt] = rep3List[i];
+	    					}
+	    					
+	    					if(rep4List.length > 0) {//치환4 문자가 있는 경우
+	    						tempRep4List[sendCnt] = rep4List[i];
+	    					}
+	    					
+	    					sendCnt++;
+	    					
+	    				}
+	    				
+	    			}
+	    			
+	    		}else {//200건 미만일 경우 한번에 발송 처리
+	    			
+	    			//분할 발송을 체크 한 경우
+					if(mjonMsgVO.getDivideChk() != null) {
+						for(int i=0; i< callToListCnt; i++) {
+							if(count > divideCnt) {
+		            			
+		            			count = 1;
+		            			
+		            			//분할 시간 간격을 증가시켜 준다.
+		            			cal.add(Calendar.MINUTE, turmMin);
+		            			dividDay = transFormat.format(cal.getTime());
+		                    	
+		            			dividDayList.add(dividDay);
+		            			//tempVO.setReqDate(dividDay); //분할 문자 예약 시간 입력해주기
+		                		count++;
+		                		
+		            		}else {
+		            			
+		            			dividDayList.add(dividDay);
+		            			//tempVO.setReqDate(dividDay); //분할 문자 예약 시간 입력해주기
+		            			count++;
+		            			
+		            		}
+						
+						}
+	    				
+	    			}
+	    			
+					mjonMsgVO.setDividDay(dividDayList);
+	    			MjonMsgReturnVO returnVO = mjonMsgDataService.insertMsgDataInfo(mjonMsgVO);
+	    			mjonMsgVO.setAgentCode(returnVO.getAgentCode());
+		    		resultSts = Integer.parseInt(returnVO.getSendMsgCnt());
+		    		resultBlockSts = Integer.parseInt(returnVO.getSendMsgBlockCnt());
+		    		
+		    		System.out.println("=========================================================================");
+		    		System.out.println("+++++++++++++++++++++++++++++++++++++++++++200건 미만 건수 선거문자 ==> resultSts ::: " + resultSts);
+		    		System.out.println("+++++++++++++++++++++++++++++++++++++++++++200건 미만 건수 선거문자 ==> resultBlockSts ::: " + resultBlockSts);
+		    		System.out.println("=========================================================================");
+	    			
+	    		}
+	    		
+	    		System.out.println("=========================================================================");
+	    		System.out.println("+++++++++++++++++++++++++++++++++++++++++++최종 건수 선거문자 ==> resultSts ::: " + resultSts);
+	    		System.out.println("+++++++++++++++++++++++++++++++++++++++++++최종 건수 선거문자 ==> resultBlockSts ::: " + resultBlockSts);
+	    		System.out.println("=========================================================================");
+	    		
+	    		try {
+	    			
+		    		//스팸문구 포함된 문자 발송의 경우 스팸 문구 내용도 별도 저장함.
+		    		String spamStatus = mjonMsgVO.getSpamStatus();
+		    		
+		    		if(spamStatus == null) {
+		    			
+		    			spamStatus = "N";
+		    			mjonMsgVO.setSpamStatus("N");
+		    			
+		    		}
+		    		
+		    		if(spamStatus.equals("Y")) {
+		    			
+		    			int resultCnt = mjonSpamMsgService.insertSpamKeyWordMsgData(mjonMsgVO);
+		    			
+		    			System.out.println("+++++++++++++스팸문구 발송 내용 등록 +++++++++++++++++++++ "+resultCnt);
+		    			
+		    		}
+					
+				} catch (Exception e) {
+					System.out.println("=========================================================================");
+					System.out.println("+++++++++++++++++++++++++++++ 선거문자 ==> MJ_MSG_GROUP && CASH INSER ERROR !!! : " + e.getMessage());
+					System.out.println("=========================================================================");
+				}
+	    		
+	        	
+        	}else {
+        		
+        		modelAndView.addObject("message", "문자 발송에 필요한 보유 잔액이 부족 합니다.");
+    			modelAndView.addObject("result", "fail");
+    			modelAndView.addObject("resultSts", "0");
+    			modelAndView.addObject("resultBlockSts", "0");
+    			
+    			return modelAndView;
+        		
+        	}
+        	
+        	//문자 발송 후 남은 보유 캐시 정보 불러오기
+        	String afterCash = mjonMsgDataService.selectBeforeCashData(mjonMsgVO);
+        	modelAndView.addObject("afterCash", afterCash);
+        	
+    	}catch(Exception e) {
+
+			System.out.println("=========================================================================");
+			System.out.println("+++++++++++++++++++++++++++++ 선거문자 ==> 기타 시스템 오류 !!! : " + e.getMessage());
+			System.out.println("=========================================================================");
+			
+    		logger.error(e.getMessage(), e);
+    		modelAndView.addObject("result", "fail");
+    		modelAndView.addObject("message", "기타 시스템 오류 : " + e.getMessage());
+    	}
+		
+		//if(!resultSts.equals("0")) {
+			
+		modelAndView.addObject("message", "문자 전송이 완료되었습니다.");
+		modelAndView.addObject("result", "success");
+		modelAndView.addObject("resultSts", resultSts);
+		modelAndView.addObject("resultBlockSts", resultBlockSts);
+			
+
+		/*
+		 * 
+		 * 문자전송이 완료되면 전송한 연락처의 발송 상태값을 변경처리 해준다.
+		 * 사용자 화면의 받는사람 리스트에서 다음 페이지의 20건을 불러오고, 발송완료 및 전송대기건의 카운트 계산을 위함이다.
+		 * 
+		 * */
+		if(resultSts > 0) {
+			
+			System.out.println(userId);
+			
+			MjonCandidateTWVO mjonCandidateTWVO = new MjonCandidateTWVO();
+			
+			mjonCandidateTWVO.setMberId(userId);
+			mjonCandidateTWVO.setCallToArr(mjonMsgVO.getCallToList());
+			
+			mjonCandidateService.updateMsgTWCallToListSendFlag(mjonCandidateTWVO);
+			
+		}
+		
+		/**
+		 * 사용자가 보낸 문자를 문자온 법인폰으로도 하나 전송하는 기능 시작
+		 * 
+		 * */
+		
+		try {
+			
+			if(resultSts > 0) {//전송 결과가 한건 이상인 경우
+				
+				String adminSmsNoticeYn = "Y";
+				String smishingYn = "N";
+				String spamStatus = mjonMsgVO.getSpamStatus(); //스미싱 의심으로 체크된 문자 정보
+				
+				UserManageVO userManageVO = new UserManageVO();
+				userManageVO.setMberId(userId);
+				if(!userId.equals("")) {
+					userManageVO = userManageService.selectAdminSmsNoticeYn(userManageVO);
+					adminSmsNoticeYn = userManageVO.getAdminSmsNoticeYn(); 
+					smishingYn = userManageVO.getSmishingYn();
+				}
+				
+				//법인폰 알림 온 이거나 스미싱의심 문자인 경우 법인폰으로 발송
+				if(adminSmsNoticeYn.equals("Y") || spamStatus.equals("Y") || smishingYn.equals("Y")) {
+
+					if(spamStatus.equals("Y")) {
+						
+						mjonMsgVO.setDelayYn("Y");
+						
+					}else if(smishingYn.equals("Y")) {
+						
+						mjonMsgVO.setSmishingYn("Y");
+					}
+					
+					// 법인폰 알람여부 체크
+					JoinSettingVO joinSettingVO = new JoinSettingVO();
+					joinSettingVO = egovSiteManagerService.selectAdminNotiDetail();
+					// SMS 체크
+					if (joinSettingVO != null && joinSettingVO.getSmsNoti().equals("Y")) {
+						MjonMsgCampainDataController mjonCampDataController = new MjonMsgCampainDataController();
+						mjonCampDataController.getAdminPhoneSendMsgData(mjonMsgVO);						
+					}
+
+					// SLACK 체크
+					if (joinSettingVO != null && joinSettingVO.getSlackNoti().equals("Y")) {
+						//Slack으로 메세지 전송 처리
+						MjonCommon comm = new MjonCommon();
+						comm.getAdminSandSlack(mjonMsgVO);
+					}
+				}
+				
+			}
+
+    	} catch (Exception e) {
+			throw new Exception("++++++++++++++++++++++ 선거문자 메뉴 getAdminPhoneSendMsgData Error !!! " + e);
+		}
+
+		return modelAndView;
+	}
+	
+	
+	
+	/*
+	 * 선거문자 20건 발송 처리 종료 
+	 * 
+	 * */
+	
+	
+	
+	
+	
+	
+	
+	
+	
 	
 	/**
 	 * 선거문자 20건씩 문자 발송 - 엑셀파일 불러오기
@@ -1289,12 +2509,6 @@
 							
 						}
 						
-						/*if(jm.get("phone") != null) {
-							
-							json.add(jm);
-							
-						}*/
-
 					} // end while
 					//jr.setData(json);
 					//jr.setSuccess(true);
src/main/resources/egovframework/sqlmap/let/msg/MjonMsgCampainData_SQL_mysql.xml
--- src/main/resources/egovframework/sqlmap/let/msg/MjonMsgCampainData_SQL_mysql.xml
+++ src/main/resources/egovframework/sqlmap/let/msg/MjonMsgCampainData_SQL_mysql.xml
@@ -249,6 +249,20 @@
 		                     'N')
 	</select>
 	
+	<update id="mjonCandidateDAO.updateMsgTWCallToListSendFlag" parameterClass="mjonCandidateTWVO">
+		
+		UPDATE MJ_CAMPAIN_TMP_CALLTO SET 
+			SEND_FLAG = 'Y',
+			LAST_UPDUSR_ID = #mberId#,
+			LAST_UPDT_PNTTM = NOW()
+		WHERE MBER_ID = #mberId#
+		    <iterate prepend="AND CALL_TO IN " open="(" close=")" conjunction="," property="callToArr">
+				#callToArr[]#
+			</iterate>
+	
+	
+	</update>
+	
 </sqlMap>  
 
 
src/main/webapp/WEB-INF/jsp/web/msgcampain/tw/MsgTWDataSMLView.jsp
--- src/main/webapp/WEB-INF/jsp/web/msgcampain/tw/MsgTWDataSMLView.jsp
+++ src/main/webapp/WEB-INF/jsp/web/msgcampain/tw/MsgTWDataSMLView.jsp
@@ -136,6 +136,17 @@
 //엑셀파일 자료 데이터베이스에 입력해주기
 function fnInsertAttchFileData(){
 	
+	var callToCnt = $("input[name=chkCallTo]").length;
+	
+	if(callToCnt > 0){
+		if(!confirm("기존 받는사람을 모두 초기화하고 새로운 받는사람을 불러옵니다. 진행하시겠습니까?")){
+			//첨부파일 초기화 시켜주기
+		    $("#excelFile").val("");
+		    $("#excelNm").val("");
+			return false;
+		}
+	}
+	
 	var data = new FormData(document.excelForm);
 	data.append("file0", $('#excelFile').prop('files')[0]);
 	
@@ -210,7 +221,7 @@
 						//첨부파일로 불러온 데이터를 받는사람 목록에 추가해 준다.
 						addTWCallToInfo();
 						
-						 //첨부파일 초기화 시켜주기
+						//첨부파일 초기화 시켜주기
 					    $("#excelFile").val("");
 					    $("#excelNm").val("");
 						
@@ -255,10 +266,6 @@
 $("#excelAdd").click(function(){
 	
 	var callSeq = $("#callSeq").val();
-	
-	if(!confirm("기존 받는사람을 모두 초기화하고 새로운 받는사람을 불러옵니다. 진행하시겠습니까?")){
-		return false;
-	}
 	
 	//엑셀파일 자료 데이터베이스에 입력해주기
 	fnInsertAttchFileData();
@@ -1276,7 +1283,7 @@
 	//오류 검사 버튼 처리
 	$('.check_validity').click(function(){
 		
-		var data = $('.liCallTo').length;
+		var data = $("input[name='chkCallTo']").length;
 		
 		if(data == 0){
 			
@@ -1285,27 +1292,26 @@
 		
 		}else{
 				
-			var callToArr = [];
+			var callToChkArr = [];
 			//받는사람 목록의 리스트 전체 데이터 불러와서 배열에 저장
 			//화면에 불러와져있는 최대 20개의 리스트만 삭제
-			$(".liCallTo a div span").each(function(){
-				
-				var callTo = $(this).text();
-				
+			$("input[name='chkCallTo']").each(function(){
+		
+				var callTo = $(this).closest("div").next().text();
 				//전화번호 유효성 체크 해주기
 				var callSts = checkHpNum(callTo);
 				
 				if(!callSts){
 					
-					callToArr.push(callTo);
+					callToChkArr.push(callTo);
 					
 				}
 				
 			});
 			
-			if(callToArr.length > 0){
+			if(callToChkArr.length > 0){
 				
-				alert("받는사람 목록 중 ["+ callToArr + "] 번호에 오류가 있습니다.");
+				alert("받는사람 목록 중 ["+ callToChkArr + "] 번호에 오류가 있습니다.");
 				return false;
 				
 			}else{
@@ -4032,6 +4038,9 @@
 	</form>
     <form id="msgForm" name="msgForm" method="post">
     	<input type="hidden" id="send_adYn" name="send_adYn" value="N"/><!-- 문자종류 선거문자 여부 값 -->
+    	<input type="hidden" id="divideChk" name="divideChk" value="N"/><!-- 예약문자 분할발송 여부 값 -->
+    	<input type="hidden" id="divideCnt" name="divideCnt" value="20"/><!-- 예약문자 분할발송 분할갯수 값 -->
+    	<input type="hidden" id="divideTime" name="divideTime" value="01"/><!-- 예약문자 분할발송 분할 간격 값 -->
 		<input type="hidden" id="msgType" name="msgType" value="4" /><!-- 문자 종류 : 단문 - 4, 장문/그림 - 6 -->
 		<input type="hidden" id="imgFilePath" name="imgFilePath" value="" /><!-- 선택 이미지 파일 경로 정보 , 로 구분 최대 3장까지 -->
 		<input type="hidden" id="imgFileId" name="imgFileId" value="" /><!-- 선택 이미지 파일 아이디 정보 , 로 구분 최대 3장까지 -->
src/main/webapp/WEB-INF/jsp/web/msgcampain/tw/MsgTWDataView.jsp
--- src/main/webapp/WEB-INF/jsp/web/msgcampain/tw/MsgTWDataView.jsp
+++ src/main/webapp/WEB-INF/jsp/web/msgcampain/tw/MsgTWDataView.jsp
@@ -199,7 +199,8 @@
 
 //문자발송 URL Move
 function goMsgUrlMove() {
-	document.location.href = "/web/mjon/msgcampain/selectTWMsgDataView.do";
+	//document.location.href = "/web/mjon/msgcampain/selectMsgTWDataView.do";
+	addTWCallToInfo();
 }
 
 function listMsgDataView(){
@@ -868,34 +869,12 @@
 	var spamStatus = false;
 	var exceptSpamYn = $("#exceptSpamYn").val(); //금지어 필터링 예외 여부 - N 일 경우만 스팸 검사를 진행
 	
-	alert(adverYn);
-	
-/* 	//이벤트 진행중 회원의 경우 이벤트 잔여금액 비교 처리 필요.
-	var eventStatus = form.eventStatus.value;
-	var eventRemainCash = parseFloat(form.eventRemainCash.value);
-	
-	if(eventStatus == 'Y'){
-		
-		if(parseFloat(eventRemainCash) < parseFloat(totPriceOnly)){
-			
-			alert("고객님의 이벤트 캐시 잔액은 " + eventRemainCash + "원으로 입력하신 수량의 문자를 전부 발송할 수 없습니다. 잔액 이하로 발송건수를 재설정하시기 바랍니다.");
-			return false;
-		}
-		
-	} */
-	
 	if(loginVO == "" || loginVO == null){
 		
 		alert("문자발송 서비스는 로그인 후 이용 가능합니다.");
 		return false;
 		
 	}
-	
-	//MJ_MSG_GROUP_DATA 누락데이터 체크
-	//if (getMsgGroupDataErrorCheck() == false) {
-	//	alert("고객님께서 발송한 최근문자가 발송결과에 표시되지않아, 문자발송이 임시로 차단되었습니다.\n문자온 고객센터에 문의해주세요.");
-	//	return false;	 	
-	//}
 	
 	if(form.callFromList.value == ""){
 		
@@ -937,19 +916,6 @@
 		alert("입력하신 문구 중 \" " + rtnStr + " \" 는 일부 휴대폰에서 표기되지 않을 수 있습니다.");
 		
 	}
-	
-	//문자내용 첫글자에 특수기호 포함 여부 체크
-	/* var strCont = form.smsTxtArea.value;
-	var repStr = strFirstCharCheck(strCont);
-	
-	if(repStr.length > 0){
-		
-		alert("문자 내용 첫 글자는 특수기호가 들어갈 수 없습니다.");
-		$('#smsTxtArea').val(strCont.replace(repStr, ""));
-		fnByteString(strCont.replace(repStr, ""));
-		return false;
-		
-	} */
 	
 	if(imgFilePath.length == 0){ // 그림문자일 경우 내용이 없어도 됨 , 장문 문자일 경우만 문자내용 체크함
 		
@@ -1007,7 +973,7 @@
 		var callToNum = $(this).closest("div").next().text();
 		
 		if(!checkHpNum(callToNum)){
-			alert("선택한 연락처 목록에 잘 못된 연락처가 있습니다. 연락처 번호 : " + callToNum + " 입니다.");
+			alert("선택한 연락처 목록에 잘못된 연락처가 있습니다. 연락처 번호 : " + callToNum + " 입니다.");
 			return false;
 		}else{
 			phoneNum.push(callToNum);
@@ -1626,7 +1592,7 @@
 	var reserYn = $("#reserveYn").val();
 	
 	var data = new FormData(form);
-	url = "/web/mjon/msgcampain/sendMsgDataAjax.do";
+	url = "/web/mjon/msgcampain/sendMsgTWDataAjax.do";
 	
 	$.ajax({
         type: "POST",
@@ -1920,8 +1886,8 @@
 				<div class="msg_text">발송성공 : <strong>1</strong> 건, 수신거부 : <span>0</span>건의<br>문자가 발송 되었습니다.</div>
 			</div>
 			<div class="popup_btn">
-				<button type="button" onclick="msgResultLink(); return false;">문자 발송결과 바로가기</button>                      
-				<button type="button" class="tooltip-close" onclick="msgSuccessClose(this);">확인</button>                      
+				<!-- <button type="button" onclick="msgResultLink(); return false;">문자 발송결과 바로가기</button>      -->                 
+				<button type="button" class="tooltip-close" onclick="msgSuccessClose(this);">다음 20건</button>                      
 			</div>
 		</div>
 	</div>
src/main/webapp/publish/js/publish.js
--- src/main/webapp/publish/js/publish.js
+++ src/main/webapp/publish/js/publish.js
@@ -23,7 +23,7 @@
       }
       $(checkTarget[cnt]).prop('checked', true); // 체크박스 체크.
       cnt++;
-      console.log("+++++ publishCommon ::: " + cnt);
+      fnChkCallToChange();
     }, checkTime);
   },
   clickCheck: function (checkTarget) {
@@ -46,21 +46,10 @@
 	
 	});
     
-    console.log("+++++ publishCommonClick ::: " + this.count);
   },
   clickCheckPrice : function(){
 	  
-	  var callToCnt = 0;
-		$("input[name=chkCallTo]").each(function(){
-			
-			var chkSts = $(this).is(':checked');
-			if(chkSts){
-				callToCnt++;
-			}
-		});
-		
-		updateTotCnt(callToCnt); //전체 데이터 갯수 구하기
-		totalPriceSum(callToCnt);
+	  fnChkCallToChange();
 	  
   }
   
Add a comment
List