From 66cd596a02eb822bc8ee2c3fccc68ae1119786a6 Mon Sep 17 00:00:00 2001 From: agent Date: Wed, 4 Nov 2026 00:53:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E7=AE=A1=E7=90=86=EF=BC=9A?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BD=93=E5=89=8D=E7=94=A8=E6=88=B7=E5=BE=85?= =?UTF-8?q?=E5=8A=9E=E7=BB=9F=E8=AE=A1=E6=8E=A5=E5=8F=A3=EF=BC=88=E6=8C=89?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E8=81=9A=E5=90=88=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - GET /api/gxmu/review-list/pending-summary:status=0 且 user_id=当前登录人, 按 module 聚合并回填注册表标题,供「待办审核」左侧模块导航显示待办数 - 不拿分页结果当计数:避免 limit 上限后数字失真 - 附 sql/20261111_spec58_review_menu.sql:三个子菜单收敛为 待办审核(14359)/ 审批规则(14355),删除「审核流分配管理」(14356) --- sql/20261111_spec58_review_menu.sql | 25 +++++++++ .../gxmu/controller/ReviewListController.java | 23 ++++++++ .../gxmu/model/ReviewPendingSummary.java | 53 +++++++++++++++++++ .../gxmu/service/ReviewListService.java | 8 +++ .../service/impl/ReviewListServiceImpl.java | 20 +++++++ 5 files changed, 129 insertions(+) create mode 100644 sql/20261111_spec58_review_menu.sql create mode 100644 src/main/java/com/gxwebsoft/gxmu/model/ReviewPendingSummary.java diff --git a/sql/20261111_spec58_review_menu.sql b/sql/20261111_spec58_review_menu.sql new file mode 100644 index 0000000..17fa6a6 --- /dev/null +++ b/sql/20261111_spec58_review_menu.sql @@ -0,0 +1,25 @@ +-- 审核管理:三个子菜单收敛成两个(变体 A「按模块的工作台」落地) +-- +-- 之前:审核流配置 / 审核流分配管理 / 审核列表 —— 三个页面各自对应一张表, +-- 用户要在脑子里 join 才能回答「这条申报现在谁在审」。 +-- 之后:待办审核(原审核列表页,改造成工作台)/ 审批规则(原审核流配置页, +-- 按模块一行展示生效的审批链,可直接换链、编辑链)。 +-- 「审核流分配管理」删除:模块与审批链的绑定并入审批规则页。 +-- +-- 依赖:先跑 20261110_spec58_approval_chain.sql(模块注册表)。 + +UPDATE sys_menu SET title = '待办审核', sort_number = 10 +WHERE menu_id = 14359 AND deleted = 0; + +UPDATE sys_menu SET title = '审批规则', sort_number = 20 +WHERE menu_id = 14355 AND deleted = 0; + +DELETE FROM sys_role_menu WHERE menu_id = 14356; +UPDATE sys_menu SET deleted = 1 +WHERE menu_id = 14356 AND deleted = 0; + +-- 校验:期望只剩「待办审核」「审批规则」两条子菜单 +SELECT menu_id, parent_id, title, path, sort_number, deleted +FROM sys_menu +WHERE parent_id = 14358 +ORDER BY sort_number; diff --git a/src/main/java/com/gxwebsoft/gxmu/controller/ReviewListController.java b/src/main/java/com/gxwebsoft/gxmu/controller/ReviewListController.java index 548c99f..f3dc591 100644 --- a/src/main/java/com/gxwebsoft/gxmu/controller/ReviewListController.java +++ b/src/main/java/com/gxwebsoft/gxmu/controller/ReviewListController.java @@ -8,6 +8,8 @@ import com.gxwebsoft.gxmu.service.ReviewFlowStarterService; import com.gxwebsoft.gxmu.service.DeclareGuardService; import com.gxwebsoft.gxmu.service.ReviewListService; import com.gxwebsoft.gxmu.entity.ReviewList; +import com.gxwebsoft.gxmu.model.ReviewPendingSummary; +import com.gxwebsoft.gxmu.module.service.ModuleRegistryService; import com.gxwebsoft.gxmu.param.ReviewListParam; import com.gxwebsoft.common.core.web.ApiResult; import com.gxwebsoft.common.core.web.PageResult; @@ -21,6 +23,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.io.Serializable; import java.util.List; +import java.util.Map; /** * 审核列表控制器 @@ -42,6 +45,8 @@ public class ReviewListController extends BaseController { private DeclareGuardService declareGuardService; @Resource private ReviewFlowStarterService reviewFlowStarterService; + @Resource + private ModuleRegistryService moduleRegistryService; @ApiOperation("分页查询审核列表") @GetMapping("/page") @@ -67,6 +72,24 @@ public class ReviewListController extends BaseController { return success(reviewListService.pageRel(param)); } + @ApiOperation("当前用户的待办统计(按模块)") + @GetMapping("/pending-summary") + public ApiResult pendingSummary() { + Map counts = reviewListService.countPendingByModule(getLoginUserId()); + Map titles = moduleRegistryService.titleMap(); + ReviewPendingSummary summary = new ReviewPendingSummary(); + counts.entrySet().stream() + // 数量倒序、同数量按模块名,保证前端导航顺序稳定 + .sorted(Map.Entry.comparingByValue().reversed() + .thenComparing(Map.Entry.comparingByKey())) + .forEach(entry -> summary.getModules().add(new ReviewPendingSummary.Item( + entry.getKey(), + ModuleRegistryService.titleOf(titles, entry.getKey()), + entry.getValue()))); + summary.setTotal(counts.values().stream().mapToLong(Long::longValue).sum()); + return success(summary); + } + @ApiOperation("查询全部审核列表") @GetMapping() public ApiResult> list(ReviewListParam param) { diff --git a/src/main/java/com/gxwebsoft/gxmu/model/ReviewPendingSummary.java b/src/main/java/com/gxwebsoft/gxmu/model/ReviewPendingSummary.java new file mode 100644 index 0000000..67bfd66 --- /dev/null +++ b/src/main/java/com/gxwebsoft/gxmu/model/ReviewPendingSummary.java @@ -0,0 +1,53 @@ +package com.gxwebsoft.gxmu.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * 当前用户的待办统计(按模块聚合)。 + * + *

「待办审核」页左侧模块导航的数字来自这里:一次请求拿全,避免前端为每个模块 + * 各发一次分页查询、也避免把分页结果当计数用。 + * + * @author LX + */ +@Data +@ApiModel("待办统计") +public class ReviewPendingSummary implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("待办总数") + private long total; + + @ApiModelProperty("按模块分组的待办数,按数量倒序") + private List modules = new ArrayList<>(); + + @Data + @ApiModel("模块待办数") + public static class Item implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("模块标识") + private String module; + + @ApiModelProperty("模块标题") + private String moduleName; + + @ApiModelProperty("待办数") + private long count; + + public Item() { + } + + public Item(String module, String moduleName, long count) { + this.module = module; + this.moduleName = moduleName; + this.count = count; + } + } +} diff --git a/src/main/java/com/gxwebsoft/gxmu/service/ReviewListService.java b/src/main/java/com/gxwebsoft/gxmu/service/ReviewListService.java index e16ba50..859c5e2 100644 --- a/src/main/java/com/gxwebsoft/gxmu/service/ReviewListService.java +++ b/src/main/java/com/gxwebsoft/gxmu/service/ReviewListService.java @@ -48,4 +48,12 @@ public interface ReviewListService extends IService { ReviewList getByIdRel(Integer id); List listByModuleNPK(String module, Integer pk); + + /** + * 统计某个用户的待办(status=0)按模块的分布。 + * + * @param userId 审批人用户id,null 表示不按人过滤 + * @return module -> 待办数,按数量倒序由调用方决定 + */ + java.util.Map countPendingByModule(Integer userId); } diff --git a/src/main/java/com/gxwebsoft/gxmu/service/impl/ReviewListServiceImpl.java b/src/main/java/com/gxwebsoft/gxmu/service/impl/ReviewListServiceImpl.java index 839744f..2c8c404 100644 --- a/src/main/java/com/gxwebsoft/gxmu/service/impl/ReviewListServiceImpl.java +++ b/src/main/java/com/gxwebsoft/gxmu/service/impl/ReviewListServiceImpl.java @@ -3,6 +3,7 @@ package com.gxwebsoft.gxmu.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gxwebsoft.common.system.service.UserService; +import com.gxwebsoft.gxmu.constant.ReviewStatus; import com.gxwebsoft.gxmu.mapper.ReviewListMapper; import com.gxwebsoft.gxmu.service.ReviewListService; import com.gxwebsoft.gxmu.entity.ReviewList; @@ -13,6 +14,7 @@ import com.gxwebsoft.common.core.web.PageResult; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -90,6 +92,24 @@ public class ReviewListServiceImpl extends ServiceImpl countPendingByModule(Integer userId) { + List pending = list( + new LambdaQueryWrapper() + .eq(ReviewList::getDeleted, 0) + .eq(ReviewList::getStatus, ReviewStatus.PENDING) + .eq(userId != null, ReviewList::getUserId, userId) + ); + Map counts = new HashMap<>(); + for (ReviewList item : pending) { + if (item.getModule() == null) { + continue; + } + counts.merge(item.getModule(), 1L, Long::sum); + } + return counts; + } + @Override public List listByModuleNPK(String module, Integer pk){ return list(