package cn.estsh.i3plus.pojo.mes.pcn.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:
 * @Reference:
 * @Author: wangjie
 * @CreateDate:2019-09-19-17:36
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "MES_WORK_ORDER_LOG", indexes = {
        @Index(columnList = "ORDER_NO"),
        @Index(columnList = "CREATE_DATE_TIME")
})
@Api("生产工单日志")
public class MesWorkOrderLog extends BaseBean implements Serializable {
    private static final long serialVersionUID = -7018645997937147427L;

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

    @Column(name = "PART_NO")
    @ApiParam("物料号")
    private String partNo;

    @Column(name = "PART_NAME_RDD")
    @ApiParam("物料名称")
    private String partNameRdd;

    @Column(name = "PROD_CFG_CODE")
    @ApiParam("产品配置代码")
    private String prodCfgCode;

    @Column(name = "QTY")
    @ApiParam("数量")
    private Double qty;

    @Column(name = "COMPLETE_QTY")
    @ApiParam("完成数量")
    private Double completeQty;

    @Column(name = "REPAIR_QTY")
    @ApiParam("返修数量")
    private Double repairQty;

    @Column(name = "SCRAP_QTY")
    @ApiParam("报废数量")
    private Double scrapQty;

    @Column(name = "SEQ")
    @ApiParam("工单序号")
    private Double seq;

    @Column(name = "WO_STATUS")
    @ApiParam("工单状态")
    private Integer workOrderStatus;

    @Column(name = "WO_TYPE")
    @ApiParam("工单类型")
    private Integer workOrderType;

    @Column(name = "NEXT_ORDER")
    @ApiParam("下一工单")
    private String nextOrder;

    @Column(name = "PLAN_ORDER_NO")
    @ApiParam("生产计划单号")
    private String planOrderNo;

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

    @Column(name = "AREA_CODE")
    @ApiParam("区域代码")
    private String areaCode;

    @Column(name = "WORK_CELL_CODE")
    @ApiParam("工作单元代码")
    private String workCellCode;

    @Column(name = "SCHEDULE_DATE")
    @ApiParam("排产日期")
    private String scheduleDate;

    @Column(name = "CUST_PROD_LINE_CODE")
    @ApiParam("客户产线代码")
    private String custProdLineCode;

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

    @Column(name = "START_TIME")
    @ApiParam("开始时间")
    private String startTime;

    @Column(name = "END_TIME")
    @ApiParam("结束时间")
    private String endTime;

    @Column(name = "WO_SOURCE")
    @ApiParam("工单来源")
    private String workOrderSource;

    @Column(name = "MEMO")
    @ApiParam("备注")
    private String memo;

    @Column(name = "SHIFT_GROUP")
    @ApiParam("班组")
    private String shiftGroup;

    @Column(name = "APPROVAL_STATUS")
    @ApiParam("审批状态")
    private Integer approvalStatus;

    @Column(name = "CUST_CODE")
    @ApiParam("客户代码")
    private String custCode;

    @Column(name = "CUST_ORDER_NO")
    @ApiParam("客户订单号")
    private String custOrderNo;

    @Column(name = "FI_QTY")
    @ApiParam("首检数量")
    private Double fiQty;

    @Column(name = "FI_COMPLETE_QTY")
    @ApiParam("首检完成数量")
    private Double fiCompleteQty;

    @Column(name = "FI_GENERATE_QTY")
    @ApiParam("首检生成数量")
    private Double fiGenerateQty;

    /**********************  冗余字段 *********************************/
    @Transient
    @ApiParam(value = "工作中心名称")
    public String workCenterName;

    @Transient
    @ApiParam(value = "工作单元名称")
    public String workCellName;

    @Transient
    @ApiParam(value = "客户产线名称")
    public String custProdLineName;

    @Transient
    @ApiParam(value = "班次名称")
    public String shiftName;

    @Transient
    @ApiParam(value = "班组名称")
    public String shiftGroupName;

    @Transient
    @ApiParam(value = "产品配置名称")
    public String prodCfgName;

    @Transient
//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiParam(value = "计划开始日期查询用，查询开始日期", example = "2018-12-31 23:59:59")
    public String startTimeStart;


    @Transient
//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiParam(value = "计划开始日期查询用，查询截至日期", example = "2018-12-31 23:59:59")
    public String startTimeEnd;

    @Transient
//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiParam(value = "计划结束日期查询用，查询结束日期起始", example = "2018-12-31 23:59:59")
    public String endTimeStart;

    @Transient
//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiParam(value = "计划结束日期查询用，查询结束日期截至", example = "2018-12-31 23:59:59")
    public String endTimeEnd;

    public double getQtyVal() {
        return this.qty == null ? 0.0d : this.qty;
    }

    public double getCompleteQtyVal() {
        return this.completeQty == null ? 0.0d : this.completeQty;
    }

    public double getRepairQtyVal() {
        return this.repairQty == null ? 0.0d : this.repairQty;
    }

    public double getScrapQtyVal() {
        return this.scrapQty == null ? 0.0d : this.scrapQty;
    }

    public double getSeqVal() {
        return this.seq == null ? 0.0d : this.seq;
    }

    public int getWorkOrderStatusVal() {
        return this.workOrderStatus == null ? 0 : this.workOrderStatus;
    }

    public int getWorkOrderTypeVal() {
        return this.workOrderType == null ? 0 : this.workOrderType;
    }

    public int getApprovalStatusVal() {
        return this.approvalStatus == null ? 0 : this.approvalStatus;
    }
}
