update 调整任务办理设置办理人
This commit is contained in:
parent
996faa1bf3
commit
47ba2bc404
@ -121,4 +121,9 @@ public class FlowTaskVo implements Serializable {
|
||||
* 办理人
|
||||
*/
|
||||
private List<UserDTO> userDTOList;
|
||||
|
||||
/**
|
||||
* 办理人类型
|
||||
*/
|
||||
private String type;
|
||||
}
|
||||
|
@ -147,10 +147,10 @@ public class FlwInstanceServiceImpl implements IFlwInstanceService {
|
||||
AssertUtil.isNull(startNode, ExceptionCons.LOST_START_NODE);
|
||||
|
||||
// 获取下一个节点,如果是网关节点,则重新获取后续节点
|
||||
List<Node> nextNodes = FlowFactory.taskService().getNextByCheckGateWay(new FlowParams(), getFirstBetween(startNode));
|
||||
Node node = nextNodes.get(0);
|
||||
FlowParams flowParams = FlowParams.build().nodeCode(node.getNodeCode()).skipType(SkipType.PASS.getKey()).permissionFlag(WorkflowUtils.permissionList());
|
||||
taskService.skip(list.get(0).getId(), flowParams);
|
||||
//List<Node> nextNodes = FlowFactory.taskService().getNextByCheckGateWay(new FlowParams(), getFirstBetween(startNode));
|
||||
//Node node = nextNodes.get(0);
|
||||
// FlowParams flowParams = FlowParams.build().nodeCode(node.getNodeCode()).skipType(SkipType.PASS.getKey()).permissionFlag(WorkflowUtils.permissionList());
|
||||
// taskService.skip(list.get(0).getId(), flowParams);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.dromara.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.warm.flow.core.dto.FlowParams;
|
||||
@ -15,8 +16,10 @@ import com.warm.flow.core.service.TaskService;
|
||||
import com.warm.flow.core.service.UserService;
|
||||
import com.warm.flow.orm.entity.FlowInstance;
|
||||
import com.warm.flow.orm.entity.FlowTask;
|
||||
import com.warm.flow.orm.mapper.FlowTaskMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.dto.UserDTO;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
@ -54,6 +57,8 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
private final IWfDefinitionConfigService wfDefinitionConfigService;
|
||||
private final IFlwInstanceService iFlwInstanceService;
|
||||
|
||||
private final FlowTaskMapper flowTaskMapper;
|
||||
|
||||
/**
|
||||
* 启动任务
|
||||
*
|
||||
@ -121,7 +126,8 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
flowParams.message(completeTaskBo.getMessage());
|
||||
flowParams.handler(userId);
|
||||
flowParams.permissionFlag(WorkflowUtils.permissionList());
|
||||
taskService.skip(taskId, flowParams);
|
||||
Instance instance = taskService.skip(taskId, flowParams);
|
||||
setHandler(instance);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
@ -129,6 +135,31 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置办理人
|
||||
*
|
||||
* @param instance 实例
|
||||
*/
|
||||
private void setHandler(Instance instance) {
|
||||
if (instance != null) {
|
||||
List<FlowTask> flowTasks = flowTaskMapper.selectList(new LambdaQueryWrapper<>(FlowTask.class)
|
||||
.eq(FlowTask::getInstanceId, instance.getId()));
|
||||
for (FlowTask flowTask : flowTasks) {
|
||||
List<User> userList = userService.getByAssociateds(Collections.singletonList(flowTask.getId()));
|
||||
if (CollUtil.isNotEmpty(userList)) {
|
||||
Set<User> users = WorkflowUtils.getUser(userList);
|
||||
if (CollUtil.isNotEmpty(users)) {
|
||||
userService.deleteByTaskIds(Collections.singletonList(flowTask.getId()));
|
||||
for (User user : users) {
|
||||
user.setAssociated(flowTask.getId());
|
||||
}
|
||||
userService.saveBatch(new ArrayList<>(users));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前用户的待办任务
|
||||
*
|
||||
|
@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.warm.flow.core.entity.Task;
|
||||
import com.warm.flow.core.entity.User;
|
||||
import com.warm.flow.orm.entity.FlowUser;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.dromara.common.core.domain.dto.RoleDTO;
|
||||
@ -111,12 +112,12 @@ public class WorkflowUtils {
|
||||
for (User user : userList) {
|
||||
if (user.getProcessedBy().startsWith("user:")) {
|
||||
userIds.add(Long.valueOf(StringUtils.substringAfter(user.getProcessedBy(), StrUtil.C_COLON)));
|
||||
}
|
||||
if (user.getProcessedBy().startsWith("role:")) {
|
||||
} else if (user.getProcessedBy().startsWith("role:")) {
|
||||
roleIds.add(Long.valueOf(StringUtils.substringAfter(user.getProcessedBy(), StrUtil.C_COLON)));
|
||||
}
|
||||
if (user.getProcessedBy().startsWith("dept:")) {
|
||||
} else if (user.getProcessedBy().startsWith("dept:")) {
|
||||
deptIds.add(Long.valueOf(StringUtils.substringAfter(user.getProcessedBy(), StrUtil.C_COLON)));
|
||||
} else {
|
||||
userIds.add(Long.valueOf(user.getProcessedBy()));
|
||||
}
|
||||
}
|
||||
List<UserDTO> users = userService.selectListByIds(userIds);
|
||||
@ -134,4 +135,50 @@ public class WorkflowUtils {
|
||||
}
|
||||
return userDTOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取办理人
|
||||
*
|
||||
* @param userList 办理用户
|
||||
* @return 用户
|
||||
*/
|
||||
public static Set<User> getUser(List<User> userList) {
|
||||
Set<User> list = new HashSet<>();
|
||||
if (CollUtil.isNotEmpty(userList)) {
|
||||
UserService userService = SpringUtils.getBean(UserService.class);
|
||||
for (User user : userList) {
|
||||
if (user.getProcessedBy().startsWith("user:")) {
|
||||
Long userId = Long.valueOf(StringUtils.substringAfter(user.getProcessedBy(), StrUtil.C_COLON));
|
||||
List<UserDTO> users = userService.selectListByIds(List.of(userId));
|
||||
if (CollUtil.isNotEmpty(users)) {
|
||||
FlowUser u = new FlowUser();
|
||||
u.setType(user.getType());
|
||||
u.setProcessedBy(String.valueOf(StreamUtils.toList(users, UserDTO::getUserId).get(0)));
|
||||
list.add(u);
|
||||
}
|
||||
}
|
||||
if (user.getProcessedBy().startsWith("role:")) {
|
||||
Long roleId = Long.valueOf(StringUtils.substringAfter(user.getProcessedBy(), StrUtil.C_COLON));
|
||||
List<UserDTO> roleUsers = userService.selectUsersByRoleIds(List.of(roleId));
|
||||
for (UserDTO roleUser : roleUsers) {
|
||||
FlowUser u = new FlowUser();
|
||||
u.setType(user.getType());
|
||||
u.setProcessedBy(String.valueOf(roleUser.getUserId()));
|
||||
list.add(u);
|
||||
}
|
||||
}
|
||||
if (user.getProcessedBy().startsWith("dept:")) {
|
||||
Long deptId = Long.valueOf(StringUtils.substringAfter(user.getProcessedBy(), StrUtil.C_COLON));
|
||||
List<UserDTO> deptUsers = userService.selectUsersByDeptIds(List.of(deptId));
|
||||
for (UserDTO deptUser : deptUsers) {
|
||||
FlowUser u = new FlowUser();
|
||||
u.setType(user.getType());
|
||||
u.setProcessedBy(String.valueOf(deptUser.getUserId()));
|
||||
list.add(u);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
<result property="formCustom" column="form_custom"/>
|
||||
<result property="formPath" column="form_path"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="type" column="type"/>
|
||||
</resultMap>
|
||||
<resultMap type="org.dromara.workflow.domain.vo.FlowHisTaskVo" id="FlowHisTaskResult">
|
||||
<result property="id" column="id"/>
|
||||
@ -63,11 +64,12 @@
|
||||
d.flow_code,
|
||||
d.form_custom,
|
||||
d.form_path,
|
||||
uu.processed_by
|
||||
uu.processed_by,
|
||||
uu.type
|
||||
FROM flow_task AS t
|
||||
LEFT JOIN flow_user uu ON uu.associated = t.id
|
||||
LEFT JOIN flow_definition d on t.definition_id = d.id
|
||||
LEFT JOIN flow_instance i on t.instance_id = i.id where t.node_type = 1 and t.del_flag = '0') t
|
||||
LEFT JOIN flow_instance i on t.instance_id = i.id where t.node_type = 1 and t.del_flag = '0' and uu.del_flag = '0') t
|
||||
${ew.getCustomSqlSegment}
|
||||
</select>
|
||||
|
||||
@ -117,7 +119,7 @@
|
||||
LEFT JOIN flow_instance b ON a.associated = b.id
|
||||
LEFT JOIN flow_definition d on b.definition_id=d.id
|
||||
WHERE
|
||||
a.type = 4
|
||||
a.type = 4 and a.del_flag = '0'
|
||||
) t ${ew.getCustomSqlSegment}
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
x
Reference in New Issue
Block a user