mac
2024-03-13 4a2d7f9ac055d10ba7baf58df690e0ad62826f52
app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
@@ -1,29 +1,39 @@
package com.hdl.photovoltaic.other;
import android.os.SystemClock;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.hdl.photovoltaic.bean.HttpResponsePack;
import com.hdl.photovoltaic.config.AppConfigManage;
import com.hdl.photovoltaic.config.UserConfigManage;
import com.hdl.photovoltaic.internet.HttpClient;
import com.hdl.photovoltaic.internet.api.HttpApi;
import com.hdl.photovoltaic.listener.BaseSuccessFailureCallBeak;
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean;
import com.hdl.photovoltaic.ui.bean.HouseInfoBean;
import com.hdl.photovoltaic.ui.bean.HouseListBean;
import com.hdl.photovoltaic.ui.bean.HouseIdBean;
import com.hdl.photovoltaic.ui.bean.MessageBean;
import com.hdl.sdk.link.common.exception.HDLLinkException;
import com.hdl.sdk.link.core.bean.gateway.GatewayBean;
import com.hdl.sdk.link.core.callback.GatewayCallBack;
import com.hdl.sdk.link.core.config.HDLLinkConfig;
import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient;
import com.hdl.sdk.link.gateway.HDLLinkLocalGateway;
import org.w3c.dom.Text;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
/**
 * 住宅逻辑界面
 * 住宅逻辑
 */
