diff --git a/shibei-gird-sdk/src/main/java/com/elink/esua/epdc/gird/shibei/api/ShiBeiCityGridApi.java b/shibei-gird-sdk/src/main/java/com/elink/esua/epdc/gird/shibei/api/ShiBeiCityGridApi.java index 5a40f68..b3064c6 100644 --- a/shibei-gird-sdk/src/main/java/com/elink/esua/epdc/gird/shibei/api/ShiBeiCityGridApi.java +++ b/shibei-gird-sdk/src/main/java/com/elink/esua/epdc/gird/shibei/api/ShiBeiCityGridApi.java @@ -45,6 +45,16 @@ public interface ShiBeiCityGridApi { */ SendEventResultDto sendEvent(SendEventFormDto sendEventFormDto); + /** + * 手动事件上报 + * + * @param data + * @return com.elink.esua.epdc.gird.shibei.dto.result.SendEventResultDto + * @author zhy + * @date 2022/9/29 15:06 + */ + SendEventResultDto sendEventManual(String data); + /** * 评价事件接口 * diff --git a/shibei-gird-sdk/src/main/java/com/elink/esua/epdc/gird/shibei/api/impl/ShiBeiCityGridApiImpl.java b/shibei-gird-sdk/src/main/java/com/elink/esua/epdc/gird/shibei/api/impl/ShiBeiCityGridApiImpl.java index 837c85e..0941a32 100644 --- a/shibei-gird-sdk/src/main/java/com/elink/esua/epdc/gird/shibei/api/impl/ShiBeiCityGridApiImpl.java +++ b/shibei-gird-sdk/src/main/java/com/elink/esua/epdc/gird/shibei/api/impl/ShiBeiCityGridApiImpl.java @@ -106,6 +106,42 @@ public class ShiBeiCityGridApiImpl implements ShiBeiCityGridApi { return result; } + @Override + public SendEventResultDto sendEventManual(String data) { + data = "content="+ data; + LOGGER.info("发送参数:" + data); + LOGGER.info("发送地址:"+ApiConstants.sendEventUrl); + HttpResponse response = null; + try { + response = HttpRequest.post(ApiConstants.sendEventUrl).body(data) + .header("lan", "zh") + .header("Content-type", "application/x-www-form-urlencoded;charset=UTF-8").execute(); + } catch (Exception e) { + e.printStackTrace(); + LOGGER.error("事件上报信息异常:" + e.getMessage()); + } + LOGGER.info("事件上报返回数据:" + response.body()); + JSONObject res = JSONObject.parseObject(response.body()); + SendEventResultDto result = null; + if(0 == Integer.parseInt(res.get("code").toString())){ + try { + result = (SendEventResultDto) JSONObject.toJavaObject((JSONObject) res.get("data"), SendEventResultDto.class); + result.setCode("0"); + }catch (Exception e){ + e.printStackTrace(); + LOGGER.error("事件上报返回结果处理错误:" + e.getMessage()); + } + }else{ + try { + result = (SendEventResultDto) JSONObject.toJavaObject(res, SendEventResultDto.class); + }catch (Exception e){ + e.printStackTrace(); + LOGGER.error("事件上报返回结果处理错误:" + e.getMessage()); + } + } + return result; + } + @Override public GridDto sendWenXinEvaluateInfo(SendWenXinEvaluateInfoFormDto sendWenXinEvaluateInfoFormDto) { Map map = Maps.newHashMap();