예제 #1
0
    def information(self, models):

        info = []
        for m in models:
            station = m.yjstationinfo

            data = dict()
            data['id'] = m.id
            data['plc_name'] = m.plc_name
            data['station_id'] = m.station_id
            data['note'] = m.note
            data['ip'] = m.ip
            data['mpi'] = m.mpi
            data['type'] = m.type
            data['plc_type'] = m.plc_type
            data['ten_id'] = m.ten_id
            data['item_id'] = m.item_id
            data['rack'] = m.rack
            data['slot'] = m.slot
            data['tcp_port'] = m.tcp_port

            if station:
                data['station_id_num'] = station.id_num
                data['station_name'] = station.station_name
            else:
                data['station_id_num'] = None
                data['station_name'] = None

            info.append(data)

        # 返回json数据
        rp = rp_get(info, self.page, self.pages, self.total, self.per_page)

        return rp
예제 #2
0
    def information(self, group):

        info = []
        for g in group:

            data = dict()
            data['id'] = g.id
            data['group_name'] = g.group_name
            data['plc_id'] = g.plc_id
            data['upload_cycle'] = g.upload_cycle
            data['note'] = g.note
            data['ten_id'] = g.ten_id
            data['item_id'] = g.item_id
            data['upload'] = g.upload

            plc = g.yjplcinfo
            if plc:
                data['plc_name'] = plc.plc_name
            else:
                data['plc_name'] = None

            info.append(data)

        # 返回json数据
        rp = rp_get(info, self.page, self.pages, self.total, self.per_page)

        return rp
예제 #3
0
    def information(self, models):

        info = [
            dict(id=m.id,
                 station_id=m.station_id,
                 level=m.level,
                 note=m.note,
                 time=m.time) for m in models
        ]

        # 返回json数据
        rp = rp_get(info, self.page, self.pages, self.total, self.per_page)

        return rp
예제 #4
0
    def information(self, models):

        info = [
            dict(username=m.username,
                 email=m.email,
                 login_count=m.login_count,
                 last_login_ip=m.last_login_ip,
                 last_login_time=m.last_login_time,
                 role=[role.name for role in m.roles]) for m in models
        ]

        # 返回json数据
        rp = rp_get(info)

        return rp
예제 #5
0
    def information(self, models):

        # 将查询到对象数据填入字典
        info = []
        for m in models:
            data = dict()
            data['id'] = m.id
            data['id_num'] = m.id_num
            data['code'] = m.code
            data['note'] = m.note
            data['time'] = m.time

            info.append(data)

        # 返回json数据
        rp = rp_get(info, self.page, self.pages, self.total, self.per_page)

        return rp
예제 #6
0
    def information(self, models):

        info = [
            dict(id=m.id,
                 plc_id=m.yjvariableinfo.yjgroupinfo.plc_id if m.yjvariableinfo
                 and m.yjvariableinfo.yjgroupinfo else None,
                 variable_id=m.variable_id,
                 variable_name=m.yjvariableinfo.variable_name
                 if m.yjvariableinfo else None,
                 alarm_type=m.alarm_type,
                 note=m.note,
                 is_send_message=m.is_send_message) for m in models
        ]

        # 返回json数据
        rp = rp_get(info, self.page, self.pages, self.total, self.per_page)

        return rp
예제 #7
0
    def information(self, query):

        info = []
        for v in query:

            data = dict()
            data['id'] = v.id
            data['variable_id'] = v.variable_id
            data['value'] = v.value
            # print(v.value, type(v.value))
            data['time'] = v.time

            variable = v.yjvariableinfo
            if variable:
                data['variable_name'] = variable.variable_name
                data['note'] = variable.note
                group = variable.yjgroupinfo
            else:
                data['variable_name'] = None
                data['note'] = None
                group = None

            if group:
                data['group_id'] = group.id
                data['group_name'] = group.group_name
                data['plc_id'] = group.plc_id
                plc = group.yjplcinfo
            else:
                data['group_id'] = None
                data['group_name'] = None
                data['plc_id'] = None
                plc = None

            if plc:
                data['plc_name'] = plc.plc_name
            else:
                data['plc_name'] = None

            info.append(data)

        # 返回json数据
        rp = rp_get(info, self.page, self.pages, self.total, self.per_page)

        return rp
