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 | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 53 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 733934b..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;
@@ -91,6 +95,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_FF000000));
//C绔惎鍔ˋpp鑷姩鎵撳紑灏忕▼搴忕數绔欒鎯呯晫闈�
@@ -101,6 +109,7 @@
this.initMqttClient();
// //涓婁紶鏋佸厜娉ㄥ唽ID鍒颁簯绔�
// this.pushTokens();
+ this.getChatInfo();
//涓婁紶鎺ㄥ姩浠ょ墝鍒颁簯绔紙璋锋瓕FCM鎺ㄩ�侊級
this.sendPushTokenToServer(UserConfigManage.getInstance().getPushToken());
//鐐瑰嚮閫氱煡鏍忔秷鎭繘鏉�
@@ -109,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;
@@ -148,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;
@@ -204,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()));
@@ -212,6 +260,7 @@
intentMessageInfoActivity.setClass(_mActivity, MessageInfoActivity.class);
intentMessageInfoActivity.putExtra("messageBean", JSONObject.toJSONString(messageBean));
startActivity(intentMessageInfoActivity);
+ HdlLogLogic.print("uni---鍘熺敓涓诲姩鍚戝皬绋嬪簭鍙戦�侀�氱煡AI浜嬩欢---11111", false);
}
}
@@ -461,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) {
@@ -498,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