const http = uni.$u.http;

// 查询设备简短列表
export function listDeviceShort(params) {
	return http.get('/iot/device/shortList', {
		params: params
	});
}

// 查询设备详细
export function getDevice(deviceId) {
	return http.get('/iot/device/' + deviceId);
}

// 设备数据同步
export function deviceSynchronization(serialNumber) {
	return http.get('/iot/device/synchronization/' + serialNumber);
}
export function addDevice(data) {
	return http.post('/iot/device', data);
}
// 查询设备运行状态详细
export function getRunningStatus(deviceId, slaveId, type, productId, serialNumber) {
	let params = {
		deviceId: deviceId,
		slaveId: slaveId,
		type: type,
		productId: productId,
		serialNumber: serialNumber,

	};
	return http.get('/iot/device/runningStatus', {
		params: params
	});
}

// 查询设备物模型的值
export function getDeviceThingsModelValue(deviceId) {
	return http.get('/iot/device/thingsModelValue/' + deviceId);
}

// 根据产品ID获取缓存的物模型
export function cacheJsonThingsModel(productId) {
	return http.get('/iot/model/cache/' + productId, {
		custom: {
			ShowLoading: false
		}
	});
}

// 根据产品ID获取缓存的物模型
export function getCacheThingsModel(productId) {
	return http.get('/iot/model/cache/' + productId);
}

// 修改设备
export function updateDevice(data) {
	return http.put('/iot/device', data)
}

// 用户关联设备
export function deviceRelateUser(data) {
	return http.post('/iot/device/relateUser', data)
}

// 删除设备
export function delDevice(deviceId) {
	return http.delete('/iot/device/' + deviceId);
}

// 查询设备最新固件
export function getLatestFirmware(deviceId) {
	return http.get('/iot/firmware/getLatest/' + deviceId);
}

// 查询分组可添加设备分页列表
export function listDeviceByGroup(query) {
	return http.get('/iot/device/listByGroup', {
		params: query
	})
}

// 查询设备绑定的视频通道列表
export function relateChannelList(deviceId) {
	return http.get('/iot/relation/dev/' + deviceId);
}

// 查询设备变量概况
export function listThingsModel(data) {
	return http.get('/iot/device/listThingsModel', {
		params: data
	})
}
// 查询指令权限
export function getOrderControl(params) {
	return http.request({
		url: '/order/control/get',
		method: 'get',
		params: params
	})
}
//主动采集
export function propGet(params) {
	return http.request({
		url: '/iot/runtime/prop/get',
		method: 'get',
		params: params,
	});
}
//告警记录列表
export function listAlertLog(params) {
	return http.request({
		url: '/iot/alertLog/list',
		method: 'get',
		params: params,
	});
}
//服务调用，等待设备响应
export function serviceInvokeReply(data) {
	return http.request({
		url: '/iot/runtime/service/invokeReply',
		method: 'post',
		data: data,
	});
}