import request from './zmaxios.js'


//获取服务端公钥
export const getPublickey = query => {
        return request.get(`info/publickey`);
    }
    // login
export const loginRequest = params => {
    return request.post("user/login", params);
};
//register
export const registerRequest = params => {
    return request.post("user/registers", params);
};
// ----------------------------------------user------------------------------------------------
export const getUserList = () => {
    return request.get(`user/getall`);
}
export const editRequest = params => {
    return request.post("user/edituser", params);
};
export const deleteUser = data => {
        return request.delete(`user/${data}`);
    }
    // ----------------------------------------user------------------------------------------------


//获取所有风场
export const fetchStationList = () => {
    return request({
        url: '' + 'info/station',
        method: 'get'
    });
};
//根据风场id获取所有风机
export const fetchWindturbineList = query => {
    return request({
        url: '' + 'info/windturbine',
        method: 'get',
        params: {
            stationId: query
        }
    });
};
// ----------------------------------------安全生产- 报警记录------------------------------------------------
//查询历史报警
export const alarm_history = (params) => {
        return request({
            url: `alarm/history/page2`,
            params: params
        });
    }
    //查报警
export const alarm_snap = (params) => {
        return request({
            url: `alarm/snap`,
            params: params
        });
    }
    // ----------------------------------------安全生产- 实时报警------------------------------------------------
    //实时故障 最高级
export const alarm_fault_recent = (params) => {
        return request({
            url: `fault/recent`,
            params: params
        });
    }
    //实时故障 第一次请求
export const alarm_fault_top = (params) => {
        return request({
            url: `fault/snap/top`,
            params: params
        });
    }
    //底下的实时报警 
export const alarm_snap_top = (params) => {
        return request({
            url: `alarm/snap/top`,
            params: params
        });
    }
    // ----------------------------------------基础数据- 设备管理------------------------------------------------
    //查询全部设备型号接口
export const device_list = () => {
        return request.get(`device/model/list`);
    }
    //获取结构tree
export function tree(params) {
    return request({
        url: 'device/structure/tree/windturbine',
        method: 'get',
    });
}
//根据结构获取测点
export function point(code, pagenum, pagesize) {
    return request.get(`device/metrics/page?pagenum=${pagenum}&pagesize=${pagesize}&deviceId=windturbine&structureCode=${code}`);
}
//测点新增
export function metrics(params) {
    return request.post(`device/metrics/single`, params);
}
//测点删除
export function delmetrics(params) {
    return request.delete(`device/metrics/single/delete/${params}`);
}

//tree新增 添加一个设备结构节点
export function treeAdd(params) {
    return request.post(`device/structure`, params);
}
//tree删除 tree删除一个设备结构节点
export function treeDel(params) {
    return request.delete(`device/structure/delete/${params}`);
}


// 故障模式
// get All
export const faultmode_windturbine = () => {
        return request.get(`device/faultmode/windturbine`);
    }
    // 根据 structurecode get
export const faultmode_structurecode = params => {
        return request.get(`device/faultmode/windturbine/${params}`);
    }
    // 根据 id delete
export const faultmode_delete = params => {
    return request.delete(`device/faultmode/delete/${params}`);
}

// 新增 修改
export const faultmode_add_edit = data => {
    return request.post(`device/faultmode`, data);
}

// ----------------------------------------end 基础数据- 风机管理------------------------------------------------


// ---------------------------------------- 报警配置- 自定义预警------------------------------------------------
export function custombj_fetchTableData(params) {
    return request.get(`alertrule2/page/`, {
        params: params
    });
}

