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
46311c41
Commit
46311c41
authored
Aug 25, 2022
by
lcn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG修复
parent
4fbf8ca1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
16 deletions
+27
-16
list_alarm_service.py
...y_api/modules/alarm_manager/service/list_alarm_service.py
+2
-2
list_alarm.py
unify_api/modules/alarm_manager/views/list_alarm.py
+18
-7
syncretize_energy_dao.py
unify_api/modules/elec_charge/dao/syncretize_energy_dao.py
+6
-6
co2_response.py
unify_api/modules/elec_charge/utils/co2_response.py
+1
-1
No files found.
unify_api/modules/alarm_manager/service/list_alarm_service.py
View file @
46311c41
...
...
@@ -260,14 +260,14 @@ async def list_alarm_service_new15(cid, point_id, start, end, importance,
if
len
(
importance
)
==
1
:
li
.
append
(
f
"importance={importance[0]}"
)
else
:
li
.
append
(
f
"importance in {
tuple(importance
)}"
)
li
.
append
(
f
"importance in {
str(tuple(importance)).strip(','
)}"
)
else
:
li
.
append
(
"importance in (1, 2, 3)"
)
if
alarm_type
:
if
len
(
alarm_type
)
==
1
:
li
.
append
(
f
"event_type='{alarm_type[0]}'"
)
else
:
li
.
append
(
f
"event_type in {
tuple(alarm_type
)}"
)
li
.
append
(
f
"event_type in {
str(tuple(alarm_type)).strip(','
)}"
)
mid_sql
=
" and "
.
join
(
li
)
total
=
await
get_total_list_alarm_dao
(
mid_sql
)
mid_sql2
=
" and "
.
join
([
"point_1min_event."
+
i
for
i
in
li
])
...
...
unify_api/modules/alarm_manager/views/list_alarm.py
View file @
46311c41
...
...
@@ -32,15 +32,26 @@ from unify_api.modules.alarm_manager.components.list_alarm import (
@
summary
(
"返回报警信息列表"
)
@
description
(
"筛选字段:监测点"
)
# @examples(list_alarm_example)
async
def
post_list_alarm
(
req
,
body
:
ListAlarmReq
)
->
ListAlarmResponse
:
cid
=
body
.
cid
point_id
=
body
.
point_id
start
=
body
.
start
end
=
body
.
end
importance
=
body
.
importance
async
def
post_list_alarm
(
req
,
body
:
PageRequest
)
->
ListAlarmResponse
:
cid
=
req
.
json
.
get
(
"cid"
)
page_size
=
body
.
page_size
page_num
=
body
.
page_num
alarm_type
=
body
.
alarm_type
start
,
end
=
''
,
''
point_id
=
None
alarm_type
=
[]
importance
=
[]
if
body
.
filter
.
ranges
:
_range
=
body
.
filter
.
ranges
[
0
]
_
,
start
,
end
=
_range
.
field
,
_range
.
start
,
_range
.
end
if
body
.
filter
.
equals
:
_equal
=
body
.
filter
.
equals
[
0
]
point_id
=
_equal
.
value
if
body
.
filter
.
in_groups
:
for
in_group
in
body
.
filter
.
in_groups
:
if
in_group
.
field
==
'type'
:
alarm_type
=
in_group
.
group
elif
in_group
.
field
==
'importance'
:
importance
=
in_group
.
group
return
await
list_alarm_service_new15
(
cid
,
point_id
,
start
,
end
,
importance
,
page_size
,
page_num
,
alarm_type
)
...
...
unify_api/modules/elec_charge/dao/syncretize_energy_dao.py
View file @
46311c41
...
...
@@ -4,7 +4,7 @@ from pot_libs.mysql_util.mysql_util import MysqlUtil
async
def
get_annual_sunshine_hours
(
cid
):
sql
=
"SELECT pv.annual_effective_hours FROM "
\
"`algo
rithm
_distributed_pv_quick_check_list` pv "
\
"`algo_distributed_pv_quick_check_list` pv "
\
"LEFT JOIN company c on c.city =pv.city where c.cid=
%
s"
async
with
MysqlUtil
()
as
conn
:
hours
=
await
conn
.
fetchone
(
sql
,
args
=
(
cid
,))
...
...
@@ -12,7 +12,7 @@ async def get_annual_sunshine_hours(cid):
async
def
get_p
(
cid
):
sql
=
"SELECT pv.hour, pv.p FROM `algo
rithm
_distributed_pv` pv "
\
sql
=
"SELECT pv.hour, pv.p FROM `algo_distributed_pv` pv "
\
"LEFT JOIN company c on c.city =pv.city where c.cid=
%
s"
async
with
MysqlUtil
()
as
conn
:
datas
=
await
conn
.
fetchall
(
sql
,
args
=
(
cid
,))
...
...
@@ -29,8 +29,8 @@ async def get_elec_price_dao(cid):
async
def
get_max_demand_by_inlid
(
inlids
):
sql
=
"""SELECT a.has_space,b.related_inlids FROM
`algo
rithm_md_space_analysis_result` a
LEFT JOIN algo
rithm_md_space_analysis_unit b on a.space_analysis_id=b.id
`algo
_md_space_analysis_result` a
LEFT JOIN algo
_md_space_analysis_unit b on a.space_analysis_id=b.id
WHERE b.related_inlids in
%
s ORDER BY a.create_time DESC LIMIT
%
s"""
async
with
MysqlUtil
()
as
conn
:
spaces
=
await
conn
.
fetchall
(
sql
,
args
=
(
inlids
,
len
(
inlids
)))
...
...
@@ -52,7 +52,7 @@ async def insert_price_policy_data_dao(cid, inline_id, start_month, quarters,
async
def
inset_algorithm_power_factor_dao
(
inline_id
,
start_time
,
std_cos
):
sql
=
"""INSERT INTO `algo
rithm_power_factor` (`inlid`, `start_time`,
sql
=
"""INSERT INTO `algo
_power_factor` (`inlid`, `start_time`,
`valid`, `std_cos`) VALUES (
%
s,
%
s,
%
s,
%
s); """
async
with
MysqlUtil
()
as
conn
:
await
conn
.
execute
(
sql
,
args
=
(
inline_id
,
start_time
,
1
,
std_cos
))
...
...
@@ -60,7 +60,7 @@ async def inset_algorithm_power_factor_dao(inline_id, start_time, std_cos):
async
def
get_algorithm_power_factor_dao
(
cid
):
sql
=
"select a.std_cos from algo
rithm
_power_factor a "
\
sql
=
"select a.std_cos from algo_power_factor a "
\
"LEFT JOIN inline_zdu line on line.inlid =a.inlid "
\
"WHERE line.cid_belongedto =
%
s ORDER BY a.start_time desc limit 1"
async
with
MysqlUtil
()
as
conn
:
...
...
unify_api/modules/elec_charge/utils/co2_response.py
View file @
46311c41
...
...
@@ -12,4 +12,4 @@ async def get_co2_price():
await
aredis_utils
.
RedisUtils
()
.
set
(
"co2_price"
,
co2_price
)
except
:
co2_price
=
await
aredis_utils
.
RedisUtils
()
.
get
(
"co2_price"
)
return
co2_price
return
co2_price
or
0
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