DeviceService.java
1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package cn.com.glsx.consumer.service;
import cn.com.glsx.consumer.client.SceneClient;
import cn.com.glsx.consumer.client.SmartPlatformClient;
import cn.com.glsx.consumer.entity.DeviceVo;
import com.alibaba.fastjson.JSONObject;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author zhouhaibao
* @date 2021/4/23 11:18
*/
@Service
@Slf4j
public class DeviceService {
@Autowired
private SceneClient sceneClient;
@Autowired
private SmartPlatformClient smartPlatformClient;
/**
* 设备绑定
*
* @param deviceVo 入参
*/
public void devBind(DeviceVo deviceVo) {
Boolean aBoolean = sceneClient.devBind(deviceVo);
log.info("设备id{}保存更新结果{}", deviceVo.getDeviceId(), aBoolean);
}
/**
* 设备解绑
*
* @param deviceVo 入参
*/
public void devUnBind(DeviceVo deviceVo) {
Boolean aBoolean = sceneClient.devUnBind(deviceVo);
log.info("设备id{}删除结果{}", deviceVo.getDeviceId(), aBoolean);
}
/**
* 获取设备名称
*
* @param devId 设备id
* @return 返回值
*/
public String getDeviceName(String devId) {
R deviceName = smartPlatformClient.getDeviceName(devId);
String message = deviceName.getMessage();
JSONObject jsonObject = JSONObject.parseObject(message);
return jsonObject.getString("name");
}
}