단속상태이력 수정.

main
JoJH 2 days ago
parent 6a89b55c2d
commit 570775294c

@ -25,7 +25,6 @@ public class CrdnSttsHstryQuery extends CmmnQuery {
public <T extends CrdnSttsHstryQuery> T setSttsHstryId(String sttsHstryId) {
this.sttsHstryId = sttsHstryId;
return self();
}
@ -35,7 +34,6 @@ public class CrdnSttsHstryQuery extends CmmnQuery {
public <T extends CrdnSttsHstryQuery> T setCrdnId(String crdnId) {
this.crdnId = crdnId;
return self();
}
@ -45,7 +43,6 @@ public class CrdnSttsHstryQuery extends CmmnQuery {
public <T extends CrdnSttsHstryQuery> T setCrdnSttsCd(String crdnSttsCd) {
this.crdnSttsCd = crdnSttsCd;
return self();
}
@ -55,7 +52,6 @@ public class CrdnSttsHstryQuery extends CmmnQuery {
public <T extends CrdnSttsHstryQuery> T setTaskDtlId(String taskDtlId) {
this.taskDtlId = taskDtlId;
return self();
}

@ -37,6 +37,17 @@ public interface CrdnSttsHstryMapper extends AbstractMapper {
* @param crdnId ID
* @return ID
*/
default DataObject selectCrdnSttsHstryInfo(CrdnSttsHstryQuery req) {
// 기본 정렬
if (req.getOrderBy() == null) {
req.setOrderBy("CSH.STTS_HSTRY_ID DESC");
}
List<DataObject> crdnSttsHstrys = selectCrdnSttsHstrys(req);
return !crdnSttsHstrys.isEmpty() ? crdnSttsHstrys.get(0) : null;
}
default DataObject selectCrdnSttsHstryInfo(String crdnId, String crdnSttsCd, String useYn) {
CrdnSttsHstryQuery req = new CrdnSttsHstryQuery();

@ -138,6 +138,54 @@ public class CrdnSttsHstryBean extends AbstractBean {
return true;
}
/** , .
* @param crdnSttsHstry
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
public boolean removeHstryUpdateCrdnSttsCd(CrdnSttsHstry crdnSttsHstry) {
// 변수 선언
int rtnNocs = -1;
// 단속 ID에 해당하는 단속상태코드의 단속상태이력(TB_CRDN_STTS_HSTRY) 대장을 조회 한다.
CrdnSttsHstryQuery req = new CrdnSttsHstryQuery();
req.setCrdnId(crdnSttsHstry.getCrdnId());
req.setUseYn("Y");
req.setOrderBy("CSH.STTS_HSTRY_ID DESC");
DataObject hstryInfo = crdnSttsHstryMapper.selectCrdnSttsHstryInfo(req);
if (hstryInfo == null) {
throw new RuntimeException("단속 상태 이력 자료가 존재하지 않습니다."); // 예외를 발생시켜서 DB Rollback
}
if (!crdnSttsHstry.getCrdnSttsCd().equals(hstryInfo.string("CRDN_STTS_CD"))) {
throw new RuntimeException("현재 단속 상태와 마지막 단속 상태 이력 정보가 다릅니다."); // 예외를 발생시켜서 DB Rollback
}
// 단속상태이력(TB_CRDN_STTS_HSTRY) 대장을 삭제한다.
crdnSttsHstry.setSttsHstryId(hstryInfo.string("STTS_HSTRY_ID")); // 상태 이력 ID
rtnNocs = crdnSttsHstryMapper.updateCrdnSttsHstry(crdnSttsHstry);
if (rtnNocs != 1) {
throw new RuntimeException("단속상태이력 대장에 이력 수정에 실패하였습니다."); // 예외를 발생시켜서 DB Rollback
}
// 단속(TB_CRDN) 대장을 수정한다.
CrdnSttsHstry updtHstry = new CrdnSttsHstry();
updtHstry.setCrdnId(crdnSttsHstry.getCrdnId()); // 단속 ID
updtHstry.setCrdnSttsCd(hstryInfo.string("BFR_STTS_CD")); // 단속 상태 코드
updtHstry.setCrdnSttsChgDt(hstryInfo.string("BFR_STTS_CHG_DT")); // 단속 상태 변경 일시
rtnNocs = crdnSttsHstryMapper.updateCrdnSttsCd(updtHstry);
if (rtnNocs != 1) {
throw new RuntimeException("단속상태이력 정보 등록 중 오류가 발생하였습니다."); // 예외를 발생시켜서 DB Rollback
}
return true;
}
/** , .
* @param crdnSttsHstry
* @return
@ -150,16 +198,19 @@ public class CrdnSttsHstryBean extends AbstractBean {
int rtnNocs = -1;
// 단속 ID에 해당하는 단속상태코드의 단속상태이력(TB_CRDN_STTS_HSTRY) 대장을 조회 한다.
DataObject crdnSttsHstryInfo = crdnSttsHstryMapper.selectCrdnSttsHstryInfo(crdnId, crdnSttsCd, "Y");
DataObject hstryInfo = crdnSttsHstryMapper.selectCrdnSttsHstryInfo(crdnId, crdnSttsCd, "Y");
if (crdnSttsHstryInfo == null) {
if (hstryInfo == null) {
throw new RuntimeException("단속상태이력 자료가 존재하지 않습니다."); // 예외를 발생시켜서 DB Rollback
}
if (!crdnSttsCd.equals("")) {
CrdnSttsHstry crdnSttsHstry = new CrdnSttsHstry();
crdnSttsHstry.setSttsHstryId(crdnSttsHstryInfo.string("STTS_HSTRY_ID"));
crdnSttsHstry.setUseYn("N");
crdnSttsHstry.setSttsHstryId(hstryInfo.string("STTS_HSTRY_ID")); // 상태 이력 ID
if (deltSttsCd.equals("")) {
crdnSttsHstry.setEtcCn(deltEtcCn); // 기타 내용
}
crdnSttsHstry.setUseYn("N"); // 사용 여부
rtnNocs = crdnSttsHstryMapper.updateCrdnSttsHstry(crdnSttsHstry);
if (rtnNocs != 1) {
@ -172,14 +223,14 @@ public class CrdnSttsHstryBean extends AbstractBean {
// 단속상태가 의견제출접수(31)가 아니면서, 삭제상태코드가 의견제출삭제(92)나 경찰서이첩삭제(97) 일 경우
if (!crdnSttsCd.equals("31") && "92,97".contains(deltSttsCd)) {
// 단속상태이력(TB_CRDN_STTS_HSTRY) 대장에서 의견제출접수(31) 이력을 조회후 사용여부를 미사용("N")으로 수정.
crdnSttsHstryInfo = crdnSttsHstryMapper.selectCrdnSttsHstryInfo(crdnId, "31", "Y");
hstryInfo = crdnSttsHstryMapper.selectCrdnSttsHstryInfo(crdnId, "31", "Y");
if (crdnSttsHstryInfo == null) {
if (hstryInfo == null) {
throw new RuntimeException("단속상태이력에 의견제출 접수 이력이 존재하지 않습니다."); // 예외를 발생시켜서 DB Rollback
}
CrdnSttsHstry opnnSttsHstry = new CrdnSttsHstry();
opnnSttsHstry.setSttsHstryId(crdnSttsHstryInfo.string("STTS_HSTRY_ID"));
opnnSttsHstry.setSttsHstryId(hstryInfo.string("STTS_HSTRY_ID"));
opnnSttsHstry.setUseYn("N");
rtnNocs = crdnSttsHstryMapper.updateCrdnSttsHstry(opnnSttsHstry);
@ -189,9 +240,9 @@ public class CrdnSttsHstryBean extends AbstractBean {
}
CrdnSttsHstry deleteSttsHstry = new CrdnSttsHstry();
deleteSttsHstry.setCrdnId(crdnSttsHstryInfo.string("CRDN_ID"));
deleteSttsHstry.setBfrSttsCd(crdnSttsHstryInfo.string("CRDN_STTS_CD"));
deleteSttsHstry.setBfrSttsChgDt(crdnSttsHstryInfo.string("REG_DT"));
deleteSttsHstry.setCrdnId(hstryInfo.string("CRDN_ID"));
deleteSttsHstry.setBfrSttsCd(hstryInfo.string("CRDN_STTS_CD"));
deleteSttsHstry.setBfrSttsChgDt(hstryInfo.string("REG_DT"));
deleteSttsHstry.setCrdnSttsCd(deltSttsCd);
deleteSttsHstry.setEtcCn(deltEtcCn);
deleteSttsHstry.setUseYn("N");
@ -205,11 +256,15 @@ public class CrdnSttsHstryBean extends AbstractBean {
if (insertBfrSttsYn) {
// 단속상태이력(TB_CRDN_STTS_HSTRY) 대장을 등록한다.
CrdnSttsHstry crdnSttsHstry = new CrdnSttsHstry();
crdnSttsHstry.setCrdnId(crdnSttsHstryInfo.string("CRDN_ID"));
crdnSttsHstry.setCrdnId(hstryInfo.string("CRDN_ID"));
if (deltSttsCd.equals("")) {
crdnSttsHstry.setBfrSttsCd(crdnSttsCd);
} else {
crdnSttsHstry.setBfrSttsCd(deltSttsCd);
}
crdnSttsHstry.setBfrSttsChgDt(crdnSttsHstry.getCreatedAt());
crdnSttsHstry.setCrdnSttsCd(crdnSttsHstryInfo.string("BFR_STTS_CD"));
crdnSttsHstry.setCrdnSttsChgDt(crdnSttsHstryInfo.string("BFR_STTS_CHG_DT"));
crdnSttsHstry.setCrdnSttsCd(hstryInfo.string("BFR_STTS_CD"));
crdnSttsHstry.setCrdnSttsChgDt(hstryInfo.string("BFR_STTS_CHG_DT"));
crdnSttsHstry.setUseYn("Y");
boolean rtnScs = createHstryUpdateCrdnSttsCd(crdnSttsHstry);

@ -130,6 +130,9 @@
<update id="updateCrdnSttsHstry" parameterType="cokr.xit.fims.cmmn.CrdnSttsHstry">/* 단속 상태 이력 수정(crdnSttsHstryMapper.updateCrdnSttsHstry) */
UPDATE TB_CRDN_STTS_HSTRY
SET USE_YN = #{useYn} <!-- 사용 여부 -->
<if test="etcCn != null">
, ETC_CN = #{etcCn} <!-- 기타 내용 -->
</if>
, MDFCN_DT = <include refid="utility.now" /> <!-- 수정 일시 -->
, MDFR = #{modifiedBy} <!-- 수정자 -->
WHERE STTS_HSTRY_ID = #{sttsHstryId} <!-- 상태 이력 ID -->

Loading…
Cancel
Save