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 |  103 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 92 insertions(+), 11 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 4265160..b21359b 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java
@@ -20,7 +20,6 @@
 import android.view.View;
 import android.widget.TextView;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
@@ -37,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;
@@ -45,10 +45,11 @@
 import com.hdl.photovoltaic.other.HdlMqttLogic;
 import com.hdl.photovoltaic.other.HdlOtaLogic;
 import com.hdl.photovoltaic.other.HdlPushLogic;
-import com.hdl.photovoltaic.other.HdlResidenceLogic;
 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;
@@ -75,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;
@@ -102,6 +108,7 @@
     private ActivityMyPowerStationBinding viewBinding;
     private EventListener allTopicsListener;
     private int backPressTimes;
+    public IFxAppControl iFxAppControl;
 
     @Override
     public Object getContentView() {
@@ -111,7 +118,7 @@
 
     @Override
     public void onBindView(Bundle savedInstanceState) {
-//        //閫氱煡鏍忕偣鍑昏繘鏉ワ紝闃叉搴旂敤鍦ㄥ悗鍙版椂琚噸澶嶅惎鍔�,闃块噷浜戞帹鍔ㄩ�氱煡鎸囧畾鎵撳紑鏌愪釜Activity锛屾病鏈夎缃瓼lags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);榛樿鍚姩鏂板疄渚嬶紝瀵艰嚧澶氫釜瀹炰緥
+////        //閫氱煡鏍忕偣鍑昏繘鏉ワ紝闃叉搴旂敤鍦ㄥ悗鍙版椂琚噸澶嶅惎鍔�,闃块噷浜戞帹鍔ㄩ�氱煡鎸囧畾鎵撳紑鏌愪釜Activity锛屾病鏈夎缃瓼lags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);榛樿鍚姩鏂板疄渚嬶紝瀵艰嚧澶氫釜瀹炰緥
 //        if (!isTaskRoot()) {
 //            finish();
 //        }
@@ -141,7 +148,8 @@
         this.getUnreadCount();
         //鑾峰彇浜戠鑴氭湰
         HdlESLocalJsonLogic.getInstance().getAllHdlESLocalJson();
-
+        this.getChatInfo();
+        this.createAppFloatWindow();
 
     }
 
@@ -155,8 +163,8 @@
             if (TextUtils.isEmpty(data)) {
                 return;
             }
-            PushMessageInfoBean pushMessageInfoBean = new Gson().fromJson(data, PushMessageInfoBean.class);
-//            PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing("", "", data);
+//            PushMessageInfoBean pushMessageInfoBean = new Gson().fromJson(data, PushMessageInfoBean.class);
+            PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing("", "", data);
             if (TextUtils.isEmpty(pushMessageInfoBean.getMsgId())) {
                 return;
             }
@@ -324,7 +332,7 @@
 //                    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) {
 
@@ -362,7 +370,7 @@
         if (TextUtils.isEmpty(token)) {
             return;
         }
-        HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() {
+        HdlPushLogic.getInstance().pushAdd(new CloudCallBeak<String>() {
             @Override
             public void onSuccess(String pushId) {
                 HdlLogLogic.print("娣诲姞浠ょ墝鍒颁簯绔� PushToken:" + UserConfigManage.getInstance().getPushToken() + " pushId:" + pushId, true);
@@ -371,6 +379,44 @@
             @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);
             }
         });
     }
@@ -479,7 +525,9 @@
         HdlUniLogic.getInstance().checkRemoveOtherUniMPEventCallBack();
         //绉婚櫎鐩戝惉
         HDLLinkLocalSdk.getInstance().removeAllTopicsListener(allTopicsListener);
-
+        if (this.iFxAppControl != null) {
+            this.iFxAppControl.cancel();
+        }
 
     }
 
@@ -787,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();
@@ -880,13 +928,14 @@
         //瑙﹀彂娑堟伅鐐瑰嚮浜嬩欢
         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.homepage_title_tab_switch, HomepageTitleTabSwitch.message.toString());
+//        HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.refresh_message_house, ConstantManage.refresh_message_house);
     }
 
 
@@ -1004,5 +1053,37 @@
         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