This commit is contained in:
parent
69117310d9
commit
bf92a7e7e4
|
@ -86,3 +86,4 @@ create table datas (
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) comment = '通用配置表';
|
) comment = '通用配置表';
|
||||||
insert into datas (`key`, data) values ('from_type', '{}');
|
insert into datas (`key`, data) values ('from_type', '{}');
|
||||||
|
insert into datas (`key`, data) values ('last_month_sell', '{}');
|
||||||
|
|
|
@ -145,7 +145,6 @@ $(function(){
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
//传染病发病趋势
|
|
||||||
if (document.getElementById('lineChart1')) {
|
if (document.getElementById('lineChart1')) {
|
||||||
var lineChart1 = echarts.init(document.getElementById('lineChart1'));
|
var lineChart1 = echarts.init(document.getElementById('lineChart1'));
|
||||||
if(lineChart1){
|
if(lineChart1){
|
||||||
|
@ -356,7 +355,7 @@ $(function(){
|
||||||
var lineChart2 = echarts.init(document.getElementById('lineChart2'));
|
var lineChart2 = echarts.init(document.getElementById('lineChart2'));
|
||||||
lineChart2.setOption({
|
lineChart2.setOption({
|
||||||
title: {
|
title: {
|
||||||
text: '购买趋势',
|
text: '前5月购买趋势',
|
||||||
textStyle:{
|
textStyle:{
|
||||||
fontSize:16,
|
fontSize:16,
|
||||||
color:'#32cd32'
|
color:'#32cd32'
|
||||||
|
@ -424,7 +423,7 @@ $(function(){
|
||||||
],
|
],
|
||||||
series : [
|
series : [
|
||||||
{
|
{
|
||||||
name:'购买趋势',
|
name:'前5月购买趋势',
|
||||||
type:'line',
|
type:'line',
|
||||||
smooth:true,
|
smooth:true,
|
||||||
itemStyle: {normal: {areaStyle: {type: 'default'}}},
|
itemStyle: {normal: {areaStyle: {type: 'default'}}},
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
<div class="div_any">
|
<div class="div_any">
|
||||||
<div class="left div_any01" style="width:100%;">
|
<div class="left div_any01" style="width:100%;">
|
||||||
<div class="div_any_child" style="width:98%;position:relative;height: 420px;">
|
<div class="div_any_child" style="width:98%;position:relative;height: 420px;">
|
||||||
<div class="div_any_title"><img src="{% static "images/title_17.png" %}">TOP10商品排行</div>
|
<div class="div_any_title"><img src="{% static "images/title_17.png" %}">商品销售排行</div>
|
||||||
<div id="histogramChart3" style="width: 55%;display: inline-block;height: 400px;margin-top: 15px;"></div>
|
<div id="histogramChart3" style="width: 55%;display: inline-block;height: 400px;margin-top: 15px;"></div>
|
||||||
<div id="lineChart2" style="width: 38%;height: 90%;display: inline-block;"></div>
|
<div id="lineChart2" style="width: 38%;height: 90%;display: inline-block;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -38,6 +38,26 @@ def getYesterday(day):
|
||||||
yesterday=today-oneday
|
yesterday=today-oneday
|
||||||
return yesterday.strftime('%Y-%m-%d')
|
return yesterday.strftime('%Y-%m-%d')
|
||||||
|
|
||||||
|
def get_last_month(num):
|
||||||
|
date = datetime.datetime.now()
|
||||||
|
year = date.year
|
||||||
|
month = date.month
|
||||||
|
month = month - num
|
||||||
|
if month<=0:
|
||||||
|
month = 12 - (num-1)
|
||||||
|
year -= 1
|
||||||
|
return "%d-%d" % (year, month)
|
||||||
|
|
||||||
|
def collect_last_month_sells(spark):
|
||||||
|
data = {}
|
||||||
|
for i in range(5):
|
||||||
|
month = get_last_month(i)
|
||||||
|
df = spark.sql("select count(*) as N from jd_comment where comment_time like '"+month+"%' ")
|
||||||
|
jd_comment_count = df.rdd.collect()[0]["N"]
|
||||||
|
data[month] = jd_comment_count
|
||||||
|
mysql_execute("update datas set data = '{}' where `key` = 'last_month_sell'".format( json.dumps(data,ensure_ascii=False) ))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def collect_crawl_info(spark):
|
def collect_crawl_info(spark):
|
||||||
df = spark.sql("select count(*) as N from jd_comment")
|
df = spark.sql("select count(*) as N from jd_comment")
|
||||||
|
@ -116,6 +136,7 @@ if __name__ == "__main__":
|
||||||
get_last_day_count(spark)
|
get_last_day_count(spark)
|
||||||
collect_top10_sells(spark)
|
collect_top10_sells(spark)
|
||||||
collect_from_type(spark)
|
collect_from_type(spark)
|
||||||
|
collect_last_month_sells(spark)
|
||||||
count = 1
|
count = 1
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
Loading…
Reference in New Issue