Commit 25eec895 by 张富康

Merge remote-tracking branch 'origin/v5.6.0' into v5.6.0

2 parents 5f653e5b caffab33
......@@ -13,7 +13,7 @@ public class DailyReportFillCheckDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("补填的日期 yyyy-MM-dd")
@ApiModelProperty("补填的月份 yyyy-MM")
private String fillDate;
@ApiModelProperty("员工手机号")
......
package cn.com.glsx.dj.staff.remote.salaryappealapply;
import cn.com.glsx.dj.staff.dto.StaffSalaryAppealApplyRecordDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.DailyReportFillCheckDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealOrderStatDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealSummaryDTO;
import cn.com.glsx.framework.core.annotation.ApiService;
......@@ -61,5 +60,5 @@ public interface StaffSalaryAppealApplyRecordRemote {
/**
* 判断选中日期是否可补填日报
*/
RpcResponse<Boolean> isDailyReportFillAllowed(DailyReportFillCheckDTO dto);
RpcResponse<Boolean> checkTodayInT1ToT5();
}
package cn.com.glsx.dj.staff.remote.salaryappealapply;
import cn.com.glsx.dj.staff.dto.StaffSalaryAppealApplyRecordDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.DailyReportFillCheckDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealOrderStatDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealSummaryDTO;
import cn.com.glsx.dj.staff.service.StaffSalaryAppealApplyRecordService;
......@@ -134,10 +133,9 @@ public class StaffSalaryAppealApplyRecordRemoteImpl implements StaffSalaryAppeal
}
@Override
public RpcResponse<Boolean> isDailyReportFillAllowed(DailyReportFillCheckDTO dto) {
public RpcResponse<Boolean> checkTodayInT1ToT5() {
try {
log.info("isDailyReportFillAllowed start, dto:{}", dto);
Boolean result = staffSalaryAppealApplyRecordService.isDailyReportFillAllowed(dto);
Boolean result = staffSalaryAppealApplyRecordService.checkTodayInT1ToT5();
return RpcResponse.success(result);
} catch (Exception e) {
log.error(e.getMessage(),e);
......
......@@ -9,7 +9,6 @@ import cn.com.glsx.dj.staff.dto.MerchantInfo;
import cn.com.glsx.dj.staff.dto.SalaryAppealApplyAttachmentDTO;
import cn.com.glsx.dj.staff.dto.StaffSalaryAppealApplyRecordDTO;
import cn.com.glsx.dj.staff.dto.performance.PerformanceTimeCycleDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.DailyReportFillCheckDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealOrderStatDTO;
import cn.com.glsx.dj.staff.dto.salaryappealapply.StaffSalaryAppealSummaryDTO;
import cn.com.glsx.dj.staff.enums.PerformanceTimeCycleCodeEnum;
......@@ -509,8 +508,8 @@ public class StaffSalaryAppealApplyRecordService {
// 判断appealMonth是否等于上个月
boolean isLastMonth = Objects.equals(appealMonth, lastMonth);
// 判断是否为驻店人员(loginRole=5)
boolean isStoreStaff = Objects.equals(dto.getLoginRole(), 5);
// 判断是否为驻店人员(cn.com.glsx.dj.carboutique.enums.LoginRoleEnum)
boolean isStoreStaff = Objects.equals(dto.getLoginRole(), 4);
// 获取T3时间配置(考勤申诉周期)
PerformanceTimeCycleDTO t3Cycle =
......@@ -526,29 +525,7 @@ public class StaffSalaryAppealApplyRecordService {
result.setPadAppealable(isStoreStaff && isLastMonth && inT3Period);
// 获取T1-T5时间配置(补日报周期)
boolean inT1ToT5Period = false;
if (isLastMonth) {
// 检查是否在T1到T5的任意一个周期内
String[] tCodes = {
PerformanceTimeCycleCodeEnum.T1.getCode(),
PerformanceTimeCycleCodeEnum.T2.getCode(),
PerformanceTimeCycleCodeEnum.T3.getCode(),
PerformanceTimeCycleCodeEnum.T4.getCode(),
PerformanceTimeCycleCodeEnum.T5.getCode()
};
Date now = new Date();
Map<String, PerformanceTimeCycleDTO> cycleMap = performanceTimeCycleService.list().stream()
.collect(Collectors.toMap(PerformanceTimeCycleDTO::getCycleCode, Function.identity()));
for (String tCode : tCodes) {
PerformanceTimeCycleDTO cycle = cycleMap.get(tCode);
if (cycle != null && cycle.getStartDate() != null && cycle.getEndDate() != null) {
if (!now.before(cycle.getStartDate()) && !now.after(cycle.getEndDate())) {
inT1ToT5Period = true;
break;
}
}
}
}
boolean inT1ToT5Period = checkTodayInT1ToT5();
// 补日报:只允许在T1-T5周期内补上个月的日报
result.setDailyReportable(isLastMonth && inT1ToT5Period);
SimpleDateFormat sdf = new SimpleDateFormat("d");
......@@ -664,65 +641,34 @@ public class StaffSalaryAppealApplyRecordService {
}
/**
* 判断选中日期是否可补填日报
* @param dto 包含补填日期、员工信息等
* 检查今天是否在T1-T5周期内
* @return true-可以补填,false-不可以补填
*/
public Boolean isDailyReportFillAllowed(DailyReportFillCheckDTO dto) {
log.info("isDailyReportFillAllowed start, dto:{}", dto);
// 1. 校验参数
if (dto == null || dto.getFillDate() == null) {
log.error("参数不能为空");
return false;
}
try {
// 2. 解析补填日期,获取所属月份 yyyy-MM
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date fillDate = sdf.parse(dto.getFillDate());
SimpleDateFormat monthFormat = new SimpleDateFormat("yyyy-MM");
String fillMonth = monthFormat.format(fillDate);
// 3. 获取上个月月份字符串
String lastMonth = DateUtils.getLastMonthString(new Date());
// 4. 判断fillMonth是否等于上个月
boolean isLastMonth = Objects.equals(fillMonth, lastMonth);
if (!isLastMonth) {
log.info("补填日期{}不是上个月,不允许补填", dto.getFillDate());
return false;
}
// 5. 检查是否在T1到T5的任意一个周期内
String[] tCodes = {
PerformanceTimeCycleCodeEnum.T1.getCode(),
PerformanceTimeCycleCodeEnum.T2.getCode(),
PerformanceTimeCycleCodeEnum.T3.getCode(),
PerformanceTimeCycleCodeEnum.T4.getCode(),
PerformanceTimeCycleCodeEnum.T5.getCode()
};
Date now = new Date();
Map<String, PerformanceTimeCycleDTO> cycleMap = performanceTimeCycleService.list().stream()
.collect(Collectors.toMap(PerformanceTimeCycleDTO::getCycleCode, Function.identity()));
for (String tCode : tCodes) {
PerformanceTimeCycleDTO cycle = cycleMap.get(tCode);
if (cycle != null && cycle.getStartDate() != null && cycle.getEndDate() != null) {
if (!now.before(cycle.getStartDate()) && !now.after(cycle.getEndDate())) {
log.info("当前时间在{}周期内,允许补填日报", tCode);
return true;
}
public Boolean checkTodayInT1ToT5() {
// 5. 检查是否在T1到T5的任意一个周期内
String[] tCodes = {
PerformanceTimeCycleCodeEnum.T1.getCode(),
PerformanceTimeCycleCodeEnum.T2.getCode(),
PerformanceTimeCycleCodeEnum.T3.getCode(),
PerformanceTimeCycleCodeEnum.T4.getCode(),
PerformanceTimeCycleCodeEnum.T5.getCode()
};
Date now = new Date();
Map<String, PerformanceTimeCycleDTO> cycleMap = performanceTimeCycleService.list().stream()
.collect(Collectors.toMap(PerformanceTimeCycleDTO::getCycleCode, Function.identity()));
for (String tCode : tCodes) {
PerformanceTimeCycleDTO cycle = cycleMap.get(tCode);
if (cycle != null && cycle.getStartDate() != null && cycle.getEndDate() != null) {
if (!now.before(cycle.getStartDate()) && !now.after(cycle.getEndDate())) {
log.info("当前时间在{}周期内,允许补填日报", tCode);
return true;
}
}
log.info("当前时间不在T1-T5周期内,不允许补填日报");
return false;
} catch (ParseException e) {
log.error("日期格式解析异常,fillDate:{}", dto.getFillDate(), e);
return false;
}
log.info("当前时间不在T1-T5周期内,不允许补填日报");
return false;
}
}
\ No newline at end of file
......@@ -111,15 +111,13 @@ public class EffectiveReferralReviewMiniProgramService {
//当前时间年月是否比核查时间晚并超过1个月,或者当前时间不在T1时间配置内,则不可编辑
long monthDiff = getMonthDiff(effectiveReferralReviews.get(0).getReviewMonth());
if ((Objects.nonNull(performanceTimeCycleDTO)
item.setUpdateFlag(1);
if (Objects.nonNull(performanceTimeCycleDTO)
&& performanceTimeCycleDTO.getStartDate() != null
&& performanceTimeCycleDTO.getEndDate() != null
&& new Date().after(performanceTimeCycleDTO.getEndDate()))
|| monthDiff > 1) {
item.setUpdateFlag(0);
}
else {
item.setUpdateFlag(1);
&& performanceTimeCycleDTO.getEndDate() != null) {
if (new Date().after(performanceTimeCycleDTO.getEndDate()) || monthDiff > 1) {
item.setUpdateFlag(0);
}
}
});
}
......@@ -148,15 +146,13 @@ public class EffectiveReferralReviewMiniProgramService {
//6、封装返回参数
StoreEffectiveReferralDetailDTO detailDTO = new StoreEffectiveReferralDetailDTO();
if ((Objects.nonNull(performanceTimeCycleDTO)
detailDTO.setUpdateFlag(1);
if (Objects.nonNull(performanceTimeCycleDTO)
&& performanceTimeCycleDTO.getStartDate() != null
&& performanceTimeCycleDTO.getEndDate() != null
&& new Date().after(performanceTimeCycleDTO.getEndDate()))
|| monthDiff > 1) {
detailDTO.setUpdateFlag(0);
}
else {
detailDTO.setUpdateFlag(1);
&& performanceTimeCycleDTO.getEndDate() != null) {
if (new Date().after(performanceTimeCycleDTO.getEndDate()) || monthDiff > 1) {
detailDTO.setUpdateFlag(0);
}
}
detailDTO.setMerchantName(referralReviewCommonDTOS.get(0).getMerchantName());
detailDTO.setSceneTypeEffectiveReferrals(sceneTypeEffectiveReferrals);
......
......@@ -122,13 +122,13 @@ public class EffectiveReferralReviewService {
//4、填充复核状态,待复核状态下的数据,如果当前时间大于T1时间配置内的结束时间,置为已失效
for (EffectiveReferralReviewCommonDTO item : list) {
if ((Objects.nonNull(performanceTimeCycleDTO)
if (Objects.nonNull(performanceTimeCycleDTO)
&& performanceTimeCycleDTO.getStartDate() != null
&& performanceTimeCycleDTO.getEndDate() != null
&& item.getIsReviewed().equals(0)
&& new Date().after(performanceTimeCycleDTO.getEndDate()))
|| (item.getIsReviewed().equals(0) && monthDiff > 1)) {
item.setIsReviewed(2);
&& item.getIsReviewed().equals(0)) {
if (new Date().after(performanceTimeCycleDTO.getEndDate()) || monthDiff > 1) {
item.setIsReviewed(2);
}
}
}
......@@ -173,13 +173,13 @@ public class EffectiveReferralReviewService {
//3、当前时间年月是否比核查时间晚并超过1个月, 则不可编辑
long monthDiff = getMonthDiff(reviewCommonDTO.getReviewMonth());
if ((Objects.nonNull(performanceTimeCycleDTO)
if (Objects.nonNull(performanceTimeCycleDTO)
&& performanceTimeCycleDTO.getStartDate() != null
&& performanceTimeCycleDTO.getEndDate() != null
&& reviewCommonDTO.getIsReviewed().equals(0)
&& new Date().after(performanceTimeCycleDTO.getEndDate()))
|| (reviewCommonDTO.getIsReviewed().equals(0) && monthDiff > 1)) {
reviewCommonDTO.setIsReviewed(2);
&& reviewCommonDTO.getIsReviewed().equals(0)) {
if (new Date().after(performanceTimeCycleDTO.getEndDate()) || monthDiff > 1) {
reviewCommonDTO.setIsReviewed(2);
}
}
return reviewCommonDTO;
}
......
......@@ -111,7 +111,9 @@
AND serr.is_reviewed = #{isReviewed}
</if>
<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 test="isReviewed != null and isReviewed == 2 and cycleStartDate == null and cycleEndDate == null">
AND serr.is_reviewed = #{isReviewed}
......
  • @wangxw1
    commented
    Master

    Auto Review Result: 您好,我是负责本次代码审查的工程师。针对您提交的关于修正工作微信商户ID配置的代码变更(Commit ID: fix(common)),我进行了详细的审查。

    以下是具体的审查报告:

    1. 问题描述和优化建议

    1.1 注释与配置的一致性 (Best Practices & Correctness)

    • 现状:本次提交主要修改了代码中的注释,将开发环境(dev)的 merchantId 备注值更新为 44211227。代码逻辑依赖 OrePropertyConfigurer 获取配置值。
    • 潜在风险:修改注释并不会改变程序的运行时行为。必须确保外部配置中心(如 Nacos, Apollo, 或 .properties 文件)中的 dj.send.work.wechat.merchant.id 键值确实已同步更新为 44211227。否则,注释与实际配置不符会误导后续维护人员。
    • 建议:确认相应的配置文件或配置中心已同步修改。

    1.2 默认值策略风险 (Safety & Best Practices)

    • 现状:代码中 getProperty 方法使用了硬编码的 44202977(线上环境ID)作为默认值。 java OrePropertyConfigurer.getProperty("...", Integer.class, 44202977);
    • 潜在风险:这是一个安全隐患。如果开发或测试环境的配置加载失败(例如配置缺失或网络问题),程序将默认使用“线上”环境的 ID。这可能导致测试数据污染生产环境,或在测试环境中发送真实的生产消息。
    • 建议:
      1. 移除生产环境默认值:建议不要在代码中硬编码生产环境 ID 作为 fallback。如果配置缺失,应允许程序抛出异常(Fail Fast),或者给出一个无效/空的默认值,以避免跨环境污染。
      2. 消除魔术数字:将 44202977 提取为具名常量(如 DEFAULT_MERCHANT_ID),虽然在本例中建议完全移除该默认值。

    2. 评分明细

    • 功能实现的正确性与健壮性(38/40分)

      • 代码逻辑本身未发生实质性破坏,沿用了原有的配置获取方式。扣分项在于修改注释不代表修改逻辑,需依赖外部操作保障正确性。
    • 安全性与潜在风险(25/30分)

      • 存在环境隔离风险。将生产环境 ID 硬编码为默认值(Fallback)属于不安全的设计模式,容易在配置中心故障时导致环境穿透。
    • 是否符合最佳实践(15/20分)

      • 优点:注释更新及时,反映了业务变更。
      • 改进空间:使用了 Magic Number(魔术数字);依赖注释来记录环境参数而非文档化或集中化管理配置元数据。
    • 性能与资源利用效率(5/5分)

      • 该变更仅涉及配置获取,对性能无影响。
    • Commits信息的清晰性与准确性(5/5分)

      • Commit Message 遵循了规范(fix(common): ...),清晰地描述了变更内容(开发环境ID更新)和目的,信息完整。

    3. 总分

    总分:88分

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