Commit 96e1bdeb by 庞善天

员工上级获取逻辑修改

1 parent e26f3c5e
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<dependency> <dependency>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-smartcarlife-api</artifactId> <artifactId>rpc-dj-smartcarlife-api</artifactId>
<version>5.7.0-SNAPSHOT</version> <version>5.7.5-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
......
...@@ -16,8 +16,11 @@ import cn.com.glsx.dj.mindworkplate.model.sop.SopShortCourseTask; ...@@ -16,8 +16,11 @@ import cn.com.glsx.dj.mindworkplate.model.sop.SopShortCourseTask;
import cn.com.glsx.dj.mindworkplate.model.sop.SopShortCourseTaskDetail; import cn.com.glsx.dj.mindworkplate.model.sop.SopShortCourseTaskDetail;
import cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.StaffBeisenBaseInfoDTO; import cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.StaffBeisenBaseInfoDTO;
import cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.StaffDetailInfoDTO; import cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.StaffDetailInfoDTO;
import cn.com.glsx.dj.smartcarlife.dto.study.StaffStudyCourseDTO;
import cn.com.glsx.dj.smartcarlife.enums.ContentManagerEnum; import cn.com.glsx.dj.smartcarlife.enums.ContentManagerEnum;
import cn.com.glsx.dj.smartcarlife.remote.ContentManagerTaskRemote;
import cn.com.glsx.dj.smartcarlife.remote.StaffBaseInfoRemote; import cn.com.glsx.dj.smartcarlife.remote.StaffBaseInfoRemote;
import cn.com.glsx.dj.smartcarlife.response.course.GetStaffStudyShortCourseDetailVO;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse; import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -70,6 +73,9 @@ public class SopShortCourseTaskService { ...@@ -70,6 +73,9 @@ public class SopShortCourseTaskService {
@Autowired @Autowired
private StaffBaseInfoRemote staffBaseInfoRemote; private StaffBaseInfoRemote staffBaseInfoRemote;
@Autowired
private ContentManagerTaskRemote contentManagerTaskRemote;
/** /**
* 将超时未完成的短课程任务置为已结束并触发处罚 * 将超时未完成的短课程任务置为已结束并触发处罚
*/ */
...@@ -238,7 +244,7 @@ public class SopShortCourseTaskService { ...@@ -238,7 +244,7 @@ public class SopShortCourseTaskService {
if (beisenInfoDTO!=null){ if (beisenInfoDTO!=null){
String directLeaderName = beisenInfoDTO.getDirectLeaderName(); String directLeaderName = beisenInfoDTO.getDirectLeaderName();
String entryDateStr = beisenInfoDTO.getEntryDate(); String entryDateStr = beisenInfoDTO.getEntryDate();
task.setSuperiors(directLeaderName); //task.setSuperiors(directLeaderName);
if (StringUtils.isNotEmpty(entryDateStr)){ if (StringUtils.isNotEmpty(entryDateStr)){
try { try {
Date entryDate = Date.from(LocalDate.parse(entryDateStr).atStartOfDay(ZoneId.systemDefault()).toInstant()); Date entryDate = Date.from(LocalDate.parse(entryDateStr).atStartOfDay(ZoneId.systemDefault()).toInstant());
...@@ -254,6 +260,18 @@ public class SopShortCourseTaskService { ...@@ -254,6 +260,18 @@ public class SopShortCourseTaskService {
} catch (Exception e) { } catch (Exception e) {
log.warn("短课程任务生成:查询员工详情失败,phone: {}", staffPhone, e); log.warn("短课程任务生成:查询员工详情失败,phone: {}", staffPhone, e);
} }
// 赋值员工上级
try {
StaffStudyCourseDTO studyCourseDTO = new StaffStudyCourseDTO();
studyCourseDTO.setStaffPhone(staffPhone);
RpcResponse<GetStaffStudyShortCourseDetailVO> staffInfo = contentManagerTaskRemote.getStaffLightShortCourseDetail(studyCourseDTO);
if (staffInfo != null && staffInfo.isSuccess() && staffInfo.getResult() != null) {
GetStaffStudyShortCourseDetailVO staffInfoResult = staffInfo.getResult();
task.setSuperiors(staffInfoResult.getSuperior());
}
} catch (Exception e) {
log.warn("短课程任务生成:查询员工上级失败,phone: {}", staffPhone, e);
}
} }
private Date addHours(Date base, Integer hours) { private Date addHours(Date base, Integer hours) {
......
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议(Top 3)

    1. 潜在的 N+1 RPC 调用性能瓶颈(性能与资源利用)

    • 问题描述:在 SopShortCourseTaskService 中新增了对 contentManagerTaskRemote.getStaffLightShortCourseDetail 的 Dubbo RPC 调用,用于获取单个员工的上级信息。
    • 影响分析:由于该类名为 TaskService,通常涉及批量处理或定时任务。如果当前方法处于一个遍历员工列表的 for 循环中,将会产生经典的 N+1 RPC 调用问题。频繁的跨服务网络请求会导致当前服务阻塞、耗时剧增,同时也会给 contentManagerTaskRemote 服务提供者带来巨大的并发压力,极端情况下可能耗尽线程池。
    • 优化建议: 评估该方法的调用场景。如果是批量处理,强烈建议在服务提供者端新增批量查询接口(例如传入 List<String> phoneList),在循环外一次性获取所有相关员工的上级信息,然后在内存中进行匹配赋值。

    2. 依赖 SNAPSHOT 版本存在发布风险(最佳实践与稳定性)

    • 问题描述:pom.xml 中将 rpc-dj-smartcarlife-api 的版本升级为了 5.7.5-SNAPSHOT。
    • 影响分析:SNAPSHOT 版本是快照版本,具有不稳定性(底层代码随时可能被覆盖更新)。在开发和联调阶段使用是合理的,但如果带着 SNAPSHOT 依赖合并到主分支并发布到生产环境,会导致构建结果不可预期,极易引发线上生产事故。
    • 优化建议: 在代码合并至 Release 或 Master 分支前,务必确保将 5.7.5-SNAPSHOT 替换为稳定的正式版本(Release 版)。建议在 CI/CD 流程中加入对 SNAPSHOT 依赖的拦截检测。

    3. 遗留注释代码与提交信息不规范(最佳实践与可维护性)

    • 问题描述:
      1. 代码中遗留了被注释掉的无用代码 //task.setSuperiors(directLeaderName);。
      2. Git 提交信息 “员工上级获取逻辑修改 (by pangst)” 过于简略,只说明了“做了什么”,没有说明“为什么做”。
    • 影响分析:被注释的代码随时间推移会变成“僵尸代码”,降低代码可读性,干扰后续维护人员的视线。缺乏业务背景的 commit message 导致代码追溯困难,无法了解将上级获取数据源从“北森”切换到“内容管理”的业务背景。
    • 优化建议:
      • 借助 Git 的版本控制能力,直接删除无用的注释代码。
      • 规范 Commit Message,建议补充修改原因,例如:“feat: 修改员工上级获取逻辑,因北森数据同步延迟,切换至通过内容管理服务实时获取上级信息”。

    二、评分明细

    • 功能实现的正确性与健壮性(38/40分) 理由:业务逻辑修改正确,新增的 RPC 调用增加了 try-catch 异常捕获,且做了判空处理,保证了获取上级失败时不会阻断主流程的执行。未发现违反 Mybatis 子查询及 Dubbo 接口参数变更的危险规则。扣掉2分是因为在异常捕获中直接吞掉了异常并仅打印 warn 日志,若上级字段是核心业务字段,可能会导致静默错误。

    • 安全性与潜在风险(30/30分) 理由:本次变更为内部逻辑调整与 RPC 调用,未涉及外部参数的直接拼接与暴露,不存在 SQL 注入、XSS、越权等明显的安全风险。

    • 最佳实践与可维护性(16/20分) 理由:存在引入 SNAPSHOT 依赖的风险,且代码中留有注释掉的废弃代码,不够整洁。

    • 性能与资源利用(2/5分) 理由:在任务处理逻辑中单条调用 RPC 接口获取数据,存在极大的 N+1 性能隐患,未采用批量查询的思想,对系统资源利用不够友好。

    • 提交信息质量(3/5分) 理由:提交信息描述了变更点,但缺乏业务上下文和变更动机(Why),不利于后期的代码 Review 和历史追溯。

    总分:89分

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