| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.google.common.collect.Lists; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.flowable.task.api.Task; |
| | | import org.flowable.task.api.TaskQuery; |
| | | import org.flowable.task.api.history.HistoricTaskInstance; |
| | | import org.flowable.task.api.history.HistoricTaskInstanceQuery; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.SpringContextUtils; |
| | | import org.jeecg.modules.flowable.apithird.business.dto.FlowMyBusinessDto; |
| | | import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; |
| | | import org.jeecg.modules.flowable.apithird.business.service.impl.FlowMyBusinessServiceImpl; |
| | | import org.jeecg.modules.flowable.apithird.common.constant.ProcessConstants; |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result finishedList(Integer pageNum, Integer pageSize) { |
| | | Page<FlowTaskDto> page = new Page<>(); |
| | | public Result finishedList(Integer pageNum, Integer pageSize, FlowMyBusinessDto flowMyBusinessDto) { |
| | | //修改查询,添加查询条件 |
| | | Page page = new Page(pageNum, pageSize); |
| | | String username = iFlowThirdService.getLoginUser().getUsername(); |
| | | HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery() |
| | | .includeProcessVariables() |
| | | .finished() |
| | | .taskAssignee(username) |
| | | .orderByHistoricTaskInstanceEndTime() |
| | | .desc(); |
| | | List<HistoricTaskInstance> historicTaskInstanceList = taskInstanceQuery.listPage((pageNum - 1)*pageSize, pageSize); |
| | | List<FlowTaskDto> hisTaskList = Lists.newArrayList(); |
| | | for (HistoricTaskInstance histTask : historicTaskInstanceList) { |
| | | FlowTaskDto flowTask = new FlowTaskDto(); |
| | | // 当前流程信息 |
| | | flowTask.setTaskId(histTask.getId()); |
| | | // 审批人员信息 |
| | | flowTask.setCreateTime(histTask.getCreateTime()); |
| | | flowTask.setFinishTime(histTask.getEndTime()); |
| | | flowTask.setDuration(getDate(histTask.getDurationInMillis())); |
| | | flowTask.setProcDefId(histTask.getProcessDefinitionId()); |
| | | flowTask.setTaskDefKey(histTask.getTaskDefinitionKey()); |
| | | flowTask.setTaskName(histTask.getName()); |
| | | FlowMyBusiness flowMyBusiness = flowMyBusinessService.getByProcessInstanceId(histTask.getProcessInstanceId()); |
| | | if (flowMyBusiness != null) { |
| | | flowTask.setDescription(flowMyBusiness.getTitle()); |
| | | } |
| | | flowMyBusinessDto.setCurrentUser(username); |
| | | IPage<FlowTaskDto> flowTaskDtoIPage = flowMyBusinessService.getPageListMyBusiness(page,flowMyBusinessDto); |
| | | flowTaskDtoIPage.getRecords().forEach(flowTaskDto -> { |
| | | // 流程定义信息 |
| | | ProcessDefinition pd = repositoryService.createProcessDefinitionQuery() |
| | | .processDefinitionId(histTask.getProcessDefinitionId()) |
| | | .processDefinitionId(flowTaskDto.getProcessDefinitionId()) |
| | | .singleResult(); |
| | | flowTask.setDeployId(pd.getDeploymentId()); |
| | | flowTask.setProcDefName(pd.getName()); |
| | | flowTask.setProcDefVersion(pd.getVersion()); |
| | | flowTask.setProcInsId(histTask.getProcessInstanceId()); |
| | | flowTask.setHisProcInsId(histTask.getProcessInstanceId()); |
| | | |
| | | flowTaskDto.setDeployId(pd.getDeploymentId()); |
| | | flowTaskDto.setProcDefName(pd.getName()); |
| | | flowTaskDto.setProcDefVersion(pd.getVersion()); |
| | | flowTaskDto.setCategory(pd.getCategory()); |
| | | // 流程发起人信息 |
| | | HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() |
| | | .processInstanceId(histTask.getProcessInstanceId()) |
| | | .processInstanceId(flowTaskDto.getTaskId()) |
| | | .singleResult(); |
| | | SysUser startUser = iFlowThirdService.getUserByUsername(historicProcessInstance.getStartUserId()); |
| | | flowTask.setStartUserId(startUser.getUsername()); |
| | | flowTask.setStartUserName(startUser.getRealname()); |
| | | flowTaskDto.setStartUserId(startUser.getUsername()); |
| | | flowTaskDto.setStartUserName(startUser.getRealname()); |
| | | List<String> departNamesByUsername = iFlowThirdService.getDepartNamesByUsername(historicProcessInstance.getStartUserId()); |
| | | flowTask.setStartDeptName(CollUtil.join(departNamesByUsername,",")); |
| | | hisTaskList.add(flowTask); |
| | | } |
| | | page.setTotal(hisTaskList.size()); |
| | | page.setRecords(hisTaskList); |
| | | // Map<String, Object> result = new HashMap<>(); |
| | | // result.put("result",page); |
| | | // result.put("finished",true); |
| | | flowTaskDto.setStartDeptName(CollUtil.join(departNamesByUsername,",")); |
| | | flowTaskDto.setTaskId(flowTaskDto.getHisProcInsId()); |
| | | }); |
| | | return Result.OK(page); |
| | | } |
| | | |