org.activiti.engine.HistoryService Java Examples

The following examples show how to use org.activiti.engine.HistoryService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InitProcessEngineBySpringAnnotation.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx =
            new AnnotationConfigApplicationContext();
    ctx.register(SpringAnnotationConfiguration.class);
    ctx.refresh();

    assertNotNull(ctx.getBean(ProcessEngine.class));
    assertNotNull(ctx.getBean(RuntimeService.class));
    TaskService bean = ctx.getBean(TaskService.class);
    assertNotNull(bean);
    assertNotNull(ctx.getBean(HistoryService.class));
    assertNotNull(ctx.getBean(RepositoryService.class));
    assertNotNull(ctx.getBean(ManagementService.class));
    assertNotNull(ctx.getBean(FormService.class));
    Task task = bean.newTask();
    task.setName("哈哈");
    bean.saveTask(task);
}
 
Example #2
Source File: ViewService.java    From lemon with Apache License 2.0 6 votes vote down vote up
public void findGraph(String processInstanceId) {
    HistoryService historyService = processEngine.getHistoryService();
    HistoricProcessInstance historicProcessInstance = historyService
            .createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();

    // model.addAttribute("nodeDtos",
    // traceService.traceProcessInstance(processInstanceId));
    // model.addAttribute("historyActivities", processEngine
    // .getHistoryService().createHistoricActivityInstanceQuery()
    // .processInstanceId(processInstanceId).list());

    // if (historicProcessInstance.getEndTime() == null) {
    // model.addAttribute("currentActivities", processEngine
    // .getRuntimeService()
    // .getActiveActivityIds(processInstanceId));
    // } else {
    // model.addAttribute("currentActivities", Collections
    // .singletonList(historicProcessInstance.getEndActivityId()));
    // }
}
 
Example #3
Source File: ComplaintUserInnerServiceSMOImpl.java    From MicroCommunity with Apache License 2.0 6 votes vote down vote up
/**
     * 查询用户任务数
     *
     * @param user
     * @return
     */
    public long getUserHistoryTaskCount(@RequestBody AuditUser user) {
        HistoryService historyService = processEngine.getHistoryService();
//        Query query = historyService.createHistoricTaskInstanceQuery()
//                .processDefinitionKey("complaint")
//                .taskAssignee(user.getUserId());

        HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
                .processDefinitionKey(getWorkflowDto(user.getCommunityId()))
                .taskAssignee(user.getUserId());
        if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) {
            historicTaskInstanceQuery.taskName("complaint");
        } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) {
            historicTaskInstanceQuery.taskName("complaitDealUser");
        }

        Query query = historicTaskInstanceQuery;
        return query.count();
    }
 
Example #4
Source File: PurchaseApplyUserInnerServiceSMOImpl.java    From MicroCommunity with Apache License 2.0 6 votes vote down vote up
/**
     * 查询用户任务数
     *
     * @param user
     * @return
     */
    public long getUserHistoryTaskCount(@RequestBody AuditUser user) {
        HistoryService historyService = processEngine.getHistoryService();
//        Query query = historyService.createHistoricTaskInstanceQuery()
//                .processDefinitionKey("complaint")
//                .taskAssignee(user.getUserId());

        HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
                .processDefinitionKey("resourceEnter")
                .taskAssignee(user.getUserId());
        if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) {
            historicTaskInstanceQuery.taskName("resourceEnter");
        } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) {
            historicTaskInstanceQuery.taskName("resourceEnterDealUser");
        }

        Query query = historicTaskInstanceQuery;
        return query.count();
    }
 
