mac
2023-11-16 f10bd384ab2c5e459b9bf20766970615e429b4ec
备份一下代码
5个文件已修改
75 ■■■■ 已修改文件
app/src/main/java/com/hdl/photovoltaic/base/BaseActivity.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/utils/HDLMD5Utils.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/base/BaseActivity.java
@@ -1,6 +1,7 @@
package com.hdl.photovoltaic.base;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
@@ -26,10 +27,11 @@
    private LoadingDialog loadingDialog;
    protected Activity _mActivity;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LocalManageUtil.changeAppLanguage("en", this);
        _mActivity = this;
        Object content = getContentView();
        //添加Activity到堆栈
@@ -47,6 +49,14 @@
    }
    @Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(newBase);
//        //app中英文设置
//        LocalManageUtil.changeAppLanguage("en", newBase);
    }
    /**
     * 获取LoadingDialog
     *
app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -90,7 +90,8 @@
                if (TextUtils.isEmpty(gatewayBean.getDevice_mac())) {
                    continue;
                }
                if (gatewayBean.getMaster().equals(GatewayMasterType.MasterTrue) && gatewayBean.getHomeId().equals(UserConfigManage.getInstance().getHomeId())) {
                //用homeId筛选当前住宅的逆变器列表
                if (gatewayBean.getHomeId().equals(UserConfigManage.getInstance().getHomeId())) {
                    newList.add(gatewayBean);
                }
            }
@@ -117,7 +118,6 @@
        }
        return null;
    }
    /**
@@ -564,7 +564,7 @@
    /**
     * 获取逆变器列表
     * 注意:有外网以云端设备为准;本地存在,云端没有则删除;内网以本地为主,搜索多少个设备就显示多少个;
     * 注意:有外网以云端设备为准,本地存在,云端没有则删除;内网以本地为主,搜索多少个设备就显示多少个;
     *
     * @param cloudCallBeak 返回逆变器列表
     */
