import { RootObject, RootWeatherObject } from '@/model/rootObject'
import { CompanyModel, OutherWeather, SpaceModel } from '@/model/userModel'
import { https, post } from '@/utils/https'
import { ContentType, Method, RequestParams } from 'axios-mapper'
import { setQueryConfig } from '@/utils'
import { customService, duoduoenvService, objectService, setupService, testApi, weachatService } from '@/config'

// const comInfo = getUserInfo()
// const comParams: string = ""

// https://sagacare-h5.tenants.link/api/company/config/245e7060643811eb934c0237aedb39a6
export const getCompanyInfo = (companyInfo: RequestParams) => {
  return https().request<RootObject<CompanyModel>>(`/api/company/config/${companyInfo.companyId}`, Method.GET, undefined, ContentType.json)
}
export const getWeather = (params: string) => {
  return https().request<RootWeatherObject<OutherWeather>>(`${objectService}weather/getCurrentWeather?${params}`, Method.GET, undefined, ContentType.json)
}

// export const getWeather = () => {
//   // return https().request<RootWeatherObject<OutherWeather>>(`${objectService}weather/getCurrent`, Method.GET, undefined, ContentType.json)
//   return https().request<RootWeatherObject<OutherWeather>>(`${objectService}weather/getCurrentWeather`, Method.GET, undefined, ContentType.json)
// }
export const getSpaceInfo = (data: any) => {
  return https().request<RootWeatherObject<SpaceModel>>(`${duoduoenvService}space/property`, Method.POST, data, ContentType.json)
}

// 获取会议室场景
export const getMeetingSceneHttp = (params: any) => {
  return https().request<any>(`${duoduoenvService}meeting/room/scene/getMeetingScene/V2?spaceId=${params.spaceId}`, Method.GET, undefined, ContentType.json)
}
// 获取设备信息
export const getEquipmentListHttp = (params: any) => {
  return https().request<any>(`${duoduoenvService}object/equipment/findForServe?spaceId=${params.spaceId}`, Method.POST, undefined, ContentType.json)
}
// 查询定制时间
export const getSetTimeHttp = (params: any) => {
  return https().request<any>(`${duoduoenvService}customScene/queryCustom?spaceId=${params.spaceId}`, Method.GET, undefined, ContentType.json)
}
//  空调 - 调节文案/空调信息
export const getFeedbackDocumentsHttp = (data: any) => {
  return https().request<any>(`${duoduoenvService}custom/feedback/documents`, Method.POST, data, ContentType.json)
}

// 空调调节
export const changeTempHttp = (params: any) => {
  return https().request<RootObject<any>>(`${duoduoenvService}custom/feedbackCreate/v2`, Method.POST, params, ContentType.json)
}
// 查询灯的状态（优先查采集的状态）
export const getLampHttp = (params: any) => {
  // { timeout: 2000 }
  return https({ timeout: 150000,isComParams:true }).request<RootObject<any>>(`${duoduoenvService}light/status/query?spaceId=${params.spaceId}`, Method.GET, undefined, ContentType.json)
  // return https({ timeout: 20000 }).request<RootObject<any>>(`${testApi}light/status/query?spaceId=${params.spaceId}`, Method.GET, undefined, ContentType.json)
}

// 批量操作 灯
export const setallLampHttp = (data: any) => {
  return post(`${duoduoenvService}light/onoff/set`, data)
}
// 设置窗帘 
export const setEquipeHttp = (data: any) => {
  return post(`${duoduoenvService}object/eqp/infocode/set`, data)
}

// 指令失败的时候轮询查询灯的状态
export const getStatusHttp = (data: any) => {
  return post(`${duoduoenvService}light/onoff/setSatus`, data)
}

// 获取窗帘数据列表
export const getObjectDataEqpGroupHttp = (params: any) => {
  // return https().request<RootObject<any>>(`${testApi}object/objectDataEqpGroup/query`, Method.POST, params, ContentType.json)
  return https().request<RootObject<any>>(`${duoduoenvService}object/objectDataEqpGroup/query`, Method.POST, params, ContentType.json)
}

// 切换场景
export const switchoverSceneHttp = (params: any) => {
  return https().request<RootObject<any>>(`${duoduoenvService}meeting/room/scene/switchover`, Method.POST, params, ContentType.json)
}