Example #5
Source File: AccessRequestService.java    From Gatekeeper with Apache License 2.0 6 votes vote down vote up
@Autowired
public AccessRequestService(TaskService taskService,
                            AccessRequestRepository accessRequestRepository,
                            GatekeeperRoleService gatekeeperRoleService,
                            RuntimeService runtimeService,
                            HistoryService historyService,
                            GatekeeperApprovalProperties gatekeeperApprovalProperties,
                            AccountInformationService accountInformationService,
                            GatekeeperOverrideProperties overridePolicy,
                            DatabaseConnectionService databaseConnectionService){
    this.taskService = taskService;
    this.accessRequestRepository = accessRequestRepository;
    this.gatekeeperRoleService = gatekeeperRoleService;
    this.runtimeService = runtimeService;
    this.historyService = historyService;
    this.approvalThreshold = gatekeeperApprovalProperties;
    this.accountInformationService = accountInformationService;
    this.overridePolicy = overridePolicy;
    this.databaseConnectionService = databaseConnectionService;
}
 
Example #6
Source File: AccessRequestService.java    From Gatekeeper with Apache License 2.0 6 votes vote down vote up
@Autowired
public AccessRequestService(TaskService taskService,
                            AccessRequestRepository accessRequestRepository,
                            GatekeeperRoleService gatekeeperRoleService,
                            RuntimeService runtimeService,
                            HistoryService historyService,
                            AccountInformationService accountInformationService,
                            SsmService ssmService,
                            GatekeeperApprovalProperties gatekeeperApprovalProperties){

    this.taskService = taskService;
    this.accessRequestRepository = accessRequestRepository;
    this.gatekeeperRoleService = gatekeeperRoleService;
    this.runtimeService = runtimeService;
    this.historyService = historyService;
    this.accountInformationService = accountInformationService;
    this.ssmService = ssmService;
    this.approvalPolicy = gatekeeperApprovalProperties;
}
 
Example #7
Source File: ProcessConnectorImpl.java    From lemon with Apache License 2.0 6 votes vote down vote up
/**
 * 已结流程.
 */
public Page findCompletedProcessInstances(String userId, String tenantId,
        Page page) {
    HistoryService historyService = processEngine.getHistoryService();

    long count = historyService.createHistoricProcessInstanceQuery()
            .processInstanceTenantId(tenantId).startedBy(userId).finished()
            .count();
    List<HistoricProcessInstance> historicProcessInstances = historyService
            .createHistoricProcessInstanceQuery().startedBy(userId)
            .processInstanceTenantId(tenantId).finished()
            .orderByProcessInstanceStartTime().desc()
            .listPage((int) page.getStart(), page.getPageSize());

    page.setResult(historicProcessInstances);
    page.setTotalCount(count);

    return page;
}
 
Example #8
Source File: ProcessConnectorImpl.java    From lemon with Apache License 2.0 6 votes vote down vote up
/**
 * 参与流程.
 */
public Page findInvolvedProcessInstances(String userId, String tenantId,
        Page page) {
    HistoryService historyService = processEngine.getHistoryService();

    // TODO: finished(), unfinished()
    long count = historyService.createHistoricProcessInstanceQuery()
            .processInstanceTenantId(tenantId).involvedUser(userId).count();
    List<HistoricProcessInstance> historicProcessInstances = historyService
            .createHistoricProcessInstanceQuery()
            .processInstanceTenantId(tenantId).involvedUser(userId)
            .orderByProcessInstanceStartTime().desc()
            .listPage((int) page.getStart(), page.getPageSize());

    page.setResult(historicProcessInstances);
    page.setTotalCount(count);

    return page;
}
 
Example #9
Source File: MyTransactionalOperationTransactionDependentTaskListener.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(String processInstanceId, String executionId, Task task, Map<String, Object> executionVariables, Map<String, Object> customPropertiesMap) {
  super.notify(processInstanceId, executionId, task, executionVariables, customPropertiesMap);

  if (Context.getCommandContext().getProcessEngineConfiguration().getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
    HistoryService historyService = Context.getCommandContext().getProcessEngineConfiguration().getHistoryService();

    // delete first historic instance
    List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
    historyService.deleteHistoricProcessInstance(historicProcessInstances.get(0).getId());
  }
}
 
