mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2026-03-22 10:47:17 +08:00
update 升级 warm-flow 1.6.7 同步vue版本按钮权限相关代码
This commit is contained in:
@@ -103,6 +103,11 @@ public class SysUserBo extends BaseEntity {
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String userIds;
|
||||
|
||||
/**
|
||||
* 排除不查询的用户(工作流用)
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,9 @@ import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.system.api.RemoteDictService;
|
||||
import org.dromara.system.api.domain.vo.RemoteDictDataVo;
|
||||
import org.dromara.system.api.domain.vo.RemoteDictTypeVo;
|
||||
import org.dromara.system.domain.vo.SysDictDataVo;
|
||||
import org.dromara.system.domain.vo.SysDictTypeVo;
|
||||
import org.dromara.system.service.ISysDictTypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -23,6 +25,12 @@ public class RemoteDictServiceImpl implements RemoteDictService {
|
||||
|
||||
private final ISysDictTypeService sysDictTypeService;
|
||||
|
||||
@Override
|
||||
public RemoteDictTypeVo selectDictTypeByType(String dictType) {
|
||||
SysDictTypeVo vo = sysDictTypeService.selectDictTypeByType(dictType);
|
||||
return MapstructUtils.convert(vo, RemoteDictTypeVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
*
|
||||
|
||||
@@ -15,11 +15,17 @@ import java.util.List;
|
||||
*/
|
||||
public interface ISysUserService {
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @param pageQuery 发呢也
|
||||
* @return 用户信息
|
||||
*/
|
||||
TableDataInfo<SysUserVo> selectPageUserList(SysUserBo user, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
* 导出用户列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
|
||||
@@ -117,6 +117,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService {
|
||||
* @param dictType 字典类型
|
||||
* @return 字典类型
|
||||
*/
|
||||
@Cacheable(cacheNames = CacheNames.SYS_DICT_TYPE, key = "#dictType")
|
||||
@Override
|
||||
public SysDictTypeVo selectDictTypeByType(String dictType) {
|
||||
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType));
|
||||
@@ -136,6 +137,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService {
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
|
||||
}
|
||||
CacheUtils.evict(CacheNames.SYS_DICT, dictType.getDictType());
|
||||
CacheUtils.evict(CacheNames.SYS_DICT_TYPE, dictType.getDictType());
|
||||
}
|
||||
baseMapper.deleteByIds(Arrays.asList(dictIds));
|
||||
}
|
||||
@@ -146,6 +148,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService {
|
||||
@Override
|
||||
public void resetDictCache() {
|
||||
CacheUtils.clear(CacheNames.SYS_DICT);
|
||||
CacheUtils.clear(CacheNames.SYS_DICT_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,6 +75,7 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||
QueryWrapper<SysUser> wrapper = Wrappers.query();
|
||||
wrapper.eq("u.del_flag", SystemConstants.NORMAL)
|
||||
.eq(ObjectUtil.isNotNull(user.getUserId()), "u.user_id", user.getUserId())
|
||||
.in(StringUtils.isNotBlank(user.getUserIds()), "u.user_id", StringUtils.splitTo(user.getUserIds(), Convert::toLong))
|
||||
.like(StringUtils.isNotBlank(user.getUserName()), "u.user_name", user.getUserName())
|
||||
.eq(StringUtils.isNotBlank(user.getStatus()), "u.status", user.getStatus())
|
||||
.like(StringUtils.isNotBlank(user.getPhonenumber()), "u.phonenumber", user.getPhonenumber())
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.dromara.workflow.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 按钮权限枚举
|
||||
*
|
||||
* @author AprilWind
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ButtonPermissionEnum implements NodeExtEnum {
|
||||
|
||||
/**
|
||||
* 是否弹窗选人
|
||||
*/
|
||||
POP("是否弹窗选人", "pop", false),
|
||||
|
||||
/**
|
||||
* 是否能委托
|
||||
*/
|
||||
TRUST("是否能委托", "trust", false),
|
||||
|
||||
/**
|
||||
* 是否能转办
|
||||
*/
|
||||
TRANSFER("是否能转办", "transfer", false),
|
||||
|
||||
/**
|
||||
* 是否能抄送
|
||||
*/
|
||||
COPY("是否能抄送", "copy", false),
|
||||
|
||||
/**
|
||||
* 是否显示退回
|
||||
*/
|
||||
BACK("是否显示退回", "back", true),
|
||||
|
||||
/**
|
||||
* 是否能加签
|
||||
*/
|
||||
ADD_SIGN("是否能加签", "addSign", false),
|
||||
|
||||
/**
|
||||
* 是否能减签
|
||||
*/
|
||||
SUB_SIGN("是否能减签", "subSign", false),
|
||||
|
||||
/**
|
||||
* 是否能终止
|
||||
*/
|
||||
TERMINATION("是否能终止", "termination", true);
|
||||
|
||||
private final String label;
|
||||
private final String value;
|
||||
private final boolean selected;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.dromara.workflow.common.enums;
|
||||
|
||||
/**
|
||||
* 节点扩展属性枚举
|
||||
*
|
||||
* @author AprilWind
|
||||
*/
|
||||
public interface NodeExtEnum {
|
||||
|
||||
/**
|
||||
* 选项label
|
||||
*
|
||||
* @return 选项label
|
||||
*/
|
||||
String getLabel();
|
||||
|
||||
/**
|
||||
* 选项值
|
||||
*
|
||||
* @return 选项值
|
||||
*/
|
||||
String getValue();
|
||||
|
||||
/**
|
||||
* 是否默认选中
|
||||
*
|
||||
* @return 是否默认选中
|
||||
*/
|
||||
boolean isSelected();
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.system.api.domain.vo.RemoteUserVo;
|
||||
import org.dromara.warm.flow.core.entity.Node;
|
||||
import org.dromara.warm.flow.orm.entity.FlowNode;
|
||||
import org.dromara.workflow.api.domain.RemoteStartProcessReturn;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.domain.bo.*;
|
||||
@@ -127,6 +128,16 @@ public class FlwTaskController extends BaseController {
|
||||
return R.ok(flwTaskService.selectById(taskId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一节点信息
|
||||
*
|
||||
* @param bo 参数
|
||||
*/
|
||||
@PostMapping("/getNextNodeList")
|
||||
public R<List<FlowNode>> getNextNodeList(@RequestBody FlowNextNodeBo bo) {
|
||||
return R.ok(flwTaskService.getNextNodeList(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 终止任务
|
||||
*
|
||||
|
||||
@@ -58,6 +58,11 @@ public class CompleteTaskBo implements Serializable {
|
||||
*/
|
||||
private Map<String, Object> variables;
|
||||
|
||||
/**
|
||||
* 弹窗选择的办理人
|
||||
*/
|
||||
private Map<String, Object> assigneeMap;
|
||||
|
||||
/**
|
||||
* 扩展变量(此处为逗号分隔的ossId)
|
||||
* @return
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.dromara.workflow.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 下一节点信息
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
@Data
|
||||
public class FlowNextNodeBo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
private String taskId;
|
||||
|
||||
/**
|
||||
* 流程变量
|
||||
*/
|
||||
private Map<String, Object> variables;
|
||||
|
||||
public Map<String, Object> getVariables() {
|
||||
if (variables == null) {
|
||||
return new HashMap<>(16);
|
||||
}
|
||||
variables.entrySet().removeIf(entry -> Objects.isNull(entry.getValue()));
|
||||
return variables;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.dromara.workflow.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 按钮权限
|
||||
*
|
||||
* @author may
|
||||
* @date 2025-02-28
|
||||
*/
|
||||
@Data
|
||||
public class ButtonPermission implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 枚举路径
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 按钮编码
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 是否显示
|
||||
*/
|
||||
private boolean show;
|
||||
}
|
||||
@@ -1,16 +1,20 @@
|
||||
package org.dromara.workflow.domain.vo;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.translation.annotation.Translation;
|
||||
import org.dromara.common.translation.constant.TransConstant;
|
||||
import org.dromara.warm.flow.core.entity.User;
|
||||
import org.dromara.workflow.common.constant.FlowConstant;
|
||||
import org.dromara.workflow.common.enums.ButtonPermissionEnum;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 任务视图
|
||||
@@ -173,4 +177,41 @@ public class FlowTaskVo implements Serializable {
|
||||
*/
|
||||
@Translation(type = TransConstant.USER_ID_TO_NICKNAME, mapper = "createBy")
|
||||
private String createByName;
|
||||
|
||||
/**
|
||||
* 是否为申请人节点
|
||||
*/
|
||||
private boolean applyNode;
|
||||
|
||||
/**
|
||||
* 按钮权限
|
||||
*/
|
||||
private List<ButtonPermission> buttonList;
|
||||
|
||||
public List<ButtonPermission> getButtonList(String ext) {
|
||||
List<ButtonPermission> buttonPermissions = Arrays.stream(ButtonPermissionEnum.values())
|
||||
.map(value -> {
|
||||
ButtonPermission buttonPermission = new ButtonPermission();
|
||||
buttonPermission.setCode(value.getValue());
|
||||
buttonPermission.setShow(false);
|
||||
return buttonPermission;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
if (StringUtils.isNotBlank(ext)) {
|
||||
List<ButtonPermission> buttonCodeList = JSONUtil.toList(JSONUtil.parseArray(ext), ButtonPermission.class);
|
||||
if (CollUtil.isNotEmpty(buttonCodeList)) {
|
||||
Optional<ButtonPermission> firstPermission = buttonCodeList.stream().findFirst();
|
||||
firstPermission.ifPresent(permission -> {
|
||||
Set<String> codeSet = Arrays.stream(permission.getValue().split(","))
|
||||
.map(String::trim)
|
||||
.filter(code -> !code.isEmpty())
|
||||
.collect(Collectors.toSet());
|
||||
buttonPermissions.forEach(bp -> bp.setShow(codeSet.contains(bp.getCode())));
|
||||
});
|
||||
}
|
||||
}
|
||||
return buttonPermissions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,15 @@ public interface IFlwCommonService {
|
||||
*/
|
||||
Set<User> buildUser(List<User> userList, Long taskId);
|
||||
|
||||
/**
|
||||
* 构建工作流用户
|
||||
*
|
||||
* @param userIdList 办理用户
|
||||
* @param taskId 任务ID
|
||||
* @return 用户
|
||||
*/
|
||||
Set<User> buildFlowUser(List<String> userIdList, Long taskId);
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.system.api.domain.vo.RemoteUserVo;
|
||||
import org.dromara.warm.flow.core.entity.Node;
|
||||
import org.dromara.warm.flow.orm.entity.FlowHisTask;
|
||||
import org.dromara.warm.flow.orm.entity.FlowNode;
|
||||
import org.dromara.warm.flow.orm.entity.FlowTask;
|
||||
import org.dromara.workflow.api.domain.RemoteStartProcessReturn;
|
||||
import org.dromara.workflow.domain.bo.*;
|
||||
@@ -132,6 +133,14 @@ public interface IFlwTaskService {
|
||||
*/
|
||||
FlowTaskVo selectById(Long taskId);
|
||||
|
||||
/**
|
||||
* 获取下一节点信息
|
||||
*
|
||||
* @param bo 参数
|
||||
* @return 结果
|
||||
*/
|
||||
List<FlowNode> getNextNodeList(FlowNextNodeBo bo);
|
||||
|
||||
/**
|
||||
* 按照任务id查询任务
|
||||
*
|
||||
@@ -188,4 +197,14 @@ public interface IFlwTaskService {
|
||||
* @return 结果
|
||||
*/
|
||||
List<RemoteUserVo> currentTaskAllUser(Long taskId);
|
||||
|
||||
/**
|
||||
* 按照节点编码查询节点
|
||||
*
|
||||
* @param nodeCode 节点编码
|
||||
* @param definitionId 流程定义id
|
||||
* @return 节点
|
||||
*/
|
||||
FlowNode getByNodeCode(String nodeCode, Long definitionId);
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.dromara.warm.flow.orm.mapper.FlowNodeMapper;
|
||||
import org.dromara.warm.flow.orm.mapper.FlowTaskMapper;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.common.enums.MessageTypeEnum;
|
||||
import org.dromara.workflow.common.enums.TaskAssigneeType;
|
||||
import org.dromara.workflow.service.IFlwCommonService;
|
||||
import org.dromara.workflow.service.IFlwTaskAssigneeService;
|
||||
import org.dromara.workflow.service.IFlwTaskService;
|
||||
@@ -108,6 +109,33 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建工作流用户
|
||||
*
|
||||
* @param userIdList 办理用户
|
||||
* @param taskId 任务ID
|
||||
* @return 用户
|
||||
*/
|
||||
@Override
|
||||
public Set<User> buildFlowUser(List<String> userIdList, Long taskId) {
|
||||
if (CollUtil.isEmpty(userIdList)) {
|
||||
return Set.of();
|
||||
}
|
||||
Set<User> list = new HashSet<>();
|
||||
Set<String> processedBySet = new HashSet<>();
|
||||
for (String userId : userIdList) {
|
||||
if (!processedBySet.contains(userId)) {
|
||||
FlowUser flowUser = new FlowUser();
|
||||
flowUser.setType(TaskAssigneeType.APPROVER.getCode());
|
||||
flowUser.setProcessedBy(String.valueOf(userId));
|
||||
flowUser.setAssociated(taskId);
|
||||
list.add(flowUser);
|
||||
processedBySet.add(String.valueOf(userId));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
|
||||
@@ -374,6 +374,7 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
|
||||
Instance instance = insService.getById(instanceId);
|
||||
if (instance != null) {
|
||||
taskService.mergeVariable(instance, variable);
|
||||
insService.updateById(instance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
package org.dromara.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.system.api.RemoteDictService;
|
||||
import org.dromara.system.api.domain.vo.RemoteDictTypeVo;
|
||||
import org.dromara.warm.flow.ui.service.NodeExtService;
|
||||
import org.dromara.warm.flow.ui.vo.NodeExt;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.common.enums.ButtonPermissionEnum;
|
||||
import org.dromara.workflow.common.enums.NodeExtEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 流程设计器-节点扩展属性
|
||||
*
|
||||
* @author AprilWind
|
||||
*/
|
||||
@ConditionalOnEnable
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class FlwNodeExtServiceImpl implements NodeExtService {
|
||||
|
||||
/**
|
||||
* 权限页code
|
||||
*/
|
||||
private static final String PERMISSION_TAB = "wf_button_tab";
|
||||
|
||||
/**
|
||||
* 权限页名称
|
||||
*/
|
||||
private static final String PERMISSION_TAB_NAME = "权限";
|
||||
|
||||
/**
|
||||
* 枚举类型标识
|
||||
*/
|
||||
private static final String ENUM_TYPE_PREFIX = "enum:";
|
||||
|
||||
/**
|
||||
* 基础设置
|
||||
*/
|
||||
private static final int TYPE_BASE_SETTING = 1;
|
||||
|
||||
/**
|
||||
* 新页签
|
||||
*/
|
||||
private static final int TYPE_NEW_TAB = 2;
|
||||
|
||||
/**
|
||||
* 存储不同 dictType 对应的配置信息
|
||||
*/
|
||||
private static final Map<String, Map<String, Object>> CHILD_NODE_MAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
CHILD_NODE_MAP.put(ButtonPermissionEnum.class.getName(),
|
||||
Map.of("label", "权限按钮", "type", 4, "must", false, "multiple", true));
|
||||
}
|
||||
|
||||
@DubboReference
|
||||
private RemoteDictService remoteDictService;
|
||||
|
||||
/**
|
||||
* 获取节点扩展属性
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public List<NodeExt> getNodeExt() {
|
||||
List<NodeExt> nodeExtList = new ArrayList<>();
|
||||
// 构建按钮权限页面
|
||||
nodeExtList.add(buildNodeExt(PERMISSION_TAB, PERMISSION_TAB_NAME, TYPE_NEW_TAB,
|
||||
ENUM_TYPE_PREFIX + ButtonPermissionEnum.class.getName()));
|
||||
return nodeExtList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建一个 NodeExt 对象
|
||||
*
|
||||
* @param code 编码,此json中唯一
|
||||
* @param name 名称,如果type为新页签时,作为页签名称
|
||||
* @param type 节点类型,1:基础设置,2:新页签
|
||||
* @param sourceTypes 字典/枚举类型来源(逗号分隔)
|
||||
* @return 返回构建好的 NodeExt 对象
|
||||
*/
|
||||
private NodeExt buildNodeExt(String code, String name, int type, String sourceTypes) {
|
||||
NodeExt nodeExt = new NodeExt();
|
||||
nodeExt.setCode(code);
|
||||
nodeExt.setType(type);
|
||||
nodeExt.setName(name);
|
||||
nodeExt.setChilds(StringUtils.splitList(sourceTypes)
|
||||
.stream().map(this::buildChildNode)
|
||||
.filter(ObjectUtil::isNotNull)
|
||||
.toList()
|
||||
);
|
||||
return nodeExt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建一个 ChildNode 对象
|
||||
*
|
||||
* @param sourceType 字典类型
|
||||
* @return 返回构建好的 ChildNode 对象
|
||||
*/
|
||||
private NodeExt.ChildNode buildChildNode(String sourceType) {
|
||||
return sourceType.startsWith(ENUM_TYPE_PREFIX) ?
|
||||
buildChildNodeFromEnum(sourceType.substring(ENUM_TYPE_PREFIX.length())) : buildChildNodeFromDict(sourceType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据枚举构建一个 ChildNode 对象
|
||||
*
|
||||
* @param enumClassName 枚举名称
|
||||
* @return 返回构建好的 ChildNode 对象
|
||||
*/
|
||||
private NodeExt.ChildNode buildChildNodeFromEnum(String enumClassName) {
|
||||
try {
|
||||
Class<?> enumClass = Class.forName(enumClassName);
|
||||
if (!enumClass.isEnum()) {
|
||||
return null;
|
||||
}
|
||||
NodeExt.ChildNode childNode = buildChildNodeMap(enumClassName);
|
||||
// 编码,此json中唯
|
||||
childNode.setCode(ENUM_TYPE_PREFIX + enumClassName);
|
||||
// 字典,下拉框和复选框时用到
|
||||
childNode.setDict(Arrays.stream(enumClass.getEnumConstants())
|
||||
.filter(NodeExtEnum.class::isInstance)
|
||||
.map(NodeExtEnum.class::cast)
|
||||
.map(x ->
|
||||
new NodeExt.DictItem(x.getLabel(), x.getValue(), x.isSelected())
|
||||
).toList());
|
||||
return childNode;
|
||||
} catch (ClassNotFoundException e) {
|
||||
log.error("Enum class not found: {}", enumClassName, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典构建一个 ChildNode 对象
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 返回构建好的 ChildNode 对象
|
||||
*/
|
||||
private NodeExt.ChildNode buildChildNodeFromDict(String dictType) {
|
||||
RemoteDictTypeVo dictTypeDTO = remoteDictService.selectDictTypeByType(dictType);
|
||||
if (ObjectUtil.isNull(dictTypeDTO)) {
|
||||
return null;
|
||||
}
|
||||
NodeExt.ChildNode childNode = buildChildNodeMap(dictType);
|
||||
// 编码,此json中唯一
|
||||
childNode.setCode(dictType);
|
||||
// label名称
|
||||
childNode.setLabel(dictTypeDTO.getDictName());
|
||||
// 描述
|
||||
childNode.setDesc(dictTypeDTO.getRemark());
|
||||
// 字典,下拉框和复选框时用到
|
||||
childNode.setDict(remoteDictService.selectDictDataByType(dictType)
|
||||
.stream().map(x ->
|
||||
new NodeExt.DictItem(x.getDictLabel(), x.getDictValue(), Convert.toBool(x.getIsDefault(), false))
|
||||
).toList());
|
||||
return childNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 CHILD_NODE_MAP 中的配置信息,构建一个基本的 ChildNode 对象
|
||||
* 该方法用于设置 ChildNode 的常规属性,例如 label、type、是否必填、是否多选等
|
||||
*
|
||||
* @param key CHILD_NODE_MAP 的 key
|
||||
* @return 返回构建好的 ChildNode 对象
|
||||
*/
|
||||
private NodeExt.ChildNode buildChildNodeMap(String key) {
|
||||
NodeExt.ChildNode childNode = new NodeExt.ChildNode();
|
||||
Map<String, Object> map = CHILD_NODE_MAP.get(key);
|
||||
// label名称
|
||||
childNode.setLabel((String) map.get("label"));
|
||||
// 1:输入框 2:输入框 3:下拉框 4:选择框
|
||||
childNode.setType(Convert.toInt(map.get("type"), 1));
|
||||
// 是否必填
|
||||
childNode.setMust(Convert.toBool(map.get("must"), false));
|
||||
// 是否多选
|
||||
childNode.setMultiple(Convert.toBool(map.get("multiple"), true));
|
||||
return childNode;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,9 +30,12 @@ import org.dromara.warm.flow.core.entity.*;
|
||||
import org.dromara.warm.flow.core.enums.NodeType;
|
||||
import org.dromara.warm.flow.core.enums.SkipType;
|
||||
import org.dromara.warm.flow.core.service.*;
|
||||
import org.dromara.warm.flow.core.utils.ExpressionUtil;
|
||||
import org.dromara.warm.flow.core.utils.MapUtil;
|
||||
import org.dromara.warm.flow.orm.entity.*;
|
||||
import org.dromara.warm.flow.orm.mapper.FlowHisTaskMapper;
|
||||
import org.dromara.warm.flow.orm.mapper.FlowInstanceMapper;
|
||||
import org.dromara.warm.flow.orm.mapper.FlowNodeMapper;
|
||||
import org.dromara.warm.flow.orm.mapper.FlowTaskMapper;
|
||||
import org.dromara.workflow.api.domain.RemoteStartProcessReturn;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
@@ -46,6 +49,7 @@ import org.dromara.workflow.handler.WorkflowPermissionHandler;
|
||||
import org.dromara.workflow.mapper.FlwCategoryMapper;
|
||||
import org.dromara.workflow.mapper.FlwTaskMapper;
|
||||
import org.dromara.workflow.service.IFlwCommonService;
|
||||
import org.dromara.workflow.service.IFlwTaskAssigneeService;
|
||||
import org.dromara.workflow.service.IFlwTaskService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -79,6 +83,8 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
private final FlowProcessEventHandler flowProcessEventHandler;
|
||||
private final FlwTaskMapper flwTaskMapper;
|
||||
private final FlwCategoryMapper flwCategoryMapper;
|
||||
private final FlowNodeMapper flowNodeMapper;
|
||||
private final IFlwTaskAssigneeService flwTaskAssigneeService;
|
||||
private final IFlwCommonService flwCommonService;
|
||||
|
||||
@DubboReference
|
||||
@@ -107,6 +113,8 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
if (ObjectUtil.isNotNull(flowInstance)) {
|
||||
BusinessStatusEnum.checkStartStatus(flowInstance.getFlowStatus());
|
||||
List<Task> taskList = taskService.list(new FlowTask().setInstanceId(flowInstance.getId()));
|
||||
taskService.mergeVariable(flowInstance, variables);
|
||||
insService.updateById(flowInstance);
|
||||
RemoteStartProcessReturn dto = new RemoteStartProcessReturn();
|
||||
dto.setProcessInstanceId(taskList.get(0).getInstanceId());
|
||||
dto.setTaskId(taskList.get(0).getId());
|
||||
@@ -159,6 +167,11 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
if (BusinessStatusEnum.isDraftOrCancelOrBack(ins.getFlowStatus())) {
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), ins.getBusinessId(), ins.getFlowStatus(), null, true);
|
||||
}
|
||||
// 设置弹窗处理人
|
||||
Map<String, Object> assigneeMap = setPopAssigneeMap(completeTaskBo.getAssigneeMap(), ins.getVariableMap());
|
||||
if (CollUtil.isNotEmpty(assigneeMap)) {
|
||||
completeTaskBo.getVariables().putAll(assigneeMap);
|
||||
}
|
||||
// 构建流程参数,包括变量、跳转类型、消息、处理人、权限等信息
|
||||
FlowParams flowParams = new FlowParams();
|
||||
flowParams.variable(completeTaskBo.getVariables());
|
||||
@@ -172,6 +185,8 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
this.setHandler(instance, flowTask, flowCopyList);
|
||||
// 消息通知
|
||||
flwCommonService.sendMessage(definition.getFlowName(), ins.getId(), messageType, notice);
|
||||
//设置下一环节处理人
|
||||
setNextHandler(ins.getId());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
@@ -179,6 +194,60 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置下一环节处理人
|
||||
*
|
||||
* @param instanceId 实例ID
|
||||
*/
|
||||
private void setNextHandler(Long instanceId) {
|
||||
Instance inst = insService.getById(instanceId);
|
||||
List<FlowTask> flowTaskList = selectByInstId(instanceId);
|
||||
Map<String, Object> variableMap = inst.getVariableMap();
|
||||
for (FlowTask task : flowTaskList) {
|
||||
if (variableMap != null && variableMap.containsKey(task.getNodeCode())) {
|
||||
String userIds = variableMap.get(task.getNodeCode()).toString();
|
||||
// 批量删除现有任务的办理人记录
|
||||
flwCommonService.getFlowUserService().deleteByTaskIds(List.of(task.getId()));
|
||||
// 批量新增任务办理人记录
|
||||
Set<User> users = flwCommonService.buildFlowUser(List.of(userIds.split(StringUtils.SEPARATOR)), task.getId());
|
||||
flwCommonService.getFlowUserService().saveBatch(new ArrayList<>(users));
|
||||
variableMap.remove(task.getNodeCode());
|
||||
}
|
||||
}
|
||||
taskService.mergeVariable(inst, variableMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置弹窗处理人
|
||||
*
|
||||
* @param assigneeMap 处理人
|
||||
* @param variablesMap 变量
|
||||
*/
|
||||
private Map<String, Object> setPopAssigneeMap(Map<String, Object> assigneeMap, Map<String, Object> variablesMap) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (CollUtil.isEmpty(assigneeMap)) {
|
||||
return map;
|
||||
}
|
||||
for (Map.Entry<String, Object> entry : assigneeMap.entrySet()) {
|
||||
if (variablesMap.containsKey(entry.getKey())) {
|
||||
String userIds = variablesMap.get(entry.getKey()).toString();
|
||||
if (StringUtils.isNotBlank(userIds)) {
|
||||
Set<String> hashSet = new HashSet<>();
|
||||
//弹窗传入的选人
|
||||
List<String> popUserIds = Arrays.asList(entry.getValue().toString().split(StringUtils.SEPARATOR));
|
||||
//已有的选人
|
||||
List<String> variableUserIds = Arrays.asList(userIds.split(StringUtils.SEPARATOR));
|
||||
hashSet.addAll(popUserIds);
|
||||
hashSet.addAll(variableUserIds);
|
||||
map.put(entry.getKey(), String.join(StringUtils.SEPARATOR, hashSet));
|
||||
}
|
||||
} else {
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置办理人
|
||||
*
|
||||
@@ -491,14 +560,52 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
flowTaskVo.setFlowCode(definition.getFlowCode());
|
||||
flowTaskVo.setFlowName(definition.getFlowName());
|
||||
flowTaskVo.setBusinessId(instance.getBusinessId());
|
||||
List<Node> nodeList = nodeService.getByNodeCodes(Collections.singletonList(flowTaskVo.getNodeCode()), instance.getDefinitionId());
|
||||
if (CollUtil.isNotEmpty(nodeList)) {
|
||||
Node node = nodeList.get(0);
|
||||
flowTaskVo.setNodeRatio(node.getNodeRatio());
|
||||
//设置按钮权限
|
||||
FlowNode flowNode = getByNodeCode(flowTaskVo.getNodeCode(), instance.getDefinitionId());
|
||||
if (ObjectUtil.isNull(flowNode)) {
|
||||
throw new NullPointerException("当前【" + flowTaskVo.getNodeCode() + "】节点编码不存在");
|
||||
}
|
||||
flowTaskVo.setButtonList(flowTaskVo.getButtonList(flowNode.getExt()));
|
||||
flowTaskVo.setNodeRatio(flowNode.getNodeRatio());
|
||||
flowTaskVo.setApplyNode(flowNode.getNodeCode().equals(flwCommonService.applyNodeCode(task.getDefinitionId())));
|
||||
return flowTaskVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一节点信息
|
||||
*
|
||||
* @param bo 参数
|
||||
*/
|
||||
@Override
|
||||
public List<FlowNode> getNextNodeList(FlowNextNodeBo bo) {
|
||||
String taskId = bo.getTaskId();
|
||||
Map<String, Object> variables = bo.getVariables();
|
||||
Task task = taskService.getById(taskId);
|
||||
Instance instance = insService.getById(task.getInstanceId());
|
||||
Definition definition = defService.getById(task.getDefinitionId());
|
||||
Map<String, Object> mergeVariable = MapUtil.mergeAll(instance.getVariableMap(), variables);
|
||||
//获取下一节点列表
|
||||
List<Node> nextNodeList = nodeService.getNextNodeList(task.getDefinitionId(), task.getNodeCode(), null, SkipType.PASS.getKey(), mergeVariable);
|
||||
List<FlowNode> nextFlowNodes = BeanUtil.copyToList(nextNodeList, FlowNode.class);
|
||||
if (CollUtil.isNotEmpty(nextNodeList)) {
|
||||
//构建以下节点数据
|
||||
List<Task> buildNextTaskList = StreamUtils.toList(nextNodeList, node -> taskService.addTask(node, instance, definition, null));
|
||||
//办理人变量替换
|
||||
ExpressionUtil.evalVariable(buildNextTaskList, mergeVariable);
|
||||
for (FlowNode flowNode : nextFlowNodes) {
|
||||
buildNextTaskList.stream().filter(t -> t.getNodeCode().equals(flowNode.getNodeCode())).findFirst().ifPresent(t -> {
|
||||
if (CollUtil.isNotEmpty(t.getPermissionList())) {
|
||||
List<RemoteUserVo> users = flwTaskAssigneeService.fetchUsersByStorageId(String.join(StringUtils.SEPARATOR, t.getPermissionList()));
|
||||
if (CollUtil.isNotEmpty(users)) {
|
||||
flowNode.setPermissionFlag(StreamUtils.join(users, e -> String.valueOf(e.getUserId())));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return nextFlowNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照任务id查询任务
|
||||
*
|
||||
@@ -581,10 +688,11 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
}
|
||||
|
||||
Long taskId = bo.getTaskId();
|
||||
FlowTaskVo flowTaskVo = selectById(taskId);
|
||||
Task task = taskService.getById(taskId);
|
||||
FlowNode flowNode = getByNodeCode(task.getNodeCode(), task.getDefinitionId());
|
||||
if ("addSignature".equals(taskOperation) || "reductionSignature".equals(taskOperation)) {
|
||||
if (flowTaskVo.getNodeRatio().compareTo(BigDecimal.ZERO) == 0) {
|
||||
throw new ServiceException(flowTaskVo.getNodeName() + "不是会签节点!");
|
||||
if (flowNode.getNodeRatio().compareTo(BigDecimal.ZERO) == 0) {
|
||||
throw new ServiceException(task.getNodeName() + "不是会签节点!");
|
||||
}
|
||||
}
|
||||
// 设置任务状态并执行对应的任务操作
|
||||
@@ -689,4 +797,17 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
return remoteUserService.selectListByIds(StreamUtils.toList(userList, e -> Long.valueOf(e.getProcessedBy())));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照节点编码查询节点
|
||||
*
|
||||
* @param nodeCode 节点编码
|
||||
* @param definitionId 流程定义id
|
||||
*/
|
||||
@Override
|
||||
public FlowNode getByNodeCode(String nodeCode, Long definitionId) {
|
||||
return flowNodeMapper.selectOne(new LambdaQueryWrapper<FlowNode>()
|
||||
.eq(FlowNode::getNodeCode, nodeCode)
|
||||
.eq(FlowNode::getDefinitionId, definitionId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +48,19 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
|
||||
private final TestLeaveMapper baseMapper;
|
||||
private final WorkflowService workflowService;
|
||||
|
||||
/**
|
||||
* spel条件表达:判断小于2
|
||||
*
|
||||
* @param leaveDays 待判断的变量(可不传自行返回true或false)
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean eval(Integer leaveDays) {
|
||||
if (leaveDays < 2) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询请假
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user