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

import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import com.fasterxml.jackson.annotation.JsonFormat;
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: Crish
 * @CreateDate:2019-04-16-17:36
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "MES_PLAN_ORDER", indexes = {@Index(columnList = "ORDER_NO")
}, uniqueConstraints = {
        @UniqueConstraint(columnNames = {"ORGANIZE_CODE", "ORDER_NO"})
    }
)
@Api("生产主计划")
public class MesPlanOrder extends BaseBean implements Serializable {
    private static final long serialVersionUID = 8571104279843276872L;
    @Column(name = "ORDER_NO", nullable = false)
    @ApiParam("生产计划单号")
    private String orderNo;

    @Column(name = "PO_TYPE")
    @ApiParam("计划类型")
    private Integer planType;

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

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

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

    @Column(name = "PLAN_QTY")
    @ApiParam("计划数量")
    private Double planQty;

    @Column(name = "DECOMPOSE_QTY")
    @ApiParam("分解数量")
    private Double decomposeQty;

    @Column(name = "STATUS")
    @ApiParam("状态")
    private Integer status;

    @Column(name = "START_TIME")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiParam("计划开始时间")
    private String startTime;

    @Column(name = "END_TIME")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiParam("计划结束时间")
    private String endTime;

    @Column(name = "DELIVERY_DATE")
    @ApiParam("交货日期")
    private String deliveryDate;

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

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

    @Column(name = "SOURCE")
    @ApiParam("计划来源")
    private String source;

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

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

    /**********************  冗余字段 *********************************/

    @Transient
    @ApiParam(value = "区域")
    public String areaCode;

    @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 getPlanQtyVal() {
        return this.planQty == null ? 0.0d : this.planQty;
    }

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

    public int getStatusVal() {
        return this.status == null ? 0 : this.status;
    }

    public int getPlanTypeVal() {
        return this.planType == null ? 0 : this.planType;
    }
}
