| | |
| | | import android.os.Process; |
| | | import android.os.SystemClock; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | |
| | | |
| | | import com.google.gson.Gson; |
| | |
| | | import com.hdl.photovoltaic.config.ConstantManage; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.databinding.ActivityCpowerStationBinding; |
| | | import com.hdl.photovoltaic.enums.LowerTagType; |
| | | 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.HdlFileLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.other.HdlMqttLogic; |
| | | import com.hdl.photovoltaic.other.HdlOtaLogic; |
| | |
| | | import com.hdl.sdk.link.core.config.HDLLinkConfig; |
| | | import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | | import org.greenrobot.eventbus.Subscribe; |
| | | import org.greenrobot.eventbus.ThreadMode; |
| | | |
| | | import java.lang.reflect.Type; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | import cn.jpush.android.api.JPushInterface; |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | // setNotificationBarBackgroundColor(CustomColor.white); |
| | | getWindow().setStatusBarColor(getColor(R.color.text_FFFFFFFF)); |
| | | setStatusBarTextColor(); |
| | | setStatusBarTranslucent(); |
| | | getWindow().setNavigationBarColor(getColor(R.color.text_FF000000)); |
| | | //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); |
| | | // } |
| | | } |
| | | }); |
| | | } |
| | |
| | | */ |
| | | 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为空 |
| | | HdlLogLogic.print("返回去"); |
| | | return; |
| | | } |
| | | UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(0); |
| | | List<HouseIdBean> HouseIdList = HdlResidenceLogic.getInstance().getHouseIdList(); |
| | | if (HouseIdList.size() == 0) { |
| | | if (HouseIdList.isEmpty()) { |
| | | if (TextUtils.isEmpty(UserConfigManage.getInstance().getHomeId())) { |
| | | String path = HDLUniMP.UNI_EVENT_OPEN_HOME_Null_C; |
| | | HdlUniLogic.getInstance().openUniMP(path, null); |
| | |
| | | } |
| | | } |
| | | 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(); |
| | | 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); |
| | | 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()); |
| | |
| | | } |
| | | |
| | | |
| | | } else if (linkResponse.getTopic().endsWith("/app/thing/property/send")) { |
| | | //设备状态变更topic:/user/${homeId}/app/thing/property/send |
| | | if (linkResponse.getData() == null) { |
| | | HdlLogLogic.print("设备状态变更--->数据为空", false); |
| | | return; |
| | | } |
| | | HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | uniCallBackBaseBean.setType(linkResponse.getTopic()); |
| | | uniCallBackBaseBean.setData(linkResponse.getData()); |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | } |
| | | |
| | | } |
| | | } |
| | | }; |