export const changeSetTimeHttp = (params: any) => {
  return https().request<RootObject<any>>(`${duoduoenvService}customScene/create`, Method.POST, params, ContentType.json)
}
//  详情页面的图表数据
export const getChartListHTTP = (params: any) => {
  return https().request<RootObject<any>>(`${duoduoenvService}/spaceAdjust/queryPropertyData?${params}`, Method.GET, undefined, ContentType.json)
}

// 查询建筑的信息
export const getBuildingList = (params: any) => {
  return https().request<any>(`${objectService}object/building/query`, Method.POST, params, ContentType.json)
}

/**
 * 查询楼层信息
 * @param params
 */
export const getFloorList = (params: any) => {
  return https().request<any>(`${objectService}object/floor/query`, Method.POST, params, ContentType.json)
}

/**
 * 获取地图数据
 * @param params
 */
export const getMapInfo = (params: any) => {
  return https().request<any>(`${setupService}map/queryMapInfo`, Method.POST, params, ContentType.json)
}

/**
 * 获取空间设备
 * @param params
 */
export const getSpaceEquipType = (params: any) => {
  return https().request<any>(`${objectService}object/equipment/querySpaceEquipType?${params}`, Method.GET, undefined, ContentType.json)
}

/**
 * 模糊查询空间列表数据
 * @param params
 */
export const getSpaceLike = (params: any) => {
  return https().request<any>(`${objectService}object/space/query`, Method.POST, params, ContentType.json)
}

/**
 * 增加常驻空间
 */
export const permanentSpace = (params: any) => {
  // return https().request<any>(`${setupService}permanentSpace/save`, Method.POST, params, ContentType.json)
  // return https().request<any>(`${testApi}permanentSpace/save`, Method.POST, params, ContentType.json)
  return https().request<any>(`${setupService}permanentSpace/save`, Method.POST, params, ContentType.json)
}

/**
 * 获取常驻空间
 */
export const getPermanentSpace = () => {
  return https().request<any>(`${setupService}permanentSpace/query`, Method.GET, undefined, ContentType.json)
}

/**
 * 删除常驻空间
 */
export const delPermanentSpace = (params: any) => {
  return https().request<any>(`${setupService}permanentSpace/delete?${params}`)
}

/**
 *  获取用户使用权限
 */
export const getUserControlAuth = () => {
  return https().request<any>(`${setupService}permanentSpace/queryZJ`, Method.GET, undefined, ContentType.json)
}

/**
 * 获取空间运行模式
 */
export const getSpaceMode = () => {
  return https().request<any>(`${objectService}object/equipment/querySpaceModeSet`, Method.GET, undefined, ContentType.json)
}
/**
 * 获取空调设备温度
 */
export const getSpaceTemp = () => {
  return https().request<any>(`${objectService}object/equipment/querySpaceTempSet`, Method.GET, undefined, ContentType.json)
}

/**
 * 
 * @param params 查询场景配置
 * @returns 
 */
export const querySpaceSceneConfig = (params: any) => {
  return https().request<any>(`${setupService}scene/querySpaceSceneConfig?${params}`, Method.GET, undefined, ContentType.json)
}

/**
 *  查询加班记录
 */
export const queryCustomAndScence = (params: any) => {
  // return https().request<any>(`${testApi}customScene/queryCustomAndScence?${params}`, Method.GET, undefined, ContentType.json)
  return https().request<any>(`${duoduoenvService}customScene/queryCustomAndScence?${params}`, Method.GET, undefined, ContentType.json)
}

/**
 * 添加(取消)加班记录
 * @param params
 */
export const saveBatchCustomScene = (data: any) => {
  // return post(`${testApi}customScene/saveBatchCustomScene`, data)
  return post(`${duoduoenvService}customScene/saveBatchCustomScene`, data)
}


/**
 *  查询默认位置
 */
export const getDefaultLocation = (params: any) => {
  return https().request<any>(`${setupService}padSpace/getDefaultLocation?${params}`, Method.GET, undefined, ContentType.json)
}

/**
 * 查询空间列表
 */
export const getPadSpaceList = (params: any) => {
  return https().request<any>(`${setupService}padSpace/getPadSpaceList?${params}`, Method.GET, undefined, ContentType.json)
}

/**
 * 设置成办公空间-("批量保存")
 */
export const saveWorkSpace = (params: any) => {
  return https().request<any>(`${setupService}padSpace/saveWorkSpace`, Method.POST, params, ContentType.json)
}

