| | |
| | | |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.JsonObject; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.linkpm.sdk.home.type.HomeType; |
| | |
| | | import com.hdl.photovoltaic.databinding.ActivityCpowerStationBinding; |
| | | import com.hdl.photovoltaic.enums.NetworkType; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlDeviceLogic; |
| | | import com.hdl.photovoltaic.other.HdlESLocalJsonLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | |
| | | import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo; |
| | | import com.hdl.photovoltaic.ui.bean.HouseIdBean; |
| | | import com.hdl.photovoltaic.ui.bean.OidBean; |
| | | import com.hdl.photovoltaic.ui.newC.PowerStationsListActivity; |
| | | import com.hdl.photovoltaic.ui.newC.PowerStationsMoveActivity; |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.uni.HDLUniMPSDKManager; |
| | | import com.hdl.photovoltaic.utils.AppManagerUtils; |
| | |
| | | String path = HDLUniMP.UNI_EVENT_OPEN_HOME_Null_C; |
| | | HdlUniLogic.getInstance().openUniMP(path, null); |
| | | } else { |
| | | //解决问题手机没有网自动登录进来,默认传上一次的住宅id |
| | | //1,解决手机没有外网,获取不到电站列表,自动登录进来,默认传上一次的住宅id; |
| | | //2,之前电站列表只有一个电站,然后删除掉电站,这时住宅id还缓存着,再一次进来,默认传上一次的住宅id; |
| | | String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS_C + "?homeId=" + UserConfigManage.getInstance().getHomeId() + "&homeName=" + UserConfigManage.getInstance().getHomeName(); |
| | | HdlUniLogic.getInstance().openUniMP(path, null); |
| | | } |
| | | } else { |
| | | |
| | | int select_home = 0; |
| | | for (int i = 0; i < HouseIdList.size(); i++) { |
| | | if (HouseIdList.get(i).getHomeId().equals(UserConfigManage.getInstance().getHomeId())) { |
| | | select_home = i; |
| | | break; |
| | | if (!TextUtils.isEmpty(UserConfigManage.getInstance().getHomeId())) {//本地缓存住宅id不为空再遍历查找 |
| | | for (int i = 0; i < HouseIdList.size(); i++) { |
| | | if (HouseIdList.get(i).getHomeId().equals(UserConfigManage.getInstance().getHomeId())) { |
| | | select_home = i; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | HouseIdBean houseIdBean = HouseIdList.get(select_home); |
| | |
| | | } |
| | | } |
| | | if (!TextUtils.isEmpty(registrationID)) { |
| | | UserConfigManage.getInstance().setRegistrationID(registrationID); |
| | | UserConfigManage.getInstance().Save(); |
| | | // UserConfigManage.getInstance().setRegistrationID(registrationID); |
| | | // UserConfigManage.getInstance().Save(); |
| | | String finalRegistrationID = registrationID; |
| | | HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String pushId) { |
| | | |
| | | if (!TextUtils.isEmpty(pushId)) { |
| | | UserConfigManage.getInstance().setRegistrationID(finalRegistrationID); |
| | | UserConfigManage.getInstance().setPushId(pushId); |
| | | UserConfigManage.getInstance().Save(); |
| | | } |
| | |
| | | // HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | HdlLogLogic.print(linkResponse.getTopic() + new Gson().toJson(linkResponse.getData()), true); |
| | | // HdlDeviceLogic.getInstance().searchAllNetworkGateway(null);//逆变器wifi状态-重新搜索一下逆变器-重新更新连接状态 |
| | | } else if (linkResponse.getTopic().endsWith("/app/thing/event/appHomeRefresh/up")) { |
| | | try { |
| | | //住宅交付状态回滚通知 |
| | | String[] topicArray = linkResponse.getTopic().split("/"); |
| | | if (topicArray.length < 2) { |
| | | return; |
| | | } |
| | | final String HomeId = topicArray[1]; |
| | | //先删除电站 |
| | | HdlResidenceLogic.getInstance().delHouseId(HomeId); |
| | | List<HouseIdBean> localHouseIdList = HdlResidenceLogic.getInstance().getHouseIdList(); |
| | | if (localHouseIdList.isEmpty()) { |
| | | JsonObject jsonObject = new JsonObject(); |
| | | jsonObject.addProperty("homeId", ""); |
| | | HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_REFRESH_DETAILS); |
| | | uniCallBackBaseBean.setData(jsonObject); |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | } else { |
| | | if (HomeId.equals(UserConfigManage.getInstance().getHomeId()) || TextUtils.isEmpty(UserConfigManage.getInstance().getHomeId())) { |
| | | HouseIdBean houseIdBean = localHouseIdList.get(0); |
| | | HdlResidenceLogic.getInstance().switchHouse(houseIdBean, true); |
| | | JsonObject jsonObject = new JsonObject(); |
| | | jsonObject.addProperty("homeId", houseIdBean.getHomeId()); |
| | | jsonObject.addProperty("homeName", houseIdBean.getHomeName()); |
| | | jsonObject.addProperty("powerStationStatus", houseIdBean.getPowerStationStatus() + ""); |
| | | HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_REFRESH_DETAILS); |
| | | uniCallBackBaseBean.setData(jsonObject); |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | } |
| | | if (AppManagerUtils.getAppManager().existsTopActivity(PowerStationsListActivity.class, PowerStationsMoveActivity.class)) { |
| | | //存在栈里再通知更新 |
| | | HdlCommonLogic.getInstance().postEventBus(ConstantManage.REFRESH_HOME_LIST, ConstantManage.REFRESH_HOME_LIST); |
| | | } |
| | | HdlLogLogic.print(linkResponse.getTopic() + new Gson().toJson(linkResponse.getData()), true); |
| | | } |
| | | |
| | | } |