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

import cn.estsh.i3plus.ext.mes.pojo.util.MesExtEnumUtil;
import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
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;
import java.util.Map;

/**
 * @DESCRIPTION:
 * @USER: wangjie
 * @DATE: 2022-11-01 15:54
 */
@Data
@ApiModel("援交图表MODEL")
public class SxAssistOutAndEnterReportModel extends SxEChartsReportCommonDataModel implements Serializable {

    private static final long serialVersionUID = -1314374265515134986L;

    @ApiParam("援入援出明细项")
    private Integer assistOutAndEnterDetail;

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

    @ApiParam(value = "责任部门")
    private String ownerDepartmentArr;

    @ApiParam("影响日期开始时间(年月)")
    private String startTime;

    @ApiParam("影响日期结束时间(年月)")
    private String endTime;

    @ApiParam("影响日期开始时间(年月日)")
    private String influenceDateStart;

    @ApiParam("影响日期结束时间(年月日)")
    private String influenceDateEnd;

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

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

    @ApiParam("表数据")
    private List<Map<String, Object>> tableDataList;

    @ApiParam("月份集合")
    private List<String> monthList;

    @ApiParam("折X轴")
    private List<String> lineX;

    @ApiParam("折Y轴")
    private List<Double> lineY;

    @ApiParam("饼数据")
    private List<SxDataModel> pieDataList;

    @ApiParam("责任部门数据")
    private Map<String, String> ownerDepartmentMap;

    @ApiParam("用户登录名称")
    private String userLoginName;

    @ApiParam("责任归属")
    @AnnoOutputColumn(refClass = MesExtEnumUtil.LIABILITY_ATTRIBUTION.class, refForeignKey = "value", value = "description")
    private Integer liabilityAttribution;

    public Map<String, String> ownerDepartmentMap(Map<String, String> ownerDepartmentMap) {
        this.ownerDepartmentMap = ownerDepartmentMap;
        return ownerDepartmentMap;
    }

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

    public SxAssistOutAndEnterReportModel addMonth(String month) {
        if (CollectionUtils.isEmpty(this.monthList)) this.monthList = new LinkedList<>();
        this.monthList.add(month);
        return this;
    }

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

    public SxAssistOutAndEnterReportModel addTableData(Map<String, Object> tableDataMap) {
        if (CollectionUtils.isEmpty(this.tableDataList)) this.tableDataList = new LinkedList<>();
        this.tableDataList.add(tableDataMap);
        return this;
    }

    public SxAssistOutAndEnterReportModel addLineX(String name) {
        if (CollectionUtils.isEmpty(this.lineX)) this.lineX = new LinkedList<>();
        this.lineX.add(name);
        return this;
    }

    public SxAssistOutAndEnterReportModel addLineY(Double value) {
        if (CollectionUtils.isEmpty(this.lineY)) this.lineY = new LinkedList<>();
        this.lineY.add(value);
        return this;
    }

    public SxAssistOutAndEnterReportModel addPieData(String name, Double value, String rate) {
        if (CollectionUtils.isEmpty(this.pieDataList)) this.pieDataList = new LinkedList<>();
        this.pieDataList.add(new SxDataModel(name, value, rate));
        return this;
    }

}
