단속 행위정보 - 남은 조치 면적 자동 계산 추가 및 버그 수정 진행중...

dev
박성영 3 months ago
parent d9a481fffc
commit 55c437e921

@ -662,4 +662,32 @@ public class CrdnActInfoController {
}
}
/**
* (AJAX)
* : .
* @param actInfoId ID
* @return
*/
@Operation(summary = "적을 수 있는 조치면적 조회", description = "행위정보 면적에서 기존 조치면적을 뺀 나머지 면적을 조회합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "500", description = "서버 오류")
})
@PostMapping("/getRemainingArea.ajax")
public ResponseEntity<?> getRemainingAreaAjax(@RequestParam String actInfoId) {
log.debug("적을 수 있는 조치면적 조회 요청: {}", actInfoId);
try {
java.math.BigDecimal remainingArea = service.getRemainingArea(actInfoId);
Map<String, Object> result = new HashMap<>();
result.put("remainingArea", remainingArea);
return ApiResponseUtil.success(result);
} catch (Exception e) {
log.error("적을 수 있는 조치면적 조회 중 오류 발생: {}", actInfoId, e);
return ApiResponseUtil.error("적을 수 있는 조치면적 조회에 실패했습니다: " + e.getMessage());
}
}
}

@ -153,4 +153,12 @@ public interface CrdnActInfoService {
*/
int deleteActnInfos(List<String> actnInfoIds);
/**
*
* : .
* @param actInfoId ID
* @return (BigDecimal)
*/
java.math.BigDecimal getRemainingArea(String actInfoId);
}

@ -9,6 +9,7 @@ import go.kr.project.crdn.crndRegistAndView.crdnActInfo.service.CrdnPhotoService
import go.kr.project.crdn.crndRegistAndView.crdnActrInfo.mapper.CrdnActrInfoMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -600,4 +601,48 @@ public class CrdnActInfoServiceImpl extends EgovAbstractServiceImpl implements C
log.info("조치정보 일괄 삭제 완료. 요청: {}건, 삭제: {}건", actnInfoIds.size(), deletedCount);
return deletedCount;
}
@Override
public BigDecimal getRemainingArea(String actInfoId) {
log.debug("적을 수 있는 조치면적 조회 요청: actInfoId={}", actInfoId);
if (StringUtils.isEmpty(actInfoId)) {
throw new MessageException("행위정보 ID가 필요합니다.");
}
// 중요한 로직 주석: 행위정보 조회
CrdnActInfoVO actInfo = mapper.selectActInfoByPk(actInfoId);
if (actInfo == null) {
throw new MessageException("행위정보를 찾을 수 없습니다.");
}
// 중요한 로직 주석: 해당 행위정보의 모든 조치정보 조회하여 총 면적 계산
CrdnActnInfoVO actnSearchVO = CrdnActnInfoVO.builder()
.actInfoId(actInfoId)
.build();
List<CrdnActnInfoVO> actnInfoList = mapper.selectActnInfoList(actnSearchVO);
BigDecimal totalActnArea = BigDecimal.ZERO;
for (CrdnActnInfoVO actnInfo : actnInfoList) {
if (actnInfo.getActnArea() != null) {
totalActnArea = totalActnArea.add(actnInfo.getActnArea());
}
}
// 중요한 로직 주석: 행위정보 면적에서 기존 조치면적 총합을 뺀 나머지 면적 계산
BigDecimal remainingArea = BigDecimal.ZERO;
if (actInfo.getArea() != null) {
remainingArea = actInfo.getArea().subtract(totalActnArea);
// 음수인 경우 0으로 설정
if (remainingArea.compareTo(BigDecimal.ZERO) < 0) {
remainingArea = BigDecimal.ZERO;
}
}
log.debug("적을 수 있는 조치면적 계산 완료: actInfoId={}, 행위면적={}, 기존조치면적={}, 남은면적={}",
actInfoId, actInfo.getArea(), totalActnArea, remainingArea);
return remainingArea.setScale(2, java.math.RoundingMode.HALF_UP);
}
}

@ -305,6 +305,7 @@
this.grid.create();
this.eventBindEvents();
this.loadActnInfoList();
this.setRemainingAreaForNew();
},
@ -333,11 +334,12 @@
self.deleteActnInfo();
});
$('#btnClearActn').on('click', function() {
self.actnInfoIdSelect = null;
self.grid.instance.readData();
self.clearActnForm();
});
@ -560,6 +562,9 @@
$('#actnPhotoFiles').val('');
this.actnSelectedFiles = [];
// 중요한 로직 주석: 신규 등록 시 적을 수 있는 조치면적을 자동으로 설정한다.
self.setRemainingAreaForNew();
console.log('조치정보 폼 초기화 완료');
},
@ -712,6 +717,38 @@
var url = '<c:url value="/crdn/crndRegistAndView/crdnActInfo/photoView.do"/>?actnInfoId=' + actnInfoId + '&actInfoId=' + actInfoId + '&crdnPhotoSn=' + crdnPhotoSn + '&crdnPhotoSeCd=' + crdnPhotoSeCd ;
openPopup(url, 1000, 700, '_blank');
},
// 중요한 로직 주석: 신규 등록 시 적을 수 있는 조치면적을 자동으로 설정하는 함수
setRemainingAreaForNew: function() {
var self = this;
if (!self.actInfoId) {
console.warn('행위정보 ID가 없어 조치면적을 자동 설정할 수 없습니다.');
return;
}
$.ajax({
url: '<c:url value="/crdn/crndRegistAndView/crdnActInfo/getRemainingArea.ajax"/>',
type: 'POST',
data: { actInfoId: self.actInfoId },
success: function(response) {
if (response && response.success && response.data) {
var remainingArea = response.data.remainingArea;
if (remainingArea && remainingArea > 0) {
$('#actnArea').val(remainingArea);
console.log('조치면적 자동 설정 완료:', remainingArea);
} else {
console.log('설정할 수 있는 조치면적이 없습니다.');
}
} else {
console.warn('조치면적 조회 실패:', response.message);
}
},
error: function() {
console.error('조치면적 조회 중 오류가 발생했습니다.');
}
});
},
};

Loading…
Cancel
Save