| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | 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.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.dao.business.dao.MemberMapper; |
| | | import com.doumee.dao.business.dao.UserActionMapper; |
| | | import com.doumee.service.business.third.model.LoginUserInfo; |
| | | import com.doumee.service.business.third.model.PageData; |
| | | import com.doumee.service.business.third.model.PageWrap; |
| | |
| | | |
| | | @Autowired |
| | | private RoomsMapper roomsMapper; |
| | | @Autowired |
| | | private UserActionMapper userActionMapper; |
| | | @Autowired |
| | | private ProjectRelJoinMapper projectRelJoinMapper; |
| | | @Autowired |
| | |
| | | |
| | | @Override |
| | | public void deleteById(Integer id,LoginUserInfo user) { |
| | | Bookings model = bookingsMapper.selectById(id); |
| | | if(model==null ||Constants.equalsInteger(Constants.ONE,model.getIsdeleted())) { |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | |
| | | Date date = new Date(); |
| | | Bookings bookings = new Bookings(); |
| | | bookings.setId(id); |
| | | bookings.setIsdeleted(MeetConstants.ONE); |
| | | bookings.setEditDate(new Date()); |
| | | bookings.setEditDate(date); |
| | | bookings.setEditor(user.getId()); |
| | | bookingsMapper.updateById(bookings); |
| | | |
| | | String[] params = new String[3]; |
| | | params[0] = user.getRealname(); |
| | | params[1]=DateUtil.getPlusTime2(date); |
| | | params[2]=model.getName()+"-【会议室:"+model.getRoomName()+" 】-【时间:"+DateUtil.getPlusTime2(model.getStartTime())+"-"+DateUtil.getPlusTime2(model.getEndTime())+"】"; |
| | | String info = Constants.UserActionType.MEET_BOOK_DEL.getInfo(); |
| | | if(params!=null){ |
| | | for (int i = 0; i < params.length; i++) { |
| | | info = info.replace("${param"+(i+1)+"}",params[i]); |
| | | } |
| | | } |
| | | UserAction userAction=new UserAction(); |
| | | userAction.setIsdeleted(Constants.ZERO); |
| | | userAction.setCreateDate(date); |
| | | userAction.setCreator(user.getId()); |
| | | userAction.setBeforeStatus(Constants.ZERO); |
| | | userAction.setType( Constants.UserActionType.MEET_BOOK_DEL.getKey()); |
| | | userAction.setContent(JSONObject.toJSONString(model)); |
| | | userAction.setRemark(info); |
| | | userAction.setMemberId(id+""); |
| | | userActionMapper.insert(userAction); |
| | | } |
| | | |
| | | @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_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.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); |
| | |
| | | SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm"); |
| | | SimpleDateFormat format1 = new SimpleDateFormat("HH:mm"); |
| | | IPage<Bookings> result = bookingsJoinMapper.selectJoinPage(page, Bookings.class, queryWrapper); |
| | | |
| | | String configMinute = systemDictDataBiz.queryByCode(MeetConstants.SYSTEM, MeetConstants.EARLY_START).getCode(); |
| | | Integer minute = StringUtils.isNotBlank(configMinute) ? Integer.valueOf(configMinute) : 120; |
| | | Integer minute =getNearStartMinut(); |
| | | result.getRecords().stream().forEach(s -> { |
| | | |
| | | if(Constants.equalsInteger(s.getStatus(),Constants.ZERO)&&Constants.equalsInteger(s.getMeetingStatus(),Constants.ONE)){ |
| | | //开始前120分钟 大于当前时间 则显示即将开始 |
| | | if( |
| | | DateUtil.afterMinutesDate(s.getStartTime(),-minute).getTime()<=System.currentTimeMillis() |
| | | ){ |
| | | s.setMeetingStatus(4); |
| | | } |
| | | } |
| | | |
| | | |
| | | if(s.getMeetingStatus().equals(Constants.ZERO)){ |
| | | if(s.getMeetingStatus()==Constants.ONE){ |
| | | //开始前120分钟 大于当前时间 则显示即将开始 |
| | | if(DateUtil.afterMinutesDate(s.getStartTime(),-120).getTime()>System.currentTimeMillis()){ |
| | | s.setMeetingStatus(4); |
| | | } |
| | | } |
| | | } |
| | | dealMeetingStatusByModel(s,minute); |
| | | MPJLambdaWrapper<Multifile> bookquery = new MPJLambdaWrapper<>(); |
| | | bookquery.eq(Multifile::getIsdeleted, MeetConstants.ZERO); |
| | | bookquery.eq(Multifile::getObjId, s.getId()); |
| | |
| | | |
| | | }); |
| | | return PageData.from(result); |
| | | } |
| | | |
| | | private void dealMeetingStatusByModel(Bookings s,Integer minute) { |
| | | //会议状态: 1=未开始;2=进行中;3=已结束 ; 4=即将开始; 5=已撤销 |
| | | //status状态 0已预约 1已撤销 2已结束 |
| | | if(Constants.equalsInteger(s.getStatus(),Constants.ONE)){ |
| | | //已撤销 |
| | | s.setMeetingStatus(Constants.FIVE); |
| | | }else if(Constants.equalsInteger(s.getStatus(),Constants.TWO)){ |
| | | //已结束 |
| | | s.setMeetingStatus(Constants.THREE); |
| | | }else if(Constants.equalsInteger(s.getStatus(),Constants.ZERO)){ |
| | | //0已预约 |
| | | if(s.getStartTimeReal() ==null){ |
| | | //如果未开始 |
| | | s.setMeetingStatus(Constants.ONE); |
| | | //开始前120分钟 大于当前时间 则显示即将开始 |
| | | if(DateUtil.afterMinutesDate(s.getStartTime(),-minute).getTime()<=System.currentTimeMillis() ){ |
| | | s.setMeetingStatus(Constants.FOUR);//则显示即将开始 |
| | | } |
| | | }else{ |
| | | //会议中 |
| | | s.setMeetingStatus(Constants.TWO); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (System.currentTimeMillis() < bookings.getStartTimeReal().getTime()) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "会议未开始,无法进行结束,如需该操作请使用取消功能"); |
| | | } |
| | | if (System.currentTimeMillis() > bookings.getEndTime().getTime()) { |
| | | /*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.setEditDate(new Date()); |
| | | bookings.setEditor(businessOverDTO.getUserId()); |
| | | bookingsMapper.updateById(bookings); |
| | | //更新已结束但未结束的会议信息为已结束 |
| | | /* //更新已结束但未结束的会议信息为已结束 |
| | | bookingsMapper.update(null,new UpdateWrapper<Bookings>() |
| | | .lambda() |
| | | .set(Bookings::getStatus,Constants.TWO) |
| | |
| | | .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){ |
| | |
| | | String prefix = systemDictDataBiz.queryByCode(MeetConstants.SYSTEM, MeetConstants.MEET_CODE_PREFIX).getCode() ; |
| | | response.setPrefix(prefix); |
| | | |
| | | String path = systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.FTP_RESOURCE_PATH) |
| | | .getCode() + systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.PROJECTS).getCode(); |
| | | 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) { |
| | |
| | | response.setMultifileList(multifileList); |
| | | } |
| | | |
| | | //查询会议列表 |
| | | |
| | | /* //查询会议列表 |
| | | List<MeetingListResponse> meetingList = bookingsMapper.meetingList( |
| | | new QueryWrapper<Bookings>() |
| | | .eq( "b.id", rooms.getId()) |
| | |
| | | .orderByAsc("a.start_time") |
| | | ); |
| | | this.dealMeetingStatus(meetingList); |
| | | response.setMeetingListResponseList(meetingList); |
| | | response.setMeetingListResponseList(meetingList);*/ |
| | | |
| | | MPJLambdaWrapper<Bookings> queryWrapper = new MPJLambdaWrapper<Bookings>() |
| | | .selectAll(Bookings.class) |
| | | .selectAs(Rooms::getName, Bookings::getRoomName) |
| | | .selectAs(Rooms::getImgurl, Bookings::getImgurl) |
| | | .selectAs(Rooms::getFileType, Bookings::getFileType) |
| | | .selectAs(SystemUser::getRealname, Bookings::getRealName) |
| | | .leftJoin(Rooms.class, Rooms::getId, Bookings::getRoomId) |
| | | .leftJoin(SystemUser.class, SystemUser::getId, Bookings::getCreator) |
| | | .eq(Bookings::getIsdeleted, MeetConstants.ZERO) |
| | | .eq(Bookings::getId, MeetConstants.ZERO) |
| | | .eq(Rooms::getId, rooms.getId()) |
| | | .apply("to_days(t.start_time) = to_days(now())")//子查询当天的 |
| | | .orderByDesc(Bookings::getStartTime); |
| | | Integer minute =getNearStartMinut(); |
| | | List<Bookings> meetingList =bookingsMapper.selectJoinList(Bookings.class,queryWrapper); |
| | | if(meetingList!=null){ |
| | | response.setMeetingListResponseList(new ArrayList<>()); |
| | | for(Bookings s : meetingList){ |
| | | dealMeetingStatusByModel(s,minute); |
| | | MeetingListResponse d = new MeetingListResponse(); |
| | | d.setId(s.getId()); |
| | | d.setRoomName(s.getRoomName()); |
| | | d.setBookingUser(s.getRealName()); |
| | | d.setMeetingStatus(s.getMeetingStatus()); |
| | | d.setPrefixUrl(path); |
| | | d.setImgUrl(s.getImgurl()); |
| | | d.setFileType(s.getFileType()); |
| | | d.setMeetingDate(DateUtil.getShortTime(s.getStartTime()));// |
| | | //CONCAT(date_format(a.START_TIME,'%H:%i') , ' ~ ',date_format(a.END_TIME,'%H:%i')) as meetingTime |
| | | d.setMeetingTime(DateUtil.formatDate(s.getStartTime(),"HH:mm")+"~"+DateUtil.formatDate(s.getEndTime(),"HH:mm")); |
| | | d.setMeetingName(s.getName()); |
| | | d.setRemark(s.getRemark()); |
| | | d.setStartTime(s.getStartTime()); |
| | | response.getMeetingListResponseList().add(d); |
| | | } |
| | | } |
| | | return response; |
| | | } |
| | | |
| | | private Integer getNearStartMinut() { |
| | | String configMinute = systemDictDataBiz.queryByCode(MeetConstants.SYSTEM, MeetConstants.EARLY_START).getCode(); |
| | | try { |
| | | return StringUtils.isNotBlank(configMinute) ? Integer.valueOf(configMinute) : 120; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return 120; |
| | | } |
| | | |
| | | |
| | | public void dealMeetingStatus(List<MeetingListResponse> meetingResponseList){ |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(meetingResponseList)){ |