|
|
@@ -105,13 +105,10 @@ public class FactorMatch {
|
|
|
.findFirst()
|
|
|
.get();
|
|
|
|
|
|
- // 构造 name->code 反向索引(attrMeta 为 null 时返回空 map,比较按纯文本走)
|
|
|
- Map<String, String> nameToCodeMap = buildNameToCodeMap(ptlAgreementUndwrtRulesAttr, undwrtRulesDictList);
|
|
|
-
|
|
|
boolean useFlag;
|
|
|
if(!Objects.isNull(ruleAttrMappingVo.getValue())) {
|
|
|
- // useFlag = attrEqual(ptlAgreementProductCostsAttrLink, ptlAgreementUndwrtRulesAttr, ruleAttrMappingVo.getValue(), false);
|
|
|
- useFlag = attrEqual(ptlAgreementProductCostsAttrLink, ptlAgreementUndwrtRulesAttr, ruleAttrMappingVo.getValue(), false);
|
|
|
+ useFlag = attrEqual(ptlAgreementProductCostsAttrLink, ptlAgreementUndwrtRulesAttr, ruleAttrMappingVo.getValue(),
|
|
|
+ ruleAttrMappingVo.getAttrCode(), false, undwrtRulesAttrList, undwrtRulesDictList);
|
|
|
}else{
|
|
|
useFlag = false;
|
|
|
}
|
|
|
@@ -182,17 +179,20 @@ public class FactorMatch {
|
|
|
/**
|
|
|
* 把 attrMeta 的 dictLabal 构造成 name->code 反向索引,用于把传入的"家庭自用"还原成"04"。
|
|
|
*/
|
|
|
- private static Map<String, String> buildNameToCodeMap(PtlAgreementUndwrtRulesAttr attrMeta,
|
|
|
- List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList) {
|
|
|
- if (attrMeta == null || attrMeta.getDictId() == null || CollUtil.isEmpty(undwrtRulesDictList)) {
|
|
|
- return Collections.emptyMap();
|
|
|
+ /**
|
|
|
+ * 按因子 attrCode 在 undwrtRulesAttrList 里找到对应的 dictId(该因子挂的是哪个字典)。
|
|
|
+ * 找不到或无 dictId 时返回 null。
|
|
|
+ */
|
|
|
+ private static Integer getDictIdByAttrCode(String attrCode, List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList) {
|
|
|
+ if (attrCode == null || CollUtil.isEmpty(undwrtRulesAttrList)) {
|
|
|
+ return null;
|
|
|
}
|
|
|
- return undwrtRulesDictList.stream()
|
|
|
- .filter(d -> Objects.equals(d.getDictId(), attrMeta.getDictId()))
|
|
|
- .collect(Collectors.toMap(
|
|
|
- PtlAgreementUndwrtRulesDictLabal::getName,
|
|
|
- PtlAgreementUndwrtRulesDictLabal::getCode,
|
|
|
- (a, b) -> a));
|
|
|
+ return undwrtRulesAttrList.stream()
|
|
|
+ .filter(a -> attrCode.equals(a.getAttrCode()))
|
|
|
+ .map(PtlAgreementUndwrtRulesAttr::getDictId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -252,7 +252,8 @@ public class FactorMatch {
|
|
|
ptlAgreementCostRule.setMax(ptlAgreementProductCostsAttrLink.getMax());
|
|
|
ptlAgreementCostRule.setOperator(ptlAgreementProductCostsAttrLink.getOperator());
|
|
|
ptlAgreementCostRule.setAttrCode(ptlAgreementProductCostsAttrLink.getAttrCode());
|
|
|
- useFlag = attrEqual(ptlAgreementCostRule, ptlAgreementUndwrtRulesAttr, ruleAttrMappingVo.getValue(), true);
|
|
|
+ useFlag = attrEqual(ptlAgreementCostRule, ptlAgreementUndwrtRulesAttr, ruleAttrMappingVo.getValue(),
|
|
|
+ ruleAttrMappingVo.getAttrCode(), true, undwrtRulesAttrList, undwrtRulesDictList);
|
|
|
log.info("承保规则校验-单属性匹配: attrCode={}, attrType={}, 规则值(min={}, max={}, operator={}), 传入值={}, useFlag={}",
|
|
|
ptlAgreementProductCostsAttrLink.getAttrCode(), ptlAgreementUndwrtRulesAttr.getAttrType(),
|
|
|
ptlAgreementProductCostsAttrLink.getMin(), ptlAgreementProductCostsAttrLink.getMax(),
|
|
|
@@ -331,7 +332,8 @@ public class FactorMatch {
|
|
|
}
|
|
|
|
|
|
private static boolean attrEqual(PtlAgreementCostRule ptlAgreementCostRule,
|
|
|
- PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, String value,boolean isUnderwrite) {
|
|
|
+ PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, String value, String attrCode, boolean isUnderwrite,
|
|
|
+ List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList, List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList) {
|
|
|
|
|
|
if (ptlAgreementUndwrtRulesAttr == null || ptlAgreementUndwrtRulesAttr.getAttrType() == null) {
|
|
|
// 没有元数据:无法得知 attrType,按"包含"语义做纯文本兜底比较
|
|
|
@@ -346,7 +348,7 @@ public class FactorMatch {
|
|
|
|
|
|
boolean result = false;
|
|
|
if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("checkbox")) {
|
|
|
- result = checkBoxEqual(ptlAgreementCostRule, value);
|
|
|
+ result = checkBoxEqual(ptlAgreementCostRule, value, attrCode, undwrtRulesAttrList, undwrtRulesDictList);
|
|
|
} else if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("inputNumber")) {
|
|
|
result = inputNumberEqual(ptlAgreementCostRule, value);
|
|
|
} else if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("input") || ptlAgreementUndwrtRulesAttr.getAttrType().equals("inputTag")) {
|
|
|
@@ -361,13 +363,17 @@ public class FactorMatch {
|
|
|
if (ptlAgreementUndwrtRulesAttr.getAttrCode().equals("LicenseNo")) {
|
|
|
value = value.substring(0, 4);
|
|
|
}
|
|
|
- result = selectEqual(ptlAgreementCostRule, value);
|
|
|
- //车龄
|
|
|
+ //车龄走数值比较,不走字典
|
|
|
if (ptlAgreementUndwrtRulesAttr.getAttrCode().equals("VehicleAge")) {
|
|
|
result = inputNumberEqual(ptlAgreementCostRule, value);
|
|
|
+ // LicenseArea 是 select 但无 dictId,按 input 纯文本比较(不走字典还原)
|
|
|
+ } else if (ptlAgreementUndwrtRulesAttr.getAttrCode().equals("LicenseArea")) {
|
|
|
+ result = inputTextEqual(ptlAgreementCostRule, value);
|
|
|
+ } else {
|
|
|
+ result = selectEqual(ptlAgreementCostRule, value, attrCode, undwrtRulesAttrList, undwrtRulesDictList);
|
|
|
}
|
|
|
} else if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("radio")) {
|
|
|
- result = radioEqual(ptlAgreementCostRule, value);
|
|
|
+ result = radioEqual(ptlAgreementCostRule, value, attrCode, undwrtRulesAttrList, undwrtRulesDictList);
|
|
|
} else if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("datetime")){ // 时间
|
|
|
result = dateTimeEqual(ptlAgreementCostRule, value);
|
|
|
} else if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("date")){
|
|
|
@@ -382,13 +388,25 @@ public class FactorMatch {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private static boolean checkBoxEqual(PtlAgreementCostRule ptlAgreementCostRule, String value) {
|
|
|
+ private static boolean checkBoxEqual(PtlAgreementCostRule ptlAgreementCostRule, String value, String attrCode,
|
|
|
+ List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList, List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList) {
|
|
|
if (ptlAgreementCostRule.getMin() == null || value == null) {
|
|
|
return false;
|
|
|
}
|
|
|
+ // attrCode 在 undwrtRulesAttrList 里的 dictId,再到 undwrtRulesDictList 中按 name 找 code。
|
|
|
+ String codeValue = value;
|
|
|
+ Integer dictId = getDictIdByAttrCode(attrCode, undwrtRulesAttrList);
|
|
|
+ if (dictId != null && CollUtil.isNotEmpty(undwrtRulesDictList)) {
|
|
|
+ for (PtlAgreementUndwrtRulesDictLabal label : undwrtRulesDictList) {
|
|
|
+ if (Objects.equals(label.getDictId(), dictId) && value.equals(label.getName())) {
|
|
|
+ codeValue = label.getCode();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
String[] split = ptlAgreementCostRule.getMin().split(",");
|
|
|
for (String sp : split) {
|
|
|
- if (sp.trim().equals(value.trim())) {
|
|
|
+ if (sp.trim().equals(value.trim()) || sp.trim().equals(codeValue.trim())) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
@@ -458,26 +476,40 @@ public class FactorMatch {
|
|
|
return returnBool.get();
|
|
|
}
|
|
|
|
|
|
- private static boolean selectEqual(PtlAgreementCostRule ptlAgreementCostRule, String value) {
|
|
|
+ private static boolean selectEqual(PtlAgreementCostRule ptlAgreementCostRule, String value, String attrCode,
|
|
|
+ List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList, List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList) {
|
|
|
if (ptlAgreementCostRule.getMin() == null || value == null) {
|
|
|
return false;
|
|
|
}
|
|
|
+ // attrCode 在 undwrtRulesAttrList 里的 dictId,再到 undwrtRulesDictList 中按 name 找 code。
|
|
|
+ String codeValue = value;
|
|
|
+ Integer dictId = getDictIdByAttrCode(attrCode, undwrtRulesAttrList);
|
|
|
+ if (dictId != null && CollUtil.isNotEmpty(undwrtRulesDictList)) {
|
|
|
+ for (PtlAgreementUndwrtRulesDictLabal label : undwrtRulesDictList) {
|
|
|
+ if (Objects.equals(label.getDictId(), dictId) && value.equals(label.getName())) {
|
|
|
+ codeValue = label.getCode();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if (ptlAgreementCostRule.getOperator().equals("2")) {
|
|
|
String [] options = ptlAgreementCostRule.getMin().split(",");
|
|
|
for (String opt : options) {
|
|
|
- if (opt.trim().equals(value.trim())) {
|
|
|
+ if (opt.trim().equals(value.trim()) || opt.trim().equals(codeValue.trim())) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
- } else if (ptlAgreementCostRule.getMin() != null && ptlAgreementCostRule.getMin().contains(value)) {
|
|
|
+ } else if (ptlAgreementCostRule.getMin() != null && (ptlAgreementCostRule.getMin().contains(value)
|
|
|
+ || ptlAgreementCostRule.getMin().contains(codeValue))) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- private static boolean radioEqual(PtlAgreementCostRule ptlAgreementCostRule, String value) {
|
|
|
+ private static boolean radioEqual(PtlAgreementCostRule ptlAgreementCostRule, String value, String attrCode,
|
|
|
+ List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList, List<PtlAgreementUndwrtRulesDictLabal> undwrtRulesDictList) {
|
|
|
//新能源判断
|
|
|
if ("NewEnergyMark".equals(ptlAgreementCostRule.getAttrCode())) {
|
|
|
// 是否是新能源车
|
|
|
@@ -487,8 +519,21 @@ public class FactorMatch {
|
|
|
} else if (!newEnergy && ptlAgreementCostRule.getMin().equals("0")) {
|
|
|
return true;
|
|
|
}
|
|
|
- } else if (ptlAgreementCostRule.getMin().contains(value)) {
|
|
|
- return true;
|
|
|
+ } else {
|
|
|
+ // attrCode 在 undwrtRulesAttrList 里的 dictId,再到 undwrtRulesDictList 中按 name 找 code。
|
|
|
+ String codeValue = value;
|
|
|
+ Integer dictId = getDictIdByAttrCode(attrCode, undwrtRulesAttrList);
|
|
|
+ if (dictId != null && CollUtil.isNotEmpty(undwrtRulesDictList)) {
|
|
|
+ for (PtlAgreementUndwrtRulesDictLabal label : undwrtRulesDictList) {
|
|
|
+ if (Objects.equals(label.getDictId(), dictId) && value.equals(label.getName())) {
|
|
|
+ codeValue = label.getCode();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ptlAgreementCostRule.getMin().contains(value) || ptlAgreementCostRule.getMin().contains(codeValue)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
return false;
|
|
|
}
|