Commit 31c9f141 by 林永健

fix(model-call): 岚图违规话术模型调用逻辑修改

- 跳转品牌和模型熟悉配置的关联关系
- 透传一二级品牌字段
1 parent 8a426338
...@@ -194,8 +194,8 @@ public class EmployeeBadgeRecordingService { ...@@ -194,8 +194,8 @@ public class EmployeeBadgeRecordingService {
conversationBatchMapper.insertUseGeneratedKeys(conversationBatch); conversationBatchMapper.insertUseGeneratedKeys(conversationBatch);
if (badgeRecordings.getCheResultFlag() == 0 && badgeRecordings.getCheckType() == 1) { if (badgeRecordings.getCheResultFlag() == 0 && badgeRecordings.getCheckType() == 1) {
// 需要质检 // 需要质检
String carModel = badgeRecordings.getCarModel(); String carBrandId = Objects.isNull(badgeRecordings.getCarBrandId()) ? null : badgeRecordings.getCarBrandId().toString();
recordingBatchModelCallService.insertWaitGet(conversationBatch.getId(), carModel); recordingBatchModelCallService.insertWaitGet(conversationBatch.getId(), carBrandId);
} }
} }
} }
......
...@@ -205,6 +205,8 @@ public class ReceptionCustomerService { ...@@ -205,6 +205,8 @@ public class ReceptionCustomerService {
boolean checkFlag = true; boolean checkFlag = true;
MerchantDTO merchantBrand = findMerchantBrand(merchantDTO); MerchantDTO merchantBrand = findMerchantBrand(merchantDTO);
badgeRecordings.setCarModel(receptionCustomerInfoDTO.getCarModel()); badgeRecordings.setCarModel(receptionCustomerInfoDTO.getCarModel());
badgeRecordings.setCarBrandId(receptionCustomerInfoDTO.getCarBrandId());
badgeRecordings.setOneCarBrandId(receptionCustomerInfoDTO.getOneCarBrandId());
Integer recordId = employeeBadgeRecordingService.addRecordingForMatePad( Integer recordId = employeeBadgeRecordingService.addRecordingForMatePad(
badgeRecordings, badgeRecordings,
recordUrlList, receptionCustomerInfoDTO.getChannelType(), checkFlag,Arrays.asList(receptionCustomerInfo.getOneCarBrandId())); recordUrlList, receptionCustomerInfoDTO.getChannelType(), checkFlag,Arrays.asList(receptionCustomerInfo.getOneCarBrandId()));
......
...@@ -74,35 +74,35 @@ public class RecordingBatchModelCallService { ...@@ -74,35 +74,35 @@ public class RecordingBatchModelCallService {
* *
* @param recordingBatchId 录音批次id * @param recordingBatchId 录音批次id
*/ */
public void insertWaitGet(Integer recordingBatchId, String carModel){ public void insertWaitGet(Integer recordingBatchId, String carBrandId){
List<RecordingBatchModelCall> recordingBatchModelCallList = new ArrayList<>(); List<RecordingBatchModelCall> recordingBatchModelCallList = new ArrayList<>();
// 通用配置 // 通用配置
String property = environment.getProperty("recording.model.call.type.nwj"); String property = environment.getProperty("recording.model.call.type.nwj");
// 车型关联配置 // 车型关联配置
String carModelPropertyStr = environment.getProperty("recording.model.call.type.map"); String carBrandPropertyStr = environment.getProperty("recording.model.call.type.map");
if (StringUtils.isBlank(carModelPropertyStr)) { if (StringUtils.isBlank(carBrandPropertyStr)) {
log.error("录音大模型任务创建异常,未配置车型对应关系"); log.error("录音大模型任务创建异常,未配置车型对应关系");
return; return;
} }
try { try {
JSONObject carModelPropertyObj = JSON.parseObject(carModelPropertyStr); JSONObject carBrandPropertyObj = JSON.parseObject(carBrandPropertyStr);
if (Objects.isNull(carModelPropertyObj)) { if (Objects.isNull(carBrandPropertyObj)) {
log.error("录音大模型任务创建异常,配置解析异常"); log.error("录音大模型任务创建异常,配置解析异常");
return; return;
} }
if (StringUtils.isNotBlank(carModel)) { if (StringUtils.isNotBlank(carBrandId)) {
property = carModelPropertyObj.keySet().stream() property = carBrandPropertyObj.keySet().stream()
.filter(carModel::contains) .filter(p -> StringUtils.equals(p, carBrandId))
.findFirst() .findFirst()
.map(carModelPropertyObj::getString) .map(carBrandPropertyObj::getString)
.orElse(property); // 匹配不到匹配的则使用通用配置 .orElse(property); // 匹配不到匹配的则使用通用配置
} }
log.info("录音大模型任务配置准备,carModel:{}, property:{}", carModel, property); log.info("录音大模型任务配置准备,carBrandId:{}, property:{}", carBrandId, property);
if (StringUtils.isEmpty(property)) { if (StringUtils.isEmpty(property)) {
log.error("录音大模型任务创建异常,配置为空, carModel:{}, property:{}", carModel, property); log.error("录音大模型任务创建异常,配置为空, carBrandId:{}, property:{}", carBrandId, property);
return; return;
} }
......
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议

    1. 潜在的 NullPointerException (NPE) 风险

    • 问题描述:在 ReceptionCustomerService.java 中,调用 employeeBadgeRecordingService.addRecordingForMatePad 时,最后一个参数使用了 Arrays.asList(receptionCustomerInfo.getOneCarBrandId())。如果 receptionCustomerInfo 对象本身为 null(虽然上下文中未完整展示其初始化,但作为 DTO 转换后的对象需警惕)或 getOneCarBrandId() 返回 null 且后续逻辑对该 List 进行了非空校验外的操作(如 contains 或迭代),可能引发异常。
    • 影响分析:若 receptionCustomerInfo 在特定场景下未获取到,会导致整个业务流程中断,影响录音数据的正常记录。
    • 优化建议:在调用前增加非空校验,或使用 Optional 及工具类(如 Collections.singletonList)确保参数安全性。 java List<Long> carBrandIds = (receptionCustomerInfo != null && receptionCustomerInfo.getOneCarBrandId() != null) ? Collections.singletonList(receptionCustomerInfo.getOneCarBrandId()) : Collections.emptyList();

    2. 配置解析性能与逻辑冗余

    • 问题描述:在 RecordingBatchModelCallService.java 的 insertWaitGet 方法中,每次调用都会通过 environment.getProperty 读取配置并使用 JSON.parseObject 解析。且在匹配 carBrandId 时,将 keySet 转为 stream 进行遍历匹配。
    • 影响分析:在高并发或大批量录音处理场景下,频繁的 JSON 解析和 Environment 访问会造成不必要的 CPU 损耗。此外,既然已经改为精确匹配 StringUtils.equals,直接使用 JSONObject.getString(carBrandId) 即可。
    • 优化建议:建议将配置缓存至内存(如使用 Map 或本地缓存),并简化匹配逻辑。 java // 优化后的匹配逻辑 if (StringUtils.isNotBlank(carBrandId)) { String matchedProperty = carBrandPropertyObj.getString(carBrandId); if (matchedProperty != null) { property = matchedProperty; } }

    3. 类型转换的健壮性问题

    • 问题描述:在 EmployeeBadgeRecordingService.java 中,carBrandId 的获取逻辑为 badgeRecordings.getCarBrandId().toString()。
    • 影响分析:虽然前置有 Objects.isNull 检查,但如果 badgeRecordings.getCarBrandId() 返回的是一个复杂的对象而非预期的数值类型,简单的 toString() 结果可能不符合 RecordingBatchModelCallService 中配置 Key 的定义,导致无法匹配到正确的模型配置。
    • 优化建议:明确 carBrandId 的类型。如果是 Long/Integer,建议使用 String.valueOf();确保该字段在 DTO 传递过程中类型一致。

    二、评分明细

    • 功能实现的正确性与健壮性(36/40分):逻辑基本正确,完成了从 carModel(模糊匹配)到 carBrandId(精确匹配)的切换,提升了匹配准确度。扣分项在于对 receptionCustomerInfo 的潜在 NPE 处理不足。
    • 安全性与潜在风险(28/30分):未发现 SQL 注入或敏感信息泄露。扣分项在于配置解析依赖外部输入字符串,若配置项格式错误可能导致运行时异常。
    • 最佳实践与可维护性(18/20分):变量重命名(carModel -> carBrandId)符合业务语义变更,代码结构清晰。
    • 性能与资源利用(4/5分):存在重复解析 JSON 的问题,虽在低频场景影响较小,但在高频 Rpc 调用中属于不必要的损耗。
    • 提交信息质量(5/5分):Commit 信息遵循了 fix(scope): description 规范,且包含了具体的修改点和作者,非常规范。

    总分:91分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!