首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Python开发物联网数据分析平台---最近一天

Python开发物联网数据分析平台---最近一天

原创
作者头像
MiaoGIS
修改2019-11-22 17:32:17
5810
修改2019-11-22 17:32:17
举报
最近一天所有设备的数据
最近一天所有设备的数据
使用搜索框可以筛选单个或多个设备最近一天的的数据
使用搜索框可以筛选单个或多个设备最近一天的的数据

前端页面day.html代码如下:

{% extends "base.html" %}
{% block css %}
<!-- DataTables -->
<link rel="stylesheet" href="plugins/datatables-bs4/css/dataTables.bootstrap4.css">
{% end %}
{% block body %}

<div class="content-wrapper" data-menu="data day">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1>最近一天</h1>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a href="#">数据</a></li>
                        <li class="breadcrumb-item active">最近一天</li>
                    </ol>
                </div>
            </div>
        </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-12">

                <!-- /.card -->

                <div class="card">
                    <div class="card-header">
                        <h3 class="card-title">最近一天的数据</h3>
                    </div>
                    <!-- /.card-header -->
                    <div class="card-body">
                        <table id="table" class="table table-bordered table-striped"  data-filter-control="true"
  data-show-search-clear-button="true">
                            <thead>
                                <tr>
                                    <th>设备ID</th>
                                    <th data-filter-control="select">单位</th>
                                    <th>电压</th>
                                    <th>数值</th>
                                    <th>监测时间</th>
                                    <th>上传时间</th>
                                     <th>报警状态</th>
                                    <th>错误码</th>
                                </tr>
                            </thead>
                            <tbody>
                                {%set dictDevUnit0={1:"PRE(Pa)",2:"TEMP(℃)"} %} 
                                
                                {%set dictDevAlarm0={0:"正常",1:"高高报",2:"高报",3:"低报",4:"低低报"} %} 
                                 {%set dictErrorCode0={'0': '无异常', '1': '电压异常', '2': '压力异常',\
              '3': '客户网络异常', '4': '设备液位异常',\
              '5': '气体泄漏异常', '6': '位置异常', \
              '7': '温度异常', '8': '温度传感器通信故障',\
              '9': '催化传感器故障', '10': '流量异常', '11': '井盖异动',\
              '12': '门禁异常', '13': '境内液位异常', '14': '燃气阀门状态', \
              '15': '液位传感器故障'} %} 
                                {%for i in range(len(df0)) %}
                                {%set row=df0.iloc[i] %}
                                 
                                <tr>
                                    <td>{{row['DevID']}}</td>
                                    <td>{{dictDevUnit0.get(row['DevUnit'],"未知")}}</td>
                                    <td>{{row['voltage']}}</td>
                                    <td>{{row['DevData']}}</td>
                                    <td>{{row.name}}</td>
                                    <td>{{row['AddTime']}}</td>
                                    <td>{{dictDevAlarm0.get(row['DevAlarm'],"未知")}}</td>
                                    <td>{{dictErrorCode0.get(row['ErrorCode'],"未知")}}</td>
                                </tr>
                                {%end%}

                            </tbody>
                            <tfoot>
                                <tr>
                                    <th>设备ID</th>
                                    <th>单位</th>
                                    <th>电压</th>
                                    <th>数值</th>
                                    <th>监测时间</th>
                                    <th>上传时间</th>
                                     <th>报警状态</th>
                                    <th>错误码</th>
                                </tr>
                            </tfoot>
                        </table>
                    </div>
                    <!-- /.card-body -->
                </div>
                <!-- /.card -->
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
{% end %}
{% block script %}
<!-- DataTables -->
<script src="plugins/datatables/jquery.dataTables.js"></script>
<script src="plugins/datatables-bs4/js/dataTables.bootstrap4.js"></script>
<script src="static/js/day.js"></script>
{% end %}

对应的js代码day.js如下:

 $(function () {
    
    $('#table').DataTable({
      "paging": true,
      "lengthChange": true,
      "searching": true,
      "ordering": true,
      "info": true,
      "autoWidth": false,
    });
  });

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档