fix:人员统计

pg_adapter
wangxy 8 months ago
parent 87b98e8959
commit 5e4fa7de3d

@ -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> sysuser = new ArrayList<>();
List<SysUser> list = userService.selectUserGroupBydept(user);
List<SysDept> 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<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(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<SysUser> 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<SysUserPost> postList = sysUserPostService.lambdaQuery().
eq(SysUserPost::getUserId, sysuser.getUserId()).list();
List<Long> postIds = postList.stream().map(SysUserPost::getPostId).collect(Collectors.toList());
if(CollUtil.isNotEmpty(postIds)){
if (CollUtil.isNotEmpty(postIds)) {
List<SysPost> 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<String> sharType = Arrays.asList("已登记", "已申报", "已审核", "已离职");
/**
*
*
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@PostMapping("/countUser")
@ResponseBody
public AjaxResult countUser() {
UserCountDTO userCountDTO = userService.selectCountUser();
List<JSONObject> datas = sharType.stream()
.map(name -> {
AtomicReference<Object> 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);
}
}

@ -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;
}

@ -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<SysUser>
* @return
*/
public SysUser checkEmailUnique(String email);
public UserCountDTO selectCountUser();
}

@ -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<SysUser>
* @return
*/
public int changeStatus(SysUser user);
public UserCountDTO selectCountUser();
}

@ -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<SysUserMapper,SysUser> imple
public boolean save(SysUser entity) {
return super.save(entity);
}
@Override
public UserCountDTO selectCountUser() {
return userMapper.selectCountUser();
}
}

@ -313,5 +313,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
now()
)
</insert>
<select id="selectCountUser" resultType="com.ruoyi.system.domain.count.UserCountDTO">
SELECT
SUM (CASE WHEN examine = 2 THEN 1 ELSE 0 END) AS ydj,
SUM (CASE WHEN examine = 3 THEN 1 ELSE 0 END) AS ysb,
SUM (CASE WHEN examine = 0 THEN 1 ELSE 0 END) AS ysh,
(SELECT SUM (CASE WHEN leavestate = 1 THEN 1 ELSE 0 END)
FROM td_leave t where t.user_id=s.user_id) as ylz
FROM ${prefix}sys_user s
</select>
</mapper>
Loading…
Cancel
Save