From 98c393ed2e298512ec4c83929ea9f8ebd4817216 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 21 Jan 2026 20:45:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=80=E7=BA=A7=E9=9C=80=E6=B1=82?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E6=8E=92=E5=90=8D=E8=A1=A8=E6=A0=BC=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=80=E7=BA=A7=E9=83=A8=E9=97=A8=E5=92=8C=E4=BA=8C?= =?UTF-8?q?=E7=BA=A7=E9=83=A8=E9=97=A8=E5=90=8D=E7=A7=B0=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designhub/service/AnalyticsService.java | 25 ++++++++++++++++++- .../designhub/vo/PrimaryDeptRankingVO.java | 18 ++++++++++++- frontend/src/views/Analytics.vue | 2 ++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/com/designhub/service/AnalyticsService.java b/backend/src/main/java/com/designhub/service/AnalyticsService.java index d599f65..9a8ebac 100644 --- a/backend/src/main/java/com/designhub/service/AnalyticsService.java +++ b/backend/src/main/java/com/designhub/service/AnalyticsService.java @@ -2479,10 +2479,33 @@ public class AnalyticsService { PrimaryDeptRankingVO vo = new PrimaryDeptRankingVO(); vo.setDeptId(deptId); - // 获取部门名称 + // 获取部门名称和上级部门名称 Department dept = departmentMapper.selectById(deptId); vo.setDeptName(dept != null ? dept.getDeptName() : "未知部门"); + // 获取一级部门和二级部门名称 + if (dept != null) { + // 向上查找部门层级 + List hierarchy = new java.util.ArrayList<>(); + Department current = dept; + while (current != null && current.getParentId() != null && current.getParentId() > 0) { + Department parent = departmentMapper.selectById(current.getParentId()); + if (parent != null) { + hierarchy.add(0, parent); // 插入到列表开头 + } + current = parent; + } + + // hierarchy 现在从根部门到当前部门的父部门 + // 一级部门是 hierarchy[0],二级部门是 hierarchy[1](如果存在) + if (hierarchy.size() >= 1) { + vo.setFirstLevelDeptName(hierarchy.get(0).getDeptName()); + } + if (hierarchy.size() >= 2) { + vo.setSecondLevelDeptName(hierarchy.get(1).getDeptName()); + } + } + vo.setTaskCount(deptTasks.size()); // 计算审核通过率 diff --git a/backend/src/main/java/com/designhub/vo/PrimaryDeptRankingVO.java b/backend/src/main/java/com/designhub/vo/PrimaryDeptRankingVO.java index 33e50c1..44c8a01 100644 --- a/backend/src/main/java/com/designhub/vo/PrimaryDeptRankingVO.java +++ b/backend/src/main/java/com/designhub/vo/PrimaryDeptRankingVO.java @@ -18,10 +18,20 @@ public class PrimaryDeptRankingVO { private Long deptId; /** - * 部门名称 + * 部门名称(三级/四级部门) */ private String deptName; + /** + * 一级部门名称 + */ + private String firstLevelDeptName; + + /** + * 二级部门名称 + */ + private String secondLevelDeptName; + /** * 发起任务数 */ @@ -63,6 +73,12 @@ public class PrimaryDeptRankingVO { public String getDeptName() { return deptName; } public void setDeptName(String deptName) { this.deptName = deptName; } + public String getFirstLevelDeptName() { return firstLevelDeptName; } + public void setFirstLevelDeptName(String firstLevelDeptName) { this.firstLevelDeptName = firstLevelDeptName; } + + public String getSecondLevelDeptName() { return secondLevelDeptName; } + public void setSecondLevelDeptName(String secondLevelDeptName) { this.secondLevelDeptName = secondLevelDeptName; } + public Integer getTaskCount() { return taskCount; } public void setTaskCount(Integer taskCount) { this.taskCount = taskCount; } diff --git a/frontend/src/views/Analytics.vue b/frontend/src/views/Analytics.vue index c57584b..53bb3cc 100644 --- a/frontend/src/views/Analytics.vue +++ b/frontend/src/views/Analytics.vue @@ -1132,6 +1132,8 @@ const platformColumns = [ const primaryDeptColumns = [ { title: '排名', key: 'rank', dataIndex: 'rank', align: 'center', width: 60 }, { title: '部门名称', dataIndex: 'deptName', key: 'deptName', ellipsis: true }, + { title: '一级部门', dataIndex: 'firstLevelDeptName', key: 'firstLevelDeptName', ellipsis: true, width: 120 }, + { title: '二级部门', dataIndex: 'secondLevelDeptName', key: 'secondLevelDeptName', ellipsis: true, width: 120 }, { title: '发起任务数', dataIndex: 'taskCount', key: 'taskCount', align: 'center', width: 100 }, { title: '审核通过率', key: 'approvalRate', align: 'center', width: 100 }, { title: '消耗积分', key: 'consumedScore', align: 'center', width: 100 },