Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
d354ed9fd7
@ -41,13 +41,21 @@ public class ConversationGroupController {
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/data")
|
||||
public void update(@PathVariable Long id, @RequestBody ConversationGroupVO vo) {
|
||||
public String update(@PathVariable Long id, @RequestBody ConversationGroupVO vo) {
|
||||
vo.setId(id);
|
||||
conversationGroupService.update(vo);
|
||||
return conversationGroupService.update(vo);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public void delete(@PathVariable Long id) {
|
||||
conversationGroupService.delete(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查群组名是否存在
|
||||
*/
|
||||
@GetMapping("/checkName")
|
||||
public boolean checkName(Long id, String name, Long mapId){
|
||||
return conversationGroupService.checkNameNotExist(id, name, mapId);
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class SimulationConversationController {
|
||||
* @return 用户群组
|
||||
*/
|
||||
@GetMapping("/group/list")
|
||||
public List<ConversationGroupVO> groupList(@PathVariable String group) {
|
||||
return conversationGroupHandlerService.getAllConversationsGroup(group);
|
||||
public List<ConversationGroupVO> groupList(@PathVariable String group, @RequestAttribute AccountVO user) {
|
||||
return conversationGroupHandlerService.getAllConversationsGroup(group, user);
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public interface ConversationGroupService {
|
||||
* 更新群组信息
|
||||
* @param vo 群组信息
|
||||
*/
|
||||
void update(ConversationGroupVO vo);
|
||||
String update(ConversationGroupVO vo);
|
||||
|
||||
/**
|
||||
* 删除群组信息
|
||||
@ -67,4 +67,13 @@ public interface ConversationGroupService {
|
||||
* @return 群组列表
|
||||
*/
|
||||
List<ConversationGroupVO> getConversationGroupByMapId(Long mapId);
|
||||
|
||||
/**
|
||||
* 检查本地图下群组名是否不存在
|
||||
* @param id 群组ID(编辑时存在)
|
||||
* @param name 群组名称
|
||||
* @param mapId 地图ID
|
||||
* @return 是否存在
|
||||
*/
|
||||
boolean checkNameNotExist(Long id, String name, Long mapId);
|
||||
}
|
||||
|
@ -50,17 +50,24 @@ public class ConversationGroupServiceImpl implements ConversationGroupService {
|
||||
@Override
|
||||
public ConversationGroupVO getById(Long id) {
|
||||
RtsConversationGroupInfo rtsConversationGroupInfo = conversationGroupInfoMapper.selectByPrimaryKey(id);
|
||||
if (rtsConversationGroupInfo != null) {
|
||||
return new ConversationGroupVO(rtsConversationGroupInfo);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String create(ConversationGroupVO vo, AccountVO user) {
|
||||
if (vo.getId() != null) {
|
||||
update(vo);
|
||||
return update(vo);
|
||||
} else {
|
||||
if (checkNameNotExist(null, vo.getName(), vo.getMapId())) {
|
||||
throw new IllegalArgumentException("名称已存在");
|
||||
}
|
||||
RtsConversationGroupInfo rtsConversationGroupInfo = vo.toEntity();
|
||||
rtsConversationGroupInfo.setCreateTime(LocalDateTime.now());
|
||||
rtsConversationGroupInfo.setUpdateTime(LocalDateTime.now());
|
||||
rtsConversationGroupInfo.setCreatorId(user.getId().toString());
|
||||
rtsConversationGroupInfo.setStatus(VALID);
|
||||
conversationGroupInfoMapper.insert(rtsConversationGroupInfo);
|
||||
}
|
||||
@ -68,11 +75,14 @@ public class ConversationGroupServiceImpl implements ConversationGroupService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ConversationGroupVO vo) {
|
||||
if (vo.getId() != null) {
|
||||
public String update(ConversationGroupVO vo) {
|
||||
if (vo.getId() != null && !checkNameNotExist(vo.getId(), vo.getName(), vo.getMapId())) {
|
||||
RtsConversationGroupInfo rtsConversationGroupInfo = vo.toEntity();
|
||||
rtsConversationGroupInfo.setUpdateTime(LocalDateTime.now());
|
||||
conversationGroupInfoMapper.updateByPrimaryKeySelective(rtsConversationGroupInfo);
|
||||
return "保存成功";
|
||||
} else {
|
||||
return "保存失败";
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,6 +98,30 @@ public class ConversationGroupServiceImpl implements ConversationGroupService {
|
||||
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())) {
|
||||
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(queryVO.getMapIds())) {
|
||||
if (!CollectionUtils.isEmpty(queryVO.getMapIds())) {
|
||||
criteria.andMapIdIn(queryVO.getMapIds());
|
||||
}
|
||||
if (StringUtils.hasText(queryVO.getProjectCode())) {
|
||||
|
@ -302,19 +302,14 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
//获取仿真工作服务
|
||||
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(workParamVO.getType());
|
||||
|
||||
|
||||
//创建仿真
|
||||
String simulationId = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), mapId);
|
||||
Simulation simulation = initService.create(mapId, workParamVO, loginUserInfoVO, simulationId);
|
||||
|
||||
|
||||
//语音配置数据
|
||||
List<VoiceDiscriminateRule> ruleList = this.discriminateRule.findRuleByMapId(mapId);
|
||||
simulation.setVoiceRuleList(ruleList);
|
||||
|
||||
// 群组配置信息
|
||||
initConversationGroup(simulation);
|
||||
|
||||
simulation.setMapFunctionId(mapFunctionId);
|
||||
simulation.setCreateUserType(createUserType);
|
||||
LoginUserInfoVO loginUserInfo = simulation.getBuildParams().getLoginUserInfo();
|
||||
@ -336,6 +331,8 @@ public class SimulationServiceImpl implements SimulationService {
|
||||
initService.addItems(simulation, workParamVO.getItemMap());
|
||||
}
|
||||
applicationContext.publishEvent(new SimulationCreateSuccessEvent(this, simulation));
|
||||
// 群组配置信息
|
||||
initConversationGroup(simulation);
|
||||
// 仿真开始运行
|
||||
simulationManager.start(simulation.getId());
|
||||
return simulation;
|
||||
|
@ -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.SimulationExceptionType;
|
||||
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.WebSocketMessageType;
|
||||
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
|
||||
@ -53,10 +54,15 @@ public class ConversationGroupHandlerService {
|
||||
* @param group 仿真ID
|
||||
* @return 群组信息
|
||||
*/
|
||||
public List<ConversationGroupVO> getAllConversationsGroup(String group) {
|
||||
public List<ConversationGroupVO> getAllConversationsGroup(String group, AccountVO user) {
|
||||
Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
|
||||
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)) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "非本组成员,不能邀请用户");
|
||||
}
|
||||
if (conversationGroup.isCreator(member)) {
|
||||
if (conversationGroup.isLeader(member)) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "请先变更群主");
|
||||
}
|
||||
conversationGroup.exit(member);
|
||||
|
@ -5,7 +5,7 @@
|
||||
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.conversation.RtsConversationGroupInfo">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<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="image_url" jdbcType="VARCHAR" property="imageUrl" />
|
||||
<result column="leader_id" jdbcType="VARCHAR" property="leaderId" />
|
||||
|
Loading…
Reference in New Issue
Block a user