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