package kcg.faics.inter.web; import java.util.Calendar; import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import javax.annotation.Resource; import kcg.faics.cmmn.excel.ExcelExporter; import kcg.faics.cmmn.service.CodeService; import kcg.faics.cmmn.vo.CodeVO; import kcg.faics.inter.service.InternationalService; import kcg.faics.inter.vo.InternationalSearchVO; import kcg.faics.inter.vo.InternationalVO; import kcg.faics.sec.AuthType; import kcg.faics.sec.LoginUserVO; import kcg.faics.sec.filter.ReloadableFilterInvocationSecurityMetadataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; 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.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.support.SessionStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @FileName : InternationalController.java * @Project : 국제해양프로젝트 * @Date : 2018. 5. 8. * @작성자 : Moon * @변경이력 : * @프로그램 설명 : */ @Controller @RequestMapping("/inter") public class InternationalController { protected static Logger log = LoggerFactory.getLogger(InternationalController.class); /** * 코드관련 정보 인터페이스. */ @Resource(name = "codeService") private CodeService codeService; /** * 나포정보 인터페이스. */ @Resource(name = "internationalService") private InternationalService internationalService; /** * 국제어선 나포정보 목록화면을 반환한다. * @param arrestSearchVo 나포정보검색객체 * @param model 모델객체 * @return 국제어선 검거현황 목록화면 * @throws Exception 기본예외처리 */ @RequestMapping(value = "/arrestListView.do") public String arrestListView(final InternationalSearchVO arrestSearchVo, Model model) throws Exception { try { // 공통코드 조회 model = getCommonCode(model); // 국제어선 나포정보 목록 조회 //arrestList = internationalService.getArrestListAll(arrestSearchVo); // 국제어선 나포정보 목록 집계정보 조회(단건) //arrestCntList = internationalService.getArrestListAllCount(arrestSearchVo); model.addAttribute("listFlag", "init"); } catch (Exception e) { e.printStackTrace(); } return "/inter/arrestList.tiles"; } /** * 국제어선 나포정보 목록 검색결과를 반환한다. * * @param internationalSearchVO 견문 검색 객체 * @param model 모델객체 * @return 견문검색결과화면 * @throws Exception 기본예외처리 */ @RequestMapping(value = "/arrestList.do") public String arrestList(@ModelAttribute final InternationalSearchVO internationalSearchVO, Model model) throws Exception { List internationalList = null; // 국제어선나포정보목록 InternationalVO internationalCntList = null; // 국제어선나포정보 집계건수 HashMap resultMap = new HashMap(); try { // 공통코드 조회 // model = getCommonCode(model); model.addAttribute("internationalList", null); model.addAttribute("internationalCntList", null); // 국제어선 나포정보 목록 조회 internationalList = internationalService.getArrestList(internationalSearchVO); if (internationalList.size() > 0) { // 국제어선 나포정보 집계정보 조회 internationalCntList = internationalService.getArrestListCount(internationalSearchVO); } else { internationalCntList = null; } model.addAttribute("internationalList", internationalList); model.addAttribute("internationalCntList", internationalCntList); model.addAttribute("internationalSearchVO", internationalSearchVO); resultMap.put("msg", "정상으로 조회되었습니다."); resultMap.put("code", 0); } catch (Exception e) { e.printStackTrace(); } return "/inter/arrestResult"; } /** * 국제어선 나포정보 화면에서 필요한 공통코드를 조회한다. * * @param model 화면에 넘길 Model 객체 * @return model 객체 * @throws Exception 기본예외처리 */ public Model getCommonCode(final Model model) throws Exception { List agencyTypeList = null; // 기관종류 List placeList = null; // 소속 List addressList = null; // 주소 List violateTypeList = null; // 위반내용구분 List shipTypeList = null; // 선종 List shipMentList = null; // 선적 List shipQualityList = null; // 선질 List shipProcTypeList = null; // 선박처리 List invasionTypeList = null; // 침범유형 List woDetentionTypeList = null; // 무혐의불구속 List marginPaymentYnList = null; // 범죄유형 //List foreignCrew = null; // 외국선원 List transportation = null; // 외국선원 List itemTest = null; // 밀수입 품목 List smugglingName = null; // 밀수출 품목 List remarksList = null; List aviolentcrime = null;// 강력범죄 List violentcrime = null; // 폭력범죄 List intelligentcrime = null; // 지능범죄 List theftcrime = null; // 절도범죄 List directSmuggling = null; // 직접밀입국 이동수단 List speciallaw = null; List ar01List = null; // 범죄유형_해양국경관리 List ar02List = null; // 범죄유형_통상질서교란 List ar03List = null; // 범죄유형_국입산업보호 List ar04List = null; // 범죄유형_국민사회안전 List ar05List = null; // 범죄유형_외국인관련범죄 LoginUserVO loginUserVo = new LoginUserVO(); try { if (AuthType.LOCAL_HEADQUARTERS == loginUserVo.getAuthType()) { placeList = codeService.getPlace1SubList(loginUserVo.getPlace1()); } else { placeList = codeService.getPlace1List(false); } ar01List = codeService.getCodeValues("AR01", ""); ar02List = codeService.getCodeValues("AR02", ""); ar03List = codeService.getCodeValues("AR03", ""); ar04List = codeService.getCodeValues("AR04", ""); ar05List = codeService.getCodeValues("AR05", ""); agencyTypeList = codeService.getCodeValues("T010", ""); /* 검거기관대분류 */ addressList = internationalService.getAddressAreaList("0000"); /* 주소(특별광역시도) */ violateTypeList = codeService.getCodeValues("T003", ""); /* 위반내용구분 */ shipTypeList = codeService.getCodeValues("FA81", ""); /* 선종 조회 */ shipMentList = codeService.getCodeValues("SSRR", ""); /* 선적 */ shipQualityList = codeService.getCodeValues("T004", ""); /* 선질 */ shipProcTypeList = codeService.getCodeValues("T007", ""); /* 선박처리 */ invasionTypeList = codeService.getCodeValues("T006", ""); /* 선박처리 */ woDetentionTypeList = codeService.getCodeValues("T005", ""); /* 선박처리 */ /*marginPaymentYnList = codeService.getCodeValues("T008", ""); 담보금납부여부 */ marginPaymentYnList = codeService.getCodeValues("T009", ""); /* 범죄유형 */ //foreignCrew = codeService.getCodeValues("CREW", ""); // 외국선원 transportation = codeService.getCodeValues("TRAN", ""); // 외국선원 itemTest = codeService.getCodeValues("TES1", ""); // 밀수입 품목 smugglingName = codeService.getCodeValues("TES2", ""); // 밀수입 품목 remarksList = codeService.getCodeValues("REMA", ""); // 비고 aviolentcrime = codeService.getCodeValues("AVIO", ""); // 강력범죄 violentcrime = codeService.getCodeValues("VIOL", ""); // 폭력범죄 intelligentcrime = codeService.getCodeValues("INTE", ""); // 지능범쥐 theftcrime = codeService.getCodeValues("THEF", ""); // 절도범죄 speciallaw = codeService.getCodeValues("SPEC", ""); // 특별법범 directSmuggling = codeService.getCodeValues("DIRT", ""); // 직접밀입국 이동수단 Collections.reverse(marginPaymentYnList); //Collections.sort(marginPaymentYnList, comparator); //CodeVO codeVO = marginPaymentYnList.get(1); //marginPaymentYnList.set(1, marginPaymentYnList.get(0)); //marginPaymentYnList.set(0, codeVO); model.addAttribute("ar01List", ar01List); model.addAttribute("ar02List", ar02List); model.addAttribute("ar03List", ar03List); model.addAttribute("ar04List", ar04List); model.addAttribute("ar05List", ar05List); model.addAttribute("placeList", placeList); model.addAttribute("addressList", addressList); model.addAttribute("shipQualityList", shipQualityList); model.addAttribute("shipMentList", shipMentList); model.addAttribute("shipTypeList", shipTypeList); model.addAttribute("violateTypeList", violateTypeList); model.addAttribute("agencyTypeList", agencyTypeList); model.addAttribute("shipProcTypeList", shipProcTypeList); model.addAttribute("invasionTypeList", invasionTypeList); model.addAttribute("woDetentionTypeList", woDetentionTypeList); model.addAttribute("marginPaymentYnList", marginPaymentYnList); log.trace("@@@@@@@ㅇㅅㅇㅅㅇㅅㅇㅅㅇㅅㅇㄴㅅㅇㅅㄴㅇㅅㄴㅇㅅㅇㅅㅇㅅㅇㅅㅇㅅㅇㅅㅇㅅㅇㅅㅇㅅㅇ"); //model.addAttribute("foreignCrew", foreignCrew); model.addAttribute("transportation", transportation); model.addAttribute("itemTest", itemTest); model.addAttribute("smugglingName", smugglingName); model.addAttribute("remarksList", remarksList); model.addAttribute("aviolentcrime", aviolentcrime); model.addAttribute("violentcrime", violentcrime); model.addAttribute("intelligentcrime", intelligentcrime); model.addAttribute("theftcrime", theftcrime); model.addAttribute("speciallaw", speciallaw); model.addAttribute("directSmuggling", directSmuggling); } catch (Exception e) { e.printStackTrace(); } return model; } /** * 국제어선 나포정보 등록/수정화면을 반환한다. * * @param internationalVO 견문 검색 객체 * @param model 모델객체 * @return 견문검색결과화면 * @throws Exception 기본예외처리 */ @RequestMapping(value = "/arrestAdd.do") public String arrestAdd(final InternationalVO internationalVO, Model model) throws Exception { try { // 공통코드 조회 model = getCommonCode(model); model.addAttribute("regFlag", "create"); } catch (Exception e) { e.printStackTrace(); } return "/inter/arrestAdd.tiles"; } /** * 국제어선 나포정보 목록화면을 반환한다. * * @param area 특별광역시도 코드 * @param internationalVO 나포정보검색객체 * @param model 모델객체 * @return 국제어선 검거현황 목록화면 * @throws Exception 기본예외처리 */ @RequestMapping(value = "/getAddressAreaList.do") public String getAddressAreaList(@RequestParam("area") final String area, final InternationalVO internationalVO, final Model model) throws Exception { HashMap result = new HashMap(); List addressCityList = null; try { /* 특별광역시&도청 목록조회 */ addressCityList = internationalService.getAddressAreaList(area); model.addAttribute("addressCityList", addressCityList); result.put("result", "OK"); result.put("msg", "시목록 조회성공"); } catch (Exception e) { e.printStackTrace(); } return "/inter/arrestAdd.tiles"; } /** * 하위소속 코드 리스트를 반환한다. * * @param codeVO * 코드VO * @return 소속 코드 리스트 * @throws Exception * 기본 예외 처리 */ @ResponseBody @RequestMapping("/getAddressList.json") public HashMap getAddressList(final CodeVO codeVO) throws Exception { HashMap result = new HashMap(); List addressCityList = null; String area = codeVO.getCode1(); /* 특별광역시&도청 목록조회 */ addressCityList = internationalService.getAddressAreaList(area); result.put("data", addressCityList); // model.addAttribute("addressCityList", addressCityList); return result; } /** * 국제어선 나포정보를 등록한다. * * @param internationalVO * 국제어선나포정보 객체 * @param bindingResult * 바인딩 객체 * @param model * 모델 객체 * @param status * 세선 상태 객체 * @return 게시물 화면 * @throws Exception * 기본 예외 처리 */ @RequestMapping(value = "/arrestInsert.do", method = RequestMethod.POST) public String arrestTempInsert( @ModelAttribute("internationalVO") final InternationalVO internationalVO, final BindingResult bindingResult, final Model model, final SessionStatus status) throws Exception { HashMap result = new HashMap(); try { internationalVO.setDelYn("N"); // 삭제여부 /* 국제어선 나포정보 등록 */ result = internationalService.insert(internationalVO); } catch (Exception e) { e.printStackTrace(); } if ((Integer) result.get("result") != 1) { return "redirect:/inter/arrestAdd.do"; } return "redirect:/inter/arrestListView.do"; } /** * 국제어선 나포정보를 수정한다. * @param internationalVO * 나포정보 객체 * @param bindingResult * 바인딩 객체 * @param model * 모델 객체 * @param status * 세선 상태 객체 * @return 게시물 화면 * @throws Exception * 기본 예외 처리 */ @RequestMapping(value = "/arrestUpdate.do", method = RequestMethod.POST) public String arrestUpdate(@ModelAttribute("internationalVO") final InternationalVO internationalVO, final BindingResult bindingResult, final Model model, final SessionStatus status) throws Exception { HashMap result = new HashMap(); try { internationalVO.setDelYn("N"); // 삭제여부 result = internationalService.update(internationalVO); } catch (Exception e) { e.printStackTrace(); } if ((Integer) result.get("result") != 1) { return "redirect:/inter/arrestAdd.do"; } return "redirect:/inter/arrestListView.do"; } /** * 국제어선 나포정보를 삭제한다. * @param internationalVO * 외사경찰 정보 객체 * @param bindingResult * 바인딩 객체 * @param model * 모델 객체 * @param status * 세선 상태 객체 * @return 게시물 화면 * @throws Exception * 기본 예외 처리 */ @RequestMapping(value = "/arrestDelete.do", method = RequestMethod.POST) public String arrestDelete(@ModelAttribute("internationalVO") final InternationalVO internationalVO, final BindingResult bindingResult, final Model model, final SessionStatus status) throws Exception { HashMap result = new HashMap(); try { internationalVO.setDelYn("Y"); // 삭제여부 result = internationalService.delete(internationalVO); } catch (Exception e) { e.printStackTrace(); } if ((Integer) result.get("result") != 1) { return "redirect:/inter/arrestAdd.do"; } return "redirect:/inter/arrestListView.do"; } /** * 국제어선 나포정보를 반환한다. * * @param internationalVO * @param model 모델 객체 * @return 국제어선나포정보 수정화면 * @throws Exception 기본 예외 처리 */ @RequestMapping("/arrestView.do") public String arrestView(final InternationalVO internationalVO, Model model) throws Exception { try { // 국제어선 나포정보 단건조회 InternationalVO result = internationalService.select(internationalVO); // 공통코드 조회 model = getCommonCode(model); model.addAttribute("internationalVO", result); model.addAttribute("regFlag", "modify"); } catch (Exception e) { e.printStackTrace(); } return "/inter/arrestAdd.tiles"; } /** * 국제어선 나포처리현황 엑셀 다운로드 * @param searchVO * @param model Model객체 * @return 외사장비 사용실적 현황 */ @RequestMapping("/arrestExcelDownload.do") public String arrestExcelDownload(final InternationalSearchVO searchVO, final Model model) throws Exception { Calendar cal = Calendar.getInstance(); InternationalVO arrestCntList = null; String title = cal.get(cal.YEAR) + "년 국제어선 검거현황"; List arrestList = internationalService.getArrestListExcel(searchVO); if (arrestList.size() > 0) { arrestCntList = internationalService.getArrestListCount(searchVO); LinkedHashMap header = new LinkedHashMap(); header.put("arrestDate", "검거일시"); header.put("addrStr", "검거관서"); header.put("violateType", "사건개요"); header.put("violateDetail", "검거장소"); /*header.put("invasion3", "침범유형(영해)"); header.put("invasion4", "침범유형(검거장소)"); header.put("invasion1", "침범유형(검거장소)"); header.put("invasion2", "침범유형(검거장소)"); header.put("specBatlYn", "침범유형(검거장소)");*/ header.put("nllYn", "적용법조"); header.put("agencyGuardStr", "검거기관"); /*header.put("agencyVessel", "함정");*/ header.put("leadDistance", "검거인원(내국인)"); header.put("leadHour", "검거인원(외국인국적)"); header.put("leadMinute", "검거인원(비자종류)"); header.put("capName", "밀입증(무사증)_알선,운송"); header.put("capChnName", "밀입증(무사증)_불법이동자"); header.put("transportation", "밀입증(무사증)_이동수단"); header.put("otherMeansOfTransport", "밀입증(무사증)_기타이동수단"); header.put("arrangeTransport", "밀입국(직접밀입국)_알선,운송"); header.put("illegalMover", "밀입국(직접밀입국)_불법이동자"); header.put("directSmuggling", "밀입국(직접밀입국)_이동수단"); header.put("otherMeansOfDirect", "밀입국(직접밀입국)_기타이동수단"); header.put("foreignCrew", "밀입국(외국선원)"); header.put("itemTest", "밀수입(품목)"); header.put("quantity", "밀수입(수량kg)"); header.put("priceMoney", "밀수입(금액)"); header.put("targetCountry", "밀수입(대상국가)"); header.put("escapeChina", "밀출국(중국)_도피"); header.put("employmentChina", "밀출국(중국)_도피"); header.put("etcChina", "밀출국(중국)_도피"); header.put("escapeJapan", "밀출국(일본)_도피"); header.put("employmentJapan", "밀출국(일본)_도피"); header.put("etcJapan", "밀출국(일본)_도피"); header.put("escapeCountries", "밀출국(기타국가)_도피"); header.put("employmentCountries", "밀출국(기타국가)_도피"); header.put("etcCountries", "밀출국(기타국가)_도피"); header.put("smugglingName", "밀수출(품목)"); header.put("smugglingChn", "밀수출(수량kg)"); header.put("smugglingAge", "밀수출(금액)"); header.put("smugglingWorld", "밀수출(대상국가)"); header.put("spilltarget", "산업기술유출(유출대상)"); header.put("amountofcompensation", "산업기술유출(보상금액)"); header.put("intelProperty", "지식재산권(상표법_대상)"); header.put("quenching", "불법위폐,외국환거래(무등록외환)"); header.put("foreignCurrency", "불법위폐,외국환거래(외화밀반출)"); header.put("foreigncurrencyamount", "불법위폐,외국환거래(금액)"); header.put("noInsurance", "외국인인권보호(보험미가입)"); header.put("alienDamage", "외국인인권보호(외국인피해)"); header.put("originIndicationViolation", "원산지표시위반"); header.put("inhibitionOfSocialSafety", "사회 등 안전저해"); header.put("sailorPeople", "불법체류(선원)"); header.put("seamanOutside", "불법체류(선원외)"); header.put("drugadministration", "기타(마약)_투약"); header.put("carryonofdrugs", "기타(마약)_소지운반"); header.put("drugsale", "기타(마약)_판매"); header.put("drugitem", "기타(마약)_품목"); header.put("drugquantity", "기타(마약)_수량"); header.put("drugamount", "기타(마약)_금액"); header.put("aviolentcrime", "기타(외국인관련범죄)_강력범죄"); header.put("violentcrime", "기타(외국인관련범죄)_폭력범죄"); header.put("intelligentcrime", "기타(외국인관련범죄)_지능범죄"); header.put("theftcrime", "기타(외국인관련범죄)_절도범죄"); header.put("speciallaw", "기타(외국인관련범죄)_특별법범"); header.put("commissionCost", "비고"); arrestCntList.setDetentionTotalCnt(String.valueOf(arrestCntList.getCaptainCount() + arrestCntList.getMateCount() + arrestCntList.getEngineerCount() + arrestCntList.getCrewCount())); arrestCntList.setSpecBatlYn(String.valueOf(arrestCntList.getSpecBatlCnt())); arrestCntList.setNllYn(String.valueOf(arrestCntList.getNllCnt())); arrestCntList.setNoPaymentCnt(String.valueOf(arrestCntList.getNotPayment())); arrestList.add(0, arrestCntList); model.addAttribute("excel", new ExcelExporter(header, arrestList, title)); model.addAttribute("filename", title); return "excelView"; } else { return ""; } } }