@@ -572,13 +572,13 @@
        HdlDeviceLogic.getInstance().searchGateway(new GatewayCallBack() {
            @Override
            public void onSuccess(List<GatewayBean> gatewayBeanList) {
                //局域网情况
                //局域网有2种情况(1:有局域网,有外网;2:有局域网,没有外网);
                HdlDeviceLogic.getInstance().getCloudInverterDeviceList(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<List<CloudInverterDeviceBean>>() {
                    @Override
                    public void onSuccess(List<CloudInverterDeviceBean> list) {
                        ///情况1:有局域网,有外网;
                        if (list == null || list.size() == 0) {
//                            //云端没有绑定逆变器,以本地为主;
//                            HDLLinkLocalGateway.getInstance().getGatewayList().clear();
                            //云端没有绑定逆变器,默认返回本地逆变器列表;
                            if (cloudCallBeak != null) {
                                cloudCallBeak.onSuccess(getCurrentHomeGatewayList());
                            }
@@ -588,11 +588,14 @@
                        AtomicInteger atomicInteger = new AtomicInteger(0);
                        for (int i = 0; i < list.size(); i++) {
                            CloudInverterDeviceBean cloudInverterDeviceBean = list.get(i);
                            //获取远程设备通讯信息(拿到网关ID,mqtt通讯秘钥)
                            getDeviceRemoteInfo(UserConfigManage.getInstance().getHomeId(), cloudInverterDeviceBean.getSpk(), cloudInverterDeviceBean.getOsn(), new CloudCallBeak<DeviceRemoteInfo>() {
                                @Override
                                public void onSuccess(DeviceRemoteInfo deviceRemoteInfo) {
                                    atomicInteger.set(atomicInteger.get() + 1);
                                    //更新逆变器本地缓存信息
                                    refreshGatewayCacheData(true, cloudInverterDeviceBean, deviceRemoteInfo);
                                    //最后一条才做删除逆变器逻辑处理
                                    if (atomicInteger.get() == list.size()) {
                                        //收集删除逆变器sid
                                        List<String> removeSidList = new ArrayList<>();
@@ -620,7 +623,7 @@
                                @Override
                                public void onFailure(HDLException e) {
                                    atomicInteger.set(atomicInteger.get() + 1);
                                    //有可能最后一条是失败的
                                    //当最后一条请求失败了,才在这里做删除逆变器逻辑处理
                                    if (atomicInteger.get() == list.size()) {
                                        //收集删除逆变器sid
                                        List<String> removeSidList = new ArrayList<>();
@@ -653,8 +656,10 @@
                    @Override
                    public void onFailure(HDLException e) {
                        ///情况2:有局域网,没有外网;
                        //本地有逆变器列表,获取云端绑定逆变器失败,默认返回本地逆变器列表;
                        if (cloudCallBeak != null) {
                            cloudCallBeak.onFailure(e);
                            cloudCallBeak.onSuccess(getCurrentHomeGatewayList());
                        }
                    }
                });
@@ -662,27 +667,32 @@
            @Override
            public void onError(HDLLinkException e) {
                //外网情况
                //外网只有1情况(本地搜索逆变器列表失败了)
                HdlDeviceLogic.getInstance().getCloudInverterDeviceList(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<List<CloudInverterDeviceBean>>() {
                    @Override
                    public void onSuccess(List<CloudInverterDeviceBean> list) {
                        //云端没有,清空本地逆变器列表
                        //外网进来先【默认】清空本地逆变器列表
                        HDLLinkLocalGateway.getInstance().getGatewayList().clear();
                        if (list == null || list.size() == 0) {
                            if (cloudCallBeak != null) {
                                cloudCallBeak.onSuccess(getCurrentHomeGatewayList());
                                //云端也没有逆变器列表,返回空列表回去
                                cloudCallBeak.onSuccess(new ArrayList<>());
                            }
                            return;
                        }
                        //记录条数
                        AtomicInteger atomicInteger = new AtomicInteger(0);
                        for (int i = 0; i < list.size(); i++) {
                            CloudInverterDeviceBean cloudInverterDeviceBean = list.get(i);
                            //获取远程设备通讯信息(拿到网关ID,mqtt通讯秘钥)
                            getDeviceRemoteInfo(UserConfigManage.getInstance().getHomeId(), cloudInverterDeviceBean.getSpk(), cloudInverterDeviceBean.getOsn(), new CloudCallBeak<DeviceRemoteInfo>() {
                                @Override
                                public void onSuccess(DeviceRemoteInfo deviceRemoteInfo) {
                                    atomicInteger.set(atomicInteger.get() + 1);
                                    //更新逆变器本地缓存信息
                                    refreshGatewayCacheData(false, cloudInverterDeviceBean, deviceRemoteInfo);
                                    //到最后一条,才有回调
                                    if (atomicInteger.get() == list.size()) {
                                        if (cloudCallBeak != null) {
                                            cloudCallBeak.onSuccess(getCurrentHomeGatewayList());
@@ -693,6 +703,7 @@
                                @Override
                                public void onFailure(HDLException e) {
                                    atomicInteger.set(atomicInteger.get() + 1);
                                    //当最后一条请求失败了,才有回调
                                    if (atomicInteger.get() == list.size()) {
                                        if (cloudCallBeak != null) {
                                            cloudCallBeak.onSuccess(getCurrentHomeGatewayList());
@@ -817,8 +828,8 @@
    /**
     * 刷新逆变器缓存信息(包括设置mqtt秘钥)
     * 注:
     * 1:本地存在更新信息即可;
     * 2:云端有本地不存在,则虚拟一个逆变器对象添加在本地;
     * 1:本地存在,更新信息即可;
     * 2:本地不存在,则虚拟一个逆变器对象添加在本地;
     *
     * @param deviceRemoteInfo        设备远程通讯信息
     * @param cloudInverterDeviceBean 逆变器
@@ -849,7 +860,7 @@
        gatewayBean.setDevice_name(cloudInverterDeviceBean.getName());//设备名称
        gatewayBean.setGatewayType(cloudInverterDeviceBean.getSpk());//设置spk
        gatewayBean.setLocalEncrypt(true);
        gatewayBean.setMaster(GatewayMasterType.MasterTrue);
        gatewayBean.setMaster(GatewayMasterType.MasterTrue);//默认都是主逆变器(以后支持从逆变器要更改)
        gatewayBean.setSystemStatusDesc(cloudInverterDeviceBean.getSystemStatusDesc());//设备状态
        gatewayBean.setHwVersion(cloudInverterDeviceBean.getHwVersion());//软件版本号
        gatewayBean.setCategorySecondName(cloudInverterDeviceBean.getCategorySecondName());//设备类型(产品二级分类名称
@@ -864,7 +875,7 @@
    /**
     * 获取网关spk列表
     * 获取网关支持spk列表
     *
     * @return -
     */
app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
@@ -30,9 +30,9 @@
import com.hdl.photovoltaic.utils.PermissionUtils;
import com.hdl.sdk.link.HDLLinkLocalSdk;
import com.hdl.sdk.link.common.event.EventListener;
import com.hdl.sdk.link.core.bean.LinkResponse;
import com.hdl.sdk.link.core.bean.ModbusResponse;
import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
import com.hdl.sdk.link.core.bean.eventbus.EventNotifyRefreshGatewayAesKeyInfo;
import com.hdl.sdk.link.core.bean.gateway.GatewayBean;
import com.hdl.sdk.link.core.config.HDLLinkConfig;
import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient;
@@ -206,6 +206,9 @@
            @Override
            public void onMessage(Object msg) {
                if (msg == null) {
                    return;
                }
                if (msg instanceof ModbusResponse) {
                    ModbusResponse response = (ModbusResponse) msg;
                    if (response.getTopic() == null) {
@@ -219,6 +222,17 @@
                    HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean);
//                    }
                } else if (msg instanceof LinkResponse) {
                    LinkResponse linkResponse = (LinkResponse) msg;
                    if (linkResponse.getTopic() == null) {
                        return;
                    }
                    if (linkResponse.getTopic().endsWith("/ota/device/progress/up")) {
                        HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
                        uniCallBackBaseBean.setType(linkResponse.getTopic());
                        uniCallBackBaseBean.setData(linkResponse.getData());
                        HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_REPLY_OTA_MODEL, uniCallBackBaseBean);
                    }
                }
            }
        };
app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java
@@ -1,10 +1,6 @@
package com.hdl.photovoltaic.uni;
import com.google.gson.Gson;
import org.json.JSONObject;
import java.io.Serializable;
/**
app/src/main/java/com/hdl/photovoltaic/utils/HDLMD5Utils.java
@@ -107,6 +107,8 @@
    }
    public final static String md5(String plainText) {
// 返回字符串