package com.jiayue.ipfcst.common.data.entity;

import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.core.annotation.Order;

import javax.persistence.*;
import javax.validation.constraints.Digits;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 组装数据时因数据不合理生成假数据的记录
 *
 * @author: xiuwei
 * @version:
 */
@Data
@Entity
public class FakeDataRecord {

	@Id
	@Order(1)
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "myid")
	@GenericGenerator(name = "myid", strategy = "com.jiayue.ipfcst.common.data.entity.id.CustomIDGenerator")
	private Integer id;


	/**
	 * 时间
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column
	private Date time;

	/**
	 * 设备编号
	 */
	@Column
	private Integer equipmentNo;

	/**
	 * 协议点描述的设备属性
	 */
	@OneToOne
	@JoinColumn(name = "equipmentAttributeId", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
	private EquipmentAttribute equipmentAttribute;

	/**
	 * 不合理数据的判定原因
	 */
	@Column()
	@Enumerated(EnumType.STRING)
	private IrrationalDataType irrationalDataType;



	/**
	 * 原始值
	 */
	@Digits(integer = 10, fraction = 2)
	@Column
	private BigDecimal originalValue = new BigDecimal(-99);



	/**
	 * 修正值
	 */
	@Digits(integer = 10, fraction = 2)
	@Column
	private BigDecimal correctionValue = new BigDecimal(-99);

	/**
	 * 不合理数据的判定原因的枚举
	 */
	public  enum IrrationalDataType{
		/**
		 * 越上限，越下限，死值，突变值, 合理的，其他原因
		 */
		OverMax,LowerMin,DeadVal,SuddenChange,Rational,Other

	}




}
