mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-31 10:37:41 +08:00 
			
		
		
		
	【代码优化】BPM:流程模型->基本信息->谁可以发起,支持指定多个部门
This commit is contained in:
		| @ -6,8 +6,10 @@ import lombok.Data; | |||||||
| @Schema(description = "部门精简信息 VO") | @Schema(description = "部门精简信息 VO") | ||||||
| @Data | @Data | ||||||
| public class DeptSimpleBaseVO { | public class DeptSimpleBaseVO { | ||||||
|  |  | ||||||
|     @Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |     @Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||||||
|     private Long id; |     private Long id; | ||||||
|     @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") |     @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "技术部") | ||||||
|     private String name; |     private String name; | ||||||
|  |  | ||||||
| } | } | ||||||
| @ -83,13 +83,12 @@ public class BpmModelController { | |||||||
|         List<ProcessDefinition> processDefinitions = processDefinitionService.getProcessDefinitionListByDeploymentIds( |         List<ProcessDefinition> processDefinitions = processDefinitionService.getProcessDefinitionListByDeploymentIds( | ||||||
|                 deploymentMap.keySet()); |                 deploymentMap.keySet()); | ||||||
|         Map<String, ProcessDefinition> processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId); |         Map<String, ProcessDefinition> processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId); | ||||||
|         // 获得 User Map |         // 获得 User Map、Dept Map | ||||||
|         Set<Long> userIds = convertSetByFlatMap(list, model -> { |         Set<Long> userIds = convertSetByFlatMap(list, model -> { | ||||||
|             BpmModelMetaInfoVO metaInfo = BpmModelConvert.INSTANCE.parseMetaInfo(model); |             BpmModelMetaInfoVO metaInfo = BpmModelConvert.INSTANCE.parseMetaInfo(model); | ||||||
|             return metaInfo != null ? metaInfo.getStartUserIds().stream() : Stream.empty(); |             return metaInfo != null ? metaInfo.getStartUserIds().stream() : Stream.empty(); | ||||||
|         }); |         }); | ||||||
|         Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds); |         Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds); | ||||||
|         // 获得 Dept Map |  | ||||||
|         Set<Long> deptIds = convertSetByFlatMap(list, model -> { |         Set<Long> deptIds = convertSetByFlatMap(list, model -> { | ||||||
|             BpmModelMetaInfoVO metaInfo = BpmModelConvert.INSTANCE.parseMetaInfo(model); |             BpmModelMetaInfoVO metaInfo = BpmModelConvert.INSTANCE.parseMetaInfo(model); | ||||||
|             return metaInfo != null && metaInfo.getStartDeptIds() != null ? metaInfo.getStartDeptIds().stream() : Stream.empty(); |             return metaInfo != null && metaInfo.getStartDeptIds() != null ? metaInfo.getStartDeptIds().stream() : Stream.empty(); | ||||||
|  | |||||||
| @ -59,7 +59,7 @@ public class BpmModelMetaInfoVO { | |||||||
|     @Schema(description = "可发起用户编号数组", example = "[1,2,3]") |     @Schema(description = "可发起用户编号数组", example = "[1,2,3]") | ||||||
|     private List<Long> startUserIds; |     private List<Long> startUserIds; | ||||||
|  |  | ||||||
|     @Schema(description = "可发起部门编号数组") |     @Schema(description = "可发起部门编号数组", example = "[2,4,6]") | ||||||
|     private List<Long> startDeptIds; |     private List<Long> startDeptIds; | ||||||
|  |  | ||||||
|     @Schema(description = "可管理用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2,4,6]") |     @Schema(description = "可管理用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2,4,6]") | ||||||
|  | |||||||
| @ -76,8 +76,7 @@ public interface BpmModelConvert { | |||||||
|     default BpmModelRespVO buildModel0(Model model, |     default BpmModelRespVO buildModel0(Model model, | ||||||
|                                        BpmModelMetaInfoVO metaInfo, BpmFormDO form, BpmCategoryDO category, |                                        BpmModelMetaInfoVO metaInfo, BpmFormDO form, BpmCategoryDO category, | ||||||
|                                        Deployment deployment, ProcessDefinition processDefinition, |                                        Deployment deployment, ProcessDefinition processDefinition, | ||||||
|                                        List<AdminUserRespDTO> startUsers, |                                        List<AdminUserRespDTO> startUsers, List<DeptRespDTO> startDepts) { | ||||||
|                                        List<DeptRespDTO> startDepts) { |  | ||||||
|         BpmModelRespVO modelRespVO = new BpmModelRespVO().setId(model.getId()).setName(model.getName()) |         BpmModelRespVO modelRespVO = new BpmModelRespVO().setId(model.getId()).setName(model.getName()) | ||||||
|                 .setKey(model.getKey()).setCategory(model.getCategory()) |                 .setKey(model.getKey()).setCategory(model.getCategory()) | ||||||
|                 .setCreateTime(DateUtils.of(model.getCreateTime())); |                 .setCreateTime(DateUtils.of(model.getCreateTime())); | ||||||
| @ -99,10 +98,9 @@ public interface BpmModelConvert { | |||||||
|                 modelRespVO.getProcessDefinition().setDeploymentTime(DateUtils.of(deployment.getDeploymentTime())); |                 modelRespVO.getProcessDefinition().setDeploymentTime(DateUtils.of(deployment.getDeploymentTime())); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         // User |         // User、Dept | ||||||
|         modelRespVO.setStartUsers(BeanUtils.toBean(startUsers, UserSimpleBaseVO.class)); |         modelRespVO.setStartUsers(BeanUtils.toBean(startUsers, UserSimpleBaseVO.class)) | ||||||
|         // Dept |                 .setStartDepts(BeanUtils.toBean(startDepts, DeptSimpleBaseVO.class)); | ||||||
|         modelRespVO.setStartDepts(BeanUtils.toBean(startDepts, DeptSimpleBaseVO.class)); |  | ||||||
|         return modelRespVO; |         return modelRespVO; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
| @ -154,7 +154,7 @@ public class BpmProcessDefinitionInfoDO extends BaseDO { | |||||||
|     /** |     /** | ||||||
|      * 可发起部门编号数组 |      * 可发起部门编号数组 | ||||||
|      * |      * | ||||||
|      * 关联 {@link AdminUserRespDTO#getId()} 字段的数组 |      * 关联 {@link AdminUserRespDTO#getDeptId()} 字段的数组 | ||||||
|      */ |      */ | ||||||
|     @TableField(typeHandler = LongListTypeHandler.class) |     @TableField(typeHandler = LongListTypeHandler.class) | ||||||
|     private List<Long> startDeptIds; |     private List<Long> startDeptIds; | ||||||
|  | |||||||
| @ -51,6 +51,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ | |||||||
|  |  | ||||||
|     @Resource |     @Resource | ||||||
|     private BpmProcessDefinitionInfoMapper processDefinitionMapper; |     private BpmProcessDefinitionInfoMapper processDefinitionMapper; | ||||||
|  |  | ||||||
|     @Resource |     @Resource | ||||||
|     private AdminUserApi adminUserApi; |     private AdminUserApi adminUserApi; | ||||||
|  |  | ||||||
| @ -93,18 +94,17 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ | |||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // 获取用户所在部门 |  | ||||||
|         AdminUserRespDTO user = adminUserApi.getUser(userId); |  | ||||||
|         Long userDeptId = user != null ? user.getDeptId() : null; |  | ||||||
|  |  | ||||||
|         // 校验用户是否在允许发起的用户列表中 |         // 校验用户是否在允许发起的用户列表中 | ||||||
|         if (!CollUtil.isEmpty(processDefinition.getStartUserIds())) { |         if (CollUtil.isNotEmpty(processDefinition.getStartUserIds())) { | ||||||
|             return processDefinition.getStartUserIds().contains(userId); |             return processDefinition.getStartUserIds().contains(userId); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // 校验用户是否在允许发起的部门列表中 |         // 校验用户是否在允许发起的部门列表中 | ||||||
|         if (!CollUtil.isEmpty(processDefinition.getStartDeptIds()) && userDeptId != null) { |         if (CollUtil.isNotEmpty(processDefinition.getStartDeptIds())) { | ||||||
|             return processDefinition.getStartDeptIds().contains(userDeptId); |             AdminUserRespDTO user = adminUserApi.getUser(userId); | ||||||
|  |             return user != null | ||||||
|  |                     && user.getDeptId() != null | ||||||
|  |                     && processDefinition.getStartDeptIds().contains(user.getDeptId()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // 都为空,则所有人都可以发起 |         // 都为空,则所有人都可以发起 | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV