package com.sundot.airport.common.statistics;

import lombok.Data;

import java.math.BigDecimal;
import java.util.Map;

/**
 * 指标计算结果
 */
@Data
public class IndicatorCalculationResult {

    /**
     * 指标类型
     */
    private String indicatorType;

    /**
     * 指标名称
     */
    private String indicatorName;

    /**
     * 指标值
     */
    private BigDecimal value;

    /**
     * 环比值
     */
    private String chainRatioValue;

    /**
     * 同比值
     */
    private String yearOnYearValue;

    /**
     * 基准值（用于环比、同比计算的参考值）
     */
    private BigDecimal baselineValue;

    /**
     * 时间维度信息
     */
    private String timeDimensionInfo;

    /**
     * 额外信息
     */
    private Map<String, Object> extraInfo;

    /**
     * 计算状态
     */
    private String status;


    /**
     * 错误信息
     */
    private String errorMessage;

    public static IndicatorCalculationResult success(BigDecimal value) {
        IndicatorCalculationResult result = new IndicatorCalculationResult();
        result.setValue(value);
        result.setStatus("SUCCESS");
        return result;
    }

    public static IndicatorCalculationResult success(BigDecimal value, String chainRatioValue, String yearOnYearValue) {
        IndicatorCalculationResult result = success(value);
        result.setChainRatioValue(chainRatioValue);
        result.setYearOnYearValue(yearOnYearValue);
        return result;
    }

    public static IndicatorCalculationResult error(String errorMessage) {
        IndicatorCalculationResult result = new IndicatorCalculationResult();
        result.setErrorMessage(errorMessage);
        result.setStatus("ERROR");
        return result;
    }
}