import httpUtil from "../scan/httpUtil";
import fetch from "../scan/fetch";
import storage from '@/framework/utils/storage'


//查询总览
export function graphic(param, success) {
  let url = '/api/datacenter/graphic/overview'
  httpUtil.postJson(url, param, success)
}

// 查询总览数量
export function graphicNumber(param, success) {
  let url = '/api/datacenter/graphic/query-count'
  httpUtil.postJson(url, param, success)

}

//导入excel
export function graphicUpload(param, success) {
  let url = '/api/datacenter/graphic/import'
  httpUtil.postJson(url, param, success)
}

// 下载报告
export function reportDownload(param, success) {
  let url = '/api/datacenter/graphic/report-downloads'
  httpUtil.getJson(url, param, success)
}

// 下载模板
export function templateDownloads(param, success) {
  let url = '/api/datacenter/graphic/template-downloads'
  httpUtil.getJson(url, param, success)
}


//    建筑下的业务空间
export function buildSpace(param, success) {
  let url = '/api/datacenter/calc_building/space'
  httpUtil.postJson(url, param, success)
}


// 管网系统设备分块 1
export function calcSpecial(param, success) {
  let url = ` /api/datacenter/calc_special/sys-block?Domain=${param.Domain}&SystemName=${param.SystemName}`
  httpUtil.postJson(url, param, success)
}


//    获取源末端 2
export function blockQuery(param, success) {
  let url = '/api/datacenter/graphic/connected-block-query'
  httpUtil.postJson(url, param, success)
}


// 覆盖源末端 3
export function blockSource(param, success) {
  let url = '/api/datacenter/graphic/replace-connected-block-source'
  httpUtil.postJson(url, param, success)
}

//    管网系统确定流向 4
export function sysDirection(param, success) {
  let buildId = param.BuildingId ? `BuildingId=${param.BuildingId}&` : ''
  let url = `/api/datacenter/calc_special/sys-direction?BlockId=${param.BlockId}&${buildId}Domain=${param.Domain}&SystemName=${param.SystemName}&isSource=${param.isSource}`
  httpUtil.postJson(url, param, success)
}

//************************无需配置源末端关系计算15种********************************//
// 建筑下的业务空间
export function businessSpaceAll(param) {
  let {relation_type, zone_type, proId} = param
  let userName = storage.get("user_name")
  let ProjectId = localStorage.getItem("projectId")
  let objectTypes = zone_type ? "?objectTypes=" + zone_type : ''
  return fetch({
    method: 'POST',
    url: "/api/datacenter/relation-calc/" + relation_type + objectTypes,
    data: proId,
    headers: {'ProjectId': ProjectId, 'Comming': 'adm', 'Account': userName}
  })
}

//************************数据转换********************************//

// 项目化字典-统计数量
export function dictCount(param, success) {
  let url = '/api/equip-component/dict-custom/project-dict-count'
  httpUtil.postJson(url, param, success)
}

// 项目化字典-需补充转换规则数量
export function dictSwitchCount(param, success) {
  let url = '/api/equip-component/dict-custom/project-dict-switch-count'
  httpUtil.postJson(url, param, success)
}

//项目化字典 - 内容
export function dectInfo(param) {
  let data = param
  let userName = storage.get("user_name")
  let ProjectId = localStorage.getItem("projectId")
  return fetch({
    method: 'POST',
    url: `/api/equip-component/dict-custom/project-dict-info`,
    data,
    headers: {'ProjectId': ProjectId, 'Comming': 'adm', 'Account': userName}
  })
}

//数据中心-物理世界数据转换
export function dictDataCenter(param, success) {
  let url = '/api/equip-component/dict-custom/project-dict-datacenter'
  httpUtil.postJson(url, param, success)
}

//物理世界-数据中心数据转换
export function dictDataPlatFrom(param, success) {
  let url = '/api/equip-component/dict-custom/project-dict-dataplatfrom'
  httpUtil.postJson(url, param, success)
}

// 同步设备
export function createEquip(param, success) {
  let url = `/api/dataplatform-sync/project-sync/create-equip?projectId=${param.projectId}`
  httpUtil.postJson(url, {}, success)
}

//更新自定义自定脚本
export function dictUpdate(param, success) {
  let url = '/api/equip-component/dict-custom/update'
  httpUtil.postJson(url, param, success)
}

// 查询关系数据
export function relQuery(param,success) {
  let url = '/api/datacenter/relation-manual-calc/rel-query'
  httpUtil.postJson(url,param,success)
}
//添加关系数据
export function relAdd(data) {
  let userName = storage.get("user_name")
  let ProjectId = localStorage.getItem("projectId")
  return fetch({
    method: 'POST',
    url: `/api/datacenter/relation-manual-calc/rel-add`,
    data,
    headers: {'ProjectId': ProjectId, 'Comming': 'adm', 'Account': userName}
  })
}

//删除关系
export function relDelete(param, success) {
  let url = '/api/datacenter/relation-manual-calc/rel-del'
  httpUtil.postJson(url, param, success)
}
