From f04487fef5ac47380dfa9670156743c9d273966b Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Sat, 23 Mar 2024 15:54:40 +0800
Subject: [PATCH] 巡查修改

---
 skjcmanager/skjcmanager-ops/skjcmanager-flow/src/main/java/cn/gistack/flow/business/service/impl/FlowBusinessServiceImpl.java |  147 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 147 insertions(+), 0 deletions(-)

diff --git a/skjcmanager/skjcmanager-ops/skjcmanager-flow/src/main/java/cn/gistack/flow/business/service/impl/FlowBusinessServiceImpl.java b/skjcmanager/skjcmanager-ops/skjcmanager-flow/src/main/java/cn/gistack/flow/business/service/impl/FlowBusinessServiceImpl.java
index 2930179..76bad5d 100644
--- a/skjcmanager/skjcmanager-ops/skjcmanager-flow/src/main/java/cn/gistack/flow/business/service/impl/FlowBusinessServiceImpl.java
+++ b/skjcmanager/skjcmanager-ops/skjcmanager-flow/src/main/java/cn/gistack/flow/business/service/impl/FlowBusinessServiceImpl.java
@@ -115,6 +115,21 @@
 	}
 
 	@Override
+	public List<BladeFlow> getMyToDoList(BladeFlow bladeFlow,String currentUserId) {
+		String taskUser = StringUtil.format("{}{}", TASK_USR_PREFIX, currentUserId);
+		List<BladeFlow> flowList = new LinkedList<>();
+
+		// 已签收的任务
+		TaskQuery todoQuery = taskService.createTaskQuery().taskAssignee(taskUser).active()
+			.includeProcessVariables().orderByTaskCreateTime().desc();
+
+		// 构建列表数据
+		buildFlowTaskList(bladeFlow, flowList, todoQuery, FlowEngineConstant.STATUS_TODO);
+
+		return flowList;
+	}
+
+	@Override
 	public IPage<BladeFlow> selectTodoPage(IPage<BladeFlow> page, BladeFlow bladeFlow,String currentUserId) {
 		String taskUser = StringUtil.format("{}{}", TASK_USR_PREFIX, currentUserId);
 		List<BladeFlow> flowList = new LinkedList<>();
@@ -275,6 +290,137 @@
 		return page;
 	}
 
