Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
joylink_zhangsai 2023-04-19 13:40:23 +08:00
commit 56c5c6b3d3
14 changed files with 128 additions and 39 deletions

View File

@ -87,7 +87,6 @@ public class LoginController {
@GetMapping(path = "/getUserInfo") @GetMapping(path = "/getUserInfo")
public AccountVO getUserInfo(String token) { public AccountVO getUserInfo(String token) {
LoginUserInfoVO loginUserInfoVO = this.iAuthenticateService.getLoginUserInfoByToken(token); LoginUserInfoVO loginUserInfoVO = this.iAuthenticateService.getLoginUserInfoByToken(token);
System.out.println(String.format("%s ====%s =========== from getUserInfo",loginUserInfoVO,loginUserInfoVO.getAccountVO().getCompanyId()));
return loginUserInfoVO.getAccountVO(); return loginUserInfoVO.getAccountVO();
} }

View File

@ -21,12 +21,14 @@ public class ConversationGroupController {
private ConversationGroupServiceImpl conversationGroupService; private ConversationGroupServiceImpl conversationGroupService;
@GetMapping("/list") @GetMapping("/list")
public List<ConversationGroupVO> queryList(ConversationGroupQueryVO queryVO) { public List<ConversationGroupVO> queryList(ConversationGroupQueryVO queryVO, @RequestAttribute AccountVO user) {
queryVO.setUserId(user.getId());
return conversationGroupService.queryList(queryVO); return conversationGroupService.queryList(queryVO);
} }
@GetMapping("/page/users") @GetMapping("/page/users")
public PageVO<ConversationGroupVO> pagingQuery(ConversationGroupQueryVO queryVO, @RequestAttribute AccountVO user) { public PageVO<ConversationGroupVO> pagingQuery(ConversationGroupQueryVO queryVO, @RequestAttribute AccountVO user) {
queryVO.setUserId(user.getId());
return conversationGroupService.pagingQuery(queryVO, user); return conversationGroupService.pagingQuery(queryVO, user);
} }
@ -41,9 +43,9 @@ public class ConversationGroupController {
} }
@PutMapping("/{id}/data") @PutMapping("/{id}/data")
public String update(@PathVariable Long id, @RequestBody ConversationGroupVO vo) { public String update(@PathVariable Long id, @RequestBody ConversationGroupVO vo, @RequestAttribute AccountVO user) {
vo.setId(id); vo.setId(id);
return conversationGroupService.update(vo); return conversationGroupService.update(vo, user);
} }
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
@ -55,7 +57,7 @@ public class ConversationGroupController {
* 检查群组名是否存在 * 检查群组名是否存在
*/ */
@GetMapping("/checkName") @GetMapping("/checkName")
public boolean checkName(Long id, String name, Long mapId){ public boolean checkName(Long id, String name, Long mapId, @RequestAttribute AccountVO user){
return conversationGroupService.checkNameNotExist(id, name, mapId); return conversationGroupService.checkNameNotExist(id, name, mapId, user.getId());
} }
} }

View File

@ -51,7 +51,7 @@ public interface ConversationGroupService {
* 更新群组信息 * 更新群组信息
* @param vo 群组信息 * @param vo 群组信息
*/ */
String update(ConversationGroupVO vo); String update(ConversationGroupVO vo, AccountVO user);
/** /**
* 删除群组信息 * 删除群组信息
@ -61,19 +61,18 @@ public interface ConversationGroupService {
void delete(Long id); void delete(Long id);
/** /**
* 通过地图获取会话群组信息 * 删除群组根据地图信息
* * @param mapId 地图ID
* @param mapId 地图信息
* @return 群组列表
*/ */
List<ConversationGroupVO> getConversationGroupByMapId(Long mapId); void deleteByMapId(Long mapId);
/** /**
* 检查本地图下群组名是否不存在 * 检查本地图下群组名是否不存在
* @param id 群组ID编辑时存在 * @param id 群组ID编辑时存在
* @param name 群组名称 * @param name 群组名称
* @param mapId 地图ID * @param mapId 地图ID
* @param userId 用户ID
* @return 是否存在 * @return 是否存在
*/ */
boolean checkNameNotExist(Long id, String name, Long mapId); boolean checkNameNotExist(Long id, String name, Long mapId, Long userId);
} }

