From 5e2d78f61bf7d1513d5d5c8cd55442133a6e898e Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期一, 14 七月 2025 18:23:36 +0800 Subject: [PATCH] 保洁巡检本周代码 --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TProjectDeptServiceImpl.java | 24 +++++++++++++++++++++--- 1 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TProjectDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TProjectDeptServiceImpl.java index 2d98a80..21b036e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TProjectDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TProjectDeptServiceImpl.java @@ -1,16 +1,20 @@ package com.ruoyi.system.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.basic.PageInfo; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.mapper.TProjectDeptMapper; import com.ruoyi.system.model.TProjectDept; -import com.ruoyi.system.query.ProjectDeptListQuery; +import com.ruoyi.system.query.DeptListQuery; import com.ruoyi.system.service.TProjectDeptService; -import com.ruoyi.system.vo.system.DeptListVO; import com.ruoyi.system.vo.system.ProjectDeptListVO; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.stream.Collectors; /** * <p> @@ -23,10 +27,24 @@ @Service public class TProjectDeptServiceImpl extends ServiceImpl<TProjectDeptMapper, TProjectDept> implements TProjectDeptService { + @Autowired + private SysUserMapper sysUserMapper; @Override - public PageInfo<ProjectDeptListVO> pageList(ProjectDeptListQuery query) { + public PageInfo<ProjectDeptListVO> pageList(DeptListQuery query) { + List<SysUser> sysUsers = sysUserMapper.selectAllList(); PageInfo<ProjectDeptListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); List<ProjectDeptListVO> list = this.baseMapper.pageList(query,pageInfo); + List<TProjectDept> projectDepts = this.baseMapper.selectList(new LambdaQueryWrapper<TProjectDept>() + .ne(TProjectDept::getParentId, 0)); + for (ProjectDeptListVO projectDeptListVO : list) { + List<TProjectDept> collect = projectDepts.stream().filter(e -> e.getParentId().equals(projectDeptListVO.getId())) + .collect(Collectors.toList()); + for (TProjectDept tProjectDept : collect) { + List<SysUser> collect1 = sysUsers.stream().filter(e -> e.getDeptId().equals(tProjectDept.getId())).collect(Collectors.toList()); + tProjectDept.setUserCount(collect1.size()); + } + projectDeptListVO.setChildren(collect); + } pageInfo.setRecords(list); return pageInfo; } -- Gitblit v1.7.1