Example #10
Source File: TestBPMN001.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@Test
public void queryHistory() throws Exception {
	
	HistoryService historyService = (HistoryService) AppContext.getBean("historyService");
	List<HistoricTaskInstance> taskInstances = historyService
			.createHistoricTaskInstanceQuery()
			.finished()
			.list();
	for (HistoricTaskInstance taskInst : taskInstances) {
		System.out.println(taskInst.getId() + " , " + taskInst.getName() + " , " 
				+ taskInst.getFormKey() + " , " + taskInst.getAssignee() );
	}
}
 
Example #11
Source File: ProcessInstanceResourceRepository.java    From crnk-framework with Apache License 2.0 5 votes vote down vote up
public ProcessInstanceResourceRepository(RuntimeService runtimeService, HistoryService historyService,
		ActivitiResourceMapper resourceMapper, Class<T>
		resourceClass, List<FilterSpec> baseFilters) {
	super(resourceMapper, resourceClass, baseFilters);
	this.historyService = historyService;
	this.runtimeService = runtimeService;
}
 
Example #12
Source File: ProxyProcessEngine.java    From lemon with Apache License 2.0 5 votes vote down vote up
public HistoryService getHistoryService() {
    if (processEngine == null) {
        return null;
    }

    return processEngine.getHistoryService();
}
 
Example #13
Source File: ProcessConnectorImpl.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 未结流程.
 */
public Page findRunningProcessInstances(String userId, String tenantId,
        Page page) {
    HistoryService historyService = processEngine.getHistoryService();

    // TODO: 改成通过runtime表搜索,提高效率
    long count = historyService.createHistoricProcessInstanceQuery()
            .processInstanceTenantId(tenantId).startedBy(userId)
            .unfinished().count();
    HistoricProcessInstanceQuery query = historyService
            .createHistoricProcessInstanceQuery()
            .processInstanceTenantId(tenantId).startedBy(userId)
            .orderByProcessInstanceStartTime().desc().unfinished();

    if (page.getOrderBy() != null) {
        String orderBy = page.getOrderBy();

        if ("processInstanceStartTime".equals(orderBy)) {
            query.orderByProcessInstanceStartTime();
        }

        if (page.isAsc()) {
            query.asc();
        } else {
            query.desc();
        }
    }

    List<HistoricProcessInstance> historicProcessInstances = query
            .listPage((int) page.getStart(), page.getPageSize());

    page.setResult(historicProcessInstances);
    page.setTotalCount(count);

    return page;
}
 
Example #14
Source File: ComplaintUserInnerServiceSMOImpl.java    From MicroCommunity with Apache License 2.0 5 votes vote down vote up
/**
 * 获取用户审批的任务
 *
 * @param user 用户信息
 */
public List<ComplaintDto> getUserHistoryTasks(@RequestBody AuditUser user) {
    HistoryService historyService = processEngine.getHistoryService();

    HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
            .processDefinitionKey(getWorkflowDto(user.getCommunityId()))
            .taskAssignee(user.getUserId());
    if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) {
        historicTaskInstanceQuery.taskName("complaint");
    } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) {
        historicTaskInstanceQuery.taskName("complaitDealUser");
    }

    Query query = historicTaskInstanceQuery.orderByHistoricTaskInstanceStartTime().desc();

    List<HistoricTaskInstance> list = null;
    if (user.getPage() != PageDto.DEFAULT_PAGE) {
        list = query.listPage((user.getPage() - 1) * user.getRow(), user.getRow());
    } else {
        list = query.list();
    }

    List<String> complaintIds = new ArrayList<>();
    for (HistoricTaskInstance task : list) {
        String processInstanceId = task.getProcessInstanceId();
        //3.使用流程实例,查询
        HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        //4.使用流程实例对象获取BusinessKey
        String business_key = pi.getBusinessKey();
        complaintIds.add(business_key);
    }

    //查询 投诉信息
    ComplaintDto complaintDto = new ComplaintDto();
    complaintDto.setStoreId(user.getStoreId());
    complaintDto.setCommunityId(user.getCommunityId());
    complaintDto.setComplaintIds(complaintIds.toArray(new String[complaintIds.size()]));
    List<ComplaintDto> tmpComplaintDtos = complaintInnerServiceSMOImpl.queryComplaints(complaintDto);
    return tmpComplaintDtos;
}
 
