09-17-netty完善

This commit is contained in:
2025-09-17 18:32:52 +08:00
parent 4ffb639d33
commit b35ff07ba4

View File

@ -135,12 +135,12 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket
//拿到该用户所参与的房间列表
List<ChatGroup> chatGroups = chatGroupService.list(queryWrapper);
boolean isHaveSystemRoom = false;
//考勤
boolean isHaveAttendanceRoom = false;
//安全
boolean isHaveSafeRoom = false;
//质量
boolean isHaveQualityRoom = false;
// //考勤
// boolean isHaveAttendanceRoom = false;
// //安全
// boolean isHaveSafeRoom = false;
// //质量
// boolean isHaveQualityRoom = false;
if (chatGroups != null && !chatGroups.isEmpty()) {
HashMap<String, Object> roomCounts = new HashMap<>();
for (ChatGroup chatGroup : chatGroups) {
@ -269,7 +269,7 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket
channelUserMap.remove(ctx);
}
log.info(ctx.channel().remoteAddress() + " 下线了");
log.info("{} 下线了", ctx.channel().remoteAddress());
}
// 当通道就绪时调用
@ -485,11 +485,10 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket
chatHistory = new ChatHistory();
//发送方设置为99 表示系统消息
chatHistory.setSenderId(99L);
chatHistory.setGeterId(groupServiceOne.getId());
chatHistory.setMessage(jsonObject.toString());
chatHistory.setMessageDate(new Date());
chatHistory.setIsRead("1");//未读
jsonObject.put("roomId", groupServiceOne.getId());
}
//2:考勤消息
@ -510,11 +509,10 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket
chatHistory = new ChatHistory();
//发送方设置为100 表示系统消息中的考勤消息
chatHistory.setSenderId(100L);
chatHistory.setGeterId(groupServiceOne.getId());
chatHistory.setMessage(jsonObject.toString());
chatHistory.setMessageDate(new Date());
chatHistory.setIsRead("1");//未读
jsonObject.put("roomId", groupServiceOne.getId());
jsonObject.put("nickName","考勤消息");
}
//安全消息
@ -535,11 +533,10 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket
chatHistory = new ChatHistory();
//发送方设置为101 表示系统消息中的安全消息
chatHistory.setSenderId(101L);
chatHistory.setGeterId(groupServiceOne.getId());
chatHistory.setMessage(jsonObject.toString());
chatHistory.setMessageDate(new Date());
chatHistory.setIsRead("1");//未读
jsonObject.put("roomId", groupServiceOne.getId());
jsonObject.put("nickName","安全消息");
}
//质量消息
@ -556,17 +553,14 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket
}else {
groupServiceOne.setLastMessage(message);
groupServiceOne.setLastMessageTime(new Date());
// chatGroupService.updateById(groupServiceOne);
}
chatHistory = new ChatHistory();
//发送方设置为102 表示系统消息中的质量消息
chatHistory.setSenderId(102L);
chatHistory.setGeterId(groupServiceOne.getId());
chatHistory.setMessage(jsonObject.toString());
chatHistory.setMessageDate(new Date());
chatHistory.setIsRead("1");//未读
jsonObject.put("roomId", groupServiceOne.getId());
jsonObject.put("nickName","质量消息");
}
default -> {
@ -575,7 +569,9 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket
}
chatGroupService.saveOrUpdate(groupServiceOne);
jsonObject.put("roomId", groupServiceOne.getId());
chatHistory.setMessageType(jsonObject.get("messageType").toString());
chatHistory.setGeterId(groupServiceOne.getId());
chatHistoryService.save(chatHistory);
//发送消息后 将该房间未读消息数加1