package com.smppw.modaq.application.components.report.parser.ai;

import com.smppw.modaq.application.components.report.parser.ReportParserConstant;
import com.smppw.modaq.common.exception.ReportParseException;
import com.smppw.modaq.domain.dto.report.*;
import com.smppw.modaq.domain.mapper.EmailFieldMappingMapper;
import org.springframework.stereotype.Component;

/**
 * 其他格式的报告（只解析报告基本信息、基金基本信息）
 */
@Component(ReportParserConstant.PARSER_AI_OTHER)
public class AIOtherReportParser extends AbstractAIReportParser<ReportData> {
    public AIOtherReportParser(EmailFieldMappingMapper fieldMappingMapper) {
        super(fieldMappingMapper);
    }

    @Override
    protected String prompt() {
        return """
                识别文件中的基金名称、基金管理人、产品代码和报告日期，产品代码的正则表达式是`S[A-Z0-9]{5}`；
                如果无法识别就返回空字符，结果用json返回，json中不要注释
                """;
    }

    @Override
    protected boolean isSupportAIParse() {
        return true;
    }

    @Override
    protected ReportData parseExtInfoAndSetData(ReportBaseInfoDTO reportInfo,
                                                ReportFundInfoDTO fundInfo) throws ReportParseException {
//        Object contact = this.allInfoMap.get("联系人信息");
//        if (Objects.equals("存在", contact)) {
//            reportInfo.setWithContacts(true);
//        }
        return new MonthlyReportData(reportInfo, fundInfo);
    }

    @Override
    protected ReportFundInfoDTO buildFundInfo(ReportParserParams params) {
        return this.buildDto(params.getFileId(), ReportFundInfoDTO.class, this.allInfoMap);
    }
}
