364 lines
10 KiB
Java
364 lines
10 KiB
Java
/**
|
|
* FaEquipmentServiceImpl.java
|
|
* @author 임새미
|
|
* @since 2016. 10. 13.
|
|
*
|
|
* 수정일 수정자 수정내용
|
|
* ------------- -------- ---------------------------
|
|
* 2016. 10. 13. 임새미 최초생성
|
|
*
|
|
*/
|
|
package kcg.faics.equip.service.impl;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import kcg.faics.board.util.BoardVOHandler;
|
|
import kcg.faics.board.vo.BoardFileVO;
|
|
import kcg.faics.cmmn.bbs.BaseFileService;
|
|
import kcg.faics.cmmn.egov.file.EgovFileMngUtil;
|
|
import kcg.faics.cmmn.file.FileUploadUtil;
|
|
import kcg.faics.cmmn.service.impl.CodeMapper;
|
|
import kcg.faics.equip.service.EquipmentService;
|
|
import kcg.faics.equip.vo.EquipSearchVO;
|
|
import kcg.faics.equip.vo.EquipVO;
|
|
|
|
/**
|
|
* FaEquipmentServiceImpl.java
|
|
* @author 임새미
|
|
* @since 2016. 10. 13.
|
|
*
|
|
* 수정일 수정자 수정내용
|
|
* ------------- -------- ---------------------------
|
|
* 2016. 10. 13. 임새미 최초생성
|
|
*
|
|
*/
|
|
@Service("equipmentService")
|
|
public class EquipmentServiceImpl implements EquipmentService {
|
|
|
|
@Resource(name = "equipmentMapper")
|
|
EquipmentMapper equipmentMapper;
|
|
|
|
@Resource(name = "codeMapper")
|
|
CodeMapper codeMapper;
|
|
|
|
/**
|
|
* EgovFileMngUtil - 파일 업로드 처리에 관한 Util 클래스
|
|
**/
|
|
@Resource(name = "EgovFileMngUtil")
|
|
private EgovFileMngUtil fileUtil;
|
|
|
|
/**
|
|
* BoardFileService - 게시판 파일에 관한 인터페이스
|
|
**/
|
|
@Resource(name = "boardFileService")
|
|
private BaseFileService<BoardFileVO> boardFileService;
|
|
|
|
/**
|
|
* 파일 업로드 유틸리티.
|
|
*/
|
|
@Resource(name = "fileUploadUtil")
|
|
private FileUploadUtil fileUploadUtil;
|
|
|
|
/**
|
|
* 전자정부 표준프레임워크 파일관리 유틸리티.
|
|
*/
|
|
@Resource(name = "EgovFileMngUtil")
|
|
private EgovFileMngUtil fileMngUtil;
|
|
|
|
/**
|
|
* 사용자 사진 저장 경로.
|
|
*/
|
|
public static final String EQUIP_SAVE_PATH = "Equip.fileStorePath";
|
|
|
|
/**
|
|
* 외사 경찰의 장비 보유 현황을 가져온다.
|
|
*
|
|
* @return 결과 데이터를 담은 map 리스트
|
|
*/
|
|
@Override
|
|
public List<HashMap<String, Object>> getEquipmentList() throws Exception {
|
|
HashMap<String, Object> params = new HashMap<String, Object>();
|
|
params.put("place1", codeMapper.getPlace1List(true));
|
|
return equipmentMapper.getEquipmentList(params);
|
|
}
|
|
|
|
/**
|
|
* 외사장비의 사용실적을 가져온다.
|
|
*
|
|
* @param params 파라미터 맵
|
|
* type - 사용 or 점검, year - 대상 연도, quater - 대상 분기
|
|
* @return 결과 데이터를 담은 map 리스트
|
|
*/
|
|
@Override
|
|
public List<HashMap<String, Object>> getEquipUseStateList(final EquipSearchVO searchVO) throws Exception {
|
|
List<HashMap<String, Object>> result = null;
|
|
HashMap<String, Object> params = new HashMap<String, Object>();
|
|
|
|
params.put("place1", codeMapper.getPlace1List(true));
|
|
params.put("criteria", searchVO);
|
|
params.put("type", (searchVO.getType().equals("a")) ? "EU_CNT" : "EU_CHECK");
|
|
|
|
result = equipmentMapper.getEquipUseStateList(params);
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
/**
|
|
* 외사장비의 사용실적 기록 연도 리스트를 가져온다.
|
|
*
|
|
* @return 결과 데이터를 담은 map 리스트
|
|
*/
|
|
@Override
|
|
public List<HashMap<String, Object>> getEquipYearList() throws Exception {
|
|
List<HashMap<String, Object>> result = null;
|
|
result = equipmentMapper.getEquipYearList();
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* 외사장비 목록 가져온다.
|
|
*
|
|
* @return 결과 데이터를 담은 map 리스트
|
|
*/
|
|
@Override
|
|
public List<HashMap<String, Object>> getEquipmentCodeList() throws Exception {
|
|
List<HashMap<String, Object>> result = null;
|
|
result = equipmentMapper.getEquipmentCodeList();
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* 선택한 조건에 해당되는 사용실적을 가져온다.
|
|
*
|
|
* @param params 파라미터 맵
|
|
* place1 - 기관코드 or 점검, year - 대상 연도, quater - 대상 분기
|
|
* @return 리턴값 설명
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@Override
|
|
public List<HashMap<String, Object>> getEquipUseStateInfo(EquipSearchVO searchVO) throws Exception {
|
|
List<HashMap<String, Object>> result = null;
|
|
result = equipmentMapper.getEquipUseStateInfo(searchVO);
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* 사용실적을 입력 or 수정한다.
|
|
*
|
|
* @param paramMap 장비별 실적 리스트
|
|
* @return 결과 데이터를 담은 map 리스트
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@Override
|
|
@Transactional
|
|
public int insertEquipUseState(final EquipSearchVO searchVO, final HashMap<String, HashMap<String, Object>> paramMap) throws Exception {
|
|
int success = 0;
|
|
|
|
Set<String> keySet = paramMap.keySet();
|
|
Iterator<String> it = keySet.iterator();
|
|
while (it.hasNext()) {
|
|
HashMap<String, Object> value = paramMap.get(it.next());
|
|
HashMap<String, Object> record = equipmentMapper.getEquipUseStateInfoByCode(value);
|
|
boolean isInsert = record == null;
|
|
|
|
if (isInsert) {
|
|
success = equipmentMapper.insertEquipUseState(value);
|
|
} else {
|
|
success = equipmentMapper.updateEquipUseState(value);
|
|
}
|
|
|
|
if (success != 1) {
|
|
throw new Exception();
|
|
}
|
|
}
|
|
return success;
|
|
};
|
|
|
|
/**
|
|
* 외사장비 목록 조회
|
|
*
|
|
* @param arrestSearchVO
|
|
* @return 외사장비목록 반환
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@Override
|
|
public List<EquipVO> getEquipList(final EquipSearchVO EquipSearchVO) throws Exception {
|
|
|
|
return equipmentMapper.getEquipList(EquipSearchVO);
|
|
}
|
|
|
|
/**
|
|
* 외사장비 목록 조회
|
|
*
|
|
* @param arrestSearchVO
|
|
* @return 외사장비단건 반환
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@Override
|
|
public EquipVO getEquipment(final EquipVO equipVO) throws Exception {
|
|
|
|
return equipmentMapper.getEquipment(equipVO);
|
|
}
|
|
|
|
/**
|
|
* 외사장비 등록
|
|
*
|
|
* @param equipVO
|
|
* @return 외사장비목록 반환
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@Override
|
|
public HashMap<String, Object> insertEquipment(final EquipVO equipVO, final Map<String, MultipartFile> fileMap) throws Exception {
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
try{
|
|
|
|
|
|
/* 파일 업로드 */
|
|
//BoardFileVO boardFileVO = BoardVOHandler.getBFileVO("EQUIPMENT", serNo, 0);
|
|
//result = boardFileService.insertAndSaveFiles(boardFileVO, fileMap);
|
|
|
|
|
|
|
|
|
|
if (fileMap != null && fileMap.get("file1").getSize() > 0) {
|
|
String fileName1 = fileUploadUtil.uploadWithExt(fileMap.get("file1"), EQUIP_SAVE_PATH);
|
|
System.out.println("fileName1 : " + fileName1);
|
|
equipVO.setFileName1(fileName1);
|
|
}
|
|
if (fileMap != null && fileMap.get("file2").getSize() > 0) {
|
|
String fileName2 = fileUploadUtil.uploadWithExt(fileMap.get("file2"), EQUIP_SAVE_PATH);
|
|
equipVO.setFileName2(fileName2);
|
|
}
|
|
if (fileMap != null && fileMap.get("file3").getSize() > 0) {
|
|
String fileName3 = fileUploadUtil.uploadWithExt(fileMap.get("file3"), EQUIP_SAVE_PATH);
|
|
equipVO.setFileName3(fileName3);
|
|
}
|
|
|
|
map = equipmentMapper.insertEquipment(equipVO);
|
|
|
|
if ((Integer)map.get("result") != 1) {
|
|
throw new Exception();
|
|
} else {
|
|
map.put("result", 1);
|
|
}
|
|
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
|
|
return map;
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 외사장비 삭제
|
|
*
|
|
* @param equipVO
|
|
* @return 처리결과 반환
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@Override
|
|
public HashMap<String, Object> deleteEquipment(final EquipVO equipVO) throws Exception {
|
|
try{
|
|
/* 파일을 삭제한다. */
|
|
//boardFileService.deleteAndRemoveFiles(BoardVOHandler.getBFileVO(boardVO)(equipVO));
|
|
}catch(Exception e){
|
|
|
|
}
|
|
return equipmentMapper.deleteEquipment(equipVO);
|
|
}
|
|
|
|
/**
|
|
* 외사장비 수정
|
|
*
|
|
* @param equipVO
|
|
* @return 처리결과 반환
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@Override
|
|
public HashMap<String, Object> updateEquipment(final EquipVO dataVO, final Map<String, MultipartFile> fileMap, final String[] deleteFiles) throws Exception {
|
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
|
|
try{
|
|
System.out.println(deleteFiles);
|
|
|
|
|
|
if( deleteFiles != null ){
|
|
for (int i = 0; i < deleteFiles.length; i++) {
|
|
if( deleteFiles[i].equals("1") ){
|
|
if (dataVO.getFileName1() != null || dataVO.getFileName1().equals("")) {
|
|
fileMngUtil.deleteFile(dataVO.getFileName1(), EQUIP_SAVE_PATH);
|
|
dataVO.setFileName1(null);
|
|
}
|
|
}else if( deleteFiles[i].equals("2") ){
|
|
// file2 삭제
|
|
if (dataVO.getFileName2() != null || dataVO.getFileName2().equals("")) {
|
|
fileMngUtil.deleteFile(dataVO.getFileName2(), EQUIP_SAVE_PATH);
|
|
dataVO.setFileName2(null);
|
|
}
|
|
}else if( deleteFiles[i].equals("3") ){
|
|
// file3 삭제
|
|
if (dataVO.getFileName3() != null || dataVO.getFileName2().equals("")) {
|
|
fileMngUtil.deleteFile(dataVO.getFileName2(), EQUIP_SAVE_PATH);
|
|
dataVO.setFileName3(null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if( fileMap != null ){
|
|
if ( fileMap.get("file1") != null ) {
|
|
if( fileMap.get("file1").getSize() > 0){
|
|
String fileName1 = fileUploadUtil.uploadWithExt(fileMap.get("file1"), EQUIP_SAVE_PATH);
|
|
System.out.println("fileName1 : " + fileName1);
|
|
dataVO.setFileName1(fileName1);
|
|
}
|
|
}
|
|
|
|
if ( fileMap.get("file2") != null ) {
|
|
if( fileMap.get("file2").getSize() > 0){
|
|
String fileName2 = fileUploadUtil.uploadWithExt(fileMap.get("file2"), EQUIP_SAVE_PATH);
|
|
dataVO.setFileName2(fileName2);
|
|
}
|
|
}
|
|
if ( fileMap.get("file3") != null ) {
|
|
if( fileMap.get("file3").getSize() > 0){
|
|
String fileName3 = fileUploadUtil.uploadWithExt(fileMap.get("file3"), EQUIP_SAVE_PATH);
|
|
dataVO.setFileName3(fileName3);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
map = equipmentMapper.updateEquipment(dataVO);
|
|
|
|
if ((Integer)map.get("result") != 1) {
|
|
throw new Exception();
|
|
} else {
|
|
map.put("result", 1);
|
|
}
|
|
|
|
}catch(Exception e){
|
|
|
|
|
|
}
|
|
|
|
return map;
|
|
}
|
|
}
|