package com.smppw.modaq.domain.dto.report;

import cn.hutool.core.util.StrUtil;
import com.smppw.modaq.common.conts.Constants;
import lombok.Getter;
import lombok.Setter;

import java.io.Serial;
import java.io.Serializable;

/**
 * @author wangzaijun
 * @date 2024/9/29 9:32
 * @description 报告解析结果对象
 */
@Getter
public abstract class ReportData implements Serializable {
    @Serial
    private static final long serialVersionUID = Constants.DEFAULT_SERIAL_ID;
    /**
     * 报告路径
     */
    @Setter
    private String reportPath;
    /**
     * 报告基本信息
     */
    private final ReportBaseInfoDTO baseInfo;
    /**
     * 报告包含的基金基本新
     */
    private final ReportFundInfoDTO fundInfo;
    /**
     * 是否ai解析的结果
     */
    @Setter
    private Boolean aiParse;
    /**
     * ai解析时上传的文件的id（方便重复使用）
     */
    @Setter
    private String aiFileId;

    public ReportData(ReportBaseInfoDTO baseInfo, ReportFundInfoDTO fundInfo) {
        this.baseInfo = baseInfo;
        this.fundInfo = fundInfo;
        this.aiParse = false;
    }

    /**
     * 判断当前数据文件数据是否解析失败
     *
     * @return true-解析失败，false-解析成功
     */
    public boolean wasFailed() {
        if (this.baseInfo == null || this.fundInfo == null) {
            return true;
        }
        return StrUtil.isBlank(this.baseInfo.getReportName())
                || StrUtil.isAllBlank(this.fundInfo.getFundName(), this.fundInfo.getFundCode());
    }

    @Override
    public String toString() {
        return "baseInfo=" + baseInfo +
                ", fundInfo=" + fundInfo +
                ", aiParse=" + aiParse;
    }

    public static class DefaultReportData extends ReportData {
        public DefaultReportData() {
            this(null, null);
        }

        public DefaultReportData(ReportBaseInfoDTO baseInfo, ReportFundInfoDTO fundInfo) {
            super(baseInfo, fundInfo);
        }
    }
}
