feat(video): 添加消防会议最大人数限制以及提示信息

dev
lishiwei 2026-07-22 17:26:38 +08:00
parent b14bda36c5
commit f4537dd7b6
4 changed files with 74 additions and 24 deletions

View File

@ -57,6 +57,7 @@ import java.util.stream.Collectors;
public class VideoPlatformServiceImpl extends FireAlarmServiceSupport implements VideoPlatformServiceI { public class VideoPlatformServiceImpl extends FireAlarmServiceSupport implements VideoPlatformServiceI {
private static final int AUTH_STATUS_SUCCESS = 1; private static final int AUTH_STATUS_SUCCESS = 1;
private static final int MAX_MEETING_TOTAL_COUNT = 4;
private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private final HstVideoPlatformProperties properties; private final HstVideoPlatformProperties properties;
@ -65,6 +66,7 @@ public class VideoPlatformServiceImpl extends FireAlarmServiceSupport implements
private final FireAlarmMeetingUserRepository fireAlarmMeetingUserRepository; private final FireAlarmMeetingUserRepository fireAlarmMeetingUserRepository;
private final FireBrigadeRepository fireBrigadeRepository; private final FireBrigadeRepository fireBrigadeRepository;
private final FireBrigadeUserRepository fireBrigadeUserRepository; private final FireBrigadeUserRepository fireBrigadeUserRepository;
private final FireAlarmUserResolver fireAlarmUserResolver;
@Override @Override
public SingleResponse<VideoPlatformConfigCO> getConfig() { public SingleResponse<VideoPlatformConfigCO> getConfig() {
@ -281,38 +283,51 @@ public class VideoPlatformServiceImpl extends FireAlarmServiceSupport implements
if (meetingUser == null || StrUtil.isBlank(meetingUser.getThirdUserName())) { if (meetingUser == null || StrUtil.isBlank(meetingUser.getThirdUserName())) {
co.setReason("当前用户未配置视频会议账号"); co.setReason("当前用户未配置视频会议账号");
co.setParticipants(buildParticipants(context, localUserId)); co.setParticipants(buildParticipants(context, localUserId));
return SingleResponse.of(co); fillMeetingCapacity(co, co.getParticipants());
}
if (relation == null) {
co.setReason("当前用户未加入消防队伍");
co.setParticipants(buildParticipants(context, localUserId));
return SingleResponse.of(co); return SingleResponse.of(co);
} }
String fireBrigadeId = relation.getFireBrigadeId(); if (relation != null) {
co.setFireBrigadeId(fireBrigadeId); co.setFireBrigadeId(relation.getFireBrigadeId());
co.setFireBrigadeName(brigade == null ? meetingUser.getFireBrigadeName() : brigade.getBrigadeName()); co.setFireBrigadeName(brigade == null ? meetingUser.getFireBrigadeName() : brigade.getBrigadeName());
}
List<VideoPlatformMeetingParticipantCO> participants = buildParticipants(context, localUserId); List<VideoPlatformMeetingParticipantCO> participants = buildParticipants(context, localUserId);
co.setParticipants(participants); co.setParticipants(participants);
fillMeetingCapacity(co, participants);
if (isUserInMeeting(participants, localUserId)) {
co.setAllowed(true);
co.setOccupied(false);
co.setReason("当前用户已在会议中");
return SingleResponse.of(co);
}
if (participants.size() >= MAX_MEETING_TOTAL_COUNT) {
co.setAllowed(false);
co.setOccupied(false);
co.setReason("当前参会人数已满,报警需要排队");
return SingleResponse.of(co);
}
if (relation != null) {
String fireBrigadeId = relation.getFireBrigadeId();
for (VideoPlatformMeetingParticipantCO participant : participants) { for (VideoPlatformMeetingParticipantCO participant : participants) {
if (!Objects.equals(fireBrigadeId, participant.getFireBrigadeId())) { if (!Objects.equals(fireBrigadeId, participant.getFireBrigadeId())) {
continue; continue;
} }
if (Objects.equals(localUserId, participant.getLocalUserId())) { if (Objects.equals(localUserId, participant.getLocalUserId())) {
co.setAllowed(true); continue;
co.setOccupied(false);
co.setReason("当前用户已在会议中");
return SingleResponse.of(co);
} }
co.setAllowed(false); co.setAllowed(false);
co.setOccupied(true); co.setOccupied(true);
co.setOccupiedUserId(participant.getLocalUserId()); co.setOccupiedUserId(participant.getLocalUserId());
co.setOccupiedUserName(participant.getLocalUserName()); co.setOccupiedUserName(participant.getLocalUserName());
co.setOccupiedThirdUserName(participant.getThirdUserName()); co.setOccupiedThirdUserName(participant.getThirdUserName());
co.setReason("当前消防队伍已有成员在会议中"); co.setReason("当前消防队伍已有成员在会议中同队每次仅允许1人入会");
return SingleResponse.of(co); return SingleResponse.of(co);
} }
}
co.setAllowed(true); co.setAllowed(true);
co.setOccupied(false); co.setOccupied(false);
@ -330,6 +345,8 @@ public class VideoPlatformServiceImpl extends FireAlarmServiceSupport implements
co.setRoomId(context.roomId); co.setRoomId(context.roomId);
co.setRoomName(context.roomName); co.setRoomName(context.roomName);
co.setParticipantCount(participants.size()); co.setParticipantCount(participants.size());
co.setTotalCount(participants.size());
co.setMaxTotalCount(MAX_MEETING_TOTAL_COUNT);
co.setParticipants(participants); co.setParticipants(participants);
if (Boolean.FALSE.equals(qry.getIncludeLogs())) { if (Boolean.FALSE.equals(qry.getIncludeLogs())) {
co.setLogQuerySuccess(true); co.setLogQuerySuccess(true);
@ -417,7 +434,9 @@ public class VideoPlatformServiceImpl extends FireAlarmServiceSupport implements
private FireAlarmMeetingUserDO resolveCurrentMeetingUser(Long localUserId, boolean required) { private FireAlarmMeetingUserDO resolveCurrentMeetingUser(Long localUserId, boolean required) {
Long actualLocalUserId = localUserId == null ? currentUserId() : localUserId; Long actualLocalUserId = localUserId == null ? currentUserId() : localUserId;
FireAlarmMeetingUserDO meetingUser = actualLocalUserId == null ? null : fireAlarmMeetingUserRepository.getByLocalUserId(actualLocalUserId); FireAlarmMeetingUserDO meetingUser = actualLocalUserId == null ? null
: fireAlarmMeetingUserRepository.getByLocalUserId(actualLocalUserId,
fireAlarmUserResolver.resolveUserTenantId(actualLocalUserId));
if (required && meetingUser == null) { if (required && meetingUser == null) {
throw new BizException("当前用户未配置会议账号映射"); throw new BizException("当前用户未配置会议账号映射");
} }
@ -482,12 +501,37 @@ public class VideoPlatformServiceImpl extends FireAlarmServiceSupport implements
co.setLocalPhone(meetingUser == null ? null : meetingUser.getLocalPhone()); co.setLocalPhone(meetingUser == null ? null : meetingUser.getLocalPhone());
co.setFireBrigadeId(meetingUser == null ? null : meetingUser.getFireBrigadeId()); co.setFireBrigadeId(meetingUser == null ? null : meetingUser.getFireBrigadeId());
co.setFireBrigadeName(meetingUser == null ? null : meetingUser.getFireBrigadeName()); co.setFireBrigadeName(meetingUser == null ? null : meetingUser.getFireBrigadeName());
co.setUserType(meetingUser == null ? null : meetingUser.getUserType());
co.setUserTypeName(userTypeName(meetingUser == null ? null : meetingUser.getUserType()));
co.setCurrentUser(currentLocalUserId != null && Objects.equals(currentLocalUserId, co.getLocalUserId())); co.setCurrentUser(currentLocalUserId != null && Objects.equals(currentLocalUserId, co.getLocalUserId()));
result.add(co); result.add(co);
} }
return result; return result;
} }
private void fillMeetingCapacity(VideoPlatformMeetingAccessCheckCO co, List<VideoPlatformMeetingParticipantCO> participants) {
List<VideoPlatformMeetingParticipantCO> safeParticipants = participants == null ? Collections.emptyList() : participants;
co.setTotalCount(safeParticipants.size());
co.setMaxTotalCount(MAX_MEETING_TOTAL_COUNT);
}
private boolean isUserInMeeting(List<VideoPlatformMeetingParticipantCO> participants, Long localUserId) {
if (participants == null || localUserId == null) {
return false;
}
return participants.stream().anyMatch(item -> Objects.equals(localUserId, item.getLocalUserId()));
}
private String userTypeName(Integer userType) {
if (Integer.valueOf(1).equals(userType)) {
return "接警人";
}
if (Integer.valueOf(2).equals(userType)) {
return "报警人";
}
return null;
}
private List<VideoPlatformMeetingLogCO> buildRoomLogs(FixedRoomContext context, VideoPlatformMeetingMemberQry qry) { private List<VideoPlatformMeetingLogCO> buildRoomLogs(FixedRoomContext context, VideoPlatformMeetingMemberQry qry) {
Map<String, Object> requestBody = new LinkedHashMap<>(); Map<String, Object> requestBody = new LinkedHashMap<>();
requestBody.put("departId", resolveRoomLogDepartId(qry)); requestBody.put("departId", resolveRoomLogDepartId(qry));

View File

@ -24,4 +24,6 @@ public class VideoPlatformMeetingAccessCheckCO extends ClientObject {
private String occupiedUserName; private String occupiedUserName;
private String occupiedThirdUserName; private String occupiedThirdUserName;
private List<VideoPlatformMeetingParticipantCO> participants; private List<VideoPlatformMeetingParticipantCO> participants;
private Integer totalCount;
private Integer maxTotalCount;
} }

View File

@ -12,6 +12,8 @@ public class VideoPlatformMeetingMemberStatusCO extends ClientObject {
private String roomId; private String roomId;
private String roomName; private String roomName;
private Integer participantCount; private Integer participantCount;
private Integer totalCount;
private Integer maxTotalCount;
private List<VideoPlatformMeetingParticipantCO> participants; private List<VideoPlatformMeetingParticipantCO> participants;
private Boolean logQuerySuccess; private Boolean logQuerySuccess;
private String logQueryMsg; private String logQueryMsg;

View File

@ -12,5 +12,7 @@ public class VideoPlatformMeetingParticipantCO extends ClientObject {
private String localPhone; private String localPhone;
private String fireBrigadeId; private String fireBrigadeId;
private String fireBrigadeName; private String fireBrigadeName;
private Integer userType;
private String userTypeName;
private Boolean currentUser; private Boolean currentUser;
} }