From 1047cbe2be6c76988d53ce544b7b326e9dbad5aa Mon Sep 17 00:00:00 2001 From: thkim Date: Tue, 20 Aug 2024 11:57:42 +0900 Subject: [PATCH] . --- .gitignore | 4 - .../inquiry/DrillingInquiryController.java | 103 +++++--- .../impl/DrillingInquiryServiceImpl.java | 132 ++++++---- .../views/drilling/input/drilling_input.jsp | 2 +- .../drilling/inquiry/drilling_inquiry.jsp | 244 +++++------------- 5 files changed, 210 insertions(+), 275 deletions(-) diff --git a/.gitignore b/.gitignore index 57e4d2b3..aa217c17 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ /target -#/src/main/webapp/**/**.jar -#/src/main/webapp/**/**.class HELP.md @@ -14,7 +12,6 @@ build/ .apt_generated .classpath .factorypath -#.project .settings .springBeans .sts4-cache @@ -64,7 +61,6 @@ out/ .mtj.tmp/ # Package Files # -#*.jar *.war *.nar *.ear diff --git a/src/main/java/geoinfo/drilling/inquiry/DrillingInquiryController.java b/src/main/java/geoinfo/drilling/inquiry/DrillingInquiryController.java index a1ecc9f6..3f0726b1 100644 --- a/src/main/java/geoinfo/drilling/inquiry/DrillingInquiryController.java +++ b/src/main/java/geoinfo/drilling/inquiry/DrillingInquiryController.java @@ -5,6 +5,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.text.ParseException; @@ -29,6 +30,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestBody; @@ -55,64 +57,83 @@ import ictway.whois.whoisSMS; @Controller public class DrillingInquiryController { - private static final Logger LOGGER = LoggerFactory.getLogger(DrillingInquiryController.class); + private static final Logger LOGGER = LoggerFactory.getLogger(DrillingInquiryController.class); - @Autowired + @Autowired DrillingInquiryService drillingInquiryService; - - @RequestMapping(value = "/drilling/inquiry.do") - public String memberRegi(@RequestParam HashMap params, ModelMap model, HttpServletRequest request, HttpServletResponse response) throws Exception { - if(request.getSession().getAttribute("USERNAME") == null){ - return "isError"; - } + @RequestMapping(value = "/drilling/inquiry.do") + public String memberRegi(@RequestParam HashMap params, ModelMap model, HttpServletRequest request, HttpServletResponse response) throws Exception { - return "/drilling/inquiry/drilling_inquiry"; - } - - @RequestMapping(value = "/drilling/inquiry/list.do", method = RequestMethod.GET) - @ResponseBody - public JSONObject drillingInquiryList ( - HttpServletRequest request, - @RequestParam HashMap params, + if(request.getSession().getAttribute("USERNAME") == null){ + return "isError"; + } + + return "/drilling/inquiry/drilling_inquiry"; + } + + @RequestMapping(value = "/drilling/inquiry/list.do", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" }) + @ResponseBody + public ResponseEntity drillingInquiryList ( + HttpServletRequest request, + @RequestParam HashMap params, HttpServletResponse response ) { - - System.out.println( - "\n--------------------------------------------------------------\n" + + + System.out.println( + "\n--------------------------------------------------------------\n" + request.getRequestURI() + " IN:" + "\n--------------------------------------------------------------\n" + "params" + params.toString() + "\n" + "\n--------------------------------------------------------------\n" ); - - JSONObject jSONOResponse = null; + + JSONObject jSONOResponse = null; try { - jSONOResponse = drillingInquiryService.drillingInquiryList( request, params ); - } catch (Exception e) { - // TODO Auto-generated catch block - jSONOResponse = new JSONObject(); - String strTxt = - "---------- BUG REPORTING START ----------" + "\n" + + jSONOResponse = drillingInquiryService.drillingInquiryList( request, params ); + } catch (Exception e) { + // TODO Auto-generated catch block + jSONOResponse = new JSONObject(); + String strTxt = + "---------- BUG REPORTING START ----------" + "\n" + "에러 문구:[" + request.getRequestURI() + " " + "]" + "\n" + "params:[\n" + params.toString() + "\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()); - } - - - System.out.println("\n--------------------------------------------------------------\n" + - request.getRequestURI() + " OUT:" + - "\n--------------------------------------------------------------\n" + - "jSONOResponse.toJSONString():[" + jSONOResponse.toJSONString() + "]\n" + - "\n--------------------------------------------------------------\n"); + System.out.println(strTxt); + jSONOResponse.put("resultCode", -1); + jSONOResponse.put("result", "false"); + jSONOResponse.put("message", e.getMessage()); + } - return jSONOResponse; - } + + System.out.println("\n--------------------------------------------------------------\n" + + request.getRequestURI() + " OUT:" + + "\n--------------------------------------------------------------\n" + + "jSONOResponse.toJSONString():[" + jSONOResponse.toJSONString() + "]\n" + + "\n--------------------------------------------------------------\n"); + + + int contentLength = 0; + try { + contentLength = jSONOResponse.toJSONString().getBytes("UTF-8").length; + } catch (UnsupportedEncodingException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + response.setStatus(HttpServletResponse.SC_OK); + response.setCharacterEncoding("UTF-8"); + response.setHeader("Content-Type", "application/json; charset=utf-8"); + response.setContentLength(contentLength); // Content-Length 설정 + try { + response.getWriter().print(jSONOResponse); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } } diff --git a/src/main/java/geoinfo/drilling/inquiry/service/impl/DrillingInquiryServiceImpl.java b/src/main/java/geoinfo/drilling/inquiry/service/impl/DrillingInquiryServiceImpl.java index 192b8d37..039c733a 100644 --- a/src/main/java/geoinfo/drilling/inquiry/service/impl/DrillingInquiryServiceImpl.java +++ b/src/main/java/geoinfo/drilling/inquiry/service/impl/DrillingInquiryServiceImpl.java @@ -4,6 +4,9 @@ import geoinfo.drilling.inquiry.service.DrillingInquiryMapper; import geoinfo.drilling.inquiry.service.DrillingInquiryService; import java.sql.SQLException; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -18,46 +21,67 @@ import org.springframework.stereotype.Service; @Service("drillingInquiryService") public class DrillingInquiryServiceImpl implements DrillingInquiryService { - - @Resource(name="drillingInquiryMapper") - private DrillingInquiryMapper drillingInquiryMapper; - - @Override - public JSONObject drillingInquiryList(HttpServletRequest request, HashMap params) throws Exception { - - JSONObject jsonResponse = new JSONObject(); - - try { - - try { - Long count = drillingInquiryMapper.sPCntTblCsiByKeyword(params); - List> data = drillingInquiryMapper.sPGetTblCsiByKeyword(params); - jsonResponse.put("count", count); - jsonResponse.put("data", data); - return jsonResponse; - } catch (SQLException e) { - throw new Exception( e.getMessage() ); + @Resource(name="drillingInquiryMapper") + private DrillingInquiryMapper drillingInquiryMapper; + + + @Override + public JSONObject drillingInquiryList(HttpServletRequest request, HashMap params) throws Exception { + + JSONObject jsonResponse = new JSONObject(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + try { + + try { + Long count = drillingInquiryMapper.sPCntTblCsiByKeyword(params); + List> datas = drillingInquiryMapper.sPGetTblCsiByKeyword(params); + + String crtDtKey = "crtDt"; + + for( HashMap data : datas ) { + + + //TIMESTAMP oracleTimestamp = (TIMESTAMP)data.get(crtDtKey); + //Timestamp javaTimestamp = oracleTimestamp.timestampValue(); + //String formattedDate = dateFormat.format(javaTimestamp); + //data.put(crtDtKey, formattedDate); + } + jsonResponse.put("count", count); + jsonResponse.put("datas", datas); + return jsonResponse; + } catch (SQLException e) { + String strTxt = + "---------- BUG REPORTING START ----------" + "\n" + + "에러 문구:[" + request.getRequestURI() + " " + "]" + "\n" + + "params:[\n" + params.toString() + "\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); + throw new Exception( "오류가 발생하였습니다." + "\n" + "SQLException" ); } - - - } catch (org.json.simple.parser.ParseException e) { - // TODO Auto-generated catch block - throw new Exception( e.getMessage() ); - } - } - /* - * - * @Override - public JSONObject drillingInquiryList(HttpServletRequest request, String strJSON) throws Exception { - - JSONObject jsonResponse = new JSONObject(); - JSONParser jsonParser = new JSONParser(); - - try { - - JSONObject jsonObject = (JSONObject)jsonParser.parse(strJSON); - + + + } catch (org.json.simple.parser.ParseException e) { + // TODO Auto-generated catch block + throw new Exception( e.getMessage() ); + } + } + /* + * + * @Override + public JSONObject drillingInquiryList(HttpServletRequest request, String strJSON) throws Exception { + + JSONObject jsonResponse = new JSONObject(); + JSONParser jsonParser = new JSONParser(); + + try { + + JSONObject jsonObject = (JSONObject)jsonParser.parse(strJSON); + // JSONObject를 HashMap으로 변환 HashMap params = new HashMap<>(); for (Object key : jsonObject.keySet()) { @@ -65,23 +89,23 @@ public class DrillingInquiryServiceImpl implements DrillingInquiryService { Object value = jsonObject.get(keyStr); params.put(keyStr, value); } - - try { - Long count = drillingInquiryMapper.sPCntTblCsiByKeyword(params); - List> data = drillingInquiryMapper.sPGetTblCsiByKeyword(params); - jsonResponse.put("count", count); - jsonResponse.put("data", data); - return jsonResponse; - } catch (SQLException e) { + + try { + Long count = drillingInquiryMapper.sPCntTblCsiByKeyword(params); + List> data = drillingInquiryMapper.sPGetTblCsiByKeyword(params); + jsonResponse.put("count", count); + jsonResponse.put("data", data); + return jsonResponse; + } catch (SQLException e) { throw new Exception( e.getMessage() ); } - - - } catch (org.json.simple.parser.ParseException e) { - // TODO Auto-generated catch block - throw new Exception( e.getMessage() ); - } - } - */ + + + } catch (org.json.simple.parser.ParseException e) { + // TODO Auto-generated catch block + throw new Exception( e.getMessage() ); + } + } + */ } diff --git a/src/main/webapp/WEB-INF/views/drilling/input/drilling_input.jsp b/src/main/webapp/WEB-INF/views/drilling/input/drilling_input.jsp index 6664a3bd..0c103975 100644 --- a/src/main/webapp/WEB-INF/views/drilling/input/drilling_input.jsp +++ b/src/main/webapp/WEB-INF/views/drilling/input/drilling_input.jsp @@ -54,7 +54,7 @@ if (request.getSession().getAttribute("CLS") == null || "2".equals(request.getSe 사업명 - + diff --git a/src/main/webapp/WEB-INF/views/drilling/inquiry/drilling_inquiry.jsp b/src/main/webapp/WEB-INF/views/drilling/inquiry/drilling_inquiry.jsp index de852404..7cd3e2e0 100644 --- a/src/main/webapp/WEB-INF/views/drilling/inquiry/drilling_inquiry.jsp +++ b/src/main/webapp/WEB-INF/views/drilling/inquiry/drilling_inquiry.jsp @@ -11,7 +11,7 @@ if (request.getSession().getAttribute("USERID") == null) { %> <% - return; + return; } %> <% @@ -21,7 +21,7 @@ if (request.getSession().getAttribute("CLS") == null || "2".equals(request.getSe %> <% - return; + return; } %> @@ -36,46 +36,69 @@ if (request.getSession().getAttribute("CLS") == null || "2".equals(request.getSe @@ -88,8 +111,8 @@ if (request.getSession().getAttribute("CLS") == null || "2".equals(request.getSe

건설현장 관리

프로젝트 조회

-

건설현장 조회

-

건설현장 입력

+

건설현장 조회

+

건설현장 입력

@@ -113,13 +136,13 @@ if (request.getSession().getAttribute("CLS") == null || "2".equals(request.getSe