feat(招商发送请求封装):
This commit is contained in:
parent
1e68d2bfcf
commit
ba39ca8472
|
@ -0,0 +1,36 @@
|
|||
package com.ruoyi.sensor.merchants;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import com.ruoyi.sensor.domain.WarningStatusInfo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MerchantsHttp {
|
||||
private static final Logger log = LoggerFactory.getLogger(MerchantsHttp.class);
|
||||
|
||||
private static final String uri = "http://localhost:8080/merchants";
|
||||
|
||||
public static void sendWarning(WarningStatusInfo warningStatusInfo){
|
||||
String jsonString = JSON.toJSONString(warningStatusInfo);
|
||||
String result = null;
|
||||
Map<String, String> header = new HashMap<>();
|
||||
try {
|
||||
result = HttpUtils.postCall(uri, jsonString, header);
|
||||
} catch (Exception e) {
|
||||
log.error("send warning error", e);
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isEmpty(result)) {
|
||||
log.error("send warning error");
|
||||
return;
|
||||
}
|
||||
// 记录上报结果
|
||||
log.info(result);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue