From 6c9d77cc6ee70e865791ecd258a5e59f178dbcf4 Mon Sep 17 00:00:00 2001 From: ijunho Date: Mon, 14 Apr 2025 09:53:42 +0900 Subject: [PATCH] Merge branch 'master_tolag3' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 알림톡 발송결과 수정 --- .../kakaoAt/service/MjonKakaoATService.java | 9 + .../kakaoAt/service/impl/MjonKakaoATDAO.java | 14 + .../service/impl/MjonKakaoATServiceImpl.java | 51 ++ .../kakaoAt/web/MjonKakaoATController.java | 9 +- .../user/sent/service/KakaoSentService.java | 3 + .../kakao/user/sent/service/KakaoSentVO.java | 4 + .../service/impl/KakaoSentServiceImpl.java | 285 +++++++ .../user/sent/web/KakaoSentController.java | 171 ++-- .../let/kakao/MjonKakaoATData_SQL_mysql.xml | 738 ++++++++++++++++++ .../let/mjo/kakao/KakaoSent_SQL_Mysql.xml | 7 +- 10 files changed, 1200 insertions(+), 91 deletions(-) diff --git a/src/main/java/itn/let/kakao/admin/kakaoAt/service/MjonKakaoATService.java b/src/main/java/itn/let/kakao/admin/kakaoAt/service/MjonKakaoATService.java index f9fe0495..aeb02f0c 100644 --- a/src/main/java/itn/let/kakao/admin/kakaoAt/service/MjonKakaoATService.java +++ b/src/main/java/itn/let/kakao/admin/kakaoAt/service/MjonKakaoATService.java @@ -45,5 +45,14 @@ public interface MjonKakaoATService { //알림톡 지연문자 리스트 조회 List selectKakaoATDelaySentList(String userId) throws Exception; + + //알림톡 전체 발송 리스트(대시보드용) + List selectMjonKakaoATGroupCompleteByUserList_advc(KakaoVO searchVO) throws Exception; + + //알림톡 발송 상세 리스트 + List selectMjonKakaoATGroupDtList_advc(KakaoVO searchVO) throws Exception; + + //알림톡 전송내역 상세 + KakaoVO selectMjonKakaoATVO_advc(KakaoVO mjonKakaoATVO) throws Exception; } diff --git a/src/main/java/itn/let/kakao/admin/kakaoAt/service/impl/MjonKakaoATDAO.java b/src/main/java/itn/let/kakao/admin/kakaoAt/service/impl/MjonKakaoATDAO.java index 1ff99bc3..6411969a 100644 --- a/src/main/java/itn/let/kakao/admin/kakaoAt/service/impl/MjonKakaoATDAO.java +++ b/src/main/java/itn/let/kakao/admin/kakaoAt/service/impl/MjonKakaoATDAO.java @@ -97,4 +97,18 @@ public class MjonKakaoATDAO extends EgovAbstractDAO { public List selectKakaoATDelaySentList(String userId) throws Exception{ return (List)list("mjonKakaoATDAO.selectKakaoATDelaySentList", userId); } + + @SuppressWarnings("unchecked") + public List selectMjonKakaoATGroupCompleteByUserList_advc(KakaoVO p_mjonKakaoATVO) throws Exception{ + return (List)list("mjonKakaoATDAO.selectMjonKakaoATGroupCompleteByUserList_advc", p_mjonKakaoATVO); + } + + @SuppressWarnings("unchecked") + public List selectMjonKakaoATGroupDtList_advc(KakaoVO p_mjonKakaoATVO) throws Exception{ + return (List)list("mjonKakaoATDAO.selectMjonKakaoATGroupDtList_advc", p_mjonKakaoATVO); + } + + public KakaoVO selectMjonKakaoATVO_advc(KakaoVO p_mjonKakaoATVO) throws Exception{ + return (KakaoVO) select("mjonKakaoATDAO.selectMjonKakaoATVO_advc", p_mjonKakaoATVO); + } } diff --git a/src/main/java/itn/let/kakao/admin/kakaoAt/service/impl/MjonKakaoATServiceImpl.java b/src/main/java/itn/let/kakao/admin/kakaoAt/service/impl/MjonKakaoATServiceImpl.java index f0686fae..53d4119b 100644 --- a/src/main/java/itn/let/kakao/admin/kakaoAt/service/impl/MjonKakaoATServiceImpl.java +++ b/src/main/java/itn/let/kakao/admin/kakaoAt/service/impl/MjonKakaoATServiceImpl.java @@ -199,4 +199,55 @@ public class MjonKakaoATServiceImpl extends EgovAbstractServiceImpl implements M public List selectKakaoATDelaySentList(String userId) throws Exception { return mjonKakaoATDAO.selectKakaoATDelaySentList(userId); } + + @Override + public List selectMjonKakaoATGroupCompleteByUserList_advc(KakaoVO p_mjonKakaoATVO) throws Exception { + + List result = new ArrayList(); + + try { + + result = mjonKakaoATDAO.selectMjonKakaoATGroupCompleteByUserList_advc(p_mjonKakaoATVO); + + } catch (Exception e) { + System.out.println("selectMjonKakaoATGroupCompleteByUserList ServiceImpl Error ::: " + e); + } + + + return result; + } + + @Override + public List selectMjonKakaoATGroupDtList_advc(KakaoVO p_mjonKakaoATVO) throws Exception { + + List resultList = new ArrayList(); + + try { + + resultList = mjonKakaoATDAO.selectMjonKakaoATGroupDtList_advc(p_mjonKakaoATVO); + + } catch (Exception e) { + System.out.println("selectMjonKakaoATGroupDtList ServiceImpl Error ::: " + e); + + } + + return resultList; + } + + @Override + public KakaoVO selectMjonKakaoATVO_advc(KakaoVO p_mjonKakaoATVO) throws Exception { + + KakaoVO result = new KakaoVO(); + + try { + + result = mjonKakaoATDAO.selectMjonKakaoATVO_advc(p_mjonKakaoATVO); + + } catch (Exception e) { + System.out.println("selectMjonKakaoATVO Service Impl Error !!! " + e); + } + + + return result; + } } diff --git a/src/main/java/itn/let/kakao/admin/kakaoAt/web/MjonKakaoATController.java b/src/main/java/itn/let/kakao/admin/kakaoAt/web/MjonKakaoATController.java index 900b889f..b4513d7a 100644 --- a/src/main/java/itn/let/kakao/admin/kakaoAt/web/MjonKakaoATController.java +++ b/src/main/java/itn/let/kakao/admin/kakaoAt/web/MjonKakaoATController.java @@ -241,7 +241,8 @@ public class MjonKakaoATController { kakaoVO.setNtceBgnde(beforeMonthDay); } - resultList = mjonKakaoATService.selectMjonKakaoATGroupCompleteByUserList(kakaoVO); +// resultList = mjonKakaoATService.selectMjonKakaoATGroupCompleteByUserList(kakaoVO); + resultList = mjonKakaoATService.selectMjonKakaoATGroupCompleteByUserList_advc(kakaoVO); model.addAttribute("resultList", resultList); @@ -331,7 +332,8 @@ public class MjonKakaoATController { } List resultList = new ArrayList(); - resultList = mjonKakaoATService.selectMjonKakaoATGroupDtList(searchVO); +// resultList = mjonKakaoATService.selectMjonKakaoATGroupDtList(searchVO); + resultList = mjonKakaoATService.selectMjonKakaoATGroupDtList_advc(searchVO); model.addAttribute("resultList", resultList); model.addAttribute("searchVO", searchVO); @@ -377,7 +379,8 @@ public class MjonKakaoATController { KakaoVO mjonKakaoATDetailVO = new KakaoVO(); if(null != searchVO.getUserData() && !"".equals(searchVO.getUserData())) { //수정 - mjonKakaoATDetailVO = mjonKakaoATService.selectMjonKakaoATVO(searchVO); +// mjonKakaoATDetailVO = mjonKakaoATService.selectMjonKakaoATVO(searchVO); + mjonKakaoATDetailVO = mjonKakaoATService.selectMjonKakaoATVO_advc(searchVO); } diff --git a/src/main/java/itn/let/kakao/user/sent/service/KakaoSentService.java b/src/main/java/itn/let/kakao/user/sent/service/KakaoSentService.java index 61308a39..eede60d6 100644 --- a/src/main/java/itn/let/kakao/user/sent/service/KakaoSentService.java +++ b/src/main/java/itn/let/kakao/user/sent/service/KakaoSentService.java @@ -3,6 +3,8 @@ package itn.let.kakao.user.sent.service; import java.util.List; import java.util.Map; +import javax.servlet.http.HttpServletResponse; + import itn.let.kakao.admin.kakaoAt.service.MjonKakaoATVO; public interface KakaoSentService { @@ -39,4 +41,5 @@ public interface KakaoSentService { //발송 관리 문자발송 내용 상세보기 팝업 public MjonKakaoATVO selectKakaoSentDetailViewPhoneAjax(MjonKakaoATVO kakaoSentVO) throws Exception; + public void kakaoExcelDown(KakaoSentVO kakaoSentVO, HttpServletResponse response) throws Exception; } diff --git a/src/main/java/itn/let/kakao/user/sent/service/KakaoSentVO.java b/src/main/java/itn/let/kakao/user/sent/service/KakaoSentVO.java index b6802230..1a2e7682 100644 --- a/src/main/java/itn/let/kakao/user/sent/service/KakaoSentVO.java +++ b/src/main/java/itn/let/kakao/user/sent/service/KakaoSentVO.java @@ -115,4 +115,8 @@ public class KakaoSentVO extends UserDefaultVO{ private String divideYn; + private String sendKind; + + private String yellowId; + } diff --git a/src/main/java/itn/let/kakao/user/sent/service/impl/KakaoSentServiceImpl.java b/src/main/java/itn/let/kakao/user/sent/service/impl/KakaoSentServiceImpl.java index 70f58ece..5e2dee52 100644 --- a/src/main/java/itn/let/kakao/user/sent/service/impl/KakaoSentServiceImpl.java +++ b/src/main/java/itn/let/kakao/user/sent/service/impl/KakaoSentServiceImpl.java @@ -1,18 +1,35 @@ package itn.let.kakao.user.sent.service.impl; +import java.io.OutputStream; import java.math.BigDecimal; import java.math.RoundingMode; +import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.stream.Collectors; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.springframework.stereotype.Service; import egovframework.rte.fdl.cmmn.EgovAbstractServiceImpl; @@ -21,6 +38,7 @@ import itn.let.kakao.admin.kakaoAt.service.MjonKakaoATVO; import itn.let.kakao.user.sent.service.KakaoSentDetailVO; import itn.let.kakao.user.sent.service.KakaoSentService; import itn.let.kakao.user.sent.service.KakaoSentVO; +import itn.let.mjo.msgsent.service.MjonMsgSentVO; @Service("KakaoSentService") public class KakaoSentServiceImpl extends EgovAbstractServiceImpl implements KakaoSentService{ @@ -437,5 +455,272 @@ public class KakaoSentServiceImpl extends EgovAbstractServiceImpl implements Ka return String.format("%,d건씩 %d분 간격", batchSize, intervalMinutes); } + + @Override + public void kakaoExcelDown( + KakaoSentVO kakaoSentVO + , HttpServletResponse response + ) throws Exception { + kakaoSentVO.setRecordCountPerPage(100000); + kakaoSentVO.setFirstIndex(0); + + if(StringUtils.isEmpty(kakaoSentVO.getSearchSortOrd())) { + kakaoSentVO.setSearchSortOrd("desc"); +// kakaoSentVO.setSearchSortCnd("B.REQ_DATE"); + } + + //예약 관리 리스트 불러오기 + List resultList = kakaoSentDAO.selectAllKakaoSentList_advc(kakaoSentVO); + +// long startTime = System.nanoTime(); // 시작 시간 측정 +// resultAllSentList = makeDetailFunction(resultAllSentList); + + resultList = resultList.stream().map(t -> setPriceNCode(t)).collect(Collectors.toList()); +// long endTime = System.nanoTime(); // 끝난 시간 측정 +// double executionTimeInSeconds = (endTime - startTime) / 1_000_000_000.0; +// System.out.println("Execution time: " + executionTimeInSeconds + " seconds"); + + SXSSFWorkbook workbook = null; // SXSSFWorkbook 변수 선언 + try{ + + + // Workbook 생성 + workbook = new SXSSFWorkbook(); + Sheet sheet = workbook.createSheet("발송 내역"); + + // 열 너비 설정 + sheet.setColumnWidth(0, 3000); // 번호 열 + sheet.setColumnWidth(1, 4000); // 발송일시 열 + sheet.setColumnWidth(2, 5000); // 구분 열 + sheet.setColumnWidth(3, 5000); //채널 ID 열 + sheet.setColumnWidth(4, 3000); // 형태 열 + sheet.setColumnWidth(5, 10000); // 내용 열 + sheet.setColumnWidth(6, 4000); // 발송건수 열 + sheet.setColumnWidth(7, 3000); // 대기 열 + sheet.setColumnWidth(8, 3000); // 카카오톡 성공 열 + sheet.setColumnWidth(9, 3000); // 카카오톡 실패 열 + sheet.setColumnWidth(10, 3000); // 대체문자 성공 열 + sheet.setColumnWidth(11, 3000); // 대체문자 실패 열 + sheet.setColumnWidth(12, 4000); // 금액 열 + sheet.setColumnWidth(13, 5000); // 진행상황 열 + + // 헤더 스타일 설정 + CellStyle headerStyle = workbook.createCellStyle(); + headerStyle.setAlignment(HorizontalAlignment.CENTER); + headerStyle.setVerticalAlignment(VerticalAlignment.CENTER); + headerStyle.setBorderTop(BorderStyle.THIN); + headerStyle.setBorderBottom(BorderStyle.THIN); + headerStyle.setBorderLeft(BorderStyle.THIN); + headerStyle.setBorderRight(BorderStyle.THIN); + headerStyle.setTopBorderColor(IndexedColors.GREY_25_PERCENT.getIndex()); + headerStyle.setBottomBorderColor(IndexedColors.GREY_25_PERCENT.getIndex()); + headerStyle.setLeftBorderColor(IndexedColors.GREY_25_PERCENT.getIndex()); + headerStyle.setRightBorderColor(IndexedColors.GREY_25_PERCENT.getIndex()); + + Font font = workbook.createFont(); + font.setBold(true); // 글씨체 굵게 + font.setFontHeightInPoints((short) 12); // 글씨 크기 + headerStyle.setFont(font); + + // 데이터 스타일 설정 (가운데 정렬) + CellStyle centerStyle = workbook.createCellStyle(); + centerStyle.setAlignment(HorizontalAlignment.CENTER); + centerStyle.setVerticalAlignment(VerticalAlignment.CENTER); + centerStyle.setBorderTop(BorderStyle.THIN); + centerStyle.setBorderBottom(BorderStyle.THIN); + centerStyle.setBorderLeft(BorderStyle.THIN); + centerStyle.setBorderRight(BorderStyle.THIN); + centerStyle.setTopBorderColor(IndexedColors.GREY_25_PERCENT.getIndex()); + centerStyle.setBottomBorderColor(IndexedColors.GREY_25_PERCENT.getIndex()); + centerStyle.setLeftBorderColor(IndexedColors.GREY_25_PERCENT.getIndex()); + centerStyle.setRightBorderColor(IndexedColors.GREY_25_PERCENT.getIndex()); + + // 첫 번째 헤더 작성 (상단 병합) + Row headerRow = sheet.createRow(0); + + // 번호 열 추가 + Cell cell = headerRow.createCell(0); + cell.setCellValue("번호"); + cell.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0)); // 번호 병합 + + // 구분 열 추가 + cell = headerRow.createCell(1); + cell.setCellValue("발송일시"); + cell.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(0, 1, 1, 1)); // 구분 병합 + + // 구분 열 추가 + cell = headerRow.createCell(2); + cell.setCellValue("구분"); + cell.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(0, 1, 2, 2)); // 구분 병합 + + cell = headerRow.createCell(3); + cell.setCellValue("채널ID"); + cell.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(0, 1, 3, 3)); // 발송일시 병합 + + cell = headerRow.createCell(4); + cell.setCellValue("형태"); + cell.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(0, 1, 4, 4)); // 형태 병합 + + cell = headerRow.createCell(5); + cell.setCellValue("내용"); + cell.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(0, 1, 5, 5)); // 내용 병합 + + cell = headerRow.createCell(6); + cell.setCellValue("발송건수"); + cell.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(0, 1, 6, 6)); // 발송건수 병합 + + cell = headerRow.createCell(7); + cell.setCellValue("대기"); + cell.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(0, 1, 7, 7)); // 발송건수 병합 + + cell = headerRow.createCell(8); + cell.setCellValue("카카오톡 결과"); + cell.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(0, 0, 8, 9)); // 카카오톡 결과 병합 + + cell = headerRow.createCell(10); + cell.setCellValue("대체문자 결과"); + cell.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(0, 0, 10, 11)); // 대체문자 결과 병합 + + cell = headerRow.createCell(12); + cell.setCellValue("금액(원)"); + cell.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(0, 1, 12, 12)); // 금액(원) 병합 + + cell = headerRow.createCell(13); + cell.setCellValue("진행상황"); + cell.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(0, 1, 13, 13)); // 진행상황 병합 + + // 두 번째 헤더 작성 (카카오톡 결과 하위 열) + Row subHeaderRow = sheet.createRow(1); + + String[] subHeadersKakao = {"성공", "실패"}; + for (int i = 0; i < subHeadersKakao.length; i++) { + cell = subHeaderRow.createCell(8 + i); // 결과 열 시작점(6번 열)부터 순차적으로 설정 + cell.setCellValue(subHeadersKakao[i]); + cell.setCellStyle(headerStyle); + } + + // 두 번째 헤더 작성 (대체문자 결과 하위 열) + String[] subHeadersKakaoDaeChae = {"성공", "실패"}; + for (int i = 0; i < subHeadersKakaoDaeChae.length; i++) { + cell = subHeaderRow.createCell(10 + i); // 결과 열 시작점(6번 열)부터 순차적으로 설정 + cell.setCellValue(subHeadersKakaoDaeChae[i]); + cell.setCellStyle(headerStyle); + } + + // Object[][]로 변환 + Object[][] data = new Object[resultList.size()][14]; // 14은 필드 수 + + for (int i = 0; i < resultList.size(); i++) { + KakaoSentVO vo = resultList.get(i); + //번호 + data[i][0] = i+1; + //발송일시 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + data[i][1] = sdf.format(vo.getReqdate()); + + //구분 + data[i][2] = "H".equals(vo.getSendKind()) ? "WEB" : "API"; + + //채널ID + data[i][3] = vo.getYellowId(); + + //형태 + data[i][4] = "8".equals(vo.getMsgType()) ? "알림톡" : "친구톡"; + + String reserveTxt = ""; + if("Y".equals(vo.getReserveYn())) {reserveTxt="[예약]";} + if("Y".equals(vo.getDivideYn())) {reserveTxt+="[분할]";} + + data[i][5] = reserveTxt + (StringUtils.isEmpty(vo.getSmsTxt()) ? "-" : vo.getSmsTxt()); + data[i][6] = vo.getMsgGroupCnt(); + data[i][7] = vo.getWaitCount(); + data[i][8] = vo.getSuccessCount(); + data[i][9] = vo.getFailCount(); + data[i][10] = vo.getKakaoResendSuccCount(); + data[i][11] = vo.getKakaoResendFailCount(); + data[i][12] = vo.getTotPrice(); + + String statusTxt="진행중"; + if ("04".equals(vo.getStatusCd())) { + statusTxt = "예약취소"; // 예약취소 코드 + } else if ("03".equals(vo.getStatusCd())) { + statusTxt = "예약대기"; // 예약대기 코드 ( 예약취소 버튼 노출 ) + } else if ("02".equals(vo.getStatusCd())) { + statusTxt = "완료"; // 완료 코드 + } + + data[i][13] = statusTxt; + } + + int rowNum = 2; // 데이터 시작 행 + for (Object[] rowData : data) { + Row row = sheet.createRow(rowNum++); + for (int col = 0; col < rowData.length; col++) { + cell = row.createCell(col); + + // "내용" 열만 제외하고 가운데 정렬 + if (col == 5) { // 내용 열 + cell.setCellValue((String) rowData[col]); + } else if (rowData[col] instanceof String) { + cell.setCellValue((String) rowData[col]); + cell.setCellStyle(centerStyle); + } else if (rowData[col] instanceof Integer) { + cell.setCellValue((Integer) rowData[col]); + cell.setCellStyle(centerStyle); + } + } + } + + // 파일 다운로드 응답 설정 + String fileName ="발송결과_리스트"; // 저장 파일명 + SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat ( "yyyyMMdd_HHmmss", Locale.KOREA ); + Date currentTime = new Date (); + String mTime = mSimpleDateFormat.format ( currentTime ); + fileName = fileName+"("+mTime+")"; + + response.setHeader("Set-Cookie", "fileDownload=true; path=/"); + response.setHeader("Content-Disposition", String.format("attachment; filename=\""+new String((fileName).getBytes("KSC5601"),"8859_1")+".xlsx")); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + + // 파일 출력 + workbook.write(response.getOutputStream()); + workbook.close(); + + } catch (Exception e) { + // 에러 처리 로직 + response.setHeader("Set-Cookie", "fileDownload=false; path=/"); + response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); + response.setHeader("Content-Type", "text/html; charset=utf-8"); + + try (OutputStream out = response.getOutputStream()) { + byte[] data = "fail..".getBytes(); + out.write(data, 0, data.length); + } catch (Exception ignore) { + ignore.printStackTrace(); + } + } finally { + if (workbook != null) { + try { + workbook.dispose(); // SXSSFWorkbook 임시 파일 제거 + workbook.close(); + } catch (Exception ignore) { + ignore.printStackTrace(); + } + } + } + + } } diff --git a/src/main/java/itn/let/kakao/user/sent/web/KakaoSentController.java b/src/main/java/itn/let/kakao/user/sent/web/KakaoSentController.java index e0871e65..e93b50d9 100644 --- a/src/main/java/itn/let/kakao/user/sent/web/KakaoSentController.java +++ b/src/main/java/itn/let/kakao/user/sent/web/KakaoSentController.java @@ -507,10 +507,7 @@ public class KakaoSentController { @RequestMapping(value= {"/web/mjon/msgsent/kakaoSentExcelDownLoadAjax.do"}) public void kakaoSentExcelDownLoadAjax( KakaoSentVO kakaoSentVO, - RedirectAttributes redirectAttributes, - HttpServletRequest request, - HttpServletResponse response , - ModelMap model) throws Exception{ + HttpServletResponse response) throws Exception{ LoginVO loginVO = EgovUserDetailsHelper.isAuthenticated()? (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser():null; String userId = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getId()); @@ -518,89 +515,91 @@ public class KakaoSentController { if(!userId.equals("")) { kakaoSentVO.setUserId(userId); +// +// String stateType = kakaoSentVO.getStateType(); +// String tabType = kakaoSentVO.getTabType(); +// +// // 메모리에 100개의 행을 유지합니다. 행의 수가 넘으면 디스크에 적습니다. +// SXSSFWorkbook wb = new SXSSFWorkbook(100); +// String fileName ="발송관리 엑셀 리스트"; // 저장 파일명 +// String sheetTitle = "문자 발송 내역" ; // 셀 제목 +// Sheet sheet = wb.createSheet(sheetTitle); +// Cell cell = null; +// Row row = null; +// +// CellStyle style = wb.createCellStyle(); +// style.setBorderBottom(CellStyle.BORDER_THIN); //테두리 두껍게 +// style.setBorderLeft(CellStyle.BORDER_THIN); +// style.setBorderRight(CellStyle.BORDER_THIN); +// style.setBorderTop(CellStyle.BORDER_THIN); +// +// CellStyle styleLastCell = wb.createCellStyle(); +// styleLastCell.setBorderLeft(CellStyle.BORDER_THIN); +// +// // 정렬 +// style.setAlignment(CellStyle.ALIGN_CENTER); //가운데 정렬 +// style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); //높이 가운데 정렬 +// +// Font font = wb.createFont(); +// font.setBoldweight(Font.BOLDWEIGHT_BOLD); //글씨 bold +// +// +// String type = ""; +// String fCnt = ""; +// +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); +// +// try{ +// +// +// kakaoSentVO.setRecordCountPerPage(100000); +// kakaoSentVO.setFirstIndex(0); +// +// if("".equals(kakaoSentVO.getSearchSortCnd())){ //최초조회시 최신것 조회List +// kakaoSentVO.setSearchSortCnd("regdate"); +// kakaoSentVO.setSearchSortOrd("desc"); +// } +// kakaoSentVO.setReserveCYn("N"); +// //발송결과-카카오톡 리스트 불러오기 +// List resultAllSentList = kakaoSentService.selectAllKakaoSentList(kakaoSentVO); +// if("groupList".equals(kakaoSentVO.getListType())) { +// //받는사람(전송건별) +// kakaoSentExcelGroup(resultAllSentList, row, sheet, cell, style, styleLastCell, type, fCnt, sdf); +// }else { +// kakaoSentExcelPrivate(resultAllSentList, row, sheet, cell, style, styleLastCell, type, fCnt, sdf); +// } +// +// +// response.setHeader("Set-Cookie", "fileDownload=true; path=/"); +// SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat ( "yyyyMMdd_HHmmss", Locale.KOREA ); +// Date currentTime = new Date (); +// String mTime = mSimpleDateFormat.format ( currentTime ); +// fileName = fileName+"("+mTime+")"; +// +// response.setHeader("Content-Disposition", String.format("attachment; filename=\""+new String((fileName).getBytes("KSC5601"),"8859_1")+".xlsx")); +// wb.write(response.getOutputStream()); +// }catch(Exception e) { +// response.setHeader("Set-Cookie", "fileDownload=false; path=/"); +// response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); +// response.setHeader("Content-Type","text/html; charset=utf-8"); +// OutputStream out = null; +// try { +// out = response.getOutputStream(); +// byte[] data = new String("fail..").getBytes(); +// out.write(data, 0, data.length); +// } catch(Exception ignore) { +// ignore.printStackTrace(); +// } finally { +// if(out != null) try { out.close(); } catch(Exception ignore) {} +// } +// }finally { +// // 디스크 적었던 임시파일을 제거합니다. +// wb.dispose(); +// try { wb.close(); } catch(Exception ignore) {} +// } + + kakaoSentService.kakaoExcelDown(kakaoSentVO, response); - String stateType = kakaoSentVO.getStateType(); - String tabType = kakaoSentVO.getTabType(); - - // 메모리에 100개의 행을 유지합니다. 행의 수가 넘으면 디스크에 적습니다. - SXSSFWorkbook wb = new SXSSFWorkbook(100); - String fileName ="발송관리 엑셀 리스트"; // 저장 파일명 - String sheetTitle = "문자 발송 내역" ; // 셀 제목 - Sheet sheet = wb.createSheet(sheetTitle); - Cell cell = null; - Row row = null; - - CellStyle style = wb.createCellStyle(); - style.setBorderBottom(CellStyle.BORDER_THIN); //테두리 두껍게 - style.setBorderLeft(CellStyle.BORDER_THIN); - style.setBorderRight(CellStyle.BORDER_THIN); - style.setBorderTop(CellStyle.BORDER_THIN); - - CellStyle styleLastCell = wb.createCellStyle(); - styleLastCell.setBorderLeft(CellStyle.BORDER_THIN); - - // 정렬 - style.setAlignment(CellStyle.ALIGN_CENTER); //가운데 정렬 - style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); //높이 가운데 정렬 - - Font font = wb.createFont(); - font.setBoldweight(Font.BOLDWEIGHT_BOLD); //글씨 bold - - - String type = ""; - String fCnt = ""; - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - - try{ - - - kakaoSentVO.setRecordCountPerPage(100000); - kakaoSentVO.setFirstIndex(0); - - if("".equals(kakaoSentVO.getSearchSortCnd())){ //최초조회시 최신것 조회List - kakaoSentVO.setSearchSortCnd("regdate"); - kakaoSentVO.setSearchSortOrd("desc"); - } - kakaoSentVO.setReserveCYn("N"); - //발송결과-카카오톡 리스트 불러오기 - List resultAllSentList = kakaoSentService.selectAllKakaoSentList(kakaoSentVO); - if("groupList".equals(kakaoSentVO.getListType())) { - //받는사람(전송건별) - kakaoSentExcelGroup(resultAllSentList, row, sheet, cell, style, styleLastCell, type, fCnt, sdf); - }else { - kakaoSentExcelPrivate(resultAllSentList, row, sheet, cell, style, styleLastCell, type, fCnt, sdf); - } - - - response.setHeader("Set-Cookie", "fileDownload=true; path=/"); - SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat ( "yyyyMMdd_HHmmss", Locale.KOREA ); - Date currentTime = new Date (); - String mTime = mSimpleDateFormat.format ( currentTime ); - fileName = fileName+"("+mTime+")"; - - response.setHeader("Content-Disposition", String.format("attachment; filename=\""+new String((fileName).getBytes("KSC5601"),"8859_1")+".xlsx")); - wb.write(response.getOutputStream()); - }catch(Exception e) { - response.setHeader("Set-Cookie", "fileDownload=false; path=/"); - response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); - response.setHeader("Content-Type","text/html; charset=utf-8"); - OutputStream out = null; - try { - out = response.getOutputStream(); - byte[] data = new String("fail..").getBytes(); - out.write(data, 0, data.length); - } catch(Exception ignore) { - ignore.printStackTrace(); - } finally { - if(out != null) try { out.close(); } catch(Exception ignore) {} - } - }finally { - // 디스크 적었던 임시파일을 제거합니다. - wb.dispose(); - try { wb.close(); } catch(Exception ignore) {} - } - }else { response.sendRedirect("/web/kakao/sent/selectKakaoSentView.do"); } diff --git a/src/main/resources/egovframework/sqlmap/let/kakao/MjonKakaoATData_SQL_mysql.xml b/src/main/resources/egovframework/sqlmap/let/kakao/MjonKakaoATData_SQL_mysql.xml index 529d8129..89462577 100644 --- a/src/main/resources/egovframework/sqlmap/let/kakao/MjonKakaoATData_SQL_mysql.xml +++ b/src/main/resources/egovframework/sqlmap/let/kakao/MjonKakaoATData_SQL_mysql.xml @@ -2406,4 +2406,742 @@ reqDate DESC ,sentDate DESC + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/egovframework/sqlmap/let/mjo/kakao/KakaoSent_SQL_Mysql.xml b/src/main/resources/egovframework/sqlmap/let/mjo/kakao/KakaoSent_SQL_Mysql.xml index e7880b70..6c71ee63 100644 --- a/src/main/resources/egovframework/sqlmap/let/mjo/kakao/KakaoSent_SQL_Mysql.xml +++ b/src/main/resources/egovframework/sqlmap/let/mjo/kakao/KakaoSent_SQL_Mysql.xml @@ -1385,7 +1385,8 @@ t1.msgNoticetalkSenderKey, t1.bizKakaoResendYn, t1.atDelayOrgTime, - t1.divideYN + t1.divideYN, + t1.yellowId FROM ( SELECT COUNT(B.USER_ID) OVER() AS totMsgCnt, B.USER_ID AS userId , @@ -1422,10 +1423,12 @@ A.MSG_NOTICETALK_SENDER_KEY AS msgNoticetalkSenderKey, A.BIZ_KAKAO_RESEND_YN AS bizKakaoResendYn, IF(B.AT_DELAY_YN = 'Y' and B.AT_DELAY_COMPLETE_YN = 'N', DATE_ADD(B.REQ_DATE, INTERVAL -30 MINUTE), B.REQ_DATE) AS atDelayOrgTime, - CASE WHEN COUNT(DISTINCT A.REQ_DATE) > 1 THEN 'Y' ELSE 'N' END AS divideYN + CASE WHEN COUNT(DISTINCT A.REQ_DATE) > 1 THEN 'Y' ELSE 'N' END AS divideYN, + C.YELLOW_ID as yellowId FROM MJ_MSG_DATA A JOIN MJ_MSG_GROUP_DATA B ON A.MSG_GROUP_ID = B.MSG_GROUP_ID + left outer join mj_kakao_profile_info C on A.MSG_NOTICETALK_SENDER_KEY = C.SENDER_KEY WHERE ( B.DEL_FLAG = 'N' OR B.DEL_FLAG IS NULL )