예제 #1
0
def get_rooms(least_num, minute_delta):
    room_list = []
    building = ''
    storey = 0
    dt = datetime.datetime.now()
    class_seq = getClassSeqNumByDatetime(dt, minute_delta)
    weekday = datetime.date(dt.year, dt.month, dt.day).weekday()
    while len(room_list) < least_num:
        building = get_building()
        storey = get_storey(building)
        room_list = getclassroomsbyfloor(building, storey, class_seq, weekday)
    return {
        'list': room_list,
        'building': building,
        'floor': storey,
    }
def get_rooms(least_num, minute_delta):
    dt = datetime.datetime.now()
    class_seq = getClassSeqNumByDatetime(dt, minute_delta)
    weekday = datetime.date(dt.year, dt.month, dt.day).weekday()
    building_index = 0
    floors = []
    floor_index = 0
    room_list = []
    while len(room_list) < least_num:
        building_index = random.randint(0, len(buildings) - 1)
        floors = building_storey[buildings[building_index]]
        floor_index = random.randint(0, len(floors) - 1)
        room_list = getclassroomsbyfloor(buildings[building_index], floors[floor_index], class_seq, weekday)
    return {
        'list': room_list,
        'building': buildings[building_index],
        'floor': floors[floor_index]
    }
예제 #3
0
def get_free_classroom(q_dict):
    room_list = getclassroomsbyfloor(q_dict['building_id'], q_dict['storey'],
                                     q_dict['class_sequence'], q_dict['weekday'])
    if room_list == []:
        ret = building_id_to_name(q_dict['building_id']) + q_dict['storey'] + u'层:\n无空闲教室\n'
    else:
        ret = building_id_to_name(q_dict['building_id']) + q_dict['storey'] + u'层:\n'
        count = 0
        for room in room_list:
            if count % 3 == 2:
                ret = ret + room['roomnumber'].split()[0] + '\n'
            else:
                ret = ret + room['roomnumber'].split()[0] + '   '
            count += 1
        ret = ret.rstrip()
        ret += '\n'
    ret += dash
    return ret
예제 #4
0
def get_rooms2(least_num, minute_delta):
    dt = datetime.datetime.now()
    class_seq = getClassSeqNumByDatetime(dt, minute_delta)
    weekday = datetime.date(dt.year, dt.month, dt.day).weekday()
    building_index = 0
    floors = []
    floor_index = 0
    room_list = []
    while len(room_list) < least_num:
        building_index = random.randint(0, len(buildings) - 1)
        floors = building_storey[buildings[building_index]]
        floor_index = random.randint(0, len(floors) - 1)
        room_list = getclassroomsbyfloor(buildings[building_index], floors[floor_index], class_seq, weekday)
    return {
        'list': room_list,
        'building': buildings[building_index],
        'floor': floors[floor_index]
    }
예제 #5
0
def getClassroomInfo_time_day(queryStr):
    queryDict = getBuildFloorTimeDaydelta(queryStr)
    if int(queryDict['floor']) not in building_storey[queryDict['buildID']]:
        return buildIDtoName(queryDict['buildID']) + u'没有' + queryDict['floor'] + u'层,只有' \
               + ''.join(map(lambda x: str(x)+u'、', building_storey[queryDict['buildID']])).rstrip(u'、') \
               + u'层'

    dt = datetime.datetime.now()
    weekday = datetime.date(dt.year, dt.month, dt.day).weekday()
    weekday += int(queryDict['delta'])
    if weekday not in range(7):
        return u'现在只能得到本周的教室排课信息'
    dt += datetime.timedelta(days=int(queryDict['delta']))
    roomList = getclassroomsbyfloor(queryDict['buildID'], queryDict['floor'],
                                    int(queryDict['time']), weekday)
    buildname = buildIDtoName(queryDict['buildID'])
    ret = buildname + queryDict['floor'] + u'层空闲教室:\n'
    if roomList == []:
        ret += u'无'
    else:
        for room in roomList:
            ret = ret + room['roomnumber'].split()[0] + '\n'
    ret = ret.rstrip('\n')
    return ret