import request from "../utils/request";
//登陆
const login = (data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/user/login`,
        method: "post",
        data:data,
    });
};
//刷新报警信息
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}`,
        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",
    });
};
export default {
    login,
    getSnap,
    refreshData,
    windturbControl,
    windturbControlLock,
    nitWinturbineBaseData,
    getOverview,
    sendWarning,
    sendRecommend,
    getPower,
    getOriginalPower,
    getWindWarning,
    getHealthDate,
    getDetial,
    getWarning,
    getCustomerLock,
    getWindturbinePower,
    getOriginalWindturbinePower,
    controlRecord,
    getLatest,
};