package com.foreverwin.mesnac.dispatch.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import java.io.Serializable;
import java.text.MessageFormat;
import java.time.LocalDateTime;

/**
 * <p>
 * 生产日历
 * </p>
 *
 * @author syngna
 * @since 2020-08-18
 */

@TableName("Z_PRODUCTION_CALENDAR")

public class ProductionCalendar extends Model<ProductionCalendar> {

    private static final long serialVersionUID = 1L;

    private static final String PRODUCTION_CALENDAR_BO_FORMAT = "ProductionCalendarBO:{0},{1},{2}";

    /**
     * 唯一标识
     */
    @TableId(value = "HANDLE", type = IdType.INPUT)
    private String handle;
    /**
     * 站点
     */
    @TableField("SITE")
    private String site;
    /**
     * 工作中心
     */
    @TableField("WORK_CENTER")
    private String workCenter;
    /**
     * 年份
     */
    private String yearId;
    /**
     * 月份
     */
    @TableField("MONTH_ID")
    private String monthId;
    /**
     * 日期ID
     */
    @TableField("DATE_ID")
    private String dateId;
    /**
     * 默认工作时段类型
     */
    @TableField("PRODUCTION_DAY_TYPE_BO")
    private String productionDayTypeBo;
    /**
     * 创建日期
     */
    @TableField("CREATED_DATE_TIME")
    private LocalDateTime createdDateTime;
    /**
     * 更新日期
     */
    @TableField("MODIFIED_DATE_TIME")
    private LocalDateTime modifiedDateTime;
    /**
     * 创建人
     */
    @TableField("CREATOR")
    private String creator;
    /**
     * 更新人
     */
    @TableField("UPDATER")
    private String updater;

    public ProductionCalendar() {

    }

    public ProductionCalendar(String site, String workCenter, String yearId, String monthId, String dateId) {
        this.site = site;
        this.workCenter = workCenter;
        this.yearId = yearId;
        this.monthId = monthId;
        this.dateId = dateId;
        this.handle = genHandle(site, workCenter, dateId);
    }

    public String getHandle() {
        return handle;
    }

    public void setHandle(String handle) {
        this.handle = handle;
    }

    public String getSite() {
        return site;
    }

    public void setSite(String site) {
        this.site = site;
    }

    public String getWorkCenter() {
        return workCenter;
    }

    public void setWorkCenter(String workCenter) {
        this.workCenter = workCenter;
    }

    public String getYearId() {
        return yearId;
    }

    public void setYearId(String yearId) {
        this.yearId = yearId;
    }

    public String getMonthId() {
        return monthId;
    }

    public void setMonthId(String monthId) {
        this.monthId = monthId;
    }

    public String getDateId() {
        return dateId;
    }

    public void setDateId(String dateId) {
        this.dateId = dateId;
    }

    public String getProductionDayTypeBo() {
        return productionDayTypeBo;
    }

    public void setProductionDayTypeBo(String productionDayTypeBo) {
        this.productionDayTypeBo = productionDayTypeBo;
    }

    public LocalDateTime getCreatedDateTime() {
        return createdDateTime;
    }

    public void setCreatedDateTime(LocalDateTime createdDateTime) {
        this.createdDateTime = createdDateTime;
    }

    public LocalDateTime getModifiedDateTime() {
        return modifiedDateTime;
    }

    public void setModifiedDateTime(LocalDateTime modifiedDateTime) {
        this.modifiedDateTime = modifiedDateTime;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public String getUpdater() {
        return updater;
    }

    public void setUpdater(String updater) {
        this.updater = updater;
    }

    @Override
    protected Serializable pkVal() {
        return this.handle;
    }

    @Override
    public String toString() {
        return "ProductionCalendar{" +
                "handle = " + handle +
                ", site = " + site +
                ", workCenter = " + workCenter +
                ", monthId = " + monthId +
                ", dateId = " + dateId +
                ", productionDayTypeBo = " + productionDayTypeBo +
                ", createdDateTime = " + createdDateTime +
                ", modifiedDateTime = " + modifiedDateTime +
                ", creator = " + creator +
                ", updater = " + updater +
                "}";
    }

    public static String genHandle(String site, String workCenter, String dateId) {
        return MessageFormat.format( PRODUCTION_CALENDAR_BO_FORMAT, site, workCenter, dateId );
    }
}