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 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(); } } }