package cn.estsh.i3plus.pojo.wms.bean;

import cn.estsh.i3plus.pojo.base.annotation.DynamicField;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
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.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * @Description : MES_生产计划主表
 * @Reference :
 * @Author : jessica.chen
 * @CreateDate : 2019-11-09 14:21
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="MES_PP_MASTER")
@Api("MES_生产计划主表")
public class MesPpMaster extends BaseBean{

    private static final long serialVersionUID = 9214639813072592726L;

    @Column(name="WROKORDER_NO")
    @ApiParam("工单号")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT, isRequire = 2)
    private String woekorderNo;

    @Column(name="PDLINE_NO")
    @ApiParam("产线代码")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.LIST, getValWay = CommonEnumUtil.DYNAMIC_FIELD_GET_WAY.OBJ,
            dataSrc = "cn.estsh.i3plus.pojo.wms.bean.WmsWorkCenter",
            searchColumnName = "workCenterCode,workCenterName", listColumnName = "workCenterCode,workCenterName", explicitColumnName = "workCenterCode")
    private String pdlineNo;

    @Column(name="PLAN_PRODUCT_TIME")
    @ApiParam("生产日期")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.DATETIME, isRequire = 2)
    private String planProductTime;

    @Column(name="SHIFT_NO")
    @ApiParam("班次代码")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.LIST,  getValWay = CommonEnumUtil.DYNAMIC_FIELD_GET_WAY.OBJ,
            dataSrc = "cn.estsh.i3plus.pojo.wms.bean.WmsShift",
            searchColumnName = "shiftNo,shiftName", listColumnName = "shiftNo,shiftName", explicitColumnName = "shiftNo")
    private String shitNo;

    @Column(name="START_PRODUCT_TIME")
    @ApiParam("开始生产时间")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.DATETIME, isRequire = 2)
    private String startProductTime;

    @Column(name="END_PRODUCT_TIME")
    @ApiParam("结束生产时间")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.DATETIME, isRequire = 2)
    private String endProductTime;

    @Column(name="ORDER_STATUS")
    @ApiParam(value = "单据状态", example = "0")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.SELECT, dataSrc = "WORK_ORDER_MASTER_STATUS")
    private Integer orderStatus = 0;

    @Column(name="SEQ")
    @ApiParam(value = "排序号", example = "0")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.NUMBER, isRequire = 2)
    private Integer seq = 0;

    @Column(name = "REMARK")
    @ApiParam("备注")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT, isRequire = 2)
    private String remark;

    @Column(name = "WORK_ORDER_PLAN_STATUS", columnDefinition = "int default 10")
    @ApiParam("工单计划状态:10-创建，20-处理中，30-已关闭")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.SELECT, dataSrc = "WORK_ORDER_PLAN_STATUS")
    private Integer workOrderPlanStatus;

    @Transient
    @ApiParam("是否要从拉动计算中扣除")
    private boolean needMinutPullQty = false;

    public Integer getOrderStatus() {
        return orderStatus == null ? 0 : this.orderStatus.intValue();
    }


}