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

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 物品信息表(用于建立物料搜索索引)
 * 
 * @author hejq
 * 
 */
@Entity
@Table(name = "PRODUCTS")
public class ProdSimpleInfo {

	public static final String TABLE_NAME = "PRODUCTS";

	/**
	 * 公用
	 */
	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 STANDARD_FIELD = "pr_standard";

	public static final String MATCHESTAUTS_FIELD = "pr_matchstatus";

	public static final String MATCHESIZE_FIELD = "pr_matchsize";

	public static final String B2BENABLED_FIELD = "pr_b2benabled";


	/**
	 * 标准属性
	 */
	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 UUID_FIELD = "pr_cmpuuid";

	/**
	 * 非标准数据
	 */
	public static final String TITLE_FIELD = "pr_title";

	public static final String SPEC_FIELD = "pr_spec";

	public static final String BRAND_FIELD = "pr_brand";

	public static final String CMPCODE_FIELD = "pr_cmpcode";

	/**
	 * 开票参数
	 */
	public static final String NOVER_FIELD = "pr_goodsnover";

	public static final String TAXNO_FIELD = "pr_goodstaxno";

	public static final String TAXPRE_FIELD = "pr_taxpre";

	public static final String TAXPRECON_FIELD = "pr_taxprecon";


	@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 = TITLE_FIELD)
	private String prodTitle;

	/**
	 * 物料规格
	 */
	@Column(name = SPEC_FIELD)
	private String prodSpec;

	/**
	 * 物料品牌
	 */
	@Column(name = BRAND_FIELD)
	private String brand;

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

	/**
	 * 是否禁用
	 */
	@Column(name = B2BENABLED_FIELD)
	private Short b2benabled;

	/**
	 * 是否可买<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;

	/**
	 * 原厂型号
	 * 
	 */
	@Column(name = CMPCODE_FIELD)
	private String cmpCode;

	/**
	 * 是否标准器件（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;

	/**
	 * 编码版本号
	 */
	@Column(name = NOVER_FIELD)
	private String goodsnover;

	/**
	 * 税收分类编码
	 */
	@Column(name = TAXNO_FIELD)
	private String goodstaxno;

	/**
	 * 是否享受优惠政策
	 */
	@Column(name = TAXPRE_FIELD)
	private String taxpre;

	/**
	 * 享受优惠政策内容
	 */
	@Column(name = TAXPRECON_FIELD)
	private String taxprecon;

	public Long getId() {
		return id;
	}

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

	public Short getStandard() {
		return standard;
	}

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

	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 String getProdTitle() {
		return prodTitle;
	}

	public void setProdTitle(String prodTitle) {
		this.prodTitle = prodTitle;
	}

	public String getProdSpec() {
		return prodSpec;
	}

	public void setProdSpec(String prodSpec) {
		this.prodSpec = prodSpec;
	}

	public String getBrand() {
		return brand;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}

	public Short getIssale() {
		return issale;
	}

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

	public Short getB2benabled() {
		return b2benabled;
	}

	public void setB2benabled(Short b2benabled) {
		this.b2benabled = b2benabled;
	}

	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 String getCmpCode() {
		return cmpCode;
	}

	public void setCmpCode(String cmpCode) {
		this.cmpCode = cmpCode;
	}

	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;
	}

	public String getGoodsnover() {
		return goodsnover;
	}

	public void setGoodsnover(String goodsnover) {
		this.goodsnover = goodsnover;
	}

	public String getGoodstaxno() {
		return goodstaxno;
	}

	public void setGoodstaxno(String goodstaxno) {
		this.goodstaxno = goodstaxno;
	}

	public String getTaxpre() {
		return taxpre;
	}

	public void setTaxpre(String taxpre) {
		this.taxpre = taxpre;
	}

	public String getTaxprecon() {
		return taxprecon;
	}

	public void setTaxprecon(String taxprecon) {
		this.taxprecon = taxprecon;
	}

	/**
	 * 获取所有可以搜索的字段列名（索引的field名）
	 * 
	 * @return 可以搜索的字段列名
	 */
	public static List<String> getKeywordFields() {
		List<String> fields = new ArrayList<>();
		fields.add(CODE_FIELD);
		fields.add(ENTERPRISE_FIELD);
		fields.add(TITLE_FIELD);
		fields.add(SPEC_FIELD);
		fields.add(BRAND_FIELD);
		fields.add(CMPCODE_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 "ProdSimpleInfo [id=" + id + ", enterprise=" + enterprise + ", prodCode=" + prodCode + ", prodTitle="
				+ prodTitle + ", prodSpec=" + prodSpec + ", brand=" + brand + ", issale=" + issale + ", isPurchase="
				+ isPurchase + ", isShow=" + isShow + ", isPubsale=" + isPubsale + ", uuid=" + uuid + ", cmpCode="
				+ cmpCode + ", standard=" + standard + ", matchstatus=" + matchstatus + ", kind=" + kind + ", kinden="
				+ kinden + ", pcmpcode=" + pcmpcode + ", pbrand=" + pbrand + ", pbranden=" + pbranden + ", matchsize="
				+ matchsize + ", b2benabled=" + b2benabled + "]";
	}

}
