Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
U
unify_api2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chaonan
unify_api2
Commits
04eac214
Commit
04eac214
authored
Sep 07, 2022
by
peng.xiaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alarm-price-costtl 大屏报警相关bug修复
parent
70e2c2d1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
51 deletions
+27
-51
list_static_dao.py
unify_api/modules/alarm_manager/dao/list_static_dao.py
+16
-41
count_info_pds.py
unify_api/modules/home_page/procedures/count_info_pds.py
+7
-7
count_info_service.py
unify_api/modules/home_page/service/count_info_service.py
+4
-3
No files found.
unify_api/modules/alarm_manager/dao/list_static_dao.py
View file @
04eac214
...
...
@@ -505,44 +505,19 @@ async def sdu_alarm_aggs_type(cid, start, end):
async
def
alarm_aggs_importance
(
cid
,
start
,
end
):
"""按报警等级聚合"""
start_dt
=
datetime
.
strptime
(
start
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
end_dt
=
datetime
.
strptime
(
end
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
es_start_str
=
datetime
(
year
=
start_dt
.
year
,
month
=
start_dt
.
month
,
day
=
start_dt
.
day
)
.
strftime
(
"
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S+08:00"
)
es_end_str
=
end_dt
.
strftime
(
"
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S+08:00"
)
query_body
=
{
"size"
:
0
,
"query"
:
{
"bool"
:
{
"must"
:
[
{
"term"
:
{
"cid"
:
cid
}
},
{
"range"
:
{
"datetime"
:
{
"gte"
:
es_start_str
,
"lte"
:
es_end_str
}
}
}
]
}
},
"aggs"
:
{
"importance"
:
{
"terms"
:
{
"field"
:
"importance"
,
"size"
:
10
}
}
}
}
log
.
info
(
"query_body={}"
.
format
(
query_body
))
async
with
EsUtil
()
as
es
:
es_result
=
await
es
.
search_origin
(
body
=
query_body
,
index
=
constants
.
POINT_1MIN_EVENT
)
return
es_result
[
"aggregations"
][
"importance"
][
"buckets"
]
sql
=
f
"""
SELECT
COUNT(*) alarm_count,
importance
FROM
point_1min_event pevent
WHERE
cid = {54}
AND pevent.event_datetime >= '{start}'
AND pevent.event_datetime <= '{end}'
GROUP BY
pevent.importance
"""
async
with
MysqlUtil
()
as
conn
:
datas
=
await
conn
.
fetchall
(
sql
)
return
datas
if
datas
else
[]
unify_api/modules/home_page/procedures/count_info_pds.py
View file @
04eac214
...
...
@@ -717,7 +717,7 @@ async def company_power_use_info_new15(company_id, start, end):
async
def
get_company_charge_price
(
company_id
,
es_time_start
,
es_time_end
):
power_use_info
=
await
company_power_use_info
(
company_id
,
es_time_start
,
power_use_info
=
await
company_power_use_info
_new15
(
company_id
,
es_time_start
,
es_time_end
)
if
power_use_info
[
"kwh"
]:
unit_price
=
power_use_info
[
"charge"
]
/
power_use_info
[
"kwh"
]
...
...
@@ -1715,12 +1715,12 @@ async def alarm_importance_count_total(cid, start, end):
es_res
=
await
alarm_aggs_importance
(
cid
,
start
,
end
)
first_cnt
,
second_cnt
,
third_cnt
=
0
,
0
,
0
for
buckets
in
es_res
:
if
buckets
[
"
key
"
]
==
Importance
.
First
.
value
:
first_cnt
+=
buckets
[
"
doc
_count"
]
elif
buckets
[
"
key
"
]
==
Importance
.
Second
.
value
:
second_cnt
+=
buckets
[
"
doc
_count"
]
elif
buckets
[
"
key
"
]
==
Importance
.
Third
.
value
:
third_cnt
+=
buckets
[
"
doc
_count"
]
if
buckets
[
"
importance
"
]
==
Importance
.
First
.
value
:
first_cnt
+=
buckets
[
"
alarm
_count"
]
elif
buckets
[
"
importance
"
]
==
Importance
.
Second
.
value
:
second_cnt
+=
buckets
[
"
alarm
_count"
]
elif
buckets
[
"
importance
"
]
==
Importance
.
Third
.
value
:
third_cnt
+=
buckets
[
"
alarm
_count"
]
return
{
"first_cnt"
:
first_cnt
,
"second_cnt"
:
second_cnt
,
...
...
unify_api/modules/home_page/service/count_info_service.py
View file @
04eac214
...
...
@@ -23,7 +23,8 @@ from unify_api.modules.home_page.procedures.count_info_pds import other_info, \
electric_use_info
,
cid_alarm_importance_count
,
\
alarm_importance_count_total
,
power_factor
,
current_load
,
\
get_company_charge_price
,
health_status_res
,
carbon_status_res_web
,
\
optimization_count_info
,
economic_index_desc
,
electric_use_info_new15
optimization_count_info
,
economic_index_desc
,
electric_use_info_new15
,
\
power_factor_new15
,
current_load_new15
from
unify_api.modules.home_page.procedures.count_info_proxy_pds
import
\
alarm_percentage_count
,
alarm_safe_power
from
unify_api.modules.tsp_water.dao.drop_dust_dao
import
\
...
...
@@ -290,9 +291,9 @@ async def alarm_price_costtl_service(cid):
# 1. 今日报警
imp_dic
=
await
alarm_importance_count_total
(
cid
,
today_start
,
today_end
)
# 2. 实时功率因数, 上月功率因数
cos_ttl
,
last_month_cos
=
await
power_factor
(
cid
)
cos_ttl
,
last_month_cos
=
await
power_factor
_new15
(
cid
)
# 3. 实时负荷
cur_load
=
await
current_load
(
cid
)
cur_load
=
await
current_load
_new15
(
cid
)
# 4. 平均电价
# 昨天
yesterday_start
,
yesterday_end
=
yesterday_range
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment