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

This commit is contained in:
joylink_zhangsai 2023-04-18 18:04:12 +08:00
commit d354ed9fd7
7 changed files with 73 additions and 19 deletions

View File

@ -41,13 +41,21 @@ public class ConversationGroupController {
} }
@PutMapping("/{id}/data") @PutMapping("/{id}/data")
public void update(@PathVariable Long id, @RequestBody ConversationGroupVO vo) { public String update(@PathVariable Long id, @RequestBody ConversationGroupVO vo) {
vo.setId(id); vo.setId(id);
conversationGroupService.update(vo); return conversationGroupService.update(vo);
} }
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
public void delete(@PathVariable Long id) { public void delete(@PathVariable Long id) {
conversationGroupService.delete(id); conversationGroupService.delete(id);
} }
/**
* 检查群组名是否存在
*/
@GetMapping("/checkName")
public boolean checkName(Long id, String name, Long mapId){
return conversationGroupService.checkNameNotExist(id, name, mapId);
}
} }

View File

@ -112,7 +112,7 @@ public class SimulationConversationController {
* @return 用户群组 * @return 用户群组
*/ */
@GetMapping("/group/list") @GetMapping("/group/list")
public List<ConversationGroupVO> groupList(@PathVariable String group) { public List<ConversationGroupVO> groupList(@PathVariable String group, @RequestAttribute AccountVO user) {
return conversationGroupHandlerService.getAllConversationsGroup(group); return conversationGroupHandlerService.getAllConversationsGroup(group, user);
} }
} }

View File

@ -51,7 +51,7 @@ public interface ConversationGroupService {
* 更新群组信息 * 更新群组信息
* @param vo 群组信息 * @param vo 群组信息
*/ */
void update(ConversationGroupVO vo); String update(ConversationGroupVO vo);
/** /**
* 删除群组信息 * 删除群组信息
@ -67,4 +67,13 @@ public interface ConversationGroupService {
* @return 群组列表 * @return 群组列表
*/ */
List<ConversationGroupVO> getConversationGroupByMapId(Long mapId); List<ConversationGroupVO> getConversationGroupByMapId(Long mapId);
/**
* 检查本地图下群组名是否不存在
* @param id 群组ID编辑时存在
* @param name 群组名称
* @param mapId 地图ID
* @return 是否存在
*/
boolean checkNameNotExist(Long id, String name, Long mapId);
} }

View File

