|  |  |  | 
|---|
|  |  |  | package com.doumee.service.business.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.Wrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.doumee.core.utils.DESUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.DateUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.Utils; | 
|---|
|  |  |  | import com.doumee.core.wx.MeetConstants; | 
|---|
|  |  |  | import com.doumee.core.wx.SendWxMessage; | 
|---|
|  |  |  | import com.doumee.dao.admin.request.BusinessOverDTO; | 
|---|
|  |  |  | import com.doumee.dao.admin.request.QrOpenDoorDto; | 
|---|
|  |  |  | import com.doumee.dao.admin.response.DevWgResponseParam; | 
|---|
|  |  |  | import com.doumee.dao.business.*; | 
|---|
|  |  |  | import com.doumee.dao.business.join.*; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.RoomStatisticsVo; | 
|---|
|  |  |  | import com.doumee.dao.system.MultifileMapper; | 
|---|
|  |  |  | import com.doumee.dao.system.SystemUserMapper; | 
|---|
|  |  |  | import com.doumee.dao.system.dto.UserStatisticsDTO; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemDepartment; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemDepartmentUser; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemUser; | 
|---|
|  |  |  | import com.doumee.dao.system.vo.RoomStatisticsVo; | 
|---|
|  |  |  | import com.doumee.dao.system.join.NoticesJoinMapper; | 
|---|
|  |  |  | import com.doumee.dao.system.model.*; | 
|---|
|  |  |  | import com.doumee.dao.system.vo.UserResponse; | 
|---|
|  |  |  | import com.doumee.dao.system.vo.UserStatisticsVo; | 
|---|
|  |  |  | import com.doumee.dao.web.request.BookingsRequest; | 
|---|
|  |  |  | import com.doumee.dao.web.request.MeetingPageRequest; | 
|---|
|  |  |  | import com.doumee.dao.web.request.UserPageRequest; | 
|---|
|  |  |  | import com.doumee.dao.web.response.*; | 
|---|
|  |  |  | import com.doumee.service.business.*; | 
|---|
|  |  |  | import com.doumee.service.business.BookingsService; | 
|---|
|  |  |  | import com.doumee.service.business.DevicesService; | 
|---|
|  |  |  | import com.doumee.service.business.ProjectsService; | 
|---|
|  |  |  | import com.doumee.service.system.SystemUserService; | 
|---|
|  |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.awt.print.Book; | 
|---|
|  |  |  | import java.text.SimpleDateFormat; | 
|---|
|  |  |  | import java.time.LocalTime; | 
|---|
|  |  |  | import java.time.format.DateTimeFormatter; | 
|---|
|  |  |  | import java.time.temporal.TemporalAdjusters; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  | import java.time.LocalDate; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.time.format.DateTimeFormatter; | 
|---|
|  |  |  | import java.time.temporal.TemporalAdjusters; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | private SystemUserMapper systemUserMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RoomRecordMapper roomRecordMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BookingsJoinMapper bookingsJoinMapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | private MultifileMapper multifileMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NoticeService noticeService; | 
|---|
|  |  |  | private NoticesJoinMapper noticesMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UserRelMapper userRelMapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class, Exception.class}) | 
|---|
|  |  |  | public Integer create(Bookings bookings) { | 
|---|
|  |  |  | LoginUserInfo user = new LoginUserInfo(); | 
|---|
|  |  |  | user.setId(bookings.getCreator()); | 
|---|
|  |  |  | LoginUserInfo user = bookings.getLoginUserInfo(); | 
|---|
|  |  |  | isCreateParamValid(bookings, user); | 
|---|
|  |  |  | bookings.setCreateDate(new Date()); | 
|---|
|  |  |  | bookings.setCreator(user.getId()); | 
|---|
|  |  |  | bookings.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | bookings.setStatus(Constants.ZERO); | 
|---|
|  |  |  | bookings.setIsdeleted(MeetConstants.ZERO); | 
|---|
|  |  |  | bookings.setStatus(MeetConstants.ZERO); | 
|---|
|  |  |  | bookingsMapper.insert(bookings); | 
|---|
|  |  |  | //更新会议室预定时间段 | 
|---|
|  |  |  | updateBookingTimes(bookings, user); | 
|---|
|  |  |  | 
|---|
|  |  |  | updateProjectRel(bookings, user); | 
|---|
|  |  |  | handleFile(bookings, user); | 
|---|
|  |  |  | //发送会议预约成功通知 | 
|---|
|  |  |  | this.sendNotice(bookings, Constants.TWO); | 
|---|
|  |  |  | this.sendNotice(bookings, MeetConstants.TWO); | 
|---|
|  |  |  | //发送微信订阅通知 | 
|---|
|  |  |  | sendWxMessage.bookingsReservation(systemUserMapper.selectById(bookings.getCreator()), bookings, roomsMapper.selectById(bookings.getRoomId())); | 
|---|
|  |  |  | //        sendWxMessage.bookingsReservation(systemUserMapper.selectById(bookings.getCreator()), bookings, roomsMapper.selectById(bookings.getRoomId())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return bookings.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void handleFile(Bookings bookings, LoginUserInfo user) { | 
|---|
|  |  |  | QueryWrapper<Multifile> bookquery = new QueryWrapper<>(); | 
|---|
|  |  |  | bookquery.lambda().eq(Multifile::getIsdeleted, Constants.ZERO); | 
|---|
|  |  |  | bookquery.lambda().eq(Multifile::getIsdeleted, MeetConstants.ZERO); | 
|---|
|  |  |  | bookquery.lambda().eq(Multifile::getObjId, bookings.getId()); | 
|---|
|  |  |  | multifileJoinMapper.delete(bookquery); | 
|---|
|  |  |  | if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(bookings.getFileList())) { | 
|---|
|  |  |  | bookings.getFileList().stream().forEach(s -> { | 
|---|
|  |  |  | s.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | s.setIsdeleted(MeetConstants.ZERO); | 
|---|
|  |  |  | s.setCreateDate(new Date()); | 
|---|
|  |  |  | s.setCreator(user.getId()); | 
|---|
|  |  |  | s.setObjId(bookings.getId()); | 
|---|
|  |  |  | s.setType(Constants.TWO); | 
|---|
|  |  |  | s.setObjType(Constants.ZERO); | 
|---|
|  |  |  | s.setType(MeetConstants.TWO); | 
|---|
|  |  |  | s.setObjType(MeetConstants.ZERO); | 
|---|
|  |  |  | multifileJoinMapper.insert(s); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | bookquery.selectAll(Bookings.class); | 
|---|
|  |  |  | bookquery.selectAs(BookingTime::getTimeId, Bookings::getRoomTimeId); | 
|---|
|  |  |  | bookquery.selectAs(BookingTime::getId, Bookings::getBookingTimeId); | 
|---|
|  |  |  | bookquery.eq(Bookings::getIsdeleted, Constants.ZERO); | 
|---|
|  |  |  | bookquery.eq(Bookings::getIsdeleted, MeetConstants.ZERO); | 
|---|
|  |  |  | bookquery.eq(BookingTime::getIsdeleted, MeetConstants.ZERO); | 
|---|
|  |  |  | bookquery.eq(Bookings::getRoomId, bookings.getRoomId()); | 
|---|
|  |  |  | bookquery.eq(Bookings::getStatus, Constants.ZERO); | 
|---|
|  |  |  | bookquery.eq(Bookings::getStatus, MeetConstants.ZERO); | 
|---|
|  |  |  | //bookquery.ge(Bookings::getStartTime, bookings.getStartTime()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bookquery.apply(" t.START_TIME like  '" + DateUtil.dateToString(bookings.getStartTime(), "yyyy-MM-dd") + "%'  "); | 
|---|
|  |  |  | 
|---|
|  |  |  | List<Bookings> bookList = bookingsJoinMapper.selectJoinList(Bookings.class, bookquery); | 
|---|
|  |  |  | for (int i = 0; i < bookings.getBookingTimeList().size(); i++) { | 
|---|
|  |  |  | BookingTime s = bookings.getBookingTimeList().get(i); | 
|---|
|  |  |  | if (!Objects.isNull(bookList) && bookList.size() > Constants.ZERO) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | RoomTime roomTime = roomTimeJoinMapper.selectById(s.getTimeId()); | 
|---|
|  |  |  | if(Objects.isNull(roomTime)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"存在未查询到的配置日期,请刷新重试"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String endRoomTime = gsDate + " " + roomTime.getEndTime()+":00"; | 
|---|
|  |  |  | if(DateUtil.StringToDate(endRoomTime, "yyyy-MM-dd HH:mm:ss").getTime()<=System.currentTimeMillis()){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),endRoomTime + "已超过当前时间,无法进行预约"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Objects.isNull(bookList) && bookList.size() > MeetConstants.ZERO) { | 
|---|
|  |  |  | List<Bookings> detailDataDtoStream = | 
|---|
|  |  |  | bookList.stream().filter(a -> Constants.equalsInteger(s.getTimeId(), a.getRoomTimeId()) | 
|---|
|  |  |  | bookList.stream().filter(a -> MeetConstants.equalsInteger(s.getTimeId(), a.getRoomTimeId()) | 
|---|
|  |  |  | ).collect(Collectors.toList()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (detailDataDtoStream.size() > 0) { | 
|---|
|  |  |  | 
|---|
|  |  |  | //编辑 | 
|---|
|  |  |  | List<Bookings> chriList = | 
|---|
|  |  |  | detailDataDtoStream.stream() | 
|---|
|  |  |  | .filter(a -> !Constants.equalsInteger(a.getId(), bookings.getId())) | 
|---|
|  |  |  | .filter(a -> Constants.equalsInteger(a.getRoomTimeId(), s.getTimeId())) | 
|---|
|  |  |  | .filter(a -> !MeetConstants.equalsInteger(a.getId(), bookings.getId())) | 
|---|
|  |  |  | .filter(a -> MeetConstants.equalsInteger(a.getRoomTimeId(), s.getTimeId())) | 
|---|
|  |  |  | .collect(Collectors.toList()); | 
|---|
|  |  |  | if (chriList.size() > 0) { | 
|---|
|  |  |  | RoomTime roomTime = roomTimeJoinMapper.selectById(s.getTimeId()); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "该会议:" + roomTime.getStartTime() + "-" + roomTime.getEndTime() + "时间段内已被使用"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | //插入 | 
|---|
|  |  |  | List<Bookings> chriList = | 
|---|
|  |  |  | detailDataDtoStream.stream() | 
|---|
|  |  |  | .filter(a -> Constants.equalsInteger(a.getRoomTimeId(), s.getTimeId())) | 
|---|
|  |  |  | .filter(a -> MeetConstants.equalsInteger(a.getRoomTimeId(), s.getTimeId())) | 
|---|
|  |  |  | .collect(Collectors.toList()); | 
|---|
|  |  |  | if (chriList.size() > 0) { | 
|---|
|  |  |  | RoomTime roomTime = roomTimeJoinMapper.selectById(s.getTimeId()); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "该会议:" + roomTime.getStartTime() + "-" + roomTime.getEndTime() + "时间段内已被使用"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void updateBookingTimes(Bookings bookings, LoginUserInfo user) { | 
|---|
|  |  |  | QueryWrapper<BookingTime> updateWrapper = new QueryWrapper<BookingTime>(); | 
|---|
|  |  |  | updateWrapper.eq("ISDELETED", Constants.ZERO); | 
|---|
|  |  |  | updateWrapper.eq("ISDELETED", MeetConstants.ZERO); | 
|---|
|  |  |  | updateWrapper.eq("BOOKING_ID", bookings.getId()); | 
|---|
|  |  |  | BookingTime bookingTime = new BookingTime(); | 
|---|
|  |  |  | bookingTime.setIsdeleted(Constants.ONE); | 
|---|
|  |  |  | bookingTime.setIsdeleted(MeetConstants.ONE); | 
|---|
|  |  |  | bookingTimeJoinMapper.update(bookingTime, updateWrapper); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bookings.getBookingTimeList().stream().forEach(s -> { | 
|---|
|  |  |  | s.setId(null); | 
|---|
|  |  |  | s.setCreator(user.getId()); | 
|---|
|  |  |  | s.setCreateDate(new Date()); | 
|---|
|  |  |  | s.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | s.setIsdeleted(MeetConstants.ZERO); | 
|---|
|  |  |  | s.setBookingId(bookings.getId()); | 
|---|
|  |  |  | bookingTimeJoinMapper.insert(s); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void updateManager(Bookings bookings, LoginUserInfo user) { | 
|---|
|  |  |  | if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(bookings.getSysList())) { | 
|---|
|  |  |  | QueryWrapper<UserRel> updateWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | updateWrapper.lambda().eq(UserRel::getIsdeleted, Constants.ZERO); | 
|---|
|  |  |  | updateWrapper.lambda().eq(UserRel::getIsdeleted, MeetConstants.ZERO); | 
|---|
|  |  |  | updateWrapper.lambda().eq(UserRel::getObjId, bookings.getId()); | 
|---|
|  |  |  | updateWrapper.lambda().eq(UserRel::getObjType, Constants.ONE); | 
|---|
|  |  |  | updateWrapper.lambda().eq(UserRel::getObjType, MeetConstants.ONE); | 
|---|
|  |  |  | UserRel userRel = new UserRel(); | 
|---|
|  |  |  | userRel.setIsdeleted(Constants.ONE); | 
|---|
|  |  |  | userRel.setIsdeleted(MeetConstants.ONE); | 
|---|
|  |  |  | userRelJoinMapper.update(userRel, updateWrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | bookings.getSysList().stream().forEach(s -> { | 
|---|
|  |  |  | s.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | s.setCreateDate(new Date()); | 
|---|
|  |  |  | s.setCreator(user.getId()); | 
|---|
|  |  |  | s.setUserId(s.getUserId()); | 
|---|
|  |  |  | s.setObjId(bookings.getId()); | 
|---|
|  |  |  | s.setObjType(Constants.ONE); | 
|---|
|  |  |  | userRelJoinMapper.insert(s); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(bookings.getSysList())){ | 
|---|
|  |  |  | bookings.getSysList().stream().forEach(s -> { | 
|---|
|  |  |  | s.setId(null); | 
|---|
|  |  |  | s.setIsdeleted(MeetConstants.ZERO); | 
|---|
|  |  |  | s.setCreateDate(new Date()); | 
|---|
|  |  |  | s.setCreator(user.getId()); | 
|---|
|  |  |  | s.setUserId(s.getUserId()); | 
|---|
|  |  |  | s.setObjId(bookings.getId()); | 
|---|
|  |  |  | s.setObjType(MeetConstants.ONE); | 
|---|
|  |  |  | userRelJoinMapper.insert(s); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void updateProjectRel(Bookings rooms, LoginUserInfo user) { | 
|---|
|  |  |  | if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(rooms.getProjectList())) { | 
|---|
|  |  |  | QueryWrapper<ProjectRel> updateWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | updateWrapper.lambda().eq(ProjectRel::getIsdeleted, Constants.ZERO); | 
|---|
|  |  |  | updateWrapper.lambda().eq(ProjectRel::getIsdeleted, MeetConstants.ZERO); | 
|---|
|  |  |  | updateWrapper.lambda().eq(ProjectRel::getObjId, rooms.getId()); | 
|---|
|  |  |  | updateWrapper.lambda().eq(ProjectRel::getObjType, Constants.ONE); | 
|---|
|  |  |  | updateWrapper.lambda().eq(ProjectRel::getObjType, MeetConstants.ONE); | 
|---|
|  |  |  | ProjectRel projectRel = new ProjectRel(); | 
|---|
|  |  |  | projectRel.setIsdeleted(Constants.ONE); | 
|---|
|  |  |  | projectRel.setIsdeleted(MeetConstants.ONE); | 
|---|
|  |  |  | projectRelJoinMapper.update(projectRel, updateWrapper); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | rooms.getProjectList().stream().forEach(s -> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | s.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | s.setId(null); | 
|---|
|  |  |  | s.setIsdeleted(MeetConstants.ZERO); | 
|---|
|  |  |  | s.setCreateDate(new Date()); | 
|---|
|  |  |  | s.setCreator(user.getId()); | 
|---|
|  |  |  | s.setProjectId(s.getProjectId()); | 
|---|
|  |  |  | s.setObjId(rooms.getId()); | 
|---|
|  |  |  | s.setObjType(Constants.ONE); | 
|---|
|  |  |  | s.setObjType(MeetConstants.ONE); | 
|---|
|  |  |  | projectRelJoinMapper.insert(s); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void deleteById(Integer id) { | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | public void deleteById(Integer id,LoginUserInfo user) { | 
|---|
|  |  |  | Bookings bookings = new Bookings(); | 
|---|
|  |  |  | bookings.setId(id); | 
|---|
|  |  |  | bookings.setIsdeleted(Constants.ONE); | 
|---|
|  |  |  | bookings.setIsdeleted(MeetConstants.ONE); | 
|---|
|  |  |  | bookings.setEditDate(new Date()); | 
|---|
|  |  |  | bookings.setEditor(user.getId()); | 
|---|
|  |  |  | bookingsMapper.updateById(bookings); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void delete(Bookings bookings) { | 
|---|
|  |  |  | public void delete(Bookings bookings,LoginUserInfo user) { | 
|---|
|  |  |  | UpdateWrapper<Bookings> deleteWrapper = new UpdateWrapper<>(bookings); | 
|---|
|  |  |  | bookingsMapper.delete(deleteWrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void deleteByIdInBatch(List<Integer> ids) { | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | public void deleteByIdInBatch(List<Integer> ids,LoginUserInfo user) { | 
|---|
|  |  |  | if (CollectionUtils.isEmpty(ids)) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "会议已开始,无法删除"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | bookings.setId(s); | 
|---|
|  |  |  | bookings.setIsdeleted(Constants.ONE); | 
|---|
|  |  |  | bookings.setIsdeleted(MeetConstants.ONE); | 
|---|
|  |  |  | bookings.setEditDate(new Date()); | 
|---|
|  |  |  | bookings.setEditor(user.getId()); | 
|---|
|  |  |  | bookingsMapper.updateById(bookings); | 
|---|
|  |  |  | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class, Exception.class}) | 
|---|
|  |  |  | public void updateById(Bookings bookings) { | 
|---|
|  |  |  | Bookings dbBookings = bookingsMapper.selectById(bookings.getId()); | 
|---|
|  |  |  | if(dbBookings.getStatus().equals(Constants.ONE)){ | 
|---|
|  |  |  | if(dbBookings.getStatus().equals(MeetConstants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "本次操作失败,预约状态已流转"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | LoginUserInfo user = new LoginUserInfo(); | 
|---|
|  |  |  | user.setId(bookings.getCreator()); | 
|---|
|  |  |  | LoginUserInfo user = bookings.getLoginUserInfo(); | 
|---|
|  |  |  | isCreateParamValid(bookings, user); | 
|---|
|  |  |  | bookings.setEditDate(new Date()); | 
|---|
|  |  |  | bookings.setEditor(user.getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | updateProjectRel(bookings, user); | 
|---|
|  |  |  | handleFile(bookings, user); | 
|---|
|  |  |  | //发送会议通知 | 
|---|
|  |  |  | this.sendNotice(bookings, Constants.TWO); | 
|---|
|  |  |  | this.sendNotice(bookings, MeetConstants.TWO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void cancelById(Bookings bs) { | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | if(user == null){ | 
|---|
|  |  |  | user = bs.getLoginUserInfo(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | if(Objects.isNull(bookings)||bookings.getId()==null){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage()); | 
|---|
|  |  |  | 
|---|
|  |  |  | if(Objects.isNull(query)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), ResponseStatus.DATA_EMPTY.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(query.getStatus(),Constants.ONE)){ | 
|---|
|  |  |  | if(MeetConstants.equalsInteger(query.getStatus(),MeetConstants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "状态已流转,禁止操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (System.currentTimeMillis() > query.getStartTime().getTime()) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | bookings.setCancelTime(new Date()); | 
|---|
|  |  |  | bookings.setCancelUser(user.getId()); | 
|---|
|  |  |  | bookings.setStatus(Constants.ONE); | 
|---|
|  |  |  | bookings.setStatus(MeetConstants.ONE); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bookings.setEditDate(new Date()); | 
|---|
|  |  |  | bookings.setEditor(user.getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (System.currentTimeMillis() > bookings.getStartTime().getTime()) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "会议已开始,无法进行取消"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(bookings.getStatus().equals(Constants.ONE)){ | 
|---|
|  |  |  | if(bookings.getStatus().equals(MeetConstants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "本次操作失败,预约状态已流转"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | bookings.setCancelTime(new Date()); | 
|---|
|  |  |  | bookings.setCancelUser(user.getId()); | 
|---|
|  |  |  | bookings.setStatus(Constants.ONE); | 
|---|
|  |  |  | bookings.setStatus(MeetConstants.ONE); | 
|---|
|  |  |  | bookings.setEditDate(new Date()); | 
|---|
|  |  |  | bookings.setEditor(user.getId()); | 
|---|
|  |  |  | bookingsMapper.updateById(bookings); | 
|---|
|  |  |  | 
|---|
|  |  |  | queryWrapper.selectAll(Bookings.class); | 
|---|
|  |  |  | queryWrapper.selectAs(Rooms::getName, Bookings::getRoomName); | 
|---|
|  |  |  | queryWrapper.selectAs(SystemUser::getRealname, Bookings::getRealName); | 
|---|
|  |  |  | queryWrapper.selectAs(SystemDepartment::getName, Bookings::getDepartmentName); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | queryWrapper.selectAs(Company::getName, Bookings::getDepartmentName); | 
|---|
|  |  |  | queryWrapper.select(" CASE WHEN t.START_TIME_REAL IS NULL AND t.`STATUS` = 0 THEN 1  WHEN ( ( t.END_TIME < now()  AND t.`STATUS` = 0 ) or t.`STATUS` = 2 ) THEN 3 WHEN t.`STATUS` = 1 THEN 5 ELSE  2  END meetingStatus "); | 
|---|
|  |  |  | queryWrapper.leftJoin(Rooms.class, Rooms::getId, Bookings::getRoomId); | 
|---|
|  |  |  | queryWrapper.leftJoin(SystemUser.class, SystemUser::getId, Bookings::getCreator); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | queryWrapper.leftJoin(SystemDepartmentUser.class, SystemDepartmentUser::getUserId, Bookings::getCreator); | 
|---|
|  |  |  | queryWrapper.leftJoin(SystemDepartment.class, SystemDepartment::getId, SystemDepartmentUser::getDepartmentId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | queryWrapper.leftJoin(Company.class,Company::getId,SystemUser::getCompanyId); | 
|---|
|  |  |  | queryWrapper.orderByDesc(Bookings::getCreateDate); | 
|---|
|  |  |  | queryWrapper.eq(Bookings::getIsdeleted, Constants.ZERO); | 
|---|
|  |  |  | queryWrapper.eq(Bookings::getIsdeleted, MeetConstants.ZERO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | queryWrapper.eq(pageWrap.getModel().getRoomId() != null, Bookings::getRoomId, pageWrap.getModel().getRoomId()); | 
|---|
|  |  |  | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getName()), Bookings::getName, pageWrap.getModel().getName()); | 
|---|
|  |  |  | queryWrapper.eq(pageWrap.getModel().getStatus() != null, Bookings::getStatus, pageWrap.getModel().getStatus()); | 
|---|
|  |  |  | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getRealName()), SystemUser::getRealname, pageWrap.getModel().getRealName()); | 
|---|
|  |  |  | queryWrapper.eq(pageWrap.getModel().getDepartmentId() != null, SystemDepartment::getId, pageWrap.getModel().getDepartmentId()); | 
|---|
|  |  |  | queryWrapper.eq(pageWrap.getModel().getDepartmentId() != null, Company::getId, pageWrap.getModel().getDepartmentId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | queryWrapper.apply(Objects.nonNull(pageWrap.getModel().getMeetingStatus()) | 
|---|
|  |  |  | &&Constants.equalsInteger(pageWrap.getModel().getMeetingStatus(),Constants.ONE), | 
|---|
|  |  |  | " ( now() < t.START_TIME and t.status = 0 ) " | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .apply(Objects.nonNull(pageWrap.getModel().getMeetingStatus()) | 
|---|
|  |  |  | &&Constants.equalsInteger(pageWrap.getModel().getMeetingStatus(),Constants.TWO), | 
|---|
|  |  |  | " ( now() >= t.START_TIME and t.END_TIME >= now() and t.status = 0 ) " | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .apply(Objects.nonNull(pageWrap.getModel().getMeetingStatus()) | 
|---|
|  |  |  | &&Constants.equalsInteger(pageWrap.getModel().getMeetingStatus(),Constants.THREE), | 
|---|
|  |  |  | " ( ( now() > t.END_TIME  and  t.`STATUS` = 0  ) or   t.`STATUS` = 2  )  " | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .apply(Objects.nonNull(pageWrap.getModel().getMeetingStatus()) | 
|---|
|  |  |  | &&Constants.equalsInteger(pageWrap.getModel().getMeetingStatus(),Constants.FOUR), | 
|---|
|  |  |  | " now() < t.START_TIME  AND SUBDATE( t.START_TIME, INTERVAL 120 MINUTE ) < NOW() " | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .apply(Objects.nonNull(pageWrap.getModel().getMeetingStatus()) | 
|---|
|  |  |  | &&Constants.equalsInteger(pageWrap.getModel().getMeetingStatus(),Constants.FIVE), | 
|---|
|  |  |  | " t.STATUS = 1  " | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (pageWrap.getModel().getStartTime() != null) { | 
|---|
|  |  |  | queryWrapper.ge(Bookings::getStartTime, pageWrap.getModel().getStartTime()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | queryWrapper.orderByDesc(Bookings::getCreateDate); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() + systemDictDataBiz.queryByCode(Constants.OSS, Constants.PROJECTS).getCode(); | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.FTP_RESOURCE_PATH).getCode() + systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.PROJECTS).getCode(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm"); | 
|---|
|  |  |  | SimpleDateFormat format1 = new SimpleDateFormat("HH:mm"); | 
|---|
|  |  |  | IPage<Bookings> result = bookingsJoinMapper.selectJoinPage(page, Bookings.class, queryWrapper); | 
|---|
|  |  |  | result.getRecords().stream().forEach(s -> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(s.getMeetingStatus().equals(Constants.ZERO)){ | 
|---|
|  |  |  | if(s.getMeetingStatus()==Constants.ONE){ | 
|---|
|  |  |  | //开始前120分钟 大于当前时间 则显示即将开始 | 
|---|
|  |  |  | if(DateUtil.afterMinutesDate(s.getStartTime(),-120).getTime()>System.currentTimeMillis()){ | 
|---|
|  |  |  | s.setMeetingStatus(4); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | MPJLambdaWrapper<Multifile> bookquery = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | bookquery.eq(Multifile::getIsdeleted, Constants.ZERO); | 
|---|
|  |  |  | bookquery.eq(Multifile::getIsdeleted, MeetConstants.ZERO); | 
|---|
|  |  |  | bookquery.eq(Multifile::getObjId, s.getId()); | 
|---|
|  |  |  | List<Multifile> filelist = multifileJoinMapper.selectList(bookquery); | 
|---|
|  |  |  | filelist.stream().forEach(a -> { | 
|---|
|  |  |  | if (StringUtils.isNotBlank(a.getFileurl())) { | 
|---|
|  |  |  | a.setFileFullUrl(path + a.getFileurl()); | 
|---|
|  |  |  | a.setFileurlFull(path + a.getFileurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | s.setFileList(filelist); | 
|---|
|  |  |  | 
|---|
|  |  |  | //参会人员列表 | 
|---|
|  |  |  | MPJLambdaWrapper<UserRel> urquery = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | urquery.selectAll(UserRel.class); | 
|---|
|  |  |  | urquery.eq(UserRel::getIsdeleted, Constants.ZERO); | 
|---|
|  |  |  | urquery.eq(UserRel::getIsdeleted, MeetConstants.ZERO); | 
|---|
|  |  |  | urquery.eq(UserRel::getObjId, s.getId()); | 
|---|
|  |  |  | urquery.select("(select REALNAME from system_user s where t.USER_ID = s.id and s.DELETED = 0  ) as realName"); | 
|---|
|  |  |  | List<UserRel> userrelList = userRelJoinMapper.selectJoinList(UserRel.class, urquery); | 
|---|
|  |  |  | 
|---|
|  |  |  | //服务项 | 
|---|
|  |  |  | MPJLambdaWrapper<ProjectRel> prquery = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | prquery.selectAll(ProjectRel.class); | 
|---|
|  |  |  | prquery.eq(ProjectRel::getIsdeleted, Constants.ZERO); | 
|---|
|  |  |  | prquery.eq(ProjectRel::getIsdeleted, MeetConstants.ZERO); | 
|---|
|  |  |  | prquery.eq(ProjectRel::getObjId, s.getId()); | 
|---|
|  |  |  | prquery.select("(select p.name from projects p where t.PROJECT_ID = p.id and p.ISDELETED = 0  ) as projectName"); | 
|---|
|  |  |  | prquery.select("(select p.name from meeting_projects p where t.PROJECT_ID = p.id and p.ISDELETED = 0  ) as projectName"); | 
|---|
|  |  |  | List<ProjectRel> prList = projectRelJoinMapper.selectJoinList(ProjectRel.class, prquery); | 
|---|
|  |  |  | s.setProjectList(prList); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | s.setFlag(Constants.ZERO); | 
|---|
|  |  |  | s.setFlag(MeetConstants.ZERO); | 
|---|
|  |  |  | if (System.currentTimeMillis() > s.getStartTime().getTime()) { | 
|---|
|  |  |  | s.setFlag(Constants.ONE); | 
|---|
|  |  |  | s.setFlag(MeetConstants.ONE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | 
|---|
|  |  |  | queryWrapper.selectAll(Bookings.class); | 
|---|
|  |  |  | queryWrapper.selectAs(Rooms::getName, Bookings::getRoomName); | 
|---|
|  |  |  | queryWrapper.selectAs(SystemUser::getRealname, Bookings::getRealName); | 
|---|
|  |  |  | queryWrapper.selectAs(SystemDepartment::getName, Bookings::getDepartmentName); | 
|---|
|  |  |  | queryWrapper.selectAs(Company::getName, Bookings::getDepartmentName); | 
|---|
|  |  |  | queryWrapper.leftJoin(Rooms.class, Rooms::getId, Bookings::getRoomId); | 
|---|
|  |  |  | queryWrapper.leftJoin(SystemUser.class, SystemUser::getId, Bookings::getCreator); | 
|---|
|  |  |  | queryWrapper.leftJoin(SystemDepartmentUser.class, SystemDepartmentUser::getUserId, Bookings::getCreator); | 
|---|
|  |  |  | queryWrapper.leftJoin(SystemDepartment.class, SystemDepartment::getId, SystemDepartmentUser::getDepartmentId); | 
|---|
|  |  |  | queryWrapper.eq(Bookings::getIsdeleted, Constants.ZERO); | 
|---|
|  |  |  | queryWrapper.leftJoin(Company.class,Company::getId,SystemUser::getCompanyId); | 
|---|
|  |  |  | queryWrapper.eq(Bookings::getIsdeleted, MeetConstants.ZERO); | 
|---|
|  |  |  | queryWrapper.eq(queryParam.getId() != null, Bookings::getId, queryParam.getId()); | 
|---|
|  |  |  | queryWrapper.eq(queryParam.getRoomId() != null, Bookings::getRoomId, queryParam.getRoomId()); | 
|---|
|  |  |  | if (queryParam.getStartTime() != null) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | queryWrapper.orderByDesc(Bookings::getCreateDate); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() + systemDictDataBiz.queryByCode(Constants.OSS, Constants.PROJECTS).getCode(); | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() + systemDictDataBiz.queryByCode(Constants.OSS, Constants.PROJECTS).getCode(); | 
|---|
|  |  |  | //        String path = systemDictDataBiz.queryByCode(MeetConstants.OSS, MeetConstants.RESOURCE_PATH).getCode() + systemDictDataBiz.queryByCode(MeetConstants.OSS, MeetConstants.PROJECTS).getCode(); | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.FTP_RESOURCE_PATH).getCode() + systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.PROJECTS).getCode(); | 
|---|
|  |  |  | Bookings result = bookingsJoinMapper.selectOne(queryWrapper.last("limit 1")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (result != null) { | 
|---|
|  |  |  | MPJLambdaWrapper<Multifile> bookquery = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | bookquery.eq(Multifile::getIsdeleted, Constants.ZERO); | 
|---|
|  |  |  | bookquery.eq(Multifile::getIsdeleted, MeetConstants.ZERO); | 
|---|
|  |  |  | bookquery.eq(Multifile::getObjId, result.getId()); | 
|---|
|  |  |  | List<Multifile> filelist = multifileJoinMapper.selectList(bookquery); | 
|---|
|  |  |  | filelist.stream().forEach(a -> { | 
|---|
|  |  |  | if (StringUtils.isNotBlank(a.getFileurl())) { | 
|---|
|  |  |  | a.setFileFullUrl(path + a.getFileurl()); | 
|---|
|  |  |  | a.setFileurlFull(path + a.getFileurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | result.setFileList(filelist); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (user == null || user.getDeleted()) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "读头扫码:无效用户"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Constants.equalsInteger(param.getType(), Constants.ZERO)) { | 
|---|
|  |  |  | if (MeetConstants.equalsInteger(param.getType(), MeetConstants.ZERO)) { | 
|---|
|  |  |  | //会议开门 | 
|---|
|  |  |  | bookOpenDoor(user, param); | 
|---|
|  |  |  | } else if (Constants.equalsInteger(param.getType(), Constants.ONE)) { | 
|---|
|  |  |  | } else if (MeetConstants.equalsInteger(param.getType(), MeetConstants.ONE)) { | 
|---|
|  |  |  | //会议室管理员开门 | 
|---|
|  |  |  | roomManagerOpenDoor(user, param); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | Long time = param.getTimestamp(); | 
|---|
|  |  |  | Long validTime = 0l; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | validTime = Long.parseLong(systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.QR_OPENROOM_VALIDTIME).getCode()); | 
|---|
|  |  |  | validTime = Long.parseLong(systemDictDataBiz.queryByCode(MeetConstants.SYSTEM, MeetConstants.QR_OPENROOM_VALIDTIME).getCode()); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (validTime > 0 && System.currentTimeMillis() - time > validTime * 60*1000) { | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "读头扫码:该二维码已过期!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Devices devices = new Devices(); | 
|---|
|  |  |  | devices.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | devices.setStatus(Constants.ZERO); | 
|---|
|  |  |  | devices.setIsdeleted(MeetConstants.ZERO); | 
|---|
|  |  |  | devices.setStatus(MeetConstants.ZERO); | 
|---|
|  |  |  | devices.setCode(param.getDeviceCode()); | 
|---|
|  |  |  | devices = devicesService.findOne(devices); | 
|---|
|  |  |  | if(devices == null){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "读头扫码:无效设备"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.equalsInteger(param.getObjId(),devices.getRoomId())){ | 
|---|
|  |  |  | if(!MeetConstants.equalsInteger(param.getObjId(),devices.getRoomId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "读头扫码:无效设备绑定"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询会议室记录 | 
|---|
|  |  |  | Rooms rooms = roomsMapper.selectById(param.getObjId()); | 
|---|
|  |  |  | if (rooms == null || Constants.equalsInteger(rooms.getIsdeleted(), Constants.ONE)) { | 
|---|
|  |  |  | if (rooms == null || MeetConstants.equalsInteger(rooms.getIsdeleted(), MeetConstants.ONE)) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "读头扫码:无效会议室"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | UserRel rel = new UserRel(); | 
|---|
|  |  |  | rel.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | rel.setIsdeleted(MeetConstants.ZERO); | 
|---|
|  |  |  | rel.setObjId(rooms.getId()); | 
|---|
|  |  |  | rel.setUserId(user.getId()); | 
|---|
|  |  |  | rel.setObjType(Constants.UserRelObjType.objTypeRoom); | 
|---|
|  |  |  | rel.setObjType(MeetConstants.UserRelObjType.objTypeRoom); | 
|---|
|  |  |  | //查询是否参会人员 | 
|---|
|  |  |  | rel = userRelJoinMapper.selectOne(new QueryWrapper<>(rel).last("limit 1")); | 
|---|
|  |  |  | if (rel == null) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | RoomRecord record = new RoomRecord(); | 
|---|
|  |  |  | record.setCreateDate(new Date()); | 
|---|
|  |  |  | record.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | record.setIsdeleted(MeetConstants.ZERO); | 
|---|
|  |  |  | record.setCreator(user.getId()); | 
|---|
|  |  |  | record.setObjId(rooms.getId()); | 
|---|
|  |  |  | record.setUserId(user.getId()); | 
|---|
|  |  |  | record.setRoomId(rooms.getId()); | 
|---|
|  |  |  | record.setObjType(Constants.RoomRecordObjType.objTypeRoom); | 
|---|
|  |  |  | record.setObjType(MeetConstants.RoomRecordObjType.objTypeRoom); | 
|---|
|  |  |  | //开门记录 | 
|---|
|  |  |  | roomRecordMapper.insert(record); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | Long time = param.getTimestamp(); | 
|---|
|  |  |  | Long validTime = 0l; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | validTime = Long.parseLong(systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.QR_OPENBOOK_VALIDTIME).getCode()); | 
|---|
|  |  |  | validTime = Long.parseLong(systemDictDataBiz.queryByCode(MeetConstants.SYSTEM, MeetConstants.QR_OPENBOOK_VALIDTIME).getCode()); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (validTime > 0 && System.currentTimeMillis() - time > validTime * 60*1000) { | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "读头扫码:二维码已失效"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Devices devices = new Devices(); | 
|---|
|  |  |  | devices.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | devices.setStatus(Constants.ZERO); | 
|---|
|  |  |  | devices.setIsdeleted(MeetConstants.ZERO); | 
|---|
|  |  |  | devices.setStatus(MeetConstants.ZERO); | 
|---|
|  |  |  | devices.setCode(param.getDeviceCode()); | 
|---|
|  |  |  | devices = devicesService.findOne(devices); | 
|---|
|  |  |  | if(devices == null){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "读头扫码:无效设备"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Bookings book = findById(param.getObjId()); | 
|---|
|  |  |  | if (book == null || Constants.equalsInteger(book.getIsdeleted(), Constants.ONE)) { | 
|---|
|  |  |  | if (book == null || MeetConstants.equalsInteger(book.getIsdeleted(), MeetConstants.ONE)) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "读头扫码:无效会议"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(!Constants.equalsInteger(book.getRoomId(),devices.getRoomId())){ | 
|---|
|  |  |  | if(!MeetConstants.equalsInteger(book.getRoomId(),devices.getRoomId())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "读头扫码:无效设备绑定"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!Constants.equalsInteger(book.getStatus(), Constants.ZERO)) { | 
|---|
|  |  |  | if (!MeetConstants.equalsInteger(book.getStatus(), MeetConstants.ZERO)) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "读头扫码:会议状态错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (book.getStartTime() == null || book.getEndTime() == null) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "读头扫码:会议时间溢出"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //提前进入时间 | 
|---|
|  |  |  | Long advanceInTime = Long.parseLong(systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.ADVANCE_IN).getCode()); | 
|---|
|  |  |  | Long advanceInTime = Long.parseLong(systemDictDataBiz.queryByCode(MeetConstants.SYSTEM, MeetConstants.ADVANCE_IN).getCode()); | 
|---|
|  |  |  | if ((book.getStartTime().getTime() - advanceInTime * 60L * 1000L) > System.currentTimeMillis()) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "读头扫码:会议未开始"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | RoomRecord record = new RoomRecord(); | 
|---|
|  |  |  | record.setCreateDate(new Date()); | 
|---|
|  |  |  | record.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | record.setIsdeleted(MeetConstants.ZERO); | 
|---|
|  |  |  | record.setCreator(user.getId()); | 
|---|
|  |  |  | record.setObjId(book.getId()); | 
|---|
|  |  |  | record.setUserId(user.getId()); | 
|---|
|  |  |  | record.setRoomId(book.getRoomId()); | 
|---|
|  |  |  | UserRel rel = new UserRel(); | 
|---|
|  |  |  | rel.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | rel.setIsdeleted(MeetConstants.ZERO); | 
|---|
|  |  |  | rel.setObjId(book.getId()); | 
|---|
|  |  |  | rel.setUserId(user.getId()); | 
|---|
|  |  |  | rel.setObjType(Constants.UserRelObjType.objTypeBook); | 
|---|
|  |  |  | rel.setObjType(MeetConstants.UserRelObjType.objTypeBook); | 
|---|
|  |  |  | //查询是否参会人员 | 
|---|
|  |  |  | rel = userRelJoinMapper.selectOne(new QueryWrapper<>(rel).last("limit 1")); | 
|---|
|  |  |  | if (rel == null) { | 
|---|
|  |  |  | //访客 | 
|---|
|  |  |  | record.setObjType(Constants.RoomRecordObjType.objTypeBook_out); | 
|---|
|  |  |  | record.setObjType(MeetConstants.RoomRecordObjType.objTypeBook_out); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | //参会人员 | 
|---|
|  |  |  | record.setObjType(Constants.RoomRecordObjType.objTypeBook_in); | 
|---|
|  |  |  | record.setObjType(MeetConstants.RoomRecordObjType.objTypeBook_in); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //开门记录 | 
|---|
|  |  |  | roomRecordMapper.insert(record); | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<Bookings> getMyBookings(Integer userId, String dateMsg) { | 
|---|
|  |  |  | return bookingsMapper.selectList(new QueryWrapper<Bookings>() | 
|---|
|  |  |  | .apply(" id in ( select u.OBJ_ID from user_rel u where u.USER_ID = '" + userId + "' and u.ISDELETED = 0 and OBJ_TYPE = 1  ) ") | 
|---|
|  |  |  | .eq("ISDELETED",Constants.ZERO) | 
|---|
|  |  |  | //                .eq("STATUS",Constants.ZERO) | 
|---|
|  |  |  | .apply(" ROOM_ID in ( select r.id from rooms r where r.ISDELETED = 0 and r.STATUS = 0  )") | 
|---|
|  |  |  | .apply(" id in ( select u.OBJ_ID from meeting_user_rel u where u.USER_ID = '" + userId + "' and u.ISDELETED = 0 and OBJ_TYPE = 1  ) ") | 
|---|
|  |  |  | .eq("ISDELETED",MeetConstants.ZERO) | 
|---|
|  |  |  | //                .eq("STATUS",MeetConstants.ZERO) | 
|---|
|  |  |  | .apply(" ROOM_ID in ( select r.id from meeting_rooms r where r.ISDELETED = 0 and r.STATUS = 0  )") | 
|---|
|  |  |  | .like(StringUtils.isNotBlank(dateMsg), "START_TIME", dateMsg)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public IPage<MeetingListResponse> getMyMeetingPage(PageWrap<MeetingPageRequest> pageWrap) { | 
|---|
|  |  |  | IPage<MeetingListResponse> page = bookingsMapper.myMeetingPage(pageWrap.toPage(), new QueryWrapper<MeetingListResponse>() | 
|---|
|  |  |  |  | 
|---|
|  |  |  | QueryWrapper queryWrapper = new QueryWrapper<MeetingListResponse>() | 
|---|
|  |  |  | .and(StringUtils.isNotBlank(pageWrap.getModel().getRoomsName()), | 
|---|
|  |  |  | j -> j.like("a.NAME",pageWrap.getModel().getRoomsName()).or() | 
|---|
|  |  |  | .like(" b.NAME", pageWrap.getModel().getRoomsName())) | 
|---|
|  |  |  | .exists(pageWrap.getModel().getQueryType().equals(Constants.ONE) && !Objects.isNull(pageWrap.getModel().getUserId()), | 
|---|
|  |  |  | " select 1 from user_rel u where a.id = u.OBJ_ID and  u.USER_ID = '" + pageWrap.getModel().getUserId() + "' and u.ISDELETED = 0 and OBJ_TYPE = 1  ") | 
|---|
|  |  |  | .eq(pageWrap.getModel().getQueryType().equals(Constants.TWO) && !Objects.isNull(pageWrap.getModel().getUserId()), "a.CREATOR", pageWrap.getModel().getUserId()) | 
|---|
|  |  |  | .like(StringUtils.isNotBlank(pageWrap.getModel().getQueryDate()), "a.START_TIME", pageWrap.getModel().getQueryDate()) | 
|---|
|  |  |  | .eq(!Objects.isNull(pageWrap.getModel().getRoomsId()), "b.id", pageWrap.getModel().getRoomsId()) | 
|---|
|  |  |  | .apply(!Objects.isNull(pageWrap.getModel().getStatus()) && pageWrap.getModel().getStatus().equals(Constants.ONE), " now() < a.END_TIME and a.STATUS = 0   ") | 
|---|
|  |  |  | .and(!Objects.isNull(pageWrap.getModel().getStatus()) && pageWrap.getModel().getStatus().equals(Constants.TWO), | 
|---|
|  |  |  | j -> j.apply("now() >= a.END_TIME ").or() | 
|---|
|  |  |  | .eq(" a.STATUS", Constants.ONE)) | 
|---|
|  |  |  | .eq("b.ISDELETED",Constants.ZERO) | 
|---|
|  |  |  | .eq("b.STATUS",Constants.ZERO) | 
|---|
|  |  |  | .eq("a.ISDELETED",Constants.ZERO) | 
|---|
|  |  |  | .orderByDesc(!Objects.isNull(pageWrap.getModel().getStatus())&&pageWrap.getModel().getStatus().equals(Constants.TWO),"a.START_TIME") | 
|---|
|  |  |  | .orderByAsc(Objects.isNull(pageWrap.getModel().getStatus())||pageWrap.getModel().getStatus().equals(Constants.ONE),"a.START_TIME") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() + systemDictDataBiz.queryByCode(Constants.OSS, Constants.PROJECTS).getCode(); | 
|---|
|  |  |  | ; | 
|---|
|  |  |  | page.getRecords().forEach(i -> { | 
|---|
|  |  |  | i.setPrefixUrl(prefixUrl); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | .exists(pageWrap.getModel().getQueryType().equals(MeetConstants.ONE) && !Objects.isNull(pageWrap.getModel().getUserId()), | 
|---|
|  |  |  | " select 1 from meeting_user_rel u where a.id = u.OBJ_ID and  u.USER_ID = '" + pageWrap.getModel().getUserId() + "' and u.ISDELETED = 0 and OBJ_TYPE = 1  ") | 
|---|
|  |  |  | .eq(pageWrap.getModel().getQueryType().equals(MeetConstants.TWO) && !Objects.isNull(pageWrap.getModel().getUserId()), "a.CREATOR", pageWrap.getModel().getUserId()) | 
|---|
|  |  |  | .like(StringUtils.isNotBlank(pageWrap.getModel().getQueryDate()), "a.START_TIME", pageWrap.getModel().getQueryDate()) | 
|---|
|  |  |  | .eq(!Objects.isNull(pageWrap.getModel().getRoomsId()), "b.id", pageWrap.getModel().getRoomsId()) | 
|---|
|  |  |  | .apply(!Objects.isNull(pageWrap.getModel().getStatus()) && pageWrap.getModel().getStatus().equals(MeetConstants.ONE), " now() < a.END_TIME and a.STATUS = 0   ") | 
|---|
|  |  |  | .and(!Objects.isNull(pageWrap.getModel().getStatus()) && pageWrap.getModel().getStatus().equals(MeetConstants.TWO), | 
|---|
|  |  |  | j -> j.apply("now() >= a.END_TIME ").or() | 
|---|
|  |  |  | .eq(" a.STATUS", MeetConstants.ONE)) | 
|---|
|  |  |  | .eq("b.ISDELETED",MeetConstants.ZERO) | 
|---|
|  |  |  | .eq("b.STATUS",MeetConstants.ZERO) | 
|---|
|  |  |  | .eq("a.ISDELETED",MeetConstants.ZERO) | 
|---|
|  |  |  | .apply(Objects.nonNull(pageWrap.getModel().getMeetingStatus()) | 
|---|
|  |  |  | &&Constants.equalsInteger(pageWrap.getModel().getMeetingStatus(),Constants.ONE), | 
|---|
|  |  |  | " ( now() < a.START_TIME and a.status = 0 ) " | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .apply(Objects.nonNull(pageWrap.getModel().getMeetingStatus()) | 
|---|
|  |  |  | &&Constants.equalsInteger(pageWrap.getModel().getMeetingStatus(),Constants.TWO), | 
|---|
|  |  |  | " ( now() >= a.START_TIME and a.END_TIME >= now() and a.status = 0 ) " | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .apply(Objects.nonNull(pageWrap.getModel().getMeetingStatus()) | 
|---|
|  |  |  | &&Constants.equalsInteger(pageWrap.getModel().getMeetingStatus(),Constants.THREE), | 
|---|
|  |  |  | " ( ( now() > a.END_TIME  and  a.`STATUS` = 0  ) or   a.`STATUS` = 2  )  " | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .apply(Objects.nonNull(pageWrap.getModel().getMeetingStatus()) | 
|---|
|  |  |  | &&Constants.equalsInteger(pageWrap.getModel().getMeetingStatus(),Constants.FOUR), | 
|---|
|  |  |  | " now() < a.START_TIME  AND SUBDATE( a.START_TIME, INTERVAL 120 MINUTE ) < NOW() " | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .apply(Objects.nonNull(pageWrap.getModel().getMeetingStatus()) | 
|---|
|  |  |  | &&Constants.equalsInteger(pageWrap.getModel().getMeetingStatus(),Constants.FIVE), | 
|---|
|  |  |  | " a.STATUS = 1  " | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | //                        .orderByDesc(!Objects.isNull(pageWrap.getModel().getStatus())&&pageWrap.getModel().getStatus().equals(MeetConstants.TWO),"a.START_TIME") | 
|---|
|  |  |  | //                        .orderByAsc(Objects.isNull(pageWrap.getModel().getStatus())||pageWrap.getModel().getStatus().equals(MeetConstants.ONE),"a.START_TIME") | 
|---|
|  |  |  | .orderByDesc(Constants.equalsInteger(pageWrap.getModel().getQueryType(),MeetConstants.TWO),"a.CREATE_DATE") | 
|---|
|  |  |  | .orderByAsc(Constants.equalsInteger(pageWrap.getModel().getQueryType(),MeetConstants.ONE),"a.START_TIME"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | IPage<MeetingListResponse> page = bookingsMapper.myMeetingPage(pageWrap.toPage(), queryWrapper); | 
|---|
|  |  |  | this.dealMeetingStatus(page.getRecords()); | 
|---|
|  |  |  | return page; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public MeetingDetailResponse getMeetingDetailByDate(Bookings bean){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | if(Objects.isNull(bean) | 
|---|
|  |  |  | || Objects.isNull(bean.getRoomId()) | 
|---|
|  |  |  | || Objects.isNull(bean.getStartTime()) | 
|---|
|  |  |  | || Objects.isNull(bean.getEndTime())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Bookings bookings = bookingsMapper.selectOne(new QueryWrapper<Bookings>().lambda() | 
|---|
|  |  |  | .eq(Bookings::getRoomId,bean.getRoomId()) | 
|---|
|  |  |  | .ge(Bookings::getEndTime,DateUtil.getPlusTime(bean.getEndTime())) | 
|---|
|  |  |  | .le(Bookings::getStartTime,DateUtil.getPlusTime(bean.getStartTime())) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.isNull(bookings)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return getMeetingDetail(bookings.getId(),null); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 会议详情 | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public MeetingDetailResponse getMeetingDetail(Integer id) { | 
|---|
|  |  |  | public MeetingDetailResponse getMeetingDetail(Integer id,Integer sysUserId) { | 
|---|
|  |  |  | MeetingDetailResponse meetingDetailResponse = bookingsMapper.meetingDetail(id); | 
|---|
|  |  |  | if (Objects.isNull(meetingDetailResponse)) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "未查询到会议详情"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //预约人 | 
|---|
|  |  |  | meetingDetailResponse.setBookingUser(systemUserService.getUserInfo(meetingDetailResponse.getBookingUserId())); | 
|---|
|  |  |  | meetingDetailResponse.setBookingUser(systemUserService.findById(meetingDetailResponse.getBookingUserId())); | 
|---|
|  |  |  | //时间段列表 | 
|---|
|  |  |  | meetingDetailResponse.setBookingTimeList(bookingTimeMapper.selectList(new QueryWrapper<BookingTime>() | 
|---|
|  |  |  | .eq("BOOKING_ID", id) | 
|---|
|  |  |  | .eq("ISDELETED", Constants.ZERO) | 
|---|
|  |  |  | .eq("ISDELETED", MeetConstants.ZERO) | 
|---|
|  |  |  | )); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //参会人员列表 | 
|---|
|  |  |  | List<UserResponse> userResponseList = systemUserService.getUserList(id); | 
|---|
|  |  |  | String avatarPath = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() + systemDictDataBiz.queryByCode(Constants.OSS, Constants.PROJECTS).getCode(); | 
|---|
|  |  |  | String avatarPath = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.FTP,Constants.MEMBER_IMG).getCode(); | 
|---|
|  |  |  | userResponseList.forEach(i -> { | 
|---|
|  |  |  | i.setPrefixUrl(avatarPath); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(i.getAvatar())){ | 
|---|
|  |  |  | i.setAvatar(avatarPath+i.getAvatar()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | meetingDetailResponse.setUserResponseList(userResponseList); | 
|---|
|  |  |  | //服务项 | 
|---|
|  |  |  | String projectsPath = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() + systemDictDataBiz.queryByCode(Constants.OSS, Constants.PROJECTS).getCode(); | 
|---|
|  |  |  | List<ProjectsResponse> projectsResponseList = projectsService.getProjectsList(id, Constants.ONE); | 
|---|
|  |  |  | String projectsPath = systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.FTP_RESOURCE_PATH).getCode() | 
|---|
|  |  |  | + systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.PROJECTS).getCode(); | 
|---|
|  |  |  | List<ProjectsResponse> projectsResponseList = projectsService.getProjectsList(id, MeetConstants.ONE); | 
|---|
|  |  |  | projectsResponseList.forEach(i -> { | 
|---|
|  |  |  | i.setPrefixUrl(projectsPath); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | meetingDetailResponse.setProjectsResponseList(projectsResponseList); | 
|---|
|  |  |  | List<Multifile> multiFileList = multifileMapper.selectList(new QueryWrapper<Multifile>() | 
|---|
|  |  |  | .eq("OBJ_ID", id) | 
|---|
|  |  |  | .eq("OBJ_TYPE", Constants.ZERO) | 
|---|
|  |  |  | .eq("OBJ_TYPE", MeetConstants.ZERO) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | multiFileList.forEach(i -> { | 
|---|
|  |  |  | i.setFileFullUrl(projectsPath); | 
|---|
|  |  |  | i.setFileurlFull(projectsPath); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | //附件信息 | 
|---|
|  |  |  | meetingDetailResponse.setMultiFileList(multiFileList); | 
|---|
|  |  |  | //会议室管理人员 | 
|---|
|  |  |  | List<UserRel> userRelList = userRelMapper.selectList(new QueryWrapper<UserRel>() | 
|---|
|  |  |  | .eq("ISDELETED",Constants.ZERO) | 
|---|
|  |  |  | .eq("ISDELETED",MeetConstants.ZERO) | 
|---|
|  |  |  | .eq("OBJ_ID", meetingDetailResponse.getRoomId()) | 
|---|
|  |  |  | .eq("OBJ_TYPE",Constants.ZERO) | 
|---|
|  |  |  | .eq("OBJ_TYPE",MeetConstants.ZERO) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if (!Objects.isNull(userRelList) && userRelList.size() > 0) { | 
|---|
|  |  |  | meetingDetailResponse.setRoomUser(systemUserService.getUserInfo(userRelList.get(Constants.ZERO).getUserId())); | 
|---|
|  |  |  | if(Constants.equalsInteger(sysUserId,meetingDetailResponse.getBookingUserId())){ | 
|---|
|  |  |  | meetingDetailResponse.setIsAdmin(Constants.ONE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!Objects.isNull(userRelList) && userRelList.size() > 0) { | 
|---|
|  |  |  | meetingDetailResponse.setRoomUser(systemUserService.findById(userRelList.get(MeetConstants.ZERO).getUserId())); | 
|---|
|  |  |  | if( Objects.nonNull(sysUserId) && | 
|---|
|  |  |  | userRelList.stream().filter(i->Constants.equalsInteger(i.getUserId(),sysUserId)).collect(Collectors.toList()).size()>Constants.ZERO | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | meetingDetailResponse.setIsAdmin(Constants.ONE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return meetingDetailResponse; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public String getQrCode(Integer id, Integer userId) { | 
|---|
|  |  |  | Bookings model = bookingsMapper.selectById(id); | 
|---|
|  |  |  | if (model == null || !Constants.equalsInteger(model.getIsdeleted(), Constants.ZERO)) { | 
|---|
|  |  |  | if (model == null || !MeetConstants.equalsInteger(model.getIsdeleted(), MeetConstants.ZERO)) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "未查询到会议详情"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | QrOpenDoorDto dto = new QrOpenDoorDto(); | 
|---|
|  |  |  | dto.setType(Constants.ZERO); | 
|---|
|  |  |  | dto.setType(MeetConstants.ZERO); | 
|---|
|  |  |  | dto.setUserId(userId); | 
|---|
|  |  |  | dto.setTimestamp(System.currentTimeMillis()); | 
|---|
|  |  |  | dto.setObjId(id); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 会议预约记录取消 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param id | 
|---|
|  |  |  | * @param userId | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void reservationCancel(Integer id, Integer userId) { | 
|---|
|  |  |  | Bookings bookings = bookingsMapper.selectById(id); | 
|---|
|  |  |  | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) | 
|---|
|  |  |  | public void reservationCancel(BusinessOverDTO businessOverDTO) { | 
|---|
|  |  |  | Bookings bookings = bookingsMapper.selectById(businessOverDTO.getId()); | 
|---|
|  |  |  | if (Objects.isNull(bookings)) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "未查询到预约记录"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!bookings.getCreator().equals(userId)) { | 
|---|
|  |  |  | if (!bookings.getCreator().equals(businessOverDTO.getUserId())) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "非你的预约记录,无法进行取消"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (System.currentTimeMillis() > bookings.getStartTime().getTime()) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "会议已开始,无法进行取消"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(bookings.getStatus().equals(Constants.ONE)){ | 
|---|
|  |  |  | if(bookings.getStatus().equals(MeetConstants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "本次操作失败,预约状态已流转"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | bookings.setCancelTime(new Date()); | 
|---|
|  |  |  | bookings.setCancelUser(userId); | 
|---|
|  |  |  | bookings.setStatus(Constants.ONE); | 
|---|
|  |  |  | bookings.setCancelUser(businessOverDTO.getUserId()); | 
|---|
|  |  |  | bookings.setCancelInfo(businessOverDTO.getBusinessRemark()); | 
|---|
|  |  |  | bookings.setStatus(MeetConstants.ONE); | 
|---|
|  |  |  | bookings.setEditDate(new Date()); | 
|---|
|  |  |  | bookings.setEditor(userId); | 
|---|
|  |  |  | bookings.setEditor(businessOverDTO.getUserId()); | 
|---|
|  |  |  | bookingsMapper.updateById(bookings); | 
|---|
|  |  |  | //取消会议 发送取消通知 | 
|---|
|  |  |  | this.sendNotice(bookings, 3); | 
|---|
|  |  |  | //发送微信订阅通知 | 
|---|
|  |  |  | sendWxMessage.bookingsCancel(systemUserMapper.selectById(bookings.getCreator()), bookings, roomsMapper.selectById(bookings.getRoomId())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) | 
|---|
|  |  |  | public void reservationOver(BusinessOverDTO businessOverDTO) { | 
|---|
|  |  |  | if(Objects.isNull(businessOverDTO) | 
|---|
|  |  |  | || Objects.isNull(businessOverDTO.getUserId()) | 
|---|
|  |  |  | || Objects.isNull(businessOverDTO.getId()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Bookings bookings = bookingsMapper.selectById(businessOverDTO.getId()); | 
|---|
|  |  |  | if (Objects.isNull(bookings)) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "未查询到预约记录"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Long userRelList = userRelMapper.selectCount(new QueryWrapper<UserRel>().lambda() | 
|---|
|  |  |  | .eq(UserRel::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(UserRel::getObjId,bookings.getRoomId()) | 
|---|
|  |  |  | .eq(UserRel::getObjType,Constants.ZERO) | 
|---|
|  |  |  | .eq(UserRel::getUserId,businessOverDTO.getUserId())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!bookings.getCreator().equals(businessOverDTO.getUserId()) && userRelList <= 0) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "非你的预约记录,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (System.currentTimeMillis() < bookings.getStartTime().getTime()) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "会议未开始,无法进行结束,如需该操作请使用取消功能"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (System.currentTimeMillis() > bookings.getEndTime().getTime()) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "会议已结束,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!bookings.getStatus().equals(MeetConstants.ZERO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "本次操作失败,会议状态已流转"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | bookings.setDoneDate(new Date()); | 
|---|
|  |  |  | bookings.setDoneUserId(businessOverDTO.getUserId()); | 
|---|
|  |  |  | bookings.setStatus(MeetConstants.TWO); | 
|---|
|  |  |  | bookings.setEditDate(new Date()); | 
|---|
|  |  |  | bookings.setEditor(businessOverDTO.getUserId()); | 
|---|
|  |  |  | bookingsMapper.updateById(bookings); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询所有的预约时间 | 
|---|
|  |  |  | List<BookingTime> bookingTimeList = bookingTimeJoinMapper.selectJoinList(BookingTime.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<BookingTime>() | 
|---|
|  |  |  | .selectAll(BookingTime.class) | 
|---|
|  |  |  | .selectAs(RoomTime::getEndTime,BookingTime::getEndTime) | 
|---|
|  |  |  | .leftJoin(RoomTime.class,RoomTime::getId,BookingTime::getTimeId) | 
|---|
|  |  |  | .eq(BookingTime::getBookingId,bookings.getId())); | 
|---|
|  |  |  | //获取当天  只有当天日期内可以处理 | 
|---|
|  |  |  | String today = DateUtil.dateToString(new Date(),"yyyy-mm-dd"); | 
|---|
|  |  |  | //循环标记数据为已删除 不再占用 | 
|---|
|  |  |  | for (BookingTime bookingTime:bookingTimeList) { | 
|---|
|  |  |  | if(DateUtil.getDateFromString(today + " " + bookingTime.getEndTime() +":00").getTime()>System.currentTimeMillis()){ | 
|---|
|  |  |  | bookingTime.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | bookingTimeJoinMapper.updateById(bookingTime); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 正常开始 | 
|---|
|  |  |  | * @param businessOverDTO | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) | 
|---|
|  |  |  | public void start(BusinessOverDTO businessOverDTO) { | 
|---|
|  |  |  | this.startEarly(businessOverDTO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 提前开始 | 
|---|
|  |  |  | * @param businessOverDTO | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) | 
|---|
|  |  |  | public void startEarly(BusinessOverDTO businessOverDTO) { | 
|---|
|  |  |  | if(Objects.isNull(businessOverDTO) | 
|---|
|  |  |  | || Objects.isNull(businessOverDTO.getUserId()) | 
|---|
|  |  |  | || Objects.isNull(businessOverDTO.getStartType()) | 
|---|
|  |  |  | || Objects.isNull(businessOverDTO.getId()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Bookings bookings = bookingsMapper.selectById(businessOverDTO.getId()); | 
|---|
|  |  |  | if (Objects.isNull(bookings)) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "未查询到预约记录"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Long userRelList = userRelMapper.selectCount(new QueryWrapper<UserRel>().lambda() | 
|---|
|  |  |  | .eq(UserRel::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(UserRel::getObjId,bookings.getRoomId()) | 
|---|
|  |  |  | .eq(UserRel::getObjType,Constants.ZERO) | 
|---|
|  |  |  | .eq(UserRel::getUserId,businessOverDTO.getUserId())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!bookings.getCreator().equals(businessOverDTO.getUserId()) && userRelList <= 0) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "非你的预约记录,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.equalsInteger(bookings.getStatus(),Constants.ZERO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "会议状态已流转,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Objects.nonNull(bookings.getStartTimeReal())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "会议已开始,请勿重复操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (System.currentTimeMillis() > bookings.getEndTime().getTime()) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "会议已结束,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(businessOverDTO.getStartType(),Constants.ZERO)){ | 
|---|
|  |  |  | //根据配置获取提前开始的分钟数量 | 
|---|
|  |  |  | String configMinute = systemDictDataBiz.queryByCode(MeetConstants.SYSTEM, MeetConstants.EARLY_START).getCode(); | 
|---|
|  |  |  | Integer beforeMinutes = StringUtils.isNotBlank(configMinute) ? Integer.valueOf(configMinute) : 120; | 
|---|
|  |  |  | if(DateUtil.afterMinutesDate(bookings.getStartTime(),-beforeMinutes).getTime()>System.currentTimeMillis()){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"会议仅可以提前"+beforeMinutes+"分钟开始"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询是否存在其他未开始的会议 防止颗粒度与提前开始的问题 | 
|---|
|  |  |  | if(bookingsMapper.selectCount(new QueryWrapper<Bookings>() | 
|---|
|  |  |  | .lambda() | 
|---|
|  |  |  | .apply(" now() < START_TIME and   END_TIME <=  '" + DateUtil.DateToStr(bookings.getStartTime(),"yyyy-MM-dd HH:mm:ss") +"'" ) | 
|---|
|  |  |  | .isNull(Bookings::getStartTimeReal) | 
|---|
|  |  |  | .isNull(Bookings::getDoneDate) | 
|---|
|  |  |  | .eq(Bookings::getStatus,Constants.ZERO) | 
|---|
|  |  |  | .eq(Bookings::getRoomId,bookings.getRoomId()) | 
|---|
|  |  |  | .ne(Bookings::getId,bookings.getId()) | 
|---|
|  |  |  | )>Constants.ZERO){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"存在未开启会议,无法进行开始会议"); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(bookingsMapper.selectCount(new QueryWrapper<Bookings>() | 
|---|
|  |  |  | .lambda() | 
|---|
|  |  |  | .apply(" (  END_TIME > now() and START_TIME < now() ) or  ( END_TIME > now() and  START_TIME_REAL < now() )  ") | 
|---|
|  |  |  | .isNotNull(Bookings::getStartTimeReal) | 
|---|
|  |  |  | .isNull(Bookings::getDoneDate) | 
|---|
|  |  |  | .eq(Bookings::getStatus,Constants.ZERO) | 
|---|
|  |  |  | .eq(Bookings::getRoomId,bookings.getRoomId()) | 
|---|
|  |  |  | )>Constants.ZERO){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前开启时间与其他会议存在冲突,无法进行开始会议"); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | if(bookings.getStartTime().getTime() > System.currentTimeMillis()){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未到会议申请开始时间,无法进行开始"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | bookings.setStartTimeReal(new Date()); | 
|---|
|  |  |  | bookings.setEditDate(new Date()); | 
|---|
|  |  |  | bookings.setEditor(businessOverDTO.getUserId()); | 
|---|
|  |  |  | bookingsMapper.updateById(bookings); | 
|---|
|  |  |  | //更新已结束但未结束的会议信息为已结束 | 
|---|
|  |  |  | bookingsMapper.update(null,new UpdateWrapper<Bookings>() | 
|---|
|  |  |  | .lambda() | 
|---|
|  |  |  | .set(Bookings::getStatus,Constants.TWO) | 
|---|
|  |  |  | .set(Bookings::getDoneDate,new Date()) | 
|---|
|  |  |  | .set(Bookings::getDoneInfo,"其他会议开始,自动关闭") | 
|---|
|  |  |  | .apply(" ( END_TIME < now() or ( END_TIME > now() and START_TIME < now() and START_TIME_REAL is null  ) )") | 
|---|
|  |  |  | .eq(Bookings::getStatus,Constants.ZERO) | 
|---|
|  |  |  | .eq(Bookings::getRoomId,bookings.getRoomId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public RoomDetailResponse getRoomDetail(Integer roomId){ | 
|---|
|  |  |  | Rooms rooms =  roomsMapper.selectById(roomId); | 
|---|
|  |  |  | if(Objects.isNull(rooms) ||  !Constants.equalsInteger(rooms.getIsdeleted(),Constants.ZERO) | 
|---|
|  |  |  | || !Constants.equalsInteger(rooms.getStatus(),Constants.ZERO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"会议室信息无效,请联系管理员"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | RoomDetailResponse response = new RoomDetailResponse(); | 
|---|
|  |  |  | response.setRoomName(rooms.getName()); | 
|---|
|  |  |  | response.setFileType(rooms.getFileType()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Multifile> multifileList = multifileJoinMapper.selectList(new QueryWrapper<Multifile>().lambda() | 
|---|
|  |  |  | .eq(Multifile::getObjId,roomId) | 
|---|
|  |  |  | .eq(Multifile::getObjType,Constants.FOUR) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String prefix = systemDictDataBiz.queryByCode(MeetConstants.SYSTEM, MeetConstants.MEET_CODE_PREFIX).getCode() ; | 
|---|
|  |  |  | response.setPrefix(prefix); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.FTP_RESOURCE_PATH).getCode() + systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.PROJECTS).getCode(); | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | multifile.setFileurlFull(path + multifile.getFileurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | response.setMultifileList(multifileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询会议列表 | 
|---|
|  |  |  | List<MeetingListResponse> meetingList = bookingsMapper.meetingList( | 
|---|
|  |  |  | new QueryWrapper<Bookings>() | 
|---|
|  |  |  | .eq( "b.id", rooms.getId()) | 
|---|
|  |  |  | .eq("b.ISDELETED",MeetConstants.ZERO) | 
|---|
|  |  |  | .eq("b.STATUS",MeetConstants.ZERO) | 
|---|
|  |  |  | .eq("a.ISDELETED",MeetConstants.ZERO) | 
|---|
|  |  |  | .eq("a.status",Constants.ZERO) | 
|---|
|  |  |  | .like("a.start_time",DateUtil.getCurrDate()) | 
|---|
|  |  |  | .orderByAsc("a.start_time") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | this.dealMeetingStatus(meetingList); | 
|---|
|  |  |  | response.setMeetingListResponseList(meetingList); | 
|---|
|  |  |  | return response; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void dealMeetingStatus(List<MeetingListResponse> meetingResponseList){ | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(meetingResponseList)){ | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.FTP_RESOURCE_PATH).getCode() + systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.PROJECTS).getCode(); | 
|---|
|  |  |  | String configMinute = systemDictDataBiz.queryByCode(MeetConstants.SYSTEM, MeetConstants.SOON_START).getCode(); | 
|---|
|  |  |  | Integer minute = StringUtils.isNotBlank(configMinute) ? Integer.valueOf(configMinute) : 120; | 
|---|
|  |  |  | for (MeetingListResponse m:meetingResponseList) { | 
|---|
|  |  |  | if(Constants.equalsInteger(m.getStatus(),Constants.ZERO)&&Constants.equalsInteger(m.getMeetingStatus(),Constants.ONE)){ | 
|---|
|  |  |  | //开始前120分钟 大于当前时间 则显示即将开始 | 
|---|
|  |  |  | if(DateUtil.afterMinutesDate(m.getStartTime(),-minute).getTime()>System.currentTimeMillis()){ | 
|---|
|  |  |  | m.setMeetingStatus(4); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | m.setPrefixUrl(path); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void sendBookingsNotice() { | 
|---|
|  |  |  | //查询配置 | 
|---|
|  |  |  | String configMinute = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.NOTICE_TIME).getCode(); | 
|---|
|  |  |  | String configMinute = systemDictDataBiz.queryByCode(MeetConstants.SYSTEM, MeetConstants.NOTICE_TIME).getCode(); | 
|---|
|  |  |  | Integer minute = StringUtils.isNotBlank(configMinute) ? Integer.valueOf(configMinute) : 30; | 
|---|
|  |  |  | //查询会议开始三十分钟前的会议 | 
|---|
|  |  |  | List<Bookings> bookingsList = bookingsMapper.selectList(new QueryWrapper<Bookings>() | 
|---|
|  |  |  | .eq("STATUS",Constants.ZERO) | 
|---|
|  |  |  | .eq("ISDELETED",Constants.ZERO) | 
|---|
|  |  |  | .eq("SEND_NOTICE", Constants.ZERO) | 
|---|
|  |  |  | .eq("STATUS",MeetConstants.ZERO) | 
|---|
|  |  |  | .eq("ISDELETED",MeetConstants.ZERO) | 
|---|
|  |  |  | .eq("SEND_NOTICE", MeetConstants.ZERO) | 
|---|
|  |  |  | .apply(" now() >= SUBDATE(START_TIME,interval + " + minute + " minute) ") | 
|---|
|  |  |  | .apply(" ROOM_ID in ( select r.id from rooms r where r.ISDELETED = 0 and r.STATUS = 0  )") | 
|---|
|  |  |  | .apply(" ROOM_ID in ( select r.id from meeting_rooms r where r.ISDELETED = 0 and r.STATUS = 0  )") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | for (Bookings bookings : bookingsList) { | 
|---|
|  |  |  | bookings.setSendNotice(Constants.ONE); | 
|---|
|  |  |  | bookings.setSendNotice(MeetConstants.ONE); | 
|---|
|  |  |  | bookings.setEditDate(new Date()); | 
|---|
|  |  |  | bookingsMapper.updateById(bookings); | 
|---|
|  |  |  | this.sendNotice(bookings, Constants.ONE); | 
|---|
|  |  |  | this.sendNotice(bookings, MeetConstants.ONE); | 
|---|
|  |  |  | //发送微信通知 | 
|---|
|  |  |  | sendWxMessage.bookingsStart(systemUserMapper.selectById(bookings.getCreator()), bookings, roomsMapper.selectById(bookings.getRoomId())); | 
|---|
|  |  |  | //            sendWxMessage.bookingsStart(systemUserMapper.selectById(bookings.getCreator()), bookings, roomsMapper.selectById(bookings.getRoomId())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | //2、会议预定成功,给所有参会人员与预约人都发送 | 
|---|
|  |  |  | //3、会议取消 会议取消,给所有参会人员都发送 | 
|---|
|  |  |  | List<UserRel> userRelList = userRelMapper.selectList(new QueryWrapper<UserRel>() | 
|---|
|  |  |  | .eq("OBJ_TYPE", Constants.ONE) | 
|---|
|  |  |  | .eq("OBJ_TYPE", MeetConstants.ONE) | 
|---|
|  |  |  | .eq("OBJ_ID", bookings.getId()) | 
|---|
|  |  |  | .eq("ISDELETED", Constants.ZERO) | 
|---|
|  |  |  | .eq("ISDELETED", MeetConstants.ZERO) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | for (UserRel i : userRelList) { | 
|---|
|  |  |  | noticeService.sendNotice(sendType, i.getUserId(), bookings.getId(), bookings.getCreator()); | 
|---|
|  |  |  | List<Notices> noticeList = new ArrayList<>(); | 
|---|
|  |  |  | Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.MEETING_START; | 
|---|
|  |  |  | if (sendType.equals(MeetConstants.THREE)){ | 
|---|
|  |  |  | noticeObjectType = Constants.NoticeObjectType.MEETING_CACEL; | 
|---|
|  |  |  | }else   if (sendType.equals(MeetConstants.TWO)){ | 
|---|
|  |  |  | noticeObjectType = Constants.NoticeObjectType.MEETING_BOOK_SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (sendType.equals(Constants.ONE)) { | 
|---|
|  |  |  | noticeService.sendNotice(Constants.ZERO, bookings.getUserId(), bookings.getId(), bookings.getUserId()); | 
|---|
|  |  |  | } else if (sendType.equals(Constants.TWO) || sendType.equals(3)) { | 
|---|
|  |  |  | Boolean flag = true; | 
|---|
|  |  |  | if(userRelList!=null && userRelList.size()>0){ | 
|---|
|  |  |  | for (UserRel i : userRelList) { | 
|---|
|  |  |  | if (i.getUserId().equals(bookings.getCreator())) { | 
|---|
|  |  |  | flag = false; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Notices notices = new Notices(noticeObjectType,i.getId(),noticeObjectType.getInfo(), i.getUserId(), Constants.ZERO); | 
|---|
|  |  |  | noticeList.add(notices); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (flag) { | 
|---|
|  |  |  | noticeService.sendNotice(sendType, bookings.getCreator(), bookings.getId(), bookings.getCreator()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //给参会人员插入 | 
|---|
|  |  |  | Notices notices = new Notices(noticeObjectType,bookings.getId(),noticeObjectType.getInfo(),bookings.getCreator(), Constants.ZERO); | 
|---|
|  |  |  | noticeList.add(notices); | 
|---|
|  |  |  | if(noticeList.size()>0){ | 
|---|
|  |  |  | noticesMapper.insert(noticeList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | lambdaWrapper.selectAll(Bookings.class) | 
|---|
|  |  |  | .selectAs(SystemUser::getRealname, Bookings::getRealName) | 
|---|
|  |  |  | .selectAs(SystemDepartment::getName, Bookings::getDepartmentName) | 
|---|
|  |  |  | .selectAs(Company::getName, Bookings::getDepartmentName) | 
|---|
|  |  |  | .selectAs(Rooms::getName, Bookings::getRoomName) | 
|---|
|  |  |  | .select("CASE DAYOFWEEK(t.START_TIME)\n" + | 
|---|
|  |  |  | "\tWHEN 1 THEN \t\"星期日\" \tWHEN 2 THEN \"星期一\"\n" + | 
|---|
|  |  |  | 
|---|
|  |  |  | //  .leftJoin(RoomTime.class, RoomTime::getId, BookingTime::getTimeId) | 
|---|
|  |  |  | .leftJoin(SystemUser.class, SystemUser::getId, Bookings::getCreator) | 
|---|
|  |  |  | .leftJoin(Rooms.class, Rooms::getId, Bookings::getRoomId) | 
|---|
|  |  |  | .leftJoin(SystemDepartmentUser.class, SystemDepartmentUser::getUserId, Bookings::getCreator) | 
|---|
|  |  |  | .leftJoin(SystemDepartment.class, SystemDepartment::getId, SystemDepartmentUser::getDepartmentId) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,SystemUser::getCompanyId) | 
|---|
|  |  |  | .eq(Objects.nonNull(roomId), Bookings::getRoomId, roomId) | 
|---|
|  |  |  | .eq(Bookings::getIsdeleted, Constants.ZERO) | 
|---|
|  |  |  | .eq(Bookings::getStatus, Constants.ZERO) | 
|---|
|  |  |  | //  .eq(BookingTime::getIsdeleted, Constants.ZERO) | 
|---|
|  |  |  | // .eq(RoomTime::getIsdeleted, Constants.ZERO) | 
|---|
|  |  |  | .eq(Bookings::getIsdeleted, MeetConstants.ZERO) | 
|---|
|  |  |  | .eq(Bookings::getStatus, MeetConstants.ZERO) | 
|---|
|  |  |  | //  .eq(BookingTime::getIsdeleted, MeetConstants.ZERO) | 
|---|
|  |  |  | // .eq(RoomTime::getIsdeleted, MeetConstants.ZERO) | 
|---|
|  |  |  | .apply("DATE_FORMAT(t.START_TIME,'%Y-%m-%d') between '" + start + "' and '" + end + "'") | 
|---|
|  |  |  | // .between(Bookings::getStartTime,start,end ) | 
|---|
|  |  |  | //  .orderByAsc(Bookings::getRoomId) | 
|---|
|  |  |  | 
|---|
|  |  |  | return PageData.from(userStatistics); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 查询参会人员分页 | 
|---|
|  |  |  | * @param pageWrap | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public IPage<UserResponse> getUserPage(PageWrap<UserPageRequest> pageWrap) { | 
|---|
|  |  |  | IPage<UserResponse> page = systemUserMapper.getUserPage(pageWrap.toPage(),new QueryWrapper<UserResponse>() | 
|---|
|  |  |  | .and(StringUtils.isNotBlank(pageWrap.getModel().getKeyword()), i -> i.like("c.realName", pageWrap.getModel().getKeyword()) | 
|---|
|  |  |  | .or().like("d.COMPANY_NAME_PATH", pageWrap.getModel().getKeyword()) | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .eq("c.DELETED",0) | 
|---|
|  |  |  | .eq("c.status",0) | 
|---|
|  |  |  | .orderByAsc("c.id") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.FTP,Constants.MEMBER_IMG).getCode(); | 
|---|
|  |  |  | //查询是否处于会议中 | 
|---|
|  |  |  | page.getRecords().forEach(j->{ | 
|---|
|  |  |  | j.setPrefixUrl(path); | 
|---|
|  |  |  | if(bookingsMapper.selectCount(new QueryWrapper<Bookings>() | 
|---|
|  |  |  | .exists(" select 1 from meeting_user_rel u where u.OBJ_ID = meeting_book.id and  u.USER_ID = '"+j.getId()+"' and u.OBJ_TYPE = 1    ") | 
|---|
|  |  |  | .and(i -> i.between("START_TIME", pageWrap.getModel().getStartTime()+":00",pageWrap.getModel().getEndTime()+":00") | 
|---|
|  |  |  | .or().between("END_TIME", pageWrap.getModel().getStartTime()+":00",pageWrap.getModel().getEndTime()+":00") | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | )>Constants.ZERO){ | 
|---|
|  |  |  | j.setStatus(Constants.ONE); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | j.setStatus(Constants.ZERO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | return page; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|