diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnBean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnBean.java index e6674026..edbfe5c4 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnBean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnBean.java @@ -1,6 +1,8 @@ package cokr.xit.fims.crdn.service.bean; +import java.text.SimpleDateFormat; import java.util.Arrays; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -9,9 +11,17 @@ import javax.annotation.Resource; import org.springframework.stereotype.Component; +import cokr.xit.base.file.FileInfo; +import cokr.xit.base.file.service.bean.FileBean; +import cokr.xit.fims.cmmn.CrdnPayerHstry; +import cokr.xit.fims.cmmn.CrdnSttsHstry; +import cokr.xit.fims.cmmn.service.bean.CrdnPayerHstryBean; +import cokr.xit.fims.cmmn.service.bean.CrdnSttsHstryBean; import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.dao.CrdnInstMapper; import cokr.xit.fims.crdn.dao.CrdnUpdtMapper; +import cokr.xit.fims.excl.LevyExcl; +import cokr.xit.fims.excl.service.bean.Excl01Bean; import cokr.xit.foundation.AbstractComponent; import cokr.xit.foundation.UserInfo; @@ -21,12 +31,127 @@ import cokr.xit.foundation.UserInfo; @Component("crdnBean") public class CrdnBean extends AbstractComponent { + @Resource(name = "crdnStngBean") + private CrdnStngBean crdnStngBean; + + @Resource(name = "excl01Bean") + private Excl01Bean excl01Bean; + + @Resource(name = "crdnSttsHstryBean") + private CrdnSttsHstryBean crdnSttsHstryBean; + + @Resource(name = "crdnPayerHstryBean") + private CrdnPayerHstryBean crdnPayerHstryBean; + + @Resource(name = "fileBean") + private FileBean fileBean; + @Resource(name = "crdnInstMapper") private CrdnInstMapper crdnInstMapper; @Resource(name = "crdnUpdtMapper") private CrdnUpdtMapper crdnUpdtMapper; + + public boolean create(Map nonQueryRequest, Crdn crdn, List fileInfoList) { + if(fileInfoList != null && !fileInfoList.isEmpty()) { + crdn.setAtchFileCnt(fileInfoList.size()); + } else { + crdn.setAtchFileCnt(0); + } + + //금액 계산 + int[] basicAmt = crdnStngBean.getBasicAmt(crdn); + crdn.setFfnlgCrdnAmt(basicAmt[0]); + crdn.setFfnlgAmt(basicAmt[0]); + crdn.setAdvntceAmt(basicAmt[1]); + + //TODO : 단속팀 저장 + //if(!ifEmpty(crdn.getTeamId(), () -> "").equals("")) { + //} + + + //TODO : 입력파라미터에 납부자ID가 없고, 납부자명이 있을때 납부자 신규등록 + //TODO : 납부자정보의 납부자ID와 입력파라미터의 납부자ID가 동일하고, 납부자명이 다를때 납부자 신규등록 + //TODO : 납부자정보ID,납부자명이 동일하고, 주소가 다를 때 주소업데이트 + + + if(ifEmpty(crdn.getCrdnSttsCd(), () -> "").equals("")){ + if(!ifEmpty(crdn.getRtpyrId(), () -> "").equals("")) { + crdn.setCrdnSttsCd("21"); + } else { + crdn.setCrdnSttsCd("01"); + } + } + + + boolean result = this.createLedger(crdn); + if (!result) { + throw new RuntimeException("단속자료 수기 등록 중 단속자료 등록에 실패하였습니다."); + } + + SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyyMMdd"); + Date curTime = new Date(); + String strCurrentDate = yyyyMMdd.format(curTime); + + String taskDtlId = crdn.getCrdnId(); + + if(crdn.getCrdnSttsCd().equals("83")) { + // 부과제외(TB_LEVY_EXCL) 대장 등록 + LevyExcl excl01 = new LevyExcl(); + excl01.setSggCd(crdn.getSggCd()); + excl01.setTaskSeCd(crdn.getTaskSeCd()); + excl01.setCrdnId(crdn.getCrdnId()); + excl01.setLevyExclYmd(strCurrentDate); + excl01.setLevyExclSeCd("2"); + excl01.setLevyExclRsnCd("192"); + excl01.setEtcCn(""); + + String retMessage = excl01Bean.createLevyExcl(excl01); + if (retMessage.contains("[F]")) { + throw new RuntimeException("단속자료 수기 등록 중 부과제외 자료 등록에 실패하였습니다."); + } + + taskDtlId = excl01.getLevyExclId(); + } + + // 단속상태이력(TB_CRDN_STTS_HSTRY) 대장 등록 + CrdnSttsHstry crdnSttsHstry = new CrdnSttsHstry(); + crdnSttsHstry.setCrdnId(crdn.getCrdnId()); + crdnSttsHstry.setBfrSttsCd(""); + crdnSttsHstry.setBfrSttsChgDt(""); + crdnSttsHstry.setCrdnSttsCd(crdn.getCrdnSttsCd()); + crdnSttsHstry.setTaskDtlId(taskDtlId); + crdnSttsHstry.setEtcCn(""); + + result = crdnSttsHstryBean.create(crdnSttsHstry); + if (!result) { + throw new RuntimeException("단속자료 수기 등록 중 단속상태 이력 등록에 실패하였습니다."); + } + + //단속납부자이력(TB_CRDN_PAYER_HSTRY) 대장 등록 + if(!ifEmpty(crdn.getRtpyrId(), () -> "").equals("")) { + CrdnPayerHstry crdnPayerHstry = new CrdnPayerHstry(); + crdnPayerHstry.setCrdnId(crdn.getCrdnId()); + crdnPayerHstry.setRtpyrId(crdn.getRtpyrId()); + result = crdnPayerHstryBean.create(crdnPayerHstry); + if (!result) { + throw new RuntimeException("단속자료 수기 등록 중 단속납부자 이력 등록에 실패하였습니다."); + } + } + + //파일 등록 + if(fileInfoList != null && !fileInfoList.isEmpty()) { + fileInfoList.forEach(fileInfo -> fileInfo.setInfoType(Crdn.INF_TYPE).setInfoKey(crdn.getCrdnId())); + int effected = fileBean.create(fileInfoList); + if(effected == 0) { + throw new RuntimeException("단속자료 수기 등록 중 파일 등록에 실패하였습니다."); + } + } + + return result; + } + /**단속 대장 정보를 등록한다. * @param crdn 단속 대장 * @return 저장 여부 @@ -34,7 +159,7 @@ public class CrdnBean extends AbstractComponent { *
  • 그렇지 않으면 false
  • * */ - public boolean create(Crdn crdn) { + public boolean createLedger(Crdn crdn) { int effected = crdnInstMapper.insertCrdn(crdn); if(effected != 1) { @@ -57,7 +182,7 @@ public class CrdnBean extends AbstractComponent { *
  • 그렇지 않으면 false
  • * */ - public boolean update(Map nonQueryRequest, Crdn crdn) { + public boolean updateLedger(Map nonQueryRequest, Crdn crdn) { String updateInfomationType = (String)ifEmpty(nonQueryRequest.get("updateInfomationType"), "") ; switch (ifEmpty(updateInfomationType, () -> "")) { @@ -86,4 +211,6 @@ public class CrdnBean extends AbstractComponent { return crdnUpdtMapper.deleteCrdn(paramMap) >= 1 ? true : false; } + + } diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnServiceBean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnServiceBean.java index 65156fe8..3324b642 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnServiceBean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnServiceBean.java @@ -1,8 +1,6 @@ package cokr.xit.fims.crdn.service.bean; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -13,8 +11,6 @@ import org.springframework.stereotype.Service; import cokr.xit.base.file.FileInfo; import cokr.xit.base.file.service.bean.FileBean; -import cokr.xit.fims.cmmn.CrdnPayerHstry; -import cokr.xit.fims.cmmn.CrdnSttsHstry; import cokr.xit.fims.cmmn.service.bean.CrdnPayerHstryBean; import cokr.xit.fims.cmmn.service.bean.CrdnSttsHstryBean; import cokr.xit.fims.crdn.Crdn; @@ -27,7 +23,6 @@ import cokr.xit.fims.crdn.dao.GlobalStngMapper; import cokr.xit.fims.crdn.service.CrdnService; import cokr.xit.fims.cvlc.dao.CrdnCvlcptMapper; import cokr.xit.fims.cvlc.service.bean.CrdnCvlcptMainBean; -import cokr.xit.fims.excl.LevyExcl; import cokr.xit.fims.excl.service.bean.Excl01Bean; import cokr.xit.foundation.component.AbstractServiceBean; import cokr.xit.foundation.data.DataObject; @@ -152,108 +147,12 @@ public class CrdnServiceBean extends AbstractServiceBean implements CrdnService @Override public boolean create(Map nonQueryRequest, Crdn crdn, List fileInfoList) { - - if(fileInfoList != null && !fileInfoList.isEmpty()) { - crdn.setAtchFileCnt(fileInfoList.size()); - } else { - crdn.setAtchFileCnt(0); - } - - //금액 계산 - int[] basicAmt = crdnStngBean.getBasicAmt(crdn); - crdn.setFfnlgCrdnAmt(basicAmt[0]); - crdn.setFfnlgAmt(basicAmt[0]); - crdn.setAdvntceAmt(basicAmt[1]); - - //TODO : 단속팀 저장 - //if(!ifEmpty(crdn.getTeamId(), () -> "").equals("")) { - //} - - - //TODO : 입력파라미터에 납부자ID가 없고, 납부자명이 있을때 납부자 신규등록 - //TODO : 납부자정보의 납부자ID와 입력파라미터의 납부자ID가 동일하고, 납부자명이 다를때 납부자 신규등록 - //TODO : 납부자정보ID,납부자명이 동일하고, 주소가 다를 때 주소업데이트 - - - if(ifEmpty(crdn.getCrdnSttsCd(), () -> "").equals("")){ - if(!ifEmpty(crdn.getRtpyrId(), () -> "").equals("")) { - crdn.setCrdnSttsCd("21"); - } else { - crdn.setCrdnSttsCd("01"); - } - } - - - boolean result = crdnBean.create(crdn); - if (!result) { - throw new RuntimeException("단속자료 수기 등록 중 단속자료 등록에 실패하였습니다."); - } - - SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyyMMdd"); - Date curTime = new Date(); - String strCurrentDate = yyyyMMdd.format(curTime); - - String taskDtlId = crdn.getCrdnId(); - - if(crdn.getCrdnSttsCd().equals("83")) { - // 부과제외(TB_LEVY_EXCL) 대장 등록 - LevyExcl excl01 = new LevyExcl(); - excl01.setSggCd(crdn.getSggCd()); - excl01.setTaskSeCd(crdn.getTaskSeCd()); - excl01.setCrdnId(crdn.getCrdnId()); - excl01.setLevyExclYmd(strCurrentDate); - excl01.setLevyExclSeCd("2"); - excl01.setLevyExclRsnCd("192"); - excl01.setEtcCn(""); - - String retMessage = excl01Bean.createLevyExcl(excl01); - if (retMessage.contains("[F]")) { - throw new RuntimeException("단속자료 수기 등록 중 부과제외 자료 등록에 실패하였습니다."); - } - - taskDtlId = excl01.getLevyExclId(); - } - - // 단속상태이력(TB_CRDN_STTS_HSTRY) 대장 등록 - CrdnSttsHstry crdnSttsHstry = new CrdnSttsHstry(); - crdnSttsHstry.setCrdnId(crdn.getCrdnId()); - crdnSttsHstry.setBfrSttsCd(""); - crdnSttsHstry.setBfrSttsChgDt(""); - crdnSttsHstry.setCrdnSttsCd(crdn.getCrdnSttsCd()); - crdnSttsHstry.setTaskDtlId(taskDtlId); - crdnSttsHstry.setEtcCn(""); - - result = crdnSttsHstryBean.create(crdnSttsHstry); - if (!result) { - throw new RuntimeException("단속자료 수기 등록 중 단속상태 이력 등록에 실패하였습니다."); - } - - //단속납부자이력(TB_CRDN_PAYER_HSTRY) 대장 등록 - if(!ifEmpty(crdn.getRtpyrId(), () -> "").equals("")) { - CrdnPayerHstry crdnPayerHstry = new CrdnPayerHstry(); - crdnPayerHstry.setCrdnId(crdn.getCrdnId()); - crdnPayerHstry.setRtpyrId(crdn.getRtpyrId()); - result = crdnPayerHstryBean.create(crdnPayerHstry); - if (!result) { - throw new RuntimeException("단속자료 수기 등록 중 단속납부자 이력 등록에 실패하였습니다."); - } - } - - //파일 등록 - if(fileInfoList != null && !fileInfoList.isEmpty()) { - fileInfoList.forEach(fileInfo -> fileInfo.setInfoType(Crdn.INF_TYPE).setInfoKey(crdn.getCrdnId())); - int effected = fileBean.create(fileInfoList); - if(effected == 0) { - throw new RuntimeException("단속자료 수기 등록 중 파일 등록에 실패하였습니다."); - } - } - - return result; + return crdnBean.create(nonQueryRequest, crdn, fileInfoList); } @Override public boolean update(Map nonQueryRequest, Crdn crdn, List newFileInfoList) { - boolean result = crdnBean.update(nonQueryRequest, crdn); + boolean result = crdnBean.updateLedger(nonQueryRequest, crdn); if(!result) { throw new RuntimeException("단속 정보 수정 중 오류가 발생하였습니다."); }