zwl
23 小时以前 fcf47692a8115c53855e5f7a593238306cd59e69
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
package com.zy.common.utils;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
 
import java.util.HashMap;
 
@Component
public class HikUtils {
 
    @Value("${zyHikUrl}")
    private String hikUrl;
 
    public void startPic(String ip, String filename) {
        try {
            HashMap<String, Object> data = new HashMap<>();
            data.put("ip", ip);
            data.put("filename", filename);
 
            String response = new HttpHandler.Builder()
                    .setUri(hikUrl)
                    .setPath("/startPic")
                    .setJson(JSON.toJSONString(data))
                    .build()
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
            if (jsonObject.getInteger("code").equals(200)) {
                News.error("请求接口成功!!!url:{};request:{};response:{}", hikUrl + "/startPic", JSON.toJSONString(data), response);
            } else {
                News.error("请求接口失败!!!url:{};request:{};response:{}", hikUrl + "/startPic", JSON.toJSONString(data), response);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
}