From 73919e36e6c84a665a2c4352fa3b22d1b2e9e6bb Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期二, 18 六月 2024 13:08:19 +0800 Subject: [PATCH] 2024年06月18日13:08:14 --- app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java | 67 +++++++++++++++++++++++++-------- 1 files changed, 50 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java index ae214d1..90eee00 100644 --- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java +++ b/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 鍦℉DLUniMPSDKManager绫婚噷闈㈡湁鏂规硶()鐩戝惉鍒板皬绋嬪簭鍏抽棴锛岀劧鍚庡彂甯冭皟鐢‥ventBus鍙戝竷鍑哄幓; +// 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); } -- Gitblit v1.8.0