package nccloud.web.hrhi.psndoc.vo;

import java.util.Vector;

import nccloud.commons.lang.StringUtils;

import nc.ui.bd.ref.AbstractRefModel;
import nc.ui.bd.ref.RefPubUtil;
import nccloud.framework.web.container.SessionContext;

/**
 * 获取薪资变动原因参照的数据 
 * @author lenovo
 *
 */
public class DefdocRefDatas {
	
	/**
	 * 获取薪资变动原因参照的数据 
	 * @param className
	 * @return
	 */
	public Vector<Vector> getDefDocRefDatas(String pk_org, String className){
		AbstractRefModel refModeByClassName = RefPubUtil.getRefModeByClassName(className);
		refModeByClassName.setPara2("bd_defdoc");
		refModeByClassName.setTableName("bd_defdoc");
		refModeByClassName.setWherePart("  pk_defdoclist = '1002Z710000000004MO1' and enablestate=2");
		refModeByClassName.setPara1("1002Z710000000004MO1");
		refModeByClassName.setPk_org(pk_org);
		refModeByClassName.setPk_group(SessionContext.getInstance().getClientInfo().getPk_group());
		refModeByClassName.reset();
		Vector<Vector> data = refModeByClassName.getData();
		return data;
	}
	
	/**
	 * 根据主键匹配值
	 * @param datas
	 * @param pk_changecause
	 * @return
	 */
	public String matchName(Vector<Vector> datas, String pk_changecause){
		if(StringUtils.isBlank(pk_changecause) || null == datas || datas.isEmpty()){
			return "";
		}
		for(Vector vector : datas){
			String changecause = vector.get(4) + "";//变动主键
			if(pk_changecause.equals(changecause)){
				String name = vector.get(1) + "";//名称
				return name;
			}
		}
		return "";
	}
	
	/**
	 * 根据值匹配主键
	 * @param datas
	 * @param pk_changecause
	 * @return
	 */
	public String matchPkChangecause(@SuppressWarnings("rawtypes") Vector<Vector> datas, String name){
		if(StringUtils.isBlank(name) || null == datas || datas.isEmpty()){
			return "";
		}
		for(Vector vector : datas){
			String realName = vector.get(1) + "";//名称
			if(name.equals(realName)){
				String changecause = vector.get(4) + "";//变动主键
				return changecause;
			}
		}
		return "";
	}
}
