import { wrapTreeNode } from "../../options/serveice";
import request from "../../request/request";
import requestCode from "../../request/requestCode";
import requestTest from "../../request/requestTest";

// 拿到服务区列表
export async function handleGetServerpartList(params: any) {
    const data: any = await requestCode.get('/BaseInfo/GetServerpartList', params)

    if (data.Result_Code !== 100) {
        return {
            data: [],
            current: 1,
            pageSize: 20,
            total: 0,
            success: true,
        };
    }

    return data.Result_Data.List;
}

// 拿到枚举列表
export async function getFieldEnumTree(params: any) {
    const data: any = await request.get('/FrameWork/GetFieldEnumTree', params)

    if (data.Result_Code !== 100) {
        return {
            data: [],
            current: 1,
            pageSize: 20,
            total: 0,
            success: true,
        };
    }

    return wrapTreeNode(data.Result_Data.List);
}

export async function getFieldGetFieEnumList(params: any) {
    const data: any = await request.get('/Dictionary/GetFieEnumList', params)

    if (data.Result_Code !== 100) {
        return []
    }

    return data.Result_Data.List
}


// 询问问题 调用的接口
export async function handleTranslateSentence(params: any) {
    const data: any = await requestCode.get('/Analysis/TranslateSentence', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data
}


// 拿到这个问题的配置明细
export async function handleGetANALYSISRULEDetail(params: any) {
    const data: any = await request.get('/Analysis/GetANALYSISRULEDetail', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data
}



// 拿到配置列表 多个的时候按照优先级去选择
export async function handleGetANALYSISRULEList(params: any) {
    const data: any = await request.post('/Analysis/GetANALYSISRULEList', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data.List
}


// 语义识别接口 同步接口
export async function handleSynchroSENTENCE(params: any) {
    const data: any = await request.post('/Analysis/SynchroSENTENCE', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data
}



// 实时交通数据接口
export async function handleGetBaiDuTrafficInfo(params: any) {
    const data: any = await requestCode.get('/BigData/GetBaiDuTrafficInfo', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data
}


// 营收热力
export async function handleGetMonthlySPINCAnalysis(params: any) {
    const data: any = await requestCode.get('/Revenue/GetMonthlySPINCAnalysis', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data.List
}


// 车辆归属地
export async function handleGetProvinceVehicleTreeList(params: any) {
    const data: any = await requestCode.get('/BigData/GetProvinceVehicleTreeList', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return wrapTreeNode(data.Result_Data.List)
}

// 预警类型
export async function handleGetMonthINCAnalysis(params: any) {
    const data: any = await request.get('/BusinessProject/GetAccountWarningList', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data.List
}


// 经营业态
export async function handleGetPeriodWarningList(params: any) {
    const data: any = await request.get('/BusinessProject/GetPeriodWarningList', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return wrapTreeNode(data.Result_Data.List);
}

// 经营项目列表
export async function handleGetBrandReceivables(params: any) {
    const data: any = await request.get('/BusinessProject/GetBrandReceivables', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data;
}

export async function handleGetPeriodWarningListPOST(params: any) {
    const data: any = await request.post('/BusinessProject/GetPeriodWarningList', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data.List;
}


export async function handleGetBusinessDate(params: any) {
    const data: any = await request.get('/Revenue/GetBusinessDate', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data;
}


export async function handleGetAnnualSplit(params: any) {
    const data: any = await request.get('/BusinessProject/GetAnnualSplit', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data.List;
}

export async function handleGetServerpartInfo(params: any) {
    const data: any = await requestCode.get('/BaseInfo/GetServerpartInfo', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data;
}


// 解密
export async function handleGetDecryptString(params: any) {
    const data: any = await requestCode.get('/Common/GetDecryptString', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data;
}

// 数据多一点的解密
export async function handleGetMapConfigByProvinceCode(params: any) {
    const data: any = await requestCode.get('/Analysis/GetMapConfigByProvinceCode', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data;
}



// 服务区门店的实时数据
export async function handleGetTransactionDetailList(params: any) {
    const data: any = await requestCode.get('/Revenue/GetTransactionDetailList', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data.List
}

// 该服务区附近的服务区
export async function handleGetNearServiceList(params: any) {
    const data: any = await requestTest.post('/location/search', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data.List
}


export async function handleGetGDNearServiceList(params: any) {
    const data: any = await requestTest.post('/location/searchAround', params)
    if (data.Result_Code !== 100) {
        return data
    }
    return data.Result_Data.list
}
