mac
2023-10-09 a59bbb7890e107a681f677765f2600e278c06a0d
app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -54,6 +54,9 @@
        if (list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                GatewayBean gatewayBean = list.get(i);
                if (TextUtils.isEmpty(gatewayBean.getDevice_mac())) {
                    continue;
                }
                if (gatewayBean.getMaster().equals("true")
                        && gatewayBean.getHomeId().equals(UserConfigManage.getInstance().getHomeId())) {
//                    if ("0101050217BBC400".equals(gatewayBean.getOid()))//测试时过滤掉无效的,这行后面代码要删除
@@ -271,7 +274,7 @@
            JsonObject jsonObject = new JsonObject();
            jsonObject.addProperty("protocolType", oidBean.getProtocolType());
            jsonObject.addProperty("deviceType", oidBean.getDeviceType());
            jsonObject.addProperty("mac", oidBean.getMac());
            jsonObject.addProperty("mac", oidBean.getDevice_mac());
            jsonObject.addProperty("oid", oidBean.getOid());
            jsonObject.addProperty("device_name", oidBean.getDevice_name());
            jsonObject.addProperty("device_model", oidBean.getDevice_model());
@@ -538,8 +541,14 @@
                            }
                        }
                        for (int i = 0; i < removeSidList.size(); i++) {
                            //获取本地的逆变器
                            //删除本地的逆变器
                            removeInverter(removeSidList.get(i));
                        }
                        for (int i = 0; i < list.size(); i++) {
                            CloudInverterDeviceBean cloudInverterDeviceBean = list.get(i);
                            GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getLocalGateway(cloudInverterDeviceBean.getSid());
                            objectAssignment(cloudInverterDeviceBean, gatewayBean);
                        }
                        if (cloudCallBeak != null) {
@@ -561,31 +570,19 @@
                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(true);
                            }
                            return;
                        }
                        //清楚本地网关列表
                        HDLLinkLocalGateway.getInstance().getGatewayList().clear();
                        for (int i = 0; i < list.size(); i++) {
                            CloudInverterDeviceBean cloudInverterDeviceBean = list.get(i);
                            //云端对象数据交换到本地对象
                            GatewayBean gatewayBean = new GatewayBean();
                            gatewayBean.setOid(cloudInverterDeviceBean.getOid());
                            gatewayBean.setSid(cloudInverterDeviceBean.getSid());
                            gatewayBean.setGatewayId(cloudInverterDeviceBean.getGatewayId());
                            gatewayBean.setOnline(cloudInverterDeviceBean.isOnline());
                            gatewayBean.setDevice_mac(cloudInverterDeviceBean.getOsn());//设备mac
                            gatewayBean.setDevice_name(cloudInverterDeviceBean.getGatewayName());
                            gatewayBean.setHomeId(UserConfigManage.getInstance().getHomeId());
                            gatewayBean.setLocalEncrypt(true);
                            gatewayBean.setMaster("true");
                            gatewayBean.setSystemStatusDesc(cloudInverterDeviceBean.getSystemStatusDesc());
                            gatewayBean.setHwVersion(cloudInverterDeviceBean.getHwVersion());
                            gatewayBean.setCategorySecondName(cloudInverterDeviceBean.getCategorySecondName());
                            gatewayBean.setDeviceId(cloudInverterDeviceBean.getDeviceId());
                            objectAssignment(cloudInverterDeviceBean, gatewayBean);
                            //添加网关
                            HDLLinkLocalGateway.getInstance().getGatewayList().add(gatewayBean);
@@ -613,7 +610,6 @@
     * @param sid 设备sid
     */
    private void removeInverter(String sid) {
        //获取本地的毫米波
        GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getLocalGateway(sid);
        if (gatewayBean != null) {
            HDLLinkLocalGateway.getInstance().getGatewayList().remove(gatewayBean);
@@ -631,6 +627,27 @@
        HDLLinkLocalGateway.getInstance().refreshGatewayByHomeIdAndSpk(UserConfigManage.getInstance().getHomeId(), spks, true, gatewayCallBack);
    }
    private void objectAssignment(CloudInverterDeviceBean cloudInverterDeviceBean, GatewayBean gatewayBean) {
        if (cloudInverterDeviceBean == null || gatewayBean == null) {
            return;
        }
        gatewayBean.setOid(cloudInverterDeviceBean.getOid());
        gatewayBean.setSid(cloudInverterDeviceBean.getSid());
        gatewayBean.setGatewayId(cloudInverterDeviceBean.getGatewayId());
        gatewayBean.setOnline(cloudInverterDeviceBean.isOnline());
        gatewayBean.setDevice_mac(cloudInverterDeviceBean.getOsn());//设备mac
        gatewayBean.setDevice_name(cloudInverterDeviceBean.getGatewayName());
        gatewayBean.setHomeId(UserConfigManage.getInstance().getHomeId());
        gatewayBean.setLocalEncrypt(true);
        gatewayBean.setMaster("true");
        gatewayBean.setSystemStatusDesc(cloudInverterDeviceBean.getSystemStatusDesc());
        gatewayBean.setHwVersion(cloudInverterDeviceBean.getHwVersion());
        gatewayBean.setCategorySecondName(cloudInverterDeviceBean.getCategorySecondName());
        gatewayBean.setDeviceId(cloudInverterDeviceBean.getDeviceId());
    }
    /**
     * 获取网关spk列表
     *