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 { getUserInfo, setQueryConfig } from '@/utils'
import { 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/getCurrent?${params}`, 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) => {
  return https({ timeout: 1000 }).request<RootObject<any>>(`${duoduoenvService}light/status/query?spaceId=${params.spaceId}`, Method.GET, undefined, ContentType.json)
}

// 批量操作 灯
export const setallLampHttp = (data: any) => {
  return post(`${duoduoenvService}light/onoff/set?${comParams}`, 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>>(`${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>(`${duoduoenvService}customScene/queryCustomAndScence?${params}`, Method.GET, undefined, ContentType.json)
}

/**
 * 添加(取消)加班记录
 * @param params
 */
export const saveBatchCustomScene = (data: any) => {
  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)
}

/**
 * 查询平板下面的办公空间
 */
export const queryWorkSpace = (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)
}



