package com.uas.search.model;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Set;

/**
 * 器件简要信息，只用于索引的创建与查询
 * 
 * @author sunyj
 * @since 2016年7月7日 下午5:55:26
 */
@Entity
@Table(name = "product$component")
public class Component implements Serializable {

	/**
	 * 序列号
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * id
	 */
	@Id
	@Column(name = "cmp_id")
	private Long id;

	/**
	 * 器件的uuid
	 */
	@Column(name = "cmp_uuid", unique = true)
	private String uuid;

	/**
	 * 原厂型号
	 */
	@Column(name = "cmp_code")
	private String code;

	/**
	 * 类目
	 */
	@ManyToOne
	@JoinColumn(name = "cmp_kiid")
	private Kind kind;

	/**
	 * 品牌
	 */
	@ManyToOne
	@JoinColumn(name = "cmp_brid")
	private Brand brand;

	/**
	 * 以下为器件的库存交易属性，由器件对应的上架商品发生变化时，更新反应到器件
	 */

	/**
	 * 器件的库存
	 */
	@Column(name = "cmp_reserve")
	private Double reserve;

	/**
	 * 样品数量汇总
	 */
	@Column(name = "cmp_sampleqty")
	private Double sampleQty;

	/**
	 * 现货数量
	 */
	@Column(name = "cmp_originalqty")
	private Double originalQty;

	/**
	 * 呆滞库存数量
	 */
	@Column(name = "cmp_inastockqty")
	private Double inactionStockQty;

	/**
	 * 描述
	 */
	@Column(name = "cmp_description")
	private String description;

	/**
	 * 访问量
	 */
	@Column(name = "cmp_visit_count")
	private Long visitCount;

	/**
	 * 搜索次数
	 */
	@Column(name = "cmp_search_count")
	private Long searchCount;

	/**
	 * 带的属性及属性的值
	 */
	@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
	@JoinColumn(name = "pv_componentid", updatable = false, insertable = false)
	@OrderBy("detno")
	private Set<PropertyValue> properties;

	public Long getId() {
		return id;
	}

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

	public String getUuid() {
		return uuid;
	}

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

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Kind getKind() {
		return kind;
	}

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

	public Brand getBrand() {
		return brand;
	}

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

	public Double getReserve() {
		return reserve;
	}

	public void setReserve(Double reserve) {
		this.reserve = reserve;
	}

	public Double getSampleQty() {
		return sampleQty;
	}

	public void setSampleQty(Double sampleQty) {
		this.sampleQty = sampleQty;
	}

	public Double getOriginalQty() {
		return originalQty;
	}

	public void setOriginalQty(Double originalQty) {
		this.originalQty = originalQty;
	}

	public Double getInactionStockQty() {
		return inactionStockQty;
	}

	public void setInactionStockQty(Double inactionStockQty) {
		this.inactionStockQty = inactionStockQty;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Set<PropertyValue> getProperties() {
		return properties;
	}

	public void setProperties(Set<PropertyValue> properties) {
		this.properties = properties;
	}

	public Long getVisitCount() {
		return visitCount;
	}

	public void setVisitCount(Long visitCount) {
		this.visitCount = visitCount;
	}

	public Long getSearchCount() {
		return searchCount;
	}

	public void setSearchCount(Long searchCount) {
		this.searchCount = searchCount;
	}

	@Override
	public String toString() {
		return "Component{" +
				"id=" + id +
				", uuid='" + uuid + '\'' +
				", code='" + code + '\'' +
				", kind=" + kind +
				", brand=" + brand +
				", reserve=" + reserve +
				", sampleQty=" + sampleQty +
				", originalQty=" + originalQty +
				", inactionStockQty=" + inactionStockQty +
				", description='" + description + '\'' +
				", visitCount=" + visitCount +
				", searchCount=" + searchCount +
				", properties=" + properties +
				'}';
	}
}
