Java Code Examples for org.activiti.engine.task.Task#getProcessInstanceId()

The following examples show how to use org.activiti.engine.task.Task#getProcessInstanceId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PermissionService.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public boolean validateIfUserIsInitiatorAndCanCompleteTask(User user, Task task) {
  boolean canCompleteTask = false;
  if (task.getProcessInstanceId() != null) {
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
    if (historicProcessInstance != null && StringUtils.isNotEmpty(historicProcessInstance.getStartUserId())) {
      String processInstanceStartUserId = historicProcessInstance.getStartUserId();
      if (String.valueOf(user.getId()).equals(processInstanceStartUserId)) {
        BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
        FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey());
        if (flowElement != null && flowElement instanceof UserTask) {
          UserTask userTask = (UserTask) flowElement;
          List<ExtensionElement> extensionElements = userTask.getExtensionElements().get("initiator-can-complete");
          if (CollectionUtils.isNotEmpty(extensionElements)) {
            String value = extensionElements.get(0).getElementText();
            if (StringUtils.isNotEmpty(value) && Boolean.valueOf(value)) {
              canCompleteTask = true;
            }
          }
        }
      }
    }
  }
  return canCompleteTask;
}
 
Example 2
Source File: TaskCommentCollectionResource.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Create a new comment on a task", tags = {"Tasks"},  nickname = "createTaskComments")
@ApiResponses(value = {
    @ApiResponse(code = 201, message = "Indicates the comment was created and the result is returned."),
    @ApiResponse(code = 400, message = "Indicates the comment is missing from the request."),
    @ApiResponse(code = 404, message = "Indicates the requested task was not found.")
})
@RequestMapping(value = "/runtime/tasks/{taskId}/comments", method = RequestMethod.POST, produces = "application/json")
public CommentResponse createComment(@ApiParam(name = "taskId", value="The id of the task to create the comment for.") @PathVariable String taskId, @RequestBody CommentRequest comment, HttpServletRequest request, HttpServletResponse response) {

  Task task = getTaskFromRequest(taskId);

  if (comment.getMessage() == null) {
    throw new ActivitiIllegalArgumentException("Comment text is required.");
  }

  String processInstanceId = null;
  if (comment.isSaveProcessInstanceId()) {
    Task taskEntity = taskService.createTaskQuery().taskId(task.getId()).singleResult();
    processInstanceId = taskEntity.getProcessInstanceId();
  }
  Comment createdComment = taskService.addComment(task.getId(), processInstanceId, comment.getMessage());
  response.setStatus(HttpStatus.CREATED.value());

  return restResponseFactory.createRestComment(createdComment);
}
 
Example 3
Source File: PurchaseApplyUserInnerServiceSMOImpl.java    From MicroCommunity with Apache License 2.0 6 votes vote down vote up
public boolean completeTask(@RequestBody PurchaseApplyDto purchaseApplyDto) {
    TaskService taskService = processEngine.getTaskService();
    Task task = taskService.createTaskQuery().taskId(purchaseApplyDto.getTaskId()).singleResult();
    String processInstanceId = task.getProcessInstanceId();
    Authentication.setAuthenticatedUserId(purchaseApplyDto.getCurrentUserId());
    taskService.addComment(purchaseApplyDto.getTaskId(), processInstanceId, purchaseApplyDto.getAuditMessage());
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("auditCode", purchaseApplyDto.getAuditCode());
    variables.put("currentUserId", purchaseApplyDto.getCurrentUserId());
    variables.put("nextAuditStaffId",purchaseApplyDto.getStaffId());
    //taskService.setAssignee(complaintDto.getTaskId(),complaintDto.getCurrentUserId());
    //taskService.addCandidateUser(complaintDto.getTaskId(), complaintDto.getCurrentUserId());
    //taskService.claim(complaintDto.getTaskId(), complaintDto.getCurrentUserId());
    taskService.complete(purchaseApplyDto.getTaskId(), variables);
    //taskService.setVariable(purchaseApplyDto.getTaskId(), "purchaseApplyDto", purchaseApplyDto);

    ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
    if (pi == null) {
        return true;
    }
    return false;
}
 
