package com.uas.search.console.model;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

/**
 * 器件简要信息，只用于索引的创建与查询
 * 
 * @author sunyj
 * @since 2016年7月7日 下午5:55:26
 */
@Entity
@Table(name = "product$component")
public class ComponentSimpleInfo 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;

	/**
	 * 类目id
	 */
	@Column(name = "cmp_kiid")
	private Long kindid;

	/**
	 * 品牌id
	 */
	@Column(name = "cmp_brid")
	private Long brandid;

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

	/**
	 * 器件的库存
	 */
	@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;

	/**
	 * 带的属性及属性的值
	 */
	@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
	@JoinColumn(name = "pv_componentid", updatable = false, insertable = false)
	@OrderBy("detno")
	private Set<PropertyValueSimpleInfo> 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 Long getKindid() {
		return kindid;
	}

	public void setKindid(Long kindid) {
		this.kindid = kindid;
	}

	public Long getBrandid() {
		return brandid;
	}

	public void setBrandid(Long brandid) {
		this.brandid = brandid;
	}

	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 Set<PropertyValueSimpleInfo> getProperties() {
		return properties;
	}

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

	@Override
	public String toString() {
		return "ComponentSimpleInfo [id=" + id + ", uuid=" + uuid + ", code=" + code + ", kindid=" + kindid
				+ ", brandid=" + brandid + ", reserve=" + reserve + ", sampleQty=" + sampleQty + ", originalQty="
				+ originalQty + ", inactionStockQty=" + inactionStockQty + ", properties=" + properties + "]";
	}

}
