From 770c89ab981b7659faabf8a812a25d99a11bdebf Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期四, 16 四月 2026 08:40:43 +0800
Subject: [PATCH] 2026年04月16日08:40:19

---
 app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java |  270 ++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 232 insertions(+), 38 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java
index f348334..b21359b 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java
@@ -5,7 +5,6 @@
 import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentManager;
 import androidx.fragment.app.FragmentTransaction;
-import androidx.lifecycle.Lifecycle;
 
 import android.Manifest;
 import android.content.Context;
@@ -21,6 +20,7 @@
 import android.view.View;
 import android.widget.TextView;
 
+import com.alibaba.fastjson.JSONObject;
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 import com.hdl.linkpm.sdk.core.exception.HDLException;
@@ -36,6 +36,7 @@
 import com.hdl.photovoltaic.enums.LowerTagType;
 import com.hdl.photovoltaic.enums.NetworkType;
 import com.hdl.photovoltaic.listener.CloudCallBeak;
+import com.hdl.photovoltaic.other.HdlAiLogic;
 import com.hdl.photovoltaic.other.HdlCommonLogic;
 import com.hdl.photovoltaic.other.HdlDeviceLogic;
 import com.hdl.photovoltaic.other.HdlESLocalJsonLogic;
@@ -43,19 +44,24 @@
 import com.hdl.photovoltaic.other.HdlMessageLogic;
 import com.hdl.photovoltaic.other.HdlMqttLogic;
 import com.hdl.photovoltaic.other.HdlOtaLogic;
-import com.hdl.photovoltaic.other.HdlResidenceLogic;
+import com.hdl.photovoltaic.other.HdlPushLogic;
 import com.hdl.photovoltaic.other.HdlThreadLogic;
 import com.hdl.photovoltaic.other.HdlUniLogic;
+import com.hdl.photovoltaic.push.PushMessageInfoBean;
+import com.hdl.photovoltaic.ui.bean.ChatInfoBean;
+import com.hdl.photovoltaic.ui.bean.ChatMessagePageBean;
 import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo;
+import com.hdl.photovoltaic.ui.bean.MessageBean;
 import com.hdl.photovoltaic.ui.bean.OidBean;
 import com.hdl.photovoltaic.ui.bean.UnCountBean;
 import com.hdl.photovoltaic.ui.home.HomePageFragment;
 import com.hdl.photovoltaic.ui.me.MeFragment;
-import com.hdl.photovoltaic.ui.message.MessageFragment;
+import com.hdl.photovoltaic.ui.message.MessageHouseFragment;
+import com.hdl.photovoltaic.ui.message.MessageInfoActivity;
 import com.hdl.photovoltaic.ui.powerstation.HouseAndDeviceFragment;
 import com.hdl.photovoltaic.uni.HDLUniMP;
+import com.hdl.photovoltaic.uni.HDLUniMPSDKManager;
 import com.hdl.photovoltaic.utils.AppManagerUtils;
-import com.hdl.photovoltaic.utils.FragmentUtils;
 import com.hdl.photovoltaic.utils.GPSManagerUtils;
 import com.hdl.photovoltaic.utils.PermissionUtils;
 import com.hdl.photovoltaic.utils.SharedPreUtils;
@@ -70,6 +76,11 @@
 import com.hdl.sdk.link.core.config.HDLLinkConfig;
 import com.hdl.sdk.link.core.connect.HDLUdpConnect;
 import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient;
+import com.petterp.floatingx.FloatingX;
+import com.petterp.floatingx.assist.FxGravity;
+import com.petterp.floatingx.assist.FxScopeType;
+import com.petterp.floatingx.assist.helper.FxAppHelper;
+import com.petterp.floatingx.listener.control.IFxAppControl;
 import com.umeng.analytics.MobclickAgent;
 
 import org.greenrobot.eventbus.Subscribe;
@@ -78,6 +89,7 @@
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 import cn.jpush.android.api.JPushInterface;
 
@@ -96,6 +108,7 @@
     private ActivityMyPowerStationBinding viewBinding;
     private EventListener allTopicsListener;
     private int backPressTimes;
