From b9408687a3c0490289206b7e3b623d1490b38afd Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期五, 06 三月 2026 09:52:30 +0800
Subject: [PATCH] 2026年03月06日09:52:20 增加AI接口

---
 app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java |   53 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java
index e058dac..e370028 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java
@@ -29,6 +29,7 @@
 import com.hdl.photovoltaic.databinding.ActivityCpowerStationBinding;
 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;
@@ -41,6 +42,9 @@
 import com.hdl.photovoltaic.other.HdlUniLogic;
 import com.hdl.photovoltaic.push.PushMessageInfoBean;
 import com.hdl.photovoltaic.services.ForeService;
+import com.hdl.photovoltaic.ui.bean.ChatInfoBean;
+import com.hdl.photovoltaic.ui.bean.ChatMessageListBean;
+import com.hdl.photovoltaic.ui.bean.ChatMessagePageBean;
 import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo;
 import com.hdl.photovoltaic.ui.bean.HouseIdBean;
 import com.hdl.photovoltaic.ui.bean.MessageBean;
@@ -105,6 +109,7 @@
         this.initMqttClient();
 //        //涓婁紶鏋佸厜娉ㄥ唽ID鍒颁簯绔�
 //        this.pushTokens();
+        this.getChatInfo();
         //涓婁紶鎺ㄥ姩浠ょ墝鍒颁簯绔紙璋锋瓕FCM鎺ㄩ�侊級
         this.sendPushTokenToServer(UserConfigManage.getInstance().getPushToken());
         //鐐瑰嚮閫氱煡鏍忔秷鎭繘鏉�
@@ -113,6 +118,41 @@
         HdlESLocalJsonLogic.getInstance().getAllHdlESLocalJson();
 //        mForegroundService= new Intent(this, ForeService.class);
 //        startService();
+    }
+
+    /**
+     * 鏌ョ湅鏅鸿兘浣撹鎯�
+     *
+     */
+    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();
+                        }
+                    }
+
+                    @Override
+                    public void onFailure(HDLException e) {
+
+                    }
+                });
+
+            }
+
+            @Override
+            public void onFailure(HDLException e) {
+                HdlLogLogic.print("鑾峰彇鏅鸿兘浣撹鎯呭け璐ワ細" + e.getMessage(), true);
+            }
+        });
     }
 
     Intent mForegroundService;
@@ -152,9 +192,10 @@
                 return;
             }
             PushMessageInfoBean pushMessageInfoBean = HdlPushLogic.getInstance().pushDataProcessing("", "", data);
-            if (TextUtils.isEmpty(pushMessageInfoBean.getMsgId())) {
+            if (TextUtils.isEmpty(pushMessageInfoBean.getMsgId()) && !pushMessageInfoBean.isAiPrompt()) {
                 return;
             }
+            Log.d("==========111111", tag);
             HDLUniMPSDKManager.uinEnabled = false;
             if (tag.equals("onNewIntent")) {
                 HDLUniMPSDKManager.uinEnabled = false;
@@ -208,7 +249,10 @@
                             @Override
                             public void run() {
                                 if (pushMessageInfoBean.isAiPrompt()) {
-                                    HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_open_ai_push_message, new HDLUniMP.UniCallBackBaseBean());
+                                    HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
+                                    uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_open_ai_push_message);
+                                    HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean);
+                                    HdlLogLogic.print("uni---鍘熺敓涓诲姩鍚戝皬绋嬪簭鍙戦�侀�氱煡AI浜嬩欢---", false);
                                 } else {
                                     MessageBean messageBean = new MessageBean();
                                     messageBean.setMsgId(Long.valueOf(pushMessageInfoBean.getMsgId()));
@@ -216,6 +260,7 @@
                                     intentMessageInfoActivity.setClass(_mActivity, MessageInfoActivity.class);
                                     intentMessageInfoActivity.putExtra("messageBean", JSONObject.toJSONString(messageBean));
                                     startActivity(intentMessageInfoActivity);
+                                    HdlLogLogic.print("uni---鍘熺敓涓诲姩鍚戝皬绋嬪簭鍙戦�侀�氱煡AI浜嬩欢---11111", false);
                                 }
 
                             }
@@ -465,7 +510,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) {
 
@@ -502,7 +547,7 @@
         if (TextUtils.isEmpty(token)) {
             return;
         }
-        HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() {
+        HdlPushLogic.getInstance().pushAdd(new CloudCallBeak<String>() {
             @Override
             public void onSuccess(String pushId) {
 

--
Gitblit v1.8.0