package com.sw.mes.yb.accessory.entity;

import com.sw.mes.base.factory.init.entity.Equipment;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.util.Date;

/**
 * 辅料更换申请
 */
@Data
@Entity
@Table(name = "zhxx_accessory_apply")
@DynamicUpdate
@DynamicInsert
public class AccessoryApply {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 热场监控信息
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "accessory_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private EquipmentAccessory equipmentAccessory;

    /**
     * 辅料信息
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "material_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private AccessoryMaterial material;

    /**
     * 设备
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "equipment_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private Equipment equipment;

    /**
     * 辅料申请反馈
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "feedback_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private AccessoryApplyFeedback accessoryApplyFeedback;

    /**
     * 申请人
     */
    @Column(length = 50)
    private String applyUser;

    /**
     * 申请人工号
     */
    @Column(length = 50)
    private String applyUserNo;

    /**
     * 申请时间
     */
    @Column(length = 19)
    @Temporal(TemporalType.TIMESTAMP)
    private Date applyDate;

    /**
     * 状态更新时间
     */
    @Column(length = 19)
    @Temporal(TemporalType.TIMESTAMP)
    private Date stateDate;

    /**
     * 状态
     */
    @Column(length = 50)
    private String state;

    /**
     * 热场条码（唯一）
     */
    @Column
    private String goodsCode;

    /**
     * 申请原因
     */
    @Column(length = 255)
    private String reason;

    /**
     * 领料单号
     */
    @Column(length=50)
    private String pickNo;

    /**
     * 数量
     */
    @Column(length = 11)
    private Integer num;

    /**
     * 出库地点
     */
    @Column(length = 11)
    private String lgort;

    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "spare_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private AccessorySpare accessorySpare;


    /**
     * 班次
     */
    @Column
    private String userClassNo;

    /**
     * 班组
     */
    @Column
    private String userTeamGroup;
}
