This commit is contained in:
baoliang 2020-10-25 19:49:46 +08:00
commit bc33d76de2
7 changed files with 274 additions and 89 deletions

View File

@ -685,3 +685,72 @@ class CheckCode(models.Model):
'手机验证码', max_length=256, null=True, blank=True)
phone = models.CharField('电话号', max_length=256, null=True, blank=True)
c_time = models.DateTimeField('时间', auto_now_add=True)
#新媒体舆情临时表
class NewmediaSentimentWeixin(models.Model):
id = models.UUIDField('id',primary_key=True,default=uuid.uuid4)
code = models.CharField('公众号',max_length=256,null=True,blank=True)
title = models.CharField('标题',max_length=256,null=True,blank=True)
comment_count = models.CharField('评论数',max_length=256,null=True,blank=True)
reply_count = models.CharField('回复数',max_length=256,null=True,blank=True)
date = models.CharField('发布时间',max_length=256,null=True,blank=True)
def __str__(self):
return self.title
class NewmediaSentimentWeibo(models.Model):
id = models.UUIDField('id',primary_key=True,default=uuid.uuid4)
code = models.CharField('微博号',max_length=256,null=True,blank=True)
title = models.CharField('标题',max_length=256,null=True,blank=True)
comment_count = models.CharField('评论数',max_length=256,null=True,blank=True)
reply_count = models.CharField('回复数',max_length=256,null=True,blank=True)
date = models.CharField('发布时间',max_length=256,null=True,blank=True)
def __str__(self):
return self.title
class NewmediaSentimentToutiao(models.Model):
id = models.UUIDField('id',primary_key=True,default=uuid.uuid4)
code = models.CharField('头条号',max_length=256,null=True,blank=True)
title = models.CharField('标题',max_length=256,null=True,blank=True)
comment_count = models.CharField('评论数',max_length=256,null=True,blank=True)
reply_count = models.CharField('回复数',max_length=256,null=True,blank=True)
date = models.CharField('发布时间',max_length=256,null=True,blank=True)
def __str__(self):
return self.title
#时效性监测临时表
class TimelinessMonitoring(models.Model):
id = models.UUIDField('id',primary_key=True,default=uuid.uuid4())
n_type = models.CharField('新媒体类型',max_length=256,null=True,blank=True)
n_name = models.CharField('新媒体名称',max_length=256,null=True,blank=True)
o_type = models.CharField('主体类型',max_length=256,null=True,blank=True)
o_name = models.CharField('主体名称',max_length=256,null=True,blank=True)
city = models.CharField('',null=True,blank=True,max_length=256)
counties = 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)
update = models.IntegerField('更新次数',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)
end_data = 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)
def __str__(self):
return self.n_name
#错别字临时表
class Wrongly(models.Model):
id = models.UUIDField('id',primary_key=True,default=uuid.uuid4)
error = models.CharField('错误',max_length=256,null=True,blank=True)
idea = models.CharField('建议',max_length=256,null=True,blank=True)
site = models.TextField('上下文',null=True,blank=True)
n_type = models.CharField('新媒体类型',max_length=256,null=True,blank=True)
n_name = models.CharField('新媒体名称',max_length=256,null=True,blank=True)
date = models.CharField('发布时间',max_length=256,null=True,blank=True)
title = models.CharField('标题',max_length=256,null=True,blank=True)
url = models.CharField('URL',max_length=256,null=True,blank=True)
def __str__(self):
return self.title

View File

