| | |
| | | package com.ycl.service.impl; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; |
| | | import com.ycl.common.constant.ProcessConstants; |
| | | import com.ycl.common.core.domain.AjaxResult; |
| | | import com.ycl.common.core.domain.entity.SysDept; |
| | | import com.ycl.common.core.domain.entity.SysRole; |
| | | import com.ycl.common.core.domain.entity.SysUser; |
| | | import com.ycl.common.enums.FlowComment; |
| | | import com.ycl.common.enums.business.FlowLogEventTypeEnum; |
| | | import com.ycl.common.enums.business.HandlerTypeEnum; |
| | | import com.ycl.common.enums.business.ProcessLogEventTypeEnum; |
| | | import com.ycl.common.enums.business.TaskStatusEnum; |
| | | import com.ycl.common.utils.SecurityUtils; |
| | | import com.ycl.constant.TaskTypeConstant; |
| | | import com.ycl.domain.dto.FlowTaskDto; |
| | | import com.ycl.domain.entity.FlowLog; |
| | | import com.ycl.domain.entity.ProjectInfo; |
| | | import com.ycl.domain.entity.ProjectProcess; |
| | | import com.ycl.domain.form.RejectTaskForm; |
| | | import com.ycl.domain.form.TaskDelegationForm; |
| | | import com.ycl.domain.json.TaskDelegateData; |
| | | import com.ycl.domain.json.DelegateData; |
| | | import com.ycl.domain.vo.CustomerTaskVO; |
| | | import com.ycl.domain.vo.IndexCustomerTaskVO; |
| | | import com.ycl.domain.vo.ProjectProcessDetailVO; |
| | | import com.ycl.event.event.TaskLogEvent; |
| | | import com.ycl.mapper.ProjectInfoMapper; |
| | | import com.ycl.mapper.ProjectProcessMapper; |
| | | import com.ycl.service.FlowLogService; |
| | | import com.ycl.service.ProjectProcessService; |
| | | import com.ycl.common.base.Result; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import org.flowable.identitylink.api.IdentityLink; |
| | | import org.flowable.identitylink.api.IdentityLinkInfo; |
| | | import org.flowable.identitylink.api.IdentityLinkType; |
| | | import org.flowable.identitylink.api.history.HistoricIdentityLink; |
| | | import org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntityImpl; |
| | | 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.springframework.context.ApplicationEventPublisher; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.RequiredArgsConstructor; |
| | | import com.ycl.framework.utils.PageUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.Assert; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.*; |
| | |
| | | private final ISysRoleService sysRoleService; |
| | | private final ISysDeptService sysDeptService; |
| | | private final TaskCommonService taskCommonService; |
| | | private final FlowLogService flowLogService; |
| | | private final ApplicationEventPublisher publisher; |
| | | |
| | | /** |
| | | * 分页查询 |
| | |
| | | @Override |
| | | public Result page(ProjectProcessQuery query) { |
| | | IPage<ProjectProcessVO> page = PageUtil.getPage(query, ProjectProcessVO.class); |
| | | baseMapper.getPage(page, query); |
| | | baseMapper.getPage(query, page); |
| | | for (ProjectProcessVO vo : page.getRecords()) { |
| | | if (Objects.nonNull(vo.getProcessDefId())) { |
| | | ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(vo.getProcessDefId()).singleResult(); |
| | | if (Objects.nonNull(processDefinition)) { |
| | | vo.setSuspended(processDefinition.isSuspended()); |
| | | vo.setFlowableProcessName(processDefinition.getName() + "(v" + processDefinition.getVersion() + ")"); |
| | | vo.setDeployId(processDefinition.getDeploymentId()); |
| | | } |
| | | } |
| | | } |
| | |
| | | entity.setProcessDefId(processDefId); |
| | | entity.setProcessInsId(processInsId); |
| | | baseMapper.insert(entity); |
| | | |
| | | return Result.ok("流程启动成功"); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | private String startPro(Long projectId, String processDefId) { |
| | | |
| | | ProjectInfo project = new LambdaQueryChainWrapper<>(projectInfoMapper) |
| | | .select(ProjectInfo::getCreateBy) |
| | | .eq(ProjectInfo::getId, projectId) |
| | | .one(); |
| | | if (Objects.isNull(project)) { |
| | | throw new RuntimeException("项目不存在"); |
| | | } |
| | | ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefId) |
| | | .latestVersion().singleResult(); |
| | | if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) { |
| | |
| | | SysUser sysUser = SecurityUtils.getLoginUser().getUser(); |
| | | identityService.setAuthenticatedUserId(sysUser.getUserId().toString()); |
| | | variables.put(ProcessConstants.PROCESS_INITIATOR, sysUser.getUserId()); |
| | | |
| | | // 将该项目的申请人(业主方)作为流程中某些环节的处理人 |
| | | variables.put(ProcessConstants.DATA_LAUNCH, project.getCreateBy()); |
| | | ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefId, projectId + "", variables); |
| | | return processInstance.getId(); |
| | | } |
| | |
| | | TaskQuery taskQuery = taskService.createTaskQuery() |
| | | .active() |
| | | .includeProcessVariables() |
| | | .includeIdentityLinks() |
| | | .orderByTaskCreateTime().desc(); |
| | | |
| | | if (StringUtils.isNotBlank(taskName)) { |
| | | taskQuery.processDefinitionNameLike(taskName); |
| | | } |
| | | if (! SecurityUtils.getLoginUser().getUser().isAdmin()) { |
| | | taskQuery |
| | | .or() |
| | | .taskCandidateGroupIn(taskCommonService.getCurrentUserGroups()) |
| | | .taskCandidateUser(SecurityUtils.getUserId() + "") |
| | | .taskAssignee(SecurityUtils.getUserId() + "") |
| | | .endOr(); |
| | | } |
| | | result.total(taskQuery.count()); |
| | | List<Task> taskList = taskQuery.listPage(pageSize * (pageNum - 1), pageSize); |
| | |
| | | List<String> handlerUnitNames = new ArrayList<>(2); |
| | | |
| | | // 流程处理人信息 |
| | | List<? extends IdentityLinkInfo> identityLinks = task.getIdentityLinks(); |
| | | List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId()); |
| | | // Boolean aboutMe = taskCommonService.taskAboutMe(identityLinks); |
| | | // if (! aboutMe) { |
| | | // continue; |
| | | // } |
| | | for (IdentityLinkInfo identityLink : identityLinks) { |
| | | // 绑定的是用户,查出用户姓名、部门 |
| | | if (StringUtils.isNotBlank(identityLink.getUserId())) { |
| | |
| | | taskService.deleteCandidateGroup(task.getId(), identityLink.getGroupId()); |
| | | } |
| | | } |
| | | TaskDelegateData jsonData = new TaskDelegateData(); |
| | | DelegateData jsonData = new DelegateData(); |
| | | jsonData.setBeforeHandlerIds(beforeHandlerIds); |
| | | jsonData.setBeforeHandlerType(beforeHandlerType); |
| | | |
| | |
| | | } |
| | | jsonData.setAfterHandlerIds(afterHandlerIds); |
| | | jsonData.setAfterHandlerType(form.getPeopleType()); |
| | | // 添加日志 |
| | | flowLogService.add(task.getId(), task.getProcessInstanceId(), FlowLogEventTypeEnum.DELEGATE, form.getProjectId(), JSON.toJSONString(jsonData)); |
| | | // 发布转办事件 |
| | | publisher.publishEvent(new TaskLogEvent(this, form.getProjectId(), form.getProcessInsId(), task.getId(), ProcessLogEventTypeEnum.DELEGATE, jsonData)); |
| | | |
| | | return Result.ok("转办成功"); |
| | | } |
| | |
| | | vo.setTaskId(historicTasks.get(0).getId()); |
| | | vo.setExecutionId(historicTasks.get(0).getExecutionId()); |
| | | vo.setCreateTime(historicTasks.get(0).getStartTime()); |
| | | |
| | | // 查询实际处理人 |
| | | long handlerUserId = Long.parseLong(historicTasks.get(0).getAssignee()); |
| | | SysUser handlerUser = sysUserService.selectUserById(handlerUserId); |
| | | if (Objects.nonNull(handlerUser)) { |
| | | handlerIds.add(handlerUserId); |
| | | handlerNames.add(handlerUser.getNickName()); |
| | | vo.setActualHandlerUserId(historicTasks.get(0).getAssignee()); |
| | | vo.setActualHandlerUserName(handlerUser.getNickName()); |
| | | } |
| | | vo.setTaskDefinitionKey(historicTasks.get(0).getTaskDefinitionKey()); |
| | | this.setPromoterAndHandler(vo, historicTasks.get(0).getIdentityLinks()); |
| | |
| | | SysUser handlerUser = sysUserService.selectUserById(handlerUserId); |
| | | if (Objects.nonNull(handlerUser)) { |
| | | |
| | | vo.setHandlerId(Arrays.asList(handlerUserId)); |
| | | vo.setHandlerName(Arrays.asList(handlerUser.getNickName())); |
| | | vo.setActualHandlerUserId(hisTaskList.get(0).getAssignee()); |
| | | vo.setActualHandlerUserName(handlerUser.getNickName()); |
| | | } |
| | | vo.setTaskDefinitionKey(hisTaskList.get(0).getTaskDefinitionKey()); |
| | | this.setPromoterAndHandler(vo, hisTaskList.get(0).getIdentityLinks()); |
| | |
| | | taskVO.setHandlerType(HandlerTypeEnum.USER); |
| | | SysUser sysUser = sysUserService.selectUserById(Long.parseLong(identityLink.getUserId())); |
| | | if (Objects.nonNull(sysUser)) { |
| | | // taskVO.setHandlerId(sysUser.getUserId()); |
| | | handlerIds.add(sysUser.getUserId()); |
| | | handlerNames.add(sysUser.getNickName()); |
| | | if (Objects.nonNull(sysUser.getDept())) { |
| | | handlerUnitIds.add(sysUser.getDept().getDeptId()); |
| | | handlerUnitNames.add(sysUser.getDept().getDeptName()); |
| | | } |
| | | // taskVO.setHandlerName(sysUser.getNickName()); |
| | | } |
| | | // 绑定的是角色,查出角色名称 |
| | | } else if (StringUtils.isNotBlank(identityLink.getGroupId())) { |