| | |
| | | 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()); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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<IndexCustomerTaskVO> vos = new ArrayList<>(); |
| | |
| | | if (Objects.nonNull(project)) { |
| | | taskVO.setProjectId(project.getId()); |
| | | taskVO.setProjectName(project.getProjectName()); |
| | | } else { |
| | | continue; |
| | | } |
| | | |
| | | // 流程发起人信息 |
| | |
| | | |
| | | // 流程处理人信息 |
| | | List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId()); |
| | | // Boolean aboutMe = taskCommonService.taskAboutMe(identityLinks); |
| | | // if (! aboutMe) { |
| | | // continue; |
| | | // } |
| | | for (IdentityLinkInfo identityLink : identityLinks) { |
| | | // 绑定的是用户,查出用户姓名、部门 |
| | | if (StringUtils.isNotBlank(identityLink.getUserId())) { |
| | |
| | | taskVO.setHandlerUnitId(handlerUnitIds); |
| | | taskVO.setHandlerUnitName(handlerUnitNames); |
| | | vos.add(taskVO); |
| | | } |
| | | if (vos.size() < pageSize) { |
| | | result.total(vos.size()); |
| | | } |
| | | result.put("taskList", vos); |
| | | } |
| | |
| | | for (FlowElement flowElement : flowElements) { |
| | | if (flowElement instanceof UserTask && flowElement.getId().equals(task.getTaskDefinitionKey())) { |
| | | UserTask userTask = (UserTask) flowElement; |
| | | needAuditing = taskCommonService.checkTaskNeedAuditing(userTask.getExtensionElements().get("properties")); |
| | | needAuditing = taskCommonService.checkHasExeProperty(userTask.getExtensionElements().get("properties"), ProcessConstants.EXTENSION_PROPERTY_NEED_AUDITING_TEXT); |
| | | break; |
| | | } |
| | | |
| | |
| | | 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("转办成功"); |
| | | } |
| | |
| | | // 未开始的任务,其关联的用户组这些都可以从UserTask中拿到,因为本身未开始的任务是没有task的,所以这里直接查 |
| | | if (StringUtils.isNotBlank(userTask.getAssignee())) { |
| | | vo.setHandlerType(HandlerTypeEnum.USER); |
| | | SysUser sysUser = sysUserService.selectUserById(Long.parseLong(userTask.getAssignee())); |
| | | if (Objects.nonNull(sysUser)) { |
| | | handlerIds.add(sysUser.getUserId()); |
| | | handlerNames.add(sysUser.getNickName()); |
| | | if (Objects.nonNull(sysUser.getDept())) { |
| | | handlerUnitIds.add(sysUser.getDept().getDeptId()); |
| | | handlerUnitNames.add(sysUser.getDept().getDeptName()); |
| | | // 处理变量表达式 |
| | | if (userTask.getAssignee().contains(ProcessConstants.DATA_LAUNCH)) { |
| | | handlerNames.add(userTask.getAssignee()); |
| | | } else { |
| | | SysUser sysUser = sysUserService.selectUserById(Long.parseLong(userTask.getAssignee())); |
| | | if (Objects.nonNull(sysUser)) { |
| | | handlerIds.add(sysUser.getUserId()); |
| | | handlerNames.add(sysUser.getNickName()); |
| | | if (Objects.nonNull(sysUser.getDept())) { |
| | | handlerUnitIds.add(sysUser.getDept().getDeptId()); |
| | | handlerUnitNames.add(sysUser.getDept().getDeptName()); |
| | | } |
| | | } |
| | | } |
| | | } else if (CollectionUtil.isNotEmpty(userTask.getCandidateGroups())) { |
| | |
| | | // 未开始的任务,其关联的用户组这些都可以从UserTask中拿到,因为本身未开始的任务是没有task的,所以这里直接查 |
| | | if (StringUtils.isNotBlank(userTask.getAssignee())) { |
| | | vo.setHandlerType(HandlerTypeEnum.USER); |
| | | // 处理变量表达式 |
| | | if (userTask.getAssignee().contains(ProcessConstants.DATA_LAUNCH)) { |
| | | handlerNames.add(userTask.getAssignee()); |
| | | continue; |
| | | } |
| | | SysUser sysUser = sysUserService.selectUserById(Long.parseLong(userTask.getAssignee())); |
| | | if (Objects.nonNull(sysUser)) { |
| | | handlerIds.add(sysUser.getUserId()); |