+
+	@Override
+	public List<BladeFlow> getMyDoneList(BladeFlow bladeFlow, String currentUserId) {
+
+		String taskUser = StringUtil.format("{}{}", TASK_USR_PREFIX, currentUserId);
+
+		List<BladeFlow> flowList = new LinkedList<>();
+
+
+		HistoricTaskInstanceQuery doneQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(taskUser).finished()
+			.includeProcessVariables().orderByHistoricTaskInstanceEndTime().desc();
+
+		if (bladeFlow.getCategory() != null) {
+			doneQuery.processCategoryIn(Func.toStrList(bladeFlow.getCategory()));
+		}
+		if (bladeFlow.getProcessDefinitionName() != null) {
+			doneQuery.processDefinitionName(bladeFlow.getProcessDefinitionName());
+		}
+		if (bladeFlow.getBeginDate() != null) {
+			doneQuery.taskCompletedAfter(bladeFlow.getBeginDate());
+		}
+		if (bladeFlow.getEndDate() != null) {
+			doneQuery.taskCompletedBefore(bladeFlow.getEndDate());
+		}
+
+		// 查询列表
+		List<HistoricTaskInstance> doneList = doneQuery.list();
+		doneList.forEach(historicTaskInstance -> {
+			BladeFlow flow = new BladeFlow();
+			flow.setTaskId(historicTaskInstance.getId());
+			flow.setTaskDefinitionKey(historicTaskInstance.getTaskDefinitionKey());
+			flow.setTaskName(historicTaskInstance.getName());
+			flow.setAssignee(historicTaskInstance.getAssignee());
+			flow.setCreateTime(historicTaskInstance.getCreateTime());
+			flow.setExecutionId(historicTaskInstance.getExecutionId());
+			flow.setHistoryTaskEndTime(historicTaskInstance.getEndTime());
+			flow.setVariables(historicTaskInstance.getProcessVariables());
+
+			FlowProcess processDefinition = FlowCache.getProcessDefinition(historicTaskInstance.getProcessDefinitionId());
+			flow.setProcessDefinitionId(processDefinition.getId());
+			flow.setProcessDefinitionName(processDefinition.getName());
+			flow.setProcessDefinitionKey(processDefinition.getKey());
+			flow.setProcessDefinitionVersion(processDefinition.getVersion());
+			flow.setCategory(processDefinition.getCategory());
+			flow.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory()));
+
+			flow.setProcessInstanceId(historicTaskInstance.getProcessInstanceId());
+			flow.setHistoryProcessInstanceId(historicTaskInstance.getProcessInstanceId());
+			HistoricProcessInstance historicProcessInstance = getHistoricProcessInstance((historicTaskInstance.getProcessInstanceId()));
+			if (Func.isNotEmpty(historicProcessInstance)) {
+				String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey());
+				flow.setBusinessTable(businessKey[0]);
+				flow.setBusinessId(businessKey[1]);
+				if (historicProcessInstance.getEndActivityId() != null) {
+					flow.setProcessIsFinished(FlowEngineConstant.STATUS_FINISHED);
+				} else {
+					flow.setProcessIsFinished(FlowEngineConstant.STATUS_UNFINISHED);
+				}
+			}
+			flow.setStatus(FlowEngineConstant.STATUS_FINISH);
+			flowList.add(flow);
+		});
+
+
+		return flowList;
+	}
+
+
+
+	@Override
+	public List<BladeFlow> getMyDonePage(BladeFlow bladeFlow, String currentUserId, Integer current, Integer size) {
+
+		String taskUser = StringUtil.format("{}{}", TASK_USR_PREFIX, currentUserId);
+		List<BladeFlow> flowList = new LinkedList<>();
+
+		HistoricTaskInstanceQuery doneQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(taskUser).finished()
+			.includeProcessVariables().orderByHistoricTaskInstanceEndTime().desc();
+
+		if (bladeFlow.getCategory() != null) {
+			doneQuery.processCategoryIn(Func.toStrList(bladeFlow.getCategory()));
+		}
+		if (bladeFlow.getProcessDefinitionName() != null) {
+			doneQuery.processDefinitionName(bladeFlow.getProcessDefinitionName());
+		}
+		if (bladeFlow.getBeginDate() != null) {
+			doneQuery.taskCompletedAfter(bladeFlow.getBeginDate());
+		}
+		if (bladeFlow.getEndDate() != null) {
+			doneQuery.taskCompletedBefore(bladeFlow.getEndDate());
+		}
+
+		// 查询列表
+		List<HistoricTaskInstance> doneList = doneQuery.listPage(Func.toInt((current - 1) * size), Func.toInt(size));
+		doneList.forEach(historicTaskInstance -> {
+			BladeFlow flow = new BladeFlow();
+			flow.setTaskId(historicTaskInstance.getId());
+			flow.setTaskDefinitionKey(historicTaskInstance.getTaskDefinitionKey());
+			flow.setTaskName(historicTaskInstance.getName());
+			flow.setAssignee(historicTaskInstance.getAssignee());
+			flow.setCreateTime(historicTaskInstance.getCreateTime());
+			flow.setExecutionId(historicTaskInstance.getExecutionId());
+			flow.setHistoryTaskEndTime(historicTaskInstance.getEndTime());
+			flow.setVariables(historicTaskInstance.getProcessVariables());
+
+			FlowProcess processDefinition = FlowCache.getProcessDefinition(historicTaskInstance.getProcessDefinitionId());
+			flow.setProcessDefinitionId(processDefinition.getId());
+			flow.setProcessDefinitionName(processDefinition.getName());
+			flow.setProcessDefinitionKey(processDefinition.getKey());
+			flow.setProcessDefinitionVersion(processDefinition.getVersion());
+			flow.setCategory(processDefinition.getCategory());
+			flow.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory()));
+
+			flow.setProcessInstanceId(historicTaskInstance.getProcessInstanceId());
+			flow.setHistoryProcessInstanceId(historicTaskInstance.getProcessInstanceId());
+			HistoricProcessInstance historicProcessInstance = getHistoricProcessInstance((historicTaskInstance.getProcessInstanceId()));
+			if (Func.isNotEmpty(historicProcessInstance)) {
+				String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey());
+				flow.setBusinessTable(businessKey[0]);
+				flow.setBusinessId(businessKey[1]);
+				if (historicProcessInstance.getEndActivityId() != null) {
+					flow.setProcessIsFinished(FlowEngineConstant.STATUS_FINISHED);
+				} else {
+					flow.setProcessIsFinished(FlowEngineConstant.STATUS_UNFINISHED);
+				}
+			}
+			flow.setStatus(FlowEngineConstant.STATUS_FINISH);
+			flowList.add(flow);
+		});
+		return flowList;
+	}
+
 	@Override
 	public IPage<BladeFlowVO> selectDonePage(IPage<BladeFlowVO> page, BladeFlow bladeFlow,String currentUserId) {
 		String taskUser = StringUtil.format("{}{}", TASK_USR_PREFIX, currentUserId);
@@ -382,6 +528,7 @@
 		return flow;
 	}
 
+
 	/**
 	 * 构建流程
 	 *

--
Gitblit v1.9.3