/** @param args */
 public static void main(String[] args) {
   // 创建流程引擎
   ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
   // 得到流程存储服务组件
   RepositoryService repositoryService = engine.getRepositoryService();
   // 得到运行时服务组件
   RuntimeService runtimeService = engine.getRuntimeService();
   // 获取流程任务组件
   TaskService taskService = engine.getTaskService();
   // 部署流程文件
   repositoryService
       .createDeployment()
       .addClasspathResource("bpmn11.5/SignalBoundaryEvent.bpmn")
       .deploy();
   // 启动2个流程实例
   ProcessInstance pi1 = runtimeService.startProcessInstanceByKey("sbProcess");
   ProcessInstance pi2 = runtimeService.startProcessInstanceByKey("sbProcess");
   // 查找第一个流程实例中签订合同的任务
   Task pi1Task = taskService.createTaskQuery().processInstanceId(pi1.getId()).singleResult();
   taskService.complete(pi1Task.getId());
   // 查找第二个流程实例中签订合同的任务
   Task pi2Task = taskService.createTaskQuery().processInstanceId(pi2.getId()).singleResult();
   taskService.complete(pi2Task.getId());
   // 此时执行流到达确认合同任务,发送一次信号
   runtimeService.signalEventReceived("contactChangeSignal");
   // 查询全部的任务
   List<Task> tasks = taskService.createTaskQuery().list();
   // 输出结果
   for (Task task : tasks) {
     System.out.println(task.getProcessInstanceId() + "---" + task.getName());
   }
 }
  @Deployment(
      resources = {
        "org/activiti/examples/bpmn/event/timer/BoundaryTimerEventTest.testInterruptingTimerDuration.bpmn"
      })
  @Test
  public void testInterruptingTimerDuration() {

    // Start process instance
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("escalationExample");

    // There should be one task, with a timer : first line support
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("First line support", task.getName());

    // Manually execute the job
    ManagementService managementService = activitiRule.getManagementService();
    Job timer = managementService.createJobQuery().singleResult();
    managementService.executeJob(timer.getId());

    // The timer has fired, and the second task (secondlinesupport) now exists
    task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("Second line support", task.getName());
  }
  @Test
  public void testAcknowledgement() {
    TaskService taskService = processEngine.getTaskService();
    FormService formService = processEngine.getFormService();

    List<Task> tasks =
        taskService
            .createTaskQuery()
            .taskAssignee("kermit")
            .processInstanceId(processInstance.getId())
            .list();
    assertEquals(1, tasks.size());
    assertEquals("get acknowledgement", tasks.get(0).getName());

    for (Task task : tasks) {
      Map<String, String> formData = new HashMap<String, String>();
      formService.submitTaskFormData(task.getId(), formData); // Stack trace starts here
    }

    tasks =
        taskService
            .createTaskQuery()
            .taskAssignee("kermit")
            .processInstanceId(processInstance.getId())
            .list();
    assertEquals(0, tasks.size());
  }
  @Override
  @Transactional(readOnly = false)
  public Defect reviewDefect(Long defectId, String assignedTo) {
    Defect existingDefect = defectRepository.getById(defectId);
    String existingAsignee = existingDefect.getAssignedTo();

    existingDefect.setStatus(DefectStatus.ASSIGNED);
    existingDefect.setAssignedTo(assignedTo);
    defectRepository.update(existingDefect);

    for (Task task : taskService.createTaskQuery().taskAssignee(existingAsignee).list()) {
      if (task.getName().equalsIgnoreCase("reviewDefect")) {
        Long taskDefectId = (Long) runtimeService.getVariable(task.getExecutionId(), "defectId");
        if (taskDefectId.equals(defectId)) {
          taskService.complete(task.getId());
          logger.info("Reviewed Defect: " + task.getName() + " Defect Id: " + taskDefectId);
        }
      }
    }
    logger.info(
        "Task assigned to: "
            + existingAsignee
            + " : "
            + taskService.createTaskQuery().taskAssignee(existingAsignee));
    logger.info(
        "Task assigned to: "
            + assignedTo
            + " : "
            + taskService.createTaskQuery().taskAssignee(assignedTo));

    return existingDefect;
  }
  @Test
  public void testCouponValidation() {
    TaskService taskService = processEngine.getTaskService();
    FormService formService = processEngine.getFormService();

    List<Task> tasks =
        taskService
            .createTaskQuery()
            .taskAssignee("kermit")
            .processInstanceId(processInstance.getId())
            .list();
    assertEquals(1, tasks.size());

    /** Invalid coupon hash */
    for (Task task : tasks) {
      assertNotNull(task);
      assertEquals("get coupon", task.getName());
      Map<String, String> formData = new HashMap<String, String>();
      formData.put("hash", "abc");
      formService.submitTaskFormData(task.getId(), formData);

      break;
    }

    tasks =
        taskService
            .createTaskQuery()
            .taskAssignee("kermit")
            .processInstanceId(processInstance.getId())
            .list();
    assertEquals(1, tasks.size());

    /** Valid coupon hash */
    for (Task task : tasks) {
      assertNotNull(task);
      assertEquals("get coupon", task.getName());
      Map<String, String> formData = new HashMap<String, String>();
      formData.put("hash", "abcd");
      formService.submitTaskFormData(task.getId(), formData);

      break;
    }

    // check if the price was reduced correctly
    Object price = runtimeService.getVariable(processInstance.getId(), "price");
    assertNotNull(price);
    assertEquals(new Double(130), price);

    // 'get bank transfer data' should be next on the list
    tasks =
        taskService
            .createTaskQuery()
            .taskAssignee("kermit")
            .processInstanceId(processInstance.getId())
            .list();
    assertEquals(1, tasks.size());
    assertEquals("get bank transfer data", tasks.get(0).getName());
  }
  @Test
  public void testBankTransferValidation() {
    TaskService taskService = processEngine.getTaskService();
    FormService formService = processEngine.getFormService();

    List<Task> tasks =
        taskService
            .createTaskQuery()
            .taskAssignee("kermit")
            .processInstanceId(processInstance.getId())
            .list();
    assertEquals(1, tasks.size());

    // Invalid bank data
    for (Task task : tasks) {
      assertNotNull(task);
      assertEquals("get bank transfer data", task.getName());
      Map<String, String> formData = new HashMap<String, String>();
      formData.put("bankName", "Bank austria"); // invalid bank-name
      formData.put("bankCode", "12000");
      formData.put("accountNumber", "12345678901");
      formData.put("holdersName", "Max Muster");
      formService.submitTaskFormData(task.getId(), formData);
    }

    tasks =
        taskService
            .createTaskQuery()
            .taskAssignee("kermit")
            .processInstanceId(processInstance.getId())
            .list();
    assertEquals(1, tasks.size());
    // As of an error the form should be empty
    assertEquals(0, formService.getTaskFormData(tasks.get(0).getId()).getFormProperties().size());

    // Valid bank data
    for (Task task : tasks) {
      assertNotNull(task);
      assertEquals("get bank transfer data", task.getName());
      Map<String, String> formData = new HashMap<String, String>();
      formData.put("bankName", "Bank Austria");
      formData.put("bankCode", "12000");
      formData.put("accountNumber", "12345678901");
      formData.put("holdersName", "Max Muster");
      formService.submitTaskFormData(task.getId(), formData); // Stack trace starts here
    }

    tasks =
        taskService
            .createTaskQuery()
            .taskAssignee("kermit")
            .processInstanceId(processInstance.getId())
            .list();
    assertEquals(1, tasks.size());
    assertEquals("get acknowledgement", tasks.get(0).getName());
  }
  @Test
  @Ignore
  public void testHappyPath() {

    // Create test applicant
    Applicant applicant = new Applicant("John Doe", "*****@*****.**", "12344");
    applicantRepository.save(applicant);

    // Start process instance
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("applicant", applicant);
    ProcessInstance processInstance =
        runtimeService.startProcessInstanceByKey("hireProcessWithJpa", variables);

    // First, the 'phone interview' should be active
    Task task =
        taskService
            .createTaskQuery()
            .processInstanceId(processInstance.getId())
            .taskCandidateGroup("dev-managers")
            .singleResult();
    Assert.assertEquals("Telephone interview", task.getName());

    // Completing the phone interview with success should trigger two new tasks
    Map<String, Object> taskVariables = new HashMap<String, Object>();
    taskVariables.put("telephoneInterviewOutcome", true);
    taskService.complete(task.getId(), taskVariables);

    List<Task> tasks =
        taskService
            .createTaskQuery()
            .processInstanceId(processInstance.getId())
            .orderByTaskName()
            .asc()
            .list();
    Assert.assertEquals(2, tasks.size());
    Assert.assertEquals("Financial negotiation", tasks.get(0).getName());
    Assert.assertEquals("Tech interview", tasks.get(1).getName());

    // Completing both should wrap up the subprocess, send out the 'welcome mail' and end the
    // process instance
    taskVariables = new HashMap<String, Object>();
    taskVariables.put("techOk", true);
    taskService.complete(tasks.get(0).getId(), taskVariables);

    taskVariables = new HashMap<String, Object>();
    taskVariables.put("financialOk", true);
    taskService.complete(tasks.get(1).getId(), taskVariables);

    // Verify email
    Assert.assertEquals(1, wiser.getMessages().size());

    // Verify process completed
    Assert.assertEquals(1, historyService.createHistoricProcessInstanceQuery().finished().count());
  }
