update - 处理老版本流程日志的兼容逻辑
This commit is contained in:
parent
0ab0a5199f
commit
f2072a73b5
6
pom.xml
6
pom.xml
@ -24,6 +24,7 @@
|
|||||||
<mysql.version>8.0.20</mysql.version>
|
<mysql.version>8.0.20</mysql.version>
|
||||||
<dingtalk.version>2.0.0</dingtalk.version>
|
<dingtalk.version>2.0.0</dingtalk.version>
|
||||||
<arthas.version>3.7.1</arthas.version>
|
<arthas.version>3.7.1</arthas.version>
|
||||||
|
<apache-maven.version>3.2.5</apache-maven.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@ -93,6 +94,11 @@
|
|||||||
<artifactId>arthas-spring-boot-starter</artifactId>
|
<artifactId>arthas-spring-boot-starter</artifactId>
|
||||||
<version>${arthas.version}</version>
|
<version>${arthas.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-artifact</artifactId>
|
||||||
|
<version>${apache-maven.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|||||||
@ -84,6 +84,9 @@
|
|||||||
<groupId>cn.axzo.workflow</groupId>
|
<groupId>cn.axzo.workflow</groupId>
|
||||||
<artifactId>workflow-engine-common</artifactId>
|
<artifactId>workflow-engine-common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-artifact</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
package cn.axzo.workflow.core.service.converter;
|
package cn.axzo.workflow.core.service.converter;
|
||||||
|
|
||||||
import cn.axzo.workflow.common.model.response.bpmn.task.BpmnHistoricTaskInstanceVO;
|
import cn.axzo.workflow.common.model.response.bpmn.task.BpmnHistoricTaskInstanceVO;
|
||||||
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
import org.flowable.task.api.history.HistoricTaskInstance;
|
import org.flowable.task.api.history.HistoricTaskInstance;
|
||||||
|
import org.flowable.variable.api.history.HistoricVariableInstance;
|
||||||
|
import org.flowable.variable.service.impl.persistence.entity.HistoricVariableInstanceEntityImpl;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
@ -13,6 +16,7 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static cn.axzo.workflow.common.constant.BpmnConstants.FLOW_SERVER_VERSION_130;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.HIDDEN_ASSIGNEE_ID;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.HIDDEN_ASSIGNEE_ID;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.OLD_TASK_ASSIGNEE_SKIP_FLAT;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.OLD_TASK_ASSIGNEE_SKIP_FLAT;
|
||||||
import static cn.axzo.workflow.core.common.enums.BpmnProcessTaskResultEnum.MI_END;
|
import static cn.axzo.workflow.core.common.enums.BpmnProcessTaskResultEnum.MI_END;
|
||||||
@ -47,7 +51,8 @@ public interface BpmnHistoricTaskInstanceConverter extends EntityConverter<BpmnH
|
|||||||
BpmnHistoricTaskInstanceVO toVo(HistoricTaskInstance entity);
|
BpmnHistoricTaskInstanceVO toVo(HistoricTaskInstance entity);
|
||||||
|
|
||||||
|
|
||||||
default List<BpmnHistoricTaskInstanceVO> toVosSkipSystemOperation(List<HistoricTaskInstance> entities) {
|
default List<BpmnHistoricTaskInstanceVO> toVosSkipSystemOperation(List<HistoricTaskInstance> entities,
|
||||||
|
HistoricVariableInstance instanceVersion) {
|
||||||
if (CollectionUtils.isEmpty(entities)) {
|
if (CollectionUtils.isEmpty(entities)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@ -56,7 +61,22 @@ public interface BpmnHistoricTaskInstanceConverter extends EntityConverter<BpmnH
|
|||||||
.filter(i -> !Objects.equals(i.getAssignee(), HIDDEN_ASSIGNEE_ID))
|
.filter(i -> !Objects.equals(i.getAssignee(), HIDDEN_ASSIGNEE_ID))
|
||||||
.filter(i -> !Objects.equals(i.getDeleteReason(), HIDDEN_ASSIGNEE_ID))
|
.filter(i -> !Objects.equals(i.getDeleteReason(), HIDDEN_ASSIGNEE_ID))
|
||||||
.filter(i -> !Objects.equals(i.getDeleteReason(), MI_END.getStatus()));
|
.filter(i -> !Objects.equals(i.getDeleteReason(), MI_END.getStatus()));
|
||||||
compatibleVersion(taskInstanceStream).forEach(i -> vos.add(toVo(i)));
|
if (Objects.isNull(instanceVersion)) {
|
||||||
|
compatibleVersion(taskInstanceStream).forEach(i -> vos.add(toVo(i)));
|
||||||
|
} else {
|
||||||
|
if (instanceVersion instanceof HistoricVariableInstanceEntityImpl) {
|
||||||
|
String textValue = ((HistoricVariableInstanceEntityImpl) instanceVersion).getTextValue();
|
||||||
|
DefaultArtifactVersion version = new DefaultArtifactVersion(textValue);
|
||||||
|
DefaultArtifactVersion supportVersion = new DefaultArtifactVersion(FLOW_SERVER_VERSION_130);
|
||||||
|
if (version.compareTo(supportVersion) < 0) {
|
||||||
|
compatibleVersion(taskInstanceStream).forEach(i -> vos.add(toVo(i)));
|
||||||
|
} else {
|
||||||
|
taskInstanceStream.forEach(i -> vos.add(toVo(i)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
taskInstanceStream.forEach(i -> vos.add(toVo(i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
return vos;
|
return vos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -91,6 +91,7 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_ACTIVITY_R
|
|||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_INFO;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_INFO;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.NO_ASSIGNEE;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.NO_ASSIGNEE;
|
||||||
import static cn.axzo.workflow.common.constant.BpmnConstants.OLD_INTERNAL_TASK_RELATION_ASSIGNEE_INFO_SNAPSHOT;
|
import static cn.axzo.workflow.common.constant.BpmnConstants.OLD_INTERNAL_TASK_RELATION_ASSIGNEE_INFO_SNAPSHOT;
|
||||||
|
import static cn.axzo.workflow.common.constant.BpmnConstants.WORKFLOW_ENGINE_VERSION;
|
||||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.APPROVED;
|
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.APPROVED;
|
||||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.PROCESSING;
|
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.PROCESSING;
|
||||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.REJECTED;
|
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.REJECTED;
|
||||||
@ -317,11 +318,6 @@ public class BpmnProcessTaskServiceImpl implements BpmnProcessTaskService {
|
|||||||
.list();
|
.list();
|
||||||
taskInstances.forEach(task -> ((HistoricTaskInstanceEntity) task).setCreateTime(((HistoricTaskInstanceEntity) task).getLastUpdateTime()));
|
taskInstances.forEach(task -> ((HistoricTaskInstanceEntity) task).setCreateTime(((HistoricTaskInstanceEntity) task).getLastUpdateTime()));
|
||||||
taskInstances.sort(Comparator.comparing(p -> ((HistoricTaskInstanceEntity) p).getLastUpdateTime()));
|
taskInstances.sort(Comparator.comparing(p -> ((HistoricTaskInstanceEntity) p).getLastUpdateTime()));
|
||||||
// 过滤了多实例或签自动完成的任务
|
|
||||||
List<BpmnHistoricTaskInstanceVO> vos = historicTaskInstanceConverter.toVosSkipSystemOperation(taskInstances);
|
|
||||||
Map<String, List<Comment>> commentByTaskIdMap =
|
|
||||||
taskService.getProcessInstanceComments(processInstanceId).stream()
|
|
||||||
.collect(Collectors.groupingBy(Comment::getTaskId));
|
|
||||||
|
|
||||||
Map<String, HistoricVariableInstance> variableInstanceMap =
|
Map<String, HistoricVariableInstance> variableInstanceMap =
|
||||||
// 不能使用框架提供的历史变量 API 查询,有 BUG
|
// 不能使用框架提供的历史变量 API 查询,有 BUG
|
||||||
@ -331,6 +327,13 @@ public class BpmnProcessTaskServiceImpl implements BpmnProcessTaskService {
|
|||||||
.list().stream()
|
.list().stream()
|
||||||
.collect(Collectors.toMap(HistoricVariableInstance::getVariableName, Function.identity(),
|
.collect(Collectors.toMap(HistoricVariableInstance::getVariableName, Function.identity(),
|
||||||
(s, t) -> s));
|
(s, t) -> s));
|
||||||
|
HistoricVariableInstance instanceVersion = variableInstanceMap.getOrDefault(WORKFLOW_ENGINE_VERSION, null);
|
||||||
|
// 过滤了多实例或签自动完成的任务
|
||||||
|
List<BpmnHistoricTaskInstanceVO> vos = historicTaskInstanceConverter.toVosSkipSystemOperation(taskInstances,
|
||||||
|
instanceVersion);
|
||||||
|
Map<String, List<Comment>> commentByTaskIdMap =
|
||||||
|
taskService.getProcessInstanceComments(processInstanceId).stream()
|
||||||
|
.collect(Collectors.groupingBy(Comment::getTaskId));
|
||||||
|
|
||||||
Map<String, List<Attachment>> attachmentByTaskIdMap =
|
Map<String, List<Attachment>> attachmentByTaskIdMap =
|
||||||
taskService.getProcessInstanceAttachments(processInstanceId).stream()
|
taskService.getProcessInstanceAttachments(processInstanceId).stream()
|
||||||
|
|||||||
@ -18,7 +18,6 @@
|
|||||||
<org.mapstruct.version>1.4.2.Final</org.mapstruct.version>
|
<org.mapstruct.version>1.4.2.Final</org.mapstruct.version>
|
||||||
<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
|
<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
|
||||||
<redisson.version>3.25.0</redisson.version>
|
<redisson.version>3.25.0</redisson.version>
|
||||||
<apache-maven.version>3.2.5</apache-maven.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -115,7 +114,6 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-artifact</artifactId>
|
<artifactId>maven-artifact</artifactId>
|
||||||
<version>${apache-maven.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user