Browse Source

问答返回问题的id 发方便前端使用

wangmiaomiao 10 months ago
parent
commit
714bd83917

+ 6 - 4
slibra-admin/src/main/java/com/slibra/web/controller/business/GRPCController.java

@@ -41,6 +41,7 @@ import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.util.*;
 
+import static com.slibra.common.constant.MyConstants.DEFAULT_ID_IDENTIFIER;
 import static com.slibra.common.constant.MyConstants.WARNING_DEFAULT_CREATE;
 
 /**
@@ -286,10 +287,6 @@ public class GRPCController extends BaseController {
             //把SessionId返回给前端  2024年5月24日11:15:23 也不返回前端
             /*outputStream.write(sessionId.getBytes());
             outputStream.flush();*/
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        } finally {
-//            System.out.println(sb.toString());
             //将问答更新到数据库中
             chatReq.setSessionId(sessionId);
             chatReq.setAnswer(sb.toString());
@@ -303,6 +300,11 @@ public class GRPCController extends BaseController {
             chatReq.setCreateBy(username);
             chatReq.setCreateTime(DateUtils.getNowDate());
             this.chatRecordMapper.insertTXinyiChatRecord(chatReq);
+            outputStream.write((DEFAULT_ID_IDENTIFIER + chatReq.getId()).getBytes());
+            outputStream.flush();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } finally {
             // 关闭输出流
             try {
                 outputStream.close();

+ 1 - 0
slibra-common/src/main/java/com/slibra/common/constant/MyConstants.java

@@ -24,6 +24,7 @@ public class MyConstants {
     public static final String WARNING_LEVEL_NO_DATE = "异常";
     public static final String WARNING_DEFAULT_QUESTION= "在线仪表数据异常";
     public static final String WARNING_DEFAULT_CREATE = "task-job";
+    public static final String DEFAULT_ID_IDENTIFIER = "@@id@@";
 
 
     public static final int maxCount = 30;