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.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

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

    private static final long serialVersionUID = 2839635247620984392L;

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

    @ApiParam("产品别")
    private String categoryName;

    @ApiParam("事业别")
    private String careerName;

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

    @ApiParam("行数据")
    private List<SxCategoryCompleteRateDetailModel> tableDataList;

    public SxCategoryCompleteRateModel(SxCategoryCompleteRateModel data) {
        BeanUtils.copyProperties(data, this);
    }

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

    public SxCategoryCompleteRateModel workTimeStart(String workTimeStart) {
        this.workTimeStart = workTimeStart;
        return this;
    }

    public SxCategoryCompleteRateModel workTimeEnd(String workTimeEnd) {
        this.workTimeEnd = workTimeEnd;
        return this;
    }

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

    public SxCategoryCompleteRateModel addTableData(String index, String dataName, String okrTarget, String lastYearRate, String curMonthRate, String completeResult) {
        if (CollectionUtils.isEmpty(this.tableDataList)) this.tableDataList = new ArrayList<>();
        this.tableDataList.add(new SxCategoryCompleteRateDetailModel(index, dataName, okrTarget, lastYearRate, curMonthRate, completeResult));
        return this;
    }

    @Data
    class SxCategoryCompleteRateDetailModel implements Serializable {

        private static final long serialVersionUID = -2713447512475711947L;

        private String index;
        private String dataName;
        private String okrTarget;
        private String lastYearRate;
        private String curMonthRate;
        private String completeResult;

        public SxCategoryCompleteRateDetailModel(String index, String dataName, String okrTarget, String lastYearRate, String curMonthRate, String completeResult) {
            this.index = index;
            this.dataName = dataName;
            this.okrTarget = okrTarget;
            this.lastYearRate = lastYearRate;
            this.curMonthRate = curMonthRate;
            this.completeResult = completeResult;
        }

    }

}
