import request from "../utils/request";
//登陆
const login = (uname, psd, data) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/user/login?userName=${uname}&psd=${psd}`,
        method: "get",
        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 = (isLockOrUnlock,pairs,test) => {
    return request({
        baseURL:process.env.VUE_APP_API,
        url: `/api/control/send?isLockOrUnlock=${isLockOrUnlock}&test=${test}`,
        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}`,
        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:'http://18.6.30.53:8070',
        url:`/alarm/statistic?stId=${stid}&wtId=${wtid}`,
        method:"get"
    })
}
const getDetial=(data)=>{
    return request({
        baseURL:process.env.VUE_APP_API,
        url:`/api/windturbine/info/${data}`,
        method:"get"
    })
}
const getWarning=(data,wtid,pt)=>{
    return request({
        baseURL:'http://18.6.30.53:8070',
        url:`/alarm/list?stId=${data}&wtId=${wtid}&widget=${pt}`,
        method:"get"
    })
}
export default {
    login,
    getSnap,
    refreshData,
    windturbControl,
    nitWinturbineBaseData,
    getOverview,
    sendWarning,
    sendRecommend,
    getPower,
    getWindWarning,
    getHealthDate,
    getDetial,
    getWarning
};