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

import cn.estsh.i3plus.ext.mes.pojo.util.MesExtEnumUtil;
import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
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.ColumnDefault;
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_Q_MANAGE_TASK_DETAIL", indexes = {
        @Index(columnList = "ORDER_NO")
})
@Api("MES_Q管理作业明细")
public class MesQManageTaskDetail extends BaseBean implements Serializable {

    private static final long serialVersionUID = -2297793151257332474L;

    @Column(name="ORDER_NO")
    @ApiParam("作业单号")
    private String orderNo;

    @Column(name = "PROCESS_CODE")
    @ApiParam(value = "工序编号")
    public String processCode;

    @Column(name="PROCESS_NAME")
    @ApiParam(value ="工序名称")
    private String processName;

    @Column(name="WORK_CELL_CODE")
    @ApiParam(value ="工位代码")
    private String workCellCode;

    @Column(name="WORK_CELL_NAME")
    @ApiParam(value ="工位名称")
    private String workCellName;

    @Column(name = "MANAGE_PROJECTS")
    @ApiParam("管理项目")
    private String manageProjects;

    @Column(name = "SCREW_TYPE")
    @ApiParam("螺钉型号")
    private String screwType;

    @Column(name = "SCREW_CUTTER_NO")
    @ApiParam("螺批刀编号")
    private String screwCutterNo;

    @Column(name = "QTY", columnDefinition = "decimal(18,8)")
    @ColumnDefault("0")
    @ApiParam(value ="打枪数量")
    private Double qty = 0d;

    @Column(name = "TIGHTENING_TORQUE")
    @ApiParam("拧紧扭矩")
    private String tighteningTorque;

    @Column(name = "MANUAL_TIGHTENING")
    @ApiParam("手动拧紧力 （该字段为点检输入值，点检输入值）")
    private String manualTightening;

    @Column(name = "IS_INTACT")
    @ApiParam("刀头是否完好")
    private String isIntact;

    @Column(name = "SPOT_CHECK_USER")
    @ApiParam("点检人员")
    private String spotCheckUser;

    @Column(name = "SPOT_CHECK_TIME")
    @ApiParam("点检时间")
    private String spotCheckTime;

    @Column(name = "TEAM_CONFIRM_USER")
    @ApiParam("班组确认人")
    private String teamConfirmUser;

    @Column(name = "TEAM_CONFIRM_TIME")
    @ApiParam("班组确认时间")
    private String teamConfirmTime;

    @Column(name = "QUALITY_CONFIRM_USER")
    @ApiParam("品质确认人")
    private String qualityConfirmUser;

    @Column(name = "QUALITY_CONFIRM_TIME")
    @ApiParam("品质确认时间")
    private String qualityConfirmTime;

    @Column(name = "IS_TEAM_CONFIRM")
    @ApiParam("是否班组确认")
    private Integer isTeamConfirm = 2;

    @Column(name = "UP_LIMIT")
    @ApiParam("上限值")
    private String upLimit;

    @Column(name = "DOWN_LIMIT")
    @ApiParam("下限值")
    private String downLimit;

    @Column(name = "CHECK_TYPE", columnDefinition = "order_check")
    @AnnoOutputColumn(refClass = MesExtEnumUtil.MES_Q_MANAGER_CHECK_TYPE.class, refForeignKey = "value", value = "description")
    @ApiParam("点检类型")
    private String checkType;

    @Transient
    @ApiParam("班组确认")
    private String isTeamConfirmName;

    @Column(name = "IS_QUALITY_CONFIRM")
    @ApiParam("是否品质确认")
    private Integer isQualityConfirm = 2;

    @Transient
    @ApiParam("品质确认")
    private String isQualityConfirmName;

    @Transient
    @ApiParam(value = "产线代码")
    public String workCenterCode;

    @Transient
    @ApiParam(value = "班次编号")
    public String shiftCode;

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

    @Transient
    @ApiParam("生产工单号")
    public String workOrderNo;

