3 Commits

Author SHA1 Message Date
dk
7f832d819e feat(workreport): 添加工作报告待提交提醒功能
- 新增 selectListByPendingSubmitReminder 方法用于查询待提交的工作报告
- 添加通知模板常量用于待审批通知功能
- 替换 ChronoField 为 IsoFields 以正确处理基于周的年份计算
- 实现个人工作报告待直属上级审批的通知发布逻辑
- 实现项目报告待审批通知的发布功能
- 创建 WorkReportPendingSubmitRemindScheduler 定时任务类
- 实现 WorkReportPendingSubmitRemindService 服务类处理提醒逻辑
- 添加定时任务每晚 8 点检查并提醒逾期未提交的报告
- 支持周报、月报和项目报告三种类型的待提交提醒
- 实现基于截止时间过滤并按创建时间排序的查询逻辑
2026-07-02 16:33:33 +08:00
dk
0bd04867b3 Merge remote-tracking branch 'origin/main' 2026-07-01 17:07:09 +08:00
dk
77b660cc34 fix(工作报告、我的绩效、加班申请、日志管理): 优化报表导出逻辑并补充日志用户昵称,团队模式查询现正确包含当前用户数据。 2026-07-01 17:06:44 +08:00
19 changed files with 398 additions and 50 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