Example 4
Source File: ComplaintUserInnerServiceSMOImpl.java    From MicroCommunity with Apache License 2.0 6 votes vote down vote up
public List<AuditMessageDto> getAuditMessage(@RequestBody ComplaintDto complaintDto) {

        TaskService taskService = processEngine.getTaskService();
        Task task = taskService.createTaskQuery().taskId(complaintDto.getTaskId()).singleResult();
        String processInstanceId = task.getProcessInstanceId();
        List<Comment> comments = taskService.getProcessInstanceComments(processInstanceId);
        List<AuditMessageDto> auditMessageDtos = new ArrayList<>();
        if (comments == null || comments.size() < 1) {
            return auditMessageDtos;
        }
        AuditMessageDto messageDto = null;
        for (Comment comment : comments) {
            messageDto = new AuditMessageDto();
            messageDto.setCreateTime(comment.getTime());
            messageDto.setUserId(comment.getUserId());
            messageDto.setMessage(comment.getFullMessage());
        }

        return auditMessageDtos;
    }
 
Example 5
Source File: ActivitiTaskComponentTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testGetStartTaskById() throws Exception
{
  
    WorkflowTask result = workflowEngine.getTaskById(ActivitiConstants.ENGINE_ID + "$Foo");
    assertNull("Should not find any result for fake (but valid) Id.", result);
    
    WorkflowPath path = workflowEngine.startWorkflow(workflowDef.getId(), new HashMap<QName, Serializable>());
   
    Task task = taskService.createTaskQuery()
        .executionId(BPMEngineRegistry.getLocalId(path.getId()))
        .singleResult();
    
    // A start task should be available for the process instance
    String startTaskId = ActivitiConstants.START_TASK_PREFIX + task.getProcessInstanceId();
    
    String taskId = createGlobalId(startTaskId);
    WorkflowTask wfTask = workflowEngine.getTaskById(taskId);
    assertNotNull(wfTask);
    assertEquals(createGlobalId(task.getProcessInstanceId()), wfTask.getPath().getId());
}
 
Example 6
Source File: LeaveController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 任务列表
 *
 * @param leave
 */
@RequestMapping(value = "task/view/{taskId}")
public ModelAndView showTaskView(@PathVariable("taskId") String taskId) {
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
    String processInstanceId = task.getProcessInstanceId();
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
    Leave leave = leaveManager.get(new Long(processInstance.getBusinessKey()));
    ModelAndView mav = new ModelAndView("/chapter7/leave/task-" + task.getTaskDefinitionKey());
    mav.addObject("leave", leave);
    mav.addObject("task", task);
    return mav;
}
 
Example 7
Source File: LeaveController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 任务列表
 *
 * @param leave
 */
@RequestMapping(value = "task/view/{taskId}")
public ModelAndView showTaskView(@PathVariable("taskId") String taskId) {
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
    String processInstanceId = task.getProcessInstanceId();
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
    Leave leave = leaveManager.get(new Long(processInstance.getBusinessKey()));
    ModelAndView mav = new ModelAndView("/chapter7/leave/task-" + task.getTaskDefinitionKey());
    mav.addObject("leave", leave);
    mav.addObject("task", task);
    return mav;
}
 
Example 8
Source File: LeaveWorkflowService.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查询待办任务
 */
@Transactional(readOnly = true)
public List<Leave> findTodoTasks(String userId) {
    List<Leave> results = new ArrayList<Leave>();
    List<Task> tasks = new ArrayList<Task>();

    // 根据当前人的ID查询
    List<Task> todoList = taskService.createTaskQuery().processDefinitionKey("leave").taskAssignee(userId).list();

    // 根据当前人未签收的任务
    List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey("leave").taskCandidateUser(userId).list();

    // 合并
    tasks.addAll(todoList);
    tasks.addAll(unsignedTasks);

    // 根据流程的业务ID查询实体并关联
    for (Task task : tasks) {
        String processInstanceId = task.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        String businessKey = processInstance.getBusinessKey();
        Leave leave = leaveManager.get(new Long(businessKey));
        leave.setTask(task);
        leave.setProcessInstance(processInstance);
        String processDefinitionId = processInstance.getProcessDefinitionId();
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
        leave.setProcessDefinition(processDefinition);
        results.add(leave);
    }
    return results;
}
 
Example 9
Source File: LeaveController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 任务列表
 *
 * @param leave
 */
