提交 47ec4794 编写于 作者: tangyaolong's avatar tangyaolong

时光轴顺序排序以及未到步骤过滤

上级 6e8568ca
......@@ -24,6 +24,7 @@ import org.flowable.bpmn.model.*;
import org.flowable.bpmn.model.Process;
import org.flowable.common.engine.api.history.HistoricData;
import org.flowable.common.engine.api.identity.AuthenticationContext;
import org.flowable.common.engine.api.query.QueryProperty;
import org.flowable.common.engine.impl.identity.Authentication;
import org.flowable.common.engine.impl.identity.UserIdAuthenticationContext;
import org.flowable.editor.language.json.converter.BpmnJsonConverter;
......@@ -42,6 +43,7 @@ import org.flowable.task.api.DelegationState;
import org.flowable.task.api.Task;
import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.service.impl.TaskQueryProperty;
import org.flowable.task.service.impl.persistence.entity.HistoricTaskInstanceEntity;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl;
......@@ -869,8 +871,13 @@ public class WFCoreService
}
}
}
wfProcessInstance.set("userTasks",nodes.values());
if(!StringUtils.isEmpty(processInstanceId)){
wfProcessInstance.set("userTasks",filterTaskMap(nodes,processInstanceId));
}else {
for (String id : processInstanceIds) {
wfProcessInstance.set("userTasks",filterTaskMap(nodes,id));
}
}
if(!StringUtils.isEmpty(wfProcessInstance.getStartuserid()))
{
wfProcessInstance.setStartusername(wfUserMap.get(wfProcessInstance.getStartuserid()).getDisplayname());
......@@ -881,6 +888,30 @@ public class WFCoreService
}
/**
* 过滤空的task,并按照开始日期进行排序
* @param map
*/
public LinkedHashMap filterTaskMap(Map<String,WFProcessNode> map,String processInstanceId){
List<HistoricTaskInstance> history = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).orderByHistoricTaskInstanceEndTime().desc().list();
LinkedHashMap<String,WFProcessNode> filterMap = new LinkedHashMap<>();
if(history.size()>0){
history.forEach(historyTask -> {
WFProcessNode value = map.get(historyTask.getTaskDefinitionKey());
if (ObjectUtils.isEmpty(value) || filterMap.containsKey(historyTask.getTaskDefinitionKey())) {
return;
}
if (ObjectUtils.isEmpty(value.getExtensionparams().get("identitylinks")) && ObjectUtils.isEmpty(value.getExtensionparams().get("comments"))) {
return;
}
filterMap.put(historyTask.getTaskDefinitionKey(), value);
});
if(filterMap.size() > 0){
return filterMap;
}
}
return (LinkedHashMap) map;
}
@Value("${ibiz.filePath:/app/file/}")
private String fileRoot;
......@@ -1971,12 +2002,10 @@ public class WFCoreService
*/
public boolean delegateTask(String taskId,String delegateUser) {
TaskEntityImpl currTask = (TaskEntityImpl) taskService.createTaskQuery().taskId(taskId).singleResult();
if (currTask != null) {
User currUser = SecurityUtils.getCurrentUserObject();
// 设置审批人是当前登录人
taskService.setAssignee(taskId, currUser.getId());
// 执行委派
if (taskId != null) {
// 委托人是当前用户
String userId=AuthenticationUser.getAuthenticationUser().getUserid();
taskService.setAssignee(taskId, userId);
taskService.delegateTask(taskId,delegateUser);
return true;
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册