Example #15
Source File: PurchaseApplyUserInnerServiceSMOImpl.java    From MicroCommunity with Apache License 2.0 5 votes vote down vote up
/**
     * 获取用户审批的任务
     *
     * @param user 用户信息
     */
    public List<PurchaseApplyDto> getUserHistoryTasks(@RequestBody AuditUser user) {
        HistoryService historyService = processEngine.getHistoryService();

        HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
                .processDefinitionKey("resourceEnter")
                .taskAssignee(user.getUserId());
        if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) {
            historicTaskInstanceQuery.taskName("resourceEnter");
        } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) {
            historicTaskInstanceQuery.taskName("resourceEnterDealUser");
        }

        Query query = historicTaskInstanceQuery.orderByHistoricTaskInstanceStartTime().desc();

        List<HistoricTaskInstance> list = null;
        if (user.getPage() != PageDto.DEFAULT_PAGE) {
            list = query.listPage((user.getPage() - 1) * user.getRow(), user.getRow());
        } else {
            list = query.list();
        }

        List<String> complaintIds = new ArrayList<>();
        for (HistoricTaskInstance task : list) {
            String processInstanceId = task.getProcessInstanceId();
            //3.使用流程实例,查询
            HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
            //4.使用流程实例对象获取BusinessKey
            String business_key = pi.getBusinessKey();
            complaintIds.add(business_key);
        }

        //查询 投诉信息
//        ComplaintDto complaintDto = new ComplaintDto();
//        complaintDto.setStoreId(user.getStoreId());
//        complaintDto.setCommunityId(user.getCommunityId());
//        complaintDto.setComplaintIds(complaintIds.toArray(new String[complaintIds.size()]));
//        List<ComplaintDto> tmpComplaintDtos = complaintInnerServiceSMOImpl.queryComplaints(complaintDto);
        return null;
    }
 
Example #16
Source File: ProcessConnectorImpl.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 已办任务(历史任务).
 */
public Page findHistoryTasks(String userId, String tenantId, Page page) {
    HistoryService historyService = processEngine.getHistoryService();

    long count = historyService.createHistoricTaskInstanceQuery()
            .taskTenantId(tenantId).taskAssignee(userId).finished().count();
    List<HistoricTaskInstance> historicTaskInstances = historyService
            .createHistoricTaskInstanceQuery().taskTenantId(tenantId)
            .taskAssignee(userId).finished()
            .listPage((int) page.getStart(), page.getPageSize());
    page.setResult(historicTaskInstances);
    page.setTotalCount(count);

    return page;
}
 
Example #17
Source File: ProcessConnectorImpl.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 历史流程实例.
 */
public Page findHistoricProcessInstances(String tenantId, Page page) {
    HistoryService historyService = processEngine.getHistoryService();

    long count = historyService.createHistoricProcessInstanceQuery()
            .processInstanceTenantId(tenantId).count();
    List<HistoricProcessInstance> historicProcessInstances = historyService
            .createHistoricProcessInstanceQuery()
            .processInstanceTenantId(tenantId)
            .listPage((int) page.getStart(), page.getPageSize());
    page.setResult(historicProcessInstances);
    page.setTotalCount(count);

    return page;
}
 
Example #18
Source File: ProcessConnectorImpl.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 历史节点.
 */
