요금사용내역 신규 화면 엑셀 다운로드 및 pdf 다운로드 기능 수정

This commit is contained in:
rosewiper 2023-12-26 12:31:24 +09:00
parent 7c713e230a
commit 36704ad454
3 changed files with 552 additions and 17 deletions

View File

@ -2678,6 +2678,270 @@ public class MjonPayController {
return "/web/pay/PayUserSWListAjax";
}
@RequestMapping(value= {"/web/member/pay/PayPdfSWListPopUpAjax.do"})
public String payPrintPdfSWDataAjax(
@ModelAttribute("searchVO") MjonMsgVO mjonMsgVO
, RedirectAttributes redirectAttributes
, ModelMap model) throws Exception {
//로그인 권한정보 불러오기
LoginVO loginVO = EgovUserDetailsHelper.isAuthenticated()? (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser():null;
String userId = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getId());
String userNm = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getName());
mjonMsgVO.setUserId(userId);
model.addAttribute("userNm", userNm);
mjonMsgVO.setFirstIndex(0);
mjonMsgVO.setRecordCountPerPage(10000);
//결제 리스트 정보 불러오기
List<MjonMsgVO> payUserList = mjonMsgDataService.selectPayUserSWList(mjonMsgVO);
model.addAttribute("payUserList", payUserList);
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1;
int day = cal.get(Calendar.DAY_OF_MONTH);
model.addAttribute("year", year);
model.addAttribute("month", month);
model.addAttribute("day", day);
return "web/pay/PrintPayUserSWListPdfPopUp";
}
/**
* 요금 사용내역 엑셀 다운
* @param mjonMsgVO
* @param model
* @return "/web/member/pay/PayUserListAjax.do"
* @throws Exception
*/
@RequestMapping(value= {"/web/member/pay/PayUserSWListExcelDownload.do"})
public void PayUserSWListExcelDownload(@ModelAttribute("searchVO") MjonMsgVO mjonMsgVO,
HttpServletRequest request,
HttpServletResponse response ,
ModelMap model) throws Exception{
// 메모리에 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);
// 정렬
style.setAlignment(CellStyle.ALIGN_CENTER); //가운데 정렬
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); //높이 가운데 정렬
Font font = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD); //글씨 bold
sheet.setColumnWidth(1, 5000); // 칼럼의 조절
sheet.setColumnWidth(4, 10000); // 칼럼의 조절
try{
LoginVO loginVO = (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser();
String userId = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getId());
mjonMsgVO.setUserId(userId);
mjonMsgVO.setRecordCountPerPage(100000);
mjonMsgVO.setFirstIndex(0);
if("".equals(mjonMsgVO.getSearchSortCnd())){ //최초조회시 최신것 조회List
mjonMsgVO.setSearchSortCnd("regDate");
mjonMsgVO.setSearchSortOrd("desc");
}
List<MjonMsgVO> payUserList = mjonMsgDataService.selectPayUserSWList(mjonMsgVO);
{//화면 리스트
row = sheet.createRow(0);
sheet.addMergedRegion(new CellRangeAddress(0,1,0,0)); //셀병합
sheet.addMergedRegion(new CellRangeAddress(0,1,1,1)); //셀병합
sheet.addMergedRegion(new CellRangeAddress(0,1,2,2)); //셀병합
sheet.addMergedRegion(new CellRangeAddress(0,1,3,3)); //셀병합
cell = row.createCell(0);
cell.setCellValue("번호");
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellValue("날짜");
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellValue("문자유형");
cell.setCellStyle(style);
cell = row.createCell(3);
cell.setCellValue("발송건수");
cell.setCellStyle(style);
cell = row.createCell(4);
cell.setCellValue("내용");
cell.setCellStyle(style);
/*cell = row.createCell(5);
cell.setCellValue("충전");
sheet.addMergedRegion(new CellRangeAddress(0,0,5,6)); //셀병합
cell.setCellStyle(style);
cell = row.createCell(6);
cell.setCellStyle(style);*/
cell = row.createCell(5);
cell.setCellValue("사용");
sheet.addMergedRegion(new CellRangeAddress(0,0,5,6)); //셀병합
cell.setCellStyle(style);
cell = row.createCell(6);
cell.setCellStyle(style);
/*cell = row.createCell(9);
cell.setCellValue("잔액");
sheet.addMergedRegion(new CellRangeAddress(0,0,9,10)); //셀병합
cell.setCellStyle(style);
cell = row.createCell(10);
cell.setCellStyle(style);*/
row = sheet.createRow(1);
cell = row.createCell(0);
cell.setCellStyle(style);
cell = row.createCell(1);
cell.setCellStyle(style);
cell = row.createCell(2);
cell.setCellStyle(style);
cell = row.createCell(3);
cell.setCellStyle(style);
cell = row.createCell(4);
cell.setCellStyle(style);
/*cell = row.createCell(5);
cell.setCellValue("충전금");
cell.setCellStyle(style);
cell = row.createCell(6);
cell.setCellValue("포인트");
cell.setCellStyle(style);*/
cell = row.createCell(5);
cell.setCellValue("충전금");
cell.setCellStyle(style);
cell = row.createCell(6);
cell.setCellValue("포인트");
cell.setCellStyle(style);
/*cell = row.createCell(9);
cell.setCellValue("충전금");
cell.setCellStyle(style);
cell = row.createCell(10);
cell.setCellValue("포인트");
cell.setCellStyle(style);*/
DecimalFormat formatter = new DecimalFormat("###,###.##");
String befCash = "";
String befPoint = "";
String totPrice = "";
String thisPoint = "";
for(int i=0; i < payUserList.size(); i++) {
befCash = formatter.format(Double.parseDouble(((MjonMsgVO)payUserList.get(i)).getBefCash()));
befPoint = formatter.format(Double.parseDouble(((MjonMsgVO)payUserList.get(i)).getBefPoint()));
totPrice = formatter.format(Double.parseDouble(((MjonMsgVO)payUserList.get(i)).getTotPrice()));
thisPoint = formatter.format(Double.parseDouble(((MjonMsgVO)payUserList.get(i)).getThisPoint()));
String msgType = "단문";
if(payUserList.get(i).getMsgTypeTxt().equals("6") && payUserList.get(i).getFileCnt().equals("0")) {
msgType = "장문";
}else if(payUserList.get(i).getMsgTypeTxt().equals("6") && !payUserList.get(i).getFileCnt().equals("0")) {
msgType = "그림";
}else if(payUserList.get(i).getMsgTypeTxt().equals("8")) {
msgType = "알림톡";
}else if(payUserList.get(i).getMsgTypeTxt().equals("9")) {
msgType = "친구톡";
}else if(payUserList.get(i).getMsgTypeTxt().equals("fax")) {
msgType = "팩스";
}
int sendCount = ((MjonMsgVO)payUserList.get(i)).getSendCount();
String sendSum = Integer.toString(sendCount);
if(payUserList.get(i).getMsgTypeTxt().equals("fax")) {
sendSum = sendSum+"("+payUserList.get(i).getFileCnt()+")";
}
row = sheet.createRow(i+2);
for(int j=0 ; j < 7 ; j++) {
cell = row.createCell(j);
cell.setCellStyle(style);
if(j==0) cell.setCellValue(i+1); //번호
if(j==1) cell.setCellValue(((MjonMsgVO)payUserList.get(i)).getRegDate()); //결제일시
if(j==2) cell.setCellValue(msgType); //문자유형
if(j==3) cell.setCellValue(((MjonMsgVO)payUserList.get(i)).getSuccSendCnt()); //발송건수
if(j==4) cell.setCellValue(((MjonMsgVO)payUserList.get(i)).getSmsTxt()); //내용
if(j==5) cell.setCellValue(((MjonMsgVO)payUserList.get(i)).getSuccSendPrice()); //충전 - 충전금
if(j==6) cell.setCellValue(0); //충전 - 포인트
/*if(j==7) cell.setCellValue(totPrice); //사용 - 충전금
if(j==8) cell.setCellValue(0); //사용 - 포인트
if(j==9) cell.setCellValue(thisPoint); //잔액 - 충전금
if(j==10) cell.setCellValue(befPoint); //잔액 - 포인트
*/ }
}
}
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

@ -71,7 +71,7 @@ $(document).ready(function(){
var frm = document.listForm;
frm.method = "post";
frm.action = "/web/member/pay/PayUserListExcelDownload.do";
frm.action = "/web/member/pay/PayUserSWListExcelDownload.do";
frm.submit();
});
});
@ -185,7 +185,7 @@ function fnShowPdfPrintPopup(){
$("#listForm").attr("target","msgSentPdfPrint");
window.open('', 'msgSentPdfPrint', 'width='+ popup_wid +', height='+ popup_ht +', left=' + popup_left + ', top='+ popup_top +',scrollbars=1');
$("#listForm").attr({"action":"/web/member/pay/PayPdfListPopUpAjax.do", "method":"post"}).submit();
$("#listForm").attr({"action":"/web/member/pay/PayPdfSWListPopUpAjax.do", "method":"post"}).submit();
}
//체크박스 전체선택/해제
@ -219,9 +219,9 @@ function fnShowPdfPrintPopup(){
<colgroup>
<%-- <col style="width: 5%;"> --%>
<col style="width: *%;">
<col style="width: 9%;">
<col style="width: 9%;">
<col style="width: 9%;">
<col style="width: 15%;">
<col style="width: 15%;">
<col style="width: 15%;">
<col style="width: 20%;">
<col style="width: 20%;">
<%-- <col style="width: 10%;">
@ -248,18 +248,18 @@ function fnShowPdfPrintPopup(){
</div>
</th>
<th rowspan="2">내용</th>
<th rowspan="2">발송건수<br/> 성공 / 실패</th>
<th rowspan="2">발송건수</th>
<!-- <th colspan="2">충전</th>
<th colspan="2">사용</th>
<th colspan="2">잔액</th> -->
<th>사용</th>
<th>반환(실패)</th>
<th colspan="2">사용</th>
<!-- <th>반환(실패)</th> -->
<!-- <th colspan="2">잔액</th> -->
</tr>
<tr>
<th>캐시</th>
<!-- <th>포인트</th> -->
<th>캐시</th>
<th>포인트</th>
<!-- <th>캐시</th> -->
<!-- <th>포인트</th> -->
<!-- <th>충전금</th>
<th>포인트</th> -->
@ -337,18 +337,19 @@ function fnShowPdfPrintPopup(){
<c:out value="${succCash}"/>
</p>
</td>
<%-- <td>
<p>
<fmt:formatNumber type="number" maxFractionDigits="3" value="${payUserInfo.befPoint}" var="befPoint" />
<c:out value="${befPoint}"/>
</p>
</td> --%>
<td>
<p>
<%-- <fmt:formatNumber type="number" maxFractionDigits="3" value="${payUserInfo.befPoint}" var="befPoint" />
<c:out value="${befPoint}"/> --%>
0
</p>
</td>
<%-- <td>
<p class="fwRg c_002c9a">
<fmt:formatNumber type="number" maxFractionDigits="3" value="${payUserInfo.failSendPrice}" var="failPrice" />
<c:out value="${failPrice}"/>
</p>
</td>
</td> --%>
<!-- <td>
<p class="fwRg c_002c9a">
0

View File

@ -0,0 +1,270 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page import="itn.com.cmm.LoginVO" %>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>요금 사용내역</title>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@100;300;400;500;700;900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/publish/css/reset.css">
<link rel="stylesheet" href="/publish/css/common.css">
<link rel="stylesheet" href="/publish/css/estimate.css">
<link rel="stylesheet" href="/publish/css/font.css">
<link rel="stylesheet" href="/publish/css/button.css">
<script type="text/javascript" src="/publish/js/jquery-3.5.0.js"></script>
<script type="text/javascript" src="/js/jsPdf/bluebird.min.js"></script>
<script type="text/javascript" src="/js/jsPdf/html2canvas.js"></script>
<script type="text/javascript" src="/js/jsPdf/jspdf.min.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function() {
$('.savePdf').click(function() { // pdf저장 button id
var HTML_Width = $(".pdfPage").width();
var HTML_Height = $(".pdfPage").height();
var top_left_margin = 15;
var PDF_Width = HTML_Width+(top_left_margin*2);
var PDF_Height = (PDF_Width*1.5)+(top_left_margin*2);
var canvas_image_width = HTML_Width;
var canvas_image_height = HTML_Height;
var totalPDFPages = Math.ceil(HTML_Height/PDF_Height)-1;
//이미지 생성시 스크롤이 있는경우 스크롤을 상단으로 이동 시킨 후 캡쳐를 진행하도록 한다.
html2canvas($(".pdfPage")[0],{allowTaint:true,
scrollX: 0,
scrollY: -window.scrollY,
windowWidth: document.documentElement.offsetWidth,
windowHeight: document.documentElement.offsetHeight}).then(function(canvas) {
canvas.getContext('2d');
var imgData = canvas.toDataURL("image/jpeg", 1.0);
var pdf = new jsPDF('p', 'pt', [PDF_Width, PDF_Height]);
pdf.addImage(imgData, 'JPG', top_left_margin, top_left_margin,canvas_image_width,canvas_image_height);
//1페이지 이상인 경우 추가 페이지 처리
if(totalPDFPages >= 1){
for (var i = 1; i <= totalPDFPages; i++) {
pdf.addPage(PDF_Width, PDF_Height);
pdf.addImage(imgData, 'JPG', top_left_margin, -(PDF_Height*i)+(top_left_margin*4),canvas_image_width,canvas_image_height);
}
}
var strDate = nowDate();
pdf.save('요금 사용내역_' + strDate + '.pdf');
});
});
});
//현재 날짜를 반환해주는 함수
function nowDate(){
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth() + 1; //월은 0부터 시작하므로 1을 더해준다.
var day = today.getDate();
var nowDate = year + "" + month+ "" + day;
return nowDate;
}
</script>
<body>
<!-- 견적서 -->
<div class="estimate_wrap pdfPage" id="pdfPage">
<div class="estimate">
<div class="est_head clearfix">
<img src="/publish/images/CI.png" alt="문자온 CI">
<div class="clearfix">
<p>(12248) 경기도 남양주시 다산순환로 20, A동 735호(다산동, 현대프리미어캠퍼스)</p>
<p>TEL 010-8432-9333</p>
</div>
</div>
<div class="est_body">
<h2>요금 사용내역</h2>
<div class="cont1 tb_ver2">
<div>
<table class="est_table">
<caption>발신자 정보</caption>
<colgroup>
<col style="width: 50px;">
<col style="width: auto;">
</colgroup>
<tbody>
<tr>
<th></th>
<td colspan="2" class="colspan">
<span><c:out value="${userNm}"/></span> &nbsp;님의 사용내역을 아래와 같이 확인합니다.
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="cont3">
<div class="est_table2_wrap">
<table class="est_table2">
<caption>사용날짜, 문자유형, 문자내용, 충전 충전금, 충전 포인트, 사용 충전금, 사용 포인트, 잔액 충전금, 잔액 포인트를 제공하는 표</caption>
<colgroup>
<col style="width: 15%;">
<col style="width: 10%;">
<col style="width: 15%;">
<col style="width: 15%;">
<col style="width: 10%;">
<%-- <col style="width: 10%;"> --%>
<%-- <col style="width: 15%;">
<col style="width: 10%;"> --%>
</colgroup>
<thead>
<tr>
<th><span style="position:relative;display:block;top:17px;background:#f2f2f2;">날짜</span></th>
<th><span style="position:relative;display:block;top:17px;background:#f2f2f2;">문자유형</span></th>
<th><span style="position:relative;display:block;top:17px;background:#f2f2f2;">발송건수</span></th>
<!-- <th colspan="2">충전</th> -->
<th colspan="2">사용</th>
<!-- <th colspan="2">잔액</th> -->
</tr>
<tr>
<th></th>
<th></th>
<th></th>
<th>충전금</th>
<th>포인트</th>
<!-- <th>충전금</th>
<th>포인트</th>
<th>충전금</th>
<th>포인트</th> -->
</tr>
</thead>
<tbody>
<c:choose>
<c:when test="${not empty payUserList}">
<c:forEach var="payUserInfo" items="${payUserList}" varStatus="status">
<tr>
<td>
<c:out value="${payUserInfo.regDate}"/>
</td>
<td>
<p style="text-align:center;">
<c:choose>
<c:when test="${payUserInfo.msgTypeTxt eq '6' && payUserInfo.fileCnt eq 0 }">
장문
</c:when>
<c:when test="${payUserInfo.msgTypeTxt eq '6' && payUserInfo.fileCnt ne 0 }">
그림
</c:when>
<c:when test="${payUserInfo.msgTypeTxt eq '8'}">
알림톡
</c:when>
<c:when test="${payUserInfo.msgTypeTxt eq '9'}">
친구톡
</c:when>
<c:when test="${payUserInfo.msgTypeTxt eq 'fax'}">
팩스
</c:when>
<c:otherwise>
단문
</c:otherwise>
</c:choose>
</p>
</td>
<td>
<c:out value="${payUserInfo.succSendCnt}"/>
<c:if test="${payUserInfo.msgTypeTxt eq 'fax'}">
(<c:out value="${payUserInfo.fileCnt}"/>)
</c:if>
<%-- <c:out value="${payUserInfo.sendCount}"/>
<c:if test="${payUserInfo.msgTypeTxt eq 'fax'}">
(<c:out value="${payUserInfo.fileCnt}"/>)
</c:if> --%>
</td>
<%-- <td>
<p>
<fmt:formatNumber type="number" maxFractionDigits="3" value="${payUserInfo.befCash}" var="befCash" />
<c:out value="${befCash}"/>
</p>
</td>
<td>
<p>
<c:out value="${payUserInfo.befPoint}"/>
</p>
</td> --%>
<td>
<p class="fwRg c_002c9a" style="text-align:center;">
<fmt:formatNumber type="number" maxFractionDigits="3" value="${payUserInfo.succSendPrice}" var="succCash" />
<c:out value="${succCash}"/>
</p>
</td>
<td>
<p class="fwRg c_002c9a" style="text-align:center;">
0
</p>
</td>
<%-- <td>
<p class="fwRg c_222">
<fmt:formatNumber type="number" maxFractionDigits="3" value="${payUserInfo.thisPoint}" var="thisPoint" />
<c:out value="${thisPoint}"/>
</p>
</td>
<td>
<p class="fwRg c_222">
<c:out value="${payUserInfo.befPoint}"/>
</p>
</td> --%>
</tr>
</c:forEach>
</c:when>
<c:otherwise>
<tr>
<td colspan="5">
사용내역이 없습니다.
</td>
</tr>
</c:otherwise>
</c:choose>
</tbody>
</table>
</div>
</div>
<div class="cont4">
<table class="est_table">
<caption>공급가액, 부가세, 총 결제금액에 대한 표</caption>
<colgroup>
<col style="width: 64px;">
<col style="width: auto;">
</colgroup>
<tbody>
<tr>
<th>대표번호</th>
<td>010-8432-9333</td>
</tr>
<tr>
<th>이메일</th>
<td>help@iten.co.kr</td>
</tr>
</tbody>
</table>
</div>
<div class="cont5">
<p><span><c:out value="${year}"/></span> 년&nbsp;&nbsp;<span><c:out value="${month}"/></span> 월&nbsp;&nbsp;<span><c:out value="${day}"/></span> 일</p>
<div>
<span>주식회사 아이티앤 대표이사</span>
<span>유&nbsp;인&nbsp;식</span>
<span class="big_stamp"><img src="/publish/images/content/big_stamp.png"></span>
</div>
</div>
</div>
</div>
</div>
<div class="est_btn_wrap" id="est_btn_wrap">
<button type="button" class="btnType savePdf" ><i class="print_img"></i>pdf저장</button>
</div>
<!--// 견적서 -->
</body>
</html>