| | |
| | | |
| | | public void startPic(String ip, String filename) { |
| | | try { |
| | | if (hikUrl == null || "".equals(hikUrl)) { |
| | | News.error("hikUrl配置为空,无法进行拍摄"); |
| | | return; |
| | | } |
| | | if (ip == null || "".equals(ip)) { |
| | | News.error("IP地址为空,无法进行拍摄"); |
| | | return; |
| | | } |
| | | if (filename == null || "".equals(filename)) { |
| | | News.error("文件名为空,无法进行拍摄"); |
| | | return; |
| | | } |
| | | HashMap<String, Object> data = new HashMap<>(); |
| | | data.put("ip", ip); |
| | | data.put("filename", filename); |
| | |
| | | .setJson(JSON.toJSONString(data)) |
| | | .build() |
| | | .doPost(); |
| | | if (response == null || "".equals(response)) { |
| | | News.error("请求接口失败,返回值为空"); |
| | | return; |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | if (jsonObject == null) { |
| | | News.error("解析响应失败,返回值不是有效的JSON"); |
| | | return; |
| | | } |
| | | Boolean success = jsonObject.getBoolean("success"); |
| | | if (success != null && success) { |
| | | News.error("请求接口成功!!!url:{};request:{};response:{}", hikUrl + "/capture", JSON.toJSONString(data), response); |
| | | } else { |
| | | News.error("请求接口失败!!!url:{};request:{};response:{}", hikUrl + "/capture", JSON.toJSONString(data), response); |
| | | } |
| | | } catch (Exception e) { |
| | | News.error("拍摄失败:{}", e.getMessage()); |
| | | e.printStackTrace(); |
| | | } |
| | | } |