package com.blueland.bpm.engine.core.service.impl;


import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.apache.commons.lang3.StringUtils;

import com.blueland.bpm.engine.config.model.ActivityRule;
import com.blueland.bpm.engine.core.model.ActivityDefinitionModel;
import com.blueland.bpm.engine.core.model.ActivityResourceModel;
import com.blueland.bpm.engine.util.PageFieldsUtil;
import com.blueland.bpm.engine.util.WorkFlowContants;
import com.blueland.bpm.identity.model.Org;
import com.blueland.bpm.identity.model.User;

public interface ProcessDefinitionResource {
	/**
	 * 获取环节资源列表,包含人员及人员对应组织机构树(将环节绑定的人员、组织、角色拆分为人员)
	 * 
	 * @param processInstId
	 * @param processDefinitionId
	 * @param curActivityId
	 * @param destActivityId
	 * @param userId
	 * @param filterIds
	 * @return
	 */
	public List<ActivityResourceModel> getNextActivityUser(String processInstId, String processDefinitionId,
			String curActInstId, String curActivityId, String destActivityId, String userId, List<String> filterIds,
			Map conditionMap);

	/**
	 * 获取流程下一任务环节列表
	 * 
	 * @param processDefinitionId 当前流程实例ID
	 * @param activityId          当前流程环节ID
	 * @param conditionMap        表单数据集合,用于环节条件过滤
	 * @return
	 */
	public List<ActivityDefinitionModel> getNextActivity(String processDefinitionId, String activityId,
			String processInstId, Map conditionMap);

	/**
	 * 获取流程上一任务环节列表
	 * 
	 * @param processDefinitionId 当前流程实例ID
	 * @param activityId          当前流程环节ID
	 * @param conditionMap        表单数据集合,用于环节条件过滤
	 * @return
	 */
	public List<ActivityDefinitionModel> getPrevActivity(String processDefinitionId, String activityId,
			Map conditionMap);

	/**
	 * 获取环节资源列表,包含人员及人员对应组织机构树(将环节绑定的人员、组织、角色拆分为人员)
	 * 
	 * @param activityDefinitionModel
	 * @return
	 */
	public List<ActivityResourceModel> getResource(String procDefId, String actDefId);

	/**
	 * 查询环节经办人
	 * 
	 * @param rpd
	 * @param processInstId
	 * @param curActivityId
	 * @param destActivityId
	 * @return
	 */
	public List<String> findActivityReturnFormer(String processDefinitionId, String processInstId, String curActInstId,
			String prevActInstId);

	/**
	 * 计算多实例环节完成条件规则
	 * 
	 * @param procDefId
	 * @param sourceActId
	 * @param conditionMap
	 * @return
	 */
	public boolean completionConditionByMultiTask(String procDefId, String sourceActId, Map conditionMap);

	/**
	 * 通过环节线绑定的脚本规则来过滤人员
	 * @param procDefId
	 * @param sourceActId
	 * @param destinationActId
	 * @param conditionMap
	 * @return
	 */
	public Set<ActivityResourceModel> filterActivityResource(String procDefId,
			String sourceActId, String destinationActId, Map conditionMap);
	/**
	 * 根据表单数据集合与连接线绑定规则来判断是否过滤环节
	 * @param transition
	 * @param conditionMap
	 * @return
	 */
	public boolean	filterActivity(String procDefId,ActivityImpl sourceAct,ActivityImpl destinationAct,
			Map<String,Object> conditionMap) ;

}