예제 #8
0
    def information(self, models):

        info = []
        for m in models:

            data = dict()
            data['id'] = m.id
            data['variable_name'] = m.variable_name
            data['group_id'] = m.group_id
            data['area'] = m.area
            data['db_num'] = m.db_num
            data['address'] = m.address
            data['data_type'] = m.data_type
            data['rw_type'] = m.rw_type
            data['upload'] = m.upload
            data['acquisition_cycle'] = m.acquisition_cycle
            data['server_record_cycle'] = m.server_record_cycle
            data['note'] = m.note
            data['ten_id'] = m.ten_id
            data['item_id'] = m.item_id
            data['write_value'] = m.write_value

            group = m.yjgroupinfo
            if group:
                data['group_name'] = group.group_name
                data['plc_id'] = group.plc_id
                plc = group.yjplcinfo
            else:
                data['group_name'] = None
                data['plc_id'] = None
                plc = None

            if plc:
                data['plc_name'] = plc.plc_name
            else:
                data['plc_name'] = None

            info.append(data)

        # 返回json数据
        rp = rp_get(info, self.page, self.pages, self.total, self.per_page)

        return rp
예제 #9
0
    def information(self, models):

        info = []
        for m in models:
            print(m)
            data = dict()
            data['id'] = m.id
            data['name'] = m.name

            variable_list = [
                dict(id=v.id, variable_name=v.variable_name) for v in m.vars
            ]

            data['variables'] = variable_list

            info.append(data)

        # 返回json数据
        rp = rp_get(info, self.page, self.pages, self.total, self.per_page)

        return rp
예제 #10
0
    def information(self, models):

        info = list()

        for m in models:
            data = dict()
            data['id'] = m.id
            data['alarm_id'] = m.alarm_id
            data['time'] = m.time

            alarm_info = m.var_alarm_info
            data['note'] = m.var_alarm_info.note if alarm_info else None
            data[
                'alarm_type'] = m.var_alarm_info.alarm_type if alarm_info else None
            data[
                'variable_id'] = m.var_alarm_info.variable_id if alarm_info else None

            var = m.var_alarm_info.yjvariableinfo if alarm_info else None

            data[
                'variable_name'] = m.var_alarm_info.yjvariableinfo.variable_name if var else None

            group = m.var_alarm_info.yjvariableinfo.yjgroupinfo if var else None
            data['plc_id'] = group.plc_id if group else None

            plc = m.var_alarm_info.yjvariableinfo.yjgroupinfo.yjplcinfo if group else None
            data['plc_name'] = plc.plc_name if plc else None
            data['station_id'] = plc.station_id if plc else None

            station = plc.yjstationinfo if plc else None
            data['station_name'] = station.station_name if station else None

            info.append(data)

        # 返回json数据
        rp = rp_get(info, self.page, self.pages, self.total, self.per_page)

        return rp
예제 #11
0
    def information(self, models):
        info = [
            dict(
                id=m.id,
                param_name=m.param_name,
                variable_id=m.variable_id,
                unit=m.unit,
            )
            for m in models
        ]

        for m in info:
            try:
                value = db.session.query(Value.value).filter(
                    Value.variable_id == m['variable_id']).order_by(Value.time.desc()).first()[0]
            except TypeError:
                value = None
            m['value'] = value

        # 返回json数据
        rp = rp_get(info, self.page, self.pages, self.total, self.per_page)

        return rp
예제 #12
0
    def information(self, models):

        info = []
        for m in models:
            data = dict()
            data['id'] = m.id
            data['station_name'] = m.station_name
            data['mac'] = m.mac
            data['ip'] = m.ip
            data['note'] = m.note
            data['id_num'] = m.id_num
            data['plc_count'] = m.plc_count
            data['ten_id'] = m.ten_id
            data['item_id'] = m.item_id
            data['modification'] = m.modification
            data['phone'] = m.phone
            data['version'] = m.version
            info.append(data)

        # 返回json数据
        rp = rp_get(info, self.page, self.pages, self.total, self.per_page)

        return rp