feat: 신규 프로젝트 사업명 중복 검사
parent
7978ffaed0
commit
e0e04e891f
|
|
@ -2,15 +2,21 @@ package geoinfo.regi.projectList;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
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.servlet.ModelAndView;
|
||||
import org.springframework.web.util.UrlPathHelper;
|
||||
|
||||
|
|
@ -33,7 +39,47 @@ public class ProjectListController {
|
|||
@Resource(name = "headerService")
|
||||
private HeaderService headerService;
|
||||
|
||||
// 지반정보등록 (관리자)
|
||||
//프로젝트명 중복여부를 체크한다.
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/project-duplicate-check", method = RequestMethod.GET, produces = "application/json; charset=UTF-8")
|
||||
public String projectDuplicateCheck(HttpServletRequest request, HttpServletResponse response, @RequestParam HashMap<String,Object> params) throws Exception {
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
strUtil sUtil = new strUtil();
|
||||
|
||||
String projectName = sUtil.checkNull((String)params.get("projectName"));
|
||||
String isProjectNameChecking = sUtil.checkNull((String)params.get("isProjectNameChecking"));
|
||||
|
||||
|
||||
if(isProjectNameChecking != null && isProjectNameChecking.toLowerCase().equals("true") && projectName == ""){
|
||||
jsonObject.put("result", "false");
|
||||
jsonObject.put("resultCode", "The name is missing.");
|
||||
jsonObject.put("message", "사업명이 없습니다. 사업명을 입력해 주세요.");
|
||||
} else {
|
||||
params.put("PROJECT_NAME", projectName);
|
||||
// 사업명(프로젝트 명) 중복 검사를 수행한다.
|
||||
ArrayList<HashMap<String, Object>> arrProjectCodeAndProjectName = masterService.getProjectCodeAndProjectNameByProjectName(params);
|
||||
if( 0 < arrProjectCodeAndProjectName.size() ) {
|
||||
jsonObject.put("result", "false");
|
||||
jsonObject.put("resultCode", "The name already exists.");
|
||||
jsonObject.put("message", "해당 사업명이 이미 있습니다. 다른 사업명으로 입력해 주세요.");
|
||||
} else {
|
||||
jsonObject.put("result", "true");
|
||||
jsonObject.put("message", "");
|
||||
}
|
||||
}
|
||||
|
||||
response.setContentType("application/json; charset=UTF-8"); // 응답 헤더 설정
|
||||
response.setCharacterEncoding("UTF-8"); // 응답 데이터 인코딩 설정 (중요)
|
||||
|
||||
try (OutputStream os = response.getOutputStream()) { // OutputStream 사용
|
||||
os.write(jsonObject.toString().getBytes("UTF-8")); // UTF-8 인코딩하여 출력
|
||||
}
|
||||
|
||||
return null; // @ResponseBody이므로 반환 값은 필요 없습니다.
|
||||
}
|
||||
|
||||
// 지반정보등록
|
||||
@RequestMapping(value = "/insertMeta.do")
|
||||
public ModelAndView insertMeta(@RequestParam HashMap<String,Object> params, ModelAndView model ,HttpServletRequest request, HttpServletResponse response) throws Exception{
|
||||
UrlPathHelper urlPathHelper = new UrlPathHelper();
|
||||
|
|
@ -68,6 +114,8 @@ public class ProjectListController {
|
|||
prjCd=masterService.getProjectCd(params);
|
||||
oPROJECT_CODE=(String)prjCd.get("P_CODE")+prjCd.get("P_NUM");
|
||||
//System.out.println(oREPORT_TYPE);
|
||||
|
||||
|
||||
params.put("PROJECT_CODE", oPROJECT_CODE);
|
||||
params.put("PROJECT_NAME", oPROJECT_NAME);
|
||||
params.put("INPUT_COMPANY", oINPUT_COMPANY);
|
||||
|
|
@ -101,6 +149,27 @@ public class ProjectListController {
|
|||
params.put("PROJECT_HOLE_NUMBER", oHOLE_NUMBER);
|
||||
params.put("STATE", "4");
|
||||
params.put("REPORT_TYPE", "CH");
|
||||
|
||||
// 사업명(프로젝트 명) 중복 검사를 수행한다.
|
||||
|
||||
ArrayList<HashMap<String, Object>> arrProjectCodeAndProjectName = masterService.getProjectCodeAndProjectNameByProjectName(params);
|
||||
if( 0 < arrProjectCodeAndProjectName.size() ) {
|
||||
//여기에서 프로젝트 중복되어서 다른 이름으로 지정해야한다는 메시지를 사용자에게 보여줘야 함.
|
||||
model.addObject("result", "false");
|
||||
model.addObject("message", "해당 사업명이 이미 있습니다. 다른 사업명으로 입력 해주세요.");
|
||||
model.setViewName("redirect:/index_db.do");
|
||||
model.addObject("rUrl",rUrl);
|
||||
|
||||
response.setCharacterEncoding("euc-kr");
|
||||
PrintWriter writer = response.getWriter();
|
||||
writer.println("<script type='text/javascript'>");
|
||||
writer.println("alert('해당 사업명이 이미 있습니다. 다른 사업명으로 입력 해주세요.');");
|
||||
writer.println("history.go(-1);");
|
||||
writer.println("</script>");
|
||||
writer.flush();
|
||||
return null;
|
||||
}
|
||||
|
||||
affectRow = masterService.insertMeta(params);
|
||||
masterService.insertProject(params);
|
||||
if("/insertMeta.do".equals(topPath)){
|
||||
|
|
@ -129,6 +198,7 @@ public class ProjectListController {
|
|||
params.put("USERID",request.getSession().getAttribute("USERID"));
|
||||
affectRow =masterService.updateMeta(params);
|
||||
}
|
||||
model.addObject("result", "true");
|
||||
model.addObject("oREPORT_TYPE", oREPORT_TYPE);
|
||||
model.addObject("affectRow", affectRow);
|
||||
model.addObject("oPROJECT_CODE", oPROJECT_CODE);
|
||||
|
|
|
|||
|
|
@ -50,4 +50,6 @@ public interface ProjectListMapper {
|
|||
public ArrayList getResistivity(HashMap<String, Object> params);
|
||||
public ArrayList getRefraction(HashMap<String, Object> params);
|
||||
public ArrayList getExpertOpinion(HashMap<String, Object> params);
|
||||
|
||||
public ArrayList<HashMap<String, Object>> getProjectCodeAndProjectNameByProjectName(HashMap<String, Object> params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,4 +48,6 @@ public interface ProjectListService {
|
|||
public ArrayList getResistivity(HashMap<String, Object> params);
|
||||
public ArrayList getRefraction(HashMap<String, Object> params);
|
||||
public ArrayList getExpertOpinion(HashMap<String, Object> params);
|
||||
|
||||
public ArrayList<HashMap<String, Object>> getProjectCodeAndProjectNameByProjectName(HashMap<String, Object> params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,4 +210,9 @@ public class ProjectListServiceImpl implements ProjectListService {
|
|||
return projectListMapper.getExpertOpinion(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<HashMap<String, Object>> getProjectCodeAndProjectNameByProjectName(HashMap<String, Object> params) {
|
||||
return projectListMapper.getProjectCodeAndProjectNameByProjectName(params);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1323,4 +1323,15 @@ INSERT INTO TEMP_META_INFO (
|
|||
|
||||
|
||||
|
||||
<select id="getProjectCodeAndProjectNameByProjectName" parameterType="map" resultType="java.util.HashMap">
|
||||
<![CDATA[
|
||||
SELECT
|
||||
tpi.PROJECT_CODE,
|
||||
tpi.PROJECT_NAME
|
||||
FROM
|
||||
temp_project_info tpi
|
||||
WHERE
|
||||
REPLACE(tpi.PROJECT_NAME, ' ', '') = REPLACE(#{PROJECT_NAME}, ' ', '')
|
||||
]]>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
<%@ include file="/include/inc_head_2021_new.jsp" %>
|
||||
|
||||
<script type="text/javaScript">
|
||||
|
||||
//aaaaaaa
|
||||
//지자체 (행정구역)
|
||||
function fn_onSelChangeDis(code, subcd, selFrm, frm){
|
||||
var subCode = selFrm.options[selFrm.selectedIndex].value;
|
||||
|
|
@ -111,6 +111,11 @@ window.onload = function() {
|
|||
fn_onkeyNumber("TEL","phone");
|
||||
fn_onkeyNumber("PHONE","phone");
|
||||
|
||||
var projectNameInput = document.getElementById("PROJECT_NAME");
|
||||
projectNameInput.onfocusout = function() {
|
||||
var projectName = this.value;
|
||||
alert('test');
|
||||
};
|
||||
};
|
||||
|
||||
/* 도움말 시작 */
|
||||
|
|
@ -148,6 +153,7 @@ function fn_help_tour(){
|
|||
}
|
||||
/* 도움말 끝 */
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<!-- header start-->
|
||||
|
|
|
|||
|
|
@ -2,6 +2,27 @@
|
|||
|
||||
<%@ include file="/include/inc_head_2021_new.jsp" %>
|
||||
|
||||
// CSS 애니메이션 추가 (head 태그 안에 넣거나 외부 CSS 파일에 추가)
|
||||
<style>
|
||||
@keyframes shake {
|
||||
0% { transform: translateX(0); }
|
||||
10% { transform: translateX(-5px); }
|
||||
20% { transform: translateX(5px); }
|
||||
30% { transform: translateX(-5px); }
|
||||
40% { transform: translateX(5px); }
|
||||
50% { transform: translateX(-5px); }
|
||||
60% { transform: translateX(5px); }
|
||||
70% { transform: translateX(-5px); }
|
||||
80% { transform: translateX(5px); }
|
||||
90% { transform: translateX(-5px); }
|
||||
100% { transform: translateX(0); }
|
||||
}
|
||||
|
||||
.shake-animation {
|
||||
animation: shake 0.6s;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javaScript">
|
||||
|
||||
//지자체 (행정구역)
|
||||
|
|
@ -92,6 +113,31 @@ function fn_save(rUrl){
|
|||
}
|
||||
|
||||
|
||||
function shakeAndHighlight(targetEle, message) {
|
||||
var originalStyle = targetEle.style.border; // 원래 스타일 저장
|
||||
|
||||
// 빨간색 테두리 설정
|
||||
targetEle.style.border = "2px solid red";
|
||||
|
||||
// 흔들리는 애니메이션 추가
|
||||
targetEle.classList.add("shake-animation");
|
||||
|
||||
|
||||
//1초 후 alert
|
||||
setTimeout(function() {
|
||||
if( typeof message != 'undefined' ) {
|
||||
alert(message);
|
||||
}
|
||||
}, 100);
|
||||
|
||||
// 3초 후 원래 스타일로 복원
|
||||
setTimeout(function() {
|
||||
targetEle.style.border = originalStyle;
|
||||
targetEle.classList.remove("shake-animation");
|
||||
//targetEle.focus();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
|
||||
var holeSpotSd = "${holeSpotSd}";
|
||||
|
|
@ -110,6 +156,35 @@ window.onload = function() {
|
|||
fn_onkeyNumber("TEL","phone");
|
||||
fn_onkeyNumber("PHONE","phone");
|
||||
|
||||
var projectNameInput = document.getElementById("PROJECT_NAME");
|
||||
projectNameInput.addEventListener('focusout', function() {
|
||||
var projectName = this.value;
|
||||
|
||||
$.ajax({
|
||||
type : "GET",
|
||||
data : {
|
||||
projectName : projectName,
|
||||
isProjectNameChecking : "true"
|
||||
},
|
||||
url : "/project-duplicate-check.json",
|
||||
dataType : "json",
|
||||
success : function( json ){
|
||||
resultData = json.result;
|
||||
if(resultData == "false"){
|
||||
shakeAndHighlight(projectNameInput, json.message);
|
||||
//projectNameInput.value = '';
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
error: function(xhr, option, error){
|
||||
alert(xhr.status); //오류코드
|
||||
alert(error); //오류내용
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
function fn_excel_input(){
|
||||
|
|
|
|||
Loading…
Reference in New Issue