This commit is contained in:
xieshen 2020-10-23 12:04:33 +08:00
parent 642d65d405
commit a32d01b564
5 changed files with 128 additions and 92 deletions

View File

@ -708,11 +708,11 @@ class TimelinessMonitoring(models.Model):
counties = models.CharField('县区',max_length=256,null=True,blank=True) counties = models.CharField('县区',max_length=256,null=True,blank=True)
remark = models.CharField('备注',max_length=256,null=True,blank=True) remark = models.CharField('备注',max_length=256,null=True,blank=True)
results = models.CharField('监测结果',max_length=256,null=True,blank=True) results = models.CharField('监测结果',max_length=256,null=True,blank=True)
update = models.CharField('更新次数',max_length=256,null=True,blank=True) update = models.IntegerField('更新次数',max_length=256,null=True,blank=True)
silet = models.CharField('最大连续静默日数',max_length=256,null= True,blank=True) silet = models.IntegerField('最大连续静默日数',max_length=256,null= True,blank=True)
start_data = models.CharField('开始时间',max_length=256,null=True,blank=True) start_data = models.CharField('开始时间',max_length=256,null=True,blank=True)
end_data = models.CharField('结束时间',max_length=256,null=True,blank=True) end_data = models.CharField('结束时间',max_length=256,null=True,blank=True)
comment = models.CharField('评论次数',max_length=256,null=True,blank=True) comment = models.IntegerField('评论次数',max_length=256,null=True,blank=True)
date = models.CharField('最近更新时间',max_length=256,null=True,blank=True) date = models.CharField('最近更新时间',max_length=256,null=True,blank=True)
def __str__(self): def __str__(self):

View File

