提交 4bcadd77 authored 作者: hzh's avatar hzh

代码优化

上级 4768f620
......@@ -97,4 +97,9 @@ public class ProcessInstanceVo implements Serializable {
* 节点配置
*/
private WfNodeConfigVo wfNodeConfigVo;
/**
* 对象信息
*/
private Object entity;
}
......@@ -655,6 +655,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
List<String> processDefinitionIds = StreamUtils.toList(list, ProcessInstanceVo::getProcessDefinitionId);
List<WfNodeConfigVo> wfNodeConfigVoList = wfNodeConfigService.selectByDefIds(processDefinitionIds);
for (ProcessInstanceVo processInstanceVo : list) {
processInstanceVo.setEntity(WorkflowUtils.getHistoricVariableByBusinessKey(processInstanceVo.getBusinessKey(), "entity"));
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(processInstanceVo.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(processInstanceVo::setWfNodeConfigVo);
}
......
......@@ -298,7 +298,7 @@ public class ActTaskServiceImpl implements IActTaskService {
List<String> processDefinitionIds = StreamUtils.toList(taskList, TaskVo::getProcessDefinitionId);
List<WfNodeConfigVo> wfNodeConfigVoList = wfNodeConfigService.selectByDefIds(processDefinitionIds);
for (TaskVo task : taskList) {
task.setEntity(getHistoricVariableByBusinessKey(task.getBusinessKey(), "entity"));
task.setEntity(WorkflowUtils.getHistoricVariableByBusinessKey(task.getBusinessKey(), "entity"));
task.setBusinessStatusName(BusinessStatusEnum.findByStatus(task.getBusinessStatus()));
task.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId(), remoteUserService));
task.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
......@@ -311,19 +311,6 @@ public class ActTaskServiceImpl implements IActTaskService {
return TableDataInfo.build(page);
}
// 查询历史流程变量(返回特定变量)
public Object getHistoricVariableByBusinessKey(String businessKey, String variableName) {
HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery()
.processInstanceBusinessKey(businessKey)
.singleResult();
return historyService.createHistoricVariableInstanceQuery()
.processInstanceId(processInstance.getId())
.variableName(variableName)
.singleResult()
.getValue();
}
/**
* 查询当前租户所有待办任务
*
......@@ -409,7 +396,7 @@ public class ActTaskServiceImpl implements IActTaskService {
List<String> processDefinitionIds = StreamUtils.toList(taskList, TaskVo::getProcessDefinitionId);
List<WfNodeConfigVo> wfNodeConfigVoList = wfNodeConfigService.selectByDefIds(processDefinitionIds);
for (TaskVo task : taskList) {
task.setEntity(getHistoricVariableByBusinessKey(task.getBusinessKey(), "entity"));
task.setEntity(WorkflowUtils.getHistoricVariableByBusinessKey(task.getBusinessKey(), "entity"));
task.setBusinessStatusName(BusinessStatusEnum.findByStatus(task.getBusinessStatus()));
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
......
......@@ -28,6 +28,7 @@ import org.dromara.workflow.mapper.ActHiTaskinstMapper;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.FlowNode;
import org.flowable.common.engine.api.delegate.Expression;
import org.flowable.engine.HistoryService;
import org.flowable.engine.ProcessEngine;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior;
......@@ -293,4 +294,24 @@ public class WorkflowUtils {
}
return taskQuery.singleResult();
}
/**
* 查询历史流程变量(返回特定变量)
*
* @param businessKey 业务id
* @param variableName 变量名称
* @return 流程变量
*/
public static Object getHistoricVariableByBusinessKey(String businessKey, String variableName) {
HistoryService historyService = PROCESS_ENGINE.getHistoryService();
HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery()
.processInstanceBusinessKey(businessKey)
.singleResult();
return historyService.createHistoricVariableInstanceQuery()
.processInstanceId(processInstance.getId())
.variableName(variableName)
.singleResult()
.getValue();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论