| | |
| | | import org.springblade.core.tool.utils.*; |
| | | |
| | | import org.springblade.mdm.flow.constants.FlowContants; |
| | | import org.springblade.mdm.flow.constants.FlowVariableContants; |
| | | 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.service.NcProgramService; |
| | | import org.springblade.mdm.program.service.ProcessProgRefService; |
| | | import org.springblade.system.feign.IUserClient; |
| | | import org.springblade.system.pojo.entity.User; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | /** |
| | | * 流程业务实现类 |
| | | * |
| | | * @author Chill |
| | | * @author yangys |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | |
| | | 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(FlowVariableContants.TITLE,likeVal); |
| | | todoQuery.processVariableValueLike(FlowVariableContants.PROCESS_NO, likeVal); |
| | | todoQuery.processVariableValueLike(FlowVariableContants.MACHINE_CODE, likeVal); |
| | | todoQuery.processVariableValueLike(FlowVariableContants.MACHINE_MODE, likeVal); |
| | | todoQuery.processVariableValueLike(FlowVariableContants.PROCESS_NAME, likeVal); |
| | | todoQuery.processVariableValueLike(FlowVariableContants.PROCESS_EDITION, likeVal); |
| | | todoQuery.processVariableValueLike(FlowVariableContants.CRAFT_EDITION, likeVal); |
| | | |
| | | todoQuery.processDefinitionNameLike(likeVal); |
| | | todoQuery.endOr(); |
| | |
| | | if(ru.isSuccess()) { |
| | | flow.setStartUserName(ru.getData().getName()); |
| | | } |
| | | ; |
| | | List<Comment> comments = lastStepComments(task);//taskService.getTaskComments(task.getId()); |
| | | if(!comments.isEmpty()){ |
| | | flow.setComment(comments.get(0).getFullMessage()); |
| | |
| | | return Collections.emptyList(); |
| | | } |
| | | } |
| | | /** |
| | | * 获取历史流程 |
| | | * |
| | | * @param processInstanceId 流程实例id |
| | | * @return HistoricProcessInstance |
| | | */ |
| | | private HistoricProcessInstance getHistoricProcessInstance(String processInstanceId) { |
| | | return historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); |
| | | } |
| | | |
| | | |
| | | public IPage<FlowVO> selectAllTaskPage(IPage<FlowVO> page, String keyword) { |
| | | |
| | |
| | | * @param keyword |
| | | * @return |
| | | */ |
| | | public IPage<FlowVO> selectSearchPage(IPage<FlowVO> page, LocalDate createTimeBegin, LocalDate createTimeEnd,String processDefinitionKey,String keyword) { |
| | | public IPage<FlowVO> selectSearchPage(IPage<FlowVO> page,String myProcessName,String keyword, LocalDate createTimeBegin, LocalDate createTimeEnd) { |
| | | |
| | | List<FlowVO> flowList = new LinkedList<>(); |
| | | Date now = new Date(); |
| | | TaskQuery taskQuery = taskService.createTaskQuery().active().includeProcessVariables(); |
| | | if(Func.isNotEmpty(createTimeBegin)) { |
| | | taskQuery.taskCreatedAfter(DateUtil.toDate(createTimeBegin)); |
| | |
| | | if(Func.isNotEmpty(createTimeEnd)) { |
| | | taskQuery.taskCreatedBefore(DateUtil.toDate(createTimeEnd.plusDays(1))); |
| | | } |
| | | if(Func.isNotEmpty(processDefinitionKey)) { |
| | | taskQuery.processDefinitionKey(processDefinitionKey); |
| | | if(Func.isNotEmpty(myProcessName)) { |
| | | taskQuery.processVariableValueEquals(FlowVariableContants.MY_PROCESS_NAME, myProcessName); |
| | | } |
| | | |
| | | addKeywordCondition(taskQuery, keyword); |
| | |
| | | * @param keyword 关键字 |
| | | * @return |
| | | */ |
| | | public IPage<FlowVO> selectFinishedPage(IPage<FlowVO> page, String processDefinitionKey,LocalDateTime createTimeBegin, LocalDateTime createTimeEnd, String keyword) { |
| | | public IPage<FlowVO> selectFinishedPage(IPage<FlowVO> page, String myProcessName, String keyword,LocalDateTime createTimeBegin, LocalDateTime createTimeEnd) { |
| | | HistoricProcessInstanceQuery query = this.historyService.createHistoricProcessInstanceQuery().finished().includeProcessVariables(); |
| | | //.finished() // 只查询已完成的流程.unfinished() // 查询未完成的流程 |
| | | if(Func.isNotEmpty(processDefinitionKey)) { |
| | | query.processDefinitionKey(processDefinitionKey); |
| | | if(Func.isNotEmpty(myProcessName)) { |
| | | query.variableValueEquals(FlowVariableContants.MY_PROCESS_NAME, myProcessName); |
| | | } |
| | | if(createTimeBegin!=null) { |
| | | query.startedAfter(DateUtil.toDate(createTimeBegin)); |
| | |
| | | if(createTimeEnd!=null) { |
| | | query.startedBefore(DateUtil.toDate(createTimeEnd)); |
| | | } |
| | | if(Func.isNotEmpty(keyword)) { |
| | | String likeVal = "%" + keyword + "%"; |
| | | query.or(); |
| | | query.variableValueLike(FlowVariableContants.TITLE,likeVal); |
| | | query.variableValueLike(FlowVariableContants.PROCESS_NO, likeVal); |
| | | query.variableValueLike(FlowVariableContants.MACHINE_CODE, likeVal); |
| | | query.variableValueLike(FlowVariableContants.MACHINE_MODE, likeVal); |
| | | query.variableValueLike(FlowVariableContants.PROCESS_NAME, likeVal); |
| | | query.variableValueLike(FlowVariableContants.PROCESS_EDITION, likeVal); |
| | | query.variableValueLike(FlowVariableContants.CRAFT_EDITION, likeVal); |
| | | |
| | | query.endOr(); |
| | | } |
| | | |
| | | |
| | | query.orderByProcessInstanceEndTime().desc(); // 按结束时间降序排列 |
| | | page.setTotal(query.count()); |
| | | |
| | |
| | | vo.setProcessCreateTime(processInstance.getStartTime()); |
| | | vo.setHistoryTaskEndTime(processInstance.getEndTime()); |
| | | |
| | | R<User> ru = userClient.userInfoById(Long.valueOf(processInstance.getStartUserId())); |
| | | if(ru.isSuccess()) { |
| | | vo.setStartUserName(ru.getData().getName()); |
| | | } |
| | | |
| | | vo.setFile(getFileString(processInstance.getId())); |
| | | records.add(vo); |
| | | } |
| | | |
| | | page.setRecords(records); |
| | | |
| | | return page; |
| | | } |
| | | |
| | | /** |
| | | * 异常流程 |
| | | * @param page |
| | | * @param myProcessName |
| | | * @param keyword |
| | | * @param createTimeBegin |
| | | * @param createTimeEnd |
| | | * @return |
| | | */ |
| | | public IPage<FlowVO> selectExceptionPage(IPage<FlowVO> page, String myProcessName, String keyword,LocalDateTime createTimeBegin, LocalDateTime createTimeEnd) { |
| | | HistoricProcessInstanceQuery query = this.historyService.createHistoricProcessInstanceQuery().finished().includeProcessVariables(); |
| | | //.finished() // 只查询已完成的流程.unfinished() // 查询未完成的流程 |
| | | |
| | | query.variableValueEquals(FlowVariableContants.EXCEPTION, "1"); |
| | | if(Func.isNotEmpty(myProcessName)) { |
| | | query.variableValueEquals(FlowVariableContants.MY_PROCESS_NAME, myProcessName); |
| | | } |
| | | if(createTimeBegin!=null) { |
| | | query.startedAfter(DateUtil.toDate(createTimeBegin)); |
| | | } |
| | | if(createTimeEnd!=null) { |
| | | query.startedBefore(DateUtil.toDate(createTimeEnd)); |
| | | } |
| | | if(Func.isNotEmpty(keyword)) { |
| | | String likeVal = "%" + keyword + "%"; |
| | | query.or(); |
| | | query.variableValueLike(FlowVariableContants.TITLE,likeVal); |
| | | query.variableValueLike(FlowVariableContants.PROCESS_NO, likeVal); |
| | | query.variableValueLike(FlowVariableContants.MACHINE_CODE, likeVal); |
| | | query.variableValueLike(FlowVariableContants.MACHINE_MODE, likeVal); |
| | | query.variableValueLike(FlowVariableContants.PROCESS_NAME, likeVal); |
| | | query.variableValueLike(FlowVariableContants.PROCESS_EDITION, likeVal); |
| | | query.variableValueLike(FlowVariableContants.CRAFT_EDITION, likeVal); |
| | | |
| | | query.endOr(); |
| | | } |
| | | |
| | | |
| | | query.orderByProcessInstanceEndTime().desc(); // 按结束时间降序排列 |
| | | page.setTotal(query.count()); |
| | | |
| | | long firstResult = (page.getCurrent()-1) * page.getSize(); |
| | | List<HistoricProcessInstance> processes = query |
| | | .listPage((int)firstResult, (int)page.getSize()); |
| | | |
| | | List<FlowVO> records = new LinkedList<>(); |
| | | |
| | | for(HistoricProcessInstance processInstance : processes) { |
| | | FlowVO vo = new FlowVO(); |
| | | vo.setProcessDefinitionKey(processInstance.getProcessDefinitionKey()); |
| | | vo.setProcessInstanceId(processInstance.getId()); |
| | | vo.setProcessDefinitionName(processInstance.getProcessDefinitionName()); |
| | | vo.setVariables(processInstance.getProcessVariables()); |
| | | |
| | | vo.setProcessCreateTime(processInstance.getStartTime()); |
| | | vo.setHistoryTaskEndTime(processInstance.getEndTime()); |
| | | R<User> ru = userClient.userInfoById(Long.valueOf(processInstance.getStartUserId())); |
| | | if(ru.isSuccess()) { |
| | | vo.setStartUserName(ru.getData().getName()); |
| | | } |
| | | vo.setFile(getFileString(processInstance.getId())); |
| | | records.add(vo); |
| | | } |
| | |
| | | |
| | | return page; |
| | | } |
| | | |
| | | } |