From 0770fc4f03196a27e8f4c899a44da63bb1a683e2 Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期四, 12 六月 2025 18:17:29 +0800 Subject: [PATCH] 2025年06月12日18:17:27 --- app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java | 97 ++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 80 insertions(+), 17 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 01af048..1db0a91 100644 --- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java +++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java @@ -10,7 +10,6 @@ import android.location.Location; import android.location.LocationManager; import android.os.IBinder; -import android.os.SystemClock; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; @@ -50,7 +49,6 @@ import com.hdl.photovoltaic.ui.bean.DeviceTimeBean; import com.hdl.photovoltaic.ui.bean.Geolocation; import com.hdl.photovoltaic.ui.bean.HouseIdBean; -import com.hdl.photovoltaic.ui.bean.HouseInfoBean; import com.hdl.photovoltaic.ui.bean.LinkBean; import com.hdl.photovoltaic.ui.bean.MemberBean; import com.hdl.photovoltaic.ui.bean.NotRunBean; @@ -62,11 +60,12 @@ import com.hdl.photovoltaic.ui.me.AsRegardsActivity; import com.hdl.photovoltaic.ui.me.CPersonalDataActivity; import com.hdl.photovoltaic.ui.me.SetActivity; -import com.hdl.photovoltaic.ui.newC.MessageCenterList; -import com.hdl.photovoltaic.ui.newC.PowerStationsListEdit; +import com.hdl.photovoltaic.ui.newC.MessageCenterListActivity; +import com.hdl.photovoltaic.ui.newC.PowerStationsListActivity; import com.hdl.photovoltaic.uni.HDLUniMP; import com.hdl.photovoltaic.uni.HDLUniMPSDKManager; import com.hdl.photovoltaic.utils.NetworkUtils; +import com.hdl.photovoltaic.utils.PermissionUtils; import com.hdl.photovoltaic.utils.WifiUtils; import com.hdl.sdk.link.common.exception.HDLLinkException; import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; @@ -81,7 +80,6 @@ import com.hdl.sdk.link.gateway.HDLLinkLocalGateway; import org.greenrobot.eventbus.EventBus; -import org.json.JSONArray; import org.json.JSONObject; @@ -148,7 +146,7 @@ String type = getKeyValue("type", data);//灏忕被 String logTag = getKeyValue("logTag", data);//鏍囪uni鎸囦护 String mode_type = "澶х被-" + topic + "---" + "灏忕被-" + type;//鐢ㄦ潵鎵撳嵃鐨� - HdlLogLogic.print(logTag + ":" + "uni---鍙戦��---" + mode_type + "\r\n" + data, true); + HdlLogLogic.print(logTag + ":" + "uni---鍙戦��---" + mode_type + "---" + data, true); if (HDLUniMP.UNI_EVENT_REPLY_USER_MODEL.equals(topic)) { //鐢ㄦ埛妯″潡 switch (type) { @@ -178,7 +176,7 @@ jsonObject.addProperty("appKey", AppConfigManage.getAppKey()); jsonObject.addProperty("appSecret", AppConfigManage.getAppSecret()); uniSuccessCallback(mode_type, jsonObject, callback); - HdlLogLogic.print("鑾峰彇鐢ㄦ埛鏈湴缂撳瓨淇℃伅---->>>" + jsonObject.toString()); + HdlLogLogic.print("鑾峰彇鐢ㄦ埛鏈湴缂撳瓨淇℃伅----" + jsonObject.toString()); } break; } @@ -206,8 +204,22 @@ break; //鍒涘缓鐢电珯 case HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION: { + //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡 +// HdlResidenceLogic.getInstance().getResidenceIdList("","","","","","",1,50,null); + try { + String dataJsonStr = getKeyValue("data", data); + if (!TextUtils.isEmpty(dataJsonStr)) { + Gson gson = new Gson(); + HouseIdBean houseIdBean = gson.fromJson(dataJsonStr, HouseIdBean.class); + HdlResidenceLogic.getInstance().switchHouse(houseIdBean, true); + } + HdlLogLogic.print("uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡---" + dataJsonStr, true); + } catch (Exception e) { + HdlLogLogic.print("uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡---" + e.getMessage(), true); + } + //EventBus浜嬩欢鍒嗗彂 - HdlCommonLogic.getInstance().postEventBus(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL, HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION, getKeyValue("data", data)); +// HdlCommonLogic.getInstance().postEventBusSticky(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL, HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION, getKeyValue("data", data)); if (callback != null) { uniSuccessCallback(type, null, callback); } @@ -387,6 +399,16 @@ WifiUtils wifiUtils = WifiUtils.getInstance(); //wifi妯″潡 switch (type) { + //鑾峰彇浣嶇疆鏉冮檺 + case HDLUniMP.UNI_EVENT_REPLY_AUTHORIZATION_GET: { + boolean isLocalAuthor = PermissionUtils.checkPermission(HDLApp.getInstance(), Manifest.permission.ACCESS_FINE_LOCATION); + if (callback != null) { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("localAuthor", isLocalAuthor); + uniSuccessCallback(mode_type, jsonObject, callback); + } + } + break; //鑾峰彇鎵嬫満wifi鍒楄〃 case HDLUniMP.UNI_EVENT_REPLY_PHONE_WIFI_LIST: { if (callback != null) { @@ -537,7 +559,7 @@ case HDLUniMP.UNI_EVENT_REPLY_MINE_SELECTED_POWERSTATION: { Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.setClass(HDLApp.getInstance(), PowerStationsListEdit.class); + intent.setClass(HDLApp.getInstance(), PowerStationsListActivity.class); HDLApp.getInstance().startActivity(intent); } break; @@ -547,7 +569,7 @@ String isShowFault = getKeyValue("isShowFault", getKeyValue("data", data)); Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.setClass(HDLApp.getInstance(), MessageCenterList.class); + intent.setClass(HDLApp.getInstance(), MessageCenterListActivity.class); if (!TextUtils.isEmpty(homeId)) { intent.putExtra("homeId", homeId); } @@ -645,6 +667,7 @@ } else if (HDLUniMP.UNI_EVENT_REPLY_OTHER_MODEL.equals(topic)) { //鍏跺畠妯″潡 switch (type) { + //鑾峰彇娓╁害鍗曚綅 case HDLUniMP.UNI_EVENT_REPLY_OTHER_UNIT: { uniSuccessCallback(mode_type, UserConfigManage.getInstance().getTemperature_unit(), callback); @@ -683,6 +706,7 @@ break; //uni閫氱煡鍘熺敓閫�鍑虹櫥褰� case HDLUniMP.UNI_EVENT_REPLY_OTHER_LOGOUT: { + HdlLogLogic.print("uni閫氱煡鍘熺敓閫�鍑虹櫥褰�---", true); HDLLinkPMUser.getInstance().logout(0); } break; @@ -729,7 +753,7 @@ String json = HdlESLocalJsonLogic.getInstance().readHdlESLocalJson(fileName + ".json", deviceModel); if (TextUtils.isEmpty(json)) { //鏈湴娌℃湁缂撳瓨 - HdlESLocalJsonLogic.getInstance().getHdlESLocalJson(fileName, deviceType, deviceModel, new CloudCallBeak<String>() { + HdlESLocalJsonLogic.getInstance().getHdlESLocalJson(fileName, deviceType, deviceModel, false, new CloudCallBeak<String>() { @Override public void onSuccess(String obj) { // if (callback != null) { @@ -782,6 +806,36 @@ //uni鑾峰彇鍥剧墖 case HDLUniMP.UNI_EVENT_REPLY_OTHER_GET_SELECTED_IMAGE: { + } + break; + } + } else if (HDLUniMP.UNI_EVENT_REPLY_NO_WORK_MODEL.equals(topic)) { + //鏃犵綉妯″紡 + switch (type) { + + case HDLUniMP.UNI_EVENT_REPLY_NO_WORK_MODEL_EXIT: { + //閫�鍑烘棤缃戞ā寮忔爣璇� + UserConfigManage.getInstance().setNoNetworkFlag(false); + UserConfigManage.getInstance().Save(); + } + break; + case HDLUniMP.UNI_EVENT_REPLY_NO_WORK_MODEL_DEVICE_INFO: { + try { + //杩涘叆鏃犵綉妯″紡閫嗗彉鍣ㄨ鎯呴〉锛岀紦瀛榤ac鍜屽瘑鐮� + String mac = getKeyValue("mac", getKeyValue("data", data)); + String password = getKeyValue("password", getKeyValue("data", data)); + UserConfigManage.getInstance().setNoNetworkDeviceMac(mac); + UserConfigManage.getInstance().setNoNetworkPassword(password); + UserConfigManage.getInstance().Save(); + } catch (Exception ignored) { + } + } + break; + case HDLUniMP.UNI_EVENT_REPLY_NO_WORK_MODEL_CLEAR_DEVICE_INFO: { + //鏃犵綉妯″紡閫嗗彉鍣ㄨ鎯呴〉锛屾竻闄ょ紦瀛榤ac鍜屽瘑鐮� + UserConfigManage.getInstance().setNoNetworkDeviceMac(""); + UserConfigManage.getInstance().setNoNetworkPassword(""); + UserConfigManage.getInstance().Save(); } break; } @@ -1309,11 +1363,20 @@ //瑙e瘑璐熻浇鏁版嵁(鍐欏瘑閽ョ粰缃戝叧涓�瀹氭槸鏄庢枃锛屽洜涓洪偅鏃剁綉鍏宠繕娌℃湁瀵嗛挜) TcpClient.getInstance().sendDataToLinkGateway(mac, false, TopicApi, jsonArray, "", new HDLLinkCallBack() { @Override - public void onSuccess(String msg) { + public void onSuccess(String s) { if (callback != null) { - uniSuccessCallback(type, msg, callback); + try { + if (s.startsWith("{")) { + uniSuccessCallback(type, new Gson().fromJson(s, JsonObject.class), callback); + } else if (s.startsWith("[")) { + uniSuccessCallback(type, new Gson().fromJson(s, JsonArray.class), callback); + } else { + uniSuccessCallback(type, s, callback); + } + } catch (Exception e) { + uniSuccessCallback(type, s, callback); + } } - } @Override @@ -2006,7 +2069,7 @@ UserConfigManage.getInstance().setBingEmail(cUserInfo.getMemberEmail()); UserConfigManage.getInstance().setUserImageUrl(cUserInfo.getMemberHeadIcon()); UserConfigManage.getInstance().Save(); - HdlLogLogic.print("澶村儚璺緞---->>>" + cUserInfo.getMemberHeadIcon()); + HdlLogLogic.print("澶村儚璺緞----" + cUserInfo.getMemberHeadIcon()); } @Override @@ -2388,6 +2451,7 @@ */ private void uniGetCurrentHomeLocalAndCloudGatewayList(String type, Object data, DCUniMPJSCallback callback) { String homeId = getKeyValue("homeId", getKeyValue("data", data)); +// UserConfigManage.getInstance().setHomeId(homeId); HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(homeId, new CloudCallBeak<List<GatewayBean>>() { @Override public void onSuccess(List<GatewayBean> list) { @@ -2893,8 +2957,7 @@ uniCallBackBaseBean.setData(obj); if (callback != null) { callback.invoke(getJSONObject(uniCallBackBaseBean)); -// callback.invoke(uniCallBackBaseBean); - HdlLogLogic.print("鍥炲---uni---" + type + "---" + new Gson().toJson(uniCallBackBaseBean), true); + HdlLogLogic.print("鍥炲---uni---" + type + "---" + getJSONObject(uniCallBackBaseBean).toString(), true); } } catch (Exception e) { HdlLogLogic.print("鍥炲---uni---" + type + "---" + e.getMessage(), true); -- Gitblit v1.8.0