+    public IFxAppControl iFxAppControl;
 
     @Override
     public Object getContentView() {
@@ -105,6 +118,10 @@
 
     @Override
     public void onBindView(Bundle savedInstanceState) {
+////        //閫氱煡鏍忕偣鍑昏繘鏉ワ紝闃叉搴旂敤鍦ㄥ悗鍙版椂琚噸澶嶅惎鍔�,闃块噷浜戞帹鍔ㄩ�氱煡鎸囧畾鎵撳紑鏌愪釜Activity锛屾病鏈夎缃瓼lags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);榛樿鍚姩鏂板疄渚嬶紝瀵艰嚧澶氫釜瀹炰緥
+//        if (!isTaskRoot()) {
+//            finish();
+//        }
         setStatusBarTranslucent();
         getWindow().setNavigationBarColor(getColor(R.color.text_FF1C1C1E));
         //鍒濆鍖栫鐗�
@@ -117,20 +134,56 @@
         this.registerAllTopicsListener();
         //鍒濆鍖杕qtt瀹㈡埛绔�
         this.initMqttClient();
-        //涓婁紶鏋佸厜娉ㄥ唽ID鍒颁簯绔�
-        this.pushTokens();
-        //鐐瑰嚮鏋佸厜閫氱煡鏍忔秷鎭繘鏉�
-        this.clickJpushNotificationMessage();
+//        //涓婁紶鏋佸厜娉ㄥ唽ID鍒颁簯绔� 闅愯棌2025-11-21 11:52:27
+//        this.pushTokens();
+        //涓婁紶鎺ㄥ姩浠ょ墝鍒颁簯绔紙璋锋瓕FCM鎺ㄩ�侊級
+        this.sendPushTokenToServer(UserConfigManage.getInstance().getPushToken());
+//        //鐐瑰嚮鏋佸厜閫氱煡鏍忔秷鎭繘鏉�
+//        this.clickJpushNotificationMessage();
+        //鐐瑰嚮閫氱煡鏍忔秷鎭繘鏉�
+        this.OpenSpecifiedPage(getIntent(), "onBindView");
         //鍒濆鍖栨潈闄�
         this.requestPermissions();
         //璇诲彇娑堟伅鏈鏁伴噺
         this.getUnreadCount();
         //鑾峰彇浜戠鑴氭湰
         HdlESLocalJsonLogic.getInstance().getAllHdlESLocalJson();
-
+        this.getChatInfo();
+        this.createAppFloatWindow();
 
     }
 
+    /**
+     * 鐐瑰嚮閫氱煡鏍忔秷鎭繘鏉�
+     */
+    private void OpenSpecifiedPage(Intent intent, String tag) {
+        Log.d("==========", tag);
+        try {
+            String data = getIntentExpantData(intent);
+            if (TextUtils.isEmpty(data)) {
+                return;
+            }
+//            PushMessageInfoBean pushMessageInfoBean = new Gson().fromJson(data, PushMessageInfoBean.class);
+            PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing("", "", data);
+            if (TextUtils.isEmpty(pushMessageInfoBean.getMsgId())) {
+                return;
+            }
+            MessageBean messageBean = new MessageBean();
+            messageBean.setMsgId(Long.valueOf(pushMessageInfoBean.getMsgId()));
+            Intent intentMessageInfoActivity = new Intent();
+            intentMessageInfoActivity.setClass(_mActivity, MessageInfoActivity.class);
+            intentMessageInfoActivity.putExtra("messageBean", JSONObject.toJSONString(messageBean));
+            startActivity(intentMessageInfoActivity);
+            this.clickNotificationMessageTab();
+            if (null != HDLUniMPSDKManager.getInstance().getUniMP()) {
+                Log.d("HDLUniMPSDKManager.getInstance().getUniMP()", "HDLUniMPSDKManager.getInstance().getUniMP()");
+                HDLUniMPSDKManager.getInstance().getUniMP().closeUniMP();
+            }
+
+        } catch (Exception e) {
+            Log.d("閿欒", " " + e.getMessage());
+        }
+    }
 
     /**
      * 鍒濆鍖朏ragment
@@ -142,7 +195,7 @@
         //纰庣墖鍒濆鍖�
         HomePageFragment mHomePageFragment = new HomePageFragment();
         HouseAndDeviceFragment mHouseAndDeviceFragment = new HouseAndDeviceFragment();
-        MessageFragment mMessageFragment = new MessageFragment();
+        MessageHouseFragment mMessageHouseFragment = new MessageHouseFragment();
         MeFragment mMeFragment = new MeFragment();
         if (savedInstanceState != null) {
             //鈥滃唴瀛橀噸鍚�濇椂璋冪敤 鑾峰彇鈥滃唴瀛橀噸鍚�濇椂淇濆瓨鐨勭储寮曚笅鏍�
@@ -164,7 +217,7 @@
             }
             fragmentList.add(mHomePageFragment);
             fragmentList.add(mHouseAndDeviceFragment);
-            fragmentList.add(mMessageFragment);
+            fragmentList.add(mMessageHouseFragment);
             fragmentList.add(mMeFragment);
             this.showFragment();
         }
@@ -247,12 +300,6 @@
         //鍚姩椤典笌mainActivity鏍峰紡涓�鏍凤紝杩欐牱鍚姩椤靛拰mainActivity鐪嬩笂鍘绘槸涓�涓晫闈紝鐩殑鏄负浜唌ainActivity閬綇涓嬩竴椤碉紱
 //        AppManagerUtils.getAppManager().finishActivity(StartActivity.class);
         portConflictDialog();
-//        Intent intent = new Intent(_mActivity, BPowerStationActivity.class);
-//        intent.setFlags(Intent.Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
-//        intent.putExtra("skip", "skip");//閲岄潰鍒ゆ柇鏈夎繖涓爣璇嗗氨璺宠浆鍒版秷鎭腑蹇冪晫闈�
-//        _mActivity.startActivity(intent);
-        //鐐瑰嚮鏋佸厜閫氱煡鏍忔秷鎭繘鏉�
-//        this.clickJpushNotificationMessage();
     }
 
 
@@ -282,14 +329,15 @@
                     }
                 }
                 if (!TextUtils.isEmpty(registrationID)) {
-                    UserConfigManage.getInstance().setRegistrationID(registrationID);
-                    UserConfigManage.getInstance().Save();
+//                    UserConfigManage.getInstance().setRegistrationID(registrationID);
+//                    UserConfigManage.getInstance().Save();
                     String finalRegistrationID = registrationID;
-                    HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() {
+                    HdlPushLogic.getInstance().pushAdd(new CloudCallBeak<String>() {
                         @Override
                         public void onSuccess(String pushId) {
 
                             if (!TextUtils.isEmpty(pushId)) {
+                                UserConfigManage.getInstance().setPushToken(finalRegistrationID);
                                 UserConfigManage.getInstance().setPushId(pushId);
                                 UserConfigManage.getInstance().Save();
                             }
@@ -308,6 +356,67 @@
                 }
 
 
+            }
+        });
+    }
+
+    /**
+     * 涓婁紶 token 鍒版湇鍔″櫒
+     *
+     * @param token 浠ょ墝
+     */
+    private void sendPushTokenToServer(final String token) {
+
+        if (TextUtils.isEmpty(token)) {
+            return;
+        }
+        HdlPushLogic.getInstance().pushAdd(new CloudCallBeak<String>() {
+            @Override
+            public void onSuccess(String pushId) {
+                HdlLogLogic.print("娣诲姞浠ょ墝鍒颁簯绔� PushToken:" + UserConfigManage.getInstance().getPushToken() + " pushId:" + pushId, true);
+            }
+
+            @Override
+            public void onFailure(HDLException e) {
+                HdlLogLogic.print("娣诲姞浠ょ墝鍒颁簯绔け璐� PushToken:" + UserConfigManage.getInstance().getPushToken() + " 閿欒锛�" + e.getMessage(), true);
+            }
+        });
+    }
+
+    /**
+     * 鏌ョ湅鏅鸿兘浣撹鎯�
+     *
+     */
+    private void getChatInfo() {
+        HdlAiLogic.getInstance().getChatInfo(new CloudCallBeak<ChatInfoBean>() {
+            @Override
+            public void onSuccess(ChatInfoBean chatInfoBean) {
+                UserConfigManage.getInstance().setAgentSecret(chatInfoBean.getAgentSecret());
+                UserConfigManage.getInstance().setAgentUrl(chatInfoBean.getAgentUrl());
+                UserConfigManage.getInstance().Save();
+                HdlAiLogic.getInstance().chatMessagesList(new CloudCallBeak<ChatMessagePageBean>() {
+                    @Override
+                    public void onSuccess(ChatMessagePageBean obj) {
+                        if (obj != null && !obj.getData().isEmpty()) {
+                            UserConfigManage.getInstance().setConversationId(obj.getData().get(0).getId());
+                            UserConfigManage.getInstance().Save();
+                        } else {
+                            //娌℃湁鎷垮埌瀵硅瘽鍒楄〃,鎶婃棫鐨勫綋鍓嶄細璇滻D娓呯┖
+                            UserConfigManage.getInstance().setConversationId("");
+                            HdlLogLogic.print("娌℃湁鎷垮埌瀵硅瘽鍒楄〃,鎶婃棫鐨勫綋鍓嶄細璇滻D娓呯┖ ", true);
+                        }
+                    }
+
+                    @Override
+                    public void onFailure(HDLException e) {
+
+                    }
+                });
+            }
+
+            @Override
+            public void onFailure(HDLException e) {
+                HdlLogLogic.print("鑾峰彇鏅鸿兘浣揂ppKey澶辫触 " + e.getMessage(), true);
             }
         });
     }
@@ -412,10 +521,13 @@
     @Override
     protected void onDestroy() {
         super.onDestroy();
+        Log.d("BPowerStationActivity", "onDestroy");
         HdlUniLogic.getInstance().checkRemoveOtherUniMPEventCallBack();
         //绉婚櫎鐩戝惉
         HDLLinkLocalSdk.getInstance().removeAllTopicsListener(allTopicsListener);
-
+        if (this.iFxAppControl != null) {
+            this.iFxAppControl.cancel();
+        }
 
     }
 
@@ -480,12 +592,12 @@
         this.notificationSet();
         //ACCESS_FINE_LOCATION	鍏佽浣跨敤GPS瀹氫綅
         //ACCESS_COARSE_LOCATION	鍏佽浣跨敤WIFI鐑偣鎴栧熀绔欐潵鑾峰彇绮楃暐鐨勫畾浣�
-//        String[] ary = PermissionUtils.checkPermission(_mActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION});
-//        if (ary.length > 0) {
-//            this.requestPermissions(ary, PermissionUtils.STATUS_SUCCESS);
-//        } else {
-//            locationUpdates();
-//        }
+        String[] ary = PermissionUtils.checkPermission(_mActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION});
+        if (ary.length > 0) {
+            this.requestPermissions(ary, PermissionUtils.STATUS_SUCCESS);
+        } else {
+            locationUpdates();
+        }
     }
 
     @Override