@RequestMapping(value = "task/view/{taskId}")
public ModelAndView showTaskView(@PathVariable("taskId") String taskId) {
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
    String processInstanceId = task.getProcessInstanceId();
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
    Leave leave = leaveManager.get(new Long(processInstance.getBusinessKey()));
    ModelAndView mav = new ModelAndView("/chapter7/leave/task-" + task.getTaskDefinitionKey());
    mav.addObject("leave", leave);
    mav.addObject("task", task);
    return mav;
}
 
Example 10
Source File: LeaveWorkflowService.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查询待办任务
 */
@Transactional(readOnly = true)
public List<Leave> findTodoTasks(String userId) {
    List<Leave> results = new ArrayList<Leave>();
    List<Task> tasks = new ArrayList<Task>();

    // 根据当前人的ID查询
    List<Task> todoList = taskService.createTaskQuery().processDefinitionKey("leave").taskAssignee(userId).list();

    // 根据当前人未签收的任务
    List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey("leave").taskCandidateUser(userId).list();

    // 合并
    tasks.addAll(todoList);
    tasks.addAll(unsignedTasks);

    // 根据流程的业务ID查询实体并关联
    for (Task task : tasks) {
        String processInstanceId = task.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        String businessKey = processInstance.getBusinessKey();
        Leave leave = leaveManager.get(new Long(businessKey));
        leave.setTask(task);
        leave.setProcessInstance(processInstance);
        String processDefinitionId = processInstance.getProcessDefinitionId();
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
        leave.setProcessDefinition(processDefinition);
        results.add(leave);
    }
    return results;
}
 
Example 11
Source File: LeaveWorkflowService.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查询待办任务
 */
@Transactional(readOnly = true)
public List<Leave> findTodoTasks(String userId) {
    List<Leave> results = new ArrayList<Leave>();
    List<Task> tasks = new ArrayList<Task>();

    // 根据当前人的ID查询
    List<Task> todoList = taskService.createTaskQuery().processDefinitionKey("leave").taskAssignee(userId).list();

    // 根据当前人未签收的任务
    List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey("leave").taskCandidateUser(userId).list();

    // 合并
    tasks.addAll(todoList);
    tasks.addAll(unsignedTasks);

    // 根据流程的业务ID查询实体并关联
    for (Task task : tasks) {
        String processInstanceId = task.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        String businessKey = processInstance.getBusinessKey();
        Leave leave = leaveManager.get(new Long(businessKey));
        leave.setTask(task);
        leave.setProcessInstance(processInstance);
        String processDefinitionId = processInstance.getProcessDefinitionId();
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
        leave.setProcessDefinition(processDefinition);
        results.add(leave);
    }
    return results;
}
 
Example 12
Source File: LeaveController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 任务列表
 *
 * @param leave
 */
@RequestMapping(value = "task/view/{taskId}")
public ModelAndView showTaskView(@PathVariable("taskId") String taskId) {
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
    String processInstanceId = task.getProcessInstanceId();
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
    Leave leave = leaveManager.get(new Long(processInstance.getBusinessKey()));
    ModelAndView mav = new ModelAndView("/chapter7/leave/task-" + task.getTaskDefinitionKey());
    mav.addObject("leave", leave);
    mav.addObject("task", task);
    return mav;
}
 
Example 13
Source File: LeaveController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 任务列表
 *
 * @param leave
 */
@RequestMapping(value = "task/view/{taskId}")
public ModelAndView showTaskView(@PathVariable("taskId") String taskId) {
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
    String processInstanceId = task.getProcessInstanceId();
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
    Leave leave = leaveManager.get(new Long(processInstance.getBusinessKey()));
    ModelAndView mav = new ModelAndView("/chapter7/leave/task-" + task.getTaskDefinitionKey());
    mav.addObject("leave", leave);
    mav.addObject("task", task);
    return mav;
}
 
Example 14
Source File: LeaveController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 任务列表
 *
 * @param leave
 */
@RequestMapping(value = "task/view/{taskId}")
public ModelAndView showTaskView(@PathVariable("taskId") String taskId) {
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
    String processInstanceId = task.getProcessInstanceId();
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
    Leave leave = leaveManager.get(new Long(processInstance.getBusinessKey()));
    ModelAndView mav = new ModelAndView("/chapter7/leave/task-" + task.getTaskDefinitionKey());
    mav.addObject("leave", leave);
    mav.addObject("task", task);
    return mav;
}
 