public Page findHistoricActivityInstances(String tenantId, Page page) {
    HistoryService historyService = processEngine.getHistoryService();

    long count = historyService.createHistoricActivityInstanceQuery()
            .activityTenantId(tenantId).count();
    List<HistoricActivityInstance> historicActivityInstances = historyService
            .createHistoricActivityInstanceQuery()
            .activityTenantId(tenantId)
            .listPage((int) page.getStart(), page.getPageSize());
    page.setResult(historicActivityInstances);
    page.setTotalCount(count);

    return page;
}
 
Example #19
Source File: SimulationRunContext.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public static HistoryService getHistoryService() {
  Stack<ProcessEngine> stack = getStack(processEngineThreadLocal);
  if (stack.isEmpty()) {
    return null;
  }
  return stack.peek().getHistoryService();
}
 
Example #20
Source File: ProcessConnectorImpl.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 历史任务.
 */
public Page findHistoricTaskInstances(String tenantId, Page page) {
    HistoryService historyService = processEngine.getHistoryService();

    long count = historyService.createHistoricTaskInstanceQuery()
            .taskTenantId(tenantId).count();
    List<HistoricTaskInstance> historicTaskInstances = historyService
            .createHistoricTaskInstanceQuery().taskTenantId(tenantId)
            .listPage((int) page.getStart(), page.getPageSize());
    page.setResult(historicTaskInstances);
    page.setTotalCount(count);

    return page;
}
 
Example #21
Source File: MyTransactionalOperationTransactionDependentTaskListener.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(String processInstanceId, String executionId, Task task, Map<String, Object> executionVariables, Map<String, Object> customPropertiesMap) {
  super.notify(processInstanceId, executionId, task, executionVariables, customPropertiesMap);

  if (Context.getCommandContext().getProcessEngineConfiguration().getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
    HistoryService historyService = Context.getCommandContext().getProcessEngineConfiguration().getHistoryService();

    // delete first historic instance
    List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
    historyService.deleteHistoricProcessInstance(historicProcessInstances.get(0).getId());
  }
}
 
Example #22
Source File: MyTransactionalOperationTransactionDependentExecutionListener.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(String processInstanceId, String executionId, FlowElement currentFlowElement,
                   Map<String, Object> executionVariables, Map<String, Object> customPropertiesMap) {
  
  super.notify(processInstanceId, executionId, currentFlowElement, executionVariables, customPropertiesMap);

  if (Context.getCommandContext().getProcessEngineConfiguration().getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
    HistoryService historyService = Context.getCommandContext().getProcessEngineConfiguration().getHistoryService();

    // delete first historic instance
    List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
    historyService.deleteHistoricProcessInstance(historicProcessInstances.get(0).getId());
  }
}
 
Example #23
Source File: ViewService.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 根据流程实例id获取历史流程实例对象.
 */
public HistoricProcessInstance findHistoricProcessInstance(
        String processInstanceId) {
    HistoryService historyService = processEngine.getHistoryService();
    HistoricProcessInstance historicProcessInstance = historyService
            .createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();

    return historicProcessInstance;
}
 
Example #24
Source File: ViewService.java    From lemon with Apache License 2.0 5 votes vote down vote up
public Map<String, Object> findProcessForm(String processInstanceId)
        throws Exception {
    Map<String, Object> result = new HashMap<String, Object>();

    HistoryService historyService = processEngine.getHistoryService();
    HistoricProcessInstance historicProcessInstance = historyService
            .createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();
    String processDefinitionId = historicProcessInstance
            .getProcessDefinitionId();

    FormDTO formDto = this.processConnector
            .findStartForm(processDefinitionId);
    // model.addAttribute("formDto", formDto);
    result.put("formDto", formDto);

    String businessKey = processConnector
            .findBusinessKeyByProcessInstanceId(processInstanceId);
    String tenantId = tenantHolder.getTenantId();
    ModelInfoDTO modelInfoDto = modelConnector.findByCode(businessKey);
    formDto = formConnector.findForm(formDto.getCode(), tenantId);

    Xform xform = this.processModelService.processFormData(businessKey,
            formDto);
    // model.addAttribute("xform", xform);
    result.put("xform", xform);
    this.processExternalForm(result, formDto, businessKey, modelInfoDto);

    return result;
}
 
