Administrator
2021-08-19 f655dd8373a0bc767115c3a4490bc3e3b0d05ec3
保安员查询修改
16 files modified
1 files added
237 ■■■■ changed files
src/main/java/org/springblade/modules/desk/controller/NoticeController.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/desk/mapper/NoticeMapper.xml 7 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/desk/service/impl/NoticeServiceImpl.java 6 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/controller/DeptController.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/controller/UserController.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/DeptMapper.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml 71 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/DictBizMapper.xml 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/UserMapper.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/UserMapper.xml 21 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/node/TreeNodes.java 42 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/IDeptService.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/IUserService.java 4 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java 22 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/desk/controller/NoticeController.java
@@ -95,7 +95,7 @@
    @ApiOperation(value = "分页", notes = "传入notice")
    public R<IPage<NoticeVO>> page(@ApiIgnore NoticeVO notice, Query query) {
        //通过deptId获取组织机构信息
        Dept dept = iDeptService.getById(notice.getDeptId());
//        Dept dept = iDeptService.getById(notice.getDeptId());
//        if (dept.getDeptCategory() == 1) {
//            notice.setCategory(1);
//        } else {
src/main/java/org/springblade/modules/desk/mapper/NoticeMapper.xml
@@ -37,9 +37,14 @@
    <select id="selectNoticePage" resultMap="noticeVOResultMap">
        SELECT
        n.*,
        d.dict_value AS categoryName
        d.dict_value AS categoryName,
        bd.dept_name deptName
        FROM
        blade_notice n
        left join
        blade_dept bd
        on
        bd.id = n.dept_id
        LEFT JOIN
        ( SELECT * FROM blade_dict WHERE code = 'notice' ) d
        ON
src/main/java/org/springblade/modules/desk/service/impl/NoticeServiceImpl.java
@@ -45,9 +45,9 @@
        // 若不使用mybatis-plus自带的分页方法,则不会自动带入tenantId,所以我们需要自行注入
        notice.setTenantId(AuthUtil.getTenantId());
        List<NoticeVO> noticeVOS = baseMapper.selectNoticePage(page, notice);
        noticeVOS.forEach(noticeVO -> {
            noticeVO.setDeptName(deptService.getById(noticeVO.getDeptId()).getDeptName());
        });
//        noticeVOS.forEach(noticeVO -> {
//            noticeVO.setDeptName(deptService.getById(noticeVO.getDeptId()).getDeptName());
//        });
        return page.setRecords(noticeVOS);
    }
