import request from '@/utils/request'

// 站点列表
export function getSiteInfoList({siteName, startTime, endTime, pageSize, pageNum}) {
    return request({
        url: `/ems/siteConfig/getSiteInfoList?siteName=${siteName}&startTime=${startTime}&endTime=${endTime}&pageSize=${pageSize}&pageNum=${pageNum}`,
        method: 'get'
    })
}

// 设备列表
export function getDeviceInfoList(data) {
    return request({
        url: `/ems/siteConfig/getDeviceInfoList`,
        method: 'get',
        params: data
    })
}

// 设备详情
export function getDeviceDetailInfo(id) {
    return request({
        url: `/ems/siteConfig/getDeviceDetailInfo?id=${id}`,
        method: 'get'
    })
}

// 获取所有设备类别
export function getDeviceCategory() {
    return request({
        url: `/ems/siteConfig/getDeviceCategory`,
        method: 'get'
    })
}

// 新增设备
export function addDevice(data) {
    return request({
        url: `/ems/siteConfig/addDevice`,
        method: 'post',
        data
    })
}

// 编辑设备
export function updateDevice(data) {
    return request({
        url: `/ems/siteConfig/updateDevice`,
        method: 'post',
        data
    })
}

// 删除设备
export function deleteService(id) {
    return request({
        url: `/ems/siteConfig/deleteService/` + id,
        method: 'delete',
    })
}

//pcs开、关机
export function updateDeviceStatus(data) {
    return request({
        url: `/ems/siteConfig/updateDeviceStatus`,
        method: 'post',
        data
    })
}

// 获取上级设备id列表
export function getParentDeviceId({siteId, deviceCategory}) {
    return request({
        url: `/ems/siteConfig/getParentDeviceId?siteId=${siteId}&deviceCategory=${deviceCategory}`,
        method: 'get',
    })
}

//获取所有设备
export function getDeviceList(siteId) {
    return request({
        url: `/ems/siteConfig/getDeviceList?siteId=${siteId}`,
        method: 'get',
    })
}

//获取设备点位table
export function getDevicePointList(data) {
    return request({
        url: `/ems/siteConfig/getDevicePointList`,
        method: 'get',
        params: data
    })
}


//获取设备类型下面的所有设备列表
export function getDeviceListBySiteAndCategory({siteId, deviceCategory}) {
    return request({
        url: `/ems/siteConfig/getDeviceListBySiteAndCategory?siteId=${siteId}&deviceCategory=${deviceCategory}`,
        method: 'get',
    })
}

//新增设备保护
export function addProtectPlan(data) {
    return request({
        url: `/ems/protectPlan`,
        method: 'post',
        data
    })
}

//修改设备保护
export function updateProtectPlan(data) {
    return request({
        url: `/ems/protectPlan`,
        method: 'put',
        data
    })
}

//删除设备保护
export function deleteProtectPlan(id) {
    return request({
        url: `/ems/protectPlan/${id}`,
        method: 'delete',
    })
}

//设备保护详情
export function getProtectPlan(id) {
    return request({
        url: `/ems/protectPlan/${id}`,
        method: 'get',
    })
}

//设备保护详情列表
//http://localhost:8089/ems/protectPlan/list?pageSize=10&pageNum=1&faultName=总压&siteId=021_DDS_01
export function protectPlanList({siteId, faultName, pageSize, pageNum}) {
    return request({
        url: `/ems/protectPlan/list?siteId=${siteId}&faultName=${faultName}&pageSize=${pageSize}&pageNum=${pageNum}`,
        method: 'get',
    })
}

// 点位导出
export function exportPointList(data) {
    return request({
        url: `/ems/pointMatch/export`,
        method: 'post',
        data
    })
}

// 点位导入
export function importPointList(data) {
    return request({
        url: `/ems/pointMatch/importData`,
        method: 'post',
        data
    })
}


//mqtt
export function getMqttList({pageSize, pageNum, mqttTopic, topicName, siteId}) {
    return request({
        url: `/ems/mqttConfig/list?pageSize=${pageSize}&pageNum=${pageNum}&mqttTopic=${mqttTopic}&topicName=${topicName}&siteId=${siteId}`,
        method: 'get',
    })
}

export function getMqttDetail(id) {
    return request({
        url: `/ems/mqttConfig/${id}`,
        method: 'get',
    })
}

export function addMqtt(data) {
    return request({
        url: `/ems/mqttConfig`,
        method: 'post',
        data
    })
}

export function editMqtt(data) {
    return request({
        url: `/ems/mqttConfig`,
        method: 'put',
        data
    })
}

export function deleteMqtt(id) {
    return request({
        url: `/ems/mqttConfig/${id}`,
        method: 'delete',
    })
}