@@ -603,6 +715,17 @@
                         uniCallBackBaseBean.setData(topicArray[1]);
                         HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean);
                         HdlLogLogic.print(linkResponse.getTopic() + new Gson().toJson(linkResponse.getData()), true);
+                    } else if (linkResponse.getTopic().endsWith("/app/thing/event/appHomeDeliverRollbackRefresh/up")) {
+                        //B绔櫥褰曠數绔欏洖婊氭椂锛屾敹鍒板洖婊氱殑浜嬩欢鏃讹紝鍙戜釜閫氱煡缁檜niapp锛寀niapp鍒锋柊涓嬬數绔欑殑鏉冮檺锛岃皟鏁翠笅鑿滃崟鏍忕殑鍐呭銆�
+                        String[] topicArray = linkResponse.getTopic().split("/");
+                        if (topicArray.length < 2) {
+                            return;
+                        }
+                        final String HomeId = topicArray[2];
+                        HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
+                        uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_home_delivery_rollback);
+                        uniCallBackBaseBean.setData(HomeId);
+                        HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean);
                     } else if (linkResponse.getTopic().endsWith("/app/thing/property/send")) {
                         //璁惧鐘舵�佸彉鏇磘opic锛�/user/${homeId}/app/thing/property/send
                         if (linkResponse.getData() == null) {
@@ -712,7 +835,7 @@
                     public void run() {
                         //闃叉app鍚姩鐨勬椂鍊欐病鏈夌綉缁�(app涔熺櫥褰曚笉浜�),瀵艰嚧鑾峰彇涓嶄簡mqtt杩滅▼杩炴帴淇℃伅;
                         initMqttClient();
-                        HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<List<GatewayBean>>() {
+                        HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(UserConfigManage.getInstance().getHomeId(), UserConfigManage.getInstance().getPowerStationType(), new CloudCallBeak<List<GatewayBean>>() {
                             @Override
                             public void onSuccess(List<GatewayBean> obj) {
 //                                AppManagerUtils.getAppManager().hideLoading();
@@ -733,6 +856,12 @@
                 bottomViewChangeOfStyle();
                 showFragment();
             }
+        } else if (event.getTopic().contains(ConstantManage.refresh_push_token)) {
+            String token = event.getType();
+            UserConfigManage.getInstance().setPushToken(token);
+            UserConfigManage.getInstance().Save();
+            //pushToken鏇存柊
+            sendPushTokenToServer(UserConfigManage.getInstance().getPushToken());
         }
     }
 
@@ -785,19 +914,28 @@
         });
     }
 
+    @Override
+    protected void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
+        //AndroidManifest.xml 闇�瑕佹坊鍔犲惎鍔ㄦā寮廰ndroid:launchMode="singleTask"鎵嶆墽琛岃繖涓柟娉�
+        OpenSpecifiedPage(intent, "onNewIntent");
+    }
 
     /**
-     * 鐐瑰嚮鏋佸厜閫氱煡鏍忔秷鎭繘鏉�
+     * 鐐瑰嚮閫氱煡鏍忔秷鎭繘鏉�,榛樿閫夋嫨娑堟伅妯″潡
      */
