Browse Source

角色树

v6
yanyan 1 year ago
parent
commit
6dc67044d7
  1. 20
      lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/domain/Ztree.java
  2. 27
      lib/EmergencyBaseLib/EmergencyCommonEntity/src/main/java/com/zdxt/domain/auth/Dept.java
  3. 12
      lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/project/system/dept/controller/DeptController.java
  4. 77
      lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/project/system/dept/service/DeptServiceImpl.java
  5. 8
      lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/project/system/dept/service/IDeptService.java
  6. 2
      lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/project/system/role/controller/RoleController.java
  7. 19
      lib/EmergencyService/zdxtEmergencyAuthService/src/main/resources/mapper/system/DeptMapper.xml
  8. 4
      lib/EmergencyService/zdxtEmergencyAuthService/src/main/resources/mapper/system/RoleMapper.xml
  9. 19
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/system/dept/add.html
  10. 9
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/system/dept/edit.html

20
lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/domain/Ztree.java

@ -23,6 +23,10 @@ public class Ztree implements Serializable
/** 节点标题 */
private String title;
private Integer zone;
private String ancestors;
/** 是否勾选 */
private boolean checked = false;
@ -101,4 +105,20 @@ public class Ztree implements Serializable
{
this.nocheck = nocheck;
}
public Integer getZone() {
return zone;
}
public void setZone(Integer zone) {
this.zone = zone;
}
public String getAncestors() {
return ancestors;
}
public void setAncestors(String ancestors) {
this.ancestors = ancestors;
}
}

27
lib/EmergencyBaseLib/EmergencyCommonEntity/src/main/java/com/zdxt/domain/auth/Dept.java

@ -5,6 +5,7 @@ import com.zdxt.common.BaseDomain;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.List;
/**
* 部门表 sys_dept
@ -123,6 +124,16 @@ public class Dept extends BaseDomain {
*/
private String creditcode;
/**
* 角色左侧树状图区分
*/
private Integer zone;
/**
* 角色左侧树状图区分
*/
private List<Integer> zoneList;
/**
* 测试
*/
@ -489,4 +500,20 @@ public class Dept extends BaseDomain {
", kingdeeOrgParentId='" + kingdeeOrgParentId + '\'' +
"} " + super.toString();
}
public Integer getZone() {
return zone;
}
public void setZone(Integer zone) {
this.zone = zone;
}
public List<Integer> getZoneList() {
return zoneList;
}
public void setZoneList(List<Integer> zoneList) {
this.zoneList = zoneList;
}
}

12
lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/project/system/dept/controller/DeptController.java

@ -16,6 +16,7 @@ import com.zdxt.common.domain.Ztree;
import com.zdxt.domain.auth.*;
import com.zdxt.log.aspectj.lang.annotation.Log;
import com.zdxt.log.aspectj.lang.enums.BusinessType;
import org.apache.commons.collections.CollectionUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -225,10 +226,15 @@ public class DeptController extends BaseController {
*/
@GetMapping("/treeData")
@ResponseBody
public List<Ztree> treeData()
public List<Ztree> treeData(@RequestParam(value = "zoneList", required = false) List<Integer> zoneList)
{
List<Ztree> ztrees = deptService.selectDeptTree(new Dept());
return ztrees;
Dept dept = new Dept();
if (CollectionUtils.isNotEmpty(zoneList)) {
dept.setZoneList(zoneList);
return deptService.selectDeptTreeNew(dept);
}else {
return deptService.selectDeptTree(dept);
}
}
/**

77
lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/project/system/dept/service/DeptServiceImpl.java

@ -7,12 +7,15 @@ import com.zdxt.auth.common.exception.BusinessException;
import com.zdxt.auth.common.utils.StringUtils;
import com.zdxt.auth.common.utils.security.ShiroUtils;
import com.zdxt.auth.project.system.dept.mapper.DeptMapper;
import com.zdxt.auth.project.system.dict.service.IDictDataService;
import com.zdxt.common.annotation.DataScope;
import com.zdxt.common.domain.Ztree;
import com.zdxt.domain.auth.Dept;
import com.zdxt.domain.auth.DictData;
import com.zdxt.domain.auth.Role;
import com.zdxt.domain.auth.SysTenant;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
@ -29,10 +32,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
* 部门管理 服务实现
@ -47,6 +48,9 @@ public class DeptServiceImpl implements IDeptService
@Autowired
private DeptMapper deptMapper;
@Autowired
private IDictDataService dictDataService;
@Value("${srnwg.url}")
private String znwgUrl;
@Value("${srnwg.paasId}")
@ -130,6 +134,69 @@ public class DeptServiceImpl implements IDeptService
List<Ztree> ztrees = initZtree(deptList);
return ztrees;
}
@Override
@DataScope(deptAlias = "d")
public List<Ztree> selectDeptTreeNew(Dept dept)
{
List<Dept> deptList = deptMapper.selectDeptList(dept);
List<Ztree> ztrees = initZtree(deptList);
if (CollectionUtils.isNotEmpty(ztrees)) {
//拿到深圳市
Ztree ztree = new Ztree();
ztree.setpId("0");
ztree.setId("0");
ztree.setTitle("深圳市");
ztree.setName("深圳市");
ztrees.add(ztree);
//拿到角色区分
List<DictData> list = dictDataService.selectDictDataByType("role_tree_zone");
if (CollectionUtils.isNotEmpty(list)) {
// 进行拆解封装
List<Ztree> zoneTree = list.stream()
.filter(item -> Objects.equals(item.getDictValue(), "1") ||
Objects.equals(item.getDictValue(), "2"))
.map(item -> {
Ztree ztree1 = new Ztree();
ztree1.setTitle(item.getDictLabel());
ztree1.setName(item.getDictLabel());
ztree1.setId(item.getDictValue());
ztree1.setpId("0");
return ztree1;
}).collect(Collectors.toList());
ztrees.addAll(zoneTree);
//给市值和区挂上深圳市
ztrees = ztrees.stream()
.peek(i -> i.setpId(Objects.equals(i.getZone(), 1) ||
Objects.equals(i.getZone(), 2) ? String.valueOf(i.getZone()) : i.getpId()))
.collect(Collectors.toList());
List<String> collect = ztrees.stream()
.filter(item -> Objects.equals(item.getZone(), 2))
.map(Ztree::getId).collect(Collectors.toList());
for (String pid : collect) {
//给区直挂上区直
Ztree ztree1 = new Ztree();
ztree1.setTitle("区直");
ztree1.setName("区直");
ztree1.setId(pid+"3");
ztree1.setpId(pid);
ztrees.add(ztree1);
//
for (Ztree ztree2 : ztrees) {
if (Objects.equals(ztree2.getZone(), 3) &&
StringUtils.isNotEmpty(ztree2.getAncestors()) && ztree2.getAncestors().contains(pid)) {
ztree2.setpId(ztree1.getId());
}
}
}
}
}
return ztrees;
}
@Override
public List<Ztree> selectDeptTreeNotRole(Dept dept)
{
@ -193,6 +260,8 @@ public class DeptServiceImpl implements IDeptService
ztree.setpId(dept.getParentId());
ztree.setName(dept.getDeptName());
ztree.setTitle(dept.getDeptName());
ztree.setAncestors(dept.getAncestors());
ztree.setZone(dept.getZone());
if (isCheck)
{
ztree.setChecked(roleDeptList.contains(dept.getDeptId() + dept.getDeptName()));

8
lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/project/system/dept/service/IDeptService.java

@ -56,6 +56,14 @@ public interface IDeptService
*/
public List<Ztree> selectDeptTree(Dept dept);
/**
* 查询部门管理树
*
* @param dept 部门信息
* @return 所有部门信息
*/
public List<Ztree> selectDeptTreeNew(Dept dept);
/**
* 根据角色ID查询菜单
*

2
lib/EmergencyService/zdxtEmergencyAuthService/src/main/java/com/zdxt/auth/project/system/role/controller/RoleController.java

@ -48,7 +48,7 @@ public class RoleController extends BaseController
@GetMapping()
public String role()
{
return prefix + "/role";
return prefix + "/roleNew";
}
@RequiresPermissions("system:role:list")

19
lib/EmergencyService/zdxtEmergencyAuthService/src/main/resources/mapper/system/DeptMapper.xml

@ -44,13 +44,13 @@
<result property="isMappingUnit" column="isMappingUnit"/>
<result property="srzUnitId" column="srzUnitId"/>
<result property="taskId" column="taskId"/>
<result property="zone" column="zone"/>
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time,dept_type,d.kingdee_org_id,d.kingdee_org_parent_id,
tenant_code, organizationId, organizationParentId, zzLevel, code, mappingUnitParentId,updateAt, createAt, description, effectOn, sequence, isDeleted, zzDisplayPath, `name`, guid, zzIsLeaf, isDisabled,
fullname, isMappingUnit, srzUnitId, taskId,creditcode from sys_dept d
fullname, isMappingUnit, srzUnitId, taskId,creditcode,zone from sys_dept d
</sql>
<select id="selectDeptAll" resultMap="DeptResult">
@ -102,6 +102,7 @@
<if test="deptType != null">dept_type,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="kingdeeOrgId != null and kingdeeOrgId != ''">kingdee_org_id,</if>
<if test="zone != null">zone,</if>
<if test="kingdeeOrgParentId != null and kingdeeOrgParentId != ''">kingdee_org_parent_id,</if>
create_time
)values(
@ -118,6 +119,7 @@
<if test="deptType != null">#{deptType},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="kingdeeOrgId != null and kingdeeOrgId != ''">#{kingdeeOrgId},</if>
<if test="zone != null">#{zone},</if>
<if test="kingdeeOrgParentId != null and kingdeeOrgParentId != ''">#{kingdeeOrgParentId},</if>
sysdate()
)
@ -156,6 +158,13 @@
<if test="deptType != null and deptType != ''">
AND dept_type = #{deptType}
</if>
<if test="zoneList != null ">
AND zone in
<foreach collection="zoneList" item="item" index="index"
separator="," open="(" close=")">
#{item}
</foreach>
</if>
<!-- 租户数据过滤 -->
<if test="tenantCode != @com.zdxt.auth.common.constant.Constants@DEFAULT_TENANT_CODE and tenantCode != null and tenantCode != ''">
AND d.tenant_code = #{tenantCode}
@ -200,7 +209,7 @@
</select>
<select id="selectDeptById" parameterType="string" resultMap="DeptResult">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,d.dept_type,d.creditcode,
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,d.dept_type,d.creditcode,d.zone,
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
from sys_dept d
where d.dept_id = #{deptId}
@ -278,6 +287,7 @@
<if test="taskId != null and taskId != ''">taskId,</if>
<if test="systemId != null and systemId != ''">systemId,</if>
<if test="creditcode != null and creditcode != ''">creditcode,</if>
<if test="zone != null">zone,</if>
create_time
)values(
<if test="deptId != null and deptId != ''">#{deptId},</if>
@ -315,6 +325,7 @@
<if test="taskId != null and taskId != ''">#{taskId},</if>
<if test="systemId != null and systemId != ''">#{systemId},</if>
<if test="creditcode != null and creditcode != ''">#{creditcode},</if>
<if test="zone != null">#{zone},</if>
sysdate()
)
</insert>
@ -334,6 +345,7 @@
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="kingdeeOrgId != null and kingdeeOrgId != ''">kingdee_org_id = #{kingdeeOrgId},</if>
<if test="zone != null">zone = #{zone},</if>
<if test="kingdeeOrgParentId != null and kingdeeOrgParentId != ''">kingdee_org_parent_id = #{kingdeeOrgParentId},</if>
update_time = sysdate()
</set>
@ -378,6 +390,7 @@
<if test="taskId != null and taskId != ''">taskId = #{taskId},</if>
<if test="systemId != null and systemId != ''">systemId = #{systemId},</if>
<if test="creditcode != null and creditcode != ''">creditcode = #{creditcode},</if>
<if test="zone != null">zone = #{zone},</if>
update_time = sysdate()
</set>
where organizationId = #{organizationId}

4
lib/EmergencyService/zdxtEmergencyAuthService/src/main/resources/mapper/system/RoleMapper.xml

@ -48,6 +48,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">
AND r.status = #{status}
</if>
<if test="deptId != null ">
AND (r.dept_id = #{deptId} OR r.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE FIND_IN_SET
(#{deptId},ancestors) ))
</if>
<if test="roleKey != null and roleKey != ''">
AND r.role_key like concat('%', #{roleKey}, '%')
</if>

19
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/system/dept/add.html

@ -8,13 +8,13 @@
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-dept-add">
<!--<input id="treeId" name="parentId" type="hidden"/>-->
<input id="treeId" name="parentId" type="hidden" th:value="${dept.deptId}" />
<input id="treeId" name="parentId" type="hidden" />
<div class="form-group">
<label class="col-sm-3 control-label">上级部门:</label>
<div class="col-sm-8">
<div class="input-group">
<!--<input class="form-control" type="text" onclick="selectDeptTree()" id="treeName" readonly="true">-->
<input class="form-control" type="text" onclick="selectDeptTree()" id="treeName" readonly="true" th:value="${dept.deptName}">
<input class="form-control" type="text" onclick="selectDeptTree()" id="treeName" readonly="true">
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
@ -60,6 +60,14 @@
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">角色列表显示:</label>
<div class="col-sm-8">
<select id="zone" name="zone" class="form-control select2-multiple" multiple th:with="type=${@dict.getType('role_tree_zone')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">部门状态:</label>
<div class="col-sm-8">
@ -73,8 +81,13 @@
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script type="text/javascript">
<script type="text/javascript" th:inline="javascript">
var prefix = ctx + "system/dept";
var dept =[[${dept}]]
if (dept.deptId !== null) {
$("#treeId").val(dept.deptId);
$("#treeName").val(dept.treeName);
}
$("#form-dept-add").validate({
onkeyup: false,

9
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/system/dept/edit.html

@ -56,6 +56,15 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">角色列表显示:</label>
<div class="col-sm-8">
<select id="zone" name="zone" class="form-control select2-multiple"
multiple th:with="type=${@dict.getType('role_tree_zone')}" th:field="*{zone}" >
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">部门状态:</label>
<div class="col-sm-8">

Loading…
Cancel
Save