Commit dcd8ef02 by 谢海旭

招聘管理:导出 招聘周期 调整

1 parent ba710fee
...@@ -1667,11 +1667,15 @@ public class RecruitmentDemandService { ...@@ -1667,11 +1667,15 @@ public class RecruitmentDemandService {
staffArrivalTime = onboardingDateStr; staffArrivalTime = onboardingDateStr;
} }
} }
// 招聘周期 = 入职时间 - 提需求时间(天) // 招聘周期 = 入职时间 - 提需求时间(天),入职早于需求创建时取0
Date demandCreatedDate = demand.getCreatedDate(); Date demandCreatedDate = demand.getCreatedDate();
if (demandCreatedDate != null) { if (demandCreatedDate != null) {
long cycleDays = DateUtil.betweenDay(demandCreatedDate, onboardingDate, true); if (onboardingDate.before(demandCreatedDate)) {
baseInfo.setRecruitmentCycle((int) Math.max(cycleDays, 0)); baseInfo.setRecruitmentCycle(0);
} else {
long cycleDays = DateUtil.betweenDay(demandCreatedDate, onboardingDate, true);
baseInfo.setRecruitmentCycle((int) cycleDays);
}
} }
} }
// 登记时间 = 入职记录创建时间 // 登记时间 = 入职记录创建时间
......
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议,如果必要,给出代码示例(仅限 Top 3)

    1. onboardingDate 存在潜在的 NullPointerException (空指针异常) 风险

    • 问题描述:在新增的逻辑中,直接调用了 onboardingDate.before(demandCreatedDate)。虽然外层对 demandCreatedDate 进行了非空判断,但并未对 onboardingDate 进行非空校验。如果上下文逻辑中 onboardingDate 可能为 null,此处将直接抛出 NPE。
    • 影响分析:如果在某些异常或边界数据情况下(如未正确录入入职时间),onboardingDate 为空,会导致整个导出任务或当前数据处理流程崩溃中断。
    • 优化建议:在调用 .before() 方法前,增加对 onboardingDate 的非空防御性判断。

    代码示例:

    Date demandCreatedDate = demand.getCreatedDate();
    // 增加 onboardingDate != null 的防御性判断
    if (demandCreatedDate != null && onboardingDate != null) {
        if (onboardingDate.before(demandCreatedDate)) {
            baseInfo.setRecruitmentCycle(0);
        } else {
            long cycleDays = DateUtil.betweenDay(demandCreatedDate, onboardingDate, true);
            baseInfo.setRecruitmentCycle((int) cycleDays);
        }
    } else if (demandCreatedDate != null) {
        // 视业务情况处理 onboardingDate 为空时的默认逻辑,或者保持原样不设置
        baseInfo.setRecruitmentCycle(0); 
    }
    

    二、评分明细

    • 1. 功能实现的正确性与健壮性 (35/40分)
      • 理由:业务逻辑调整是正确的(修复了原代码中 DateUtil.betweenDay 可能返回绝对值导致 Math.max 无法正确处理入职早于需求场景的 Bug)。但缺乏对 onboardingDate 的非空校验,健壮性存在微小瑕疵,扣除 5 分。未触发 MyBatis 子查询与 Dubbo 接口变更的红线规则。
    • 2. 安全性与潜在风险 (30/30分)
      • 理由:本次变更仅涉及日期计算和简单的对象赋值,不存在 SQL 注入、XSS、越权等安全隐患。
    • 3. 最佳实践与可维护性 (18/20分)
      • 理由:代码结构清晰,且同步更新了业务注释,可读性较好。但防御性编程意识可以进一步加强,扣除 2 分。
    • 4. 性能与资源利用 (5/5分)
      • 理由:仅为基础的日期比较与计算,无性能瓶颈,资源利用合理。
    • 5. 提交信息质量 (4/5分)
      • 理由:Commit 信息“招聘管理:导出 招聘周期 调整”说明了修改模块和动作,但稍微缺乏对“为什么调整(即修复入职早于需求时的计算问题)”的描述,扣除 1 分。

    总分:92分

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