| | |
| | | /** |
| | | * 获取当前住宅的逆变器列表(包括从的逆变器) |
| | | * |
| | | * @param homeId 电站ID |
| | | * @param cloudInverterDeviceList 元端上的逆变器列表(并网,离网,负载中心) |
| | | * @param homeId 电站ID |
| | | */ |
| | | public List<GatewayBean> getCurrentHomeGatewayList(String homeId, List<CloudInverterDeviceBean> cloudInverterDeviceList) { |
| | | public List<GatewayBean> getCurrentHomeGatewayList(String homeId) { |
| | | try { |
| | | |
| | | List<GatewayBean> newList = new ArrayList<>(); |
| | | //云端有设备列表,本地没有,即HDLLinkLocalGateway.getInstance().getGatewayList()没有,里面会调用refreshGatewayCacheData()方法虚拟一个逆变器实体添加本地列表里面; |
| | | List<GatewayBean> list = HDLLinkLocalGateway.getInstance().getGatewayList(); |
| | |
| | | } |
| | | } |
| | | } |
| | | //有外网,以云端设备列表为准;云端没有,本地存在,则删除本地;否则,没有外网只有局域网,以本地为主,搜索多少个设备就显示多少个 |
| | | |
| | | |
| | | return newList; |
| | | } catch (Exception e) { |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取当前住宅的逆变器列表(包括从的逆变器) |
| | | * 可以设置是否整合本地逆变器列表数据 |
| | | * |
| | | * @param homeId 电站ID |
| | | * @param cloudInverterDeviceList 云端上的逆变器列表(并网,离网,负载中心) |
| | | * @param isIntegrateLocalData 是否强制整合本地逆变器数据(false:不需要(以云端列表为主(逆变器,负载中心)多少个显示多少个),true:需要(有外网,以云端设备列表为准;云端没有,本地存在,则删除本地;否则,没有外网只有局域网,以本地列表为主,搜索多少个设备就显示多少个)) |
| | | */ |
| | | public List<GatewayBean> IntegrateCloudAndLocalData(String homeId, List<CloudInverterDeviceBean> cloudInverterDeviceList, boolean isIntegrateLocalData) { |
| | | try { |
| | | List<GatewayBean> newList = new ArrayList<>(); |
| | | //云端有设备列表,本地没有,即HDLLinkLocalGateway.getInstance().getGatewayList()没有,里面会调用refreshGatewayCacheData()方法虚拟一个逆变器实体添加本地列表里面; |
| | | List<GatewayBean> list = getCurrentHomeGatewayList(homeId); |
| | | if (list != null && list.size() > 0) { |
| | | newList.addAll(list); |
| | | } |
| | | |
| | | //有外网,以云端设备列表为准;云端没有,本地存在,则删除本地;否则,没有外网只有局域网,以本地newList列表为主,搜索多少个设备就显示多少个 |
| | | if (cloudInverterDeviceList != null && cloudInverterDeviceList.size() > 0) { |
| | | List<GatewayBean> checkNewList = new ArrayList<>(); |
| | | for (int i = 0; i < cloudInverterDeviceList.size(); i++) { |
| | |
| | | } |
| | | newList.clear(); |
| | | newList.addAll(checkNewList); |
| | | |
| | | } |
| | | // // 模拟设备列表数据 |
| | | |
| | | |
| | | |
| | | // //模拟设备列表数据 |
| | | // List<GatewayBean> mockData = getGatewayDeviceListMockData(3); |
| | | // if (mockData.size() > 0) { |
| | | // for (GatewayBean mockDatum : mockData) { |
| | |
| | | // } |
| | | // } |
| | | |
| | | //胡彬要求的 2025年05月19日13:28:47 即使逆变器删除了云端上成功,本地逆变器初始化不成功(断开)依然不显示; |
| | | if (!isIntegrateLocalData) { |
| | | //强制以云端为主,云端有就显示逆变器列表,没有就不显示 |
| | | if (cloudInverterDeviceList == null || cloudInverterDeviceList.size() == 0) { |
| | | newList.clear(); |
| | | } |
| | | } |
| | | return newList; |
| | | } catch (Exception e) { |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加逆变器到缓存列表里面去 |
| | |
| | | if (newGatewayBean == null || TextUtils.isEmpty(homeId)) { |
| | | return; |
| | | } |
| | | List<GatewayBean> list = getCurrentHomeGatewayList(homeId, null); |
| | | List<GatewayBean> list = getCurrentHomeGatewayList(homeId); |
| | | if (list == null || list.size() == 0) { |
| | | return; |
| | | } |
| | |
| | | if (TextUtils.isEmpty(mac)) { |
| | | return; |
| | | } |
| | | List<GatewayBean> list = getCurrentHomeGatewayList(homeId, null); |
| | | List<GatewayBean> list = getCurrentHomeGatewayList(homeId); |
| | | if (list == null || list.size() == 0) { |
| | | return; |
| | | } |
| | |
| | | if (TextUtils.isEmpty(deviceId)) { |
| | | return; |
| | | } |
| | | List<GatewayBean> list = getCurrentHomeGatewayList(homeId, null); |
| | | List<GatewayBean> list = getCurrentHomeGatewayList(homeId); |
| | | if (list == null || list.size() == 0) { |
| | | return; |
| | | } |
| | |
| | | if (loadCentreDeviceList == null) { |
| | | if (cloudCallBeak != null) { |
| | | //没有数据,默认返回本地逆变器列表; |
| | | cloudCallBeak.onSuccess(getCurrentHomeGatewayList(homeId, null)); |
| | | cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, null,false)); |
| | | } |
| | | return; |
| | | } |
| | |
| | | public void onFailure(HDLException e) { |
| | | //向云端获取负载中心设备列表失败后,默认返回本地逆变器列表; |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onSuccess(getCurrentHomeGatewayList(homeId, null)); |
| | | cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, null,false)); |
| | | } |
| | | } |
| | | }); |
| | |
| | | if (list == null || list.size() == 0) { |
| | | //云端没有绑定逆变器,默认返回本地逆变器列表; |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onSuccess(getCurrentHomeGatewayList(homeId, list)); |
| | | cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, list,false)); |
| | | } |
| | | return; |
| | | } |
| | |
| | | //到最后一条,才处理回调 |
| | | if (atomicInteger.get() == list.size()) { |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onSuccess(getCurrentHomeGatewayList(homeId, list)); |
| | | cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, list,false)); |
| | | } |
| | | } |
| | | } |
| | |
| | | //到最后一条,才处理回调 |
| | | if (atomicInteger.get() == list.size()) { |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onSuccess(getCurrentHomeGatewayList(homeId, list)); |
| | | cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, list,false)); |
| | | } |
| | | } |
| | | HdlLogLogic.print("获取设备远程通讯信息失败(mac:"+cloudInverterDeviceBean.getOsn()+")------" + e.getMsg() + "(" + e.getCode() + ")",true); |
| | | HdlLogLogic.print("获取设备远程通讯信息失败(mac:" + cloudInverterDeviceBean.getOsn() + ")------" + e.getMsg() + "(" + e.getCode() + ")", true); |
| | | } |
| | | }); |
| | | } |
| | |
| | | gatewayBean.setDevice_model(cloudInverterDeviceBean.getOmodel());//设备型号 |
| | | } |
| | | gatewayBean.setSpk(cloudInverterDeviceBean.getSpk());//设备spk |
| | | |
| | | |
| | | |
| | | } |