755 lines
22 KiB
Java
755 lines
22 KiB
Java
package kcg.faics.equip.web;
|
|
|
|
import java.io.BufferedInputStream;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.util.ArrayList;
|
|
import java.util.Calendar;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import kcg.faics.cmmn.CommonsUtils;
|
|
import kcg.faics.cmmn.excel.ExcelExporter;
|
|
import kcg.faics.cmmn.file.FileResponser;
|
|
import kcg.faics.cmmn.service.CodeService;
|
|
import kcg.faics.cmmn.vo.CodeVO;
|
|
import kcg.faics.equip.service.ApproveService;
|
|
import kcg.faics.equip.service.EquipmentService;
|
|
import kcg.faics.equip.service.StateWaitingService;
|
|
import kcg.faics.equip.service.impl.EquipmentServiceImpl;
|
|
import kcg.faics.equip.vo.ApproveVO;
|
|
import kcg.faics.equip.vo.EquipSearchVO;
|
|
import kcg.faics.equip.vo.EquipVO;
|
|
import kcg.faics.equip.vo.StateWaitingSearchVO;
|
|
import kcg.faics.equip.vo.UseStateVO;
|
|
import kcg.faics.member.service.MemberAuthService;
|
|
import kcg.faics.member.vo.MemberVO;
|
|
import kcg.faics.sec.AuthType;
|
|
import kcg.faics.sec.LoginUserVO;
|
|
import kcg.faics.sec.UserUtil;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.MessageSource;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.util.FileCopyUtils;
|
|
import org.springframework.validation.BindingResult;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.support.SessionStatus;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
|
import egovframework.rte.fdl.property.EgovPropertyService;
|
|
|
|
/**
|
|
* FaEquipmentController.java
|
|
* @author 임새미
|
|
* @since 2016. 10. 13.
|
|
*
|
|
* 수정일 수정자 수정내용
|
|
* ------------- -------- ---------------------------
|
|
* 2016. 10. 13. 임새미 최초생성
|
|
*
|
|
*/
|
|
@Controller
|
|
@RequestMapping("/equip")
|
|
public class EquipmentController {
|
|
|
|
/**
|
|
* 사용실적 결재관련 서비스 객체.
|
|
*/
|
|
@Resource(name = "equipStateWaitingSerivce")
|
|
private StateWaitingService stateWaitingService;
|
|
|
|
/**
|
|
* 사용실적 결재관련 서비스 객체.
|
|
*/
|
|
@Resource(name = "approveService")
|
|
private ApproveService approveService;
|
|
|
|
@Resource(name = "equipmentService")
|
|
EquipmentService equipmentService;
|
|
|
|
@Resource(name = "codeService")
|
|
CodeService codeService;
|
|
|
|
/**
|
|
* properties값을 가져오는 인터페이스.
|
|
**/
|
|
@Resource(name = "propertiesService")
|
|
private EgovPropertyService propertiesService;
|
|
|
|
/**
|
|
* 사용자 권한 서비스 객체 .
|
|
*/
|
|
@Resource(name = "memberAuthService")
|
|
private MemberAuthService memberAuthService;
|
|
|
|
/**
|
|
* message.properties의 값을 가져오는 인터페이스.
|
|
*/
|
|
@Autowired
|
|
private MessageSource messageSource;
|
|
|
|
/**
|
|
* 외사 경찰의 장비 보유 현황을 가져온다.
|
|
*
|
|
* @param model Model객체
|
|
* @return 외사장비현황
|
|
*/
|
|
@RequestMapping("/status.do")
|
|
public String equipStatusView(final Model model) throws Exception {
|
|
|
|
List<HashMap<String, Object>> equipStatusList = equipmentService.getEquipmentList();
|
|
try {
|
|
|
|
model.addAttribute("equipStatusList", equipStatusList);
|
|
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
return "equip/status.tiles";
|
|
}
|
|
|
|
/**
|
|
* 외사 경찰의 장비 보유 현황을 엑셀로 출력한다.
|
|
*
|
|
* @param model Model객체
|
|
* @return 외사장비현황
|
|
*/
|
|
@RequestMapping("/statusExcel.do")
|
|
public String equipStatusExcel(final Model model) throws Exception {
|
|
|
|
String title = "외사장비현황";
|
|
|
|
List<HashMap<String, Object>> equipStatusList = equipmentService.getEquipmentList();
|
|
|
|
LinkedHashMap<String, String> header = new LinkedHashMap<String, String>();
|
|
List<CodeVO> codeList = codeService.getPlace1List(true);
|
|
header.put("EQUIP_NM", "구분");
|
|
header.put("TOTAL", "계");
|
|
|
|
/*if (codeList != null) {
|
|
for (CodeVO vo : codeList) {
|
|
header.put(vo.getCode2(), vo.getCodenmYak());
|
|
}
|
|
}*/
|
|
|
|
try {
|
|
|
|
model.addAttribute("equipStatusList", equipStatusList);
|
|
if (codeList != null) {
|
|
for (CodeVO vo : codeList) {
|
|
header.put(vo.getCode2(), vo.getCodenmYak());
|
|
}
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
model.addAttribute("excel", new ExcelExporter<HashMap<String, Object>>(header, equipStatusList, title));
|
|
model.addAttribute("filename", title);
|
|
|
|
return "excelView";
|
|
}
|
|
|
|
|
|
/**
|
|
* 외사장비의 사용실적을 가져온다.
|
|
*
|
|
* @param searchVO 파라미터 관리를 위한 EquipSearchVO 객체
|
|
* @param model Model객체
|
|
* @return 외사장비현황
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping("/useStateList.do")
|
|
public String equipUseStateList(@ModelAttribute("searchVO") final EquipSearchVO searchVO, final Model model) throws Exception {
|
|
List<HashMap<String, Object>> year = equipmentService.getEquipYearList();
|
|
EquipSearchVO equipSearchVO = new EquipSearchVO();
|
|
|
|
Calendar c = Calendar.getInstance();
|
|
int currYear = c.get(Calendar.YEAR);
|
|
int lastYear = Integer.parseInt((String) year.get(year.size() - 1).get("UYEAR"));
|
|
for (int i = lastYear + 1; i <= currYear; i++) {
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
map.put("UYEAR", i);
|
|
year.add(map);
|
|
}
|
|
|
|
/* 파라미터가 없을 때의 초기 값 */
|
|
if (searchVO == null || searchVO.getYear() == 0) {
|
|
equipSearchVO.setYear(lastYear);
|
|
equipSearchVO.setType("a");
|
|
equipSearchVO.setQuater(1);
|
|
} else {
|
|
equipSearchVO.setYear(searchVO.getYear());
|
|
equipSearchVO.setType(searchVO.getType());
|
|
equipSearchVO.setQuater(searchVO.getQuater());
|
|
}
|
|
|
|
model.addAttribute("equipStatusList", equipmentService.getEquipUseStateList(equipSearchVO));
|
|
model.addAttribute("equipStatusYearList", year);
|
|
model.addAttribute("searchVO", equipSearchVO);
|
|
|
|
return "equip/useStateList.tiles";
|
|
}
|
|
|
|
/**
|
|
* 외사장비의 사용실적을 입력화면을 가져온다.
|
|
*
|
|
* @param searchVO EquipSearchVO 객체
|
|
* @param model Model객체
|
|
* @return 외사장비현황
|
|
*/
|
|
@RequestMapping(value = "/useStateAddView.do", method=RequestMethod.POST)
|
|
public String equipUseStateAddView(@ModelAttribute("searchVO") final EquipSearchVO searchVO, final Model model) throws Exception {
|
|
List<HashMap<String, Object>> equipUseStateInfo = equipmentService.getEquipUseStateInfo(searchVO);
|
|
if (equipUseStateInfo != null) {
|
|
model.addAttribute("equipList", equipUseStateInfo);
|
|
model.addAttribute("registerFlag", "modify");
|
|
} else {
|
|
model.addAttribute("equipList", equipmentService.getEquipmentCodeList());
|
|
model.addAttribute("registerFlag", "create");
|
|
}
|
|
model.addAttribute("fail", false);
|
|
model.addAttribute("searchVO", searchVO);
|
|
|
|
return "equip/useStateAdd.tiles";
|
|
}
|
|
|
|
/**
|
|
* 외사장비의 사용실적을 입력한다.
|
|
*
|
|
* @param req HttpServletRequest 객체
|
|
* @param searchVO EquipSearchVO 객체
|
|
* @param model Model객체
|
|
* @return 외사장비현황
|
|
*/
|
|
@RequestMapping(value = "/useStateAdd.do", method=RequestMethod.POST)
|
|
public String equipUseStateAdd(final HttpServletRequest req, final EquipSearchVO searchVO, final Model model) throws Exception {
|
|
try {
|
|
HashMap<String, Object> paramMap = CommonsUtils.getParameterMap(req);
|
|
HashMap<String, HashMap<String, Object>> dataMap = new HashMap<String, HashMap<String, Object>>();
|
|
LoginUserVO user = UserUtil.getMemberInfo();
|
|
|
|
Set<String> keySet = paramMap.keySet();
|
|
Iterator<String> it = keySet.iterator();
|
|
while (it.hasNext()) {
|
|
String key = it.next();
|
|
if (key.contains("_")) {
|
|
String code = key.split("_")[0];
|
|
String col = key.split("_")[1];
|
|
String value = (String) paramMap.get(key);
|
|
|
|
HashMap<String, Object> map = dataMap.get(code);
|
|
if (dataMap.get(code) == null) {
|
|
map = new HashMap<String, Object>();
|
|
map.put("police", searchVO.getPolice());
|
|
map.put("quater", searchVO.getQuater());
|
|
map.put("year", searchVO.getYear());
|
|
map.put("writer", user.getUserid());
|
|
map.put("code", code);
|
|
|
|
dataMap.put(code, map);
|
|
}
|
|
|
|
if (col.equals("cnt") || col.equals("check")) {
|
|
map.put(col, (value == null || value.equals("")) ? 0 : Integer.parseInt(value));
|
|
} else {
|
|
map.put(col, value);
|
|
}
|
|
}
|
|
}
|
|
|
|
int result = equipmentService.insertEquipUseState(searchVO, dataMap);
|
|
if (result > 0) {
|
|
return "redirect:/equip/useStateList.do?year=" + searchVO.getYear() + "&quater=" + searchVO.getQuater() + "&type=a";
|
|
} else {
|
|
throw new Exception();
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
|
|
req.setAttribute("fail", true);
|
|
return "forward:/equip/useStateAddView.do";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 외사 경찰의 장비 사용 현황을 엑셀로 출력한다.
|
|
*
|
|
* @param model Model객체
|
|
* @return 외사장비 사용실적 현황
|
|
*/
|
|
@RequestMapping("/useStateExcel.do")
|
|
public String equipUseStateExcel(final EquipSearchVO searchVO, final Model model) throws Exception {
|
|
|
|
String type = (searchVO.getType().equals("a") ? "사용" : "점검");
|
|
String title = "외사장비 " + type + " 실적현황";
|
|
|
|
List<HashMap<String, Object>> equipStatusList = equipmentService.getEquipUseStateList(searchVO);
|
|
|
|
LinkedHashMap<String, String> header = new LinkedHashMap<String, String>();
|
|
List<CodeVO> codeList = codeService.getPlace1List(true);
|
|
header.put("GUBUN", "구분");
|
|
header.put("TOTAL", "계");
|
|
|
|
if (codeList != null) {
|
|
for (CodeVO vo : codeList) {
|
|
header.put(vo.getCode2(), vo.getCodenmYak());
|
|
}
|
|
}
|
|
|
|
model.addAttribute("excel", new ExcelExporter<HashMap<String, Object>>(header, equipStatusList, title));
|
|
model.addAttribute("filename", title);
|
|
|
|
return "excelView";
|
|
}
|
|
|
|
|
|
/**
|
|
* 사이버외사장비 조회화면을 반환한다.
|
|
*
|
|
* @param model
|
|
* Model객체
|
|
* @return 외사장비 사용실적 현황
|
|
* @throws Exception
|
|
* 기본 예외 처리
|
|
*/
|
|
@RequestMapping("/cyberEquipList.do")
|
|
public String cyberEquipList(final Model model) throws Exception {
|
|
return "equip/cyberEquipList.tiles";
|
|
}
|
|
|
|
/**
|
|
* 사용실적 결재목록 조회화면을 반환한다.
|
|
*
|
|
* @param searchVO
|
|
* 검색조건 VO
|
|
* @param model
|
|
* Model 객체
|
|
* @return 사용실적 결재목록 조회화면
|
|
* @throws Exception
|
|
* 기본 예외 처리
|
|
*/
|
|
@RequestMapping("/useStateWaiting.do")
|
|
public String stateWaitingList(@ModelAttribute("searchVO") final StateWaitingSearchVO searchVO, final Model model) throws Exception {
|
|
List<Integer> yearList = new ArrayList<Integer>();
|
|
Calendar c = Calendar.getInstance();
|
|
int currYear = c.get(Calendar.YEAR);
|
|
for (int i = 2005; i <= currYear; i++) {
|
|
yearList.add(i);
|
|
}
|
|
model.addAttribute("yearList", yearList);
|
|
|
|
LoginUserVO user = UserUtil.getMemberInfo();
|
|
searchVO.setPolice(user.getPlace1());
|
|
if (StringUtils.isBlank(searchVO.getYear())) {
|
|
searchVO.setYear(Integer.toString(currYear));
|
|
}
|
|
|
|
List<UseStateVO> stateWaitingList = stateWaitingService.selectList(searchVO);
|
|
model.addAttribute("stateWaitingList", stateWaitingList);
|
|
|
|
return "equip/stateWaitingList.tiles";
|
|
}
|
|
|
|
/**
|
|
* 사용실적 결재화면을 반환한다.
|
|
*
|
|
* @param approveVO
|
|
* 조회할 사용실적 결재 VO
|
|
* @param model
|
|
* Model 객체
|
|
* @return 사용실적 결재화면
|
|
* @throws Exception
|
|
* 기본 예외 처리
|
|
*/
|
|
@RequestMapping("/useStateApprove.do")
|
|
public String useStateApprove(final ApproveVO approveVO, final Model model) throws Exception {
|
|
|
|
EquipSearchVO searchVO = new EquipSearchVO();
|
|
searchVO.setPolice(approveVO.getPolice());
|
|
searchVO.setYear(Integer.parseInt(approveVO.getYear()));
|
|
searchVO.setQuater(Integer.parseInt(approveVO.getQuater()));
|
|
|
|
List<HashMap<String, Object>> useStateList = equipmentService.getEquipUseStateInfo(searchVO);
|
|
model.addAttribute("useStateList", useStateList);
|
|
|
|
LoginUserVO loginUserVO = UserUtil.getMemberInfo();
|
|
model.addAttribute("loginUserVO", loginUserVO);
|
|
|
|
String approvePlace1 = "";
|
|
if (StringUtils.isBlank(approveVO.getPolice())) {
|
|
approvePlace1 = approveVO.getPolice();
|
|
} else {
|
|
approvePlace1 = loginUserVO.getPlace1();
|
|
}
|
|
MemberVO headVO = memberAuthService.getHead(approvePlace1);
|
|
headVO.setPositionStr(codeService.getPositionStr(headVO.getPosition()));
|
|
headVO.setPlace1Str(codeService.getPlace1Str(headVO.getPlace1()));
|
|
model.addAttribute("headVO", headVO);
|
|
|
|
ApproveVO apprVo = approveService.select(approveVO);
|
|
if (apprVo != null) {
|
|
model.addAttribute("approveVO", apprVo);
|
|
}
|
|
|
|
return "equip/useStateApprove.tiles";
|
|
}
|
|
|
|
/**
|
|
* 사용실적을 결재한다.
|
|
*
|
|
* @param approveVO
|
|
* 결재정보 VO
|
|
* @param model
|
|
* Model 객체
|
|
* @return 사용실적 결재목록 조회화면
|
|
* @throws Exception
|
|
* 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value = "/useStateApprove.do", method = RequestMethod.POST)
|
|
public String approve(final ApproveVO approveVO, final Model model) throws Exception {
|
|
HashMap<String, Object> result = approveService.insert(approveVO, null);
|
|
if ("1".equals(result.get("result").toString())) {
|
|
return String
|
|
.format("redirect:/equip/useStateWaiting.do?police=%s&year=%s&quater=%s",
|
|
approveVO.getPolice(), approveVO.getYear(),
|
|
approveVO.getQuater());
|
|
}
|
|
return useStateApprove(approveVO, model);
|
|
}
|
|
|
|
/**
|
|
* 외사장비목륵을 조회한다.
|
|
*
|
|
* @param equipSearchVO
|
|
* @param model 모델 객체
|
|
* @return 외사장비현황 목록화면
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping("/equipList.do")
|
|
public String equipList(final EquipSearchVO equipSearchVO, Model model, HttpServletRequest request) throws Exception {
|
|
List<CodeVO> equipList = null; // 외사장비구분
|
|
List<EquipVO> equipmentList = null; // 외사장비목록
|
|
int temp = 0;
|
|
temp = temp + 1;
|
|
|
|
try {
|
|
LoginUserVO loginUserVO = UserUtil.getMemberInfo();
|
|
|
|
|
|
|
|
if( equipSearchVO.getType() == null || equipSearchVO.getType().equals("")){
|
|
if( request.getParameter("type") == null ){
|
|
equipSearchVO.setType("02");
|
|
}else{
|
|
equipSearchVO.setType(request.getParameter("type"));
|
|
}
|
|
}
|
|
|
|
equipmentList = equipmentService.getEquipList(equipSearchVO);
|
|
List result = null;
|
|
// 공통코드 조회
|
|
equipList = codeService.getCodeValues("EQUI", ""); /* 외사장비구분 */
|
|
|
|
model.addAttribute("loginUserVO", loginUserVO);
|
|
model.addAttribute("equipList", equipList);
|
|
model.addAttribute("equipmentList", equipmentList);
|
|
//model.addAttribute("regFlag", "modify");
|
|
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
return "/equip/equipList.tiles";
|
|
}
|
|
|
|
/**
|
|
* 외사장비 단건정보를 반환한다.
|
|
*
|
|
* @param model
|
|
* Model 객체
|
|
* @param divMngVO
|
|
* 외사분실운영현황 VO
|
|
* @return 외사분실운영현황 정보 조회화면
|
|
* @throws Exception
|
|
* 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value = "/equipView.do")
|
|
public String equipView(final Model model, final EquipVO equipVO) throws Exception {
|
|
LoginUserVO loginUserVO = UserUtil.getMemberInfo();
|
|
EquipSearchVO esVO = new EquipSearchVO();
|
|
|
|
model.addAttribute("loginUserVO", loginUserVO);
|
|
|
|
EquipVO vo = equipmentService.getEquipment(equipVO);
|
|
|
|
|
|
|
|
model.addAttribute("equipVO", vo);
|
|
model.addAttribute("equipSearchVO", esVO);
|
|
|
|
return "/equip/equipView.tiles";
|
|
}
|
|
|
|
/**
|
|
* 외사장비등록화면을 반환한다.
|
|
*
|
|
* @param model
|
|
* Model 객체
|
|
* @param equipVO
|
|
* 외사장비 VO
|
|
* @return 외사장비 등록화면
|
|
* @throws Exception
|
|
* 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value = "/equipAdd.do")
|
|
public String equipAdd(final Model model, final EquipVO equipVO) throws Exception {
|
|
LoginUserVO loginUserVo = new LoginUserVO();
|
|
List<CodeVO> placeList = null; // 소속
|
|
List<CodeVO> equipList = null; // 소속
|
|
|
|
try{
|
|
LoginUserVO loginUserVO = UserUtil.getMemberInfo();
|
|
|
|
if (AuthType.LOCAL_HEADQUARTERS == loginUserVo.getAuthType()) {
|
|
placeList = codeService.getPlace1SubList(loginUserVo.getPlace1());
|
|
} else {
|
|
placeList = codeService.getPlace1List(false);
|
|
}
|
|
equipList = codeService.getCodeValues("EQUI", ""); /* 외사장비구분 */
|
|
|
|
model.addAttribute("loginUserVO", loginUserVO);
|
|
model.addAttribute("policeList", placeList);
|
|
model.addAttribute("equipList", equipList);
|
|
|
|
|
|
|
|
if( equipVO.getSerNo() == null ){
|
|
|
|
model.addAttribute("registerFlag", "create");
|
|
}else{
|
|
EquipVO vo = equipmentService.getEquipment(equipVO);
|
|
model.addAttribute("registerFlag", "modify");
|
|
model.addAttribute("equipVO", vo);
|
|
}
|
|
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
|
|
return "/equip/equipAdd.tiles";
|
|
}
|
|
|
|
/**
|
|
* 외사장비를 등록한다.
|
|
*
|
|
* @param equipVO
|
|
* 외사장비정보 객체
|
|
* @param bindingResult
|
|
* 바인딩 객체
|
|
* @param model
|
|
* 모델 객체
|
|
* @param status
|
|
* 세선 상태 객체
|
|
* @return 게시물 화면
|
|
* @throws Exception
|
|
* 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value = "/equipSave.do", method = RequestMethod.POST)
|
|
public String equipSave(
|
|
@ModelAttribute("equipVO") final EquipVO equipVO,
|
|
final BindingResult bindingResult, final Model model,
|
|
final SessionStatus status, final MultipartHttpServletRequest multiRequest) throws Exception {
|
|
|
|
HashMap<String, Object> result = new HashMap<String, Object>();
|
|
try {
|
|
|
|
LoginUserVO loginUserVO = UserUtil.getMemberInfo();
|
|
|
|
|
|
equipVO.setBuyDateEach();
|
|
|
|
// 파일 저장 및 데이터 입력
|
|
String[] deleteFiles = multiRequest.getParameterValues("deleteFile");
|
|
final Map<String, MultipartFile> fileMap = multiRequest.getFileMap();
|
|
|
|
|
|
if( equipVO.getSerNo().equals("") || equipVO.getSerNo().equals(null)){
|
|
/* 등록 처리 */
|
|
|
|
equipVO.setWriter(loginUserVO.getUserid());
|
|
|
|
equipVO.print();
|
|
|
|
/* 외사장비 등록 */
|
|
result = equipmentService.insertEquipment(equipVO, fileMap);
|
|
}else{
|
|
/* 수정 처리 */
|
|
result = equipmentService.updateEquipment(equipVO, fileMap, deleteFiles);
|
|
}
|
|
|
|
|
|
equipVO.print();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
if ((Integer) result.get("result") != 1) {
|
|
return "redirect:/equip/equipAdd.do";
|
|
}
|
|
|
|
return "redirect:/equip/equipList.do?type="+equipVO.getEquipType();
|
|
}
|
|
|
|
/**
|
|
* 파일을 반환한다.
|
|
*
|
|
* @param divMngVO
|
|
* 외사분실운영현황 VO
|
|
* @param fileId
|
|
* 파일ID
|
|
* @param request
|
|
* HttpServletRequest 객체
|
|
* @param response
|
|
* HttpServletResponse 객체
|
|
* @throws Exception
|
|
* 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value = "/download.do")
|
|
public void fileResponse(final EquipVO equipVO, final String fileName,
|
|
final HttpServletRequest request, final HttpServletResponse response)
|
|
throws Exception {
|
|
EquipVO vo = equipmentService.getEquipment(equipVO);
|
|
//String fileName = "";
|
|
|
|
//fileName = vo.getFileName1();
|
|
System.out.println("fileName : " + fileName);
|
|
if (StringUtils.isNotBlank(fileName)) {
|
|
String fileFullPath = propertiesService
|
|
.getString(EquipmentServiceImpl.EQUIP_SAVE_PATH) + fileName;
|
|
File file = new File(fileFullPath);
|
|
if (file.exists()) {
|
|
FileResponser.setResponse(file, fileName, request, response);
|
|
BufferedInputStream in = null;
|
|
try {
|
|
in = new BufferedInputStream(new FileInputStream(file));
|
|
FileCopyUtils.copy(in, response.getOutputStream());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
if (in != null) {
|
|
try {
|
|
in.close();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
response.setStatus(HttpStatus.NOT_FOUND.value());
|
|
throw new Exception();
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 외사장비를 삭제한다.
|
|
* @param equipVO
|
|
* 외사장비 객체
|
|
* @param bindingResult
|
|
* 바인딩 객체
|
|
* @param model
|
|
* 모델 객체
|
|
* @param status
|
|
* 세선 상태 객체
|
|
* @return 게시물 화면
|
|
* @throws Exception
|
|
* 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value = "/equipDelete.do", method = RequestMethod.POST)
|
|
public String arrestDelete(@ModelAttribute("equipVO") final EquipVO equipVO,
|
|
final BindingResult bindingResult, final Model model, final SessionStatus status) throws Exception {
|
|
|
|
HashMap<String, Object> result = new HashMap<String, Object>();
|
|
try {
|
|
|
|
//equipVO.setDelYn("Y"); // 삭제여부
|
|
|
|
result = equipmentService.deleteEquipment(equipVO);
|
|
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
if ((Integer) result.get("result") != 1) {
|
|
return "redirect:/equip/equipView.do";
|
|
}
|
|
|
|
return "redirect:/equip/equipList.do?type="+equipVO.getEquipType();
|
|
}
|
|
|
|
/**
|
|
* 외사장비현황 목록을 엑셀로 반환한다.
|
|
*
|
|
* @param model
|
|
* Model 객체
|
|
* @param locale
|
|
* Locale 객체
|
|
* @param searchVO
|
|
* 검색조건 VO
|
|
* @return 외사장비현황 목록 엑셀
|
|
* @throws Exception
|
|
* 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value = "/listtoexcel.do")
|
|
public String listToExcel(final Model model, final Locale locale,
|
|
@ModelAttribute("searchVO") final EquipSearchVO searchVO)
|
|
throws Exception {
|
|
String title = messageSource.getMessage("menu.equip.stat", null, locale);
|
|
|
|
// 엑셀 헤더 생성
|
|
LinkedHashMap<String, String> header = new LinkedHashMap<String, String>();
|
|
header.put("num", messageSource.getMessage("equip.num", null, locale));
|
|
header.put("policeStr", messageSource.getMessage("equip.police", null, locale));
|
|
header.put("equipTypeName", messageSource.getMessage("equip.equipType", null, locale));
|
|
header.put("equipName", messageSource.getMessage("equip.equipName", null, locale));
|
|
//header.put("buyDate", messageSource.getMessage("equip.buyDate", null, locale));
|
|
|
|
// 데이터 생성
|
|
List<EquipVO> equipList = equipmentService.getEquipList(searchVO);
|
|
|
|
|
|
|
|
// Export
|
|
model.addAttribute("excel", new ExcelExporter<EquipVO>(header, equipList, title));
|
|
model.addAttribute("filename", title);
|
|
|
|
return "excelView";
|
|
}
|
|
}
|