From 1f6c005d4446b0bdf40d1680c385e43bd53d963d Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期五, 25 八月 2023 11:04:28 +0800
Subject: [PATCH] 主数据 码段展示(层级码段)
---
Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/business/service/impl/FlowBusinessServiceImpl.java | 47 +++++++++++++++++++++++++++++++++++++----------
1 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/business/service/impl/FlowBusinessServiceImpl.java b/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/business/service/impl/FlowBusinessServiceImpl.java
index 502f332..6aca608 100644
--- a/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/business/service/impl/FlowBusinessServiceImpl.java
+++ b/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/business/service/impl/FlowBusinessServiceImpl.java
@@ -24,6 +24,8 @@
import com.vci.ubcs.flow.engine.constant.FlowEngineConstant;
import com.vci.ubcs.flow.engine.entity.FlowProcess;
import com.vci.ubcs.flow.engine.utils.FlowCache;
+import com.vci.ubcs.flow.engine.utils.FlowableUtils;
+import com.vci.ubcs.starter.web.util.VciDateUtil;
import com.vci.ubcs.system.user.cache.UserCache;
import com.vci.ubcs.system.user.entity.User;
import lombok.AllArgsConstructor;
@@ -39,6 +41,7 @@
import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
+import org.flowable.variable.api.history.HistoricVariableInstance;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.Func;
@@ -81,9 +84,9 @@
.includeProcessVariables().active().orderByTaskCreateTime().desc();
// 鏋勫缓鍒楄〃鏁版嵁
- buildFlowTaskList(bladeFlow, flowList, claimUserQuery, FlowEngineConstant.STATUS_CLAIM);
- buildFlowTaskList(bladeFlow, flowList, claimRoleWithTenantIdQuery, FlowEngineConstant.STATUS_CLAIM);
- buildFlowTaskList(bladeFlow, flowList, claimRoleWithoutTenantIdQuery, FlowEngineConstant.STATUS_CLAIM);
+ buildFlowTaskList(bladeFlow, flowList, claimUserQuery, FlowEngineConstant.STATUS_CLAIM, page);
+ buildFlowTaskList(bladeFlow, flowList, claimRoleWithTenantIdQuery, FlowEngineConstant.STATUS_CLAIM, page);
+ buildFlowTaskList(bladeFlow, flowList, claimRoleWithoutTenantIdQuery, FlowEngineConstant.STATUS_CLAIM, page);
// 璁$畻鎬绘暟
long count = claimUserQuery.count() + claimRoleWithTenantIdQuery.count() + claimRoleWithoutTenantIdQuery.count();
@@ -106,7 +109,7 @@
.includeProcessVariables().orderByTaskCreateTime().desc();
// 鏋勫缓鍒楄〃鏁版嵁
- buildFlowTaskList(bladeFlow, flowList, todoQuery, FlowEngineConstant.STATUS_TODO);
+ buildFlowTaskList(bladeFlow, flowList, todoQuery, FlowEngineConstant.STATUS_TODO,page);
// 璁$畻鎬绘暟
long count = todoQuery.count();
@@ -180,6 +183,21 @@
flow.setProcessIsFinished(FlowEngineConstant.STATUS_UNFINISHED);
}
flow.setStatus(FlowEngineConstant.STATUS_FINISH);
+
+ //娴佺▼鍙戣捣鏃堕棿
+ flow.setProcessDefinitionStartTime(VciDateUtil.date2Str(historicProcessInstance.getStartTime(),VciDateUtil.DateTimeFormat));
+
+ //娴佺▼鍙橀噺
+
+ List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery().processInstanceId(historicProcessInstance.getId()).list();
+ Map<String,Object> variables = FlowableUtils.switchVariable(variableInstances);
+ flow.setVariables(variables);
+
+ //businessKey
+ if (Func.isNotEmpty(historicProcessInstance)) {
+ flow.setBusinessId(businessKey.length>1 && StringUtils.isNotEmpty(businessKey[1])?businessKey[1]:"1");
+ }
+
flowList.add(flow);
});
@@ -298,8 +316,9 @@
* @param flowList 娴佺▼鍒楄〃
* @param taskQuery 浠诲姟鏌ヨ绫�
* @param status 鐘舵��
+ * @param page
*/
- private void buildFlowTaskList(BladeFlow bladeFlow, List<BladeFlow> flowList, TaskQuery taskQuery, String status) {
+ private void buildFlowTaskList(BladeFlow bladeFlow, List<BladeFlow> flowList, TaskQuery taskQuery, String status, IPage<BladeFlow> page) {
// if (bladeFlow.getCategory() != null) {
if (StringUtils.isNotEmpty(bladeFlow.getCategory())) {
taskQuery.processCategoryIn(Func.toStrList(bladeFlow.getCategory()));
@@ -313,7 +332,9 @@
if (bladeFlow.getEndDate() != null) {
taskQuery.taskCreatedBefore(bladeFlow.getEndDate());
}
- taskQuery.list().forEach(task -> {
+ int firstResult = (int) ((page.getCurrent()-1)* page.getSize());
+ int maxResult = (int) page.getSize();
+ taskQuery.listPage(firstResult,maxResult).forEach(task -> {
BladeFlow flow = new BladeFlow();
flow.setTaskId(task.getId());
flow.setTaskDefinitionKey(task.getTaskDefinitionKey());
@@ -340,10 +361,11 @@
flow.setHistoryActivityIdea(commentList.get(0).getFullMessage());
}
}
+ List<HistoricProcessInstance> processInstanceList = historyService.createHistoricProcessInstanceQuery()
+ .processInstanceId(task.getProcessInstanceId()).orderByProcessInstanceStartTime().asc().list();
+ flow.setProcessDefinitionStartTime(VciDateUtil.date2Str(processInstanceList.get(0).getStartTime(),VciDateUtil.DateTimeFormat));
// 鑾峰彇娴佺▼鍙戣捣浜哄悕绉�
if (FlowEngineConstant.START_EVENT.equals(historicActivityInstance.getActivityType())) {
- List<HistoricProcessInstance> processInstanceList = historyService.createHistoricProcessInstanceQuery()
- .processInstanceId(task.getProcessInstanceId()).orderByProcessInstanceStartTime().asc().list();
if (processInstanceList.size() > 0) {
if (StringUtil.isNotBlank(processInstanceList.get(0).getStartUserId())) {
String taskUser = processInstanceList.get(0).getStartUserId();
@@ -357,9 +379,14 @@
}
if (Func.isNotEmpty(historicProcessInstance)) {
- String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey());
+ String[] businessKey = new String[2];
+ if(historicProcessInstance.getBusinessKey().contains(StringPool.COLON)){
+ businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey());
+ }else{
+ businessKey[0] = historicProcessInstance.getBusinessKey();
+ }
flow.setBusinessTable(businessKey[0]);
- flow.setBusinessId(businessKey.length>1?businessKey[1]:"1");
+ flow.setBusinessId(businessKey.length>1 && StringUtils.isNotEmpty(businessKey[1])?businessKey[1]:"1");
}
FlowProcess processDefinition = FlowCache.getProcessDefinition(task.getProcessDefinitionId());
--
Gitblit v1.9.3