1979 lines
114 KiB
Python
1979 lines
114 KiB
Python
import csv
|
|
import datetime
|
|
import json
|
|
import time
|
|
from collections import Counter
|
|
|
|
import jieba
|
|
from dateutil.relativedelta import relativedelta
|
|
from django.contrib.auth.decorators import login_required
|
|
from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
|
|
from django.db.models import Sum
|
|
from django.http import HttpResponse, JsonResponse
|
|
from django.shortcuts import render
|
|
from datetime import timedelta, date
|
|
# Create your views here.
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
|
|
from dashboard.models import Weixin, Weixin_data, Toutiao_data, Weibo_data, Qita_jc, Group, Toutiao, Weibo, Qita, \
|
|
Douyin, Douyin_data, News, TimelinessMonitoring, Organization, Wrongly, NewMedia, Comment, Area_code_2020
|
|
from monitor.models import Test
|
|
|
|
import pandas as pd
|
|
|
|
|
|
@login_required
|
|
def new_media_public_opinion_weixin(request):
|
|
# weixin = Weixin.objects.all()
|
|
group = Group.objects.all()
|
|
weixin_data = Weixin_data.objects.all()[:10]
|
|
res = []
|
|
for w in weixin_data:
|
|
o = dict()
|
|
o['id'] = str(w.id)
|
|
o['code'] = w.weixin.code
|
|
o['mp'] = w.mp
|
|
o['title'] = w.title
|
|
o['content'] = w.content
|
|
o['author'] = w.author
|
|
o['timestamp'] = w.timestamp
|
|
o['link'] = w.link
|
|
res.append(o)
|
|
return render(request, 'monitor/new-media-public-opinion-weixin.html',
|
|
{'res': res, 'group': group})
|
|
|
|
|
|
@login_required
|
|
def new_media_public_opinion_toutiao(request):
|
|
# toutiao = Toutiao.objects.all()
|
|
group = Group.objects.all()
|
|
toutiao_data = Toutiao_data.objects.all().order_by('-likenum')[:10]
|
|
res = []
|
|
for t in toutiao_data:
|
|
o = dict()
|
|
o['id'] = str(t.id)
|
|
o['code'] = t.toutiao.code
|
|
o['image'] = t.toutiao.image
|
|
o['title'] = t.title
|
|
o['commentcount'] = t.commentcount
|
|
o['readnum'] = t.readnum
|
|
o['likenum'] = t.likenum
|
|
o['shownum'] = t.shownum
|
|
o['celltype'] = t.celltype
|
|
res.append(o)
|
|
return render(request, 'monitor/new-media-public-opinion-toutiao.html',
|
|
{'res': res, 'group': group})
|
|
|
|
|
|
@login_required
|
|
def new_media_public_opinion_douyin(request):
|
|
# douyin = Douyin.objects.all()
|
|
group = Group.objects.all()
|
|
douyin_data = Douyin_data.objects.all().order_by('-comment')[:10]
|
|
res = []
|
|
for d in douyin_data:
|
|
o = dict()
|
|
o['id'] = str(d.id)
|
|
o['code'] = d.newmedia.code
|
|
o['image'] = d.newmedia.image
|
|
o['count'] = d.count
|
|
o['count_jc'] = d.count_jc
|
|
o['comment'] = d.comment
|
|
o['reply'] = d.reply
|
|
o['date'] = d.date
|
|
res.append(o)
|
|
return render(request, 'monitor/new-media-public-opinion-douyin.html',
|
|
{'res': res, 'group': group})
|
|
|
|
|
|
@login_required
|
|
def new_media_public_opinion_weibo(request):
|
|
# weibo = Weibo.objects.all()
|
|
group = Group.objects.all()
|
|
weibo_data = Weibo_data.objects.all().order_by('-like')[:10]
|
|
res = []
|
|
for w in weibo_data:
|
|
o = dict()
|
|
o['id'] = str(w.id)
|
|
o['code'] = w.weibo.code
|
|
o['image'] = w.weibo.image
|
|
o['title'] = w.title
|
|
o['like'] = w.like
|
|
o['transpond'] = w.transpond
|
|
o['comment'] = w.comment
|
|
o['year'] = w.year
|
|
o['month'] = w.month
|
|
o['day'] = w.day
|
|
res.append(o)
|
|
return render(request, 'monitor/new-media-public-opinion-weibo.html', {'res': res,'group': group})
|
|
|
|
|
|
@login_required
|
|
def new_media_public_opinion_qita(request):
|
|
# qita = Qita.objects.all()
|
|
group = Group.objects.all()
|
|
qita_jc = Qita_jc.objects.all().order_by('-comment')[:10]
|
|
res = []
|
|
for q in qita_jc:
|
|
o = dict()
|
|
o['id'] = str(q.id)
|
|
o['type'] = q.qita.type
|
|
o['name'] = q.qita.name
|
|
o['image'] = q.qita.image
|
|
o['count'] = q.count
|
|
o['count_jc'] = q.count_jc
|
|
o['comment'] = q.comment
|
|
o['reply'] = q.reply
|
|
o['year'] = q.year
|
|
o['month'] = q.month
|
|
o['day'] = q.day
|
|
res.append(o)
|
|
return render(request, 'monitor/new-media-public-opinion-qita.html', {'res': res, 'group': group})
|
|
|
|
|
|
@login_required
|
|
def timeliness_monitoring_weixin(request):
|
|
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)
|
|
if now.month == 12:
|
|
this_month_end = datetime.datetime(now.year, now.month, 1) - timedelta(days=1) + datetime.timedelta(
|
|
hours=23, minutes=59, seconds=59)
|
|
else:
|
|
this_month_end = datetime.datetime(now.year, now.month, 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().aggregate(nums=Sum('update'))['nums']
|
|
wrongly_count = Wrongly.objects.all().count
|
|
sensitive_count = None
|
|
organization_count = Organization.objects.all().count()
|
|
organization_count_month = Organization.objects.filter(created__range=(this_month_start, this_month_end)).count()
|
|
organization_count_week = Organization.objects.filter(created__range=(this_week_start, this_week_end)).count()
|
|
|
|
timelinessmonitoring = TimelinessMonitoring.objects.filter(n_type__contains='微信').order_by('date')
|
|
res = []
|
|
|
|
if timelinessmonitoring is not None:
|
|
paginator = Paginator(timelinessmonitoring, 6)
|
|
page = int(request.GET.get('page', 1))
|
|
try:
|
|
timelinessmonitoring = paginator.page(page)
|
|
except PageNotAnInteger:
|
|
timelinessmonitoring = paginator.page(1)
|
|
except EmptyPage:
|
|
timelinessmonitoring = paginator.page(paginator.num_pages)
|
|
for t in timelinessmonitoring:
|
|
o = dict()
|
|
o['n_type'] = t.n_type
|
|
o['n_name'] = Weixin.objects.get(identificationcode=t.identificationcode).code
|
|
o['count'] = \
|
|
TimelinessMonitoring.objects.filter(identificationcode=t.identificationcode).aggregate(nums=Sum('update'))[
|
|
'nums']
|
|
o['results'] = t.results
|
|
o['update'] = t.update
|
|
o['silent'] = t.silent
|
|
o['start_data'] = t.start_data
|
|
o['end_data'] = t.end_data
|
|
o['date_length'] = t.date_length
|
|
o['date'] = t.date
|
|
o['city'] = Area_code_2020.objects.get(code=t.city).name
|
|
o['district'] = Area_code_2020.objects.get(code=t.district).name
|
|
o['wrongly'] = Wrongly.objects.filter(
|
|
n_name=Weixin.objects.get(identificationcode=t.identificationcode).code).count()
|
|
res.append(o)
|
|
|
|
return render(request, 'monitor/timeliness-monitoring-weixin.html',
|
|
{'new_media_count': new_media_count, 'new_media_count_month': new_media_count_month,
|
|
'new_media_count_week': new_media_count_week, 'wrongly_count': wrongly_count,
|
|
'organization_count': organization_count, 'update_count': update_count,
|
|
'organization_count_month': organization_count_month,
|
|
'organization_count_week': organization_count_week, 'res': res,
|
|
'timelinessmonitoring': timelinessmonitoring})
|
|
|
|
|
|
@login_required
|
|
def timeliness_monitoring_weibo(request):
|
|
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)
|
|
if now.month != 12:
|
|
this_month_end = datetime.datetime(now.year, now.month + 1, 1) - timedelta(days=1) + datetime.timedelta(
|
|
hours=23, minutes=59, seconds=59)
|
|
else:
|
|
this_month_end = datetime.datetime(now.year, now.month, 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().aggregate(nums=Sum('update'))['nums']
|
|
# update_count_month = TimelinessMonitoring.objects.filter(created__range=(this_month_start,this_month_end)).aggregate(nums=Sum('update'))['nums']
|
|
# update_count_week = TimelinessMonitoring.objects.filter(created__range=(this_week_start,this_week_end)).aggregate(nums=Sum('update'))['nums']
|
|
|
|
wrongly_count = Wrongly.objects.all().count
|
|
sensitive_count = None
|
|
organization_count = Organization.objects.all().count()
|
|
organization_count_month = Organization.objects.filter(created__range=(this_month_start, this_month_end)).count()
|
|
organization_count_week = Organization.objects.filter(created__range=(this_week_start, this_week_end)).count()
|
|
|
|
timelinessmonitoring = TimelinessMonitoring.objects.filter(n_type__contains='微博').order_by('date')
|
|
res = []
|
|
|
|
if timelinessmonitoring is not None:
|
|
paginator = Paginator(timelinessmonitoring, 6)
|
|
page = int(request.GET.get('page', 1))
|
|
try:
|
|
timelinessmonitoring = paginator.page(page)
|
|
except PageNotAnInteger:
|
|
timelinessmonitoring = paginator.page(1)
|
|
except EmptyPage:
|
|
timelinessmonitoring = paginator.page(paginator.num_pages)
|
|
for t in timelinessmonitoring:
|
|
o = dict()
|
|
o['n_type'] = t.n_type
|
|
o['count'] = \
|
|
TimelinessMonitoring.objects.filter(identificationcode=t.identificationcode).aggregate(nums=Sum('update'))[
|
|
'nums']
|
|
o['n_name'] = Weibo.objects.get(identificationcode=t.identificationcode).code
|
|
o['results'] = t.results
|
|
o['update'] = t.update
|
|
o['silent'] = t.silent
|
|
o['start_data'] = t.start_data
|
|
o['end_data'] = t.end_data
|
|
o['date_length'] = t.date_length
|
|
o['date'] = t.date
|
|
o['city'] = Area_code_2020.objects.get(code=t.city).name
|
|
o['district'] = Area_code_2020.objects.get(code=t.district).name
|
|
o['wrongly'] = Wrongly.objects.filter(
|
|
n_name=Weibo.objects.get(identificationcode=t.identificationcode).code).count()
|
|
res.append(o)
|
|
|
|
return render(request, 'monitor/timeliness-monitoring-weibo.html',
|
|
{'new_media_count': new_media_count, 'new_media_count_month': new_media_count_month,
|
|
'new_media_count_week': new_media_count_week, 'wrongly_count': wrongly_count,
|
|
'organization_count': organization_count, 'update_count': update_count,
|
|
'organization_count_month': organization_count_month,
|
|
'organization_count_week': organization_count_week, 'res': res,
|
|
'timelinessmonitoring': timelinessmonitoring})
|
|
|
|
|
|
@login_required
|
|
def timeliness_monitoring_toutiao(request):
|
|
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)
|
|
if now.month != 12:
|
|
this_month_end = datetime.datetime(now.year, now.month + 1, 1) - timedelta(days=1) + datetime.timedelta(
|
|
hours=23, minutes=59, seconds=59)
|
|
else:
|
|
this_month_end = datetime.datetime(now.year, now.month, 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().aggregate(nums=Sum('update'))['nums']
|
|
wrongly_count = Wrongly.objects.all().count
|
|
sensitive_count = None
|
|
organization_count = Organization.objects.all().count()
|
|
organization_count_month = Organization.objects.filter(created__range=(this_month_start, this_month_end)).count()
|
|
organization_count_week = Organization.objects.filter(created__range=(this_week_start, this_week_end)).count()
|
|
|
|
timelinessmonitoring = TimelinessMonitoring.objects.filter(n_type__contains='头条').order_by('date')
|
|
res = []
|
|
|
|
if timelinessmonitoring is not None:
|
|
paginator = Paginator(timelinessmonitoring, 6)
|
|
page = int(request.GET.get('page', 1))
|
|
try:
|
|
timelinessmonitoring = paginator.page(page)
|
|
except PageNotAnInteger:
|
|
timelinessmonitoring = paginator.page(1)
|
|
except EmptyPage:
|
|
timelinessmonitoring = paginator.page(paginator.num_pages)
|
|
for t in timelinessmonitoring:
|
|
o = dict()
|
|
o['n_type'] = t.n_type
|
|
o['count'] = \
|
|
TimelinessMonitoring.objects.filter(identificationcode=t.identificationcode).aggregate(nums=Sum('update'))[
|
|
'nums']
|
|
o['n_name'] = Toutiao.objects.get(identificationcode=t.identificationcode).code
|
|
o['results'] = t.results
|
|
o['update'] = t.update
|
|
o['silent'] = t.silent
|
|
o['start_data'] = t.start_data
|
|
o['end_data'] = t.end_data
|
|
o['date'] = t.date
|
|
o['date_length'] = t.date_length
|
|
o['city'] = Area_code_2020.objects.get(code=t.city).name
|
|
o['district'] = Area_code_2020.objects.get(code=t.district).name
|
|
o['wrongly'] = Wrongly.objects.filter(
|
|
n_name=Toutiao.objects.get(identificationcode=t.identificationcode).code).count()
|
|
res.append(o)
|
|
|
|
return render(request, 'monitor/timeliness-monitoring-toutiao.html',
|
|
{'new_media_count': new_media_count, 'new_media_count_month': new_media_count_month,
|
|
'new_media_count_week': new_media_count_week, 'wrongly_count': wrongly_count,
|
|
'organization_count': organization_count, 'update_count': update_count,
|
|
'organization_count_month': organization_count_month,
|
|
'organization_count_week': organization_count_week, 'res': res,
|
|
'timelinessmonitoring': timelinessmonitoring})
|
|
|
|
|
|
@login_required
|
|
def timeliness_monitoring_douyin(request):
|
|
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)
|
|
if now.month != 12:
|
|
this_month_end = datetime.datetime(now.year, now.month + 1, 1) - timedelta(days=1) + datetime.timedelta(
|
|
hours=23, minutes=59, seconds=59)
|
|
else:
|
|
this_month_end = datetime.datetime(now.year, now.month, 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().aggregate(nums=Sum('update'))['nums']
|
|
# update_count_month = TimelinessMonitoring.objects.filter(created__range=(this_month_start,this_month_end)).aggregate(nums=Sum('update'))['nums']
|
|
# update_count_week = TimelinessMonitoring.objects.filter(created__range=(this_week_start,this_week_end)).aggregate(nums=Sum('update'))['nums']
|
|
|
|
wrongly_count = Wrongly.objects.all().count
|
|
sensitive_count = None
|
|
organization_count = Organization.objects.all().count()
|
|
organization_count_month = Organization.objects.filter(created__range=(this_month_start, this_month_end)).count()
|
|
organization_count_week = Organization.objects.filter(created__range=(this_week_start, this_week_end)).count()
|
|
|
|
timelinessmonitoring = TimelinessMonitoring.objects.filter(n_type__contains='抖音').order_by('date')
|
|
res = []
|
|
|
|
if timelinessmonitoring is not None:
|
|
paginator = Paginator(timelinessmonitoring, 6)
|
|
page = int(request.GET.get('page', 1))
|
|
try:
|
|
timelinessmonitoring = paginator.page(page)
|
|
except PageNotAnInteger:
|
|
timelinessmonitoring = paginator.page(1)
|
|
except EmptyPage:
|
|
timelinessmonitoring = paginator.page(paginator.num_pages)
|
|
for t in timelinessmonitoring:
|
|
o = dict()
|
|
o['n_type'] = t.n_type
|
|
o['count'] = \
|
|
TimelinessMonitoring.objects.filter(identificationcode=t.identificationcode).aggregate(nums=Sum('update'))[
|
|
'nums']
|
|
o['n_name'] = Douyin.objects.get(identificationcode=t.identificationcode).code
|
|
o['results'] = t.results
|
|
o['update'] = t.update
|
|
o['silent'] = t.silent
|
|
o['start_data'] = t.start_data
|
|
o['end_data'] = t.end_data
|
|
o['date'] = t.date
|
|
o['date_length'] = t.date_length
|
|
o['city'] = Area_code_2020.objects.get(code=t.city).name
|
|
o['district'] = Area_code_2020.objects.get(code=t.district).name
|
|
o['wrongly'] = Wrongly.objects.filter(
|
|
n_name=Douyin.objects.get(identificationcode=t.identificationcode).code).count()
|
|
res.append(o)
|
|
|
|
return render(request, 'monitor/timeliness-monitoring-douyin.html',
|
|
{'new_media_count': new_media_count, 'new_media_count_month': new_media_count_month,
|
|
'new_media_count_week': new_media_count_week, 'wrongly_count': wrongly_count,
|
|
'organization_count': organization_count, 'update_count': update_count,
|
|
'organization_count_month': organization_count_month,
|
|
'organization_count_week': organization_count_week, 'res': res,
|
|
'timelinessmonitoring': timelinessmonitoring})
|
|
|
|
|
|
@login_required
|
|
def timeliness_monitoring_qita(request):
|
|
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)
|
|
if now.month != 12:
|
|
this_month_end = datetime.datetime(now.year, now.month + 1, 1) - timedelta(days=1) + datetime.timedelta(
|
|
hours=23, minutes=59, seconds=59)
|
|
else:
|
|
this_month_end = datetime.datetime(now.year, now.month, 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().aggregate(nums=Sum('update'))['nums']
|
|
# update_count_month = TimelinessMonitoring.objects.filter(created__range=(this_month_start,this_month_end)).aggregate(nums=Sum('update'))['nums']
|
|
# update_count_week = TimelinessMonitoring.objects.filter(created__range=(this_week_start,this_week_end)).aggregate(nums=Sum('update'))['nums']
|
|
|
|
wrongly_count = Wrongly.objects.all().count
|
|
sensitive_count = None
|
|
organization_count = Organization.objects.all().count()
|
|
organization_count_month = Organization.objects.filter(created__range=(this_month_start, this_month_end)).count()
|
|
organization_count_week = Organization.objects.filter(created__range=(this_week_start, this_week_end)).count()
|
|
|
|
timelinessmonitoring = TimelinessMonitoring.objects.exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).order_by(
|
|
'date')
|
|
res = []
|
|
|
|
if timelinessmonitoring is not None:
|
|
paginator = Paginator(timelinessmonitoring, 6)
|
|
page = int(request.GET.get('page', 1))
|
|
try:
|
|
timelinessmonitoring = paginator.page(page)
|
|
except PageNotAnInteger:
|
|
timelinessmonitoring = paginator.page(1)
|
|
except EmptyPage:
|
|
timelinessmonitoring = paginator.page(paginator.num_pages)
|
|
for t in timelinessmonitoring:
|
|
o = dict()
|
|
o['n_type'] = t.n_type
|
|
o['count'] = \
|
|
TimelinessMonitoring.objects.filter(identificationcode=t.identificationcode).aggregate(nums=Sum('update'))[
|
|
'nums']
|
|
try:
|
|
o['n_name'] = Qita.objects.get(identificationcode=t.identificationcode).code
|
|
except:
|
|
print(str(t.identificationcode) + "6666666666666666666666666666666666666777")
|
|
o['results'] = t.results
|
|
o['update'] = t.update
|
|
o['silent'] = t.silent
|
|
o['start_data'] = t.start_data
|
|
o['end_data'] = t.end_data
|
|
o['date'] = t.date
|
|
o['date_length'] = t.date_length
|
|
o['city'] = Area_code_2020.objects.get(code=t.city).name
|
|
o['district'] = Area_code_2020.objects.get(code=t.district).name
|
|
|
|
try:
|
|
o['wrongly'] = Wrongly.objects.filter(
|
|
n_name=Douyin.objects.get(identificationcode=t.identificationcode).code).count()
|
|
except:
|
|
print(str(t.identificationcode) + "111111111111111111111111111111111")
|
|
res.append(o)
|
|
|
|
return render(request, 'monitor/timeliness-monitoring-qita.html',
|
|
{'new_media_count': new_media_count, 'new_media_count_month': new_media_count_month,
|
|
'new_media_count_week': new_media_count_week, 'wrongly_count': wrongly_count,
|
|
'organization_count': organization_count, 'update_count': update_count,
|
|
'organization_count_month': organization_count_month,
|
|
'organization_count_week': organization_count_week, 'res': res,
|
|
'timelinessmonitoring': timelinessmonitoring})
|
|
|
|
|
|
@login_required
|
|
def error_monitoring(request):
|
|
wrongly = Wrongly.objects.all()
|
|
paginator = Paginator(wrongly, 8)
|
|
page = int(request.GET.get('page', 1))
|
|
try:
|
|
wrongly = paginator.page(page)
|
|
except PageNotAnInteger:
|
|
wrongly = paginator.page(1)
|
|
except EmptyPage:
|
|
wrongly = paginator.page(paginator.num_pages)
|
|
return render(request, 'monitor/error-monitoring.html', {'wrongly': wrongly})
|
|
|
|
|
|
@login_required
|
|
def sensitive_word_monitoring(request):
|
|
data = range(1, 8)
|
|
return render(request, 'monitor/sensitive-word-monitoring.html', {'data': data})
|
|
|
|
|
|
@login_required
|
|
def comment_on_interactive_monitoring(request):
|
|
comment = Comment.objects.all().order_by('-date')
|
|
paginator = Paginator(comment, 8)
|
|
page = int(request.GET.get('page', 1))
|
|
try:
|
|
comment = paginator.page(page)
|
|
except PageNotAnInteger:
|
|
comment = paginator.page(1)
|
|
except EmptyPage:
|
|
comment = paginator.page(paginator.num_pages)
|
|
return render(request, 'monitor/comment-on-interactive-monitoring.html', {"comment": comment})
|
|
|
|
|
|
@login_required
|
|
def comment_on_interactive_monitoring_json(request):
|
|
data = Comment.objects.all()
|
|
r = []
|
|
for d in data:
|
|
content = d.comment
|
|
r.append(content)
|
|
# result = jieba.analyse.textrank(content, topK=400, withWeight=True)
|
|
seg_list = jieba.cut(str(r)) # 对文本进行分词
|
|
c = Counter()
|
|
for x in seg_list: # 进行词频统计
|
|
if len(x) > 1 and x != '\r\n':
|
|
c[x] += 1
|
|
res = []
|
|
for (k, v) in c.most_common(250): # 遍历输出高频词
|
|
# print('%s%s %s %d' % (' ' * (5 - len(k)), k, '*', v))
|
|
# 剔除不是汉字的值
|
|
if all(map(lambda c: '\u4e00' <= c <= '\u9fa5', k)):
|
|
o = dict()
|
|
o['name'] = k
|
|
o['value'] = v
|
|
res.append(o)
|
|
return HttpResponse(json.dumps({
|
|
"res": res
|
|
}))
|
|
|
|
|
|
@login_required
|
|
def monitoring_report(request):
|
|
news = News.objects.filter(type='3').order_by('-date')
|
|
count = News.objects.filter(type='3').count()
|
|
|
|
return render(request, 'monitor/monitoring-report.html', {'news': news, 'count': count})
|
|
|
|
|
|
@login_required
|
|
def monitoring_report_json(request):
|
|
news = News.objects.filter(type='3').order_by('date')
|
|
# year_now = datetime.datetime.now().year
|
|
# year = range(2019, int(year_now) + 1)
|
|
# month = range(1, 13)
|
|
news_list = []
|
|
for n in news:
|
|
o = dict()
|
|
# o['date'] = n.date
|
|
o['count'] = 1
|
|
o['year'] = str(n.date).split('-')[0]
|
|
o['month'] = str(n.date).split('-')[1]
|
|
news_list.append(o)
|
|
return JsonResponse(news_list, safe=False)
|
|
|
|
|
|
def test(request):
|
|
return render(request, 'monitor/test.html')
|
|
|
|
|
|
@login_required
|
|
def test_json(request):
|
|
res = []
|
|
with open('D:/2020/舆论监测平台/新媒体监测数据/平凉/Result_PL.csv', encoding='utf-8') as csvfile:
|
|
reader = csv.reader(csvfile)
|
|
results = []
|
|
try:
|
|
for r in reader:
|
|
print(r[0])
|
|
results.append(r[5])
|
|
except:
|
|
print("777777777777777777777777777777777777777777777777")
|
|
seg_list = jieba.cut(str(results)) # 对文本进行分词
|
|
c = Counter()
|
|
for x in seg_list: # 进行词频统计
|
|
if len(x) > 1 and x != '\r\n':
|
|
c[x] += 1
|
|
for (k, v) in c.most_common(200): # 遍历输出高频词
|
|
if all(map(lambda c: '\u4e00' <= c <= '\u9fa5', k)):
|
|
o = dict()
|
|
o['name'] = k
|
|
o['value'] = v
|
|
res.append(o)
|
|
return HttpResponse(json.dumps({
|
|
"res": res
|
|
}))
|
|
|
|
|
|
@login_required
|
|
def timeliness_monitoring_json(request):
|
|
date = TimelinessMonitoring.objects.distinct('date')
|
|
date_list = []
|
|
lanzhou = []
|
|
lanzhou_YIELD = []
|
|
jiayuguan = []
|
|
jiayuguan_YIELD = []
|
|
jinchang = []
|
|
jinchang_YIELD = []
|
|
jiuquan = []
|
|
jiuquan_YIELD = []
|
|
zhangye = []
|
|
zhangye_YIELD = []
|
|
wuwei = []
|
|
wuwei_YIELD = []
|
|
baiyin = []
|
|
baiyin_YIELD = []
|
|
tianshui = []
|
|
tianshui_YIELD = []
|
|
pingliang = []
|
|
pingliang_YIELD = []
|
|
qingyang = []
|
|
qingyang_YIELD = []
|
|
dingxi = []
|
|
dingxi_YIELD = []
|
|
longnan = []
|
|
longnan_YIELD = []
|
|
gannan = []
|
|
gannan_YIELD = []
|
|
linxia = []
|
|
linxia_YIELD = []
|
|
for d in date:
|
|
date_list.append(d.date)
|
|
lanzhou.append(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date).aggregate(nums=Sum('update'))['nums'])
|
|
jiayuguan.append(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date).aggregate(nums=Sum('update'))['nums'])
|
|
jinchang.append(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date).aggregate(nums=Sum('update'))['nums'])
|
|
jiuquan.append(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date).aggregate(nums=Sum('update'))['nums'])
|
|
zhangye.append(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date).aggregate(nums=Sum('update'))['nums'])
|
|
wuwei.append(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date).aggregate(nums=Sum('update'))['nums'])
|
|
baiyin.append(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date).aggregate(nums=Sum('update'))['nums'])
|
|
tianshui.append(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date).aggregate(nums=Sum('update'))['nums'])
|
|
pingliang.append(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date).aggregate(nums=Sum('update'))['nums'])
|
|
qingyang.append(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date).aggregate(nums=Sum('update'))['nums'])
|
|
dingxi.append(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date).aggregate(nums=Sum('update'))['nums'])
|
|
longnan.append(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date).aggregate(nums=Sum('update'))['nums'])
|
|
gannan.append(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date).aggregate(nums=Sum('update'))['nums'])
|
|
linxia.append(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date).aggregate(nums=Sum('update'))['nums'])
|
|
if TimelinessMonitoring.objects.filter(city='620100000000', date=d.date).count() != 0:
|
|
lanzhou_YIELD.append(round(
|
|
int(TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, results='合格').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date).count()), 2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620200000000', date=d.date).count() != 0:
|
|
jiayuguan_YIELD.append(round(
|
|
int(TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, results='合格').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date).count()), 2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620300000000', date=d.date).count() != 0:
|
|
jinchang_YIELD.append(round(
|
|
int(TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, results='合格').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date).count()), 2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620900000000', date=d.date).count() != 0:
|
|
jiuquan_YIELD.append(round(
|
|
int(TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, results='合格').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date).count()), 2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620700000000', date=d.date).count() != 0:
|
|
zhangye_YIELD.append(round(
|
|
int(TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, results='合格').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date).count()), 2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620600000000', date=d.date).count() != 0:
|
|
wuwei_YIELD.append(round(
|
|
int(TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, results='合格').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date).count()), 2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620400000000', date=d.date).count() != 0:
|
|
baiyin_YIELD.append(round(
|
|
int(TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, results='合格').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date).count()), 2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620500000000', date=d.date).count() != 0:
|
|
tianshui_YIELD.append(round(
|
|
int(TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, results='合格').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date).count()), 2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620800000000', date=d.date).count() != 0:
|
|
pingliang_YIELD.append(round(
|
|
int(TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, results='合格').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date).count()), 2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621000000000', date=d.date).count() != 0:
|
|
qingyang_YIELD.append(round(
|
|
int(TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, results='合格').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date).count()), 2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621100000000', date=d.date).count() != 0:
|
|
dingxi_YIELD.append(round(
|
|
int(TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, results='合格').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date).count()), 2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621200000000', date=d.date).count() != 0:
|
|
longnan_YIELD.append(round(
|
|
int(TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, results='合格').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date).count()), 2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='623000000000', date=d.date).count() != 0:
|
|
gannan_YIELD.append(round(
|
|
int(TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, results='合格').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date).count()), 2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='622900000000', date=d.date).count() != 0:
|
|
linxia_YIELD.append(round(
|
|
int(TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, results='合格').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date).count()), 2) * 100)
|
|
|
|
return HttpResponse(json.dumps({
|
|
"status": "1",
|
|
"lanzhou": lanzhou,
|
|
"lanzhou_YIELD": lanzhou_YIELD,
|
|
"jiayuguan": jiayuguan,
|
|
"jiayuguan_YIELD": jiayuguan_YIELD,
|
|
"jinchang": jinchang,
|
|
"jinchang_YIELD": jinchang_YIELD,
|
|
"jiuquan": jiuquan,
|
|
"jiuquan_YIELD": jiuquan_YIELD,
|
|
"zhangye": zhangye,
|
|
"zhangye_YIELD": zhangye_YIELD,
|
|
"wuwei": wuwei,
|
|
"wuwei_YIELD": wuwei_YIELD,
|
|
"baiyin": baiyin,
|
|
"baiyin_YIELD": baiyin_YIELD,
|
|
"tianshui": tianshui,
|
|
"tianshui_YIELD": tianshui_YIELD,
|
|
"pingliang": pingliang,
|
|
"pingliang_YIELD": pingliang_YIELD,
|
|
"qingyang": qingyang,
|
|
"qingyang_YIELD": qingyang_YIELD,
|
|
"dingxi": dingxi,
|
|
"dingxi_YIELD": dingxi_YIELD,
|
|
"longnan": longnan,
|
|
"longnan_YIELD": longnan_YIELD,
|
|
"gannan": gannan,
|
|
"gannan_YIELD": gannan_YIELD,
|
|
"linxia": linxia,
|
|
"linxia_YIELD": linxia_YIELD,
|
|
"date": date_list,
|
|
}))
|
|
|
|
|
|
@login_required
|
|
def timeliness_monitoring_json_weixin(request):
|
|
date = TimelinessMonitoring.objects.distinct('date')
|
|
date_list = []
|
|
lanzhou = []
|
|
lanzhou_YIELD = []
|
|
jiayuguan = []
|
|
jiayuguan_YIELD = []
|
|
jinchang = []
|
|
jinchang_YIELD = []
|
|
jiuquan = []
|
|
jiuquan_YIELD = []
|
|
zhangye = []
|
|
zhangye_YIELD = []
|
|
wuwei = []
|
|
wuwei_YIELD = []
|
|
baiyin = []
|
|
baiyin_YIELD = []
|
|
tianshui = []
|
|
tianshui_YIELD = []
|
|
pingliang = []
|
|
pingliang_YIELD = []
|
|
qingyang = []
|
|
qingyang_YIELD = []
|
|
dingxi = []
|
|
dingxi_YIELD = []
|
|
longnan = []
|
|
longnan_YIELD = []
|
|
gannan = []
|
|
gannan_YIELD = []
|
|
linxia = []
|
|
linxia_YIELD = []
|
|
for d in date:
|
|
date_list.append(d.date)
|
|
lanzhou.append(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, n_type__contains='微信').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
jiayuguan.append(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, n_type__contains='微信').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
jinchang.append(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, n_type__contains='微信').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
jiuquan.append(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, n_type__contains='微信').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
zhangye.append(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, n_type__contains='微信').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
wuwei.append(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, n_type__contains='微信').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
baiyin.append(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, n_type__contains='微信').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
tianshui.append(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, n_type__contains='微信').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
pingliang.append(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, n_type__contains='微信').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
qingyang.append(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, n_type__contains='微信').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
dingxi.append(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, n_type__contains='微信').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
longnan.append(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, n_type__contains='微信').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
gannan.append(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, n_type__contains='微信').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
linxia.append(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, n_type__contains='微信').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
if TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, n_type__contains='微信').count() != 0:
|
|
lanzhou_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, results='合格',
|
|
n_type__contains='微信').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, n_type__contains='微信').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, n_type__contains='微信').count() != 0:
|
|
jiayuguan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, results='合格',
|
|
n_type__contains='微信').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, n_type__contains='微信').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, n_type__contains='微信').count() != 0:
|
|
jinchang_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, results='合格',
|
|
n_type__contains='微信').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, n_type__contains='微信').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, n_type__contains='微信').count() != 0:
|
|
jiuquan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, results='合格',
|
|
n_type__contains='微信').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, n_type__contains='微信').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, n_type__contains='微信').count() != 0:
|
|
zhangye_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, results='合格',
|
|
n_type__contains='微信').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, n_type__contains='微信').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, n_type__contains='微信').count() != 0:
|
|
wuwei_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, results='合格',
|
|
n_type__contains='微信').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, n_type__contains='微信').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, n_type__contains='微信').count() != 0:
|
|
baiyin_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, results='合格',
|
|
n_type__contains='微信').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, n_type__contains='微信').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, n_type__contains='微信').count() != 0:
|
|
tianshui_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, results='合格',
|
|
n_type__contains='微信').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, n_type__contains='微信').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, n_type__contains='微信').count() != 0:
|
|
pingliang_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, results='合格',
|
|
n_type__contains='微信').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, n_type__contains='微信').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, n_type__contains='微信').count() != 0:
|
|
qingyang_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, results='合格',
|
|
n_type__contains='微信').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, n_type__contains='微信').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, n_type__contains='微信').count() != 0:
|
|
dingxi_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, results='合格',
|
|
n_type__contains='微信').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, n_type__contains='微信').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, n_type__contains='微信').count() != 0:
|
|
longnan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, results='合格',
|
|
n_type__contains='微信').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, n_type__contains='微信').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, n_type__contains='微信').count() != 0:
|
|
gannan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, results='合格',
|
|
n_type__contains='微信').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, n_type__contains='微信').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, n_type__contains='微信').count() != 0:
|
|
linxia_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, results='合格',
|
|
n_type__contains='微信').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, n_type__contains='微信').count()),
|
|
2) * 100)
|
|
|
|
return HttpResponse(json.dumps({
|
|
"status": "1",
|
|
"lanzhou": lanzhou,
|
|
"lanzhou_YIELD": lanzhou_YIELD,
|
|
"jiayuguan": jiayuguan,
|
|
"jiayuguan_YIELD": jiayuguan_YIELD,
|
|
"jinchang": jinchang,
|
|
"jinchang_YIELD": jinchang_YIELD,
|
|
"jiuquan": jiuquan,
|
|
"jiuquan_YIELD": jiuquan_YIELD,
|
|
"zhangye": zhangye,
|
|
"zhangye_YIELD": zhangye_YIELD,
|
|
"wuwei": wuwei,
|
|
"wuwei_YIELD": wuwei_YIELD,
|
|
"baiyin": baiyin,
|
|
"baiyin_YIELD": baiyin_YIELD,
|
|
"tianshui": tianshui,
|
|
"tianshui_YIELD": tianshui_YIELD,
|
|
"pingliang": pingliang,
|
|
"pingliang_YIELD": pingliang_YIELD,
|
|
"qingyang": qingyang,
|
|
"qingyang_YIELD": qingyang_YIELD,
|
|
"dingxi": dingxi,
|
|
"dingxi_YIELD": dingxi_YIELD,
|
|
"longnan": longnan,
|
|
"longnan_YIELD": longnan_YIELD,
|
|
"gannan": gannan,
|
|
"gannan_YIELD": gannan_YIELD,
|
|
"linxia": linxia,
|
|
"linxia_YIELD": linxia_YIELD,
|
|
"date": date_list,
|
|
}))
|
|
|
|
|
|
@login_required
|
|
def timeliness_monitoring_json_weibo(request):
|
|
date = TimelinessMonitoring.objects.distinct('date')
|
|
date_list = []
|
|
lanzhou = []
|
|
lanzhou_YIELD = []
|
|
jiayuguan = []
|
|
jiayuguan_YIELD = []
|
|
jinchang = []
|
|
jinchang_YIELD = []
|
|
jiuquan = []
|
|
jiuquan_YIELD = []
|
|
zhangye = []
|
|
zhangye_YIELD = []
|
|
wuwei = []
|
|
wuwei_YIELD = []
|
|
baiyin = []
|
|
baiyin_YIELD = []
|
|
tianshui = []
|
|
tianshui_YIELD = []
|
|
pingliang = []
|
|
pingliang_YIELD = []
|
|
qingyang = []
|
|
qingyang_YIELD = []
|
|
dingxi = []
|
|
dingxi_YIELD = []
|
|
longnan = []
|
|
longnan_YIELD = []
|
|
gannan = []
|
|
gannan_YIELD = []
|
|
linxia = []
|
|
linxia_YIELD = []
|
|
for d in date:
|
|
date_list.append(d.date)
|
|
lanzhou.append(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, n_type__contains='微博').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
jiayuguan.append(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, n_type__contains='微博').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
jinchang.append(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, n_type__contains='微博').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
jiuquan.append(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, n_type__contains='微博').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
zhangye.append(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, n_type__contains='微博').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
wuwei.append(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, n_type__contains='微博').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
baiyin.append(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, n_type__contains='微博').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
tianshui.append(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, n_type__contains='微博').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
pingliang.append(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, n_type__contains='微博').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
qingyang.append(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, n_type__contains='微博').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
dingxi.append(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, n_type__contains='微博').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
longnan.append(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, n_type__contains='微博').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
gannan.append(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, n_type__contains='微博').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
linxia.append(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, n_type__contains='微博').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
if TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, n_type__contains='微博').count() != 0:
|
|
lanzhou_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, results='合格',
|
|
n_type__contains='微博').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, n_type__contains='微博').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, n_type__contains='微博').count() != 0:
|
|
jiayuguan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, results='合格',
|
|
n_type__contains='微博').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, n_type__contains='微博').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, n_type__contains='微博').count() != 0:
|
|
jinchang_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, results='合格',
|
|
n_type__contains='微博').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, n_type__contains='微博').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, n_type__contains='微博').count() != 0:
|
|
jiuquan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, results='合格',
|
|
n_type__contains='微博').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, n_type__contains='微博').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, n_type__contains='微博').count() != 0:
|
|
zhangye_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, results='合格',
|
|
n_type__contains='微博').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, n_type__contains='微博').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, n_type__contains='微博').count() != 0:
|
|
wuwei_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, results='合格',
|
|
n_type__contains='微博').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, n_type__contains='微博').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, n_type__contains='微博').count() != 0:
|
|
baiyin_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, results='合格',
|
|
n_type__contains='微博').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, n_type__contains='微博').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, n_type__contains='微博').count() != 0:
|
|
tianshui_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, results='合格',
|
|
n_type__contains='微博').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, n_type__contains='微博').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, n_type__contains='微博').count() != 0:
|
|
pingliang_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, results='合格',
|
|
n_type__contains='微博').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, n_type__contains='微博').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, n_type__contains='微博').count() != 0:
|
|
qingyang_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, results='合格',
|
|
n_type__contains='微博').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, n_type__contains='微博').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, n_type__contains='微博').count() != 0:
|
|
dingxi_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, results='合格',
|
|
n_type__contains='微博').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, n_type__contains='微博').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, n_type__contains='微博').count() != 0:
|
|
longnan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, results='合格',
|
|
n_type__contains='微博').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, n_type__contains='微博').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, n_type__contains='微博').count() != 0:
|
|
gannan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, results='合格',
|
|
n_type__contains='微博').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, n_type__contains='微博').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, n_type__contains='微博').count() != 0:
|
|
linxia_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, results='合格',
|
|
n_type__contains='微博').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, n_type__contains='微博').count()),
|
|
2) * 100)
|
|
|
|
return HttpResponse(json.dumps({
|
|
"status": "1",
|
|
"lanzhou": lanzhou,
|
|
"lanzhou_YIELD": lanzhou_YIELD,
|
|
"jiayuguan": jiayuguan,
|
|
"jiayuguan_YIELD": jiayuguan_YIELD,
|
|
"jinchang": jinchang,
|
|
"jinchang_YIELD": jinchang_YIELD,
|
|
"jiuquan": jiuquan,
|
|
"jiuquan_YIELD": jiuquan_YIELD,
|
|
"zhangye": zhangye,
|
|
"zhangye_YIELD": zhangye_YIELD,
|
|
"wuwei": wuwei,
|
|
"wuwei_YIELD": wuwei_YIELD,
|
|
"baiyin": baiyin,
|
|
"baiyin_YIELD": baiyin_YIELD,
|
|
"tianshui": tianshui,
|
|
"tianshui_YIELD": tianshui_YIELD,
|
|
"pingliang": pingliang,
|
|
"pingliang_YIELD": pingliang_YIELD,
|
|
"qingyang": qingyang,
|
|
"qingyang_YIELD": qingyang_YIELD,
|
|
"dingxi": dingxi,
|
|
"dingxi_YIELD": dingxi_YIELD,
|
|
"longnan": longnan,
|
|
"longnan_YIELD": longnan_YIELD,
|
|
"gannan": gannan,
|
|
"gannan_YIELD": gannan_YIELD,
|
|
"linxia": linxia,
|
|
"linxia_YIELD": linxia_YIELD,
|
|
"date": date_list,
|
|
}))
|
|
|
|
|
|
@login_required
|
|
def timeliness_monitoring_json_toutiao(request):
|
|
date = TimelinessMonitoring.objects.distinct('date')
|
|
date_list = []
|
|
lanzhou = []
|
|
lanzhou_YIELD = []
|
|
jiayuguan = []
|
|
jiayuguan_YIELD = []
|
|
jinchang = []
|
|
jinchang_YIELD = []
|
|
jiuquan = []
|
|
jiuquan_YIELD = []
|
|
zhangye = []
|
|
zhangye_YIELD = []
|
|
wuwei = []
|
|
wuwei_YIELD = []
|
|
baiyin = []
|
|
baiyin_YIELD = []
|
|
tianshui = []
|
|
tianshui_YIELD = []
|
|
pingliang = []
|
|
pingliang_YIELD = []
|
|
qingyang = []
|
|
qingyang_YIELD = []
|
|
dingxi = []
|
|
dingxi_YIELD = []
|
|
longnan = []
|
|
longnan_YIELD = []
|
|
gannan = []
|
|
gannan_YIELD = []
|
|
linxia = []
|
|
linxia_YIELD = []
|
|
for d in date:
|
|
date_list.append(d.date)
|
|
lanzhou.append(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, n_type__contains='头条').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
jiayuguan.append(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, n_type__contains='头条').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
jinchang.append(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, n_type__contains='头条').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
jiuquan.append(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, n_type__contains='头条').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
zhangye.append(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, n_type__contains='头条').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
wuwei.append(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, n_type__contains='头条').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
baiyin.append(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, n_type__contains='头条').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
tianshui.append(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, n_type__contains='头条').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
pingliang.append(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, n_type__contains='头条').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
qingyang.append(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, n_type__contains='头条').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
dingxi.append(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, n_type__contains='头条').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
longnan.append(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, n_type__contains='头条').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
gannan.append(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, n_type__contains='头条').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
linxia.append(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, n_type__contains='头条').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
if TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, n_type__contains='头条').count() != 0:
|
|
lanzhou_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, results='合格',
|
|
n_type__contains='头条').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, n_type__contains='头条').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, n_type__contains='头条').count() != 0:
|
|
jiayuguan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, results='合格',
|
|
n_type__contains='头条').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, n_type__contains='头条').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, n_type__contains='头条').count() != 0:
|
|
jinchang_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, results='合格',
|
|
n_type__contains='头条').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, n_type__contains='头条').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, n_type__contains='头条').count() != 0:
|
|
jiuquan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, results='合格',
|
|
n_type__contains='头条').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, n_type__contains='头条').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, n_type__contains='头条').count() != 0:
|
|
zhangye_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, results='合格',
|
|
n_type__contains='头条').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, n_type__contains='头条').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, n_type__contains='头条').count() != 0:
|
|
wuwei_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, results='合格',
|
|
n_type__contains='头条').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, n_type__contains='头条').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, n_type__contains='头条').count() != 0:
|
|
baiyin_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, results='合格',
|
|
n_type__contains='头条').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, n_type__contains='头条').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, n_type__contains='头条').count() != 0:
|
|
tianshui_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, results='合格',
|
|
n_type__contains='头条').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, n_type__contains='头条').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, n_type__contains='头条').count() != 0:
|
|
pingliang_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, results='合格',
|
|
n_type__contains='头条').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, n_type__contains='头条').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, n_type__contains='头条').count() != 0:
|
|
qingyang_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, results='合格',
|
|
n_type__contains='头条').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, n_type__contains='头条').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, n_type__contains='头条').count() != 0:
|
|
dingxi_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, results='合格',
|
|
n_type__contains='头条').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, n_type__contains='头条').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, n_type__contains='头条').count() != 0:
|
|
longnan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, results='合格',
|
|
n_type__contains='头条').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, n_type__contains='头条').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, n_type__contains='头条').count() != 0:
|
|
gannan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, results='合格',
|
|
n_type__contains='头条').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, n_type__contains='头条').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, n_type__contains='头条').count() != 0:
|
|
linxia_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, results='合格',
|
|
n_type__contains='头条').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, n_type__contains='头条').count()),
|
|
2) * 100)
|
|
|
|
return HttpResponse(json.dumps({
|
|
"status": "1",
|
|
"lanzhou": lanzhou,
|
|
"lanzhou_YIELD": lanzhou_YIELD,
|
|
"jiayuguan": jiayuguan,
|
|
"jiayuguan_YIELD": jiayuguan_YIELD,
|
|
"jinchang": jinchang,
|
|
"jinchang_YIELD": jinchang_YIELD,
|
|
"jiuquan": jiuquan,
|
|
"jiuquan_YIELD": jiuquan_YIELD,
|
|
"zhangye": zhangye,
|
|
"zhangye_YIELD": zhangye_YIELD,
|
|
"wuwei": wuwei,
|
|
"wuwei_YIELD": wuwei_YIELD,
|
|
"baiyin": baiyin,
|
|
"baiyin_YIELD": baiyin_YIELD,
|
|
"tianshui": tianshui,
|
|
"tianshui_YIELD": tianshui_YIELD,
|
|
"pingliang": pingliang,
|
|
"pingliang_YIELD": pingliang_YIELD,
|
|
"qingyang": qingyang,
|
|
"qingyang_YIELD": qingyang_YIELD,
|
|
"dingxi": dingxi,
|
|
"dingxi_YIELD": dingxi_YIELD,
|
|
"longnan": longnan,
|
|
"longnan_YIELD": longnan_YIELD,
|
|
"gannan": gannan,
|
|
"gannan_YIELD": gannan_YIELD,
|
|
"linxia": linxia,
|
|
"linxia_YIELD": linxia_YIELD,
|
|
"date": date_list,
|
|
}))
|
|
|
|
|
|
@login_required
|
|
def timeliness_monitoring_json_douyin(request):
|
|
date = TimelinessMonitoring.objects.distinct('date')
|
|
date_list = []
|
|
lanzhou = []
|
|
lanzhou_YIELD = []
|
|
jiayuguan = []
|
|
jiayuguan_YIELD = []
|
|
jinchang = []
|
|
jinchang_YIELD = []
|
|
jiuquan = []
|
|
jiuquan_YIELD = []
|
|
zhangye = []
|
|
zhangye_YIELD = []
|
|
wuwei = []
|
|
wuwei_YIELD = []
|
|
baiyin = []
|
|
baiyin_YIELD = []
|
|
tianshui = []
|
|
tianshui_YIELD = []
|
|
pingliang = []
|
|
pingliang_YIELD = []
|
|
qingyang = []
|
|
qingyang_YIELD = []
|
|
dingxi = []
|
|
dingxi_YIELD = []
|
|
longnan = []
|
|
longnan_YIELD = []
|
|
gannan = []
|
|
gannan_YIELD = []
|
|
linxia = []
|
|
linxia_YIELD = []
|
|
for d in date:
|
|
date_list.append(d.date)
|
|
lanzhou.append(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, n_type__contains='抖音').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
jiayuguan.append(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, n_type__contains='抖音').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
jinchang.append(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, n_type__contains='抖音').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
jiuquan.append(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, n_type__contains='抖音').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
zhangye.append(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, n_type__contains='抖音').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
wuwei.append(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, n_type__contains='抖音').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
baiyin.append(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, n_type__contains='抖音').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
tianshui.append(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, n_type__contains='抖音').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
pingliang.append(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, n_type__contains='抖音').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
qingyang.append(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, n_type__contains='抖音').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
dingxi.append(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, n_type__contains='抖音').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
longnan.append(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, n_type__contains='抖音').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
gannan.append(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, n_type__contains='抖音').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
linxia.append(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, n_type__contains='抖音').aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
if TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, n_type__contains='抖音').count() != 0:
|
|
lanzhou_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, results='合格',
|
|
n_type__contains='抖音').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, n_type__contains='抖音').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, n_type__contains='抖音').count() != 0:
|
|
jiayuguan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, results='合格',
|
|
n_type__contains='抖音').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, n_type__contains='抖音').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, n_type__contains='抖音').count() != 0:
|
|
jinchang_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, results='合格',
|
|
n_type__contains='抖音').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, n_type__contains='抖音').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, n_type__contains='抖音').count() != 0:
|
|
jiuquan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, results='合格',
|
|
n_type__contains='抖音').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, n_type__contains='抖音').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, n_type__contains='抖音').count() != 0:
|
|
zhangye_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, results='合格',
|
|
n_type__contains='抖音').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, n_type__contains='抖音').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, n_type__contains='抖音').count() != 0:
|
|
wuwei_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, results='合格',
|
|
n_type__contains='抖音').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, n_type__contains='抖音').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, n_type__contains='抖音').count() != 0:
|
|
baiyin_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, results='合格',
|
|
n_type__contains='抖音').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, n_type__contains='抖音').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, n_type__contains='抖音').count() != 0:
|
|
tianshui_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, results='合格',
|
|
n_type__contains='抖音').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, n_type__contains='抖音').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, n_type__contains='抖音').count() != 0:
|
|
pingliang_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, results='合格',
|
|
n_type__contains='抖音').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, n_type__contains='抖音').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, n_type__contains='抖音').count() != 0:
|
|
qingyang_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, results='合格',
|
|
n_type__contains='抖音').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, n_type__contains='抖音').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, n_type__contains='抖音').count() != 0:
|
|
dingxi_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, results='合格',
|
|
n_type__contains='抖音').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, n_type__contains='抖音').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, n_type__contains='抖音').count() != 0:
|
|
longnan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, results='合格',
|
|
n_type__contains='抖音').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, n_type__contains='抖音').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, n_type__contains='抖音').count() != 0:
|
|
gannan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, results='合格',
|
|
n_type__contains='抖音').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, n_type__contains='抖音').count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, n_type__contains='抖音').count() != 0:
|
|
linxia_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, results='合格',
|
|
n_type__contains='抖音').count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, n_type__contains='抖音').count()),
|
|
2) * 100)
|
|
|
|
return HttpResponse(json.dumps({
|
|
"status": "1",
|
|
"lanzhou": lanzhou,
|
|
"lanzhou_YIELD": lanzhou_YIELD,
|
|
"jiayuguan": jiayuguan,
|
|
"jiayuguan_YIELD": jiayuguan_YIELD,
|
|
"jinchang": jinchang,
|
|
"jinchang_YIELD": jinchang_YIELD,
|
|
"jiuquan": jiuquan,
|
|
"jiuquan_YIELD": jiuquan_YIELD,
|
|
"zhangye": zhangye,
|
|
"zhangye_YIELD": zhangye_YIELD,
|
|
"wuwei": wuwei,
|
|
"wuwei_YIELD": wuwei_YIELD,
|
|
"baiyin": baiyin,
|
|
"baiyin_YIELD": baiyin_YIELD,
|
|
"tianshui": tianshui,
|
|
"tianshui_YIELD": tianshui_YIELD,
|
|
"pingliang": pingliang,
|
|
"pingliang_YIELD": pingliang_YIELD,
|
|
"qingyang": qingyang,
|
|
"qingyang_YIELD": qingyang_YIELD,
|
|
"dingxi": dingxi,
|
|
"dingxi_YIELD": dingxi_YIELD,
|
|
"longnan": longnan,
|
|
"longnan_YIELD": longnan_YIELD,
|
|
"gannan": gannan,
|
|
"gannan_YIELD": gannan_YIELD,
|
|
"linxia": linxia,
|
|
"linxia_YIELD": linxia_YIELD,
|
|
"date": date_list,
|
|
}))
|
|
|
|
|
|
@login_required
|
|
def timeliness_monitoring_json_qita(request):
|
|
date = TimelinessMonitoring.objects.distinct('date')
|
|
date_list = []
|
|
lanzhou = []
|
|
lanzhou_YIELD = []
|
|
jiayuguan = []
|
|
jiayuguan_YIELD = []
|
|
jinchang = []
|
|
jinchang_YIELD = []
|
|
jiuquan = []
|
|
jiuquan_YIELD = []
|
|
zhangye = []
|
|
zhangye_YIELD = []
|
|
wuwei = []
|
|
wuwei_YIELD = []
|
|
baiyin = []
|
|
baiyin_YIELD = []
|
|
tianshui = []
|
|
tianshui_YIELD = []
|
|
pingliang = []
|
|
pingliang_YIELD = []
|
|
qingyang = []
|
|
qingyang_YIELD = []
|
|
dingxi = []
|
|
dingxi_YIELD = []
|
|
longnan = []
|
|
longnan_YIELD = []
|
|
gannan = []
|
|
gannan_YIELD = []
|
|
linxia = []
|
|
linxia_YIELD = []
|
|
for d in date:
|
|
date_list.append(d.date)
|
|
lanzhou.append(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
jiayuguan.append(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
jinchang.append(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
jiuquan.append(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
zhangye.append(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
wuwei.append(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
baiyin.append(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
tianshui.append(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
pingliang.append(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
qingyang.append(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
dingxi.append(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
longnan.append(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
gannan.append(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
linxia.append(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).aggregate(
|
|
nums=Sum('update'))['nums'])
|
|
if TimelinessMonitoring.objects.filter(city='620100000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count() != 0:
|
|
lanzhou_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date, results='合格').exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620100000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620200000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count() != 0:
|
|
jiayuguan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date, results='合格').exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620200000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620300000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count() != 0:
|
|
jinchang_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date, results='合格').exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620300000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620900000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count() != 0:
|
|
jiuquan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date, results='合格').exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620900000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620700000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count() != 0:
|
|
zhangye_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date, results='合格').exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620700000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620600000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count() != 0:
|
|
wuwei_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date, results='合格').exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620600000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620400000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count() != 0:
|
|
baiyin_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date, results='合格').exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620400000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620500000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count() != 0:
|
|
tianshui_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date, results='合格').exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620500000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='620800000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count() != 0:
|
|
pingliang_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date, results='合格').exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='620800000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621000000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count() != 0:
|
|
qingyang_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date, results='合格').exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621000000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621100000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count() != 0:
|
|
dingxi_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date, results='合格').exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621100000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='621200000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count() != 0:
|
|
longnan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date, results='合格').exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='621200000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='623000000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count() != 0:
|
|
gannan_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date, results='合格').exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='623000000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()),
|
|
2) * 100)
|
|
if TimelinessMonitoring.objects.filter(city='622900000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count() != 0:
|
|
linxia_YIELD.append(round(int(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, results='合格').exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()) / int(
|
|
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date).exclude(
|
|
n_type__in=['微信', '微博', '今日头条', '抖音', '微信订阅号', '新浪微博', '微信服务号', '抖音短视频', '小程序+微信']).count()),
|
|
2) * 100)
|
|
|
|
return HttpResponse(json.dumps({
|
|
"status": "1",
|
|
"lanzhou": lanzhou,
|
|
"lanzhou_YIELD": lanzhou_YIELD,
|
|
"jiayuguan": jiayuguan,
|
|
"jiayuguan_YIELD": jiayuguan_YIELD,
|
|
"jinchang": jinchang,
|
|
"jinchang_YIELD": jinchang_YIELD,
|
|
"jiuquan": jiuquan,
|
|
"jiuquan_YIELD": jiuquan_YIELD,
|
|
"zhangye": zhangye,
|
|
"zhangye_YIELD": zhangye_YIELD,
|
|
"wuwei": wuwei,
|
|
"wuwei_YIELD": wuwei_YIELD,
|
|
"baiyin": baiyin,
|
|
"baiyin_YIELD": baiyin_YIELD,
|
|
"tianshui": tianshui,
|
|
"tianshui_YIELD": tianshui_YIELD,
|
|
"pingliang": pingliang,
|
|
"pingliang_YIELD": pingliang_YIELD,
|
|
"qingyang": qingyang,
|
|
"qingyang_YIELD": qingyang_YIELD,
|
|
"dingxi": dingxi,
|
|
"dingxi_YIELD": dingxi_YIELD,
|
|
"longnan": longnan,
|
|
"longnan_YIELD": longnan_YIELD,
|
|
"gannan": gannan,
|
|
"gannan_YIELD": gannan_YIELD,
|
|
"linxia": linxia,
|
|
"linxia_YIELD": linxia_YIELD,
|
|
"date": date_list,
|
|
}))
|
|
|
|
|
|
@login_required
|
|
def index_map(request):
|
|
name = request.GET.get('name')
|
|
print(name)
|
|
timelinessmonitoring_weixin = \
|
|
TimelinessMonitoring.objects.filter(city=Area_code_2020.objects.get(name=name,level=2).code, n_type__contains='微信').aggregate(nums=Sum('update'))['nums']
|
|
timelinessmonitoring_weibo = \
|
|
TimelinessMonitoring.objects.filter(city=Area_code_2020.objects.get(name=name,level=2).code, n_type__contains='微博').aggregate(nums=Sum('update'))['nums']
|
|
timelinessmonitoring_toutiao = \
|
|
TimelinessMonitoring.objects.filter(city=Area_code_2020.objects.get(name=name,level=2).code, n_type__contains='头条').aggregate(nums=Sum('update'))['nums']
|
|
timelinessmonitoring_douyin = \
|
|
TimelinessMonitoring.objects.filter(city=Area_code_2020.objects.get(name=name,level=2).code, n_type__contains='抖音').aggregate(nums=Sum('update'))['nums']
|
|
timelinessmonitoring_qita = \
|
|
TimelinessMonitoring.objects.filter(city=Area_code_2020.objects.get(name=name,level=2).code).exclude(
|
|
n_type__in=['微信', '微博', '头条', '抖音']).aggregate(
|
|
nums=Sum('update'))['nums']
|
|
return HttpResponse(json.dumps({
|
|
"status": "1",
|
|
"timelinessmonitoring_weixin": timelinessmonitoring_weixin,
|
|
"timelinessmonitoring_weibo": timelinessmonitoring_weibo,
|
|
"timelinessmonitoring_toutiao": timelinessmonitoring_toutiao,
|
|
"timelinessmonitoring_douyin": timelinessmonitoring_douyin,
|
|
"timelinessmonitoring_qita": timelinessmonitoring_qita,
|
|
}))
|
|
|
|
|
|
def index_newmedia_count(request):
|
|
date_list = [x.strftime('%Y-%m-%d') for x in list(pd.date_range(start='2020-09-01', end=datetime.datetime.now()))]
|
|
weixin_list = []
|
|
weibo_list = []
|
|
toutiao_list = []
|
|
douyin_list = []
|
|
qita_list = []
|
|
for d in date_list:
|
|
s = str(d).split('-')
|
|
weixin = Weixin.objects.filter(created__lt=d).count()
|
|
weixin_list.append(weixin)
|
|
weibo = Weibo.objects.filter(created__lt=d).count()
|
|
weibo_list.append(weibo)
|
|
toutiao = Toutiao.objects.filter(created__lt=d).count()
|
|
toutiao_list.append(toutiao)
|
|
douyin = Douyin.objects.filter(created__lt=d).count()
|
|
douyin_list.append(douyin)
|
|
qita = Qita.objects.filter(created__lt=d).count()
|
|
qita_list.append(qita)
|
|
return HttpResponse(json.dumps({
|
|
"status": "1",
|
|
"date": date_list,
|
|
"weixin": weixin_list,
|
|
"weibo": weibo_list,
|
|
"toutiao": toutiao_list,
|
|
"douyin": douyin_list,
|
|
"qita": qita_list,
|
|
}))
|
|
|
|
|
|
def index_warning_count(request):
|
|
# date_list = [x.strftime('%Y-%m-%d') for x in list(pd.date_range(start='2019-07-01',end=datetime.datetime.now()))]
|
|
# data = []
|
|
# for d in date_list:
|
|
# news = News.objects.filter(type='3',date=d).count()
|
|
# data.append(news)
|
|
# print(str(data)+"6666666666666666666666666666666")
|
|
date = News.objects.distinct('date').order_by('-date')
|
|
|
|
data = []
|
|
date_list = []
|
|
for d in date:
|
|
date_list.append(str(d.date))
|
|
news = News.objects.filter(type='3', date=str(d.date)).count()
|
|
data.append(news)
|
|
return HttpResponse(json.dumps({
|
|
"status": "1",
|
|
"data": data,
|
|
"date_list": date_list
|
|
}))
|
|
|
|
|
|
def index_update_count(request):
|
|
# date_list = [x.strftime('%Y-%m-%d') for x in list(pd.date_range(start=datetime.date.today() - relativedelta(months=+2), end=datetime.datetime.now()))]
|
|
date_list = [x.strftime('%Y-%m-%d') for x in list(pd.date_range(start='2020-01-01', end=datetime.datetime.now()))]
|
|
date_list.reverse()
|
|
lanzhou = []
|
|
jiayuguan = []
|
|
jinchang = []
|
|
jiuquan = []
|
|
zhangye = []
|
|
wuwei = []
|
|
baiyin = []
|
|
tianshui = []
|
|
pingliang = []
|
|
qingyang = []
|
|
dingxi = []
|
|
longnan = []
|
|
gannan = []
|
|
linxia = []
|
|
for d in date_list[:30]:
|
|
weixin_lanzhou = Weixin_data.objects.filter(timestamp=d,weixin__organization__cities='620100000000').count()
|
|
toutiao_lanzhou = Toutiao_data.objects.filter(time=d,toutiao__organization__cities='620100000000').count()
|
|
lanzhou.append(weixin_lanzhou+toutiao_lanzhou)
|
|
weixin_jiayuguan = Weixin_data.objects.filter(timestamp=d,weixin__organization__cities='620200000000').count()
|
|
toutiao_jiayuguan = Toutiao_data.objects.filter(time=d,toutiao__organization__cities='620200000000').count()
|
|
jiayuguan.append(weixin_jiayuguan+toutiao_jiayuguan)
|
|
weixin_jinchang = Weixin_data.objects.filter(timestamp=d,weixin__organization__cities='620300000000').count()
|
|
toutiao_jinchang = Toutiao_data.objects.filter(time=d,toutiao__organization__cities='620300000000').count()
|
|
jinchang.append(weixin_jinchang+toutiao_jinchang)
|
|
weixin_jiuquan = Weixin_data.objects.filter(timestamp=d,weixin__organization__cities='620900000000').count()
|
|
toutiao_jiuquan = Toutiao_data.objects.filter(time=d,toutiao__organization__cities='620900000000').count()
|
|
jiuquan.append(weixin_jiuquan+toutiao_jiuquan)
|
|
weixin_zhangye = Weixin_data.objects.filter(timestamp=d,weixin__organization__cities='620700000000').count()
|
|
toutiao_zhangye = Toutiao_data.objects.filter(time=d,toutiao__organization__cities='620700000000').count()
|
|
zhangye.append(weixin_zhangye+toutiao_zhangye)
|
|
weixin_wuwei = Weixin_data.objects.filter(timestamp=d,weixin__organization__cities='620600000000').count()
|
|
toutiao_wuwei = Toutiao_data.objects.filter(time=d,toutiao__organization__cities='620600000000').count()
|
|
wuwei.append(weixin_wuwei+toutiao_wuwei)
|
|
weixin_baiyin = Weixin_data.objects.filter(timestamp=d,weixin__organization__cities='620400000000').count()
|
|
toutiao_baiyin = Toutiao_data.objects.filter(time=d,toutiao__organization__cities='620400000000').count()
|
|
baiyin.append(weixin_baiyin+toutiao_baiyin)
|
|
weixin_tianshui = Weixin_data.objects.filter(timestamp=d,weixin__organization__cities='620500000000').count()
|
|
toutiao_tianshui = Toutiao_data.objects.filter(time=d,toutiao__organization__cities='620500000000').count()
|
|
tianshui.append(weixin_tianshui+toutiao_tianshui)
|
|
weixin_pingliang = Weixin_data.objects.filter(timestamp=d,weixin__organization__cities='620800000000').count()
|
|
toutiao_pingliang = Toutiao_data.objects.filter(time=d,toutiao__organization__cities='620800000000').count()
|
|
pingliang.append(weixin_pingliang+toutiao_pingliang)
|
|
weixin_qingyang = Weixin_data.objects.filter(timestamp=d,weixin__organization__cities='621000000000').count()
|
|
toutiao_qingyang = Toutiao_data.objects.filter(time=d,toutiao__organization__cities='621000000000').count()
|
|
qingyang.append(weixin_qingyang+toutiao_qingyang)
|
|
weixin_dingxi = Weixin_data.objects.filter(timestamp=d,weixin__organization__cities='621100000000').count()
|
|
toutiao_dingxi = Toutiao_data.objects.filter(time=d,toutiao__organization__cities='621100000000').count()
|
|
dingxi.append(weixin_dingxi+toutiao_dingxi)
|
|
weixin_longnan = Weixin_data.objects.filter(timestamp=d,weixin__organization__cities='621200000000').count()
|
|
toutiao_longnan = Toutiao_data.objects.filter(time=d,toutiao__organization__cities='621200000000').count()
|
|
longnan.append(weixin_longnan+toutiao_longnan)
|
|
weixin_linxia = Weixin_data.objects.filter(timestamp=d,weixin__organization__cities='622900000000').count()
|
|
toutiao_linxia = Toutiao_data.objects.filter(time=d,toutiao__organization__cities='622900000000').count()
|
|
linxia.append(weixin_linxia+toutiao_linxia)
|
|
weixin_gannan = Weixin_data.objects.filter(timestamp=d,weixin__organization__cities='623000000000').count()
|
|
toutiao_gannan = Toutiao_data.objects.filter(time=d,toutiao__organization__cities='623000000000').count()
|
|
gannan.append(weixin_gannan+toutiao_gannan)
|
|
|
|
return HttpResponse(json.dumps({
|
|
"status": "1",
|
|
"lanzhou": lanzhou,
|
|
"jiayuguan": jiayuguan,
|
|
"jinchang": jinchang,
|
|
"jiuquan": jiuquan,
|
|
"zhangye": zhangye,
|
|
"wuwei": wuwei,
|
|
"baiyin": baiyin,
|
|
"tianshui": tianshui,
|
|
"pingliang": pingliang,
|
|
"qingyang": qingyang,
|
|
"dingxi": dingxi,
|
|
"longnan": longnan,
|
|
"gannan": gannan,
|
|
"linxia": linxia,
|
|
"date": date_list[:30],
|
|
}))
|