    @Transient
    @ApiParam("点检日期")
    private String spotCheckDate;

    @Transient
    @ApiParam("点检开始时间")
    public String spotCheckTimeStart;

    @Transient
    @ApiParam("点检结束时间")
    public String spotCheckTimeEnd;

    @Transient
    @ApiParam("刀头是否完好名称")
    private String isIntactName;

    @Transient
    @ApiParam("产品条码")
    private String serialNumber;

    public MesQManageTaskDetail(){}

    // EP Q管理作业查询
    public MesQManageTaskDetail(Long id, String workOrderNo, String workCenterCode, String workCellName,
                                String shiftCode, String partNo, String processName, String manageProjects,
                                String screwType, String screwCutterNo, Double qty, String tighteningTorque, String upLimit, String downLimit,
                                String manualTightening, String isIntact, String spotCheckUser, String spotCheckTime,
                                String teamConfirmUser, String teamConfirmTime, String qualityConfirmUser,
                                String qualityConfirmTime, Integer isTeamConfirm, Integer isQualityConfirm, String serialNumber) {
        this.id = id;
        this.workOrderNo = workOrderNo;
        this.workCenterCode = workCenterCode;
        this.workCellName = workCellName;
        this.shiftCode = shiftCode;
        this.partNo = partNo;
        this.processName = processName;
        this.manageProjects = manageProjects;
        this.screwType = screwType;
        this.screwCutterNo = screwCutterNo;
        this.qty = qty;
        this.tighteningTorque = tighteningTorque;
        this.upLimit = upLimit;
        this.downLimit = downLimit;
        this.manualTightening = manualTightening;
        this.isIntact = isIntact;
        this.spotCheckUser = spotCheckUser;
        this.spotCheckTime = spotCheckTime;
        this.teamConfirmUser = teamConfirmUser;
        this.teamConfirmTime = teamConfirmTime;
        this.qualityConfirmUser = qualityConfirmUser;
        this.qualityConfirmTime = qualityConfirmTime;
        this.isTeamConfirm = isTeamConfirm;
        this.isQualityConfirm = isQualityConfirm;
        this.serialNumber = serialNumber;
    }

    // BU Q管理作业查询
    public MesQManageTaskDetail(Long id, String workOrderNo, String workCenterCode, String workCellCode, String workCellName,
                                String shiftCode, String partNo, String processName, String manageProjects,
                                String screwType, String screwCutterNo, Double qty, String tighteningTorque, String upLimit, String downLimit,
                                String manualTightening, String isIntact, String spotCheckUser, String spotCheckTime,
                                String teamConfirmUser, String teamConfirmTime, String qualityConfirmUser,
                                String qualityConfirmTime, Integer isTeamConfirm, Integer isQualityConfirm, String serialNumber, String checkType) {
        this.id = id;
        this.workOrderNo = workOrderNo;
        this.workCenterCode = workCenterCode;
        this.workCellCode = workCellCode;
        this.workCellName = workCellName;
        this.shiftCode = shiftCode;
        this.partNo = partNo;
        this.processName = processName;
        this.manageProjects = manageProjects;
        this.screwType = screwType;
        this.screwCutterNo = screwCutterNo;
        this.qty = qty;
        this.tighteningTorque = tighteningTorque;
        this.upLimit = upLimit;
        this.downLimit = downLimit;
        this.manualTightening = manualTightening;
        this.isIntact = isIntact;
        this.spotCheckUser = spotCheckUser;
        this.spotCheckTime = spotCheckTime;
        this.teamConfirmUser = teamConfirmUser;
        this.teamConfirmTime = teamConfirmTime;
        this.qualityConfirmUser = qualityConfirmUser;
        this.qualityConfirmTime = qualityConfirmTime;
        this.isTeamConfirm = isTeamConfirm;
        this.isQualityConfirm = isQualityConfirm;
        this.serialNumber = serialNumber;
        this.checkType = checkType;
    }
}
