import request from "../utils/request";
//全部风机
const getWindturbine = () => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/windturbine/all`,
        method: "get",
    });
};
// 标题栏数据
const stationOverview = () => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/station/overview`,
        method: "get",
    });
};
//获取报警数据
const alarmFault = () => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/alarm/fault`,
        method: "get",
    });
};
//获取推荐风机信息
const recommendation = () => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/windturbine/recommendation`,
        method: "get",
    });
};
//登陆
const login = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/user/login`,
        method: "post",
        data:data,
    });
};
//获取场站
const getStation = () => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/station/info`,
        method: "get",
    });
};
//获取AGC场站
const getAGCStation = () => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/station/agc`,
        method: "get",
    });
};
//刷新报警信息
const getSnap = (data) => {
    return request({
        baseURL:process.env.VUE_APP_SHARDINGURL,
        url: `/alarm/snap/page?pagenum=${data.pagenum}&pagesize=${data.pagesize}&category1=${data.category1}&isopened=${data.isopened}&starttime=${data.starttime}&endtime=${data.endtime}&windturbineId=${data.windturbineId?data.windturbineId:''}`,
        method: "get",
    });
};
//数据刷新
const refreshData = (keys) => {
    return request({
        baseURL:process.env.VUE_APP_ADAPTERURL,
        url: `/ts/latest?keys=${keys}`,
        method: "get",
    });
};
//风机控制
const windturbControl = (pairs) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/control/`,
        method: "post",
        data:pairs
    });
};
//风机控制
const windturbControlLock = (pairs) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/control/lock`,
        method: "post",
        data:pairs
    });
};
//获取风机详情页面数据
const nitWinturbineBaseData = (data) => {
    return request({
        baseURL:process.env.VUE_APP_ADAPTERURL,
        url: `/ts/latest?thingType=${data.thingType}&thingId=${data.thingId}&uniformCodes=${data.uniformCodes}`,
        method: "get",
    });
};
const getOverview = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/windturbine/overview`,
        method: "get",
    });
};
const sendWarning = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/alarm/confirm?snapID=${data.snapID}&faultID=${data.faultID}&userName=${data.userName}`,
        method: "get",
    });
};
const sendRecommend = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `api/voice-control/addvoicetask`,
        method: "post",
        data:data
    });
};
const getPower = (data) => {
    return request({
        baseURL:process.env.VUE_APP_ADAPTERURL,
        url: `/ts/history/snap?tagName=${data.tagName}&startTs=${data.startTs}&endTs=${data.endTs}&interval=${data.interval}`,
        method: "get",
    });
};
const getOriginalPower = (data) => {
    return request({
        baseURL:process.env.VUE_APP_ADAPTERURL,
        url: `/ts/history/raw?tagName=${data.tagName}&startTs=${data.startTs}&endTs=${data.endTs}`,
        method: "get",
    });
};
const getWindturbinePower = (data) => {
    return request({
        baseURL:process.env.VUE_APP_ADAPTERURL,
        url: `/ts/history/snap?thingId=${data.thingId}&uniformCode=${data.uniformCode}&startTs=${data.startTs}&endTs=${data.endTs}&thingType=${data.thingType}&interval=${data.interval}`,
        method: "get",
    });
};
const getOriginalWindturbinePower = (data) => {
    return request({
        baseURL:process.env.VUE_APP_ADAPTERURL,
        url: `/ts/history/raw?thingId=${data.thingId}&uniformCode=${data.uniformCode}&startTs=${data.startTs}&endTs=${data.endTs}&thingType=${data.thingType}`,
        method: "get",
    });
};
const getWindWarning = (data,pageIndex,pageSize) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/alarm/real-time-alarm?objectId=${data}&pageIndex=${pageIndex}&pageSize=${pageSize}`,
        method: "get"
    });
};
const getHealthDate=(stid,wtid)=>{
    return request({
        baseURL:process.env.VUE_APP_WARNING,
        url:`/alarm/statistic?stId=${stid}&wtId=${wtid}`,
        method:"get"
    })
}
const getDetial=(data)=>{
    return request({
        baseURL:process.env.VUE_APP_API,
        url:`/api/windturbine/${data}`,
        method:"get"
    })
}
const getWarning=(data,wtid,pt)=>{
    return request({
        baseURL:process.env.VUE_APP_WARNING,
        url:`/alarm/list?stId=${data}&wtId=${wtid}&widget=${pt}`,
        method:"get"
    })
}
const getCustomerLock=()=>{
    return request({
        baseURL: process.env.VUE_APP_API,
        url:`/api/windturbine/customer-lock`,
        method:"get"
    })
}
const controlRecord = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/control-record/search?stationId=${data.stationId}&userName=${data.userName}&windturbineId=${data.windturbineId}&startTime=${data.startTime}&endTime=${data.endTime}&pageSize=${data.pageSize}&pageIndex=${data.pageIndex}`,
        method: "get",
    });
};
const getLatest = (data) => {
    return request({
        baseURL:process.env.VUE_APP_ADAPTERURL,
        url: `/ts/latest?keys=${data}`,
        method: "get",
    });
};
//获取智能模式下场站
const getControlType = () => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/station/status`,
        method: "get",
    });
};
const uodateControlType = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/station/status/update?stationid=${data.stationid}&type=${data.type}&userName=${data.userName}`,
        method: "get",
    });
};
//获取UniformCodes数据
const getUniformCodes = () => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/windturbine/uniform-code`,
        method: "get",
    });
};
const getBoostStation = () => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/station/boost-station`,
        method: "get",
    });
};
//获取风机code名称
const getWindturbineFdc = () => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/windturbine/fdc`,
        method: "get",
    });
};
const getWindturbineWarning = (data) => {
    return request({
        baseURL:process.env.VUE_APP_SHARDINGURL,
        url: `/alarm/history/page?pagenum=${data.pagenum}&pagesize=${data.pagesize}&windturbineid=${data.windturbineid?data.windturbineid:''}&starttime=${data.starttime}&endtime=${data.endtime}&keyword=${data.keyword?data.keyword:''}&stationid=${data.stationid?data.stationid:''}&category1=${data.category1?data.category1:''}`,
        method: "get",
    });
};
//获取报警历史数据
const getFaultHistory = (data) => {
    return request({
        baseURL:process.env.VUE_APP_SHARDINGURL,
        url: `/fault/history/listpage?pagenum=${data.pageIndex}&pagesize=${data.pageSize}&stationid=${data.stationid}&keyword=${data.keyword}&starttime=${data.startTime}&endtime=${data.endTime}`,
        method: "get",
    });
};

