/**
   * 开始流程
   *
   * @return
   */
  @RequestMapping(value = "/start.do")
  public String startProcessDefinition(
      HttpServletRequest request,
      @RequestParam("processDefId") String processDefId,
      @RequestParam("userId") String userId) {

    // 用来设置启动流程的人员ID,引擎会自动把用户ID保存到activiti:initiator中
    identityService.setAuthenticatedUserId(userId);

    Map map = new HashMap();
    map.put("owner", userId);
    runtimeService.startProcessInstanceById(processDefId, map);

    return "redirect:/simple/index.do";
  }
  /**
   * 提交流程
   *
   * @return
   */
  @RequestMapping(value = "/submit.do")
  public String submit(
      HttpServletRequest request,
      HttpServletResponse response,
      @RequestParam(value = "taskId", required = false) String taskId,
      @RequestParam(value = "day", required = false) String day,
      @RequestParam(value = "type", required = false) String type,
      @RequestParam(value = "reason", required = false) String reason,
      @RequestParam(value = "result", required = false) String result,
      @RequestParam(value = "toSign", required = false) String toSign,
      @RequestParam(value = "backActivityId", required = false) String backActivityId)
      throws Exception {
    List<Task> taskList = taskService.createTaskQuery().taskId(taskId).list();
    Task task = taskList.get(0);
    String taskName = task.getName();

    // result = new String(result.getBytes("ISO-8859-1"), "UTF-8");

    if (result.equals("同意")) {
      Map map = new HashMap();
      if (StringUtils.isNotBlank(day)) {
        map.put("day", day);
        map.put("reason", reason);
        map.put("type", 0);
        taskService.complete(taskId, map);
      } else {
        taskService.complete(taskId);
      }
    } else if (result.equals("驳回")) {
      ProcessInstance processInstance = processExtensionService.findProcessInstanceByTaskId(taskId);

      Map<String, Object> map = runtimeService.getVariables(processInstance.getId());

      processExtensionService.backProcess(taskId, backActivityId, map);
    } else if (result.equals("转签")) {

      if (processExtensionService.isPermissionInActivity(taskId, toSign)) {
        taskService.setAssignee(taskId, toSign);
      }
    }
    return "redirect:/simple/index.do";
  }