package cn.estsh.i3plus.ext.mes.pojo.bean;

import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.io.Serializable;

/**
 * @Description:
 * @Author: xiangming.liao
 * @Date: 2021/01/18 15:44
 * @Modify:
 */
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "MES_ORDER_JOB", indexes = {
        @Index(columnList = "ORDER_NO")
})
@Api("MES_单据作业")
public class MesOrderJob extends BaseBean implements Serializable {

    private static final long serialVersionUID = -2297793151238705444L;

    /**
     * 作业类型： 10=准备作业，20=过程作业
     */
    @Column(name="TASK_TYPE")
    @ApiParam("作业类型")
    private Integer taskType;

    /**
     * 10=物料点检，20=人员点检，30=Q管理，40=设备点检、50=防静电点检、
     * 60=工单首检、70=4M变更、80=失败事例点检、90=特殊过程工艺参数、
     * 100=铭牌保证书一致性、110=外观防划伤点检、120=工程巡回确认、130=称重管理表
     */
    @Column(name = "ORDER_TYPE")
    @ApiParam(value = "单据类型", example = "10")
    public Integer orderType;

    /**
     * 根据编码规则产生
     */
    @Column(name="ORDER_NO")
    @ApiParam(value ="单据编号")
    private String orderNo;

    @Column(name = "WORK_CENTER_CODE")
    @ApiParam("工作中心代码")
    private String workCenterCode;

    @Column(name = "SHIFT_CODE")
    @ApiParam("班次代码")
    private String shiftCode;

    @Column(name = "WORK_ORDER_NO")
    @ApiParam("生产工单号")
    private String workOrderNo;

    /**
     * 单据状态：10=创建、20=点检中、30=点检完成、40=关闭
     */
    @Column(name="ORDER_STATUS")
    @ApiParam(value ="单据状态")
    private Integer orderStatus;

    @Column(name = "ORDER_DATE")
    @ApiParam("单据日期")
    private String orderDate;

    @Column(name = "WORK_TIME")
    @ApiParam("作业时间")
    private String workTime;

    @Column(name = "GENERATE_TIME")
    @ApiParam("生成时间")
    private String generateTime;

    @Column(name = "COMPLATE_TIME")
    @ApiParam("完成时间")
    private String complateTime;

    @Transient
    @ApiParam("物料编号")
    public String partNo;

    @Transient
    @ApiParam("物料名称")
    private String partNameRdd;

    @Column(name = "CHECK_TYPE")
    @ApiParam("类型")
    private String checkType;

    @Column(name = "HANDLER_METHOD")
    @ApiParam("是否手动创建 10手动创建 20自动创建")
    private Integer handlerMethod;

    @Column(name = "SERIAL_NUMBER")
    @ApiParam("过程条码")
    private String serialNumber;

    @Lob
    @Column(name = "CELL_COLLECT")
    @ApiParam("工位集合")
    private String cellCollect;

    @Lob
    @Column(name = "CLOSE_REASON")
    @ApiParam("关闭原因")
    private String closeReason;

    @Column(name = "CLOSE_TIME")
    @ApiParam("关闭时间")
    private String closeTime;

    @Column(name = "CLOSE_USER")
    @ApiParam("关闭人")
    private String closeUser;

    @Transient
    @ApiParam("生成时间开始")
    private String generateTimeStart;

    @Transient
    @ApiParam("生成时间截止")
    private String generateTimeEnd;


    public MesOrderJob() {
    }

    public MesOrderJob(String orderNo, String workCenterCode, String workOrderNo, String partNo, String partNameRdd) {
        this.orderNo = orderNo;
        this.workCenterCode = workCenterCode;
        this.workOrderNo = workOrderNo;
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
    }

    public MesOrderJob(Integer taskType, Integer orderType, String orderNo, String workCenterCode, String shiftCode, String workOrderNo, Integer orderStatus, String orderDate, String generateTime, String complateTime) {
        this.taskType = taskType;
        this.orderType = orderType;
        this.orderNo = orderNo;
        this.workCenterCode = workCenterCode;
        this.shiftCode = shiftCode;
        this.workOrderNo = workOrderNo;
        this.orderStatus = orderStatus;
        this.orderDate = orderDate;
        this.generateTime = generateTime;
        this.complateTime = complateTime;
    }

    public MesOrderJob(Integer taskType, Integer orderType, String orderNo, String workCenterCode, String shiftCode, String workOrderNo, Integer orderStatus, String orderDate, String workTime, String generateTime, String complateTime, String partNo, String partNameRdd) {
        this.taskType = taskType;
        this.orderType = orderType;
        this.orderNo = orderNo;
        this.workCenterCode = workCenterCode;
        this.shiftCode = shiftCode;
        this.workOrderNo = workOrderNo;
        this.orderStatus = orderStatus;
        this.orderDate = orderDate;
        this.workTime = workTime;
        this.generateTime = generateTime;
        this.complateTime = complateTime;
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
    }
}