Beispiel #8
0
  /**
   * 查询待办任务
   *
   * @param userId 用户ID
   * @return
   */
  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(ActUtils.PD_LEAVE[0])
            .taskAssignee(userId)
            .active()
            .orderByTaskPriority()
            .desc()
            .orderByTaskCreateTime()
            .desc()
            .list();
    // 根据当前人未签收的任务
    List<Task> unsignedTasks =
        taskService
            .createTaskQuery()
            .processDefinitionKey(ActUtils.PD_LEAVE[0])
            .taskCandidateUser(userId)
            .active()
            .orderByTaskPriority()
            .desc()
            .orderByTaskCreateTime()
            .desc()
            .list();
    // 合并
    tasks.addAll(todoList);
    tasks.addAll(unsignedTasks);
    // 根据流程的业务ID查询实体并关联
    for (Task task : tasks) {
      String processInstanceId = task.getProcessInstanceId();
      ProcessInstance processInstance =
          runtimeService
              .createProcessInstanceQuery()
              .processInstanceId(processInstanceId)
              .active()
              .singleResult();
      String businessKey = processInstance.getBusinessKey();
      Leave leave = leaveDao.get(businessKey);
      leave.setTask(task);
      leave.setProcessInstance(processInstance);
      leave.setProcessDefinition(
          repositoryService
              .createProcessDefinitionQuery()
              .processDefinitionId((processInstance.getProcessDefinitionId()))
              .singleResult());
      results.add(leave);
    }
    return results;
  }
  /** 任务. */
  public Page findTasks(String tenantId, Page page) {
    TaskService taskService = processEngine.getTaskService();
    long count = taskService.createTaskQuery().taskTenantId(tenantId).count();
    List<Task> tasks =
        taskService
            .createTaskQuery()
            .taskTenantId(tenantId)
            .listPage((int) page.getStart(), page.getPageSize());
    page.setResult(tasks);
    page.setTotalCount(count);

    return page;
  }
  /**
   * 跳转到任务执行页面
   *
   * @param request
   * @return
   */
  @RequestMapping(value = "/form.do")
  public String from(
      HttpServletRequest request, @RequestParam("taskId") String taskId, Model model) {

    List<Task> taskList = taskService.createTaskQuery().taskId(taskId).list();
    Task task = taskList.get(0);
    // 获取表单数据
    TaskFormData tfd = formService.getTaskFormData(taskId);
    List<FormProperty> fpList = tfd.getFormProperties();

    Map map = runtimeService.getVariables(task.getExecutionId());

    List<ActivityImpl> activityList = new ArrayList<ActivityImpl>();

    try {
      // 查找所有可驳回的节点
      activityList = processExtensionService.findBackActivity(taskId);
      // model.addAttribute("activityList",activityList);
    } catch (Exception e) {
      e.printStackTrace();
    }

    //        model.addAttribute("task",task);
    //        model.addAttribute("fpList",fpList);
    //        model.addAttribute("map",map);
    //        model.addAttribute("taskId",taskId);

    request.setAttribute("task", task);
    request.setAttribute("fpList", fpList);
    request.setAttribute("map", map);
    request.setAttribute("taskId", taskId);
    request.setAttribute("activityList", activityList);

    return "/simple/form";
  }
