🐛 评分自评得分哨兵值-1归一为空,避免线下评估默认回显

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-06 09:32:37 +08:00
parent 896564d911
commit 4ebf19de64
@@ -1173,6 +1173,7 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
/** 将 Excel 填写值回填到评分明细:选项型匹配选项,分值型写入 scoreInput/selfScore */
private void applyImportedScoreDetail(CustomerCreditScoreDetailVO detail, String fillValue, String selfScoreText) {
BigDecimal importedSelfScore = parseImportedSelfScore(selfScoreText);
if ("score".equalsIgnoreCase(detail.getOptionType())) {
BigDecimal scoreInput;
try {
@@ -1181,12 +1182,8 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
throw new ServiceException("填写值必须为数字");
}
detail.setScoreInput(scoreInput);
if (Func.isNotEmpty(selfScoreText)) {
try {
detail.setSelfScore(new BigDecimal(selfScoreText));
} catch (NumberFormatException exception) {
throw new ServiceException("自评得分必须为数字");
}
if (importedSelfScore != null) {
detail.setSelfScore(importedSelfScore);
}
return;
}
@@ -1203,13 +1200,19 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
}
detail.setSelectedOption(optionValue == null ? fillValue : String.valueOf(optionValue));
BigDecimal optionScore = resolveOptionScore(matched);
detail.setSelfScore(optionScore == null ? BigDecimal.ZERO : optionScore);
if (Func.isNotEmpty(selfScoreText)) {
try {
detail.setSelfScore(new BigDecimal(selfScoreText));
} catch (NumberFormatException exception) {
throw new ServiceException("自评得分必须为数字");
}
detail.setSelfScore(importedSelfScore != null ? importedSelfScore : (optionScore == null ? BigDecimal.ZERO : optionScore));
}
/** 解析线下 Excel 自评得分;空值或哨兵值 -1 视为未填写 */
private BigDecimal parseImportedSelfScore(String selfScoreText) {
if (Func.isEmpty(selfScoreText) || "-1".equals(selfScoreText.trim())) {
return null;
}
try {
BigDecimal selfScore = new BigDecimal(selfScoreText.trim());
return selfScore.compareTo(BigDecimal.ONE.negate()) == 0 ? null : selfScore;
} catch (NumberFormatException exception) {
throw new ServiceException("自评得分必须为数字");
}
}
@@ -1700,6 +1703,9 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
scoreVO.setMaxCreditLimit(normalizeSentinelAmount(scoreVO.getMaxCreditLimit()));
scoreVO.setApplyCreditLimit(normalizeSentinelAmount(scoreVO.getApplyCreditLimit()));
scoreVO.setTempApplyCreditLimit(normalizeOptionalScoreAmount(scoreVO.getTempApplyCreditLimit()));
scoreVO.setSelfScore(normalizeSentinelAmount(scoreVO.getSelfScore()));
scoreVO.setReviewScore(normalizeSentinelAmount(scoreVO.getReviewScore()));
scoreVO.setFinalScore(normalizeSentinelAmount(scoreVO.getFinalScore()));
scoreVO.setProofAttachments(normalizeScoreProofAttachments(scoreVO));
CustomerCreditScore score = Objects.requireNonNull(BeanUtil.copyProperties(scoreVO, CustomerCreditScore.class));
score.setId(scoreId);
@@ -1720,6 +1726,9 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
if (detailVO.getScore() == null) {
detailVO.setScore(resolveFullScore(detailVO.getOptionsJson()));
}
detailVO.setSelfScore(normalizeSentinelAmount(detailVO.getSelfScore()));
detailVO.setReviewScore(normalizeSentinelAmount(detailVO.getReviewScore()));
detailVO.setScoreInput(normalizeSentinelAmount(detailVO.getScoreInput()));
CustomerCreditScoreDetail detail = Objects.requireNonNull(BeanUtil.copyProperties(detailVO, CustomerCreditScoreDetail.class));
detail.setId(IdWorker.getId());
detail.setTenantId(score.getTenantId());
@@ -1883,8 +1892,17 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
.collect(Collectors.groupingBy(CustomerCreditScoreDetailVO::getScoreId));
return scores.stream().map(score -> {
CustomerCreditScoreVO scoreVO = Objects.requireNonNull(BeanUtil.copyProperties(score, CustomerCreditScoreVO.class));
scoreVO.setSelfScore(normalizeSentinelAmount(scoreVO.getSelfScore()));
scoreVO.setReviewScore(normalizeSentinelAmount(scoreVO.getReviewScore()));
scoreVO.setFinalScore(normalizeSentinelAmount(scoreVO.getFinalScore()));
scoreVO.setAttachments(parseScoreAttachments(score.getProofAttachments()));
scoreVO.setDetails(detailMap.getOrDefault(score.getId(), new ArrayList<>()));
List<CustomerCreditScoreDetailVO> details = detailMap.getOrDefault(score.getId(), new ArrayList<>());
details.forEach(detail -> {
detail.setSelfScore(normalizeSentinelAmount(detail.getSelfScore()));
detail.setReviewScore(normalizeSentinelAmount(detail.getReviewScore()));
detail.setScoreInput(normalizeSentinelAmount(detail.getScoreInput()));
});
scoreVO.setDetails(details);
scoreVO.setStandards(loadStandards(score.getQuantificationId()));
return scoreVO;
}).toList();
@@ -2004,8 +2022,9 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
: resolveFullScore(itemOptions);
detail.setScore(fullScore == null ? BigDecimal.ZERO : fullScore);
detail.setOptionsJson(buildOptionsJson(itemOptions));
detail.setSelfScore(BigDecimal.ZERO);
detail.setReviewScore(BigDecimal.ZERO);
// 模板明细自评/复评默认空,避免前端线下评估回显 -1/0 哨兵值
detail.setSelfScore(null);
detail.setReviewScore(null);
details.add(detail);
}
return details;