/**
   * Task variation over time i.e. tasks started and completed over the months
   *
   * @return array with the no. of tasks started and completed over the months
   */
  @GET
  @Path("/taskVariation/")
  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
  public ResponseHolder taskVariationOverTime() {
    ResponseHolder response = new ResponseHolder();
    List list = new ArrayList();
    String[] MONTHS = {
      "Jan", "Feb", "March", "April", "May", "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec"
    };
    SimpleDateFormat ft = new SimpleDateFormat("M");

    InstanceStatPerMonth[] taskStatPerMonths = new InstanceStatPerMonth[12];
    for (int i = 0; i < taskStatPerMonths.length; i++) {
      taskStatPerMonths[i] = new InstanceStatPerMonth();
      taskStatPerMonths[i].setMonth(MONTHS[i]);
      taskStatPerMonths[i].setCompletedInstances(0);
      taskStatPerMonths[i].setStartedInstances(0);
    }
    // Get completed tasks
    List<HistoricTaskInstance> taskList =
        BPMNOSGIService.getHistoryService()
            .createHistoricTaskInstanceQuery()
            .taskTenantId(str)
            .finished()
            .list();

    for (HistoricTaskInstance instance : taskList) {
      int startTime = Integer.parseInt(ft.format(instance.getCreateTime()));
      int endTime = Integer.parseInt(ft.format(instance.getEndTime()));
      taskStatPerMonths[startTime - 1].setStartedInstances(
          taskStatPerMonths[startTime - 1].getStartedInstances() + 1);
      taskStatPerMonths[endTime - 1].setCompletedInstances(
          taskStatPerMonths[endTime - 1].getCompletedInstances() + 1);
    }
    // Get active/started tasks
    List<Task> taskActive =
        BPMNOSGIService.getTaskService().createTaskQuery().taskTenantId(str).active().list();
    for (Task instance : taskActive) {

      int startTime = Integer.parseInt(ft.format(instance.getCreateTime()));
      taskStatPerMonths[startTime - 1].setStartedInstances(
          taskStatPerMonths[startTime - 1].getStartedInstances() + 1);
    }

    // Get suspended tasks
    List<Task> taskSuspended =
        BPMNOSGIService.getTaskService().createTaskQuery().taskTenantId(str).suspended().list();
    for (Task instance : taskSuspended) {

      int startTime = Integer.parseInt(ft.format(instance.getCreateTime()));
      taskStatPerMonths[startTime - 1].setStartedInstances(
          taskStatPerMonths[startTime - 1].getStartedInstances() + 1);
    }
    for (int i = 0; i < taskStatPerMonths.length; i++) {
      list.add(taskStatPerMonths[i]);
    }
    response.setData(list);
    return response;
  }
Пример #2
0
 public void tesBasicTaskPropertiesNotNull() {
   Task task = taskService.createTaskQuery().taskId(taskIds.get(0)).singleResult();
   assertNotNull(task.getDescription());
   assertNotNull(task.getId());
   assertNotNull(task.getName());
   assertNotNull(task.getCreateTime());
 }
Пример #3
0
  /**
   * @param tasks
   * @return
   */
  public List<TaskVo> buildTaskVos(List<Task> tasks) {
    List<TaskVo> taskRtn = new ArrayList<>();

    if (null != tasks && !tasks.isEmpty()) {
      // 根据流程的业务ID查询实体并关联
      for (Task task : tasks) {

        String processInstanceId = task.getProcessInstanceId();
        ProcessInstance processInstance =
            runtimeService
                .createProcessInstanceQuery()
                .processInstanceId(processInstanceId)
                .active()
                .singleResult();
        String businessName = (String) task.getTaskLocalVariables().get(WebConstants.BUSINESS_NAME);
        String taskId = task.getId();
        String businessKey = processInstance.getBusinessKey();

        if (StringUtils.isBlank(businessKey)) {
          continue;
        }
        if (StringUtils.isBlank(businessName)) {
          businessName = getBusinessName(taskId, businessKey);
        }

        ProcessDefinition processDefinition =
            getProcessDefinition(processInstance.getProcessDefinitionId());
        int version = processDefinition.getVersion();
        String taskName = task.getName();
        String createTime =
            DateUtils.SINGLETONE.format(task.getCreateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
        String assignee = task.getAssignee();
        boolean suspended = task.isSuspended();

        String processDefinitionId = processInstance.getProcessDefinitionId();

        TaskVo taskInfo = new TaskVo();
        taskInfo.setProcessInstanceId(processInstanceId);
        taskInfo.setBusinessKey(businessKey);
        taskInfo.setProcessDefinitionId(processDefinitionId);
        taskInfo.setId(taskId);
        taskInfo.setName(taskName);
        taskInfo.setCreateTime(createTime);
        taskInfo.setAssignee(assignee);
        taskInfo.setSuspended(suspended);
        taskInfo.setVersion(version);
        taskInfo.setBusinessName(businessName);
        taskRtn.add(taskInfo);
      }
    }
    return taskRtn;
  }
  public TTaskAbstract adapt(Task vendorTask) {
    TTaskAbstract taskAbstract = new TTaskAbstract();
    taskAbstract.setId(vendorTask.getId());
    taskAbstract.setName(new QName(vendorTask.getName()));
    // taskAbstract.set ->  vendorTask.getAssignee()
    taskAbstract.setPresentationName(vendorTask.getDescription()); // /not sure about this
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(vendorTask.getCreateTime());
    taskAbstract.setCreatedOn(new XMLGregorianCalendarImpl(calendar));
    taskAbstract.setPriority(BigInteger.valueOf(vendorTask.getPriority()));

    return taskAbstract;
  }
Пример #5
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());
      }
    }
  }