package com.qmth.distributed.print.business.bean.dto;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @Description: 课程权重dto
 * @Author: CaoZixuan
 * @Date: 2024-03-01
 */
public class CourseWeightDto implements Serializable {

    @ApiModelProperty("课程目标id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long courseTargetId;

    @ApiModelProperty("课程目标名称")
    private String courseTargetName;

    @ApiModelProperty("指标点id")
    private Long obeCultureProgramRequirementId;

    @ApiModelProperty("指标点名称")
    private String obeCultureProgramRequirementName;

    @ApiModelProperty("毕业要求指标（评价依据）")
    private List<CourseDimensionDto> dimensionList;

    @ApiModelProperty("毕业要求指标（评价依据）解析字符串")
    private String dimensionStr;

    @ApiModelProperty("支撑毕业要求")
    private String degreeRequirement;

    @ApiModelProperty("目标整体权重")
    private BigDecimal totalWeight;

    @ApiModelProperty("评价方式权重详情")
    private List<CourseWeightDetailDto> evaluationList;

    public Long getCourseTargetId() {
        return courseTargetId;
    }

    public void setCourseTargetId(Long courseTargetId) {
        this.courseTargetId = courseTargetId;
    }

    public String getCourseTargetName() {
        return courseTargetName;
    }

    public void setCourseTargetName(String courseTargetName) {
        this.courseTargetName = courseTargetName;
    }

    public Long getObeCultureProgramRequirementId() {
        return obeCultureProgramRequirementId;
    }

    public void setObeCultureProgramRequirementId(Long obeCultureProgramRequirementId) {
        this.obeCultureProgramRequirementId = obeCultureProgramRequirementId;
    }

    public String getObeCultureProgramRequirementName() {
        return obeCultureProgramRequirementName;
    }

    public void setObeCultureProgramRequirementName(String obeCultureProgramRequirementName) {
        this.obeCultureProgramRequirementName = obeCultureProgramRequirementName;
    }

    public List<CourseDimensionDto> getDimensionList() {
        return dimensionList;
    }

    public void setDimensionList(List<CourseDimensionDto> dimensionList) {
        this.dimensionList = dimensionList;
    }

    public String getDimensionStr() {
        return dimensionStr;
    }

    public void setDimensionStr(String dimensionStr) {
        this.dimensionStr = dimensionStr;
    }

    public String getDegreeRequirement() {
        return degreeRequirement;
    }

    public void setDegreeRequirement(String degreeRequirement) {
        this.degreeRequirement = degreeRequirement;
    }

    public BigDecimal getTotalWeight() {
        return totalWeight;
    }

    public void setTotalWeight(BigDecimal totalWeight) {
        this.totalWeight = totalWeight;
    }

    public List<CourseWeightDetailDto> getEvaluationList() {
        return evaluationList;
    }

    public void setEvaluationList(List<CourseWeightDetailDto> evaluationList) {
        this.evaluationList = evaluationList;
    }

    // 解析指标集合
    public void analyzeDimensionStr() {
        dimensionStr = dimensionList.stream().map(e -> String.format("%s(%s)", e.getName(), e.getCode())).collect(Collectors.joining(","));
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        CourseWeightDto that = (CourseWeightDto) o;
        return courseTargetId.equals(that.courseTargetId) && obeCultureProgramRequirementId.equals(that.obeCultureProgramRequirementId) && obeCultureProgramRequirementName.equals(that.obeCultureProgramRequirementName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(courseTargetId, obeCultureProgramRequirementId, obeCultureProgramRequirementName);
    }
}
