|
@@ -13,9 +13,7 @@ import com.izouma.wenlvju.exception.BusinessException;
|
|
|
import com.izouma.wenlvju.repo.ExamRoomRepo;
|
|
import com.izouma.wenlvju.repo.ExamRoomRepo;
|
|
|
import com.izouma.wenlvju.repo.OrganizationRepo;
|
|
import com.izouma.wenlvju.repo.OrganizationRepo;
|
|
|
import com.izouma.wenlvju.repo.RecordExamRoomRepo;
|
|
import com.izouma.wenlvju.repo.RecordExamRoomRepo;
|
|
|
-import com.izouma.wenlvju.repo.RecordRepo;
|
|
|
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
|
-import jodd.util.StringUtil;
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
@@ -23,11 +21,7 @@ import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
import javax.persistence.criteria.Predicate;
|
|
|
-import java.time.LocalDate;
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -48,10 +42,10 @@ public class ExamRoomService {
|
|
|
/*
|
|
/*
|
|
|
查看设备列表
|
|
查看设备列表
|
|
|
*/
|
|
*/
|
|
|
- public List<String> showDevice() {
|
|
|
|
|
|
|
+ public Map<String, Integer> showDevice() {
|
|
|
String uri = "https://open.ys7.com/api/lapp/device/list";
|
|
String uri = "https://open.ys7.com/api/lapp/device/list";
|
|
|
String accessToken = ezvizTokenService.getToken();
|
|
String accessToken = ezvizTokenService.getToken();
|
|
|
- String send = "accessToken=" + accessToken + "&pageStart=0&pageSize=10";
|
|
|
|
|
|
|
+ String send = "accessToken=" + accessToken + "&pageStart=0&pageSize=50";
|
|
|
log.info("萤石查看设备--->" + send);
|
|
log.info("萤石查看设备--->" + send);
|
|
|
|
|
|
|
|
String body = HttpRequest.post(uri).send(send).body();
|
|
String body = HttpRequest.post(uri).send(send).body();
|
|
@@ -63,11 +57,12 @@ public class ExamRoomService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
JSONArray data = JSONObject.parseArray(json.getString("data"));
|
|
JSONArray data = JSONObject.parseArray(json.getString("data"));
|
|
|
- List<String> devices = new ArrayList<>();
|
|
|
|
|
|
|
+ Map<String, Integer> devices = new HashMap<>();
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
for (int i = 0; i < data.size(); i++) {
|
|
|
JSONObject jsonObject = data.getJSONObject(i);
|
|
JSONObject jsonObject = data.getJSONObject(i);
|
|
|
String name = jsonObject.getString("deviceSerial");
|
|
String name = jsonObject.getString("deviceSerial");
|
|
|
- devices.add(name);
|
|
|
|
|
|
|
+ int status = jsonObject.getInteger("status");
|
|
|
|
|
+ devices.put(name, status);
|
|
|
}
|
|
}
|
|
|
return devices;
|
|
return devices;
|
|
|
}
|
|
}
|
|
@@ -76,7 +71,7 @@ public class ExamRoomService {
|
|
|
添加设备
|
|
添加设备
|
|
|
*/
|
|
*/
|
|
|
public void addDevice(String deviceSerial, String validateCode) {
|
|
public void addDevice(String deviceSerial, String validateCode) {
|
|
|
- List<String> devices = this.showDevice();
|
|
|
|
|
|
|
+ Set<String> devices = this.showDevice().keySet();
|
|
|
if (devices.contains(deviceSerial)) {
|
|
if (devices.contains(deviceSerial)) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|