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.math.BigDecimal;
import java.util.LinkedList;
import java.util.List;

/**
 * @DESCRIPTION:
 * @USER: wangjie
 * @DATE: 2022-11-01 15:54
 */
@Data
@ApiModel("综合能率推移分析（制造能率）报表数据MODEL")
public class SxEnergyCompositeRatePassAnalysisModel extends SxEChartsReportCommonDataModel implements Serializable {

    private static final long serialVersionUID = 4761547844313985634L;

    @ApiParam(value = "事业别代码")
    private String careerCodeArr;

    @ApiParam("产品别代码")
    private String categoryCodeArr;

    @ApiParam(value = "生产线代码")
    private String workCenterCodeArr;

    @ApiParam("事业别代码集合")
    private List<String> careerCodeList;

    @ApiParam("产品别代码集合")
    private List<String> categoryCodeList;

    @ApiParam("上下数据标志")
    public Integer flag;

    @ApiParam("头部信息")
    private List<SxDataModel> headDataList;

    @ApiParam("综合能率")
    private List<SxDataModel> compositeList;

    @ApiParam("ST能率")
    private List<SxDataModel> stList;

    @ApiParam("稼动率")
    private List<SxDataModel> utilizationList;

    @ApiParam("非作业率")
    private List<SxDataModel> nonWorkingList;

    @ApiParam("综合能率分析")
    private List<SxDataModel> compositeDataList;

    @ApiParam("ST能率分析")
    private List<SxDataModel> stDataList;

    @ApiParam("图表单位")
    private String dataUnit;

    public SxEnergyCompositeRatePassAnalysisModel careerCodeList(List<String> careerCodeList) {
        this.careerCodeList = careerCodeList;
        return this;
    }

    public SxEnergyCompositeRatePassAnalysisModel categoryCodeList(List<String> categoryCodeList) {
        this.categoryCodeList = categoryCodeList;
        return this;
    }

    public SxEnergyCompositeRatePassAnalysisModel addHeadData(String key, String value) {
        if (CollectionUtils.isEmpty(this.headDataList)) this.headDataList = new LinkedList<>();
        this.headDataList.add(new SxDataModel(key, value));
        return this;
    }

    public SxEnergyCompositeRatePassAnalysisModel addCompositeList(String key, BigDecimal value) {
        if (CollectionUtils.isEmpty(this.compositeList)) this.compositeList = new LinkedList<>();
        this.compositeList.add(new SxDataModel(key, value).valueToSort(value.doubleValue()));
        return this;
    }

    public SxEnergyCompositeRatePassAnalysisModel addStList(String key, BigDecimal value) {
        if (CollectionUtils.isEmpty(this.stList)) this.stList = new LinkedList<>();
        this.stList.add(new SxDataModel(key, value).valueToSort(value.doubleValue()));
        return this;
    }

    public SxEnergyCompositeRatePassAnalysisModel addUtilizationList(String key, BigDecimal value) {
        if (CollectionUtils.isEmpty(this.utilizationList)) this.utilizationList = new LinkedList<>();
        this.utilizationList.add(new SxDataModel(key, value).valueToSort(value.doubleValue()));
        return this;
    }

    public SxEnergyCompositeRatePassAnalysisModel addNonWorkingList(String key, BigDecimal value) {
        if (CollectionUtils.isEmpty(this.nonWorkingList)) this.nonWorkingList = new LinkedList<>();
        this.nonWorkingList.add(new SxDataModel(key, value).valueToSort(value.doubleValue()));
        return this;
    }

    public SxEnergyCompositeRatePassAnalysisModel addDataList(String key, Double value, Double value2, BigDecimal value3, BigDecimal value4, BigDecimal value5, BigDecimal value6) {
        if (CollectionUtils.isEmpty(this.compositeDataList)) this.compositeDataList = new LinkedList<>();
        if (CollectionUtils.isEmpty(this.stDataList)) this.stDataList = new LinkedList<>();
        this.compositeDataList.add(new SxDataModel(key, value, value2, value3, value5));
        this.stDataList.add(new SxDataModel(key, value, value2, value4, value6));
        return this;
    }

    public SxEnergyCompositeRatePassAnalysisModel dataUnit(String dataUnit) {
        this.dataUnit = dataUnit;
        return this;
    }

    public SxEnergyCompositeRatePassAnalysisModel sortReversedMoreList() {
        this.compositeList = sortReversedValue(this.compositeList);
        this.stList = sortReversedValue(this.stList);
        this.utilizationList = sortReversedValue(this.utilizationList);
        this.nonWorkingList = sortReversedValue(this.nonWorkingList);
        return this;
    }

}
