Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
董杰
/
qisda_charts
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit c2e944ca
由
董杰
编写于
2020-09-17 16:10:14 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
获取数据方式修改8点到8点,状态信息修改
1 个父辈
1569c1f8
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
288 行增加
和
229 行删除
app/api/__init__.py
app/api/__pycache__/__init__.cpython-37.pyc
app/api/__pycache__/routes.cpython-37.pyc
app/api/boxstate.py
app/api/routes.py
app/static/css/common.css
app/templates/boxstate.html
app/templates/index.html
app/templates/state.html
config.py
app/api/__init__.py
查看文件 @
c2e944c
...
...
@@ -3,4 +3,4 @@ from flask import Blueprint
bp
=
Blueprint
(
'api'
,
__name__
)
# 写在最后是为了防止循环导入,ping.py文件也会导入 bp
from
app.api
import
ping
,
routes
\ No newline at end of file
from
app.api
import
ping
,
routes
,
boxstate
\ No newline at end of file
app/api/__pycache__/__init__.cpython-37.pyc
查看文件 @
c2e944c
此文件类型无法预览
app/api/__pycache__/routes.cpython-37.pyc
查看文件 @
c2e944c
此文件类型无法预览
app/api/boxstate.py
0 → 100644
查看文件 @
c2e944c
#!/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
app/api/routes.py
查看文件 @
c2e944c
...
...
@@ -4,7 +4,6 @@ from config import Config
from
pyecharts.charts
import
Bar
,
Line
from
pyecharts.options.global_options
import
ThemeType
import
pyecharts.options
as
opts
import
pymysql
import
pymongo
import
pandas
as
pd
import
pytz
...
...
@@ -75,7 +74,7 @@ def conn_mongo_datalog(start,end):
mongo_client
=
pymongo
.
MongoClient
(
host
=
'localhost'
,
port
=
27017
)
# current_dbname=Config.DB_NAME
# db = mongo_client[current_dbname]
db
=
mongo_client
[
'qisda
2
'
]
db
=
mongo_client
[
'qisda'
]
cach
=
db
.
dataLog
start_date
=
local2utc
(
start
)
end_date
=
local2utc
(
end
)
...
...
@@ -87,13 +86,12 @@ def conn_mongo_datalog(start,end):
return
(
df
)
def
process_datalog_hour
():
now
=
datetime
.
now
()
start
=
datetime
.
now
()
-
timedelta
(
hours
=
24
)
#
now = datetime.now()
start
=
datetime
.
now
()
-
timedelta
(
hours
=
12
)
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小时数据准备中*******************"
)
# start = datetime(2020,9,7,16,00,00)
# end = datetime(2020,9,8,16,00,00)
df
=
conn_mongo_datalog
(
start
,
end
)
if
not
df
.
empty
:
df
[
'updateDate'
]
=
df
[
'updateDate'
]
.
apply
(
iso2timestamp
)
...
...
@@ -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
()
hour_list_in
=
datalog_hour_in
.
index
.
to_list
()
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)
temp_df_out
=
df
[(
df
[
'type'
]
==
2
)
&
(
df
[
'status'
]
!=
'CANCEL'
)
&
(
df
[
'status'
]
!=
'WAIT'
)
&
(
df
[
'posName'
]
!=
""
)]
df_out
=
temp_df_out
[[
'updateDate'
,
'status'
]]
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
()
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
:
hour_list_in
=
[]
count_list_in
=
[]
hour_list_out
=
[]
count_list_out
=
[]
hour_list_in
,
count_list_in
=
check_hour_zero
(
start
,
now
,
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_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
,
end
,
hour_list_out
,
count_list_out
)
data_dict
=
{
'hour_list_in'
:
hour_list_in
,
'count_list_in'
:
count_list_in
,
...
...
@@ -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
)
def
process_datalog_day
(
n
=
5
):
#默认取前10天(含当天)
now
=
datetime
.
now
()
start
=
get_days_before_today
(
n
)
end
=
now
+
timedelta
(
days
=
1
)
end
=
datetime
(
end
.
year
,
end
.
month
,
end
.
day
,
23
,
59
,
59
)
# start = datetime(2020,9,1)
# end = datetime(2020,9,8)
print
(
"*********************datalog**7天数据准备中*******************"
)
df
=
conn_mongo_datalog
(
start
,
end
)
day_count_list_in
=
[]
day_count_list_out
=
[]
while
n
>=
0
:
start
=
get_days_before_today
(
n
)
start
=
datetime
(
start
.
year
,
start
.
month
,
start
.
day
,
8
,
0
,
0
)
end
=
start
+
timedelta
(
days
=
1
)
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
:
df
[
'updateDate'
]
=
df
[
'updateDate'
]
.
apply
(
iso2timestamp
)
# df.to_csv('./7day.csv')
# temp_df_in = df[(df['type'] == 1)&(df['status' !='CANCEL'])]
temp_df_in
=
df
[(
df
[
'type'
]
==
1
)
&
(
df
[
'status'
]
!=
'CANCEL'
)
&
(
df
[
'status'
]
!=
'WAIT'
)
&
(
df
[
'posName'
]
!=
""
)]
df_in
=
temp_df_in
[[
'updateDate'
,
'status'
]]
datalog_day_in
=
df_in
[
'updateDate'
]
.
groupby
(
df_in
[
'updateDate'
]
.
map
(
lambda
x
:
x
[
0
:
10
]))
.
count
()
day_list_in
=
datalog_day_in
.
index
.
to_list
()
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
)
# 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_list_in
=
[]
day_count_list_in
=
[]
day_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
day_count_list_in
.
append
(
0
)
day_count_list_out
.
append
(
0
)
return
(
day_count_list_in
,
day_count_list_out
)
def
conn_mongo_outinfo
(
start
,
end
):
mongo_client
=
pymongo
.
MongoClient
(
host
=
'localhost'
,
port
=
27017
)
# current_dbname = Config.DB_NAME
# db = mongo_client[current_dbname]
db
=
mongo_client
[
'qisda
2
'
]
db
=
mongo_client
[
'qisda'
]
cach
=
db
.
outInfo
start_date
=
local2utc
(
start
)
end_date
=
local2utc
(
end
)
...
...
@@ -191,13 +187,11 @@ def conn_mongo_outinfo(start,end):
return
(
df
)
def
process_outinfo_hour
():
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
)
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小时数据准备中*********************"
)
# start = datetime(2020, 9, 7, 16, 00, 00)
# end = datetime(2020, 9, 8, 16, 00, 00)
df
=
conn_mongo_outinfo
(
start
,
end
)
if
not
df
.
empty
:
df
[
'taskNeedOutDate'
]
=
df
[
'taskNeedOutDate'
]
.
apply
(
iso2timestamp
)
...
...
@@ -206,52 +200,60 @@ def process_outinfo_hour():
sum_outinfo_hour
=
outinfo_hour
.
sum
()
outhour_list
=
sum_outinfo_hour
.
index
.
to_list
()
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
:
outhour_list
=
[]
outcounthour_list
=
[]
return
(
outhour_list
,
outcounthour_list
)
def
process_outinfo_day
(
n
=
5
):
#默认取前6天(含当天)
now
=
datetime
.
now
()
start
=
get_days_before_today
(
n
)
end
=
now
+
timedelta
(
days
=
1
)
end
=
datetime
(
end
.
year
,
end
.
month
,
end
.
day
,
23
,
59
,
59
)
# start = datetime(2020,9,7)
# end = datetime(2020,9,15)
print
(
"*******************outinfo**7天数据准备中*********************"
)
df
=
conn_mongo_outinfo
(
start
,
end
)
first_start
=
get_days_before_today
(
n
)
outcount_list
=
[]
while
n
>=
0
:
start
=
get_days_before_today
(
n
)
start
=
datetime
(
start
.
year
,
start
.
month
,
start
.
day
,
8
,
0
,
0
)
end
=
start
+
timedelta
(
days
=
1
)
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
:
df
[
'taskNeedOutDate'
]
=
df
[
'taskNeedOutDate'
]
.
apply
(
iso2timestamp
)
# df.to_csv('./7dayoutinfo.csv')
df_need
=
df
[[
'taskNeedOutDate'
,
'totalBindNum'
]]
outinfo_day
=
df_need
[
'totalBindNum'
]
.
groupby
(
df_need
[
'taskNeedOutDate'
]
.
map
(
lambda
x
:
x
[
0
:
10
]))
sum_outinfo_day
=
outinfo_day
.
sum
()
outday_list
=
sum_outinfo_day
.
index
.
to_list
()
outcount_list
=
sum_outinfo_day
.
values
.
tolist
()
# print ("1111{}--{}".format(outday_list,outcount_list))
outday_list
,
outcount_list
=
check_zero
(
start
,
end
,
outday_list
,
outcount_list
)
else
:
outday_list
=
[]
outcount_list
=
[]
if
'totalBindNum'
not
in
df
.
columns
.
to_list
():
current_num
=
0
else
:
current_num
=
df
[
'totalBindNum'
]
.
sum
()
outcount_list
.
append
(
current_num
)
# outday_list.append(add_start)
date
=
pd
.
date_range
(
first_start
,
add_start
)
outday_list
=
[
datetime
.
strftime
(
x
,
'
%
F'
)
for
x
in
date
]
return
(
outday_list
,
outcount_list
)
def
check_zero
(
start
,
end
,
day_list
,
count_list
):
print
(
"7天原始数据,日期{},数量{}"
.
format
(
day_list
,
count_list
))
date
=
pd
.
date_range
(
start
,
end
)
date_list
=
[
datetime
.
strftime
(
x
,
'
%
F'
)
for
x
in
date
]
if
len
(
day_list
)
==
len
(
date_list
):
return
(
day_list
,
count_list
)
else
:
l
=
len
(
date_list
)
new_l
=
[
0
]
*
l
for
index
,
value
in
enumerate
(
date_list
):
for
index1
,
value1
in
enumerate
(
day_list
):
if
value
==
value1
:
new_l
[
index
]
=
count_list
[
index1
]
print
(
"7天补全数据,日期{},数量{}"
.
format
(
date_list
,
new_l
))
return
(
date_list
,
new_l
)
# print (date_list)
#
def check_zero(start,end,day_list,count_list):
#
print ("7天原始数据,日期{},数量{}".format(day_list,count_list))
#
date = pd.date_range(start, end)
#
date_list = [datetime.strftime(x, '%F') for x in date]
#
if len(day_list) == len(date_list):
#
return (day_list,count_list)
#
else:
#
l = len(date_list)
#
new_l = [0]*l
#
for index,value in enumerate(date_list):
#
for index1,value1 in enumerate(day_list):
#
if value == value1:
#
new_l[index] = count_list[index1]
#
print ("7天补全数据,日期{},数量{}".format(date_list,new_l))
#
return (date_list,new_l)
#
# print (date_list)
def
check_hour_zero
(
start
,
end
,
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):
@bp.route
(
'/index'
)
def
index
():
stop
=
0
print
(
"*******************outinfo**7天数据准备中*********************"
)
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
()
print
(
"24小时需求总数量{}"
.
format
(
sum
(
outcounthour_list
)))
# outcount_list = [4335,4321,4360,4329,4132,4199,3180]
log_data_day
=
process_datalog_day
()
print
(
"*******************datalog**7天数据准备中*********************"
)
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
()
hour_list_in
=
log_data
.
get
(
'hour_list_in'
)
count_list_in
=
log_data
.
get
(
'count_list_in'
)
...
...
@@ -291,11 +297,6 @@ def index():
hour_list_out
=
log_data
.
get
(
'hour_list_out'
)
count_list_out
=
log_data
.
get
(
'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
)]
bar
=
(
Bar
(
init_opts
=
opts
.
InitOpts
(
bg_color
=
'rgba(255,255,255,0.7)'
,
...
...
@@ -315,8 +316,8 @@ def index():
theme
=
ThemeType
.
LIGHT
)
)
.
add_xaxis
(
day_list_in
)
.
add_yaxis
(
"需求数量"
,
outcount_list
,
stack
=
"outinfo_day"
)
.
add_xaxis
(
outday_list
)
.
add_yaxis
(
"需求数量"
,
outcount_list
1
,
stack
=
"outinfo_day"
)
.
add_yaxis
(
"实际出库数量"
,
day_count_list_out
,
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
),
...
...
@@ -330,7 +331,7 @@ def index():
)
line
=
(
Line
()
.
add_xaxis
(
day_list_in
)
.
add_xaxis
(
outday_list
)
.
add_yaxis
(
"总数量"
,
y_total
,
...
...
@@ -354,7 +355,6 @@ def open_url(url):
return
ele_json
def
add_outinfo
(
equip_info
,
origin_equip
,
sign
):
print
(
equip_info
)
equips
=
[]
if
sign
==
'agv'
:
for
equip
in
equip_info
:
...
...
@@ -365,7 +365,7 @@ def add_outinfo(equip_info,origin_equip,sign):
number
=
int
(
re
.
findall
(
r"\d+"
,
add
)[
0
])
add_dict
=
{
'name'
:
add
,
'des'
:
'
充电中/待机位
'
,
'des'
:
'
运转正常
'
,
'state'
:
'正常'
,
'number'
:
number
}
...
...
@@ -411,22 +411,30 @@ def getagvinfo():
ele_json
=
open_url
(
url
)
current_agv
=
Config
.
CONFIG_AGV
info_agv
=
[]
agv_name
=
[]
for
info
in
ele_json
:
if
(
info
[
'name'
])[
-
2
:]
==
'号车'
:
if
info
[
'type'
]
==
0
:
state
=
'异常'
des
=
info
[
'msgValue'
]
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
])
# print (number)
c_dict
=
{
'name'
:
info
[
'name'
],
'des'
:
info
[
'msgValue'
]
,
'des'
:
des
,
'state'
:
state
,
'number'
:
number
}
info_agv
.
append
(
c_dict
)
else
:
pass
sign
=
'agv'
info_agv
=
add_outinfo
(
info_agv
,
current_agv
,
sign
)
info_agv
=
sorted
(
info_agv
,
key
=
operator
.
itemgetter
(
'number'
))
...
...
@@ -436,19 +444,25 @@ def getagvinfo():
def
get4cinfo
():
url
=
Config
.
URL
ele_json
=
open_url
(
url
)
nodes
=
[{
'name'
:
'AGV001'
,
'des'
:
'test'
,
'state'
:
'正常'
}]
current_4c
=
Config
.
CONFIG_4C
info_4c
=
[]
for
info
in
ele_json
:
if
info
[
'msgKey'
][
8
:
9
]
==
'C'
:
if
info
[
'type'
]
==
0
:
state
=
'异常'
if
info
[
'name'
]
in
[
'4C-15线'
,
'4C-14线'
,
'4C-10线'
]:
state
=
'--'
else
:
state
=
'异常'
else
:
state
=
'正常'
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
=
{
'name'
:
info
[
'name'
],
'des'
:
info
[
'msgValue'
]
,
'des'
:
des
,
'state'
:
state
,
'number'
:
number
}
info_4c
.
append
(
c_dict
)
...
...
@@ -492,17 +506,26 @@ def getboxinfo():
url
=
Config
.
BOX_URL
ele_json
=
open_url
(
url
)
current_box
=
Config
.
CONFIG_BOX
current_box_status
=
Config
.
CONFIG_BOX_STATUS
ratio_list
=
get_boxratio
()
info_box
=
[]
for
info
in
ele_json
:
if
info
[
'cid'
][
0
:
7
]
==
'line-ac'
:
if
info
[
'status'
]
==
1
:
state
=
'正常'
else
:
status
=
info
[
'boxStatus'
][
'1'
][
'status'
]
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
=
'异常'
number
=
int
(
re
.
findall
(
r"\d+"
,
info
[
'cid'
])[
0
])
c_dict
=
{
'name'
:
info
[
'cid'
],
'des'
:
'状态正常'
,
'des'
:
des
,
'state'
:
state
,
'number'
:
number
}
info_box
.
append
(
c_dict
)
...
...
@@ -512,8 +535,45 @@ def getboxinfo():
sign
=
'box'
info_box
=
add_outinfo
(
info_box
,
current_box
,
sign
)
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
)
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
=
(
'
%.2
f
%%
'
%
(
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'
)
def
state
():
return
render_template
(
"state.html"
)
...
...
app/static/css/common.css
查看文件 @
c2e944c
...
...
@@ -328,7 +328,7 @@ a:hover{
height
:
470px
;
}
.div_any01
{
width
:
23
%
;
width
:
46
%
;
margin-right
:
2%
;
}
.div_any02
{
...
...
app/templates/boxstate.html
0 → 100644
查看文件 @
c2e944c
<!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
app/templates/index.html
查看文件 @
c2e944c
...
...
@@ -20,6 +20,7 @@
<ul>
<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_3"
></i><a
href=
"{{ url_for('api.boxstate') }}"
>
料仓库存信息
</a>
</li>
</ul>
</div>
<div
class=
"header_center left"
style=
"position:relative"
>
...
...
@@ -63,102 +64,6 @@
</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>
<!-- <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>
</html>
\ No newline at end of file
app/templates/state.html
查看文件 @
c2e944c
...
...
@@ -17,6 +17,7 @@
<ul>
<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><i
class=
"nav_3"
></i><a
href=
"{{ url_for('api.boxstate') }}"
>
料仓库存信息
</a>
</li>
</ul>
</div>
<div
class=
"header_center left"
style=
"position:relative"
>
...
...
@@ -72,28 +73,10 @@
<thead><tr>
<th>
设备
</th>
<th>
描述
</th>
<th>
状态
</th>
<th>
利用率
</th>
</tr>
</thead>
<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>
</table>
</div>
...
...
@@ -184,7 +167,9 @@
$
(
'#agv'
).
empty
();
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>'
;}
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>'
$
(
'#agv'
).
append
(
s
);
console
.
log
(
json
)
...
...
@@ -239,8 +224,8 @@
//$('#box tr:gt(0)').remove();//删除之前的数据
$
(
'#box'
).
empty
();
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>'
;}
else
{
s
+=
'<tr><td>'
+
json
[
i
].
name
+
'</td><td>'
+
json
[
i
].
des
+
'</td><td style="color:red;">'
+
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
].
ratio
+
'</td></tr>'
;}
$
(
'#box'
).
append
(
s
);
console
.
log
(
json
)
},
...
...
config.py
查看文件 @
c2e944c
...
...
@@ -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_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_STATUS
=
{
1
:
'准备就绪'
,
2
:
'急停'
,
3
:
'故障'
,
4
:
'警告'
,
5
:
'调试中'
,
6
:
'入库执行中'
,
7
:
'入仓位完成'
,
8
:
'入库失败'
,
9
:
'出库执行中'
,
10
:
'出仓位完成'
,
11
:
'出库失败'
,
12
:
'出库移载中'
,
13
:
'远点返回中'
}
DB_NAME
=
'qisada2'
URL
=
'http://192.168.101.11/myproject/rest/api/qisda/device/deviceMsgList'
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!
Cancel
请
注册
或
登录
后发表评论