From d1bb52748505caa0c9bd9c71c4c91c1afba73847 Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期五, 30 六月 2023 18:11:05 +0800 Subject: [PATCH] 2023年06月30日18:11:01 --- app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java | 112 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 99 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java index 470427b..4e7f0d6 100644 --- a/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java +++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java @@ -10,8 +10,14 @@ import com.hdl.photovoltaic.internet.api.HttpApi; import com.hdl.photovoltaic.listener.BaseSuccessFailureCallBeak; import com.hdl.photovoltaic.listener.CloudCallBeak; +import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean; import com.hdl.photovoltaic.ui.bean.HouseInfoBean; import com.hdl.photovoltaic.ui.bean.HouseIdBean; +import com.hdl.sdk.link.common.exception.HDLLinkException; +import com.hdl.sdk.link.core.bean.gateway.GatewayBean; +import com.hdl.sdk.link.core.callback.GatewayCallBack; +import com.hdl.sdk.link.core.config.HDLLinkConfig; +import com.hdl.sdk.link.gateway.HDLLinkLocalGateway; import java.util.ArrayList; import java.util.List; @@ -253,13 +259,19 @@ HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() { @Override public void onSuccess(HttpResponsePack httpResponsePack) { - if (httpResponsePack != null && httpResponsePack.getData() != null) { - Gson gson = new Gson(); - String jsonStr = gson.toJson(httpResponsePack.getData()); - HouseInfoBean houseInfoBean = gson.fromJson(jsonStr, HouseInfoBean.class); + try { + if (httpResponsePack != null && httpResponsePack.getData() != null) { + Gson gson = new Gson(); + String jsonStr = gson.toJson(httpResponsePack.getData()); + HouseInfoBean houseInfoBean = gson.fromJson(jsonStr, HouseInfoBean.class); + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(houseInfoBean); + } + } + } catch (Exception exception) { if (cloudCallBeak != null) { - cloudCallBeak.onSuccess(houseInfoBean); + cloudCallBeak.onFailure(exception); } } } @@ -406,6 +418,37 @@ } + /** + * 鑾峰彇浣忓畢鍥剧墖 + */ + public void getResidenceImage(String imageUrl, CloudCallBeak<List<HouseIdBean>> cloudCallBeak) { + String requestUrl = imageUrl; + JsonObject json = new JsonObject(); + List<HouseIdBean> list = new ArrayList<>(); + HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() { + @Override + public void onSuccess(HttpResponsePack httpResponsePack) { + if (httpResponsePack != null && httpResponsePack.getData() != null) { + Gson gson = new Gson(); + String jsonStr = gson.toJson(httpResponsePack.getData()); + HouseBeanClass houseInfoBeanClass = gson.fromJson(jsonStr, HouseBeanClass.class); + } else { + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(list); + } + } + } + + @Override + public void onFailure(Exception exception) { + if (cloudCallBeak != null) { + cloudCallBeak.onFailure(exception); + } + } + }); + + + } /** * 娣诲姞銆愪綇瀹呰鎯呫�戝埌鏈湴缂撳瓨 @@ -471,17 +514,60 @@ /** * 鍒囨崲浣忓畢 * - * @param homeId 浣忓畢id + * @param houseIdBean 浣忓畢Id瀵硅薄 */ - public Boolean switchHouse(String homeId) { - UserConfigManage.getInstance().setHomeId(homeId); - HdlThreadLogic.runThread(new Runnable() { + public void switchHouse(HouseIdBean houseIdBean) { + String oidHomeId = UserConfigManage.getInstance().getHomeId(); +// if (houseIdBean.getHomeId().equals(oidHomeId)) { +// return; +// } + //鍒犻櫎鏃х殑浣忓畢鏂囦欢澶� + HdlFileLogic.getInstance().deleteDirectory(HdlFileLogic.getInstance().getCurrentHomeRootPath()); + //閲嶆柊璁剧疆浣忓畢id + UserConfigManage.getInstance().setHomeId(houseIdBean.getHomeId()); + //閲嶆柊璁剧疆鏈湴閫氳绉橀挜 + UserConfigManage.getInstance().setLocalSecret(houseIdBean.getLocalSecret()); + //閲嶆柊鍒涘缓浣忓畢鏂囦欢澶� + HdlFileLogic.getInstance().createDirectory(); + //閰嶇疆鏈湴閫氫俊鐨勪俊鎭� + initLocalLinkSdk(); + +// HdlDeviceLogic.getInstance().getInverterDeviceList(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<CloudInverterDeviceBean>() { +// @Override +// public void onSuccess(CloudInverterDeviceBean obj) { +// +// +// } +// +// @Override +// public void onFailure(Exception exception) { +// +// } +// }); + HdlDeviceLogic.getInstance().searchGateway(new GatewayCallBack() { @Override - public void run() { - //鎼滅储涓�涓嬩綇瀹呰澶� + public void onSuccess(List<GatewayBean> gatewayBeanList) { + } - }, null, null); - return true; + + @Override + public void onError(HDLLinkException e) { + + } + }); + + + + } + + /** + * 閰嶇疆鏈湴閫氫俊鐨勪俊鎭�(tcp閫氫俊鐢ㄥ埌) + */ + private void initLocalLinkSdk() { + HDLLinkConfig.getInstance().setHomeId(UserConfigManage.getInstance().getHomeId()); + HDLLinkConfig.getInstance().setLocalSecret(UserConfigManage.getInstance().getLocalSecret()); + + } -- Gitblit v1.8.0