관리자 문자/알림톡 발송결과 코드 엑셀다운로드 기능 추가

This commit is contained in:
rosewiper 2025-05-12 10:14:34 +09:00
parent 6ae41121dd
commit e3323e30f9
4 changed files with 238 additions and 0 deletions

View File

@ -1,10 +1,21 @@
package itn.let.kakao.admin.kakaoAt.web;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
@ -25,6 +36,17 @@ public class MjonKakaoSendResultController {
@Resource(name = "mjonMsgService")
private MjonMsgService mjonMsgService;
//카카오알림톡 발송 결과 코드 리스트 엑셀 다운로드
private String[][] kakaoResultCodeExcelValue ={
{"0" ,"번호" , "1" , "" },
{"1", "전송사" , "IHT" , ""},
{"2", "결과코드1" , "결과코드", ""},
{"3", "결과코드2" , "결과코드 ", ""},
{"4", "코드설명" , "코드 내용", ""},
{"5", "코드이름" , "코드이름", ""},
{"6", "등록일자" , "2021-06-01 19:05:12", ""},
};
/**
* 알림톡 발송 결과 리스트
* @param searchVO
@ -61,6 +83,101 @@ public class MjonKakaoSendResultController {
}
/**
* 카카오 알림톡 발송 결과 코드 엑셀 다운로드
* @param MjonMsgResultCodeVO
* @param model
* @return ""
* @throws Exception
*/
@RequestMapping(value= {"/uss/ion/kakaoat/sendresult/KakaoResultCodeExcelDownload.do"})
public void kakaoResultCodeExcelDownload( MjonMsgResultCodeVO mjonMsgResultCodeVO,
HttpServletRequest request,
HttpServletResponse response ,
ModelMap model) throws Exception {
mjonMsgResultCodeVO.setRecordCountPerPage(100000);
mjonMsgResultCodeVO.setFirstIndex(0);
LoginVO loginVO = (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser();
if(null != loginVO && !"super".equals(loginVO.getSiteId())){
mjonMsgResultCodeVO.setSiteId(loginVO.getSiteId());
}
// 메모리에 100개의 행을 유지합니다. 행의 수가 넘으면 디스크에 적습니다.
SXSSFWorkbook wb = new SXSSFWorkbook(100);
CellStyle style = wb.createCellStyle();
style.setBorderBottom(CellStyle.BORDER_THIN); //테두리 두껍게
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setBorderRight(CellStyle.BORDER_THIN);
style.setBorderTop(CellStyle.BORDER_THIN);
Font font = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD); //글씨 bold
Cell cell = null;
Row row = null;
String fileName ="카카오 알림톡 발송 결과 코드 리스트(중계사별)";
String sheetTitle = "";
try{
//List<MjonMsgVO> resultList = mjonMsgService.selectMjonMsgGroupList(mjonMsgVO);
mjonMsgResultCodeVO.setAgentCode("04");
List<MjonMsgResultCodeVO> resultList = mjonMsgService.selectKakaoResultCodeListPageing(mjonMsgResultCodeVO);
{ //화면 리스트
sheetTitle = "카카오 알림톡 발송 결과 코드 리스트(중계사별)" ; //제목
Sheet sheet = wb.createSheet(sheetTitle);
row = sheet.createRow(0);
for(int i=0 ; i < kakaoResultCodeExcelValue.length ; i++) {
cell = row.createCell(i);
cell.setCellStyle(style);
cell.setCellValue(kakaoResultCodeExcelValue[i][1]);
}
for(int i=0; i < resultList.size(); i++){
row = sheet.createRow(i+1);
for(int j=0 ; j < kakaoResultCodeExcelValue.length ; j++) {
cell = row.createCell(j);
cell.setCellStyle(style);
if(j==0) cell.setCellValue(i+1); //번호
if(j==1) cell.setCellValue(resultList.get(i).getAgentCodeTxt()); //전송사 코드
if(j==2) cell.setCellValue(resultList.get(i).getResultCode()); //결과코드1
if(j==3) cell.setCellValue(resultList.get(i).getResultCode2()); //결과코드2
if(j==4) cell.setCellValue(resultList.get(i).getResultCodeTxt()); //코드설명
if(j==5) cell.setCellValue(resultList.get(i).getResultCodeNm()); //코드이름
if(j==6) cell.setCellValue(resultList.get(i).getLastUpdtPnttm()); //등록일자
}
}
}
response.setHeader("Set-Cookie", "fileDownload=true; path=/");
SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat ( "yyyy_MM_dd_HH_mm_ss", 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) {}
}
}
/**
* 카카오 알림톡 발송 결과 코드 수정
* @param MjonMsgResultCodeVO

View File

@ -211,6 +211,17 @@ public class MjonMsgController {
{"8", "발송결과" , "", ""},
{"9", "전송사" , "", ""}
};
//문자 발송 결과 코드 리스트 엑셀 다운로드
private String[][] msgResultCodeExcelValue ={
{"0" ,"번호" , "1" , "" },
{"1", "전송사" , "IHT" , ""},
{"2", "결과코드1" , "결과코드", ""},
{"3", "결과코드2" , "결과코드 ", ""},
{"4", "코드설명" , "코드 내용", ""},
{"5", "코드이름" , "코드이름", ""},
{"6", "등록일자" , "2021-06-01 19:05:12", ""},
};
/**
@ -2980,6 +2991,100 @@ public class MjonMsgController {
return "/uss/ion/msg/MsgResultCodeList"; //문자결과 리스트
}
/**
* 문자발송 결과 코드 엑셀 다운로드
* @param MjonMsgResultCodeVO
* @param model
* @return ""
* @throws Exception
*/
@RequestMapping(value= {"/uss/ion/msg/MsgResultCodeExcelDownload.do"})
public void msgResultCodeExcelDownload( MjonMsgResultCodeVO mjonMsgResultCodeVO,
HttpServletRequest request,
HttpServletResponse response ,
ModelMap model) throws Exception {
mjonMsgResultCodeVO.setRecordCountPerPage(100000);
mjonMsgResultCodeVO.setFirstIndex(0);
LoginVO loginVO = (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser();
if(null != loginVO && !"super".equals(loginVO.getSiteId())){
mjonMsgResultCodeVO.setSiteId(loginVO.getSiteId());
}
// 메모리에 100개의 행을 유지합니다. 행의 수가 넘으면 디스크에 적습니다.
SXSSFWorkbook wb = new SXSSFWorkbook(100);
CellStyle style = wb.createCellStyle();
style.setBorderBottom(CellStyle.BORDER_THIN); //테두리 두껍게
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setBorderRight(CellStyle.BORDER_THIN);
style.setBorderTop(CellStyle.BORDER_THIN);
Font font = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD); //글씨 bold
Cell cell = null;
Row row = null;
String fileName ="문자 발송 결과 코드 리스트(중계사별)";
String sheetTitle = "";
try{
//List<MjonMsgVO> resultList = mjonMsgService.selectMjonMsgGroupList(mjonMsgVO);
List<MjonMsgResultCodeVO> resultList = mjonMsgService.selectMsgResultCodeListPageing(mjonMsgResultCodeVO);
{ //화면 리스트
sheetTitle = "문자 발송 결과 코드 리스트(중계사별)" ; //제목
Sheet sheet = wb.createSheet(sheetTitle);
row = sheet.createRow(0);
for(int i=0 ; i < msgResultCodeExcelValue.length ; i++) {
cell = row.createCell(i);
cell.setCellStyle(style);
cell.setCellValue(msgResultCodeExcelValue[i][1]);
}
for(int i=0; i < resultList.size(); i++){
row = sheet.createRow(i+1);
for(int j=0 ; j < msgResultCodeExcelValue.length ; j++) {
cell = row.createCell(j);
cell.setCellStyle(style);
if(j==0) cell.setCellValue(i+1); //번호
if(j==1) cell.setCellValue(resultList.get(i).getAgentCodeTxt()); //전송사 코드
if(j==2) cell.setCellValue(resultList.get(i).getResultCode()); //결과코드1
if(j==3) cell.setCellValue(resultList.get(i).getResultCode2()); //결과코드2
if(j==4) cell.setCellValue(resultList.get(i).getResultCodeTxt()); //코드설명
if(j==5) cell.setCellValue(resultList.get(i).getResultCodeNm()); //코드이름
if(j==6) cell.setCellValue(resultList.get(i).getLastUpdtPnttm()); //등록일자
}
}
}
response.setHeader("Set-Cookie", "fileDownload=true; path=/");
SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat ( "yyyy_MM_dd_HH_mm_ss", 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) {}
}
}
/**
* 전송사 발송 결과 코드 등록 화면

View File

@ -52,6 +52,13 @@ function fn_modify(resultId){
frm.submit();
}
//엑셀 다운로드
function rstCodeListExcelDownload(){
document.listForm.method = "post";
document.listForm.action = "<c:url value='/uss/ion/kakaoat/sendresult/KakaoResultCodeExcelDownload.do'/>";
document.listForm.submit();
}
</script>
<style>
@ -97,6 +104,7 @@ function fn_modify(resultId){
<p class="tType5">총 <span class="tType4 c_456ded fwBold"><fmt:formatNumber value="${paginationInfo.totalRecordCount}" pattern="#,###" /></span>건</p>
<div class="rightWrap">
<!-- <input type="button" class="printBtn"> -->
<input type="button" class="excelBtn" onclick="javascript:rstCodeListExcelDownload();" style="cursor:pointer;">
<select name="pageUnit" id="pageUnit" class="select" title="검색조건선택" onchange="linkPage(1);">
<option value='10' <c:if test="${searchVO.pageUnit == '10' or searchVO.pageUnit == ''}">selected</c:if>>10줄</option>
<option value='20' <c:if test="${searchVO.pageUnit == '20'}">selected</c:if>>20줄</option>

View File

@ -52,6 +52,13 @@ function fn_modify(resultId){
frm.submit();
}
//엑셀 다운로드
function rstCodeListExcelDownload(){
document.listForm.method = "post";
document.listForm.action = "<c:url value='/uss/ion/msg/MsgResultCodeExcelDownload.do'/>";
document.listForm.submit();
}
</script>
<style>
@ -97,6 +104,7 @@ function fn_modify(resultId){
<p class="tType5">총 <span class="tType4 c_456ded fwBold"><fmt:formatNumber value="${paginationInfo.totalRecordCount}" pattern="#,###" /></span>건</p>
<div class="rightWrap">
<!-- <input type="button" class="printBtn"> -->
<input type="button" class="excelBtn" onclick="javascript:rstCodeListExcelDownload();" style="cursor:pointer;">
<select name="pageUnit" id="pageUnit" class="select" title="검색조건선택" onchange="linkPage(1);">
<option value='10' <c:if test="${searchVO.pageUnit == '10' or searchVO.pageUnit == ''}">selected</c:if>>10줄</option>
<option value='20' <c:if test="${searchVO.pageUnit == '20'}">selected</c:if>>20줄</option>