-    private void clickJpushNotificationMessage() {
-        Intent intent = getIntent();
-        if (intent != null) {
-            String key = intent.getStringExtra("skip");
-            if (key != null) {
-                //瑙﹀彂娑堟伅鐐瑰嚮浜嬩欢
-                viewBinding.myMessageBottomIl2.clickTv.performClick();
-            }
-        }
+    private void clickNotificationMessageTab() {
+        //瑙﹀彂娑堟伅鐐瑰嚮浜嬩欢
+        viewBinding.myMessageBottomIl2.clickTv.performClick();
+//        if (currentFragmentIndex == 2) {
+//            HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.refresh_message_house, ConstantManage.refresh_message_house);
+//            return;
+//        }
+//        currentFragmentIndex = 2;
+//        bottomViewChangeOfStyle();
+//        showFragment();
+//        HdlCommonLogic.lowerTagType = LowerTagType.message;
+//        HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.refresh_message_house, ConstantManage.refresh_message_house);
     }
 
 
@@ -891,5 +1029,61 @@
         }
     }
 
+    /**
+     * 澶勭悊浠庨�氱煡鐐瑰嚮甯︽潵鐨勬暟鎹紝杩欓噷鑾峰彇鏁版嵁锛岀劧鍚庨�忎紶缁欎富鐣岄潰鍋氬鐞�
+     *
+     * @return 杩斿洖闄勫姞鏁版嵁
+     */
+    private String getIntentExpantData(Intent intent) {
+        try {
+            if (intent == null) {
+                return "";
+            }
+            // 澶勭悊浠庨�氱煡鐐瑰嚮甯︽潵鐨勬暟鎹紝杩欓噷鑾峰彇鏁版嵁锛岀劧鍚庨�忎紶缁欎富鐣岄潰鍋氬鐞�
+            if (intent.getExtras() != null) {
+                for (String key : intent.getExtras().keySet()) {
+                    if (key.equals("pushData")) {
+                        return Objects.requireNonNull(intent.getExtras().get(key)).toString();
+                    }
+                }
+            }
+        } catch (Exception e) {
+            return "";
+        }
+        return "";
+    }
+
+    /**
+     * 鍒涘缓搴旂敤绾I灏忕粍浠舵偓娴獥
+     */
+    private void createAppFloatWindow() {
+        if (this.iFxAppControl != null) {
+            //褰诲簳閿�姣佹偓娴獥锛堜細浠庣晫闈笂绉婚櫎锛�
+            this.iFxAppControl.cancel();
+        }
+        FxAppHelper helper = FxAppHelper.builder()
+                .setContext(_mActivity)        // 璁剧疆涓婁笅鏂�
+                .setLayout(R.layout.item_ai)    // 璁剧疆鎮诞绐楀竷灞�
+                .setScopeType(FxScopeType.APP)        // 璁剧疆涓哄簲鐢ㄥ唴鎮诞绐楃被鍨嬶紝鏃犻渶鏉冮檺
+                .setEnableEdgeAdsorption(true)// 寮�鍚竟缂樺惛闄�
+//                .setEnableHalfHide(true)  // 寮�鍚崐闅愯棌妯″紡锛堝疄鐜扳�滈潬杈归殣钘忊�濓級
+                // 1. 璁剧疆閲嶅姏涓哄彸涓嬭
+                .setGravity(FxGravity.RIGHT_OR_BOTTOM)
+                // 2. 璁剧疆搴曢儴杈圭晫杈硅窛锛岀‘淇濇诞绐椾笉琚嫋鎷藉埌杈圭晫浠ヤ笅锛岀暀鍑虹┖闂�
+                .setBottomBorderMargin(230f)
+                .setRightBorderMargin(40f)
+                .setTopBorderMargin(250f)
+                .build();  // 鏈�鍚庤皟鐢� build() 瀹屾垚鏋勫缓
+        // 鑾峰彇鎺у埗瀵硅薄
+        this.iFxAppControl = FloatingX.install(helper);
+        this.iFxAppControl.show();
+        this.iFxAppControl.setClickListener(300, new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_AIChatBox, null);
+            }
+        });
+
+    }
 
 }
\ No newline at end of file

--
Gitblit v1.8.0