feat: 添加项目进度统计功能,支持在列表中显示各项目的进度步骤统计信息,以及跳转

This commit is contained in:
2026-04-23 12:47:23 +08:00
parent 335dc88a2a
commit db90e2a084
12 changed files with 480 additions and 18 deletions

View File

@@ -207,6 +207,11 @@ public class SysOaProjectBo extends BaseEntity {
*/
private String keyword;
/**
* 为 true 时在列表结果中附带各项目进度步骤统计(综合看板等,不参与 SQL 条件)
*/
private Boolean scheduleStats;
//是否置顶
private Integer isTop;

View File

@@ -0,0 +1,18 @@
package com.ruoyi.oa.domain.dto;
import lombok.Data;
/**
* 项目维度进度步骤汇总(综合看板左侧列表等)
*/
@Data
public class ProjectScheduleStepStatsDto {
private Long projectId;
private Long totalNodes;
private Long completedNodes;
private Long pendingAcceptNodes;
}

View File

@@ -5,6 +5,7 @@ import java.util.Date;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.ruoyi.common.annotation.ExcelDictFormat;
@@ -284,4 +285,14 @@ public class SysOaProjectVo {
private Long processCardCount;
private Long deliveryOrderCount;
/** 进度步骤总数(列表请求 scheduleStats=true 时由后端填充) */
@ExcelIgnore
private Long scheduleStepTotal;
@ExcelIgnore
private Long scheduleStepCompleted;
@ExcelIgnore
private Long scheduleStepPendingAccept;
}

View File

@@ -3,6 +3,7 @@ package com.ruoyi.oa.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.oa.domain.OaProjectScheduleStep;
import com.ruoyi.oa.domain.dto.ProjectScheduleStepStatsDto;
import com.ruoyi.oa.domain.vo.OaProjectScheduleStepVo;
import com.ruoyi.common.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Param;
@@ -44,4 +45,9 @@ public interface OaProjectScheduleStepMapper extends BaseMapperPlus<OaProjectSch
int deleteByScheduleIds(@Param("scheduleIds") Collection<Long> scheduleIds);
Page<OaProjectScheduleStepVo> selectVoPageNew(Page<Object> build,@Param(Constants.WRAPPER) QueryWrapper<OaProjectScheduleStep> lqw);
/**
* 按项目汇总进度步骤:总数、已完成(2)、待验收(1)
*/
List<ProjectScheduleStepStatsDto> selectStepStatsGroupByProjectId(@Param("projectIds") Collection<Long> projectIds);
}

View File

@@ -16,6 +16,7 @@ import com.ruoyi.oa.domain.bo.OaProjectScheduleBo;
import com.ruoyi.oa.domain.bo.SysOaWarehouseDetailBo;
import com.ruoyi.oa.domain.dto.ProjectActivityDTO;
import com.ruoyi.oa.domain.dto.ProjectDataDTO;
import com.ruoyi.oa.domain.dto.ProjectScheduleStepStatsDto;
import com.ruoyi.oa.domain.vo.*;
import com.ruoyi.oa.service.CodeGeneratorService;
import com.ruoyi.oa.service.IExchangeRateService;
@@ -27,12 +28,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.oa.domain.bo.SysOaProjectBo;
import com.ruoyi.oa.domain.SysOaProject;
import com.ruoyi.oa.mapper.OaProjectScheduleStepMapper;
import com.ruoyi.oa.mapper.SysOaProjectMapper;
import com.ruoyi.oa.service.ISysOaProjectService;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -53,6 +56,8 @@ public class SysOaProjectServiceImpl implements ISysOaProjectService {
private final IOaProjectScheduleStepService oaProjectScheduleStepService;
private final OaProjectScheduleStepMapper oaProjectScheduleStepMapper;
@Autowired
private CodeGeneratorService codeGeneratorService;
@Autowired
@@ -191,7 +196,32 @@ public class SysOaProjectServiceImpl implements ISysOaProjectService {
vo.setFundsRmb(vo.getFunds());
}
}
if (Boolean.TRUE.equals(bo.getScheduleStats()) && result.getRecords() != null && !result.getRecords().isEmpty()) {
List<Long> projectIds = result.getRecords().stream()
.map(SysOaProjectVo::getProjectId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
if (!projectIds.isEmpty()) {
List<ProjectScheduleStepStatsDto> statRows = oaProjectScheduleStepMapper.selectStepStatsGroupByProjectId(projectIds);
Map<Long, ProjectScheduleStepStatsDto> statMap = statRows.stream()
.collect(Collectors.toMap(ProjectScheduleStepStatsDto::getProjectId, Function.identity(), (a, b) -> a));
for (SysOaProjectVo vo : result.getRecords()) {
ProjectScheduleStepStatsDto s = statMap.get(vo.getProjectId());
if (s != null) {
vo.setScheduleStepTotal(s.getTotalNodes());
vo.setScheduleStepCompleted(s.getCompletedNodes());
vo.setScheduleStepPendingAccept(s.getPendingAcceptNodes());
} else {
vo.setScheduleStepTotal(0L);
vo.setScheduleStepCompleted(0L);
vo.setScheduleStepPendingAccept(0L);
}
}
}
}
return TableDataInfo.build(result);
}
private QueryWrapper<SysOaProject> buildAliasPQueryWrapper(SysOaProjectBo bo) {

View File

@@ -282,5 +282,22 @@
WHERE schedule_id = #{scheduleId}
</select>
<select id="selectStepStatsGroupByProjectId"
resultType="com.ruoyi.oa.domain.dto.ProjectScheduleStepStatsDto">
SELECT
sch.project_id AS projectId,
COUNT(step.track_id) AS totalNodes,
IFNULL(SUM(CASE WHEN step.status = 2 THEN 1 ELSE 0 END), 0) AS completedNodes,
IFNULL(SUM(CASE WHEN step.status = 1 THEN 1 ELSE 0 END), 0) AS pendingAcceptNodes
FROM oa_project_schedule sch
INNER JOIN oa_project_schedule_step step ON step.schedule_id = sch.schedule_id
WHERE sch.del_flag = '0'
AND step.del_flag = '0'
AND sch.project_id IN
<foreach collection="projectIds" item="pid" open="(" separator="," close=")">
#{pid}
</foreach>
GROUP BY sch.project_id
</select>
</mapper>