Beispiel #1
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(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";
  }
 /**
  * 转办流程
  *
  * @param taskId 当前任务节点ID
  * @param userCode 被转办人Code
  */
 @Override
 public void transferAssignee(String taskId, String userCode) {
   taskService.setAssignee(taskId, userCode);
 }