diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmUserGroupController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmUserGroupController.java index b2ac618d6..fc97a0112 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmUserGroupController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmUserGroupController.java @@ -7,6 +7,10 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.group.B import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmUserGroupConvert; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmUserGroupDO; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmUserGroupService; +import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.SysUserSimpleRespVO; +import cn.iocoder.yudao.adminserver.modules.system.convert.user.SysUserConvert; +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import io.swagger.annotations.Api; @@ -19,6 +23,8 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; +import java.util.List; + import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Api(tags = "用户组") @@ -71,4 +77,13 @@ public class BpmUserGroupController { return success(BpmUserGroupConvert.INSTANCE.convertPage(pageResult)); } + @GetMapping("/list-all-simple") + @ApiOperation(value = "获取用户组精简信息列表", notes = "只包含被开启的用户组,主要用于前端的下拉选项") + public CommonResult> getSimpleUserGroups() { + // 获用户门列表,只要开启状态的 + List list = userGroupService.getUserGroupListByStatus(CommonStatusEnum.ENABLE.getStatus()); + // 排序后,返回给前端 + return success(BpmUserGroupConvert.INSTANCE.convertList2(list)); + } + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/rule/BpmUserGroupSimpleRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/rule/BpmUserGroupSimpleRespVO.java new file mode 100644 index 000000000..b327bb38d --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/rule/BpmUserGroupSimpleRespVO.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@ApiModel("用户组精简信息 Response VO") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class BpmUserGroupSimpleRespVO { + + @ApiModelProperty(value = "用户组编号", required = true, example = "1024") + private Long id; + + @ApiModelProperty(value = "用户组名字", required = true, example = "芋道") + private String name; + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmUserGroupConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmUserGroupConvert.java index 2b7e2c79a..4e7cd997f 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmUserGroupConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmUserGroupConvert.java @@ -9,6 +9,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmUse import cn.iocoder.yudao.framework.common.pojo.PageResult; import org.mapstruct.Mapper; +import org.mapstruct.Named; import org.mapstruct.factory.Mappers; /** @@ -31,4 +32,6 @@ public interface BpmUserGroupConvert { PageResult convertPage(PageResult page); + @Named("convertList2") + List convertList2(List list); } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmUserGroupMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmUserGroupMapper.java index 9f645f943..192f2600a 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmUserGroupMapper.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmUserGroupMapper.java @@ -7,6 +7,8 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 用户组 Mapper * @@ -23,4 +25,8 @@ public interface BpmUserGroupMapper extends BaseMapperX { .orderByDesc("id")); } + default List selectListByStatus(Integer status) { + return selectList("status", status); + } + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java index 9e539793e..7181d2d3f 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java @@ -54,4 +54,6 @@ public interface BpmErrorCodeConstants { // ========== 用户组模块 1-009-011-000 ========== ErrorCode USER_GROUP_NOT_EXISTS = new ErrorCode(1009011000, "用户组不存在"); + ErrorCode USER_GROUP_IS_DISABLE = new ErrorCode(1009011001, "名字为【{}】的用户组已被禁用"); + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/package-info.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/package-info.java new file mode 100644 index 000000000..eaf54d5dd --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/package-info.java @@ -0,0 +1,7 @@ +/** + * 拓展 {@link org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior} 实现,基于 {@link cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO} 实现自定义的任务分配规则。 + * 原因:BPMN 默认的 assign、candidateUsers、candidateGroups 拓展起来有一定的难度,所以选择放弃它们,使用自己定义的规则。 + * + * @author 芋道源码 + */ +package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/script/BpmTaskAssignScript.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/script/BpmTaskAssignScript.java new file mode 100644 index 000000000..cf3e03519 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/script/BpmTaskAssignScript.java @@ -0,0 +1,26 @@ +package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script; + +import org.activiti.engine.impl.persistence.entity.TaskEntity; + +import java.util.List; + +/** + * Bpm 任务分配的自定义 Script 脚本 + * 使用场景: + * 1. 设置审批人为发起人 + * 2. 设置审批人为发起人的 Leader + * 3. 甚至审批人为发起人的 Leader 的 Leader + * + * @author 芋道源码 + */ +public interface BpmTaskAssignScript { + + /** + * 基于流程任务,获得任务的候选用户们 + * + * @param task 任务 + * @return 候选人用户的编号数组 + */ + List calculateTaskCandidateUsers(TaskEntity task); + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/listener/package-info.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/listener/package-info.java new file mode 100644 index 000000000..1b704ce3f --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/listener/package-info.java @@ -0,0 +1,7 @@ +/** + * 自定义各种 Activiti 的监听器,实现流程示例、流程任务的拓展表信息的同步 + * 例如说,{@link org.activiti.api.task.model.Task} 新建时,我们也要新建对应的 {@link cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmTaskExtDO} 记录 + * + * @author 芋道源码 + */ +package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.listener; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupService.java index b3bfc7395..f1fd4debe 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupService.java @@ -54,6 +54,14 @@ public interface BpmUserGroupService { */ List getUserGroupList(Collection ids); + /** + * 获得指定状态的用户组列表 + * + * @param status 状态 + * @return 用户组列表 + */ + List getUserGroupListByStatus(Integer status); + /** * 获得用户组分页 * @@ -62,4 +70,13 @@ public interface BpmUserGroupService { */ PageResult getUserGroupPage(BpmUserGroupPageReqVO pageReqVO); + /** + * 校验用户组们是否有效。如下情况,视为无效: + * 1. 用户组编号不存在 + * 2. 用户组被禁用 + * + * @param ids 用户组编号数组 + */ + void validUserGroups(Set ids); + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmTaskAssignRuleServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmTaskAssignRuleServiceImpl.java index 9be1af3ea..2e6a7ef9f 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmTaskAssignRuleServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmTaskAssignRuleServiceImpl.java @@ -12,9 +12,15 @@ import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmTaskAssignRu import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmModelService; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService; +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmUserGroupService; +import cn.iocoder.yudao.adminserver.modules.system.enums.SysDictTypeConstants; import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; +import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysPostService; +import cn.iocoder.yudao.adminserver.modules.system.service.dict.SysDictDataService; import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysRoleService; +import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; import lombok.extern.slf4j.Slf4j; import org.activiti.bpmn.model.BpmnModel; @@ -30,6 +36,7 @@ import java.util.Objects; import java.util.Set; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.*; +import static cn.iocoder.yudao.adminserver.modules.system.enums.SysDictTypeConstants.BPM_TASK_ASSIGN_RULE_TYPE; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; /** @@ -53,6 +60,14 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService { private SysRoleService roleService; @Resource private SysDeptService deptService; + @Resource + private SysPostService postService; + @Resource + private SysUserService userService; + @Resource + private BpmUserGroupService userGroupService; + @Resource + private SysDictDataService dictDataService; @Override public List getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId, @@ -146,8 +161,18 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService { } else if (ObjectUtils.equalsAny(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(), BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType())) { deptService.validDepts(options); + } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.POST.getType())) { + postService.validPosts(options); + } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.USER.getType())) { + userService.validUsers(options); + } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.USER_GROUP.getType())) { + userGroupService.validUserGroups(options); + } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.SCRIPT.getType())) { + dictDataService.validDictDatas(SysDictTypeConstants.BPM_TASK_ASSIGN_SCRIPT, + CollectionUtils.convertSet(options, String::valueOf)); + } else { + throw new IllegalArgumentException(StrUtil.format("未知的规则类型({})", type)); } - // TODO 其它的 } } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmUserGroupServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmUserGroupServiceImpl.java index a2eba9858..3e6829081 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmUserGroupServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmUserGroupServiceImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.impl; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.group.BpmUserGroupCreateReqVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.group.BpmUserGroupPageReqVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.group.BpmUserGroupUpdateReqVO; @@ -7,15 +8,23 @@ import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmUserGroupC import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmUserGroupDO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmUserGroupMapper; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmUserGroupService; +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.util.Collection; import java.util.List; +import java.util.Map; +import java.util.Set; +import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.USER_GROUP_IS_DISABLE; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.USER_GROUP_NOT_EXISTS; +import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.USER_IS_DISABLE; +import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.USER_NOT_EXISTS; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; /** @@ -72,9 +81,34 @@ public class BpmUserGroupServiceImpl implements BpmUserGroupService { return userGroupMapper.selectBatchIds(ids); } + @Override + public List getUserGroupListByStatus(Integer status) { + return userGroupMapper.selectListByStatus(status); + } + @Override public PageResult getUserGroupPage(BpmUserGroupPageReqVO pageReqVO) { return userGroupMapper.selectPage(pageReqVO); } + @Override + public void validUserGroups(Set ids) { + if (CollUtil.isEmpty(ids)) { + return; + } + // 获得用户组信息 + List userGroups = userGroupMapper.selectBatchIds(ids); + Map userGroupMap = CollectionUtils.convertMap(userGroups, BpmUserGroupDO::getId); + // 校验 + ids.forEach(id -> { + BpmUserGroupDO userGroup = userGroupMap.get(id); + if (userGroup == null) { + throw exception(USER_GROUP_NOT_EXISTS); + } + if (!CommonStatusEnum.ENABLE.getStatus().equals(userGroup.getStatus())) { + throw exception(USER_GROUP_IS_DISABLE, userGroup.getName()); + } + }); + } + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/mysql/dict/SysDictDataMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/mysql/dict/SysDictDataMapper.java index ad63bf624..cc1046344 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/mysql/dict/SysDictDataMapper.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/dal/mysql/dict/SysDictDataMapper.java @@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.ibatis.annotations.Mapper; +import java.util.Collection; import java.util.Date; import java.util.List; @@ -20,6 +21,11 @@ public interface SysDictDataMapper extends BaseMapperX { .eq("value", value)); } + default List selectByDictTypeAndValues(String dictType, Collection values) { + return selectList(new QueryWrapper().eq("dict_type", dictType) + .in("value", values)); + } + default int selectCountByDictType(String dictType) { return selectCount("dict_type", dictType); } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysDictTypeConstants.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysDictTypeConstants.java index 64c1b5e81..2a1dece7f 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysDictTypeConstants.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysDictTypeConstants.java @@ -22,4 +22,7 @@ public interface SysDictTypeConstants { String SMS_SEND_STATUS = "sys_sms_send_status"; // 短信发送状态 String SMS_RECEIVE_STATUS = "sys_sms_receive_status"; // 短信接收状态 + String BPM_TASK_ASSIGN_RULE_TYPE = "bpm_task_assign_rule_type"; // 任务分配规则类型 + String BPM_TASK_ASSIGN_SCRIPT = "bpm_task_assign_script"; // 任务分配自定义脚本 + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysErrorCodeConstants.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysErrorCodeConstants.java index b7576c344..867f8e359 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysErrorCodeConstants.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/enums/SysErrorCodeConstants.java @@ -40,6 +40,7 @@ public interface SysErrorCodeConstants { ErrorCode USER_NOT_EXISTS = new ErrorCode(1002004003, "用户不存在"); ErrorCode USER_IMPORT_LIST_IS_EMPTY = new ErrorCode(1002004004, "导入用户数据不能为空!"); ErrorCode USER_PASSWORD_FAILED = new ErrorCode(1002004005, "用户密码校验失败"); + ErrorCode USER_IS_DISABLE = new ErrorCode(1002003004, "名字为【{}】的用户已被禁用"); // ========== 部门模块 1002005000 ========== ErrorCode DEPT_NAME_DUPLICATE = new ErrorCode(1002004001, "已经存在该名字的部门"); @@ -66,7 +67,7 @@ public interface SysErrorCodeConstants { // ========== 字典数据 1002007000 ========== ErrorCode DICT_DATA_NOT_EXISTS = new ErrorCode(1002007001, "当前字典数据不存在"); - ErrorCode DICT_DATA_NOT_ENABLE = new ErrorCode(1002007002, "字典数据不处于开启状态,不允许选择"); + ErrorCode DICT_DATA_NOT_ENABLE = new ErrorCode(1002007002, "字典数据({})不处于开启状态,不允许选择"); ErrorCode DICT_DATA_VALUE_DUPLICATE = new ErrorCode(1002007003, "已经存在该值的字典数据"); // ========== 通知公告 1002008000 ========== diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dept/SysPostService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dept/SysPostService.java index d9a0db748..608e360b2 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dept/SysPostService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dept/SysPostService.java @@ -86,4 +86,13 @@ public interface SysPostService { */ SysPostDO getPost(Long id); + /** + * 校验岗位们是否有效。如下情况,视为无效: + * 1. 岗位编号不存在 + * 2. 岗位被禁用 + * + * @param ids 岗位编号数组 + */ + void validPosts(Collection ids); + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dept/impl/SysPostServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dept/impl/SysPostServiceImpl.java index 032e59ae9..220724e33 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dept/impl/SysPostServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dept/impl/SysPostServiceImpl.java @@ -1,5 +1,8 @@ package cn.iocoder.yudao.adminserver.modules.system.service.dept.impl; +import cn.hutool.core.collection.CollUtil; +import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.adminserver.modules.system.controller.dept.vo.post.SysPostCreateReqVO; @@ -10,14 +13,17 @@ import cn.iocoder.yudao.adminserver.modules.system.convert.dept.SysPostConvert; import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.dept.SysPostMapper; import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysPostDO; import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysPostService; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.util.Collection; import java.util.List; +import java.util.Map; import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; /** * 岗位 Service 实现类 @@ -78,6 +84,26 @@ public class SysPostServiceImpl implements SysPostService { return postMapper.selectById(id); } + @Override + public void validPosts(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return; + } + // 获得岗位信息 + List posts = postMapper.selectBatchIds(ids); + Map postMap = CollectionUtils.convertMap(posts, SysPostDO::getId); + // 校验 + ids.forEach(id -> { + SysPostDO post = postMap.get(id); + if (post == null) { + throw exception(POST_NOT_FOUND); + } + if (!CommonStatusEnum.ENABLE.getStatus().equals(post.getStatus())) { + throw exception(POST_NOT_ENABLE, post.getName()); + } + }); + } + private void checkCreateOrUpdate(Long id, String name, String code) { // 校验自己存在 checkPostExists(id); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dict/SysDictDataService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dict/SysDictDataService.java index e1efea03d..7fd19f4e9 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dict/SysDictDataService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dict/SysDictDataService.java @@ -8,6 +8,7 @@ import cn.iocoder.yudao.adminserver.modules.system.controller.dict.vo.data.SysDi import cn.iocoder.yudao.adminserver.modules.system.controller.dict.vo.data.SysDictDataPageReqVO; import cn.iocoder.yudao.adminserver.modules.system.controller.dict.vo.data.SysDictDataUpdateReqVO; +import java.util.Collection; import java.util.List; /** @@ -78,4 +79,14 @@ public interface SysDictDataService { */ int countByDictType(String dictType); + /** + * 校验字典数据们是否有效。如下情况,视为无效: + * 1. 字典数据不存在 + * 2. 字典数据被禁用 + * + * @param dictType 字典类型 + * @param values 字典数据值的数组 + */ + void validDictDatas(String dictType, Collection values); + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dict/impl/SysDictDataServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dict/impl/SysDictDataServiceImpl.java index 88fb99966..60fb10332 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dict/impl/SysDictDataServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/dict/impl/SysDictDataServiceImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.adminserver.modules.system.service.dict.impl; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.adminserver.modules.system.controller.dict.vo.data.SysDictDataCreateReqVO; import cn.iocoder.yudao.adminserver.modules.system.controller.dict.vo.data.SysDictDataExportReqVO; import cn.iocoder.yudao.adminserver.modules.system.controller.dict.vo.data.SysDictDataPageReqVO; @@ -11,16 +12,16 @@ import cn.iocoder.yudao.adminserver.modules.system.mq.producer.dict.SysDictDataP import cn.iocoder.yudao.adminserver.modules.system.service.dict.SysDictDataService; import cn.iocoder.yudao.adminserver.modules.system.service.dict.SysDictTypeService; import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dict.SysDictDataDO; +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import com.google.common.annotations.VisibleForTesting; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.Comparator; -import java.util.Date; -import java.util.List; +import java.util.*; import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.*; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -133,6 +134,26 @@ public class SysDictDataServiceImpl implements SysDictDataService { return dictDataMapper.selectCountByDictType(dictType); } + @Override + public void validDictDatas(String dictType, Collection values) { + if (CollUtil.isEmpty(values)) { + return; + } + // 获得字典数据信息 + List dictDatas = dictDataMapper.selectByDictTypeAndValues(dictType, values); + Map dictDataMap = CollectionUtils.convertMap(dictDatas, SysDictDataDO::getValue); + // 校验 + values.forEach(value -> { + SysDictDataDO dictData = dictDataMap.get(value); + if (dictData == null) { + throw exception(DICT_DATA_NOT_EXISTS); + } + if (!CommonStatusEnum.ENABLE.getStatus().equals(dictData.getStatus())) { + throw exception(DICT_DATA_NOT_ENABLE, dictData.getLabel()); + } + }); + } + private void checkCreateOrUpdate(Long id, String value, String dictType) { // 校验自己存在 checkDictDataExists(id); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/SysUserService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/SysUserService.java index b237bc2c3..10fef200e 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/SysUserService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/SysUserService.java @@ -9,10 +9,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import java.io.InputStream; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 后台用户 Service 接口 @@ -177,4 +174,13 @@ public interface SysUserService { */ List getUsersByStatus(Integer status); + /** + * 校验用户们是否有效。如下情况,视为无效: + * 1. 用户编号不存在 + * 2. 用户被禁用 + * + * @param ids 用户编号数组 + */ + void validUsers(Set ids); + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/impl/SysUserServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/impl/SysUserServiceImpl.java index 8b868ce1d..3b7fe1c10 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/impl/SysUserServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/user/impl/SysUserServiceImpl.java @@ -182,6 +182,11 @@ public class SysUserServiceImpl implements SysUserService { return userMapper.selectBatchIds(ids); } + @Override + public Map getUserMap(Collection ids) { + return SysUserService.super.getUserMap(ids); + } + @Override public List getUsersByNickname(String nickname) { return userMapper.selectListByNickname(nickname); @@ -384,4 +389,24 @@ public class SysUserServiceImpl implements SysUserService { return userMapper.selectListByStatus(status); } + @Override + public void validUsers(Set ids) { + if (CollUtil.isEmpty(ids)) { + return; + } + // 获得岗位信息 + List users = userMapper.selectBatchIds(ids); + Map userMap = CollectionUtils.convertMap(users, SysUserDO::getId); + // 校验 + ids.forEach(id -> { + SysUserDO user = userMap.get(id); + if (user == null) { + throw exception(USER_NOT_EXISTS); + } + if (!CommonStatusEnum.ENABLE.getStatus().equals(user.getStatus())) { + throw exception(USER_IS_DISABLE, user.getNickname()); + } + }); + } + } diff --git a/yudao-admin-ui/src/api/bpm/userGroup.js b/yudao-admin-ui/src/api/bpm/userGroup.js index cd0a01ede..251baff0f 100644 --- a/yudao-admin-ui/src/api/bpm/userGroup.js +++ b/yudao-admin-ui/src/api/bpm/userGroup.js @@ -42,3 +42,11 @@ export function getUserGroupPage(query) { params: query }) } + +// 获取用户组精简信息列表 +export function listSimpleUserGroups() { + return request({ + url: '/bpm/user-group/list-all-simple', + method: 'get' + }) +} diff --git a/yudao-admin-ui/src/utils/dict.js b/yudao-admin-ui/src/utils/dict.js index 32f32986d..815a98d65 100644 --- a/yudao-admin-ui/src/utils/dict.js +++ b/yudao-admin-ui/src/utils/dict.js @@ -40,6 +40,7 @@ export const DICT_TYPE = { BPM_TASK_ASSIGN_RULE_TYPE: 'bpm_task_assign_rule_type', BPM_PROCESS_INSTANCE_STATUS: 'bpm_process_instance_status', BPM_PROCESS_INSTANCE_RESULT: 'bpm_process_instance_result', + BPM_TASK_ASSIGN_SCRIPT: 'bpm_task_assign_script', OA_LEAVE_STATUS: 'flow_status', // todo 芋艿:可以删除 OA_LEAVE_TYPE: 'oa_leave_type' } @@ -51,6 +52,10 @@ export const DICT_TYPE = { * @returns {*|Array} 数据字典数组 */ export function getDictDatas(dictType) { + // if (dictType === 'bpm_task_assign_script') { + // console.log(store.getters.dict_datas[dictType]); + // debugger + // } return store.getters.dict_datas[dictType] || [] } diff --git a/yudao-admin-ui/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue b/yudao-admin-ui/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue index 94387f5df..654a2390e 100644 --- a/yudao-admin-ui/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue +++ b/yudao-admin-ui/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue @@ -37,7 +37,7 @@ - + @@ -49,6 +49,27 @@ + + + + + + + + + + + + + + + + + + + +