我的待办数量中加入协作组内数量

This commit is contained in:
wangliwen 2022-12-12 16:38:13 +08:00
parent c883aaf8d2
commit d9f600f046
1 changed files with 32 additions and 2 deletions

View File

@ -11,6 +11,8 @@ import io.renren.common.utils.Result;
import io.renren.modules.activiti.dto.BatchCompleteDTO; import io.renren.modules.activiti.dto.BatchCompleteDTO;
import io.renren.modules.activiti.dto.TaskDTO; import io.renren.modules.activiti.dto.TaskDTO;
import io.renren.modules.activiti.service.ActTaskService; import io.renren.modules.activiti.service.ActTaskService;
import io.renren.modules.audit_team.dto.SysAuditTeamDTO;
import io.renren.modules.audit_team.service.SysAuditTeamService;
import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.security.user.UserDetail; import io.renren.modules.security.user.UserDetail;
import io.renren.modules.sys.dto.SysUserDTO; import io.renren.modules.sys.dto.SysUserDTO;
@ -27,6 +29,7 @@ import org.activiti.engine.task.TaskQuery;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -63,6 +66,11 @@ public class ActTaskController {
protected RepositoryService repositoryService; protected RepositoryService repositoryService;
@Autowired @Autowired
protected TaskService taskService; protected TaskService taskService;
@Autowired
private SysAuditTeamService sysAuditTeamService;
@Value("#{new Boolean(${auditteam.enable})}")
private Boolean auditteam; // 是否进行审核组
/** /**
@ -163,7 +171,8 @@ public class ActTaskController {
}) })
public Result<Map<String, Long>> myToDoTaskNum(@ApiIgnore @RequestParam Map<String, Object> params) { public Result<Map<String, Long>> myToDoTaskNum(@ApiIgnore @RequestParam Map<String, Object> params) {
Map<String, Long> result = new LinkedHashMap<>(); Map<String, Long> result = new LinkedHashMap<>();
params.put("userId", SecurityUser.getUserId().toString()); String userId = SecurityUser.getUserId().toString();
params.put("userId", userId);
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery() ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
.orderByProcessDefinitionId().desc().orderByProcessDefinitionKey().desc(); .orderByProcessDefinitionId().desc().orderByProcessDefinitionKey().desc();
processDefinitionQuery.latestVersion(); processDefinitionQuery.latestVersion();
@ -173,7 +182,28 @@ public class ActTaskController {
taskQuery.processDefinitionKey(index.getKey()); // 流程模型key taskQuery.processDefinitionKey(index.getKey()); // 流程模型key
taskQuery.taskAssignee(SecurityUser.getUserId().toString()); taskQuery.taskAssignee(SecurityUser.getUserId().toString());
taskQuery.active(); taskQuery.active();
if (auditteam) { // 允许流程审核协作时
List<SysAuditTeamDTO> sysAuditTeamDTOS = sysAuditTeamService.selectByMemberOne(userId);
List<String> groupUserId = sysAuditTeamDTOS
.stream()
.map(index_ -> index_.getMember())
.filter(Objects::nonNull)
.flatMap(index_ -> index_.stream())
.map(index_ -> (String) index_.get("id"))
.filter(index_ -> !userId.equals(index_)) // 过滤非本人
.distinct()
.collect(Collectors.toList());
long sum = groupUserId.stream().mapToLong(inedx_ -> {
TaskQuery taskQuery_ = taskService.createTaskQuery();
taskQuery_.processDefinitionKey(index.getKey()); // 流程模型key
taskQuery_.taskAssignee(inedx_); // 协作组审核人
taskQuery_.active();
return taskQuery_.count();
}).sum();
result.put(index.getKey(), taskQuery.count() + sum); // 加上协作组任务数
} else {
result.put(index.getKey(), taskQuery.count()); result.put(index.getKey(), taskQuery.count());
}
}); });
result.put("meetingroom_book", jdbcTemplate.queryForObject("SELECT COUNT(id) FROM t_meetingroom_book WHERE state = 1;", Long.class)); result.put("meetingroom_book", jdbcTemplate.queryForObject("SELECT COUNT(id) FROM t_meetingroom_book WHERE state = 1;", Long.class));
return new Result<Map<String, Long>>().ok(result); return new Result<Map<String, Long>>().ok(result);