| | |
| | | import org.flowable.task.api.TaskQuery; |
| | | import org.flowable.task.api.history.HistoricTaskInstance; |
| | | import org.flowable.task.api.history.HistoricTaskInstanceQuery; |
| | | import org.springblade.core.launch.constant.FlowConstant; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.*; |
| | |
| | | private final TaskService taskService; |
| | | private final HistoryService historyService; |
| | | private final IUserClient userClient; |
| | | private final ProcessProgRefService processProgRefService; |
| | | private final ApproveRecordService approveRecordService; |
| | | private final NcProgramService ncProgramService; |
| | | private final FlowProgramFileService flowProgramFileService; |
| | | /** |
| | | * æ¥è¯¢æçæµç¨(个人å¾
åå表) |
| | |
| | | todoQuery.endOr(); |
| | | } |
| | | } |
| | | /* |
| | | @Override |
| | | public IPage<BladeFlow> selectSendPage(IPage<BladeFlow> page, BladeFlow bladeFlow) { |
| | | String taskUser = TaskUtil.getTaskUser(); |
| | | List<BladeFlow> flowList = new LinkedList<>(); |
| | | |
| | | HistoricProcessInstanceQuery historyQuery = historyService.createHistoricProcessInstanceQuery().startedBy(taskUser).orderByProcessInstanceStartTime().desc(); |
| | | |
| | | if (bladeFlow.getCategory() != null) { |
| | | historyQuery.processDefinitionCategory(bladeFlow.getCategory()); |
| | | } |
| | | if (bladeFlow.getProcessDefinitionName() != null) { |
| | | historyQuery.processDefinitionName(bladeFlow.getProcessDefinitionName()); |
| | | } |
| | | if (bladeFlow.getBeginDate() != null) { |
| | | historyQuery.startedAfter(bladeFlow.getBeginDate()); |
| | | } |
| | | if (bladeFlow.getEndDate() != null) { |
| | | historyQuery.startedBefore(bladeFlow.getEndDate()); |
| | | } |
| | | |
| | | // æ¥è¯¢å表 |
| | | List<HistoricProcessInstance> historyList = historyQuery.listPage(Func.toInt((page.getCurrent() - 1) * page.getSize()), Func.toInt(page.getSize())); |
| | | |
| | | historyList.forEach(historicProcessInstance -> { |
| | | BladeFlow flow = new BladeFlow(); |
| | | // historicProcessInstance |
| | | flow.setCreateTime(historicProcessInstance.getStartTime()); |
| | | flow.setEndTime(historicProcessInstance.getEndTime()); |
| | | flow.setVariables(historicProcessInstance.getProcessVariables()); |
| | | String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey()); |
| | | if (businessKey.length > 1) { |
| | | flow.setBusinessTable(businessKey[0]); |
| | | flow.setBusinessId(businessKey[1]); |
| | | } |
| | | flow.setHistoryActivityName(historicProcessInstance.getName()); |
| | | flow.setProcessInstanceId(historicProcessInstance.getId()); |
| | | flow.setHistoryProcessInstanceId(historicProcessInstance.getId()); |
| | | // ProcessDefinition |
| | | FlowProcess processDefinition = FlowCache.getProcessDefinition(historicProcessInstance.getProcessDefinitionId()); |
| | | flow.setProcessDefinitionId(processDefinition.getId()); |
| | | flow.setProcessDefinitionName(processDefinition.getName()); |
| | | flow.setProcessDefinitionVersion(processDefinition.getVersion()); |
| | | flow.setProcessDefinitionKey(processDefinition.getKey()); |
| | | flow.setCategory(processDefinition.getCategory()); |
| | | flow.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory())); |
| | | flow.setProcessInstanceId(historicProcessInstance.getId()); |
| | | // HistoricTaskInstance |
| | | List<HistoricTaskInstance> historyTasks = historyService.createHistoricTaskInstanceQuery().processInstanceId(historicProcessInstance.getId()).orderByHistoricTaskInstanceEndTime().desc().list(); |
| | | if (Func.isNotEmpty(historyTasks)) { |
| | | HistoricTaskInstance historyTask = historyTasks.iterator().next(); |
| | | flow.setTaskId(historyTask.getId()); |
| | | flow.setTaskName(historyTask.getName()); |
| | | flow.setTaskDefinitionKey(historyTask.getTaskDefinitionKey()); |
| | | } |
| | | // Status |
| | | if (historicProcessInstance.getEndActivityId() != null) { |
| | | flow.setProcessIsFinished(FlowEngineConstant.STATUS_FINISHED); |
| | | } else { |
| | | flow.setProcessIsFinished(FlowEngineConstant.STATUS_UNFINISHED); |
| | | } |
| | | flow.setStatus(FlowEngineConstant.STATUS_FINISH); |
| | | flowList.add(flow); |
| | | }); |
| | | |
| | | // è®¡ç®æ»æ° |
| | | long count = historyQuery.count(); |
| | | // è®¾ç½®æ»æ° |
| | | page.setTotal(count); |
| | | page.setRecords(flowList); |
| | | return page; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<BladeFlow> selectDonePage(IPage<BladeFlow> page, BladeFlow bladeFlow) { |
| | | String taskUser = TaskUtil.getTaskUser(); |
| | | 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((page.getCurrent() - 1) * page.getSize()), Func.toInt(page.getSize())); |
| | | 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); |
| | | }); |
| | | // è®¡ç®æ»æ° |
| | | long count = doneQuery.count(); |
| | | // è®¾ç½®æ»æ° |
| | | page.setTotal(count); |
| | | page.setRecords(flowList); |
| | | return page; |
| | | } |
| | | |
| | | */ |
| | | /** |
| | | * æå»ºæµç¨ |
| | | * |
| | |
| | | flow.setProcessDefinitionId(task.getProcessDefinitionId()); |
| | | |
| | | flow.setFile(getFileString(task.getProcessInstanceId())); |
| | | //flow.setProcessDefinitionKey(processDefinition.getKey()); |
| | | //flow.setProcessDefinitionVersion(processDefinition.getVersion()); |
| | | flow.setProcessInstanceId(task.getProcessInstanceId()); |
| | | |
| | | // æ¥è¯¢æµç¨å®ä¾å建æ¶é´ |
| | |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢å·²åä»»å¡åé¡µæ°æ® |
| | | * 个人已å(已宿任å¡) |
| | | * @param page |
| | | * @param processDefinitionKey |
| | | * @param createTimeBegin |
| | | * @param createTimeEnd |
| | | * @param keyword |
| | | * @return |
| | | */ |
| | | /* |
| | | public IPage<FlowVO> selectDonePage(IPage<FlowVO> page, LocalDateTime createTimeBegin, LocalDateTime createTimeEnd, String keyword) { |
| | | String userId = "" + AuthUtil.getUserId(); |
| | | List<FlowVO> flowList = new LinkedList<>(); |
| | | |
| | | HistoricTaskInstanceQuery doneTaskQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(userId).finished().includeProcessVariables(); |
| | | //TaskQuery todoQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(userId).finished().includeProcessVariables() |
| | | if (Func.isNotEmpty(createTimeBegin)) { |
| | | doneTaskQuery.taskCreatedAfter(DateUtil.toDate(createTimeBegin)); |
| | | } |
| | | if (Func.isNotEmpty(createTimeEnd)) { |
| | | doneTaskQuery.taskCreatedBefore(DateUtil.toDate(createTimeEnd)); |
| | | //todoQuery.taskInProgressStartTimeBefore(DateUtil.toDate(createTimeEnd)); |
| | | } |
| | | if (Func.isNotEmpty(keyword)) { |
| | | addKeywordCondition(doneTaskQuery, keyword); |
| | | } |
| | | |
| | | todoQuery.orderByTaskCreateTime().desc(); |
| | | |
| | | // æå»ºåè¡¨æ°æ® |
| | | FlowVO bladeFlow = new FlowVO(); |
| | | buildFlowTaskList(bladeFlow, flowList, todoQuery,page.getCurrent(),page.getSize()); |
| | | |
| | | // è®¡ç®æ»æ° |
| | | long count = todoQuery.count(); |
| | | |
| | | // è®¾ç½®æ»æ° |
| | | page.setTotal(count); |
| | | // è®¾ç½®æ°æ® |
| | | page.setRecords(flowList); |
| | | return page; |
| | | }*/ |
| | | public IPage<FlowVO> selectDonePage(IPage<FlowVO> page, String processDefinitionKey,LocalDateTime completeTimeBegin, LocalDateTime createTimeEnd, String keyword) { |
| | | public IPage<FlowVO> selectDonePage(IPage<FlowVO> page, String processDefinitionKey,LocalDateTime createTimeBegin, LocalDateTime createTimeEnd, String keyword) { |
| | | String userId = "" + AuthUtil.getUserId(); |
| | | HistoricTaskInstanceQuery doneTaskQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(userId).finished().includeProcessVariables(); |
| | | |
| | |
| | | if(Func.isNotEmpty(processDefinitionKey)) { |
| | | doneTaskQuery.processDefinitionKey(processDefinitionKey); |
| | | } |
| | | if(completeTimeBegin!=null) { |
| | | doneTaskQuery.taskCompletedAfter(DateUtil.toDate(completeTimeBegin)); |
| | | if(createTimeBegin!=null) { |
| | | Date after = DateUtil.toDate(createTimeBegin); |
| | | |
| | | doneTaskQuery.taskCreatedAfter(after); |
| | | |
| | | //doneTaskQuery.taskCreatedOn(after); |
| | | //doneTaskQuery.taskInProgressStartTimeAfter(after); |
| | | } |
| | | if(createTimeEnd!=null) { |
| | | doneTaskQuery.taskCompletedBefore(DateUtil.toDate(createTimeEnd)); |
| | | Date before = DateUtil.toDate(createTimeEnd); |
| | | |
| | | doneTaskQuery.taskCreatedBefore(before); |
| | | |
| | | //doneTaskQuery.taskInProgressStartTimeBefore(before); |
| | | } |
| | | //QueryProperty |
| | | |
| | | if (Func.isNotEmpty(keyword)) { |
| | | addKeywordCondition(doneTaskQuery, keyword); |
| | | } |
| | | |
| | | doneTaskQuery.orderByTaskCreateTime().desc(); // æç»ææ¶é´éåºæå |
| | | page.setTotal(doneTaskQuery.count()); |
| | | |
| | |
| | | .listPage((int)firstResult, (int)page.getSize()); |
| | | |
| | | List<FlowVO> records = new LinkedList<>(); |
| | | //Map<String,String> processDefKeyMap = new HashMap<>();//使ç¨TaskDefinitionKeyç¼åProcessDefinitionKey |
| | | //Map<String,String> processDefNameMap = new HashMap<>();//使ç¨TaskDefinitionKeyç¼åProcessDefinitionName |
| | | |
| | | Map<String,String> startUserMap = new HashMap<>();//使ç¨userIdç¼åå
¶å§å |
| | | for(HistoricTaskInstance hisTask : processes) { |
| | | FlowVO vo = new FlowVO(); |
| | | |
| | | |
| | | HistoricProcessInstance processInstance = historyService |
| | | .createHistoricProcessInstanceQuery() |