| | |
| | | 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.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; |
| | |
| | | |
| | | private final MeetingMinutesMapper meetingMinutesMapper; |
| | | private final SysUserMapper userMapper; |
| | | private final SysPostMapper sysPostMapper; |
| | | private final ISysNoticeService sysNoticeService; |
| | | |
| | | |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |
| | | |
| | | |