//根据场站编号，风机型号获取AI测点
export const fetchAIPointList = (stationId, modelId) => {
    return request({
        url: '' + 'info/testing_point_ai',
        method: 'get',
        params: {
            stationId: stationId,
            modelId: modelId
        }
    });
};
//根据场站编号，风机型号获取DI测点
export const fetchDIPointList = (stationId, modelId) => {
    return request({
        url: '' + 'info/testing_point_di',
        method: 'get',
        params: {
            stationId: stationId,
            modelId: modelId
        }
    });
};
//根据场站编号，获取电气DI测点
export const fetchElectricDIPointList = (stationId) => {
    return request({
        url: '' + 'info/electrical_point_di',
        method: 'get',
        params: {
            stationId: stationId
        }
    });
};
//根据电气测点，获取测点信息
export const fetchElectricDIPointByPointId = (pointId) => {
    return request({
        url: '' + 'info/electrical_point_di/byId',
        method: 'get',
        params: {
            pointId: pointId
        }
    });
};

//获取风机关联部件列表
export const fetchRelatePart = () => {
    return request({
        url: '' + 'info/windturbine_parts',
        method: 'get',
    });
};
//根据风场编号获取电气AI测点
export const fetch_electrical_point_ai = (stationId) => {
    return request({
        url: '' + 'info/electrical_point_ai',
        method: 'get',
        params: {
            stationId: stationId
        }
    });
};
//根据风场编号获取电气DI测点
export const fetch_electrical_point_di = (stationId) => {
    return request({
        url: '' + 'info/electrical_point_di',
        method: 'get',
        params: {
            stationId: stationId
        }
    });
};
//获取报警类型
export const fetchWarningType = () => {
    return request({
        url: '' + 'info/warning_type',
        method: 'get',
    });
};
//获取报警种类
export const fetchWarningClassify = () => {
    return request({
        url: '' + 'info/warning_classify',
        method: 'get',
    });
};
export const custombj_batchImport = list => {
    return Axrequestios.post('' + "alertrule2/save-batch", list);
};
export const custombj_postSave = form => {
    return request.post('' + "alertrule2/save", form)
};

//******************************end****************************************//


//******************************升压站报警API************************************//

export const scadabj_fetchTableData = query => {
    return request({
        url: '' + 'scadabj/page',
        method: 'get',
        params: query,
        timeout: 20000,
    });
};
export const scadabj_postSave = objData => {
    return request.post('' + "scadabj/save", objData);
};
export const scadabj_batchImport = list => {
    return request.post('' + "scadabj/save-batch", list);
};
//********************************************end********************************//\



//******************************风机报警API************************************//
export const windturbinebj_fetchTableData = query => {
    return request({
        url: '' + 'warning2/page',
        method: 'get',
        params: query,
        timeout: 20000,
    });
};
export const windturbinebj_postSave = form => {
    return Axios.post('' + 'warning2/save', form);
};
export const windturbinebj_batchImport = list => {
    return Axios.post('' + "warning2/save-batch", list);
};

export const fetchLeaf = () => {
    return request({
        url: '' + 'warning2/page',
        method: 'get',
        params: {
            pagenum: 1,
            pagesize: 10000,
            isLeaf: 0,
        }
    });
};


//根据风机型号获取DI测点统一编码相关数据 testingpointdi2
export const getDIPointByModelId = query => {
    return request({
        url: '' + 'info/testing_point_di',
        method: 'get',
        params: query
    });
};

//******************************end*******************************************// 
//******************************预警统计*******************************************//
export const statistics_querymap = params => {
    return request.get(`alarm/count/querymap2`, { params: params })
        // return request.get(`alarm/count/querymap?stationid=XS_FDC&datebegin=2021-10-12&dateend=2021-11-13`)
};
export const statistics_querybyname = params => {
    return request.get('alarm/count/querybyname2', { params: params })
};
export const statistics_lineandproject = params => {
    return request.get('alarm/count/lineandproject2', { params: params })
};
//******************************end*******************************************//

//******************************预警分析*******************************************//
export const warning_query_new = params => {
    return request.get(`alarm/count/query/new2`, { params: params })
};
export const warning_detail = params => {
    return request.get('analysis/detail', { params: params })
};
// export const statistics_lineandproject = params => {
//     return request.get('alarm/count/lineandproject', { params: params })
// };
//******************************end*******************************************//