1 Commits

Author SHA1 Message Date
dk
7f832d819e feat(workreport): 添加工作报告待提交提醒功能
- 新增 selectListByPendingSubmitReminder 方法用于查询待提交的工作报告
- 添加通知模板常量用于待审批通知功能
- 替换 ChronoField 为 IsoFields 以正确处理基于周的年份计算
- 实现个人工作报告待直属上级审批的通知发布逻辑
- 实现项目报告待审批通知的发布功能
- 创建 WorkReportPendingSubmitRemindScheduler 定时任务类
- 实现 WorkReportPendingSubmitRemindService 服务类处理提醒逻辑
- 添加定时任务每晚 8 点检查并提醒逾期未提交的报告
- 支持周报、月报和项目报告三种类型的待提交提醒
- 实现基于截止时间过滤并按创建时间排序的查询逻辑
2026-07-02 16:33:33 +08:00
8 changed files with 247 additions and 3 deletions

View File

@@ -162,6 +162,18 @@ public interface MonthlyReportMapper extends BaseMapperX<MonthlyReportDO> {
.in(MonthlyReportDO::getStatusCode, statuses));
}
default List<MonthlyReportDO> selectListByPendingSubmitReminder(LocalDateTime cutoffTime,
Collection<String> statusCodes) {
if (cutoffTime == null || statusCodes == null || statusCodes.isEmpty()) {
return List.of();
}
return selectList(new LambdaQueryWrapperX<MonthlyReportDO>()
.in(MonthlyReportDO::getStatusCode, statusCodes)
.le(MonthlyReportDO::getCreateTime, cutoffTime)
.orderByAsc(MonthlyReportDO::getCreateTime)
.orderByAsc(MonthlyReportDO::getId));
}
private LambdaQueryWrapperX<MonthlyReportDO> buildPageQuery(MonthlyReportPageReqVO reqVO) {
LambdaQueryWrapperX<MonthlyReportDO> wrapper = new LambdaQueryWrapperX<MonthlyReportDO>()
.eqIfPresent(MonthlyReportDO::getStatusCode, reqVO.getStatusCode())

View File

@@ -172,6 +172,18 @@ public interface ProjectReportMapper extends BaseMapperX<ProjectReportDO> {
.in(ProjectReportDO::getStatusCode, statuses));
}
default List<ProjectReportDO> selectListByPendingSubmitReminder(LocalDateTime cutoffTime,
Collection<String> statusCodes) {
if (cutoffTime == null || statusCodes == null || statusCodes.isEmpty()) {
return List.of();
}
return selectList(new LambdaQueryWrapperX<ProjectReportDO>()
.in(ProjectReportDO::getStatusCode, statusCodes)
.le(ProjectReportDO::getCreateTime, cutoffTime)
.orderByAsc(ProjectReportDO::getCreateTime)
.orderByAsc(ProjectReportDO::getId));
}
private LambdaQueryWrapperX<ProjectReportDO> buildPageQuery(ProjectReportPageReqVO reqVO) {
LambdaQueryWrapperX<ProjectReportDO> wrapper = new LambdaQueryWrapperX<ProjectReportDO>()
.eqIfPresent(ProjectReportDO::getProjectId, reqVO.getProjectId())

View File

@@ -162,6 +162,18 @@ public interface WeeklyReportMapper extends BaseMapperX<WeeklyReportDO> {
.in(WeeklyReportDO::getStatusCode, statuses));
}
default List<WeeklyReportDO> selectListByPendingSubmitReminder(LocalDateTime cutoffTime,
Collection<String> statusCodes) {
if (cutoffTime == null || statusCodes == null || statusCodes.isEmpty()) {
return List.of();
}
return selectList(new LambdaQueryWrapperX<WeeklyReportDO>()
.in(WeeklyReportDO::getStatusCode, statusCodes)
.le(WeeklyReportDO::getCreateTime, cutoffTime)
.orderByAsc(WeeklyReportDO::getCreateTime)
.orderByAsc(WeeklyReportDO::getId));
}
private LambdaQueryWrapperX<WeeklyReportDO> buildPageQuery(WeeklyReportPageReqVO reqVO) {
LambdaQueryWrapperX<WeeklyReportDO> wrapper = new LambdaQueryWrapperX<WeeklyReportDO>()
.eqIfPresent(WeeklyReportDO::getStatusCode, reqVO.getStatusCode())

View File

@@ -32,6 +32,14 @@ public class NotifyTemplateCodeConstants {
public static final String WORK_REPORT_PROJECT_HALF_MONTH_TEAM_REMIND =
"work_report_project_half_month_team_remind";
/** 工作报告待直属上级审批通知:周报/月报通用 */
public static final String WORK_REPORT_PENDING_APPROVAL_NOTIFY =
"work_report_pending_approval_notify";
/** 项目半月报待直属上级审批通知 */
public static final String WORK_REPORT_PROJECT_HALF_MONTH_PENDING_APPROVAL_NOTIFY =
"work_report_project_half_month_pending_approval_notify";
/** 执行指派:创建执行后通知负责人 + 协办人 */
public static final String EXECUTION_ASSIGNED = "execution_assigned";

View File

@@ -7,6 +7,8 @@ import com.njcn.rdms.framework.common.util.object.BeanUtils;
import com.njcn.rdms.framework.security.core.util.SecurityFrameworkUtils;
import com.njcn.rdms.module.project.constant.ProjectObjectConstants;
import com.njcn.rdms.module.project.constant.WorkReportConstants;
import com.njcn.rdms.module.project.framework.notify.NotifySendEvent;
import com.njcn.rdms.module.project.framework.notify.NotifyTemplateCodeConstants;
import com.njcn.rdms.module.project.controller.admin.workreport.common.vo.*;
import com.njcn.rdms.module.project.controller.admin.workreport.monthly.vo.*;
import com.njcn.rdms.module.project.controller.admin.workreport.project.vo.*;
@@ -58,7 +60,9 @@ import com.njcn.rdms.module.system.api.permission.dto.ObjectRoleRespDTO;
import com.njcn.rdms.module.system.api.user.AdminUserApi;
import com.njcn.rdms.module.system.api.user.UserManagementRelationApi;
import com.njcn.rdms.module.system.api.user.dto.AdminUserRespDTO;
import com.njcn.rdms.module.system.enums.notify.NotifyMessageLevelConstants;
import jakarta.annotation.Resource;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
@@ -66,6 +70,7 @@ import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.IsoFields;
import java.util.*;
import java.util.stream.Collectors;
@@ -131,6 +136,8 @@ public class WorkReportCommonService {
private UserObjectRoleMapper userObjectRoleMapper;
@Resource
private TeamDashboardAccessService teamDashboardAccessService;
@Resource
private ApplicationEventPublisher applicationEventPublisher;
public List<WorkReportStatusDictRespVO> getStatusDict() {
return objectStatusModelMapper.selectListByObjectTypeEnabled(WorkReportConstants.STATUS_OBJECT_TYPE).stream()
@@ -282,6 +289,9 @@ public class WorkReportCommonService {
transition.getToStatusCode(), null, buildWeeklyRemark(latest));
writeAuditLog(WorkReportConstants.BIZ_TYPE_WEEKLY, id, actionCode, current.getStatusCode(),
transition.getToStatusCode(), null, buildWeeklyRemark(latest));
publishPersonalReportPendingApprovalNotice(latest.getSupervisorUserId(),
NotifyTemplateCodeConstants.WORK_REPORT_PENDING_APPROVAL_NOTIFY,
"周报", latest.getReporterName(), formatWeeklyPeriodLabelForNotify(latest));
}
@Transactional(rollbackFor = Exception.class)
@@ -451,6 +461,9 @@ public class WorkReportCommonService {
transition.getToStatusCode(), null, buildMonthlyRemark(latest));
writeAuditLog(WorkReportConstants.BIZ_TYPE_MONTHLY, id, actionCode, current.getStatusCode(),
transition.getToStatusCode(), null, buildMonthlyRemark(latest));
publishPersonalReportPendingApprovalNotice(latest.getSupervisorUserId(),
NotifyTemplateCodeConstants.WORK_REPORT_PENDING_APPROVAL_NOTIFY,
"月报", latest.getReporterName(), latest.getPeriodLabel());
}
@Transactional(rollbackFor = Exception.class)
@@ -649,6 +662,7 @@ public class WorkReportCommonService {
transition.getToStatusCode(), null, buildProjectRemark(latest));
writeAuditLog(WorkReportConstants.BIZ_TYPE_PROJECT, id, actionCode, current.getStatusCode(),
transition.getToStatusCode(), null, buildProjectRemark(latest));
publishProjectReportPendingApprovalNotice(latest);
}
@Transactional(rollbackFor = Exception.class)
@@ -879,6 +893,49 @@ public class WorkReportCommonService {
return new ArrayList<>(merged);
}
private void publishPersonalReportPendingApprovalNotice(Long supervisorUserId, String templateCode,
String reportTypeName, String reporterName, String periodLabel) {
if (supervisorUserId == null) {
return;
}
Map<String, Object> params = new LinkedHashMap<>();
params.put("reportTypeName", reportTypeName);
params.put("reporterName", defaultText(reporterName));
params.put("periodLabel", defaultText(periodLabel));
applicationEventPublisher.publishEvent(NotifySendEvent.of(
List.of(supervisorUserId), templateCode, params, NotifyMessageLevelConstants.REMIND));
}
private void publishProjectReportPendingApprovalNotice(ProjectReportDO report) {
if (report == null || report.getSupervisorUserId() == null) {
return;
}
Map<String, Object> params = new LinkedHashMap<>();
params.put("reporterName", defaultText(report.getProjectOwnerName()));
params.put("projectName", defaultText(report.getProjectName()));
params.put("periodLabel", defaultText(report.getPeriodLabel()));
applicationEventPublisher.publishEvent(NotifySendEvent.of(
List.of(report.getSupervisorUserId()),
NotifyTemplateCodeConstants.WORK_REPORT_PROJECT_HALF_MONTH_PENDING_APPROVAL_NOTIFY,
params, NotifyMessageLevelConstants.REMIND));
}
private String formatWeeklyPeriodLabelForNotify(WeeklyReportDO report) {
if (report == null || report.getPeriodStartDate() == null || report.getPeriodEndDate() == null) {
return defaultText(report == null ? null : report.getPeriodLabel());
}
LocalDate startDate = report.getPeriodStartDate();
LocalDate endDate = report.getPeriodEndDate();
int weekBasedYear = startDate.get(IsoFields.WEEK_BASED_YEAR);
int weekOfYear = startDate.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
return weekBasedYear + "" + weekOfYear + "周(" + formatMonthDayRange(startDate, endDate) + "";
}
private String formatMonthDayRange(LocalDate startDate, LocalDate endDate) {
return startDate.getMonthValue() + "" + startDate.getDayOfMonth()
+ "日-" + endDate.getMonthValue() + "" + endDate.getDayOfMonth() + "";
}
private ObjectStatusModelDO getInitialStatusModel() {
ObjectStatusModelDO statusModel = objectStatusModelMapper
.selectInitialByObjectTypeEnabled(WorkReportConstants.STATUS_OBJECT_TYPE);

View File

@@ -0,0 +1,17 @@
package com.njcn.rdms.module.project.service.workreport.remind;
import jakarta.annotation.Resource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class WorkReportPendingSubmitRemindScheduler {
@Resource
private WorkReportPendingSubmitRemindService workReportPendingSubmitRemindService;
@Scheduled(cron = "0 0 20 * * ?", zone = "Asia/Shanghai")
public void remindPendingSubmitReports() {
workReportPendingSubmitRemindService.remindPendingSubmitReports();
}
}

View File

@@ -0,0 +1,125 @@
package com.njcn.rdms.module.project.service.workreport.remind;
import com.njcn.rdms.module.project.constant.WorkReportConstants;
import com.njcn.rdms.module.project.dal.dataobject.workreport.monthly.MonthlyReportDO;
import com.njcn.rdms.module.project.dal.dataobject.workreport.project.ProjectReportDO;
import com.njcn.rdms.module.project.dal.dataobject.workreport.weekly.WeeklyReportDO;
import com.njcn.rdms.module.project.dal.mysql.workreport.monthly.MonthlyReportMapper;
import com.njcn.rdms.module.project.dal.mysql.workreport.project.ProjectReportMapper;
import com.njcn.rdms.module.project.dal.mysql.workreport.weekly.WeeklyReportMapper;
import com.njcn.rdms.module.project.framework.notify.NotifySendEvent;
import com.njcn.rdms.module.project.framework.notify.NotifyTemplateCodeConstants;
import com.njcn.rdms.module.system.enums.notify.NotifyMessageLevelConstants;
import jakarta.annotation.Resource;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.IsoFields;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class WorkReportPendingSubmitRemindService {
private static final List<String> REMIND_STATUS_CODES = List.of(
WorkReportConstants.STATUS_DRAFT,
WorkReportConstants.STATUS_REJECTED);
@Resource
private WeeklyReportMapper weeklyReportMapper;
@Resource
private MonthlyReportMapper monthlyReportMapper;
@Resource
private ProjectReportMapper projectReportMapper;
@Resource
private ApplicationEventPublisher applicationEventPublisher;
@Transactional(rollbackFor = Exception.class)
public void remindPendingSubmitReports() {
LocalDateTime cutoffTime = LocalDateTime.now().minusDays(2);
remindWeekly(cutoffTime);
remindMonthly(cutoffTime);
remindProject(cutoffTime);
}
private void remindWeekly(LocalDateTime cutoffTime) {
List<WeeklyReportDO> reports = weeklyReportMapper.selectListByPendingSubmitReminder(cutoffTime, REMIND_STATUS_CODES);
for (WeeklyReportDO report : reports) {
if (report == null || report.getReporterId() == null) {
continue;
}
Map<String, Object> params = new HashMap<>();
params.put("reportTypeName", "周报");
params.put("periodKey", formatWeeklyPeriod(report.getPeriodKey(), report.getPeriodStartDate(), report.getPeriodEndDate()));
params.put("managerName", defaultText(report.getSupervisorName(), "系统通知"));
applicationEventPublisher.publishEvent(NotifySendEvent.of(
List.of(report.getReporterId()),
NotifyTemplateCodeConstants.WORK_REPORT_TEAM_REMIND,
params,
NotifyMessageLevelConstants.REMIND));
}
}
private void remindMonthly(LocalDateTime cutoffTime) {
List<MonthlyReportDO> reports = monthlyReportMapper.selectListByPendingSubmitReminder(cutoffTime, REMIND_STATUS_CODES);
for (MonthlyReportDO report : reports) {
if (report == null || report.getReporterId() == null) {
continue;
}
Map<String, Object> params = new HashMap<>();
params.put("reportTypeName", "月报");
params.put("periodKey", formatMonthlyPeriod(report.getPeriodKey(), report.getPeriodStartDate()));
params.put("managerName", defaultText(report.getSupervisorName(), "系统通知"));
applicationEventPublisher.publishEvent(NotifySendEvent.of(
List.of(report.getReporterId()),
NotifyTemplateCodeConstants.WORK_REPORT_TEAM_REMIND,
params,
NotifyMessageLevelConstants.REMIND));
}
}
private void remindProject(LocalDateTime cutoffTime) {
List<ProjectReportDO> reports = projectReportMapper.selectListByPendingSubmitReminder(cutoffTime, REMIND_STATUS_CODES);
for (ProjectReportDO report : reports) {
if (report == null || report.getProjectOwnerId() == null) {
continue;
}
Map<String, Object> params = new HashMap<>();
params.put("projectName", defaultText(report.getProjectName(), ""));
params.put("periodLabel", defaultText(report.getPeriodLabel(), report.getPeriodKey()));
params.put("managerName", defaultText(report.getSupervisorName(), "系统通知"));
applicationEventPublisher.publishEvent(NotifySendEvent.of(
List.of(report.getProjectOwnerId()),
NotifyTemplateCodeConstants.WORK_REPORT_PROJECT_HALF_MONTH_TEAM_REMIND,
params,
NotifyMessageLevelConstants.REMIND));
}
}
private String formatWeeklyPeriod(String periodKey, LocalDate startDate, LocalDate endDate) {
if (startDate == null || endDate == null) {
return defaultText(periodKey, "");
}
int weekBasedYear = startDate.get(IsoFields.WEEK_BASED_YEAR);
int weekOfYear = startDate.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
return weekBasedYear + "" + weekOfYear + "周("
+ startDate.getMonthValue() + "" + startDate.getDayOfMonth() + "日-"
+ endDate.getMonthValue() + "" + endDate.getDayOfMonth() + "日)";
}
private String formatMonthlyPeriod(String periodKey, LocalDate startDate) {
if (startDate == null) {
return defaultText(periodKey, "");
}
return startDate.getYear() + "" + startDate.getMonthValue() + "";
}
private String defaultText(String text, String fallback) {
return StringUtils.hasText(text) ? text.trim() : fallback;
}
}

View File

@@ -31,7 +31,7 @@ import org.springframework.util.StringUtils;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoField;
import java.time.temporal.IsoFields;
import java.time.temporal.TemporalAdjusters;
import java.util.ArrayList;
import java.util.Collection;
@@ -576,8 +576,9 @@ public class TeamWorkReportServiceImpl implements TeamWorkReportService {
}
LocalDate startDate = parsePeriodDate(parts, 1);
LocalDate endDate = parsePeriodDate(parts, 4);
int weekOfYear = startDate.get(ChronoField.ALIGNED_WEEK_OF_YEAR);
return startDate.getYear() + "" + weekOfYear + "周(" + formatMonthDayRange(startDate, endDate) + "";
int weekBasedYear = startDate.get(IsoFields.WEEK_BASED_YEAR);
int weekOfYear = startDate.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
return weekBasedYear + "" + weekOfYear + "周(" + formatMonthDayRange(startDate, endDate) + "";
}
private String formatMonthlyPeriodKey(String periodKey) {