guoshilong
2024-03-23 f04487fef5ac47380dfa9670156743c9d273966b
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;
   }
   /**
    * 构建流程
    *