package com.sw.mes.agv.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name="mobile_recharge")
public class MobileRecharge {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
	/**
	 * 物料包编码
	 */
    @Column(length=255)
    private String rechargeCode;
    
	/**
	 * 载具编号
	 */
    @Column(length=80)
    private String slingCode;

    /**
     * 复投类型
     * 初始复投、复投、断苞复投
     */
    @Column(length = 80)
    private String rechargeType;

    /**
     * 桶数
     */
    @Column
    private Integer chargeNum;
    
	/**
	 * 灌料开始时间
	 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(length=19)
	@Temporal(TemporalType.TIMESTAMP)
    private Date preRechargeTime;

    /**
     * 灌料结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(length=19)
    @Temporal(TemporalType.TIMESTAMP)
    private Date rechargeFinishTime;
    
	/**
	 * 灌料人员
	 */
    @Column(length=40)
    private String preRechargeUser;
    
	/**
	 * 灌料人员ID
	 */
    @Column(length=19)
    private Long userId;
    
	/**
	 * 物料搭配方案
	 */
    @Column(length=80)
    private String techName;
    
	/**
	 * 物料搭配方案ID
	 */
    @Column(length=19)
    private Long techId;
    
	/**
	 * 灌料重量
	 */
    @Column(length=22)
    private Double prepareCount;
    
	/**
	 * 当前重量
	 */
    @Column(length=22)
    private Double currentCount;

    /**
     * 右桶编号
     */
    @Column(length = 80)
    private String rightSlingCode;

    /**
     * 左桶重量
     */
    @Column(length=18)
    private Double leftNum;

    /**
     * 右桶重量
     */
    @Column(length=18)
    private Double rightNum;
    
	/**
	 * 备注
	 */
    @Column(length=2147483647)
    private String remark;

    @OneToMany(mappedBy = "recharge", cascade = CascadeType.ALL)
    @OrderBy("id ASC")
    private List<MobileChargeItem> list = new ArrayList<>();

    /**
     *炉台名称
     */
    @Column(length=40)
    private String deviceNo;

    /**
     * 炉次号
     */
    @Column(length=80)
    private String lotNo;

    /**
     *配料人员
     */
    @Column(length=40)
    private String mixedUser;

    /**
     *合金编号
     */
    @Column(length=80)
    private String alloyCode;

    /**
     *合金类型
     */
    @Column(length=80)
    private String alloyType;

    /**
     *合金重量
     */
    @Column(length=22)
    private Double alloyWeight;

    /**
     *合金规格
     */
    @Column(length=80)
    private String alloyNorms;

    /**
     * 合金配料时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(length=19)
    @Temporal(TemporalType.TIMESTAMP)
    private Date alloyTime;

    /**
     * 班次
     */
    @Column(length = 40)
    private String classNo;

    /**
     * 班组
     */
    @Column(length = 40)
    private String className;

    /**
     * 图片地址,分割
     */
    @Column(length = 0)
    private String imgsUrl;

    @Column
    private String backoffReason;

    @Column
    private BigDecimal backoffWeight;


    public MobileRecharge() {}

    public MobileRecharge(Long id) {
        this.id = id;
    }

}
