Java Code Examples for org.activiti.engine.runtime.ProcessInstance#getBusinessKey()

The following examples show how to use org.activiti.engine.runtime.ProcessInstance#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 processInstanceDetail() {
    String processInstanceId = getPara("id"); // 运行时流程实例id
    ProcessInstance instance = ActivitiKit.getRuntimeService().createProcessInstanceQuery()
            .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);// 流程实例id
    setAttr("processInstanceName", instance.getName());//流程实例 名称
    setAttr("businessKey", businessKey);  // 业务表主键
    setAttr("businessForm", businessForm); // 业务表名称
    render("oa/processInstance_detail.ftl");
}
 
Example 2
Source File: LeaveService.java    From Shop-for-JavaWeb with MIT License 6 votes vote down vote up
/**
 * 查询待办任务
 * @param userId 用户ID
 * @return
 */
public List<Leave> findTodoTasks(String userId) {
	
	List<Leave> results = new ArrayList<Leave>();
	List<Task> tasks = new ArrayList<Task>();
	// 根据当前人的ID查询
	List<Task> todoList = taskService.createTaskQuery().processDefinitionKey(ActUtils.PD_LEAVE[0]).taskAssignee(userId).active().orderByTaskPriority().desc().orderByTaskCreateTime().desc().list();
	// 根据当前人未签收的任务
	List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey(ActUtils.PD_LEAVE[0]).taskCandidateUser(userId).active().orderByTaskPriority().desc().orderByTaskCreateTime().desc().list();
	// 合并
	tasks.addAll(todoList);
	tasks.addAll(unsignedTasks);
	// 根据流程的业务ID查询实体并关联
	for (Task task : tasks) {
		String processInstanceId = task.getProcessInstanceId();
		ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).active().singleResult();
		String businessKey = processInstance.getBusinessKey();
		Leave leave = leaveDao.get(businessKey);
		leave.setTask(task);
		leave.setProcessInstance(processInstance);
		leave.setProcessDefinition(repositoryService.createProcessDefinitionQuery().processDefinitionId((processInstance.getProcessDefinitionId())).singleResult());
		results.add(leave);
	}
	return results;
}
 
Example 3
Source File: LeaveWorkFlowServiceImpl.java    From maven-framework-project with MIT License 5 votes vote down vote up
/**
 * 根据用户Id查询待办任务列表
 * @param userid 用户id
 * @param processDefinitionKey 流程定义的key
 * @return
 */
@Transactional(propagation=Propagation.REQUIRED)
public List<Leave> findTask(String userid,String processDefinitionKey){

	//存放当前用户的所有任务
	List<Task> tasks=new ArrayList<Task>();
	
	
	List<Leave> leaves=new ArrayList<Leave>();
	
	
	//根据当前用户的id查询代办任务列表(已经签收)
	List<Task> taskAssignees = taskService.createTaskQuery().processDefinitionKey(processDefinitionKey).taskAssignee(userid).orderByTaskPriority().desc().orderByTaskCreateTime().desc().list();
	//根据当前用户id查询未签收的任务列表
	List<Task> taskCandidates = taskService.createTaskQuery().processDefinitionKey(processDefinitionKey).taskCandidateUser(userid).orderByTaskPriority().desc().orderByTaskCreateTime().desc().list();
	
	tasks.addAll(taskAssignees);//添加已签收准备执行的任务(已经分配到任务的人)
	tasks.addAll(taskCandidates);//添加还未签收的任务(任务的候选者)
	
	
	//遍历所有的任务列表,关联实体
	for (Task task : tasks) {
		String processInstanceId = task.getProcessInstanceId();
		//根据流程实例id查询流程实例
		ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
		//获取业务id
		String businessKey=processInstance.getBusinessKey();
		//查询请假实体
		Leave leave = leaveService.findById(businessKey);
		//设置属性
		leave.setTask(task);
		leave.setProcessInstance(processInstance);
		leave.setProcessInstanceId(processInstance.getId());
		leave.setProcessDefinition(getProcessDefinition(processInstance.getProcessDefinitionId()));
		
		leaves.add(leave);
	}
	
	return leaves;
}
 
Example 4
Source File: LeaveWorkflowService.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查询待办任务
 */