const stationCompared = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/station/compared?models=${data}`,
        method: "get",
    });
};
//温度矩阵
const temperatureInfo = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/windturbine/temperature-info?id=${data.id}&status=${data.status}&pagenum=${data.pagenum}&pagesize=${data.pagesize}`,
        method: "get",
    });
};
//获取风机故障
const alarmSnap = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/alarm/alarm-snap?windturbineId=${data.windturbineId}`,
        method: "get",
    });
};

//预警分析
const analysisDetail = (data) => {
    return request({
        baseURL:process.env.VUE_APP_WARNING,
        url: `/analysis/detail?station=${data.station}&startTs=${data.startTs}&endTs=${data.endTs}&interval=${data.interval}&wtId=${data.wtId}&name=${data.name}`,
        method: "get",
    });
};
//预警分析
const alarmCountQuery = (data) => {
    return request({
        baseURL:process.env.VUE_APP_WARNING,
        url: `/alarm/count/query/new2?stationid=${data.stationid}&startdate=${data.startdate}&enddate=${data.enddate}`,
        method: "get",
    });
};
//状态时间查询
const statusTime = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/windturbine/status-time?stationId=${data.stationid}&startTs=${data.startTs}&endTs=${data.endTs}`,
        method: "get",
    });
};

//推荐记录查询
const recommended = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `control-record/recommended?pagesize=${data.pagesize}&pagenum=${data.pagenum}&stationid=${data.stationid}&windturbineid=${data.windturbineid}`,
        method: "get",
    });
};

//状态变化查询
const statusChange = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/windturbine/status?startTs=${data.startTs}&endTs=${data.endTs}&pagesize=${data.pagesize}&pagenum=${data.pagenum}&windturbineId=${data.windturbineid}`,
        method: "get",
    });
};

//获取风场机型
const getStationModels = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/station/models?stationid=${data.stationid}`,
        method: "get",
    });
};
//获取设置查询
const getSettings = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/settings/recommendation?stationId=${data.stationId}&modelId=${data.modelId}`,
        method: "get",
    });
};
//修改设置
const updateSettings = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/settings/recommendation`,
        method: "post",
        data:data
    });
};
//恢复默认设置
const returnSetting = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/settings/recommendation/recover?stationId=${data.stationId}&modelId=${data.modelId}`,
        method: "get",
    });
};

//获取报警列表
const warningSetting = (data) => {
    return request({
        baseURL: process.env.VUE_APP_API,
        url: `/api/settings/alarminfos?stationId=${data.stationId}&modelId=${data.modelId}`,
        method: "get"
    })
}

//获取预警列表
const costumeSetting = (data) => {
    return request({
        baseURL: process.env.VUE_APP_API,
        url: `/api/settings/costume-alarminfos?stationId=${data.stationId}&modelId=${data.modelId}`,
        method: "get"
    })
}

export default {
    login,
    getStation,
    getAGCStation,
    getSnap,
    refreshData,
    windturbControl,
    windturbControlLock,
    nitWinturbineBaseData,
    getOverview,
    sendWarning,
    sendRecommend,
    getPower,
    getOriginalPower,
    getWindWarning,
    getHealthDate,
    getDetial,
    getWarning,
    getCustomerLock,
    getWindturbinePower,
    getOriginalWindturbinePower,
    controlRecord,
    getLatest,
    getControlType,
    uodateControlType,
    getUniformCodes,
    getBoostStation,
    getWindturbineFdc,
    getWindturbineWarning,
    getFaultHistory,
    stationCompared,
    temperatureInfo,
    alarmSnap,
    analysisDetail,
    alarmCountQuery,
    statusTime,
    getWindturbine,
    stationOverview,
    alarmFault,
    recommendation,
    recommended,
    statusChange,
    getStationModels,
    getSettings,
    updateSettings,
    returnSetting,
    warningSetting,
    costumeSetting,
};