From 3452c0838a2a1672c2e56cfea81867addd499988 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期日, 02 三月 2025 23:46:18 +0800
Subject: [PATCH] Merge branch 'dev'
---
business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java | 1286 ++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 1,074 insertions(+), 212 deletions(-)
diff --git a/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java b/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
index 80790af..f6cfa5b 100644
--- a/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
@@ -1,45 +1,41 @@
package com.ycl.service.impl;
-import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.ycl.common.constant.ProcessConstants;
-import com.ycl.common.core.domain.AjaxResult;
+import com.ycl.common.constant.ProcessOverTimeConstants;
import com.ycl.common.core.domain.entity.SysDept;
+import com.ycl.common.core.domain.entity.SysDictData;
import com.ycl.common.core.domain.entity.SysRole;
import com.ycl.common.core.domain.entity.SysUser;
-import com.ycl.common.enums.FlowComment;
-import com.ycl.common.enums.business.FlowLogEventTypeEnum;
-import com.ycl.common.enums.business.HandlerTypeEnum;
-import com.ycl.common.enums.business.TaskStatusEnum;
+import com.ycl.common.enums.business.*;
import com.ycl.common.utils.SecurityUtils;
import com.ycl.constant.TaskTypeConstant;
-import com.ycl.domain.dto.FlowTaskDto;
-import com.ycl.domain.entity.FlowLog;
-import com.ycl.domain.entity.ProjectInfo;
-import com.ycl.domain.entity.ProjectProcess;
-import com.ycl.domain.form.RejectTaskForm;
-import com.ycl.domain.form.TaskDelegationForm;
-import com.ycl.domain.json.TaskDelegateData;
+import com.ycl.domain.entity.*;
+import com.ycl.domain.form.*;
+import com.ycl.domain.json.*;
import com.ycl.domain.vo.CustomerTaskVO;
import com.ycl.domain.vo.IndexCustomerTaskVO;
import com.ycl.domain.vo.ProjectProcessDetailVO;
+import com.ycl.event.event.TaskLogEvent;
import com.ycl.mapper.ProjectInfoMapper;
import com.ycl.mapper.ProjectProcessMapper;
-import com.ycl.service.FlowLogService;
-import com.ycl.service.ProjectProcessService;
+import com.ycl.service.*;
import com.ycl.common.base.Result;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ycl.domain.form.ProjectProcessForm;
import com.ycl.domain.vo.ProjectProcessVO;
import com.ycl.domain.query.ProjectProcessQuery;
import com.ycl.service.common.TaskCommonService;
import com.ycl.system.service.ISysDeptService;
+import com.ycl.system.service.ISysDictTypeService;
import com.ycl.system.service.ISysRoleService;
import com.ycl.system.service.ISysUserService;
+import lombok.Synchronized;
import org.apache.commons.lang3.StringUtils;
import org.flowable.bpmn.model.*;
import org.flowable.bpmn.model.Process;
@@ -51,18 +47,15 @@
import org.flowable.identitylink.api.IdentityLink;
import org.flowable.identitylink.api.IdentityLinkInfo;
import org.flowable.identitylink.api.IdentityLinkType;
-import org.flowable.identitylink.api.history.HistoricIdentityLink;
import org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntityImpl;
import org.flowable.task.api.Task;
import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance;
-import org.flowable.task.api.history.HistoricTaskInstanceQuery;
+import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
import com.ycl.framework.utils.PageUtil;
-import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import java.util.*;
@@ -89,7 +82,14 @@
private final ISysRoleService sysRoleService;
private final ISysDeptService sysDeptService;
private final TaskCommonService taskCommonService;
- private final FlowLogService flowLogService;
+ private final IFlowTaskService flowTaskService;
+ private final ISysFormService formService;
+ private final ProcessCodingService processCodingService;
+ private final ApplicationEventPublisher publisher;
+ private final ISysDeptService deptService;
+ private final ProcessLogService processLogService;
+ private final ISysDictTypeService dictTypeService;
+ private final ProcessConfigInfoService processConfigInfoService;
/**
* 鍒嗛〉鏌ヨ
@@ -100,13 +100,15 @@
@Override
public Result page(ProjectProcessQuery query) {
IPage<ProjectProcessVO> page = PageUtil.getPage(query, ProjectProcessVO.class);
- baseMapper.getPage(page, query);
+ baseMapper.getPage(query, page);
for (ProjectProcessVO vo : page.getRecords()) {
+ vo.setStatus(vo.getProjectStatus());
if (Objects.nonNull(vo.getProcessDefId())) {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(vo.getProcessDefId()).singleResult();
if (Objects.nonNull(processDefinition)) {
vo.setSuspended(processDefinition.isSuspended());
vo.setFlowableProcessName(processDefinition.getName() + "(v" + processDefinition.getVersion() + ")");
+ vo.setDeployId(processDefinition.getDeploymentId());
}
}
}
@@ -138,23 +140,45 @@
}
}
}
- String processInsId = this.startPro(form.getProjectId(), form.getProcessDefId());
+ ProjectInfo project = new LambdaQueryChainWrapper<>(projectInfoMapper)
+ .select(ProjectInfo::getProjectOwnerUnit)
+ .eq(ProjectInfo::getId, form.getProjectId())
+ .one();
+ if (Objects.isNull(project)) {
+ throw new RuntimeException("椤圭洰涓嶅瓨鍦�");
+ }
+ SysDept dept = deptService.selectDeptById(project.getProjectOwnerUnit());
+ if (Objects.isNull(dept)) {
+ throw new RuntimeException("椤圭洰涓氫富鍗曚綅涓嶅瓨鍦�");
+ }
+ String processInsId = this.startPro(form.getProjectId(), form.getProcessDefId(), dept.getDeptId());
new LambdaUpdateChainWrapper<>(baseMapper)
.eq(ProjectProcess::getProjectId, form.getProjectId())
.set(ProjectProcess::getProcessDefId, form.getProcessDefId())
.set(ProjectProcess::getProcessInsId, processInsId)
+ .set(ProjectProcess::getDataLaunch, project.getProjectOwnerUnit())
.update();
+
return Result.ok("娴佺▼鍙樻洿鎴愬姛");
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result startProcess(Long projectId, String processDefId) {
- String processInsId = this.startPro(projectId, processDefId);
+ ProjectInfo project = projectInfoMapper.selectById(projectId);
+ if (Objects.isNull(project)) {
+ throw new RuntimeException("椤圭洰涓嶅瓨鍦�");
+ }
+ SysDept dept = deptService.selectDeptById(project.getProjectOwnerUnit());
+ if (Objects.isNull(dept)) {
+ throw new RuntimeException("椤圭洰涓氫富鍗曚綅涓嶅瓨鍦�");
+ }
+ String processInsId = this.startPro(projectId, processDefId, dept.getDeptId());
ProjectProcess entity = new ProjectProcess();
entity.setProjectId(projectId);
entity.setProcessDefId(processDefId);
entity.setProcessInsId(processInsId);
+ entity.setDataLaunch(project.getProjectOwnerUnit());
baseMapper.insert(entity);
return Result.ok("娴佺▼鍚姩鎴愬姛");
@@ -167,15 +191,9 @@
* @param processDefId
* @return
*/
- private String startPro(Long projectId, String processDefId) {
+ private String startPro(Long projectId, String processDefId, Long createBy) {
- ProjectInfo project = new LambdaQueryChainWrapper<>(projectInfoMapper)
- .select(ProjectInfo::getCreateBy)
- .eq(ProjectInfo::getId, projectId)
- .one();
- if (Objects.isNull(project)) {
- throw new RuntimeException("椤圭洰涓嶅瓨鍦�");
- }
+
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefId)
.latestVersion().singleResult();
if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) {
@@ -186,9 +204,8 @@
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
identityService.setAuthenticatedUserId(sysUser.getUserId().toString());
variables.put(ProcessConstants.PROCESS_INITIATOR, sysUser.getUserId());
-
// 灏嗚椤圭洰鐨勭敵璇蜂汉锛堜笟涓绘柟锛変綔涓烘祦绋嬩腑鏌愪簺鐜妭鐨勫鐞嗕汉
- variables.put(ProcessConstants.DATA_LAUNCH, project.getCreateBy());
+ variables.put(ProcessConstants.DATA_LAUNCH, "dept:" + createBy);
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefId, projectId + "", variables);
return processInstance.getId();
}
@@ -229,13 +246,16 @@
taskStatistics.setTotalTaskNum(this.getTotalTaskNum(processDefId));
taskStatistics.setTodoTaskNum(this.getTodoTaskNum(projectProcess.getProcessInsId()));
taskStatistics.setRemainingTaskNum(this.getRemainingTaskNum(processDefId, projectProcess.getProcessInsId(), taskStatistics.getTotalTaskNum()));
+ taskStatistics.setTimelyFinishedTaskNum(this.getTimelyTaskNum(projectProcess.getProcessInsId()));
+ taskStatistics.setOvertimeTaskNum(this.getOvertimeTaskNum(projectProcess.getProcessInsId()));
+ taskStatistics.setWillOvertimeTaskNum(this.getWillOvertimeTaskNum(projectProcess.getProcessInsId()));
// taskStatistics.setCurrentTask(this.getCurrentNodeTaskList(projectProcess.getProcessInstanceId()));
detail.setStatistics(taskStatistics);
Result result = Result.ok();
// 浠e姙浠诲姟
- this.getTodoTaskList(projectProcess.getProcessInsId(), "", 5, 1, result);
+ this.getTodoTaskList(projectProcess.getProjectId(), projectProcess.getProcessInsId(), "", 5, 1, result);
return result.data(detail);
}
@@ -252,16 +272,25 @@
Result ok = Result.ok();
switch (query.getTaskType()) {
case TaskTypeConstant.ALL:
- this.getAllUserTask(query.getProcessDefId(), projectProcess.getProcessInsId(), query.getTaskName(), (int) query.getCurrentPage(), (int) query.getPageSize(), ok);
+ this.getAllUserTask(query.getProjectId(), query.getProcessDefId(), projectProcess.getProcessInsId(), query.getTaskName(), (int) query.getCurrentPage(), (int) query.getPageSize(), ok);
break;
case TaskTypeConstant.TODO:
- this.getTodoTaskList(projectProcess.getProcessInsId(), query.getTaskName(), (int) query.getPageSize(), (int) query.getCurrentPage(), ok);
+ this.getTodoTaskList(query.getProjectId(), projectProcess.getProcessInsId(), query.getTaskName(), (int) query.getPageSize(), (int) query.getCurrentPage(), ok);
ok.data(ok.get("taskList"));
break;
case TaskTypeConstant.CURRENT:
break;
case TaskTypeConstant.REMAINING:
- this.getRemainingTask(query.getProcessDefId(), projectProcess.getProcessInsId(), query.getTaskName(), (int) query.getCurrentPage(), (int) query.getPageSize(), ok);
+ this.getRemainingTask(query.getProjectId(), query.getProcessDefId(), projectProcess.getProcessInsId(), query.getTaskName(), (int) query.getCurrentPage(), (int) query.getPageSize(), ok);
+ break;
+ case TaskTypeConstant.TIMELY:
+ this.getTimelyTask(query.getProjectId(), query.getProcessDefId(), projectProcess.getProcessInsId(), query.getTaskName(), (int) query.getCurrentPage(), (int) query.getPageSize(), ok);
+ break;
+ case TaskTypeConstant.OVERTIME:
+ this.getOvertimeTask(query.getProjectId(), query.getProcessDefId(), projectProcess.getProcessInsId(), query.getTaskName(), (int) query.getCurrentPage(), (int) query.getPageSize(), ok);
+ break;
+ case TaskTypeConstant.WILL_OVER_TIME:
+ this.getWillOvertimeTask(query.getProjectId(), query.getProcessDefId(), projectProcess.getProcessInsId(), query.getTaskName(), (int) query.getCurrentPage(), (int) query.getPageSize(), ok);
break;
default:
break;
@@ -276,11 +305,17 @@
.active()
.includeProcessVariables()
.orderByTaskCreateTime().desc();
-
- if (StringUtils.isNotBlank(taskName)) {
- taskQuery.processDefinitionNameLike(taskName);
+ List<String> insIds = baseMapper.getNormalInsIds();
+ if (CollectionUtils.isEmpty(insIds)) {
+ result.data(new ArrayList<>()).total(0L);
+ return;
+ } else {
+ taskQuery.processInstanceIdIn(insIds);
}
- if (! SecurityUtils.getLoginUser().getUser().isAdmin()) {
+ if (StringUtils.isNotBlank(taskName)) {
+ taskQuery.taskNameLike(taskName);
+ }
+ if (!SecurityUtils.getLoginUser().getUser().isAdmin()) {
taskQuery
.or()
.taskCandidateGroupIn(taskCommonService.getCurrentUserGroups())
@@ -305,7 +340,7 @@
.processDefinitionId(task.getProcessDefinitionId())
.singleResult();
taskVO.setDeployId(pd.getDeploymentId());
- taskVO.setProcessName(pd.getName());
+ taskVO.setProcessName(pd.getName() + "(v" + pd.getVersion() + ")");
taskVO.setProcessInsId(task.getProcessInstanceId());
taskVO.setTaskDefinitionKey(task.getTaskDefinitionKey());
@@ -314,6 +349,8 @@
if (Objects.nonNull(project)) {
taskVO.setProjectId(project.getId());
taskVO.setProjectName(project.getProjectName());
+ } else {
+ continue;
}
// 娴佺▼鍙戣捣浜轰俊鎭�
@@ -324,6 +361,10 @@
List<String> handlerNames = new ArrayList<>(2);
List<Long> handlerUnitIds = new ArrayList<>(2);
List<String> handlerUnitNames = new ArrayList<>(2);
+ taskVO.setHandlerId(handlerIds);
+ taskVO.setHandlerName(handlerNames);
+ taskVO.setHandlerUnitId(handlerUnitIds);
+ taskVO.setHandlerUnitName(handlerUnitNames);
// 娴佺▼澶勭悊浜轰俊鎭�
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId());
@@ -367,13 +408,52 @@
}
}
}
- taskVO.setHandlerId(handlerIds);
- taskVO.setHandlerName(handlerNames);
- taskVO.setHandlerUnitId(handlerUnitIds);
- taskVO.setHandlerUnitName(handlerUnitNames);
+ // 妫�鏌ユ槸鍚︽寕璧�
+ if (processLogService.taskIsHangup(task.getId(), task.getProcessInstanceId())) {
+ taskVO.setTaskStatus(TaskStatusEnum.HANGUP);
+ }
+
+ // 璁$畻鍔炵悊鏃堕棿
+ ProcessCoding processCoding = processCodingService.getByTaskId(task.getId());
+ if (processCoding != null) {
+ if (StringUtils.isNotBlank(processCoding.getOvertime())) {
+ Long overtime = getTime(processCoding.getOvertime());
+ long durationTime = 0l;
+ if (Objects.nonNull(processCoding.getStartTaskTime())) {
+ durationTime = ((new Date()).getTime() - processCoding.getStartTaskTime().getTime()) / 1000;
+ } else {
+ taskVO.setRemainingTime("鏈缃姙鐞嗘椂闂�");
+ }
+ if (overtime > durationTime) {
+ taskVO.setRemainingTime((overtime - durationTime) / 3600 + "灏忔椂");
+ } else {
+ taskVO.setRemainingTime("宸茶秴鏃�");
+ }
+ } else {
+ taskVO.setRemainingTime("-");
+ }
+ }
+ this.distinctVo(taskVO);
vos.add(taskVO);
}
result.put("taskList", vos);
+ }
+
+ private Long getTime(String timeStr) {
+ Long time = null;
+ if (StringUtils.isNotBlank(timeStr)) {
+ String[] timeArr = timeStr.split("-");
+ // 瑙f瀽澶╂暟鍜屽皬鏃舵暟
+ int days = Integer.parseInt(timeArr[0]);
+ int hours = 0;
+ if (timeArr.length > 1) {
+ hours = Integer.parseInt(timeArr[1]);
+ }
+ time = (days * 24L + hours) * 3600L;
+// //鍒�-绉�
+// time= (days * 60L) + hours;
+ }
+ return time;
}
@Override
@@ -480,7 +560,7 @@
for (FlowElement flowElement : flowElements) {
if (flowElement instanceof UserTask && flowElement.getId().equals(task.getTaskDefinitionKey())) {
UserTask userTask = (UserTask) flowElement;
- needAuditing = taskCommonService.checkTaskNeedAuditing(userTask.getExtensionElements().get("properties"));
+ needAuditing = taskCommonService.checkHasExeProperty(userTask.getExtensionElements().get("properties"), ProcessConstants.EXTENSION_PROPERTY_NEED_AUDITING_TEXT);
break;
}
@@ -521,7 +601,7 @@
taskService.deleteCandidateGroup(task.getId(), identityLink.getGroupId());
}
}
- TaskDelegateData jsonData = new TaskDelegateData();
+ DelegateData jsonData = new DelegateData();
jsonData.setBeforeHandlerIds(beforeHandlerIds);
jsonData.setBeforeHandlerType(beforeHandlerType);
@@ -566,37 +646,216 @@
}
jsonData.setAfterHandlerIds(afterHandlerIds);
jsonData.setAfterHandlerType(form.getPeopleType());
- // 娣诲姞鏃ュ織
- flowLogService.add(task.getId(), task.getProcessInstanceId(), FlowLogEventTypeEnum.DELEGATE, form.getProjectId(), JSON.toJSONString(jsonData));
+ // 鍙戝竷杞姙浜嬩欢
+ publisher.publishEvent(new TaskLogEvent(this, null, SecurityUtils.getUserId(), form.getProjectId(), form.getProcessInsId(), task.getId(), task.getTaskDefinitionKey(), task.getName(), ProcessLogEventTypeEnum.DELEGATE, jsonData));
return Result.ok("杞姙鎴愬姛");
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public Result taskJump(TaskJumpForm form) {
+ Task task = taskService.createTaskQuery().taskId(form.getTaskId()).processInstanceId(form.getProcessInsId()).singleResult();
+ if (Objects.nonNull(task)) {
+ // 娣诲姞璺宠繃鏃ュ織
+ publisher.publishEvent(new TaskLogEvent(this, null, SecurityUtils.getUserId(), form.getProjectId(), form.getProcessInsId(), task.getId(), task.getTaskDefinitionKey(), task.getName(), ProcessLogEventTypeEnum.JUMP, new JumpData(form.getDesc())));
+ // 鏌ュ嚭璇ヤ换鍔$粦瀹氱殑琛ㄥ崟
+
+ Map<String, Object> data = new HashMap<>(1);
+ if (StringUtils.isNotBlank(task.getFormKey())) {
+ SysForm sysForm = formService.selectSysFormById(Long.parseLong(task.getFormKey()));
+ if (Objects.nonNull(sysForm)) {
+ data.put(ProcessConstants.TASK_FORM_KEY, JSONObject.parseObject(sysForm.getFormContent()));
+ }
+ }
+ // 瀹屾垚浠诲姟
+ flowTaskService.completeSubmitForm(form.getTaskId(), data);
+ }
+ return Result.ok("鎿嶄綔鎴愬姛");
+ }
+
+ @Override
+ public Result taskSupervise(TaskSuperviseForm form) {
+ Task task = taskService.createTaskQuery().taskId(form.getTaskId()).singleResult();
+ if (Objects.isNull(task)) {
+ throw new RuntimeException("浠诲姟涓嶅瓨鍦�");
+ }
+ SuperviseData jsonData = new SuperviseData();
+ jsonData.setCreateTime(new Date());
+ jsonData.setContent(form.getContent());
+ jsonData.setSenderId(SecurityUtils.getUserId() + "");
+ jsonData.setSenderType(HandlerTypeEnum.USER);
+ jsonData.setReceiverIds(form.getReceiverIds());
+ jsonData.setReceiverType(form.getReceiverType());
+ jsonData.setSuperviseType(form.getSuperviseType());
+
+ ProcessLog processLog = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+ .eq(ProcessLog::getTaskId, form.getTaskId())
+ .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.SUPERVISE)
+ .eq(ProcessLog::getProcessInsId, form.getProcessInsId())
+ .one();
+ List<SuperviseData> dataList;
+ if (processLog != null) {
+ String eventDataJson = processLog.getEventDataJson();
+ dataList = JSONArray.parseArray(eventDataJson, SuperviseData.class);
+ } else {
+ processLog = new ProcessLog();
+ processLog.setUserId(SecurityUtils.getUserId());
+ dataList = new ArrayList<>();
+ }
+ dataList.add(jsonData);
+ //娣诲姞鐫e姙鏃ュ織
+ publisher.publishEvent(new TaskLogEvent(this,
+ processLog.getId(),
+ processLog.getUserId(),
+ form.getProjectId(),
+ form.getProcessInsId(),
+ form.getTaskId(),
+ task.getTaskDefinitionKey(),
+ task.getName(),
+ ProcessLogEventTypeEnum.SUPERVISE,
+ dataList));
+ return Result.ok("鎿嶄綔鎴愬姛");
+ }
+
+ @Override
+ @Synchronized
+ public Result taskHangup(TaskHangupForm form) {
+ Task task = taskService.createTaskQuery().taskId(form.getTaskId()).singleResult();
+ if (Objects.isNull(task)) {
+ throw new RuntimeException("浠诲姟涓嶅瓨鍦�");
+ }
+ List<ProcessLog> logs = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+ .eq(ProcessLog::getTaskId, form.getTaskId())
+ .eq(ProcessLog::getProcessInsId, form.getProcessInsId())
+ .eq(ProcessLog::getProjectId, form.getProjectId())
+ .in(ProcessLog::getEventType, ProcessLogEventTypeEnum.HANGUP, ProcessLogEventTypeEnum.CANCEL_HANGUP)
+ .list();
+ if (logs.size() % 2 != 0) {
+ throw new RuntimeException("璇ヤ换鍔℃鍦ㄦ寕璧蜂腑锛屼笉鑳藉啀娆℃寕璧�");
+ }
+ // 浠诲姟鎸傝捣鍙渶瑕佸瓨鏃ュ織锛屾煡璇㈠緟鍔炴椂濡傛灉鏈夎繖涓棩蹇楄褰曪紝鍒欑鐢ㄦ彁浜ゆ寜閽紝浠ユ瀹炵幇浠诲姟鎸傝捣
+ publisher.publishEvent(new TaskLogEvent(this,
+ null,
+ SecurityUtils.getUserId(),
+ form.getProjectId(),
+ form.getProcessInsId(),
+ form.getTaskId(),
+ task.getTaskDefinitionKey(),
+ task.getName(),
+ ProcessLogEventTypeEnum.HANGUP,
+ new HangupData(form.getReason())
+ ));
+ return Result.ok("鎿嶄綔鎴愬姛");
+ }
+
+ @Override
+ @Synchronized
+ public Result cancelTaskHangup(TaskHangupForm form) {
+ Task task = taskService.createTaskQuery().taskId(form.getTaskId()).singleResult();
+ if (Objects.isNull(task)) {
+ throw new RuntimeException("浠诲姟涓嶅瓨鍦�");
+ }
+ List<ProcessLog> logs = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+ .eq(ProcessLog::getTaskId, form.getTaskId())
+ .eq(ProcessLog::getProcessInsId, form.getProcessInsId())
+ .eq(ProcessLog::getProjectId, form.getProjectId())
+ .in(ProcessLog::getEventType, ProcessLogEventTypeEnum.HANGUP, ProcessLogEventTypeEnum.CANCEL_HANGUP)
+ .list();
+ if (logs.size() % 2 == 0) {
+ throw new RuntimeException("璇ヤ换鍔℃湭琚寕璧凤紝涓嶈兘鍙栨秷鎸傝捣");
+ }
+ publisher.publishEvent(new TaskLogEvent(this,
+ null,
+ SecurityUtils.getUserId(),
+ form.getProjectId(),
+ form.getProcessInsId(),
+ form.getTaskId(),
+ task.getTaskDefinitionKey(),
+ task.getName(),
+ ProcessLogEventTypeEnum.CANCEL_HANGUP,
+ new HangupData(form.getReason())
+ ));
+ return Result.ok("鎿嶄綔鎴愬姛");
+ }
+
+ @Override
+ public Result taskTeamwork(TaskTeamWorkForm form) {
+ Task task = taskService.createTaskQuery().taskId(form.getTaskId()).singleResult();
+ if (Objects.isNull(task)) {
+ return Result.error("浠诲姟涓嶅瓨鍦�");
+ }
+ ProjectProcess projectProcess = new LambdaQueryChainWrapper<>(projectProcessMapper)
+ .eq(ProjectProcess::getProcessInsId, task.getProcessInstanceId())
+ .eq(ProjectProcess::getProcessDefId, task.getProcessDefinitionId())
+ .one();
+ if (Objects.isNull(projectProcess)) {
+ return Result.error("椤圭洰娴佺▼鏈粦瀹�");
+ }
+ // 1. 淇濆瓨鍙戣捣浜哄~鍐欑殑琛ㄥ崟鏁版嵁锛屼絾涓嶇洿鎺ュ畬鎴愯浠诲姟銆傛彁浜ゅ悗浠诲姟澶勭悊浜哄繀椤荤瓑鍒板崗鍚屼汉澶勭悊瀹屼箣鍚庢墠鑳藉畬鎴愪换鍔�
+ Map<String, Object> processVariables = new HashMap<>();
+ //鏌ュ嚭瀛楀吀涓渶瑕佹敞鍏ョ殑瀛楁淇℃伅
+ List<String> dictList = dictTypeService.selectDictDataByType("flow_variables").stream().map(SysDictData::getDictValue).collect(Collectors.toList());
+ Map<String, Object> newV = new HashMap<>(2);
+ if (!org.springframework.util.CollectionUtils.isEmpty(form.getVariables())) {
+ for (String key : form.getVariables().keySet()) {
+ newV.put(task.getTaskDefinitionKey() + "&" + key, form.getVariables().get(key));
+ //瀛楀吀閲屾湁灏辨斁鍏ユ祦绋嬪彉閲忎腑
+ if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(dictList) && dictList.contains(key)) {
+ processVariables.put(key, form.getVariables().get(key));
+ }
+ }
+ }
+ if (!processVariables.isEmpty()) {
+ taskService.setVariables(form.getTaskId(), processVariables);
+ }
+
+ // 2. 淇濆瓨鏃ュ織
+ publisher.publishEvent(new TaskLogEvent(this,
+ null,
+ SecurityUtils.getUserId(),
+ form.getProjectId(),
+ form.getProcessInsId(),
+ form.getTaskId(),
+ task.getTaskDefinitionKey(),
+ task.getName(),
+ ProcessLogEventTypeEnum.TEAM_WORK,
+ new TeamWorkData(form.getHandlerType(), form.getHandlerIds(), TeamWorkStatusEnum.NOT_FINISHED)
+ ));
+ return Result.ok("鎿嶄綔鎴愬姛");
}
/**
* 鏌ヨ寰呭姙浠诲姟
*
+ * @param projectId
* @param processInsId
* @param taskName
* @param pageSize
* @param pageNum
* @param result
*/
- public void getTodoTaskList(String processInsId, String taskName, int pageSize, int pageNum, Result result) {
+ public void getTodoTaskList(Long projectId, String processInsId, String taskName, int pageSize, int pageNum, Result result) {
TaskQuery taskQuery = taskService.createTaskQuery()
.active()
.processInstanceId(processInsId)
.includeProcessVariables()
- .orderByTaskCreateTime().desc();
+ .orderByTaskCreateTime()
+ .desc();
if (StringUtils.isNotBlank(taskName)) {
- taskQuery.processDefinitionNameLike(taskName);
+ taskQuery.taskNameLike(taskName);
}
result.total(taskQuery.count());
List<Task> taskList = taskQuery.listPage(pageSize * (pageNum - 1), pageSize);
List<CustomerTaskVO> vos = new ArrayList<>();
for (Task task : taskList) {
CustomerTaskVO taskVO = new CustomerTaskVO();
- this.setRuntimeTaskInfo(task, taskVO);
+ this.setRuntimeTaskInfo(task, taskVO, projectId);
+ // 妫�鏌ユ槸鍚︽寕璧�
+ if (processLogService.taskIsHangup(task.getId(), task.getProcessInstanceId())) {
+ taskVO.setTaskStatus(TaskStatusEnum.HANGUP);
+ }
vos.add(taskVO);
}
result.put("taskList", vos);
@@ -605,6 +864,7 @@
/**
* 鑾峰彇鎵�鏈変换鍔�
*
+ * @param projectId 椤圭洰id
* @param processDefinitionId 娴佺▼杩愯id
* @param processInsId 娴佺▼瀹炰緥id
* @param pageNum
@@ -612,7 +872,7 @@
* @param result
* @return
*/
- private List<CustomerTaskVO> getAllUserTask(String processDefinitionId, String processInsId, String taskName, Integer pageNum, Integer pageSize, Result result) {
+ private List<CustomerTaskVO> getAllUserTask(Long projectId, String processDefinitionId, String processInsId, String taskName, Integer pageNum, Integer pageSize, Result result) {
int startNum = pageSize * (pageNum - 1);
int endNum = startNum + pageSize;
List<UserTask> allUserTaskElement = this.getAllUserTaskElement(processDefinitionId);
@@ -631,7 +891,7 @@
ProcessInstance process = runtimeService.createProcessInstanceQuery().processInstanceId(processInsId).singleResult();
if (Objects.isNull(process)) {
// 濡傛灉杩愯鏃舵壘涓嶅埌璇存槑鏄凡瀹屾垚鐨勬祦绋嬶紝鐩存帴鏌ュ巻鍙蹭换鍔�
- List<CustomerTaskVO> vos = this.getFinishedProcessTaskInfo(userTasks, processInsId, processDefinitionId);
+ List<CustomerTaskVO> vos = this.getFinishedProcessTaskInfo(userTasks, projectId, processInsId, processDefinitionId);
result.data(vos);
return vos;
}
@@ -653,6 +913,16 @@
List<String> handlerNames = new ArrayList<>(2);
List<Long> handlerUnitIds = new ArrayList<>(2);
List<String> handlerUnitNames = new ArrayList<>(2);
+ List<String> promoterNames = new ArrayList<>(2);
+ List<String> promoterUnitNames = new ArrayList<>(2);
+ vo.setHandlerId(handlerIds);
+ vo.setHandlerName(handlerNames);
+ vo.setHandlerUnitId(handlerUnitIds);
+ vo.setHandlerUnitName(handlerUnitNames);
+ vo.setPromoterName(promoterNames);
+ vo.setPromoterUnitName(promoterUnitNames);
+
+ this.setCandidateInfo(userTask, vo, projectId, processInsId);
if (Objects.isNull(task)) {
// 濡傛灉浠诲姟鍦ㄨ繍琛屾椂娌℃壘鍒帮紝閭d箞鍙兘涓烘湭寮�濮嬫垨鑰呭凡瀹屾垚锛岄渶瑕佷粠鍘嗗彶浠诲姟涓啀鎵句竴涓�
@@ -664,15 +934,13 @@
.desc()
.list();
if (CollectionUtils.isEmpty(historicTasks)) {
- vo.setPromoterName("鏆傛棤");
- vo.setPromoterUnitName("鏆傛棤");
// 鏈紑濮嬬殑浠诲姟锛屽叾鍏宠仈鐨勭敤鎴风粍杩欎簺閮藉彲浠ヤ粠UserTask涓嬁鍒帮紝鍥犱负鏈韩鏈紑濮嬬殑浠诲姟鏄病鏈塼ask鐨勶紝鎵�浠ヨ繖閲岀洿鎺ユ煡
if (StringUtils.isNotBlank(userTask.getAssignee())) {
vo.setHandlerType(HandlerTypeEnum.USER);
SysUser sysUser = sysUserService.selectUserById(Long.parseLong(userTask.getAssignee()));
if (Objects.nonNull(sysUser)) {
handlerIds.add(sysUser.getUserId());
- handlerNames.add(sysUser.getNickName());
+ handlerNames.add(this.getUserShowName(sysUser));
if (Objects.nonNull(sysUser.getDept())) {
handlerUnitIds.add(sysUser.getDept().getDeptId());
handlerUnitNames.add(sysUser.getDept().getDeptName());
@@ -681,7 +949,11 @@
} else if (CollectionUtil.isNotEmpty(userTask.getCandidateGroups())) {
List<String> groupIds = userTask.getCandidateGroups();
for (String groupId : groupIds) {
- if (groupId.startsWith("dept")) { // 閮ㄩ棬鐨刬d鏄姞浜嗗墠缂�鐨勫锛歞ept:1
+ // 澶勭悊鍙橀噺琛ㄨ揪寮忥紝DATA_LAUNCH鍙彲鑳芥槸閮ㄩ棬涓嶄細鏄鑹诧紝鍥犱负浠h〃鐨勬槸涓氫富閮ㄩ棬
+ if (groupId.contains(ProcessConstants.DATA_LAUNCH)) {
+ vo.setHandlerType(HandlerTypeEnum.DEPT);
+ this.varYzReview(vo, projectId, processInsId, HandlerTypeEnum.DEPT, 1);
+ } else if (groupId.startsWith("dept")) { // 閮ㄩ棬鐨刬d鏄姞浜嗗墠缂�鐨勫锛歞ept:1
vo.setHandlerType(HandlerTypeEnum.DEPT);
String[] split = groupId.split(":");
if (split.length > 1) {
@@ -690,7 +962,7 @@
if (Objects.nonNull(dept)) {
handlerUnitIds.add(dept.getDeptId());
handlerUnitNames.add(dept.getDeptName());
-
+ handlerNames.add(this.getDeptLeaderShowName(dept));
}
}
} else {
@@ -716,17 +988,15 @@
SysUser handlerUser = sysUserService.selectUserById(handlerUserId);
if (Objects.nonNull(handlerUser)) {
handlerIds.add(handlerUserId);
- handlerNames.add(handlerUser.getNickName());
- vo.setActualHandlerUserId(historicTasks.get(0).getAssignee());
- vo.setActualHandlerUserName(handlerUser.getNickName());
+ handlerNames.add(this.getUserShowName(handlerUser));
+ if (Objects.nonNull(handlerUser.getDept())) {
+ handlerUnitNames.add(handlerUser.getDept().getDeptName());
+ handlerUnitIds.add(handlerUser.getDept().getDeptId());
+ }
}
vo.setTaskDefinitionKey(historicTasks.get(0).getTaskDefinitionKey());
this.setPromoterAndHandler(vo, historicTasks.get(0).getIdentityLinks());
}
- vo.setHandlerId(handlerIds);
- vo.setHandlerName(handlerNames);
- vo.setHandlerUnitId(handlerUnitIds);
- vo.setHandlerUnitName(handlerUnitNames);
} else {
vo.setTaskStatus(TaskStatusEnum.TODO);
vo.setTaskId(task.getId());
@@ -735,9 +1005,9 @@
vo.setTaskDefinitionKey(task.getTaskDefinitionKey());
this.setPromoterAndHandler(vo, null);
- this.setRuntimeTaskInfo(task, vo);
+ this.setRuntimeTaskInfo(task, vo, projectId);
}
-
+ this.distinctVo(vo);
return vo;
}).collect(Collectors.toList());
result.data(vos);
@@ -747,13 +1017,16 @@
/**
* 鏌ヨ宸插畬鎴愮殑娴佺▼鐨勪换鍔′俊鎭�
*
- * @param userTasks 浠诲姟鑺傜偣鍒楄〃
+ * @param userTasks 浠诲姟鑺傜偣鍒楄〃
* @param processInsId 娴佺▼瀹炰緥id
* @param processDefId 娴佺▼瀹氫箟id
* @return
*/
- private List<CustomerTaskVO> getFinishedProcessTaskInfo(List<UserTask> userTasks, String processInsId, String processDefId) {
+ private List<CustomerTaskVO> getFinishedProcessTaskInfo(List<UserTask> userTasks, Long projectId, String processInsId, String processDefId) {
HistoricProcessInstance hisProcess = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInsId).singleResult();
+ if (Objects.isNull(hisProcess)) {
+ return new ArrayList<>();
+ }
List<CustomerTaskVO> vos = userTasks.stream().map(userTask -> {
CustomerTaskVO vo = new CustomerTaskVO();
vo.setProcessInsId(hisProcess.getId());
@@ -761,6 +1034,23 @@
vo.setDeployId(hisProcess.getDeploymentId());
vo.setTaskName(userTask.getName());
vo.setProcessName(hisProcess.getProcessDefinitionName());
+
+ // 涓�涓换鍔″彲鑳芥湁澶氫釜鍊欓�変汉/缁勶紝鎵�浠ラ渶瑕佷娇鐢╨ist
+ List<Long> handlerIds = new ArrayList<>(2);
+ List<String> handlerNames = new ArrayList<>(2);
+ List<Long> handlerUnitIds = new ArrayList<>(2);
+ List<String> handlerUnitNames = new ArrayList<>(2);
+ List<String> promoterNames = new ArrayList<>(2);
+ List<String> promoterUnitNames = new ArrayList<>(2);
+ vo.setHandlerId(handlerIds);
+ vo.setHandlerName(handlerNames);
+ vo.setHandlerUnitId(handlerUnitIds);
+ vo.setHandlerUnitName(handlerUnitNames);
+ vo.setPromoterName(promoterNames);
+ vo.setPromoterUnitName(promoterUnitNames);
+
+
+ this.setCandidateInfo(userTask, vo, projectId, processInsId);
// 鏌ュ涓槸鍥犱负椹冲洖鍚庝細鏌ュ嚭涓ゆ潯鍙婁互涓婏紝鍙栨渶鏂颁竴鏉�
List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
@@ -794,10 +1084,11 @@
/**
* 璁剧疆杩愯鏃朵换鍔$殑淇℃伅
*
- * @param task 浠诲姟
- * @param taskVO 浠诲姟vo
+ * @param task 浠诲姟
+ * @param taskVO 浠诲姟vo
+ * @param projectId 椤圭洰id
*/
- private void setRuntimeTaskInfo(Task task, CustomerTaskVO taskVO) {
+ private void setRuntimeTaskInfo(Task task, CustomerTaskVO taskVO, Long projectId) {
// 褰撳墠娴佺▼淇℃伅
taskVO.setTaskId(task.getId());
taskVO.setCreateTime(task.getCreateTime());
@@ -806,39 +1097,56 @@
taskVO.setTaskName(task.getName());
taskVO.setTaskStatus(TaskStatusEnum.TODO);
// 娴佺▼瀹氫箟淇℃伅
- ProcessDefinition pd = repositoryService.createProcessDefinitionQuery()
- .processDefinitionId(task.getProcessDefinitionId())
- .singleResult();
- taskVO.setDeployId(pd.getDeploymentId());
- taskVO.setProcessName(pd.getName());
+ ProcessInstance process = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
+ String deployId = "";
+ String processName = "";
+ if (Objects.nonNull(process)) {
+ deployId = process.getDeploymentId();
+ processName = process.getProcessDefinitionName();
+ } else {
+ HistoricProcessInstance hisProcess = historyService.createHistoricProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
+ deployId = hisProcess.getDeploymentId();
+ processName = hisProcess.getProcessDefinitionName();
+ }
+ taskVO.setDeployId(deployId);
+ taskVO.setProcessName(processName);
taskVO.setProcessInsId(task.getProcessInstanceId());
taskVO.setTaskDefinitionKey(task.getTaskDefinitionKey());
-
- // 娴佺▼鍙戣捣浜轰俊鎭�
- this.setPromoterInfo(taskVO);
// 涓�涓换鍔″彲鑳芥湁澶氫釜鍊欓�変汉/缁勶紝鎵�浠ラ渶瑕佷娇鐢╨ist
List<Long> handlerIds = new ArrayList<>(2);
List<String> handlerNames = new ArrayList<>(2);
List<Long> handlerUnitIds = new ArrayList<>(2);
List<String> handlerUnitNames = new ArrayList<>(2);
+ List<String> promoterNames = new ArrayList<>(2);
+ List<String> promoterUnitNames = new ArrayList<>(2);
+ taskVO.setHandlerId(handlerIds);
+ taskVO.setHandlerName(handlerNames);
+ taskVO.setHandlerUnitId(handlerUnitIds);
+ taskVO.setHandlerUnitName(handlerUnitNames);
+ taskVO.setPromoterName(promoterNames);
+ taskVO.setPromoterUnitName(promoterUnitNames);
// 娴佺▼澶勭悊浜轰俊鎭�
List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(task.getId());
for (IdentityLinkInfo identityLink : identityLinksForTask) {
-// if (StringUtils.isBlank(((IdentityLinkEntityImpl)identityLink).getId())) {
-// continue;
-// }
// 缁戝畾鐨勬槸鐢ㄦ埛锛屾煡鍑虹敤鎴峰鍚嶃�侀儴闂�
if (StringUtils.isNotBlank(identityLink.getUserId())) {
+ // 澶勭悊鍙橀噺琛ㄨ揪寮忥紝杩愯涓殑浠诲姟鏃犻渶鍐嶅鐞嗚〃杈惧紡浜嗭紝flowable宸茬粡鑷姩鏍规嵁鍙橀噺璁剧疆浜�
+// if (identityLink.getUserId().contains(ProcessConstants.DATA_LAUNCH)) {
+// this.varReview(taskVO, projectId, task.getProcessInstanceId());
+// continue;
+// }
taskVO.setHandlerType(HandlerTypeEnum.USER);
SysUser sysUser = sysUserService.selectUserById(Long.parseLong(identityLink.getUserId()));
if (Objects.nonNull(sysUser)) {
- handlerIds.add(sysUser.getUserId());
- handlerNames.add(sysUser.getNickName());
+ taskVO.getHandlerId().add(sysUser.getUserId());
+ taskVO.getHandlerName().add(this.getUserShowName(sysUser));
if (Objects.nonNull(sysUser.getDept())) {
- handlerUnitIds.add(sysUser.getDept().getDeptId());
- handlerUnitNames.add(sysUser.getDept().getDeptName());
+ taskVO.getHandlerUnitId().add(sysUser.getDept().getDeptId());
+ taskVO.getHandlerUnitName().add(sysUser.getDept().getDeptName());
+ taskVO.getPromoterName().add(this.getUserShowName(sysUser));
+ taskVO.getPromoterUnitName().add(sysUser.getDept().getDeptName());
}
}
// 缁戝畾鐨勬槸瑙掕壊鎴栬�呴儴闂�
@@ -850,29 +1158,471 @@
// 閮ㄩ棬
SysDept dept = sysDeptService.selectDeptById(Long.parseLong(split[1]));
if (Objects.nonNull(dept)) {
- handlerUnitIds.add(dept.getDeptId());
- handlerUnitNames.add(dept.getDeptName());
+ taskVO.getHandlerUnitId().add(dept.getDeptId());
+ taskVO.getHandlerUnitName().add(dept.getDeptName());
+ taskVO.getPromoterName().add(this.getDeptLeaderShowName(dept));
+ taskVO.getPromoterUnitName().add(dept.getDeptName());
}
}
} else {
taskVO.setHandlerType(HandlerTypeEnum.ROLE);
SysRole role = sysRoleService.selectRoleById(Long.parseLong(identityLink.getGroupId()));
if (Objects.nonNull(role)) {
- handlerUnitIds.add(Long.parseLong(identityLink.getGroupId()));
- handlerUnitNames.add(role.getRoleName());
+ taskVO.getHandlerUnitId().add(Long.parseLong(identityLink.getGroupId()));
+ taskVO.getHandlerUnitName().add(role.getRoleName());
}
}
}
- taskVO.setHandlerId(handlerIds);
- taskVO.setHandlerName(handlerNames);
- taskVO.setHandlerUnitId(handlerUnitIds);
- taskVO.setHandlerUnitName(handlerUnitNames);
+ this.distinctVo(taskVO);
}
+ }
+
+ /**
+ * 缁熻鎸夋椂瀹屾垚鐨勪换鍔�
+ *
+ * @param processInsId 娴佺▼瀹炰緥id
+ * @return
+ */
+ private Long getTimelyTaskNum(String processInsId) {
+ // 鏌ュ嚭宸插畬鎴愮殑浠诲姟key
+ List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
+ .processInstanceId(processInsId)
+ .finished()
+ .list();
+ hisTaskList = this.distinctHisTask(hisTaskList);
+ if (CollectionUtils.isEmpty(hisTaskList)) {
+ return 0L;
+ }
+
+ List<String> hisTaskKeys = hisTaskList.stream().map(HistoricTaskInstance::getTaskDefinitionKey).distinct().collect(Collectors.toList());
+ Map<String, HistoricTaskInstance> hisTaskMap = hisTaskList.stream().collect(Collectors.toMap(HistoricTaskInstance::getTaskDefinitionKey, his -> his));
+ // 鏌ュ嚭鏃堕棿姝e父鐨勪换鍔ey
+ List<ProcessCoding> codeList = new LambdaQueryChainWrapper<>(processCodingService.getBaseMapper())
+ .eq(ProcessCoding::getProcessInsId, processInsId)
+ .in(ProcessCoding::getTaskDefKey, hisTaskKeys)
+ .list();
+ List<HistoricTaskInstance> finishedTaskList = new ArrayList<>();
+ // 鍒ゆ柇
+ for (String key : hisTaskMap.keySet()) {
+ List<ProcessCoding> targetProcessCodings = codeList.stream().filter(code -> key.equals(code.getTaskDefKey())).collect(Collectors.toList());
+ // 濡傛灉宸插畬鎴愮殑浠诲姟娌′粠鏁版嵁搴撴煡鎵惧嚭鏉ワ紝璇存槑璇ヤ换鍔℃病閰嶇疆璧嬬爜绛夋椂闂达紝鐩存帴璁剧疆涓烘寜鏃跺畬鎴�
+ if (CollectionUtils.isEmpty(targetProcessCodings)) {
+ finishedTaskList.add(hisTaskMap.get(key));
+ } else {
+ // 鎸夌収鏃堕棿闄嶅簭鎺掑垪
+ targetProcessCodings.sort(Comparator.comparing(ProcessCoding::getGmtCreate).reversed());
+ ProcessCoding latestProjectProcess = targetProcessCodings.get(0);
+ if (ProcessOverTimeConstants.NORMAL.equals(latestProjectProcess.getOvertimeStatus()) || StringUtils.isBlank(latestProjectProcess.getOvertimeStatus())) {
+ finishedTaskList.add(hisTaskMap.get(key));
+ }
+ }
+ }
+ return Long.valueOf(finishedTaskList.size());
+ }
+
+ /**
+ * 鏌ヨ鎸夋椂瀹屾垚鐨勪换鍔�
+ *
+ * @param processDefinitionId 娴佺▼瀹氫箟id
+ * @param processInsId 娴佺▼瀹炰緥id
+ * @param taskName 浠诲姟鍚嶇О--鎼滅储鏉′欢
+ * @param pageNum
+ * @param pageSize
+ * @param result
+ * @return
+ */
+ private List<CustomerTaskVO> getTimelyTask(Long projectId, String processDefinitionId, String processInsId, String taskName, Integer pageNum, Integer pageSize, Result result) {
+ int startNum = pageSize * (pageNum - 1);
+ int endNum = startNum + pageSize;
+
+ // 鏌ュ嚭宸插畬鎴愮殑浠诲姟key
+ List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
+ .processInstanceId(processInsId)
+ .finished()
+ .taskNameLike(taskName)
+ .includeIdentityLinks()
+ .orderByTaskCreateTime()
+ .desc()
+ .list();
+ if (CollectionUtils.isEmpty(hisTaskList)) {
+ result.total(0);
+ return new ArrayList<>();
+ }
+
+ List<String> hisTaskKeys = hisTaskList.stream().map(HistoricTaskInstance::getTaskDefinitionKey).distinct().collect(Collectors.toList());
+ Map<String, HistoricTaskInstance> hisTaskMap = this.distinctHisTask(hisTaskList).stream().collect(Collectors.toMap(HistoricTaskInstance::getTaskDefinitionKey, his -> his));
+ // 鏌ュ嚭鏃堕棿姝e父鐨勪换鍔ey
+ List<ProcessCoding> codeList = new LambdaQueryChainWrapper<>(processCodingService.getBaseMapper())
+ .eq(ProcessCoding::getProcessInsId, processInsId)
+ .in(ProcessCoding::getTaskDefKey, hisTaskKeys)
+ .list();
+ List<HistoricTaskInstance> finishedTaskList = new ArrayList<>();
+ // 鍒ゆ柇
+ for (String key : hisTaskMap.keySet()) {
+ List<ProcessCoding> targetProcessCodings = codeList.stream().filter(code -> key.equals(code.getTaskDefKey())).collect(Collectors.toList());
+ // 濡傛灉宸插畬鎴愮殑浠诲姟娌′粠鏁版嵁搴撴煡鎵惧嚭鏉ワ紝璇存槑璇ヤ换鍔℃病閰嶇疆璧嬬爜绛夋椂闂达紝鐩存帴璁剧疆涓烘寜鏃跺畬鎴�
+ if (CollectionUtils.isEmpty(targetProcessCodings)) {
+ finishedTaskList.add(hisTaskMap.get(key));
+ } else {
+ // 鎸夌収鏃堕棿闄嶅簭鎺掑垪
+ targetProcessCodings.sort(Comparator.comparing(ProcessCoding::getGmtCreate).reversed());
+ ProcessCoding latestProjectProcess = targetProcessCodings.get(0);
+ if (ProcessOverTimeConstants.NORMAL.equals(latestProjectProcess.getOvertimeStatus()) || StringUtils.isBlank(latestProjectProcess.getOvertimeStatus())) {
+ finishedTaskList.add(hisTaskMap.get(key));
+ }
+ }
+ }
+
+ if (startNum >= finishedTaskList.size()) {
+ // 濡傛灉璧峰绱㈠紩瓒呭嚭浜嗗垪琛ㄧ殑澶у皬锛岃繑鍥炰竴涓┖鍒楄〃
+ return new ArrayList<>();
+ }
+ result.total(finishedTaskList.size());
+ int end = Math.min(endNum, finishedTaskList.size());
+ List<HistoricTaskInstance> pageFinishedTaskList = finishedTaskList.subList(startNum, end);
+ List<String> taskDefs = pageFinishedTaskList.stream().map(HistoricTaskInstance::getTaskDefinitionKey).collect(Collectors.toList());
+ Map<String, HistoricTaskInstance> keyMap = pageFinishedTaskList.stream().collect(Collectors.toMap(HistoricTaskInstance::getTaskDefinitionKey, his -> his));
+
+ // 寰楀埌鐩爣浠诲姟瀵瑰簲鐨勫畾涔�
+ List<UserTask> finishedUserTaskElement = this.getAllUserTaskElement(processDefinitionId).stream().filter(el -> taskDefs.contains(el.getId())).collect(Collectors.toList());
+ // 鏌ュ嚭娴佺▼
+
+ ProcessInstance process = runtimeService.createProcessInstanceQuery().processInstanceId(processInsId).singleResult();
+ String deployId = "";
+ String processName = "";
+ if (Objects.nonNull(process)) {
+ deployId = process.getDeploymentId();
+ processName = process.getProcessDefinitionName();
+ } else {
+ HistoricProcessInstance hisProcess = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInsId).singleResult();
+ deployId = hisProcess.getDeploymentId();
+ processName = hisProcess.getProcessDefinitionName();
+ }
+
+ String finalDeployId = deployId;
+ String finalProcessName = processName;
+ List<CustomerTaskVO> vos = finishedUserTaskElement.stream().map(userTask -> {
+ CustomerTaskVO vo = new CustomerTaskVO();
+ vo.setProcessInsId(processInsId);
+ vo.setProcessDefId(processDefinitionId);
+ vo.setDeployId(finalDeployId);
+ vo.setTaskName(userTask.getName());
+ vo.setProcessName(finalProcessName);
+
+ // 涓�涓换鍔″彲鑳芥湁澶氫釜鍊欓�変汉/缁勶紝鎵�浠ラ渶瑕佷娇鐢╨ist
+ List<Long> handlerIds = new ArrayList<>(2);
+ List<String> handlerNames = new ArrayList<>(2);
+ List<Long> handlerUnitIds = new ArrayList<>(2);
+ List<String> handlerUnitNames = new ArrayList<>(2);
+ List<String> promoterNames = new ArrayList<>(2);
+ List<String> promoterUnitNames = new ArrayList<>(2);
+ vo.setHandlerId(handlerIds);
+ vo.setHandlerName(handlerNames);
+ vo.setHandlerUnitId(handlerUnitIds);
+ vo.setHandlerUnitName(handlerUnitNames);
+ vo.setPromoterName(promoterNames);
+ vo.setPromoterUnitName(promoterUnitNames);
+
+ this.setCandidateInfo(userTask, vo, projectId, processInsId);
+ HistoricTaskInstance hisTask = keyMap.get(userTask.getId());
+ if (Objects.nonNull(hisTask)) {
+ vo.setTaskStatus(TaskStatusEnum.FINISHED);
+ // 濡傛灉鏄凡瀹屾垚鐨勶紝淇℃伅闇�瑕佸崟鐙祴鍊�
+ vo.setTaskId(hisTask.getId());
+ vo.setExecutionId(hisTask.getExecutionId());
+ vo.setCreateTime(hisTask.getStartTime());
+
+ // 鏌ヨ瀹為檯澶勭悊浜�
+ long handlerUserId = Long.parseLong(hisTask.getAssignee());
+ SysUser handlerUser = sysUserService.selectUserById(handlerUserId);
+ if (Objects.nonNull(handlerUser)) {
+ vo.getHandlerId().add(handlerUserId);
+ vo.getHandlerName().add(this.getUserShowName(handlerUser));
+ }
+ vo.setTaskDefinitionKey(hisTask.getTaskDefinitionKey());
+ this.setPromoterAndHandler(vo, hisTask.getIdentityLinks());
+ }
+
+ this.distinctVo(vo);
+ return vo;
+ }).collect(Collectors.toList());
+ result.data(vos);
+ return vos;
+ }
+
+ /**
+ * 鐢ㄦ埛鍚嶇О鍚庨潰璺熺數璇濆彿鐮�
+ *
+ * @param user
+ * @return
+ */
+ private String getUserShowName(SysUser user) {
+ return user.getNickName() + (StringUtils.isNotBlank(user.getPhonenumber()) ? "(" + user.getPhonenumber() + ")" : "");
+ }
+
+ /**
+ * 閮ㄩ棬璐熻矗浜哄悕绉板悗闈㈣窡鐢佃瘽鍙风爜
+ *
+ * @param dept
+ * @return
+ */
+ private String getDeptLeaderShowName(SysDept dept) {
+ return dept.getLeader() + (StringUtils.isNotBlank(dept.getPhone()) ? "(" + dept.getPhone() + ")" : "");
+ }
+
+ /**
+ * 鏍规嵁浠诲姟key鍘婚噸鍘嗗彶浠诲姟锛岀浉鍚屾儏鍐典笅鍙栨渶鏂扮殑涓�鏉�
+ *
+ * @param hisTaskList
+ * @return
+ */
+ private List<HistoricTaskInstance> distinctHisTask(List<HistoricTaskInstance> hisTaskList) {
+ Map<String, HistoricTaskInstance> uniqueTasks = new HashMap<>();
+ for (HistoricTaskInstance task : hisTaskList) {
+ String taskDefinitionKey = task.getTaskDefinitionKey();
+ HistoricTaskInstance existingTask = uniqueTasks.get(taskDefinitionKey);
+
+ // 濡傛灉浠诲姟key閲嶅锛堝彲鑳借椹冲洖杩囷紝閲嶆柊鎻愪氦瀵艰嚧key閲嶅锛夛紝鍙栨渶杩戠殑涓�鏉�
+ if (existingTask == null || task.getCreateTime().after(existingTask.getCreateTime())) {
+ uniqueTasks.put(taskDefinitionKey, task);
+ }
+ }
+ // 鏈�缁堝幓閲嶅悗鐨勪换鍔″垪琛�
+ return new ArrayList<>(uniqueTasks.values());
+ }
+
+
+ /**
+ * 缁熻瓒呮椂鐨勪换鍔℃暟
+ *
+ * @param processInsId 娴佺▼瀹炰緥id
+ * @return
+ */
+ private Long getOvertimeTaskNum(String processInsId) {
+ // 鏌ュ嚭杩愯鍦ㄧ殑浠诲姟key
+ List<Task> taskList = taskService.createTaskQuery().processInstanceId(processInsId).list();
+
+ if (CollectionUtils.isEmpty(taskList)) {
+ return 0L;
+ }
+ List<String> taskKeys = taskList.stream().map(Task::getTaskDefinitionKey).distinct().collect(Collectors.toList());
+ Map<String, Task> taskMap = taskList.stream().collect(Collectors.toMap(Task::getTaskDefinitionKey, his -> his));
+ // 鏌ュ嚭鏁版嵁搴撶殑浠诲姟key
+ List<ProcessCoding> codeList = new LambdaQueryChainWrapper<>(processCodingService.getBaseMapper())
+ .eq(ProcessCoding::getProcessInsId, processInsId)
+ .in(ProcessCoding::getTaskDefKey, taskKeys)
+ .list();
+ List<Task> tList = new ArrayList<>();
+ // 鍒ゆ柇
+ for (String key : taskMap.keySet()) {
+ List<ProcessCoding> targetProcessCodings = codeList.stream().filter(code -> key.equals(code.getTaskDefKey())).collect(Collectors.toList());
+ // 濡傛灉宸插畬鎴愮殑浠诲姟娌′粠鏁版嵁搴撴煡鎵惧嚭鏉ワ紝璇存槑璇ヤ换鍔℃病閰嶇疆璧嬬爜绛夋椂闂达紝鐩存帴璁剧疆涓烘寜鏃跺畬鎴�
+ if (CollectionUtils.isEmpty(targetProcessCodings)) {
+ tList.add(taskMap.get(key));
+ } else {
+ // 鎸夌収鏃堕棿闄嶅簭鎺掑垪
+ targetProcessCodings.sort(Comparator.comparing(ProcessCoding::getGmtCreate).reversed());
+ ProcessCoding latestProjectProcess = targetProcessCodings.get(0);
+ if (Objects.nonNull(latestProjectProcess) && ProcessOverTimeConstants.OVERTIME.equals(latestProjectProcess.getOvertimeStatus())) {
+ tList.add(taskMap.get(key));
+ }
+ }
+ }
+ return Long.valueOf(taskList.size());
+ }
+
+ /**
+ * 鏌ヨ瓒呮椂鐨勪换鍔�
+ *
+ * @param projectId 椤圭洰id
+ * @param processDefinitionId 娴佺▼瀹氫箟id
+ * @param processInsId 娴佺▼瀹炰緥id
+ * @param taskName 浠诲姟鍚嶇О--鎼滅储鏉′欢
+ * @param pageNum
+ * @param pageSize
+ * @param result
+ * @return
+ */
+ private List<CustomerTaskVO> getOvertimeTask(Long projectId, String processDefinitionId, String processInsId, String taskName, Integer pageNum, Integer pageSize, Result result) {
+ int startNum = pageSize * (pageNum - 1);
+ int endNum = startNum + pageSize;
+
+ // 鏌ュ嚭杩愯鍦ㄧ殑浠诲姟key
+ List<Task> taskList = new ArrayList<>(12);
+ if (StringUtils.isNotBlank(taskName)) {
+ taskList = taskService.createTaskQuery().processInstanceId(processInsId).taskNameLike(taskName).orderByTaskCreateTime().desc().list();
+ } else {
+ taskList = taskService.createTaskQuery().processInstanceId(processInsId).orderByTaskCreateTime().desc().list();
+ }
+ if (CollectionUtils.isEmpty(taskList)) {
+ result.total(0);
+ return new ArrayList<>();
+ }
+ List<String> taskKeys = taskList.stream().map(Task::getTaskDefinitionKey).distinct().collect(Collectors.toList());
+ Map<String, Task> taskMap = taskList.stream().collect(Collectors.toMap(Task::getTaskDefinitionKey, his -> his));
+ // 鏌ュ嚭鏁版嵁搴撶殑浠诲姟key
+ List<ProcessCoding> codeList = new LambdaQueryChainWrapper<>(processCodingService.getBaseMapper())
+ .eq(ProcessCoding::getProcessInsId, processInsId)
+ .in(ProcessCoding::getTaskDefKey, taskKeys)
+ .list();
+ List<Task> tList = new ArrayList<>();
+ // 鍒ゆ柇
+ for (String key : taskMap.keySet()) {
+ List<ProcessCoding> targetProcessCodings = codeList.stream().filter(code -> key.equals(code.getTaskDefKey())).collect(Collectors.toList());
+ // 濡傛灉宸插畬鎴愮殑浠诲姟娌′粠鏁版嵁搴撴煡鎵惧嚭鏉ワ紝璇存槑璇ヤ换鍔℃病閰嶇疆璧嬬爜绛夋椂闂达紝鐩存帴璁剧疆涓烘寜鏃跺畬鎴�
+ if (CollectionUtils.isEmpty(targetProcessCodings)) {
+ tList.add(taskMap.get(key));
+ } else {
+ // 鎸夌収鏃堕棿闄嶅簭鎺掑垪
+ targetProcessCodings.sort(Comparator.comparing(ProcessCoding::getGmtCreate).reversed());
+ ProcessCoding latestProjectProcess = targetProcessCodings.get(0);
+ if (Objects.nonNull(latestProjectProcess) && ProcessOverTimeConstants.OVERTIME.equals(latestProjectProcess.getOvertimeStatus())) {
+ tList.add(taskMap.get(key));
+ }
+ }
+ }
+
+ if (startNum >= tList.size()) {
+ // 濡傛灉璧峰绱㈠紩瓒呭嚭浜嗗垪琛ㄧ殑澶у皬锛岃繑鍥炰竴涓┖鍒楄〃
+ return new ArrayList<>();
+ }
+ result.total(tList.size());
+ int end = Math.min(endNum, tList.size());
+ List<Task> pageTaskList = tList.subList(startNum, end);
+ List<String> taskDefs = pageTaskList.stream().map(Task::getTaskDefinitionKey).collect(Collectors.toList());
+ Map<String, Task> keyMap = pageTaskList.stream().collect(Collectors.toMap(Task::getTaskDefinitionKey, his -> his));
+
+ // 寰楀埌鐩爣浠诲姟瀵瑰簲鐨勫畾涔�
+ List<UserTask> finishedUserTaskElement = this.getAllUserTaskElement(processDefinitionId).stream().filter(el -> taskDefs.contains(el.getId())).collect(Collectors.toList());
+
+ // 鏌ヨ浠诲姟鐩稿叧淇℃伅
+ List<CustomerTaskVO> vos = finishedUserTaskElement.stream().map(userTask -> {
+ Task task = keyMap.get(userTask.getId());
+ CustomerTaskVO vo = new CustomerTaskVO();
+ this.setRuntimeTaskInfo(task, vo, projectId);
+ return vo;
+ }).collect(Collectors.toList());
+ result.data(vos);
+ return vos;
+ }
+
+ /**
+ * 缁熻鍗冲皢瓒呮椂鐨勪换鍔℃暟
+ *
+ * @param processInsId 娴佺▼瀹炰緥id
+ * @return
+ */
+ private Long getWillOvertimeTaskNum(String processInsId) {
+ // 鏌ュ嚭杩愯鍦ㄧ殑浠诲姟key
+ List<Task> taskList = taskService.createTaskQuery().processInstanceId(processInsId).list();
+ if (CollectionUtils.isEmpty(taskList)) {
+ return 0L;
+ }
+ List<String> taskKeys = taskList.stream().map(Task::getTaskDefinitionKey).distinct().collect(Collectors.toList());
+ Map<String, Task> taskMap = taskList.stream().collect(Collectors.toMap(Task::getTaskDefinitionKey, his -> his));
+ // 鏌ュ嚭鏁版嵁搴撶殑浠诲姟key
+ List<ProcessCoding> codeList = new LambdaQueryChainWrapper<>(processCodingService.getBaseMapper())
+ .eq(ProcessCoding::getProcessInsId, processInsId)
+ .in(ProcessCoding::getTaskDefKey, taskKeys)
+ .list();
+ List<Task> tList = new ArrayList<>();
+ // 鍒ゆ柇
+ for (String key : taskMap.keySet()) {
+ List<ProcessCoding> targetProcessCodings = codeList.stream().filter(code -> key.equals(code.getTaskDefKey())).collect(Collectors.toList());
+ // 濡傛灉宸插畬鎴愮殑浠诲姟娌′粠鏁版嵁搴撴煡鎵惧嚭鏉ワ紝璇存槑璇ヤ换鍔℃病閰嶇疆璧嬬爜绛夋椂闂达紝鐩存帴璁剧疆涓烘寜鏃跺畬鎴�
+ if (CollectionUtils.isEmpty(targetProcessCodings)) {
+ tList.add(taskMap.get(key));
+ } else {
+ // 鎸夌収鏃堕棿闄嶅簭鎺掑垪
+ targetProcessCodings.sort(Comparator.comparing(ProcessCoding::getGmtCreate).reversed());
+ ProcessCoding latestProjectProcess = targetProcessCodings.get(0);
+ if (Objects.nonNull(latestProjectProcess) && ProcessOverTimeConstants.WILLOVERTIME.equals(latestProjectProcess.getOvertimeStatus())) {
+ tList.add(taskMap.get(key));
+ }
+ }
+ }
+ return Long.valueOf(tList.size());
+ }
+
+ /**
+ * 鏌ヨ鍗冲皢瓒呮椂鐨勪换鍔�
+ *
+ * @param projectId 椤圭洰id
+ * @param processDefinitionId 娴佺▼瀹氫箟id
+ * @param processInsId 娴佺▼瀹炰緥id
+ * @param taskName 浠诲姟鍚嶇О--鎼滅储鏉′欢
+ * @param pageNum
+ * @param pageSize
+ * @param result
+ * @return
+ */
+ private List<CustomerTaskVO> getWillOvertimeTask(Long projectId, String processDefinitionId, String processInsId, String taskName, Integer pageNum, Integer pageSize, Result result) {
+ int startNum = pageSize * (pageNum - 1);
+ int endNum = startNum + pageSize;
+
+ // 鏌ュ嚭杩愯鍦ㄧ殑浠诲姟key
+ List<Task> taskList = new ArrayList<>(12);
+ if (StringUtils.isNotBlank(taskName)) {
+ taskList = taskService.createTaskQuery().processInstanceId(processInsId).taskNameLike(taskName).orderByTaskCreateTime().desc().list();
+ } else {
+ taskList = taskService.createTaskQuery().processInstanceId(processInsId).orderByTaskCreateTime().desc().list();
+ }
+ if (CollectionUtils.isEmpty(taskList)) {
+ result.total(0);
+ return new ArrayList<>();
+ }
+ List<String> taskKeys = taskList.stream().map(Task::getTaskDefinitionKey).distinct().collect(Collectors.toList());
+ Map<String, Task> taskMap = taskList.stream().collect(Collectors.toMap(Task::getTaskDefinitionKey, his -> his));
+ // 鏌ュ嚭鏁版嵁搴撶殑浠诲姟key
+ List<ProcessCoding> codeList = new LambdaQueryChainWrapper<>(processCodingService.getBaseMapper())
+ .eq(ProcessCoding::getProcessInsId, processInsId)
+ .in(ProcessCoding::getTaskDefKey, taskKeys)
+ .list();
+ List<Task> tList = new ArrayList<>();
+ // 鍒ゆ柇
+ for (String key : taskMap.keySet()) {
+ List<ProcessCoding> targetProcessCodings = codeList.stream().filter(code -> key.equals(code.getTaskDefKey())).collect(Collectors.toList());
+ // 濡傛灉宸插畬鎴愮殑浠诲姟娌′粠鏁版嵁搴撴煡鎵惧嚭鏉ワ紝璇存槑璇ヤ换鍔℃病閰嶇疆璧嬬爜绛夋椂闂达紝鐩存帴璁剧疆涓烘寜鏃跺畬鎴�
+ if (CollectionUtils.isEmpty(targetProcessCodings)) {
+ tList.add(taskMap.get(key));
+ } else {
+ // 鎸夌収鏃堕棿闄嶅簭鎺掑垪
+ targetProcessCodings.sort(Comparator.comparing(ProcessCoding::getGmtCreate).reversed());
+ ProcessCoding latestProjectProcess = targetProcessCodings.get(0);
+ if (Objects.nonNull(latestProjectProcess) && ProcessOverTimeConstants.WILLOVERTIME.equals(latestProjectProcess.getOvertimeStatus())) {
+ tList.add(taskMap.get(key));
+ }
+ }
+ }
+
+ if (startNum >= tList.size()) {
+ // 濡傛灉璧峰绱㈠紩瓒呭嚭浜嗗垪琛ㄧ殑澶у皬锛岃繑鍥炰竴涓┖鍒楄〃
+ return new ArrayList<>();
+ }
+ result.total(tList.size());
+ int end = Math.min(endNum, tList.size());
+ List<Task> pageTaskList = tList.subList(startNum, end);
+ List<String> taskDefs = pageTaskList.stream().map(Task::getTaskDefinitionKey).collect(Collectors.toList());
+ Map<String, Task> keyMap = pageTaskList.stream().collect(Collectors.toMap(Task::getTaskDefinitionKey, his -> his));
+
+ // 寰楀埌鐩爣浠诲姟瀵瑰簲鐨勫畾涔�
+ List<UserTask> finishedUserTaskElement = this.getAllUserTaskElement(processDefinitionId).stream().filter(el -> taskDefs.contains(el.getId())).collect(Collectors.toList());
+
+ // 鏌ヨ浠诲姟鐩稿叧淇℃伅
+ List<CustomerTaskVO> vos = finishedUserTaskElement.stream().map(userTask -> {
+ Task task = keyMap.get(userTask.getId());
+ CustomerTaskVO vo = new CustomerTaskVO();
+ this.setRuntimeTaskInfo(task, vo, projectId);
+ return vo;
+ }).collect(Collectors.toList());
+ result.data(vos);
+ return vos;
}
/**
* 鏌ヨ鍓╀綑浜嬮」锛堟湭寮�濮嬬殑浠诲姟锛�
*
+ * @param projectId 椤圭洰id
* @param processDefinitionId
* @param processInsId
* @param taskName
@@ -881,22 +1631,13 @@
* @param result
* @return
*/
- private List<CustomerTaskVO> getRemainingTask(String processDefinitionId, String processInsId, String taskName, Integer pageNum, Integer pageSize, Result result) {
- int startNum = pageSize * (pageNum - 1);
- int endNum = startNum + pageSize;
- List<UserTask> allUserTaskElement = this.getAllUserTaskElement(processDefinitionId);
-
- if (startNum >= allUserTaskElement.size()) {
- // 濡傛灉璧峰绱㈠紩瓒呭嚭浜嗗垪琛ㄧ殑澶у皬锛岃繑鍥炰竴涓┖鍒楄〃
- return new ArrayList<>();
- }
- if (StringUtils.isNotBlank(taskName)) {
- // 妯℃嫙妯$硦鏌ヨ
- allUserTaskElement = allUserTaskElement.stream().filter(taskEl -> taskEl.getName().contains(taskName)).collect(Collectors.toList());
- }
- result.total(allUserTaskElement.size());
- int end = Math.min(endNum, allUserTaskElement.size());
- List<UserTask> userTasks = allUserTaskElement.subList(startNum, end);
+ private List<CustomerTaskVO> getRemainingTask(Long projectId,
+ String processDefinitionId,
+ String processInsId,
+ String taskName,
+ Integer pageNum,
+ Integer pageSize,
+ Result result) {
// 鏌ュ嚭娴佺▼
ProcessInstance process = runtimeService.createProcessInstanceQuery().processInstanceId(processInsId).singleResult();
if (Objects.isNull(process)) {
@@ -906,87 +1647,153 @@
return vos;
}
- // 涓�涓换鍔″彲鑳芥湁澶氫釜鍊欓�変汉/缁勶紝鎵�浠ラ渶瑕佷娇鐢╨ist
- List<Long> handlerIds = new ArrayList<>(2);
- List<String> handlerNames = new ArrayList<>(2);
- List<Long> handlerUnitIds = new ArrayList<>(2);
- List<String> handlerUnitNames = new ArrayList<>(2);
+ int startNum = pageSize * (pageNum - 1);
+ int endNum = startNum + pageSize;
+ List<UserTask> allUserTaskElement = this.getAllUserTaskElement(processDefinitionId);
+
+ // 鎺掗櫎杩涜涓殑浠诲姟鍜屽凡瀹屾垚鐨勪换鍔�
+ List<String> runTaskKeyList = taskService.createTaskQuery().processInstanceId(processInsId).list().stream().map(Task::getTaskDefinitionKey).collect(Collectors.toList());
+ List<String> finishedTaskKeyList = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInsId).finished().list().stream().map(HistoricTaskInstance::getTaskDefinitionKey).distinct().collect(Collectors.toList());
+ allUserTaskElement = allUserTaskElement.stream().filter(el -> !runTaskKeyList.contains(el.getId()) && !finishedTaskKeyList.contains(el.getId())).collect(Collectors.toList());
+ // 妯℃嫙妯$硦鏌ヨ
+ if (StringUtils.isNotBlank(taskName)) {
+ allUserTaskElement = allUserTaskElement.stream().filter(taskEl -> taskEl.getName().contains(taskName)).collect(Collectors.toList());
+ }
+ if (startNum >= allUserTaskElement.size()) {
+ // 濡傛灉璧峰绱㈠紩瓒呭嚭浜嗗垪琛ㄧ殑澶у皬锛岃繑鍥炰竴涓┖鍒楄〃
+ return new ArrayList<>();
+ }
+ result.total(allUserTaskElement.size());
+ int end = Math.min(endNum, allUserTaskElement.size());
+ List<UserTask> userTasks = allUserTaskElement.subList(startNum, end);
+
// 鍒ゆ柇浠诲姟鐘舵�侊紝鏋勫缓vo
List<CustomerTaskVO> vos = new ArrayList<>(48);
for (UserTask userTask : userTasks) {
CustomerTaskVO vo = new CustomerTaskVO();
+ // 涓�涓换鍔″彲鑳芥湁澶氫釜鍊欓�変汉/缁勶紝鎵�浠ラ渶瑕佷娇鐢╨ist
+ List<Long> handlerIds = new ArrayList<>(2);
+ List<String> handlerNames = new ArrayList<>(2);
+ List<Long> handlerUnitIds = new ArrayList<>(2);
+ List<String> handlerUnitNames = new ArrayList<>(2);
+ List<String> promoterNames = new ArrayList<>(2);
+ List<String> promoterUnitNames = new ArrayList<>(2);
+ vo.setHandlerId(handlerIds);
+ vo.setHandlerName(handlerNames);
+ vo.setHandlerUnitId(handlerUnitIds);
+ vo.setHandlerUnitName(handlerUnitNames);
+ vo.setPromoterName(promoterNames);
+ vo.setPromoterUnitName(promoterUnitNames);
+
vo.setProcessInsId(process.getId());
vo.setProcessDefId(processDefinitionId);
vo.setDeployId(process.getDeploymentId());
vo.setTaskName(userTask.getName());
vo.setProcessName(process.getProcessDefinitionName());
- Task task = taskService.createTaskQuery()
- .processInstanceId(process.getId())
- .taskDefinitionKey(userTask.getId())
- .singleResult();
- if (Objects.isNull(task)) {
- // 濡傛灉浠诲姟鍦ㄨ繍琛屾椂娌℃壘鍒帮紝閭d箞鍙兘涓烘湭寮�濮嬫垨鑰呭凡瀹屾垚锛屽彧鏌ヨ鏈紑濮嬬殑
- List<HistoricTaskInstance> historicTasks = historyService.createHistoricTaskInstanceQuery()
- .processInstanceId(process.getProcessInstanceId())
- .taskDefinitionKey(userTask.getId())
- .includeIdentityLinks()
- .orderByHistoricTaskInstanceStartTime()
- .desc()
- .list();
- if (CollectionUtils.isEmpty(historicTasks)) {
- // 鏈紑濮嬬殑浠诲姟锛屽叾鍏宠仈鐨勭敤鎴风粍杩欎簺閮藉彲浠ヤ粠UserTask涓嬁鍒帮紝鍥犱负鏈韩鏈紑濮嬬殑浠诲姟鏄病鏈塼ask鐨勶紝鎵�浠ヨ繖閲岀洿鎺ユ煡
- if (StringUtils.isNotBlank(userTask.getAssignee())) {
- vo.setHandlerType(HandlerTypeEnum.USER);
- SysUser sysUser = sysUserService.selectUserById(Long.parseLong(userTask.getAssignee()));
- if (Objects.nonNull(sysUser)) {
- handlerIds.add(sysUser.getUserId());
- handlerNames.add(sysUser.getNickName());
- if (Objects.nonNull(sysUser.getDept())) {
- handlerUnitIds.add(sysUser.getDept().getDeptId());
- handlerUnitNames.add(sysUser.getDept().getDeptName());
+ vo.setTaskStatus(TaskStatusEnum.NOT_START);
+
+ this.setCandidateInfo(userTask, vo, projectId, processInsId);
+
+ // 鏈紑濮嬬殑浠诲姟锛屽叾鍏宠仈鐨勭敤鎴风粍杩欎簺閮藉彲浠ヤ粠UserTask涓嬁鍒帮紝鍥犱负鏈韩鏈紑濮嬬殑浠诲姟鏄病鏈塼ask鐨勶紝鎵�浠ヨ繖閲岀洿鎺ユ煡
+ if (StringUtils.isNotBlank(userTask.getAssignee())) {
+ vo.setHandlerType(HandlerTypeEnum.USER);
+ SysUser sysUser = sysUserService.selectUserById(Long.parseLong(userTask.getAssignee()));
+ if (Objects.nonNull(sysUser)) {
+ vo.getHandlerId().add(sysUser.getUserId());
+ vo.getHandlerName().add(sysUser.getNickName());
+ if (Objects.nonNull(sysUser.getDept())) {
+ vo.getHandlerUnitId().add(sysUser.getDept().getDeptId());
+ vo.getHandlerUnitName().add(sysUser.getDept().getDeptName());
+ }
+ }
+ } else if (CollectionUtil.isNotEmpty(userTask.getCandidateGroups())) {
+ List<String> groupIds = userTask.getCandidateGroups();
+ for (String groupId : groupIds) {
+ // 澶勭悊鍙橀噺琛ㄨ揪寮忥紝DATA_LAUNCH鍙彲鑳芥槸閮ㄩ棬涓嶄細鏄鑹诧紝鍥犱负浠h〃鐨勬槸涓氫富閮ㄩ棬
+ if (groupId.contains(ProcessConstants.DATA_LAUNCH)) {
+ vo.setHandlerType(HandlerTypeEnum.DEPT);
+ this.varYzReview(vo, projectId, processInsId, HandlerTypeEnum.DEPT, 1);
+ } else if (groupId.startsWith("dept")) { // 閮ㄩ棬鐨刬d鏄姞浜嗗墠缂�鐨勫锛歞ept:1
+ vo.setHandlerType(HandlerTypeEnum.DEPT);
+ String[] split = groupId.split(":");
+ if (split.length > 1) {
+ // 閮ㄩ棬
+ SysDept dept = sysDeptService.selectDeptById(Long.parseLong(split[1]));
+ if (Objects.nonNull(dept)) {
+ vo.getHandlerUnitId().add(dept.getDeptId());
+ vo.getHandlerUnitName().add(dept.getDeptName());
}
}
- } else if (CollectionUtil.isNotEmpty(userTask.getCandidateGroups())) {
- List<String> groupIds = userTask.getCandidateGroups();
- for (String groupId : groupIds) {
- if (groupId.startsWith("dept")) { // 閮ㄩ棬鐨刬d鏄姞浜嗗墠缂�鐨勫锛歞ept:1
- vo.setHandlerType(HandlerTypeEnum.DEPT);
- String[] split = groupId.split(":");
- if (split.length > 1) {
- // 閮ㄩ棬
- SysDept dept = sysDeptService.selectDeptById(Long.parseLong(split[1]));
- if (Objects.nonNull(dept)) {
- handlerUnitIds.add(dept.getDeptId());
- handlerUnitNames.add(dept.getDeptName());
-
- }
- }
- } else {
- vo.setHandlerType(HandlerTypeEnum.ROLE);
- SysRole role = sysRoleService.selectRoleById(Long.parseLong(groupId));
- if (Objects.nonNull(role)) {
- handlerUnitIds.add(role.getRoleId());
- handlerUnitNames.add(role.getRoleName());
- }
- }
+ } else {
+ vo.setHandlerType(HandlerTypeEnum.ROLE);
+ SysRole role = sysRoleService.selectRoleById(Long.parseLong(groupId));
+ if (Objects.nonNull(role)) {
+ vo.getHandlerUnitId().add(role.getRoleId());
+ vo.getHandlerUnitName().add(role.getRoleName());
}
}
- vo.setTaskStatus(TaskStatusEnum.NOT_START);
- vo.setHandlerId(handlerIds);
- vo.setHandlerName(handlerNames);
- vo.setHandlerUnitId(handlerUnitIds);
- vo.setHandlerUnitName(handlerUnitNames);
- } else {
- continue;
}
- } else {
- this.setRuntimeTaskInfo(task, vo);
}
+ this.distinctVo(vo);
vos.add(vo);
}
result.data(vos);
return vos;
+ }
+
+ /**
+ * 瀵逛换鍔′俊鎭腑澶勭悊浜虹殑鍘婚噸
+ *
+ * @param vo
+ */
+ private void distinctVo(CustomerTaskVO vo) {
+ vo.setHandlerId(vo.getHandlerId().stream().distinct().collect(Collectors.toList()));
+ vo.setHandlerName(vo.getHandlerName().stream().distinct().collect(Collectors.toList()));
+ vo.setHandlerUnitId(vo.getHandlerUnitId().stream().distinct().collect(Collectors.toList()));
+ vo.setHandlerUnitName(vo.getHandlerUnitName().stream().distinct().collect(Collectors.toList()));
+ }
+
+ /**
+ * 澶勭悊娴佺▼鍙橀噺-涓氫富鍗曚綅
+ * @param setType 0 璁剧疆璐d换鍗曚綅 1 璁剧疆鍔炵悊鍗曚綅
+ * @param vo
+ */
+ private void varYzReview(CustomerTaskVO vo, Long projectId, String processInsId, HandlerTypeEnum type, Integer setType) {
+ ProjectProcess projectProcess = new LambdaQueryChainWrapper<>(projectProcessMapper)
+ .eq(ProjectProcess::getProjectId, projectId)
+ .eq(ProjectProcess::getProcessInsId, processInsId)
+ .one();
+ if (Objects.isNull(projectProcess)) {
+ throw new RuntimeException("璇ユ祦绋嬫湭缁戝畾椤圭洰");
+ }
+ if (HandlerTypeEnum.USER.equals(type) || HandlerTypeEnum.FIX_USER.equals(type)) {
+ SysUser user = sysUserService.selectUserById(projectProcess.getDataLaunch());
+ if (Objects.nonNull(user) && Objects.nonNull(user.getDept())) {
+ vo.getHandlerName().add(user.getNickName());
+ vo.getHandlerId().add(user.getUserId());
+ }
+ } else if (HandlerTypeEnum.DEPT.equals(type)) {
+ SysDept dept = deptService.selectDeptById(projectProcess.getDataLaunch());
+ if (Objects.nonNull(dept)) {
+ if (setType == 1) {
+ vo.getHandlerUnitId().add(dept.getDeptId());
+ vo.getHandlerUnitName().add(dept.getDeptName());
+ vo.getHandlerName().add(this.getDeptLeaderShowName(dept));
+ } else {
+ vo.getPromoterUnitName().add(dept.getDeptName());
+ vo.getPromoterName().add(this.getDeptLeaderShowName(dept));
+ }
+ }
+ } else if (HandlerTypeEnum.ROLE.equals(type)) {
+ SysRole role = sysRoleService.selectRoleById(projectProcess.getDataLaunch());
+ if (Objects.nonNull(role)) {
+ vo.getHandlerUnitId().add(role.getRoleId());
+ vo.getHandlerUnitName().add(role.getRoleName());
+ }
+ }
+
+ this.distinctVo(vo);
}
/**
@@ -1009,11 +1816,57 @@
.processInstanceId(process.getProcessInstanceId())
.finished()
.list();
- long num = list.stream().map(HistoricTaskInstance::getTaskDefinitionId).distinct().count();
+ long num = list.stream().map(HistoricTaskInstance::getTaskDefinitionKey).distinct().count();
return totalNum - num;
}
+ /**
+ * 璁剧疆鍊欓�変汉淇℃伅/璐d换鍗曚綅
+ *
+ * @param userTask
+ * @param vo
+ * @param projectId
+ * @param processInsId
+ */
+ private void setCandidateInfo(UserTask userTask, CustomerTaskVO vo, Long projectId, String processInsId) {
+ if (StringUtils.isNotBlank(userTask.getAssignee())) {
+ SysUser sysUser = sysUserService.selectUserById(Long.parseLong(userTask.getAssignee()));
+ if (Objects.nonNull(sysUser)) {
+ if (Objects.nonNull(sysUser.getDept())) {
+ // 濡傛灉鏄寚瀹氱殑鏌愪釜浜猴紝閭d箞璐d换鍗曚綅鏄繖涓汉鎵�鍦ㄧ殑閮ㄩ棬
+ vo.getPromoterUnitName().add(sysUser.getDept().getDeptName());
+ vo.getPromoterName().add(this.getUserShowName(sysUser));
+ }
+ }
+ } else if (CollectionUtil.isNotEmpty(userTask.getCandidateGroups())) {
+ List<String> groupIds = userTask.getCandidateGroups();
+ for (String groupId : groupIds) {
+ // 澶勭悊鍙橀噺琛ㄨ揪寮忥紝DATA_LAUNCH鍙彲鑳芥槸閮ㄩ棬涓嶄細鏄鑹诧紝鍥犱负浠h〃鐨勬槸涓氫富閮ㄩ棬
+ if (groupId.contains(ProcessConstants.DATA_LAUNCH)) {
+ vo.setHandlerType(HandlerTypeEnum.DEPT);
+ this.varYzReview(vo, projectId, processInsId, HandlerTypeEnum.DEPT, 0);
+ } else if (groupId.startsWith("dept")) { // 閮ㄩ棬鐨刬d鏄姞浜嗗墠缂�鐨勫锛歞ept:1
+ vo.setHandlerType(HandlerTypeEnum.DEPT);
+ String[] split = groupId.split(":");
+ if (split.length > 1) {
+ // 閮ㄩ棬
+ SysDept dept = sysDeptService.selectDeptById(Long.parseLong(split[1]));
+ if (Objects.nonNull(dept)) {
+ vo.getPromoterUnitName().add(dept.getDeptName());
+ vo.getPromoterName().add(this.getDeptLeaderShowName(dept));
+ }
+ }
+ } else {
+ vo.setHandlerType(HandlerTypeEnum.ROLE);
+ SysRole role = sysRoleService.selectRoleById(Long.parseLong(groupId));
+ if (Objects.nonNull(role)) {
+ vo.getPromoterUnitName().add(role.getRoleName());
+ }
+ }
+ }
+ }
+ }
/**
* 璁剧疆浠诲姟鐨勫彂璧蜂汉&澶勭悊浜� 鍙湁寰呭姙浠诲姟鍜屽凡瀹屾垚浠诲姟鎵嶄細鎺夎繖涓柟娉�
@@ -1022,19 +1875,23 @@
* @param identityLinkInfos 濡傛灉鏄凡瀹屾垚鐨勪换鍔★紝鐢ㄨ繖涓幓鍙栧叧鑱旂殑鐢ㄦ埛/鐢ㄦ埛缁�
*/
private void setPromoterAndHandler(CustomerTaskVO taskVO, List<? extends IdentityLinkInfo> identityLinkInfos) {
- this.setPromoterInfo(taskVO);
+// this.setPromoterInfo(taskVO);
// 涓�涓换鍔″彲鑳芥湁澶氫釜鍊欓�変汉/缁勶紝鎵�浠ラ渶瑕佷娇鐢╨ist
List<Long> handlerIds = new ArrayList<>(2);
List<String> handlerNames = new ArrayList<>(2);
List<Long> handlerUnitIds = new ArrayList<>(2);
List<String> handlerUnitNames = new ArrayList<>(2);
+ taskVO.setHandlerId(handlerIds);
+ taskVO.setHandlerName(handlerNames);
+ taskVO.setHandlerUnitId(handlerUnitIds);
+ taskVO.setHandlerUnitName(handlerUnitNames);
// 娴佺▼澶勭悊浜轰俊鎭�
if (TaskStatusEnum.TODO.equals(taskVO.getTaskStatus())) {
List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(taskVO.getTaskId());
for (IdentityLink identityLink : identityLinksForTask) {
- if (StringUtils.isBlank(((IdentityLinkEntityImpl)identityLink).getId())) {
+ if (StringUtils.isBlank(((IdentityLinkEntityImpl) identityLink).getId())) {
continue;
}
// 缁戝畾鐨勬槸鐢ㄦ埛锛屾煡鍑虹敤鎴峰鍚嶃�侀儴闂�
@@ -1043,7 +1900,7 @@
if (Objects.nonNull(sysUser)) {
taskVO.setHandlerType(HandlerTypeEnum.USER);
handlerIds.add(sysUser.getUserId());
- handlerNames.add(sysUser.getNickName());
+ handlerNames.add(this.getUserShowName(sysUser));
if (Objects.nonNull(sysUser.getDept())) {
handlerUnitIds.add(sysUser.getDept().getDeptId());
handlerUnitNames.add(sysUser.getDept().getDeptName());
@@ -1080,7 +1937,7 @@
SysUser sysUser = sysUserService.selectUserById(Long.parseLong(identityLink.getUserId()));
if (Objects.nonNull(sysUser)) {
handlerIds.add(sysUser.getUserId());
- handlerNames.add(sysUser.getNickName());
+ handlerNames.add(this.getUserShowName(sysUser));
if (Objects.nonNull(sysUser.getDept())) {
handlerUnitIds.add(sysUser.getDept().getDeptId());
handlerUnitNames.add(sysUser.getDept().getDeptName());
@@ -1110,10 +1967,7 @@
}
}
}
- taskVO.setHandlerId(handlerIds);
- taskVO.setHandlerName(handlerNames);
- taskVO.setHandlerUnitId(handlerUnitIds);
- taskVO.setHandlerUnitName(handlerUnitNames);
+ this.distinctVo(taskVO);
}
/**
@@ -1122,33 +1976,41 @@
* @param taskVO
*/
private void setPromoterInfo(CustomerTaskVO taskVO) {
- // 鍙戣捣浜哄簲涓轰笂涓�鑺傜偣鐨勫鐞嗕汉
- List<String> beforeNodeKey = taskCommonService.getBeforeNodeInfo(taskVO.getProcessDefId(), taskVO.getTaskDefinitionKey());
- List<SysUser> userList = beforeNodeKey.stream().map(key -> {
- List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery()
- .processInstanceId(taskVO.getProcessInsId())
- .taskDefinitionKey(key)
- .orderByHistoricTaskInstanceStartTime()
- .desc()
- .list(); // 涔嬫墍浠ョ敤list鏄洜涓哄鏋滄煇涓换鍔¤椹冲洖杩囷紝涓斿鏋滆浠诲姟鍐嶆鎵ц鏃朵細鏈夊鏉℃暟鎹紝鍙栨渶鏂扮殑涓�鏉�
- if (! CollectionUtils.isEmpty(historicTaskInstances)) {
- // 瀹為檯棰嗗彇杩欎釜浠诲姟鐨勪汉锛屼篃灏辨槸澶勭悊浜�
- String assignee = historicTaskInstances.get(0).getAssignee();
- SysUser startUser = sysUserService.selectUserById(Long.parseLong(assignee));
- return startUser;
- } else {
- return null;
- }
- }).filter(user -> Objects.nonNull(user)).collect(Collectors.toList());
- if (CollectionUtils.isEmpty(userList)) {
- taskVO.setPromoterName("鏆傛棤");
- taskVO.setPromoterUnitName("鏆傛棤");
- } else {
- taskVO.setPromoterId(userList.stream().map(user -> { return user.getUserId() + ""; }).collect(Collectors.joining("銆�")));
- taskVO.setPromoterName(userList.stream().map(user -> { return user.getNickName(); }).collect(Collectors.joining("銆�")));
- taskVO.setPromoterUnitId(userList.stream().filter(user -> Objects.nonNull(user.getDept())).map(user -> { return user.getDept().getDeptId() + "";}).collect(Collectors.joining("銆�")));
- taskVO.setPromoterUnitName(userList.stream().filter(user -> Objects.nonNull(user.getDept())).map(user -> { return user.getDept().getDeptName() + "";}).collect(Collectors.joining("銆�")));
- }
+// // 鍙戣捣浜哄簲涓轰笂涓�鑺傜偣鐨勫鐞嗕汉
+// List<String> beforeNodeKey = taskCommonService.getBeforeNodeInfo(taskVO.getProcessDefId(), taskVO.getTaskDefinitionKey());
+// List<SysUser> userList = beforeNodeKey.stream().map(key -> {
+// List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery()
+// .processInstanceId(taskVO.getProcessInsId())
+// .taskDefinitionKey(key)
+// .orderByHistoricTaskInstanceStartTime()
+// .desc()
+// .list(); // 涔嬫墍浠ョ敤list鏄洜涓哄鏋滄煇涓换鍔¤椹冲洖杩囷紝涓斿鏋滆浠诲姟鍐嶆鎵ц鏃朵細鏈夊鏉℃暟鎹紝鍙栨渶鏂扮殑涓�鏉�
+// if (!CollectionUtils.isEmpty(historicTaskInstances)) {
+// // 瀹為檯棰嗗彇杩欎釜浠诲姟鐨勪汉锛屼篃灏辨槸澶勭悊浜�
+// String assignee = historicTaskInstances.get(0).getAssignee();
+// SysUser startUser = sysUserService.selectUserById(Long.parseLong(assignee));
+// return startUser;
+// } else {
+// return null;
+// }
+// }).filter(user -> Objects.nonNull(user)).collect(Collectors.toList());
+// if (CollectionUtils.isEmpty(userList)) {
+// taskVO.setPromoterName("鏆傛棤");
+// taskVO.setPromoterUnitName("鏆傛棤");
+// } else {
+// taskVO.setPromoterId(userList.stream().map(user -> {
+// return user.getUserId() + "";
+// }).collect(Collectors.joining("銆�")));
+// taskVO.setPromoterName(userList.stream().map(user -> {
+// return this.getUserShowName(user);
+// }).collect(Collectors.joining("銆�")));
+// taskVO.setPromoterUnitId(userList.stream().filter(user -> Objects.nonNull(user.getDept())).map(user -> {
+// return user.getDept().getDeptId() + "";
+// }).collect(Collectors.joining("銆�")));
+// taskVO.setPromoterUnitName(userList.stream().filter(user -> Objects.nonNull(user.getDept())).map(user -> {
+// return user.getDept().getDeptName() + "";
+// }).collect(Collectors.joining("銆�")));
+// }
}
/**
--
Gitblit v1.8.0