/**
   * 跳转到任务执行页面
   *
   * @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";
  }
 @RequestMapping(value = "/complete-task/{taskId}")
 public String completeTask(@PathVariable String taskId, HttpServletRequest request) {
   TaskFormData taskFormData = formService.getTaskFormData(taskId);
   boolean hasFormKey =
       taskFormData.getFormKey() != null && taskFormData.getFormKey().length() > 0;
   List<FormProperty> formProperties = taskFormData.getFormProperties();
   Map<String, String> formValues =
       generateFormValueMap(hasFormKey, formProperties, request); // 生成提交数据
   formService.submitTaskFormData(taskId, formValues);
   return "redirect:/identity/user";
 }
 @RequestMapping(value = "/do-task/{taskId}")
 public ModelAndView doTask(@PathVariable String taskId) {
   ModelAndView mav = new ModelAndView("workflow/task-form");
   Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
   TaskFormData taskFormData = formService.getTaskFormData(taskId);
   boolean hasFormKey =
       taskFormData.getFormKey() != null && taskFormData.getFormKey().length() > 0;
   mav.addObject("task", task);
   mav.addObject("hasFormKey", hasFormKey);
   if (task.getFormKey() != null) {
     Object renderFormData = formService.getRenderedTaskForm(taskId);
     mav.addObject("taskFormData", renderFormData);
   } else {
     mav.addObject("taskFormData", taskFormData);
   }
   return mav;
 }
예제 #4
0
  /**
   * 完成任务
   *
   * @return
   */
  public String completeTask() {
    HttpServletRequest request = ServletActionContext.getRequest();
    IdentityService identityService = processEngine.getIdentityService();
    identityService.setAuthenticatedUserId(SpringSecurityUtils.getCurrentUsername());

    FormService formService = processEngine.getFormService();
    TaskFormData taskFormData = formService.getTaskFormData(taskId);

    Map<String, String> map = new HashMap<String, String>();

    for (FormProperty formProperty : taskFormData.getFormProperties()) {
      if (formProperty.isWritable()) {
        String name = formProperty.getId();
        map.put(name, request.getParameter(name));
      }
    }

    formService.submitTaskFormData(taskId, map);

    return RELOAD;
  }