From 6cd8ba22b99f5dff56630f07fc7154c57cdc01f2 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Thu, 22 Sep 2022 10:09:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gird/city/api/impl/CityGridApiImpl.java | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/shibei-gird-sdk/src/main/java/com/elink/esua/epdc/gird/city/api/impl/CityGridApiImpl.java b/shibei-gird-sdk/src/main/java/com/elink/esua/epdc/gird/city/api/impl/CityGridApiImpl.java index 2e26d90..ded45cf 100644 --- a/shibei-gird-sdk/src/main/java/com/elink/esua/epdc/gird/city/api/impl/CityGridApiImpl.java +++ b/shibei-gird-sdk/src/main/java/com/elink/esua/epdc/gird/city/api/impl/CityGridApiImpl.java @@ -39,30 +39,33 @@ public class CityGridApiImpl implements CityGridApi { response = HttpRequest.post(httpUrl).body(data) .header("lan", "zh") .header("Content-type", "application/json").execute(); + LOGGER.info(interFaceName + "返回数据:" + 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(interFaceName + "返回结果处理错误:" + e.getMessage()); + // } + // } else { + // try { + // result = (SendEventResultDto) JSONObject.toJavaObject(res, SendEventResultDto.class); + // } catch (Exception e) { + // e.printStackTrace(); + // LOGGER.error(interFaceName + "返回结果处理错误:" + e.getMessage()); + // } + } } catch (Exception e) { - e.printStackTrace(); LOGGER.error(interFaceName + "信息异常:" + e.getMessage()); + SendEventResultDto dto = new SendEventResultDto(); + dto.setCode("-1"); + dto.setMessage(null == response?"调用接口失败":response.body()); + return JSONObject.toJSONString(dto); } - LOGGER.info(interFaceName + "返回数据:" + 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(interFaceName + "返回结果处理错误:" + e.getMessage()); -// } -// } else { -// try { -// result = (SendEventResultDto) JSONObject.toJavaObject(res, SendEventResultDto.class); -// } catch (Exception e) { -// e.printStackTrace(); -// LOGGER.error(interFaceName + "返回结果处理错误:" + e.getMessage()); -// } - } - return response.body(); }