| | |
| | | import org.springblade.core.tool.utils.*; |
| | | |
| | | import org.springblade.mdm.basesetting.machine.MachineService; |
| | | import org.springblade.mdm.flow.constants.FlowContants; |
| | | import org.springblade.mdm.flow.entity.MdmFlowProcess; |
| | | import org.springblade.mdm.flow.util.MdmFlowCache; |
| | | import org.springblade.mdm.flow.vo.FlowVO; |
| | | import org.springblade.mdm.program.entity.NcProgram; |
| | | import org.springblade.mdm.program.entity.ProcessProgRef; |
| | | import org.springblade.mdm.program.service.NcProgramService; |
| | | import org.springblade.mdm.program.service.ProcessProgRefService; |
| | | import org.springblade.system.feign.IUserClient; |
| | | import org.springblade.system.pojo.entity.User; |
| | |
| | | private final IUserClient userClient; |
| | | private final ProcessProgRefService processProgRefService; |
| | | private final ApproveRecordService approveRecordService; |
| | | |
| | | private final NcProgramService ncProgramService; |
| | | /** |
| | | * 查询我的流程(个人待办列表) |
| | | * @param page |
| | | * @param createTimeBegin |
| | | * @param createTimeEnd |
| | | * @param keyword |
| | | * @param page 分页信息 |
| | | * @param createTimeBegin 创建时间开始 |
| | | * @param createTimeEnd 创建时间截止 |
| | | * @param keyword 查询关键字 |
| | | * @return |
| | | */ |
| | | public IPage<FlowVO> selectTodoPage(IPage<FlowVO> page, LocalDateTime createTimeBegin, LocalDateTime createTimeEnd, String keyword) { |
| | |
| | | |
| | | // 构建列表数据 |
| | | FlowVO bladeFlow = new FlowVO(); |
| | | buildFlowTaskList(bladeFlow, flowList, todoQuery); |
| | | buildFlowTaskList(bladeFlow, flowList, todoQuery,page.getCurrent(),page.getSize()); |
| | | flowList.forEach(flowVO -> { |
| | | if(flowVO.getVariables().containsKey("machineCode")){ |
| | | //Machine machinemachineService.getByCode((String)flowVO.getVariables().get("machineCode")) |
| | |
| | | }); |
| | | // 计算总数 |
| | | long count = todoQuery.count(); |
| | | // 设置页数 |
| | | //page.setSize(count); |
| | | |
| | | // 设置总数 |
| | | page.setTotal(count); |
| | | // 设置数据 |
| | |
| | | * @param flowList 流程列表 |
| | | * @param taskQuery 任务查询类 |
| | | */ |
| | | private void buildFlowTaskList(FlowVO bladeFlow, List<FlowVO> flowList, TaskQuery taskQuery) { |
| | | private void buildFlowTaskList(FlowVO bladeFlow, List<FlowVO> flowList, TaskQuery taskQuery,Long currentPage,Long pageSize) { |
| | | if (bladeFlow.getCategory() != null) { |
| | | taskQuery.processCategoryIn(Func.toStrList(bladeFlow.getCategory())); |
| | | } |
| | |
| | | taskQuery.taskCreatedBefore(bladeFlow.getEndDate()); |
| | | } |
| | | |
| | | List<Task> tasks = taskQuery.list(); |
| | | //List<Task> tasks = taskQuery.list(); |
| | | long total = taskQuery.count(); |
| | | Long firstResult = (currentPage-1)*pageSize; |
| | | List<Task> tasks = taskQuery.listPage(Func.toInt(firstResult), Func.toInt(pageSize)); |
| | | tasks.forEach(task -> { |
| | | FlowVO flow = new FlowVO(); |
| | | flow.setTaskId(task.getId()); |
| | |
| | | |
| | | flow.setProcessDefinitionId(task.getProcessDefinitionId()); |
| | | |
| | | flow.setFile(getNcFileString(String.valueOf(task.getProcessVariables().get("programIds")))); |
| | | //flow.setProcessDefinitionKey(processDefinition.getKey()); |
| | | //flow.setProcessDefinitionVersion(processDefinition.getVersion()); |
| | | flow.setProcessInstanceId(task.getProcessInstanceId()); |
| | |
| | | |
| | | // 构建列表数据 |
| | | FlowVO bladeFlow = new FlowVO(); |
| | | buildFlowTaskList(bladeFlow, flowList, todoQuery);//FlowEngineConstant.STATUS_TODO |
| | | buildFlowTaskList(bladeFlow, flowList, todoQuery,page.getCurrent(),page.getSize());//FlowEngineConstant.STATUS_TODO |
| | | |
| | | // 计算总数 |
| | | long count = todoQuery.count(); |
| | |
| | | |
| | | // 构建列表数据 |
| | | FlowVO bladeFlow = new FlowVO(); |
| | | buildFlowTaskList(bladeFlow, flowList, todoQuery);//FlowEngineConstant.STATUS_TODO |
| | | buildFlowTaskList(bladeFlow, flowList, todoQuery,page.getCurrent(),page.getSize());//FlowEngineConstant.STATUS_TODO |
| | | |
| | | // 计算总数 |
| | | long count = todoQuery.count(); |
| | | // 设置页数 |
| | | page.setSize(count); |
| | | |
| | | // 设置总数 |
| | | page.setTotal(count); |
| | | // 设置数据 |
| | |
| | | * @param keyword |
| | | * @return |
| | | */ |
| | | public IPage<FlowVO> selectSearchPage(IPage<FlowVO> page, LocalDate createTimeBegin, LocalDate createTimeEnd, String keyword) { |
| | | public IPage<FlowVO> selectSearchPage(IPage<FlowVO> page, LocalDate createTimeBegin, LocalDate createTimeEnd,String processDefinitionKey,String keyword) { |
| | | |
| | | List<FlowVO> flowList = new LinkedList<>(); |
| | | Date now = new Date(); |
| | |
| | | if(Func.isNotEmpty(createTimeEnd)) { |
| | | taskQuery.taskCreatedBefore(DateUtil.toDate(createTimeEnd.plusDays(1))); |
| | | } |
| | | if(Func.isNotEmpty(processDefinitionKey)) { |
| | | taskQuery.processDefinitionKey(processDefinitionKey); |
| | | } |
| | | |
| | | addKeywordCondition(taskQuery, keyword); |
| | | |
| | |
| | | |
| | | // 构建列表数据 |
| | | FlowVO bladeFlow = new FlowVO(); |
| | | buildFlowTaskList(bladeFlow, flowList, taskQuery);//FlowEngineConstant.STATUS_TODO |
| | | buildFlowTaskList(bladeFlow, flowList, taskQuery,page.getCurrent(),page.getSize());//FlowEngineConstant.STATUS_TODO |
| | | |
| | | // 计算总数 |
| | | long count = taskQuery.count(); |
| | | // 设置页数 |
| | | page.setSize(count); |
| | | // 设置总数 |
| | | page.setTotal(count); |
| | | // 设置数据 |
| | |
| | | |
| | | /** |
| | | * 已完结的流程分页列表 |
| | | * @param page |
| | | * @param page 分页信息 |
| | | * @param createTimeBegin |
| | | * @param createTimeEnd |
| | | * @param keyword |
| | | * @param keyword 关键字 |
| | | * @return |
| | | */ |
| | | public IPage<FlowVO> selectFinishedPage(IPage<FlowVO> page, String processDefinitionKey,LocalDate createTimeBegin, LocalDate createTimeEnd, String keyword) { |
| | |
| | | query.orderByProcessInstanceEndTime().desc(); // 按结束时间降序排列 |
| | | page.setTotal(query.count()); |
| | | |
| | | long firstResult = (page.getCurrent()-1) * page.getSize() + 1; |
| | | long firstResult = (page.getCurrent()-1) * page.getSize(); |
| | | List<HistoricProcessInstance> processes = query |
| | | .listPage((int)firstResult, (int)page.getSize()); |
| | | |
| | |
| | | vo.setProcessCreateTime(processInstance.getStartTime()); |
| | | vo.setHistoryTaskEndTime(processInstance.getEndTime()); |
| | | |
| | | vo.setFile(getNcFileString(String.valueOf(processInstance.getProcessVariables().get(FlowContants.PROGRAM_IDS_KEY)))); |
| | | records.add(vo); |
| | | } |
| | | |
| | |
| | | |
| | | return page; |
| | | } |
| | | |
| | | String getNcFileString(String programIds){ |
| | | String result = ""; |
| | | if(Func.isNotEmpty(programIds)) { |
| | | List<NcProgram> progList= ncProgramService.listByIds(Func.toLongList(programIds)); |
| | | result = String.join(",",progList.stream().map(NcProgram::getName).toList()); |
| | | } |
| | | return result; |
| | | } |
| | | } |