aijinhui
2023-10-30 1487a187cc4e9daf2b733626929c77e945c926fe
app任务管理组织架构
已添加1个文件
已修改5个文件
173 ■■■■■ 文件已修改
ard-work/src/main/java/com/ruoyi/app/task/controller/ArdAppTaskController.java 61 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/DeptUserTree.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/app/task/controller/ArdAppTaskController.java
@@ -1,26 +1,22 @@
package com.ruoyi.app.task.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.alarm.steal.domain.ArdAlarmStealelec;
import com.ruoyi.app.task.domain.AppParam;
import com.ruoyi.app.task.domain.ArdAppTaskDetail;
import com.ruoyi.app.task.domain.WellParam;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.app.task.domain.*;
import com.ruoyi.common.core.domain.DeptUserTree;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.utils.pagehelper.JpaPageHelper;
import com.ruoyi.utils.pagehelper.JpaPageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.catalina.security.SecurityUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -28,11 +24,9 @@
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.app.task.domain.ArdAppTask;
import com.ruoyi.app.task.service.IArdAppTaskService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/**
 * app任务管理Controller
@@ -46,6 +40,11 @@
public class ArdAppTaskController extends BaseController {
    @Autowired
    private IArdAppTaskService ardAppTaskService;
    @Autowired
    private ISysUserService sysUserService;
    @Autowired
    private ISysDeptService sysDeptService;
    /**
@@ -180,4 +179,40 @@
        return success(ardAppTaskService.likeWell(wellParam));
    }
    @ApiOperation("指挥端-查询树形组织架构")
    @PostMapping(value = "/treeDept")
    public AjaxResult treeDept() {
        //查询用户ID
        String usersId = SecurityUtils.getUserId();
        //根据userId查询部门Id
        SysUser sysUser = sysUserService.selectUserById(usersId);
        //根据当前deptId或者当前及所属下级的所有deptId
        List<Long> deptList = sysDeptService.deptIdBySub(sysUser.getDeptId());
        //查询所有部门信息
        List<SysDept> sysDeptList = sysDeptService.allByUser(deptList);
        List<DeptUserTree> deptUserTrees = new ArrayList<>();
        for (int i = 0; i < sysDeptList.size(); i++) {
            SysDept sysDept = sysDeptList.get(i);
            DeptUserTree deptUserTree = new DeptUserTree();
            deptUserTree.setAncestors(sysDept.getAncestors());
            deptUserTree.setDeptId(sysDept.getDeptId());
            deptUserTree.setDeptName(sysDept.getDeptName());
            deptUserTree.setParentId(sysDept.getParentId());
            deptUserTrees.add(deptUserTree);
            QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("dept_id",sysDept.getDeptId());
            List<SysUser> users = sysUserService.userByDept(sysDept.getDeptId());
            for (int j = 0; j < users.size(); j++) {
                SysUser user = users.get(j);
                DeptUserTree deptUserTree1 = new DeptUserTree();
                deptUserTree1.setDeptId(user.getDeptId());
                deptUserTree1.setUserId(user.getUserId());
                deptUserTree1.setNickName(user.getNickName());
                deptUserTree1.setParentId(sysDept.getParentId());
                deptUserTrees.add(deptUserTree1);
            }
        }
        return success(sysDeptService.deptUserTree(deptUserTrees));
    }
}
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/DeptUserTree.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,35 @@
package com.ruoyi.common.core.domain;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.core.domain.TreeDeptWell;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class DeptUserTree {
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Long deptId;
    /** çˆ¶éƒ¨é—¨ID */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Long parentId;
    /** ç¥–级列表 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private String ancestors;
    /** éƒ¨é—¨åç§° */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private String deptName;
    /** å§“名ID */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private String userId;
    /** å§“名 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private String nickName;
    private List<DeptUserTree> children = new ArrayList<>();
}
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java
@@ -4,6 +4,7 @@
import java.util.Map;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.core.domain.DeptUserTree;
import com.ruoyi.common.core.domain.TreeDeptWell;
import com.ruoyi.common.core.domain.TreeSelect;
import com.ruoyi.common.core.domain.TreeSelectWell;
@@ -145,4 +146,9 @@
     */
    List<TreeDeptWell> wellTree(List<TreeDeptWell> depts);
    List<TreeDeptWell> buildDeptWellTree(List<TreeDeptWell> depts);
    /**
     * äººå‘˜éƒ¨é—¨ç»“构树形
     */
    List<DeptUserTree> deptUserTree(List<DeptUserTree> depts);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
@@ -236,4 +236,6 @@
    List<SysUser> userByDeptList(List<Long> deptList);
    List<SysUser> userByDept(Long deptId);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
@@ -4,13 +4,10 @@
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.HealthVo;
import com.ruoyi.common.core.domain.TreeDeptWell;
import com.ruoyi.common.core.domain.TreeSelectWell;
import com.ruoyi.common.core.domain.*;
import org.springframework.stereotype.Service;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.TreeSelect;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
@@ -429,4 +426,61 @@
    {
        return getChildListWell(list, t).size() > 0;
    }
    @Override
    public List<DeptUserTree> deptUserTree(List<DeptUserTree> depts)
    {
        List<DeptUserTree> returnList = new ArrayList<>();
        List<Long> tempList = depts.stream().map(DeptUserTree::getDeptId).collect(Collectors.toList());
        for (DeptUserTree dept : depts)
        {
            // å¦‚果是顶级节点, éåŽ†è¯¥çˆ¶èŠ‚ç‚¹çš„æ‰€æœ‰å­èŠ‚ç‚¹
            if (!tempList.contains(dept.getParentId()))
            {
                recursionFnDeptUserTree(depts, dept);
                returnList.add(dept);
            }
        }
        if (returnList.isEmpty())
        {
            returnList = depts;
        }
        return returnList;
    }
    private void recursionFnDeptUserTree(List<DeptUserTree> list, DeptUserTree t)
    {
        // å¾—到子节点列表
        if(t.getUserId()==null){
            List<DeptUserTree> childList = getChildListDeptUserTree(list, t);
            t.setChildren(childList);
            for (DeptUserTree tChild : childList) {
                if (hasChildDeptUserTree(list, tChild)) {
                    recursionFnDeptUserTree(list, tChild);
                }
            }
        }
    }
    private List<DeptUserTree> getChildListDeptUserTree(List<DeptUserTree> list, DeptUserTree t)
    {
        List<DeptUserTree> tlist = new ArrayList<>();
        Iterator<DeptUserTree> it = list.iterator();
        while (it.hasNext())
        {
            DeptUserTree n = (DeptUserTree) it.next();
            if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue())
            {
                tlist.add(n);
            }
        }
        return tlist;
    }
    private boolean hasChildDeptUserTree(List<DeptUserTree> list, DeptUserTree t)
    {
        return getChildListDeptUserTree(list, t).size() > 0;
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
@@ -640,4 +640,11 @@
        queryWrapper.in("dept_id",deptList);
        return userMapper.selectList(queryWrapper);
    }
    @Override
    public List<SysUser> userByDept(Long deptId) {
        QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("dept_id",deptId);
        return userMapper.selectList(queryWrapper);
    }
}