Beispiel #11
0
  /**
   * easyui AJAX请求数据 待办任务
   *
   * @param request
   * @param response
   * @param dataGrid
   */
  @RequestMapping(params = "claimedTaskDataGrid")
  public void claimedTaskDataGrid(
      HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {

    // String userId = "leaderuser";
    String userId = ResourceUtil.getSessionUserName().getId();
    TaskService taskService = processEngine.getTaskService();
    List<Task> tasks = taskService.createTaskQuery().taskAssignee(userId).list();

    StringBuffer rows = new StringBuffer();
    for (Task t : tasks) {
      rows.append(
          "{'name':'"
              + t.getName()
              + "','description':'"
              + t.getDescription()
              + "','taskId':'"
              + t.getId()
              + "','processDefinitionId':'"
              + t.getProcessDefinitionId()
              + "','processInstanceId':'"
              + t.getProcessInstanceId()
              + "'},");
    }
    String rowStr = StringUtils.substringBeforeLast(rows.toString(), ",");

    JSONObject jObject =
        JSONObject.fromObject("{'total':" + tasks.size() + ",'rows':[" + rowStr + "]}");
    responseDatagrid(response, jObject);
  }
  @Override
  public void costWorkFlowStart(CostApprovalEntity costApproval, HttpServletRequest request) {
    // 由session取到登录用户id
    String applyUserId = ResourceUtil.getSessionUserName().getId();
    this.save(costApproval);
    String processKey = request.getParameter("processKey");
    if (!StringUtil.isNotEmpty(processKey)) {
      WorkFlowSetEntity workFlowSet =
          this.findUniqueByProperty(
              WorkFlowSetEntity.class, "entityName", costApproval.getClass().getSimpleName());
      processKey = workFlowSet.getProcessKey();
    }
    String businessKey = costApproval.getId().toString();
    ProcessInstance processInstance = null;
    // 用来设置启动流程的人员ID,引擎会自动把用户ID保存到activiti:initiator中
    identityService.setAuthenticatedUserId(applyUserId);

    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put(ProcessConstantsUtil.getApplyUserId(), applyUserId);
    processInstance = runtimeService.startProcessInstanceByKey(processKey, businessKey, variables);
    String processInstanceId = processInstance.getId();
    costApproval.setProcessinstanceId(processInstanceId);

    // 获取并执行当前流程实例的下一步任务
    Task task = null;
    TaskQuery query =
        taskService.createTaskQuery().processInstanceBusinessKey(businessKey).active();
    task = query.singleResult();
    variables.put(
        ProcessConstantsUtil.getDeptLeaderId(),
        ResourceUtil.getSessionUserName().getCurrentDepart().getDepartManager().getId());
    taskService.complete(task.getId(), variables);
  }
  /**
   * 代领任务(组任务)
   *
   * @return
   */
  public String listGroupTasks() {
    TaskService taskService = processEngine.getTaskService();
    String username = SpringSecurityUtils.getCurrentUsername();
    tasks = taskService.createTaskQuery().taskCandidateUser(username).list();

    return "listGroupTasks";
  }
  /**
   * 待办任务(个人任务)
   *
   * @return
   */
  public String listPersonalTasks() {
    TaskService taskService = processEngine.getTaskService();
    String username = SpringSecurityUtils.getCurrentUsername();
    tasks = taskService.createTaskQuery().taskAssignee(username).list();

    return "listPersonalTasks";
  }
 /**
  * 根据任务ID获得任务实例
  *
  * @param taskId 任务ID
  * @return
  * @throws Exception
  */
 private TaskEntity findTaskById(String taskId) throws Exception {
   TaskEntity task = (TaskEntity) taskService.createTaskQuery().taskId(taskId).singleResult();
   if (task == null) {
     throw new Exception("任务实例未找到!");
   }
   return task;
 }
 /**
  * 根据流程实例ID和任务key值查询所有同级任务集合
  *
  * @param processInstanceId
  * @param key
  * @return
  */
 private List<Task> findTaskListByKey(String procInstId, String key) {
   return taskService
       .createTaskQuery()
       .processInstanceId(procInstId)
       .taskDefinitionKey(key)
       .list();
 }
 @Test
 public void testMail() {
   createNewProcess();
   Task nextTask = taskService.createTaskQuery().singleResult();
   HashMap<String, String> map = new HashMap<String, String>();
   formService.submitTaskFormData(nextTask.getId(), map);
 }
  @Test
  public void testRemindCustomer() {
    createNewProcess();
    runtimeService.setVariable(pid, "RemainderAmount", "0");
    Task nextTask = taskService.createTaskQuery().singleResult();
    HashMap<String, String> map = new HashMap<String, String>();
    formService.submitTaskFormData(nextTask.getId(), map);

    Task nextTask2 = taskService.createTaskQuery().singleResult();
    formService.submitTaskFormData(nextTask2.getId(), map);

    Task nextTask3 = taskService.createTaskQuery().singleResult();
    formService.submitTaskFormData(nextTask3.getId(), map);

    Task lastTasks = taskService.createTaskQuery().singleResult();
  }
 /**
  * @Title: isJointTask @Description: 根据taskId判断是否是会签任务节点
  *
  * @param @param taskId
  * @param @return 设定文件
  * @return boolean 返回类型
  * @throws
  */
 public boolean isJointTask(String taskId) {
   Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
   if (task.getTaskLocalVariables().containsKey("nrOfInstances")) {
     return true;
   } else {
     return true;
   }
 }
 @Override
 public Task getDossierToAdmission(Long dossierId) {
   return taskService
       .createTaskQuery()
       .processInstanceBusinessKey(dossierId.toString())
       .taskDefinitionKey(ValidationTask.AFFECTATION.getValue())
       .singleResult();
 }
Beispiel #21
0
 @Test
 public void test() {
   ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
   RepositoryService repositoryService = engine.getRepositoryService();
   RuntimeService runtimeService = engine.getRuntimeService();
   TaskService taskService = engine.getTaskService();
   repositoryService.createDeployment().addClasspathResource("bpmn/first.bpmn").deploy();
   runtimeService.startProcessInstanceByKey("process1");
   Task task = taskService.createTaskQuery().singleResult();
   System.out.println("第一个任务完成前,当前任务名称:" + task.getName());
   taskService.complete(task.getId());
   task = taskService.createTaskQuery().singleResult();
   System.out.println("第二个任务完成前,当前任务名称:" + task.getName());
   taskService.complete(task.getId());
   task = taskService.createTaskQuery().singleResult();
   System.out.println("流程结束后,查找任务:" + task);
 }
 @Override
 public Task getDossierToReceive(Long dossierId) {
   return taskService
       .createTaskQuery()
       .processInstanceBusinessKey(dossierId.toString())
       .processDefinitionKey("validation")
       .singleResult();
 }
 @Override
 public Task getDossierToReAccept(Long dossierId) {
   return taskService
       .createTaskQuery()
       .processInstanceBusinessKey(dossierId.toString())
       .taskDefinitionKey(ValidationTask.CHANGER_STATE.getValue())
       .singleResult();
 }
  /**
   * Generic method which will figure out to which task page must be jumped, based on the task data.
   *
   * <p>Note that, if possible, it is always more performant to use the more specific showXXXPage()
   * methods.
   */
  public void showTaskPage(String taskId) {
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
    String loggedInUserId = ExplorerApp.get().getLoggedInUser().getId();

    if (task == null) {
      // If no runtime task exists, our only hope is the archive page
      boolean isOwner =
          historyService
                  .createHistoricTaskInstanceQuery()
                  .taskId(taskId)
                  .taskOwner(loggedInUserId)
                  .count()
              == 1;
      if (isOwner) {
        showArchivedPage(taskId);
      } else {
        showNavigationError(taskId);
      }
    } else if (loggedInUserId.equals(task.getOwner())) {
      showTasksPage(taskId);
    } else if (loggedInUserId.equals(task.getAssignee())) {
      showInboxPage(taskId);
    } else if (taskService.createTaskQuery().taskInvolvedUser(loggedInUserId).count() == 1) {
      showInvolvedPage(taskId);
    } else {
      // queued
      List<String> groupIds = getGroupIds(loggedInUserId);
      List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId());
      Iterator<IdentityLink> identityLinkIterator = identityLinks.iterator();

      boolean pageFound = false;
      while (!pageFound && identityLinkIterator.hasNext()) {
        IdentityLink identityLink = identityLinkIterator.next();
        if (identityLink.getGroupId() != null && groupIds.contains(identityLink.getGroupId())) {
          showQueuedPage(identityLink.getGroupId(), task.getId());
          pageFound = true;
        }
      }

      // We've tried hard enough, the user now gets a notification. He deserves it.
      if (!pageFound) {
        showNavigationError(taskId);
      }
    }
  }
 @Override
 public List<PiecejustifDTO> getPieceJustifFromProcess(Long dossierId, ValidationTask step) {
   Task task =
       taskService
           .createTaskQuery()
           .processInstanceBusinessKey(dossierId.toString())
           .taskDefinitionKey(step.getValue())
           .singleResult();
   return (List<PiecejustifDTO>) runtimeService.getVariable(task.getExecutionId(), "piecejustifs");
 }
  @Test
  public void testRollbackJobExecutorPath() throws Exception {

    ProcessInstance instance = runtimeService.startProcessInstanceByKey("errorProcess1");
    assertNotNull(instance);
    waitForTasksToExpire();

    List<Task> activeTasks =
        taskService.createTaskQuery().processInstanceId(instance.getId()).list();
    assertTrue(activeTasks.size() == 1);
  }
 private List<Defect> findDefects(String username, String taskName) {
   List<Task> tasks = taskService.createTaskQuery().taskAssignee(username).list();
   List<Long> defectIds = new ArrayList<Long>();
   for (Task task : tasks) {
     if (task.getName().equalsIgnoreCase(taskName)) {
       Long defectId = (Long) runtimeService.getVariable(task.getExecutionId(), "defectId");
       defectIds.add(defectId);
     }
   }
   return defectRepository.findByIds(defectIds);
 }
  /**
   * 代理中的任务(代理人还未完成该任务)
   *
   * @return
   */
  public String listDelegatedTasks() {
    TaskService taskService = processEngine.getTaskService();
    String username = SpringSecurityUtils.getCurrentUsername();
    tasks =
        taskService
            .createTaskQuery()
            .taskOwner(username)
            .taskDelegationState(DelegationState.PENDING)
            .list();

    return "listDelegatedTasks";
  }
