multi-admin/src/main/java/com/gkhy/exam/admin/controller/system/SysDeptController.java
@@ -31,7 +31,7 @@ * * @author expert */ @Api(tags = "部门-业务处室") @Api(tags = "部门管理") @RestController @RequestMapping("/system/dept") public class SysDeptController @@ -60,17 +60,17 @@ * 查询部门列表(排除节点) */ //@PreAuthorize("hasAnyAuthority('system:dept:list')") @GetMapping("/list/exclude/{deptId}") @ApiImplicitParams({ @ApiImplicitParam(paramType = "query", name = "deptId", dataType = "Long", required = true, value = "部门id"), }) @ApiOperation(value = "查询部门列表(排除节点)") public CommonResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) { List<SysDept> depts = deptService.getOutDeptList(new SysDept()); depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); return CommonResult.success(depts); } // @GetMapping("/list/exclude/{deptId}") // @ApiImplicitParams({ // @ApiImplicitParam(paramType = "query", name = "deptId", dataType = "Long", required = true, value = "部门id"), // }) // @ApiOperation(value = "查询部门列表(排除节点)") // public CommonResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) // { // List<SysDept> depts = deptService.getOutDeptList(new SysDept()); // depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); // return CommonResult.success(depts); // } /** * 根据部门编号获取详细信息 @@ -182,19 +182,19 @@ */ //@PreAuthorize("hasAnyAuthority('system:dept:remove')") @DeleteMapping("/{deptId}") @ApiOperation(value = "删除部门门业务处室") @ApiOperation(value = "删除部门") public CommonResult remove(@PathVariable Long deptId) { if (deptService.hasChildByDeptId(deptId)) { return CommonResult.failed("存在下级部门,不允许删除"); } if (deptService.checkDeptExistUser(deptId)) { return CommonResult.failed("部门存在用户,不允许删除"); } // if (deptService.checkDeptExistUser(deptId)) // { // return CommonResult.failed("部门存在用户,不允许删除"); // } //todo 校验专家是否申请复用 deptService.checkDeptDataScope(deptId); // deptService.checkDeptDataScope(deptId); return CommonResult.success(deptService.deleteDeptById(deptId)); } } multi-common/src/main/java/com/gkhy/exam/common/utils/SecurityUtils.java
@@ -48,6 +48,24 @@ /* ** * 用户ID **/ public static Long getCompanyId() { try { return getLoginUser().getUser().getCompanyId(); } catch (Exception e) { throw new ApiException("获取用户公司异常"); } } /** * 获取用户账户 **/ multi-system/src/main/java/com/gkhy/exam/system/domain/SysClauseManagement.java
@@ -16,6 +16,10 @@ @ApiModelProperty("排序") private Integer sort; @ApiModelProperty("条款名称") @NotBlank(message = "条款名称不能为空") private String name; @ApiModelProperty("条款编码") @NotBlank(message = "条款编码不能为空") private String clauseNum; multi-system/src/main/java/com/gkhy/exam/system/service/impl/InformationPlatformServiceImpl.java
@@ -27,7 +27,7 @@ @Override public List<InformationPlatform> getInformationPlatforms(Long companyId) { if (companyId == null) { companyId = SecurityUtils.getLoginUser().getUser().getCompanyId(); companyId = SecurityUtils.getCompanyId(); } LambdaQueryWrapper<InformationPlatform> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(InformationPlatform::getCompanyId, companyId); @@ -41,7 +41,7 @@ @Override public int saveInformationPlatform(InformationPlatform informationPlatform) { Long companyId = informationPlatform.getCompanyId(); if (!companyId.equals(SecurityUtils.getLoginUser().getUser().getCompanyId())){ if (!companyId.equals(SecurityUtils.getCompanyId())){ throw new ApiException("无权操作!"); } multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysClauseManagementServiceImpl.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gkhy.exam.common.exception.ApiException; import com.gkhy.exam.common.utils.SecurityUtils; import com.gkhy.exam.system.domain.SysClauseManagement; import com.gkhy.exam.system.mapper.SysClauseManagementMapper; @@ -29,13 +30,13 @@ @Override public int saveSysClauseManagement(SysClauseManagement sysClauseManagement) { if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ throw new RuntimeException("没有权限访问!"); throw new ApiException("没有权限访问!"); } LambdaQueryWrapper<SysClauseManagement> lambdaQueryWrapper = Wrappers.<SysClauseManagement>lambdaQuery() .eq(SysClauseManagement::getDelFlag, "0").eq(SysClauseManagement::getClauseNum, sysClauseManagement.getClauseNum()); if (sysClauseManagement.getId() == null){ if (baseMapper.selectCount(lambdaQueryWrapper) > 0){ throw new RuntimeException("条款编号已存在!"); throw new ApiException("条款编号已存在!"); } sysClauseManagement.setCreateBy(SecurityUtils.getUsername()); sysClauseManagement.setCreateTime(LocalDateTime.now()); @@ -43,7 +44,7 @@ }else { lambdaQueryWrapper.ne(SysClauseManagement::getId, sysClauseManagement.getId()); if (baseMapper.selectCount(lambdaQueryWrapper) > 0){ throw new RuntimeException("条款编号已存在!"); throw new ApiException("条款编号已存在!"); } sysClauseManagement.setUpdateBy(SecurityUtils.getUsername()); sysClauseManagement.setUpdateTime(LocalDateTime.now()); @@ -56,7 +57,7 @@ @Override public int delSysClauseManagement(Long id) { if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ throw new RuntimeException("没有权限访问!"); throw new ApiException("没有权限访问!"); } //todo 校验已使用的? SysClauseManagement sysClauseManagement = new SysClauseManagement(); multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java
@@ -28,6 +28,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.*; @@ -64,6 +65,9 @@ public List<DeptVo> selectDeptList(SysDept dept) { if (dept.getCompanyId() == null){ dept.setCompanyId(SecurityUtils.getCompanyId()); } return deptMapper.selectDeptList(dept); } @@ -208,7 +212,7 @@ public boolean checkDeptNameUnique(SysDept dept) { Long deptId = ObjectUtil.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); Long companyId = SecurityUtils.getLoginUser().getUser().getCompanyId(); Long companyId = SecurityUtils.getCompanyId(); SysDept info = deptMapper.checkDeptNameUnique(companyId,dept.getDeptName(), dept.getParentId()); if (ObjectUtil.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) @@ -258,8 +262,9 @@ } @Override @Transactional public int saveDept(SysDeptSaveDTOReq dept) { Long companyId = SecurityUtils.getLoginUser().getUser().getCompanyId(); Long companyId = SecurityUtils.getCompanyId(); if (!companyId.equals(dept.getCompanyId())){ throw new ApiException("无权操作!"); } @@ -294,8 +299,9 @@ } @Override @Transactional public int saveDeptResponsibility(SysDeptResponsibilityReqVo reqVo) { Long companyId = SecurityUtils.getLoginUser().getUser().getCompanyId(); Long companyId = SecurityUtils.getCompanyId(); if (!companyId.equals(reqVo.getCompanyId())){ throw new ApiException("无权操作!"); } @@ -324,13 +330,16 @@ @Override public List<SysFunctionalDistribution> getFunctionalDistributionList(Long companyId) { if (companyId != null){ companyId = SecurityUtils.getCompanyId(); } return sysFunctionalDistributionMapper.selectListVo(companyId); } @Override public int initFunctionalDistribution(Long companyId) { if (!companyId.equals(SecurityUtils.getLoginUser().getUser().getCompanyId())){ if (!companyId.equals(SecurityUtils.getCompanyId())){ throw new ApiException("无权操作!"); } sysFunctionalDistributionMapper.delete(new LambdaQueryWrapper<SysFunctionalDistribution>().eq(SysFunctionalDistribution::getCompanyId, SecurityUtils.getLoginUser().getUser().getCompanyId())); @@ -396,9 +405,14 @@ if (emptyIdClauseNumSet.size() != emptyIdClauseNums.size()){ throw new ApiException("部门条款编码重复!"); } List<Long> emptyIdClauseIds = sysDeptResponsibilityList.stream() .filter(item -> item.getId() != null) .map(SysDeptResponsibility::getId) .collect(Collectors.toList()); if (!emptyIdClauseNums.isEmpty()){ List<SysDeptResponsibility> sysDeptResponsibilities = deptResponsibilityMapper.selectList(new LambdaQueryWrapper<SysDeptResponsibility>() .eq(SysDeptResponsibility::getDeptId, reqVo.getDeptId()).in(SysDeptResponsibility::getClauseNum, emptyIdClauseNums)); .eq(SysDeptResponsibility::getDeptId, reqVo.getDeptId()).in(SysDeptResponsibility::getClauseNum, emptyIdClauseNums).notIn(SysDeptResponsibility::getId, emptyIdClauseIds)); if (!sysDeptResponsibilities.isEmpty()){ throw new ApiException("部门条款编码重复!"); } @@ -426,7 +440,7 @@ .update(new SysDeptResponsibility(), new LambdaUpdateWrapper<SysDeptResponsibility>().set(SysDeptResponsibility::getDelFlag, UserConstant.DEPT_DISABLE) .set(SysDeptResponsibility::getUpdateTime, LocalDateTime.now()).set(SysDeptResponsibility::getUpdateBy, SecurityUtils.getUsername()) .eq(SysDeptResponsibility::getDeptId, deptId)); .eq(SysDeptResponsibility::getDeptId, deptId).in(SysDeptResponsibility::getId, delCaluseIds)); } private void batchSaveCaluse(Long deptId,Long companyId, List<CaluseVO1> caluseVO1List) { @@ -449,9 +463,11 @@ sysDeptResponsibility.setCompanyId(companyId); sysDeptResponsibility.setDeptId(deptId); if (sysDeptResponsibility.getId() == null){ sysDeptResponsibility.setCreateBy(SecurityUtils.getUsername()); sysDeptResponsibility.setCreateTime(LocalDateTime.now()); sysDeptResponsibility.setDataType("2"); deptResponsibilityMapper.insert(sysDeptResponsibility); }else { sysDeptResponsibility.setUpdateBy(SecurityUtils.getUsername()); multi-system/src/main/resources/mapper/system/SysDeptMapper.xml
@@ -42,24 +42,24 @@ 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 from sys_dept d left join sys_user u on d.leader_user_id = u.user_id 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 where d.del_flag = '0' <if test="companyId != null and companyId != 0"> AND company_id = #{companyId} AND d.company_id = #{companyId} </if> <if test="deptId != null and deptId != 0"> AND dept_id = #{deptId} AND d.dept_id = #{deptId} </if> <if test="parentId != null and parentId != 0"> AND parent_id = #{parentId} AND d.parent_id = #{parentId} </if> <if test="deptName != null and deptName != ''"> AND dept_name like concat('%', #{deptName}, '%') AND d.dept_name like concat('%', #{deptName}, '%') </if> <if test="status != null and status != ''"> AND status = #{status} AND d.status = #{status} </if> order by d.parent_id, d.order_num </select> @@ -131,7 +131,7 @@ and del_flag = '0' limit 1 </select> <insert id="insertDept" parameterType="com.gkhy.exam.common.domain.entity.SysDept"> <insert id="insertDept" parameterType="com.gkhy.exam.common.domain.entity.SysDept" useGeneratedKeys="true" keyProperty="deptId"> insert into sys_dept( <if test="deptId != null and deptId != 0">dept_id,</if> <if test="parentId != null and parentId != 0">parent_id,</if> @@ -202,7 +202,7 @@ </update> <delete id="deleteDeptById" parameterType="Long"> update sys_dept set del_flag = '2' where dept_id = #{deptId} update sys_dept set del_flag = '1' where dept_id = #{deptId} </delete> </mapper> multi-system/src/main/resources/mapper/system/SysFunctionalDistributionMapper.xml
@@ -24,13 +24,12 @@ a.company_id, a.clause_num, a.choose_lab, a.dept_name, a.create_by, a.create_time, a.update_by, a.update_time from sys_functional_distribution a left join sys_dept b on a.dept_id = b.id left join sys_dept b on a.dept_id = b.dept_id where 1=1 and a.company_id = #{companyId} order by a.clause_num asc @@ -45,7 +44,7 @@ <foreach collection="list" item="item" separator=";"> update sys_functional_distribution <trim prefix="SET" suffixOverrides=","> <if test="item.score != null">choose_lab = #{item.chooseLab},</if> <if test="item.chooseLab != null">choose_lab = #{item.chooseLab},</if> <if test="item.updateBy != null">update_by = #{item.updateBy},</if> <if test="item.updateTime != null">update_time = #{item.updateTime},</if> </trim>