public class HdlResidenceLogic {
@@ -48,60 +58,118 @@
        return sHdlResidenceLogic;
    }
    /**
     * 获取缓存住宅列表
     *
     * @return 住宅列表
     */
    public List<HouseInfoBean> getHouseInfoList() {
        return houseInfoList;
    }
    public void setHouseInfoList(List<HouseInfoBean> houseInfoList) {
        if (houseInfoList == null) {
            houseInfoList = new ArrayList<>();
        }
        this.houseInfoList = houseInfoList;
    }
    public List<HouseListBean> getHouseInfoBeanList() {
        return houseList;
    /**
     * 获取缓存住宅ID列表
     *
     * @return 住宅ID列表
     */
    public List<HouseIdBean> getHouseIdList() {
        return houseIdList;
    }
    public void setHouseInfoBeanList(List<HouseListBean> houseListBeanList) {
        this.houseList = houseListBeanList;
    public void setHouseIdList(List<HouseIdBean> houseIdList) {
        if (houseIdList == null) {
            houseIdList = new ArrayList<>();
        }
        this.houseIdList = houseIdList;
    }
    //住宅列表
    private List<HouseListBean> houseList = new ArrayList<>();
    /**
     * 删除电站
     *
     * @param houseId 电站id
     */
    public void delHouseId(String houseId) {
        if (TextUtils.isEmpty(houseId)) {
            return;
        }
        for (int i = 0; i < houseIdList.size(); i++) {
            if (houseIdList.get(i).getHomeId().equals(houseId)) {
                houseIdList.remove(i);
                break;
            }
        }
    }
    /**
     * 移动电站位置
     *
     * @param houseId 电站id
     */
    public void moveHouseId(String houseId) {
        if (TextUtils.isEmpty(houseId)) {
            return;
        }
        int index = -1;
        for (int i = 0; i < houseIdList.size(); i++) {
            if (houseIdList.get(i).getHomeId().equals(houseId)) {
                index = i;
                break;
            }
        }
        if (index == -1) {
            return;
        }
        //index==0表示只有一个元素或者在首位,不需要移动位置
        if (index > 0) {
            Collections.swap(houseIdList, index - 1, index);
        }
    }
    //住宅ID列表
    private List<HouseIdBean> houseIdList = new ArrayList<>();
    //住宅详情列表
    private List<HouseInfoBean> houseInfoList = new ArrayList<>();
    /**
     * 获取住宅列表
     * 获取住宅列表,包括获取住宅id列表,住宅详情列表;
     *
     * @param cloudCallBeak -
     */
    public void getHouseList(CloudCallBeak<Boolean> cloudCallBeak) {
        //获取住宅列表
        getResidenceList("", "", new CloudCallBeak<List<HouseListBean>>() {
        //获取住宅ID列表
        getResidenceIdList("", "", new CloudCallBeak<List<HouseIdBean>>() {
            @Override
            public void onSuccess(List<HouseListBean> houseListBeanList) {
                if (houseListBeanList != null && houseListBeanList.size() > 0) {
                    houseList.clear();
                    houseList.addAll(houseListBeanList);
                    //标记最后一条
            public void onSuccess(List<HouseIdBean> houseListBeanIDList) {
                if (houseListBeanIDList != null && houseListBeanIDList.size() > 0) {
                    houseIdList.clear();
                    houseIdList.addAll(houseListBeanIDList);
                    //记录请求条数
                    AtomicInteger atomicInteger = new AtomicInteger(0);
                    for (int i = 0; i < houseList.size(); i++) {
                        HouseListBean houseListBean = houseList.get(i);
                        atomicInteger.set(i);
                    for (int i = 0; i < houseIdList.size(); i++) {
                        HouseIdBean houseIdBean = houseIdList.get(i);
                        //获取住宅详情列表
                        getResidenceInfo(houseListBean.getHomeId(), new CloudCallBeak<HouseInfoBean>() {
                        getResidenceInfo(houseIdBean.getHomeId(), new CloudCallBeak<HouseInfoBean>() {
                            @Override
                            public void onSuccess(HouseInfoBean houseInfoBean) {
                                atomicInteger.set(atomicInteger.get() + 1);
                                if (houseInfoBean != null) {
                                    houseInfoBean.setHomeImage(houseListBean.getHomeImage());//电站图片
                                    houseInfoBean.setInstalledCapacity(houseListBean.getInstalledCapacity());//装机容量
                                    houseInfoBean.setPower(houseListBean.getPower());//发电功率
                                    houseInfoBean.setTodayElectricity(houseListBean.getTodayElectricity());//今天发电量
                                    houseInfoBean.setPowerStationStatus(houseListBean.getPowerStationStatus());//电站状态(电站状态   1:正常(运行),2:离线,3:连接中,4:故障)
                                    houseInfoBean.setPowerStationImage(houseIdBean.getPowerStationImage());//电站图片
                                    houseInfoBean.setInstalledCapacity(houseIdBean.getInstalledCapacity());//装机容量
                                    houseInfoBean.setPower(houseIdBean.getPower());//发电功率
                                    houseInfoBean.setTodayElectricity(houseIdBean.getTodayElectricity());//今天发电量
                                    houseInfoBean.setPowerStationStatus(houseIdBean.getPowerStationStatus());//电站状态(电站状态   1:正常(运行),2:离线,3:连接中,4:故障)
                                    //添加到本地缓存
                                    addHouseToLocalMemory(houseInfoBean);
                                }
                                if (atomicInteger.get() == houseList.size() - 1) {
                                if (atomicInteger.get() == houseIdList.size()) {
                                    //最后一条退出
                                    if (cloudCallBeak != null) {
                                        cloudCallBeak.onSuccess(true);
@@ -111,10 +179,12 @@
                            }
                            @Override
                            public void onFailure(Exception exception) {
                                if (atomicInteger.get() == houseList.size() - 1) {
                            public void onFailure(HDLException e) {
                                atomicInteger.set(atomicInteger.get() + 1);
                                if (atomicInteger.get() == houseIdList.size()) {
                                    //最后一条退出
                                    if (cloudCallBeak != null) {
                                        cloudCallBeak.onFailure(exception);
                                        cloudCallBeak.onFailure(e);
                                    }
                                }
                            }
@@ -129,9 +199,9 @@
            }
            @Override
            public void onFailure(Exception exception) {
            public void onFailure(HDLException e) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(exception);
                    cloudCallBeak.onFailure(e);
                }
            }
        });
@@ -139,142 +209,81 @@
    }
    /**
     * 获取住宅(电站)列表
     * 获取住宅(电站)ID列表
     *
     * @param pageNo   当前页数 开始默认1
     * @param pageSize 一页大小 开始默认50
     * @param key      发电功率排序(powerSort);今日发电量排序(todayElectricitySort);创建时间排序(createTimeSort);
     * @param keyValue (descending:降序ascending:升序),
     * @param key      发电功率排序(powerSort);
     *                 今日发电量排序(todayElectricitySort);
     *                 创建时间排序(createTimeSort);
     * @param keyValue (descending:降序
     *                 ascending:升序),
     */
    public void getResidenceList(int pageNo, int pageSize, String key, String keyValue, CloudCallBeak<Boolean> cloudCallBeak) {
        if (pageNo == 1) {
            //第一次进来清空列表
            houseList.clear();
        }
        String requestUrl = HttpApi.POST_PowerStation_List;
        JsonObject json = new JsonObject();
        if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(keyValue)) {
            json.addProperty(key, keyValue);//发电功率排序(descending:降序ascending:升序)
        }
//        json.addProperty("powerSort", "descending");//发电功率排序(descending:降序ascending:升序)
//        json.addProperty("todayElectricitySort", "descending");//今日发电量排序
//        json.addProperty("createTimeSort", "descending");//创建时间排序
//        json.addProperty("zoneType", "password");//区域
        json.addProperty("pageNo", pageNo);//页码
        json.addProperty("pageSize", pageSize);//页数
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
            @Override
            public void onSuccess(HttpResponsePack httpResponsePack) {
                if (httpResponsePack != null && httpResponsePack.getData() != null) {
                    Gson gson = new Gson();
                    String jsonStr = gson.toJson(httpResponsePack.getData());
                    HouseInfoBeanClass houseInfoBeanClass = gson.fromJson(jsonStr, HouseInfoBeanClass.class);
                    //添加【住宅】到本地缓存
                    houseList.addAll(houseInfoBeanClass.getList());
                    //总共有多少页
                    long totalPage = houseInfoBeanClass.totalPage;
                    if (totalPage == houseInfoBeanClass.getPageNo()) {
                        if (cloudCallBeak != null) {
                            cloudCallBeak.onSuccess(true);
                        }
                        return;
                    }
                    if (pageNo > totalPage) {
                        //当前请求的页数大于总页数,云端出错了立即返回去;
                        if (cloudCallBeak != null) {
                            cloudCallBeak.onSuccess(true);
                        }
                        return;
                    }
                    getResidenceList(pageNo + 1, pageSize, key, keyValue, cloudCallBeak);
                }
            }
            @Override
            public void onFailure(Exception exception) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(exception);
                }
            }
        });
    }
    public void getResidenceList(String key, String keyValue, CloudCallBeak<List<HouseListBean>> cloudCallBeak) {
    public void getResidenceIdList(String key, String keyValue, CloudCallBeak<List<HouseIdBean>> cloudCallBeak) {
        String requestUrl = HttpApi.POST_PowerStation_List;
        JsonObject json = new JsonObject();
        if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(keyValue)) {
            json.addProperty(key, keyValue);//发电功率排序(descending:降序ascending:升序)
        }
//        json.addProperty("powerSort", "descending");//发电功率排序(descending:降序ascending:升序)
//        json.addProperty("todayElectricitySort", "descending");//今日发电量排序
//        json.addProperty("createTimeSort", "descending");//创建时间排序
//        json.addProperty("zoneType", "password");//区域
        json.addProperty("pageNo", 1);//页码
        json.addProperty("pageSize", pageSize);//页数
        List<HouseListBean> list = new ArrayList<>();
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
        List<HouseIdBean> list = new ArrayList<>();
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
            @Override
            public void onSuccess(HttpResponsePack httpResponsePack) {
                if (httpResponsePack != null && httpResponsePack.getData() != null) {
                    Gson gson = new Gson();
                    String jsonStr = gson.toJson(httpResponsePack.getData());
                    HouseInfoBeanClass houseInfoBeanClass = gson.fromJson(jsonStr, HouseInfoBeanClass.class);
                    list.addAll(houseInfoBeanClass.getList());
                    //总共有多少页
                    long totalPage = houseInfoBeanClass.totalPage;
                    if (totalPage < 2) {
                        if (cloudCallBeak != null) {
                            cloudCallBeak.onSuccess(list);
                        }
                        return;
                    }
                    //标记最后一条
                    AtomicBoolean isLast = new AtomicBoolean(false);
                    //从第二页获取数据
                    for (int i = 2; i <= totalPage; i++) {
                        if (totalPage == i) {
                            isLast.set(true);
                        }
                        json.addProperty("pageNo", i);//更新页码
                        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
                            @Override
                            public void onSuccess(HttpResponsePack httpResponsePack) {
                                Gson gson = new Gson();
                                String jsonStr = gson.toJson(httpResponsePack.getData());
                                HouseInfoBeanClass houseInfoBeanClass = gson.fromJson(jsonStr, HouseInfoBeanClass.class);
                                list.addAll(houseInfoBeanClass.getList());
                                if (isLast.get()) {
                                    if (cloudCallBeak != null) {
                                        cloudCallBeak.onSuccess(list);
                                    }
                                }
                            }
                            @Override
                            public void onFailure(Exception exception) {
                                if (isLast.get()) {
                                    if (cloudCallBeak != null) {
                                        cloudCallBeak.onSuccess(list);
                                    }
                                }
                            }
                        });
                    }
                } else {
            public void onSuccess(String jsonStr) {
                if (TextUtils.isEmpty(jsonStr)) {
                    if (cloudCallBeak != null) {
                        cloudCallBeak.onSuccess(list);
                    }
                }
                Gson gson = new Gson();
                HouseBeanClass houseInfoBeanClass = gson.fromJson(jsonStr, HouseBeanClass.class);
                list.addAll(houseInfoBeanClass.getList());
                //总共有多少页
                long totalPage = houseInfoBeanClass.totalPage;
                if (totalPage < 2) {
                    if (cloudCallBeak != null) {
                        cloudCallBeak.onSuccess(list);
                    }
                    return;
                }
                //记录请求条数
                AtomicInteger atomicInteger = new AtomicInteger(0);
                //从第二页获取数据
                for (int i = 2; i <= totalPage; i++) {
                    json.addProperty("pageNo", i);//更新页码
                    HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
                        @Override
                        public void onSuccess(String jsonStr) {
                            atomicInteger.set(atomicInteger.get() + 1);
                            Gson gson = new Gson();
                            HouseBeanClass houseInfoBeanClass = gson.fromJson(jsonStr, HouseBeanClass.class);
                            list.addAll(houseInfoBeanClass.getList());
                            if (atomicInteger.get() == totalPage - 1) {
                                //最后一条退出
                                if (cloudCallBeak != null) {
                                    cloudCallBeak.onSuccess(list);
                                }
                            }
                        }
                        @Override
                        public void onFailure(HDLException e) {
                            atomicInteger.set(atomicInteger.get() + 1);
                            if (atomicInteger.get() == totalPage - 1) {
                                //最后一条退出
                                if (cloudCallBeak != null) {
                                    cloudCallBeak.onSuccess(list);
                                }
                            }
                        }
                    });
                }
            }
            @Override
            public void onFailure(Exception exception) {
            public void onFailure(HDLException exception) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(exception);
                }
@@ -285,7 +294,7 @@
    }
    /**
     * 获取住宅(电站)详情
     * 获取住宅(电站)ID详情
     *
     * @param homeId        住宅id
     * @param cloudCallBeak 回调
@@ -295,24 +304,25 @@
        JsonObject json = new JsonObject();
        json.addProperty("homeId", homeId);//电站id
        //json.addProperty("zoneType", "password");//区域
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
            @Override
            public void onSuccess(HttpResponsePack httpResponsePack) {
                if (httpResponsePack != null && httpResponsePack.getData() != null) {
                    Gson gson = new Gson();
                    String jsonStr = gson.toJson(httpResponsePack.getData());
                    HouseInfoBean houseInfoBean = gson.fromJson(jsonStr, HouseInfoBean.class);
            public void onSuccess(String jsonStr) {
                if (TextUtils.isEmpty(jsonStr)) {
                    if (cloudCallBeak != null) {
                        cloudCallBeak.onSuccess(houseInfoBean);
                        cloudCallBeak.onSuccess(null);
                    }
                }
                Gson gson = new Gson();
                HouseInfoBean houseInfoBean = gson.fromJson(jsonStr, HouseInfoBean.class);
                if (cloudCallBeak != null) {
                    cloudCallBeak.onSuccess(houseInfoBean);
                }
            }
            @Override
            public void onFailure(Exception exception) {
            public void onFailure(HDLException e) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(exception);
                    cloudCallBeak.onFailure(e);
                }
            }
        });
@@ -352,9 +362,9 @@
        json.addProperty("electrovalence", houseInfoBean.getElectrovalence());
        json.addProperty("totalCost", houseInfoBean.getTotalCost());
        json.addProperty("zoneType", houseInfoBean.getZoneType());
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
            @Override
            public void onSuccess(HttpResponsePack httpResponsePack) {
            public void onSuccess(String str) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onSuccess(true);
                }
@@ -362,9 +372,42 @@
            }
            @Override
            public void onFailure(Exception exception) {
            public void onFailure(HDLException e) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(exception);
                    cloudCallBeak.onFailure(e);
                }
            }
        });
    }
    /**
     * 住宅(电站)移动位置
     *
     * @param homeId        电站id
     * @param frontHomeId   前面的电站id,如果不传表示排到第一位
     * @param cloudCallBeak -
     */
    public void moveResidence(String homeId, String frontHomeId, CloudCallBeak<Boolean> cloudCallBeak) {
        String requestUrl = HttpApi.POST_PowerStation_UserSort;
        JsonObject json = new JsonObject();
        json.addProperty("homeId", homeId);
        if (!TextUtils.isEmpty(frontHomeId)) {
            json.addProperty("frontHomeId", frontHomeId);
        }
//        json.addProperty("zoneType", "zoneType");
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
            @Override
            public void onSuccess(String str) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onSuccess(true);
                }
            }
            @Override
            public void onFailure(HDLException e) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(e);
                }
            }
        });
@@ -381,9 +424,9 @@
        JsonObject json = new JsonObject();
        json.addProperty("homeId", homeId);//电站id
        //json.addProperty("zoneType", "password");//区域
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
            @Override
            public void onSuccess(HttpResponsePack httpResponsePack) {
            public void onSuccess(String str) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onSuccess(true);
                }
@@ -391,9 +434,9 @@
            }
            @Override
            public void onFailure(Exception exception) {
            public void onFailure(HDLException e) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(exception);
                    cloudCallBeak.onFailure(e);
                }
            }
        });
@@ -431,9 +474,9 @@
        json.addProperty("electrovalence", houseInfoBean.getElectrovalence());
        json.addProperty("totalCost", houseInfoBean.getTotalCost());
        json.addProperty("zoneType", houseInfoBean.getZoneType());
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
            @Override
            public void onSuccess(HttpResponsePack httpResponsePack) {
            public void onSuccess(String str) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onSuccess(true);
                }
@@ -441,9 +484,9 @@
            }
            @Override
            public void onFailure(Exception exception) {
            public void onFailure(HDLException e) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(exception);
                    cloudCallBeak.onFailure(e);
                }
            }
        });
