进度控制开发,任务模式bug修正

This commit is contained in:
2025-04-17 16:46:47 +08:00
parent a67cac2ebe
commit e159c3acc0
30 changed files with 1537 additions and 26 deletions

View File

@@ -292,6 +292,7 @@
p.color,
TIMESTAMPDIFF(DAY, NOW(), p.postpone_time) AS remainTime
FROM sys_oa_project p
${ew.getCustomSqlSegment}
</select>
@@ -380,4 +381,102 @@
</select>
<!-- 项目与进度关联的结果映射 -->
<resultMap type="com.ruoyi.oa.domain.vo.SysOaProjectVo" id="ProjectProgressResult">
<id property="projectId" column="project_id"/>
<result property="projectName" column="project_name"/>
<result property="projectNum" column="project_num"/>
<result property="projectType" column="project_type"/>
<result property="remainTime" column="remainTime"/>
<!-- 根据项目 ID 查询顶级进度parent_id 为 0 或 NULL -->
<collection property="progressList"
ofType="com.ruoyi.oa.domain.vo.OaProgressVo"
select="selectProgressByProjectId"
column="project_id"/>
</resultMap>
<!-- 进度项的结果映射 -->
<resultMap type="com.ruoyi.oa.domain.vo.OaProgressVo" id="OaProgressResult">
<id property="progressId" column="progress_id"/>
<result property="projectId" column="project_id"/>
<result property="type" column="type"/>
<result property="progressName" column="progress_name"/>
<result property="parentId" column="parent_id"/>
<result property="sort" column="sort"/>
<result property="remark" column="remark"/>
<result property="status" column="status"/>
<!-- 新增字段映射 -->
<result property="progressSize" column="progress_size"/>
<result property="finishCount" column="finish_count"/>
<result property="completionPercent" column="completionPercent"/>
<!-- 嵌套查询孩子节点(如果需要展示孩子节点明细,可保留) -->
<collection property="children"
ofType="com.ruoyi.oa.domain.vo.OaProgressVo"
select="selectChildProgress"
column="progress_id"/>
</resultMap>
<!-- 根据项目 ID 查询顶级进度 -->
<select id="selectProgressByProjectId" resultMap="OaProgressResult">
SELECT
p.progress_id,
p.project_id,
p.type,
p.progress_name,
p.parent_id,
p.sort,
p.remark,
p.status,
-- 孩子节点总数:如果没有匹配则返回 0
IFNULL(child.totalCount, 0) AS progress_size,
-- 孩子节点中 status 为1的数量
IFNULL(child.finishedCount, 0) AS finish_count,
-- 计算完成比例避免除以0的情况
CASE WHEN child.totalCount > 0
THEN ROUND(child.finishedCount / child.totalCount, 2) *100
ELSE 0
END AS completionPercent
FROM oa_progress p
LEFT JOIN (
SELECT
parent_id,
COUNT(*) AS totalCount,
SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) AS finishedCount
FROM oa_progress
GROUP BY parent_id
) child ON p.progress_id = child.parent_id
WHERE p.project_id = #{projectId}
AND p.parent_id = 0
</select>
<!-- 根据进度 ID 查询子进度 -->
<select id="selectChildProgress" resultMap="OaProgressResult">
SELECT
progress_id,
project_id,
type,
progress_name,
parent_id,
sort,
remark,
status
FROM oa_progress
WHERE parent_id = #{progressId}
</select>
<!-- 主项目查询,同时获取项目的一些计算字段 -->
<select id="selectVoAndProgress" resultMap="ProjectProgressResult">
SELECT
p.project_id,
p.project_name,
p.project_num,
p.project_type,
p.funds,
TIMESTAMPDIFF(DAY, NOW(), p.postpone_time) AS remainTime
FROM sys_oa_project p
${ew.getCustomSqlSegment}
</select>
</mapper>