app/src/main/java/com/hdl/photovoltaic/config/ConstantManage.java
@@ -22,6 +22,8 @@ public static final String message_count = "message_count"; public static final String homepage_title_tab_switch = "homepage_title_tab_switch"; public static final String home_del= "home_del"; //网络状态发生变化 public static final String network_change_post = "network_change"; //电站状态 app/src/main/java/com/hdl/photovoltaic/enums/LowerTagType.java
@@ -1,8 +1,8 @@ package com.hdl.photovoltaic.enums; public enum LowerTagType { home, power_station, message, me home,//首页 power_station,//电站 message,//消息 me//我的 } app/src/main/java/com/hdl/photovoltaic/other/HdlCommonLogic.java
@@ -43,6 +43,9 @@ private static volatile HdlCommonLogic sHdlCommonLogic; /** * 模块类型(首页,电站,消息,我的) */ public static LowerTagType lowerTagType = LowerTagType.home; @@ -280,7 +283,7 @@ BaseEventBus baseEventBus = new BaseEventBus(); baseEventBus.setTopic(topic); baseEventBus.setType(type); EventBus.getDefault().postSticky(baseEventBus); EventBus.getDefault().post(baseEventBus); } /** @@ -294,7 +297,7 @@ baseEventBus.setTopic(topic); baseEventBus.setType(type); baseEventBus.setData(o); EventBus.getDefault().postSticky(baseEventBus); EventBus.getDefault().post(baseEventBus); } } app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -137,7 +137,7 @@ * @param homeId 电站id * @param mac 逆变器mac */ public void removeLocalCacheMemoryGateway(String homeId, String mac) { public void removeLocalCacheMemoryGatewayToMac(String homeId, String mac) { if (TextUtils.isEmpty(mac)) { return; } @@ -157,6 +157,32 @@ list.remove(index); } } /** * 移除缓存列表里面逆变器 * * @param homeId 电站id * @param deviceId 逆变器deviceId */ public void removeLocalCacheMemoryGatewayToDeviceId(String homeId, String deviceId) { if (TextUtils.isEmpty(deviceId)) { return; } List<GatewayBean> list = getCurrentHomeGatewayList(homeId); if (list == null || list.size() == 0) { return; } int index = -1; for (int i = 0; i < list.size(); i++) { GatewayBean gatewayBean = list.get(i); if (gatewayBean.getDeviceId().equals(deviceId)) { index = i; break; } } if (index > 0) { list.remove(index); } } /** * 添加【设备列表】到本地缓存 app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -33,7 +33,9 @@ import com.hdl.photovoltaic.bean.ModBusBean; import com.hdl.photovoltaic.bean.PageNumberObject; import com.hdl.photovoltaic.config.AppConfigManage; import com.hdl.photovoltaic.config.ConstantManage; import com.hdl.photovoltaic.config.UserConfigManage; import com.hdl.photovoltaic.enums.LowerTagType; import com.hdl.photovoltaic.internet.HttpServer.MyNanoHttpServer; import com.hdl.photovoltaic.internet.TcpClient; import com.hdl.photovoltaic.internet.api.HttpApi; @@ -168,11 +170,10 @@ //创建电站 case HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION: { //EventBus事件分发 BaseEventBus baseEventBus = new BaseEventBus(); baseEventBus.setTopic(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL); baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION); baseEventBus.setData(getKeyValue("data", data)); EventBus.getDefault().post(baseEventBus); HdlCommonLogic.getInstance().postEventBus( HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL, HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION, getKeyValue("data", data)); } break; //读取详情 @@ -180,23 +181,28 @@ } break; //电站删除 case HDLUniMP.UNI_EVENT_REPLY_HOME_DEl: { this.uniGetDelResidence(mode_type, data, callback); } break; //关闭详情页 case HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE: { //EventBus事件分发 BaseEventBus baseEventBus = new BaseEventBus(); baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE); baseEventBus.setData(getKeyValue("data", data)); EventBus.getDefault().post(baseEventBus); // todo 在HDLUniMPSDKManager类里面有方法()监听到小程序关闭,然后发布调用EventBus发布出去; // HdlCommonLogic.getInstance().postEventBus( // HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE, // LowerTagType.power_station.toString(), // getKeyValue("data", data)); } break; //住宅【电站】编辑 case HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT: { //EventBus事件分发 BaseEventBus baseEventBus = new BaseEventBus(); baseEventBus.setTopic(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL); baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT); baseEventBus.setData(getKeyValue("data", data)); EventBus.getDefault().post(baseEventBus); HdlCommonLogic.getInstance().postEventBus( HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL, HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT, getKeyValue("data", data)); } break; //电站的交付二维码(安装商) @@ -643,6 +649,34 @@ //endregion //region ******uni接口方法****** /** * 电站删除 */ private void uniGetDelResidence(String type, Object data, DCUniMPJSCallback callback) { String homeId = getKeyValue("homeId", getKeyValue("data", data)); HdlResidenceLogic.getInstance().delResidence(homeId, new CloudCallBeak<Boolean>() { @Override public void onSuccess(Boolean obj) { List<GatewayBean> list = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId); for (int i = 0; i < list.size(); i++) { GatewayBean gatewayBean = list.get(i); HdlDeviceLogic.getInstance().initializeInverter(gatewayBean.getDevice_mac(), null); } list.clear();//清空缓存; // HDLLinkLocalGateway.getInstance().getGatewayList().clear(); HdlResidenceLogic.getInstance().delHouseId(homeId);//删除电站缓存 //uni收到成功结果响应后,会自动关闭小程序,在HDLUniMPSDKManager类里面有方法()监听到小程序关闭,监听到小程序关闭事件后,会重新获取电站列表进行刷界面; uniSuccessCallback(type, obj, callback); } @Override public void onFailure(HDLException e) { uniExceptionCallback(type, e, callback); } }); } /** * 电站授权安装商(C端) @@ -1915,12 +1949,11 @@ private void uniDelInverterDevice(String type, Object data, DCUniMPJSCallback callback) { String deviceId = getKeyValue("deviceId", getKeyValue("data", data)); String homeId = getKeyValue("homeId", getKeyValue("data", data)); if (TextUtils.isEmpty(homeId)) { homeId = UserConfigManage.getInstance().getHomeId(); } HdlDeviceLogic.getInstance().delInverterDevice(homeId, deviceId, new CloudCallBeak<Boolean>() { @Override public void onSuccess(Boolean obj) { //移除本地缓存 HdlDeviceLogic.getInstance().removeLocalCacheMemoryGatewayToDeviceId(homeId, deviceId); uniSuccessCallback(type, null, callback); } app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
@@ -629,9 +629,8 @@ // } // } } } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE.equals(eventBus.getType())) { } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE.equals(eventBus.getTopic())) { // 取消粘性事件 EventBus.getDefault().removeStickyEvent(eventBus); //是在电站列表页才进来这里 app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListEditActivity.java
@@ -14,11 +14,13 @@ import com.hdl.photovoltaic.config.UserConfigManage; import com.hdl.photovoltaic.databinding.ActivityHouseListEditBinding; import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch; import com.hdl.photovoltaic.enums.MessageStateType; import com.hdl.photovoltaic.enums.ShowErrorMode; import com.hdl.photovoltaic.listener.CloudCallBeak; import com.hdl.photovoltaic.listener.LinkCallBack; import com.hdl.photovoltaic.other.HdlCommonLogic; import com.hdl.photovoltaic.other.HdlDeviceLogic; import com.hdl.photovoltaic.other.HdlLogLogic; import com.hdl.photovoltaic.other.HdlResidenceLogic; import com.hdl.photovoltaic.other.HdlThreadLogic; import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean; @@ -30,6 +32,8 @@ import com.hdl.sdk.link.core.bean.gateway.GatewayBean; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; import java.util.List; @@ -136,7 +140,7 @@ } }); //电站移动位置按钮 //电站删除位置按钮 houseListAdapter.setDelOnclickListener(new HouseListAdapter.OnDelClickListener() { @Override public void onDelClick(int position, HouseIdBean houseIdBean) { @@ -206,6 +210,7 @@ houseListAdapter.setList(this.houseListBeanIDList); this.nullDataUpdateUi(houseListBeanIDList); } /** * 删除电站,逆变器 @@ -327,6 +332,7 @@ } } /** * 没有电站列表的样式 */ app/src/main/java/com/hdl/photovoltaic/ui/test/TestMainActivity.java
@@ -296,7 +296,7 @@ public void onSuccess(Boolean obj) { hideLoading(); gsonConvertJsonStr(obj); HdlDeviceLogic.getInstance().removeLocalCacheMemoryGateway(UserConfigManage.getInstance().getHomeId(), mGatewayBean.getDevice_mac()); HdlDeviceLogic.getInstance().removeLocalCacheMemoryGatewayToMac(UserConfigManage.getInstance().getHomeId(), mGatewayBean.getDevice_mac()); HdlDeviceLogic.getInstance().delInverterDevice(UserConfigManage.getInstance().getHomeId(), mGatewayBean.getDeviceId(), null); } app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMPSDKManager.java
@@ -11,6 +11,7 @@ import com.hdl.photovoltaic.HDLApp; import com.hdl.photovoltaic.R; import com.hdl.photovoltaic.config.AppConfigManage; import com.hdl.photovoltaic.enums.LowerTagType; import com.hdl.photovoltaic.other.HdlLogLogic; import com.hdl.photovoltaic.other.HdlThreadLogic; import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; @@ -119,7 +120,8 @@ //小程序被关闭了通知给原生 BaseEventBus baseEventBus = new BaseEventBus(); baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE); baseEventBus.setTopic(HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE); baseEventBus.setType(LowerTagType.power_station.toString()); EventBus.getDefault().post(baseEventBus); }