/***********************   报表相关 *********************/
import { getUserId } from "@/services/bus/account";
import { commonSearch_go } from "@/services/go";
import {
    AreaExpourseReportReq,
    AreaSpotplReportReq,
    AreaStockReportReq,
    Ermcp3ArealSumPL,
    Ermcp3AreaSpotPLReport,
    Ermcp3AreaStockReport,
    Ermcp3ExposureContractDetail, Ermcp3ExposureFutuDetail, Ermcp3ExposureHedgeplanDetail, Ermcp3ExposureParamChLog,
    Ermcp3ExpourseReport,
    Ermcp3FinanceReport,
    Ermcp3TaFutuReDataReport,
    FinanceReportReq,
    QryAreaExpourseContractDetailReq,
    QryAreaExpourseFutuDetailReq, QryAreaExpourseHedgeplanDetailReq, QryAreaExpourseParamChLogDetailReq,
    QryAreaSumPLReq,
    QryTaFutureDataReportReq
} from "@/services/go/ermcp/report/interface";

/**
 * 查询敞口报表 /Ermcp3/QryAreaExpourseReport
 * @param req.userid
 * @param req.querytype  查询类型 1-日报表 2-周期报表 3-日报表(指定时间段[开始交易日,结束交易日]) 4-日报表明细
 */
export function qryAreaExpourseReport(req: AreaExpourseReportReq): Promise<Ermcp3ExpourseReport[]> {
    if (!req.userid) {
        req.userid = getUserId()
    }
    return commonSearch_go('/Ermcp3/QryAreaExpourseReport', req).catch((err) => {
        throw new Error(`查询敞口报表: ${err}`);
    });
}

/**
 *  查询现货报表 /Ermcp3/QryAreaSpotplReport
 */
export function QryAreaSpotplReport(req: AreaSpotplReportReq): Promise<Ermcp3AreaSpotPLReport[]> {
    if (!req.userid) {
        req.userid = getUserId()
    }
    return commonSearch_go('/Ermcp3/QryAreaSpotplReport', req).catch((err) => {
        throw new Error(`查询现货报表: ${err}`);
    });
}

/**
 * 查询库存报表 /Ermcp3/QryAreaStockReport
 * @param req
 */
export function qryAreaStockReport(req: AreaStockReportReq): Promise<Ermcp3AreaStockReport[]> {
    if (!req.userid) {
        req.userid = getUserId()
    }
    return commonSearch_go('/Ermcp3/QryAreaStockReport', req).catch((err) => {
        throw new Error(`查询库存报表: ${err}`);
    });
}

/**
 * 查询财务报表 /Ermcp3/QryFinanceReport
 * @param req
 */
export function qryFinanceReport(req: FinanceReportReq): Promise<Ermcp3FinanceReport[]> {
    if (!req.userid) {
        req.userid = getUserId()
    }
    return commonSearch_go('/Ermcp3/QryFinanceReport', req).catch((err) => {
        throw new Error(`查询财务报表: ${err}`);
    });
}

/**
 * 查询汇总损益表 /Ermcp3/QryAreaSumPL
 */
export function qryAreaSumPL(req: QryAreaSumPLReq): Promise<Ermcp3ArealSumPL[]> {
    if (!req.userid) {
        req.userid = getUserId()
    }
    return commonSearch_go('/Ermcp3/QryAreaSumPL', req).catch((err) => {
        throw new Error(`查询汇总损益表: ${err}`);
    });
}

/**
 * 查询期货报表 /Ermcp3/QryTaFutureDataReport
 */
export function qryTaFutureDataReport(req: QryTaFutureDataReportReq): Promise<Ermcp3TaFutuReDataReport[]> {
    if (!req.userid) {
        req.userid = getUserId()
    }
    return commonSearch_go('/Ermcp3/QryTaFutureDataReport', req).catch((err) => {
        throw new Error(`查询期货报表: ${err}`);
    });
}

/*****************  敞口报表明细  ********************/
/**
 * /Ermcp3/QryAreaExpourseContractDetail
 * 查询敞口合同明细(敞口报表/现货合同明细)
 * @param req
 */
export function qryAreaExpourseContractDetail(req: QryAreaExpourseContractDetailReq): Promise<Ermcp3ExposureContractDetail[]> {
    if (!req.userid) {
        req.userid = getUserId()
    }
    return commonSearch_go('/Ermcp3/QryAreaExpourseContractDetail', req).catch((err) => {
        throw new Error(`查询敞口合同明细(敞口报表/现货合同明细): ${err}`);
    });
}

/**
 * /Ermcp3/QryAreaExpourseFutuDetail
 * 查询敞口期货明细(敞口报表/期货明细)
 * @param req
 */
export function qryAreaExpourseFutuDetail(req: QryAreaExpourseFutuDetailReq): Promise<Ermcp3ExposureFutuDetail[]> {
    if (!req.userid) {
        req.userid = getUserId()
    }
    return commonSearch_go('/Ermcp3/QryAreaExpourseFutuDetail', req).catch((err) => {
        throw new Error(`查询敞口期货明细(敞口报表/期货明细): ${err}`);
    });
}

/**
 * /Ermcp3/QryAreaExpourseHedgeplanDetail
 * 查询敞口套保计划明细(敞口报表/套保计划明细)
 * @param req
 */
export function qryAreaExpourseHedgeplanDetail(req: QryAreaExpourseHedgeplanDetailReq): Promise<Ermcp3ExposureHedgeplanDetail[]> {
    if (!req.userid) {
        req.userid = getUserId()
    }
    return commonSearch_go('/Ermcp3/QryAreaExpourseHedgeplanDetail', req).catch((err) => {
        throw new Error(`查询敞口套保计划明细(敞口报表/套保计划明细): ${err}`);
    });
}

/**
 * /Ermcp3/QryAreaExpourseParamChLogDetail
 * 查询敞口参数调整明细(敞口报表/参数调整明细)
 * @param req
 */
export function qryAreaExpourseParamChLogDetail(req: QryAreaExpourseParamChLogDetailReq): Promise<Ermcp3ExposureParamChLog[]> {
    if (!req.userid) {
        req.userid = getUserId()
    }
    return commonSearch_go('/Ermcp3/QryAreaExpourseParamChLogDetail', req).catch((err) => {
        throw new Error(`查询敞口参数调整明细(敞口报表/参数调整明细): ${err}`);
    });
}