Example #25
Source File: MyTransactionalOperationTransactionDependentExecutionListener.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(String processInstanceId, String executionId, FlowElement currentFlowElement,
                   Map<String, Object> executionVariables, Map<String, Object> customPropertiesMap) {
  
  super.notify(processInstanceId, executionId, currentFlowElement, executionVariables, customPropertiesMap);
  
  if (Context.getProcessEngineConfiguration().getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
    HistoryService historyService = Context.getProcessEngineConfiguration().getHistoryService();

    // delete first historic instance
    List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
    historyService.deleteHistoricProcessInstance(historicProcessInstances.get(0).getId());
  }
}
 
Example #26
Source File: ViewService.java    From lemon with Apache License 2.0 4 votes vote down vote up
public ProcessBaseInfo findProcess(String processInstanceId) {
    HistoryService historyService = processEngine.getHistoryService();
    HistoricProcessInstance historicProcessInstance = historyService
            .createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();
    ProcessDefinition processDefinition = processEngine
            .getRepositoryService()
            .createProcessDefinitionQuery()
            .processDefinitionId(
                    historicProcessInstance.getProcessDefinitionId())
            .singleResult();

    ProcessBaseInfo processBaseInfo = new ProcessBaseInfo();
    processBaseInfo
            .setBusinessKey(historicProcessInstance.getBusinessKey());
    processBaseInfo.setId(processInstanceId);
    processBaseInfo.setCode(processDefinition.getKey());
    processBaseInfo.setName(processDefinition.getName());
    processBaseInfo.setUserId(historicProcessInstance.getStartUserId());
    processBaseInfo.setStartTime(historicProcessInstance.getStartTime());

    if (historicProcessInstance.getEndTime() == null) {
        processBaseInfo.setStatus("active");
    } else {
        processBaseInfo.setStatus("end");
    }

    List<String> userIds = new ArrayList<String>();
    List<String> activityNames = new ArrayList<String>();
    List<Task> tasks = processEngine.getTaskService().createTaskQuery()
            .processInstanceId(processInstanceId).list();

    for (Task task : tasks) {
        userIds.add(task.getAssignee());
        activityNames.add(task.getName());
    }

    processBaseInfo.setAssignee(StringUtils.join(userIds, ","));
    processBaseInfo.setActivityName(StringUtils.join(activityNames, ","));

    return processBaseInfo;
}
 
Example #27
Source File: WorkspaceController.java    From lemon with Apache License 2.0 4 votes vote down vote up
/**
 * 查看历史【包含流程跟踪、任务列表(完成和未完成)、流程变量】.
 */