Example 15
Source File: LeaveWorkflowService.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查询待办任务
 */
@Transactional(readOnly = true)
public List<Leave> findTodoTasks(String userId) {
    List<Leave> results = new ArrayList<Leave>();
    List<Task> tasks = new ArrayList<Task>();

    // 根据当前人的ID查询
    List<Task> todoList = taskService.createTaskQuery().processDefinitionKey("leave").taskAssignee(userId).active().list();

    // 根据当前人未签收的任务
    List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey("leave").taskCandidateUser(userId).active().list();

    // 合并
    tasks.addAll(todoList);
    tasks.addAll(unsignedTasks);

    // 根据流程的业务ID查询实体并关联
    for (Task task : tasks) {
        String processInstanceId = task.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        String businessKey = processInstance.getBusinessKey();
        Leave leave = leaveManager.get(new Long(businessKey));
        leave.setTask(task);
        leave.setProcessInstance(processInstance);
        String processDefinitionId = processInstance.getProcessDefinitionId();
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
        leave.setProcessDefinition(processDefinition);
        results.add(leave);
    }
    return results;
}
 
Example 16
Source File: LeaveController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 任务列表
 *
 * @param leave
 */
@RequestMapping(value = "task/view/{taskId}")
public ModelAndView showTaskView(@PathVariable("taskId") String taskId) {
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
    String processInstanceId = task.getProcessInstanceId();
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
    Leave leave = leaveManager.get(new Long(processInstance.getBusinessKey()));
    ModelAndView mav = new ModelAndView("/chapter7/leave/task-" + task.getTaskDefinitionKey());
    mav.addObject("leave", leave);
    mav.addObject("task", task);
    return mav;
}
 
Example 17
Source File: LeaveWorkflowService.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查询待办任务
 */
@Transactional(readOnly = true)
public List<Leave> findTodoTasks(String userId) {
    List<Leave> results = new ArrayList<Leave>();
    List<Task> tasks = new ArrayList<Task>();

    // 根据当前人的ID查询
    List<Task> todoList = taskService.createTaskQuery().processDefinitionKey("leave").taskAssignee(userId).list();

    // 根据当前人未签收的任务
    List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey("leave").taskCandidateUser(userId).list();

    // 合并
    tasks.addAll(todoList);
    tasks.addAll(unsignedTasks);

    // 根据流程的业务ID查询实体并关联
    for (Task task : tasks) {
        String processInstanceId = task.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        String businessKey = processInstance.getBusinessKey();
        Leave leave = leaveManager.get(new Long(businessKey));
        leave.setTask(task);
        leave.setProcessInstance(processInstance);
        String processDefinitionId = processInstance.getProcessDefinitionId();
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
        leave.setProcessDefinition(processDefinition);
        results.add(leave);
    }
    return results;
}
 
Example 18
Source File: LeaveController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 任务列表
 *
 * @param leave
 */
@RequestMapping(value = "task/view/{taskId}")
public ModelAndView showTaskView(@PathVariable("taskId") String taskId) {
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
    String processInstanceId = task.getProcessInstanceId();
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
    Leave leave = leaveManager.get(new Long(processInstance.getBusinessKey()));
    ModelAndView mav = new ModelAndView("/chapter7/leave/task-" + task.getTaskDefinitionKey());
    mav.addObject("leave", leave);
    mav.addObject("task", task);
    return mav;
}
 
