| | |
| | | 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.github.xiaoymin.knife4j.core.util.StrUtil; |
| | | import com.ruoyi.approve.pojo.ApproveProcess; |
| | | import com.ruoyi.collaborativeApproval.dto.MeetSummaryDto; |
| | | import com.ruoyi.collaborativeApproval.dto.MeetUseDto; |
| | | import com.ruoyi.collaborativeApproval.dto.MeetingItem; |
| | |
| | | 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.SysPost; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.project.system.mapper.SysPostMapper; |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import com.ruoyi.project.system.service.ISysNoticeService; |
| | | import com.ruoyi.staff.mapper.StaffOnJobMapper; |
| | | 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; |
| | |
| | | |
| | | private final MeetingMinutesMapper meetingMinutesMapper; |
| | | private final SysUserMapper userMapper; |
| | | private final SysPostMapper sysPostMapper; |
| | | private final ISysNoticeService sysNoticeService; |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | @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); |
| | | } |
| | | |
| | |
| | | if (!userIds.isEmpty()) { |
| | | sysNoticeService.simpleNoticeByUser( |
| | | "会议通知", |
| | | "会议主题:" + application.getTitle() + "\n" + |
| | | "会议时间:" + application.getStartTime() + "-" + application.getEndTime() + "\n" + |
| | | "会议主题:" + application.getTitle() + "\t" + |
| | | "会议时间:" + application.getStartTime() + "-" + application.getEndTime() + "\t" + |
| | | "发起人:" + application.getApplicant(), |
| | | userIds, |
| | | "" |
| | |
| | | .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); |
| | |
| | | public List<MeetingSimpleDto> getMeetSummaryItems() { |
| | | return meetApplicationMapper.getMeetSummaryItems(); |
| | | } |
| | | |
| | | @Override |
| | | public List<ApproveProcess> getUpcomingMeetingReminders() { |
| | | List<ApproveProcess> reminders = new ArrayList<>(); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | List<MeetApplication> meetings = meetApplicationMapper.selectList( |
| | | Wrappers.<MeetApplication>lambdaQuery() |
| | | .eq(MeetApplication::getPublishStatus, 1) |
| | | .gt(MeetApplication::getStartTime, now) |
| | | .le(MeetApplication::getStartTime, now.plusHours(1)) |
| | | .orderByAsc(MeetApplication::getStartTime)); |
| | | if (meetings == null || meetings.isEmpty()) { |
| | | return reminders; |
| | | } |
| | | Long currentUserId = SecurityUtils.getLoginUser().getUserId(); |
| | | Map<Integer, SysPost> postCache = new HashMap<>(); |
| | | for (MeetApplication meeting : meetings) { |
| | | if (meeting.getStartTime() == null) { |
| | | continue; |
| | | } |
| | | List<Long> staffIds = parseParticipantStaffIds(meeting.getParticipants()); |
| | | if (staffIds.isEmpty()) { |
| | | continue; |
| | | } |
| | | List<StaffOnJob> staffs = staffOnJobMapper.selectBatchIds(staffIds); |
| | | Map<Long, StaffOnJob> staffMap = (staffs == null) ? new HashMap<>() |
| | | : staffs.stream().collect(Collectors.toMap(StaffOnJob::getId, s -> s, (a, b) -> a)); |
| | | boolean isParticipant = false; |
| | | List<String> participantNames = new ArrayList<>(); |
| | | for (Long staffId : staffIds) { |
| | | StaffOnJob staff = staffMap.get(staffId); |
| | | if (staff == null) { |
| | | continue; |
| | | } |
| | | String display = staff.getStaffName() == null ? "" : staff.getStaffName(); |
| | | if (staff.getSysPostId() != null) { |
| | | SysPost post = postCache.get(staff.getSysPostId()); |
| | | if (post == null) { |
| | | post = sysPostMapper.selectPostById(staff.getSysPostId().longValue()); |
| | | if (post != null) { |
| | | postCache.put(staff.getSysPostId(), post); |
| | | } |
| | | } |
| | | if (post != null && post.getPostName() != null && !post.getPostName().isEmpty()) { |
| | | display = display + " (" + post.getPostName() + ")"; |
| | | } |
| | | } |
| | | if (!display.isEmpty()) { |
| | | participantNames.add(display); |
| | | } |
| | | if (!isParticipant && staff.getStaffNo() != null) { |
| | | SysUser user = userMapper.selectOne( |
| | | Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUserName, staff.getStaffNo())); |
| | | if (user != null && currentUserId.equals(user.getUserId())) { |
| | | isParticipant = true; |
| | | } |
| | | } |
| | | } |
| | | if (!isParticipant) { |
| | | continue; |
| | | } |
| | | String roomName = "会议"; |
| | | if (meeting.getRoomId() != null) { |
| | | MeetingRoom room = meetingRoomMapper.selectById(meeting.getRoomId()); |
| | | if (room != null && room.getName() != null && !room.getName().isEmpty()) { |
| | | roomName = room.getName(); |
| | | } |
| | | } |
| | | ApproveProcess ap = new ApproveProcess(); |
| | | ap.setId(100000000L + meeting.getId()); |
| | | ap.setApproveId("会议提醒"); |
| | | ap.setApproveDeptName(roomName); |
| | | String reason = "会议《" + meeting.getTitle() + "》将于 " |
| | | + meeting.getStartTime().format(DateTimeFormatter.ofPattern("HH:mm")) + " 开始"; |
| | | if (!participantNames.isEmpty()) { |
| | | reason += ";参会人员:" + String.join("、", participantNames); |
| | | } |
| | | ap.setApproveReason(reason); |
| | | ap.setApproveUserName(meeting.getApplicant()); |
| | | ap.setApproveTime(java.sql.Timestamp.valueOf(meeting.getStartTime())); |
| | | ap.setApproveTypeName("会议提醒"); |
| | | reminders.add(ap); |
| | | } |
| | | return reminders; |
| | | } |
| | | |
| | | private List<Long> parseParticipantStaffIds(String participants) { |
| | | List<Long> ids = new ArrayList<>(); |
| | | if (participants == null || participants.trim().isEmpty()) { |
| | | return ids; |
| | | } |
| | | String cleanStr = participants.replaceAll("^\\[|\\]$", "").trim(); |
| | | if (cleanStr.isEmpty()) { |
| | | return ids; |
| | | } |
| | | for (String s : cleanStr.split(",")) { |
| | | String val = s.trim(); |
| | | if (val.isEmpty()) { |
| | | continue; |
| | | } |
| | | try { |
| | | ids.add(Long.valueOf(val)); |
| | | } catch (NumberFormatException ignored) { |
| | | } |
| | | } |
| | | return ids; |
| | | } |
| | | |
| | | } |
| | | |
| | | |