Commit c2e944ca 董杰

获取数据方式修改8点到8点,状态信息修改

1 个父辈 1569c1f8
...@@ -3,4 +3,4 @@ from flask import Blueprint ...@@ -3,4 +3,4 @@ from flask import Blueprint
bp = Blueprint('api', __name__) bp = Blueprint('api', __name__)
# 写在最后是为了防止循环导入,ping.py文件也会导入 bp # 写在最后是为了防止循环导入,ping.py文件也会导入 bp
from app.api import ping,routes
\ No newline at end of file \ No newline at end of file
from app.api import ping,routes,boxstate
\ No newline at end of file \ No newline at end of file
#!/usr/bin/env python
# encoding: utf-8
'''
@author: dongjie
@license: (C) Copyright 2013-2020, Node Supply Chain Manager Corporation Limited.
@contact: 503479457@qq.com
@software: garner
@file: boxstate.py
@time: 2020/9/17 13:45
@desc:
'''
from flask import jsonify,render_template
from app.api import bp
from config import Config
from pyecharts.charts import Bar,Line
from pyecharts.options.global_options import ThemeType
import pyecharts.options as opts
@bp.route('/boxstate')
def boxstate():
return render_template("boxstate.html")
\ No newline at end of file \ No newline at end of file
...@@ -4,7 +4,6 @@ from config import Config ...@@ -4,7 +4,6 @@ from config import Config
from pyecharts.charts import Bar,Line from pyecharts.charts import Bar,Line
from pyecharts.options.global_options import ThemeType from pyecharts.options.global_options import ThemeType
import pyecharts.options as opts import pyecharts.options as opts
import pymysql
import pymongo import pymongo
import pandas as pd import pandas as pd
import pytz import pytz
...@@ -75,7 +74,7 @@ def conn_mongo_datalog(start,end): ...@@ -75,7 +74,7 @@ def conn_mongo_datalog(start,end):
mongo_client = pymongo.MongoClient(host='localhost', port=27017) mongo_client = pymongo.MongoClient(host='localhost', port=27017)
# current_dbname=Config.DB_NAME # current_dbname=Config.DB_NAME
# db = mongo_client[current_dbname] # db = mongo_client[current_dbname]
db = mongo_client['qisda2'] db = mongo_client['qisda']
cach = db.dataLog cach = db.dataLog
start_date = local2utc(start) start_date = local2utc(start)
end_date = local2utc(end) end_date = local2utc(end)
...@@ -87,13 +86,12 @@ def conn_mongo_datalog(start,end): ...@@ -87,13 +86,12 @@ def conn_mongo_datalog(start,end):
return (df) return (df)
def process_datalog_hour(): def process_datalog_hour():
now = datetime.now() # now = datetime.now()
start=datetime.now() - timedelta(hours=24) start=datetime.now() - timedelta(hours=12)
start = datetime(start.year, start.month, start.day, start.hour, start.minute, start.second) start = datetime(start.year, start.month, start.day, start.hour, start.minute, start.second)
end = datetime(now.year, now.month, now.day, now.hour, now.minute, now.second) end = datetime.now() + timedelta(hours=12)
end = datetime(end.year, end.month, end.day, end.hour, end.minute, end.second)
print("*********************datalog**24小时数据准备中*******************") print("*********************datalog**24小时数据准备中*******************")
# start = datetime(2020,9,7,16,00,00)
# end = datetime(2020,9,8,16,00,00)
df = conn_mongo_datalog(start,end) df = conn_mongo_datalog(start,end)
if not df.empty: if not df.empty:
df['updateDate'] = df['updateDate'].apply(iso2timestamp) df['updateDate'] = df['updateDate'].apply(iso2timestamp)
...@@ -102,21 +100,21 @@ def process_datalog_hour(): ...@@ -102,21 +100,21 @@ def process_datalog_hour():
datalog_hour_in = df_in['updateDate'].groupby(df_in['updateDate'].map(lambda x: x[5:13])).count() datalog_hour_in = df_in['updateDate'].groupby(df_in['updateDate'].map(lambda x: x[5:13])).count()
hour_list_in = datalog_hour_in.index.to_list() hour_list_in = datalog_hour_in.index.to_list()
count_list_in = datalog_hour_in.values.tolist() count_list_in = datalog_hour_in.values.tolist()
hour_list_in,count_list_in = check_hour_zero(start,now,hour_list_in,count_list_in) hour_list_in,count_list_in = check_hour_zero(start,end,hour_list_in,count_list_in)
# check_hour_zero(start, now, hour_list_in, count_list_in) # check_hour_zero(start, now, hour_list_in, count_list_in)
temp_df_out = df[(df['type'] == 2) & (df['status'] != 'CANCEL') & (df['status'] != 'WAIT') & (df['posName'] !="")] temp_df_out = df[(df['type'] == 2) & (df['status'] != 'CANCEL') & (df['status'] != 'WAIT') & (df['posName'] !="")]
df_out = temp_df_out[['updateDate', 'status']] df_out = temp_df_out[['updateDate', 'status']]
datalog_hour_out = df_out['updateDate'].groupby(df_out['updateDate'].map(lambda x: x[5:13])).count() datalog_hour_out = df_out['updateDate'].groupby(df_out['updateDate'].map(lambda x: x[5:13])).count()
hour_list_out = datalog_hour_out.index.to_list() hour_list_out = datalog_hour_out.index.to_list()
count_list_out = datalog_hour_out.values.tolist() count_list_out = datalog_hour_out.values.tolist()
hour_list_out, count_list_out = check_hour_zero(start, now, hour_list_out, count_list_out) hour_list_out, count_list_out = check_hour_zero(start, end, hour_list_out, count_list_out)
else: else:
hour_list_in = [] hour_list_in = []
count_list_in = [] count_list_in = []
hour_list_out = [] hour_list_out = []
count_list_out = [] count_list_out = []
hour_list_in,count_list_in = check_hour_zero(start,now,hour_list_in,count_list_in) hour_list_in,count_list_in = check_hour_zero(start,end,hour_list_in,count_list_in)
hour_list_out,count_list_out = check_hour_zero(start,now,hour_list_out,count_list_out) hour_list_out,count_list_out = check_hour_zero(start,end,hour_list_out,count_list_out)
data_dict = { data_dict = {
'hour_list_in':hour_list_in, 'hour_list_in':hour_list_in,
'count_list_in':count_list_in, 'count_list_in':count_list_in,
...@@ -137,49 +135,47 @@ def get_days_before_today(n=0): ...@@ -137,49 +135,47 @@ def get_days_before_today(n=0):
return datetime(n_days_before.year, n_days_before.month, n_days_before.day) return datetime(n_days_before.year, n_days_before.month, n_days_before.day)
def process_datalog_day(n=5):#默认取前10天(含当天) def process_datalog_day(n=5):#默认取前10天(含当天)
now = datetime.now() day_count_list_in = []
start = get_days_before_today(n) day_count_list_out = []
end = now + timedelta(days=1) while n >=0:
end = datetime(end.year, end.month, end.day, 23, 59, 59) start = get_days_before_today(n)
# start = datetime(2020,9,1) start = datetime(start.year,start.month,start.day,8,0,0)
# end = datetime(2020,9,8) end = start + timedelta(days=1)
print ("*********************datalog**7天数据准备中*******************") df = conn_mongo_datalog(start, end)
df = conn_mongo_datalog(start,end) if not df.empty:
# df['updateDate'] = df['updateDate'].apply(iso2timestamp)
temp_df_in = df[(df['type'] == 1) & (df['status'] != 'CANCEL') & (df['status'] != 'WAIT') & (df['posName'] != "")]
temp_df_out = df[(df['type'] == 2) & (df['status'] != 'CANCEL') & (df['status'] != 'WAIT') & (df['posName'] != "")]
current_num_in = temp_df_in.shape[0]
current_num_out = temp_df_out.shape[0]
day_count_list_in.append(current_num_in)
day_count_list_out.append(current_num_out)
else:
day_count_list_in.append(0)
day_count_list_out.append(0)
n -= 1
add_start = end
add_end = end + timedelta(days=1)
df = conn_mongo_datalog(add_start, add_end)
if not df.empty: if not df.empty:
df['updateDate'] = df['updateDate'].apply(iso2timestamp) # df['updateDate'] = df['updateDate'].apply(iso2timestamp)
# df.to_csv('./7day.csv') temp_df_in = df[(df['type'] == 1) & (df['status'] != 'CANCEL') & (df['status'] != 'WAIT') & (df['posName'] != "")]
# temp_df_in = df[(df['type'] == 1)&(df['status' !='CANCEL'])] temp_df_out = df[(df['type'] == 2) & (df['status'] != 'CANCEL') & (df['status'] != 'WAIT') & (df['posName'] != "")]
temp_df_in=df[(df['type'] == 1) & (df['status'] != 'CANCEL') & (df['status'] != 'WAIT') & (df['posName'] !="")] current_num_in = temp_df_in.shape[0]
df_in = temp_df_in[['updateDate', 'status']] current_num_out = temp_df_out.shape[0]
datalog_day_in = df_in['updateDate'].groupby(df_in['updateDate'].map(lambda x: x[0:10])).count() day_count_list_in.append(current_num_in)
day_list_in = datalog_day_in.index.to_list() day_count_list_out.append(current_num_out)
day_count_list_in = datalog_day_in.values.tolist()
day_list_in, day_count_list_in = check_zero(start, end, day_list_in, day_count_list_in)
temp_df_out = df[(df['type'] == 2) & (df['status'] != 'CANCEL') & (df['status'] != 'WAIT') & (df['posName'] !="")]
df_out = temp_df_out[['updateDate', 'status']]
datalog_day_out = df_out['updateDate'].groupby(df_out['updateDate'].map(lambda x: x[0:10])).count()
day_list_out = datalog_day_out.index.to_list()
day_count_list_out = datalog_day_out.values.tolist()
day_list_out, day_count_list_out = check_zero(start, end, day_list_out, day_count_list_out)
else: else:
day_list_in = [] day_count_list_in.append(0)
day_count_list_in = [] day_count_list_out.append(0)
day_list_out = [] return (day_count_list_in,day_count_list_out)
day_count_list_out = []
data_dict = {
'day_list_in':day_list_in,
'day_count_list_in':day_count_list_in,
'day_list_out':day_list_out,
'day_count_list_out':day_count_list_out
}
return data_dict
def conn_mongo_outinfo(start,end): def conn_mongo_outinfo(start,end):
mongo_client = pymongo.MongoClient(host='localhost', port=27017) mongo_client = pymongo.MongoClient(host='localhost', port=27017)
# current_dbname = Config.DB_NAME # current_dbname = Config.DB_NAME
# db = mongo_client[current_dbname] # db = mongo_client[current_dbname]
db = mongo_client['qisda2'] db = mongo_client['qisda']
cach = db.outInfo cach = db.outInfo
start_date = local2utc(start) start_date = local2utc(start)
end_date = local2utc(end) end_date = local2utc(end)
...@@ -191,13 +187,11 @@ def conn_mongo_outinfo(start,end): ...@@ -191,13 +187,11 @@ def conn_mongo_outinfo(start,end):
return (df) return (df)
def process_outinfo_hour(): def process_outinfo_hour():
now = datetime.now() start = datetime.now() - timedelta(hours=12)
start = datetime.now() - timedelta(hours=24)
start = datetime(start.year, start.month, start.day, start.hour, start.minute, start.second) start = datetime(start.year, start.month, start.day, start.hour, start.minute, start.second)
end = datetime(now.year, now.month, now.day, now.hour, now.minute, now.second) end = datetime.now() + timedelta(hours=12)
end = datetime(end.year, end.month, end.day, end.hour, end.minute, end.second)
print("*******************outinfo**24小时数据准备中*********************") print("*******************outinfo**24小时数据准备中*********************")
# start = datetime(2020, 9, 7, 16, 00, 00)
# end = datetime(2020, 9, 8, 16, 00, 00)
df = conn_mongo_outinfo(start,end) df = conn_mongo_outinfo(start,end)
if not df.empty: if not df.empty:
df['taskNeedOutDate'] = df['taskNeedOutDate'].apply(iso2timestamp) df['taskNeedOutDate'] = df['taskNeedOutDate'].apply(iso2timestamp)
...@@ -206,52 +200,60 @@ def process_outinfo_hour(): ...@@ -206,52 +200,60 @@ def process_outinfo_hour():
sum_outinfo_hour = outinfo_hour.sum() sum_outinfo_hour = outinfo_hour.sum()
outhour_list = sum_outinfo_hour.index.to_list() outhour_list = sum_outinfo_hour.index.to_list()
outcounthour_list = sum_outinfo_hour.values.tolist() outcounthour_list = sum_outinfo_hour.values.tolist()
outhour_list, outcounthour_list = check_hour_zero(start, now, outhour_list, outcounthour_list) outhour_list, outcounthour_list = check_hour_zero(start, end, outhour_list, outcounthour_list)
else: else:
outhour_list = [] outhour_list = []
outcounthour_list = [] outcounthour_list = []
return (outhour_list, outcounthour_list) return (outhour_list, outcounthour_list)
def process_outinfo_day(n=5):#默认取前6天(含当天) def process_outinfo_day(n=5):#默认取前6天(含当天)
now = datetime.now() first_start = get_days_before_today(n)
start = get_days_before_today(n) outcount_list = []
end = now + timedelta(days=1) while n >=0:
end = datetime(end.year, end.month, end.day, 23,59,59) start = get_days_before_today(n)
# start = datetime(2020,9,7) start = datetime(start.year,start.month,start.day,8,0,0)
# end = datetime(2020,9,15) end = start + timedelta(days=1)
print ("*******************outinfo**7天数据准备中*********************") df = conn_mongo_outinfo(start, end)
df = conn_mongo_outinfo(start,end) if not df.empty:
df['taskNeedOutDate'] = df['taskNeedOutDate'].apply(iso2timestamp)
if 'totalBindNum' not in df.columns.to_list():
current_num = 0
else:
current_num = df['totalBindNum'].sum()
outcount_list.append(current_num)
n -= 1
# 处理向后一天数据
add_start = end
add_end = end + timedelta(days=1)
df = conn_mongo_outinfo(add_start, add_end)
if not df.empty: if not df.empty:
df['taskNeedOutDate'] = df['taskNeedOutDate'].apply(iso2timestamp) df['taskNeedOutDate'] = df['taskNeedOutDate'].apply(iso2timestamp)
# df.to_csv('./7dayoutinfo.csv') if 'totalBindNum' not in df.columns.to_list():
df_need = df[['taskNeedOutDate', 'totalBindNum']] current_num = 0
outinfo_day = df_need['totalBindNum'].groupby(df_need['taskNeedOutDate'].map(lambda x: x[0:10])) else:
sum_outinfo_day = outinfo_day.sum() current_num = df['totalBindNum'].sum()
outday_list = sum_outinfo_day.index.to_list() outcount_list.append(current_num)
outcount_list = sum_outinfo_day.values.tolist() # outday_list.append(add_start)
# print ("1111{}--{}".format(outday_list,outcount_list)) date = pd.date_range(first_start, add_start)
outday_list,outcount_list=check_zero(start,end,outday_list,outcount_list) outday_list = [datetime.strftime(x, '%F') for x in date]
else:
outday_list = []
outcount_list = []
return (outday_list,outcount_list) return (outday_list,outcount_list)
def check_zero(start,end,day_list,count_list): # def check_zero(start,end,day_list,count_list):
print ("7天原始数据,日期{},数量{}".format(day_list,count_list)) # print ("7天原始数据,日期{},数量{}".format(day_list,count_list))
date = pd.date_range(start, end) # date = pd.date_range(start, end)
date_list = [datetime.strftime(x, '%F') for x in date] # date_list = [datetime.strftime(x, '%F') for x in date]
if len(day_list) == len(date_list): # if len(day_list) == len(date_list):
return (day_list,count_list) # return (day_list,count_list)
else: # else:
l = len(date_list) # l = len(date_list)
new_l = [0]*l # new_l = [0]*l
for index,value in enumerate(date_list): # for index,value in enumerate(date_list):
for index1,value1 in enumerate(day_list): # for index1,value1 in enumerate(day_list):
if value == value1: # if value == value1:
new_l[index] = count_list[index1] # new_l[index] = count_list[index1]
print ("7天补全数据,日期{},数量{}".format(date_list,new_l)) # print ("7天补全数据,日期{},数量{}".format(date_list,new_l))
return (date_list,new_l) # return (date_list,new_l)
# print (date_list) # # print (date_list)
def check_hour_zero(start,end,hour_list,count_list): def check_hour_zero(start,end,hour_list,count_list):
print ("24小时原始数据,时间{},数量{}".format(hour_list,count_list)) print ("24小时原始数据,时间{},数量{}".format(hour_list,count_list))
...@@ -279,11 +281,15 @@ def check_hour_zero(start,end,hour_list,count_list): ...@@ -279,11 +281,15 @@ def check_hour_zero(start,end,hour_list,count_list):
@bp.route('/index') @bp.route('/index')
def index(): def index():
stop=0 stop=0
print("*******************outinfo**7天数据准备中*********************")
outday_list,outcount_list=process_outinfo_day() outday_list,outcount_list=process_outinfo_day()
print("outinfo**7天数据{}{}".format(outday_list,outcount_list))
outcount_list1 = [int(x) for x in outcount_list]
outhour_list, outcounthour_list = process_outinfo_hour() outhour_list, outcounthour_list = process_outinfo_hour()
print ("24小时需求总数量{}".format(sum(outcounthour_list))) print ("24小时需求总数量{}".format(sum(outcounthour_list)))
# outcount_list = [4335,4321,4360,4329,4132,4199,3180] print("*******************datalog**7天数据准备中*********************")
log_data_day = process_datalog_day() day_count_list_in,day_count_list_out = process_datalog_day()
print("datalog**7天数据出库--{},入库--{}".format(day_count_list_in, day_count_list_in))
log_data=process_datalog_hour() log_data=process_datalog_hour()
hour_list_in = log_data.get('hour_list_in') hour_list_in = log_data.get('hour_list_in')
count_list_in = log_data.get('count_list_in') count_list_in = log_data.get('count_list_in')
...@@ -291,11 +297,6 @@ def index(): ...@@ -291,11 +297,6 @@ def index():
hour_list_out = log_data.get('hour_list_out') hour_list_out = log_data.get('hour_list_out')
count_list_out = log_data.get('count_list_out') count_list_out = log_data.get('count_list_out')
print("24小时出库总数量{}".format(sum(count_list_out))) print("24小时出库总数量{}".format(sum(count_list_out)))
day_list_in = log_data_day.get('day_list_in')
day_count_list_in = log_data_day.get('day_count_list_in')
day_list_out = log_data_day.get('day_list_out')
day_count_list_out = log_data_day.get('day_count_list_out')
# date_list,count_list = get_data()
y_total = [i + j for i, j in zip(day_count_list_in, day_count_list_out)] y_total = [i + j for i, j in zip(day_count_list_in, day_count_list_out)]
bar = ( bar = (
Bar(init_opts=opts.InitOpts(bg_color='rgba(255,255,255,0.7)', Bar(init_opts=opts.InitOpts(bg_color='rgba(255,255,255,0.7)',
...@@ -315,8 +316,8 @@ def index(): ...@@ -315,8 +316,8 @@ def index():
theme=ThemeType.LIGHT theme=ThemeType.LIGHT
) )
) )
.add_xaxis(day_list_in) .add_xaxis(outday_list)
.add_yaxis("需求数量", outcount_list, stack="outinfo_day") .add_yaxis("需求数量", outcount_list1, stack="outinfo_day")
.add_yaxis("实际出库数量", day_count_list_out, stack="datalog_day",) .add_yaxis("实际出库数量", day_count_list_out, stack="datalog_day",)
.add_yaxis("实际入库数量", day_count_list_in, stack="datalog_day") .add_yaxis("实际入库数量", day_count_list_in, stack="datalog_day")
.set_series_opts(label_opts=opts.LabelOpts(is_show=True,position='inside', font_size=12), .set_series_opts(label_opts=opts.LabelOpts(is_show=True,position='inside', font_size=12),
...@@ -330,7 +331,7 @@ def index(): ...@@ -330,7 +331,7 @@ def index():
) )
line = ( line = (
Line() Line()
.add_xaxis(day_list_in) .add_xaxis(outday_list)
.add_yaxis( .add_yaxis(
"总数量", "总数量",
y_total, y_total,
...@@ -354,7 +355,6 @@ def open_url(url): ...@@ -354,7 +355,6 @@ def open_url(url):
return ele_json return ele_json
def add_outinfo(equip_info,origin_equip,sign): def add_outinfo(equip_info,origin_equip,sign):
print (equip_info)
equips = [] equips = []
if sign == 'agv': if sign == 'agv':
for equip in equip_info: for equip in equip_info:
...@@ -365,7 +365,7 @@ def add_outinfo(equip_info,origin_equip,sign): ...@@ -365,7 +365,7 @@ def add_outinfo(equip_info,origin_equip,sign):
number = int(re.findall(r"\d+", add)[0]) number = int(re.findall(r"\d+", add)[0])
add_dict = { add_dict = {
'name':add, 'name':add,
'des':'充电中/待机位', 'des':'运转正常',
'state':'正常', 'state':'正常',
'number':number 'number':number
} }
...@@ -411,22 +411,30 @@ def getagvinfo(): ...@@ -411,22 +411,30 @@ def getagvinfo():
ele_json = open_url(url) ele_json = open_url(url)
current_agv = Config.CONFIG_AGV current_agv = Config.CONFIG_AGV
info_agv = [] info_agv = []
agv_name = []
for info in ele_json: for info in ele_json:
if (info['name'])[-2:] == '号车': if (info['name'])[-2:] == '号车':
if info['type'] == 0: if info['type'] == 0:
state = '异常' state = '异常'
des = info['msgValue']
else: else:
state = '正常' if info['msgValue'] == 'Standby':
state = '正常'
des = '待机位'
elif info['msgValue'] == 'AutoCharge':
state = '充电中'
des = '充电'
else:
state = '正常'
des = info['msgValue']
number = int(re.findall(r"\d+", info['name'])[0]) number = int(re.findall(r"\d+", info['name'])[0])
# print (number) # print (number)
c_dict = { c_dict = {
'name':info['name'], 'name':info['name'],
'des':info['msgValue'], 'des':des,
'state':state, 'state':state,
'number':number} 'number':number}
info_agv.append(c_dict) info_agv.append(c_dict)
else:
pass
sign = 'agv' sign = 'agv'
info_agv = add_outinfo(info_agv,current_agv,sign) info_agv = add_outinfo(info_agv,current_agv,sign)
info_agv = sorted(info_agv, key=operator.itemgetter('number')) info_agv = sorted(info_agv, key=operator.itemgetter('number'))
...@@ -436,19 +444,25 @@ def getagvinfo(): ...@@ -436,19 +444,25 @@ def getagvinfo():
def get4cinfo(): def get4cinfo():
url = Config.URL url = Config.URL
ele_json = open_url(url) ele_json = open_url(url)
nodes = [{'name':'AGV001','des':'test','state':'正常'}]
current_4c = Config.CONFIG_4C current_4c = Config.CONFIG_4C
info_4c = [] info_4c = []
for info in ele_json: for info in ele_json:
if info['msgKey'][8:9] == 'C': if info['msgKey'][8:9] == 'C':
if info['type'] == 0: if info['type'] == 0:
state = '异常' if info['name'] in ['4C-15线','4C-14线','4C-10线']:
state = '--'
else:
state = '异常'
else: else:
state = '正常' state = '正常'
number = int(re.findall(r"\d+", info['name'])[1]) number = int(re.findall(r"\d+", info['name'])[1])
if info['name'] in ['4C-15线', '4C-14线', '4C-10线']:
des = '--'
else:
des=info['msgValue']
c_dict = { c_dict = {
'name': info['name'], 'name': info['name'],
'des': info['msgValue'], 'des': des,
'state': state, 'state': state,
'number':number} 'number':number}
info_4c.append(c_dict) info_4c.append(c_dict)
...@@ -492,17 +506,26 @@ def getboxinfo(): ...@@ -492,17 +506,26 @@ def getboxinfo():
url = Config.BOX_URL url = Config.BOX_URL
ele_json = open_url(url) ele_json = open_url(url)
current_box = Config.CONFIG_BOX current_box = Config.CONFIG_BOX
current_box_status = Config.CONFIG_BOX_STATUS
ratio_list = get_boxratio()
info_box = [] info_box = []
for info in ele_json: for info in ele_json:
if info['cid'][0:7] == 'line-ac': if info['cid'][0:7] == 'line-ac':
if info['status'] == 1: if info['status'] == 1:
state = '正常' status = info['boxStatus']['1']['status']
else: if status in [2,3,4,5]:
state = '异常'
else:
state = '正常'
# des = current_box_status[status] + '温度' + info['boxStatus']['1']['temperature'] + '℃' + '湿度' + info['boxStatus']['1']['humidity']
des = current_box_status[status]
elif info['status'] == 999:
des = '离线'
state = '异常' state = '异常'
number = int(re.findall(r"\d+", info['cid'])[0]) number = int(re.findall(r"\d+", info['cid'])[0])
c_dict = { c_dict = {
'name': info['cid'], 'name': info['cid'],
'des': '状态正常', 'des': des,
'state': state, 'state': state,
'number':number} 'number':number}
info_box.append(c_dict) info_box.append(c_dict)
...@@ -512,8 +535,45 @@ def getboxinfo(): ...@@ -512,8 +535,45 @@ def getboxinfo():
sign = 'box' sign = 'box'
info_box = add_outinfo(info_box, current_box,sign) info_box = add_outinfo(info_box, current_box,sign)
info_box = sorted(info_box, key=operator.itemgetter('number')) info_box = sorted(info_box, key=operator.itemgetter('number'))
info_boxs = [info_box[i:i + 2] for i in range(0, len(info_box), 2)]
temp_list = []
for index,value in enumerate(info_boxs):
str1 = '云料仓' + str(index+1) + '-' +'1'
str2 = '云料仓' + str(index+1) + '-' +'2'
temp_list.append(str1)
temp_list.append(str2)
for index,s in enumerate(info_box):
info_box[index]['name'] = temp_list[index]
info_box[index]['ratio'] = ratio_list[index]
return json.dumps(info_box) return json.dumps(info_box)
def get_boxratio():
url = Config.BOX_RATIO_URL
ele_json = open_url(url)
ratio_list = []
for info in ele_json:
usecount = 0
totalcount = 0
for nummap in info['usageMap'].values():
usecount += int(nummap['usedCount'])
totalcount += int(nummap['totalCount'])
current_ratio = usecount/totalcount
current_ratio = ('%.2f%%' % (current_ratio * 100))
number = int(re.findall(r"\d+", info['cid'])[0])
# name = info['cid']
ratio_dict = {
'ratio':current_ratio,
'number':number
}
ratio_list.append(ratio_dict)
ratio_list = sorted(ratio_list, key=operator.itemgetter('number'))
out_list = []
for m in ratio_list:
out_list.append(m['ratio'])
return out_list
@bp.route('/state') @bp.route('/state')
def state(): def state():
return render_template("state.html") return render_template("state.html")
......
...@@ -328,7 +328,7 @@ a:hover{ ...@@ -328,7 +328,7 @@ a:hover{
height: 470px; height: 470px;
} }
.div_any01{ .div_any01{
width: 23%; width: 46%;
margin-right: 2%; margin-right: 2%;
} }
.div_any02{ .div_any02{
......
<!DOCTYPE html>
<html lang="zh-cn">
<head>
{# <meta charset="UTF-8">#}
{% if 0 == stop %}
<meta charset="UTF-8" http-equiv="refresh" content="1200;url={{ url_for('api.index') }}">
{% endif %}
<title>Neotel Datashow</title>
<link href="/static/css/common.css?v=3" rel="stylesheet">
<script src="/static/jquery-3.3.1.min.js"></script>
<script src="/static/echarts.min.js"></script>
<script src="/static/common.js"></script>
<script src="/static/index.js"></script>
<script src="/static/laydate.js"></script>
</head>
<body>
<!--顶部-->
<header class="header left">
<div class="left nav">
<ul>
<li><i class="nav_1"></i><a href="{{ url_for('api.index') }}">数据概况</a> </li>
<li><i class="nav_2"></i><a href="{{ url_for('api.state') }}">设备状态信息</a> </li>
<li class="nav_active"><i class="nav_3"></i><a href="{{ url_for('api.boxstate') }}">料仓库存信息</a> </li>
</ul>
</div>
<div class="header_center left" style="position:relative">
<h2><strong>大数据展示</strong></h2>
</div>
<div class="right nav text_right">
<ul>
</ul>
</div>
</header>
<div class="con left">
<!--统计分析图-->
<div class="div_any">
<div class="div_any">
<div class="left div_any01">
<div class="div_any_child" style="height: 300px;">
<div class="div_any_title"><img src="static/images/title_5.png">云料仓1-1</div>
<p id="histogramChart1" class="p_chart"></p>
</div>
<div class="div_any_child" style="height: 300px;">
<div class="div_any_title"><img src="static/images/title_6.png">云料仓1-2</div>
<p id="histogramChart2" class="p_chart"></p>
</div>
</div>
<div class="left div_any01">
<<div class="div_any_child" style="height: 300px;">
<div class="div_any_title"><img src="static/images/title_5.png">云料仓1-1</div>
<p id="histogramChart1" class="p_chart"></p>
</div>
<div class="div_any_child" style="height: 300px;">
<div class="div_any_title"><img src="static/images/title_6.png">云料仓1-2</div>
<p id="histogramChart2" class="p_chart"></p>
</div>
</div>
<div class="left div_any01">
<div class="div_any_child" style="height: 300px;">
<div class="div_any_title"><img src="static/images/title_5.png">云料仓1-1</div>
<p id="histogramChart1" class="p_chart"></p>
</div>
<div class="div_any_child" style="height: 300px;">
<div class="div_any_title"><img src="static/images/title_6.png">云料仓1-2</div>
<p id="histogramChart2" class="p_chart"></p>
</div>
</div>
<div class="left div_any01">
<div class="div_any_child" style="height: 300px;">
<div class="div_any_title"><img src="static/images/title_5.png">云料仓1-1</div>
<p id="histogramChart1" class="p_chart"></p>
</div>
<div class="div_any_child" style="height: 300px;">
<div class="div_any_title"><img src="static/images/title_6.png">云料仓1-2</div>
<p id="histogramChart2" class="p_chart"></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file \ No newline at end of file
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
<ul> <ul>
<li class="nav_active"><i class="nav_1"></i><a href="{{ url_for('api.index') }}">数据概况</a> </li> <li class="nav_active"><i class="nav_1"></i><a href="{{ url_for('api.index') }}">数据概况</a> </li>
<li><i class="nav_2"></i><a href="{{ url_for('api.state') }}">设备状态信息</a> </li> <li><i class="nav_2"></i><a href="{{ url_for('api.state') }}">设备状态信息</a> </li>
<li><i class="nav_3"></i><a href="{{ url_for('api.boxstate') }}">料仓库存信息</a> </li>
</ul> </ul>
</div> </div>
<div class="header_center left" style="position:relative"> <div class="header_center left" style="position:relative">
...@@ -63,102 +64,6 @@ ...@@ -63,102 +64,6 @@
</div> </div>
</div> </div>
</div> </div>
<!-- <div class="div_any">
<div class="left div_table_box" style="width: 31%;">
<div class="div_any_child" style="height: 420px;">
<div class="div_any_title"><img src="/static/images/title_16.png">AGV状态信息</div>
<div class="table_p">
<table id="tb">
<thead><tr>
<th>类型</th>
<th>描述</th>
<th>状态</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
<div class="left div_table_box" style="width: 31%;">
<div class="div_any_child" style="height: 420px;">
<div class="div_any_title"><img src="static/images/title_16.png">AGV状态信息</div>
<div class="table_p">
<table>
<thead><tr>
<th>类型</th>
<th>描述</th>
<th>状态</th>
</tr>
</thead>
<tbody>
<tr><td>AGV1</td><td>描述1</td><td>正常</td></tr>
<tr><td>AGV2</td><td>描述2</td><td>正常</td></tr>
<tr><td>AGV3</td><td>描述3</td><td>正常</td></tr>
<tr><td>AGV4</td><td>描述4</td><td>正常</td></tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="left div_table_box" style="width: 31%;">
<div class="div_any_child" style="height: 420px;">
<div class="div_any_title"><img src="static/images/title_16.png">AGV状态信息</div>
<div class="table_p">
<table>
<thead><tr>
<th>类型</th>
<th>描述</th>
<th>状态</th>
</tr>
</thead>
<tbody>
<tr><td>AGV1</td><td>描述1</td><td>正常</td></tr>
<tr><td>AGV2</td><td>描述2</td><td>正常</td></tr>
<tr><td>AGV3</td><td>描述3</td><td>正常</td></tr>
<tr><td>AGV4</td><td>描述4</td><td>正常</td></tr>
</tbody>
</table>
</div>
</div>
</div>
</div> -->
</div> </div>
<!-- <script>
var app = {
};
// 发送ajax请求,从后台获取json数据
$(document).ready(function () {
getData();
console.log('success');
});
function getData() {
$.ajax({
url: '/test',
type: "post",
dataType: "json",
processData: false,
contentType: false,
data:
{
selects: $("#selects").val(),
values: $("#values").val()
},
success: function(json) {
$('#tb tr:gt(0)').remove();//删除之前的数据
var s = '';
for (var i = 0; i < json.length; i++) s +='<tr bgcolor="#FF0000"><td>' + json[i].name + '</td><td>' + json[i].des + '</td><td>' + json[i].state + '</td></tr>';
var s = '<tbody>' + s + '</tbody>'
$('#tb').append(s);
console.log(json)
},
error: function(e) {
alert("获取menu信息失败");
}
})
$("td:contains('正常')").css("color","blue");
$("td:contains('异常')").css("color","red");
}
</script> -->
</body> </body>
</html> </html>
\ No newline at end of file \ No newline at end of file
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<ul> <ul>
<li><i class="nav_1"></i><a href="{{ url_for('api.index') }}">数据概况</a> </li> <li><i class="nav_1"></i><a href="{{ url_for('api.index') }}">数据概况</a> </li>
<li class="nav_active"><i class="nav_2"></i><a href="{{ url_for('api.state') }}">设备状态信息</a> </li> <li class="nav_active"><i class="nav_2"></i><a href="{{ url_for('api.state') }}">设备状态信息</a> </li>
<li><i class="nav_3"></i><a href="{{ url_for('api.boxstate') }}">料仓库存信息</a> </li>
</ul> </ul>
</div> </div>
<div class="header_center left" style="position:relative"> <div class="header_center left" style="position:relative">
...@@ -72,28 +73,10 @@ ...@@ -72,28 +73,10 @@
<thead><tr> <thead><tr>
<th>设备</th> <th>设备</th>
<th>描述</th> <th>描述</th>
<th>状态</th> <th>利用率</th>
</tr> </tr>
</thead> </thead>
<tbody id="box"> <tbody id="box">
{# <tr><td>料仓1</td><td>演示数据</td><td>正常</td></tr>#}
{# <tr><td>料仓2</td><td>演示数据</td><td>异常</td></tr>#}
{# <tr><td>料仓3</td><td>演示数据</td><td>正常</td></tr>#}
{# <tr><td>料仓4</td><td>演示数据</td><td>异常</td></tr>#}
{# <tr><td>料仓5</td><td>演示数据</td><td>正常</td></tr>#}
{# <tr><td>料仓6</td><td>演示数据</td><td>正常</td></tr>#}
{# <tr><td>料仓7</td><td>演示数据</td><td>正常</td></tr>#}
{# <tr><td>料仓8</td><td>演示数据</td><td>异常</td></tr>#}
{# <tr><td>料仓9</td><td>演示数据</td><td>正常</td></tr>#}
{# <tr><td>料仓10</td><td>演示数据</td><td>正常</td></tr>#}
{# <tr><td>料仓11</td><td>演示数据</td><td>异常</td></tr>#}
{# <tr><td>料仓12</td><td>演示数据</td><td>正常</td></tr>#}
{# <tr><td>环形线</td><td>演示数据</td><td>正常</td></tr>#}
{# <tr><td>皮带线</td><td>演示数据</td><td>异常</td></tr>#}
{# <tr><td>双层线</td><td>演示数据</td><td>正常</td></tr>#}
{# <tr><td>ABB1</td><td>演示数据</td><td>正常</td></tr>#}
{# <tr><td>ABB2</td><td>演示数据</td><td>异常</td></tr>#}
{# <tr><td>ABB3</td><td>演示数据</td><td>正常</td></tr>#}
</tbody> </tbody>
</table> </table>
</div> </div>
...@@ -184,7 +167,9 @@ ...@@ -184,7 +167,9 @@
$('#agv').empty(); $('#agv').empty();
var s = ''; var s = '';
for (var i = 0; i < json.length; i++) if (json[i].state == '正常') {s +='<tr><td>' + json[i].name + '</td><td>' + json[i].des + '</td><td style="color:green;">' + json[i].state + '</td></tr>';} for (var i = 0; i < json.length; i++) if (json[i].state == '正常') {s +='<tr><td>' + json[i].name + '</td><td>' + json[i].des + '</td><td style="color:green;">' + json[i].state + '</td></tr>';}
else {s +='<tr><td>' + json[i].name + '</td><td>' + json[i].des + '</td><td style="color:red;">' + json[i].state + '</td></tr>';} else if (json[i].state == '充电中')
{s +='<tr><td>' + json[i].name + '</td><td>' + json[i].des + '</td><td style="color:yellow;">' + json[i].state + '</td></tr>';}
else {s +='<tr><td>' + json[i].name + '</td><td>' + json[i].des + '</td><td style="color:red;">' + json[i].state + '</td></tr>';}
// var s = '<tbody>' + s + '</tbody>' // var s = '<tbody>' + s + '</tbody>'
$('#agv').append(s); $('#agv').append(s);
console.log(json) console.log(json)
...@@ -239,8 +224,8 @@ ...@@ -239,8 +224,8 @@
//$('#box tr:gt(0)').remove();//删除之前的数据 //$('#box tr:gt(0)').remove();//删除之前的数据
$('#box').empty(); $('#box').empty();
var s = ''; var s = '';
for (var i = 0; i < json.length; i++) if (json[i].state == '正常') {s +='<tr><td>' + json[i].name + '</td><td>' + json[i].des + '</td><td style="color:green;">' + json[i].state + '</td></tr>';} for (var i = 0; i < json.length; i++) if (json[i].state == '正常') {s +='<tr><td>' + json[i].name + '</td><td>' + json[i].des + '</td><td style="color:green;">' + json[i].ratio + '</td></tr>';}
else {s +='<tr><td>' + json[i].name + '</td><td>' + json[i].des + '</td><td style="color:red;">' + json[i].state + '</td></tr>';} else {s +='<tr><td>' + json[i].name + '</td><td>' + json[i].des + '</td><td style="color:red;">' + json[i].ratio + '</td></tr>';}
$('#box').append(s); $('#box').append(s);
console.log(json) console.log(json)
}, },
......
...@@ -11,6 +11,8 @@ class Config(object): ...@@ -11,6 +11,8 @@ class Config(object):
CONFIG_4D = ['4D-1线','4D-2线','4D-3线','4D-4线','4D-5线','4D-6线','4D-7线','4D-8线','4D-9线','4D-10线','4D-11线','4D-12线','4D-13线','4D-14线','4D-15线','4D-16线'] CONFIG_4D = ['4D-1线','4D-2线','4D-3线','4D-4线','4D-5线','4D-6线','4D-7线','4D-8线','4D-9线','4D-10线','4D-11线','4D-12线','4D-13线','4D-14线','4D-15线','4D-16线']
CONFIG_BOX = ['line-ac-01','line-ac-02','line-ac-03','line-ac-04','line-ac-05','line-ac-06','line-ac-07','line-ac-08','line-ac-09','line-ac-10','line-ac-11','line-ac-12','line-ac-13','line-ac-14','line-ac-15','line-ac-16','line-ac-17','line-ac-18'] CONFIG_BOX = ['line-ac-01','line-ac-02','line-ac-03','line-ac-04','line-ac-05','line-ac-06','line-ac-07','line-ac-08','line-ac-09','line-ac-10','line-ac-11','line-ac-12','line-ac-13','line-ac-14','line-ac-15','line-ac-16','line-ac-17','line-ac-18']
# CONFIG_BOX = ['云料仓1', '云料仓1', '云料仓1', '云料仓4', '云料仓5', '云料仓6', '云料仓7', '云料仓8', '云料仓9', '云料仓10', '云料仓11', '云料仓12'] # CONFIG_BOX = ['云料仓1', '云料仓1', '云料仓1', '云料仓4', '云料仓5', '云料仓6', '云料仓7', '云料仓8', '云料仓9', '云料仓10', '云料仓11', '云料仓12']
CONFIG_BOX_STATUS = {1:'准备就绪',2:'急停',3:'故障',4:'警告',5:'调试中',6:'入库执行中',7:'入仓位完成',8:'入库失败',9:'出库执行中',10:'出仓位完成',11:'出库失败',12:'出库移载中',13:'远点返回中'}
DB_NAME = 'qisada2' DB_NAME = 'qisada2'
URL = 'http://192.168.101.11/myproject/rest/api/qisda/device/deviceMsgList' URL = 'http://192.168.101.11/myproject/rest/api/qisda/device/deviceMsgList'
BOX_URL = 'http://192.168.101.11/myproject/service/store/statusList' BOX_URL = 'http://192.168.101.11/myproject/service/store/statusList'
BOX_RATIO_URL = 'http://192.168.101.11/myproject/service/store/storageList'
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!