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.util.Date;

@Data
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "monitor_equipment_recharge")
public class MonitorEquipmentRecharge {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 设备名称
     */
    @Column(length = 40)
    private String name;

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

    /**
     * 搭配方案
     */
    @Column(length = 80)
    private String techBom;

    /**
     * 物料信息详情
     */
    @Column
    private String techBomItem;

    /**
     * 预计复投时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(length = 19)
    @Temporal(TemporalType.TIMESTAMP)
    private Date preSlingTime;

    /**
     * 复投开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(length = 19)
    @Temporal(TemporalType.TIMESTAMP)
    private Date startSlingTime;

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

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

    /**
     * 当前复投状态
     */
    @Column(length = 40)
    private String slingState;

    /**
     * 设备状态
     */
    @Column(length = 40)
    private String equipmentState;

    /**
     * 复投桶数-呼叫桶数
     */
    @Column(length = 10)
    private Integer rechargeNum;

    /**
     * 复投重量-呼叫重量
     */
    @Column
    private Double rechargeWeight;

    /**
     * 已备料桶数-灌料桶数
     */
    @Column(length = 10)
    private Integer pareNum;

    /**
     * 已备料数量-灌料重量
     */
    @Column
    private Double pareWeight;

    /**
     * AGV调度桶数
     */
    @Column(length = 10)
    private Integer agvCallNum;

    /**
     * 剩料重量
     */
    @Column
    private Double leftWeight;

    /**
     * 初始炉内投料量
     */
    @Column
    private Double initWeight;

    /**
     * 实际复投桶数
     */
    @Column(length = 10)
    private Integer prepareNum;

    /**
     * 已复投重量-实际重量
     */
    @Column
    private Double preRechargeWeight;

    /**
     * 复投类型
     * 初始复投、复投
     */
    @Column
    private String rechargeType;

    /**
     * 库位编号
     */
    @Column(length = 40)
    private String storeCode;

    /**
     * 状态：1未调度，2已调度，3运输中，4送达，5复投中
     */
    @Column(length = 1)
    private Integer state;

    /**
     * 区域
     */
    @Column(length = 80)
    private String area;

    /**
     * 颜色
     */
    @Transient
    private String color;

    /**
     * 左桶重量
     */
    @Column
    private Double leftNum;
    /**
     * 右桶重量
     */
    @Column
    private Double rightNum;

    /**
     * 设置总重量
     */
    @Column
    private Double setNum;

    /**
     * 重量设置时间
     */
    @Column(length = 19)
    @Temporal(TemporalType.TIMESTAMP)
    private Date numTime;

    /**
     * 是否发送TaskLog信息
     */
    @Column
    private Boolean sending;

    /**
     * 满料入库送走 标识
     * 1:显示
     */
    @Column
    private Integer padSend;

    /**
     * 设置总重量
     */
    @Column
    private String mixUser;

    /**
     * 重量设置时间
     */
    @Column(length = 19)
    @Temporal(TemporalType.TIMESTAMP)
    private Date mixTime;

    /**
     * 导电型号
     */
    @Column(length = 20)
    private String pn;

    /**
     * 复投次数
     */
    @Column
    private Integer rechargeTimes;

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    public MonitorEquipmentRecharge() {
    }

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

    public void initNum() {
        this.rechargeNum = 0;
        this.rechargeWeight = 0d;
        this.pareNum = 0;
        this.pareWeight = 0d;
        this.agvCallNum = 0;
        this.prepareNum = 0;
        this.preRechargeWeight = 0d;
        this.leftNum = 0d;
        this.rightNum = 0d;
        this.setNum = 0d;
        this.leftWeight = 0d;
        this.initWeight = 0d;
        this.padSend = 0;
        this.pn = "";
        this.rechargeTimes = 0;
    }

}
