| | |
| | | @ApiOperation(value = "获取部门列表树状") |
| | | public CommonResult treeList(SysDept dept) |
| | | { |
| | | List<TreeSelect> treeSelects = deptService.selectDeptTreeList(dept); |
| | | List<SysDept> treeSelects = deptService.selectDeptTreeList(dept); |
| | | return CommonResult.success(treeSelects); |
| | | } |
| | | |
| | |
| | | private Long deptId; |
| | | |
| | | /** 父部门ID */ |
| | | @ApiModelProperty("主要负责部门ID") |
| | | @ApiModelProperty("主要负责部门ID作废") |
| | | private Long parentId; |
| | | |
| | | /** 祖级列表 */ |
| | |
| | | |
| | | @ApiModelProperty("部门职责") |
| | | private String responsibilities; |
| | | |
| | | |
| | | |
| | | @ApiModelProperty("部门类型1默认2管理") |
| | | private String deptType; |
| | | |
| | | @ApiModelProperty("是否智能分配1是2否") |
| | | private String responsType; |
| | | /** 子部门 */ |
| | | private List<SysDept> children = new ArrayList<SysDept>(); |
| | | |
| | |
| | | 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; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.gkhy.exam.system.domain; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class SysDeptManage { |
| | | private Long deptId; |
| | | |
| | | private Long subDeptId; |
| | | |
| | | private Long companyId; |
| | | } |
| | |
| | | public class DeptVo extends SysDept { |
| | | @ApiModelProperty(value = "条款信息") |
| | | private List<CaluseVO1> caluseVO1List; |
| | | @ApiModelProperty(value = "负责部门") |
| | | private List<SysDeptManageVo> sysDeptManageVoList; |
| | | |
| | | |
| | | public List<CaluseVO1> getCaluseVO1List() { |
| | | return caluseVO1List; |
| | |
| | | public void setCaluseVO1List(List<CaluseVO1> caluseVO1List) { |
| | | this.caluseVO1List = caluseVO1List; |
| | | } |
| | | |
| | | public List<SysDeptManageVo> getSysDeptManageVoList() { |
| | | return sysDeptManageVoList; |
| | | } |
| | | |
| | | public void setSysDeptManageVoList(List<SysDeptManageVo> sysDeptManageVoList) { |
| | | this.sysDeptManageVoList = sysDeptManageVoList; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | 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; |
| | | } |
| | |
| | | @ApiModelProperty("祖级列表") |
| | | private String ancestors; |
| | | |
| | | /** 显示顺序 */ |
| | | @ApiModelProperty("显示顺序") |
| | | private Integer orderNum; |
| | | |
| | | /** 部门名称 */ |
| | | @ApiModelProperty("部门名称") |
| | | @NotBlank(message ="部门名称不能为空" ) |
| | |
| | | @ApiModelProperty(value = "删除条款id") |
| | | private List<Long> delCaluseIds; |
| | | |
| | | @ApiModelProperty("是否智能分配1是2否") |
| | | @NotBlank(message = "是否智能分配不能为空") |
| | | private String responsType; |
| | | |
| | | @ApiModelProperty("负责部门id") |
| | | private List<Long> childDeptIds; |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | 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; |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | public int deleteDeptById(Long deptId); |
| | | |
| | | |
| | | int insetMangeBatch(List<SysDeptManage> sysDeptManages); |
| | | int deleteMangeBatch(long deptId); |
| | | |
| | | List<SysDeptManage> getAllManage(long deptId); |
| | | } |
| | |
| | | * @param dept 部门信息 |
| | | * @return 部门树信息集合 |
| | | */ |
| | | public List<TreeSelect> selectDeptTreeList(SysDept dept); |
| | | public List<SysDept> selectDeptTreeList(SysDept dept); |
| | | |
| | | /** |
| | | * 构建前端所需要树结构 |
| | |
| | | //部门 |
| | | 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); |
| | |
| | | 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.*; |
| | |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @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"}; |
| | | /** |
| | | * 查询部门管理数据 |
| | | * |
| | |
| | | * @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); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 构建前端所需要树结构 |
| | |
| | | //处理条款 |
| | | 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 |
| | |
| | | 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<>(); |
| | |
| | | } |
| | | } |
| | | int i = sysFunctionalDistributionMapper.batchUpdate(list); |
| | | if (i < 1){ |
| | | throw new ApiException("保存失败!"); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | |
| | | 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())){ |
| | |
| | | <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" /> |
| | |
| | | <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} |
| | |
| | | |
| | | <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 |
| | |
| | | <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> |
| | |
| | | <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> |
| | |
| | | <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} |
| | |
| | | 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> |