package com.uas.search.console.b2b.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * 物品信息表(标准物料)
 * 
 */
@Entity
@Table(name = "PRODUCTS")
public class ProdStandardSimpleInfo {

	public static final String TABLE_NAME = "PRODUCTS_STANDARD";

	public static final String ID_FIELD = "pr_id";

	public static final String ENTERPRISE_FIELD = "pr_enuu";

	public static final String CODE_FIELD = "pr_code";

	public static final String ISSALE_FIELD = "pr_issale";

	public static final String ISPURC_FIELD = "pr_ispurchase";

	public static final String ISSHOW_FIELD = "pr_isshow";

	public static final String ISPUBSALE_FIELD = "pr_ispubsale";

	public static final String UUID_FIELD = "pr_cmpuuid";

	public static final String STANDARD_FIELD = "pr_standard";

	public static final String MATCHESTAUTS_FIELD = "pr_matchstatus";

	public static final String KIND_FIELD = "pr_kind";

	public static final String PCMPCODE_FIELD = "pr_pcmpcode";

	public static final String PBRANDEN_FIELD = "pr_pbranden";

	public static final String PBRAND_FIELD = "pr_pbrand";

	public static final String KINDEN_FIELD = "pr_kinden";

	public static final String MATCHESIZE_FIELD = "pr_matchsize";

	@Id
	@Column(name = ID_FIELD)
	private Long id;

	/**
	 * 物料所属企业UU
	 */
	@OneToOne
	@JoinColumn(name = ENTERPRISE_FIELD, insertable = false, updatable = false)
	private EnterpriseSimpleInfo enterprise;

	/**
	 * 物料编号
	 * 
	 */
	@Column(name = CODE_FIELD)
	private String prodCode;

	/**
	 * 是否可卖
	 */
	@Column(name = ISSALE_FIELD)
	private Short issale;

	/**
	 * 是否可买<br>
	 * 1. 可以买<br>
	 * 0. 不可
	 */
	@Column(name = ISPURC_FIELD)
	private Short isPurchase;

	/**
	 * 公开展示<br>
	 * 
	 * 1. 是<br>
	 * 0. 否
	 */
	@Column(name = ISSHOW_FIELD)
	private Short isShow;

	/**
	 * 公开销售 <br>
	 * 1. 是<br>
	 * 0. 否
	 */
	@Column(name = ISPUBSALE_FIELD)
	private Short isPubsale;

	/**
	 * 标准料号
	 * 
	 */
	@Column(name = UUID_FIELD)
	private String uuid;

	/**
	 * 是否标准器件（1为标准，2为非标） 根据uuid是否存在判断，数据库字段为null
	 */
	@Column(name = STANDARD_FIELD)
	private Short standard;

	/**
	 * 匹配状态，主要用于过滤匹配结果显示
	 */
	@Column(name = MATCHESTAUTS_FIELD)
	private Short matchstatus;

	/**
	 * 类目
	 */
	@Column(name = KIND_FIELD)
	private String kind;

	/**
	 * 类目（英文）
	 */
	@Column(name = KINDEN_FIELD)
	private String kinden;

	/**
	 * 原厂型号
	 */
	@Column(name = PCMPCODE_FIELD)
	private String pcmpcode;

	/**
	 * 标准品牌
	 */
	@Column(name = PBRAND_FIELD)
	private String pbrand;

	/**
	 * 标准品牌（英文）
	 */
	@Column(name = PBRANDEN_FIELD)
	private String pbranden;

	/**
	 * 每一条匹配的结果数（用作排序）
	 */
	@Column(name = MATCHESIZE_FIELD)
	private Integer matchsize;


	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public EnterpriseSimpleInfo getEnterprise() {
		return enterprise;
	}

	public void setEnterprise(EnterpriseSimpleInfo enterprise) {
		this.enterprise = enterprise;
	}

	public String getProdCode() {
		return prodCode;
	}

	public void setProdCode(String prodCode) {
		this.prodCode = prodCode;
	}

	public Short getIssale() {
		return issale;
	}

	public void setIssale(Short issale) {
		this.issale = issale;
	}

	public Short getIsPurchase() {
		return isPurchase;
	}

	public void setIsPurchase(Short isPurchase) {
		this.isPurchase = isPurchase;
	}

	public Short getIsShow() {
		return isShow;
	}

	public void setIsShow(Short isShow) {
		this.isShow = isShow;
	}

	public Short getIsPubsale() {
		return isPubsale;
	}

	public void setIsPubsale(Short isPubsale) {
		this.isPubsale = isPubsale;
	}

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public Short getStandard() {
		return (null != uuid) ? (short) 1 : (short) 0;
	}

	public void setStandard(Short standard) {
		this.standard = standard;
	}

	public Short getMatchstatus() {
		return matchstatus;
	}

	public void setMatchstatus(Short matchstatus) {
		this.matchstatus = matchstatus;
	}

	public String getKind() {
		return kind;
	}

	public void setKind(String kind) {
		this.kind = kind;
	}

	public String getKinden() {
		return kinden;
	}

	public void setKinden(String kinden) {
		this.kinden = kinden;
	}

	public String getPcmpcode() {
		return pcmpcode;
	}

	public void setPcmpcode(String pcmpcode) {
		this.pcmpcode = pcmpcode;
	}

	public String getPbrand() {
		return pbrand;
	}

	public void setPbrand(String pbrand) {
		this.pbrand = pbrand;
	}

	public String getPbranden() {
		return pbranden;
	}

	public void setPbranden(String pbranden) {
		this.pbranden = pbranden;
	}

	public Integer getMatchsize() {
		return (null != matchsize) ? matchsize : (int) 0;
	}

	public void setMatchsize(Integer matchsize) {
		this.matchsize = matchsize ;
	}

	/**
	 * 获取所有可以搜索的字段列名（索引的field名）
	 * 
	 * @return 可以搜索的字段列名
	 */
	public static List<String> getKeywordFields() {
		List<String> fields = new ArrayList<>();
		fields.add(CODE_FIELD);
		fields.add(ENTERPRISE_FIELD);
		fields.add(UUID_FIELD);
		fields.add(KIND_FIELD);
		fields.add(KINDEN_FIELD);
		fields.add(PBRAND_FIELD);
		fields.add(PBRANDEN_FIELD);
		fields.add(PCMPCODE_FIELD);
		return fields;
	}

	@Override
	public String toString() {
		return "ProdStandardSimpleInfo [id=" + id + ", enterprise=" + enterprise + ", prodCode=" + prodCode
				+ ", issale=" + issale + ", isPurchase=" + isPurchase + ", isShow=" + isShow + ", isPubsale="
				+ isPubsale + ", uuid=" + uuid + ", standard=" + standard + ", matchstatus=" + matchstatus + ", kind="
				+ kind + ", kinden=" + kinden + ", pcmpcode=" + pcmpcode + ", pbrand=" + pbrand + ", pbranden="
				+ pbranden + ", matchsize=" + matchsize + "]";
	}

}