@RequestMapping("workspace-viewHistory")
public String viewHistory(
        @RequestParam("processInstanceId") String processInstanceId,
        Model model) {
    String userId = currentUserHolder.getUserId();
    HistoryService historyService = processEngine.getHistoryService();
    HistoricProcessInstance historicProcessInstance = historyService
            .createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();

    if (userId.equals(historicProcessInstance.getStartUserId())) {
        // startForm
    }

    List<HistoricTaskInstance> historicTasks = historyService
            .createHistoricTaskInstanceQuery()
            .processInstanceId(processInstanceId).list();
    // List<HistoricVariableInstance> historicVariableInstances = historyService
    // .createHistoricVariableInstanceQuery()
    // .processInstanceId(processInstanceId).list();
    model.addAttribute("historicTasks", historicTasks);

    // 获取流程对应的所有人工任务(目前还没有区分历史)
    List<HumanTaskDTO> humanTasks = humanTaskConnector
            .findHumanTasksByProcessInstanceId(processInstanceId);
    List<HumanTaskDTO> humanTaskDtos = new ArrayList<HumanTaskDTO>();

    for (HumanTaskDTO humanTaskDto : humanTasks) {
        if (humanTaskDto.getParentId() != null) {
            continue;
        }

        humanTaskDtos.add(humanTaskDto);
    }

    model.addAttribute("humanTasks", humanTaskDtos);
    // model.addAttribute("historicVariableInstances",
    // historicVariableInstances);
    model.addAttribute("nodeDtos",
            traceService.traceProcessInstance(processInstanceId));
    model.addAttribute("historyActivities", processEngine
            .getHistoryService().createHistoricActivityInstanceQuery()
            .processInstanceId(processInstanceId).list());

    if (historicProcessInstance.getEndTime() == null) {
        model.addAttribute("currentActivities", processEngine
                .getRuntimeService()
                .getActiveActivityIds(processInstanceId));
    } else {
        model.addAttribute("currentActivities", Collections
                .singletonList(historicProcessInstance.getEndActivityId()));
    }

    Graph graph = processEngine.getManagementService().executeCommand(
            new FindHistoryGraphCmd(processInstanceId));
    model.addAttribute("graph", graph);
    model.addAttribute("historicProcessInstance", historicProcessInstance);

    return "bpm/workspace-viewHistory";
}
 
Example #28
Source File: ProcessCustomService.java    From maven-framework-project with MIT License 4 votes vote down vote up
public static HistoryService getHistoryService() {
	return historyService;
}
 
Example #29
Source File: ServiceSpringModuleConfig.java    From herd with Apache License 2.0 4 votes vote down vote up
@Bean
public HistoryService activitiHistoryService(ProcessEngine activitiProcessEngine) throws Exception
{
    return activitiProcessEngine.getHistoryService();
}
 
Example #30
Source File: ViewService.java    From lemon with Apache License 2.0 4 votes vote down vote up
public List<Map<String, String>> findProcessToolbar(String processInstanceId) {
    HistoryService historyService = processEngine.getHistoryService();
    HistoricProcessInstance historicProcessInstance = historyService
            .createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();
    boolean isEnd = historicProcessInstance.getEndTime() != null;
    List<Map<String, String>> buttons = new ArrayList<Map<String, String>>();

    if (isEnd) {
        // this.addButton(buttons, "复制",
        // "/workspace-copyProcessInstance.do?processInstanceId="
        // + processInstanceId);
        // this.addButton(buttons, "转发", "javascript:void(0);doTransfer('"
        // + processInstanceId + "')");
        this.addButton(buttons, "复制", "taskOperation.copyProcess()");
        this.addButton(buttons, "转发", "taskOperation.transferProcess()");
    } else {
        // this.addButton(buttons, "终止",
        // "/bpm/workspace-endProcessInstance.do?processInstanceId="
        // + processInstanceId + "&userId=&comment=");
        // this.addButton(buttons, "催办",
        // "/bpm/workspace-remind.do?processInstanceId="
        // + processInstanceId + "&userId=&comment=");
        // 跳过风险太高了,想明白了再加
        // this.addButton(buttons, "跳过",
        // "/bpm/workspace-skip.do?processInstanceId="
        // + processInstanceId + "&userId=&comment=");
        // if (couldProcessWithdraw(processInstanceId)) {
        // this.addButton(buttons, "撤销",
        // "/bpm/workspace-withdraw.do?processInstanceId="
        // + processInstanceId + "&userId=&comment=");
        // }
        this.addButton(buttons, "终止", "taskOperation.endProcess()");
        this.addButton(buttons, "催办", "taskOperation.remind()");
        this.addButton(buttons, "跳过", "taskOperation.skip()");

        if (couldProcessWithdraw(processInstanceId)) {
            this.addButton(buttons, "撤销", "taskOperation.withdrawProcess()");
        }
    }

    return buttons;
}