添加消息最大记忆数
This commit is contained in:
parent
87b7512d44
commit
594d1b377c
@ -0,0 +1,25 @@
|
|||||||
|
spring:
|
||||||
|
data:
|
||||||
|
redis:
|
||||||
|
host: krcia.top
|
||||||
|
port: 6379
|
||||||
|
password: xiong990416.
|
||||||
|
database: 3
|
||||||
|
datasource:
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
url: jdbc:mysql://krcia.top:3306/elysia-db?serverTimezone=Asia/Shanghai
|
||||||
|
username: root
|
||||||
|
password: xiong990416.
|
||||||
|
elysia-authorization:
|
||||||
|
version: v0.3-0909
|
||||||
|
enable-cors: true
|
||||||
|
enable-api-doc: true
|
||||||
|
mail:
|
||||||
|
host: smtp.qq.com
|
||||||
|
port: 465
|
||||||
|
username: krcia@qq.com
|
||||||
|
auth-code: ghylxjvfnnjqdfhe
|
||||||
|
enable-ssl: true
|
||||||
|
metadata-save:
|
||||||
|
path: /app/metadata
|
||||||
|
agent-url: http://192.168.1.2:4562/oss
|
||||||
File diff suppressed because one or more lines are too long
@ -25,15 +25,16 @@ import top.krcia.elysiaserver.utils.JWTGenerator;
|
|||||||
import top.krcia.elysiaserver.utils.P;
|
import top.krcia.elysiaserver.utils.P;
|
||||||
import top.krcia.elysiaserver.utils.U;
|
import top.krcia.elysiaserver.utils.U;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ChatServiceImpl implements ChatService {
|
public class ChatServiceImpl implements ChatService {
|
||||||
|
|
||||||
@Value("${elysia-authorization.metadata-save.agent-url}")
|
@Value("${elysia-authorization.metadata-save.agent-url}")
|
||||||
private String agentUrl;
|
private String agentUrl;
|
||||||
|
|
||||||
|
@Value("${elysia-chat.max-memory}")
|
||||||
|
private int maxMemory;
|
||||||
@Resource
|
@Resource
|
||||||
private ChatRoomDao chatRoomDao;
|
private ChatRoomDao chatRoomDao;
|
||||||
@Resource
|
@Resource
|
||||||
@ -75,7 +76,7 @@ public class ChatServiceImpl implements ChatService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public R sendMessage(String authorization, String roomId, String message,String messageId) {
|
public R sendMessage(String authorization, String roomId, String message, String messageId) {
|
||||||
Long userId = JWTGenerator.getUserId(authorization);
|
Long userId = JWTGenerator.getUserId(authorization);
|
||||||
ChatRoom chatRoom = new ChatRoom(roomId);
|
ChatRoom chatRoom = new ChatRoom(roomId);
|
||||||
chatRoom = chatRoomDao.selectById(chatRoom);
|
chatRoom = chatRoomDao.selectById(chatRoom);
|
||||||
@ -87,14 +88,17 @@ public class ChatServiceImpl implements ChatService {
|
|||||||
chatRoomRecordDao.addMessage(messageId, chatRoom.getRoomId(), 1, message, new Date());
|
chatRoomRecordDao.addMessage(messageId, chatRoom.getRoomId(), 1, message, new Date());
|
||||||
IPage<ChatRoomRecord> iPage = new Page();
|
IPage<ChatRoomRecord> iPage = new Page();
|
||||||
iPage.setCurrent(1);
|
iPage.setCurrent(1);
|
||||||
iPage.setSize(100);
|
iPage.setSize(maxMemory);
|
||||||
QueryWrapper<ChatRoomRecord> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ChatRoomRecord> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.orderByAsc("chat_date");
|
queryWrapper.orderByDesc("chat_date");
|
||||||
iPage = chatRoomRecordDao.selectPage(iPage, queryWrapper, roomId);
|
iPage = chatRoomRecordDao.selectPage(iPage, queryWrapper, roomId);
|
||||||
SysUser sysUser = new SysUser(userId);
|
SysUser sysUser = new SysUser(userId);
|
||||||
sysUser = sysUserDao.selectById(sysUser);
|
sysUser = sysUserDao.selectById(sysUser);
|
||||||
RobotTemplate robotTemplate = robotTemplateDao.selectById(new RobotTemplate(robot.getTemplateId()));
|
RobotTemplate robotTemplate = robotTemplateDao.selectById(new RobotTemplate(robot.getTemplateId()));
|
||||||
ReplyQueue replyQueue = new ReplyQueue(sysUser.getUserId(), roomId, iPage.getRecords(), sysUser.getDeepseekKey(), chatRoom.getEngine(), chatRoom.getRoomName(), agentUrl + chatRoom.getRoomImage(), robot.getSystemPrompt(), robotTemplate.getContent(), robotTemplate.getTemperature());
|
List<ChatRoomRecord> messageH = new ArrayList<>();
|
||||||
|
messageH.addAll(iPage.getRecords());
|
||||||
|
Collections.reverse(messageH);
|
||||||
|
ReplyQueue replyQueue = new ReplyQueue(sysUser.getUserId(), roomId, messageH, sysUser.getDeepseekKey(), chatRoom.getEngine(), chatRoom.getRoomName(), agentUrl + chatRoom.getRoomImage(), robot.getSystemPrompt(), robotTemplate.getContent(), robotTemplate.getTemperature());
|
||||||
robotReplyTask.addTask(replyQueue);
|
robotReplyTask.addTask(replyQueue);
|
||||||
chatRoom.setLastChatTime(new Date());
|
chatRoom.setLastChatTime(new Date());
|
||||||
chatRoomDao.updateById(chatRoom);
|
chatRoomDao.updateById(chatRoom);
|
||||||
@ -128,15 +132,15 @@ public class ChatServiceImpl implements ChatService {
|
|||||||
public R chatRoomRecord(String authorization, List<HistoryListParam> historyList) {
|
public R chatRoomRecord(String authorization, List<HistoryListParam> historyList) {
|
||||||
Long userId = JWTGenerator.getUserId(authorization);
|
Long userId = JWTGenerator.getUserId(authorization);
|
||||||
HistoryVo historyVo = new HistoryVo();
|
HistoryVo historyVo = new HistoryVo();
|
||||||
for (HistoryListParam hlp : historyList){
|
for (HistoryListParam hlp : historyList) {
|
||||||
ChatRoom chatRoom = new ChatRoom(hlp.getRoomId());
|
ChatRoom chatRoom = new ChatRoom(hlp.getRoomId());
|
||||||
chatRoom = chatRoomDao.selectById(chatRoom);
|
chatRoom = chatRoomDao.selectById(chatRoom);
|
||||||
if (chatRoom.getSysUserId().longValue() != userId.longValue()) {
|
if (chatRoom.getSysUserId().longValue() != userId.longValue()) {
|
||||||
return R.print(RS.NOT_FIND_JURISDICTION_DO);
|
return R.print(RS.NOT_FIND_JURISDICTION_DO);
|
||||||
}
|
}
|
||||||
List<ChatRoomRecord> data = chatRoomRecordDao.selectCache(hlp.getRoomId(), hlp.getMessageId());
|
List<ChatRoomRecord> data = chatRoomRecordDao.selectCache(hlp.getRoomId(), hlp.getMessageId());
|
||||||
historyVo.add(hlp.getRoomId(),data);
|
historyVo.add(hlp.getRoomId(), data);
|
||||||
}
|
}
|
||||||
return R.success(historyVo);
|
return R.success(historyVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@ public class ChatSocketHandler extends TextWebSocketHandler {
|
|||||||
sessions.put(userId, session);
|
sessions.put(userId, session);
|
||||||
// 上线发送最近一条消息
|
// 上线发送最近一条消息
|
||||||
if (offlineMessage.containsKey(userId)) {
|
if (offlineMessage.containsKey(userId)) {
|
||||||
sendDelayedMessage(session, offlineMessage.get(userId), 15);
|
// sendDelayedMessage(session, offlineMessage.get(userId), 15);
|
||||||
try {
|
try {
|
||||||
offlineMessage.remove(userId);
|
offlineMessage.remove(userId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@ -20,4 +20,6 @@ elysia-authorization:
|
|||||||
enable-api-doc: true
|
enable-api-doc: true
|
||||||
metadata-save:
|
metadata-save:
|
||||||
path: ./metadata/
|
path: ./metadata/
|
||||||
agent-url: http://192.168.1.2:4563/oss
|
agent-url: http://192.168.1.2:4563/oss
|
||||||
|
elysia-chat:
|
||||||
|
max-memory: 300
|
||||||
@ -1,37 +1,25 @@
|
|||||||
spring:
|
spring:
|
||||||
data:
|
data:
|
||||||
redis:
|
redis:
|
||||||
host: 192.168.8.88
|
host: krcia.top
|
||||||
port: 6379
|
port: 6379
|
||||||
password: xiong990416.
|
password: xiong990416.
|
||||||
database: 3
|
database: 3
|
||||||
datasource:
|
datasource:
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://192.168.8.88:3306/elysia-db?serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://krcia.top:3306/elysia-db?serverTimezone=Asia/Shanghai
|
||||||
username: root
|
username: root
|
||||||
password: xiong990416.
|
password: xiong990416.
|
||||||
|
servlet:
|
||||||
|
multipart:
|
||||||
|
max-file-size: 10MB # 单个文件最大 10MB
|
||||||
|
max-request-size: 20MB # 整个请求最大 20MB
|
||||||
elysia-authorization:
|
elysia-authorization:
|
||||||
version: v0.1-0909-dev
|
version: v0.1-0909-dev
|
||||||
enable-cors: true
|
enable-cors: true
|
||||||
enable-api-doc: true
|
enable-api-doc: true
|
||||||
mail:
|
|
||||||
host: smtp.qq.com
|
|
||||||
port: 465
|
|
||||||
username: krcia@qq.com
|
|
||||||
auth-code: ghylxjvfnnjqdfhe
|
|
||||||
enable-ssl: true
|
|
||||||
metadata-save:
|
metadata-save:
|
||||||
path: ./metadata/
|
path: /app/metadata
|
||||||
agent-url: http://krcia.top:4560/oss
|
agent-url: http://127.0.0.1:9091/oss
|
||||||
|
elysia-chat:
|
||||||
#打印数据日志
|
max-memory: 300
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
#MyBatis SQL 日志
|
|
||||||
top.krcia.elysiaserver.chat.dao: debug # 你的Mapper接口所在包
|
|
||||||
#MyBatis-Plus SQL 日志
|
|
||||||
com.baomidou.mybatisplus.core.override.MybatisMapperProxy: debug
|
|
||||||
org.apache.ibatis: debug
|
|
||||||
java.sql: debug
|
|
||||||
java.sql.Statement: debug
|
|
||||||
java.sql.PreparedStatement: debug
|
|
||||||
File diff suppressed because one or more lines are too long
@ -3,8 +3,8 @@ services:
|
|||||||
container_name: elysia-authorization
|
container_name: elysia-authorization
|
||||||
image: jdk-17:prod
|
image: jdk-17:prod
|
||||||
volumes:
|
volumes:
|
||||||
- ./authorization/:/app/
|
- /DATA/elysia/authorization/:/app/
|
||||||
- ./metadata:/app/metadata
|
- /DATA/elysia/metadata:/app/metadata
|
||||||
command:
|
command:
|
||||||
- java
|
- java
|
||||||
- -Dfile.encoding=UTF-8
|
- -Dfile.encoding=UTF-8
|
||||||
@ -15,8 +15,8 @@ services:
|
|||||||
container_name: elysia-chat
|
container_name: elysia-chat
|
||||||
image: jdk-17:prod
|
image: jdk-17:prod
|
||||||
volumes:
|
volumes:
|
||||||
- ./chat/:/app/
|
- /DATA/elysia/chat/:/app/
|
||||||
- ./metadata:/app/metadata
|
- /DATA/elysia/metadata:/app/metadata
|
||||||
command:
|
command:
|
||||||
- java
|
- java
|
||||||
- -Dfile.encoding=UTF-8
|
- -Dfile.encoding=UTF-8
|
||||||
@ -27,8 +27,8 @@ services:
|
|||||||
container_name: elysia-server
|
container_name: elysia-server
|
||||||
image: jdk-17:prod
|
image: jdk-17:prod
|
||||||
volumes:
|
volumes:
|
||||||
- ./server/:/app/
|
- /DATA/elysia/server/:/app/
|
||||||
- ./metadata:/app/metadata
|
- /DATA/elysia/metadata:/app/metadata
|
||||||
command:
|
command:
|
||||||
- java
|
- java
|
||||||
- -Dfile.encoding=UTF-8
|
- -Dfile.encoding=UTF-8
|
||||||
@ -40,7 +40,7 @@ services:
|
|||||||
container_name: elysia-nginx
|
container_name: elysia-nginx
|
||||||
image: nginx:latest
|
image: nginx:latest
|
||||||
volumes:
|
volumes:
|
||||||
- ./nginx/conf/conf.d:/etc/nginx/conf.d
|
- /DATA/elysia/nginx/conf/conf.d:/etc/nginx/conf.d
|
||||||
- ./nginx/html:/etc/nginx/html
|
- /DATA/elysia/nginx/html:/etc/nginx/html
|
||||||
- ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf
|
- /DATA/elysia/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
|
||||||
- ./metadata:/etc/nginx/metadata
|
- /DATA/elysia/metadata:/etc/nginx/metadata
|
||||||
|
|||||||
@ -0,0 +1,15 @@
|
|||||||
|
spring:
|
||||||
|
data:
|
||||||
|
redis:
|
||||||
|
host: krcia.top
|
||||||
|
port: 6379
|
||||||
|
password: xiong990416.
|
||||||
|
database: 3
|
||||||
|
datasource:
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
url: jdbc:mysql://krcia.top:3306/elysia-db?serverTimezone=Asia/Shanghai
|
||||||
|
username: root
|
||||||
|
password: xiong990416.
|
||||||
|
app:
|
||||||
|
agent-url: http://192.168.1.2:4561/oss
|
||||||
|
release: /app/metadata
|
||||||
@ -6,6 +6,6 @@ spring:
|
|||||||
profiles:
|
profiles:
|
||||||
active: development
|
active: development
|
||||||
elysia-server:
|
elysia-server:
|
||||||
version: v0.1-0909-dev
|
version: v0.3-251201
|
||||||
enable-cors: true
|
enable-cors: true
|
||||||
enable-api-doc: true
|
enable-api-doc: true
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user