|  |  |  | 
|---|
|  |  |  | import com.doumee.core.model.LoginUserInfo; | 
|---|
|  |  |  | import com.doumee.core.model.PageData; | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.core.utils.DESUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.DateUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.Utils; | 
|---|
|  |  |  | import com.doumee.core.utils.*; | 
|---|
|  |  |  | import com.doumee.core.wx.MeetConstants; | 
|---|
|  |  |  | import com.doumee.core.wx.SendWxMessage; | 
|---|
|  |  |  | import com.doumee.core.wx.WxPlatNotice; | 
|---|
|  |  |  | 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.dao.SmsConfigMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.dao.SmsEmailMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.join.*; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.RoomStatisticsVo; | 
|---|
|  |  |  | 
|---|
|  |  |  | import java.time.format.DateTimeFormatter; | 
|---|
|  |  |  | import java.time.temporal.TemporalAdjusters; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | private String desPwd; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BookingsMapper bookingsMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SmsConfigMapper smsConfigMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemUserMapper systemUserMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NoticesJoinMapper noticesMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SmsEmailMapper smsEmailMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UserRelMapper userRelMapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class, Exception.class}) | 
|---|
|  |  |  | public Integer create(Bookings bookings) { | 
|---|
|  |  |  | LoginUserInfo user = bookings.getLoginUserInfo(); | 
|---|
|  |  |  | Rooms rooms = roomsMapper.selectById(bookings.getRoomId()); | 
|---|
|  |  |  | if(rooms==null ){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,该会议室暂时无法预约"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | bookings.setRoomName(rooms.getName()); | 
|---|
|  |  |  | isCreateParamValid(bookings, user); | 
|---|
|  |  |  | bookings.setCreateDate(new Date()); | 
|---|
|  |  |  | bookings.setCreator(user.getId()); | 
|---|
|  |  |  | bookings.setIsdeleted(MeetConstants.ZERO); | 
|---|
|  |  |  | bookings.setStatus(MeetConstants.ZERO); | 
|---|
|  |  |  | bookingsMapper.insert(bookings); | 
|---|
|  |  |  | bookings.setManagerInfo(user.getRealname()); | 
|---|
|  |  |  | //更新会议室预定时间段 | 
|---|
|  |  |  | updateBookingTimes(bookings, user); | 
|---|
|  |  |  | //添加管理人员 | 
|---|
|  |  |  | 
|---|
|  |  |  | updateProjectRel(bookings, user); | 
|---|
|  |  |  | handleFile(bookings, user); | 
|---|
|  |  |  | //发送会议预约成功通知 | 
|---|
|  |  |  | this.sendNotice(bookings, MeetConstants.TWO); | 
|---|
|  |  |  | //发送微信订阅通知 | 
|---|
|  |  |  | sendWxMessage.bookingsReservation(systemUserMapper.selectById(bookings.getCreator()), bookings, roomsMapper.selectById(bookings.getRoomId())); | 
|---|
|  |  |  | if(Constants.equalsInteger(bookings.getJoinNotice(),Constants.ZERO)){ | 
|---|
|  |  |  | this.sendNotice(bookings, MeetConstants.TWO); | 
|---|
|  |  |  | SystemUser systemUser = systemUserMapper.selectById(user.getId()); | 
|---|
|  |  |  | this.sendWxNotice(bookings,Objects.isNull(systemUser)||StringUtils.isBlank(systemUser.getOpenid())?null:systemUser.getOpenid(),Constants.ZERO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return bookings.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | updateProjectRel(bookings, user); | 
|---|
|  |  |  | handleFile(bookings, user); | 
|---|
|  |  |  | //发送会议通知 | 
|---|
|  |  |  | this.sendNotice(bookings, MeetConstants.TWO); | 
|---|
|  |  |  | if(Constants.equalsInteger(bookings.getJoinNotice(),Constants.ZERO)){ | 
|---|
|  |  |  | this.sendNotice(bookings, MeetConstants.TWO); | 
|---|
|  |  |  | SystemUser systemUser = systemUserMapper.selectById(bookings.getUserId()); | 
|---|
|  |  |  | this.sendWxNotice(bookings,Objects.isNull(systemUser)||StringUtils.isBlank(systemUser.getOpenid())?null:systemUser.getOpenid(),Constants.ZERO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | bookings.setEditDate(new Date()); | 
|---|
|  |  |  | bookings.setEditor(user.getId()); | 
|---|
|  |  |  | bookingsMapper.updateById(bookings); | 
|---|
|  |  |  | //取消会议 发送取消通知 | 
|---|
|  |  |  | this.sendNotice(bookings, 3); | 
|---|
|  |  |  | //发送微信订阅通知 | 
|---|
|  |  |  | sendWxMessage.bookingsCancel(systemUserMapper.selectById(bookings.getCreator()), bookings, roomsMapper.selectById(bookings.getRoomId())); | 
|---|
|  |  |  | SystemUser systemUser = systemUserMapper.selectById(bookings.getCreator()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bookings.setManagerInfo(systemUser.getRealname()); | 
|---|
|  |  |  | //取消会议 发送取消通知 | 
|---|
|  |  |  | if(Constants.equalsInteger(bookings.getJoinNotice(),Constants.ZERO)){ | 
|---|
|  |  |  | this.sendNotice(bookings, 3); | 
|---|
|  |  |  | this.sendWxNotice(bookings,Objects.isNull(systemUser)||StringUtils.isBlank(systemUser.getOpenid())?null:systemUser.getOpenid(),Constants.ONE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | queryWrapper.selectAs(Rooms::getName, Bookings::getRoomName); | 
|---|
|  |  |  | queryWrapper.selectAs(SystemUser::getRealname, Bookings::getRealName); | 
|---|
|  |  |  | queryWrapper.selectAs(Company::getName, Bookings::getDepartmentName); | 
|---|
|  |  |  | queryWrapper.select(" CASE WHEN t.START_TIME > now() 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.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(Company.class,Company::getId,SystemUser::getCompanyId); | 
|---|
|  |  |  | queryWrapper.orderByDesc(Bookings::getCreateDate); | 
|---|
|  |  |  | queryWrapper.eq(Bookings::getIsdeleted, MeetConstants.ZERO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //数据权限开始--------------------start---------------- | 
|---|
|  |  |  | LoginUserInfo userInfo =pageWrap.getModel().getLoginUserInfo(); | 
|---|
|  |  |  | if(userInfo!=null && userInfo.getCompanyIdList()!=null){ | 
|---|
|  |  |  | if(  userInfo.getCompanyIdList().size() ==0){ | 
|---|
|  |  |  | //只看自己 | 
|---|
|  |  |  | queryWrapper.and(wrapper ->{ | 
|---|
|  |  |  | wrapper.eq(Bookings::getCreator,userInfo.getId()) | 
|---|
|  |  |  | .or().exists("select rel.id from meeting_user_rel rel where rel.OBJ_TYPE=0 and rel.obj_id=t.id and rel.isdeleted=0 and rel.user_id="+userInfo.getId()); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | queryWrapper.eq(Bookings::getCreator,userInfo.getId()); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //权限范围内 | 
|---|
|  |  |  | queryWrapper.and(wrapper ->{ | 
|---|
|  |  |  | wrapper.in(SystemUser::getCompanyId ,userInfo.getCompanyIdList()) | 
|---|
|  |  |  | .or().exists("select rel.id from meeting_user_rel rel where rel.OBJ_TYPE=0 and rel.obj_id=t.id and rel.isdeleted=0 and rel.user_id="+userInfo.getId()); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //数据权限开始--------------------end---------------- | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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, Company::getId, pageWrap.getModel().getDepartmentId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | queryWrapper.apply(Objects.nonNull(pageWrap.getModel().getMeetingStatus()) | 
|---|
|  |  |  | &&Constants.equalsInteger(pageWrap.getModel().getMeetingStatus(),Constants.ONE), | 
|---|
|  |  |  | 
|---|
|  |  |  | .orderByAsc(Constants.equalsInteger(pageWrap.getModel().getQueryType(),MeetConstants.ONE),"a.START_TIME"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | IPage<MeetingListResponse> page = bookingsMapper.myMeetingPage(pageWrap.toPage(), queryWrapper); | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.FTP_RESOURCE_PATH).getCode() + systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.PROJECTS).getCode(); | 
|---|
|  |  |  | page.getRecords().forEach(i -> { | 
|---|
|  |  |  | i.setPrefixUrl(path); | 
|---|
|  |  |  | if(i.getMeetingStatus().equals(Constants.ZERO)){ | 
|---|
|  |  |  | if(i.getMeetingStatus()==Constants.ONE){ | 
|---|
|  |  |  | //开始前120分钟 大于当前时间 则显示即将开始 | 
|---|
|  |  |  | if(DateUtil.afterMinutesDate(i.getStartTime(),-120).getTime()>System.currentTimeMillis()){ | 
|---|
|  |  |  | i.setMeetingStatus(4); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | this.dealMeetingStatus(page.getRecords()); | 
|---|
|  |  |  | return page; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | if(Objects.isNull(bookings)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return getMeetingDetail(bookings.getId()); | 
|---|
|  |  |  | return getMeetingDetail(bookings.getId(),null); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | * @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(), "未查询到会议详情"); | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq("BOOKING_ID", id) | 
|---|
|  |  |  | .eq("ISDELETED", MeetConstants.ZERO) | 
|---|
|  |  |  | )); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //参会人员列表 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<UserResponse> userResponseList = systemUserService.getUserList(id); | 
|---|
|  |  |  | String avatarPath = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.FTP,Constants.MEMBER_IMG).getCode(); | 
|---|
|  |  |  | userResponseList.forEach(i -> { | 
|---|
|  |  |  | if(StringUtils.isNotBlank(i.getAvatar())){ | 
|---|
|  |  |  | if(StringUtils.isNotBlank(i.getAvatar()) && !i.getAvatar().startsWith("HKIMG") ){ | 
|---|
|  |  |  | i.setAvatar(avatarPath+i.getAvatar()); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | i.setAvatar(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | meetingDetailResponse.setUserResponseList(userResponseList); | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq("OBJ_ID", meetingDetailResponse.getRoomId()) | 
|---|
|  |  |  | .eq("OBJ_TYPE",MeetConstants.ZERO) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!bookings.getCreator().equals(businessOverDTO.getUserId())) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "非你的预约记录,无法进行取消"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (System.currentTimeMillis() > bookings.getStartTime().getTime()) { | 
|---|
|  |  |  | if (Objects.nonNull(bookings.getStartTimeReal()) && System.currentTimeMillis() > bookings.getStartTimeReal().getTime()) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "会议已开始,无法进行取消"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(bookings.getStatus().equals(MeetConstants.ONE)){ | 
|---|
|  |  |  | 
|---|
|  |  |  | bookings.setStatus(MeetConstants.ONE); | 
|---|
|  |  |  | bookings.setEditDate(new Date()); | 
|---|
|  |  |  | bookings.setEditor(businessOverDTO.getUserId()); | 
|---|
|  |  |  | Rooms rooms = roomsMapper.selectById(bookings.getRoomId()); | 
|---|
|  |  |  | if(Objects.nonNull(rooms)){ | 
|---|
|  |  |  | bookings.setRoomName(rooms.getName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | bookingsMapper.updateById(bookings); | 
|---|
|  |  |  | //取消会议 发送取消通知 | 
|---|
|  |  |  | this.sendNotice(bookings, 3); | 
|---|
|  |  |  | //发送微信订阅通知 | 
|---|
|  |  |  | sendWxMessage.bookingsCancel(systemUserMapper.selectById(bookings.getCreator()), bookings, roomsMapper.selectById(bookings.getRoomId())); | 
|---|
|  |  |  | //        if(Constants.equalsInteger(bookings.getJoinNotice(),Constants.ZERO)){ | 
|---|
|  |  |  | //            this.sendNotice(bookings, 3); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | SystemUser systemUser = systemUserMapper.selectById(bookings.getCreator()); | 
|---|
|  |  |  | bookings.setManagerInfo(systemUser.getRealname()); | 
|---|
|  |  |  | this.sendWxNotice(bookings,Objects.isNull(systemUser)||StringUtils.isBlank(systemUser.getOpenid())?null:systemUser.getOpenid(),Constants.ONE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | Long userRelList = userRelMapper.selectCount(new QueryWrapper<UserRel>().lambda() | 
|---|
|  |  |  | .eq(UserRel::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(UserRel::getObjId,bookings.getRoomId()) | 
|---|
|  |  |  | .eq(UserRel::getObjType,Constants.ONE) | 
|---|
|  |  |  | .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()) { | 
|---|
|  |  |  | if (System.currentTimeMillis() < bookings.getStartTimeReal().getTime()) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "会议未开始,无法进行结束,如需该操作请使用取消功能"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (System.currentTimeMillis() > bookings.getEndTime().getTime()) { | 
|---|
|  |  |  | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | String localPath = systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.FTP_LOCAL_RESOURCE_PATH) | 
|---|
|  |  |  | .getCode() + systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.PROJECTS).getCode(); | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | multifile.setFileurlFull(path + multifile.getFileurl()); | 
|---|
|  |  |  | multifile.setLocalFileurlFull(localPath + 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) | 
|---|
|  |  |  | .ne("a.status",Constants.TWO) | 
|---|
|  |  |  | .like("a.start_time",DateUtil.getCurrDate()) | 
|---|
|  |  |  | .apply(" not exists ( select 1  from  meeting_book mb where mb.END_TIME < now() and  mb.id = a.id and START_TIME_REAL is null  )   ") | 
|---|
|  |  |  | .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.EARLY_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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 定时发送会议 即将开始通知 | 
|---|
|  |  |  | 
|---|
|  |  |  | bookings.setEditDate(new Date()); | 
|---|
|  |  |  | bookingsMapper.updateById(bookings); | 
|---|
|  |  |  | 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())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | //1、参与会议:参与会议即将开始  给每个参会人员发送会议通知并且给会议预约人发送预定的会议即将开始 如果预订人也参与会议,则会有2条会议通知 | 
|---|
|  |  |  | //2、会议预定成功,给所有参会人员与预约人都发送 | 
|---|
|  |  |  | //3、会议取消 会议取消,给所有参会人员都发送 | 
|---|
|  |  |  | List<UserRel> userRelList = userRelMapper.selectList(new QueryWrapper<UserRel>() | 
|---|
|  |  |  | .eq("OBJ_TYPE", MeetConstants.ONE) | 
|---|
|  |  |  | .eq("OBJ_ID", bookings.getId()) | 
|---|
|  |  |  | .eq("ISDELETED", MeetConstants.ZERO) | 
|---|
|  |  |  | List<UserRel> userRelList = userRelMapper.selectJoinList(UserRel.class,new MPJLambdaWrapper<UserRel>() | 
|---|
|  |  |  | .selectAll(UserRel.class) | 
|---|
|  |  |  | .selectAs(SystemUser::getRealname,UserRel::getRealName) | 
|---|
|  |  |  | .selectAs(SystemUser::getMobile,UserRel::getUserPhone) | 
|---|
|  |  |  | .leftJoin(SystemUser.class,SystemUser::getId,UserRel::getUserId) | 
|---|
|  |  |  | .eq(UserRel::getObjType, MeetConstants.ONE) | 
|---|
|  |  |  | .eq(UserRel::getObjId, bookings.getId()) | 
|---|
|  |  |  | .eq(UserRel::getIsdeleted, MeetConstants.ZERO) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | List<SmsEmail> smsEmailList = new ArrayList<>(); | 
|---|
|  |  |  | List<Notices> noticeList = new ArrayList<>(); | 
|---|
|  |  |  | SmsConfig smsConfig = null; | 
|---|
|  |  |  | Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.MEETING_START; | 
|---|
|  |  |  | if (sendType.equals(MeetConstants.THREE)){ | 
|---|
|  |  |  | noticeObjectType = Constants.NoticeObjectType.MEETING_CACEL; | 
|---|
|  |  |  | smsConfig   = smsConfigMapper.selectOne(new QueryWrapper<SmsConfig>().lambda().eq(SmsConfig::getCode, | 
|---|
|  |  |  | SmsConstants.meetingContent.meetingBookCancel) | 
|---|
|  |  |  | .eq(SmsConfig::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .last(" limit 1 ")); | 
|---|
|  |  |  | }else   if (sendType.equals(MeetConstants.TWO)){ | 
|---|
|  |  |  | noticeObjectType = Constants.NoticeObjectType.MEETING_BOOK_SUCCESS; | 
|---|
|  |  |  | smsConfig   = smsConfigMapper.selectOne(new QueryWrapper<SmsConfig>().lambda().eq(SmsConfig::getCode, | 
|---|
|  |  |  | SmsConstants.meetingContent.meetingBookJoinUser) | 
|---|
|  |  |  | .eq(SmsConfig::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .last(" limit 1 ")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(userRelList!=null && userRelList.size()>0){ | 
|---|
|  |  |  | for (UserRel i : userRelList) { | 
|---|
|  |  |  | Notices notices = new Notices(noticeObjectType,i.getId(),noticeObjectType.getInfo(), i.getUserId(), Constants.ZERO); | 
|---|
|  |  |  | noticeList.add(notices); | 
|---|
|  |  |  | if (smsConfig!=null && Constants.equalsInteger(smsConfig.getStatus(),Constants.ZERO)){ | 
|---|
|  |  |  | SmsEmail smsEmail = new SmsEmail(); | 
|---|
|  |  |  | //{参会人员姓名},您好!您有一个新的会议,会议主题:{会议主题},会议地点:{会议室名称},会议时间:{会议时间段},请按时参加 | 
|---|
|  |  |  | String timeInfo =DateUtil.getFomartDate( bookings.getStartTime(),"MM/dd HH:mm")+"-" | 
|---|
|  |  |  | +DateUtil.getFomartDate( bookings.getEndTime(),"HH:mm"); | 
|---|
|  |  |  | smsEmail.setPhone(i.getUserPhone()); | 
|---|
|  |  |  | smsEmail.setRemark("等待发送"); | 
|---|
|  |  |  | smsEmail.setStatus(Constants.TWO);// | 
|---|
|  |  |  | smsEmail.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | smsEmail.setType(Constants.ZERO); | 
|---|
|  |  |  | smsEmail.setObjId(bookings.getId()); | 
|---|
|  |  |  | smsEmail.setCreateDate(new Date()); | 
|---|
|  |  |  | smsEmail.setTitle("会议室申请参会通知"); | 
|---|
|  |  |  | smsEmail.setContent(StringUtils.defaultString(smsConfig.getContent(),"") | 
|---|
|  |  |  | .replace("{参会人员姓名}",StringUtils.defaultString(i.getRealName(),"")) | 
|---|
|  |  |  | .replace("{会议主题}",StringUtils.defaultString(bookings.getName(),"")) | 
|---|
|  |  |  | .replace("{会议室名称}",StringUtils.defaultString(bookings.getRoomName(),"")) | 
|---|
|  |  |  | .replace("{会议时间段}",StringUtils.defaultString(timeInfo,""))); | 
|---|
|  |  |  | smsEmailList.add(smsEmail); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //给参会人员插入 | 
|---|
|  |  |  | 
|---|
|  |  |  | if(noticeList.size()>0){ | 
|---|
|  |  |  | noticesMapper.insert(noticeList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(smsEmailList.size()>0){ | 
|---|
|  |  |  | smsEmailMapper.insert(smsEmailList);//待发短信数据 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Async | 
|---|
|  |  |  | public void sendWxNotice(Bookings bookings,String openid, Integer sendType) { | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | List<UserRel> userRelList = userRelMapper.selectJoinList(UserRel.class,new MPJLambdaWrapper<UserRel>() | 
|---|
|  |  |  | .selectAll(UserRel.class) | 
|---|
|  |  |  | .selectAs(SystemUser::getRealname,UserRel::getRealName) | 
|---|
|  |  |  | .selectAs(SystemUser::getMobile,UserRel::getUserPhone) | 
|---|
|  |  |  | .selectAs(SystemUser::getOpenid,UserRel::getOpenid) | 
|---|
|  |  |  | .leftJoin(SystemUser.class,SystemUser::getId,UserRel::getUserId) | 
|---|
|  |  |  | .eq(UserRel::getObjType, MeetConstants.ONE) | 
|---|
|  |  |  | .eq(UserRel::getObjId, bookings.getId()) | 
|---|
|  |  |  | .eq(UserRel::getIsdeleted, MeetConstants.ZERO) | 
|---|
|  |  |  | .isNotNull(SystemUser::getOpenid) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | List<String> openIdList = userRelList.stream().map(i->i.getOpenid()).collect(Collectors.toList()); | 
|---|
|  |  |  | openIdList.add(openid); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(openIdList)){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Set<String> openIds = new HashSet<String>(openIdList); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(openIds)){ | 
|---|
|  |  |  | WxPlatNotice wxPlatNotice = new WxPlatNotice(); | 
|---|
|  |  |  | if(Constants.equalsInteger(sendType,Constants.ZERO)){ | 
|---|
|  |  |  | wxPlatNotice.sendMeetingBookTemplateNotice(systemDictDataBiz,bookings,"CuoDoxOl6SFwi4NhNgOQgKSJVjDD4VCIaPYlnbv_zdY", | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.WX_PLATFORM, Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(),openIds); | 
|---|
|  |  |  | }else if(Constants.equalsInteger(sendType,Constants.ONE)){ | 
|---|
|  |  |  | wxPlatNotice.sendMeetingBookCancelTemplateNotice(systemDictDataBiz,bookings,"CiB6vCT2InovAoQfudY-lvzLSV0-3lfz3a5GsSFCzd8", | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.WX_PLATFORM, Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(),openIds); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | .eq("c.DELETED",0) | 
|---|
|  |  |  | .eq("c.status",0) | 
|---|
|  |  |  | .eq("m.WORK_STATUS",0) | 
|---|
|  |  |  | .orderByAsc("c.id") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() | 
|---|