@@ -452,24 +495,97 @@
    }
    /**
     * 切换住宅
     *
     * @param homeId 住宅id
     * 获取住宅图片
     */
    public Boolean switchHouse(String homeId) {
        UserConfigManage.getInstance().setHomeId(homeId);
        HdlThreadLogic.runThread(new Runnable() {
    public void getResidenceImage(String imageUrl, CloudCallBeak<Bitmap> cloudCallBeak) {
        String requestUrl = imageUrl;
        JsonObject json = new JsonObject();
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
            @Override
            public void run() {
                //搜索一下住宅设备
            public void onSuccess(String jsonStr) {
                if (TextUtils.isEmpty(jsonStr)) {
                    if (cloudCallBeak != null) {
                        cloudCallBeak.onSuccess(null);
                    }
                    return;
                }
                Bitmap bitmap = BitmapFactory.decodeByteArray(jsonStr.getBytes(), 0, jsonStr.getBytes().length);
                if (cloudCallBeak != null) {
                    cloudCallBeak.onSuccess(bitmap);
                }
            }
        }, null, null);
        //关闭进度条
            @Override
            public void onFailure(HDLException e) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(e);
                }
            }
        });
        return true;
    }
    /**
     * 用户自定义配置温度单位
     *
     * @param tempType      温度单位类型 (C :摄氏度, F :华氏度)
     * @param cloudCallBeak -
     */
    public void setResidenceTemperatureUnit(String tempType, CloudCallBeak<Boolean> cloudCallBeak) {
        String requestUrl = HttpApi.POST_C_F_CustomConfig;
        JsonObject json = new JsonObject();
        json.addProperty("tempType", tempType);
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
            @Override
            public void onSuccess(String str) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onSuccess(true);
                }
            }
            @Override
            public void onFailure(HDLException e) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(e);
                }
            }
        });
    }
    /**
     * 获取用户自定义配置温度单位详情
     *
     * @param cloudCallBeak -
     */
    public void getResidenceTemperatureUnit(CloudCallBeak<String> cloudCallBeak) {
        String requestUrl = HttpApi.POST_C_F_CustomConfigInfo;
        JsonObject json = new JsonObject();
//        json.addProperty("homeId", homeId);
        List<MessageBean> list = new ArrayList<>();
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
            @Override
            public void onSuccess(String jsonStr) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onSuccess(jsonStr);
                }
            }
            @Override
            public void onFailure(HDLException e) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(e);
                }
            }
        });
    }
    /**
     * 添加【住宅详情】到本地缓存
@@ -532,8 +648,119 @@
        }
    }
    /**
     * 获取住宅Id对象
     *
     * @param homeId 住宅id
     * @return 列表索引
     */
    public HouseIdBean getHouseId(String homeId) {
        for (int i = 0; i < houseIdList.size(); i++) {
            if (houseIdList.get(i).getHomeId().equals(homeId)) {
                return houseIdList.get(i);
            }
        }
        return null;
    }
    static class HouseInfoBeanClass {
    /**
     * 切换住宅
     *
     * @param houseIdBean 住宅Id对象
     */
    public void switchHouse(HouseIdBean houseIdBean) {
        String homeId = UserConfigManage.getInstance().getHomeId();
        if (houseIdBean.getHomeId().equals(homeId)) {
            HdlLogLogic.print("点击同一个住宅--->" + homeId);
            return;
        }
        //订阅要全部取消
        if (MqttRecvClient.getInstance() != null) {
            MqttRecvClient.getInstance().removeAllTopic();
        }
        //要清空之前tcp连接缓存
        //TODO: 10/10/23
        //删除旧的住宅文件夹 2023年11月03日14:28:19暂时去掉
//        HdlFileLogic.getInstance().deleteDirectory(HdlFileLogic.getInstance().getCurrentHomeRootPath());
        //重新设置住宅id
        UserConfigManage.getInstance().setHomeId(houseIdBean.getHomeId());
        UserConfigManage.getInstance().setHomeName(houseIdBean.getHomeName());
        //重新设置本地通讯秘钥
        UserConfigManage.getInstance().setLocalSecret(houseIdBean.getLocalSecret());
        UserConfigManage.getInstance().Save();
        //配置本地通信的信息
        HDLLinkConfig.getInstance().setHomeId(UserConfigManage.getInstance().getHomeId());
        HDLLinkConfig.getInstance().setLocalSecret(UserConfigManage.getInstance().getLocalSecret());
        //重新创建住宅文件夹
        HdlFileLogic.getInstance().createDirectory();
        //进去住宅详情搜索一下逆变器列表,目的是建立通讯通道;
        HdlDeviceLogic.getInstance().searchCurrentHomeGateway(null);
    }
    /**
     * 电站数据(统计)
     *
     * @param homeId 住宅id
     */
    public void getResidenceInverterAllInfo(String homeId, CloudCallBeak<Bitmap> cloudCallBeak) {
        String requestUrl = HttpApi.POST_inverter_allInfo;
        JsonObject json = new JsonObject();
        json.addProperty("homeId", homeId);
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
            @Override
            public void onSuccess(String jsonStr) {
                if (cloudCallBeak != null) {
//                    cloudCallBeak.onSuccess(jsonStr);
                }
            }
            @Override
            public void onFailure(HDLException e) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(e);
                }
            }
        });
    }
    /**
     * 添加推送Token
     *
     * @param cloudCallBeak -
     */
    public void pushAdd(CloudCallBeak<String> cloudCallBeak) {
        String requestUrl = HttpApi.POST_push_add;
        JsonObject json = new JsonObject();
        json.addProperty("deviceName", Build.MODEL);//设备名称
        json.addProperty("deviceType", "Android");//设备类型
        json.addProperty("produce", AppConfigManage.isIsOnlineServer());//表示是否是正式服务器
        json.addProperty("pushToken", UserConfigManage.getInstance().getRegistrationID());//App的推送Token,在极光为RegId
        json.addProperty("software", "PHOTOVOLTAIC");//软件来源
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
            @Override
            public void onSuccess(String jsonStr) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onSuccess(jsonStr);
                }
            }
            @Override
            public void onFailure(HDLException e) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(e);
                }
            }
        });
    }
    static class HouseBeanClass {
        //总条数
        private long totalCount;
@@ -544,7 +771,7 @@
        //页数
        private long pageSize;
        //电站列表
        private List<HouseListBean> list;
        private List<HouseIdBean> list;
        public long getTotalCount() {
            return totalCount;
@@ -578,11 +805,11 @@
            this.pageSize = pageSize;
        }
        public List<HouseListBean> getList() {
        public List<HouseIdBean> getList() {
            return list == null ? new ArrayList<>() : list;
        }
        public void setList(List<HouseListBean> list) {
        public void setList(List<HouseIdBean> list) {
            this.list = list;
        }
    }