소유자 구분 코드 리스트 동적 처리 및 신원미상 선택 시 기본값 설정, 행위별 대상자 선택 검증 로직 추가, 단속정보 그룹화 후 행 색상 적용 로직 구현

dev
박성영 2 months ago
parent 0da2a60c15
commit b63580b0f9

@ -5,6 +5,7 @@ import egovframework.constant.TilesConstants;
import egovframework.exception.MessageException;
import egovframework.util.ApiResponseUtil;
import egovframework.util.SessionUtil;
import go.kr.project.common.model.CmmnCodeSearchVO;
import go.kr.project.common.service.CommonCodeService;
import go.kr.project.crdn.ownac.model.OwnActRegistAndViewVO;
import go.kr.project.crdn.ownac.service.OwnActRegistAndViewService;
@ -106,6 +107,14 @@ public class OwnActRegistAndViewController {
ModelAndView mav = new ModelAndView("crdn/ownact/ownActRegistPopup" + TilesConstants.POPUP);
mav.addObject("mode", mode);
// 구분
CmmnCodeSearchVO cmmnCodeSearchVO = CmmnCodeSearchVO.builder()
.searchCdGroupId("OWNR_SE_CD")
.sortColumn("SORT_ORDR")
.sortAscending(true)
.build();
model.addAttribute("ownrSeCdList", commonCodeService.selectCodeDetailList(cmmnCodeSearchVO));
// 수정/조회 모드인 경우 기존 데이터 조회
if (("U".equals(mode) || "V".equals(mode))) {

@ -9,7 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.*;
/**
@ -40,7 +40,66 @@ public class NotiServiceImpl extends EgovAbstractServiceImpl implements NotiServ
@Override
public List<NotiImpltInfoVO> selectImpltInfoList(NotiImpltInfoVO vo) {
return mapper.selectImpltInfoList(vo);
List<NotiImpltInfoVO> list = mapper.selectImpltInfoList(vo);
// 중요로직: 같은 단속년도(crdnYr), 단속번호(crdnNo) 그룹별로 그리드 행에 CSS 클래스를 적용
applyRowColorByGroup(list);
return list;
}
/**
* ,
* : .
* @param list
*/
private void applyRowColorByGroup(List<NotiImpltInfoVO> list) {
// 단속년도 + 단속번호 조합을 키로 하여 그룹 인덱스 매핑
Map<String, Integer> groupIndexMap = new LinkedHashMap<>();
int groupIndex = 0;
// 첫 번째 패스: 각 단속년도+단속번호 조합에 그룹 인덱스 할당
for (NotiImpltInfoVO item : list) {
if (item.getCrdnYr() != null && item.getCrdnNo() != null) {
String groupKey = item.getCrdnYr() + "-" + item.getCrdnNo();
if (!groupIndexMap.containsKey(groupKey)) {
groupIndexMap.put(groupKey, groupIndex++);
}
}
}
// 두 번째 패스: 각 항목에 _attributes 설정
for (NotiImpltInfoVO item : list) {
try {
if (item.getCrdnYr() != null && item.getCrdnNo() != null) {
String groupKey = item.getCrdnYr() + "-" + item.getCrdnNo();
Integer currentGroupIndex = groupIndexMap.get(groupKey);
if (currentGroupIndex != null) {
// TUI Grid _attributes 설정
Map<String, Object> attributes = new HashMap<>();
Map<String, Object> className = new HashMap<>();
List<String> rowClass = new ArrayList<>();
// 그룹 인덱스의 홀/짝에 따라 색상 클래스 적용
if (currentGroupIndex % 2 == 0) {
rowClass.add("tui-grid-custom-color-blue");
} else {
rowClass.add("tui-grid-custom-color-red");
}
className.put("row", rowClass);
attributes.put("className", className);
item.set_attributes(attributes);
}
}
} catch (Exception e) {
// 예외 발생 시 로그를 남기고 계속 진행
log.warn("Failed to apply row color for crdnYr: {}, crdnNo: {}",
item.getCrdnYr(), item.getCrdnNo(), e);
}
}
}
// ==================== 이행 대상자 정보(TB_IMPLT_TRPR_INFO) 관련 메서드 ====================

@ -426,6 +426,11 @@
return;
}
// 행위별로 최소 1명 이상 선택되었는지 검증
if (!this.validateActNoSelection(selectedTrprInfoList)) {
return;
}
// 이행 대상자 정보를 formData에 추가
for (var i = 0; i < selectedTrprInfoList.length; i++) {
var trprInfo = selectedTrprInfoList[i];
@ -521,13 +526,13 @@
$('#impltBgngYmd').focus();
return false;
}
if (!$('#impltEndYmd').val()) {
alert('행정처분 종료일을 입력해주세요.');
$('#impltEndYmd').focus();
return false;
}
if ($('#impltBgngYmd').val() > $('#impltEndYmd').val()) {
alert('행정처분 시작일은 종료일보다 이전이어야 합니다.');
$('#impltBgngYmd').focus();
@ -537,6 +542,49 @@
return true;
},
/**
* 행위별 선택 검증
* 중요한 로직 주석: 각 행위번호별로 최소 1명 이상의 이행 대상자가 선택되었는지 검증합니다.
* @param {Array} selectedTrprInfoList - 선택된 이행 대상자 정보 배열
* @returns {boolean} 검증 성공 여부
*/
validateActNoSelection: function(selectedTrprInfoList) {
// 전체 그리드 데이터에서 고유한 행위번호 목록 추출
var allData = this.grid.instance.getData();
var actNoSet = new Set();
for (var i = 0; i < allData.length; i++) {
if (allData[i].actNo) {
actNoSet.add(allData[i].actNo);
}
}
// 선택된 데이터에서 행위번호별 개수 집계
var selectedActNoMap = {};
for (var i = 0; i < selectedTrprInfoList.length; i++) {
var actNo = selectedTrprInfoList[i].actNo;
if (actNo) {
selectedActNoMap[actNo] = (selectedActNoMap[actNo] || 0) + 1;
}
}
// 각 행위번호별로 최소 1명 이상 선택되었는지 확인
var missingActNos = [];
actNoSet.forEach(function(actNo) {
if (!selectedActNoMap[actNo] || selectedActNoMap[actNo] === 0) {
missingActNos.push(actNo);
}
});
// 선택되지 않은 행위번호가 있으면 경고
if (missingActNos.length > 0) {
alert('행위번호 ' + missingActNos.join(', ') + '번의 이행 대상자를 최소 1명 이상 선택해주세요.');
return false;
}
return true;
},
};
/**

@ -27,9 +27,10 @@
<td colspan="3">
<select id="ownrSeCd" name="ownrSeCd" class="input" validation-check="required">
<option value="">선택하세요</option>
<option value="1">미상</option>
<option value="2" selected>개인</option>
<option value="3">법인</option>
<c:set var="selectVal" value="${empty data.ownrSeCd ? '2':data.ownrSeCd}"/>
<c:forEach items="${ownrSeCdList}" var="cd">
<option value="${cd.cdId}" <c:if test="${selectVal eq cd.cdId}">selected</c:if> >${cd.cdNm}</option>
</c:forEach>
</select>
</td>
</tr>
@ -194,6 +195,13 @@
self.cancel();
});
$('#ownrSeCd').on('change', function() {
if( $(this).val() === '1' ) {
$('#rrno').val('0000000000000');
$('#flnm').val('미상');
}
});
},
cancel: function() {

Loading…
Cancel
Save