카톡전송리스트 - 엑셀다운로드
This commit is contained in:
parent
5ec476e721
commit
529c786a0b
@ -228,7 +228,15 @@ public class MjonKakaoATServiceImpl extends EgovAbstractServiceImpl implements M
|
||||
} catch (Exception e) {
|
||||
System.out.println("selectMjonKakaoATGroupCompleteByUserList ServiceImpl Error ::: " + e);
|
||||
}
|
||||
|
||||
|
||||
// 리스트 치환 부분
|
||||
result.stream().forEach(t->{
|
||||
if("A".equals(t.getSendKind())) {
|
||||
t.setSendKind("API");
|
||||
}else {
|
||||
t.setSendKind("WEB");
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1,11 +1,22 @@
|
||||
package itn.let.kakao.admin.kakaoAt.web;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
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.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@ -139,16 +150,6 @@ public class MjonKakaoATController {
|
||||
resultList = mjonKakaoATService.selectMjonKakaoATGroupCompleteByUserList_advc(kakaoVO);
|
||||
int totCnt = mjonKakaoATService.selectMjonKakaoATGroupCompleteByUserListCnt_advc(kakaoVO);
|
||||
|
||||
|
||||
// 리스트 치환 부분
|
||||
resultList.stream().forEach(t->{
|
||||
if("A".equals(t.getSendKind())) {
|
||||
t.setSendKind("API");
|
||||
}else {
|
||||
t.setSendKind("WEB");
|
||||
}
|
||||
});
|
||||
|
||||
model.addAttribute("resultList", resultList);
|
||||
|
||||
//알림톡발송 실패 결과 코드정보 리스트 불러오기
|
||||
@ -173,6 +174,109 @@ public class MjonKakaoATController {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//문자 전송 리스트(전체) 엑셀 다운로드
|
||||
@RequestMapping(value= {"/uss/ion/kakaoat/SendMsgExcelDownload.do"})
|
||||
public void sendMsgExcelDownload( KakaoVO kakaoVO,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response ,
|
||||
ModelMap model) throws Exception {
|
||||
|
||||
kakaoVO.setRecordCountPerPage(kakaoVO.getPageUnit());
|
||||
kakaoVO.setFirstIndex(0);
|
||||
LoginVO loginVO = (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser();
|
||||
if(null != loginVO && !"super".equals(loginVO.getSiteId())){
|
||||
kakaoVO.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<KakaoVO> resultList = mjonKakaoATService.selectMjonKakaoATGroupCompleteByUserList_advc(kakaoVO);
|
||||
{ //화면 리스트
|
||||
sheetTitle = "문자 전송 리스트(전체)" ; //제목
|
||||
Sheet sheet = wb.createSheet(sheetTitle);
|
||||
row = sheet.createRow(0);
|
||||
for(int i=0 ; i < sendKakaoExcelValue.length ; i++) {
|
||||
cell = row.createCell(i);
|
||||
cell.setCellStyle(style);
|
||||
cell.setCellValue(sendKakaoExcelValue[i][1]);
|
||||
}
|
||||
|
||||
for(int i=0; i < resultList.size(); i++){
|
||||
row = sheet.createRow(i+1);
|
||||
for(int j=0 ; j < sendKakaoExcelValue.length ; j++) {
|
||||
cell = row.createCell(j);
|
||||
cell.setCellStyle(style);
|
||||
|
||||
if(j==0) cell.setCellValue(i+1); //번호
|
||||
if(j==1) cell.setCellValue(((KakaoVO)resultList.get(i)).getUserId()); //아이디
|
||||
if(j==2) cell.setCellValue(((KakaoVO)resultList.get(i)).getMsgGroupCnt()); //발송건수
|
||||
if(j==3) cell.setCellValue(((KakaoVO)resultList.get(i)).getReqDate() ); //요청시간
|
||||
if(j==4) cell.setCellValue("Y".equals(((KakaoVO)resultList.get(i)).getReserveYn())? "예약" : "즉시" ); //예약
|
||||
if(j==5) cell.setCellValue(((KakaoVO)resultList.get(i)).getSmsTxt()); //문자내용
|
||||
if(j==6) cell.setCellValue(((KakaoVO)resultList.get(i)).getMsgTypeName()); //메시지타입
|
||||
if(j==7) cell.setCellValue(((KakaoVO)resultList.get(i)).getSendKind()); //방식
|
||||
}
|
||||
}
|
||||
}
|
||||
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) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//배열 정의{"컬럼순차번호, 컬럼이름, 컬럼내용, 컬럼이름에 붙여야할 내용(엑셀코드양식다운로드시 필요)"}
|
||||
private String[][] sendKakaoExcelValue ={
|
||||
{"0" ,"번호" , "1" , "" },
|
||||
{"1", "아이디" , "itn" , ""},
|
||||
{"2", "발송건수" , "3", ""},
|
||||
{"3", "요청시간" , "2021-06-01 19:05:12", ""},
|
||||
{"4", "예약" , "즉시", ""},
|
||||
{"5", "내용" , "카카오 내용", ""},
|
||||
{"8", "메시지타입" , "알림톡", ""},
|
||||
{"9", "방식" , "API", ""}
|
||||
};
|
||||
|
||||
// 알림톡 금일/금월/금년 통계
|
||||
@RequestMapping(value = "/uss/umt/user/selectMjonKakaoAtThisSumAjax.do")
|
||||
public ModelAndView MjonKakaoAtThisSumAjax(
|
||||
|
||||
@ -525,6 +525,16 @@ function fn_SpamMberUpdt(userId, p_mberSttus, p_smiMemo, p_confirm_msg) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//엑셀 다운로드
|
||||
function sendExcelDownload(){
|
||||
var frm = document.listForm;
|
||||
frm.method = "post";
|
||||
frm.action = "<c:url value='/uss/ion/kakaoat/SendMsgExcelDownload.do'/>";
|
||||
frm.submit();
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<style>
|
||||
.calBtn{
|
||||
@ -637,6 +647,7 @@ function fn_SpamMberUpdt(userId, p_mberSttus, p_smiMemo, p_confirm_msg) {
|
||||
<p class="tType5">총 <span class="tType4 c_456ded fwBold"><fmt:formatNumber value="${paginationInfo.totalRecordCount}" pattern="#,###" /></span>건<span id="mjonKakaoAtThisSumArea"></span>
|
||||
</p>
|
||||
<div class="rightWrap">
|
||||
<input type="button" class="excelBtn" onclick="javascript:sendExcelDownload();">
|
||||
<!-- <input type="button" class="excelBtn" onclick="javascript:sendMsgExcelDownload();"> -->
|
||||
<!-- <input type="button" class="printBtn"> -->
|
||||
<select name="pageUnit" id="pageUnit" class="select" title="검색조건선택" onchange="linkPage(1);">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user