#add message

This commit is contained in:
xieshen 2021-01-07 12:04:02 +08:00
parent 3d3d94640d
commit 44e9e65d37
12 changed files with 1465 additions and 598 deletions

View File

@ -420,19 +420,14 @@ class Weixin(NewMedia):
# 微信文章采集
class Weixin_data(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
title = models.CharField('文章标题', max_length=256, null=True, blank=True)
site = models.CharField('位置', max_length=256, null=True, blank=True)
year = models.CharField('', max_length=256, null=True, blank=True)
month = models.CharField('', max_length=256, null=True, blank=True)
day = models.CharField('', max_length=256, null=True, blank=True)
original = models.BooleanField('是否原创', null=True, blank=True)
url = models.CharField('文章链接', max_length=256, null=True, blank=True)
author = models.CharField('作者', max_length=256, null=True, blank=True)
comment = models.CharField('评论数', max_length=256, null=True, blank=True)
reply = models.CharField('作者回复数', max_length=256, null=True, blank=True)
content = models.TextField('正文', null=True, blank=True)
weixin = models.ForeignKey(
Weixin, on_delete=models.CASCADE, null=True, blank=True)
mp = models.CharField('mp',max_length=256,null=True,blank=True)
title = models.CharField('标题',max_length=256,null=True,blank=True)
content = models.TextField('content',null=True,blank=True)
author = models.CharField('author',max_length=256,null=True,blank=True)
timestamp = models.CharField('timestamp',max_length=256,null=True,blank=True)
link = models.CharField('link',max_length=2560,null=True,blank=True)
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
@ -549,16 +544,27 @@ class Toutiao_data(models.Model):
# 今日头条评论
class Toutiao_comment(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
comment = models.TextField('评论', null=True, blank=True)
user = models.CharField('用户', max_length=256, null=True, blank=True)
reply = models.TextField('回复', null=True, blank=True)
toutiao = models.ForeignKey(
Toutiao, on_delete=models.CASCADE, null=True, blank=True)
# comment = models.TextField('评论', null=True, blank=True)
# user = models.CharField('用户', max_length=256, null=True, blank=True)
# reply = models.TextField('回复', null=True, blank=True)
# toutiao = models.ForeignKey(
# Toutiao, on_delete=models.CASCADE, null=True, blank=True)
type = models.CharField('type',max_length=256,null=True,blank=True)
tid = models.CharField('tid',max_length=256,null=True,blank=True)
cid = models.CharField('cid',max_length=256,null=True,blank=True)
rid = models.CharField('rid',max_length=256,null=True,blank=True)
username = models.CharField('username',max_length=256,null=True,blank=True)
content = models.TextField('content',null=True,blank=True)
time = models.CharField('time',max_length=256,null=True,blank=True)
reply_count = models.IntegerField('reply_count',null=True,blank=True)
diggcount = models.IntegerField('diggcount',null=True,blank=True)
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.user
return self.username
# 今日头条错别字

View File

@ -7,6 +7,50 @@
crossorigin=""/>
<link href="{% static 'dashboard/css/legend.css' %}" rel="stylesheet">
<!-- OTHER SCRIPTS INCLUDED ON THIS PAGE - END -->
<!-- 动态列表 - START -->
<style>
#express li {
height: 25px;
border-bottom: dashed 1px #999;
line-height: 20px;
font-size: 12px;
list-style: none;
}
#dome {
height: 580px;
overflow: hidden;
margin-top: 0px;
}
#book_class {
width: 100%;
height: 600px;
border: 3px solid #999;
margin-left: auto;
margin-right: auto;
margin-top: 30px;
border-radius: 5px 5px 5px 5px;
box-shadow: 0px 0px 10px 10px #CECED1;
}
#express {
margin-left: -30px;
margin-right: 10px;
margin-bottom: 0px;
margin-top: 0px;
}
#book_class div div ul li a {
text-decoration: none;
color: #333333;
}
#book_class div div ul li a:hover {
text-decoration: underline;
}
</style>
<!-- 动态列表 - END -->
{% endblock %}
{% block content %}
<!-- START TOPBAR -->
@ -194,7 +238,7 @@
<div class="col-lg-6 col-md-6 col-sm-7 col-xs-12" style="background-color: white">
<span class='bold'>更新次数/时间</span>
<span class='bold'>更新次数/时间(天)</span>
<div id="main" style="width: 100%;height:400px;"></div>
</div>
@ -202,17 +246,44 @@
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="col-md-8 col-sm-8 col-xs-8">
<div id="map" style="width: 100%;height: 600px;margin-top: 30px">
{# <div class="legend">#}
{# <div style="background: white;text-align: center;color: black">更新次数</div>#}
{# <img src="http://210.77.68.250:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=newmedia:gansu&STYLE=newmedia:newmedia_gansu_shidaima">#}
{# </div>#}
{# <div class="legend">#}
{# <div style="background: white;text-align: center;color: black">更新次数</div>#}
{# <img src="http://210.77.68.250:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=newmedia:gansu&STYLE=newmedia:newmedia_gansu_shidaima">#}
{# </div>#}
</div>
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
<div id="book_class">
<div id="dome">
<div id="dome1">
<ul id="express">
{% for w in weixin_data %}
{% if w.title|length > 20 %}
<li><a href="#">{{ w.title|slice:"20" }}...</a>
<div style="display: inline-block;float: right">
<span>{% if w.mp|length > 10 %}{{ w.mp|slice:"10" }}
...{% else %}{{ w.mp }}{% endif %}</span></div>
</li>
{% else %}
<li><a href="#">{{ w.title }}</a>
<div style="display: inline-block;float: right">
<span>{% if w.mp|length > 10 %}{{ w.mp|slice:"10" }}
...{% else %}{{ w.mp }}{% endif %}</span></div>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
<div id="dome2"></div>
</div>
</div>
</div>
</div> <!-- End .row -->
<div style="height: 200px"></div>
<div style="height: 50px"></div>
</div>
</section>
</div>
@ -251,128 +322,175 @@
<script src="{% static 'leaflet/leaflet.NonTiledLayer.js' %}" type="text/javascript"></script>
<script src="{% static 'monitor/js/index-map.js' %}" type="text/javascript"></script>
<script>
$.getJSON('/monitor/timeliness/monitoring/json/', function (res) {
$.getJSON('/monitor/index/update/count/', function (res) {
// 基于准备好的dom初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));
option = {
{#title: {#}
{# text: '更新次数/时间',#}
{# top: '-2%'#}
{# },#}
tooltip: {
trigger: 'axis'
},
legend: {
data: ['兰州市', '嘉峪关市', '金昌市', '酒泉市', '张掖市', '武威市', '白银市', '天水市', '平凉市', '庆阳市', '定西市', '陇南市', '甘南州', '临夏州']
},
grid: {
left: '3%',
right: '8%',
bottom: '1%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: res.date
},
yAxis: {
type: 'value'
},
series: [
{
name: '兰州市',
type: 'line',
stack: '总量',
data: res.lanzhou
$.getJSON('/monitor/index/update/count/', function (res) {
// 基于准备好的dom初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));
option = {
title: {
{#text: '更新次数/时间(天)',#}
{#subtext: '数据来自西安兰特水电测控技术有限公司',#}
left: 'center',
align: 'right',
top: 60
},
{
name: '嘉峪关市',
type: 'line',
stack: '总量',
data: res.jiayuguan
grid: {
bottom: 80,
top: 80
},
{
name: '金昌市',
type: 'line',
stack: '总量',
data: res.jinchang
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
animation: false,
label: {
backgroundColor: '#505765'
}
}
},
{
name: '酒泉市',
type: 'line',
stack: '总量',
data: res.jiuquan
legend: {
data: ['兰州市', '嘉峪关市', '金昌市', '酒泉市', '张掖市', '武威市', '白银市', '天水市', '平凉市', '庆阳市', '定西市', '陇南市', '甘南州', '临夏州', '合格率'],
left: 10
},
{
name: '张掖市',
type: 'line',
stack: '总量',
data: res.zhangye
},
{
name: '武威市',
type: 'line',
stack: '总量',
data: res.wuwei
},
{
name: '白银市',
type: 'line',
stack: '总量',
data: res.baiyin
},
{
name: '天水市',
type: 'line',
stack: '总量',
data: res.tianshui
},
{
name: '平凉市',
type: 'line',
stack: '总量',
data: res.pingliang
},
{
name: '庆阳市',
type: 'line',
stack: '总量',
data: res.qingyang
},
{
name: '定西市',
type: 'line',
stack: '总量',
data: res.dingxi
},
{
name: '陇南市',
type: 'line',
stack: '总量',
data: res.longnan
},
{
name: '甘南州',
type: 'line',
stack: '总量',
data: res.gannan
},
{
name: '临夏州',
type: 'line',
stack: '总量',
data: res.linxia
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
dataZoom: [
{
show: true,
realtime: true,
start: 0,
end: 50
},
{
type: 'inside',
realtime: true,
start: 0,
end: 50
}
],
xAxis: [
{
type: 'category',
boundaryGap: false,
axisLine: {onZero: false},
data: res.date.map(function (str) {
return str.replace(' ', '\n');
})
}
],
yAxis: [
{
name: '更新量',
type: 'value',
}
],
series: [
{
name: '兰州市',
type: 'line',
stack: '总量',
barWidth: 20,
data: res.lanzhou
},
{
name: '嘉峪关市',
type: 'line',
stack: '总量',
barWidth: 20,
data: res.jiayuguan
},
{
name: '金昌市',
type: 'line',
stack: '总量',
barWidth: 20,
data: res.jinchang
},
{
name: '酒泉市',
type: 'line',
stack: '总量',
barWidth: 20,
data: res.jiuquan
},
{
name: '张掖市',
type: 'line',
stack: '总量',
barWidth: 20,
data: res.zhangye
},
{
name: '武威市',
type: 'line',
stack: '总量',
barWidth: 20,
data: res.wuwei
},
{
name: '白银市',
type: 'line',
stack: '总量',
barWidth: 20,
data: res.baiyin
},
{
name: '天水市',
type: 'line',
stack: '总量',
barWidth: 20,
data: res.tianshui
},
{
name: '平凉市',
type: 'line',
stack: '总量',
barWidth: 20,
data: res.pingliang
},
{
name: '庆阳市',
type: 'line',
stack: '总量',
barWidth: 20,
data: res.qingyang
},
{
name: '定西市',
type: 'line',
stack: '总量',
barWidth: 20,
data: res.dingxi
},
{
name: '陇南市',
type: 'line',
stack: '总量',
barWidth: 20,
data: res.longnan
},
{
name: '甘南州',
type: 'line',
stack: '总量',
barWidth: 20,
data: res.gannan
},
{
name: '临夏州',
type: 'line',
stack: '总量',
barWidth: 20,
data: res.linxia
}
]
}
;
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
});
})
$.getJSON('/monitor/index/newmedia/count/', function (res) {
@ -592,5 +710,25 @@
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
})
var dome = document.getElementById("dome");
var dome1 = document.getElementById("dome1");
var dome2 = document.getElementById("dome2");
var speed = 400;//设置向上轮动的速度
dome2.innerHTML = dome1.innerHTML;//复制节点
function moveTop() {
if (dome1.offsetHeight - dome.scrollTop <= 0) {
dome.scrollTop = 0;
} else {
dome.scrollTop++;
}
}
var myFunction = setInterval("moveTop()", speed);
dome.onmouseover = function () {
clearInterval(myFunction);
}
dome.onmouseout = function () {
myFunction = setInterval(moveTop, speed);
}
</script>
{% endblock %}

View File

@ -23,7 +23,7 @@ import datetime
# Create your views here.
from dashboard.models import Userprofile, Organization, Area_code_2020, Weixin, Weibo, Toutiao, Qita, News, Douyin, \
CheckCode, Group, Group_admin, Group_user, TimelinessMonitoring
CheckCode, Group, Group_admin, Group_user, TimelinessMonitoring, Weixin_data
from dashboard.yunpian import YunPian
import os
@ -50,15 +50,24 @@ def home(request):
def index(request):
data = []
weixin_count = Weixin.objects.all().count()
weibo_count = Weibo.objects.all().count()
toutiao_count = Toutiao.objects.all().count()
qita_count = Qita.objects.all().count()
douyin_count = Douyin.objects.all().count()
organization_count = Organization.objects.filter(status='1').count()
weixin_data = Weixin_data.objects.all().order_by('-timestamp')[:100]
for w in weixin_data:
o = dict()
o['id'] = str(w.id)
o['title'] = w.title
o['timestamp'] = w.timestamp
o['mp'] = w.mp
data.append(o)
return render(request, 'dashboard/index.html',
{'weixin_count': weixin_count, 'weibo_count': weibo_count, 'toutiao_count': toutiao_count,
'qita_count': qita_count, 'douyin_count': douyin_count, 'organization_count': organization_count})
'qita_count': qita_count, 'douyin_count': douyin_count, 'organization_count': organization_count,'weixin_data':data})
def user_login(request):

View File

@ -1,16 +0,0 @@
import pymysql
host = "210.72.82.249"
user = "pom"
password = "pomWechat2020"
port = 3306
database = 'pomdb'
mysql = pymysql.connect(host=host,user=user,password=password,port=port,database=database)
cursor = mysql.cursor()
sql = 'select * from toutiao_article where id = "65226"'
cursor.execute(sql)
results = cursor.fetchall()
for r in results:
print(r)

View File

@ -0,0 +1,52 @@
import uuid
import psycopg2
import pymysql
host = "210.72.82.249"
user = "pom"
password = "pomWechat2020"
port = 3306
database = 'pomdb'
mysql = pymysql.connect(host=host,user=user,password=password,port=port,database=database)
cursor = mysql.cursor()
G2 = 'host=210.77.68.250 port=5432 dbname=newmediaDB3 user=newmedia password=newmedia2020!@#'
def insert(toutiao_id, tid, celltype, title, content, time, url, commentcount, readnum, likenum,shownum):
try:
with psycopg2.connect(G2) as connection:
with connection.cursor() as cursor1:
cursor1.execute("select * from dashboard_toutiao where toutiaoid = '%s'" % (toutiao_id))
r = cursor1.fetchall()
for i in r:
print(i[9])
with connection.cursor() as cursor:
id = uuid.uuid4()
cursor.execute(
"insert into dashboard_toutiao_data(id,toutiao_id, tid, celltype, title, content, time, url, commentcount, readnum, likenum,shownum,created,updated) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,now(),now() )"
, (str(id), i[0], tid, celltype, title, content, time, url, commentcount, readnum, likenum,
shownum))
connection.commit()
except:
pass
if __name__ == '__main__':
sql = 'select * from toutiao_article'
cursor.execute(sql)
results = cursor.fetchall()
for r in results:
print(r)
toutiao_id = r[1]
tid = r[3]
celltype = r[4]
title = r[5]
content = r[6]
time = r[7]
url = r[8]
commentcount = r[9]
readnum = r[10]
likenum = r[11]
shownum = r[12]
insert(toutiao_id, tid, celltype, title, content, time, url, commentcount, readnum, likenum, shownum)

View File

@ -0,0 +1,44 @@
import uuid
import psycopg2
import pymysql
host = "210.72.82.249"
user = "pom"
password = "pomWechat2020"
port = 3306
database = 'pomdb'
mysql = pymysql.connect(host=host,user=user,password=password,port=port,database=database)
cursor = mysql.cursor()
G2 = 'host=210.77.68.250 port=5432 dbname=newmediaDB3 user=newmedia password=newmedia2020!@#'
def insert(type, tid, cid, rid, username, content, time, reply_count, diggcount):
try:
with psycopg2.connect(G2) as connection:
with connection.cursor() as cursor:
id = uuid.uuid4()
cursor.execute(
"insert into dashboard_toutiao_comment(id,type, tid, cid, rid, username, content, time, reply_count, diggcount,created,updated) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,now(),now() )"
, (str(id),type, tid, cid, rid, username, content, time, reply_count, diggcount))
connection.commit()
except:
pass
if __name__ == '__main__':
sql = 'select * from toutiao_comment'
cursor.execute(sql)
results = cursor.fetchall()
for r in results:
print(r)
type = r[1]
tid = r[2]
cid = r[3]
rid = r[4]
username = r[5]
content = r[6]
time = r[7]
reply_count = r[8]
diggcount = r[9]
insert(type, tid, cid, rid, username, content, time, reply_count, diggcount)

View File

@ -0,0 +1,46 @@
import uuid
import psycopg2
import pymysql
host = "210.72.82.249"
user = "pom"
password = "pomWechat2020"
port = 3306
database = 'pomdb'
mysql = pymysql.connect(host=host,user=user,password=password,port=port,database=database)
cursor = mysql.cursor()
G2 = 'host=210.77.68.250 port=5432 dbname=newmediaDB3 user=newmedia password=newmedia2020!@#'
def insert(mp, title, content, author, timestamp, link,weixin_id):
try:
with psycopg2.connect(G2) as connection:
with connection.cursor() as cursor1:
cursor1.execute("select * from dashboard_weixin where weixinid = '%s'" % (weixin_id))
r = cursor1.fetchall()
for i in r:
with connection.cursor() as cursor:
id = uuid.uuid4()
cursor.execute(
"insert into dashboard_weixin_data(id,weixin_id, mp, title, content, author, timestamp, link,created,updated) values (%s,%s,%s,%s,%s,%s,%s,%s,now(),now() )"
, (str(id), i[0], mp, title, content, author, timestamp, link))
connection.commit()
except:
pass
if __name__ == '__main__':
sql = 'select * from weixin_article'
cursor.execute(sql)
results = cursor.fetchall()
for r in results:
print(r)
mp = r[1]
title = r[2]
content = r[3]
author = r[4]
timestamp = r[5]
link = r[6]
weixin_id = str(link).split('biz=')[1].split('&mid')[0]
insert(mp, title, content, author, timestamp, link,weixin_id)

View File

@ -35,6 +35,7 @@ urlpatterns = [
path('index/map/',views.index_map,name='index-map'),
path('index/newmedia/count/',views.index_newmedia_count,name='index-newmedia-count'),
path('index/warning/count/',views.index_warning_count,name='index-warning-count'),
path('index/update/count/',views.index_update_count,name='index-update-count'),

File diff suppressed because it is too large Load Diff

12
test.py
View File

@ -1,4 +1,8 @@
import re
s = '2020-10-9'
mat = re.search(r"(\d{4}-\d{1,2}-\d{1,2})",s)
print(mat)
# import re
# s = '2020-10-9'
# mat = re.search(r"(\d{4}-\d{1,2}-\d{1,2})",s)
# print(mat)
import time
s = time.strftime('%Y-%m-%d', time.localtime(1598716628))
print(s)

View File

@ -0,0 +1,40 @@
import time
import uuid
import psycopg2
import pymysql
host = "210.72.82.249"
user = "pom"
password = "pomWechat2020"
port = 3306
database = 'pomdb'
mysql = pymysql.connect(host=host,user=user,password=password,port=port,database=database)
cursor = mysql.cursor()
G2 = 'host=210.77.68.250 port=5432 dbname=newmediaDB3 user=newmedia password=newmedia2020!@#'
def update(id, s):
# try:
with psycopg2.connect(G2) as connection:
with connection.cursor() as cursor:
cursor.execute(
"update dashboard_toutiao_data set time = %s where id = %s"
, (s,id))
connection.commit()
# except:
# pass
if __name__ == '__main__':
with psycopg2.connect(G2) as connection:
with connection.cursor() as cursor:
id = uuid.uuid4()
cursor.execute(
"select id,time from dashboard_toutiao_data")
results = cursor.fetchall()
for r in results:
id = r[0]
s = time.strftime('%Y-%m-%d', time.localtime(int(r[1])))
print(id,s)
update(id, s)

41
替换时间戳_weixin.py Normal file
View File

@ -0,0 +1,41 @@
import time
import uuid
import psycopg2
import pymysql
host = "210.72.82.249"
user = "pom"
password = "pomWechat2020"
port = 3306
database = 'pomdb'
mysql = pymysql.connect(host=host,user=user,password=password,port=port,database=database)
cursor = mysql.cursor()
G2 = 'host=210.77.68.250 port=5432 dbname=newmediaDB3 user=newmedia password=newmedia2020!@#'
def update(id, s):
# try:
with psycopg2.connect(G2) as connection:
with connection.cursor() as cursor:
cursor.execute(
"update dashboard_weixin_data set timestamp = %s where id = %s"
, (s,id))
connection.commit()
# except:
# pass
if __name__ == '__main__':
with psycopg2.connect(G2) as connection:
with connection.cursor() as cursor:
id = uuid.uuid4()
cursor.execute(
"select id,timestamp from dashboard_weixin_data")
results = cursor.fetchall()
for r in results:
id = r[0]
timestamp = r[1]
s = time.strftime('%Y-%m-%d', time.localtime(int(timestamp)))
print(id,s)
update(id, s)