| | |
| | | import com.ycl.domain.form.ProjectProcessForm; |
| | | import com.ycl.domain.vo.ProjectProcessVO; |
| | | import com.ycl.domain.query.ProjectProcessQuery; |
| | | import com.ycl.service.common.TaskCommonService; |
| | | import com.ycl.system.service.ISysDeptService; |
| | | import com.ycl.system.service.ISysRoleService; |
| | | import com.ycl.system.service.ISysUserService; |
| | |
| | | private final ISysUserService sysUserService; |
| | | private final ISysRoleService sysRoleService; |
| | | private final ISysDeptService sysDeptService; |
| | | private final TaskCommonService taskCommonService; |
| | | |
| | | /** |
| | | * 分页查询 |
| | |
| | | if (Objects.nonNull(pp.getProcessInsId())) { |
| | | HistoricProcessInstance historicProcessInstance = |
| | | historyService.createHistoricProcessInstanceQuery().processInstanceId(pp.getProcessInsId()).singleResult(); |
| | | // 删除之前流程的数据 |
| | | if (historicProcessInstance.getEndTime() != null) { |
| | | historyService.deleteHistoricProcessInstance(historicProcessInstance.getId()); |
| | | } else { |
| | | // 删除流程实例 |
| | | runtimeService.deleteProcessInstance(pp.getProcessInsId(), ""); |
| | | // 删除历史流程实例 |
| | | historyService.deleteHistoricProcessInstance(pp.getProcessInsId()); |
| | | if (Objects.nonNull(historicProcessInstance)) { |
| | | // 删除之前流程的数据 |
| | | if (historicProcessInstance.getEndTime() != null) { |
| | | historyService.deleteHistoricProcessInstance(historicProcessInstance.getId()); |
| | | } else { |
| | | // 删除流程实例 |
| | | runtimeService.deleteProcessInstance(pp.getProcessInsId(), ""); |
| | | // 删除历史流程实例 |
| | | historyService.deleteHistoricProcessInstance(pp.getProcessInsId()); |
| | | } |
| | | } |
| | | } |
| | | String processInsId = this.startPro(form.getProjectId(), form.getProcessDefId()); |
| | |
| | | taskStatistics.setTodoTaskNum(this.getTodoTaskNum(projectProcess.getProcessInsId())); |
| | | taskStatistics.setRemainingTaskNum(this.getRemainingTaskNum(processDefId, projectProcess.getProcessInsId())); |
| | | // taskStatistics.setCurrentTask(this.getCurrentNodeTaskList(projectProcess.getProcessInstanceId())); |
| | | taskStatistics.setRemainingTaskNum(this.getNotFinishedTaskNum(projectProcess.getProcessInsId())); |
| | | taskStatistics.setRemainingTaskNum(this.getRemainingTaskNum(projectProcess.getProcessDefId(), projectProcess.getProcessInsId())); |
| | | detail.setStatistics(taskStatistics); |
| | | |
| | | Result result = Result.ok(); |
| | |
| | | |
| | | @Override |
| | | public Result taskIsAuditing(String processDefinitionId, String taskId) { |
| | | Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
| | | BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); |
| | | Collection<Process> processes = bpmnModel.getProcesses(); |
| | | Boolean needAuditing = Boolean.FALSE; |
| | | for (Process process : processes) { |
| | | Collection<FlowElement> flowElements = process.getFlowElements(); |
| | | for (FlowElement flowElement : flowElements) { |
| | | if (flowElement instanceof UserTask) { |
| | | if (flowElement instanceof UserTask && flowElement.getId().equals(task.getTaskDefinitionKey())) { |
| | | UserTask userTask = (UserTask) flowElement; |
| | | List<ExtensionElement> extensionElements = userTask.getExtensionElements().get("flowable:properties"); |
| | | if (! CollectionUtils.isEmpty(extensionElements)) { |
| | | for (ExtensionElement extensionElement : extensionElements) { |
| | | String fieldName = extensionElement.getAttributeValue(taskId,"name"); |
| | | String fieldValue = extensionElement.getAttributeValue(taskId,"value"); |
| | | System.out.println("Field Name: " + fieldName + ", Field Value: " + fieldValue); |
| | | } |
| | | } |
| | | needAuditing = taskCommonService.checkTaskNeedAuditing(userTask.getExtensionElements().get("properties")); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | } |
| | | return null; |
| | | return Result.ok().data(needAuditing); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (StringUtils.isNotBlank(identityLink.getUserId())) { |
| | | SysUser sysUser = sysUserService.selectUserById(Long.parseLong(identityLink.getUserId())); |
| | | if (Objects.nonNull(sysUser)) { |
| | | taskVO.setHandlerType(HandlerTypeEnum.USER); |
| | | taskVO.setHandlerId(sysUser.getUserId()); |
| | | if (Objects.nonNull(sysUser.getDept())) { |
| | | taskVO.setHandlerUnitId(sysUser.getDept().getDeptId()); |
| | |
| | | // 绑定的是角色或者是部门,需要根据id判断 |
| | | } else if (StringUtils.isNotBlank(identityLink.getGroupId())) { |
| | | if (identityLink.getGroupId().startsWith("dept")) { // 部门的id是加了前缀的如:dept:1 |
| | | taskVO.setHandlerType(HandlerTypeEnum.DEPT); |
| | | String[] split = identityLink.getGroupId().split(":"); |
| | | if (split.length > 1) { |
| | | // 部门 |
| | |
| | | } |
| | | } |
| | | } else { |
| | | taskVO.setHandlerType(HandlerTypeEnum.ROLE); |
| | | SysRole role = sysRoleService.selectRoleById(Long.parseLong(identityLink.getGroupId())); |
| | | if (Objects.nonNull(role)) { |
| | | taskVO.setHandlerUnitId(Long.parseLong(identityLink.getGroupId())); |
| | |
| | | for (IdentityLinkInfo identityLink : identityLinkInfos) { |
| | | // 绑定的是用户,查出用户姓名、部门 |
| | | if (StringUtils.isNotBlank(identityLink.getUserId())) { |
| | | taskVO.setHandlerType(HandlerTypeEnum.USER); |
| | | SysUser sysUser = sysUserService.selectUserById(Long.parseLong(identityLink.getUserId())); |
| | | if (Objects.nonNull(sysUser)) { |
| | | // taskVO.setHandlerId(sysUser.getUserId()); |
| | |
| | | // 绑定的是角色,查出角色名称 |
| | | } else if (StringUtils.isNotBlank(identityLink.getGroupId())) { |
| | | if (identityLink.getGroupId().startsWith("dept")) { |
| | | taskVO.setHandlerType(HandlerTypeEnum.DEPT); |
| | | String[] split = identityLink.getGroupId().split(":"); |
| | | if (split.length > 1) { |
| | | // 部门 |
| | |
| | | taskVO.setHandlerUnitName(dept.getDeptName()); |
| | | } |
| | | } |
| | | } |
| | | SysRole role = sysRoleService.selectRoleById(Long.parseLong(identityLink.getGroupId())); |
| | | if (Objects.nonNull(role)) { |
| | | taskVO.setHandlerUnitId(Long.parseLong(identityLink.getGroupId())); |
| | | taskVO.setHandlerUnitName("由拥有角色:【" + role.getRoleName() + "】的人处理"); |
| | | } else { |
| | | taskVO.setHandlerType(HandlerTypeEnum.ROLE); |
| | | SysRole role = sysRoleService.selectRoleById(Long.parseLong(identityLink.getGroupId())); |
| | | if (Objects.nonNull(role)) { |
| | | taskVO.setHandlerUnitId(Long.parseLong(identityLink.getGroupId())); |
| | | taskVO.setHandlerUnitName("由拥有角色:【" + role.getRoleName() + "】的人处理"); |
| | | // taskVO.setHandlerName(role.getRoleName()); |
| | | // taskVO.setHandlerId(null); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | private Long getTotalTaskNum(String processDefinitionId) { |
| | | return Long.valueOf(this.getAllUserTaskElement(processDefinitionId).size()); |
| | | } |
| | | |
| | | /** |
| | | * 获取流程剩余未完成的任务数 |
| | | * |
| | | * @param processInstanceId |
| | | * @return |
| | | */ |
| | | private Long getNotFinishedTaskNum(String processInstanceId) { |
| | | return historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).processUnfinished().count(); |
| | | } |
| | | |
| | | /** |