Bug
This commit is contained in:
parent
df2bc13a38
commit
296e46d5af
@ -4,11 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
|
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
|
||||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionListReqVO;
|
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceMyPageReqVO;
|
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstancePageItemRespVO;
|
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
|
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
|
||||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
|
||||||
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
|
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
@ -34,9 +30,6 @@ public class BpmTaskController {
|
|||||||
@Resource
|
@Resource
|
||||||
private BpmTaskService taskService;
|
private BpmTaskService taskService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private BpmProcessInstanceService processInstanceService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add by yaojun 2024.1.3
|
* add by yaojun 2024.1.3
|
||||||
* 流程审核添加了抄送用户(多用户)的功能
|
* 流程审核添加了抄送用户(多用户)的功能
|
||||||
|
@ -38,4 +38,10 @@ public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> {
|
|||||||
update(updateObj, new LambdaQueryWrapper<BpmTaskExtDO>().in(BpmTaskExtDO::getTaskId, taskIdList));
|
update(updateObj, new LambdaQueryWrapper<BpmTaskExtDO>().in(BpmTaskExtDO::getTaskId, taskIdList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default Long selectListCount(Long userId, String processInstanceId){
|
||||||
|
|
||||||
|
return selectCount(new LambdaQueryWrapperX<BpmTaskExtDO>().eq(BpmTaskExtDO::getAssigneeUserId, userId)
|
||||||
|
.eq(BpmTaskExtDO::getProcessInstanceId, processInstanceId)
|
||||||
|
.eq(BpmTaskExtDO::getResult, BpmProcessInstanceResultEnum.APPROVE.getResult()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
|
||||||
import cn.iocoder.yudao.module.bpm.service.task.BpmActivityService;
|
import cn.iocoder.yudao.module.bpm.service.task.BpmActivityService;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||||
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
|
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -37,6 +38,10 @@ public class BpmTaskEventListener extends AbstractFlowableEngineEventListener {
|
|||||||
@Lazy // 解决循环依赖
|
@Lazy // 解决循环依赖
|
||||||
private BpmActivityService activityService;
|
private BpmActivityService activityService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
@Lazy // 解决循环依赖
|
||||||
|
private BpmProcessInstanceService processInstanceService;
|
||||||
|
|
||||||
public static final Set<FlowableEngineEventType> TASK_EVENTS = ImmutableSet.<FlowableEngineEventType>builder()
|
public static final Set<FlowableEngineEventType> TASK_EVENTS = ImmutableSet.<FlowableEngineEventType>builder()
|
||||||
.add(FlowableEngineEventType.TASK_CREATED)
|
.add(FlowableEngineEventType.TASK_CREATED)
|
||||||
.add(FlowableEngineEventType.TASK_ASSIGNED)
|
.add(FlowableEngineEventType.TASK_ASSIGNED)
|
||||||
@ -50,7 +55,11 @@ public class BpmTaskEventListener extends AbstractFlowableEngineEventListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void taskCreated(FlowableEngineEntityEvent event) {
|
protected void taskCreated(FlowableEngineEntityEvent event) {
|
||||||
taskService.createTaskExt((Task) event.getEntity());
|
Task task = (Task) event.getEntity();
|
||||||
|
taskService.createTaskExt(task);
|
||||||
|
|
||||||
|
//在TASK创建时, 监听审批人是否时发起人
|
||||||
|
taskService.approveAuto(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,6 @@ package cn.iocoder.yudao.module.bpm.service.task;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceMyPageReqVO;
|
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstancePageItemRespVO;
|
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
|
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
|
||||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
|
||||||
import org.flowable.task.api.Task;
|
import org.flowable.task.api.Task;
|
||||||
@ -199,4 +197,10 @@ public interface BpmTaskService {
|
|||||||
*/
|
*/
|
||||||
String getCurrentTaskIdByProcessInstanceId(String processInstanceId) ;
|
String getCurrentTaskIdByProcessInstanceId(String processInstanceId) ;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听 判断流程审批人是否是发起人
|
||||||
|
* @param task
|
||||||
|
*/
|
||||||
|
void approveAuto(Task task);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ import org.flowable.engine.HistoryService;
|
|||||||
import org.flowable.engine.ManagementService;
|
import org.flowable.engine.ManagementService;
|
||||||
import org.flowable.engine.RuntimeService;
|
import org.flowable.engine.RuntimeService;
|
||||||
import org.flowable.engine.TaskService;
|
import org.flowable.engine.TaskService;
|
||||||
import org.flowable.engine.history.HistoricActivityInstance;
|
|
||||||
import org.flowable.engine.history.HistoricProcessInstance;
|
import org.flowable.engine.history.HistoricProcessInstance;
|
||||||
import org.flowable.engine.runtime.ProcessInstance;
|
import org.flowable.engine.runtime.ProcessInstance;
|
||||||
import org.flowable.task.api.DelegationState;
|
import org.flowable.task.api.DelegationState;
|
||||||
@ -660,8 +659,10 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
*/
|
*/
|
||||||
private Task validateTask(Long userId, String taskId) {
|
private Task validateTask(Long userId, String taskId) {
|
||||||
Task task = validateTaskExist(taskId);
|
Task task = validateTaskExist(taskId);
|
||||||
if (!Objects.equals(userId, NumberUtils.parseLong(task.getAssignee()))) {
|
if( userId != null ) {
|
||||||
throw exception(TASK_OPERATE_FAIL_ASSIGN_NOT_SELF);
|
if (!Objects.equals(userId, NumberUtils.parseLong(task.getAssignee()))) {
|
||||||
|
throw exception(TASK_OPERATE_FAIL_ASSIGN_NOT_SELF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
@ -1168,6 +1169,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getCurrentTaskIdByProcessInstanceId(String processInstanceId) {
|
public String getCurrentTaskIdByProcessInstanceId(String processInstanceId) {
|
||||||
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(processInstanceId).active();
|
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(processInstanceId).active();
|
||||||
List<Task> tasks = taskQuery.list();
|
List<Task> tasks = taskQuery.list();
|
||||||
@ -1183,4 +1185,43 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
throw exception(TASK_NOT_EXISTS);
|
throw exception(TASK_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听 判断流程审批人是否是发起人
|
||||||
|
* @param task
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void approveAuto(Task task) {
|
||||||
|
|
||||||
|
//在事务提交后, 进行判断
|
||||||
|
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterCommit() {
|
||||||
|
|
||||||
|
ProcessInstance processInstance = processInstanceService.getProcessInstance(task.getProcessInstanceId());
|
||||||
|
|
||||||
|
//如果当前审批人是流程发起人,则自动通过当前审批节点
|
||||||
|
if (processInstance.getStartUserId().equals(task.getAssignee())) {
|
||||||
|
|
||||||
|
BpmTaskApproveReqVO reqVO = new BpmTaskApproveReqVO();
|
||||||
|
reqVO.setId(task.getId());
|
||||||
|
reqVO.setReason(BpmConstants.AUTO_APPRAVAL);
|
||||||
|
approveTask(Long.valueOf(task.getAssignee()), reqVO);
|
||||||
|
}else {
|
||||||
|
//判断 当前审批人是否在该流程中 已通过审批
|
||||||
|
//如果有,则自动审批通过该审批人节点
|
||||||
|
Long count = taskExtMapper.selectListCount(Long.valueOf(task.getAssignee()), task.getProcessInstanceId());
|
||||||
|
|
||||||
|
if (count > 0L) {
|
||||||
|
|
||||||
|
BpmTaskApproveReqVO reqVO = new BpmTaskApproveReqVO();
|
||||||
|
reqVO.setId(task.getId());
|
||||||
|
reqVO.setReason(BpmConstants.AUTO_APPRAVAL);
|
||||||
|
approveTask(Long.valueOf(task.getAssignee()), reqVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
@ -126,7 +125,19 @@ public class UserController {
|
|||||||
// 拼接数据
|
// 拼接数据
|
||||||
DeptDO dept = deptService.getDept(user.getDeptId());
|
DeptDO dept = deptService.getDept(user.getDeptId());
|
||||||
|
|
||||||
return success(UserConvert.INSTANCE.convert(user, dept));
|
// 获取岗位信息
|
||||||
|
PostDO post = new PostDO();
|
||||||
|
Set<Long> postIds = user.getPostIds();
|
||||||
|
if (postIds != null && !postIds.isEmpty()) {
|
||||||
|
|
||||||
|
ArrayList<Long> list = new ArrayList<>(postIds);
|
||||||
|
// 只获配置的首个岗位
|
||||||
|
Long postId = list.get(0);
|
||||||
|
|
||||||
|
post = postService.getPost(postId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return success(UserConvert.INSTANCE.convert(user, dept, post));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
|
@ -49,6 +49,7 @@ public class DeptServiceImpl implements DeptService {
|
|||||||
|
|
||||||
// 插入部门
|
// 插入部门
|
||||||
DeptDO dept = BeanUtils.toBean(createReqVO, DeptDO.class);
|
DeptDO dept = BeanUtils.toBean(createReqVO, DeptDO.class);
|
||||||
|
deptMapper.insert(dept);
|
||||||
|
|
||||||
if (dept.getParentId().toString().equals("0")) {
|
if (dept.getParentId().toString().equals("0")) {
|
||||||
|
|
||||||
@ -65,7 +66,8 @@ public class DeptServiceImpl implements DeptService {
|
|||||||
dept.setFlag(patentDeptDO.getFlag() + "-" + dept.getId().toString());
|
dept.setFlag(patentDeptDO.getFlag() + "-" + dept.getId().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
deptMapper.insert(dept);
|
//更新部门 信息
|
||||||
|
deptMapper.updateById(dept);
|
||||||
return dept.getId();
|
return dept.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,8 +91,9 @@ public class DeptServiceImpl implements DeptService {
|
|||||||
// 更新部门
|
// 更新部门
|
||||||
DeptDO updateObj = BeanUtils.toBean(updateReqVO, DeptDO.class);
|
DeptDO updateObj = BeanUtils.toBean(updateReqVO, DeptDO.class);
|
||||||
|
|
||||||
if (updateObj.getLeaderUserId() == null)
|
if (updateObj.getLeaderUserId() == null) {
|
||||||
updateObj.setLeaderUserId(new Long(0));
|
updateObj.setLeaderUserId(0L);
|
||||||
|
}
|
||||||
|
|
||||||
// 如果变换上级部门
|
// 如果变换上级部门
|
||||||
if (!updateObj.getParentId().toString().equals(oldDeptDO.getParentId().toString())) {
|
if (!updateObj.getParentId().toString().equals(oldDeptDO.getParentId().toString())) {
|
||||||
|
@ -100,6 +100,4 @@ public interface PostService {
|
|||||||
*/
|
*/
|
||||||
void validatePostList(Collection<Long> ids);
|
void validatePostList(Collection<Long> ids);
|
||||||
|
|
||||||
PostDO getByPostName(String postName);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -150,10 +150,4 @@ public class PostServiceImpl implements PostService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PostDO getByPostName(String postName) {
|
|
||||||
|
|
||||||
return postMapper.selectOne(PostDO::getName, postName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user