Java Code Examples for org.activiti.engine.history.HistoricProcessInstance#getBusinessKey()

The following examples show how to use org.activiti.engine.history.HistoricProcessInstance#getBusinessKey() . 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: OAController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 历史流程 详情
 */
@Before(IdRequired.class)
public void historicProcessInstanceDetail() {
    String processInstanceId = getPara("id"); // 历史流程实例 id
    HistoricProcessInstance instance = ActivitiKit.getHistoryService().createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId)
            .includeProcessVariables()
            .singleResult();
    String businessKey = instance.getBusinessKey();
    String businessForm = (String) instance.getProcessVariables().get("businessForm"); // 业务表单
    String initiator = (String) instance.getProcessVariables().get("initiator"); // 申请人
    setAttr("initiator", initiator);
    setAttr("processInstanceId", processInstanceId);
    setAttr("processInstanceName", instance.getName());
    setAttr("businessKey", businessKey);
    setAttr("businessForm", businessForm);
    render("oa/processInstance_detail.ftl");
}
 
Example 2
Source File: ProcessInstanceRepresentation.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public ProcessInstanceRepresentation(HistoricProcessInstance processInstance, boolean graphicalNotation, User startedBy) {
    this.id = processInstance.getId();
    this.name = processInstance.getName();
    this.businessKey = processInstance.getBusinessKey();
    this.processDefinitionId = processInstance.getProcessDefinitionId();
    this.tenantId = processInstance.getTenantId();
    this.graphicalNotationDefined = graphicalNotation;
    this.started = processInstance.getStartTime();
    this.ended = processInstance.getEndTime();
    this.startedBy = new UserRepresentation(startedBy);
}
 
Example 3
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 4
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 5
Source File: ProcessInfo.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ProcessInfo(HistoricProcessInstance processInstance)
{
    this.id = processInstance.getId();
    this.processDefinitionId = processInstance.getProcessDefinitionId();
    this.startedAt = processInstance.getStartTime();
    this.endedAt = processInstance.getEndTime();
    this.durationInMs = processInstance.getDurationInMillis();
    this.deleteReason = processInstance.getDeleteReason();
    this.startUserId = processInstance.getStartUserId();
    this.startActivityId = processInstance.getStartActivityId();
    this.endActivityId = processInstance.getEndActivityId();
    this.businessKey = processInstance.getBusinessKey();
    this.superProcessInstanceId = processInstance.getSuperProcessInstanceId();
    this.completed = (processInstance.getEndTime() != null);
}
 
Example 6
Source File: ProcessConnectorImpl.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 根据processInstanceId获取businessKey.
 */
public String findBusinessKeyByProcessInstanceId(String processInstanceId) {
    HistoricProcessInstance historicProcessInstance = processEngine
            .getHistoryService().createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId)
            .processInstanceTenantId("1").singleResult();

    if (historicProcessInstance == null) {
        logger.info("cannot find processInstance : {}", processInstanceId);
        throw new IllegalStateException("cannot find process instance : "
                + processInstanceId);
    }

    return historicProcessInstance.getBusinessKey();
}
 
Example 7
Source File: LeaveWorkFlowServiceImpl.java    From maven-framework-project with MIT License 4 votes vote down vote up
/**
 * 查询已结束的流程实例
 * @param processDefinitionKey
 * @return
 */
@Transactional(propagation=Propagation.REQUIRED)
public List<Leave> findFinishedProcessInstaces(String processDefinitionKey){
	
	List<Leave> leaves=new ArrayList<Leave>();
	
	//根据流程定义的key查询已经结束的流程实例(HistoricProcessInstance)
	List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery().finished().processDefinitionKey(processDefinitionKey).list();
	
	//关联业务实体
	for (HistoricProcessInstance historicProcessInstance : list) {
		
		String businessKey = historicProcessInstance.getBusinessKey();
		
		Leave leave = leaveService.findById(businessKey);
		
		leave.setHistoricProcessInstance(historicProcessInstance);
		leave.setProcessDefinition(getProcessDefinition(historicProcessInstance.getProcessDefinitionId()));
		
		leaves.add(leave);
	}
	
	return leaves;
}
 
Example 8
Source File: WorkspaceController.java    From lemon with Apache License 2.0 4 votes vote down vote up
@RequestMapping("workspace-copyProcessInstance")
public String copyProcessInstance(
        @RequestParam("processInstanceId") String processInstanceId)
        throws Exception {
    // 复制流程
    // 1. 从历史获取businessKey
    HistoricProcessInstance historicProcessInstance = processEngine
            .getHistoryService().createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();
    String businessKey = historicProcessInstance.getBusinessKey();
    String processDefinitionId = historicProcessInstance
            .getProcessDefinitionId();

    // 2. 从businessKey获取keyvalue
    // Record original = keyValueConnector.findByCode(businessKey);
    ModelInfoDTO original = modelConnector.findByCode(businessKey);

    // 3. 找到流程的第一个form
    FormDTO formDto = this.processConnector
            .findStartForm(processDefinitionId);

    List<String> fieldNames = new ArrayList<String>();

    if (formDto.isExists()) {
        String content = formDto.getContent();
        logger.debug("content : {}", content);

        Map<String, Object> formJson = jsonMapper.fromJson(
                formDto.getContent(), Map.class);
        List<Map<String, Object>> sections = (List<Map<String, Object>>) formJson
                .get("sections");

        for (Map<String, Object> section : sections) {
            if (!"grid".equals(section.get("type"))) {
                continue;
            }

            List<Map<String, Object>> fields = (List<Map<String, Object>>) section
                    .get("fields");

            for (Map<String, Object> field : fields) {
                logger.debug("field : {}", field);

                String type = (String) field.get("type");
                String name = (String) field.get("name");
                String label = name;

                if ("label".equals(type)) {
                    continue;
                }

                // if (formField != null) {
                // continue;
                // }
                fieldNames.add(name);
            }
        }
    }

    logger.debug("fieldNames : {}", fieldNames);

    // 4. 使用第一个form复制数据,后续的审批意见数据之类的不要复制
    // Record record = keyValueConnector.copyRecord(original, fieldNames);
    ModelInfoDTO modelInfoDto = modelConnector.copyModel(original,
            fieldNames);

    // 5. 跳转到草稿箱
    return "redirect:/operation/process-operation-listDrafts.do";
}