@ -78,6 +78,7 @@
<div class="content-body">
<div class="row">
<div class="col-md-2 col-sm-6 col-xs-6">
<a href="{% url 'newmedia-management-edit-weixin' %}">
<div class="r4_counter db_box">
{# <i class='pull-left fa fa-thumbs-up icon-md icon-rounded icon-primary'></i>#}
<img src="{% static 'dashboard/image/weixin.png' %}"
@ -87,8 +88,10 @@
<span>微信</span>
</div>
</div>
</a>
</div>
<div class="col-md-2 col-sm-6 col-xs-6">
<a href="{% url 'newmedia-management-edit-weibo' %}">
<div class="r4_counter db_box">
{# <i class='pull-left fa fa-shopping-cart icon-md icon-rounded icon-orange'></i>#}
<img src="{% static 'dashboard/image/weibo.png' %}"
@ -98,8 +101,10 @@
<span>微博</span>
</div>
</div>
</a>
</div>
<div class="col-md-2 col-sm-6 col-xs-6">
<a href="{% url 'newmedia-management-edit-toutiao' %}">
<div class="r4_counter db_box">
{# <i class='pull-left fa fa-dollar icon-md icon-rounded icon-purple'></i>#}
<img src="{% static 'dashboard/image/toutiao.png' %}"
@ -109,8 +114,10 @@
<span>今日头条</span>
</div>
</div>
</a>
</div>
<div class="col-md-2 col-sm-6 col-xs-6">
<a href="{% url 'newmedia-management-edit-douyin' %}">
<div class="r4_counter db_box">
{# <i class='pull-left fa fa-dollar icon-md icon-rounded icon-purple'></i>#}
<img src="{% static 'dashboard/image/douyin.jpg' %}"
@ -120,8 +127,10 @@
<span>抖音</span>
</div>
</div>
</a>
</div>
<div class="col-md-2 col-sm-6 col-xs-6">
<a href="{% url 'newmedia-management-edit-qita' %}">
<div class="r4_counter db_box">
{# <i class='pull-left fa fa-users icon-md icon-rounded icon-warning'></i>#}
<img src="{% static 'dashboard/image/qita.png' %}"
@ -131,8 +140,10 @@
<span>其他新媒体</span>
</div>
</div>
</a>
</div>
<div class="col-md-2 col-sm-6 col-xs-6">
<a href="{% url 'organization-management-management' %}">
<div class="r4_counter db_box">
{# <i class='pull-left fa fa-users icon-md icon-rounded icon-warning'></i>#}
<img src="{% static 'dashboard/image/shuliang.jpg' %}"
@ -142,6 +153,7 @@
<span>注册单位</span>
</div>
</div>
</a>
</div>
</div> <!-- End .row -->
<div class="col-lg-12">

42
import_时效性监测.py Normal file
View File

@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
import csv
import uuid
import os
import psycopg2
from pip._vendor import chardet
# G1 = 'host=210.77.68.250 port=5432 dbname=g214_test user=g214 password=g214G214'
G2 = 'host=210.77.68.250 port=5432 dbname=newmediaDB3 user=newmedia password=newmedia2020!@#'
def insert_shixiaoxingjiance(n_type, n_name, o_type, o_name, city, counties, remark, results, update, silet,start, end):
with psycopg2.connect(G2) as connection:
with connection.cursor() as cursor:
id = uuid.uuid4()
cursor.execute(
"insert into dashboard_timelinessmonitoring(id,n_type, n_name, o_type, o_name, city, counties, remark, results, update, silet,start_data,end_data,comment,date) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,null ,null )"
, (str(id), n_type, n_name, o_type, o_name, city, counties, remark, results, update,silet,start,end))
connection.commit()
if __name__ == '__main__':
with open('D:/2020/舆论监测平台/XMTJC/数据/时效性监测临时表.csv', encoding='utf-8') as csvfile:
reader = csv.reader(csvfile)
for r in reader:
print(r)
n_type = r[0]
n_name = r[1]
o_type = r[2]
o_name = r[3]
city = r[4]
counties = r[5]
remark = r[6]
results = r[7]
update = r[8]
silet = r[9]
start = r[10]
end = r[11]
insert_shixiaoxingjiance(n_type, n_name, o_type, o_name, city, counties, remark, results, update, silet,start, end)

38
import_错别字.py Normal file
View File

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
import csv
import uuid
import os
import psycopg2
from pip._vendor import chardet
# G1 = 'host=210.77.68.250 port=5432 dbname=g214_test user=g214 password=g214G214'
G2 = 'host=210.77.68.250 port=5432 dbname=newmediaDB3 user=newmedia password=newmedia2020!@#'
def insert_shixiaoxingjiance(error, idea, site, n_type, n_name, date, title):
with psycopg2.connect(G2) as connection:
with connection.cursor() as cursor:
id = uuid.uuid4()
cursor.execute(
"insert into dashboard_wrongly(id,error, idea, site, n_type, n_name, date, title,url) values (%s,%s,%s,%s,%s,%s,%s,%s,null )"
, (str(id),error, idea, site, n_type, n_name, date, title))
connection.commit()
if __name__ == '__main__':
with open('D:/2020/舆论监测平台/XMTJC/数据/错别字临时表.csv', encoding='utf-8') as csvfile:
reader = csv.reader(csvfile)
for r in reader:
print(r)
error = r[0]
idea = r[1]
site = r[2]
n_type = r[3]
n_name = r[4]
date = r[5]
title = r[6]
insert_shixiaoxingjiance(error, idea, site, n_type, n_name, date, title)

View File

@ -65,35 +65,35 @@
</div>
</div>
<div class="panel-body">
<div class="panel panel-default">
<div class="panel-heading">热点评论</div>
<div class="panel panel-default">
<!-- Default panel contents -->
<table class="table table-hover" style="font-size: 14px">
<thead>
<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>
</tr>
</thead>
<tbody>
<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>
</tr>
</tbody>
</table>
</div>
</div>
</div>
{# <div class="panel-body">#}
{# <div class="panel panel-default">#}
{# <div class="panel-heading">热点评论</div>#}
{# <div class="panel panel-default">#}
{# <!-- Default panel contents -->#}
{# <table class="table table-hover" style="font-size: 14px">#}
{# <thead>#}
{# <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>#}
{# </tr>#}
{# </thead>#}
{# <tbody>#}
{# <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>#}
{# </tr>#}
{# </tbody>#}
{# </table>#}
{# </div>#}
{##}
{# </div>#}
{# </div>#}
</div>
</section>

View File

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

View File

@ -1,14 +1,16 @@
import csv
import datetime
import json
from collections import Counter
import jieba
from django.db.models import Sum
from django.http import HttpResponse
from django.shortcuts import render
from datetime import timedelta
# Create your views here.
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
@ -119,7 +121,29 @@ def new_media_public_opinion_qita(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):