|  |  | 
 |  |  | 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.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()); | 
 |  |  | 
 |  |  |         updateProjectRel(bookings, user); | 
 |  |  |         handleFile(bookings, user); | 
 |  |  |         //发送会议预约成功通知 | 
 |  |  |         this.sendNotice(bookings, MeetConstants.TWO); | 
 |  |  |         if(Constants.equalsInteger(bookings.getJoinNotice(),Constants.ZERO)){ | 
 |  |  |             this.sendNotice(bookings, MeetConstants.TWO); | 
 |  |  |         } | 
 |  |  |         //发送微信订阅通知 | 
 |  |  | //        sendWxMessage.bookingsReservation(systemUserMapper.selectById(bookings.getCreator()), bookings, roomsMapper.selectById(bookings.getRoomId())); | 
 |  |  |  | 
 |  |  | 
 |  |  |         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 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); | 
 |  |  |         } | 
 |  |  | 
 |  |  |         //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; | 
 |  |  |         }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);//待发短信数据 | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  |