@Transactional(readOnly = true)
public List<Leave> findTodoTasks(String userId) {
    List<Leave> results = new ArrayList<Leave>();
    List<Task> tasks = new ArrayList<Task>();

    // 根据当前人的ID查询
    List<Task> todoList = taskService.createTaskQuery().processDefinitionKey("leave").taskAssignee(userId).active().list();

    // 根据当前人未签收的任务
    List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey("leave").taskCandidateUser(userId).active().list();

    // 合并
    tasks.addAll(todoList);
    tasks.addAll(unsignedTasks);

    // 根据流程的业务ID查询实体并关联
    for (Task task : tasks) {
        String processInstanceId = task.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        String businessKey = processInstance.getBusinessKey();
        Leave leave = leaveManager.get(new Long(businessKey));
        leave.setTask(task);
        leave.setProcessInstance(processInstance);
        String processDefinitionId = processInstance.getProcessDefinitionId();
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
        leave.setProcessDefinition(processDefinition);
        results.add(leave);
    }
    return results;
}
 
Example 5
Source File: LeaveWorkflowService.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查询待办任务
 */
@Transactional(readOnly = true)
public List<Leave> findTodoTasks(String userId) {
    List<Leave> results = new ArrayList<Leave>();
    List<Task> tasks = new ArrayList<Task>();

    // 根据当前人的ID查询
    List<Task> todoList = taskService.createTaskQuery().processDefinitionKey("leave").taskAssignee(userId).list();

    // 根据当前人未签收的任务
    List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey("leave").taskCandidateUser(userId).list();

    // 合并
    tasks.addAll(todoList);
    tasks.addAll(unsignedTasks);

    // 根据流程的业务ID查询实体并关联
    for (Task task : tasks) {
        String processInstanceId = task.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        String businessKey = processInstance.getBusinessKey();
        Leave leave = leaveManager.get(new Long(businessKey));
        leave.setTask(task);
        leave.setProcessInstance(processInstance);
        String processDefinitionId = processInstance.getProcessDefinitionId();
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
        leave.setProcessDefinition(processDefinition);
        results.add(leave);
    }
    return results;
}
 
Example 6
Source File: DocumentWorkflow.java    From maven-framework-project with MIT License 5 votes vote down vote up
/**
 * Task listener that runs when an approveDoc task is created. Sets the candidate group to the document's group.
 *
 * @param execution
 * @param task
 */
public void setAssignee(Execution execution, DelegateTask task) {
    String pId = execution.getProcessInstanceId();
    log.debug("doc being published - procId={}", pId);
    ProcessInstance pi = runtimeService.createProcessInstanceQuery().
            processInstanceId(execution.getProcessInstanceId()).singleResult();
    String docId = pi.getBusinessKey();
    Document doc = this.docSrvc.getDocument(docId);
    taskService.addCandidateGroup(task.getId(), doc.getGroupId());
}
 
Example 7
Source File: LeaveWorkflowService.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查询待办任务
 */
@Transactional(readOnly = true)
public List<Leave> findTodoTasks(String userId) {
    List<Leave> results = new ArrayList<Leave>();
    List<Task> tasks = new ArrayList<Task>();

    // 根据当前人的ID查询
    List<Task> todoList = taskService.createTaskQuery().processDefinitionKey("leave").taskAssignee(userId).active().list();

    // 根据当前人未签收的任务
    List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey("leave").taskCandidateUser(userId).active().list();

    // 合并
    tasks.addAll(todoList);
    tasks.addAll(unsignedTasks);

    // 根据流程的业务ID查询实体并关联
    for (Task task : tasks) {
        String processInstanceId = task.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        String businessKey = processInstance.getBusinessKey();
        Leave leave = leaveManager.get(new Long(businessKey));
        leave.setTask(task);
        leave.setProcessInstance(processInstance);
        String processDefinitionId = processInstance.getProcessDefinitionId();
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
        leave.setProcessDefinition(processDefinition);
        results.add(leave);
    }
    return results;
}
 
Example 8
Source File: LeaveWorkflowService.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查询待办任务
 */
@Transactional(readOnly = true)
public List<Leave> findTodoTasks(String userId) {
    List<Leave> results = new ArrayList<Leave>();
    List<Task> tasks = new ArrayList<Task>();

    // 根据当前人的ID查询
    List<Task> todoList = taskService.createTaskQuery().processDefinitionKey("leave").taskAssignee(userId).active().list();

    // 根据当前人未签收的任务
    List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey("leave").taskCandidateUser(userId).active().list();

    // 合并
    tasks.addAll(todoList);
    tasks.addAll(unsignedTasks);

    // 根据流程的业务ID查询实体并关联
    for (Task task : tasks) {
        String processInstanceId = task.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        String businessKey = processInstance.getBusinessKey();
        Leave leave = leaveManager.get(new Long(businessKey));
        leave.setTask(task);
        leave.setProcessInstance(processInstance);
        String processDefinitionId = processInstance.getProcessDefinitionId();
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
        leave.setProcessDefinition(processDefinition);
        results.add(leave);
    }
    return results;
}
 
