package cn.estsh.i3plus.ext.mes.pojo.model.bu3;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

/**
 * @DESCRIPTION:
 * @USER: wangjie
 * @DATE: 2022-11-01 15:54
 */
@Data
@ApiModel("完结率/达成率报表数据MODEL")
public class SxCompleteRateChartModel extends SxEChartsReportCommonDataModel implements Serializable {

    private static final long serialVersionUID = 6836394475639333765L;

    @ApiParam("业务标志:达成率=1, 完结率=2")
    public String flag;

    @ApiParam("无差别标志")
    public String unGroupByDate;

    @ApiParam("数据维度")
    public Integer dimension1;

    @ApiParam("物料编码")
    private String partNo;

    @ApiParam("产品类别")
    private String categoryCode3;

    @ApiParam("表字段")
    private List<SxDataModel> tableNameList;

    @ApiParam("表数据")
    private List<SxCompleteRateDetailModel> tableDataList;

    public SxCompleteRateChartModel addTableName(String field, String name) {
        if (CollectionUtils.isEmpty(this.tableNameList)) this.tableNameList = new LinkedList<>();
        this.tableNameList.add(new SxDataModel(field, name));
        return this;
    }

    public SxCompleteRateChartModel addTableData(SxCompleteRateDetailModel tableData) {
        if (CollectionUtils.isEmpty(this.tableDataList)) this.tableDataList = new LinkedList<>();
        this.tableDataList.add(tableData);
        return this;
    }

}
