From 47dfa3614abfc1532fc33a612b4d4e1cb23e90a8 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期五, 25 十月 2024 11:47:10 +0800 Subject: [PATCH] 2024年10月25日11:46:51 --- app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 45 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java index 1c33af8..80fb4b7 100644 --- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java +++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java @@ -46,6 +46,7 @@ import com.hdl.photovoltaic.ui.bean.BUserInfo; import com.hdl.photovoltaic.ui.bean.CUserInfo; import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean; +import com.hdl.photovoltaic.ui.bean.DeviceInfoBean; import com.hdl.photovoltaic.ui.bean.DeviceTimeBean; import com.hdl.photovoltaic.ui.bean.Geolocation; import com.hdl.photovoltaic.ui.bean.HouseIdBean; @@ -165,6 +166,16 @@ jsonObject.addProperty("user_name", UserConfigManage.getInstance().getUserName()); jsonObject.addProperty("user_image_url", UserConfigManage.getInstance().getUserImageUrl()); jsonObject.addProperty("user_account", UserConfigManage.getInstance().getAccount()); + + jsonObject.addProperty("token", HDLLinkPMUser.getInstance().getAccessToken()); + jsonObject.addProperty("refreshToken", HDLLinkPMUser.getInstance().getRefreshToken()); + if (TextUtils.isEmpty(AppConfigManage.getUserRegionUrl())) { + AppConfigManage.setUserRegionUrl(HDLLinkPMUser.getInstance().getUserRegionUrl()); + } + jsonObject.addProperty("serverAddress", AppConfigManage.getUserRegionUrl()); + jsonObject.addProperty("appKey", AppConfigManage.getAppKey()); + jsonObject.addProperty("appSecret", AppConfigManage.getAppSecret()); + uniSuccessCallback(mode_type, jsonObject, callback); } @@ -361,7 +372,12 @@ break; //蹇嵎寮�鍚�嗗彉鍣� case HDLUniMP.UNI_EVENT_REPLY_DEVICE_OPEN_DEVICE_LIST: { - this.uniOidEditName(mode_type, data, callback); + this.uniSetDeviceStartup(mode_type, data, callback); + } + break; + //鑾峰彇璁惧璇︽儏 + case HDLUniMP.UNI_EVENT_REPLY_DEVICE_OPEN_DEVICE_info: { + this.uniGetDeviceInfo(mode_type, data, callback); } break; } @@ -2475,10 +2491,35 @@ public void uniSetDeviceStartup(String type, Object data, DCUniMPJSCallback callback) { String homeId = getKeyValue("homeId", getKeyValue("data", data)); String aryJson = getKeyValue("deviceIds", getKeyValue("data", data)); - HdlDeviceLogic.getInstance().setDeviceStartup(homeId, aryJson, new CloudCallBeak<Boolean>() { + JsonArray jsonArray = new Gson().fromJson(aryJson, JsonArray.class); + HdlDeviceLogic.getInstance().setDeviceStartup(homeId, jsonArray, new CloudCallBeak<Boolean>() { @Override public void onSuccess(Boolean obj) { uniSuccessCallback(type, obj, callback); + } + + @Override + public void onFailure(HDLException e) { + uniCallbackData(type, null, e.getCode(), e.getMsg(), callback); + } + }); + } + + /** + * 鑾峰彇璁惧璇︽儏 + * + * @param type 绫诲瀷 + * @param data uni璇锋眰鏁版嵁 + * @param callback uni鍥炶皟 + */ + public void uniGetDeviceInfo(String type, Object data, DCUniMPJSCallback callback) { + String homeId = getKeyValue("homeId", getKeyValue("data", data)); + String aryJson = getKeyValue("deviceIds", getKeyValue("data", data)); + JsonArray jsonArray = new Gson().fromJson(aryJson, JsonArray.class); + HdlDeviceLogic.getInstance().getDeviceInfo(homeId, jsonArray, new CloudCallBeak<List<DeviceInfoBean>>() { + @Override + public void onSuccess(List<DeviceInfoBean> list) { + uniSuccessCallback(type, list, callback); } @Override @@ -2560,8 +2601,8 @@ } if (isTokenAndRefreshToken) { //灏忕▼搴忛偅閲屾湁鑷繁鐨勮姹傛柟娉�,浣嗛渶瑕佸師鐢熸彁渚涜繖浜涙暟鎹� - data.put("token", UserConfigManage.getInstance().getToken()); - data.put("refreshToken", UserConfigManage.getInstance().getRefreshToken()); + data.put("token", HDLLinkPMUser.getInstance().getAccessToken()); + data.put("refreshToken", HDLLinkPMUser.getInstance().getRefreshToken()); if (TextUtils.isEmpty(AppConfigManage.getUserRegionUrl())) { AppConfigManage.setUserRegionUrl(HDLLinkPMUser.getInstance().getUserRegionUrl()); } -- Gitblit v1.8.0