parent
8db7fb661b
commit
54eccf5ce3
BIN
bpmn/模型.zip
BIN
bpmn/模型.zip
Binary file not shown.
|
|
@ -67,4 +67,12 @@ public interface RemoteWorkflowService {
|
||||||
*/
|
*/
|
||||||
void setVariablesLocal(String taskId, Map<String, Object> variables);
|
void setVariablesLocal(String taskId, Map<String, Object> variables);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照业务id查询流程实例id
|
||||||
|
*
|
||||||
|
* @param businessKey 业务id
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
String getInstanceIdByBusinessKey(String businessKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@ public class ActHistoryInfoVo implements Serializable {
|
||||||
* 流程实例id
|
* 流程实例id
|
||||||
*/
|
*/
|
||||||
private String processInstanceId;
|
private String processInstanceId;
|
||||||
|
/**
|
||||||
|
* 版本
|
||||||
|
*/
|
||||||
|
private Integer version;
|
||||||
/**
|
/**
|
||||||
* 开始时间
|
* 开始时间
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -56,4 +56,15 @@ public class RemoteWorkflowServiceImpl implements RemoteWorkflowService {
|
||||||
public void setVariablesLocal(String taskId, Map<String, Object> variables) {
|
public void setVariablesLocal(String taskId, Map<String, Object> variables) {
|
||||||
workflowService.setVariablesLocal(taskId, variables);
|
workflowService.setVariablesLocal(taskId, variables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照业务id查询流程实例id
|
||||||
|
*
|
||||||
|
* @param businessKey 业务id
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getInstanceIdByBusinessKey(String businessKey) {
|
||||||
|
return workflowService.getInstanceIdByBusinessKey(businessKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,4 +65,12 @@ public interface WorkflowService {
|
||||||
* @param variables 流程变量
|
* @param variables 流程变量
|
||||||
*/
|
*/
|
||||||
void setVariablesLocal(String taskId, Map<String, Object> variables);
|
void setVariablesLocal(String taskId, Map<String, Object> variables);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照业务id查询流程实例id
|
||||||
|
*
|
||||||
|
* @param businessKey 业务id
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
String getInstanceIdByBusinessKey(String businessKey);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ import org.dromara.workflow.service.IWfNodeConfigService;
|
||||||
import org.dromara.workflow.service.IWfTaskBackNodeService;
|
import org.dromara.workflow.service.IWfTaskBackNodeService;
|
||||||
import org.dromara.workflow.utils.QueryUtils;
|
import org.dromara.workflow.utils.QueryUtils;
|
||||||
import org.dromara.workflow.utils.WorkflowUtils;
|
import org.dromara.workflow.utils.WorkflowUtils;
|
||||||
import org.flowable.bpmn.model.BpmnModel;
|
import org.flowable.bpmn.model.*;
|
||||||
import org.flowable.engine.*;
|
import org.flowable.engine.*;
|
||||||
import org.flowable.engine.history.HistoricActivityInstance;
|
import org.flowable.engine.history.HistoricActivityInstance;
|
||||||
import org.flowable.engine.history.HistoricProcessInstance;
|
import org.flowable.engine.history.HistoricProcessInstance;
|
||||||
|
|
@ -280,7 +280,7 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
map.put("taskList", taskList);
|
map.put("taskList", taskList);
|
||||||
List<ActHistoryInfoVo> historyTaskList = getHistoryTaskList(processInstanceId);
|
List<ActHistoryInfoVo> historyTaskList = getHistoryTaskList(processInstanceId, processInstance.getProcessDefinitionVersion());
|
||||||
map.put("historyList", historyTaskList);
|
map.put("historyList", historyTaskList);
|
||||||
InputStream inputStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getResourceName());
|
InputStream inputStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getResourceName());
|
||||||
xml.append(IoUtil.read(inputStream, StandardCharsets.UTF_8));
|
xml.append(IoUtil.read(inputStream, StandardCharsets.UTF_8));
|
||||||
|
|
@ -292,8 +292,9 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
||||||
* 获取历史任务节点信息
|
* 获取历史任务节点信息
|
||||||
*
|
*
|
||||||
* @param processInstanceId 流程实例id
|
* @param processInstanceId 流程实例id
|
||||||
|
* @param version 版本
|
||||||
*/
|
*/
|
||||||
private List<ActHistoryInfoVo> getHistoryTaskList(String processInstanceId) {
|
private List<ActHistoryInfoVo> getHistoryTaskList(String processInstanceId, Integer version) {
|
||||||
//查询任务办理记录
|
//查询任务办理记录
|
||||||
List<HistoricTaskInstance> list = QueryUtils.hisTaskInstanceQuery(processInstanceId).orderByHistoricTaskInstanceEndTime().desc().list();
|
List<HistoricTaskInstance> list = QueryUtils.hisTaskInstanceQuery(processInstanceId).orderByHistoricTaskInstanceEndTime().desc().list();
|
||||||
list = StreamUtils.sorted(list, Comparator.comparing(HistoricTaskInstance::getEndTime, Comparator.nullsFirst(Date::compareTo)).reversed());
|
list = StreamUtils.sorted(list, Comparator.comparing(HistoricTaskInstance::getEndTime, Comparator.nullsFirst(Date::compareTo)).reversed());
|
||||||
|
|
@ -305,27 +306,48 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
||||||
if (ObjectUtil.isNotEmpty(historicTaskInstance.getDurationInMillis())) {
|
if (ObjectUtil.isNotEmpty(historicTaskInstance.getDurationInMillis())) {
|
||||||
actHistoryInfoVo.setRunDuration(getDuration(historicTaskInstance.getDurationInMillis()));
|
actHistoryInfoVo.setRunDuration(getDuration(historicTaskInstance.getDurationInMillis()));
|
||||||
}
|
}
|
||||||
|
actHistoryInfoVo.setVersion(version);
|
||||||
actHistoryInfoVoList.add(actHistoryInfoVo);
|
actHistoryInfoVoList.add(actHistoryInfoVo);
|
||||||
}
|
}
|
||||||
List<ActHistoryInfoVo> historyInfoVoList = new ArrayList<>();
|
List<ActHistoryInfoVo> historyInfoVoList = new ArrayList<>();
|
||||||
Map<String, List<ActHistoryInfoVo>> groupByKey = StreamUtils.groupByKey(actHistoryInfoVoList, ActHistoryInfoVo::getTaskDefinitionKey);
|
Map<String, List<ActHistoryInfoVo>> groupByKey = StreamUtils.groupByKey(actHistoryInfoVoList, ActHistoryInfoVo::getTaskDefinitionKey);
|
||||||
for (Map.Entry<String, List<ActHistoryInfoVo>> entry : groupByKey.entrySet()) {
|
for (Map.Entry<String, List<ActHistoryInfoVo>> entry : groupByKey.entrySet()) {
|
||||||
ActHistoryInfoVo historyInfoVo = new ActHistoryInfoVo();
|
ActHistoryInfoVo historyInfoVo = new ActHistoryInfoVo();
|
||||||
BeanUtils.copyProperties(entry.getValue().get(0), historyInfoVo);
|
if (entry.getValue().size() > 1) {
|
||||||
actHistoryInfoVoList.stream().filter(e -> e.getTaskDefinitionKey().equals(entry.getKey()) && e.getEndTime() == null).findFirst()
|
List<ActHistoryInfoVo> historyInfoVos = StreamUtils.filter(entry.getValue(), e -> StringUtils.isNotBlank(e.getAssignee()));
|
||||||
.ifPresent(e -> {
|
if (CollUtil.isNotEmpty(historyInfoVos)) {
|
||||||
historyInfoVo.setStatus("待处理");
|
ActHistoryInfoVo infoVo = historyInfoVos.get(0);
|
||||||
historyInfoVo.setStartTime(e.getStartTime());
|
BeanUtils.copyProperties(infoVo, historyInfoVo);
|
||||||
historyInfoVo.setEndTime(null);
|
historyInfoVo.setStatus(infoVo.getEndTime() == null ? "待处理" : "已处理");
|
||||||
historyInfoVo.setRunDuration(null);
|
historyInfoVo.setStartTime(infoVo.getStartTime());
|
||||||
if (ObjectUtil.isEmpty(e.getAssignee())) {
|
historyInfoVo.setEndTime(infoVo.getEndTime() == null ? null : infoVo.getEndTime());
|
||||||
ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(e.getId());
|
historyInfoVo.setRunDuration(infoVo.getEndTime() == null ? null : infoVo.getRunDuration());
|
||||||
|
if (ObjectUtil.isEmpty(infoVo.getAssignee())) {
|
||||||
|
ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(infoVo.getId());
|
||||||
if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) {
|
if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) {
|
||||||
historyInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr));
|
historyInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
} else {
|
||||||
|
actHistoryInfoVoList.stream().filter(e -> e.getTaskDefinitionKey().equals(entry.getKey())).findFirst()
|
||||||
|
.ifPresent(e -> {
|
||||||
|
BeanUtils.copyProperties(e, historyInfoVo);
|
||||||
|
historyInfoVo.setStatus(e.getEndTime() == null ? "待处理" : "已处理");
|
||||||
|
historyInfoVo.setStartTime(e.getStartTime());
|
||||||
|
historyInfoVo.setEndTime(e.getEndTime() == null ? null : e.getEndTime());
|
||||||
|
historyInfoVo.setRunDuration(e.getEndTime() == null ? null : e.getRunDuration());
|
||||||
|
if (ObjectUtil.isEmpty(e.getAssignee())) {
|
||||||
|
ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(e.getId());
|
||||||
|
if (ObjectUtil.isNotEmpty(participantVo) && CollUtil.isNotEmpty(participantVo.getCandidate())) {
|
||||||
|
historyInfoVo.setAssignee(StreamUtils.join(participantVo.getCandidate(), Convert::toStr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
historyInfoVoList.add(historyInfoVo);
|
historyInfoVoList.add(historyInfoVo);
|
||||||
|
|
||||||
}
|
}
|
||||||
return historyInfoVoList;
|
return historyInfoVoList;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
package org.dromara.workflow.service.impl;
|
package org.dromara.workflow.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.dromara.workflow.domain.ActHiProcinst;
|
||||||
|
import org.dromara.workflow.service.IActHiProcinstService;
|
||||||
import org.dromara.workflow.service.IActProcessInstanceService;
|
import org.dromara.workflow.service.IActProcessInstanceService;
|
||||||
import org.dromara.workflow.service.WorkflowService;
|
import org.dromara.workflow.service.WorkflowService;
|
||||||
import org.dromara.workflow.utils.WorkflowUtils;
|
import org.dromara.workflow.utils.WorkflowUtils;
|
||||||
|
|
@ -19,9 +22,9 @@ import java.util.Map;
|
||||||
@Service
|
@Service
|
||||||
public class WorkflowServiceImpl implements WorkflowService {
|
public class WorkflowServiceImpl implements WorkflowService {
|
||||||
|
|
||||||
private final IActProcessInstanceService iActProcessInstanceService;
|
private final IActProcessInstanceService actProcessInstanceService;
|
||||||
private final RuntimeService runtimeService;
|
private final RuntimeService runtimeService;
|
||||||
|
private final IActHiProcinstService actHiProcinstService;
|
||||||
/**
|
/**
|
||||||
* 运行中的实例 删除程实例,删除历史记录,删除业务与流程关联信息
|
* 运行中的实例 删除程实例,删除历史记录,删除业务与流程关联信息
|
||||||
*
|
*
|
||||||
|
|
@ -30,7 +33,7 @@ public class WorkflowServiceImpl implements WorkflowService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteRunAndHisInstance(List<String> businessKeys) {
|
public boolean deleteRunAndHisInstance(List<String> businessKeys) {
|
||||||
return iActProcessInstanceService.deleteRunAndHisInstance(businessKeys);
|
return actProcessInstanceService.deleteRunAndHisInstance(businessKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -98,4 +101,19 @@ public class WorkflowServiceImpl implements WorkflowService {
|
||||||
public void setVariablesLocal(String taskId, Map<String, Object> variables) {
|
public void setVariablesLocal(String taskId, Map<String, Object> variables) {
|
||||||
runtimeService.setVariablesLocal(taskId, variables);
|
runtimeService.setVariablesLocal(taskId, variables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照业务id查询流程实例id
|
||||||
|
*
|
||||||
|
* @param businessKey 业务id
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getInstanceIdByBusinessKey(String businessKey) {
|
||||||
|
ActHiProcinst actHiProcinst = actHiProcinstService.selectByBusinessKey(businessKey);
|
||||||
|
if (actHiProcinst == null) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
|
return actHiProcinst.getId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue