diff --git a/src/main/java/geoinfo/drilling/input/DrillingInputController.java b/src/main/java/geoinfo/drilling/input/DrillingInputController.java index 56cad1e3..1d4f1bf2 100644 --- a/src/main/java/geoinfo/drilling/input/DrillingInputController.java +++ b/src/main/java/geoinfo/drilling/input/DrillingInputController.java @@ -455,4 +455,83 @@ public class DrillingInputController { return jsonResult; // @ResponseBody이므로 반환 값은 필요 없습니다. } + + /** + * 발주기관 건설현장 삭제처리 + * @param request + * @param strJSON + * @param response + * @return + */ + @RequestMapping(value = "/drilling/input/delete.do", method = RequestMethod.POST) + @ResponseBody + public JSONObject drillingInputDelete(HttpServletRequest request,@RequestParam HashMap params, HttpServletResponse response) { + + JSONObject jSONOResponse = new JSONObject(); + + System.out.println( + "\n--------------------------------------------------------------\n" + + request.getRequestURI() + " IN:" + + "\n--------------------------------------------------------------\n" + +// "jstrJSON: \n" + strJSON + "\n" + + "params: \n" + params + "\n" + + "\n--------------------------------------------------------------\n" + ); + + JSONParser jsonParser = new JSONParser(); + JSONArray jsonArr = null; + boolean isFail = false; + String failMsg = ""; + + try { + +// HashMap hashMap = drillingInputService.drillingInputDel(request, response, params); + drillingInputService.drillingInputDel(request, response, params); + int nRetCode = MyUtil.getIntegerFromObject(params.get("v_RetCode")); + String lpszRetMsg = MyUtil.getStringFromObject(params.get("v_RetMsg")); + + if( nRetCode == 100 ) { + jSONOResponse.put("resultCode", nRetCode); + jSONOResponse.put("result", "true"); + jSONOResponse.put("message", "삭제가 완료되었습니다."); + } else { + jSONOResponse.put("resultCode", nRetCode); + jSONOResponse.put("result", "false"); + jSONOResponse.put("message", lpszRetMsg); + + isFail = true; + failMsg = lpszRetMsg; + } + + } catch (Exception e) { + // TODO Auto-generated catch block + String strTxt = + "---------- BUG REPORTING START ----------" + "\n" + + "에러 문구:[" + request.getRequestURI() + " " + "]" + "\n" + + "params:[\n" + params + "\n]\n" + + "e.getMessage():[\n" + e.getMessage() + "\n]\n" + "\n" + + "new Date().toString():[" + new Date().toString() + "]\n" + "\n" + + "---------- BUG REPORTING END ----------" + "\n" + + ""; + System.out.println(strTxt); + jSONOResponse.put("resultCode", -1); + jSONOResponse.put("result", "false"); + jSONOResponse.put("message", e.getMessage()); + } + + if( isFail ) { + jSONOResponse.put("resultCode", -2); + jSONOResponse.put("result", "false"); + jSONOResponse.put("message", failMsg); + } + + System.out.println("\n--------------------------------------------------------------\n" + + request.getRequestURI() + " OUT:" + + "\n--------------------------------------------------------------\n" + + "jSONOResponse.toJSONString():[" + jSONOResponse.toJSONString() + "]\n" + + "\n--------------------------------------------------------------\n"); + + return jSONOResponse; + } + } diff --git a/src/main/java/geoinfo/drilling/input/service/DrillingInputMapper.java b/src/main/java/geoinfo/drilling/input/service/DrillingInputMapper.java index 5a0b65c8..3691b1f1 100644 --- a/src/main/java/geoinfo/drilling/input/service/DrillingInputMapper.java +++ b/src/main/java/geoinfo/drilling/input/service/DrillingInputMapper.java @@ -10,6 +10,7 @@ import egovframework.rte.psl.dataaccess.util.EgovMap; @Mapper("drillingInputMapper") public interface DrillingInputMapper { public HashMap spAddTblCsi(HashMap params) throws SQLException; + public HashMap spDelTblCsi(HashMap params) throws SQLException; public String test(HashMap params) throws SQLException; public Long findConstCompanyCodeByConstCompanyName(HashMap params) throws SQLException; diff --git a/src/main/java/geoinfo/drilling/input/service/DrillingInputService.java b/src/main/java/geoinfo/drilling/input/service/DrillingInputService.java index 8992e0ed..c720ed05 100644 --- a/src/main/java/geoinfo/drilling/input/service/DrillingInputService.java +++ b/src/main/java/geoinfo/drilling/input/service/DrillingInputService.java @@ -16,6 +16,7 @@ import egovframework.rte.psl.dataaccess.util.EgovMap; public interface DrillingInputService { HashMap getOrganizationUserGlGmGsGfCodes(String userId) throws Exception; HashMap drillingInputAdd(HttpServletRequest request, HttpServletResponse response, HashMap params) throws Exception; + HashMap drillingInputDel(HttpServletRequest request, HttpServletResponse response, HashMap params) throws Exception; List selectConstructCompanyList(HashMap params) throws Exception; Map selectConstructUserInfo(HashMap params) throws Exception; void getDepartments(HttpServletRequest request, HashMap params, JSONObject jsonResponse) throws Exception; diff --git a/src/main/java/geoinfo/drilling/input/service/impl/DrillingInputServiceImpl.java b/src/main/java/geoinfo/drilling/input/service/impl/DrillingInputServiceImpl.java index 7659f36f..b20d1908 100644 --- a/src/main/java/geoinfo/drilling/input/service/impl/DrillingInputServiceImpl.java +++ b/src/main/java/geoinfo/drilling/input/service/impl/DrillingInputServiceImpl.java @@ -119,6 +119,31 @@ public class DrillingInputServiceImpl implements DrillingInputService { } + @Override + public HashMap drillingInputDel(HttpServletRequest request, HttpServletResponse response, HashMap params) throws Exception { + params.put("CID", params.get("cid")); + + JSONObject tempConstructSiteInfo = drillingInquiryService.drillingInquiryOneItem(request, params); + // JSONObject를 HashMap으로 변환 + ArrayList arrayList = (ArrayList) MyUtil.JSONObjectToHashMap( tempConstructSiteInfo ).get("datas"); + HashMap oldTempConstructSiteInfo = new HashMap(arrayList.get(0)); + + // 기업사용자 입력 진행 여부: !NULL -> 입력 전, NULL -> 입력 중(삭제불가) + EgovMap constCompanyProjectWriting = drillingInputMapper.selectConstructCompanyProjectWriting(oldTempConstructSiteInfo); + if (!"0".equals(oldTempConstructSiteInfo.get("projectStateCode")) && constCompanyProjectWriting == null) { // 5-1) + params.put("v_RetCode", 11); + params.put("v_RetMsg", "해당 프로젝트는 기업 사용자가 입력을 시작하였으므로 삭제가 불가합니다."); + return params; + } else { // 5-2) + deleteTempMetaInfo(oldTempConstructSiteInfo); + deleteTempProjectInfo(oldTempConstructSiteInfo); + oldTempConstructSiteInfo.put("PROJECT_STATE_CODE", "0"); + updateTempConstructSiteInfoSetPROJECT_CODE_NULL(oldTempConstructSiteInfo); + params = drillingInputMapper.spDelTblCsi(params); + } + return params; + } + @Override public List selectConstructCompanyList(HashMap params) throws Exception { List list = new ArrayList(); diff --git a/src/main/resources/egovframework/sqlmap/mapper/drilling/input/DrillingInputMapper.xml b/src/main/resources/egovframework/sqlmap/mapper/drilling/input/DrillingInputMapper.xml index 0cf24483..f9a0a1a1 100644 --- a/src/main/resources/egovframework/sqlmap/mapper/drilling/input/DrillingInputMapper.xml +++ b/src/main/resources/egovframework/sqlmap/mapper/drilling/input/DrillingInputMapper.xml @@ -40,6 +40,14 @@ #{v_RetMsg, mode=OUT, jdbcType=VARCHAR} ) } + +