@ -78,70 +78,82 @@
<div class="content-body"> <div class="content-body">
<div class="row"> <div class="row">
<div class="col-md-2 col-sm-6 col-xs-6"> <div class="col-md-2 col-sm-6 col-xs-6">
<div class="r4_counter db_box"> <a href="{% url 'newmedia-management-edit-weixin' %}">
{# <i class='pull-left fa fa-thumbs-up icon-md icon-rounded icon-primary'></i>#} <div class="r4_counter db_box">
<img src="{% static 'dashboard/image/weixin.png' %}" {# <i class='pull-left fa fa-thumbs-up icon-md icon-rounded icon-primary'></i>#}
class='pull-left fa fa-thumbs-up '> <img src="{% static 'dashboard/image/weixin.png' %}"
<div class="stats"> class='pull-left fa fa-thumbs-up '>
<h4><strong>{{ weixin_count }}</strong></h4> <div class="stats">
<span>微信</span> <h4><strong>{{ weixin_count }}</strong></h4>
<span>微信</span>
</div>
</div> </div>
</div> </a>
</div> </div>
<div class="col-md-2 col-sm-6 col-xs-6"> <div class="col-md-2 col-sm-6 col-xs-6">
<div class="r4_counter db_box"> <a href="{% url 'newmedia-management-edit-weibo' %}">
{# <i class='pull-left fa fa-shopping-cart icon-md icon-rounded icon-orange'></i>#} <div class="r4_counter db_box">
<img src="{% static 'dashboard/image/weibo.png' %}" {# <i class='pull-left fa fa-shopping-cart icon-md icon-rounded icon-orange'></i>#}
class='pull-left fa fa-thumbs-up '> <img src="{% static 'dashboard/image/weibo.png' %}"
<div class="stats"> class='pull-left fa fa-thumbs-up '>
<h4><strong>{{ weibo_count }}</strong></h4> <div class="stats">
<span>微博</span> <h4><strong>{{ weibo_count }}</strong></h4>
<span>微博</span>
</div>
</div> </div>
</div> </a>
</div> </div>
<div class="col-md-2 col-sm-6 col-xs-6"> <div class="col-md-2 col-sm-6 col-xs-6">
<div class="r4_counter db_box"> <a href="{% url 'newmedia-management-edit-toutiao' %}">
{# <i class='pull-left fa fa-dollar icon-md icon-rounded icon-purple'></i>#} <div class="r4_counter db_box">
<img src="{% static 'dashboard/image/toutiao.png' %}" {# <i class='pull-left fa fa-dollar icon-md icon-rounded icon-purple'></i>#}
class='pull-left fa fa-thumbs-up '> <img src="{% static 'dashboard/image/toutiao.png' %}"
<div class="stats"> class='pull-left fa fa-thumbs-up '>
<h4><strong>{{ toutiao_count }}</strong></h4> <div class="stats">
<span>今日头条</span> <h4><strong>{{ toutiao_count }}</strong></h4>
<span>今日头条</span>
</div>
</div> </div>
</div> </a>
</div> </div>
<div class="col-md-2 col-sm-6 col-xs-6"> <div class="col-md-2 col-sm-6 col-xs-6">
<div class="r4_counter db_box"> <a href="{% url 'newmedia-management-edit-douyin' %}">
{# <i class='pull-left fa fa-dollar icon-md icon-rounded icon-purple'></i>#} <div class="r4_counter db_box">
<img src="{% static 'dashboard/image/douyin.jpg' %}" {# <i class='pull-left fa fa-dollar icon-md icon-rounded icon-purple'></i>#}
class='pull-left fa fa-thumbs-up '> <img src="{% static 'dashboard/image/douyin.jpg' %}"
<div class="stats"> class='pull-left fa fa-thumbs-up '>
<h4><strong>{{ douyin_count }}</strong></h4> <div class="stats">
<span>抖音</span> <h4><strong>{{ douyin_count }}</strong></h4>
<span>抖音</span>
</div>
</div> </div>
</div> </a>
</div> </div>
<div class="col-md-2 col-sm-6 col-xs-6"> <div class="col-md-2 col-sm-6 col-xs-6">
<div class="r4_counter db_box"> <a href="{% url 'newmedia-management-edit-qita' %}">
{# <i class='pull-left fa fa-users icon-md icon-rounded icon-warning'></i>#} <div class="r4_counter db_box">
<img src="{% static 'dashboard/image/qita.png' %}" {# <i class='pull-left fa fa-users icon-md icon-rounded icon-warning'></i>#}
class='pull-left fa fa-thumbs-up '> <img src="{% static 'dashboard/image/qita.png' %}"
<div class="stats"> class='pull-left fa fa-thumbs-up '>
<h4><strong>{{ qita_count }}</strong></h4> <div class="stats">
<span>其他新媒体</span> <h4><strong>{{ qita_count }}</strong></h4>
<span>其他新媒体</span>
</div>
</div> </div>
</div> </a>
</div> </div>
<div class="col-md-2 col-sm-6 col-xs-6"> <div class="col-md-2 col-sm-6 col-xs-6">
<div class="r4_counter db_box"> <a href="{% url 'organization-management-management' %}">
{# <i class='pull-left fa fa-users icon-md icon-rounded icon-warning'></i>#} <div class="r4_counter db_box">
<img src="{% static 'dashboard/image/shuliang.jpg' %}" {# <i class='pull-left fa fa-users icon-md icon-rounded icon-warning'></i>#}
class='pull-left fa fa-thumbs-up '> <img src="{% static 'dashboard/image/shuliang.jpg' %}"
<div class="stats"> class='pull-left fa fa-thumbs-up '>
<h4><strong>{{ organization_count }}</strong></h4> <div class="stats">
<span>注册单位</span> <h4><strong>{{ organization_count }}</strong></h4>
<span>注册单位</span>
</div>
</div> </div>
</div> </a>
</div> </div>
</div> <!-- End .row --> </div> <!-- End .row -->
<div class="col-lg-12"> <div class="col-lg-12">

View File

@ -65,35 +65,35 @@
</div> </div>
</div> </div>
<div class="panel-body"> {# <div class="panel-body">#}
<div class="panel panel-default"> {# <div class="panel panel-default">#}
<div class="panel-heading">热点评论</div> {# <div class="panel-heading">热点评论</div>#}
<div class="panel panel-default"> {# <div class="panel panel-default">#}
<!-- Default panel contents --> {# <!-- Default panel contents -->#}
<table class="table table-hover" style="font-size: 14px"> {# <table class="table table-hover" style="font-size: 14px">#}
<thead> {# <thead>#}
<tr> {# <tr>#}
<th style="text-align: center">新媒体类型</th> {# <th style="text-align: center">新媒体类型</th>#}
<th style="text-align: center">账号名</th> {# <th style="text-align: center">账号名</th>#}
<th style="text-align: center">评论内容</th> {# <th style="text-align: center">评论内容</th>#}
<th style="text-align: center">时间</th> {# <th style="text-align: center">时间</th>#}
<th style="text-align: center">跟评数</th> {# <th style="text-align: center">跟评数</th>#}
</tr> {# </tr>#}
</thead> {# </thead>#}
<tbody> {# <tbody>#}
<tr> {# <tr>#}
<td style="vertical-align: middle;text-align: center">{{ r.date }}</td> {# <td style="vertical-align: middle;text-align: center">{{ r.date }}</td>#}
<td style="vertical-align: middle;text-align: center">{{ r.date }}</td> {# <td style="vertical-align: middle;text-align: center">{{ r.date }}</td>#}
<td style="vertical-align: middle;text-align: center">{{ r.date }}</td> {# <td style="vertical-align: middle;text-align: center">{{ r.date }}</td>#}
<td style="vertical-align: middle;text-align: center">{{ r.date }}</td> {# <td style="vertical-align: middle;text-align: center">{{ r.date }}</td>#}
<td style="vertical-align: middle;text-align: center">{{ r.date }}</td> {# <td style="vertical-align: middle;text-align: center">{{ r.date }}</td>#}
</tr> {# </tr>#}
</tbody> {# </tbody>#}
</table> {# </table>#}
</div> {# </div>#}
{##}
</div> {# </div>#}
</div> {# </div>#}
</div> </div>
</section> </section>

View File

@ -25,15 +25,15 @@
<div class="list-group col-md-2 "> <div class="list-group col-md-2 ">
<a href="#" class="list-group-item active" style="text-align: center"> <a href="#" class="list-group-item active" style="text-align: center">
<h4 class="list-group-item-heading">新媒体数量</h4> <h4 class="list-group-item-heading">新媒体数量</h4>
<p class="list-group-item-text">288</p> <p class="list-group-item-text">{{ new_media_count }}</p>
<p class="list-group-item-text">本周新增</p> <p class="list-group-item-text">本周新增{{ new_media_count_week }}</p>
<p class="list-group-item-text">本月新增</p> <p class="list-group-item-text">本月新增{{ new_media_count_month }}</p>
</a> </a>
</div> </div>
<div class="list-group col-md-2 "> <div class="list-group col-md-2 ">
<a href="#" class="list-group-item active" style="text-align: center"> <a href="#" class="list-group-item active" style="text-align: center">
<h4 class="list-group-item-heading">内容更新次数</h4> <h4 class="list-group-item-heading">内容更新次数</h4>
<p class="list-group-item-text">288</p> <p class="list-group-item-text">{{ update_count }}</p>
<p class="list-group-item-text">本周新增次数</p> <p class="list-group-item-text">本周新增次数</p>
<p class="list-group-item-text">本月新增次数</p> <p class="list-group-item-text">本月新增次数</p>
</a> </a>
@ -57,14 +57,14 @@
<div class="list-group col-md-2 "> <div class="list-group col-md-2 ">
<a href="#" class="list-group-item active" style="text-align: center"> <a href="#" class="list-group-item active" style="text-align: center">
<h4 class="list-group-item-heading">敏感词</h4> <h4 class="list-group-item-heading">敏感词</h4>
<p class="list-group-item-text">288</p> <p class="list-group-item-text">0</p>
<p class="list-group-item-text">本周新增</p> <p class="list-group-item-text">本周新增0</p>
<p class="list-group-item-text">本月新增</p> <p class="list-group-item-text">本月新增0</p>
</a> </a>
</div> </div>
<div class="list-group col-md-2 "> <div class="list-group col-md-2 ">
<a href="#" class="list-group-item active list-group-item-success" style="text-align: center"> <a href="#" class="list-group-item active" style="text-align: center">
<h4 class="list-group-item-heading">新媒体数量</h4> <h4 class="list-group-item-heading">体数量</h4>
<p class="list-group-item-text">288</p> <p class="list-group-item-text">288</p>
<p class="list-group-item-text">本周新增</p> <p class="list-group-item-text">本周新增</p>
<p class="list-group-item-text">本月新增</p> <p class="list-group-item-text">本月新增</p>

View File

@ -1,14 +1,16 @@
import csv import csv
import datetime
import json import json
from collections import Counter from collections import Counter
import jieba import jieba
from django.db.models import Sum
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import render from django.shortcuts import render
from datetime import timedelta
# Create your views here. # Create your views here.
from dashboard.models import Weixin, Weixin_data, Toutiao_data, Weibo_data, Qita_jc, Group, Toutiao, Weibo, Qita, \ from dashboard.models import Weixin, Weixin_data, Toutiao_data, Weibo_data, Qita_jc, Group, Toutiao, Weibo, Qita, \
Douyin, Douyin_data, News Douyin, Douyin_data, News, TimelinessMonitoring, Organization, Wrongly
from monitor.models import Test from monitor.models import Test
@ -119,7 +121,29 @@ def new_media_public_opinion_qita(request):
def timeliness_monitoring(request): def timeliness_monitoring(request):
return render(request, 'monitor/timeliness-monitoring.html') now = datetime.datetime.now()
# 本周第一天和最后一天
this_week_start = now - timedelta(days=now.weekday())
this_week_end = now + timedelta(days=6 - now.weekday())
# 本月第一天和最后一天
this_month_start = datetime.datetime(now.year, now.month, 1)
this_month_end = datetime.datetime(now.year, now.month + 1, 1) - timedelta(days=1) + datetime.timedelta(
hours=23, minutes=59, seconds=59)
new_media_count = int(Weixin.objects.all().count())+int(Weibo.objects.all().count())+int(Toutiao.objects.all().count())+int(Douyin.objects.all().count())+int(Qita.objects.all().count())
new_media_count_month =int(Weixin.objects.filter(created__range=(this_month_start,this_month_end)).count())+int(Weibo.objects.filter(created__range=(this_month_start,this_month_end)).count())+int(Toutiao.objects.filter(created__range=(this_month_start,this_month_end)).count())+int(Douyin.objects.filter(created__range=(this_month_start,this_month_end)).count())+int(Qita.objects.filter(created__range=(this_month_start,this_month_end)).count())
new_media_count_week =int(Weixin.objects.filter(created__range=(this_week_start,this_week_end)).count())+int(Weibo.objects.filter(created__range=(this_week_start,this_week_end)).count())+int(Toutiao.objects.filter(created__range=(this_week_start,this_week_end)).count())+int(Douyin.objects.filter(created__range=(this_week_start,this_week_end)).count())+int(Qita.objects.filter(created__range=(this_week_start,this_week_end)).count())
# update_count = TimelinessMonitoring.objects.all().count()
update = TimelinessMonitoring.objects.all().aggregate(nums=Sum('update'))
update_count = update['nums']
comment = TimelinessMonitoring.objects.all().aggregate(nums=Sum('comment'))
comment_count = comment['nums']
wrongly_count = Wrongly.objects.all().count
sensitive_count = None
organization_count = Organization.objects.all().count()
return render(request, 'monitor/timeliness-monitoring.html',{'new_media_count':new_media_count,'new_media_count_month':new_media_count_month,'new_media_count_week':new_media_count_week,'update_count':update_count,'comment_count':comment_count,'wrongly_count':wrongly_count,'organization_count':organization_count})
def error_monitoring(request): def error_monitoring(request):