Commit 0f0ea5b8 by 崔彦峰

modify:列表查询。

1 parent 3a4a7f2a
...@@ -111,12 +111,12 @@ public class EffectiveReferralReviewMiniProgramService { ...@@ -111,12 +111,12 @@ public class EffectiveReferralReviewMiniProgramService {
//当前时间年月是否比核查时间晚并超过1个月,或者当前时间不在T1时间配置内,则不可编辑 //当前时间年月是否比核查时间晚并超过1个月,或者当前时间不在T1时间配置内,则不可编辑
long monthDiff = getMonthDiff(effectiveReferralReviews.get(0).getReviewMonth()); long monthDiff = getMonthDiff(effectiveReferralReviews.get(0).getReviewMonth());
if ((Objects.nonNull(performanceTimeCycleDTO) if (Objects.nonNull(performanceTimeCycleDTO)
&& performanceTimeCycleDTO.getStartDate() != null && performanceTimeCycleDTO.getStartDate() != null
&& performanceTimeCycleDTO.getEndDate() != null && performanceTimeCycleDTO.getEndDate() != null) {
&& new Date().after(performanceTimeCycleDTO.getEndDate())) if (new Date().after(performanceTimeCycleDTO.getEndDate()) || monthDiff > 1) {
|| monthDiff > 1) { item.setUpdateFlag(0);
item.setUpdateFlag(0); }
} }
else { else {
item.setUpdateFlag(1); item.setUpdateFlag(1);
...@@ -148,12 +148,12 @@ public class EffectiveReferralReviewMiniProgramService { ...@@ -148,12 +148,12 @@ public class EffectiveReferralReviewMiniProgramService {
//6、封装返回参数 //6、封装返回参数
StoreEffectiveReferralDetailDTO detailDTO = new StoreEffectiveReferralDetailDTO(); StoreEffectiveReferralDetailDTO detailDTO = new StoreEffectiveReferralDetailDTO();
if ((Objects.nonNull(performanceTimeCycleDTO) if (Objects.nonNull(performanceTimeCycleDTO)
&& performanceTimeCycleDTO.getStartDate() != null && performanceTimeCycleDTO.getStartDate() != null
&& performanceTimeCycleDTO.getEndDate() != null && performanceTimeCycleDTO.getEndDate() != null) {
&& new Date().after(performanceTimeCycleDTO.getEndDate())) if (new Date().after(performanceTimeCycleDTO.getEndDate()) || monthDiff > 1) {
|| monthDiff > 1) { detailDTO.setUpdateFlag(0);
detailDTO.setUpdateFlag(0); }
} }
else { else {
detailDTO.setUpdateFlag(1); detailDTO.setUpdateFlag(1);
......
...@@ -122,13 +122,13 @@ public class EffectiveReferralReviewService { ...@@ -122,13 +122,13 @@ public class EffectiveReferralReviewService {
//4、填充复核状态,待复核状态下的数据,如果当前时间大于T1时间配置内的结束时间,置为已失效 //4、填充复核状态,待复核状态下的数据,如果当前时间大于T1时间配置内的结束时间,置为已失效
for (EffectiveReferralReviewCommonDTO item : list) { for (EffectiveReferralReviewCommonDTO item : list) {
if ((Objects.nonNull(performanceTimeCycleDTO) if (Objects.nonNull(performanceTimeCycleDTO)
&& performanceTimeCycleDTO.getStartDate() != null && performanceTimeCycleDTO.getStartDate() != null
&& performanceTimeCycleDTO.getEndDate() != null && performanceTimeCycleDTO.getEndDate() != null
&& item.getIsReviewed().equals(0) && item.getIsReviewed().equals(0)) {
&& new Date().after(performanceTimeCycleDTO.getEndDate())) if (new Date().after(performanceTimeCycleDTO.getEndDate()) || monthDiff > 1) {
|| (item.getIsReviewed().equals(0) && monthDiff > 1)) { item.setIsReviewed(2);
item.setIsReviewed(2); }
} }
} }
...@@ -173,13 +173,13 @@ public class EffectiveReferralReviewService { ...@@ -173,13 +173,13 @@ public class EffectiveReferralReviewService {
//3、当前时间年月是否比核查时间晚并超过1个月, 则不可编辑 //3、当前时间年月是否比核查时间晚并超过1个月, 则不可编辑
long monthDiff = getMonthDiff(reviewCommonDTO.getReviewMonth()); long monthDiff = getMonthDiff(reviewCommonDTO.getReviewMonth());
if ((Objects.nonNull(performanceTimeCycleDTO) if (Objects.nonNull(performanceTimeCycleDTO)
&& performanceTimeCycleDTO.getStartDate() != null && performanceTimeCycleDTO.getStartDate() != null
&& performanceTimeCycleDTO.getEndDate() != null && performanceTimeCycleDTO.getEndDate() != null
&& reviewCommonDTO.getIsReviewed().equals(0) && reviewCommonDTO.getIsReviewed().equals(0)) {
&& new Date().after(performanceTimeCycleDTO.getEndDate())) if (new Date().after(performanceTimeCycleDTO.getEndDate()) || monthDiff > 1) {
|| (reviewCommonDTO.getIsReviewed().equals(0) && monthDiff > 1)) { reviewCommonDTO.setIsReviewed(2);
reviewCommonDTO.setIsReviewed(2); }
} }
return reviewCommonDTO; return reviewCommonDTO;
} }
......
...@@ -111,7 +111,9 @@ ...@@ -111,7 +111,9 @@
AND serr.is_reviewed = #{isReviewed} AND serr.is_reviewed = #{isReviewed}
</if> </if>
<if test="isReviewed != null and isReviewed == 2 and cycleStartDate != null and cycleEndDate != null"> <if test="isReviewed != null and isReviewed == 2 and cycleStartDate != null and cycleEndDate != null">
AND serr.is_reviewed = 0 AND (now() &lt; #{cycleStartDate} OR now() &gt; #{cycleEndDate}) AND serr.is_reviewed = 0
AND ((now() &lt; #{cycleStartDate} OR now() &gt; #{cycleEndDate})
OR PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'), REPLACE(serr.review_month, '-', '')) &gt; 1)
</if> </if>
<if test="isReviewed != null and isReviewed == 2 and cycleStartDate == null and cycleEndDate == null"> <if test="isReviewed != null and isReviewed == 2 and cycleStartDate == null and cycleEndDate == null">
AND serr.is_reviewed = #{isReviewed} AND serr.is_reviewed = #{isReviewed}
......
  • @wangxw1
    commented
    Master

    Auto Review Result: 你好。作为代码审查员,我仔细查阅了提交的 rpc-dj-staff 模块中的代码变更。

    本次代码变更主要涉及 EffectiveReferralReviewMiniProgramService 和 EffectiveReferralReviewService 两个服务类中关于绩效考核复核状态判断逻辑的重构。

    以下是详细的代码审查报告:

    代码审查报告

    1. 问题描述和优化建议

    1.1. 严重逻辑缺陷(功能性错误)

    问题描述: 本次修改将原本的布尔逻辑表达式拆分为嵌套的 if 语句,导致了业务逻辑的非预期变更(Regression)。

    • 原逻辑:((配置有效 && 当前时间>配置结束时间) || (月份差异 > 1))。含义是:只要“配置过期”或者“月份过久”,任意一个条件满足即触发锁定(或置为无效)。即使 performanceTimeCycleDTO 为 null,只要 monthDiff > 1,条件依然成立。
    • 新逻辑: java if (Objects.nonNull(performanceTimeCycleDTO) && ...) { if (new Date().after(...) || monthDiff > 1) { ... } } 在新逻辑中,如果 performanceTimeCycleDTO 为 null,外层 if 为假,代码直接跳过内层判断。这意味着,当配置对象为空时,原本应该因为 monthDiff > 1 而被锁定的数据,现在会被错误地判定为可编辑/有效。

    影响:可能导致旧月份的历史数据在未配置时间周期的情况下被错误地允许修改,破坏数据一致性。

    优化建议: 必须恢复原有的逻辑优先级。如果目的是为了代码可读性,建议将逻辑提取为独立的 private 方法,而不是简单的嵌套 if。

    1.2. 违反 DRY (Don't Repeat Yourself) 原则

    问题描述: 相同的逻辑判断代码块(判断 DTO 有效性、时间、月份差异)在两个文件中出现了至少 4次。这增加了维护成本,且容易导致类似本次提交的修改不一致问题。

    优化建议: 建议在工具类或公共 Service 中封装一个方法,例如 boolean isReviewEditable(PerformanceTimeCycleDTO cycleDTO, Date reviewMonth),统一管理该校验逻辑。

    1.3. 性能问题:循环内创建对象

    问题描述: 在 EffectiveReferralReviewService 的循环(Line 124)中,每次迭代都调用 new Date()。

    // 循环内
    if (new Date().after(performanceTimeCycleDTO.getEndDate()) ...)
    

    影响:如果在处理大量数据列表时,会频繁创建短生命周期的 Date 对象,增加 GC 压力。

    优化建议: 将 Date now = new Date(); 提取到循环体外部,循环内部直接使用 now 变量。

    1.4. 魔术数字 (Magic Numbers)

    问题描述: 代码中使用了 0、1、2 等数字字面量来表示状态(如 item.setUpdateFlag(0),item.setIsReviewed(2))。

    优化建议: 应使用枚举(Enum)或常量类来定义这些状态,以提高代码的可读性和可维护性。例如 ReviewStatus.INVALID 或 UpdateFlag.LOCKED。

    1.5. Commit 信息不规范

    问题描述: 提交信息为 modify:列表查询。。该信息过于模糊,未能准确描述本次修改实际上是对“复核校验逻辑”的变更,也没有解释修改的原因。

    优化建议: 遵循 commit message 规范,例如:fix(staff): 修复/重构绩效复核的时间校验逻辑,并在 body 中简述修改了判断优先级。


    2. 评分明细

    评分标准 得分 扣分理由
    功能实现的正确性与健壮性 15/40 存在严重的逻辑回归(Regression),重构改变了原有的业务规则,导致特定条件下(DTO为null)的校验失效。
    安全性与潜在风险 20/30 虽然无注入风险,但业务逻辑漏洞可能导致数据在不应被修改时被修改(越权/脏数据风险)。
    是否符合最佳实践 10/20 代码大量重复(违反DRY),存在魔术数字,未使用 java.time API。
    性能与资源利用效率 3/5 循环内重复创建 Date 对象,虽影响不大但属于不良习惯。
    Commits信息的清晰性与准确性 2/5 提交信息含糊不清,无法反映代码变更的实质内容。

    3. 总分

    总分:50分

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