/**
 * 设置工作空间
 * @param params 
 */
export const insertWorkSpace = (params: any) => {
  return https().request<any>(`${setupService}padSpace/insertWorkSpace`, Method.POST, params, ContentType.json)
}

/**
 * 删除工作空间
 * @param params 
 */
export const deleteWorkSpace = (params: any) => {
  return https().request<any>(`${setupService}padSpace/deleteWorkSpace`, Method.POST, params, ContentType.json)
}



/**
 * 查询平板下面的办公空间
 */
export let queryWorkSpace = (params: any) => {
  return https().request<any>(`${setupService}padSpace/queryWorkSpace`, Method.POST, params, ContentType.json)
}


/**
 * 查询平板下面的办公空间
 */
export let checkWorkSpace = (params: any) => {
  return https().request<any>(`${setupService}padSpace/queryWorkSpace`, Method.POST, params, ContentType.json)
}

/**
 * 查询客户列表
 */
export const queryCustomerservice = (params: any) => {
  return https().request<RootObject<any>>(`${weachatService}wechat-service-duoduoenv/duoduoenv/customerservice/query`, Method.POST, params, ContentType.json)
}


/**
 * 获取二维码状态
 */
export const getPadQrCodeStatus = (params: any) => {
  return https().request<any>(`${setupService}padLogin/getPadQrCodeStatus?${params}`, Method.GET, undefined, ContentType.json)
}


/**
 * 获取背景图
 * @param params 
 * @returns 
 */
export const getPadImg = (params: any) => {
  // return https().request<any>(`${setupService}/padImage/queryImageByFuncType`,Method.GET, undefined, ContentType.json)
  return https().request<any>(`${setupService}padImage/queryImageByFuncType?${params}`, Method.GET, undefined, ContentType.json)
}

/**
 * 设备手动控制
 */
export const querySpaceConditioners = (params: any) => {
  return https().request<any>(`${duoduoenvService}ctrl/querySpaceConditioners?${params}`, Method.GET, undefined, ContentType.json)
  // return https().request<any>(`${testApi}ctrl/querySpaceConditioners?${params}`, Method.GET, undefined, ContentType.json)
}

/**
 * 设备手动控制(灯-空调-窗帘下发窗帘)
 */
export const setSpaceCondtioners = (data: any) => {
  return post(`${duoduoenvService}ctrl/set`, data)
  // return post(`${testApi}ctrl/set`, data)
}

// 地图数据保存
export const saveMapPointInfo = (data: any) => {
  // return post(`${duoduoenvService}map/saveMapPointInfo`, data)
  return https().request<any>(`${setupService}/map/saveMapPointInfo`, Method.POST, data, ContentType.json)
}


// 获取空间下的可控制的设备
export const getSpaceEquipList = (params: any) => {
  return https().request<any>(`${customService}equipmentRun/queryEquipmentRunConfig?${params}`, Method.GET, undefined, ContentType.json)
}

// 查询地暖列表
export const querySapceFloorHeating = (params: any) => {
  return https().request<any>(`${duoduoenvService}ctrl/querySapceFloorHeating?${params}`, Method.GET, undefined, ContentType.json)
  // return https().request<any>(`${testApi}ctrl/querySapceFloorHeating?${params}`, Method.GET, undefined, ContentType.json)
}

// 192.168.0.47:52015/padSpace/insertWorkSpaceBatch
// 批量选中空间
export const insertWorkSpaceBatch = (data: any) => {
  return post(`${setupService}padSpace/insertWorkSpaceBatch`, data);
}

// 批量删除空间
export const deleteWorkSpaceBatch = (data: any) => {
  return post(`${setupService}padSpace/deleteWorkSpaceBatch`, data);
}

//获取插座列表
export const queryEquipmentStatusInfo = (params: any) => {
  return https().request<any>(`${duoduoenvService}ctrl/queryEquipmentStatusInfo?${params}`, Method.GET, undefined, ContentType.json)
}

export const getWeatherNew = (params: string) => {
  return https({ isComParams: false }).request<RootWeatherObject<OutherWeather>>(`${objectService}weather/getCurrentWeather?${params}`, Method.GET, undefined, ContentType.json)
}

export const getPacSpaceInfo = (data: any) => {
  return https({ isComParams: false }).request<RootWeatherObject<SpaceModel>>(`${duoduoenvService}space/property`, Method.POST, data, ContentType.json)
}
