Ejemplo n.º 1
0
    def get_data_list(cls,
                      page,
                      is_admin,
                      uid,
                      filter_by=None,
                      filter_content=None):
        filter = {}
        if is_admin:
            if filter_content:
                if filter_by == "type":
                    filter['_type'] = EquipmentType.str2int(
                        filter_content).value
                else:
                    filter[filter_by] = filter_content
            # r = Temperature.query.join(Equipment, Equipment.id==Temperature.equ_id).filter_by(**filter)\
            #     .paginate(page, per_page=10)
            return Temperature.query.join(Equipment, Equipment.id==Temperature.equ_id).filter_by(**filter)\
                .paginate(page, per_page=PER_PAGE)

        else:
            filter['uid'] = uid
            if filter_content:
                if filter_by == "type":
                    filter['_type'] = EquipmentType.str2int(
                        filter_content).value
                else:
                    filter[filter_by] = filter_content
            return Temperature.query.join(Equipment, Equipment.id==Temperature.equ_id).filter_by(**filter)\
                .paginate(page, per_page=PER_PAGE)
Ejemplo n.º 2
0
 def get_equ_list(cls,
                  page,
                  is_admin,
                  uid,
                  filter_by=None,
                  filter_content=None):
     filter = {}
     if is_admin:
         if filter_content:
             if filter_by == 'type':
                 filter['_type'] = EquipmentType.str2enum(
                     filter_content).value
             else:
                 filter[filter_by] = filter_content
         # print(filter)
         return Equipment.query.filter_by(**filter).paginate(
             page, per_page=PER_PAGE)
     else:
         filter["uid"] = uid
         if filter_content:
             if filter_by == 'type':
                 filter['_type'] = EquipmentType.str2enum(
                     filter_content).value
             else:
                 filter[filter_by] = filter_content
         return Equipment.query.filter_by(**filter).paginate(
             page, per_page=PER_PAGE)
Ejemplo n.º 3
0
 def __init__(self, equipment):
     self.id = equipment.id
     self.no = equipment.no
     self.cm_no = equipment.cm_no
     self.name = equipment.name
     self.producer = equipment.producer
     self.phone = equipment.phone
     self.address = equipment.address
     self.type = EquipmentType.type_str(equipment.type, 'desc')
     # self.type = equipment.type
     self.latitude = equipment.latitude
     self.longitude = equipment.longitude
     # self.data_time = self.last_data['last_time']
     # self.temperature = self.last_data['temperature']
     # self.open_count = self.last_data['open_count']
     self.mm_temp_01 = equipment.mm_temp_01
     self.mm_temp_02 = equipment.mm_temp_02
     self.mm_temp_03 = equipment.mm_temp_03
     self.mm_temp_04 = equipment.mm_temp_04
     self.fm_temp_01 = equipment.fm_temp_01
     self.fm_temp_02 = equipment.fm_temp_02
     self.fm_temp_03 = equipment.fm_temp_03
     self.fm_temp_04 = equipment.fm_temp_04
     self.open_count = equipment.open_count
     self.humidity = equipment.humidity
Ejemplo n.º 4
0
 def __init__(self, switch):
     self.id = switch.id
     self.equ_id = switch.equ_id
     self.switch = SwitchEnum.desc(switch.switch, 'desc')
     self.count = switch.count
     self.create_datetime = switch.create_datetime
     self.equ_name = switch.equ_summary.name
     self.equ_no = switch.equ_summary.no
     self.equ_type = EquipmentType.type_str(switch.equ_summary.type, 'desc')
     # self.equ_type = data.equ_summary.type
     self.raw_data = switch.raw_data
Ejemplo n.º 5
0
 def __init__(self, humidity):
     self.id = humidity.id
     self.equ_id = humidity.equ_id
     self.humidity = humidity.humidity
     self.create_datetime = humidity.create_datetime
     self.equ_name = humidity.equ_summary.name
     self.equ_no = humidity.equ_summary.no
     self.equ_type = EquipmentType.type_str(humidity.equ_summary.type,
                                            'desc')
     # self.equ_type = data.equ_summary.type
     self.raw_data = humidity.raw_data
Ejemplo n.º 6
0
 def __init__(self, temperature):
     self.id = temperature.id
     self.equ_id = temperature.equ_id
     self.mm_temp_01 = temperature.mm_temp_01
     self.mm_temp_02 = temperature.mm_temp_02
     self.mm_temp_03 = temperature.mm_temp_03
     self.mm_temp_04 = temperature.mm_temp_04
     self.fm_temp_01 = temperature.fm_temp_01
     self.fm_temp_02 = temperature.fm_temp_02
     self.fm_temp_03 = temperature.fm_temp_03
     self.fm_temp_04 = temperature.fm_temp_04
     self.create_datetime = temperature.create_datetime
     self.equ_name = temperature.equ_summary.name
     self.equ_no = temperature.equ_summary.no
     self.equ_type = EquipmentType.type_str(temperature.equ_summary.type,
                                            'desc')
     # self.equ_type = data.equ_summary.type
     self.raw_data = temperature.raw_data
Ejemplo n.º 7
0
 def type(self):  # 转化成枚举
     return EquipmentType(self._type)