Example 19
Source File: ResourceEntryStoreInnerServiceSMOImpl.java    From MicroCommunity with Apache License 2.0 4 votes vote down vote up
/**
     * 获取用户任务
     *
     * @param user 用户信息
     */
    public List<PurchaseApplyDto> getUserTasks(@RequestBody AuditUser user) {
        TaskService taskService = processEngine.getTaskService();
        TaskQuery query = taskService.createTaskQuery().processDefinitionKey("resourceEntry");
        query.taskAssignee(user.getUserId());
        query.orderByTaskCreateTime().desc();
        List<Task> list = null;
        if(user.getPage()  >=1){
            user.setPage(user.getPage()-1);
        }
        if (user.getPage() != PageDto.DEFAULT_PAGE) {
            list = query.listPage(user.getPage(), user.getRow());
        }else{
            list = query.list();
        }

//        List<PurchaseApplyDto> purchaseApplyDtos = new ArrayList<>();
//
//        for (Task task : list) {
//            String id = task.getId();
//            //System.out.println("tasks:" + JSONObject.toJSONString(task));
//            PurchaseApplyDto purchaseApplyDto = (PurchaseApplyDto) taskService.getVariable(id, "purchaseApplyDto");
//            purchaseApplyDto.setTaskId(id);
//            purchaseApplyDto.setProcessInstanceId(task.getProcessInstanceId());
//            purchaseApplyDtos.add(purchaseApplyDto);
//        }
//        return purchaseApplyDtos;

        List<String> applyOrderIds = new ArrayList<>();
        Map<String, String> taskBusinessKeyMap = new HashMap<>();
        for (Task task : list) {
            String processInstanceId = task.getProcessInstanceId();
            //3.使用流程实例,查询
            ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
            //4.使用流程实例对象获取BusinessKey
            String business_key = pi.getBusinessKey();
            applyOrderIds.add(business_key);
            taskBusinessKeyMap.put(business_key, task.getId());
        }

        if (applyOrderIds == null || applyOrderIds.size() == 0) {
            return new ArrayList<>();
        }

        //查询 投诉信息
        PurchaseApplyDto purchaseApplyDto = new PurchaseApplyDto();
        purchaseApplyDto.setStoreId(user.getStoreId());
        purchaseApplyDto.setApplyOrderIds(applyOrderIds.toArray(new String[applyOrderIds.size()]));
        List<PurchaseApplyDto> tmpPurchaseApplyDtos = purchaseApplyInnerServiceSMOImpl.queryPurchaseApplyAndDetails(purchaseApplyDto);

        for (PurchaseApplyDto tmpPurchaseApplyDto : tmpPurchaseApplyDtos) {
            tmpPurchaseApplyDto.setTaskId(taskBusinessKeyMap.get(tmpPurchaseApplyDto.getApplyOrderId()));
        }
        return tmpPurchaseApplyDtos;
    }
 
Example 20
Source File: PurchaseApplyUserInnerServiceSMOImpl.java    From MicroCommunity with Apache License 2.0 4 votes vote down vote up
/**
     * 获取用户任务
     *
     * @param user 用户信息
     */
    public List<PurchaseApplyDto> getUserTasks(@RequestBody AuditUser user) {
        TaskService taskService = processEngine.getTaskService();
        TaskQuery query = taskService.createTaskQuery().processDefinitionKey("resourceEnter");
        ;
        query.taskAssignee(user.getUserId());
        query.orderByTaskCreateTime().desc();
        List<Task> list = null;
        if (user.getPage() != PageDto.DEFAULT_PAGE) {
            list = query.listPage((user.getPage() - 1) * user.getRow(), user.getRow());
        } else {
            list = query.list();
        }

        List<String> complaintIds = new ArrayList<>();
        Map<String, String> taskBusinessKeyMap = new HashMap<>();
        for (Task task : list) {
            String processInstanceId = task.getProcessInstanceId();
            //3.使用流程实例,查询
            ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
            //4.使用流程实例对象获取BusinessKey
            String business_key = pi.getBusinessKey();
            complaintIds.add(business_key);
            taskBusinessKeyMap.put(business_key, task.getId());
        }

        if (complaintIds == null || complaintIds.size() == 0) {
            return new ArrayList<>();
        }

        //查询 投诉信息
        PurchaseApplyDto purchaseApplyDto = new PurchaseApplyDto();
        List<PurchaseApplyDto> purchaseApplyDtos = new ArrayList<>();

//        ComplaintDto complaintDto = new ComplaintDto();
//        complaintDto.setStoreId(user.getStoreId());
//        complaintDto.setCommunityId(user.getCommunityId());
//        complaintDto.setComplaintIds(complaintIds.toArray(new String[complaintIds.size()]));
//        List<ComplaintDto> tmpComplaintDtos = complaintInnerServiceSMOImpl.queryComplaints(complaintDto);
//
//        for (ComplaintDto tmpComplaintDto : tmpComplaintDtos) {
//            tmpComplaintDto.setTaskId(taskBusinessKeyMap.get(tmpComplaintDto.getComplaintId()));
//        }
        return purchaseApplyDtos;
    }