feat: –신규 프로젝트 사업명 중복 검사 추가 구현

지반자료 입력 결과 보고서에도 중복을 체크하도록 구현.
"
main
thkim 2024-07-19 13:50:04 +09:00
parent b8e8ef2fb1
commit 7a048c66f4
6 changed files with 105 additions and 22 deletions

View File

@ -1,5 +1,6 @@
package geoinfo.com.file.service; package geoinfo.com.file.service;
import java.sql.SQLException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -12,7 +13,7 @@ public interface FileService {
void insertFile(Map<String, Object> map) throws Exception; void insertFile(Map<String, Object> map) throws Exception;
List<Map<String, Object>> selectFiles(Map<String, Object> map) throws Exception; List<Map<String, Object>> selectFiles(Map<String, Object> map) throws Exception, SQLException;
void deleteFiles(Map<String, Object> map) throws Exception; void deleteFiles(Map<String, Object> map) throws Exception;

View File

@ -3,6 +3,7 @@ package geoinfo.com.file.service.impl;
import geoinfo.com.file.service.FileMapper; import geoinfo.com.file.service.FileMapper;
import geoinfo.com.file.service.FileService; import geoinfo.com.file.service.FileService;
import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -38,7 +39,7 @@ public class FileServiceImpl implements FileService{
} }
@Override @Override
public List<Map<String, Object>> selectFiles(Map<String, Object> map) throws Exception { public List<Map<String, Object>> selectFiles(Map<String, Object> map) throws Exception, SQLException {
return fileMapper.selectFiles(map); return fileMapper.selectFiles(map);
} }

View File

@ -48,8 +48,11 @@ public class ProjectListController {
strUtil sUtil = new strUtil(); strUtil sUtil = new strUtil();
String projectName = sUtil.checkNull((String)params.get("projectName")); String projectName = sUtil.checkNull((String)params.get("projectName"));
String projectCode = sUtil.checkNull((String)params.get("projectCode"));
String isProjectNameChecking = sUtil.checkNull((String)params.get("isProjectNameChecking")); String isProjectNameChecking = sUtil.checkNull((String)params.get("isProjectNameChecking"));
System.out.println( "thkim 20240719:" + projectCode );
if(isProjectNameChecking != null && isProjectNameChecking.toLowerCase().equals("true") && projectName == ""){ if(isProjectNameChecking != null && isProjectNameChecking.toLowerCase().equals("true") && projectName == ""){
jsonObject.put("result", "false"); jsonObject.put("result", "false");
@ -59,10 +62,16 @@ public class ProjectListController {
params.put("PROJECT_NAME", projectName); params.put("PROJECT_NAME", projectName);
// 사업명(프로젝트 명) 중복 검사를 수행한다. // 사업명(프로젝트 명) 중복 검사를 수행한다.
ArrayList<HashMap<String, Object>> arrProjectCodeAndProjectName = masterService.getProjectCodeAndProjectNameByProjectName(params); ArrayList<HashMap<String, Object>> arrProjectCodeAndProjectName = masterService.getProjectCodeAndProjectNameByProjectName(params);
if( 0 < arrProjectCodeAndProjectName.size() ) { if( 0 < arrProjectCodeAndProjectName.size() ) {
jsonObject.put("result", "false");
jsonObject.put("resultCode", "The name already exists."); if( projectCode != null && arrProjectCodeAndProjectName.size() == 1 && projectCode.equals(arrProjectCodeAndProjectName.get(0).get("PROJECT_CODE")) ) {
jsonObject.put("message", "해당 사업명이 이미 있습니다. 다른 사업명으로 입력해 주세요."); // 나 자신의 프로젝트가 검색된 거임.
} else {
jsonObject.put("result", "false");
jsonObject.put("resultCode", "The name already exists.");
jsonObject.put("message", "해당 사업명이 이미 있습니다. 다른 사업명으로 입력해 주세요.");
}
} else { } else {
jsonObject.put("result", "true"); jsonObject.put("result", "true");
jsonObject.put("message", ""); jsonObject.put("message", "");

View File

@ -4,8 +4,28 @@
<%@ include file="/include/inc_head_2021_new.jsp" %> <%@ include file="/include/inc_head_2021_new.jsp" %>
<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"> <script type="text/javaScript">
//aaaaaaa
//지자체 (행정구역) //지자체 (행정구역)
function fn_onSelChangeDis(code, subcd, selFrm, frm){ function fn_onSelChangeDis(code, subcd, selFrm, frm){
var subCode = selFrm.options[selFrm.selectedIndex].value; var subCode = selFrm.options[selFrm.selectedIndex].value;
@ -93,6 +113,30 @@ function fn_save(rUrl){
document.frmMeta.submit(); document.frmMeta.submit();
} }
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() { window.onload = function() {
@ -112,12 +156,50 @@ window.onload = function() {
fn_onkeyNumber("PHONE","phone"); fn_onkeyNumber("PHONE","phone");
var projectNameInput = document.getElementById("PROJECT_NAME"); var projectNameInput = document.getElementById("PROJECT_NAME");
projectNameInput.onfocusout = function() { projectNameInput.addEventListener('focusout', function() {
var projectName = this.value; var projectName = this.value;
alert('test'); projectCode = getProjectCode();
};
$.ajax({
type : "GET",
data : {
projectName : projectName,
projectCode : projectCode,
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 getProjectCode() {
url = location.href;
var regex = /PROJECT_CODE=([^&]+)/;
var match = regex.exec(url);
if (match && match[1]) {
return match[1];
} else {
return null; // PROJECT_CODE를 찾지 못한 경우
}
}
/* 도움말 시작 */ /* 도움말 시작 */
function fn_help_tour_confirm(){ function fn_help_tour_confirm(){
var answer; var answer;

View File

@ -2,7 +2,6 @@
<%@ include file="/include/inc_head_2021_new.jsp" %> <%@ include file="/include/inc_head_2021_new.jsp" %>
// CSS 애니메이션 추가 (head 태그 안에 넣거나 외부 CSS 파일에 추가)
<style> <style>
@keyframes shake { @keyframes shake {
0% { transform: translateX(0); } 0% { transform: translateX(0); }

View File

@ -39,15 +39,6 @@
frm.options[no] = new Option('선택', ''); frm.options[no] = new Option('선택', '');
no++; no++;
var dis = JSON.parse('${result.commCode}');
for (var i = 0; i < dis.length; i++) {
if (code == dis[i].parentCode && subcd == dis[i].code && subCode == dis[i].parentCodeValue) {
frm.options[no] = new Option(dis[i].codeText, dis[i].codeValue);
no++;
}
}
frm.length = no; frm.length = no;
frm.selectedIndex = 0; frm.selectedIndex = 0;
} }
@ -900,7 +891,7 @@
<tr> <tr>
<th class="td-head">프로젝트명(사업명)</th> <th class="td-head">프로젝트명(사업명)</th>
<td colspan="4"> <td colspan="4">
<input id="PROJECT_NAME" name="PROJECT_NAME" type="text" style="width: 100%;" value="${result.project.projectName}" maxlength="2000" valid="notnull" validNm="프로젝트명" /> <input id="PROJECT_NAME" name="PROJECT_NAME" type="text" style="width: 100%;" value="${result.project.projectName}" maxlength="2000" valid="notnull" validNm="프로젝트명" readonly disabled />
</td> </td>
</tr> </tr>
<tr> <tr>