package cn.estsh.i3plus.ext.mes.pcn.pojo.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.ColumnDefault;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Map;

/**
 * @PROJECT_NAME: i3plus-mes-panasonic-bu
 * @DESCRIPTION: MES_产线未达成原因表
 * @USER: xinwang.yi
 * @DATE: 2023-07-22 16:06
 */
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "MES_WORK_CENTER_NOT_REACH_REASON" ,indexes = {
        @Index(columnList = "WORK_TIME,WORK_CENTER_CODE")
})
@Api("MES_产线未达成原因表")
public class MesWorkCenterNotReachReason extends BaseBean implements Serializable {

    private static final long serialVersionUID = 3987314173473333334L;
    @Column(name = "WORK_TIME")
    @ApiParam("生产日期")
    private String workTime;

    @Column(name = "WORK_CENTER_CODE")
    @ApiParam("产线代码")
    private String workCenterCode;

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

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

    @Column(name = "YIELD_RATE")
    @ApiParam("达成率")
    private Double yieldRate;

    @Transient
    @ApiParam("达成率")
    private String yieldRateStr;

    @Column(name = "COMPLETE_RATE")
    @ApiParam("完结率")
    private Double completeRate;

    @Transient
    @ApiParam("完结率")
    private String completeRateStr;

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

    @Column(name = "NOT_REACH_REASON")
    @ApiParam("未达成原因")
    private String notReachReason;

    @Column(name = "SYSTEM_SYNC_STATUS")
    @ColumnDefault("2")
    @ApiParam(value = "系统同步标志")
    public Integer systemSyncStatus = 2;

    @Transient
    @ApiParam("根据物料分组的计划完成数量")
    private Map<String, Double> planQtyMapByPartNo;

    @Transient
    @ApiParam("根据物料分组的完成数量")
    private Map<String, Double> completeQtyMapByPartNo;

    public String getYieldRateStr() {
        return yieldRate + "%";
    }

    public String getCompleteRateStr() {
        return completeRate + "%";
    }
}
