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

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 JxCenterWorkingBoardBusiModel extends JxEChartsReportCommonDataModel implements Serializable {

    private static final long serialVersionUID = -3290431005501985429L;

    @ApiParam("图表数据")
    private List<List<SxDataModel>> chartDataLists;

    @ApiParam("图表数据")
    private List<SxDataModel> chartDataList;

    @ApiParam("标题")
    private String title;

    public JxCenterWorkingBoardBusiModel title(String title) {
        this.title = title;
        return this;
    }

    public JxCenterWorkingBoardBusiModel addChartData2ChartDataLists(Integer size, String key, Object value, Object value2, Object value3) {
        if (CollectionUtils.isEmpty(this.chartDataLists)) this.chartDataLists = new LinkedList<>();
        List<SxDataModel> chartDataList = (CollectionUtils.isEmpty(this.chartDataLists) || this.chartDataLists.get(this.chartDataLists.size() - 1).size() == size) ? new LinkedList<>() : this.chartDataLists.get(this.chartDataLists.size() - 1);
        chartDataList.add(new JxEChartsReportCommonDataModel.SxDataModel(key, value, value2, value3));
        this.chartDataLists.add(chartDataList.size() == 1 ? this.chartDataLists.size() : this.chartDataLists.size() - 1, chartDataList);
        return this;
    }

    public JxCenterWorkingBoardBusiModel addChartData(String key, Object value, Object value2, Object value3) {
        if (CollectionUtils.isEmpty(this.chartDataList)) this.chartDataList = new LinkedList<>();
        this.chartDataList.add(new JxEChartsReportCommonDataModel.SxDataModel(key, value, value2, value3));
        return this;
    }

    public JxCenterWorkingBoardBusiModel addChartData(String key, Object value, Object value2) {
        if (CollectionUtils.isEmpty(this.chartDataList)) this.chartDataList = new LinkedList<>();
        this.chartDataList.add(new JxEChartsReportCommonDataModel.SxDataModel(key, value, value2));
        return this;
    }

}