Example 9
Source File: LeaveWorkflowService.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查询待办任务
 */
@Transactional(readOnly = true)
public List<Leave> findTodoTasks(String userId) {
    List<Leave> results = new ArrayList<Leave>();
    List<Task> tasks = new ArrayList<Task>();

    // 根据当前人的ID查询
    List<Task> todoList = taskService.createTaskQuery().processDefinitionKey("leave").taskAssignee(userId).list();

    // 根据当前人未签收的任务
    List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey("leave").taskCandidateUser(userId).list();

    // 合并
    tasks.addAll(todoList);
    tasks.addAll(unsignedTasks);

    // 根据流程的业务ID查询实体并关联
    for (Task task : tasks) {
        String processInstanceId = task.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        String businessKey = processInstance.getBusinessKey();
        Leave leave = leaveManager.get(new Long(businessKey));
        leave.setTask(task);
        leave.setProcessInstance(processInstance);
        String processDefinitionId = processInstance.getProcessDefinitionId();
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
        leave.setProcessDefinition(processDefinition);
        results.add(leave);
    }
    return results;
}
 
Example 10
Source File: LeaveWorkflowService.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查询待办任务
 */
@Transactional(readOnly = true)
public List<Leave> findTodoTasks(String userId) {
    List<Leave> results = new ArrayList<Leave>();
    List<Task> tasks = new ArrayList<Task>();

    // 根据当前人的ID查询
    List<Task> todoList = taskService.createTaskQuery().processDefinitionKey("leave").taskAssignee(userId).list();

    // 根据当前人未签收的任务
    List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey("leave").taskCandidateUser(userId).list();

    // 合并
    tasks.addAll(todoList);
    tasks.addAll(unsignedTasks);

    // 根据流程的业务ID查询实体并关联
    for (Task task : tasks) {
        String processInstanceId = task.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        String businessKey = processInstance.getBusinessKey();
        Leave leave = leaveManager.get(new Long(businessKey));
        leave.setTask(task);
        leave.setProcessInstance(processInstance);
        String processDefinitionId = processInstance.getProcessDefinitionId();
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
        leave.setProcessDefinition(processDefinition);
        results.add(leave);
    }
    return results;
}
 
Example 11
Source File: LeaveWorkflowService.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查询待办任务
 */
@Transactional(readOnly = true)
public List<Leave> findTodoTasks(String userId) {
    List<Leave> results = new ArrayList<Leave>();
    List<Task> tasks = new ArrayList<Task>();

    // 根据当前人的ID查询
    List<Task> todoList = taskService.createTaskQuery().processDefinitionKey("leave").taskAssignee(userId).list();

    // 根据当前人未签收的任务
    List<Task> unsignedTasks = taskService.createTaskQuery().processDefinitionKey("leave").taskCandidateUser(userId).list();

    // 合并
    tasks.addAll(todoList);
    tasks.addAll(unsignedTasks);

    // 根据流程的业务ID查询实体并关联
    for (Task task : tasks) {
        String processInstanceId = task.getProcessInstanceId();
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        String businessKey = processInstance.getBusinessKey();
        Leave leave = leaveManager.get(new Long(businessKey));
        leave.setTask(task);
        leave.setProcessInstance(processInstance);
        String processDefinitionId = processInstance.getProcessDefinitionId();
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
        leave.setProcessDefinition(processDefinition);
        results.add(leave);
    }
    return results;
}
 
Example 12
Source File: DocumentWorkflow.java    From maven-framework-project with MIT License 5 votes vote down vote up
public void rejected(DelegateExecution execution) {
    log.debug("doc rejected - process id: " + execution.getProcessInstanceId());
    ProcessInstance pi = runtimeService.createProcessInstanceQuery().
            processInstanceId(execution.getProcessInstanceId()).singleResult();
    String docId = pi.getBusinessKey();
    Document doc = this.docSrvc.getDocument(docId);
    Map<String, Object> vars = runtimeService.getVariables(execution.getId());
    log.debug("setting doc {} with title = {}: state set to REJECTED", doc.getId(), doc.getTitle());
    doc.setState(Document.STATE_REJECTED);
    String message = String.format("Document entitled '%s' has been rejected", doc.getTitle(), doc.getId());
    this.alertService.sendAlert(doc.getAuthor(), Alert.DANGER, message);
    this.docSrvc.updateDocument(doc);

    log.debug("document rejected: " + docId);
}
 
