package nc.ui.wa.ref;

import nc.bs.logging.Logger;
import nc.hr.utils.ResHelper;
import nc.ui.bd.ref.AbstractRefModel;
import nc.vo.pub.BusinessException;
import nc.vo.util.VisibleUtil;
import nc.vo.wa.grade.WaGradeVO;

import nccloud.commons.lang.StringUtils;
/**
 * 薪资类别标准参照模型
 *
 * @author: xuhw
 * @date: 2009-11-17 下午12:56:56
 * @since: eHR V6.0
 * @走查人:
 * @走查日期:
 * @修改人:
 * @修改日期:
 */
public class WaGradeExRefModel extends AbstractRefModel
{
	/**
	 * 薪资标准类别
	 */
	public final static String WA_GRADE_BEAN_ID = "92054d71-866d-4d82-9085-75ad2f63d4c1";
	/**
	 * 薪资项目
	 */
	private String strPkItem;

	public WaGradeExRefModel(String pk_item, String strPKOrg)
	{
		super();
		this.setTableName(" wa_grade ");
		this.setFieldCode(new String[]
		{ "code", "name", "vmemo" });
		this.setFieldName(new String[]
		{ ResHelper.getString("6013commonbasic","06013commonbasic0043")/*@res "薪资标准类别编码"*/, ResHelper.getString("6013commonbasic","06013commonbasic0044")/*@res "薪资标准类别名称"*/, ResHelper.getString("common","UC000-0003660")/*@res "说明"*/ });
		this.setPkFieldCode("pk_wa_grd");
		this.setHiddenFieldCode(new String[]
		{ "pk_wa_grd", "pk_group", "pk_org", "ismultsec" ,WaGradeVO.ISRANGE});
		this.setDefaultFieldCount(4);
		this.setRefTitle(ResHelper.getString("6013commonbasic","06013commonbasic0045")/*@res "薪资类别标准"*/);
		this.setStrPkItem(pk_item);
		setRefCodeField("name");
		setRefNameField("name");
//		begin 20150723 xiejie3 参照的缓存键值是用bd_refinfo表的name字段值，目前很多参照的refModel中没有设置RefNodeName的值
		setRefNodeName("薪资标准"); /*-=notranslate=-*/
//		end
	}

	public WaGradeExRefModel()
	{
		super();
		this.setTableName(" wa_grade ");
		this.setFieldCode(new String[]
		{ "code", "name", "vmemo" });
		this.setFieldName(new String[]
	    // 2015-09-06 zhousze 解决公共薪资项目、薪资发放项目参照薪资标准表时，表头显示主键问题，主要是多语路径错误，
	    // 不能有空格 begin
		{ ResHelper.getString("6013commonbasic","06013commonbasic0043")/*@res "薪资标准类别编码"*/, ResHelper.getString("6013commonbasic","06013commonbasic0044")/*@res "薪资标准类别名称"*/, ResHelper.getString("common","UC000-0003660")/*@res "说明"*/ });
		// 2015-09-06 zhousze 解决公共薪资项目、薪资发放项目参照薪资标准表时，表头显示主键问题，主要是多语路径错误，
		// 不能有空格 end
		this.setPkFieldCode("pk_wa_grd");
		this.setHiddenFieldCode(new String[]
		{ "pk_wa_grd", "pk_group", "pk_org", "ismultsec",WaGradeVO.ISRANGE });
		this.setDefaultFieldCount(3);
		this.setRefTitle(ResHelper.getString("6013commonbasic","06013commonbasic0045")/*@res "薪资类别标准"*/);
		setRefCodeField("name");
		setRefNameField("name");
//		begin 20150723 xiejie3 参照的缓存键值是用bd_refinfo表的name字段值，目前很多参照的refModel中没有设置RefNodeName的值
		setRefNodeName("薪资标准"); /*-=notranslate=-*/
//		end
		
	}

	/**
	 * 拼写sql<BR>
	 * 和5系列相比去掉了<BR>
	 * 和币种相关的过滤<BR>
	 * bd_currtype.dr=0 and wa_grade.pk_currtype = bd_currtype.pk_currtype
	 *
	 * @author xuhw on 2009-11-20
	 * @see nc.ui.bd.ref.AbstractRefModel#getEnvWherePart()
	 */
	@Override
	protected String getEnvWherePart()
	{
		StringBuffer sbWhere = new StringBuffer();

		sbWhere.append(" wa_grade.pk_wa_grd in (select pk_wa_grd from wa_grade_ver where effect_flag = 'Y') and wa_grade.standard_type = 1");
		
		if (!StringUtils.isBlank(getStrPkItem()))
		{
			sbWhere.append(" wa_grade.pk_wa_item = '" + getStrPkItem() + "' and ");
		}
		
		

		try
		{
			return sbWhere.toString() + " " + VisibleUtil.getRefVisibleCondition(getPk_group(), getPk_org(), WA_GRADE_BEAN_ID) + "";
		}
		catch (BusinessException e)
		{
			Logger.error(e.getMessage(), e);
		}

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

	}

	public String getStrPkItem()
	{
		return strPkItem;
	}

	public void setStrPkItem(String strPkItem)
	{
		this.strPkItem = strPkItem;
	}
}