| | |
| | | import org.flowable.task.api.Task; |
| | | import org.flowable.task.api.TaskQuery; |
| | | import org.flowable.task.api.history.HistoricTaskInstance; |
| | | 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.*; |
| | | |
| | | import org.springblade.mdm.basesetting.machine.MachineService; |
| | | import org.springblade.mdm.flow.constants.FlowContants; |
| | | import org.springblade.mdm.flow.entity.FlowProgramFile; |
| | | 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.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; |
| | |
| | | import java.util.Date; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 流程业务实现类 |
| | |
| | | private final IUserClient userClient; |
| | | private final ProcessProgRefService processProgRefService; |
| | | private final ApproveRecordService approveRecordService; |
| | | |
| | | private final NcProgramService ncProgramService; |
| | | private final FlowProgramFileService flowProgramFileService; |
| | | /** |
| | | * 查询我的流程(个人待办列表) |
| | | * @param page 分页信息 |
| | |
| | | TaskQuery todoQuery = taskService.createTaskQuery().taskAssignee(userId).active().includeProcessVariables(); |
| | | if (Func.isNotEmpty(createTimeBegin)) { |
| | | todoQuery.taskCreatedAfter(DateUtil.toDate(createTimeBegin)); |
| | | |
| | | ////如果查询实例的开始时间:只能用以下这个,先查出实例id来 |
| | | //todoQuery.processInstanceIdIn() |
| | | } |
| | | if (Func.isNotEmpty(createTimeEnd)) { |
| | | todoQuery.taskCreatedBefore(DateUtil.toDate(createTimeEnd)); |
| | |
| | | // 构建列表数据 |
| | | FlowVO bladeFlow = new FlowVO(); |
| | | 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(); |
| | | |
| | |
| | | |
| | | void addKeywordCondition(TaskQuery todoQuery,String keyword) { |
| | | if(Func.isNotEmpty(keyword)) { |
| | | String likeVal = "%" + keyword + "%"; |
| | | todoQuery.or(); |
| | | todoQuery.processVariableValueLike(FlowContants.TITLE,likeVal); |
| | | todoQuery.processVariableValueLike(FlowContants.PROCESS_NO, likeVal); |
| | | todoQuery.processVariableValueLike(FlowContants.MACHINE_CODE, likeVal); |
| | | todoQuery.processVariableValueLike(FlowContants.MACHINE_MODE, likeVal); |
| | | todoQuery.processVariableValueLike(FlowContants.PROCESS_NAME, likeVal); |
| | | todoQuery.processVariableValueLike(FlowContants.PROCESS_EDITION, likeVal); |
| | | todoQuery.processVariableValueLike(FlowContants.CRAFT_EDITION, likeVal); |
| | | |
| | | todoQuery.processVariableValueLike("processNo", "%" + keyword + "%"); |
| | | todoQuery.processVariableValueLike("machineCode", "%" + keyword + "%"); |
| | | todoQuery.processVariableValueLike("machineMode", "%" + keyword + "%"); |
| | | todoQuery.processVariableValueLike("processName", "%" + keyword + "%"); |
| | | todoQuery.processVariableValueLike("processEdition", "%" + keyword + "%"); |
| | | todoQuery.processVariableValueLike("craftEdition", "%" + keyword + "%"); |
| | | |
| | | todoQuery.processDefinitionNameLike(likeVal); |
| | | todoQuery.endOr(); |
| | | } |
| | | } |
| | |
| | | |
| | | //List<Task> tasks = taskQuery.list(); |
| | | long total = taskQuery.count(); |
| | | Long firstResult = (currentPage-1)*pageSize+1; |
| | | Long firstResult = (currentPage-1)*pageSize; |
| | | List<Task> tasks = taskQuery.listPage(Func.toInt(firstResult), Func.toInt(pageSize)); |
| | | tasks.forEach(task -> { |
| | | FlowVO flow = new FlowVO(); |
| | |
| | | |
| | | flow.setProcessDefinitionId(task.getProcessDefinitionId()); |
| | | |
| | | flow.setFile(getFileString(task.getProcessInstanceId())); |
| | | //flow.setProcessDefinitionKey(processDefinition.getKey()); |
| | | //flow.setProcessDefinitionVersion(processDefinition.getVersion()); |
| | | flow.setProcessInstanceId(task.getProcessInstanceId()); |
| | |
| | | |
| | | /** |
| | | * 已完结的流程分页列表 |
| | | * @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(getFileString(processInstance.getId())); |
| | | records.add(vo); |
| | | } |
| | | |
| | |
| | | |
| | | return page; |
| | | } |
| | | /* |
| | | 获取列表中的文件名 |
| | | */ |
| | | String getFileString(String processInstanceId){ |
| | | String result = ""; |
| | | List<FlowProgramFile> fileList = flowProgramFileService.lambdaQuery().eq(FlowProgramFile::getProcessInstanceId, processInstanceId).list(); |
| | | |
| | | result = String.join(",",fileList.stream().map(FlowProgramFile::getName).toList()); |
| | | |
| | | return result; |
| | | } |
| | | } |