| | |
| | | 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.linkpm.sdk.user.HDLLinkPMUser; |
| | | import com.hdl.photovoltaic.HDLApp; |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.base.CustomBaseActivity; |
| | |
| | | import com.hdl.photovoltaic.enums.NetworkType; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlDeviceLogic; |
| | | import com.hdl.photovoltaic.other.HdlESLocalJsonLogic; |
| | | import com.hdl.photovoltaic.other.HdlFileLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.other.HdlMqttLogic; |
| | | import com.hdl.photovoltaic.other.HdlOtaLogic; |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | setNotificationBarBackgroundColor(CustomColor.white); |
| | | // setNotificationBarBackgroundColor(CustomColor.white); |
| | | getWindow().setStatusBarColor(getColor(R.color.text_FFFFFFFF)); |
| | | setStatusBarTextColor(); |
| | | //C端启动App自动打开小程序电站详情界面 |
| | | startAppAutomaticallyOpenUni(); |
| | |
| | | this.initMqttClient(); |
| | | //上传极光注册ID到云端 |
| | | this.pushTokens(); |
| | | |
| | | //获取云端脚本 |
| | | HdlESLocalJsonLogic.getInstance().getAllHdlESLocalJson(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //低于安卓14版本 |
| | | if (android.os.Build.VERSION.SDK_INT < 34) { |
| | | startAppAutomaticallyOpenUni(false); |
| | | } else { |
| | | startAppAutomaticallyOpenUni(true); |
| | | } |
| | | startAppAutomaticallyOpenUni(false); |
| | | // //低于安卓14版本 |
| | | // if (android.os.Build.VERSION.SDK_INT < 34) { |
| | | // startAppAutomaticallyOpenUni(false); |
| | | // } else { |
| | | // startAppAutomaticallyOpenUni(false); |
| | | // } |
| | | } |
| | | }); |
| | | } |
| | |
| | | } else if (event.getTopic().contains(HDLUniMP.UNI_EVENT_REPLY_OTHER_MODEL) && event.getType().contains(HDLUniMP.UNI_EVENT_REPLY_OTHER_BACK)) { |
| | | //物理按键返回事件(包括左滑移除事件) |
| | | killProcessApp(); |
| | | } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(event.getType())) { |
| | | if (MqttRecvClient.getInstance() != null) { |
| | | MqttRecvClient.getInstance().removeAllTopic(); |
| | | } |
| | | String homeId = event.getData().toString(); |
| | | //进去住宅详情uni读取逆变器列表成功后通知 |
| | | for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId).size(); i++) { |
| | | String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId).get(i).getGatewayId(); |
| | | //字符串是自己按规则拼接的,里面注册主题时会解析字符串,只拿getGatewayId()值; |
| | | String topic = "/user/" + gatewayId + "/#"; |
| | | //进去住宅详情开始订阅主题 |
| | | MqttRecvClient.getInstance().checkAndsubscribeAllTopics(topic);//订阅【逆变器】消息 |
| | | |
| | | } |
| | | String topicHome = "/user/" + homeId + "/#"; |
| | | MqttRecvClient.getInstance().checkAndsubscribeAllTopics(topicHome);//订阅【电站】消息 |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | private void startAppAutomaticallyOpenUni(boolean delay) { |
| | | |
| | | if (delay) { |
| | | SystemClock.sleep(2000); |
| | | // if (delay) { |
| | | // SystemClock.sleep(2000); |
| | | // } |
| | | if (TextUtils.isEmpty(HDLLinkPMUser.getInstance().getAccessToken())) { |
| | | //其实刷新token失败已通知退出登录,数据已经清空,因为等2s uni加载慢导致请求链接的时候出现token为空 |
| | | return; |
| | | } |
| | | List<HouseIdBean> HouseIdList = HdlResidenceLogic.getInstance().getHouseIdList(); |
| | | if (HouseIdList.size() == 0) { |
| | | String path = HDLUniMP.UNI_EVENT_OPEN_HOME_Null_C; |
| | | if(delay){ |
| | | HdlUniLogic.getInstance().openUniMPDelay(path, null); |
| | | }else { |
| | | if (TextUtils.isEmpty(UserConfigManage.getInstance().getHomeId())) { |
| | | String path = HDLUniMP.UNI_EVENT_OPEN_HOME_Null_C; |
| | | HdlUniLogic.getInstance().openUniMP(path, null); |
| | | } else { |
| | | //解决问题手机没有网自动登录进来,默认传上一次的住宅id |
| | | String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS_C + "?homeId=" + UserConfigManage.getInstance().getHomeId() + "&homeName=" + UserConfigManage.getInstance().getHomeName(); |
| | | HdlUniLogic.getInstance().openUniMP(path, null); |
| | | } |
| | | } else { |
| | |
| | | } |
| | | } |
| | | HouseIdBean houseIdBean = HouseIdList.get(select_home); |
| | | HdlResidenceLogic.getInstance().switchHouse(houseIdBean); |
| | | HdlResidenceLogic.getInstance().switchHouse(houseIdBean, false); |
| | | String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS_C + "?homeId=" + houseIdBean.getHomeId() + "&homeName=" + houseIdBean.getHomeName() + "&powerStationStatus=" + houseIdBean.getPowerStationStatus(); |
| | | if(delay) { |
| | | HdlUniLogic.getInstance().openUniMPDelay(path, null); |
| | | }else { |
| | | HdlUniLogic.getInstance().openUniMP(path, null); |
| | | } |
| | | HdlUniLogic.getInstance().openUniMP(path, null); |
| | | } |
| | | } |
| | | |
| | |
| | | UserConfigManage.getInstance().Save(); |
| | | } |
| | | HDLApp.getInstance().setInfoMap(registrationId_tag, "true");//记录一下状态,后台杀死app会清空; |
| | | HdlLogLogic.print("C端--->添加极光ID到云端--->registrationID:" + UserConfigManage.getInstance().getUserName() + "--->" + finalRegistrationID, true); |
| | | HdlLogLogic.print("C端---添加极光ID到云端---registrationID:" + UserConfigManage.getInstance().getUserName() + "--->" + finalRegistrationID, true); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HDLApp.getInstance().setInfoMap(registrationId_tag, "false");//记录一下状态,后台杀死app会清空; |
| | | HdlLogLogic.print("C端--->添加极光ID到云端失败--->registrationID:" + UserConfigManage.getInstance().getUserName() + "--->" + finalRegistrationID, true); |
| | | HdlLogLogic.print("C端---添加极光ID到云端失败---registrationID:" + UserConfigManage.getInstance().getUserName() + "--->" + finalRegistrationID, true); |
| | | } |
| | | }); |
| | | |
| | |
| | | if (info != null) { |
| | | MqttRecvClient.getInstance().setConnectParam(info.getUrl(), info.getClientId(), info.getUserName(), info.getPassWord()); |
| | | MqttRecvClient.getInstance().connect(); |
| | | HdlLogLogic.print("mqtt链接成功---ClientId---" + info.getClientId(), true); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlLogLogic.print("读取mqtt远程信息失败--->" + e.getMessage(), e.getCode(), true); |
| | | HdlLogLogic.print("读取mqtt远程信息失败---" + e.getMessage(), e.getCode(), true); |
| | | } |
| | | }); |
| | | } |
| | |
| | | if (response.getTopic() == null) { |
| | | return; |
| | | } |
| | | HdlLogLogic.print("C端--->监听到Modbus数据--->" + new Gson().toJson(response), false); |
| | | HdlLogLogic.print("C端---监听到Modbus数据---" + new Gson().toJson(response), false); |
| | | // if (response.getTopic().endsWith("custom/native/inverter/up")) { |
| | | HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | uniCallBackBaseBean.setType(response.getTopic()); |