feat: 발주기관 로그인 내역 엑셀 다운로드 기능 추가
parent
8256845953
commit
d5ae09274d
|
|
@ -1,3 +1 @@
|
||||||
#게시판 - 자료실에 파일 업로드 안 되는 문제 수정 건
|
src\main\webapp\WEB-INF\views\admins\constructionProjectManagement\construction-user-login-history.jsp
|
||||||
src\main\webapp\WEB-INF\views\admins\constructionProjectManagement\construction-project-statistics-index.jsp
|
|
||||||
src\main\resources\geoinfo\sqlmap\mappers\admins\constructionProjectManagement\ConstructionProjectManagementMapper.xml
|
|
||||||
|
|
|
||||||
|
|
@ -896,7 +896,7 @@ public class ConstructionProjectManagementController {
|
||||||
params.put("firstRecordIndex", paginationInfo.getFirstRecordIndex());
|
params.put("firstRecordIndex", paginationInfo.getFirstRecordIndex());
|
||||||
params.put("recordCountPerPage", paginationInfo.getRecordCountPerPage());
|
params.put("recordCountPerPage", paginationInfo.getRecordCountPerPage());
|
||||||
|
|
||||||
List<?> resultList = masterService.selectUserLoginHistory(params);
|
List<EgovMap> resultList = masterService.selectUserLoginHistory(params);
|
||||||
|
|
||||||
int totalCnt = resultList.size() == 0 ? 0 : Integer.valueOf(((EgovMap) resultList.get(0)).get("totalrows").toString());
|
int totalCnt = resultList.size() == 0 ? 0 : Integer.valueOf(((EgovMap) resultList.get(0)).get("totalrows").toString());
|
||||||
paginationInfo.setTotalRecordCount(totalCnt);
|
paginationInfo.setTotalRecordCount(totalCnt);
|
||||||
|
|
@ -925,5 +925,53 @@ public class ConstructionProjectManagementController {
|
||||||
ServletOutputStream myOut = response.getOutputStream();
|
ServletOutputStream myOut = response.getOutputStream();
|
||||||
workbook.write(myOut); // 파일 저장
|
workbook.write(myOut); // 파일 저장
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 발주기관 건설현장 CSV 다운로드 처리
|
||||||
|
* @param workbook
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "admins/constructionProjectManagement/excel.do")
|
||||||
|
public void constructionProjectManagementExcel(HttpServletRequest request, HttpServletResponse response, HSSFWorkbook workbook, @RequestParam HashMap<String, Object> params) throws Exception {
|
||||||
|
|
||||||
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
String[] headers = {"num","userid","userName","companyName","datetime","note"};
|
||||||
|
String[] headerNames = {"번호", "아이디", "이름", "소속", "로그인일시", "로그인여부"};
|
||||||
|
|
||||||
|
final int[] headerWidths = {1325, 15900, 4240, 6360, 5830, 8830, 6890, 2915, 3710, 5035, 2915, 3710};
|
||||||
|
String[] columnType = {"String", "String", "String", "String", "String", "String"};
|
||||||
|
String sheetName = "발주기관 로그인 내역";
|
||||||
|
|
||||||
|
String excelFileName = "국토지반_발주기관_로그인_내역";
|
||||||
|
|
||||||
|
// int startIndex = 0;
|
||||||
|
Long totalCount = 0L;
|
||||||
|
// DB 조회
|
||||||
|
/** pageing */
|
||||||
|
PaginationInfo paginationInfo = new PaginationInfo();
|
||||||
|
|
||||||
|
if (params.get("pageIndex") == null || "".equals(params.get("pageIndex"))) {
|
||||||
|
paginationInfo.setCurrentPageNo(1);
|
||||||
|
params.put("pageIndex", 1);
|
||||||
|
} else {
|
||||||
|
paginationInfo.setCurrentPageNo(Integer.valueOf((String) params.get("pageIndex")));
|
||||||
|
}
|
||||||
|
|
||||||
|
paginationInfo.setRecordCountPerPage(10);
|
||||||
|
paginationInfo.setPageSize(10);
|
||||||
|
|
||||||
|
params.put("firstRecordIndex", paginationInfo.getFirstRecordIndex());
|
||||||
|
params.put("recordCountPerPage", paginationInfo.getRecordCountPerPage());
|
||||||
|
|
||||||
|
List<EgovMap> resultList = masterService.selectUserLoginHistory(params);
|
||||||
|
|
||||||
|
int totalCnt = resultList.size() == 0 ? 0 : Integer.valueOf(((EgovMap) resultList.get(0)).get("totalrows").toString());
|
||||||
|
paginationInfo.setTotalRecordCount(totalCnt);
|
||||||
|
|
||||||
|
ExcelMergeHeaderUtil.listToExcelMergeHeaderForLoginHistory(resultList, response, headers, headerNames, headerWidths, columnType, sheetName, excelFileName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +48,7 @@ public interface GeneralUserMngMapper {
|
||||||
|
|
||||||
public void updateUserPassInfo(HashMap<String, Object> params) throws Exception;
|
public void updateUserPassInfo(HashMap<String, Object> params) throws Exception;
|
||||||
|
|
||||||
public List<?> selectUserLoginHistory(HashMap<String, Object> params) throws Exception;
|
public List<EgovMap> selectUserLoginHistory(HashMap<String, Object> params) throws Exception;
|
||||||
|
|
||||||
String findProjectMasterCompanyNameByUserid(String userId);
|
String findProjectMasterCompanyNameByUserid(String userId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,6 @@ public interface GeneralUserMngService {
|
||||||
|
|
||||||
public void updateUserPassInfo(HashMap<String, Object> params) throws Exception;
|
public void updateUserPassInfo(HashMap<String, Object> params) throws Exception;
|
||||||
|
|
||||||
public List<?> selectUserLoginHistory(HashMap<String, Object> params) throws Exception;
|
public List<EgovMap> selectUserLoginHistory(HashMap<String, Object> params) throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ public class GeneralUserMngServiceImpl implements GeneralUserMngService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<?> selectUserLoginHistory(HashMap<String, Object> params) throws Exception {
|
public List<EgovMap> selectUserLoginHistory(HashMap<String, Object> params) throws Exception {
|
||||||
return masterMapper.selectUserLoginHistory(params);
|
return masterMapper.selectUserLoginHistory(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -544,5 +544,112 @@ public class ExcelMergeHeaderUtil {
|
||||||
String formattedDate = localDateTime.toLocalDate().format(formatter);
|
String formattedDate = localDateTime.toLocalDate().format(formatter);
|
||||||
return formattedDate;
|
return formattedDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void listToExcelMergeHeaderForLoginHistory(List<EgovMap> list, HttpServletResponse response, String[] headers, String[] headerNames, int[] headerWidths, String[] columnType, String sheetName, String excelFileName) throws IOException {
|
||||||
|
if(ExcelMergeHeaderUtil.isNotEmpty(list)) {
|
||||||
|
// 메모리에 100개의 행을 유지합니다. 행의 수가 넘으면 디스크에 적습니다.
|
||||||
|
XSSFWorkbook wb = new XSSFWorkbook();
|
||||||
|
Sheet sheet = wb.createSheet(sheetName);
|
||||||
|
Row headerRow = sheet.createRow(headerNames.length);
|
||||||
|
CellStyle cellStyle1 = wb.createCellStyle(); //쉼표들어간 숫자 양식
|
||||||
|
CellStyle cellStyle2 = wb.createCellStyle(); //숫자양식
|
||||||
|
CellStyle headerStyle = wb.createCellStyle(); //헤더 스타일
|
||||||
|
CellStyle borderStyle = wb.createCellStyle(); // 기본 검정 테두리 스타일
|
||||||
|
|
||||||
|
// 기본 검정 테두리 스타일 설정
|
||||||
|
borderStyle.setBorderTop(BorderStyle.THIN);
|
||||||
|
borderStyle.setBorderBottom(BorderStyle.THIN);
|
||||||
|
borderStyle.setBorderLeft(BorderStyle.THIN);
|
||||||
|
borderStyle.setBorderRight(BorderStyle.THIN);
|
||||||
|
|
||||||
|
// 글꼴 색상 흰색으로 설정
|
||||||
|
Font headerFont = wb.createFont();
|
||||||
|
headerFont.setColor(IndexedColors.WHITE.getIndex()); // 글씨 색상 흰색
|
||||||
|
headerStyle.setFont(headerFont); // 헤더 스타일에 적용
|
||||||
|
|
||||||
|
XSSFDataFormat format = wb.createDataFormat();
|
||||||
|
cellStyle1.setDataFormat(format.getFormat("#,##0"));
|
||||||
|
cellStyle2.setDataFormat(format.getFormat("#"));
|
||||||
|
headerStyle.setBorderTop(BorderStyle.THIN);
|
||||||
|
headerStyle.setBorderBottom(BorderStyle.THIN);
|
||||||
|
headerStyle.setBorderLeft(BorderStyle.THIN);
|
||||||
|
headerStyle.setBorderRight(BorderStyle.THIN);
|
||||||
|
headerStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||||
|
// headerStyle.setFillForegroundColor((short)3);
|
||||||
|
headerStyle.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());
|
||||||
|
|
||||||
|
// 바디 스타일
|
||||||
|
CellStyle bodyStyle = wb.createCellStyle();
|
||||||
|
bodyStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
// ---------- 헤더구성 ------------------------------------
|
||||||
|
Row hRow = null;
|
||||||
|
// rows
|
||||||
|
int rowCnt = 0;
|
||||||
|
|
||||||
|
// 헤더 정보 구성
|
||||||
|
hRow = sheet.createRow(rowCnt++);
|
||||||
|
for (int i = 0; i < headerNames.length; i++) {
|
||||||
|
Cell cell = headerRow.createCell(i);
|
||||||
|
cell = hRow.createCell(i);
|
||||||
|
cell.setCellStyle(headerStyle);
|
||||||
|
cell.setCellValue(headerNames[i]);
|
||||||
|
sheet.setColumnWidth(i, (sheet.getColumnWidth(i)) + 1000);
|
||||||
|
sheet.setColumnWidth(i, headerWidths[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- 헤더구성 끝------------------------------------
|
||||||
|
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
EgovMap rowData = list.get(i);
|
||||||
|
Row row = sheet.createRow(i + 1);
|
||||||
|
|
||||||
|
for (int j = 0; j < headers.length; j++) {
|
||||||
|
Cell cell = row.createCell(j);
|
||||||
|
|
||||||
|
Object value = rowData.get(headers[j]);
|
||||||
|
|
||||||
|
// Money 타입
|
||||||
|
if ("Money".equalsIgnoreCase(columnType[j])) {
|
||||||
|
if (value instanceof Number) {
|
||||||
|
cell.setCellValue(((Number) value).doubleValue());
|
||||||
|
} else {
|
||||||
|
cell.setCellValue(0);
|
||||||
|
}
|
||||||
|
cell.setCellStyle(cellStyle1);
|
||||||
|
|
||||||
|
// Int 타입
|
||||||
|
} else if ("Int".equalsIgnoreCase(columnType[j])) {
|
||||||
|
if (value instanceof Number) {
|
||||||
|
cell.setCellValue(((Number) value).doubleValue());
|
||||||
|
} else {
|
||||||
|
cell.setCellValue(0);
|
||||||
|
}
|
||||||
|
cell.setCellStyle(cellStyle2);
|
||||||
|
|
||||||
|
// String 타입
|
||||||
|
} else {
|
||||||
|
cell.setCellValue(value == null ? "" : String.valueOf(value));
|
||||||
|
}
|
||||||
|
// 검정 테두리 적용
|
||||||
|
cell.setCellStyle(borderStyle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//엑셀이름 한글깨짐방지
|
||||||
|
String outputFileName = new String(excelFileName.getBytes("KSC5601"), "8859_1");
|
||||||
|
|
||||||
|
response.setHeader("Set-Cookie", "fileDownload=true; path=/");
|
||||||
|
response.setHeader("Content-Disposition", String.format("attachment; filename=\""+outputFileName+"_"+ExcelMergeHeaderUtil.getTimeStampString("yyyyMMdd_HHmm")+".xlsx\""));
|
||||||
|
|
||||||
|
wb.write(response.getOutputStream());
|
||||||
|
wb.close();
|
||||||
|
} else {
|
||||||
|
createNoDataAlert(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,33 @@ $(function(){
|
||||||
searchTitle = searchTitle == "" ? "0" : searchTitle;
|
searchTitle = searchTitle == "" ? "0" : searchTitle;
|
||||||
$("#searchTitle").val(searchTitle);
|
$("#searchTitle").val(searchTitle);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 엑셀 다운로드
|
||||||
|
function clickExcelDownload(){
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
params.append("constTag", "");
|
||||||
|
params.append("constName", "");
|
||||||
|
params.append("constStartDate", "");
|
||||||
|
params.append("constEndDate", "");
|
||||||
|
params.append("constStateCode", "");
|
||||||
|
params.append("projectStateCode", "");
|
||||||
|
params.append("constCompanyName", "");
|
||||||
|
params.append("constCompanyAdmin", "");
|
||||||
|
params.append("constCompanyTel", "");
|
||||||
|
params.append("excelDownload", "Y");
|
||||||
|
|
||||||
|
// 페이지 정보
|
||||||
|
const pagingEle = document.getElementById('paging');
|
||||||
|
params.append("nPage", "0");
|
||||||
|
params.append("nCount", "10000");
|
||||||
|
|
||||||
|
// AJAX가 아닌 직접 다운로드 요청
|
||||||
|
window.location.href = "/admins/constructionProjectManagement/excel.do?" + params.toString();
|
||||||
|
$('#excelDownload').val("");
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
@ -143,6 +170,11 @@ $(function(){
|
||||||
</tr>
|
</tr>
|
||||||
<!-- END : list head ----------------------------------------------------------------------------->
|
<!-- END : list head ----------------------------------------------------------------------------->
|
||||||
|
|
||||||
|
|
||||||
|
<div class="table-info-group">
|
||||||
|
<span class="pull-right" style="float:right; margin-bottom: 8px;"><img src="${pageContext.request.contextPath}/images/admins/excel.gif" style="cursor:hand" onClick="javascript:clickExcelDownload()"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- REPEAT TABLE -->
|
<!-- REPEAT TABLE -->
|
||||||
<c:forEach items="${resultList}" var="resultList" varStatus="status">
|
<c:forEach items="${resultList}" var="resultList" varStatus="status">
|
||||||
<tr height=28 bgcolor="#FFFFFF" class="list_content" align="center">
|
<tr height=28 bgcolor="#FFFFFF" class="list_content" align="center">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue