diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/count/SysUsernumController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/count/SysUsernumController.java index 28c87d2..0cf92d9 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/count/SysUsernumController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/count/SysUsernumController.java @@ -3,6 +3,7 @@ package com.ruoyi.web.controller.system.count; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.convert.Convert; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; @@ -17,6 +18,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.domain.SysUserPost; import com.ruoyi.system.domain.SysUserRole; +import com.ruoyi.system.domain.count.UserCountDTO; import com.ruoyi.system.service.*; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -25,8 +27,10 @@ import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; /** @@ -52,28 +56,27 @@ public class SysUsernumController extends BaseController { @RequiresPermissions("system:usernum:view") @GetMapping() - public String user() - { + public String user() { return prefix + "/usernum"; } /** * 用户列表 + * * @param user * @return */ @RequiresPermissions("system:usernum:list") @PostMapping("/list") @ResponseBody - public TableDataInfo list(SysUser user,SysDept dept) - { + public TableDataInfo list(SysUser user, SysDept dept) { startPage(); List sysuser = new ArrayList<>(); List list = userService.selectUserGroupBydept(user); List sysDepts = deptService.selectDeptList(dept); - for (SysDept Dept : sysDepts){ - for ( SysUser user1 : list){ - if (Dept.getDeptName().equals(user1.getDept().getDeptName())){ + for (SysDept Dept : sysDepts) { + for (SysUser user1 : list) { + if (Dept.getDeptName().equals(user1.getDept().getDeptName())) { sysuser.add(user1); } } @@ -83,6 +86,7 @@ public class SysUsernumController extends BaseController { /** * 导出用户 + * * @param user * @return */ @@ -90,8 +94,7 @@ public class SysUsernumController extends BaseController { @RequiresPermissions("system:usernum:export") @PostMapping("/export") @ResponseBody - public AjaxResult export(SysUser user) - { + public AjaxResult export(SysUser user) { List list = userService.selectUserList(user); ExcelUtil util = new ExcelUtil(SysUser.class); return util.exportExcel(list, "用户统计数据"); @@ -102,25 +105,59 @@ public class SysUsernumController extends BaseController { */ @RequiresPermissions("system:usernum:detail") @GetMapping("/print/{deptId}") - public String print(@PathVariable("deptId")Long deptId, SysUser user,ModelMap mmap) - - { + public String print(@PathVariable("deptId") Long deptId, SysUser user, ModelMap mmap) { List list = userService.lambdaQuery().eq(SysUser::getDeptId, deptId) - .eq(SysUser::getDelFlag,0) - .ne(SysUser::getUserId,1) + .eq(SysUser::getDelFlag, 0) + .ne(SysUser::getUserId, 1) .list(); list.forEach(sysuser -> { List postList = sysUserPostService.lambdaQuery(). eq(SysUserPost::getUserId, sysuser.getUserId()).list(); List postIds = postList.stream().map(SysUserPost::getPostId).collect(Collectors.toList()); - if(CollUtil.isNotEmpty(postIds)){ + if (CollUtil.isNotEmpty(postIds)) { List sysPostList = postService.lambdaQuery().in(SysPost::getPostId, postIds).list(); - sysuser.setPosts( Convert.toList(SysPostVO.class, sysPostList)); + sysuser.setPosts(Convert.toList(SysPostVO.class, sysPostList)); } }); mmap.put("list", list); - mmap.put("dept",deptService.selectDeptById(deptId)); - mmap.put("sysuser",getSysUser()); + mmap.put("dept", deptService.selectDeptById(deptId)); + mmap.put("sysuser", getSysUser()); return prefix + "/print"; } + + + private List sharType = Arrays.asList("已登记", "已申报", "已审核", "已离职"); + + + /** + * + * 统计人员已登记、已申报、已审核、已离职 + * @return com.ruoyi.common.core.domain.AjaxResult + */ + @PostMapping("/countUser") + @ResponseBody + public AjaxResult countUser() { + UserCountDTO userCountDTO = userService.selectCountUser(); + List datas = sharType.stream() + .map(name -> { + AtomicReference value = new AtomicReference<>(0L); + if("已登记".equals(name)){ + value.set(userCountDTO.getYdj()); + }else if("已申报".equals(name)){ + value.set(userCountDTO.getYsb()); + }else if("已审核".equals(name)){ + value.set(userCountDTO.getYsh()); + }else{ + value.set(userCountDTO.getYlz()); + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("name", name); + jsonObject.put("value", value.get()); + return jsonObject; + }) + .collect(Collectors.toList()); + return AjaxResult.success(datas); + } + + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/count/UserCountDTO.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/count/UserCountDTO.java new file mode 100644 index 0000000..1d78184 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/count/UserCountDTO.java @@ -0,0 +1,33 @@ +package com.ruoyi.system.domain.count; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * packageName com.ruoyi.system.domain.userexam.dto.response + * + * @author wangxy + * @version JDK 8 + * @className ExamCountDTO + * @date 2024/8/7 + * @description 用户统计 + */ +@Data +@ApiModel(value="用户统计", description="用户统计") +public class UserCountDTO implements Serializable { + + @ApiModelProperty(value = "已登记") + private Integer ydj; + + @ApiModelProperty(value = "已申报") + private Integer ysb; + + @ApiModelProperty(value = "已审核") + private Integer ysh; + + @ApiModelProperty(value = "已离职") + private Integer ylz; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java index 6290b5f..fa6b4cd 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java @@ -5,6 +5,7 @@ import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.system.domain.count.UserCountDTO; /** * 用户表 数据层 @@ -126,4 +127,7 @@ public interface SysUserMapper extends BaseMapper * @return 结果 */ public SysUser checkEmailUnique(String email); + + + public UserCountDTO selectCountUser(); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index f86a733..1518b43 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.system.domain.SysUserRole; +import com.ruoyi.system.domain.count.UserCountDTO; /** * 用户 业务层 @@ -226,4 +227,7 @@ public interface ISysUserService extends IService * @return 结果 */ public int changeStatus(SysUser user); + + + public UserCountDTO selectCountUser(); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index aed3c9c..9c1e71b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -7,6 +7,7 @@ import javax.validation.Validator; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.system.domain.count.UserCountDTO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -581,4 +582,9 @@ public class SysUserServiceImpl extends ServiceImpl imple public boolean save(SysUser entity) { return super.save(entity); } + + @Override + public UserCountDTO selectCountUser() { + return userMapper.selectCountUser(); + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index d8d9171..bac3282 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -313,5 +313,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" now() ) + + + + + + \ No newline at end of file