Browse Source

🐛 修复ProcessDefinition在redis缓存json模式下报错的问题

test
smallchill 3 years ago
parent
commit
688e4a78f9
  1. 8
      blade-ops/blade-flow/src/main/java/org/springblade/flow/business/service/impl/FlowBusinessServiceImpl.java
  2. 26
      blade-ops/blade-flow/src/main/java/org/springblade/flow/engine/entity/FlowProcess.java
  3. 2
      blade-ops/blade-flow/src/main/java/org/springblade/flow/engine/service/impl/FlowEngineServiceImpl.java
  4. 11
      blade-ops/blade-flow/src/main/java/org/springblade/flow/engine/utils/FlowCache.java

8
blade-ops/blade-flow/src/main/java/org/springblade/flow/business/service/impl/FlowBusinessServiceImpl.java

@ -22,7 +22,6 @@ import org.flowable.engine.HistoryService;
import org.flowable.engine.TaskService;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.history.HistoricProcessInstanceQuery;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
@ -36,6 +35,7 @@ import org.springblade.flow.core.constant.ProcessConstant;
import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.utils.TaskUtil;
import org.springblade.flow.engine.constant.FlowEngineConstant;
import org.springblade.flow.engine.entity.FlowProcess;
import org.springblade.flow.engine.utils.FlowCache;
import org.springframework.stereotype.Service;
@ -148,7 +148,7 @@ public class FlowBusinessServiceImpl implements FlowBusinessService {
flow.setProcessInstanceId(historicProcessInstance.getId());
flow.setHistoryProcessInstanceId(historicProcessInstance.getId());
// ProcessDefinition
ProcessDefinition processDefinition = FlowCache.getProcessDefinition(historicProcessInstance.getProcessDefinitionId());
FlowProcess processDefinition = FlowCache.getProcessDefinition(historicProcessInstance.getProcessDefinitionId());
flow.setProcessDefinitionId(processDefinition.getId());
flow.setProcessDefinitionName(processDefinition.getName());
flow.setProcessDefinitionVersion(processDefinition.getVersion());
@ -216,7 +216,7 @@ public class FlowBusinessServiceImpl implements FlowBusinessService {
flow.setHistoryTaskEndTime(historicTaskInstance.getEndTime());
flow.setVariables(historicTaskInstance.getProcessVariables());
ProcessDefinition processDefinition = FlowCache.getProcessDefinition(historicTaskInstance.getProcessDefinitionId());
FlowProcess processDefinition = FlowCache.getProcessDefinition(historicTaskInstance.getProcessDefinitionId());
flow.setProcessDefinitionId(processDefinition.getId());
flow.setProcessDefinitionName(processDefinition.getName());
flow.setProcessDefinitionKey(processDefinition.getKey());
@ -307,7 +307,7 @@ public class FlowBusinessServiceImpl implements FlowBusinessService {
flow.setBusinessId(businessKey[1]);
}
ProcessDefinition processDefinition = FlowCache.getProcessDefinition(task.getProcessDefinitionId());
FlowProcess processDefinition = FlowCache.getProcessDefinition(task.getProcessDefinitionId());
flow.setCategory(processDefinition.getCategory());
flow.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory()));
flow.setProcessDefinitionId(processDefinition.getId());

26
blade-ops/blade-flow/src/main/java/org/springblade/flow/engine/entity/FlowProcess.java

@ -17,6 +17,7 @@
package org.springblade.flow.engine.entity;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.flowable.engine.impl.persistence.entity.ProcessDefinitionEntityImpl;
import org.springblade.flow.engine.utils.FlowCache;
@ -29,6 +30,7 @@ import java.util.Date;
* @author Chill
*/
@Data
@NoArgsConstructor
public class FlowProcess implements Serializable {
private String id;
@ -45,17 +47,19 @@ public class FlowProcess implements Serializable {
private Date deploymentTime;
public FlowProcess(ProcessDefinitionEntityImpl entity) {
this.id = entity.getId();
this.tenantId = entity.getTenantId();
this.name = entity.getName();
this.key = entity.getKey();
this.category = entity.getCategory();
this.categoryName = FlowCache.getCategoryName(entity.getCategory());
this.version = entity.getVersion();
this.deploymentId = entity.getDeploymentId();
this.resourceName = entity.getResourceName();
this.diagramResourceName = entity.getDiagramResourceName();
this.suspensionState = entity.getSuspensionState();
if (entity != null) {
this.id = entity.getId();
this.tenantId = entity.getTenantId();
this.name = entity.getName();
this.key = entity.getKey();
this.category = entity.getCategory();
this.categoryName = FlowCache.getCategoryName(entity.getCategory());
this.version = entity.getVersion();
this.deploymentId = entity.getDeploymentId();
this.resourceName = entity.getResourceName();
this.diagramResourceName = entity.getDiagramResourceName();
this.suspensionState = entity.getSuspensionState();
}
}
}

2
blade-ops/blade-flow/src/main/java/org/springblade/flow/engine/service/impl/FlowEngineServiceImpl.java

@ -151,7 +151,7 @@ public class FlowEngineServiceImpl extends ServiceImpl<FlowMapper, FlowModel> im
flowExecution.setProcessDefinitionId(execution.getProcessDefinitionId());
flowExecution.setProcessDefinitionKey(execution.getProcessDefinitionKey());
flowExecution.setSuspensionState(execution.getSuspensionState());
ProcessDefinition processDefinition = FlowCache.getProcessDefinition(execution.getProcessDefinitionId());
FlowProcess processDefinition = FlowCache.getProcessDefinition(execution.getProcessDefinitionId());
flowExecution.setCategory(processDefinition.getCategory());
flowExecution.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory()));
flowList.add(flowExecution);

11
blade-ops/blade-flow/src/main/java/org/springblade/flow/engine/utils/FlowCache.java

@ -17,11 +17,14 @@
package org.springblade.flow.engine.utils;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.impl.persistence.entity.ProcessDefinitionEntityImpl;
import org.flowable.engine.repository.ProcessDefinition;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.core.tool.utils.StringPool;
import org.springblade.flow.engine.entity.FlowProcess;
import org.springblade.system.cache.DictCache;
import static org.springblade.core.cache.constant.CacheConstant.FLOW_CACHE;
@ -49,8 +52,12 @@ public class FlowCache {
* @param processDefinitionId 流程对象id
* @return
*/
public static ProcessDefinition getProcessDefinition(String processDefinitionId) {
return CacheUtil.get(FLOW_CACHE, FLOW_DEFINITION_ID , processDefinitionId, () -> getRepositoryService().createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult());
public static FlowProcess getProcessDefinition(String processDefinitionId) {
return CacheUtil.get(FLOW_CACHE, FLOW_DEFINITION_ID, processDefinitionId, () -> {
ProcessDefinition processDefinition = getRepositoryService().createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
ProcessDefinitionEntityImpl processDefinitionEntity = BeanUtil.copy(processDefinition, ProcessDefinitionEntityImpl.class);
return new FlowProcess(processDefinitionEntity);
});
}
/**

Loading…
Cancel
Save