File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
2024-11-14
File name
Commit message
Commit date
File name
Commit message
Commit date
2024-07-22
package itn.let.mjo.pay.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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import egovframework.rte.fdl.security.userdetails.util.EgovUserDetailsHelper;
import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
import itn.com.cmm.EgovMessageSource;
import itn.com.cmm.LoginVO;
import itn.com.cmm.util.RedirectUrlMaker;
import itn.com.utl.fcc.service.EgovStringUtil;
import itn.let.mjo.pay.service.MjonPayService;
import itn.let.mjo.pay.service.MjonPrePayService;
import itn.let.mjo.pay.service.MjonPrePayVO;
import itn.let.uss.umt.service.EgovUserManageService;
@Controller
public class MjonPrePayController {
private static final Logger LOGGER = LoggerFactory.getLogger(MjonPrePayController.class);
@Resource(name = "mjonPayService")
private MjonPayService mjonPayService;
@Resource(name = "mjonPrePayService")
private MjonPrePayService mjonPrePayService;
/** EgovMessageSource */
@Resource(name="egovMessageSource")
EgovMessageSource egovMessageSource;
/** userManageService */
@Resource(name = "userManageService")
private EgovUserManageService userManageService;
//배열 정의{"컬럼순차번호, 컬럼이름, 컬럼내용, 컬럼이름에 붙여야할 내용(엑셀코드양식다운로드시 필요)"}
private String[][] sendPrePayExcelValue ={
{"0" ,"번호" , "1" , "" },
{"1", "아이디" , "아이디" , ""},
{"2", "전송사" , "개인전용계좌", ""},
{"3", "선결제일시" , "2021-06-08 11:05:38", ""},
{"4", "결제금액" , "1000", ""},
{"5", "등록일자" , "2021-06-08 11:05:38", ""},
} ;
/**
* 결제 리스트
* @param searchVO
* @param model
* @return "/uss/ion/msg/SendNumberList"
* @throws Exception
*/
@RequestMapping(value= {"/uss/ion/pay/PrePayList.do"})
public String selectPrePayList(@ModelAttribute("searchVO") MjonPrePayVO mjonPrePayVO,
HttpServletRequest request,
ModelMap model) throws Exception{
String pattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE) ;
// 미인증 사용자에 대한 보안처리
Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
if(!isAuthenticated) {
model.addAttribute("message", egovMessageSource.getMessage("fail.common.login"));
return "uat/uia/EgovLoginUsr";
}
/** pageing */
PaginationInfo paginationInfo = new PaginationInfo();
paginationInfo.setCurrentPageNo(mjonPrePayVO.getPageIndex());
paginationInfo.setRecordCountPerPage(mjonPrePayVO.getPageUnit());
paginationInfo.setPageSize(mjonPrePayVO.getPageSize());
mjonPrePayVO.setFirstIndex(paginationInfo.getFirstRecordIndex());
mjonPrePayVO.setLastIndex(paginationInfo.getLastRecordIndex());
mjonPrePayVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());
if("".equals(mjonPrePayVO.getSearchSortCnd())){ //최초조회시 최신것 조회List
mjonPrePayVO.setSearchSortCnd("prePayDate");
mjonPrePayVO.setSearchSortOrd("desc");
}
List<MjonPrePayVO> resultList = mjonPrePayService.selectPrePayList(mjonPrePayVO);
model.addAttribute("resultList", resultList);
model.addAttribute("totSumPrice", resultList.size() > 0 ? ((MjonPrePayVO)resultList.get(0)).getTotSum() : 0);
paginationInfo.setTotalRecordCount(resultList.size() > 0 ? ((MjonPrePayVO)resultList.get(0)).getTotCnt() : 0);
model.addAttribute("paginationInfo", paginationInfo);
return "/uss/ion/pay/prePay/PrePayList";
}
/**
* 선결제 등록화면
* @param searchVO
* @param model
* @return "/uss/ion/pay/PrePayRegist.do"
* @throws Exception
*/
@RequestMapping(value= {"/uss/ion/pay/PrePayRegist.do"})
public String PrePayRegist(@ModelAttribute("searchVO") MjonPrePayVO mjonPrePayVO,
HttpServletRequest request,
ModelMap model) throws Exception{
// 미인증 사용자에 대한 보안처리
Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
if(!isAuthenticated) {
model.addAttribute("message", egovMessageSource.getMessage("fail.common.login"));
return "uat/uia/EgovLoginUsr";
}
return "/uss/ion/pay/prePay/PrePayRegist";
}
/**
* 선결제 등록 처리
* @param searchVO
* @param model
* @return "uss/ion/pay/insertPrePayRegistAjax"
* @throws Exception
*/
@RequestMapping(value= {"/uss/ion/pay/insertPrePayRegistAjax.do"})
public ModelAndView insertPrePayRegistAjax(@ModelAttribute("searchVO") MjonPrePayVO mjonPrePayVO,
HttpServletRequest request,
ModelMap model) throws Exception{
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("jsonView");
// 미인증 사용자에 대한 보안처리
Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
if(!isAuthenticated) {
modelAndView.addObject("result", "loginFail");
modelAndView.addObject("message", "로그인이 필요합니다.");
return modelAndView;
}
try {
LoginVO loginVO = EgovUserDetailsHelper.isAuthenticated()? (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser():null;
String userId = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getId());
String mberId = mjonPrePayVO.getMberId();
mjonPrePayVO.setFrstRegisterId(userId);
mjonPrePayVO.setLastUpdusrId(userId);
if(mjonPrePayVO.getAmt().length() == 0
|| mjonPrePayVO.getMberId().length() == 0
|| mjonPrePayVO.getPrePayDate().length() == 0) {
modelAndView.addObject("result", "dataFail");
modelAndView.addObject("message", "필수 입력값을 확인해 주세요.");
return modelAndView;
}
int mberCnt = mjonPrePayService.selectBLineMberCnt(mberId);
if(mberCnt > 0) {
int resultCnt = mjonPrePayService.insertPrePayInfo(mjonPrePayVO);
if(resultCnt > 0) {
modelAndView.addObject("result", "success");
modelAndView.addObject("message", "등록이 완료되었습니다.");
}else {
modelAndView.addObject("result", "insertFail");
modelAndView.addObject("message", "선결제 정보 등록 중 오류가 발생하였습니다.");
return modelAndView;
}
}else {
modelAndView.addObject("result", "mberFail");
modelAndView.addObject("message", mberId + "의 회원정보를 찾을 수 없습니다.");
return modelAndView;
}
} catch (Exception e) {
System.out.println("++++++++++++++ insertPrePayRegistAjax Controller Error !!! " + e);
modelAndView.addObject("result", "Error");
modelAndView.addObject("message", "등록 중 오류가 발생하였습니다.");
return modelAndView;
}
return modelAndView;
}
/**
* 선결제 삭제 처리
* @param searchVO
* @param model
* @return "/uss/ion/pay/PrePayDelete.do"
* @throws Exception
*/
@RequestMapping(value = {"/uss/ion/pay/PrePayDelete.do"})
public String deleteCash(
@RequestParam("chkEach") String[] chkEach,
@ModelAttribute("searchVO") MjonPrePayVO mjonPrePayVO,
HttpServletRequest request , RedirectAttributes redirectAttributes,
Model model) throws Exception {
try {
LoginVO loginVO = (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser();
String userId = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getId());
if(userId == "") {
redirectAttributes.addFlashAttribute("message", egovMessageSource.getMessage("info.user.login"));
RedirectUrlMaker redirectUrlMaker = new RedirectUrlMaker("/uat/uia/EgovLoginUsr.do");
return redirectUrlMaker.getRedirectUrl();
}
for(String id: chkEach) {
mjonPrePayVO.setPrePayId(id);
mjonPrePayService.deletePrePayInfo(mjonPrePayVO);
}
redirectAttributes.addFlashAttribute("message", egovMessageSource.getMessage("success.common.delete"));
RedirectUrlMaker redirectUrlMaker = new RedirectUrlMaker("/uss/ion/pay/PrePayList.do");
return redirectUrlMaker.getRedirectUrl();
}catch(Exception e) {
redirectAttributes.addFlashAttribute("message", egovMessageSource.getMessage("fail.common.delete"));
}
redirectAttributes.addFlashAttribute("message", egovMessageSource.getMessage("success.common.delete"));
RedirectUrlMaker redirectUrlMaker = new RedirectUrlMaker("/uss/ion/pay/PrePayList.do");
return redirectUrlMaker.getRedirectUrl();
}
/**
* 선결제 수정화면
* @param searchVO
* @param model
* @return "/uss/ion/pay/PrePayModify.do"
* @throws Exception
*/
@RequestMapping(value= {"/uss/ion/pay/PrePayModify.do"})
public String PrePayModify(@ModelAttribute("searchVO") MjonPrePayVO mjonPrePayVO,
HttpServletRequest request, RedirectAttributes redirectAttributes,
ModelMap model) throws Exception{
// 미인증 사용자에 대한 보안처리
Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
if(!isAuthenticated) {
model.addAttribute("message", egovMessageSource.getMessage("fail.common.login"));
return "uat/uia/EgovLoginUsr";
}
try {
MjonPrePayVO resultVO = mjonPrePayService.selectPrePayInfo(mjonPrePayVO);
model.addAttribute("resultVO", resultVO);
} catch (Exception e) {
redirectAttributes.addFlashAttribute("message", egovMessageSource.getMessage("fail.common.msg"));
RedirectUrlMaker redirectUrlMaker = new RedirectUrlMaker("/uss/ion/pay/PrePayList.do");
return redirectUrlMaker.getRedirectUrl();
}
return "/uss/ion/pay/prePay/PrePayModify";
}
/**
* 선결제 수정화면
* @param searchVO
* @param model
* @return "/uss/ion/pay/updatePrePayModify.do"
* @throws Exception
*/
@RequestMapping(value= {"/uss/ion/pay/updatePrePayModify.do"})
public String updatePrePayModify(@ModelAttribute("searchVO") MjonPrePayVO mjonPrePayVO,
HttpServletRequest request, RedirectAttributes redirectAttributes,
ModelMap model) throws Exception{
// 미인증 사용자에 대한 보안처리
Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
if(!isAuthenticated) {
model.addAttribute("message", egovMessageSource.getMessage("fail.common.login"));
return "uat/uia/EgovLoginUsr";
}
try {
String mberId = mjonPrePayVO.getMberId();
int mberCnt = mjonPrePayService.selectBLineMberCnt(mberId);
if(mberCnt > 0) {
LoginVO loginVO = EgovUserDetailsHelper.isAuthenticated()? (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser():null;
String userId = loginVO == null ? "" : EgovStringUtil.isNullToString(loginVO.getId());
mjonPrePayVO.setLastUpdusrId(userId);
mjonPrePayVO.setAmt(mjonPrePayVO.getAmt().replace(",", ""));
int resultCnt = mjonPrePayService.updatePrePayModify(mjonPrePayVO);
}else {
redirectAttributes.addFlashAttribute("message", mberId + "의 회원정보를 찾을 수 없습니다.");
RedirectUrlMaker redirectUrlMaker = new RedirectUrlMaker("/uss/ion/pay/PrePayList.do");
return redirectUrlMaker.getRedirectUrl();
}
} catch (Exception e) {
redirectAttributes.addFlashAttribute("message", egovMessageSource.getMessage("fail.common.msg"));
RedirectUrlMaker redirectUrlMaker = new RedirectUrlMaker("/uss/ion/pay/PrePayList.do");
return redirectUrlMaker.getRedirectUrl();
}
return "redirect:/uss/ion/pay/PrePayList.do";
}
/**
* 결제 리스트 팝업
* @param searchVO
* @param model
* @return "/uss/ion/pay/PrePayPopupListAjax.do"
* @throws Exception
*/
@RequestMapping(value= {"/uss/ion/pay/PrePayPopupListAjax.do"})
public String selectPrePayPopupListAjax(@ModelAttribute("searchVO") MjonPrePayVO mjonPrePayVO,
HttpServletRequest request,
ModelMap model) throws Exception{
String pattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE) ;
// 미인증 사용자에 대한 보안처리
Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
if(!isAuthenticated) {
model.addAttribute("message", egovMessageSource.getMessage("fail.common.login"));
return "uat/uia/EgovLoginUsr";
}
/** pageing */
PaginationInfo paginationInfo = new PaginationInfo();
paginationInfo.setCurrentPageNo(mjonPrePayVO.getPageIndex());
paginationInfo.setRecordCountPerPage(mjonPrePayVO.getPageUnit());
paginationInfo.setPageSize(mjonPrePayVO.getPageSize());
mjonPrePayVO.setFirstIndex(paginationInfo.getFirstRecordIndex());
mjonPrePayVO.setLastIndex(paginationInfo.getLastRecordIndex());
mjonPrePayVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());
if("".equals(mjonPrePayVO.getSearchSortCnd())){ //최초조회시 최신것 조회List
mjonPrePayVO.setSearchSortCnd("prePayDate");
mjonPrePayVO.setSearchSortOrd("desc");
}
//특정 회원 정보리스트만 조회 되도록 검색값 셋팅
String mberId = mjonPrePayVO.getMberId();
List<MjonPrePayVO> resultList = mjonPrePayService.selectPrePayList(mjonPrePayVO);
model.addAttribute("resultList", resultList);
model.addAttribute("totSumPrice", resultList.size() > 0 ? ((MjonPrePayVO)resultList.get(0)).getTotSum() : 0);
paginationInfo.setTotalRecordCount(resultList.size() > 0 ? ((MjonPrePayVO)resultList.get(0)).getTotCnt() : 0);
model.addAttribute("paginationInfo", paginationInfo);
model.addAttribute("mberId", mberId);
return "/uss/ion/pay/prePay/popup/PrePayPopupList";
}
/**
* 선결제 등록화면
* @param searchVO
* @param model
* @return "/uss/ion/pay/PrePayPopupRegistAjax.do"
* @throws Exception
*/
@RequestMapping(value= {"/uss/ion/pay/PrePayPopupRegistAjax.do"})
public String selectPrePayPopupRegistAjax(@ModelAttribute("searchVO") MjonPrePayVO mjonPrePayVO,
HttpServletRequest request,
ModelMap model) throws Exception{
// 미인증 사용자에 대한 보안처리
Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
if(!isAuthenticated) {
model.addAttribute("message", egovMessageSource.getMessage("fail.common.login"));
return "uat/uia/EgovLoginUsr";
}
System.out.println(mjonPrePayVO.getMberId());
String mberId = mjonPrePayVO.getMberId();
model.addAttribute("mberId", mberId);
return "/uss/ion/pay/prePay/popup/PrePayPopupRegist";
}
/**
* 선결제 수정화면
* @param searchVO
* @param model
* @return "/uss/ion/pay/PrePayModify.do"
* @throws Exception
*/
@RequestMapping(value= {"/uss/ion/pay/PrePayPopupModifyAjax.do"})
public String selectPrePayPopupModifyAjax(@ModelAttribute("searchVO") MjonPrePayVO mjonPrePayVO,
HttpServletRequest request, RedirectAttributes redirectAttributes,
ModelMap model) throws Exception{
// 미인증 사용자에 대한 보안처리
Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
if(!isAuthenticated) {
model.addAttribute("message", egovMessageSource.getMessage("fail.common.login"));
return "uat/uia/EgovLoginUsr";
}
try {
MjonPrePayVO resultVO = mjonPrePayService.selectPrePayInfo(mjonPrePayVO);
model.addAttribute("resultVO", resultVO);
} catch (Exception e) {
redirectAttributes.addFlashAttribute("message", egovMessageSource.getMessage("fail.common.msg"));
RedirectUrlMaker redirectUrlMaker = new RedirectUrlMaker("/uss/ion/pay/PrePayPopupListAjax.do");
return redirectUrlMaker.getRedirectUrl();
}
return "/uss/ion/pay/prePay/popup/PrePayPopupModify";
}
//관리자 결제 엑셀 다운로드
@RequestMapping(value= {"/uss/ion/pay/SendPrePayExcelDownload.do"})
public void SendPrePayExcelDownload( MjonPrePayVO mjonPrePayVO,
HttpServletRequest request,
HttpServletResponse response ,
ModelMap model) throws Exception {
mjonPrePayVO.setRecordCountPerPage(5000);
mjonPrePayVO.setFirstIndex(0);
LoginVO loginVO = (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser();
// 메모리에 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 ="B선 회원 선결제내역";
String sheetTitle = "";
try{
if("".equals(mjonPrePayVO.getSearchSortCnd())){ //최초조회시 최신것 조회List
mjonPrePayVO.setSearchSortCnd("prePayDate");
mjonPrePayVO.setSearchSortOrd("desc");
}
List<MjonPrePayVO> resultList = mjonPrePayService.selectPrePayList(mjonPrePayVO);
{ //화면 리스트
sheetTitle = "선결제내역" ; //제목
Sheet sheet = wb.createSheet(sheetTitle);
sheet.setColumnWidth(0, 2500);
sheet.setColumnWidth(1, 3500);
sheet.setColumnWidth(2, 3500);
sheet.setColumnWidth(3, 4000);
sheet.setColumnWidth(4, 3500);
sheet.setColumnWidth(5, 5000);
row = sheet.createRow(0);
for(int i=0 ; i < sendPrePayExcelValue.length ; i++) {
cell = row.createCell(i);
cell.setCellStyle(style);
cell.setCellValue(sendPrePayExcelValue[i][1]);
}
for(int i=0; i < resultList.size(); i++){
row = sheet.createRow(i+1);
for(int j=0 ; j < sendPrePayExcelValue.length ; j++) {
// 번호, 회원 아이디, 전용 전송사, 선결제 일자, 결제 금액, 등록일자
cell = row.createCell(j);
cell.setCellStyle(style);
if(j==0) cell.setCellValue(i+1); //번호
if(j==1) cell.setCellValue(((MjonPrePayVO)resultList.get(i)).getMberId()); //회원 아이디
if(j==2) cell.setCellValue(((MjonPrePayVO)resultList.get(i)).getAgentCodeDc()); //전용 전송사
if(j==3) cell.setCellValue(((MjonPrePayVO)resultList.get(i)).getPrePayDate() + " " + ((MjonPrePayVO)resultList.get(i)).getPrePayTime()); //선결제 일자
if(j==4) cell.setCellValue(((MjonPrePayVO)resultList.get(i)).getAmt()); //결제금액
if(j==5) cell.setCellValue(((MjonPrePayVO)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) {}
}
}
}