【剧本保存会话群组草稿信息】
This commit is contained in:
parent
f861256107
commit
221200cfcd
@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.conversation;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
@ -15,7 +16,8 @@ public class ConversationGroupMessage extends ConversationMessage {
|
||||
/**
|
||||
* 已读角色的ID列表
|
||||
*/
|
||||
private final Set<String> readerSet = new HashSet<>();
|
||||
@Setter
|
||||
private Set<String> readerSet = new HashSet<>();
|
||||
|
||||
/**
|
||||
* 是否全部已读
|
||||
|
@ -2,8 +2,10 @@ package club.joylink.rtss.simulation.cbtc.data.storage;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.Conversation;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
|
||||
import club.joylink.rtss.simulation.cbtc.data.storage.ctc.StorageSimulationCtcDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.storage.vo.StorageConversation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.storage.vo.StorageConversationGroup;
|
||||
import club.joylink.rtss.util.jsonSerialize.Boolean2NumDeserializer;
|
||||
import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
@ -68,6 +70,8 @@ public class StorageSimulation {
|
||||
*/
|
||||
private List<StorageConversation> conversationList;
|
||||
|
||||
private List<StorageConversationGroup> conversationGroupList;
|
||||
|
||||
public StorageSimulation(Simulation simulation, boolean script) {
|
||||
this.systemTime = simulation.getSystemTime();
|
||||
this.planRunning = simulation.isPlanRunning();
|
||||
@ -82,6 +86,10 @@ public class StorageSimulation {
|
||||
this.conversationList = simulation.getSimulationConversationMap().values().stream()
|
||||
.map(StorageConversation::new).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(simulation.getSimulationConversationGroupMap())) {
|
||||
this.conversationGroupList = simulation.getSimulationConversationGroupMap().values().stream()
|
||||
.map(StorageConversationGroup::new).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
public void recover2Simulation(Simulation simulation) {
|
||||
@ -98,5 +106,10 @@ public class StorageSimulation {
|
||||
simulation.getSimulationConversationMap().clear(); // 清空会话信息
|
||||
this.conversationList.forEach(c -> simulation.addConversation(c.convert2SimulationObj(simulation)));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(this.conversationGroupList)) {
|
||||
Map<Long, ConversationGroup> conversationGroupMap = this.conversationGroupList.stream()
|
||||
.map(g -> g.convert2SimulationObj(simulation)).collect(Collectors.toMap(ConversationGroup::getId, g -> g));
|
||||
simulation.initDefaultConversationGroupMap(conversationGroupMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,86 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.vo;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.CommunicationObject;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.Conversation;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroupMessage;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 背景会话信息
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class StorageConversationGroup {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String imageUrl;
|
||||
|
||||
private String name;
|
||||
|
||||
private String creatorId;
|
||||
|
||||
private LocalDateTime time;
|
||||
|
||||
private List<StorageConversationMember> memberList;
|
||||
|
||||
private List<StorageConversationGroupMessage> messageList;
|
||||
|
||||
private Integer messageId;
|
||||
|
||||
/**
|
||||
* 保存背景时会话群组消息
|
||||
*/
|
||||
public StorageConversationGroup(ConversationGroup conversationGroup) {
|
||||
this.id = conversationGroup.getId();
|
||||
this.imageUrl = conversationGroup.getImageUrl();
|
||||
this.name = conversationGroup.getName();
|
||||
if (conversationGroup.getCreator() != null) {
|
||||
this.creatorId = conversationGroup.getCreator().getId();
|
||||
}
|
||||
this.time = conversationGroup.getTime();
|
||||
if (!CollectionUtils.isEmpty(conversationGroup.getMemberList())) {
|
||||
this.memberList = conversationGroup.getMemberList().stream().map(StorageConversationMember::new).collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(conversationGroup.getMessageList())) {
|
||||
this.messageList = conversationGroup.getMessageList().stream().map(StorageConversationGroupMessage::new).collect(Collectors.toList());
|
||||
}
|
||||
this.messageId = conversationGroup.getMessageId().get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载背景时会话信息
|
||||
*
|
||||
* @param simulation 仿真
|
||||
* @return 会话信息
|
||||
*/
|
||||
public ConversationGroup convert2SimulationObj(Simulation simulation) {
|
||||
SimulationMember creator = StringUtils.hasText(this.creatorId) ? simulation.querySimulationMemberById(this.creatorId) : null;
|
||||
List<SimulationMember> memberList = null;
|
||||
if (!CollectionUtils.isEmpty(this.memberList)) {
|
||||
memberList = this.memberList.stream().map(m -> simulation.querySimulationMemberById(m.getMemberId())).collect(Collectors.toList());
|
||||
}
|
||||
ConversationGroup group = new ConversationGroup(this.id, this.imageUrl, this.name, this.time, creator, memberList);
|
||||
if (this.messageId != null) {
|
||||
group.getMessageId().set(this.messageId);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(this.messageList)) {
|
||||
this.messageList.forEach(message -> group.addMessage(message.convert2SimulationObj(simulation)));
|
||||
}
|
||||
return group;
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.vo;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroupMessage;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationMessage;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Set;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
public class StorageConversationGroupMessage {
|
||||
|
||||
private String id;
|
||||
|
||||
private String memberId;
|
||||
|
||||
private LocalDateTime time;
|
||||
|
||||
private String content;
|
||||
|
||||
private String audioPath;
|
||||
|
||||
private Set<String> readerSet;
|
||||
|
||||
/**
|
||||
* 是否全部已读
|
||||
*/
|
||||
private Boolean allRead;
|
||||
|
||||
public StorageConversationGroupMessage(ConversationGroupMessage conversationMessage) {
|
||||
this.id = conversationMessage.getId();
|
||||
this.memberId = conversationMessage.getMember().getId();
|
||||
this.time = conversationMessage.getTime();
|
||||
this.content = conversationMessage.getContent();
|
||||
this.audioPath = conversationMessage.getAudioPath();
|
||||
this.readerSet = !CollectionUtils.isEmpty(readerSet) ? conversationMessage.getReaderSet() : null;
|
||||
this.allRead = conversationMessage.isAllRead() ? true : null;
|
||||
}
|
||||
|
||||
public ConversationGroupMessage convert2SimulationObj(Simulation simulation) {
|
||||
SimulationMember simulationMember = simulation.querySimulationMemberById(this.memberId);
|
||||
ConversationGroupMessage message = new ConversationGroupMessage(id, simulationMember, time, content, audioPath);
|
||||
if (!CollectionUtils.isEmpty(readerSet)) {
|
||||
message.setReaderSet(readerSet);
|
||||
}
|
||||
if (allRead != null) {
|
||||
message.finishRead();
|
||||
}
|
||||
return message;
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -28,10 +29,24 @@ public class StorageConversationMember {
|
||||
|
||||
private Boolean connect;
|
||||
|
||||
/**
|
||||
* 加入时间
|
||||
*/
|
||||
@Setter
|
||||
private LocalDateTime time;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
@Setter
|
||||
private ConversationMember.Role role;
|
||||
|
||||
public StorageConversationMember(ConversationMember conversationMember) {
|
||||
this.memberId = conversationMember.getMember().getId();
|
||||
if (conversationMember.isConnect()) {
|
||||
this.connect = Boolean.TRUE;
|
||||
}
|
||||
this.time = conversationMember.getTime();
|
||||
this.role = conversationMember.getRole();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user