| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.ruoyi.collaborativeApproval.vo.SearchMeetingDraftVo; |
| | | import com.ruoyi.collaborativeApproval.vo.SearchMeetingRoomVo; |
| | | import com.ruoyi.collaborativeApproval.vo.SearchMeetingUseVo; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | |
| | | import com.ruoyi.staff.pojo.StaffOnJob; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteMeetingRoom(Long id) { |
| | | if (id == null){ |
| | | throw new ServiceException("删除会议室失败,会议室ID不能为空"); |
| | | } |
| | | |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | List<MeetApplication> meetApplicationList = meetApplicationMapper.selectList(Wrappers.<MeetApplication>lambdaQuery() |
| | | .eq(MeetApplication::getRoomId, id) |
| | | .gt(MeetApplication::getEndTime, now) |
| | | .in(MeetApplication::getStatus, Arrays.asList(0, 1))); |
| | | |
| | | if (!meetApplicationList.isEmpty()){ |
| | | throw new ServiceException("删除会议室失败,该会议室尚有未开始或进行中的有效会议预约"); |
| | | } |
| | | |
| | | meetingRoomMapper.deleteById(id); |
| | | } |
| | | |
| | |
| | | //参会人员id(人员台账和用户表通过人员编号和用户名称(登录账号)做匹配) |
| | | if (Integer.valueOf(1).equals(meetApplication.getPublishStatus())) { |
| | | MeetApplication application = meetApplicationMapper.selectById(meetApplication.getId()); |
| | | |
| | | String cleanStr = application.getParticipants() |
| | | .replaceAll("^\\[|\\]$", "") |
| | | .trim(); |
| | | |
| | | List<Long> userIds = Arrays.stream(cleanStr.split(",")) |
| | | .map(String::trim) |
| | | .filter(s -> !s.isEmpty()) |
| | | .map(Long::valueOf) |
| | | .map(staffId -> { |
| | | StaffOnJob record = staffOnJobMapper.selectById(staffId); |
| | | if (record == null) { |
| | | return null; |
| | | } |
| | | return userMapper.selectOne( |
| | | Wrappers.<SysUser>lambdaQuery() |
| | | .eq(SysUser::getUserName, record.getStaffNo()) |
| | | ); |
| | | }) |
| | | .filter(Objects::nonNull) |
| | | .map(SysUser::getUserId) |
| | | .collect(Collectors.toList()); |
| | | List<Long> userIds = resolveParticipantUserIds(application.getParticipants()); |
| | | |
| | | if (!userIds.isEmpty()) { |
| | | sysNoticeService.simpleNoticeByUser( |
| | | "会议通知", |
| | | "会议主题:" + application.getTitle() + "\n" + |
| | | "会议时间:" + application.getStartTime() + "-" + application.getEndTime() + "\n" + |
| | | "会议主题:" + application.getTitle() + "\t" + |
| | | "会议时间:" + application.getStartTime() + "-" + application.getEndTime() + "\t" + |
| | | "发起人:" + application.getApplicant(), |
| | | userIds, |
| | | "" |
| | |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | // 参会人员台账id -> 登录用户id;同一登录账号在 sys_user 存在多条历史记录时,按未删除优先取一条,避免 selectOne 抛 TooManyResultsException |
| | | private List<Long> resolveParticipantUserIds(String participants) { |
| | | if (StrUtil.isBlank(participants)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | String cleanStr = participants.replaceAll("^\\[|\\]$", "").trim(); |
| | | if (cleanStr.isEmpty()) { |
| | | return Collections.emptyList(); |
| | | } |
| | | List<Long> staffIds = Arrays.stream(cleanStr.split(",")) |
| | | .map(String::trim) |
| | | .filter(s -> !s.isEmpty()) |
| | | .map(Long::valueOf) |
| | | .collect(Collectors.toList()); |
| | | if (staffIds.isEmpty()) { |
| | | return Collections.emptyList(); |
| | | } |
| | | List<String> loginNames = staffOnJobMapper.selectBatchIds(staffIds).stream() |
| | | .map(StaffOnJob::getStaffNo) |
| | | .filter(StrUtil::isNotBlank) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | if (loginNames.isEmpty()) { |
| | | return Collections.emptyList(); |
| | | } |
| | | return userMapper.selectList(Wrappers.<SysUser>lambdaQuery() |
| | | .in(SysUser::getUserName, loginNames) |
| | | .orderByAsc(SysUser::getDelFlag) |
| | | .orderByAsc(SysUser::getUserId)) |
| | | .stream() |
| | | .collect(Collectors.toMap(SysUser::getUserName, SysUser::getUserId, |
| | | (first, ignored) -> first, LinkedHashMap::new)) |
| | | .values() |
| | | .stream() |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | .or() |
| | | .eq(MeetApplication::getApplicationType, "notification"); |
| | | }); |
| | | if (Objects.nonNull(vo.getMeetingDate())) { |
| | | if (Objects.nonNull(vo.getDate())) { |
| | | alWrapper.and(wrapper -> { |
| | | wrapper.eq(MeetApplication::getMeetingDate, vo.getMeetingDate()); |
| | | wrapper.eq(MeetApplication::getMeetingDate, vo.getDate()); |
| | | }); |
| | | } |
| | | alWrapper.orderByAsc(MeetApplication::getStartTime); |