perf: 优化流程详情页信息查询,减少接口参数和优化查询效率
This commit is contained in:
@@ -220,11 +220,10 @@ public class WfProcessController extends BaseController {
|
||||
* 查询流程详情信息
|
||||
*
|
||||
* @param procInsId 流程实例ID
|
||||
* @param deployId 部署ID
|
||||
* @param taskId 任务ID
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public R detail(String procInsId, String deployId, String taskId) {
|
||||
return R.ok(processService.queryProcessDetail(procInsId, deployId, taskId));
|
||||
public R detail(String procInsId, String taskId) {
|
||||
return R.ok(processService.queryProcessDetail(procInsId, taskId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,8 +104,7 @@ public interface IWfProcessService {
|
||||
/**
|
||||
* 查询流程任务详情信息
|
||||
* @param procInsId 流程实例ID
|
||||
* @param deployId 流程部署ID
|
||||
* @param taskId 任务ID
|
||||
*/
|
||||
WfDetailVo queryProcessDetail(String procInsId, String deployId, String taskId);
|
||||
WfDetailVo queryProcessDetail(String procInsId, String taskId);
|
||||
}
|
||||
|
||||
@@ -614,28 +614,34 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
* 流程详情信息
|
||||
*
|
||||
* @param procInsId 流程实例ID
|
||||
* @param deployId 流程部署ID
|
||||
* @param taskId 任务ID
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public WfDetailVo queryProcessDetail(String procInsId, String deployId, String taskId) {
|
||||
public WfDetailVo queryProcessDetail(String procInsId, String taskId) {
|
||||
WfDetailVo detailVo = new WfDetailVo();
|
||||
HistoricTaskInstance taskIns = historyService.createHistoricTaskInstanceQuery()
|
||||
.taskId(taskId)
|
||||
.includeIdentityLinks()
|
||||
// 获取流程实例
|
||||
HistoricProcessInstance historicProcIns = historyService.createHistoricProcessInstanceQuery()
|
||||
.processInstanceId(procInsId)
|
||||
.includeProcessVariables()
|
||||
.includeTaskLocalVariables()
|
||||
.singleResult();
|
||||
if (taskIns == null) {
|
||||
throw new ServiceException("没有可办理的任务!");
|
||||
if (StringUtils.isNotBlank(taskId)) {
|
||||
HistoricTaskInstance taskIns = historyService.createHistoricTaskInstanceQuery()
|
||||
.taskId(taskId)
|
||||
.includeIdentityLinks()
|
||||
.includeProcessVariables()
|
||||
.includeTaskLocalVariables()
|
||||
.singleResult();
|
||||
if (taskIns == null) {
|
||||
throw new ServiceException("没有可办理的任务!");
|
||||
}
|
||||
detailVo.setTaskFormData(currTaskFormData(historicProcIns.getDeploymentId(), taskIns));
|
||||
}
|
||||
// 获取Bpmn模型信息
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(taskIns.getProcessDefinitionId());
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(historicProcIns.getProcessDefinitionId());
|
||||
detailVo.setBpmnXml(ModelUtils.getBpmnXmlStr(bpmnModel));
|
||||
detailVo.setTaskFormData(currTaskFormData(deployId, taskIns));
|
||||
detailVo.setHistoryProcNodeList(historyProcNodeList(procInsId));
|
||||
detailVo.setProcessFormList(processFormList(bpmnModel, procInsId, deployId));
|
||||
detailVo.setHistoryProcNodeList(historyProcNodeList(historicProcIns));
|
||||
detailVo.setProcessFormList(processFormList(bpmnModel, historicProcIns));
|
||||
detailVo.setFlowViewer(getFlowViewer(bpmnModel, procInsId));
|
||||
return detailVo;
|
||||
}
|
||||
@@ -698,11 +704,11 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
/**
|
||||
* 获取历史流程表单信息
|
||||
*/
|
||||
private List<FormConf> processFormList(BpmnModel bpmnModel, String procInsId, String deployId) {
|
||||
private List<FormConf> processFormList(BpmnModel bpmnModel, HistoricProcessInstance historicProcIns) {
|
||||
List<FormConf> procFormList = new ArrayList<>();
|
||||
HistoricProcessInstance historicProcIns = historyService.createHistoricProcessInstanceQuery().processInstanceId(procInsId).includeProcessVariables().singleResult();
|
||||
|
||||
List<HistoricActivityInstance> activityInstanceList = historyService.createHistoricActivityInstanceQuery()
|
||||
.processInstanceId(procInsId).finished()
|
||||
.processInstanceId(historicProcIns.getId()).finished()
|
||||
.activityTypes(CollUtil.newHashSet(BpmnXMLConstants.ELEMENT_EVENT_START, BpmnXMLConstants.ELEMENT_TASK_USER))
|
||||
.orderByHistoricActivityInstanceStartTime().asc()
|
||||
.list();
|
||||
@@ -720,7 +726,7 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
if (localScope) {
|
||||
// 查询任务节点参数,并转换成Map
|
||||
variables = historyService.createHistoricVariableInstanceQuery()
|
||||
.processInstanceId(procInsId)
|
||||
.processInstanceId(historicProcIns.getId())
|
||||
.taskId(activityInstance.getTaskId())
|
||||
.list()
|
||||
.stream()
|
||||
@@ -734,7 +740,7 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
}
|
||||
// 非节点表单此处查询结果可能有多条,只获取第一条信息
|
||||
List<WfDeployFormVo> formInfoList = deployFormMapper.selectVoList(new LambdaQueryWrapper<WfDeployForm>()
|
||||
.eq(WfDeployForm::getDeployId, deployId)
|
||||
.eq(WfDeployForm::getDeployId, historicProcIns.getDeploymentId())
|
||||
.eq(WfDeployForm::getFormKey, formKey)
|
||||
.eq(localScope, WfDeployForm::getNodeKey, flowElement.getId()));
|
||||
WfDeployFormVo formInfo = formInfoList.iterator().next();
|
||||
@@ -820,7 +826,8 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
/**
|
||||
* 获取历史任务信息列表
|
||||
*/
|
||||
private List<WfProcNodeVo> historyProcNodeList(String procInsId) {
|
||||
private List<WfProcNodeVo> historyProcNodeList(HistoricProcessInstance historicProcIns) {
|
||||
String procInsId = historicProcIns.getId();
|
||||
List<HistoricActivityInstance> historicActivityInstanceList = historyService.createHistoricActivityInstanceQuery()
|
||||
.processInstanceId(procInsId)
|
||||
.activityTypes(CollUtil.newHashSet(BpmnXMLConstants.ELEMENT_EVENT_START, BpmnXMLConstants.ELEMENT_EVENT_END, BpmnXMLConstants.ELEMENT_TASK_USER))
|
||||
@@ -828,10 +835,6 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
.orderByHistoricActivityInstanceEndTime().desc()
|
||||
.list();
|
||||
|
||||
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
|
||||
.processInstanceId(procInsId)
|
||||
.singleResult();
|
||||
|
||||
List<Comment> commentList = taskService.getProcessInstanceComments(procInsId);
|
||||
|
||||
List<WfProcNodeVo> elementVoList = new ArrayList<>();
|
||||
@@ -848,8 +851,8 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
}
|
||||
|
||||
if (BpmnXMLConstants.ELEMENT_EVENT_START.equals(activityInstance.getActivityType())) {
|
||||
if (ObjectUtil.isNotNull(historicProcessInstance)) {
|
||||
Long userId = Long.parseLong(historicProcessInstance.getStartUserId());
|
||||
if (ObjectUtil.isNotNull(historicProcIns)) {
|
||||
Long userId = Long.parseLong(historicProcIns.getStartUserId());
|
||||
SysUser user = userService.selectUserById(userId);
|
||||
if (user != null) {
|
||||
elementVo.setAssigneeId(user.getUserId());
|
||||
|
||||
@@ -192,10 +192,7 @@ export default {
|
||||
this.$router.push({
|
||||
path: '/workflow/process/detail/' + row.instanceId,
|
||||
query: {
|
||||
definitionId: row.processId,
|
||||
deployId: row.deploymentId,
|
||||
taskId: row.taskId,
|
||||
finished: false
|
||||
processed: false
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-tabs tab-position="top" :value="finished === 'true' ? 'approval' : 'form'">
|
||||
<el-tabs tab-position="top" :value="processed === true ? 'approval' : 'form'">
|
||||
|
||||
<el-tab-pane label="任务办理" name="approval" v-if="finished === 'true'">
|
||||
<el-tab-pane label="任务办理" name="approval" v-if="processed === true">
|
||||
<el-card class="box-card" shadow="hover" v-if="taskFormOpen">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>填写表单</span>
|
||||
@@ -56,9 +56,6 @@
|
||||
<el-col :span="1.5">
|
||||
<el-button icon="el-icon-thumb" type="success" @click="handleTransfer">转办</el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="2">-->
|
||||
<!-- <el-button icon="el-icon-edit-outline" type="primary"" @click="handle">签收</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<el-col :span="1.5">
|
||||
<el-button icon="el-icon-refresh-left" type="warning" @click="handleReturn">退回</el-button>
|
||||
</el-col>
|
||||
@@ -285,9 +282,7 @@ export default {
|
||||
taskForm:{
|
||||
comment:"", // 意见内容
|
||||
procInsId: "", // 流程实例编号
|
||||
deployId: "", // 流程定义编号
|
||||
taskId: "" ,// 流程任务编号
|
||||
definitionId: "", // 流程编号
|
||||
copyUserIds: "", // 抄送人Id
|
||||
vars: "",
|
||||
targetKey:""
|
||||
@@ -302,7 +297,7 @@ export default {
|
||||
processFormList: [], // 流程变量数据
|
||||
formOpen: false, // 是否加载流程变量数据
|
||||
returnTaskList: [], // 回退列表数据
|
||||
finished: 'false',
|
||||
processed: false,
|
||||
returnTitle: null,
|
||||
returnOpen: false,
|
||||
rejectOpen: false,
|
||||
@@ -325,14 +320,10 @@ export default {
|
||||
methods: {
|
||||
initData() {
|
||||
this.taskForm.procInsId = this.$route.params && this.$route.params.procInsId;
|
||||
this.taskForm.deployId = this.$route.query && this.$route.query.deployId;
|
||||
this.taskForm.definitionId = this.$route.query && this.$route.query.definitionId;
|
||||
this.taskForm.taskId = this.$route.query && this.$route.query.taskId;
|
||||
this.finished = this.$route.query && this.$route.query.finished
|
||||
this.processed = this.$route.query && this.$route.query.processed;
|
||||
// 流程任务重获取变量表单
|
||||
if (this.taskForm.taskId) {
|
||||
this.getProcessDetails(this.taskForm.procInsId, this.taskForm.deployId, this.taskForm.taskId);
|
||||
}
|
||||
this.getProcessDetails(this.taskForm.procInsId, this.taskForm.taskId);
|
||||
this.loadIndex = this.taskForm.procInsId;
|
||||
},
|
||||
/** 查询部门下拉树结构 */
|
||||
@@ -429,8 +420,8 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
getProcessDetails(procInsId, deployId, taskId) {
|
||||
const params = {procInsId: procInsId, deployId: deployId, taskId: taskId}
|
||||
getProcessDetails(procInsId, taskId) {
|
||||
const params = {procInsId: procInsId, taskId: taskId}
|
||||
detailProcess(params).then(res => {
|
||||
const data = res.data;
|
||||
this.xmlData = data.bpmnXml;
|
||||
|
||||
@@ -217,9 +217,6 @@ export default {
|
||||
this.$router.push({
|
||||
path: '/workflow/process/detail/' + row.procInsId,
|
||||
query: {
|
||||
definitionId: row.procDefId,
|
||||
deployId: row.deployId,
|
||||
taskId: row.taskId,
|
||||
finished: false
|
||||
}
|
||||
})
|
||||
|
||||
@@ -258,10 +258,7 @@ export default {
|
||||
this.$router.push({
|
||||
path: '/workflow/process/detail/' + row.procInsId,
|
||||
query: {
|
||||
definitionId: row.procDefId,
|
||||
deployId: row.deployId,
|
||||
taskId: row.taskId,
|
||||
finished: false
|
||||
processed: false
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@@ -143,10 +143,8 @@ export default {
|
||||
this.$router.push({
|
||||
path: '/workflow/process/detail/' + row.procInsId,
|
||||
query: {
|
||||
definitionId: row.procDefId,
|
||||
deployId: row.deployId,
|
||||
taskId: row.taskId,
|
||||
finished: true
|
||||
processed: true
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user