Commit af5c43a6 by 林永健

fix(data): 修复客户信息查询中业务类型过滤问题

- 修改 ReceptionCustomerInfoMapper.xml 中的 SQL 查询条件
- 将单一业务类型匹配改为多业务类型匹配
- 添加业务类型 1107 到查询范围以支持新业务需求
- 保持原有业务类型 11 的查询功能
1 parent 8b3ba539
......@@ -631,7 +631,7 @@
left join inspection_employee_badge t5 on t2.badge_id =t5.badge_id
left join inspection_conversation_batch t3 on t2.id =t3.record_id
left join recording_batch_model_call_wghs t4 on t3.id =t4.batch_id
left join recording_batch_model_call t6 on (t6.recording_batch_id =t4.batch_id and t6.business_type=11)
left join recording_batch_model_call t6 on (t6.recording_batch_id =t4.batch_id and t6.business_type in (11,1107))
where t4.id is not null
<if test="merchantNo!=null">
and t1.merchant_id = #{merchantNo}
......
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议(仅限 Top 1)

    • 问题 1:SQL 关联查询性能与索引效率风险
      • 问题描述:在 recording_batch_model_call 表(t6)的 LEFT JOIN 条件中,新增了 business_type IN (11, 1107) 的多值过滤。如果该表数据量巨大且 business_type 字段上没有建立合适的复合索引(例如 (recording_batch_id, business_type)),或者索引区分度不高,会导致连接查询效率下降。
      • 影响分析:随着业务类型增加和数据量增长,该 LEFT JOIN 操作可能引发全表扫描或索引扫描范围扩大,增加数据库 CPU 和 I/O 负载,延长接口响应时间。
      • 优化建议:
        1. 确保 recording_batch_model_call 表在 (recording_batch_id, business_type) 字段上有复合索引。
        2. 评估是否必须使用 LEFT JOIN。如果业务逻辑上 t6 必须存在,建议改为 INNER JOIN 以提升驱动表选择的灵活性。
        3. 检查 t4.id is not null 的逻辑,由于 t4 也是 LEFT JOIN,此 WHERE 条件实际上将其转换为了 INNER JOIN 效果,建议直接统一使用 INNER JOIN 以提高查询优化器的执行效率。

    二、评分明细

    • 功能实现的正确性与健壮性(40分):40分。逻辑修改符合业务需求,正确扩展了业务类型范围,且未违反“禁止子查询”的硬性规定。
    • 安全性与潜在风险(30分):30分。使用 MyBatis 预编译占位符,无 SQL 注入风险。
    • 最佳实践与可维护性(20分):18分。SQL 结构清晰,使用了别名。但多表关联(t1-t6)层级较深,建议未来考虑通过宽表或搜索引擎优化复杂查询。
    • 性能与资源利用(5分):4分。增加 IN 条件对性能影响有限,但需关注大表索引覆盖情况。
    • 提交信息质量(5分):5分。Commit 信息遵循 Conventional Commits 规范,描述详尽,包含修改原因与影响。

    总分:97分

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