fix bug
This commit is contained in:
+5
-1
@@ -272,7 +272,11 @@ public class CreditScoreQuantificationServiceImpl extends BaseServiceImpl<Credit
|
||||
}
|
||||
|
||||
private BigDecimal normalizeBaseValue(BigDecimal value) {
|
||||
return value == null ? null : value.stripTrailingZeros();
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
BigDecimal normalized = value.stripTrailingZeros();
|
||||
return normalized.scale() < 0 ? normalized.setScale(0) : normalized;
|
||||
}
|
||||
|
||||
private List<CreditRatingStandardVO> loadStandards(Long quantificationId) {
|
||||
|
||||
+43
-2
@@ -513,6 +513,7 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
detail.setTenantId(score.getTenantId());
|
||||
detail.setScoreId(scoreId);
|
||||
detail.setQuantificationId(score.getQuantificationId());
|
||||
detail.setOptionsJson(normalizeOptionsJson(detail.getOptionsJson()));
|
||||
detail.setSort(detailIndex + 1);
|
||||
detail.setStatus(STATUS_ENABLED);
|
||||
detail.setIsDeleted(0);
|
||||
@@ -698,9 +699,9 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("label", option.getOptionName());
|
||||
map.put("value", option.getOptionName());
|
||||
map.put("score", option.getScore());
|
||||
map.put("score", toPlainDecimalString(option.getScore()));
|
||||
map.put("changeType", option.getChangeType());
|
||||
map.put("changeValue", option.getChangeValue());
|
||||
map.put("changeValue", toPlainDecimalString(option.getChangeValue()));
|
||||
map.put("changeUnit", option.getChangeUnit());
|
||||
map.put("scoreType", option.getScoreType());
|
||||
return map;
|
||||
@@ -708,6 +709,46 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
return JsonUtil.toJson(optionList);
|
||||
}
|
||||
|
||||
private String normalizeOptionsJson(String optionsJson) {
|
||||
if (Func.isEmpty(optionsJson)) {
|
||||
return optionsJson;
|
||||
}
|
||||
try {
|
||||
Object value = JsonUtil.parse(optionsJson, List.class);
|
||||
if (!(value instanceof List<?> options)) {
|
||||
return optionsJson;
|
||||
}
|
||||
List<Object> normalizedOptions = options.stream().map(option -> {
|
||||
if (!(option instanceof Map<?, ?> optionMap)) {
|
||||
return option;
|
||||
}
|
||||
Map<String, Object> normalizedOption = new LinkedHashMap<>();
|
||||
optionMap.forEach((key, optionValue) -> normalizedOption.put(String.valueOf(key), optionValue));
|
||||
if (normalizedOption.containsKey("score")) {
|
||||
normalizedOption.put("score", toPlainDecimalString(normalizedOption.get("score")));
|
||||
}
|
||||
if (normalizedOption.containsKey("changeValue")) {
|
||||
normalizedOption.put("changeValue", toPlainDecimalString(normalizedOption.get("changeValue")));
|
||||
}
|
||||
return normalizedOption;
|
||||
}).toList();
|
||||
return JsonUtil.toJson(normalizedOptions);
|
||||
} catch (Exception exception) {
|
||||
return optionsJson;
|
||||
}
|
||||
}
|
||||
|
||||
private String toPlainDecimalString(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return new BigDecimal(String.valueOf(value)).stripTrailingZeros().toPlainString();
|
||||
} catch (NumberFormatException exception) {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
private List<CreditRatingStandardVO> loadStandards(Long quantificationId) {
|
||||
if (Func.isEmpty(quantificationId)) {
|
||||
return new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user