View File

@ -59,9 +59,9 @@ public class ConversationGroupServiceImpl implements ConversationGroupService {
@Override @Override
public String create(ConversationGroupVO vo, AccountVO user) { public String create(ConversationGroupVO vo, AccountVO user) {
if (vo.getId() != null) { if (vo.getId() != null) {
return update(vo); return update(vo, user);
} else { } else {
if (checkNameNotExist(null, vo.getName(), vo.getMapId())) { if (checkNameNotExist(null, vo.getName(), vo.getMapId(), user.getId())) {
throw new IllegalArgumentException("名称已存在"); throw new IllegalArgumentException("名称已存在");
} }
RtsConversationGroupInfo rtsConversationGroupInfo = vo.toEntity(); RtsConversationGroupInfo rtsConversationGroupInfo = vo.toEntity();
@ -75,8 +75,8 @@ public class ConversationGroupServiceImpl implements ConversationGroupService {
} }
@Override @Override
public String update(ConversationGroupVO vo) { public String update(ConversationGroupVO vo, AccountVO user) {
if (vo.getId() != null && !checkNameNotExist(vo.getId(), vo.getName(), vo.getMapId())) { if (vo.getId() != null && !checkNameNotExist(vo.getId(), vo.getName(), vo.getMapId(), user.getId())) {
RtsConversationGroupInfo rtsConversationGroupInfo = vo.toEntity(); RtsConversationGroupInfo rtsConversationGroupInfo = vo.toEntity();
rtsConversationGroupInfo.setUpdateTime(LocalDateTime.now()); rtsConversationGroupInfo.setUpdateTime(LocalDateTime.now());
conversationGroupInfoMapper.updateByPrimaryKeySelective(rtsConversationGroupInfo); conversationGroupInfoMapper.updateByPrimaryKeySelective(rtsConversationGroupInfo);
@ -92,10 +92,10 @@ public class ConversationGroupServiceImpl implements ConversationGroupService {
} }
@Override @Override
public List<ConversationGroupVO> getConversationGroupByMapId(Long mapId) { public void deleteByMapId(Long mapId) {
ConversationGroupQueryVO queryVO = new ConversationGroupQueryVO(); RtsConversationGroupInfoExample example = new RtsConversationGroupInfoExample();
queryVO.setMapIds(Arrays.asList(mapId)); example.createCriteria().andMapIdEqualTo(mapId);
return queryList(queryVO); conversationGroupInfoMapper.deleteByExample(example);
} }
/** /**
@ -106,7 +106,7 @@ public class ConversationGroupServiceImpl implements ConversationGroupService {
* @return 存在结果 * @return 存在结果
*/ */
@Override @Override
public boolean checkNameNotExist(Long id, String name, Long mapId) { public boolean checkNameNotExist(Long id, String name, Long mapId, Long userId) {
RtsConversationGroupInfoExample example = new RtsConversationGroupInfoExample(); RtsConversationGroupInfoExample example = new RtsConversationGroupInfoExample();
RtsConversationGroupInfoExample.Criteria criteria = example.createCriteria(); RtsConversationGroupInfoExample.Criteria criteria = example.createCriteria();
if (StringUtils.hasText(name)) { if (StringUtils.hasText(name)) {
@ -118,11 +118,11 @@ public class ConversationGroupServiceImpl implements ConversationGroupService {
if (id != null) { if (id != null) {
criteria.andMapIdNotEqualTo(id); criteria.andMapIdNotEqualTo(id);
} }
criteria.andCreatorIdEqualTo(userId);
criteria.andStatusEqualTo(VALID); criteria.andStatusEqualTo(VALID);
return CollectionUtils.isEmpty(conversationGroupInfoMapper.selectByExampleWithBLOBs(example)); return CollectionUtils.isEmpty(conversationGroupInfoMapper.selectByExampleWithBLOBs(example));
} }
/** /**
* 获取查询条件 * 获取查询条件
* *
@ -135,12 +135,13 @@ public class ConversationGroupServiceImpl implements ConversationGroupService {
if (StringUtils.hasText(queryVO.getName())) { if (StringUtils.hasText(queryVO.getName())) {
criteria.andNameLike(String.format("%%%s%%", queryVO.getName())); criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
} }
if (!CollectionUtils.isEmpty(queryVO.getMapIds())) { if (queryVO.getMapId() != null) {
criteria.andMapIdIn(queryVO.getMapIds()); criteria.andMapIdEqualTo(queryVO.getMapId());
} }
if (StringUtils.hasText(queryVO.getProjectCode())) { if (StringUtils.hasText(queryVO.getProjectCode())) {
criteria.andProjectCodeEqualTo(queryVO.getProjectCode()); criteria.andProjectCodeEqualTo(queryVO.getProjectCode());
} }
criteria.andCreatorIdEqualTo(queryVO.getUserId());
criteria.andStatusEqualTo(VALID); criteria.andStatusEqualTo(VALID);
return example; return example;
} }

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.services.voice.discriminate; package club.joylink.rtss.services.voice.discriminate;
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup; import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroupHandlerService;
import club.joylink.rtss.simulation.cbtc.conversation.ConversationMember; import club.joylink.rtss.simulation.cbtc.conversation.ConversationMember;
import club.joylink.rtss.simulation.cbtc.discriminate.VoiceDiscriminateResult; import club.joylink.rtss.simulation.cbtc.discriminate.VoiceDiscriminateResult;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
@ -42,6 +43,9 @@ public class VoiceDiscriminateService {
@Qualifier(value = "correctSourceServiceImpl") @Qualifier(value = "correctSourceServiceImpl")
private VoiceTransactionalService correctSourceService; private VoiceTransactionalService correctSourceService;
@Autowired
private ConversationGroupHandlerService conversationGroupManagerService;
/** /**
* 接受语音文件资源等必要条件解析开始 * 接受语音文件资源等必要条件解析开始
*/ */
@ -87,7 +91,9 @@ public class VoiceDiscriminateService {
if (CollectionUtils.isEmpty(memberList)) { // 人员全部为真实人员时直接返回 if (CollectionUtils.isEmpty(memberList)) { // 人员全部为真实人员时直接返回
return; return;
} }
// 增加机器人已读操作
memberList.forEach(m -> conversationGroupManagerService.readConversationGroup(event.getSimulation(), m, conversationGroup.getId()));
// 执行语音识别 // 执行语音识别
doAnalysis(event.getSimulation(), event.getContent(), memberList); doAnalysis(event.getSimulation(), event.getMessage().getContent(), memberList);
} }
} }

View File

@ -7,6 +7,7 @@ import club.joylink.rtss.services.conversation.ConversationGroupService;
import club.joylink.rtss.services.mapFunction.RtsMapFunctionService; import club.joylink.rtss.services.mapFunction.RtsMapFunctionService;
import club.joylink.rtss.services.permission.PermissionSubjectService; import club.joylink.rtss.services.permission.PermissionSubjectService;
import club.joylink.rtss.simulation.SimulationManager; import club.joylink.rtss.simulation.SimulationManager;
import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup; import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
import club.joylink.rtss.simulation.cbtc.discriminate.IVoiceDiscriminateRule; import club.joylink.rtss.simulation.cbtc.discriminate.IVoiceDiscriminateRule;
import club.joylink.rtss.simulation.cbtc.discriminate.VoiceDiscriminateRule; import club.joylink.rtss.simulation.cbtc.discriminate.VoiceDiscriminateRule;
@ -75,9 +76,6 @@ public class SimulationServiceImpl implements SimulationService {
@Autowired @Autowired
private IVoiceDiscriminateRule discriminateRule; private IVoiceDiscriminateRule discriminateRule;
@Autowired
private ConversationGroupService conversationGroupService;
@Override @Override
public String createSimulation(long mapId, Long mapFunctionId, SimulationWorkParamVO workParamVO, @NonNull LoginUserInfoVO loginUserInfoVO,Map<String,Boolean> createUserType) { public String createSimulation(long mapId, Long mapFunctionId, SimulationWorkParamVO workParamVO, @NonNull LoginUserInfoVO loginUserInfoVO,Map<String,Boolean> createUserType) {
return createSimulationPojo(mapId, mapFunctionId, workParamVO, loginUserInfoVO, createUserType).getId(); return createSimulationPojo(mapId, mapFunctionId, workParamVO, loginUserInfoVO, createUserType).getId();
@ -380,8 +378,9 @@ public class SimulationServiceImpl implements SimulationService {
* @param simulation 仿真对象 * @param simulation 仿真对象
*/ */
private void initConversationGroup(Simulation simulation) { private void initConversationGroup(Simulation simulation) {
List<ConversationGroupVO> conversationGroupVOList = SimulationBuildParams buildParams = simulation.getBuildParams();
conversationGroupService.getConversationGroupByMapId(simulation.getBuildParams().getMap().getId()); List<ConversationGroupVO> conversationGroupVOList = buildParams.getMap().getGraphDataNew()
.getConversationGroupMap().get(buildParams.getWorkParamVO().getType());
if (CollectionUtils.isEmpty(conversationGroupVOList)) { if (CollectionUtils.isEmpty(conversationGroupVOList)) {
return; return;
} }

View File

@ -273,13 +273,16 @@ public class ConversationGroupHandlerService {
if (CollectionUtils.isEmpty(messageList)) { if (CollectionUtils.isEmpty(messageList)) {
return List.of(); return List.of();
} }
int memberSize = conversationGroup.getMemberList().size(); List<String> memberIds = conversationGroup.getSimulationMemberIds();
messageList.forEach(message -> { messageList.forEach(message -> {
message.read(member); message.read(member);
if (message.getReaderSet().size() >= memberSize) { // 全部用户已读 if (memberIds.stream()
.filter(mid -> !Objects.equals(message.getMember().getId(), mid))
.allMatch(mid -> message.getReaderSet().contains(mid))) { // 除发送用户外全部已读
message.finishRead(); message.finishRead();
} }
}); });
applicationEventPublisher.publishEvent(new SimulationConversationGroupMessageStatusEvent(this, simulation, conversationGroup, messageList));
return ConversationGroupMessageVO.convert2VO(messageList); return ConversationGroupMessageVO.convert2VO(messageList);
} }
@ -406,6 +409,20 @@ public class ConversationGroupHandlerService {
doSendMessage(event.getSimulation(), userIdSet, exitMessageVO); doSendMessage(event.getSimulation(), userIdSet, exitMessageVO);
} }
/**
* 处理消息状态
* @param event
*/
@EventListener
public void handleMessageStatus(SimulationConversationGroupMessageStatusEvent event) {
ConversationGroup conversationGroup = event.getConversationGroup();
event.getMessageList().stream().filter(m -> !m.getMember().isRobot()).forEach(message -> {
ConversationGroupSocketMessageVO messageStatusVO
= ConversationGroupSocketMessageVO.MessageType.MESSAGE_STATUS.generateMessageVO(conversationGroup, new ConversationGroupMessageVO(message));
doSendMessage(event.getSimulation(), Set.of(message.getMember().getUserId()), messageStatusVO);
});
}
/** /**
* 对群组操作时基础判断 * 对群组操作时基础判断
* *
@ -454,7 +471,7 @@ public class ConversationGroupHandlerService {
doSendMessage(simulation, userIdSet, ConversationGroupSocketMessageVO.MessageType.MESSAGE.generateMessageVO(conversationGroup, messageVO)); doSendMessage(simulation, userIdSet, ConversationGroupSocketMessageVO.MessageType.MESSAGE.generateMessageVO(conversationGroup, messageVO));
} }
// 语音识别开始 // 语音识别开始
applicationEventPublisher.publishEvent(new SimulationConversationGroupMessageEvent(this, simulation, conversationGroup, member, message.getContent())); applicationEventPublisher.publishEvent(new SimulationConversationGroupMessageEvent(this, simulation, conversationGroup, member, message));
return messageVO; return messageVO;
} }

View File

@ -31,6 +31,12 @@ public class ConversationGroupMessageVO extends ConversationMessageVO {
this.allRead = message.isAllRead(); this.allRead = message.isAllRead();
} }
public ConversationGroupMessageVO(String id, Set<String> readerSet, boolean allRead) {
setId(id);
this.readerSet = readerSet;
this.allRead = allRead;
}
public static List<ConversationGroupMessageVO> convert2VO(List<ConversationGroupMessage> list) { public static List<ConversationGroupMessageVO> convert2VO(List<ConversationGroupMessage> list) {
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
return List.of(); return List.of();

View File

@ -110,6 +110,17 @@ public class ConversationGroupSocketMessageVO {
return messageVO; return messageVO;
} }
}, },
/** 更新消息状态 */
MESSAGE_STATUS {
@Override
public ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message) {
ConversationGroupSocketMessageVO messageVO = new ConversationGroupSocketMessageVO();
messageVO.id = group.getId();
messageVO.message = new ConversationGroupMessageVO(message.getId(), message.getReaderSet(), message.isAllRead());
messageVO.messageType = MessageType.MESSAGE_STATUS;
return messageVO;
}
},
/** 会话组解散 */ /** 会话组解散 */
EXIT { EXIT {
@Override @Override

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.data.vo;
import club.joylink.rtss.simulation.cbtc.conversation.ConversationMessage; import club.joylink.rtss.simulation.cbtc.conversation.ConversationMessage;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -11,6 +12,7 @@ import java.util.List;
@Getter @Getter
@Setter @Setter
@NoArgsConstructor
public class ConversationMessageVO { public class ConversationMessageVO {
private String id; private String id;

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.event.conversation;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup; import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroupMessage;
import club.joylink.rtss.simulation.cbtc.event.AbstractSimulationEvent; import club.joylink.rtss.simulation.cbtc.event.AbstractSimulationEvent;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import lombok.Getter; import lombok.Getter;
@ -25,13 +26,13 @@ public class SimulationConversationGroupMessageEvent extends AbstractSimulationE
/** /**
* 消息内容 * 消息内容
*/ */
private String content; private ConversationGroupMessage message;
public SimulationConversationGroupMessageEvent(Object source, Simulation simulation, ConversationGroup conversationGroup public SimulationConversationGroupMessageEvent(Object source, Simulation simulation, ConversationGroup conversationGroup
, SimulationMember member, String content) { , SimulationMember member, ConversationGroupMessage message) {
super(source, simulation); super(source, simulation);
this.conversationGroup = conversationGroup; this.conversationGroup = conversationGroup;
this.member = member; this.member = member;
this.content = content; this.message = message;
} }
} }

View File

@ -0,0 +1,35 @@
package club.joylink.rtss.simulation.cbtc.event.conversation;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroupMessage;
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupMessageVO;
import club.joylink.rtss.simulation.cbtc.event.AbstractSimulationEvent;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import lombok.Getter;
import java.util.List;
/**
* 群组消息状态事件
*/
@Getter
public class SimulationConversationGroupMessageStatusEvent extends AbstractSimulationEvent {
/**
* 会话对象
*/
private ConversationGroup conversationGroup;
/**
* 消息内容
*/
private List<ConversationGroupMessage> messageList;
public SimulationConversationGroupMessageStatusEvent(Object source, Simulation simulation
, ConversationGroup conversationGroup, List<ConversationGroupMessage> messageList) {
super(source, simulation);
this.conversationGroup = conversationGroup;
this.messageList = messageList;
}
}

View File

@ -25,5 +25,10 @@ public class ConversationGroupQueryVO extends PageQueryVO {
/** /**
* 地图ID * 地图ID
*/ */
private List<Long> mapIds; private Long mapId;
/**
* 用户ID
*/
private Long userId;
} }

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.vo.map;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.conversation.ConversationGroupVO;
import club.joylink.rtss.vo.map.display.PictureVO; import club.joylink.rtss.vo.map.display.PictureVO;
import club.joylink.rtss.vo.map.graph.*; import club.joylink.rtss.vo.map.graph.*;
import lombok.Getter; import lombok.Getter;
@ -243,6 +244,11 @@ public class MapGraphDataNewVO {
*/ */
private Map<Simulation.Type, List<MapMemberVO>> memberMap = new HashMap<>(); private Map<Simulation.Type, List<MapMemberVO>> memberMap = new HashMap<>();
/**
* 会话群组列表
*/
private Map<Simulation.Type, List<ConversationGroupVO>> conversationGroupMap = new HashMap<>();
public MapGraphDataNewVO() { public MapGraphDataNewVO() {
this.bigScreenConfig = new BigScreenConfig(); this.bigScreenConfig = new BigScreenConfig();
this.generateConfig = new MapCiGenerateConfig(); this.generateConfig = new MapCiGenerateConfig();