package nc.ui.wa.ref;

import nc.hr.utils.ResHelper;
import nc.ui.bd.ref.AbstractRefModel;

import nccloud.commons.lang.StringUtils;


/**
 * 薪资类别标准 - 薪级参照
 *
 * @author: xuhw
 * @date: 2009-11-17 下午12:56:56
 * @since: eHR V6.0
 * @走查人:
 * @走查日期:
 * @修改人:
 * @修改日期:
 */
public class WaPrmlvExRefModel extends AbstractRefModel
{
	/**
	 * 薪资项目
	 */
	private String strPkGrd;

	/**
	 * 所属人力资源组织
	 * 因为在取得人力资源组织为空，所以在这里定义一个属性存储
	 */
	private String strPKOrg;
	public WaPrmlvExRefModel(String pk_grd)
	{
		super();
//		begin 20150723 xiejie3 参照的缓存键值是用bd_refinfo表的name字段值，目前很多参照的refModel中没有设置RefNodeName的值
		setRefNodeName("薪资级别"); /*-=notranslate=-*/
//		end
		this.setTableName(" wa_grade inner join wa_prmlv on wa_grade.pk_wa_grd = wa_prmlv.pk_wa_grd ");
		this.setFieldCode(new String[]{"wa_prmlv.displayindex", "wa_prmlv.levelname"});
		this.setFieldName(new String[]{ResHelper.getString("common","UC000-0001821")/*@res "序号"*/,ResHelper.getString("6013salaryadjmgt","06013salaryadjmgt0135")/*@res "薪级数值"*/});
		this.setPkFieldCode("wa_prmlv.pk_wa_prmlv");
		this.setHiddenFieldCode(new String[]{"wa_grade.pk_wa_grd","wa_prmlv.pk_wa_prmlv"});
		this.setDefaultFieldCount(2);
		this.setRefTitle(ResHelper.getString("6013salaryadjmgt","06013salaryadjmgt0136")/*@res "薪资标准薪级参照"*/);
		this.setStrPkGrd(pk_grd);
		this.setStrPKOrg(strPKOrg);
		this.setOrderPart("wa_prmlv.displayindex");
		setRefCodeField("wa_prmlv.levelname");
		setRefNameField("wa_prmlv.levelname");
		super.setMutilLangNameRef(false);
	}

	public WaPrmlvExRefModel()
	{
		super();
//		begin 20150723 xiejie3 参照的缓存键值是用bd_refinfo表的name字段值，目前很多参照的refModel中没有设置RefNodeName的值
		setRefNodeName("薪资级别"); /*-=notranslate=-*/
//		end
		this.setTableName(" wa_grade inner join wa_prmlv on wa_grade.pk_wa_grd = wa_prmlv.pk_wa_grd ");
		this.setFieldCode(new String[]{"wa_prmlv.displayindex", "wa_grade.name","wa_prmlv.levelname"});
		this.setFieldName(new String[]{ResHelper.getString("common","UC000-0001821")/*@res "序号"*/,ResHelper.getString("6013salaryadjmgt","06013salaryadjmgt0137")/*@res "薪资标准类别"*/,ResHelper.getString("6013salaryadjmgt","06013salaryadjmgt0135")/*@res "薪级数值"*/});
		this.setPkFieldCode("wa_prmlv.pk_wa_prmlv");
		this.setHiddenFieldCode(new String[]{"wa_grade.pk_wa_grd","wa_prmlv.pk_wa_prmlv"});
		this.setDefaultFieldCount(3);
		this.setRefTitle(ResHelper.getString("6013salaryadjmgt","06013salaryadjmgt0136")/*@res "薪资标准薪级参照"*/);
//		this.setStrPkGrd(pk_grd);
		this.setStrPKOrg(strPKOrg);
		this.setOrderPart("wa_grade.name,wa_prmlv.displayindex");
		setRefCodeField("wa_prmlv.levelname");
		setRefNameField("wa_prmlv.levelname");
		super.setMutilLangNameRef(false);
	}

	/**
	 * 拼写sql<BR>
	 * @author xuhw on 2009-11-20
	 * @see nc.ui.bd.ref.AbstractRefModel#getEnvWherePart()
	 */
	@Override
	protected String getEnvWherePart()
	{
		StringBuffer sbWhere = new StringBuffer();
		if (getStrPkGrd() != null)
		{
			sbWhere.append(" wa_prmlv.pK_wa_grd = '" + getStrPkGrd() +  "'  ");
		}else{
			sbWhere.append(" wa_grade.pk_group = '"+getPk_group()+"' and (wa_grade.pk_org = '"+getPk_org()+"' or wa_grade.pk_org = '"+getPk_group()+"')"
					// 2015-09-07 zhousze 修改对于薪资级别参照不生效数据，联查下面的表得出pk过滤掉就行了 begin
					+ " and wa_grade.pk_wa_grd in (select pk_wa_grd from wa_grade_ver where effect_flag = 'Y') ");
			        // end
		}

		if(StringUtils.isBlank(sbWhere.toString())){
			return null;
		}
		return sbWhere.toString();
	}

	public String getStrPKOrg()
	{
		return strPKOrg;
	}

	public void setStrPKOrg(String strPKOrg)
	{
		this.strPKOrg = strPKOrg;
	}

	public String getStrPkGrd()
	{
		return strPkGrd;
	}

	public void setStrPkGrd(String strPkGrd)
	{
		this.strPkGrd = strPkGrd;
	}

}