|  |  |  | 
|---|
|  |  |  | import com.doumee.dao.business.RoomsMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.join.*; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.system.model.Multifile; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemUser; | 
|---|
|  |  |  | import com.doumee.dao.web.request.MeetingPageRequest; | 
|---|
|  |  |  | import com.doumee.dao.web.request.RoomsRequest; | 
|---|
|  |  |  | 
|---|
|  |  |  | private RoomsMapper roomsMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RoomsJoinMapper roomsJoinMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MultifileJoinMapper multifileJoinMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RoomTimeJoinMapper roomTimeJoinMapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class, Exception.class}) | 
|---|
|  |  |  | public Integer create(Rooms rooms) { | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(user ==null){ | 
|---|
|  |  |  | user = rooms.getLoginUserInfo(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | isCreateParamValid(rooms, user); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Calendar starttime = Calendar.getInstance(); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (starttime.after(endtime) || starttime.equals(endtime)) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "日期区间错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(!Constants.equalsInteger(rooms.getFileType(),Constants.TWO)&&CollectionUtils.isEmpty(rooms.getMultifileList())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未上传文件图片"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | rooms.setCreateDate(new Date()); | 
|---|
|  |  |  | rooms.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | 
|---|
|  |  |  | rooms.setStatus(Constants.ZERO); | 
|---|
|  |  |  | rooms.setEditDate(rooms.getCreateDate()); | 
|---|
|  |  |  | roomsMapper.insert(rooms); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(!Constants.equalsInteger(rooms.getFileType(),Constants.TWO)){ | 
|---|
|  |  |  | List<Multifile> multifileList = rooms.getMultifileList(); | 
|---|
|  |  |  | if(CollectionUtils.isEmpty(multifileList)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"请上传附件信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | if(Objects.isNull(multifile) | 
|---|
|  |  |  | || StringUtils.isBlank(multifile.getFileurl())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"附件参数错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifile.setCreateDate(new Date()); | 
|---|
|  |  |  | multifile.setObjId(rooms.getId()); | 
|---|
|  |  |  | multifile.setObjType(Constants.FOUR); | 
|---|
|  |  |  | multifile.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | multifile.setCreator(user.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifileJoinMapper.insert(multifileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | rooms.setStartTime(rooms.getStartTime()+":00"); | 
|---|
|  |  |  | rooms.setEndTime(rooms.getEndTime()+":00"); | 
|---|
|  |  |  | rooms.setStartTime(DateUtil.formatDate(starttime.getTime(), "yyyy-MM-dd HH:mm:ss")); | 
|---|
|  |  |  | rooms.setEndTime(DateUtil.formatDate(endtime.getTime(), "yyyy-MM-dd HH:mm:ss")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //TODO 更新会议室时间段 | 
|---|
|  |  |  | //  更新会议室时间段 | 
|---|
|  |  |  | updateRoomTimes(rooms, user); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //TODO 添加管理人员 | 
|---|
|  |  |  | //  添加管理人员 | 
|---|
|  |  |  | updateManager(rooms, user); | 
|---|
|  |  |  | //TODO 添加管服务项目 | 
|---|
|  |  |  | //  添加管服务项目 | 
|---|
|  |  |  | updateProjectRel(rooms, user); | 
|---|
|  |  |  | return rooms.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if (StringUtils.isBlank(rooms.getName()) || | 
|---|
|  |  |  | StringUtils.isBlank(rooms.getStartTime()) || | 
|---|
|  |  |  | StringUtils.isBlank(rooms.getEndTime()) || | 
|---|
|  |  |  | Objects.isNull(rooms.getFileType()) || | 
|---|
|  |  |  | rooms.getIntervalTime() == null | 
|---|
|  |  |  | ) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage()); | 
|---|
|  |  |  | 
|---|
|  |  |  | public void updateById(Rooms rooms) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(user ==null){ | 
|---|
|  |  |  | user = rooms.getLoginUserInfo(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | isCreateParamValid(rooms, user); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Calendar starttime = Calendar.getInstance(); | 
|---|
|  |  |  | 
|---|
|  |  |  | rooms.setIntervalTime(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | rooms.setEditDate(new Date()); | 
|---|
|  |  |  | rooms.setEditor(user.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        if(!Constants.equalsInteger(rooms.getFileType(),Constants.TWO)&&StringUtils.isBlank(rooms.getImgurl())){ | 
|---|
|  |  |  | //            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未上传文件图片"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        if(Constants.equalsInteger(rooms.getFileType(),Constants.TWO)){ | 
|---|
|  |  |  | //            rooms.setImgurl(null); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | roomsMapper.update(rooms, Wrappers.<Rooms>lambdaUpdate() | 
|---|
|  |  |  | .set(Rooms::getFileType, rooms.getFileType()) | 
|---|
|  |  |  | .set(Rooms::getLimitNum, rooms.getLimitNum()) | 
|---|
|  |  |  | .set(Rooms::getTips, rooms.getTips()) | 
|---|
|  |  |  | .set(Rooms::getImgurl, rooms.getImgurl()) | 
|---|
|  |  |  | .eq(Rooms::getId, rooms.getId())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | multifileJoinMapper.delete(new QueryWrapper<Multifile>().lambda() | 
|---|
|  |  |  | .eq(Multifile::getObjId,rooms.getId()) | 
|---|
|  |  |  | .eq(Multifile::getObjType,Constants.FOUR) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(!Constants.equalsInteger(rooms.getFileType(),Constants.TWO)){ | 
|---|
|  |  |  | List<Multifile> multifileList = rooms.getMultifileList(); | 
|---|
|  |  |  | if(CollectionUtils.isEmpty(multifileList)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"请上传附件信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | if(Objects.isNull(multifile) | 
|---|
|  |  |  | || StringUtils.isBlank(multifile.getFileurl())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"附件参数错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifile.setCreateDate(new Date()); | 
|---|
|  |  |  | multifile.setObjId(rooms.getId()); | 
|---|
|  |  |  | multifile.setObjType(Constants.FOUR); | 
|---|
|  |  |  | multifile.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | multifile.setCreator(user.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifileJoinMapper.insert(multifileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | rooms.setStartTime(rooms.getStartTime()+":00"); | 
|---|
|  |  |  | rooms.setEndTime(rooms.getEndTime()+":00"); | 
|---|
|  |  |  | 
|---|
|  |  |  | //   queryWrapper.leftJoin(UserRel.class,UserRel::getObjId,Rooms::getId); | 
|---|
|  |  |  | List<Integer> collect = pageWrap.getModel().getSysList().stream().map(UserRel::getUserId).collect(Collectors.toList()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | queryWrapper.exists("select u.id from user_rel u where u.ISDELETED=0 and u.OBJ_ID =t.id and  u.USER_ID in (" +     StringUtils.strip(collect.toString(),"[]")+" )"); | 
|---|
|  |  |  | queryWrapper.exists("select u.id from meeting_user_rel u where u.ISDELETED=0 and u.OBJ_ID =t.id and  u.USER_ID in (" +     StringUtils.strip(collect.toString(),"[]")+" )"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() + systemDictDataBiz.queryByCode(MeetConstants.OSS, MeetConstants.PROJECTS).getCode(); | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.FTP, Constants.FTP_RESOURCE_PATH).getCode() + systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.PROJECTS).getCode(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | IPage<Rooms> result = roomsJoinMapper.selectJoinPage(page, Rooms.class, queryWrapper); | 
|---|
|  |  |  | result.getRecords().stream().forEach(s ->{ | 
|---|
|  |  |  | 
|---|
|  |  |  | findpr.leftJoin(Projects.class,Projects::getId,ProjectRel::getProjectId); | 
|---|
|  |  |  | List<ProjectRel> projectLisr=  projectRelJoinMapper.selectJoinList(ProjectRel.class,findpr); | 
|---|
|  |  |  | s.setProjectList(projectLisr); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(!Constants.equalsInteger(s.getFileType(),Constants.TWO)){ | 
|---|
|  |  |  | List<Multifile > multifileList = multifileJoinMapper.selectList(new QueryWrapper<Multifile>().lambda() | 
|---|
|  |  |  | .eq(Multifile::getObjId,s.getId()) | 
|---|
|  |  |  | .eq(Multifile::getObjType,Constants.FOUR) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | multifile.setFileurlFull(path + multifile.getFileurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | s.setMultifileList(multifileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return PageData.from(result); | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq("STATUS",Constants.ZERO) | 
|---|
|  |  |  | .eq("ISDELETED",Constants.ZERO) | 
|---|
|  |  |  | .like(StringUtils.isNotBlank(pageWrap.getModel().getRoomsName()),"NAME",pageWrap.getModel().getRoomsName()) | 
|---|
|  |  |  | .exists(" select 1 from user_rel u where u.USER_ID = "+pageWrap.getModel().getUserId()+" and u.ISDELETED = 0 and u.OBJ_ID = rooms.id and u.OBJ_TYPE = 0  ") | 
|---|
|  |  |  | .exists(" select 1 from meeting_user_rel u where u.USER_ID = "+pageWrap.getModel().getUserId()+" and u.ISDELETED = 0 and u.OBJ_ID = rooms.id and u.OBJ_TYPE = 0  ") | 
|---|
|  |  |  | .orderByDesc("CREATE_DATE") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() | 
|---|
|  |  |  | + systemDictDataBiz.queryByCode(MeetConstants.OSS, MeetConstants.PROJECTS).getCode(); | 
|---|
|  |  |  | String prefixUrl = systemDictDataBiz.queryByCode(Constants.FTP, Constants.FTP_RESOURCE_PATH).getCode() | 
|---|
|  |  |  | + systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.PROJECTS).getCode(); | 
|---|
|  |  |  | page.getRecords().forEach(s->{ | 
|---|
|  |  |  | s.setPrefixUrl(prefixUrl); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到会议室信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() + systemDictDataBiz.queryByCode(MeetConstants.OSS, MeetConstants.PROJECTS).getCode(); | 
|---|
|  |  |  | String prefixUrl = systemDictDataBiz.queryByCode(Constants.FTP, Constants.FTP_RESOURCE_PATH).getCode() + systemDictDataBiz.queryByCode(MeetConstants.FTP, MeetConstants.PROJECTS).getCode(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | roomsResponse.setPrefixUrl(prefixUrl); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | List<ProjectRel> projectList=  projectRelJoinMapper.selectJoinList(ProjectRel.class,findProjectRel); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | roomsResponse.setProjectList(projectList); | 
|---|
|  |  |  | if(Objects.nonNull(roomsResponse.getFileType()) && !Constants.equalsInteger(roomsResponse.getFileType(),Constants.TWO)){ | 
|---|
|  |  |  | roomsResponse.setMultifileList( | 
|---|
|  |  |  | multifileJoinMapper.selectList(new QueryWrapper<Multifile>().lambda().eq(Multifile::getObjId,roomsResponse.getId()) | 
|---|
|  |  |  | .eq(Multifile::getObjType,Constants.FOUR)) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return roomsResponse; | 
|---|
|  |  |  | } | 
|---|