Ejemplo n.º 1
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);
  }
Ejemplo n.º 2
0
 public static ProcessDefinition getProcessDefinitionByTask(Task task) {
   String processDefinitionId = task.getProcessDefinitionId();
   ProcessDefinition processDefinition =
       repositoryService
           .createProcessDefinitionQuery()
           .processDefinitionId(processDefinitionId)
           .singleResult();
   return processDefinition;
 }
Ejemplo n.º 3
0
  /** 查询当前人的个人任务 */
  @Test
  public void findMyProcess() {
    String assignee = "王五";

    List<Task> list =
        processEngine
            .getTaskService() // 与正在执行的任务管理相关的service
            .createTaskQuery() // 创建查询对象
            .taskAssignee(assignee) // 指定个人任务查询,指定办理人
            .list();
    if (list != null && list.size() > 0) {
      for (Task task : list) {
        System.out.println("id" + task.getId());
        System.out.println("任务名称:" + task.getName());
        System.out.println("time:" + task.getCreateTime());
        System.out.println("办理人:" + task.getAssignee());
        System.out.println("流程实例ID" + task.getProcessInstanceId());
        System.out.println("执行对象ID:" + task.getExecutionId());
        System.out.println("流程定义ID" + task.getProcessDefinitionId());
      }
    }
  }
Ejemplo n.º 4
0
  /**
   * 打开任务 传入的request必须有以下参数 taskId:task的Id taskPage:处理task的页面路径 model:业务表类名 formId:业务表id
   * formProperties:控制表单的名称
   *
   * @return
   * @throws Exception
   */
  public String open_task() throws Exception {
    log.debug("open_task()");
    List<String> nextTaskList = new ArrayList<String>();
    String taskId = getpara("taskId");
    String taskPage = getpara("taskPage");
    String modelStr = getpara("model");
    // add by hb for only query user task
    String readonly = getpara("readonly");
    // end
    String formId = (String) infActiviti.getVariableByTaskId(taskId, "formId");
    if (formId == null || formId.equals("") || modelStr == null || "".equals(modelStr)) {
      rhs.put("model", null);
    } else {
      BaseModel model = (BaseModel) baseDao.loadById(modelStr, Long.parseLong(formId));
      rhs.put("model", model);
    }

    /* add by chenzhijian 20130419 -s */
    // 获取 formProperties 配置文件
    String formProperties = getpara("formProperties");
    HashMap<String, String> formPro = new HashMap<String, String>();
    Properties p = new Properties();
    try {
      // String filepath = System.getProperty("webroot", "./src/main/webapp/");
      String filepath = getWebroot();
      // eg: app/manager/wo/wo.properties
      filepath +=
          "/app/manager/" + modelStr.toLowerCase() + "/" + modelStr.toLowerCase() + ".properties";
      FileInputStream in = new FileInputStream(filepath);
      p.load(in);
      in.close();
      Set<String> set = p.stringPropertyNames();
      for (String s : set) {
        if (s.startsWith("default")) {
          formPro.put(s.replace("default.", ""), p.getProperty(s));
        }
      }
      for (String s : set) {
        if (s.startsWith(formProperties)) {
          formPro.put(s.replace(formProperties + ".", ""), p.getProperty(s));
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    rhs.put("formPro", formPro);
    /* add by chenzhijian 20130419 -e */

    Task task = infActiviti.getTaskById(taskId);
    /*add by hb for get next task 20140128 start*/
    String nextTask = "";
    String initiator = (String) infActiviti.getVariableByTaskId(task.getId(), "initiator");
    // 当前任务获取当前流程的流程定义,然后根据流程定义获得所有的节点
    ProcessDefinitionEntity def =
        (ProcessDefinitionEntity)
            ((RepositoryServiceImpl) repositoryService)
                .getDeployedProcessDefinition(task.getProcessDefinitionId());
    List<ActivityImpl> activitiList = def.getActivities();
    // 根据任务获取当前流程执行ID,执行实例以及当前流程节点的ID
    String excId = task.getExecutionId();
    ExecutionEntity execution =
        (ExecutionEntity) runtimeService.createExecutionQuery().executionId(excId).singleResult();
    String activitiId = execution.getActivityId();
    // 循环activitiList 并判断出当前流程所处节点,然后得到当前节点实例,
    // 根据节点实例获取所有从当前节点出发的路径,然后根据路径获得下一个节点实例
    for (ActivityImpl activityImpl : activitiList) {
      String id = activityImpl.getId();
      if (activitiId.equals(id)) {
        log.debug("当前任务:" + activityImpl.getProperty("name"));
        List<PvmTransition> outTransitions =
            activityImpl.getOutgoingTransitions(); // 获取从某个节点出来的所有线路
        for (PvmTransition tr : outTransitions) {
          PvmActivity ac = tr.getDestination(); // 获取线路的终点节点,在这里应该还要加个判断,如果是并行或者相容关口,则需要继续往下找下一个任务。
          if (ac.getProperty("type").equals("parallelGateway")
              || ac.getProperty("type")
                  .equals(
                      "inclusiveGateway")) { // 不能包括互斥关口
                                             // ac.getProperty("type").equals("exclusiveGateway")
            List<PvmTransition> outTransitions2 = ac.getOutgoingTransitions(); // 因为是关口,所以继续往下找任务
            for (PvmTransition pvmTransition : outTransitions2) {
              PvmActivity ac2 = pvmTransition.getDestination();
              nextTask = (String) ac2.getId();
              log.debug("下一个任务----->:" + nextTask);
              nextTaskList.add(nextTask);
            }
          } else {
            nextTask = (String) ac.getId();
            log.debug("下一个任务++++>:" + nextTask);
            nextTaskList.add(nextTask);
          }
        }
        break;
      }
    }

    /*end*/
    rhs.put("task", task);
    rhs.put("initiator", initiator);
    rhs.put("nextTaskList", nextTaskList);
    rhs.put("taskPage", taskPage);
    rhs.put("readonly", readonly);
    getAllUserAndGroupInfo();

    return "success";
  }