diff --git a/src/main/java/cokr/xit/fims/crdn/CrdnQuery.java b/src/main/java/cokr/xit/fims/crdn/CrdnQuery.java index 8ef84e2b..5b72a867 100644 --- a/src/main/java/cokr/xit/fims/crdn/CrdnQuery.java +++ b/src/main/java/cokr/xit/fims/crdn/CrdnQuery.java @@ -46,6 +46,12 @@ public class CrdnQuery extends QueryRequest { private String crdnInptSeCd; private String cvlcptPrcsCd; + private String aplcnYmd; + private String amtDcsnCdGroupId; + private String amtDcsnCd; + private String dtlAmtDcsnCdGroupId; + private String dtlAmtDcsnCd; + public String getMainOption() { return ifEmpty(mainOption, () -> null); } @@ -298,4 +304,49 @@ public class CrdnQuery extends QueryRequest { return self(); } + public String getAplcnYmd() { + return ifEmpty(aplcnYmd, () -> null); + } + + public T setAplcnYmd(String aplcnYmd) { + this.aplcnYmd = aplcnYmd; + return self(); + } + + public String getAmtDcsnCdGroupId() { + return ifEmpty(amtDcsnCdGroupId, () -> null); + } + + public T setAmtDcsnCdGroupId(String amtDcsnCdGroupId) { + this.amtDcsnCdGroupId = amtDcsnCdGroupId; + return self(); + } + + public String getAmtDcsnCd() { + return ifEmpty(amtDcsnCd, () -> null); + } + + public T setAmtDcsnCd(String amtDcsnCd) { + this.amtDcsnCd = amtDcsnCd; + return self(); + } + + public String getDtlAmtDcsnCdGroupId() { + return ifEmpty(dtlAmtDcsnCdGroupId, () -> null); + } + + public T setDtlAmtDcsnCdGroupId(String dtlAmtDcsnCdGroupId) { + this.dtlAmtDcsnCdGroupId = dtlAmtDcsnCdGroupId; + return self(); + } + + public String getDtlAmtDcsnCd() { + return ifEmpty(dtlAmtDcsnCd, () -> null); + } + + public T setDtlAmtDcsnCd(String dtlAmtDcsnCd) { + this.dtlAmtDcsnCd = dtlAmtDcsnCd; + return self(); + } + } diff --git a/src/main/java/cokr/xit/fims/crdn/dao/Crdn05Mapper.java b/src/main/java/cokr/xit/fims/crdn/dao/Crdn05Mapper.java index 4bbf4446..ab1e2259 100644 --- a/src/main/java/cokr/xit/fims/crdn/dao/Crdn05Mapper.java +++ b/src/main/java/cokr/xit/fims/crdn/dao/Crdn05Mapper.java @@ -42,4 +42,11 @@ public interface Crdn05Mapper extends AbstractMapper { default boolean insert(Crdn crdn) { return crdn != null && insertCrdn(params().set("crdn", crdn)) == 1; } + + /**기본금액을 조회한다.
+ * {@link cokr.xit.fims.crdn.service.Crdn05Service#getBasicAmt(CrdnQuery)} 참고 + * @param query 단속자료 정보 + * @return 기본금액 + */ + int selectBasicAmt(CrdnQuery query); } diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/Crdn05Bean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/Crdn05Bean.java index 499510a8..694c7459 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/Crdn05Bean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/Crdn05Bean.java @@ -2,9 +2,11 @@ package cokr.xit.fims.crdn.service.bean; import javax.annotation.Resource; +import org.assertj.core.util.Arrays; import org.springframework.stereotype.Component; import cokr.xit.fims.crdn.Crdn; +import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.dao.Crdn05Mapper; import cokr.xit.foundation.AbstractComponent; @@ -13,6 +15,11 @@ import cokr.xit.foundation.AbstractComponent; */ @Component("crdn05Bean") public class Crdn05Bean extends AbstractComponent { + public String[] SAFE_TAG_AREA = {"03","06","07"}; //안전표지구역 + + public String[] CAR_GROUP1 = {"12","14","15","21"}; //승합자동차등 + public String[] CAR_GROUP2 = {"11","13"}; //승용자동차등 + public String[] CAR_GROUP3 = {"31"}; //이륜자동차등 @Resource(name = "crdn05Mapper") private Crdn05Mapper crdn05Mapper; @@ -27,4 +34,112 @@ public class Crdn05Bean extends AbstractComponent { public boolean create(Crdn crdn) { return crdn05Mapper.insert(crdn); } + + /**기본금액을 계산한다. + * @param crdn 대장 정보 + * @return 기본금액 + */ + public int getBasicAmt(Crdn crdn) { + int amt = 0; + + CrdnQuery query = new CrdnQuery(); + query.setTaskSeCd(crdn.getTaskSeCd()); + query.setAplcnYmd(crdn.getCrdnYmd()); + + String ffnlgCarmdlCd = crdn.getFfnlgCarmdlCd(); + + if(crdn.getTaskSeCd().equals("PVS") || crdn.getTaskSeCd().equals("BPV") || crdn.getTaskSeCd().equals("TPV")) { + if(ifEmpty(ffnlgCarmdlCd, () -> "").equals("")) { + return 0; + } + } + + switch(crdn.getTaskSeCd()) { + case "PVS": + + query.setAmtDcsnCdGroupId("FIM055"); + String crdnSpareaCd = crdn.getCrdnSpareaCd(); + if(Arrays.asList(SAFE_TAG_AREA).contains(crdnSpareaCd)) { + query.setAmtDcsnCd("02"); + } else { + + String crdnTm = crdn.getCrdnTm(); + boolean workTimeYn = Integer.parseInt(crdnTm) >= 80000 && Integer.parseInt(crdnTm) <= 200000; + + if(crdnSpareaCd.equals("01") && workTimeYn) { + query.setAmtDcsnCd("03"); + } else if((crdnSpareaCd.equals("02") || crdnSpareaCd.equals("05")) && workTimeYn) { + query.setAmtDcsnCd("04"); + } else { + query.setAmtDcsnCd("01"); + } + } + + query.setDtlAmtDcsnCdGroupId("FIM056"); + if(Arrays.asList(CAR_GROUP1).contains(ffnlgCarmdlCd)) { + query.setDtlAmtDcsnCd("01"); + } + if(Arrays.asList(CAR_GROUP2).contains(ffnlgCarmdlCd)) { + query.setDtlAmtDcsnCd("02"); + } + + break; + case "BPV": + + query.setAmtDcsnCdGroupId("FIM056"); + if(Arrays.asList(CAR_GROUP1).contains(ffnlgCarmdlCd)) { + query.setAmtDcsnCd("01"); + } + if(Arrays.asList(CAR_GROUP2).contains(ffnlgCarmdlCd)) { + query.setAmtDcsnCd("02"); + } + if(Arrays.asList(CAR_GROUP3).contains(ffnlgCarmdlCd)) { + query.setAmtDcsnCd("03"); + } + break; + case "DPV": + + query.setAmtDcsnCdGroupId("FIM006"); + query.setAmtDcsnCd(crdn.getVltnCd()); + + break; + case "ECA": + + break; + case "TPV": + + query.setAmtDcsnCdGroupId("FIM057"); + + if(ffnlgCarmdlCd.equals("21")) { + query.setAmtDcsnCd("01"); + query.setDtlAmtDcsnCdGroupId("FIM059"); + + String vltnNmtm = crdn.getVltnNmtm(); + if(vltnNmtm == null || vltnNmtm.equals("") || vltnNmtm.equals("0") || vltnNmtm.equals("1")) { + query.setDtlAmtDcsnCd("01"); + } else if(vltnNmtm.equals("2")) { + query.setDtlAmtDcsnCd("02"); + } else { + query.setDtlAmtDcsnCd("03"); + } + } + + if(ffnlgCarmdlCd.equals("13") || ffnlgCarmdlCd.equals("14")) { + query.setAmtDcsnCd("02"); + query.setDtlAmtDcsnCdGroupId("FIM058"); + //query.setDtlAmtDcsnCd(업종); // TODO : 차주 업종 + } + break; + } + + amt = crdn05Mapper.selectBasicAmt(query); + + if(crdn.getTaskSeCd().equals("PVS")) { + if(crdn.getOvtimeYn().equals("Y")) { + amt += 10000; + } + } + + return amt; + } } diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/Crdn05ServiceBean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/Crdn05ServiceBean.java index 863b4fd5..23383fc8 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/Crdn05ServiceBean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/Crdn05ServiceBean.java @@ -53,6 +53,19 @@ public class Crdn05ServiceBean extends AbstractServiceBean implements Crdn05Serv crdn.setAtchFileCnt(0); } + int basicAmt = crdn05Bean.getBasicAmt(crdn); + crdn.setFfnlgAmt(basicAmt); + crdn.setLevyAmt(basicAmt); + + boolean isPenaltyAmt = crdn.getTaskSeCd().equals("TPV") + && (crdn.getFfnlgCarmdlCd().equals("13") || crdn.getFfnlgCarmdlCd().equals("14")); //과징금 + + if(crdn.getTaskSeCd().equals("BPV") || isPenaltyAmt) { + crdn.setAdvntceLevyAmt(basicAmt); + } else { + crdn.setAdvntceLevyAmt((int)(basicAmt * 0.8)); + } + if(ifEmpty(crdn.getDoGuidance(), () -> "").equals("on")) { crdn.setCrdnSttsCd("83"); } else { diff --git a/src/main/resources/sql/mapper/fims/crdn/crdn05-mapper.xml b/src/main/resources/sql/mapper/fims/crdn/crdn05-mapper.xml index 3767f5ed..5fe620b2 100644 --- a/src/main/resources/sql/mapper/fims/crdn/crdn05-mapper.xml +++ b/src/main/resources/sql/mapper/fims/crdn/crdn05-mapper.xml @@ -185,4 +185,21 @@ INSERT INTO TB_CRDN ( ) + + \ No newline at end of file