| | |
| | | * // * @param validateCode 设备验证码,设备机身上的六位大写字母 |
| | | */ |
| | | public boolean addYSYMonitor(String deviceSerial, String validateCode) { |
| | | List<Monitor> list = list(Wrappers.lambdaQuery(Monitor.class).eq(Monitor::getDeviceSerial, deviceSerial)); |
| | | if (list.size() != 0) { |
| | | throw new BusinessException("该摄像头已存在,无法重复添加!"); |
| | | } |
| | | |
| | | Map<String, Object> paramMap = new HashMap<>(); |
| | | paramMap.put("accessToken", getAccessToken()); |
| | | paramMap.put("deviceSerial", deviceSerial); |
| | |
| | | paramMap.put("validateCode", validateCode); |
| | | } |
| | | String s = HttpUtil.post(YSY_URL + ADD_DEVICE_URL, paramMap); |
| | | if (!s.startsWith("{") && !s.endsWith("}")) { |
| | | throw new BusinessException("萤石云数据异常"); |
| | | } |
| | | |
| | | YSY_MonitorDto monitorDto = JSON.parseObject(s, YSY_MonitorDto.class); |
| | | |
| | | boolean result; |
| | | if ("200".equals(monitorDto.getCode()) || "20017".equals(monitorDto.getCode())) { |
| | | if ("20017".equals(monitorDto.getCode())) { |
| | | //当前摄像头已经被萤石云官网添加过,Code:20017 |
| | | monitorDto = getYSYMonitorInfo(getAccessToken(), deviceSerial); |
| | | |
| | | } else if (!"200".equals(monitorDto.getCode())) { |
| | | //当前摄像头成功被萤石云官网添加,Code:200 |
| | | throw new BusinessException(monitorDto.getMsg()); |
| | | } |
| | | |
| | | if (monitorDto.getData() == null) { |
| | | throw new BusinessException("萤石云数据异常!"); |
| | | } |
| | | Monitor monitor = new Monitor(); |
| | | monitor.setDeviceSerial(monitorDto.getData().getDeviceSerial()); |
| | | monitor.setDevicesCode(validateCode); |
| | |
| | | /** |
| | | * 新增摄像头结束 |
| | | */ |
| | | |
| | | } else { |
| | | result = false; |
| | | } |
| | | return result; |
| | | } |
| | | |