@@ -42,12 +42,13 @@ import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Collection;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -229,8 +230,22 @@ public class OvertimeApplicationServiceImpl implements OvertimeApplicationServic
@Override
public List<OvertimeApplicationExportVO> getExportList(OvertimeApplicationPageReqVO reqVO) {
reqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
PageResult<OvertimeApplicationRespVO> page = getMyPage(reqVO);
return BeanUtils.toBean(page.getList(), OvertimeApplicationExportVO.class);
PageResult<OvertimeApplicationDO> page;
if (reqVO.getApplicantIds() != null) {
List<Long> applicantIds = teamDashboardAccessService.resolveRequestedSubordinateUserIds(
reqVO.getApplicantIds(), OvertimeApplicationConstants.PERMISSION_TEAM_DASHBOARD);
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
if (loginUserId != null) {
LinkedHashSet<Long> mergedIds = new LinkedHashSet<>(applicantIds);
mergedIds.add(loginUserId);
applicantIds = new ArrayList<>(mergedIds);
}
page = overtimeApplicationMapper.selectMyPage(applicantIds, reqVO, TEAM_VISIBLE_STATUS_CODES);
} else {
page = overtimeApplicationMapper.selectMyPage(SecurityFrameworkUtils.getLoginUserId(), reqVO);
}
return BeanUtils.toBean(BeanUtils.toBean(page, OvertimeApplicationRespVO.class, this::applyStatusView).getList(),
OvertimeApplicationExportVO.class);
}
private void processApprovalAction(Long id, String actionCode, OvertimeApplicationStatusActionReqVO reqVO) {

View File

@@ -265,6 +265,12 @@ public class PerformanceSheetServiceImpl implements PerformanceSheetService {
if (reqVO.getEmployeeIds() != null) {
employeeIds = teamDashboardAccessService.resolveRequestedSubordinateUserIds(
reqVO.getEmployeeIds(), PerformanceConstants.PERMISSION_TEAM_DASHBOARD);
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
if (loginUserId != null) {
LinkedHashSet<Long> mergedIds = new LinkedHashSet<>(employeeIds);
mergedIds.add(loginUserId);
employeeIds = new ArrayList<>(mergedIds);
}
} else {
employeeIds = List.of(Objects.requireNonNull(SecurityFrameworkUtils.getLoginUserId()));
}

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()
@@ -181,19 +188,6 @@ public class WorkReportCommonService {
return createWeeklyReportInternal(reqVO, overrideReporterId);
}
public WeeklyReportRespVO mergeWeeklyDraft(WeeklyReportRespVO latestDraft, WeeklyReportRefreshDraftReqVO reqVO) {
WeeklyReportRespVO respVO = latestDraft;
respVO.setIsBusinessTrip(Boolean.TRUE.equals(reqVO.getIsBusinessTrip()));
respVO.setTravelSegments(BeanUtils.toBean(defaultList(reqVO.getTravelSegments()), WeeklyReportTravelSegmentRespVO.class));
respVO.setReviewItems(mergeWeeklyReviewItems(reqVO.getReviewItems(), latestDraft.getReviewItems()));
respVO.setPlanItems(mergePlanItems(reqVO.getPlanItems(), latestDraft.getPlanItems()));
respVO.setTotalTravelDays(Boolean.TRUE.equals(reqVO.getIsBusinessTrip())
? defaultIfNull(sumTravelDays(reqVO.getTravelSegments()))
: BigDecimal.ZERO);
respVO.setTotalWorkHours(sumReviewWorkHoursResp(respVO.getReviewItems()));
return respVO;
}
private Long createWeeklyReportInternal(WeeklyReportSaveReqVO reqVO, Long overrideReporterId) {
validatePeriod(reqVO.getPeriodStartDate(), reqVO.getPeriodEndDate());
CurrentUserProfile profile = resolveProfile(overrideReporterId, true);
@@ -239,11 +233,23 @@ public class WorkReportCommonService {
}
public PageResult<WeeklyReportRespVO> getWeeklyReportPage(WeeklyReportPageReqVO reqVO) {
return getWeeklyReportPage(reqVO, false);
}
public PageResult<WeeklyReportRespVO> getWeeklyReportExportPage(WeeklyReportPageReqVO reqVO) {
return getWeeklyReportPage(reqVO, true);
}
private PageResult<WeeklyReportRespVO> getWeeklyReportPage(WeeklyReportPageReqVO reqVO,
boolean includeSelfInTeamMode) {
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
PageResult<WeeklyReportDO> pageResult;
if (reqVO.getReporterIds() != null) {
List<Long> reporterIds = teamDashboardAccessService.resolveRequestedSubordinateUserIds(
reqVO.getReporterIds(), WorkReportConstants.PERMISSION_TEAM_DASHBOARD);
if (includeSelfInTeamMode) {
reporterIds = appendLoginUser(reporterIds);
}
pageResult = weeklyReportMapper.selectReporterPage(reporterIds, reqVO, TEAM_VISIBLE_STATUS_CODES);
} else {
pageResult = weeklyReportMapper.selectReporterPage(loginUserId, reqVO, getEnabledStatusCodes());
@@ -283,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)
@@ -351,14 +360,6 @@ public class WorkReportCommonService {
return createMonthlyReportInternal(reqVO, overrideReporterId);
}
public MonthlyReportRespVO mergeMonthlyDraft(MonthlyReportRespVO latestDraft, MonthlyReportRefreshDraftReqVO reqVO) {
MonthlyReportRespVO respVO = latestDraft;
respVO.setReviewItems(mergeReviewItems(reqVO.getReviewItems(), latestDraft.getReviewItems()));
respVO.setPlanItems(mergePlanItems(reqVO.getPlanItems(), latestDraft.getPlanItems()));
respVO.setTotalWorkHours(sumReviewWorkHoursResp(respVO.getReviewItems()));
return respVO;
}
private Long createMonthlyReportInternal(MonthlyReportSaveReqVO reqVO, Long overrideReporterId) {
validatePeriod(reqVO.getPeriodStartDate(), reqVO.getPeriodEndDate());
CurrentUserProfile profile = resolveProfile(overrideReporterId, true);
@@ -404,11 +405,23 @@ public class WorkReportCommonService {
}
public PageResult<MonthlyReportRespVO> getMonthlyReportPage(MonthlyReportPageReqVO reqVO) {
return getMonthlyReportPage(reqVO, false);
}
public PageResult<MonthlyReportRespVO> getMonthlyReportExportPage(MonthlyReportPageReqVO reqVO) {
return getMonthlyReportPage(reqVO, true);
}
private PageResult<MonthlyReportRespVO> getMonthlyReportPage(MonthlyReportPageReqVO reqVO,
boolean includeSelfInTeamMode) {
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
PageResult<MonthlyReportDO> pageResult;
if (reqVO.getReporterIds() != null) {
List<Long> reporterIds = teamDashboardAccessService.resolveRequestedSubordinateUserIds(
reqVO.getReporterIds(), WorkReportConstants.PERMISSION_TEAM_DASHBOARD);
if (includeSelfInTeamMode) {
reporterIds = appendLoginUser(reporterIds);
}
pageResult = monthlyReportMapper.selectReporterPage(reporterIds, reqVO, TEAM_VISIBLE_STATUS_CODES);
} else {
pageResult = monthlyReportMapper.selectReporterPage(loginUserId, reqVO, getEnabledStatusCodes());
@@ -448,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)
@@ -588,11 +604,23 @@ public class WorkReportCommonService {
}
public PageResult<ProjectReportRespVO> getProjectReportPage(ProjectReportPageReqVO reqVO) {
return getProjectReportPage(reqVO, false);
}
public PageResult<ProjectReportRespVO> getProjectReportExportPage(ProjectReportPageReqVO reqVO) {
return getProjectReportPage(reqVO, true);
}
private PageResult<ProjectReportRespVO> getProjectReportPage(ProjectReportPageReqVO reqVO,
boolean includeSelfInTeamMode) {
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
PageResult<ProjectReportDO> pageResult;
if (reqVO.getProjectOwnerIds() != null) {
List<Long> projectOwnerIds = teamDashboardAccessService.resolveRequestedSubordinateUserIds(
reqVO.getProjectOwnerIds(), WorkReportConstants.PERMISSION_TEAM_DASHBOARD);
if (includeSelfInTeamMode) {
projectOwnerIds = appendLoginUser(projectOwnerIds);
}
pageResult = projectReportMapper.selectReporterPage(projectOwnerIds, reqVO, TEAM_VISIBLE_STATUS_CODES);
} else {
pageResult = projectReportMapper.selectReporterPage(loginUserId, reqVO, getEnabledStatusCodes());
@@ -634,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)
@@ -854,6 +883,59 @@ public class WorkReportCommonService {
.collect(Collectors.toList());
}
private List<Long> appendLoginUser(List<Long> userIds) {
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
if (loginUserId == null) {
return userIds;
}
LinkedHashSet<Long> merged = new LinkedHashSet<>(userIds);
merged.add(loginUserId);
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

@@ -91,7 +91,7 @@ public class WorkReportContentExportService {
if (Boolean.TRUE.equals(reqVO.getExportAll())) {
reqVO.setPageNo(1);
reqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
return workReportCommonService.getWeeklyReportPage(reqVO).getList().stream()
return workReportCommonService.getWeeklyReportExportPage(reqVO).getList().stream()
.map(item -> workReportCommonService.getWeeklyReport(item.getId()))
.toList();
}
@@ -104,7 +104,7 @@ public class WorkReportContentExportService {
if (Boolean.TRUE.equals(reqVO.getExportAll())) {
reqVO.setPageNo(1);
reqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
return workReportCommonService.getMonthlyReportPage(reqVO).getList().stream()
return workReportCommonService.getMonthlyReportExportPage(reqVO).getList().stream()
.map(item -> workReportCommonService.getMonthlyReport(item.getId()))
.toList();
}
@@ -117,7 +117,7 @@ public class WorkReportContentExportService {
if (Boolean.TRUE.equals(reqVO.getExportAll())) {
reqVO.setPageNo(1);
reqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
return workReportCommonService.getProjectReportPage(reqVO).getList().stream()
return workReportCommonService.getProjectReportExportPage(reqVO).getList().stream()
.map(item -> workReportCommonService.getProjectReport(item.getId()))
.toList();
}

View File

@@ -43,8 +43,7 @@ public class MonthlyReportServiceImpl implements MonthlyReportService {
draftReqVO.setPeriodLabel(reqVO.getPeriodLabel());
draftReqVO.setPeriodStartDate(reqVO.getPeriodStartDate());
draftReqVO.setPeriodEndDate(reqVO.getPeriodEndDate());
MonthlyReportRespVO latestDraft = workReportDefaultDraftService.previewMonthlyDefaultDraft(draftReqVO);
return workReportCommonService.mergeMonthlyDraft(latestDraft, reqVO);
return workReportDefaultDraftService.previewMonthlyDefaultDraft(draftReqVO);
}
@Override

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) {

View File

@@ -42,8 +42,7 @@ public class WeeklyReportServiceImpl implements WeeklyReportService {
draftReqVO.setPeriodLabel(reqVO.getPeriodLabel());
draftReqVO.setPeriodStartDate(reqVO.getPeriodStartDate());
draftReqVO.setPeriodEndDate(reqVO.getPeriodEndDate());
WeeklyReportRespVO latestDraft = workReportDefaultDraftService.previewWeeklyDefaultDraft(draftReqVO);
return workReportCommonService.mergeWeeklyDraft(latestDraft, reqVO);
return workReportDefaultDraftService.previewWeeklyDefaultDraft(draftReqVO);
}
@Override

View File

@@ -4,12 +4,15 @@ import com.njcn.rdms.framework.apilog.core.annotation.ApiAccessLog;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.framework.common.pojo.PageParam;
import com.njcn.rdms.framework.common.pojo.PageResult;
import com.njcn.rdms.framework.common.util.collection.CollectionUtils;
import com.njcn.rdms.framework.common.util.object.BeanUtils;
import com.njcn.rdms.framework.excel.core.util.ExcelUtils;
import com.njcn.rdms.module.system.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
import com.njcn.rdms.module.system.controller.admin.logger.vo.apiaccesslog.ApiAccessLogRespVO;
import com.njcn.rdms.module.system.dal.dataobject.logger.ApiAccessLogDO;
import com.njcn.rdms.module.system.dal.dataobject.user.AdminUserDO;
import com.njcn.rdms.module.system.service.logger.ApiAccessLogService;
import com.njcn.rdms.module.system.service.user.AdminUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -24,7 +27,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static com.njcn.rdms.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@@ -37,14 +42,17 @@ public class ApiAccessLogController {
@Resource
private ApiAccessLogService apiAccessLogService;
@Resource
private AdminUserService adminUserService;
@GetMapping("/get")
@Operation(summary = "获得 API 访问日志")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:api-access-log:query')")
public CommonResult<ApiAccessLogRespVO> getApiAccessLog(@RequestParam("id") Long id) {
ApiAccessLogDO apiAccessLog = apiAccessLogService.getApiAccessLog(id);
return success(BeanUtils.toBean(apiAccessLog, ApiAccessLogRespVO.class));
ApiAccessLogRespVO respVO = BeanUtils.toBean(apiAccessLogService.getApiAccessLog(id), ApiAccessLogRespVO.class);
fillUserNicknames(Collections.singletonList(respVO));
return success(respVO);
}
@GetMapping("/page")
@@ -52,7 +60,9 @@ public class ApiAccessLogController {
@PreAuthorize("@ss.hasPermission('system:api-access-log:query')")
public CommonResult<PageResult<ApiAccessLogRespVO>> getApiAccessLogPage(@Valid ApiAccessLogPageReqVO pageReqVO) {
PageResult<ApiAccessLogDO> pageResult = apiAccessLogService.getApiAccessLogPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ApiAccessLogRespVO.class));
PageResult<ApiAccessLogRespVO> respPageResult = BeanUtils.toBean(pageResult, ApiAccessLogRespVO.class);
fillUserNicknames(respPageResult.getList());
return success(respPageResult);
}
@GetMapping("/export-excel")
@@ -62,10 +72,26 @@ public class ApiAccessLogController {
public void exportApiAccessLogExcel(@Valid ApiAccessLogPageReqVO exportReqVO,
HttpServletResponse response) throws IOException {
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ApiAccessLogDO> list = apiAccessLogService.getApiAccessLogPage(exportReqVO).getList();
List<ApiAccessLogRespVO> respVOList = BeanUtils.toBean(
apiAccessLogService.getApiAccessLogPage(exportReqVO).getList(), ApiAccessLogRespVO.class);
fillUserNicknames(respVOList);
// 导出 Excel
ExcelUtils.write(response, "API 访问日志.xls", "数据", ApiAccessLogRespVO.class,
BeanUtils.toBean(list, ApiAccessLogRespVO.class));
respVOList);
}
private void fillUserNicknames(List<ApiAccessLogRespVO> respVOList) {
if (respVOList == null || respVOList.isEmpty()) {
return;
}
Map<Long, AdminUserDO> userMap = adminUserService.getUserMap(
CollectionUtils.convertSet(respVOList, ApiAccessLogRespVO::getUserId));
respVOList.forEach(respVO -> {
AdminUserDO user = userMap.get(respVO.getUserId());
if (user != null) {
respVO.setUserNickname(user.getNickname());
}
});
}
}

View File

@@ -4,12 +4,15 @@ import com.njcn.rdms.framework.apilog.core.annotation.ApiAccessLog;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.framework.common.pojo.PageParam;
import com.njcn.rdms.framework.common.pojo.PageResult;
import com.njcn.rdms.framework.common.util.collection.CollectionUtils;
import com.njcn.rdms.framework.common.util.object.BeanUtils;
import com.njcn.rdms.framework.excel.core.util.ExcelUtils;
import com.njcn.rdms.module.system.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
import com.njcn.rdms.module.system.controller.admin.logger.vo.apierrorlog.ApiErrorLogRespVO;
import com.njcn.rdms.module.system.dal.dataobject.logger.ApiErrorLogDO;
import com.njcn.rdms.module.system.service.logger.ApiErrorLogService;
import com.njcn.rdms.module.system.dal.dataobject.user.AdminUserDO;
import com.njcn.rdms.module.system.service.user.AdminUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
@@ -22,7 +25,9 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static com.njcn.rdms.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@@ -36,6 +41,8 @@ public class ApiErrorLogController {
@Resource
private ApiErrorLogService apiErrorLogService;
@Resource
private AdminUserService adminUserService;
@PutMapping("/update-status")
@Operation(summary = "更新 API 错误日志的状态")
@@ -55,8 +62,9 @@ public class ApiErrorLogController {
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:api-error-log:query')")
public CommonResult<ApiErrorLogRespVO> getApiErrorLog(@RequestParam("id") Long id) {
ApiErrorLogDO apiErrorLog = apiErrorLogService.getApiErrorLog(id);
return success(BeanUtils.toBean(apiErrorLog, ApiErrorLogRespVO.class));
ApiErrorLogRespVO respVO = BeanUtils.toBean(apiErrorLogService.getApiErrorLog(id), ApiErrorLogRespVO.class);
fillUserNicknames(Collections.singletonList(respVO));
return success(respVO);
}
@GetMapping("/page")
@@ -64,7 +72,9 @@ public class ApiErrorLogController {
@PreAuthorize("@ss.hasPermission('system:api-error-log:query')")
public CommonResult<PageResult<ApiErrorLogRespVO>> getApiErrorLogPage(@Valid ApiErrorLogPageReqVO pageReqVO) {
PageResult<ApiErrorLogDO> pageResult = apiErrorLogService.getApiErrorLogPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ApiErrorLogRespVO.class));
PageResult<ApiErrorLogRespVO> respPageResult = BeanUtils.toBean(pageResult, ApiErrorLogRespVO.class);
fillUserNicknames(respPageResult.getList());
return success(respPageResult);
}
@GetMapping("/export-excel")
@@ -74,10 +84,26 @@ public class ApiErrorLogController {
public void exportApiErrorLogExcel(@Valid ApiErrorLogPageReqVO exportReqVO,
HttpServletResponse response) throws IOException {
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ApiErrorLogDO> list = apiErrorLogService.getApiErrorLogPage(exportReqVO).getList();
List<ApiErrorLogRespVO> respVOList = BeanUtils.toBean(
apiErrorLogService.getApiErrorLogPage(exportReqVO).getList(), ApiErrorLogRespVO.class);
fillUserNicknames(respVOList);
// 导出 Excel
ExcelUtils.write(response, "API 错误日志.xls", "数据", ApiErrorLogRespVO.class,
BeanUtils.toBean(list, ApiErrorLogRespVO.class));
respVOList);
}
private void fillUserNicknames(List<ApiErrorLogRespVO> respVOList) {
if (respVOList == null || respVOList.isEmpty()) {
return;
}
Map<Long, AdminUserDO> userMap = adminUserService.getUserMap(
CollectionUtils.convertSet(respVOList, ApiErrorLogRespVO::getUserId));
respVOList.forEach(respVO -> {
AdminUserDO user = userMap.get(respVO.getUserId());
if (user != null) {
respVO.setUserNickname(user.getNickname());
}
});
}
}

View File

@@ -16,7 +16,7 @@ import java.time.LocalDateTime;
public class ApiAccessLogRespVO {
@Schema(description = "日志主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@ExcelProperty("日志主键")
//@ExcelProperty("日志主键")
private Long id;
@Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "66600cb6-7852-11eb-9439-0242ac130002")
@@ -24,9 +24,13 @@ public class ApiAccessLogRespVO {
private String traceId;
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
@ExcelProperty("用户编号")
//@ExcelProperty("用户编号")
private Long userId;
@Schema(description = "用户姓名", example = "灿能管理员")
@ExcelProperty("用户姓名")
private String userNickname;
@Schema(description = "用户类型,参见 UserTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
@DictFormat(DictTypeConstants.USER_TYPE)

View File

@@ -16,7 +16,7 @@ import java.time.LocalDateTime;
public class ApiErrorLogRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@ExcelProperty("编号")
//@ExcelProperty("编号")
private Long id;
@Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "66600cb6-7852-11eb-9439-0242ac130002")
@@ -24,9 +24,13 @@ public class ApiErrorLogRespVO {
private String traceId;
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
@ExcelProperty("用户编号")
//@ExcelProperty("用户编号")
private Long userId;
@Schema(description = "用户姓名", example = "灿能管理员")
@ExcelProperty("用户姓名")
private String userNickname;
@Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
@DictFormat(DictTypeConstants.USER_TYPE)

View File

@@ -16,7 +16,7 @@ import java.time.LocalDateTime;
public class LoginLogRespVO {
@Schema(description = "日志编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@ExcelProperty("日志主键")
//@ExcelProperty("日志主键")
private Long id;
@Schema(description = "日志类型,参见 LoginLogTypeEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")

View File

@@ -17,7 +17,7 @@ import java.time.LocalDateTime;
public class OperateLogRespVO implements VO {
@Schema(description = "日志编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@ExcelProperty("日志编号")
//@ExcelProperty("日志编号")
private Long id;
@Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "89aca178-a370-411c-ae02-3f0d672be4ab")