/* * 读取会议室信息 创建空闲时间表 * 1.得出所有的会议室信息 HashMap * 2.得到未来两周的预定记录 ArrayList * * 再对应处理每一个会议室未来两周的空闲时间记录表 map * * map[i][j] 表示其相应的会议室距离今天第 i 天的第 j 个时间段状态 * map[i][j] = 1 表示被占用 * map[i][j] = 0表示该会议室该时间段空闲 * */ public void config() { // 所有会议室信息 allConfrenceRoomInfo = conferenceRoomDao.getAllConferenceRoomInfoToHash(); // 未来两周预定记录 bookingRecords = conferenceRecordDao.getBookingConferenceRecordVo(); // 读取 map PS:存储时完全严格按照朝九晚五的模式且半小时为一个单位, 所以读取 map 直接处理即可 for (int i = 0; i < bookingRecords.size(); i++) { ConferenceRecordVo recordVo = bookingRecords.get(i); int conferenceRoomId = recordVo.getConferenceId(); ConferenceRoomVo roomVo = allConfrenceRoomInfo.get(Integer.valueOf(conferenceRoomId)); roomVo.setFreeTimeMap(recordVo, 1); } }
// 得到所有的会议室信息 public HashMap<Integer, ConferenceRoomVo> getAllConferenceRoomInfoToHash() { HashMap<Integer, ConferenceRoomVo> AllConferenceRooms = new HashMap<Integer, ConferenceRoomVo>(); String sql = "select * from conferenceRoom"; String[] parameters = {}; ArrayList<Object[]> conferences = SqlHelper.executeQuery(sql, parameters); for (int i = 0; i < conferences.size(); i++) { Object[] ob = conferences.get(i); Integer key = Integer.valueOf(ob[0].toString()); ConferenceRoomVo conferenceRoomVo = new ConferenceRoomVo(); conferenceRoomVo.setConferenceId(Integer.parseInt(ob[0].toString())); conferenceRoomVo.setConferenceCapital(Integer.parseInt(ob[1].toString())); conferenceRoomVo.setConferenceLocation(ob[2].toString()); AllConferenceRooms.put(key, conferenceRoomVo); } return AllConferenceRooms; }