Example 13
Source File: LeaveWorkFlowServiceImpl.java    From maven-framework-project with MIT License 5 votes vote down vote up
/**
 * 查询运行中的流程实例
 * @param processDefinitionKey 流程定义的key
 * @return
 */
@Transactional(propagation=Propagation.REQUIRED)
public List<Leave> findRunningProcessInstaces(String processDefinitionKey){
	List<Leave> leaves=new ArrayList<Leave>();
	
	List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().processDefinitionKey(processDefinitionKey).list();
	
	//关联业务实体
	for (ProcessInstance processInstance : processInstances) {
		
		String businessKey = processInstance.getBusinessKey();
		
		Leave leave = leaveService.findById(businessKey);
		
		leave.setProcessInstance(processInstance);
		leave.setProcessInstanceId(processInstance.getId());
		leave.setProcessDefinition(getProcessDefinition(processInstance.getProcessDefinitionId()));
		
		//设置当前任务信息
		//根据流程实例id,按照任务创建时间降序排列,查询一条任务信息
		List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).orderByTaskCreateTime().desc().listPage(0, 1);
		leave.setTask(tasks.get(0));
		
		leaves.add(leave);
	}
	
	return leaves;
}
 
Example 14
Source File: DocumentWorkflow.java    From maven-framework-project with MIT License 5 votes vote down vote up
public void publish(Execution execution) {
    String pId = execution.getProcessInstanceId();
    log.debug("doc being published - procId={}", pId);
    ProcessInstance pi = runtimeService.createProcessInstanceQuery().
            processInstanceId(execution.getProcessInstanceId()).singleResult();
    String docId = pi.getBusinessKey();
    Document doc = this.docSrvc.getDocument(docId);
    doc.setState(Document.STATE_PUBLISHED);
    String message = String.format("Document entitled '%s' has been successfully published ", doc.getTitle());
    this.alertService.sendAlert(doc.getAuthor(), Alert.SUCCESS, message);
    this.docSrvc.updateDocument(doc);
}
 
Example 15
Source File: LeaveModifyProcessor.java    From Shop-for-JavaWeb with MIT License 5 votes vote down vote up
public void notify(DelegateTask delegateTask) {
	String processInstanceId = delegateTask.getProcessInstanceId();
	ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
	Leave leave = new Leave(processInstance.getBusinessKey());
	leave.setLeaveType((String) delegateTask.getVariable("leaveType"));
	leave.setStartTime((Date) delegateTask.getVariable("startTime"));
	leave.setEndTime((Date) delegateTask.getVariable("endTime"));
	leave.setReason((String) delegateTask.getVariable("reason"));
	leave.preUpdate();
	leaveDao.update(leave);
}
 
Example 16
Source File: Act.java    From Shop-for-JavaWeb with MIT License 5 votes vote down vote up
public void setProcIns(ProcessInstance procIns) {
	this.procIns = procIns;
	if (procIns != null && procIns.getBusinessKey() != null){
		String[] ss = procIns.getBusinessKey().split(":");
		setBusinessTable(ss[0]);
		setBusinessId(ss[1]);
	}
}
 
Example 17
Source File: ComplaintUserInnerServiceSMOImpl.java    From MicroCommunity with Apache License 2.0 4 votes vote down vote up
/**
 * 获取用户任务
 *
 * @param user 用户信息
 */
public List<ComplaintDto> getUserTasks(@RequestBody AuditUser user) {
    TaskService taskService = processEngine.getTaskService();
    TaskQuery query = taskService.createTaskQuery().processDefinitionKey(getWorkflowDto(user.getCommunityId()));
    ;
    query.taskAssignee(user.getUserId());
    query.orderByTaskCreateTime().desc();
    List<Task> 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<>();
    Map<String, String> taskBusinessKeyMap = new HashMap<>();
    for (Task task : list) {
        String processInstanceId = task.getProcessInstanceId();
        //3.使用流程实例,查询
        ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        //4.使用流程实例对象获取BusinessKey
        String business_key = pi.getBusinessKey();
        complaintIds.add(business_key);
        taskBusinessKeyMap.put(business_key, task.getId());
    }

    if (complaintIds == null || complaintIds.size() == 0) {
        return new ArrayList<>();
    }

    //查询 投诉信息
    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);

    for (ComplaintDto tmpComplaintDto : tmpComplaintDtos) {
        tmpComplaintDto.setTaskId(taskBusinessKeyMap.get(tmpComplaintDto.getComplaintId()));
    }
    return tmpComplaintDtos;
}
 
