import {get, post, request } from './request'
import httpUtil from "@/api/scan/httpUtil";
let point = '/pointconfig'
let relation = '/relation'

//添加数据源信息
export function createDataSource(param, success) {
    let data = param
    return post(`${point}/datasource/create`, data, success)
}

//根据id删除数据源
export function delDataSource(param, success) {
    let data = param
    return post(`${point}/datasource/delete`, data, success)
}

//查询数据源信息
export function queryDataSource(param, success) {
    let data = param
    return post(`${point}/datasource/query`, data, success)
}

//查询数据源信息-包含统计信息
export function queryDataSourceCount(param, success) {
    let data = param
    return post(`${point}/datasource/queryWithCount`, data, success)
}

//更新数据源信息
export function updateDataSource(param, success) {
    let data = param
    return post(`${point}/datasource/update`, data, success)
}

/**----------------位置标签接口---------------------------- */
//添加
export function addLocaltionFlag(param, success) {
    let data = param
    return post(`${point}/location-flag/create`, data, success)
}
//删除
export function delLocaltionFlag(param, success) {
    let data = param
    return post(`${point}/location-flag/delete`, data, success)
}
//修改
export function updateLocaltionFlag(param, success) {
    let data = param
    return post(`${point}/location-flag/update`, data, success)
}
//查询
export function queryLocaltionFlag(param, success) {
    let data = param
    return post(`${point}/location-flag/query`, data, success)
}


/**  --------------任何点位接口必传一个type---------------------   */
//下载模板
export function downloadTemplete(param, header, success) {
    let data = param.data
    return request('post', `${point}/point/${param.type}/template-export`, data, header, success)
}

//查询point list
export function queryPoint(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/query`, data, success)
}

//查询点位对应关系
export function queryPointRela(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/point-relation`, data, success)
}

//更新point
export function updatePoint(param, success) {
    let data = param.data,
        key;
    data.Content = data.Content.map(item => {
        for (let key in item) {
            if (item[key] === "") {
                item[key] = null
            }
        }
        return item
    })
    data.Projection = []
    data.Content.map(item => {
        for (key in item) {
            if (data.Projection.indexOf(key) == -1) {
                data.Projection.push(key)
            }
        }
    })
    return post(`${point}/point/${param.type}/update`, data, success)
}



//删除point
export function deletePoint(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/delete`, data, success)
}

//添加point
export function createPoint(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/create`, data, success)
}

//发现关键字(设备参数)
export function findKeysWord(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/next-equipment-parameter`, data, success)
}

//发现关键字(设备类型)
export function findKeysWordType(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/next-equipment-type`, data, success)
}

//查询设备类型分组列表(涉及点位数,包含空)
export function queryAllEqTypeList(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/group-equipment-type-statis-all`, data, success)
}

//查询设备类型分组列表(涉及点位数)
export function queryEqTypeList(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/group-equipment-type-statis`, data, success)
}

//根据设备参数获取值说明列表
export function queryDescription(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/group-value-description`, data, success)
}
//查询设备参数分组列表(含空参数)
export function queryAllEqParamList(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/group-equipment-parameter-all`, data, success)
}

//查询设备参数分组列表(涉及点位数)
export function queryEqParamList(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/group-equipment-parameter-statis`, data, success)
}

///重命名关键字（设备参数）
export function renameParam(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/rename-equipment-parameter`, data, success)
}

///重命名关键字（设备类型）
export function renameType(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/rename-equipment-type`, data, success)
}

//设定关键字（设备参数）
export function setParamTer(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/set-equipment-parameter`, data, success)
}

//设定关键字（设备类型）
export function setTypeTer(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/set-equipment-type`, data, success)
}

//删除关键字（设备参数）
export function delParamTer(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/delete-equipment-parameter`, data, success)
}
//删除关键字（设备类型）
export function delTypeTer(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/delete-equipment-type`, data, success)
}

//查询设备类型分组列表(是否标准化设备标识)
export function getStandType(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/group-equipment-type-standarded`, data, success)
}

//查询设备标识分组列表(是否标准化设备标识,通过设备类型)
export function getStandParam(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/group-equipment-mark`, data, success)
}

//查询设备类型分组列表(是否对应数据字典)
export function groupRelated(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/group-equipment-type-related`, data, success)
}

