Merge remote-tracking branch 'origin/v5.7.3' into v5.7.1
# Conflicts: # rpc-dj-mindworkplate-api/pom.xml # rpc-dj-mindworkplate/pom.xml
Showing
19 changed files
with
1035 additions
and
0 deletions
This diff is collapsed.
Click to expand it.
-
一、关键问题与优化建议(Top 3)
1. 严重逻辑缺陷与性能瓶颈(功能正确性与性能)
-
问题描述:在
ReceptionCustomerFileGenerateService.java的sendWeChatPushMessages方法中存在两个严重问题。第一,在批量生成初始化档案时,错误地遍历了全量receptionList,而不是发送成功的sucessList;第二,在for循环中同步调用qwManager.getUserId()(发起 HTTP 请求),存在典型的 N+1 性能问题。 -
影响分析:
- 只要有一个企微消息发送成功,系统就会为所有待处理记录(包含发送失败或未查到企微ID的人员)生成客户档案,导致产生脏数据。
- 循环内发起 HTTP 请求,若当批次数据量较大,会导致长时间阻塞,甚至引发连接超时或内存溢出。
-
优化建议:修复遍历集合的错误;建议将获取企微 ID 的逻辑改为批量查询,或在可控的小批量数据下使用。
java // 修复脏数据插入Bug:将 receptionList 替换为 sucessList if (CollectionUtils.isNotEmpty(sucessList)) { Date now = new Date(); List<ReceptionCustomerFile> insertList = sucessList.stream() // <-- 此处改为 sucessList .map(x -> buildInitCustomerFile(x, now)) .collect(Collectors.toList()); receptionCustomerFileMapper.batchInsertInit(insertList); }
2. 违反开发规范:MyBatis 存在子查询(功能正确性)
-
问题描述:在
ReceptionCustomerFileMapper.xml的listNeedGenerateTodayLightModReception方法中,使用了NOT EXISTS子查询。 - 影响分析:违反了“mybatis SQL中不允许使用子查询”的强制规则。子查询在某些 MySQL 版本下会导致未能有效利用索引,引发慢 SQL,影响数据库性能。
-
优化建议:使用
LEFT JOIN结合IS NULL来替换NOT EXISTS子查询。xml <!-- 优化后的 SQL 示例 --> select distinct rci.id as id, ... from reception_customer_info rci ... left join reception_customer_file rcf on rcf.reception_id = rci.id and rcf.deleted_flag = 'N' where rci.deleted_flag = 'N' and rci.bussiness_type = 2 and rci.reception_start_time >= #{startTime} and rci.reception_start_time < #{endTime} and ibr.recording_id is not null and ibr.recording_id != '' and rcf.id is null <!-- 替换 NOT EXISTS --> order by rci.id asc
3. 定时任务存在空指针异常风险(健壮性)
-
问题描述:在
ReceptionCustomerFileGenerateJob.java中,@Autowired注解被注释掉了(//@Autowired),但execute方法中直接调用了receptionCustomerFileGenerateService。 -
影响分析:Spring 容器无法注入该 Service,当 Elastic-Job 触发该任务执行时,必定会抛出
NullPointerException,导致定时任务完全失效。 -
优化建议:恢复
@Autowired注解,或使用构造器注入。java @Autowired // <-- 移除注释 private ReceptionCustomerFileGenerateService receptionCustomerFileGenerateService;
二、评分明细
- 功能实现的正确性与健壮性(20/40分):扣分较多。严重违反了 MyBatis 禁用子查询的强制规则;定时任务存在明显的 NPE 导致不可用;批量插入逻辑错误导致产生脏数据。
-
安全性与潜在风险(28/30分):整体安全性较好,使用了参数化查询防止 SQL 注入。微小扣分项在于
QWManager.java中使用了e.printStackTrace();吞噬了日志上下文,生产环境中应统一使用log.error("...", e)记录异常信息。 -
最佳实践与可维护性(17/20分):代码结构清晰,分层合理,DTO 与实体类隔离较好。但在
QWManager等地方存在部分硬编码,且部分被注释的废弃代码(如@ElasticJobConf)未清理,影响可读性。 -
性能与资源利用(2/5分):在
for循环中频繁发起 HTTP 请求(N+1 问题)是明显的性能反模式,尤其在定时任务批处理场景下容易引发资源耗尽。 - 提交信息质量(4/5分):Commit 信息(如“添加推送轻改客户录音到群聊功能”、“修改查询客户档案逻辑”)基本能说明意图,但存在多次细碎提交未做 Squash 的情况,追溯起来略显冗余。
总分:71分
-
问题描述:在
-
Please register or sign in to post a comment