@ -50,17 +50,24 @@ public class ConversationGroupServiceImpl implements ConversationGroupService {
@Override @Override
public ConversationGroupVO getById(Long id) { public ConversationGroupVO getById(Long id) {
RtsConversationGroupInfo rtsConversationGroupInfo = conversationGroupInfoMapper.selectByPrimaryKey(id); RtsConversationGroupInfo rtsConversationGroupInfo = conversationGroupInfoMapper.selectByPrimaryKey(id);
return new ConversationGroupVO(rtsConversationGroupInfo); if (rtsConversationGroupInfo != null) {
return new ConversationGroupVO(rtsConversationGroupInfo);
}
return null;
} }
@Override @Override
public String create(ConversationGroupVO vo, AccountVO user) { public String create(ConversationGroupVO vo, AccountVO user) {
if (vo.getId() != null) { if (vo.getId() != null) {
update(vo); return update(vo);
} else { } else {
if (checkNameNotExist(null, vo.getName(), vo.getMapId())) {
throw new IllegalArgumentException("名称已存在");
}
RtsConversationGroupInfo rtsConversationGroupInfo = vo.toEntity(); RtsConversationGroupInfo rtsConversationGroupInfo = vo.toEntity();
rtsConversationGroupInfo.setCreateTime(LocalDateTime.now()); rtsConversationGroupInfo.setCreateTime(LocalDateTime.now());
rtsConversationGroupInfo.setUpdateTime(LocalDateTime.now()); rtsConversationGroupInfo.setUpdateTime(LocalDateTime.now());
rtsConversationGroupInfo.setCreatorId(user.getId().toString());
rtsConversationGroupInfo.setStatus(VALID); rtsConversationGroupInfo.setStatus(VALID);
conversationGroupInfoMapper.insert(rtsConversationGroupInfo); conversationGroupInfoMapper.insert(rtsConversationGroupInfo);
} }
@ -68,11 +75,14 @@ public class ConversationGroupServiceImpl implements ConversationGroupService {
} }
@Override @Override
public void update(ConversationGroupVO vo) { public String update(ConversationGroupVO vo) {
if (vo.getId() != null) { if (vo.getId() != null && !checkNameNotExist(vo.getId(), vo.getName(), vo.getMapId())) {
RtsConversationGroupInfo rtsConversationGroupInfo = vo.toEntity(); RtsConversationGroupInfo rtsConversationGroupInfo = vo.toEntity();
rtsConversationGroupInfo.setUpdateTime(LocalDateTime.now()); rtsConversationGroupInfo.setUpdateTime(LocalDateTime.now());
conversationGroupInfoMapper.updateByPrimaryKeySelective(rtsConversationGroupInfo); conversationGroupInfoMapper.updateByPrimaryKeySelective(rtsConversationGroupInfo);
return "保存成功";
} else {
return "保存失败";
} }
} }
@ -88,6 +98,30 @@ public class ConversationGroupServiceImpl implements ConversationGroupService {
return queryList(queryVO); return queryList(queryVO);
} }
/**
* 检查群组名称是否存在
* @param id 群组ID编辑时存在
* @param name 群组名称
* @param mapId 地图ID
* @return 存在结果
*/
@Override
public boolean checkNameNotExist(Long id, String name, Long mapId) {
RtsConversationGroupInfoExample example = new RtsConversationGroupInfoExample();
RtsConversationGroupInfoExample.Criteria criteria = example.createCriteria();
if (StringUtils.hasText(name)) {
criteria.andNameEqualTo(name);
}
if (mapId != null) {
criteria.andMapIdEqualTo(mapId);
}
if (id != null) {
criteria.andMapIdNotEqualTo(id);
}
criteria.andStatusEqualTo(VALID);
return CollectionUtils.isEmpty(conversationGroupInfoMapper.selectByExampleWithBLOBs(example));
}
/** /**
* 获取查询条件 * 获取查询条件
@ -101,7 +135,7 @@ 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 (!CollectionUtils.isEmpty(queryVO.getMapIds())) {
criteria.andMapIdIn(queryVO.getMapIds()); criteria.andMapIdIn(queryVO.getMapIds());
} }
if (StringUtils.hasText(queryVO.getProjectCode())) { if (StringUtils.hasText(queryVO.getProjectCode())) {

View File

@ -302,19 +302,14 @@ public class SimulationServiceImpl implements SimulationService {
//获取仿真工作服务 //获取仿真工作服务
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(workParamVO.getType()); SimulationWorkService initService = simulationWorkServiceManager.getWorkService(workParamVO.getType());
//创建仿真 //创建仿真
String simulationId = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), mapId); String simulationId = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), mapId);
Simulation simulation = initService.create(mapId, workParamVO, loginUserInfoVO, simulationId); Simulation simulation = initService.create(mapId, workParamVO, loginUserInfoVO, simulationId);
//语音配置数据 //语音配置数据
List<VoiceDiscriminateRule> ruleList = this.discriminateRule.findRuleByMapId(mapId); List<VoiceDiscriminateRule> ruleList = this.discriminateRule.findRuleByMapId(mapId);
simulation.setVoiceRuleList(ruleList); simulation.setVoiceRuleList(ruleList);
// 群组配置信息
initConversationGroup(simulation);
simulation.setMapFunctionId(mapFunctionId); simulation.setMapFunctionId(mapFunctionId);
simulation.setCreateUserType(createUserType); simulation.setCreateUserType(createUserType);
LoginUserInfoVO loginUserInfo = simulation.getBuildParams().getLoginUserInfo(); LoginUserInfoVO loginUserInfo = simulation.getBuildParams().getLoginUserInfo();
@ -336,6 +331,8 @@ public class SimulationServiceImpl implements SimulationService {
initService.addItems(simulation, workParamVO.getItemMap()); initService.addItems(simulation, workParamVO.getItemMap());
} }
applicationContext.publishEvent(new SimulationCreateSuccessEvent(this, simulation)); applicationContext.publishEvent(new SimulationCreateSuccessEvent(this, simulation));
// 群组配置信息
initConversationGroup(simulation);
// 仿真开始运行 // 仿真开始运行
simulationManager.start(simulation.getId()); simulationManager.start(simulation.getId());
return simulation; return simulation;

View File

@ -11,6 +11,7 @@ import club.joylink.rtss.simulation.cbtc.event.conversation.*;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.SocketMessageVO; import club.joylink.rtss.vo.client.SocketMessageVO;
import club.joylink.rtss.vo.client.WebSocketMessageType; import club.joylink.rtss.vo.client.WebSocketMessageType;
import club.joylink.rtss.vo.client.factory.SocketMessageFactory; import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
@ -53,10 +54,15 @@ public class ConversationGroupHandlerService {
* @param group 仿真ID * @param group 仿真ID
* @return 群组信息 * @return 群组信息
*/ */
public List<ConversationGroupVO> getAllConversationsGroup(String group) { public List<ConversationGroupVO> getAllConversationsGroup(String group, AccountVO user) {
Simulation simulation = groupSimulationCache.getSimulationByGroup(group); Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
List<ConversationGroup> allGroup = simulation.queryAllConversationGroup(); List<ConversationGroup> allGroup = simulation.queryAllConversationGroup();
return ConversationGroupVO.convert2VOList(allGroup); SimulationMember member = simulation.querySimulationMemberByUserId(user.getId());
if (member == null) {
return List.of();
} else {
return allGroup.stream().filter(g -> g.isConversationMember(member)).map(ConversationGroupVO::new).collect(Collectors.toList());
}
} }
/** /**
@ -180,7 +186,7 @@ public class ConversationGroupHandlerService {
if (!conversationGroup.isConversationMember(member)) { if (!conversationGroup.isConversationMember(member)) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "非本组成员,不能邀请用户"); throw new SimulationException(SimulationExceptionType.Illegal_Argument, "非本组成员,不能邀请用户");
} }
if (conversationGroup.isCreator(member)) { if (conversationGroup.isLeader(member)) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "请先变更群主"); throw new SimulationException(SimulationExceptionType.Illegal_Argument, "请先变更群主");
} }
conversationGroup.exit(member); conversationGroup.exit(member);

View File

@ -5,7 +5,7 @@
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.conversation.RtsConversationGroupInfo"> <resultMap id="BaseResultMap" type="club.joylink.rtss.entity.conversation.RtsConversationGroupInfo">
<id column="id" jdbcType="BIGINT" property="id" /> <id column="id" jdbcType="BIGINT" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" /> <result column="name" jdbcType="VARCHAR" property="name" />
<result column="map_ids" jdbcType="BIGINT" property="mapId" /> <result column="map_id" jdbcType="BIGINT" property="mapId" />
<result column="project_code" jdbcType="VARCHAR" property="projectCode" /> <result column="project_code" jdbcType="VARCHAR" property="projectCode" />
<result column="image_url" jdbcType="VARCHAR" property="imageUrl" /> <result column="image_url" jdbcType="VARCHAR" property="imageUrl" />
<result column="leader_id" jdbcType="VARCHAR" property="leaderId" /> <result column="leader_id" jdbcType="VARCHAR" property="leaderId" />