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/uni/HDLUniMP.java | 10
app/src/main/java/com/hdl/photovoltaic/ui/CPowerStationActivity.java | 40 ++
app/src/main/java/com/hdl/photovoltaic/ui/me/AsRegardsActivity.java | 1
app/src/main/java/com/hdl/photovoltaic/other/HdlAiLogic.java | 345 +++++++++++++++++
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java | 67 +++
app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java | 40 +
app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatMessageListBean.java | 93 ++++
app/src/main/java/com/hdl/photovoltaic/ui/me/MeFragment.java | 2
app/src/main/java/com/hdl/photovoltaic/internet/api/HttpApi.java | 2
app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatMessageBean.java | 77 +++
app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatMessagePageBean.java | 38 +
app/src/main/java/com/hdl/photovoltaic/config/UserConfigManage.java | 37 +
app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatInfoBean.java | 78 +++
app/src/main/java/com/hdl/photovoltaic/internet/ChatStreamClient.java | 338 ++++++++++++++++
14 files changed, 1,164 insertions(+), 4 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/config/UserConfigManage.java b/app/src/main/java/com/hdl/photovoltaic/config/UserConfigManage.java
index 6f0d251..6295c57 100644
--- a/app/src/main/java/com/hdl/photovoltaic/config/UserConfigManage.java
+++ b/app/src/main/java/com/hdl/photovoltaic/config/UserConfigManage.java
@@ -65,6 +65,42 @@
//鏄惁姝e紡鏈嶅姟鍣�(true锛氭寮忥紝false锛氭祴璇�)
private boolean isOnlineServer = false;
+ //鏅鸿兘浣撴帴鍙e瘑閽�
+ private String agentSecret;
+ //鏅鸿兘浣撴帴鍙e湴鍧�
+ private String agentUrl;
+ //褰撳墠浼氳瘽ID
+ private String conversationId;
+
+ public String getAgentUrl() {
+ return agentUrl == null ? "" : agentUrl;
+ }
+
+ public void setAgentUrl(String agentUrl) {
+ this.agentUrl = agentUrl;
+ }
+
+ /**
+ * 鏅鸿兘浣揂ppKey
+ *
+ * @return 鏅鸿兘浣揂ppKey
+ */
+ public String getAgentSecret() {
+ return agentSecret == null ? "" : agentSecret;
+ }
+
+ public void setAgentSecret(String agentApiKey) {
+ this.agentSecret = agentApiKey;
+ }
+
+ public String getConversationId() {
+ return conversationId == null ? "" : conversationId;
+ }
+
+ public void setConversationId(String conversationId) {
+ this.conversationId = conversationId;
+ }
+
public boolean isOnlineServer() {
return isOnlineServer;
}
@@ -450,6 +486,7 @@
/**
* 鏄笉鏄樋鎷変集璇█
+ *
* @return true琛ㄧず鏄樋鎷変集璇█锛屽惁鍒欎笉鏄�
*/
public boolean isArabicLanguage() {
diff --git a/app/src/main/java/com/hdl/photovoltaic/internet/ChatStreamClient.java b/app/src/main/java/com/hdl/photovoltaic/internet/ChatStreamClient.java
new file mode 100644
index 0000000..2c2cda4
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/internet/ChatStreamClient.java
@@ -0,0 +1,338 @@
+package com.hdl.photovoltaic.internet;
+
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.hdl.photovoltaic.config.UserConfigManage;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+import okhttp3.Cache;
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.MediaType;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import okhttp3.ResponseBody;
+import okio.Buffer;
+
+/**
+ * AI 鑱婂ぉ娴佸紡璇锋眰宸ュ叿绫�
+ * 鏀寔 SSE (Server-Sent Events) 娴佸紡鍝嶅簲
+ * 绫讳技 ChatGPT 鐨勬祦寮忚緭鍑烘晥鏋�
+ */
+public class ChatStreamClient {
+ // 鍗曚緥瀹炰緥
+ private static volatile ChatStreamClient instance;
+
+ /**
+ * 鑾峰彇鍗曚緥瀹炰緥
+ */
+ public static ChatStreamClient getInstance() {
+ if (instance == null) {
+ synchronized (ChatStreamClient.class) {
+ if (instance == null) {
+ instance = new ChatStreamClient();
+ }
+ }
+ }
+ return instance;
+ }
+
+ // ==================== 甯搁噺瀹氫箟 ====================
+ private static final MediaType JSON = MediaType.get("application/json");
+ private static final String SSE_MEDIA_TYPE = "text/event-stream";
+ private static final String JSON_MEDIA_TYPE = "application/json";
+ private static final String DONE_FLAG = "[DONE]";
+
+ private final OkHttpClient okHttpClient = new OkHttpClient.Builder()
+ .connectTimeout(30, TimeUnit.SECONDS)
+ .readTimeout(0, TimeUnit.SECONDS)
+ .writeTimeout(30, TimeUnit.SECONDS)
+// .connectionPool(new ConnectionPool(
+// builder.maxIdleConnections,
+// builder.keepAliveDuration,
+// builder.timeUnit
+// ))
+// .retryOnConnectionFailure(builder.retryOnFailure)
+// .addInterceptor(new HttpLoggingInterceptor()) // 鍙�夛細娣诲姞鏃ュ織
+ .build();
+ ; // HTTP 瀹㈡埛绔�
+ private final Gson gson = new Gson(); // JSON 瑙f瀽鍣�
+ private final String apiKey = "Bearer " + UserConfigManage.getInstance().getAgentSecret(); // API 瀵嗛挜
+ private final String baseUrl = UserConfigManage.getInstance().getAgentUrl();// "https://agent.hdlcontrol.com/v1";; // 鍩虹 URL
+
+
+ // ==================== 鍥炶皟鎺ュ彛 ====================
+ public interface ChatCallback {
+ /**
+ * 鏀跺埌娑堟伅鐗囨鏃跺洖璋冿紙娴佸紡杈撳嚭锛�
+ *
+ * @param content 娑堟伅鍐呭鐗囨
+ */
+ void onMessage(String content);
+
+ /**
+ * 娑堟伅瀹屾垚鏃跺洖璋�
+ */
+ default void onComplete() {
+ }
+
+ /**
+ * 鍙戠敓閿欒鏃跺洖璋�
+ *
+ * @param error 閿欒淇℃伅
+ */
+ default void onError(String error) {
+ }
+
+ /**
+ * 鏀跺埌瀹屾暣娑堟伅鏃跺洖璋冿紙闈炴祦寮忔ā寮忎娇鐢級
+ *
+ * @param fullMessage 瀹屾暣娑堟伅
+ */
+ default void onFullMessage(String fullMessage) {
+ }
+ }
+
+ // ==================== 璇锋眰鍙傛暟绫� ====================
+ public static class ChatMode {
+ public boolean stream = true;
+ public boolean isGet = false;
+ public String url = "";
+ public Object data = null;
+ }
+
+
+ /**
+ * 鍙戦�佹祦寮忚亰澶╄姹傦紙瀹屾暣鍙傛暟锛�
+ *
+ * @param chatMode 璇锋眰鍙傛暟
+ * @param callback 鍥炶皟鎺ュ彛
+ * @return Cancelable 鍙彇娑堢殑瀵硅薄
+ */
+ public Cancelable streamChat(ChatMode chatMode, ChatCallback callback) {
+// // 纭繚鏄祦寮忚姹�
+// chatMode.stream = true;
+
+ // 鏋勫缓 HTTP 璇锋眰
+ Request httpRequest = buildHttpRequest(chatMode);
+// try {
+// // 鑾峰彇璇锋眰浣�
+// if (httpRequest.body() != null) {
+// Buffer buffer = new Buffer();
+// httpRequest.body().writeTo(buffer);
+// String body = buffer.readUtf8();
+// // 娉ㄦ剰锛氳鍙栧悗璁板緱鍏抽棴 buffer
+// buffer.close();
+// System.out.println("Request Body: " + body);
+//
+// }
+// } catch (Exception e) {
+//
+// }
+ // 鍒涘缓鍙彇娑堢殑 Call
+ Call call = okHttpClient.newCall(httpRequest);
+
+ // 鎵ц寮傛璇锋眰
+ call.enqueue(new StreamCallbackHandler(call, chatMode, callback));
+
+ // 杩斿洖鍙彇娑堝璞�
+ return () -> {
+ if (!call.isCanceled()) {
+ call.cancel();
+ }
+ };
+ }
+
+ /**
+ * 鍙戦�侀潪娴佸紡鑱婂ぉ璇锋眰锛堜竴娆℃�ц繑鍥烇級
+ *
+ * @param request 璇锋眰鍙傛暟
+ * @return 瀹屾暣鍝嶅簲
+ */
+ public String chatSync(ChatMode request) {
+// request.stream = false;
+ Request httpRequest = buildHttpRequest(request);
+ try (Response response = okHttpClient.newCall(httpRequest).execute()) {
+ if (!response.isSuccessful()) {
+ return response.message() + "(" + response.code() + ")";
+ }
+ return Objects.requireNonNull(response.body()).string();
+ } catch (Exception e) {
+ return e.getMessage();
+ }
+ }
+
+
+ /**
+ * 鏋勫缓 HTTP 璇锋眰
+ */
+ private Request buildHttpRequest(ChatMode ChatMode) {
+
+ String jsonBody = "";
+ if (ChatMode.data != null) {
+ jsonBody = gson.toJson(ChatMode.data);
+ }
+ String newUrl = baseUrl + ChatMode.url;
+ if (ChatMode.isGet) {
+ return new Request.Builder()
+ .url(newUrl)
+ .get()
+ .addHeader("Authorization", apiKey)
+ .addHeader("Cache-Control", "no-cache")
+ .addHeader("Connection", "keep-alive")
+ .build();
+ } else {
+ return new Request.Builder()
+ .url(newUrl)
+ .post(RequestBody.create(jsonBody, JSON))
+ .addHeader("Authorization", apiKey)
+ .addHeader("Accept", ChatMode.stream ? SSE_MEDIA_TYPE : JSON_MEDIA_TYPE)
+ .addHeader("Cache-Control", "no-cache")
+ .addHeader("Connection", "keep-alive")
+ .build();
+ }
+ }
+
+
+ /**
+ * 瑙f瀽娴佸紡鏁版嵁鍧�
+ */
+ private String parseStreamChunk(String data) {
+ if (data == null || data.isEmpty() || data.equals(DONE_FLAG)) {
+ return "";
+ }
+ try {
+ JsonObject json = JsonParser.parseString(data).getAsJsonObject();
+ String event = json.has("event") ? json.get("event").getAsString() : "";
+ if (event.equals("message")) {
+ return json.getAsString();
+ } else if (event.equals("message_end")) {
+ return DONE_FLAG;
+ } else if (event.equals("error")) {
+ return "error";
+ } else {
+ return "";
+ }
+
+ } catch (Exception e) {
+ // 瑙f瀽澶辫触锛岃繑鍥炲師濮嬫暟鎹�
+ return data;
+ }
+ }
+
+ // ==================== 娴佸紡鍝嶅簲澶勭悊鍣� ====================
+ private class StreamCallbackHandler implements Callback {
+ private final Call call;
+ private final ChatMode request;
+ private final ChatCallback callback;
+ private final StringBuilder fullContent = new StringBuilder();
+
+ public StreamCallbackHandler(Call call, ChatMode request, ChatCallback callback) {
+ this.call = call;
+ this.request = request;
+ this.callback = callback;
+ }
+
+ @Override
+ public void onFailure(@NotNull Call call, @NotNull IOException e) {
+ callback.onError("Network error: " + e.getMessage());
+
+ }
+
+ @Override
+ public void onResponse(@NotNull Call call, @NotNull Response response) {
+ if (!response.isSuccessful()) {
+ callback.onError("HTTP error: " + response.code());
+ response.close();
+ return;
+ }
+ // 妫�鏌ュ唴瀹圭被鍨�
+ MediaType contentType = response.body().contentType();
+ if (contentType == null || !contentType.toString().startsWith(SSE_MEDIA_TYPE)) {
+ // 濡傛灉涓嶆槸娴佸紡锛屽彲鑳芥槸鏅�� JSON
+ try {
+ String body = response.body().string();
+ callback.onFullMessage(body);
+ } catch (IOException e) {
+ callback.onError("Parse error: " + e.getMessage());
+ }
+ response.close();
+ return;
+ }
+
+ // 娴佸紡澶勭悊
+ try (ResponseBody responseBody = response.body()) {
+ BufferedReader reader = new BufferedReader(responseBody.charStream());
+ String line;
+ while ((line = reader.readLine()) != null) {
+ if (call.isCanceled()) {
+ break;
+ }
+
+ if (line.startsWith("data:")) {
+ String data = line.substring(5).trim();
+ Log.d("娴佸紡澶勭悊==", line);
+ if (data.equals(DONE_FLAG)) {
+ callback.onComplete();
+ break;
+ }
+ String content = parseStreamChunk(data);
+ if (!TextUtils.isEmpty(content)) {
+ if (content.equals(DONE_FLAG)) {
+ callback.onComplete();
+ break;
+ } else if (content.equals("error")) {
+ callback.onError(data);
+ break;
+ }
+ fullContent.append(content);
+ callback.onMessage(content);
+ }
+ }
+ }
+
+// // 濡傛灉娌℃敹鍒� DONE 浣嗘祦缁撴潫浜嗭紝涔熷洖璋� complete
+// if (isActive.get()) {
+// callback.onComplete();
+// }
+
+ } catch (IOException e) {
+ callback.onError("Stream error: " + e.getMessage());
+ }
+ }
+ }
+
+ // ==================== 鍙彇娑堟帴鍙� ====================
+ public interface Cancelable {
+ void cancel();
+ }
+
+
+ /**
+ * 閲婃斁璧勬簮锛堝簲鐢ㄩ��鍑烘椂璋冪敤锛�
+ */
+ public void shutdown() {
+ okHttpClient.dispatcher().executorService().shutdown();
+ okHttpClient.connectionPool().evictAll();
+ try {
+ Cache cache = okHttpClient.cache();
+ if (cache != null) {
+ cache.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/hdl/photovoltaic/internet/api/HttpApi.java b/app/src/main/java/com/hdl/photovoltaic/internet/api/HttpApi.java
index 7ca72e6..2b637b1 100644
--- a/app/src/main/java/com/hdl/photovoltaic/internet/api/HttpApi.java
+++ b/app/src/main/java/com/hdl/photovoltaic/internet/api/HttpApi.java
@@ -229,6 +229,8 @@
public static final String C_POST_HOME_GETHEADP脧ORTRAIT = "/home-wisdom/app/child/account/getHeadP脧ortrait";
//娉ㄩ攢璐﹀彿
public static final String C_POST_MEMBER_UNREGISTER = "/basis-footstone/member/unregister";
+ //鏌ョ湅鏅鸿兘浣撹鎯�
+ public static final String GET_AGENT_INFO = "/basis-footstone/agent/info";
//endregion
//endregion
diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlAiLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlAiLogic.java
new file mode 100644
index 0000000..9c9de51
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlAiLogic.java
@@ -0,0 +1,345 @@
+package com.hdl.photovoltaic.other;
+
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.google.gson.reflect.TypeToken;
+import com.hdl.linkpm.sdk.HDLLinkPMSdk;
+import com.hdl.linkpm.sdk.core.exception.HDLException;
+import com.hdl.linkpm.sdk.user.HDLLinkPMUser;
+import com.hdl.photovoltaic.bean.PageNumberObject;
+import com.hdl.photovoltaic.config.UserConfigManage;
+import com.hdl.photovoltaic.internet.ChatStreamClient;
+import com.hdl.photovoltaic.internet.HttpClient;
+import com.hdl.photovoltaic.internet.api.HttpApi;
+import com.hdl.photovoltaic.listener.CloudCallBeak;
+import com.hdl.photovoltaic.ui.bean.ChatInfoBean;
+import com.hdl.photovoltaic.ui.bean.ChatMessageBean;
+import com.hdl.photovoltaic.ui.bean.ChatMessageListBean;
+import com.hdl.photovoltaic.ui.bean.ChatMessagePageBean;
+import com.hdl.photovoltaic.ui.bean.StaffBean;
+import com.hdl.photovoltaic.uni.HDLUniMPSDKManager;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Ai閫昏緫
+ */
+public class HdlAiLogic {
+ private static volatile HdlAiLogic sHdlAiLogic;
+ private final Gson gson = new Gson();
+
+ /**
+ * 鑾峰彇褰撳墠瀵硅薄
+ *
+ * @return HdlAccountLogic
+ */
+ public static synchronized HdlAiLogic getInstance() {
+ if (sHdlAiLogic == null) {
+ synchronized (HdlAiLogic.class) {
+ if (sHdlAiLogic == null) {
+ sHdlAiLogic = new HdlAiLogic();
+ }
+ }
+
+ }
+ return sHdlAiLogic;
+ }
+
+ /**
+ * 鑾峰彇鏅鸿兘浣撹鎯�
+ *
+ * @param cloudCallBeak -
+ */
+ public void getChatInfo(CloudCallBeak<ChatInfoBean> cloudCallBeak) {
+ String requestUrl = HttpApi.GET_AGENT_INFO;
+ JsonObject json = new JsonObject();
+ json.addProperty("agentCode", "xenterra_app_rag");
+ HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
+ @Override
+ public void onSuccess(String jsonStr) {
+ if (TextUtils.isEmpty(jsonStr)) {
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(new ChatInfoBean());
+ }
+ }
+ Type type = new TypeToken<ChatInfoBean>() {
+ }.getType();
+ ChatInfoBean chatInfoBean = gson.fromJson(jsonStr, type);
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(chatInfoBean);
+ }
+
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onFailure(e);
+ }
+ }
+ });
+
+
+ }
+
+ /**
+ * 鑾峰彇瀵硅瘽鍒楄〃
+ *
+ */
+ public void chatMessagesList(CloudCallBeak<ChatMessagePageBean> cloudCallBeak) {
+ ChatStreamClient.ChatMode chatMode = new ChatStreamClient.ChatMode();
+ chatMode.stream = false;
+ chatMode.isGet = true;
+ chatMode.url = "/conversations?" + "user=" + UserConfigManage.getInstance().getUserId();//+"&"+;
+ ChatStreamClient.getInstance().streamChat(chatMode, new ChatStreamClient.ChatCallback() {
+ @Override
+ public void onMessage(String content) {
+
+ }
+
+ @Override
+ public void onFullMessage(String fullMessage) {
+ ChatStreamClient.ChatCallback.super.onFullMessage(fullMessage);
+ try {
+ if (TextUtils.isEmpty(fullMessage)) {
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(new ChatMessagePageBean());
+ }
+ return;
+ }
+ Type type = new TypeToken<ChatMessagePageBean>() {
+ }.getType();
+ ChatMessagePageBean chatMessagePageBean = gson.fromJson(fullMessage, type);
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(chatMessagePageBean);
+ }
+ } catch (Exception e) {
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(null);
+ }
+ }
+
+ }
+
+ @Override
+ public void onError(String error) {
+ ChatStreamClient.ChatCallback.super.onError(error);
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onFailure(new HDLException(-10201, error));
+ }
+ }
+ });
+ }
+
+ /**
+ * 鍒涘缓浼氳瘽娑堟伅,AI鑱婂ぉ
+ *
+ * @param message 鐢ㄦ埛杈撳叆/鎻愰棶鍐呭銆�
+ */
+ public void chatMessages(String message, CloudCallBeak<ChatMessageBean> cloudCallBeak) {
+ if (TextUtils.isEmpty(UserConfigManage.getInstance().getConversationId())) {
+ this.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();
+ }
+ ChatStreamClient.ChatMode chatMode = new ChatStreamClient.ChatMode();
+ chatMode.data = getJsonObject(message);
+ chatMode.stream = true;
+ chatMode.url = "/chat-messages";
+ ChatStreamClient.getInstance().streamChat(chatMode, new ChatStreamClient.ChatCallback() {
+ @Override
+ public void onMessage(String content) {
+ try {
+ Type type = new TypeToken<ChatMessageBean>() {
+ }.getType();
+ ChatMessageBean ChatMessageBean = gson.fromJson(content, type);
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(ChatMessageBean);
+ }
+ Log.d("AI鑱婂ぉ鍥炲===", gson.toJson(ChatMessageBean));
+ } catch (Exception e) {
+// if (cloudCallBeak != null) {
+// cloudCallBeak.onSuccess(null);
+// }
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onFailure(new HDLException(-10202, e.getMessage()));
+ }
+ }
+ }
+
+ @Override
+ public void onComplete() {
+ ChatStreamClient.ChatCallback.super.onComplete();
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(null);
+ }
+ Log.d("AI鑱婂ぉ鍥炲===", "done");
+ }
+
+ @Override
+ public void onError(String error) {
+ ChatStreamClient.ChatCallback.super.onError(error);
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onFailure(new HDLException(-10201, error));
+ }
+ }
+ });
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ ChatStreamClient.ChatMode chatMode = new ChatStreamClient.ChatMode();
+ chatMode.data = getJsonObject(message);
+ chatMode.stream = true;
+ chatMode.url = "/chat-messages";
+ ChatStreamClient.getInstance().streamChat(chatMode, new ChatStreamClient.ChatCallback() {
+ @Override
+ public void onMessage(String content) {
+ try {
+ Type type = new TypeToken<ChatMessageBean>() {
+ }.getType();
+ ChatMessageBean ChatMessageBean = gson.fromJson(content, type);
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(ChatMessageBean);
+ }
+ Log.d("AI鑱婂ぉ鍥炲===", gson.toJson(ChatMessageBean));
+ } catch (Exception e) {
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(null);
+ }
+ }
+ }
+
+ @Override
+ public void onComplete() {
+ ChatStreamClient.ChatCallback.super.onComplete();
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(null);
+ }
+ Log.d("AI鑱婂ぉ鍥炲===", "done");
+ }
+
+ @Override
+ public void onError(String error) {
+ ChatStreamClient.ChatCallback.super.onError(error);
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onFailure(new HDLException(-10201, error));
+ }
+ }
+ });
+ }
+ });
+ } else {
+ ChatStreamClient.ChatMode chatMode = new ChatStreamClient.ChatMode();
+ chatMode.data = getJsonObject(message);
+ chatMode.stream = true;
+ chatMode.url = "/chat-messages";
+ ChatStreamClient.getInstance().streamChat(chatMode, new ChatStreamClient.ChatCallback() {
+ @Override
+ public void onMessage(String content) {
+ try {
+ Type type = new TypeToken<ChatMessageBean>() {
+ }.getType();
+ ChatMessageBean ChatMessageBean = gson.fromJson(content, type);
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(ChatMessageBean);
+ }
+ Log.d("AI鑱婂ぉ鍥炲===", gson.toJson(ChatMessageBean));
+ } catch (Exception e) {
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(null);
+ }
+ }
+ }
+
+ @Override
+ public void onComplete() {
+ ChatStreamClient.ChatCallback.super.onComplete();
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(null);
+ }
+ Log.d("AI鑱婂ぉ鍥炲===", "done");
+ }
+
+ @Override
+ public void onError(String error) {
+ ChatStreamClient.ChatCallback.super.onError(error);
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onFailure(new HDLException(-10201, error));
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ * 鍋滄鍝嶅簲
+ *
+ * @param task_id 浠诲姟ID
+ */
+ public void chatMessageStop(String task_id, CloudCallBeak<Boolean> cloudCallBeak) {
+ JsonObject json = new JsonObject();
+ if (!TextUtils.isEmpty(task_id)) {
+ json.addProperty("task_id", task_id);
+ }
+ json.addProperty("user", UserConfigManage.getInstance().getUserId());
+ ChatStreamClient.ChatMode chatMode = new ChatStreamClient.ChatMode();
+ chatMode.data = json;
+ chatMode.stream = false;
+ chatMode.isGet = false;
+ chatMode.url = "/chat-messages/:task_id/stop";
+ ChatStreamClient.getInstance().streamChat(chatMode, new ChatStreamClient.ChatCallback() {
+ @Override
+ public void onMessage(String content) {
+ }
+
+ @Override
+ public void onFullMessage(String fullMessage) {
+ //涓�娆℃�у洖澶�
+ if (cloudCallBeak != null) {
+// boolean isSuccess = fullMessage.contains("\"success\":true");
+ boolean isSuccess = fullMessage.contains("true");
+ cloudCallBeak.onSuccess(isSuccess);
+ }
+ }
+
+ @Override
+ public void onError(String error) {
+ ChatStreamClient.ChatCallback.super.onError(error);
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onFailure(new HDLException(-10201, error));
+ }
+ }
+ });
+ }
+
+ /**
+ * 鑾峰彇json瀵硅薄
+ *
+ * @param message 瀵硅瘽鍐呭
+ * @return json瀵硅薄
+ */
+ private JsonObject getJsonObject(String message) {
+ JsonObject json = new JsonObject();
+ JsonObject inputs = new JsonObject();
+ inputs.addProperty("source", "APP");
+ inputs.addProperty("platform", "APP");
+ json.add("inputs", inputs);
+ json.addProperty("query", message);
+ json.addProperty("response_mode", "streaming");
+ json.addProperty("conversation_id", UserConfigManage.getInstance().getConversationId());
+ json.addProperty("user", UserConfigManage.getInstance().getUserId());
+ return json;
+ }
+
+
+}
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 e459528..b6b2a79 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -47,6 +47,7 @@
import com.hdl.photovoltaic.listener.LinkCallBack;
import com.hdl.photovoltaic.ui.LoginActivity;
import com.hdl.photovoltaic.ui.bean.CUserInfo;
+import com.hdl.photovoltaic.ui.bean.ChatMessageBean;
import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean;
import com.hdl.photovoltaic.ui.bean.DeviceInfoBean;
import com.hdl.photovoltaic.ui.bean.DeviceTimeBean;
@@ -939,6 +940,19 @@
}
});
+ } else if (HDLUniMP.UNI_EVENT_REPLY_AI_MODEL.equals(topic)) {
+ switch (type) {
+ //鍙戦�乤i瀵硅瘽鑱婂ぉ
+ case HDLUniMP.UNI_EVENT_REPLY_AI_MODEL_SENDAIREQUEST: {
+ this.uniSendAIChat(mode_type, data, callback);
+ }
+ break;
+ //鍙戦�乤i瀵硅瘽鑱婂ぉ
+ case HDLUniMP.UNI_EVENT_REPLY_AI_MODEL_PAUSEAIREQUEST: {
+ this.uniSendStopAIChat(mode_type, data, callback);
+ }
+ break;
+ }
}
} catch (Exception e) {
@@ -947,6 +961,59 @@
}
+ /**
+ * Uni(鍙栨秷/鏆傚仠)AI鑱婂ぉ瀵硅瘽
+ *
+ * @param callback -
+ */
+ private void uniSendStopAIChat(String type, Object data, DCUniMPJSCallback callback) {
+ String task_id = getKeyValue("task_id", getKeyValue("data", data));
+ HdlAiLogic.getInstance().chatMessageStop(task_id, new CloudCallBeak<Boolean>() {
+ @Override
+ public void onSuccess(Boolean obj) {
+ if (callback != null) {
+ uniSuccessCallback(type, obj, callback);
+ }
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
+ }
+ });
+ }
+
+ /**
+ * Uni鍙戣捣AI鑱婂ぉ瀵硅瘽
+ *
+ * @param callback -
+ */
+ private void uniSendAIChat(String type, Object data, DCUniMPJSCallback callback) {
+ String query = getKeyValue("query", getKeyValue("data", data));
+ HdlAiLogic.getInstance().chatMessages(query, new CloudCallBeak<ChatMessageBean>() {
+ @Override
+ public void onSuccess(ChatMessageBean obj) {
+ HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
+ if (obj == null) {
+ //琛ㄧず缁撴潫
+ uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_REPLY_AI_MODEL_AISTREAMINGEND);
+ } else {
+ uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_REPLY_AI_MODEL_AISTREAMING);
+ uniCallBackBaseBean.setData(obj);
+ }
+ HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean);
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
+// HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
+// uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_REPLY_AI_MODEL_AISTREAMINGEND);
+// uniCallBackBaseBean.setData(e.getMessage());
+// HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean);
+ }
+ });
+ }
/**
* 鍘熺敓銆愭墦寮�銆憉ni鎸囧畾椤甸潰
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 1d22b7e..ef0499e 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java
@@ -37,6 +37,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;
@@ -49,6 +50,9 @@
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.ChatMessageListBean;
+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;
@@ -141,7 +145,7 @@
this.getUnreadCount();
//鑾峰彇浜戠鑴氭湰
HdlESLocalJsonLogic.getInstance().getAllHdlESLocalJson();
-
+ this.getChatInfo();
}
@@ -376,6 +380,40 @@
}
/**
+ * 鏌ョ湅鏅鸿兘浣撹鎯�
+ *
+ */
+ 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("鑾峰彇鏅鸿兘浣揂ppKey澶辫触 Pu" + e.getMessage(), true);
+ }
+ });
+ }
+
+ /**
* 寮�鍚�氱煡鏉冮檺
*/
private void notificationSet() {
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 e77b1ce..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());
//鐐瑰嚮閫氱煡鏍忔秷鎭繘鏉�
@@ -115,6 +120,41 @@
// 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;
private void startService() {
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatInfoBean.java b/app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatInfoBean.java
new file mode 100644
index 0000000..6e175c3
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatInfoBean.java
@@ -0,0 +1,78 @@
+package com.hdl.photovoltaic.ui.bean;
+
+import java.io.Serializable;
+
+public class ChatInfoBean implements Serializable {
+
+ /**
+ * 鏅鸿兘浣撳钩鍙�
+ */
+ private String agentPlatform;
+ private String agentCode;
+ /**
+ * 鍚嶇О
+ */
+ private String agentName;
+ /**
+ * 鎻忚堪
+ */
+ private String agentDesc;
+ /**
+ * 鎺ュ彛瀵嗛挜
+ */
+ private String agentSecret;
+ /**
+ * 鎺ュ彛鍦板潃
+ */
+ private String agentUrl;
+
+ public String getAgentPlatform() {
+ return agentPlatform == null ? "" : agentPlatform;
+ }
+
+ public void setAgentPlatform(String agentPlatform) {
+ this.agentPlatform = agentPlatform;
+ }
+
+ public String getAgentCode() {
+ return agentCode == null ? "" : agentCode;
+ }
+
+ public void setAgentCode(String agentCode) {
+ this.agentCode = agentCode;
+ }
+
+ public String getAgentName() {
+ return agentName == null ? "" : agentName;
+ }
+
+ public void setAgentName(String agentName) {
+ this.agentName = agentName;
+ }
+
+ public String getAgentDesc() {
+ return agentDesc == null ? "" : agentDesc;
+ }
+
+ public void setAgentDesc(String agentDesc) {
+ this.agentDesc = agentDesc;
+ }
+
+ public String getAgentSecret() {
+ return agentSecret == null ? "" : agentSecret;
+ }
+
+ public void setAgentSecret(String agentSecret) {
+ this.agentSecret = agentSecret;
+ }
+
+ public String getAgentUrl() {
+ return agentUrl == null ? "" : agentUrl;
+ }
+
+ public void setAgentUrl(String agentUrl) {
+ this.agentUrl = agentUrl;
+ }
+
+
+}
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatMessageBean.java b/app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatMessageBean.java
new file mode 100644
index 0000000..f377805
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatMessageBean.java
@@ -0,0 +1,77 @@
+package com.hdl.photovoltaic.ui.bean;
+
+import java.io.Serializable;
+
+/**
+ * 鑱婂ぉ淇℃伅鏈嶅姟鍣ㄨ繑鍥炰簨浠�(event)瀵硅薄
+ *
+ * @author HDL
+ */
+public class ChatMessageBean implements Serializable {
+
+ private String event;
+ private String conversation_id;
+ private String message_id;
+ private long created_at;
+ private String task_id;
+ private String id;
+ private String answer;
+
+ public String getEvent() {
+ return event == null ? "" : event;
+ }
+
+ public void setEvent(String event) {
+ this.event = event;
+ }
+
+ public String getConversation_id() {
+ return conversation_id == null ? "" : conversation_id;
+ }
+
+ public void setConversation_id(String conversation_id) {
+ this.conversation_id = conversation_id;
+ }
+
+ public String getMessage_id() {
+ return message_id == null ? "" : message_id;
+ }
+
+ public void setMessage_id(String message_id) {
+ this.message_id = message_id;
+ }
+
+ public long getCreated_at() {
+ return created_at;
+ }
+
+ public void setCreated_at(long created_at) {
+ this.created_at = created_at;
+ }
+
+ public String getTask_id() {
+ return task_id == null ? "" : task_id;
+ }
+
+ public void setTask_id(String task_id) {
+ this.task_id = task_id;
+ }
+
+ public String getId() {
+ return id == null ? "" : id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getAnswer() {
+ return answer == null ? "" : answer;
+ }
+
+ public void setAnswer(String answer) {
+ this.answer = answer;
+ }
+
+
+}
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatMessageListBean.java b/app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatMessageListBean.java
new file mode 100644
index 0000000..e922bf4
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatMessageListBean.java
@@ -0,0 +1,93 @@
+package com.hdl.photovoltaic.ui.bean;
+
+import java.io.Serializable;
+
+/**
+ * 鑱婂ぉ瀵硅瘽鍒楄〃瀹炰綋绫�
+ */
+public class ChatMessageListBean implements Serializable {
+ private String id;
+ private String name;
+ private Inputs inputs;
+ private String status;
+ private String introduction;
+ private long createdAt;
+ private long updatedAt;
+
+ public String getId() {
+ return id == null ? "" : id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name == null ? "" : name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Inputs getInputs() {
+ return inputs;
+ }
+
+ public void setInputs(Inputs inputs) {
+ this.inputs = inputs;
+ }
+
+ public String getStatus() {
+ return status == null ? "" : status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getIntroduction() {
+ return introduction == null ? "" : introduction;
+ }
+
+ public void setIntroduction(String introduction) {
+ this.introduction = introduction;
+ }
+
+ public long getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(long createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public long getUpdatedAt() {
+ return updatedAt;
+ }
+
+ public void setUpdatedAt(long updatedAt) {
+ this.updatedAt = updatedAt;
+ }
+
+ public static class Inputs implements Serializable {
+ private String source;
+ private String platform;
+
+ public String getSource() {
+ return source == null ? "" : source;
+ }
+
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ public String getPlatform() {
+ return platform == null ? "" : platform;
+ }
+
+ public void setPlatform(String platform) {
+ this.platform = platform;
+ }
+ }
+}
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatMessagePageBean.java b/app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatMessagePageBean.java
new file mode 100644
index 0000000..976069f
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/bean/ChatMessagePageBean.java
@@ -0,0 +1,38 @@
+package com.hdl.photovoltaic.ui.bean;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ChatMessagePageBean implements Serializable {
+ private int limit;
+ private boolean has_more;
+ private List<ChatMessageListBean> data = new ArrayList<ChatMessageListBean>();
+
+ public boolean isHas_more() {
+ return has_more;
+ }
+
+ public void setHas_more(boolean has_more) {
+ this.has_more = has_more;
+ }
+
+ public int getLimit() {
+ return limit;
+ }
+
+ public void setLimit(int limit) {
+ this.limit = limit;
+ }
+
+ public List<ChatMessageListBean> getData() {
+ return data;
+ }
+
+ public void setData(List<ChatMessageListBean> data) {
+ this.data = data;
+ }
+
+
+
+}
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/me/AsRegardsActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/me/AsRegardsActivity.java
index feeee19..6581138 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/me/AsRegardsActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/me/AsRegardsActivity.java
@@ -17,6 +17,7 @@
import com.hdl.photovoltaic.databinding.ActivityAsRegardsBinding;
import com.hdl.photovoltaic.enums.ShowErrorMode;
import com.hdl.photovoltaic.listener.CloudCallBeak;
+import com.hdl.photovoltaic.other.HdlAiLogic;
import com.hdl.photovoltaic.other.HdlAppUpdateLogic;
import com.hdl.photovoltaic.other.HdlCommonLogic;
import com.hdl.photovoltaic.other.HdlThreadLogic;
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/me/MeFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/me/MeFragment.java
index 2f4d379..0ba6622 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/me/MeFragment.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/me/MeFragment.java
@@ -20,6 +20,7 @@
import com.hdl.photovoltaic.enums.LogoutType;
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.other.HdlAccountLogic;
+import com.hdl.photovoltaic.other.HdlAiLogic;
import com.hdl.photovoltaic.other.HdlLogLogic;
import com.hdl.photovoltaic.other.HdlMemberLogic;
import com.hdl.photovoltaic.other.HdlResidenceLogic;
@@ -173,6 +174,7 @@
viewBinding.exitTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+
HdlAccountLogic.getInstance().logout(LogoutType.NormalLogout);
}
});
diff --git a/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java b/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java
index 094070c..2deb311 100644
--- a/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java
+++ b/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java
@@ -128,7 +128,6 @@
public final static String UNI_EVENT_REPLY_help_Detail = "help";//鎵撳紑C绔府鍔╅〉闈�
-
/*********Wifi妯″潡*********/
public final static String UNI_EVENT_REPLY_WIFI_MODEL = "uni_wifi_model";//wifi妯″潡(澶х被)
public final static String UNI_EVENT_REPLY_PHONE_WIFI_LIST = "phone_wifi_list";//鎵嬫満鑾峰彇wifi鍒楄〃
@@ -152,7 +151,12 @@
/*********缃戠粶璇锋眰妯″潡*********/
public final static String UNI_EVENT_REPLY_UNI_SEND_TO_CLOUD = "uni_send_to_cloud";//uni缃戠粶璇锋眰
-
+ /*********AI妯″潡*********/
+ public final static String UNI_EVENT_REPLY_AI_MODEL = "uni_ai_model";//AI妯″潡(澶х被)
+ public final static String UNI_EVENT_REPLY_AI_MODEL_SENDAIREQUEST = "uni_SendAIRequest";//鍙戦�乤i璇锋眰
+ public final static String UNI_EVENT_REPLY_AI_MODEL_AISTREAMING = "uni_AIStreaming";// 娴佸紡璇锋眰鐗囨
+ public final static String UNI_EVENT_REPLY_AI_MODEL_AISTREAMINGEND = "uni_AIStreamingEnd";// 娴佸紡璇锋眰缁撴潫
+ public final static String UNI_EVENT_REPLY_AI_MODEL_PAUSEAIREQUEST = "uni_PauseAIRequest";//鍙栨秷ai璇锋眰
//endregion
//region --------銆愬師鐢熴�戜富鍔ㄥ彂閫佸埌銆愬皬绋嬪簭銆�--------
@@ -171,7 +175,7 @@
public final static String UNI_EVENT_NOTIFICATION_DEVICE_home_debug_refresh = "home_debug_refresh";//鐢电珯浜屾璋冭瘯
public final static String UNI_EVENT_NOTIFICATION_DEVICE_home_delivery_refresh = "home_delivery_refresh";//鐢电珯浜や粯
public final static String UNI_EVENT_NOTIFICATION_DEVICE_home_delivery_rollback = "home_delivery_rollback";//鐢电珯浜や粯鍥炴粴
- public final static String UNI_EVENT_NOTIFICATION_DEVICE_open_ai_push_message = "open_ai_push_message";//鎵撳紑AiTab
+ public final static String UNI_EVENT_NOTIFICATION_DEVICE_open_ai_push_message = "open_ai_push_message";//鎵撳紑AiTab
//endregion
--
Gitblit v1.8.0