978 lines
35 KiB
Java
978 lines
35 KiB
Java
package geoinfo.admins.chLog;
|
|
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
import java.net.URLEncoder;
|
|
import java.text.DecimalFormat;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.ServletOutputStream;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import org.apache.commons.io.FilenameUtils;
|
|
import org.apache.log4j.Logger;
|
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
import org.apache.poi.ss.usermodel.CellStyle;
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.ModelMap;
|
|
import org.springframework.util.FileCopyUtils;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import egovframework.com.cmm.service.EgovProperties;
|
|
import egovframework.rte.psl.dataaccess.util.EgovMap;
|
|
import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
|
|
import geoinfo.admins.board.RefrncRoomController;
|
|
import geoinfo.admins.chLog.service.ChInfoService;
|
|
import geoinfo.com.EgovExcel;
|
|
import geoinfo.com.GeoinfoCommon;
|
|
import geoinfo.session.UserInfo;
|
|
|
|
/**
|
|
* 관리자시스템 > 유통/공급 통계분석 > 유통정보를 처리하는 Controller 클래스
|
|
*
|
|
* @author 공간정보기술(주)
|
|
* @since 2017.06.07
|
|
* @version 1.0
|
|
* @see
|
|
*
|
|
* <pre>
|
|
* << 개정이력(Modification Information) >>
|
|
*
|
|
* 수정일 수정자 수정내용
|
|
* ------------ ---------------- ---------------------------
|
|
* 2017.06.07 공간정보기술(주) 최초 생성
|
|
* 2023.11.01 ICTWAY 임효주 공종/공정/광역시도/시군구별 통계 추가
|
|
*
|
|
* </pre>
|
|
*/
|
|
@Controller
|
|
public class ChInfoController {
|
|
@Resource(name = "chInfoService")
|
|
private ChInfoService masterService;
|
|
|
|
private static final Logger LOGGER = Logger.getLogger(RefrncRoomController.class.getName());
|
|
|
|
// 운영서버 경로
|
|
// private final String savePath = "D:\\Tomcat6\\geoinfoEgov\\webapps\\geoinfo\\files";
|
|
// 개발서버 경로
|
|
private final String savePath = EgovProperties.getProperty("Geoinfo.FilePath");
|
|
|
|
/**
|
|
* 관리자시스템 > 유통/공급 통계분석 > 유통정보 > 날짜별 리스트
|
|
*
|
|
* @param params
|
|
* @param model
|
|
* @param response
|
|
* @param request
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value = "admins/chLog/00.do")
|
|
public String selectInfoListDate(@RequestParam HashMap<String, Object> params, ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
|
if (!UserInfo.isValidSession(request, response, "admin")) {
|
|
return "";
|
|
}
|
|
|
|
List<?> getYear_date = masterService.getYear_date();
|
|
|
|
if ("".equals(params.get("year")) || params.get("year") == null) {
|
|
params.put("year", ((EgovMap) getYear_date.get(0)).get("value"));
|
|
}
|
|
|
|
List<?> getMonth_date = masterService.getMonth_date(params);
|
|
|
|
if ("".equals(params.get("month")) || params.get("month") == null || (getMonth_date.size() != 0 && getMonth_date.size() < Integer.valueOf((String) params.get("month")))) {
|
|
params.put("month", ((EgovMap) getMonth_date.get(0)).get("value"));
|
|
}
|
|
|
|
/** 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(20);
|
|
paginationInfo.setPageSize(10);
|
|
|
|
params.put("firstRecordIndex", paginationInfo.getFirstRecordIndex());
|
|
params.put("recordCountPerPage", paginationInfo.getRecordCountPerPage());
|
|
|
|
if (params.get("agreeyn") == null || "".equals(params.get("agreeyn"))) {
|
|
params.put("agreeyn", "0");
|
|
}
|
|
if (params.get("downyn") == null || "".equals(params.get("downyn"))) {
|
|
params.put("downyn", "0");
|
|
}
|
|
|
|
List<?> resultList = masterService.selectInfoListDate(params);
|
|
|
|
int totalCnt = resultList.size() == 0 ? 0 : Integer.valueOf(((EgovMap) resultList.get(0)).get("totalrows").toString());
|
|
paginationInfo.setTotalRecordCount(totalCnt);
|
|
|
|
model.addAttribute("params", params);
|
|
model.addAttribute("getYear_date", getYear_date);
|
|
model.addAttribute("getMonth_date", getMonth_date);
|
|
model.addAttribute("resultList", resultList);
|
|
model.addAttribute("paginationInfo", paginationInfo);
|
|
|
|
return "admins/chLog/00";
|
|
}
|
|
|
|
/**
|
|
* 관리자시스템 > 유통/공급 통계분석 > 유통정보 > 날짜별 리스트 > 그래프
|
|
*
|
|
* @param params
|
|
* @param model
|
|
* @param response
|
|
* @param request
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value = "admins/chLog/00_graph.do")
|
|
public String selectInfoGraph(@RequestParam HashMap<String, Object> params, ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
|
if (!UserInfo.isValidSession(request, response, "admin")) {
|
|
return "";
|
|
}
|
|
|
|
List<?> getYear_date = masterService.getYear_date();
|
|
|
|
if ("".equals(params.get("year")) || params.get("year") == null) {
|
|
params.put("year", ((EgovMap) getYear_date.get(0)).get("value"));
|
|
}
|
|
|
|
List<?> getMonth_date = masterService.getMonth_date(params);
|
|
|
|
if ("".equals(params.get("month")) || params.get("month") == null || (getMonth_date.size() != 0 && getMonth_date.size() < Integer.valueOf((String) params.get("month")))) {
|
|
params.put("month", ((EgovMap) getMonth_date.get(0)).get("value"));
|
|
}
|
|
|
|
EgovMap result = masterService.selectInfoGraph(params);
|
|
|
|
model.addAttribute("params", params);
|
|
model.addAttribute("getYear_date", getYear_date);
|
|
model.addAttribute("getMonth_date", getMonth_date);
|
|
model.addAttribute("result", result);
|
|
|
|
return "admins/chLog/00_graph";
|
|
}
|
|
|
|
/**
|
|
* 관리자시스템 > 유통/공급 통계분석 > 유통정보 > 날짜별 리스트 엑셀 다운로드
|
|
*
|
|
* @param params
|
|
* @param workbook
|
|
* @param request
|
|
* @param response
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value = "admins/chLog/00_excel.do")
|
|
public void selectInfoListDateExcel(@RequestParam HashMap<String, Object> params, HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response)
|
|
throws Exception {
|
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
|
|
List<?> selectInfoListExcel = masterService.selectInfoListDateExcel(params);
|
|
|
|
String[] arrHeader = { "번호", "사업명", "다운로드 수" };
|
|
|
|
map.put("selectInfoListExcel", selectInfoListExcel);
|
|
map.put("arrHeader", arrHeader);
|
|
map.put("sheetName", "날짜별 유통정보");
|
|
map.put("fileName", "날짜별유통정보_");
|
|
|
|
buildExcelDocument(map, workbook, request, response);
|
|
}
|
|
|
|
/**
|
|
* 관리자시스템 > 유통/공급 통계분석 > 유통정보 > 사업별 리스트
|
|
*
|
|
* @param params
|
|
* @param model
|
|
* @param response
|
|
* @param request
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value = "admins/chLog/01.do")
|
|
public String selectInfoListBusiness(@RequestParam HashMap<String, Object> params, ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
|
if (!UserInfo.isValidSession(request, response, "admin")) {
|
|
return "";
|
|
}
|
|
|
|
/** 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(20);
|
|
paginationInfo.setPageSize(10);
|
|
|
|
params.put("firstRecordIndex", paginationInfo.getFirstRecordIndex());
|
|
params.put("recordCountPerPage", paginationInfo.getRecordCountPerPage());
|
|
|
|
List<?> resultList = masterService.selectInfoListBusiness(params);
|
|
|
|
int totalCnt = resultList.size() == 0 ? 0 : Integer.valueOf(((EgovMap) resultList.get(0)).get("totalrows").toString());
|
|
paginationInfo.setTotalRecordCount(totalCnt);
|
|
|
|
model.addAttribute("params", params);
|
|
model.addAttribute("resultList", resultList);
|
|
model.addAttribute("paginationInfo", paginationInfo);
|
|
|
|
return "admins/chLog/01";
|
|
}
|
|
|
|
/**
|
|
* 관리자시스템 > 유통/공급 통계분석 > 유통정보 > 사업별 리스트 엑셀 다운로드
|
|
*
|
|
* @param params
|
|
* @param workbook
|
|
* @param request
|
|
* @param response
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value = "admins/chLog/01_excel.do")
|
|
public void selectInfoListBusinessExcel(@RequestParam HashMap<String, Object> params, HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response)
|
|
throws Exception {
|
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
|
|
List<?> selectInfoListExcel = masterService.selectInfoListBusinessExcel(params);
|
|
|
|
String[] arrHeader = { "번호", "사업명", "다운로드 수" };
|
|
|
|
map.put("selectInfoListExcel", selectInfoListExcel);
|
|
map.put("arrHeader", arrHeader);
|
|
map.put("sheetName", "사업별 유통정보");
|
|
map.put("fileName", "사업별유통정보_");
|
|
|
|
buildExcelDocument(map, workbook, request, response);
|
|
}
|
|
|
|
/**
|
|
* 관리자시스템 > 유통/공급 통계분석 > 유통정보 > 다운로드 로그정보 팝업
|
|
*
|
|
* @param params
|
|
* @param model
|
|
* @param response
|
|
* @param request
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value = "admins/chLog/download_view.do")
|
|
public String selectInfoListDateLogPop(@RequestParam HashMap<String, Object> params, ModelMap model, HttpServletResponse response, HttpServletRequest request)
|
|
throws Exception {
|
|
if (!UserInfo.isValidSession(request, response, "admin")) {
|
|
return "";
|
|
}
|
|
|
|
/** 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(6);
|
|
paginationInfo.setPageSize(10);
|
|
|
|
params.put("firstRecordIndex", paginationInfo.getFirstRecordIndex());
|
|
params.put("recordCountPerPage", paginationInfo.getRecordCountPerPage());
|
|
|
|
List<?> resultList = masterService.selectInfoListDateLogPop(params);
|
|
|
|
int totalCnt = resultList.size() == 0 ? 0 : Integer.valueOf(((EgovMap) resultList.get(0)).get("totalrows").toString());
|
|
paginationInfo.setTotalRecordCount(totalCnt);
|
|
|
|
model.addAttribute("params", params);
|
|
model.addAttribute("resultList", resultList);
|
|
model.addAttribute("paginationInfo", paginationInfo);
|
|
|
|
return "admins/chLog/download_view";
|
|
}
|
|
|
|
@RequestMapping(value = "admins/chLog/03.do")
|
|
public String selectInfoListPurpose(ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
|
if (!UserInfo.isValidSession(request, response, "admin")) {
|
|
return "";
|
|
}
|
|
|
|
List<?> resultList = masterService.selectInfoListPurpose();
|
|
|
|
model.addAttribute("resultList", resultList);
|
|
|
|
return "admins/chLog/03";
|
|
}
|
|
|
|
@RequestMapping(value = "admins/chLog/03_excel.do")
|
|
public void selectInfoListPurposeExcel(HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
|
|
List<?> selectInfoListExcel = masterService.selectInfoListPurpose();
|
|
|
|
String[] arrHeader = { "년도", "정책입안", "학술연구", "공사계획 및 예비조사", "기본설계", "실시설계", "시공 및 유지관리", "사업비산정", "지하시설물 유지관리",
|
|
"스마트시티","도시재생","지진 예방","산사태 예방","급경사지 관리","홍수 예방","지하안전영향평가","소규모지하안전영향평가","사후지하안전영향조사","지반침하위험도평가","지하안전점검",
|
|
"기타", "검수", "총계" };
|
|
|
|
map.put("selectInfoListExcel", selectInfoListExcel);
|
|
map.put("arrHeader", arrHeader);
|
|
map.put("sheetName", "목적별 유통정보");
|
|
map.put("fileName", "목적별유통정보_");
|
|
|
|
buildExcelDocument(map, workbook, request, response);
|
|
}
|
|
|
|
/**
|
|
* 2023.11.01 LHJ 공종별 시추공등록 통계 추가
|
|
* 2023.11.01 LHJ 유통/공급 통계분석 > 유통정보 > 공종별 리스트
|
|
*
|
|
* @param model
|
|
* @param response
|
|
* @param request
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value = "admins/chLog/11.do")
|
|
public String selectInfoListGongjong(ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
|
if (!UserInfo.isValidSession(request, response, "admin")) {
|
|
return "";
|
|
}
|
|
|
|
List<Map<String, Object>> originalList = masterService.selectInfoListGongjong();
|
|
List<List<Object>> transposedList = new ArrayList<>();
|
|
transposedList = transposeMatrix(originalList);
|
|
List<List<Object>> resultList = transposedList;
|
|
model.addAttribute("resultList", resultList);
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
String jsonList = mapper.writeValueAsString(resultList);
|
|
model.addAttribute("jsonList", jsonList);
|
|
|
|
return "admins/chLog/11";
|
|
}
|
|
|
|
/**
|
|
* 2024.01.09 LHJ 공정별 시추공등록 통계 추가
|
|
* 2023.01.09 LHJ 유통/공급 통계분석 > 유통정보 > 공정별 리스트
|
|
*
|
|
* @param model
|
|
* @param response
|
|
* @param request
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value = "admins/chLog/12.do")
|
|
public String selectInfoListGongjeong(ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
|
if (!UserInfo.isValidSession(request, response, "admin")) {
|
|
return "";
|
|
}
|
|
|
|
List<Map<String, Object>> originalList = masterService.selectInfoListGongjeong();
|
|
List<List<Object>> transposedList = new ArrayList<>();
|
|
transposedList = transposeMatrix(originalList);
|
|
List<List<Object>> resultList = transposedList;
|
|
model.addAttribute("resultList", resultList);
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
String jsonList = mapper.writeValueAsString(resultList);
|
|
model.addAttribute("jsonList", jsonList);
|
|
|
|
return "admins/chLog/12";
|
|
}
|
|
|
|
/**
|
|
* 2024.01.10 LHJ 시도별 프로젝트 등록 통계 추가
|
|
* 2023.01.10 LHJ 유통/공급 통계분석 > 유통정보 > 시도별 리스트
|
|
*
|
|
* @param model
|
|
* @param response
|
|
* @param request
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value = "admins/chLog/13.do")
|
|
public String selectInfoListSido(ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
|
if (!UserInfo.isValidSession(request, response, "admin")) {
|
|
return "";
|
|
}
|
|
|
|
List<Map<String, Object>> originalList = masterService.selectInfoListSido();
|
|
List<List<Object>> transposedList = new ArrayList<>();
|
|
transposedList = transposeMatrix(originalList);
|
|
List<List<Object>> resultList = transposedList;
|
|
model.addAttribute("resultList", resultList);
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
String jsonList = mapper.writeValueAsString(resultList);
|
|
model.addAttribute("jsonList", jsonList);
|
|
|
|
return "admins/chLog/13";
|
|
}
|
|
|
|
/**
|
|
* 2024.01.30 LHJ 시군구별 프로젝트 등록 통계 추가
|
|
* 2023.01.30 LHJ 유통/공급 통계분석 > 유통정보 > 시군구별 리스트
|
|
*
|
|
* @param model
|
|
* @param response
|
|
* @param request
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value = "admins/chLog/14.do")
|
|
public String selectInfoListSigungu_imsi(@RequestParam HashMap<String, Object> params, ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
|
|
|
String sidoCode;
|
|
|
|
if(params != null && params.get("sidoCode") != null && !((params.get("sidoCode")).equals(""))) {
|
|
sidoCode = params.get("sidoCode").toString();
|
|
} else {
|
|
sidoCode = "04:";
|
|
}
|
|
|
|
List<Map<String, Object>> sigunguCode = masterService.selectSigunguCode(sidoCode);
|
|
|
|
int sidoLength = 0;
|
|
List<String> aliasList = new ArrayList<>();
|
|
outerloop:
|
|
|
|
for (char first = 'A'; first <= 'Z'; ++first) {
|
|
for (char second = 'A'; second <= 'Z'; ++second) {
|
|
aliasList.add("" + first + second);
|
|
sidoLength++;
|
|
if (sidoLength == sigunguCode.size()) {
|
|
break outerloop;
|
|
}
|
|
}
|
|
}
|
|
|
|
HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
|
paramMap.put("sigunguCode", sigunguCode);
|
|
paramMap.put("sidoCode", sidoCode);
|
|
paramMap.put("aliasList", aliasList);
|
|
|
|
List<Map<String, Object>> originalList = masterService.selectInfoListSigungu(paramMap);
|
|
List<List<Object>> transposedList = new ArrayList<>();
|
|
transposedList = transposeMatrix(originalList);
|
|
List<List<Object>> resultList = transposedList;
|
|
model.addAttribute("resultList", resultList);
|
|
|
|
model.addAttribute("sidoCode", sidoCode);
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
String jsonList = mapper.writeValueAsString(resultList);
|
|
model.addAttribute("jsonList", jsonList);
|
|
|
|
return "admins/chLog/14";
|
|
}
|
|
|
|
|
|
public void buildExcelDocument(Map<String, Object> model, HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
|
List<?> selectInfoListExcel = (List<?>) model.get("selectInfoListExcel");
|
|
|
|
String[] arrHeader = (String[]) model.get("arrHeader");
|
|
|
|
Sheet sheet = workbook.createSheet((String) model.get("sheetName"));
|
|
|
|
if (Objects.nonNull(arrHeader)) {
|
|
EgovExcel.SetExcelList(workbook, sheet, arrHeader, selectInfoListExcel, 0, 0);
|
|
} else {
|
|
EgovExcel.SetExcelList(workbook, sheet, selectInfoListExcel, 0, 0);
|
|
}
|
|
response.setContentType("application/vnd.ms-excel");
|
|
response.setHeader("Content-disposition", "attachment;filename="
|
|
+ URLEncoder.encode((String) model.get("fileName") + (new SimpleDateFormat("yyyyMMdd", Locale.KOREA)).format(new Date()), "UTF-8") + ".xls" + ";");
|
|
ServletOutputStream myOut = response.getOutputStream();
|
|
workbook.write(myOut); // 파일 저장
|
|
}
|
|
|
|
@RequestMapping(value = "admins/chLog/41.do")
|
|
public String selectLiqInfoList( @RequestParam HashMap<String, Object> params, ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
|
|
|
/** 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); //searchVO.getPageUnit()
|
|
paginationInfo.setPageSize(10); //searc1hVO.getPageSize()
|
|
|
|
params.put("firstRecordIndex", paginationInfo.getFirstRecordIndex());
|
|
params.put("recordCountPerPage", paginationInfo.getRecordCountPerPage());
|
|
|
|
List<?> resultList = masterService.selectLiqInfoList(params);
|
|
int totCnt = masterService.selectLiqInfoListCnt(params);
|
|
paginationInfo.setTotalRecordCount(totCnt);
|
|
|
|
model.addAttribute("params", params);
|
|
model.addAttribute("liqInfo", resultList);
|
|
model.addAttribute("paginationInfo", paginationInfo);
|
|
|
|
return "admins/chLog/41";
|
|
}
|
|
|
|
@RequestMapping(value = "admins/chLog/41_view.do")
|
|
public String selectLiqInfoDetailView(@RequestParam HashMap<String, Object> params, ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
|
|
|
EgovMap resultList = masterService.selectWebLiqInfo(params);
|
|
|
|
String cntChk = "R";
|
|
String purpose_code = "READ";
|
|
|
|
params.put("cntChk", cntChk);
|
|
params.put("purpose_code", purpose_code);
|
|
|
|
masterService.updateLiqInfoLog(params);
|
|
|
|
model.addAttribute("detailView", resultList);
|
|
model.addAttribute("br", "\r");
|
|
|
|
return "admins/chLog/41_view";
|
|
}
|
|
|
|
@RequestMapping(value = "admins/chLog/41_write.do")
|
|
public String selectLiqInfoListWrite(@RequestParam HashMap<String, Object> params, ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
|
|
|
if (!UserInfo.isValidSession(request, response, "admin")) {
|
|
return "";
|
|
}
|
|
|
|
return "admins/chLog/41_write";
|
|
}
|
|
|
|
@RequestMapping(value = "admins/chLog/51.do")
|
|
public String selectLiqInfoListDate(@RequestParam HashMap<String, Object> params, ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
|
if (!UserInfo.isValidSession(request, response, "admin")) {
|
|
return "";
|
|
}
|
|
|
|
/** 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(20);
|
|
paginationInfo.setPageSize(10);
|
|
|
|
params.put("firstRecordIndex", paginationInfo.getFirstRecordIndex());
|
|
params.put("recordCountPerPage", paginationInfo.getRecordCountPerPage());
|
|
|
|
if((params.get("searchTitle") == null || "".equals(params.get("searchTitle")))) {
|
|
params.put("searchTitle", "2");
|
|
}else {
|
|
params.put("searchTitle", params.get("searchTitle"));
|
|
}
|
|
|
|
List<?> resultList = masterService.selectLiqInfoListDate(params);
|
|
|
|
model.addAttribute("params", params);
|
|
model.addAttribute("resultList", resultList);
|
|
model.addAttribute("paginationInfo", paginationInfo);
|
|
|
|
|
|
return "admins/chLog/51";
|
|
}
|
|
|
|
/**
|
|
* 관리자시스템 > 액상화 위험지도 사업별 통계 엑셀 다운로드
|
|
*
|
|
* @param params
|
|
* @param workbook
|
|
* @param request
|
|
* @param response
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value = "admins/notice/51_excel.do")
|
|
public void selectLiqInfoListDateExcel(@RequestParam HashMap<String, Object> params, HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response)
|
|
throws Exception {
|
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
|
|
List<?> selectLiqInfoListExcel = masterService.selectLiqInfoListDateExcel(params);
|
|
|
|
String[] arrHeader = { "번호", "파일명", "주소", "조회 수" , "다운로드 수" };
|
|
|
|
map.put("selectLiqInfoListExcel", selectLiqInfoListExcel);
|
|
map.put("arrHeader", arrHeader);
|
|
map.put("sheetName", "액상화 위험정보");
|
|
map.put("fileName", "액상화 위험정보_");
|
|
|
|
buildExcelLiq(map, workbook, request, response);
|
|
}
|
|
|
|
@RequestMapping(value = "admins/chLog/52.do")
|
|
public String selectSidoInfoListDate(@RequestParam HashMap<String, Object> params, ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
|
if (!UserInfo.isValidSession(request, response, "admin")) {
|
|
return "";
|
|
}
|
|
|
|
/** 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(20);
|
|
paginationInfo.setPageSize(10);
|
|
|
|
params.put("firstRecordIndex", paginationInfo.getFirstRecordIndex());
|
|
params.put("recordCountPerPage", paginationInfo.getRecordCountPerPage());
|
|
|
|
if((params.get("searchTitle") == null || "".equals(params.get("searchTitle")))) {
|
|
params.put("searchTitle", "1");
|
|
}else {
|
|
params.put("searchTitle", params.get("searchTitle"));
|
|
}
|
|
List<?> resultList = masterService.selectLiqSidoInfoListDate(params);
|
|
|
|
model.addAttribute("params", params);
|
|
model.addAttribute("resultList", resultList);
|
|
model.addAttribute("paginationInfo", paginationInfo);
|
|
|
|
|
|
return "admins/chLog/52";
|
|
}
|
|
|
|
/**
|
|
* 관리자시스템 > 액상화 위험지도 지역별 통계 엑셀 다운로드
|
|
*
|
|
* @param params
|
|
* @param workbook
|
|
* @param request
|
|
* @param response
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value = "admins/notice/52_excel.do")
|
|
public void selectSidoInfoListDateExcel(@RequestParam HashMap<String, Object> params, HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response)
|
|
throws Exception {
|
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
|
|
List<?> selectLiqInfoListExcel = masterService.selectLiqInfoListDateExcel(params);
|
|
|
|
String[] arrHeader = { "번호", "파일명", "주소", "조회 수" , "다운로드 수" };
|
|
|
|
map.put("selectLiqInfoListExcel", selectLiqInfoListExcel);
|
|
map.put("arrHeader", arrHeader);
|
|
map.put("sheetName", "액상화 위험정보");
|
|
map.put("fileName", "액상화 위험정보_");
|
|
|
|
buildExcelLiq(map, workbook, request, response);
|
|
}
|
|
|
|
/**
|
|
* 관리자시스템 > 액상화 위험지도 로그정보 팝업
|
|
*
|
|
* @param params
|
|
* @param model
|
|
* @param response
|
|
* @param request
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value = "admins/chLog/download_liq.do")
|
|
public String selectLiqInfoListDateLogPop(@RequestParam HashMap<String, Object> params, ModelMap model, HttpServletResponse response, HttpServletRequest request)
|
|
throws Exception {
|
|
if (!UserInfo.isValidSession(request, response, "admin")) {
|
|
return "";
|
|
}
|
|
|
|
/** 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(6);
|
|
paginationInfo.setPageSize(10);
|
|
|
|
params.put("firstRecordIndex", paginationInfo.getFirstRecordIndex());
|
|
params.put("recordCountPerPage", paginationInfo.getRecordCountPerPage());
|
|
|
|
List<?> resultList = masterService.selectLiqInfoListLogPop(params);
|
|
|
|
int totalCnt = resultList.size() == 0 ? 0 : Integer.valueOf(((EgovMap) resultList.get(0)).get("totalrows").toString());
|
|
paginationInfo.setTotalRecordCount(totalCnt);
|
|
|
|
model.addAttribute("params", params);
|
|
model.addAttribute("resultList", resultList);
|
|
model.addAttribute("paginationInfo", paginationInfo);
|
|
|
|
return "admins/chLog/download_liq";
|
|
}
|
|
|
|
public void buildExcelLiq(Map<String, Object> model, HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
|
List<?> selectLiqInfoListExcel = (List<?>) model.get("selectLiqInfoListExcel");
|
|
|
|
String[] arrHeader = (String[]) model.get("arrHeader");
|
|
|
|
Sheet sheet = workbook.createSheet((String) model.get("sheetName"));
|
|
|
|
EgovExcel.SetExcelList(workbook, sheet, arrHeader, selectLiqInfoListExcel, 0, 0);
|
|
|
|
response.setContentType("application/vnd.ms-excel");
|
|
response.setHeader("Content-disposition", "attachment;filename="
|
|
+ URLEncoder.encode((String) model.get("fileName") + (new SimpleDateFormat("yyyy.MM.dd", Locale.KOREA)).format(new Date()), "UTF-8") + ".xls" + ";");
|
|
ServletOutputStream myOut = response.getOutputStream();
|
|
workbook.write(myOut); // 파일 저장
|
|
}
|
|
|
|
@RequestMapping(value = "admins/liq/fileDownload.do")
|
|
public void fileDownload(@RequestParam HashMap<String, Object> params, ModelMap model, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
|
|
|
String savename = params.get("savename").toString();
|
|
|
|
String cntChk = "D";
|
|
String purpose_code = "DOWN";
|
|
|
|
params.put("cntChk", cntChk);
|
|
params.put("purpose_code", purpose_code);
|
|
masterService.updateLiqInfoLog(params);
|
|
|
|
File file = new File(savePath + "\\" + FilenameUtils.getName(savename));
|
|
|
|
response.setContentType("multipart/form-data");
|
|
response.setContentLength((int)file.length());
|
|
response.setHeader("Content-Disposition", GeoinfoCommon.safeHttpHeader("attachment; filename=\"" + savename + "\""));
|
|
response.setHeader("Content-Transfer-Encoding", "binary");
|
|
|
|
OutputStream out = response.getOutputStream();
|
|
FileInputStream fis = null;
|
|
|
|
try {
|
|
fis = new FileInputStream(file);
|
|
FileCopyUtils.copy(fis, out);
|
|
}
|
|
catch(IOException e){
|
|
LOGGER.error(e);
|
|
}finally{
|
|
if(fis != null){
|
|
try{
|
|
fis.close();
|
|
}catch(IOException e){
|
|
LOGGER.error(e);
|
|
}
|
|
}
|
|
}
|
|
out.flush();
|
|
}
|
|
|
|
@SuppressWarnings("unused")
|
|
private List<List<Object>> transposeMatrix(List<Map<String, Object>> originalList) {
|
|
|
|
List<List<Object>> valueList = new ArrayList<>();
|
|
List<List<Object>> transposedList = new ArrayList<>();
|
|
|
|
/** originalList의 value만 list로 만듬 **/
|
|
for (Map<String, Object> row : originalList) {
|
|
valueList.add(new ArrayList<>(row.values()));
|
|
}
|
|
|
|
/** 행과 열 뒤집음 **/
|
|
if (!valueList.isEmpty()) {
|
|
int size = valueList.get(0).size();
|
|
for (int i = 0; i < size; i++) {
|
|
List<Object> columnData = new ArrayList<>();
|
|
for (List<Object> row : valueList) {
|
|
columnData.add(row.get(i));
|
|
}
|
|
transposedList.add(columnData);
|
|
}
|
|
}
|
|
|
|
/** 첫번째 열 숫자의 오름차순 순서대로 행의 순서를 정리하고, 그 첫번째 열을 삭제함 **/
|
|
Collections.sort(transposedList, new java.util.Comparator<List<Object>>() {
|
|
@Override
|
|
public int compare(List<Object> o1, List<Object> o2) {
|
|
return Integer.compare(Integer.parseInt((String) o1.get(0)), Integer.parseInt((String) o2.get(0)));
|
|
}
|
|
});
|
|
for (List<Object> row : transposedList) {
|
|
row.remove(0);
|
|
}
|
|
|
|
/** 숫자 포맷팅 **/
|
|
DecimalFormat df = new DecimalFormat("#,###");
|
|
for (int i = 1; i < transposedList.size(); i++) {
|
|
List<Object> row = transposedList.get(i);
|
|
for (int j = 0; j < row.size(); j++) {
|
|
Object data = row.get(j);
|
|
if (data instanceof String) {
|
|
try {
|
|
Number num = df.parse((String) data);
|
|
row.set(j, df.format(num));
|
|
} catch (ParseException e) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return transposedList;
|
|
}
|
|
|
|
@RequestMapping(value = "admins/downloadExcel.do", method = RequestMethod.POST)
|
|
public void downloadExcel(@RequestParam HashMap<String, Object> params, HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
|
String pId = (String) params.get("pId");
|
|
String resultListJson = (String) params.get("resultList");
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
List<List<Object>> result = mapper.readValue(resultListJson, new TypeReference<List<List<Object>>>(){});
|
|
|
|
String fileName = "";
|
|
String sheetName = "";
|
|
|
|
switch (pId) {
|
|
case "11":
|
|
fileName = "공종별등록정보_";
|
|
sheetName = "공종별등록정보";
|
|
break;
|
|
case "12":
|
|
fileName = "공정별등록정보_";
|
|
sheetName = "공정별등록정보";
|
|
break;
|
|
case "13":
|
|
fileName = "시도별등록정보_";
|
|
sheetName = "시도별등록정보";
|
|
break;
|
|
case "14":
|
|
String sidoCode = (String) params.get("sidoCode");
|
|
switch (sidoCode) {
|
|
case "04:":
|
|
fileName = "시군구별_서울특별시_";
|
|
sheetName = "시군구별_서울특별시";
|
|
break;
|
|
case "05:":
|
|
fileName = "시군구별_부산광역시_";
|
|
sheetName = "시군구별_부산광역시";
|
|
break;
|
|
case "06:":
|
|
fileName = "시군구별_광주광역시_";
|
|
sheetName = "시군구별_광주광역시";
|
|
break;
|
|
case "07:":
|
|
fileName = "시군구별_대전광역시_";
|
|
sheetName = "시군구별_대전광역시";
|
|
break;
|
|
case "08:":
|
|
fileName = "시군구별_대구광역시_";
|
|
sheetName = "시군구별_대구광역시";
|
|
break;
|
|
case "09:":
|
|
fileName = "시군구별_인천광역시_";
|
|
sheetName = "시군구별_인천광역시";
|
|
break;
|
|
case "10:":
|
|
fileName = "시군구별_울산광역시_";
|
|
sheetName = "시군구별_울산광역시";
|
|
break;
|
|
case "11:":
|
|
fileName = "시군구별_경기도_";
|
|
sheetName = "시군구별_경기도";
|
|
break;
|
|
case "12:":
|
|
fileName = "시군구별_강원도_";
|
|
sheetName = "시군구별_강원도";
|
|
break;
|
|
case "13:":
|
|
fileName = "시군구별_충청북도_";
|
|
sheetName = "시군구별_충청북도";
|
|
break;
|
|
case "14:":
|
|
fileName = "시군구별_충청남도_";
|
|
sheetName = "시군구별_충청남도";
|
|
break;
|
|
case "15:":
|
|
fileName = "시군구별_경상북도_";
|
|
sheetName = "시군구별_경상북도";
|
|
break;
|
|
case "16:":
|
|
fileName = "시군구별_경상남도_";
|
|
sheetName = "시군구별_경상남도";
|
|
break;
|
|
case "17:":
|
|
fileName = "시군구별_전라북도_";
|
|
sheetName = "시군구별_전라북도";
|
|
break;
|
|
case "18:":
|
|
fileName = "시군구별_전라남도_";
|
|
sheetName = "시군구별_전라남도";
|
|
break;
|
|
case "19:":
|
|
fileName = "시군구별_제주특별자치도_";
|
|
sheetName = "시군구별_제주특별자치도";
|
|
break;
|
|
case "20:":
|
|
fileName = "시군구별_세종특별자치시_";
|
|
sheetName = "시군구별_세종특별자치시";
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
|
|
map.put("selectInfoListExcel", result);
|
|
map.put("fileName", fileName);
|
|
map.put("sheetName", sheetName);
|
|
|
|
buildExcelDocument(map, workbook, request, response);
|
|
}
|
|
|
|
}
|