From 457822e37199dd74f6c3d1b7d16f920261084685 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期五, 19 七月 2024 19:05:26 +0800 Subject: [PATCH] 2024年07月19日19:05:20 --- app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java | 30 ++++++++++++++++++++---------- 1 files changed, 20 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java index 104b350..9a57ee2 100644 --- a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java +++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java @@ -909,20 +909,29 @@ */ public void getGatewayInfo(String mac, LinkCallBack<GatewayBean> linkCallBack) { String requestUrl = TopicApi.GET_GATEWAY_INFO; - TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, null, "", new HDLLinkCallBack() { + JsonObject json = new JsonObject(); + json.addProperty("device_mac", mac); + TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, json, "", new HDLLinkCallBack() { @Override public void onSuccess(String json) { - if (TextUtils.isEmpty(json)) { - if (linkCallBack != null) { - linkCallBack.onSuccess(null); - } + if (linkCallBack == null) { return; } - Gson gson = new Gson(); - GatewayBean gatewayBean = gson.fromJson(json, GatewayBean.class); - if (linkCallBack != null) { - linkCallBack.onSuccess(gatewayBean); + if (TextUtils.isEmpty(json)) { + linkCallBack.onSuccess(null); + return; } + + Gson gson = new Gson(); + Type typeOfT = new TypeToken<BaseLocalResponse<GatewayBean>>() { + }.getType(); + BaseLocalResponse<GatewayBean> baseLocalResponse = gson.fromJson(json, typeOfT); + if (baseLocalResponse == null || baseLocalResponse.getObjects() == null) { + linkCallBack.onSuccess(new GatewayBean()); + } else { + linkCallBack.onSuccess(baseLocalResponse.getObjects()); + } + } @Override @@ -1398,8 +1407,9 @@ HDLLinkConfig.getInstance().setGatewayId(deviceRemoteInfo.getGatewayId());//璁剧疆gatewayId } + gatewayBean.setHomeId(homeId);//浣忓畢id - gatewayBean.setDeviceStatus(cloudInverterDeviceBean.getDeviceStatus());//璁剧疆缃戝叧鐘舵�� + gatewayBean.setDeviceStatus(cloudInverterDeviceBean.getDeviceStatus());//璁剧疆缃戝叧鐘舵��(1 锛� 杩炴帴涓�,2 锛� 鏁呴殰, 3 锛� 杩愯,4 锛� 绂荤嚎) gatewayBean.setDeviceId(cloudInverterDeviceBean.getDeviceId());//璁剧疆link璁惧id gatewayBean.setDevice_mac(cloudInverterDeviceBean.getOsn());//璁剧疆mac gatewayBean.setOid(cloudInverterDeviceBean.getOid());//璁惧oid -- Gitblit v1.8.0