Example 18
Source File: ResourceEntryStoreInnerServiceSMOImpl.java    From MicroCommunity with Apache License 2.0 4 votes vote down vote up
/**
     * 获取用户任务
     *
     * @param user 用户信息
     */
    public List<PurchaseApplyDto> getUserTasks(@RequestBody AuditUser user) {
        TaskService taskService = processEngine.getTaskService();
        TaskQuery query = taskService.createTaskQuery().processDefinitionKey("resourceEntry");
        query.taskAssignee(user.getUserId());
        query.orderByTaskCreateTime().desc();
        List<Task> list = null;
        if(user.getPage()  >=1){
            user.setPage(user.getPage()-1);
        }
        if (user.getPage() != PageDto.DEFAULT_PAGE) {
            list = query.listPage(user.getPage(), user.getRow());
        }else{
            list = query.list();
        }

//        List<PurchaseApplyDto> purchaseApplyDtos = new ArrayList<>();
//
//        for (Task task : list) {
//            String id = task.getId();
//            //System.out.println("tasks:" + JSONObject.toJSONString(task));
//            PurchaseApplyDto purchaseApplyDto = (PurchaseApplyDto) taskService.getVariable(id, "purchaseApplyDto");
//            purchaseApplyDto.setTaskId(id);
//            purchaseApplyDto.setProcessInstanceId(task.getProcessInstanceId());
//            purchaseApplyDtos.add(purchaseApplyDto);
//        }
//        return purchaseApplyDtos;

        List<String> applyOrderIds = new ArrayList<>();
        Map<String, String> taskBusinessKeyMap = new HashMap<>();
        for (Task task : list) {
            String processInstanceId = task.getProcessInstanceId();
            //3.使用流程实例,查询
            ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
            //4.使用流程实例对象获取BusinessKey
            String business_key = pi.getBusinessKey();
            applyOrderIds.add(business_key);
            taskBusinessKeyMap.put(business_key, task.getId());
        }

        if (applyOrderIds == null || applyOrderIds.size() == 0) {
            return new ArrayList<>();
        }

        //查询 投诉信息
        PurchaseApplyDto purchaseApplyDto = new PurchaseApplyDto();
        purchaseApplyDto.setStoreId(user.getStoreId());
        purchaseApplyDto.setApplyOrderIds(applyOrderIds.toArray(new String[applyOrderIds.size()]));
        List<PurchaseApplyDto> tmpPurchaseApplyDtos = purchaseApplyInnerServiceSMOImpl.queryPurchaseApplyAndDetails(purchaseApplyDto);

        for (PurchaseApplyDto tmpPurchaseApplyDto : tmpPurchaseApplyDtos) {
            tmpPurchaseApplyDto.setTaskId(taskBusinessKeyMap.get(tmpPurchaseApplyDto.getApplyOrderId()));
        }
        return tmpPurchaseApplyDtos;
    }
 
Example 19
Source File: PurchaseApplyUserInnerServiceSMOImpl.java    From MicroCommunity with Apache License 2.0 4 votes vote down vote up
/**
     * 获取用户任务
     *
     * @param user 用户信息
     */
    public List<PurchaseApplyDto> getUserTasks(@RequestBody AuditUser user) {
        TaskService taskService = processEngine.getTaskService();
        TaskQuery query = taskService.createTaskQuery().processDefinitionKey("resourceEnter");
        ;
        query.taskAssignee(user.getUserId());
        query.orderByTaskCreateTime().desc();
        List<Task> 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<>();
        Map<String, String> taskBusinessKeyMap = new HashMap<>();
        for (Task task : list) {
            String processInstanceId = task.getProcessInstanceId();
            //3.使用流程实例,查询
            ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
            //4.使用流程实例对象获取BusinessKey
            String business_key = pi.getBusinessKey();
            complaintIds.add(business_key);
            taskBusinessKeyMap.put(business_key, task.getId());
        }

        if (complaintIds == null || complaintIds.size() == 0) {
            return new ArrayList<>();
        }

        //查询 投诉信息
        PurchaseApplyDto purchaseApplyDto = new PurchaseApplyDto();
        List<PurchaseApplyDto> purchaseApplyDtos = new ArrayList<>();

//        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);
//
//        for (ComplaintDto tmpComplaintDto : tmpComplaintDtos) {
//            tmpComplaintDto.setTaskId(taskBusinessKeyMap.get(tmpComplaintDto.getComplaintId()));
//        }
        return purchaseApplyDtos;
    }
 
Example 20
Source File: BusinessKeyProducer.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Produces
@Named
@BusinessKey
public String businessKey(ProcessInstance processInstance) {
  return processInstance.getBusinessKey();
}