|
|
@@ -40,10 +40,10 @@ public class ExamRoomService {
|
|
|
String uri = "https://open.ys7.com/api/lapp/device/list";
|
|
|
String accessToken = ezvizTokenService.getToken();
|
|
|
String send = "accessToken=" + accessToken + "&pageStart=0&pageSize=50";
|
|
|
- log.info("萤石查看设备--->" + send);
|
|
|
+ log.info("萤石查看设备列表--->" + send);
|
|
|
|
|
|
String body = HttpRequest.post(uri).send(send).body();
|
|
|
- log.info("萤石查看设备返回--->" + body);
|
|
|
+ log.info("萤石查看设备列表返回--->" + body);
|
|
|
|
|
|
JSONObject json = JSONObject.parseObject(body);
|
|
|
if (!"200".equals(json.getString("code"))) {
|
|
|
@@ -66,21 +66,29 @@ public class ExamRoomService {
|
|
|
*/
|
|
|
public void addDevice(String deviceSerial, String validateCode) {
|
|
|
Set<String> devices = this.showDevice().keySet();
|
|
|
- if (devices.contains(deviceSerial)) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- String uri = "https://open.ys7.com/api/lapp/device/add";
|
|
|
String accessToken = ezvizTokenService.getToken();
|
|
|
- String send = "accessToken=" + accessToken + "&deviceSerial=" + deviceSerial + "&validateCode=" + validateCode;
|
|
|
- log.info("萤石添加设备--->" + send);
|
|
|
|
|
|
- String body = HttpRequest.post(uri).send(send).body();
|
|
|
- log.info("萤石添加设备返回--->" + body);
|
|
|
+ if (!devices.contains(deviceSerial)) {
|
|
|
+ String uri = "https://open.ys7.com/api/lapp/device/add";
|
|
|
|
|
|
- JSONObject json = JSONObject.parseObject(body);
|
|
|
- if (!"200".equals(json.getString("code"))) {
|
|
|
- throw new BusinessException(json.getString("msg"));
|
|
|
+ String send = "accessToken=" + accessToken + "&deviceSerial=" + deviceSerial + "&validateCode=" + validateCode;
|
|
|
+ log.info("萤石添加设备--->" + send);
|
|
|
+
|
|
|
+ String body = HttpRequest.post(uri).send(send).body();
|
|
|
+ log.info("萤石添加设备返回--->" + body);
|
|
|
+
|
|
|
+ JSONObject json = JSONObject.parseObject(body);
|
|
|
+ if (!"200".equals(json.getString("code"))) {
|
|
|
+ throw new BusinessException(json.getString("msg"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject info = this.info(deviceSerial, accessToken);
|
|
|
+ JSONObject data = JSONObject.parseObject(info.getString("data"));
|
|
|
+ Integer isEncrypt = data.getInteger("isEncrypt");
|
|
|
+ if (isEncrypt == 1) {
|
|
|
+ // 解密设备
|
|
|
+ this.encryptOff(deviceSerial, validateCode, accessToken);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -104,6 +112,25 @@ public class ExamRoomService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ 查询单个设备
|
|
|
+ */
|
|
|
+ public JSONObject info(String deviceSerial, String accessToken) {
|
|
|
+ String uri = "https://open.ys7.com/api/lapp/device/info";
|
|
|
+
|
|
|
+ String send = "accessToken=" + accessToken + "&deviceSerial=" + deviceSerial;
|
|
|
+ log.info("萤石设备查询--->" + send);
|
|
|
+
|
|
|
+ String body = HttpRequest.post(uri).send(send).body();
|
|
|
+ log.info("萤石设备查询返回--->" + body);
|
|
|
+
|
|
|
+ JSONObject json = JSONObject.parseObject(body);
|
|
|
+ if (!"200".equals(json.getString("code"))) {
|
|
|
+ throw new BusinessException(json.getString("msg"));
|
|
|
+ }
|
|
|
+ return json;
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
开启设备加密
|
|
|
*/
|
|
|
@@ -128,10 +155,10 @@ public class ExamRoomService {
|
|
|
/*
|
|
|
关闭设备加密
|
|
|
*/
|
|
|
- public void encryptOff(String deviceSerial, String validateCode) {
|
|
|
+ public void encryptOff(String deviceSerial, String validateCode, String accessToken) {
|
|
|
|
|
|
String uri = "https://open.ys7.com/api/lapp/device/encrypt/off";
|
|
|
- String accessToken = ezvizTokenService.getToken();
|
|
|
+// String accessToken = ezvizTokenService.getToken();
|
|
|
String send = "accessToken=" + accessToken + "&deviceSerial=" + deviceSerial + "&validateCode=" + validateCode;
|
|
|
log.info("萤石关闭设备加密--->" + send);
|
|
|
|