//查询设备参数分组列表
export function groupParamRelated(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/group-equipment-parameter`, data, success)
}

//设备标识为空的查询
export function getNullofParam(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/group-equipment-point`, data, success)
}

//待处理点位
export function getNoDealPoint(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/point-pending`, data, success)
}

//物理世界角度获取图数据(获取系统)
export function platformSysJsMind(param, success) {
    let data = param
    return post(`${point}/relation/check-physical-system`, data, success)
}

//物理世界角度获取图数据(获取设备类)
export function platformEqJsMind(param, success) {
    let data = param
    return post(`${point}/relation/check-physical-equipment-type`, data, success)
}

//物理世界角度获取图数据(设备标识)
export function platformIdentJsMind(param, success) {
    let data = param
    return post(`${point}/relation/check-physical-equipment-mark`, data, success)
}

//物理世界角度获取图数据(物理世界信息点)
export function platformInfoJsMind(param, success) {
    let data = param
    return post(`${point}/relation/check-physical-info`, data, success)
}

//物理世界角度获取图数据(原始点位)
export function platformPointJsMind(param, success) {
    let data = param
    return post(`${point}/relation/check-physical-point`, data, success)
}

//原始点位角度检查图(专业系统)
export function pointSytemJsMind(param, success) {
    let data = param
    return post(`${point}/relation/check-original-system`, data, success)
}

//原始点位角度检查图(原始点位)
export function pointPostJsMind(param, success) {
    let data = param
    return post(`${point}/relation/check-original-point`, data, success)
}

//原始点位角度检查图(物理世界信息点)
export function pointInfoJsMind(param, success) {
    let data = param
    return post(`${point}/relation/check-original-info`, data, success)
}


//原始点位角度检查图(设备类)
export function pointTypeJsMind(param, success) {
    let data = param
    return post(`${point}/relation/check-original-equipment-type`, data, success)
}
//查询所有关系，从物理世界角度
export function queryAllRela(param, success) {
    let data = param
    return post(`${point}/relation/check-physical`, data, success)
}

//查询所有关系，从原始点位角度
export function queryAllPointRela(param, success) {
    let data = param
    return post(`${point}/relation/check-original`, data, success)
}

//获取当前值
export function getPointValue(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/original-present`, data, success)
}

/******************数据字典-单位接口***************************************************** */

export function batchQueryUnit(param, success) {
    let data = param
    return post(`${point}/unit/batchquery`, data, success)
}



/******************物理世界关系对应****************************************************** */
//批量创建对应关系
export function batchCreate(param, success) {
    let data = param
    return post(`${point}/relation/batch-create`, data, success)
}

//上传
export function uploadPointFile(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/point-import`, data, success)
}

//上传2
export function uploadPointFile2(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/point-import2`, data, success)
}

//根据id批量删除对应关系
export function deleteRelationList(param, success) {
    let data = param
    return post(`${point}/relation/group-delete`, data, success)
}

/**项目接口 */
export function synchronizeProj(success) {
    return post(`${point}/project/synchronize`, {}, success)
}

//ai自动识别
export function AIFindPoint(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/ai`, data, success)
}

//ai识别进度
export function AIPlan(param, success) {
    let data = param.data
    return post(`${point}/point/${param.type}/query-ai`, data, success)
}

//查询协议列表
export function queryProtocalList(param, success) {
    let url = `${point}/protocol/type-list`
    httpUtil.postJson(url, param, success)
  }

  //查询通讯模式
  export function queryTxList(param, success){
    let url = `${point}/protocol/query`
    httpUtil.postJson(url, param, success)
  }
  //测试数据源  
  export function queryTest(param, success){
    let url = `${point}/datasource/check`
    httpUtil.postJson(url, param, success)
  }
  //下载协议
  export function dowloadProtocol(param, success){
    let url = `${point}/protocol/download`
    httpUtil.download(url, param, success)
  }
  //添加协议
  export function addProtocol(param, success){
    let url = `${point}/protocol/create`
    httpUtil.postJson(url, param, success)
  }
  //删除协议
  export function deleteProtocol(param, success){
    let url = `${point}/protocol/delete`
    httpUtil.postJson(url, param, success)
  }
  //更新协议
  export function updateProtocol(param, success){
    let url = `${point}/protocol/update`
    httpUtil.postJson(url, param, success)
  }
   //上传协议
   export function uploadProtocol(param, success){
    let url = `${point}/protocol/upload`
    httpUtil.postJson(url, param, success)
  }