Beispiel #29
0
 @Test
 public void testSetAssignee() {
   ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
   IdentityService identityService = engine.getIdentityService();
   User user = creatUser(identityService, "user1", "张三", "last", "*****@*****.**", "123");
   TaskService taskService = engine.getTaskService();
   Task task1 = taskService.newTask("task1");
   task1.setName("申请任务");
   taskService.saveTask(task1);
   taskService.setAssignee(task1.getId(), user.getId());
   System.out.println(
       "用户张三受理的任务数量:" + taskService.createTaskQuery().taskAssignee(user.getId()).count());
 }
  /**
   * 个人任务首页
   *
   * @return
   */
  @RequestMapping("/index.do")
  public String index(HttpServletRequest request, HttpServletResponse response, Model model) {

    User user =
        request.getSession(true).getAttribute("user") == null
            ? null
            : (User) request.getSession(true).getAttribute("user");

    List<Group> groups =
        request.getSession(true).getAttribute("groups") == null
            ? null
            : (List<Group>) request.getSession(true).getAttribute("groups");

    if (null == user) {
      return "redirect:/simple/login.do";
    } else {
      model.addAttribute("user", user);
      model.addAttribute("groups", groups);
      /** */
      List<ProcessDefinition> pdList = repositoryService.createProcessDefinitionQuery().list();

      model.addAttribute("pdList", pdList);
      /** 该用户所有可以认领的任务 */
      List<Task> groupTasks = taskService.createTaskQuery().taskCandidateUser(user.getId()).list();

      List<Task> userTasks = taskService.createTaskQuery().taskAssignee(user.getId()).list();
      model.addAttribute("userTasks", userTasks);
      model.addAttribute("groupTasks", groupTasks);
      /** 查看任务实例 */
      List<Task> taskList = taskService.createTaskQuery().list();
      model.addAttribute("taskList", taskList);
      /** 历史流程 */
      List<HistoricProcessInstance> hpiList =
          historyService.createHistoricProcessInstanceQuery().finished().list();
      model.addAttribute("hpiList", hpiList);
    }

    return "/simple/index";
  }