|
|
|
@ -1,14 +1,18 @@
|
|
|
|
|
package cn.iocoder.yudao.module.bpm.service.task;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.collection.ListUtil;
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
|
|
|
import cn.hutool.core.util.ReflectUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
|
|
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
|
|
|
|
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert;
|
|
|
|
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
|
|
|
|
@ -38,6 +42,7 @@ import javax.annotation.Resource;
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
|
|
|
@ -316,5 +321,34 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|
|
|
|
private HistoricTaskInstance getHistoricTask(String id) {
|
|
|
|
|
return historyService.createHistoricTaskInstanceQuery().taskId(id).taskTenantId(TenantContextHolder.getTenantId().toString()).singleResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public <T extends TenantBaseDO> List<T> handleApprovalAuthority(List<T> list) {
|
|
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
|
|
for (T t : list) {
|
|
|
|
|
Object processInstanceId = ReflectUtil.getFieldValue(t, "processInstanceId");
|
|
|
|
|
if (processInstanceId != null) {
|
|
|
|
|
List<HistoricTaskInstance> taskList = historyService.createHistoricTaskInstanceQuery()
|
|
|
|
|
.processInstanceId(Convert.toStr(processInstanceId))
|
|
|
|
|
.taskTenantId(TenantContextHolder.getTenantId().toString())
|
|
|
|
|
.list();
|
|
|
|
|
if (CollUtil.isNotEmpty(taskList)) {
|
|
|
|
|
//endtime为null表示未结束的task
|
|
|
|
|
List<String> taskIdS = taskList.stream().filter(tk -> tk.getEndTime() == null).map(HistoricTaskInstance::getId).collect(Collectors.toList());
|
|
|
|
|
if (CollUtil.isNotEmpty(taskIdS)) {
|
|
|
|
|
LambdaQueryWrapperX<BpmTaskExtDO> wrapperX = new LambdaQueryWrapperX<>();
|
|
|
|
|
wrapperX.in(BpmTaskExtDO::getTaskId, taskIdS);
|
|
|
|
|
wrapperX.in(BpmTaskExtDO::getAssigneeUserId, SecurityFrameworkUtils.getLoginUserId());
|
|
|
|
|
boolean exists = taskExtMapper.exists(wrapperX);
|
|
|
|
|
if (exists) {
|
|
|
|
|
t.setIsAuthorised(true);
|
|
|
|
|
} else {
|
|
|
|
|
t.setIsAuthorised(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|