src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java
@@ -18,7 +18,9 @@
import org.springblade.modules.exam.service.ExamScoreService;
import org.springblade.modules.exam.util.SecurityPaperUtil;
import org.springblade.modules.exam.vo.ExamScoreVO;
import org.springblade.modules.system.entity.Role;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IRoleService;
import org.springblade.modules.system.service.IUserService;
import org.springblade.modules.system.vo.UserVO;
import org.springframework.web.bind.annotation.*;
@@ -44,6 +46,8 @@
    private final IUserService userService;
    private final ExamPaperService examPaperService;
    private final IRoleService roleService;
    /**
     * 自定义分页
@@ -124,6 +128,13 @@
                        result = pre + (decimalFormat.format(count++));
                    }
                    user.setSecuritynumber(result);
                    //修改为持证保安
                    user.setHold("1");
                    //分配保安角色
                    Role role = new Role();
                    role.setRoleAlias("保安");
                    Role oneRole = roleService.getOne(Condition.getQueryWrapper(role));
                    user.setRoleId(oneRole.getId().toString());
                    //更新保安数据
                    userService.updateById(user);
                }
src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
@@ -20,7 +20,9 @@
import org.springblade.modules.exam.util.SecurityPaperUtil;
import org.springblade.modules.exam.vo.ExamResultVO;
import org.springblade.modules.exam.vo.ExamScoreVO;
import org.springblade.modules.system.entity.Role;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IRoleService;
import org.springblade.modules.system.service.IUserService;
import org.springblade.modules.system.vo.UserVO;
import org.springblade.modules.training.entity.TrainingRegistration;
@@ -52,6 +54,8 @@
    private final ApplyService applyService;
    private final TrainingRegistrationService trainingRegistrationService;
    private final IRoleService roleService;
    /**
     * 自定义分页数据
@@ -235,6 +239,13 @@
                                    result = pre + (decimalFormat.format(count++));
                                }
                                user.setSecuritynumber(result);
                                //修改为持证保安
                                user.setHold("1");
                                //分配保安角色
                                Role role = new Role();
                                role.setRoleAlias("保安");
                                Role oneRole = roleService.getOne(Condition.getQueryWrapper(role));
                                user.setRoleId(oneRole.getId().toString());
                                //更新保安数据
                                userService.updateById(user);
                            }
src/main/java/org/springblade/modules/system/controller/DeptController.java
@@ -34,6 +34,7 @@
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.system.entity.Dept;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.node.TreeNodes;
import org.springblade.modules.system.service.IDeptService;
import org.springblade.modules.system.service.IUserService;
import org.springblade.modules.system.vo.DeptVO;
@@ -139,6 +140,16 @@
        return R.data(tree);
    }
    /**
     * 懒加载获取部门树形结构(包含用户数据),只查下一级的数据
     * @return
     */
    @GetMapping("/lazy-tree-users")
    public R<List<TreeNodes>> lazyTreeUsers(String tenantId, Long parentId, BladeUser bladeUser) {
        List<TreeNodes> tree = deptService.lazyTreeUsers(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()), parentId);
        return R.data(tree);
    }
    /**
     * 懒加载获取部门树形结构(包含用户数据)app
src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -140,8 +140,8 @@
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "列表", notes = "传入account和realName")
    //@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
    public R<IPage<UserVO>> pages(@ApiIgnore UserVO user, Query query, Long deptId, BladeUser bladeUser) {
        IPage<UserVO> pages = userService.selectUserPages(Condition.getPage(query), user, deptId, "000000");
    public R<IPage<UserVO>> pages(@ApiIgnore UserVO user, Query query) {
        IPage<UserVO> pages = userService.selectUserPages(Condition.getPage(query), user);
        return R.data(pages);
    }
src/main/java/org/springblade/modules/system/mapper/DeptMapper.java
@@ -18,8 +18,10 @@
import com.baomidou.mybatisplus.annotation.SqlParser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.system.entity.Dept;
import org.springblade.modules.system.node.TreeNodes;
import org.springblade.modules.system.vo.DeptVO;
import java.util.List;
@@ -108,4 +110,12 @@
     */
    @SqlParser(filter=true)
    List<DeptVO> lazyTreeUserApp(@Param("type")Integer type,@Param("jurisdiction")String jurisdiction);
    /**
     * 懒加载获取部门树形结构(包含用户数据),只查下一级的数据
     * @return
     */
    @MapKey(value = "id")
    @SqlParser(filter=true)
    Map<Long, TreeNodes> lazyTreeUsers(@Param("parentId") Long parentId);
}
src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
@@ -160,20 +160,7 @@
    <!--懒加载获取部门树形结构(包含用户数据)app-->
    <select id="lazyTreeUserApp" resultType="org.springblade.modules.system.vo.DeptAndUserVO" >
        select DISTINCT
            c.id,
            c.parent_id,
            c.title,
            c.value,
            c.key,
            (
            SELECT
            CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
            FROM
            blade_dept
            where
            id = c.parent_id
            and dept_category=1
            ) AS "has_children"
            *
        from (
            (SELECT
            dept.id,
@@ -287,7 +274,7 @@
                        dept.is_deleted = 0
                    <if test="parentId!=null and parentId!=''">
                        and dept_category=1
                        AND dept.id = #{parentId}
                        AND dept.parent_id = #{parentId}
                    </if>
            )
@@ -316,6 +303,60 @@
    </select>
    <!--懒加载获取部门树形结构(包含用户数据)-->
    <select id="lazyTreeUsers" resultType="org.springblade.modules.system.node.TreeNodes" >
        select DISTINCT
            *
        from (
            (SELECT
              dept.id,
              dept.parent_id parentId,
              dept.dept_name AS title,
              dept.id AS "value",
              dept.id AS "key",
                        (
                            SELECT
                                CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
                            FROM
                                blade_dept
                            WHERE
                                parent_id = dept.id and is_deleted = 0
                        ) AS "has_children"
                    FROM
                        blade_dept dept
                    WHERE
                        dept.is_deleted = 0
                    <if test="parentId!=null and parentId!='' or parentId==0">
                        and dept_category=1
                        AND dept.parent_id = #{parentId}
                    </if>
            )
            union
            (select
                bu.id,
                bu.dept_id  parentId,
                bu.real_name AS title,
                bu.id AS "value",
                bu.id AS "key",
                0 as "has_children"
                from blade_user bu
                left join
                blade_dept bd
                on
                bd.id = bu.dept_id
                where 1=1
                and bu.is_deleted = 0
                <if test="parentId!=null and parentId!='' or parentId==0">
                    and dept_category=1
                    AND bu.dept_id = #{parentId}
                </if>
            )
        )c
    </select>
    <select id="lazyTrees" resultMap="treeNodeResultMap" >
    SELECT
src/main/java/org/springblade/modules/system/mapper/DictBizMapper.xml
@@ -76,7 +76,6 @@
            blade_dict_biz bdb
        where
            1=1
        and bdb.parent_id = 0
    </select>
src/main/java/org/springblade/modules/system/mapper/UserMapper.java
@@ -46,7 +46,7 @@
     * @param tenantId
     * @return
     */
    List<UserVO> selectUserPages(IPage<UserVO> page, @Param("user") UserVO user, @Param("deptIdList") List<Long> deptIdList, @Param("tenantId") String tenantId);
    List<UserVO> selectUserPages(IPage<UserVO> page, @Param("user") UserVO user);
    /**
src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -69,12 +69,6 @@
        br.id = bu.role_id
        where
        bu.is_deleted = 0
        <if test="tenantId!=null and tenantId != ''">
            and bu.tenant_id = #{tenantId}
        </if>
        <if test="user.tenantId!=null and user.tenantId != ''">
            and bu.tenant_id = #{user.tenantId}
        </if>
        <if test="user.account!=null and user.account != ''">
            and bu.account = #{user.account}
        </if>
@@ -82,7 +76,7 @@
            and bu.hold = #{user.hold}
        </if>
        <if test="user.deptId!=null and user.deptId != ''">
            and (bd.parent_id = #{user.deptId} or bd.id = #{user.deptId})
            and bu.dept_id = #{user.deptId}
        </if>
        <if test="user.roleId!=null and user.roleId != ''">
            and bu.role_id = #{user.roleId}
@@ -107,19 +101,6 @@
        </if>
        <if test="user.examinationType!=null and user.examinationType != ''">
            and bu.examination_type = #{user.examinationType}
        </if>
        <if test="deptIdList!=null and deptIdList.size>0">
            and bu.id in (
            SELECT
            user_id
            FROM
            blade_user_dept
            WHERE
            dept_id IN
            <foreach collection="deptIdList" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
            )
        </if>
        ORDER BY bu.id
    </select>
src/main/java/org/springblade/modules/system/node/TreeNodes.java
New file
@@ -0,0 +1,42 @@
package org.springblade.modules.system.node;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
 * @author zhongrj
 * avue 返回格式
 */
@Data
public class TreeNodes {
    /**
     * id
     */
    private Long id;
    /**
     * key
     */
    private Long key;
    /**
     * 父id
     */
    private Long parentId;
    /**
     * 树节点名称
     */
    private String title;
    /**
     * 子节点
     */
    private List<TreeNodes> children = new ArrayList<>();
    /**
     * 是否有子节点
     */
    private Boolean hasChildren;
}
src/main/java/org/springblade/modules/system/service/IDeptService.java
@@ -18,6 +18,7 @@
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.system.entity.Dept;
import org.springblade.modules.system.node.TreeNodes;
import org.springblade.modules.system.vo.DeptVO;
import java.util.List;
@@ -150,4 +151,10 @@
     * @return
     */
    List<DeptVO> lazyTreeUserApp(Integer type,String jurisdiction);
    /**
     * 懒加载获取部门树形结构(包含用户数据),只查下一级的数据
     * @return
     */
    List<TreeNodes> lazyTreeUsers(String tenantId, Long parentId);
}
src/main/java/org/springblade/modules/system/service/IUserService.java
@@ -69,11 +69,9 @@
     *
     * @param page
     * @param user
     * @param deptId
     * @param tenantId
     * @return
     */
    IPage<UserVO> selectUserPages(IPage<UserVO> page, UserVO user, Long deptId, String tenantId);
    IPage<UserVO> selectUserPages(IPage<UserVO> page, UserVO user);
    /**
     * 自定义分页
src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java
@@ -28,11 +28,14 @@
import org.springblade.core.tool.utils.StringPool;
import org.springblade.modules.system.entity.Dept;
import org.springblade.modules.system.mapper.DeptMapper;
import org.springblade.modules.system.node.TreeNode;
import org.springblade.modules.system.node.TreeNodes;
import org.springblade.modules.system.service.IDeptService;
import org.springblade.modules.system.vo.DeptVO;
import org.springblade.modules.system.wrapper.DeptWrapper;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -235,4 +238,23 @@
    public List<DeptVO> lazyTreeUserApp(Integer type,String jurisdiction) {
        return ForestNodeMerger.merge(baseMapper.lazyTreeUserApp(type,jurisdiction));
    }
    /**
     * 懒加载获取部门树形结构(包含用户数据),只查下一级的数据
     * @return
     */
    @Override
    public List<TreeNodes> lazyTreeUsers(String tenantId, Long parentId) {
        Map<Long,TreeNodes> map = baseMapper.lazyTreeUsers(parentId);
        System.out.println("map = " + map.size());
        List<TreeNodes> tree = new ArrayList<>();
        map.forEach((id,treeNodes) ->{
            if (map.containsKey(treeNodes.getParentId())){
                map.get(treeNodes.getParentId()).getChildren().add(treeNodes);
            }else {
                tree.add(treeNodes);
            }
        });
        return tree;
    }
}
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -138,9 +138,8 @@
    }
    @Override
    public IPage<UserVO> selectUserPages(IPage<UserVO> page, UserVO user, Long deptId, String tenantId) {
        List<Long> deptIdList = SysCache.getDeptChildIds(deptId);
        return page.setRecords(baseMapper.selectUserPages(page, user, deptIdList, tenantId));
    public IPage<UserVO> selectUserPages(IPage<UserVO> page, UserVO user) {
        return page.setRecords(baseMapper.selectUserPages(page, user));
    }
    @Override