|
@@ -16,7 +16,7 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
import org.dromara.workflow.common.constant.FlowConstant;
|
|
import org.dromara.workflow.common.constant.FlowConstant;
|
|
-import org.dromara.workflow.common.enums.BusinessStatusEnum;
|
|
|
|
|
|
+import org.dromara.common.core.enums.BusinessStatusEnum;
|
|
import org.dromara.workflow.common.enums.TaskStatusEnum;
|
|
import org.dromara.workflow.common.enums.TaskStatusEnum;
|
|
import org.dromara.workflow.domain.ActHiProcinst;
|
|
import org.dromara.workflow.domain.ActHiProcinst;
|
|
import org.dromara.workflow.domain.bo.ProcessInstanceBo;
|
|
import org.dromara.workflow.domain.bo.ProcessInstanceBo;
|
|
@@ -26,8 +26,7 @@ import org.dromara.workflow.domain.vo.*;
|
|
import org.dromara.workflow.flowable.CustomDefaultProcessDiagramGenerator;
|
|
import org.dromara.workflow.flowable.CustomDefaultProcessDiagramGenerator;
|
|
import org.dromara.workflow.flowable.cmd.DeleteExecutionCmd;
|
|
import org.dromara.workflow.flowable.cmd.DeleteExecutionCmd;
|
|
import org.dromara.workflow.flowable.cmd.ExecutionChildByExecutionIdCmd;
|
|
import org.dromara.workflow.flowable.cmd.ExecutionChildByExecutionIdCmd;
|
|
-import org.dromara.workflow.flowable.strategy.FlowEventStrategy;
|
|
|
|
-import org.dromara.workflow.flowable.strategy.FlowProcessEventHandler;
|
|
|
|
|
|
+import org.dromara.workflow.flowable.handler.FlowProcessEventHandler;
|
|
import org.dromara.workflow.service.IActHiProcinstService;
|
|
import org.dromara.workflow.service.IActHiProcinstService;
|
|
import org.dromara.workflow.service.IActProcessInstanceService;
|
|
import org.dromara.workflow.service.IActProcessInstanceService;
|
|
import org.dromara.workflow.service.IWfNodeConfigService;
|
|
import org.dromara.workflow.service.IWfNodeConfigService;
|
|
@@ -75,9 +74,9 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|
private final TaskService taskService;
|
|
private final TaskService taskService;
|
|
private final IActHiProcinstService actHiProcinstService;
|
|
private final IActHiProcinstService actHiProcinstService;
|
|
private final ManagementService managementService;
|
|
private final ManagementService managementService;
|
|
- private final FlowEventStrategy flowEventStrategy;
|
|
|
|
private final IWfTaskBackNodeService wfTaskBackNodeService;
|
|
private final IWfTaskBackNodeService wfTaskBackNodeService;
|
|
private final IWfNodeConfigService wfNodeConfigService;
|
|
private final IWfNodeConfigService wfNodeConfigService;
|
|
|
|
+ private final FlowProcessEventHandler flowProcessEventHandler;
|
|
|
|
|
|
@Value("${flowable.activity-font-name}")
|
|
@Value("${flowable.activity-font-name}")
|
|
private String activityFontName;
|
|
private String activityFontName;
|
|
@@ -184,28 +183,28 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 通过流程实例id获取历史流程图
|
|
|
|
|
|
+ * 通过业务id获取历史流程图
|
|
*
|
|
*
|
|
- * @param processInstanceId 流程实例id
|
|
|
|
|
|
+ * @param businessKey 业务id
|
|
*/
|
|
*/
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
@Override
|
|
@Override
|
|
- public String getHistoryImage(String processInstanceId) {
|
|
|
|
|
|
+ public String getHistoryImage(String businessKey) {
|
|
String processDefinitionId;
|
|
String processDefinitionId;
|
|
// 获取当前的流程实例
|
|
// 获取当前的流程实例
|
|
- ProcessInstance processInstance = QueryUtils.instanceQuery(processInstanceId).singleResult();
|
|
|
|
|
|
+ ProcessInstance processInstance = QueryUtils.businessKeyQuery(businessKey).singleResult();
|
|
// 如果流程已经结束,则得到结束节点
|
|
// 如果流程已经结束,则得到结束节点
|
|
if (Objects.isNull(processInstance)) {
|
|
if (Objects.isNull(processInstance)) {
|
|
- HistoricProcessInstance pi = QueryUtils.hisInstanceQuery(processInstanceId).singleResult();
|
|
|
|
|
|
+ HistoricProcessInstance pi = QueryUtils.hisInstanceQuery().processInstanceBusinessKey(businessKey).singleResult();
|
|
processDefinitionId = pi.getProcessDefinitionId();
|
|
processDefinitionId = pi.getProcessDefinitionId();
|
|
} else {
|
|
} else {
|
|
// 根据流程实例ID获得当前处于活动状态的ActivityId合集
|
|
// 根据流程实例ID获得当前处于活动状态的ActivityId合集
|
|
- ProcessInstance pi = QueryUtils.instanceQuery(processInstanceId).singleResult();
|
|
|
|
|
|
+ ProcessInstance pi = QueryUtils.instanceQuery(processInstance.getProcessInstanceId()).singleResult();
|
|
processDefinitionId = pi.getProcessDefinitionId();
|
|
processDefinitionId = pi.getProcessDefinitionId();
|
|
}
|
|
}
|
|
|
|
|
|
// 获得活动的节点
|
|
// 获得活动的节点
|
|
- List<HistoricActivityInstance> highLightedFlowList = QueryUtils.hisActivityInstanceQuery(processInstanceId).orderByHistoricActivityInstanceStartTime().asc().list();
|
|
|
|
|
|
+ List<HistoricActivityInstance> highLightedFlowList = QueryUtils.hisActivityInstanceQuery(processInstance.getProcessInstanceId()).orderByHistoricActivityInstanceStartTime().asc().list();
|
|
|
|
|
|
List<String> highLightedFlows = new ArrayList<>();
|
|
List<String> highLightedFlows = new ArrayList<>();
|
|
List<String> highLightedNodes = new ArrayList<>();
|
|
List<String> highLightedNodes = new ArrayList<>();
|
|
@@ -240,15 +239,16 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 通过流程实例id获取历史流程图运行中,历史等节点
|
|
|
|
|
|
+ * 通过业务id获取历史流程图运行中,历史等节点
|
|
*
|
|
*
|
|
- * @param processInstanceId 流程实例id
|
|
|
|
|
|
+ * @param businessKey 业务id
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Map<String, Object> getHistoryList(String processInstanceId) {
|
|
|
|
|
|
+ public Map<String, Object> getHistoryList(String businessKey) {
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
List<Map<String, Object>> taskList = new ArrayList<>();
|
|
List<Map<String, Object>> taskList = new ArrayList<>();
|
|
- HistoricProcessInstance historicProcessInstance = QueryUtils.hisInstanceQuery(processInstanceId).singleResult();
|
|
|
|
|
|
+ HistoricProcessInstance historicProcessInstance = QueryUtils.hisBusinessKeyQuery(businessKey).singleResult();
|
|
|
|
+ String processInstanceId = historicProcessInstance.getId();
|
|
StringBuilder xml = new StringBuilder();
|
|
StringBuilder xml = new StringBuilder();
|
|
ProcessDefinition processDefinition = repositoryService.getProcessDefinition(historicProcessInstance.getProcessDefinitionId());
|
|
ProcessDefinition processDefinition = repositoryService.getProcessDefinition(historicProcessInstance.getProcessDefinitionId());
|
|
// 获取节点
|
|
// 获取节点
|
|
@@ -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, processDefinition.getVersion());
|
|
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);
|
|
|
|
- actHistoryInfoVoList.stream().filter(e -> e.getTaskDefinitionKey().equals(entry.getKey()) && e.getEndTime() == null).findFirst()
|
|
|
|
- .ifPresent(e -> {
|
|
|
|
- historyInfoVo.setStatus("待处理");
|
|
|
|
- historyInfoVo.setStartTime(e.getStartTime());
|
|
|
|
- historyInfoVo.setEndTime(null);
|
|
|
|
- historyInfoVo.setRunDuration(null);
|
|
|
|
- if (ObjectUtil.isEmpty(e.getAssignee())) {
|
|
|
|
- ParticipantVo participantVo = WorkflowUtils.getCurrentTaskParticipant(e.getId());
|
|
|
|
|
|
+ if (entry.getValue().size() > 1) {
|
|
|
|
+ List<ActHistoryInfoVo> historyInfoVos = StreamUtils.filter(entry.getValue(), e -> StringUtils.isNotBlank(e.getAssignee()));
|
|
|
|
+ if (CollUtil.isNotEmpty(historyInfoVos)) {
|
|
|
|
+ ActHistoryInfoVo infoVo = historyInfoVos.get(0);
|
|
|
|
+ BeanUtils.copyProperties(infoVo, historyInfoVo);
|
|
|
|
+ historyInfoVo.setStatus(infoVo.getEndTime() == null ? "待处理" : "已处理");
|
|
|
|
+ historyInfoVo.setStartTime(infoVo.getStartTime());
|
|
|
|
+ historyInfoVo.setEndTime(infoVo.getEndTime() == null ? null : infoVo.getEndTime());
|
|
|
|
+ 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;
|
|
}
|
|
}
|
|
@@ -333,13 +355,15 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|
/**
|
|
/**
|
|
* 获取审批记录
|
|
* 获取审批记录
|
|
*
|
|
*
|
|
- * @param processInstanceId 流程实例id
|
|
|
|
|
|
+ * @param businessKey 业务id
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public List<ActHistoryInfoVo> getHistoryRecord(String processInstanceId) {
|
|
|
|
|
|
+ public List<ActHistoryInfoVo> getHistoryRecord(String businessKey) {
|
|
// 查询任务办理记录
|
|
// 查询任务办理记录
|
|
- List<HistoricTaskInstance> list = QueryUtils.hisTaskInstanceQuery(processInstanceId).orderByHistoricTaskInstanceEndTime().desc().list();
|
|
|
|
|
|
+ List<HistoricTaskInstance> list = QueryUtils.hisTaskBusinessKeyQuery(businessKey).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());
|
|
|
|
+ HistoricProcessInstance historicProcessInstance = QueryUtils.hisBusinessKeyQuery(businessKey).singleResult();
|
|
|
|
+ String processInstanceId = historicProcessInstance.getId();
|
|
List<ActHistoryInfoVo> actHistoryInfoVoList = new ArrayList<>();
|
|
List<ActHistoryInfoVo> actHistoryInfoVoList = new ArrayList<>();
|
|
List<Comment> processInstanceComments = taskService.getProcessInstanceComments(processInstanceId);
|
|
List<Comment> processInstanceComments = taskService.getProcessInstanceComments(processInstanceId);
|
|
//附件
|
|
//附件
|
|
@@ -440,7 +464,8 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public boolean deleteRunInstance(ProcessInvalidBo processInvalidBo) {
|
|
public boolean deleteRunInstance(ProcessInvalidBo processInvalidBo) {
|
|
try {
|
|
try {
|
|
- List<Task> list = QueryUtils.taskQuery(processInvalidBo.getProcessInstanceId()).list();
|
|
|
|
|
|
+ List<Task> list = QueryUtils.taskQuery().processInstanceBusinessKey(processInvalidBo.getBusinessKey()).list();
|
|
|
|
+ String processInstanceId = list.get(0).getProcessInstanceId();
|
|
List<Task> subTasks = StreamUtils.filter(list, e -> StringUtils.isNotBlank(e.getParentTaskId()));
|
|
List<Task> subTasks = StreamUtils.filter(list, e -> StringUtils.isNotBlank(e.getParentTaskId()));
|
|
if (CollUtil.isNotEmpty(subTasks)) {
|
|
if (CollUtil.isNotEmpty(subTasks)) {
|
|
subTasks.forEach(e -> taskService.deleteTask(e.getId()));
|
|
subTasks.forEach(e -> taskService.deleteTask(e.getId()));
|
|
@@ -452,14 +477,13 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|
for (Task task : StreamUtils.filter(list, e -> StringUtils.isBlank(e.getParentTaskId()))) {
|
|
for (Task task : StreamUtils.filter(list, e -> StringUtils.isBlank(e.getParentTaskId()))) {
|
|
taskService.addComment(task.getId(), task.getProcessInstanceId(), TaskStatusEnum.INVALID.getStatus(), deleteReason);
|
|
taskService.addComment(task.getId(), task.getProcessInstanceId(), TaskStatusEnum.INVALID.getStatus(), deleteReason);
|
|
}
|
|
}
|
|
- HistoricProcessInstance historicProcessInstance = QueryUtils.hisInstanceQuery(processInvalidBo.getProcessInstanceId()).singleResult();
|
|
|
|
|
|
+ HistoricProcessInstance historicProcessInstance = QueryUtils.hisInstanceQuery(processInstanceId).singleResult();
|
|
BusinessStatusEnum.checkInvalidStatus(historicProcessInstance.getBusinessStatus());
|
|
BusinessStatusEnum.checkInvalidStatus(historicProcessInstance.getBusinessStatus());
|
|
- runtimeService.updateBusinessStatus(processInvalidBo.getProcessInstanceId(), BusinessStatusEnum.INVALID.getStatus());
|
|
|
|
- runtimeService.deleteProcessInstance(processInvalidBo.getProcessInstanceId(), deleteReason);
|
|
|
|
- FlowProcessEventHandler processHandler = flowEventStrategy.getProcessHandler(historicProcessInstance.getProcessDefinitionKey());
|
|
|
|
- if (processHandler != null) {
|
|
|
|
- processHandler.handleProcess(historicProcessInstance.getBusinessKey(), BusinessStatusEnum.INVALID.getStatus(), false);
|
|
|
|
- }
|
|
|
|
|
|
+ runtimeService.updateBusinessStatus(processInstanceId, BusinessStatusEnum.INVALID.getStatus());
|
|
|
|
+ runtimeService.deleteProcessInstance(processInstanceId, deleteReason);
|
|
|
|
+ //流程作废监听
|
|
|
|
+ flowProcessEventHandler.processHandler(historicProcessInstance.getProcessDefinitionKey(),
|
|
|
|
+ historicProcessInstance.getBusinessKey(), BusinessStatusEnum.INVALID.getStatus(), false);
|
|
return true;
|
|
return true;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -470,40 +494,11 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|
/**
|
|
/**
|
|
* 运行中的实例 删除程实例,删除历史记录,删除业务与流程关联信息
|
|
* 运行中的实例 删除程实例,删除历史记录,删除业务与流程关联信息
|
|
*
|
|
*
|
|
- * @param processInstanceIds 流程实例id
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
- public boolean deleteRunAndHisInstance(List<String> processInstanceIds) {
|
|
|
|
- try {
|
|
|
|
- // 1.删除运行中流程实例
|
|
|
|
- List<Task> list = QueryUtils.taskQuery(processInstanceIds).list();
|
|
|
|
- List<Task> subTasks = StreamUtils.filter(list, e -> StringUtils.isNotBlank(e.getParentTaskId()));
|
|
|
|
- if (CollUtil.isNotEmpty(subTasks)) {
|
|
|
|
- subTasks.forEach(e -> taskService.deleteTask(e.getId()));
|
|
|
|
- }
|
|
|
|
- runtimeService.bulkDeleteProcessInstances(processInstanceIds, LoginHelper.getUserId() + "删除了当前流程申请");
|
|
|
|
- // 2.删除历史记录
|
|
|
|
- List<HistoricProcessInstance> historicProcessInstanceList = QueryUtils.hisInstanceQuery(new HashSet<>(processInstanceIds)).list();
|
|
|
|
- if (ObjectUtil.isNotEmpty(historicProcessInstanceList)) {
|
|
|
|
- historyService.bulkDeleteHistoricProcessInstances(processInstanceIds);
|
|
|
|
- }
|
|
|
|
- wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds);
|
|
|
|
- return true;
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- throw new ServiceException(e.getMessage());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 按照业务id删除 运行中的实例 删除程实例,删除历史记录,删除业务与流程关联信息
|
|
|
|
- *
|
|
|
|
* @param businessKeys 业务id
|
|
* @param businessKeys 业务id
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
- public boolean deleteRunAndHisInstanceByBusinessKeys(List<String> businessKeys) {
|
|
|
|
|
|
+ public boolean deleteRunAndHisInstance(List<String> businessKeys) {
|
|
try {
|
|
try {
|
|
// 1.删除运行中流程实例
|
|
// 1.删除运行中流程实例
|
|
List<ActHiProcinst> actHiProcinsts = actHiProcinstService.selectByBusinessKeyIn(businessKeys);
|
|
List<ActHiProcinst> actHiProcinsts = actHiProcinstService.selectByBusinessKeyIn(businessKeys);
|
|
@@ -534,12 +529,18 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|
/**
|
|
/**
|
|
* 已完成的实例 删除程实例,删除历史记录,删除业务与流程关联信息
|
|
* 已完成的实例 删除程实例,删除历史记录,删除业务与流程关联信息
|
|
*
|
|
*
|
|
- * @param processInstanceIds 流程实例id
|
|
|
|
|
|
+ * @param businessKeys 业务id
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
- public boolean deleteFinishAndHisInstance(List<String> processInstanceIds) {
|
|
|
|
|
|
+ public boolean deleteFinishAndHisInstance(List<String> businessKeys) {
|
|
try {
|
|
try {
|
|
|
|
+ List<ActHiProcinst> actHiProcinsts = actHiProcinstService.selectByBusinessKeyIn(businessKeys);
|
|
|
|
+ if (CollUtil.isEmpty(actHiProcinsts)) {
|
|
|
|
+ log.warn("当前业务ID:{}查询到流程实例为空!", businessKeys);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ List<String> processInstanceIds = StreamUtils.toList(actHiProcinsts, ActHiProcinst::getId);
|
|
historyService.bulkDeleteHistoricProcessInstances(processInstanceIds);
|
|
historyService.bulkDeleteHistoricProcessInstances(processInstanceIds);
|
|
wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds);
|
|
wfTaskBackNodeService.deleteByInstanceIds(processInstanceIds);
|
|
return true;
|
|
return true;
|
|
@@ -552,13 +553,13 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|
/**
|
|
/**
|
|
* 撤销流程申请
|
|
* 撤销流程申请
|
|
*
|
|
*
|
|
- * @param processInstanceId 流程实例id
|
|
|
|
|
|
+ * @param businessKey 业务id
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
- public boolean cancelProcessApply(String processInstanceId) {
|
|
|
|
|
|
+ public boolean cancelProcessApply(String businessKey) {
|
|
try {
|
|
try {
|
|
- ProcessInstance processInstance = QueryUtils.instanceQuery(processInstanceId)
|
|
|
|
|
|
+ ProcessInstance processInstance = QueryUtils.businessKeyQuery(businessKey)
|
|
.startedBy(String.valueOf(LoginHelper.getUserId())).singleResult();
|
|
.startedBy(String.valueOf(LoginHelper.getUserId())).singleResult();
|
|
if (ObjectUtil.isNull(processInstance)) {
|
|
if (ObjectUtil.isNull(processInstance)) {
|
|
throw new ServiceException("您不是流程发起人,撤销失败!");
|
|
throw new ServiceException("您不是流程发起人,撤销失败!");
|
|
@@ -566,13 +567,14 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|
if (processInstance.isSuspended()) {
|
|
if (processInstance.isSuspended()) {
|
|
throw new ServiceException(FlowConstant.MESSAGE_SUSPENDED);
|
|
throw new ServiceException(FlowConstant.MESSAGE_SUSPENDED);
|
|
}
|
|
}
|
|
|
|
+ String processInstanceId = processInstance.getId();
|
|
BusinessStatusEnum.checkCancelStatus(processInstance.getBusinessStatus());
|
|
BusinessStatusEnum.checkCancelStatus(processInstance.getBusinessStatus());
|
|
List<Task> taskList = QueryUtils.taskQuery(processInstanceId).list();
|
|
List<Task> taskList = QueryUtils.taskQuery(processInstanceId).list();
|
|
for (Task task : taskList) {
|
|
for (Task task : taskList) {
|
|
taskService.setAssignee(task.getId(), null);
|
|
taskService.setAssignee(task.getId(), null);
|
|
taskService.addComment(task.getId(), processInstanceId, TaskStatusEnum.CANCEL.getStatus(), LoginHelper.getLoginUser().getNickname() + ":撤销申请");
|
|
taskService.addComment(task.getId(), processInstanceId, TaskStatusEnum.CANCEL.getStatus(), LoginHelper.getLoginUser().getNickname() + ":撤销申请");
|
|
}
|
|
}
|
|
- HistoricTaskInstance historicTaskInstance = QueryUtils.hisTaskInstanceQuery().finished().orderByHistoricTaskInstanceEndTime().asc().list().get(0);
|
|
|
|
|
|
+ HistoricTaskInstance historicTaskInstance = QueryUtils.hisTaskInstanceQuery(processInstanceId).finished().orderByHistoricTaskInstanceEndTime().asc().list().get(0);
|
|
List<String> nodeIds = StreamUtils.toList(taskList, Task::getTaskDefinitionKey);
|
|
List<String> nodeIds = StreamUtils.toList(taskList, Task::getTaskDefinitionKey);
|
|
runtimeService.createChangeActivityStateBuilder()
|
|
runtimeService.createChangeActivityStateBuilder()
|
|
.processInstanceId(processInstanceId)
|
|
.processInstanceId(processInstanceId)
|
|
@@ -588,10 +590,9 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|
managementService.executeCommand(deleteExecutionCmd);
|
|
managementService.executeCommand(deleteExecutionCmd);
|
|
}
|
|
}
|
|
runtimeService.updateBusinessStatus(processInstanceId, BusinessStatusEnum.CANCEL.getStatus());
|
|
runtimeService.updateBusinessStatus(processInstanceId, BusinessStatusEnum.CANCEL.getStatus());
|
|
- FlowProcessEventHandler processHandler = flowEventStrategy.getProcessHandler(processInstance.getProcessDefinitionKey());
|
|
|
|
- if (processHandler != null) {
|
|
|
|
- processHandler.handleProcess(processInstance.getBusinessKey(), BusinessStatusEnum.CANCEL.getStatus(), false);
|
|
|
|
- }
|
|
|
|
|
|
+ //流程作废监听
|
|
|
|
+ flowProcessEventHandler.processHandler(processInstance.getProcessDefinitionKey(),
|
|
|
|
+ processInstance.getBusinessKey(), BusinessStatusEnum.CANCEL.getStatus(), false);
|
|
return true;
|
|
return true;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|