From b48be73219c84cf00f4fbbabe6ea31f6e511c4a9 Mon Sep 17 00:00:00 2001
From: heheng <475597332@qq.com>
Date: 星期一, 07 七月 2025 09:54:05 +0800
Subject: [PATCH] 功能改造
---
multi-system/src/main/java/com/gkhy/exam/system/mapper/SysDeptMapper.java | 7 +
multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java | 79 ++++++++++++++++++-
multi-system/src/main/java/com/gkhy/exam/system/domain/SysDeptManage.java | 12 +++
multi-system/src/main/java/com/gkhy/exam/system/service/impl/StandardizedTemplateServiceImpl.java | 2
multi-system/src/main/resources/mapper/system/SysDeptMapper.xml | 43 ++++++++++
multi-system/src/main/java/com/gkhy/exam/system/domain/vo/DeptVo.java | 11 ++
multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysUserServiceImpl.java | 7 +
multi-system/src/main/java/com/gkhy/exam/system/domain/vo/SysDeptManageVo.java | 10 ++
multi-system/src/main/java/com/gkhy/exam/system/service/ISysDeptService.java | 2
multi-admin/src/main/java/com/gkhy/exam/admin/controller/system/SysDeptController.java | 2
multi-common/src/main/java/com/gkhy/exam/common/domain/entity/SysDept.java | 26 ++++++
multi-system/src/main/java/com/gkhy/exam/system/domain/vo/SysDeptSaveDTOReq.java | 11 ++
12 files changed, 196 insertions(+), 16 deletions(-)
diff --git a/multi-admin/src/main/java/com/gkhy/exam/admin/controller/system/SysDeptController.java b/multi-admin/src/main/java/com/gkhy/exam/admin/controller/system/SysDeptController.java
index fa76240..b8dabc1 100644
--- a/multi-admin/src/main/java/com/gkhy/exam/admin/controller/system/SysDeptController.java
+++ b/multi-admin/src/main/java/com/gkhy/exam/admin/controller/system/SysDeptController.java
@@ -59,7 +59,7 @@
@ApiOperation(value = "获取部门列表树状")
public CommonResult treeList(SysDept dept)
{
- List<TreeSelect> treeSelects = deptService.selectDeptTreeList(dept);
+ List<SysDept> treeSelects = deptService.selectDeptTreeList(dept);
return CommonResult.success(treeSelects);
}
diff --git a/multi-common/src/main/java/com/gkhy/exam/common/domain/entity/SysDept.java b/multi-common/src/main/java/com/gkhy/exam/common/domain/entity/SysDept.java
index 6becccf..d399fb1 100644
--- a/multi-common/src/main/java/com/gkhy/exam/common/domain/entity/SysDept.java
+++ b/multi-common/src/main/java/com/gkhy/exam/common/domain/entity/SysDept.java
@@ -27,7 +27,7 @@
private Long deptId;
/** 父部门ID */
- @ApiModelProperty("主要负责部门ID")
+ @ApiModelProperty("主要负责部门ID作废")
private Long parentId;
/** 祖级列表 */
@@ -76,7 +76,13 @@
@ApiModelProperty("部门职责")
private String responsibilities;
-
+
+
+ @ApiModelProperty("部门类型1默认2管理")
+ private String deptType;
+
+ @ApiModelProperty("是否智能分配1是2否")
+ private String responsType;
/** 子部门 */
private List<SysDept> children = new ArrayList<SysDept>();
@@ -245,4 +251,20 @@
public void setInternalAuditorsName(String internalAuditorsName) {
this.internalAuditorsName = internalAuditorsName;
}
+
+ public String getDeptType() {
+ return deptType;
+ }
+
+ public void setDeptType(String deptType) {
+ this.deptType = deptType;
+ }
+
+ public String getResponsType() {
+ return responsType;
+ }
+
+ public void setResponsType(String responsType) {
+ this.responsType = responsType;
+ }
}
diff --git a/multi-system/src/main/java/com/gkhy/exam/system/domain/SysDeptManage.java b/multi-system/src/main/java/com/gkhy/exam/system/domain/SysDeptManage.java
new file mode 100644
index 0000000..e8e5ba6
--- /dev/null
+++ b/multi-system/src/main/java/com/gkhy/exam/system/domain/SysDeptManage.java
@@ -0,0 +1,12 @@
+package com.gkhy.exam.system.domain;
+
+import lombok.Data;
+
+@Data
+public class SysDeptManage {
+ private Long deptId;
+
+ private Long subDeptId;
+
+ private Long companyId;
+}
diff --git a/multi-system/src/main/java/com/gkhy/exam/system/domain/vo/DeptVo.java b/multi-system/src/main/java/com/gkhy/exam/system/domain/vo/DeptVo.java
index f7a732b..5617e6b 100644
--- a/multi-system/src/main/java/com/gkhy/exam/system/domain/vo/DeptVo.java
+++ b/multi-system/src/main/java/com/gkhy/exam/system/domain/vo/DeptVo.java
@@ -10,6 +10,9 @@
public class DeptVo extends SysDept {
@ApiModelProperty(value = "条款信息")
private List<CaluseVO1> caluseVO1List;
+ @ApiModelProperty(value = "负责部门")
+ private List<SysDeptManageVo> sysDeptManageVoList;
+
public List<CaluseVO1> getCaluseVO1List() {
return caluseVO1List;
@@ -18,4 +21,12 @@
public void setCaluseVO1List(List<CaluseVO1> caluseVO1List) {
this.caluseVO1List = caluseVO1List;
}
+
+ public List<SysDeptManageVo> getSysDeptManageVoList() {
+ return sysDeptManageVoList;
+ }
+
+ public void setSysDeptManageVoList(List<SysDeptManageVo> sysDeptManageVoList) {
+ this.sysDeptManageVoList = sysDeptManageVoList;
+ }
}
diff --git a/multi-system/src/main/java/com/gkhy/exam/system/domain/vo/SysDeptManageVo.java b/multi-system/src/main/java/com/gkhy/exam/system/domain/vo/SysDeptManageVo.java
new file mode 100644
index 0000000..f8a6896
--- /dev/null
+++ b/multi-system/src/main/java/com/gkhy/exam/system/domain/vo/SysDeptManageVo.java
@@ -0,0 +1,10 @@
+package com.gkhy.exam.system.domain.vo;
+
+import com.gkhy.exam.system.domain.SysDeptManage;
+import lombok.Data;
+
+@Data
+public class SysDeptManageVo extends SysDeptManage {
+
+ private String subDeptName;
+}
diff --git a/multi-system/src/main/java/com/gkhy/exam/system/domain/vo/SysDeptSaveDTOReq.java b/multi-system/src/main/java/com/gkhy/exam/system/domain/vo/SysDeptSaveDTOReq.java
index d19f1fe..08aea38 100644
--- a/multi-system/src/main/java/com/gkhy/exam/system/domain/vo/SysDeptSaveDTOReq.java
+++ b/multi-system/src/main/java/com/gkhy/exam/system/domain/vo/SysDeptSaveDTOReq.java
@@ -23,6 +23,10 @@
@ApiModelProperty("祖级列表")
private String ancestors;
+ /** 显示顺序 */
+ @ApiModelProperty("显示顺序")
+ private Integer orderNum;
+
/** 部门名称 */
@ApiModelProperty("部门名称")
@NotBlank(message ="部门名称不能为空" )
@@ -43,4 +47,11 @@
@ApiModelProperty(value = "删除条款id")
private List<Long> delCaluseIds;
+ @ApiModelProperty("是否智能分配1是2否")
+ @NotBlank(message = "是否智能分配不能为空")
+ private String responsType;
+
+ @ApiModelProperty("负责部门id")
+ private List<Long> childDeptIds;
+
}
diff --git a/multi-system/src/main/java/com/gkhy/exam/system/mapper/SysDeptMapper.java b/multi-system/src/main/java/com/gkhy/exam/system/mapper/SysDeptMapper.java
index 211ab27..5a62f35 100644
--- a/multi-system/src/main/java/com/gkhy/exam/system/mapper/SysDeptMapper.java
+++ b/multi-system/src/main/java/com/gkhy/exam/system/mapper/SysDeptMapper.java
@@ -2,6 +2,7 @@
import com.gkhy.exam.common.domain.entity.SysDept;
+import com.gkhy.exam.system.domain.SysDeptManage;
import com.gkhy.exam.system.domain.vo.DeptVo;
import org.apache.ibatis.annotations.Param;
@@ -125,4 +126,10 @@
* @return 结果
*/
public int deleteDeptById(Long deptId);
+
+
+ int insetMangeBatch(List<SysDeptManage> sysDeptManages);
+ int deleteMangeBatch(long deptId);
+
+ List<SysDeptManage> getAllManage(long deptId);
}
diff --git a/multi-system/src/main/java/com/gkhy/exam/system/service/ISysDeptService.java b/multi-system/src/main/java/com/gkhy/exam/system/service/ISysDeptService.java
index 406f476..0630f21 100644
--- a/multi-system/src/main/java/com/gkhy/exam/system/service/ISysDeptService.java
+++ b/multi-system/src/main/java/com/gkhy/exam/system/service/ISysDeptService.java
@@ -32,7 +32,7 @@
* @param dept 部门信息
* @return 部门树信息集合
*/
- public List<TreeSelect> selectDeptTreeList(SysDept dept);
+ public List<SysDept> selectDeptTreeList(SysDept dept);
/**
* 构建前端所需要树结构
diff --git a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/StandardizedTemplateServiceImpl.java b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/StandardizedTemplateServiceImpl.java
index cc57162..1340450 100644
--- a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/StandardizedTemplateServiceImpl.java
+++ b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/StandardizedTemplateServiceImpl.java
@@ -173,7 +173,7 @@
//部门
SysDept sysDept = new SysDept();
sysDept.setCompanyId(companyId.longValue());
- List<TreeSelect> treeSelects = iSysDeptService.selectDeptTreeList(sysDept);
+ List<SysDept> treeSelects = iSysDeptService.selectDeptTreeList(sysDept);
//公司概况
List<CompanySummary> companySummaries = companySummaryMapper.selectCompanySummaryList(companyId);
diff --git a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java
index 4f5bd1a..51fef94 100644
--- a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java
+++ b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java
@@ -13,6 +13,7 @@
import com.gkhy.exam.common.exception.ApiException;
import com.gkhy.exam.common.utils.SecurityUtils;
import com.gkhy.exam.common.utils.SpringUtils;
+import com.gkhy.exam.system.domain.SysDeptManage;
import com.gkhy.exam.system.domain.SysDeptResponsibility;
import com.gkhy.exam.system.domain.SysFunctionalDistribution;
import com.gkhy.exam.system.domain.vo.*;
@@ -28,6 +29,7 @@
import java.time.LocalDateTime;
import java.util.*;
+import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -50,7 +52,9 @@
@Autowired
private SysFunctionalDistributionMapper sysFunctionalDistributionMapper;
public static final String[] DEPT_ROOT = {"4.1", "4.2", "4.3", "4.4", "5.1", "5.2", "5.3","6.1", "6.2", "6.3",
- "7.1.1", "7.1.2", "7.1.3", "7.1.4", "7.1.5", "7.1.6"};
+ "7.1.1", "7.1.2", "7.1.3", "7.1.4", "7.1.5", "7.1.6","7.2", "7.3", "7.4", "7.5", "7.6","8.1","8.2","8.2.1","8.2.2", "8.2.3", "8.2.4", "8.3", "8.3.1", "8.3.2", "8.3.3", "8.3.4", "8.3.5", "8.3.6", "8.3.7", "8.3.8", "8.4",
+ "8.4.1", "8.4.2", "8.4.3", "8.5", "8.5.1", "8.5.2", "8.5.3", "8.5.4", "8.5.5", "8.5.6", "8.5.7", "8.6","8.7","9.1","9.1.1","9.1.2","9.1.3","9.2", "9.3","10.1"
+ ,"10.2", "10.3"};
/**
* 查询部门管理数据
*
@@ -79,11 +83,56 @@
* @return 部门树信息集合
*/
@Override
- public List<TreeSelect> selectDeptTreeList(SysDept dept)
+ public List<SysDept> selectDeptTreeList(SysDept dept)
{
List<SysDept> depts = SpringUtils.getAopProxy(this).getOutDeptList(dept);
- return buildDeptTreeSelect(depts);
+
+ List<SysDeptManage> allManage = deptMapper.getAllManage(dept.getCompanyId());
+ // 构建父部门到子部门的映射
+ Map<Long, List<Long>> parentToChildrenMap = new HashMap<>();
+ for (SysDeptManage responsibility : allManage) {
+ parentToChildrenMap.computeIfAbsent(responsibility.getDeptId(), k -> new ArrayList<>())
+ .add(responsibility.getSubDeptId());
+ }
+
+ // 构建部门ID到部门对象的映射
+ Map<Long, SysDept> deptMap = depts.stream()
+ .collect(Collectors.toMap(SysDept::getDeptId, Function.identity()));
+
+
+ return buildDeptTree(depts,parentToChildrenMap, deptMap);
}
+
+ public List<SysDept> buildDeptTree(List<SysDept> allDepts, Map<Long, List<Long>> parentToChildrenMap, Map<Long, SysDept> deptMap) {
+ List<SysDept> rootNodes = new ArrayList<>();
+
+ for (SysDept dept : allDepts) {
+ if (!deptMap.values().stream()
+ .anyMatch(d -> parentToChildrenMap.containsValue(dept.getDeptId()))) {
+ // 如果没有其他部门将它作为子部门,则为根节点
+ rootNodes.add(dept);
+ }
+ }
+
+ for (SysDept root : rootNodes) {
+ buildChildren(root, parentToChildrenMap, deptMap);
+ }
+
+ return rootNodes;
+ }
+
+ private void buildChildren(SysDept parent, Map<Long, List<Long>> parentToChildrenMap, Map<Long, SysDept> deptMap) {
+ List<Long> childIds = parentToChildrenMap.getOrDefault(parent.getDeptId(), Collections.emptyList());
+
+ List<SysDept> children = childIds.stream()
+ .map(deptMap::get)
+ .filter(Objects::nonNull)
+ .peek(child -> buildChildren(child, parentToChildrenMap, deptMap))
+ .collect(Collectors.toList());
+
+ parent.setChildren(children);
+ }
+
/**
* 构建前端所需要树结构
@@ -288,9 +337,28 @@
//处理条款
batchSaveCaluse(sysDept.getDeptId(), dept.getCompanyId(), dept.getCaluseVO1List());
+ List<Long> childDeptIds = dept.getChildDeptIds();
+ bacthInsertManager(sysDept.getDeptId(), childDeptIds, dept.getCompanyId());
}
return sysDept.getDeptId().byteValue();
+ }
+
+ private void bacthInsertManager(Long deptId, List<Long> managerIds,Long companyId) {
+ deptMapper.deleteMangeBatch(deptId);
+ if (managerIds != null && !managerIds.isEmpty())
+ {
+ List<SysDeptManage> sysDeptManagers = new ArrayList<>();
+ for (Long managerId : managerIds)
+ {
+ SysDeptManage sysDeptManage = new SysDeptManage();
+ sysDeptManage.setDeptId(deptId);
+ sysDeptManage.setSubDeptId(managerId);
+ sysDeptManage.setCompanyId(companyId);
+ sysDeptManagers.add(sysDeptManage);
+ }
+ deptMapper.insetMangeBatch(sysDeptManagers);
+ }
}
@Override
@@ -340,6 +408,7 @@
sysFunctionalDistributionMapper.delByCompanyId(companyId);
SysDept sysDept = new SysDept();
sysDept.setCompanyId(companyId);
+ sysDept.setResponsType("1");
List<DeptVo> deptVos = deptMapper.selectDeptList(sysDept);
if (deptVos != null && !deptVos.isEmpty()){
List<SysFunctionalDistribution> sysFunctionalDistributions = new ArrayList<>();
@@ -381,9 +450,7 @@
}
}
int i = sysFunctionalDistributionMapper.batchUpdate(list);
- if (i < 1){
- throw new ApiException("保存失败!");
- }
+
return 1;
}
diff --git a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysUserServiceImpl.java b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysUserServiceImpl.java
index 379e974..31c246a 100644
--- a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysUserServiceImpl.java
+++ b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysUserServiceImpl.java
@@ -228,8 +228,11 @@
Integer userType=user.getUserType();
//校验权限,规则:上一级用户可以增加下一级用户类型的用户
if(currentUserType.equals(UserTypeEnum.SYSTEM_USER.getCode())){
- if( !userType.equals(UserTypeEnum.SYSTEM_USER.getCode())&&!userType.equals(UserTypeEnum.OTHER_USER.getCode()) &&!userType.equals(UserTypeEnum.COMPANY_USER.getCode())){
- throw new ApiException("管理员只能操作管理员、企业级和其他类型的用户");
+// if( !userType.equals(UserTypeEnum.SYSTEM_USER.getCode())&&!userType.equals(UserTypeEnum.OTHER_USER.getCode()) &&!userType.equals(UserTypeEnum.COMPANY_USER.getCode())){
+// throw new ApiException("管理员只能操作管理员、企业级和其他类型的用户");
+// }
+ if (user.getId().toString().equals("1")){
+ throw new ApiException("管理员用户不能被删除");
}
}else{
if(userType.equals(UserTypeEnum.OTHER_USER.getCode())){
diff --git a/multi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/multi-system/src/main/resources/mapper/system/SysDeptMapper.xml
index 01802b7..54dcded 100644
--- a/multi-system/src/main/resources/mapper/system/SysDeptMapper.xml
+++ b/multi-system/src/main/resources/mapper/system/SysDeptMapper.xml
@@ -21,6 +21,8 @@
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="responsibilities" column="responsibilities" />
+ <result property="deptType" column="dept_type" />
+ <result property="responsType" column="respons_type" />
<result property="personNum" column="person_num" />
<result property="internalAuditors" column="internal_auditors" />
<result property="internalAuditorsName" column="internal_auditors_name" />
@@ -32,24 +34,39 @@
<result property="clauseId" column="clause_id" />
<result property="id" column="data_id" />
</collection>
+ <collection ofType="com.gkhy.exam.system.domain.vo.SysDeptManageVo" property="sysDeptManageVoList">
+ <result property="subDeptId" column="sub_dept_id" />
+ <result property="subDeptName" column="sub_dept_name" />
+ <result property="deptId" column="p_dept_id" />
+
+ </collection>
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader_user_id, d.company_id, d.status, d.del_flag, d.create_by, d.create_time,d.person_num,d.internal_auditors,
- d.responsibilities
+ d.responsibilities,d.dept_type,d.respons_type
from sys_dept d
</sql>
<select id="selectDeptList" parameterType="com.gkhy.exam.common.domain.entity.SysDept" resultMap="DeptVoResult">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader_user_id, d.company_id, d.status, d.del_flag, d.create_by, d.create_time,d.person_num,d.internal_auditors,
- d.responsibilities,u.name as leader_name,d2.dept_name as parent_name, dr.content ,dr.clause_num,dr.id as data_id,dr.clause_id
+ d.responsibilities,d.dept_type,d.respons_type,u.name as leader_name,d2.dept_name as parent_name, dr.content ,dr.clause_num,dr.id as data_id,dr.clause_id,
+ sm.sub_dept_id ,sm2.dept_name sub_dept_name,sm.dept_id as p_dept_id
from sys_dept d
left join sys_user u on d.leader_user_id = u.id
left join sys_dept d2 on d.parent_id = d2.dept_id
left join sys_dept_responsibility dr on d.dept_id = dr.dept_id and dr.del_flag = '0' and data_type = 2
+ left join sys_dept_manage sm on d.dept_id = sm.dept_id
+ left join sys_dept sm2 on sm2.dept_id = sm.sub_dept_id
where d.del_flag = '0'
<if test="companyId != null and companyId != 0">
AND d.company_id = #{companyId}
+ </if>
+ <if test="deptType != null and deptType != '' " >
+ AND d.dept_type = #{deptType}
+ </if>
+ <if test="responsType != null and responsType != '' " >
+ AND d.respons_type = #{responsType}
</if>
<if test="deptId != null and deptId != 0">
AND d.dept_id = #{deptId}
@@ -102,7 +119,7 @@
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader_user_id,d.company_id,d.status,d.person_num,d.internal_auditors,
- d.responsibilities,
+ d.responsibilities,d.dept_type,d.respons_type,
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name,(select dept_name from sys_user where id = d.leader_user_id) leader_name
,(select dept_name from sys_user where id = d.internal_auditors) internal_auditors_name
from sys_dept d
@@ -147,6 +164,7 @@
<if test="responsibilities != null and responsibilities != ''">responsibilities,</if>
<if test="status != null">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
+ <if test="responsType != null and responsType != ''">respons_type,</if>
create_time
)values(
<if test="deptId != null and deptId != 0">#{deptId},</if>
@@ -161,6 +179,7 @@
<if test="responsibilities != null and responsibilities != ''">#{responsibilities},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
+ <if test="responsType != null and responsType != ''">#{responsType},</if>
sysdate()
)
</insert>
@@ -178,6 +197,7 @@
<if test="responsibilities != null and responsibilities != ''">responsibilities = #{responsibilities},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+ <if test="responsType != null and responsType != ''">respons_type = #{responsType},</if>
update_time = sysdate()
</set>
where dept_id = #{deptId}
@@ -207,4 +227,21 @@
update sys_dept set del_flag = '1' where dept_id = #{deptId}
</delete>
+
+ <insert id="insetMangeBatch">
+ insert into sys_dept_manage(dept_id,sub_dept_id,company_id) values
+ <foreach item="item" index="index" collection="list" separator=",">
+ (#{item.deptId},#{item.subDeptId},#{item.companyId})
+ </foreach>
+ </insert>
+
+ <delete id="deleteMangeBatch">
+ delete from sys_dept_manage where dept_id = #{deptId}
+ </delete>
+
+ <select id="getAllManage" parameterType="long" resultType="com.gkhy.exam.system.domain.SysDeptManage">
+ select * from sys_dept_manage
+ where company_id = #{companyId}
+ </select>
+
</mapper>
\ No newline at end of file
--
Gitblit v1.9.2