Merge remote-tracking branch 'origin/test-training2' into test
This commit is contained in:
commit
598e5e2491
13
sql/20230414-wei-conversation-group.sql
Normal file
13
sql/20230414-wei-conversation-group.sql
Normal file
@ -0,0 +1,13 @@
|
||||
CREATE TABLE `rts_conversation_group_info` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '群组名称',
|
||||
`map_id` bigint DEFAULT NULL COMMENT '所属地图ID',
|
||||
`project_code` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '所属项目',
|
||||
`leader_id` varchar(12) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '群主角色ID',
|
||||
`member_ids` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '群组用户角色ID',
|
||||
`create_time` datetime DEFAULT NULL,
|
||||
`update_time` datetime DEFAULT NULL,
|
||||
`creator_id` bigint DEFAULT NULL,
|
||||
`status` int DEFAULT NULL COMMENT '状态0=编辑,1=使用',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='群组信息设置';
|
@ -21,8 +21,8 @@ public class ConversationGroupController {
|
||||
private ConversationGroupServiceImpl conversationGroupService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public List<ConversationGroupVO> queryList(ConversationGroupQueryVO queryVO, @RequestAttribute AccountVO user) {
|
||||
return conversationGroupService.queryList(queryVO, user);
|
||||
public List<ConversationGroupVO> queryList(ConversationGroupQueryVO queryVO) {
|
||||
return conversationGroupService.queryList(queryVO);
|
||||
}
|
||||
|
||||
@GetMapping("/page/users")
|
||||
|
@ -2,8 +2,10 @@ package club.joylink.rtss.controller.simulation;
|
||||
|
||||
import club.joylink.rtss.controller.advice.AuthenticateInterceptor;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.CommunicationObject;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroupManagerService;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationManagerService;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationText;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupVO;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationVO;
|
||||
import club.joylink.rtss.vo.AccountVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -22,6 +24,9 @@ public class SimulationConversationController {
|
||||
@Autowired
|
||||
private ConversationManagerService conversationManagerService;
|
||||
|
||||
@Autowired
|
||||
private ConversationGroupManagerService conversationGroupManagerService;
|
||||
|
||||
/**
|
||||
*根据会话id获取仿真会话
|
||||
*/
|
||||
@ -100,4 +105,14 @@ public class SimulationConversationController {
|
||||
this.conversationManagerService.textChat(group, id, text, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本仿真的用户群组信息
|
||||
*
|
||||
* @param group 仿真ID
|
||||
* @return 用户群组
|
||||
*/
|
||||
@GetMapping("/group/list")
|
||||
public List<ConversationGroupVO> groupList(@PathVariable String group) {
|
||||
return conversationGroupManagerService.getAllConversationsGroup(group);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class RtsConversationGroupInfo {
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private Long creatorId;
|
||||
private String creatorId;
|
||||
|
||||
/**
|
||||
* 状态,1为有效
|
||||
@ -53,7 +53,7 @@ public class RtsConversationGroupInfo {
|
||||
/**
|
||||
* 群组ID
|
||||
*/
|
||||
private Long leaderId;
|
||||
private String leaderId;
|
||||
|
||||
/**
|
||||
* 成员ID
|
||||
|
@ -625,52 +625,52 @@ public class RtsConversationGroupInfoExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLeaderIdEqualTo(Long value) {
|
||||
public Criteria andLeaderIdEqualTo(String value) {
|
||||
addCriterion("leader_id =", value, "leaderId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLeaderIdNotEqualTo(Long value) {
|
||||
public Criteria andLeaderIdNotEqualTo(String value) {
|
||||
addCriterion("leader_id <>", value, "leaderId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLeaderIdGreaterThan(Long value) {
|
||||
public Criteria andLeaderIdGreaterThan(String value) {
|
||||
addCriterion("leader_id >", value, "leaderId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLeaderIdGreaterThanOrEqualTo(Long value) {
|
||||
public Criteria andLeaderIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("leader_id >=", value, "leaderId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLeaderIdLessThan(Long value) {
|
||||
public Criteria andLeaderIdLessThan(String value) {
|
||||
addCriterion("leader_id <", value, "leaderId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLeaderIdLessThanOrEqualTo(Long value) {
|
||||
public Criteria andLeaderIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("leader_id <=", value, "leaderId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLeaderIdIn(List<Long> values) {
|
||||
public Criteria andLeaderIdIn(List<String> values) {
|
||||
addCriterion("leader_id in", values, "leaderId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLeaderIdNotIn(List<Long> values) {
|
||||
public Criteria andLeaderIdNotIn(List<String> values) {
|
||||
addCriterion("leader_id not in", values, "leaderId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLeaderIdBetween(Long value1, Long value2) {
|
||||
public Criteria andLeaderIdBetween(String value1, String value2) {
|
||||
addCriterion("leader_id between", value1, value2, "leaderId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLeaderIdNotBetween(Long value1, Long value2) {
|
||||
public Criteria andLeaderIdNotBetween(String value1, String value2) {
|
||||
addCriterion("leader_id not between", value1, value2, "leaderId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public interface ConversationGroupService {
|
||||
* @param user 用户
|
||||
* @return 群组列表
|
||||
*/
|
||||
List<ConversationGroupVO> queryList(ConversationGroupQueryVO queryVO, AccountVO user);
|
||||
List<ConversationGroupVO> queryList(ConversationGroupQueryVO queryVO);
|
||||
|
||||
/**
|
||||
* 查询带参数的会话群组列表
|
||||
@ -59,4 +59,12 @@ public interface ConversationGroupService {
|
||||
* @param id 主键
|
||||
*/
|
||||
void delete(Long id);
|
||||
|
||||
/**
|
||||
* 通过地图获取会话群组信息
|
||||
*
|
||||
* @param mapId 地图信息
|
||||
* @return 群组列表
|
||||
*/
|
||||
List<ConversationGroupVO> getConversationGroupByMapId(Long mapId);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -33,9 +34,8 @@ public class ConversationGroupServiceImpl implements ConversationGroupService {
|
||||
@Autowired
|
||||
private RtsConversationGroupInfoMapper conversationGroupInfoMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<ConversationGroupVO> queryList(ConversationGroupQueryVO queryVO, AccountVO user) {
|
||||
public List<ConversationGroupVO> queryList(ConversationGroupQueryVO queryVO) {
|
||||
List<RtsConversationGroupInfo> conversationGroupInfoList = conversationGroupInfoMapper.selectByExampleWithBLOBs(getExample(queryVO));
|
||||
return conversationGroupInfoList.stream().map(ConversationGroupVO::new).collect(Collectors.toList());
|
||||
}
|
||||
@ -81,6 +81,14 @@ public class ConversationGroupServiceImpl implements ConversationGroupService {
|
||||
conversationGroupInfoMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConversationGroupVO> getConversationGroupByMapId(Long mapId) {
|
||||
ConversationGroupQueryVO queryVO = new ConversationGroupQueryVO();
|
||||
queryVO.setMapIds(Arrays.asList(mapId));
|
||||
return queryList(queryVO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取查询条件
|
||||
*
|
||||
|
@ -10,6 +10,7 @@ import club.joylink.rtss.simulation.cbtc.command.VoiceCommandBO;
|
||||
import club.joylink.rtss.simulation.cbtc.competition.CompetitionBO;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.Conversation;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationMember;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
|
||||
@ -148,6 +149,13 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
|
||||
*/
|
||||
private Map<String, Conversation> simulationConversationMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 用户组会话
|
||||
* key-用户组ID
|
||||
* val-仿真用户组信息
|
||||
*/
|
||||
private Map<Long, ConversationGroup> simulationConversationGroupMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 地图数据是否异常
|
||||
*/
|
||||
@ -308,6 +316,27 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
|
||||
return new ArrayList<>(this.simulationConversationMap.values());
|
||||
}
|
||||
|
||||
public void addConversationGroup(ConversationGroup group) {
|
||||
this.simulationConversationGroupMap.put(group.getId(), group);
|
||||
}
|
||||
|
||||
public void addConversationGroupMap(Map<Long, ConversationGroup> map) {
|
||||
this.simulationConversationGroupMap.putAll(map);
|
||||
}
|
||||
|
||||
public ConversationGroup getConversationGroup(Long id) {
|
||||
ConversationGroup group = this.simulationConversationGroupMap.get(id);
|
||||
if (Objects.isNull(group)) {
|
||||
throw new SimulationException(SimulationExceptionType.Simulation_Conversation_Not_Exist,
|
||||
String.format("id[%s]的群组不存在", id));
|
||||
}
|
||||
return group;
|
||||
}
|
||||
|
||||
public List<ConversationGroup> queryAllConversationGroup(){
|
||||
return new ArrayList<>(this.simulationConversationGroupMap.values());
|
||||
}
|
||||
|
||||
public RealDeviceConfig getRealDeviceById(Long id) {
|
||||
for (RealDeviceConfig realDevice : this.realDeviceList) {
|
||||
if (Objects.equals(realDevice.getProjectDevice().getId(), id)) {
|
||||
|
@ -3,9 +3,11 @@ package club.joylink.rtss.simulation.cbtc;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.services.ISysUserService;
|
||||
import club.joylink.rtss.services.RunPlanDraftService;
|
||||
import club.joylink.rtss.services.conversation.ConversationGroupService;
|
||||
import club.joylink.rtss.services.mapFunction.RtsMapFunctionService;
|
||||
import club.joylink.rtss.services.permission.PermissionSubjectService;
|
||||
import club.joylink.rtss.simulation.SimulationManager;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
|
||||
import club.joylink.rtss.simulation.cbtc.discriminate.IVoiceDiscriminateRule;
|
||||
import club.joylink.rtss.simulation.cbtc.discriminate.VoiceDiscriminateRule;
|
||||
import club.joylink.rtss.simulation.cbtc.event.SimulationCreateSuccessEvent;
|
||||
@ -23,6 +25,7 @@ import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
|
||||
import club.joylink.rtss.vo.client.mapFunction.MapFunctionVO;
|
||||
import club.joylink.rtss.vo.client.runplan.RunPlanVO;
|
||||
import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam;
|
||||
import club.joylink.rtss.vo.conversation.ConversationGroupVO;
|
||||
import club.joylink.rtss.vo.permission.PermissionSubjectTypeEnum;
|
||||
import club.joylink.rtss.vo.permission.PermissionSystemAbilityVO;
|
||||
import club.joylink.rtss.vo.permission.subject.PermissionSubjectVO;
|
||||
@ -71,6 +74,10 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
|
||||
@Autowired
|
||||
private IVoiceDiscriminateRule discriminateRule;
|
||||
|
||||
@Autowired
|
||||
private ConversationGroupService conversationGroupService;
|
||||
|
||||
@Override
|
||||
public String createSimulation(long mapId, Long mapFunctionId, SimulationWorkParamVO workParamVO, @NonNull LoginUserInfoVO loginUserInfoVO,Map<String,Boolean> createUserType) {
|
||||
return createSimulationPojo(mapId, mapFunctionId, workParamVO, loginUserInfoVO, createUserType).getId();
|
||||
@ -305,6 +312,9 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
List<VoiceDiscriminateRule> ruleList = this.discriminateRule.findRuleByMapId(mapId);
|
||||
simulation.setVoiceRuleList(ruleList);
|
||||
|
||||
// 群组配置信息
|
||||
initConversationGroup(simulation);
|
||||
|
||||
simulation.setMapFunctionId(mapFunctionId);
|
||||
simulation.setCreateUserType(createUserType);
|
||||
LoginUserInfoVO loginUserInfo = simulation.getBuildParams().getLoginUserInfo();
|
||||
@ -365,4 +375,21 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
this.simulationLifeCycleService.reloadRunPlan(simulation, runPlanVO, null);
|
||||
simulation.getRepository().clearChangeTrips(); //清除掉之前的车次计划变化信息
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化地图的群组信息
|
||||
*
|
||||
* @param simulation 仿真对象
|
||||
*/
|
||||
private void initConversationGroup(Simulation simulation) {
|
||||
List<ConversationGroupVO> conversationGroupVOList =
|
||||
conversationGroupService.getConversationGroupByMapId(simulation.getBuildParams().getMap().getId());
|
||||
if (CollectionUtils.isEmpty(conversationGroupVOList)) {
|
||||
return;
|
||||
}
|
||||
Map<Long, ConversationGroup> groupMap = conversationGroupVOList.stream().map(g -> new ConversationGroup(simulation, g))
|
||||
.collect(Collectors.toMap(ConversationGroup::getId, group -> group));
|
||||
simulation.addConversationGroupMap(groupMap);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,70 @@
|
||||
package club.joylink.rtss.simulation.cbtc.conversation;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import lombok.Data;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 谈话
|
||||
*/
|
||||
@Data
|
||||
public abstract class Chat {
|
||||
|
||||
private SimulationMember creator;
|
||||
|
||||
private LocalDateTime time;
|
||||
|
||||
private List<ConversationMember> memberList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 获取会话中所有仿真成员
|
||||
*/
|
||||
public List<SimulationMember> getSimulationMemberList() {
|
||||
return this.memberList.stream().map(ConversationMember::getMember).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会话中的所有仿真成员的id
|
||||
*/
|
||||
public List<String> getSimulationMemberIds() {
|
||||
return this.memberList.stream().map(conversationMember -> conversationMember.getMember().getId()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public boolean isConversationMember(SimulationMember member) {
|
||||
for (ConversationMember conversationMember : this.memberList) {
|
||||
if (Objects.equals(conversationMember.getMember(), member)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isCreator(SimulationMember member) {
|
||||
return Objects.equals(member, this.creator);
|
||||
}
|
||||
|
||||
public boolean contains(SimulationMember member) {
|
||||
for (ConversationMember conversationMember : this.memberList) {
|
||||
if (Objects.equals(member, conversationMember.getMember())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 该成员退出会话
|
||||
*/
|
||||
public void exit(SimulationMember member) {
|
||||
if (CollectionUtils.isEmpty(this.memberList)) {
|
||||
return;
|
||||
}
|
||||
this.memberList.removeIf(conversationMember -> Objects.equals(conversationMember.getMember().getId(), member.getId()));
|
||||
}
|
||||
}
|
@ -13,16 +13,10 @@ import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
public class Conversation {
|
||||
public class Conversation extends Chat {
|
||||
|
||||
private String id;
|
||||
|
||||
private SimulationMember creator;
|
||||
|
||||
private LocalDateTime time;
|
||||
|
||||
private List<ConversationMember> memberList = new ArrayList<>();
|
||||
|
||||
private List<ConversationMessage> messageList = new ArrayList<>();
|
||||
|
||||
private CommunicationObject object;
|
||||
@ -31,53 +25,29 @@ public class Conversation {
|
||||
|
||||
public Conversation(String id, SimulationMember creator, LocalDateTime systemTime, List<SimulationMember> memberList, CommunicationObject object) {
|
||||
this.id = id;
|
||||
this.creator = creator;
|
||||
this.time = systemTime;
|
||||
setCreator(creator);
|
||||
setTime(systemTime);
|
||||
if (creator != null) {
|
||||
ConversationMember member1 = new ConversationMember(creator);
|
||||
member1.connect();
|
||||
this.memberList.add(member1);
|
||||
getMemberList().add(member1);
|
||||
}
|
||||
if (memberList != null) {
|
||||
for (SimulationMember member : memberList) {
|
||||
this.memberList.add(new ConversationMember(member));
|
||||
getMemberList().add(new ConversationMember(member));
|
||||
}
|
||||
}
|
||||
|
||||
this.over = false;
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会话中所有仿真成员
|
||||
*/
|
||||
public List<SimulationMember> getSimulationMemberList() {
|
||||
return this.memberList.stream().map(ConversationMember::getMember).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会话中的所有仿真成员的id
|
||||
*/
|
||||
public List<String> getSimulationMemberIds() {
|
||||
return this.memberList.stream().map(conversationMember -> conversationMember.getMember().getId()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public boolean isConversationMember(SimulationMember member) {
|
||||
for (ConversationMember conversationMember : this.memberList) {
|
||||
if (Objects.equals(conversationMember.getMember(), member)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void memberConnect(SimulationMember member) {
|
||||
ConversationMember conversationMember = this.getConversationMember(member);
|
||||
conversationMember.connect();
|
||||
}
|
||||
|
||||
public boolean hasMemberConnect() {
|
||||
for (ConversationMember conversationMember : this.memberList) {
|
||||
for (ConversationMember conversationMember : getMemberList()) {
|
||||
if (conversationMember.isConnect()) {
|
||||
return true;
|
||||
}
|
||||
@ -86,8 +56,8 @@ public class Conversation {
|
||||
}
|
||||
|
||||
public boolean hasOtherMemberConnect() {
|
||||
for (ConversationMember conversationMember : this.memberList) {
|
||||
if (!Objects.equals(conversationMember.getMember(), creator) && conversationMember.isConnect()) {
|
||||
for (ConversationMember conversationMember : getMemberList()) {
|
||||
if (!Objects.equals(conversationMember.getMember(), getCreator()) && conversationMember.isConnect()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -95,7 +65,7 @@ public class Conversation {
|
||||
}
|
||||
|
||||
private ConversationMember getConversationMember(SimulationMember member) {
|
||||
for (ConversationMember conversationMember : this.memberList) {
|
||||
for (ConversationMember conversationMember : getMemberList()) {
|
||||
if (Objects.equals(conversationMember.getMember(), member)) {
|
||||
return conversationMember;
|
||||
}
|
||||
@ -103,42 +73,19 @@ public class Conversation {
|
||||
throw new SimulationException(SimulationExceptionType.System_Fault);
|
||||
}
|
||||
|
||||
public boolean isCreator(SimulationMember member) {
|
||||
return Objects.equals(member, this.creator);
|
||||
public void addMessage(ConversationMessage conversationMessage) {
|
||||
this.messageList.add(conversationMessage);
|
||||
}
|
||||
|
||||
public void over() {
|
||||
this.over = true;
|
||||
}
|
||||
|
||||
public void addMessage(ConversationMessage conversationMessage) {
|
||||
this.messageList.add(conversationMessage);
|
||||
}
|
||||
|
||||
public boolean contains(SimulationMember member) {
|
||||
for (ConversationMember conversationMember : this.memberList) {
|
||||
if (Objects.equals(member, conversationMember.getMember())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 该成员退出会话
|
||||
*/
|
||||
public void exit(SimulationMember member) {
|
||||
if (CollectionUtils.isEmpty(memberList)) {
|
||||
return;
|
||||
}
|
||||
this.memberList.removeIf(conversationMember -> Objects.equals(conversationMember.getMember().getId(), member.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 会话中是否已经没有成员了
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return CollectionUtils.isEmpty(memberList);
|
||||
return CollectionUtils.isEmpty(getMemberList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,107 @@
|
||||
package club.joylink.rtss.simulation.cbtc.conversation;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupMessageVO;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import club.joylink.rtss.vo.conversation.ConversationGroupVO;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 群组对象
|
||||
*/
|
||||
@Getter
|
||||
public class ConversationGroup extends Chat {
|
||||
|
||||
/**
|
||||
* 聊天室ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 聊天室名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
private List<ConversationGroupMessage> messageList = new ArrayList<>();
|
||||
|
||||
private AtomicInteger messageId = new AtomicInteger(0);
|
||||
|
||||
/**
|
||||
* 用户组信息
|
||||
*
|
||||
* @param simulation 仿真信息
|
||||
* @param info 群组配置信息
|
||||
*/
|
||||
public ConversationGroup(Simulation simulation, ConversationGroupVO info) {
|
||||
this.id = info.getId();
|
||||
this.name = info.getName();
|
||||
SimulationMember leader = null;
|
||||
if (info.getLeaderId() != null) {
|
||||
leader = simulation.getSimulationMemberById(info.getLeaderId());
|
||||
setCreator(leader);
|
||||
}
|
||||
List<ConversationMember> memberList = null;
|
||||
if (CollectionUtils.isEmpty(info.getMemberIds())) {
|
||||
memberList = info.getMemberIds().stream().map(simulation::getSimulationMemberById).map(ConversationMember::new).collect(Collectors.toList());
|
||||
setMemberList(memberList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成消息ID
|
||||
*
|
||||
* @return 消息ID
|
||||
*/
|
||||
public String generateMessageId() {
|
||||
return String.format("%s_%s", id, messageId.incrementAndGet());
|
||||
}
|
||||
|
||||
public void addMessage(ConversationGroupMessage message) {
|
||||
this.messageList.add(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取该角色未读信息列表
|
||||
*
|
||||
* @param member 角色信息
|
||||
* @return 消息列表
|
||||
*/
|
||||
public List<ConversationGroupMessage> getUnreadMessages(SimulationMember member) {
|
||||
// 没有消息,不是本群人员
|
||||
if (CollectionUtils.isEmpty(getMessageList()) && !isCreator(member) && !isConversationMember(member)) {
|
||||
return List.of();
|
||||
}
|
||||
return messageList.stream().filter(message -> {
|
||||
if (message.isAllRead()) { // 全部已读
|
||||
return false;
|
||||
}
|
||||
return !message.getReaderSet().contains(member.getId()); // 在已读名单中
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户读消息
|
||||
*
|
||||
* @param member 角色信息
|
||||
*/
|
||||
public void readMessage(SimulationMember member){
|
||||
// 没有消息,不是本群人员
|
||||
List<ConversationGroupMessage> messageList = getUnreadMessages(member);
|
||||
if (CollectionUtils.isEmpty(messageList)) {
|
||||
return;
|
||||
}
|
||||
messageList.forEach(message -> {
|
||||
message.read(member);
|
||||
if (message.getReaderSet().size() >= getMemberList().size()) { // 全部用户已读
|
||||
message.finishRead();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package club.joylink.rtss.simulation.cbtc.conversation;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.GroupSimulationCache;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ConversationGroupManagerService {
|
||||
|
||||
@Autowired
|
||||
private GroupSimulationCache groupSimulationCache;
|
||||
|
||||
/**
|
||||
* 获取所有群组信息
|
||||
* @param group
|
||||
* @return
|
||||
*/
|
||||
public List<ConversationGroupVO> getAllConversationsGroup(String group) {
|
||||
Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
|
||||
List<ConversationGroup> allGroup = simulation.queryAllConversationGroup();
|
||||
return ConversationGroupVO.convert2VOList(allGroup);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package club.joylink.rtss.simulation.cbtc.conversation;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import lombok.Getter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 用户组消息实体
|
||||
*/
|
||||
@Getter
|
||||
public class ConversationGroupMessage extends ConversationMessage {
|
||||
/**
|
||||
* 已读角色的ID列表
|
||||
*/
|
||||
private final Set<String> readerSet = new HashSet<>();
|
||||
|
||||
/**
|
||||
* 是否全部已读
|
||||
*/
|
||||
private boolean allRead;
|
||||
|
||||
public ConversationGroupMessage(String id, SimulationMember member, LocalDateTime systemTime, String content, String filePath) {
|
||||
super(id, member, systemTime, content, filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户读群消息
|
||||
*/
|
||||
public void read(SimulationMember member) {
|
||||
readerSet.add(member.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 所有人都已读完
|
||||
*/
|
||||
public void finishRead() {
|
||||
this.allRead = true;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package club.joylink.rtss.simulation.cbtc.conversation;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* 群组会话操作
|
||||
*/
|
||||
@OperateHandler
|
||||
@Slf4j
|
||||
public class ConversationGroupOperateHandler {
|
||||
@Autowired
|
||||
private ConversationGroupManagerService conversationGroupManagerService;
|
||||
|
||||
|
||||
}
|
@ -4,6 +4,7 @@ import club.joylink.rtss.services.voice.VoiceService;
|
||||
import club.joylink.rtss.simulation.cbtc.GroupSimulationCache;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.competition.ScriptExecuteService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupVO;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationMessageVO;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationVO;
|
||||
import club.joylink.rtss.simulation.cbtc.event.*;
|
||||
@ -447,4 +448,5 @@ public class ConversationManagerService {
|
||||
simulation.addConversation(conversation);
|
||||
return conversation;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.vo;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroupMessage;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationMessage;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ConversationGroupMessageVO extends ConversationMessageVO {
|
||||
/**
|
||||
* 已读角色的ID列表
|
||||
*/
|
||||
private Set<String> readerSet;
|
||||
|
||||
/**
|
||||
* 是否全部已读
|
||||
*/
|
||||
private boolean allRead;
|
||||
|
||||
public ConversationGroupMessageVO(ConversationGroupMessage message) {
|
||||
super(message);
|
||||
this.readerSet = message.getReaderSet();
|
||||
this.allRead = message.isAllRead();
|
||||
}
|
||||
|
||||
public static List<ConversationGroupMessageVO> convert2VO(List<ConversationGroupMessage> list) {
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return List.of();
|
||||
}
|
||||
return list.stream().map(ConversationGroupMessageVO::new).collect(Collectors.toList());
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.vo;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ConversationGroupVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String creatorId;
|
||||
|
||||
private List<ConversationMemberVO> memberList;
|
||||
|
||||
private List<ConversationGroupMessageVO> messageList;
|
||||
|
||||
public ConversationGroupVO(ConversationGroup conversation) {
|
||||
this.id = conversation.getId();
|
||||
if (conversation.getCreator() != null) {
|
||||
this.creatorId = conversation.getCreator().getId();
|
||||
}
|
||||
this.memberList = ConversationMemberVO.convert2VOList(conversation.getMemberList());
|
||||
this.messageList = ConversationGroupMessageVO.convert2VO(conversation.getMessageList());
|
||||
}
|
||||
|
||||
public static List<ConversationGroupVO> convert2VOList(List<ConversationGroup> list) {
|
||||
List<ConversationGroupVO> voList = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
for (ConversationGroup conversation : list) {
|
||||
voList.add(new ConversationGroupVO(conversation));
|
||||
}
|
||||
}
|
||||
return voList;
|
||||
}
|
||||
}
|
@ -39,12 +39,12 @@ public class ConversationGroupVO {
|
||||
/**
|
||||
* 群主角色ID
|
||||
*/
|
||||
private Long leaderId;
|
||||
private String leaderId;
|
||||
|
||||
/**
|
||||
* 群成员ID
|
||||
*/
|
||||
private List<Long> memberIds;
|
||||
private List<String> memberIds;
|
||||
|
||||
public ConversationGroupVO(RtsConversationGroupInfo info) {
|
||||
this.id = info.getId();
|
||||
@ -53,7 +53,7 @@ public class ConversationGroupVO {
|
||||
this.leaderId = info.getLeaderId();
|
||||
this.projectCode = info.getProjectCode();
|
||||
if (StringUtils.hasText(info.getMemberIds())) {
|
||||
this.memberIds = Arrays.stream(info.getMemberIds().split(",")).map(Long::valueOf).collect(Collectors.toList());
|
||||
this.memberIds = Arrays.stream(info.getMemberIds().split(",")).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ public class ConversationGroupVO {
|
||||
info.setProjectCode(this.projectCode);
|
||||
info.setLeaderId(this.leaderId);
|
||||
if (this.memberIds != null) {
|
||||
info.setMemberIds(this.memberIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||
info.setMemberIds(String.join(",", this.memberIds));
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="map_ids" jdbcType="BIGINT" property="mapId" />
|
||||
<result column="project_code" jdbcType="VARCHAR" property="projectCode" />
|
||||
<result column="leader_id" jdbcType="BIGINT" property="leaderId" />
|
||||
<result column="leader_id" jdbcType="VARCHAR" property="leaderId" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
<result column="creator_id" jdbcType="BIGINT" property="creatorId" />
|
||||
@ -135,7 +135,7 @@
|
||||
#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{mapId,jdbcType=BIGINT},
|
||||
#{projectCode,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
|
||||
#{creatorId,jdbcType=BIGINT}, #{status,jdbcType=INTEGER}, #{memberIds,jdbcType=LONGVARCHAR},
|
||||
#{leaderId,jdbcType=BIGINT}
|
||||
#{leaderId,jdbcType=VARCHAR}
|
||||
)
|
||||
</insert>
|
||||
|
||||
@ -202,7 +202,7 @@
|
||||
#{memberIds,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="leaderId != null">
|
||||
#{leaderId,jdbcType=BIGINT},
|
||||
#{leaderId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
@ -238,7 +238,7 @@
|
||||
member_ids = #{record.memberIds,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="record.leaderId != null">
|
||||
leader_id = #{record.leaderId,jdbcType=BIGINT},
|
||||
leader_id = #{record.leaderId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
@ -257,7 +257,7 @@
|
||||
creator_id = #{record.creatorId,jdbcType=BIGINT},
|
||||
status = #{record.status,jdbcType=INTEGER},
|
||||
member_ids = #{record.memberIds,jdbcType=LONGVARCHAR},
|
||||
leader_id = #{record.leaderId,jdbcType=BIGINT}
|
||||
leader_id = #{record.leaderId,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
@ -273,7 +273,7 @@
|
||||
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
|
||||
creator_id = #{record.creatorId,jdbcType=BIGINT},
|
||||
status = #{record.status,jdbcType=INTEGER},
|
||||
leader_id = #{record.leaderId,jdbcType=BIGINT}
|
||||
leader_id = #{record.leaderId,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
@ -307,7 +307,7 @@
|
||||
member_ids = #{memberIds,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="leaderId != null">
|
||||
leader_id = #{leaderId,jdbcType=BIGINT},
|
||||
leader_id = #{leaderId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
@ -319,7 +319,7 @@
|
||||
project_code = #{projectCode,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
update_time = #{updateTime,jdbcType=TIMESTAMP}, creator_id = #{creatorId,jdbcType=BIGINT},
|
||||
status = #{status,jdbcType=INTEGER}, member_ids = #{memberIds,jdbcType=LONGVARCHAR},
|
||||
leader_id = #{leaderId,jdbcType=BIGINT}
|
||||
leader_id = #{leaderId,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
|
||||
@ -327,7 +327,7 @@
|
||||
update rts_conversation_group_info
|
||||
set name = #{name,jdbcType=VARCHAR}, map_id = #{mapId,jdbcType=BIGINT}, project_code = #{projectCode,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP},
|
||||
creator_id = #{creatorId,jdbcType=BIGINT}, status = #{status,jdbcType=INTEGER},leader_id = #{leaderId,jdbcType=BIGINT}
|
||||
creator_id = #{creatorId,jdbcType=BIGINT}, status = #{status,jdbcType=INTEGER},leader_id = #{leaderId,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user