From 1a0aaa0bd03b3a491c751b5ce1bfca16302767b1 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期三, 19 六月 2024 19:30:12 +0800
Subject: [PATCH] 2024年06月19日19:30:03

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java |  103 ++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 68 insertions(+), 35 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..3806220 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;
                     //鐢电珯鐨勪氦浠樹簩缁寸爜(瀹夎鍟�)
@@ -645,6 +651,34 @@
     //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绔�)
      */
     private void uniHomeUpdateDebugPerm(String type, Object data, DCUniMPJSCallback callback) {
@@ -728,10 +762,10 @@
      */
     private void uniGetStaffEdit(String type, Object data, DCUniMPJSCallback callback) {
         StaffBean staffBean = new StaffBean();
-        String member_info = getKeyValue("staffInfo", getKeyValue("data", data));
-        if (!TextUtils.isEmpty(member_info)) {
+        String staffInfo = getKeyValue("staffInfo", getKeyValue("data", data));
+        if (!TextUtils.isEmpty(staffInfo)) {
             try {
-                staffBean = new Gson().fromJson(member_info, StaffBean.class);
+                staffBean = new Gson().fromJson(staffInfo, StaffBean.class);
             } catch (Exception ignored) {
             }
         }
@@ -753,10 +787,10 @@
      */
     private void uniGetStaffDelete(String type, Object data, DCUniMPJSCallback callback) {
         StaffBean staffBean = new StaffBean();
-        String member_info = getKeyValue("staffInfo", getKeyValue("data", data));
-        if (!TextUtils.isEmpty(member_info)) {
+        String staffInfo = getKeyValue("staffInfo", getKeyValue("data", data));
+        if (!TextUtils.isEmpty(staffInfo)) {
             try {
-                staffBean = new Gson().fromJson(member_info, StaffBean.class);
+                staffBean = new Gson().fromJson(staffInfo, StaffBean.class);
             } catch (Exception ignored) {
             }
         }
@@ -778,10 +812,10 @@
      */
     private void uniGetStaffAdd(String type, Object data, DCUniMPJSCallback callback) {
         StaffBean staffBean = new StaffBean();
-        String member_info = getKeyValue("staffInfo", getKeyValue("data", data));
-        if (!TextUtils.isEmpty(member_info)) {
+        String staffInfo = getKeyValue("staffInfo", getKeyValue("data", data));
+        if (!TextUtils.isEmpty(staffInfo)) {
             try {
-                staffBean = new Gson().fromJson(member_info, StaffBean.class);
+                staffBean = new Gson().fromJson(staffInfo, StaffBean.class);
             } catch (Exception ignored) {
             }
         }
@@ -822,10 +856,10 @@
      */
     private void uniGetMemberEdit(String type, Object data, DCUniMPJSCallback callback) {
         MemberBean memberBean = new MemberBean();
-        String member_info = getKeyValue("memberInfo", getKeyValue("data", data));
-        if (!TextUtils.isEmpty(member_info)) {
+        String memberInfo = getKeyValue("memberInfo", getKeyValue("data", data));
+        if (!TextUtils.isEmpty(memberInfo)) {
             try {
-                memberBean = new Gson().fromJson(member_info, MemberBean.class);
+                memberBean = new Gson().fromJson(memberInfo, MemberBean.class);
             } catch (Exception ignored) {
             }
         }
@@ -847,10 +881,10 @@
      */
     private void uniGetMemberDelete(String type, Object data, DCUniMPJSCallback callback) {
         MemberBean memberBean = new MemberBean();
-        String member_info = getKeyValue("memberInfo", getKeyValue("data", data));
-        if (!TextUtils.isEmpty(member_info)) {
+        String memberInfo = getKeyValue("memberInfo", getKeyValue("data", data));
+        if (!TextUtils.isEmpty(memberInfo)) {
             try {
-                memberBean = new Gson().fromJson(member_info, MemberBean.class);
+                memberBean = new Gson().fromJson(memberInfo, MemberBean.class);
             } catch (Exception ignored) {
             }
         }
@@ -872,10 +906,10 @@
      */
     private void uniGetMemberAdd(String type, Object data, DCUniMPJSCallback callback) {
         MemberBean memberBean = new MemberBean();
-        String member_info = getKeyValue("memberInfo", getKeyValue("data", data));
-        if (!TextUtils.isEmpty(member_info)) {
+        String memberInfo = getKeyValue("memberInfo", getKeyValue("data", data));
+        if (!TextUtils.isEmpty(memberInfo)) {
             try {
-                memberBean = new Gson().fromJson(member_info, MemberBean.class);
+                memberBean = new Gson().fromJson(memberInfo, MemberBean.class);
             } catch (Exception ignored) {
             }
         }
@@ -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