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
95140e9a
Commit
95140e9a
authored
May 19, 2023
by
lcn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修复
parent
fd3450a0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
14 deletions
+24
-14
list_alarm_dao.py
unify_api/modules/alarm_manager/dao/list_alarm_dao.py
+11
-8
list_alarm.py
unify_api/modules/alarm_manager/views/list_alarm.py
+4
-1
proxy_ranking.py
unify_api/modules/electric/views/proxy_ranking.py
+5
-1
count_info_pds.py
unify_api/modules/home_page/procedures/count_info_pds.py
+1
-1
count_info_proxy.py
unify_api/modules/home_page/views/count_info_proxy.py
+1
-1
security_info.py
unify_api/modules/home_page/views/security_info.py
+2
-2
No files found.
unify_api/modules/alarm_manager/dao/list_alarm_dao.py
View file @
95140e9a
...
@@ -16,7 +16,7 @@ async def new_list_alarm_dao(cid, points, page_num, page_size, start, end,
...
@@ -16,7 +16,7 @@ async def new_list_alarm_dao(cid, points, page_num, page_size, start, end,
#
#
# if product == Product.RecognitionElectric.value: # 识电u
# if product == Product.RecognitionElectric.value: # 识电u
alarm_list
=
SDU_ALARM_LIST
alarm_list
=
SDU_ALARM_LIST
query_body
=
{
query_body
=
{
"from"
:
(
page_num
-
1
)
*
page_size
,
"from"
:
(
page_num
-
1
)
*
page_size
,
"size"
:
page_size
,
"size"
:
page_size
,
...
@@ -126,12 +126,12 @@ async def new_list_alarm_dao_new15(cid, points, start, end, importance, offset,
...
@@ -126,12 +126,12 @@ async def new_list_alarm_dao_new15(cid, points, start, end, importance, offset,
async
def
wx_list_alarm_dao
(
cids
,
product
,
start
,
end
):
async
def
wx_list_alarm_dao
(
cids
,
product
,
start
,
end
):
"""小程序消息列表, 取当前范围最新40条"""
"""小程序消息列表, 取当前范围最新40条"""
# alarm_list = list(EVENT_TYPE_MAP.keys()) # 安电u
# alarm_list = list(EVENT_TYPE_MAP.keys()) # 安电u
#
#
# if product == Product.RecognitionElectric.value: # 识电u
# if product == Product.RecognitionElectric.value: # 识电u
alarm_list
=
SDU_ALARM_LIST
alarm_list
=
SDU_ALARM_LIST
query_body
=
{
query_body
=
{
"size"
:
40
,
"size"
:
40
,
"query"
:
{
"query"
:
{
...
@@ -171,7 +171,7 @@ async def wx_list_alarm_dao(cids, product, start, end):
...
@@ -171,7 +171,7 @@ async def wx_list_alarm_dao(cids, product, start, end):
}
}
}
}
)
)
log
.
info
(
f
"index:{index}--query_body:{query_body}"
)
log
.
info
(
f
"index:{index}--query_body:{query_body}"
)
async
with
EsUtil
()
as
es
:
async
with
EsUtil
()
as
es
:
es_re
=
await
es
.
search_origin
(
body
=
query_body
,
index
=
index
)
es_re
=
await
es
.
search_origin
(
body
=
query_body
,
index
=
index
)
...
@@ -181,7 +181,7 @@ async def wx_list_alarm_dao(cids, product, start, end):
...
@@ -181,7 +181,7 @@ async def wx_list_alarm_dao(cids, product, start, end):
async
def
list_alarm_zdu_dao
(
cid
,
points
,
page_num
,
page_size
,
start
,
end
,
async
def
list_alarm_zdu_dao
(
cid
,
points
,
page_num
,
page_size
,
start
,
end
,
importance
,
event_type
):
importance
,
event_type
):
"""智电u, es报警信息分页列表, 可根据报警等级筛选"""
"""智电u, es报警信息分页列表, 可根据报警等级筛选"""
query_body
=
{
query_body
=
{
"from"
:
(
page_num
-
1
)
*
page_size
,
"from"
:
(
page_num
-
1
)
*
page_size
,
"size"
:
page_size
,
"size"
:
page_size
,
...
@@ -268,7 +268,7 @@ async def list_alarm_zdu_dao_new15(cid, points, start,
...
@@ -268,7 +268,7 @@ async def list_alarm_zdu_dao_new15(cid, points, start,
async
def
wx_list_alarm_zdu_dao
(
cid
,
points
,
start
,
end
):
async
def
wx_list_alarm_zdu_dao
(
cid
,
points
,
start
,
end
):
"""智电u, wx小程序, 取当前范围最新100条"""
"""智电u, wx小程序, 取当前范围最新100条"""
query_body
=
{
query_body
=
{
"size"
:
100
,
"size"
:
100
,
"query"
:
{
"query"
:
{
...
@@ -350,10 +350,13 @@ async def alarm_content_time_distribution_dao(cid, start, end, ):
...
@@ -350,10 +350,13 @@ async def alarm_content_time_distribution_dao(cid, start, end, ):
"""
"""
智电温度漏电流电参数分布
智电温度漏电流电参数分布
"""
"""
mid_li
=
[
f
"cid={cid}"
]
if
isinstance
(
cid
,
list
):
mid_li
=
[
f
"cid in {str(tuple(cid)).replace(',)', ')')}"
]
else
:
mid_li
=
[
f
"cid={cid}"
]
if
start
and
end
:
if
start
and
end
:
mid_li
.
append
(
f
"event_datetime BETWEEN '{start}' and '{end}'"
)
mid_li
.
append
(
f
"event_datetime BETWEEN '{start}' and '{end}'"
)
sql
=
f
"""
sql
=
f
"""
SELECT
SELECT
event_type,
event_type,
...
...
unify_api/modules/alarm_manager/views/list_alarm.py
View file @
95140e9a
...
@@ -66,7 +66,10 @@ async def post_list_alarm(req, body: PageRequest) -> ListAlarmResponse:
...
@@ -66,7 +66,10 @@ async def post_list_alarm(req, body: PageRequest) -> ListAlarmResponse:
# cids = await get_cids(user_id, product)
# cids = await get_cids(user_id, product)
proxy_cids
=
await
get_proxy_cids
(
user_id
,
product
,
proxy_id
)
proxy_cids
=
await
get_proxy_cids
(
user_id
,
product
,
proxy_id
)
cids
=
list
(
set
(
req_cids
)
&
set
(
proxy_cids
))
if
req_cids
and
proxy_cids
:
cids
=
list
(
set
(
req_cids
)
&
set
(
proxy_cids
))
else
:
cids
=
proxy_cids
if
req
.
json
.
get
(
"product"
)
in
[
Product
.
RecognitionElectric
.
value
,
if
req
.
json
.
get
(
"product"
)
in
[
Product
.
RecognitionElectric
.
value
,
Product
.
IntelligentU
.
value
]:
Product
.
IntelligentU
.
value
]:
...
...
unify_api/modules/electric/views/proxy_ranking.py
View file @
95140e9a
...
@@ -14,7 +14,11 @@ async def post_elec_count_info(req, body: ProxyRankingReq) -> ProxyRankingResp:
...
@@ -14,7 +14,11 @@ async def post_elec_count_info(req, body: ProxyRankingReq) -> ProxyRankingResp:
product
=
body
.
product
product
=
body
.
product
# sql = "SELECT cid,safe_exp,health_exp,ele_quan,ele_charge " \
# sql = "SELECT cid,safe_exp,health_exp,ele_quan,ele_charge " \
# "FROM safe_health_stats_cid where cid in %s and cal_month = %s"
# "FROM safe_health_stats_cid where cid in %s and cal_month = %s"
sql
=
"SELECT safe_exp,health_exp,ele_quan,ele_charge,shsc.cid,"
\
sql
=
"SELECT ifnull(safe_exp,0) safe_exp,"
\
"ifnull(health_exp,0) health_exp,"
\
"ifnull(ele_quan,0) ele_quan,"
\
"ifnull(ele_charge,0) ele_charge,"
\
"shsc.cid,"
\
"company.shortname FROM safe_health_stats_cid shsc "
\
"company.shortname FROM safe_health_stats_cid shsc "
\
"left join company on shsc.cid=company.cid where "
\
"left join company on shsc.cid=company.cid where "
\
"shsc.cid in
%
s and shsc.cal_month =
%
s"
"shsc.cid in
%
s and shsc.cal_month =
%
s"
...
...
unify_api/modules/home_page/procedures/count_info_pds.py
View file @
95140e9a
...
@@ -63,7 +63,7 @@ async def other_info(company_id):
...
@@ -63,7 +63,7 @@ async def other_info(company_id):
# 获取到工厂安装时间create_time
# 获取到工厂安装时间create_time
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
company_sql
=
"select create_time from company where cid =
%
s"
company_sql
=
"select create_time from company where cid =
%
s"
alarm_data
=
await
conn
.
fetch
one
(
alarm_sql
,
(
company_id
,))
alarm_data
=
await
conn
.
fetch
all
(
alarm_sql
,
(
company_id
,))
company
=
await
conn
.
fetchone
(
company_sql
,
(
company_id
,))
company
=
await
conn
.
fetchone
(
company_sql
,
(
company_id
,))
create_time_timestamp
=
company
[
"create_time"
]
create_time_timestamp
=
company
[
"create_time"
]
create_time
=
datetime
.
fromtimestamp
(
create_time_timestamp
)
create_time
=
datetime
.
fromtimestamp
(
create_time_timestamp
)
...
...
unify_api/modules/home_page/views/count_info_proxy.py
View file @
95140e9a
...
@@ -79,7 +79,7 @@ async def post_count_info_proxy(req) -> CountInfoProxyResp:
...
@@ -79,7 +79,7 @@ async def post_count_info_proxy(req) -> CountInfoProxyResp:
safe_operation_days
+=
safe_run_days
safe_operation_days
+=
safe_run_days
total_alarm
+=
alarm_count
total_alarm
+=
alarm_count
# 4. 累计监测用电
# 4. 累计监测用电
total_power
=
await
proxy_power
(
cid_list
)
total_power
=
await
proxy_power
15
(
cid_list
)
return
CountInfoProxyResp
(
return
CountInfoProxyResp
(
total_cid
=
total_cid
,
total_cid
=
total_cid
,
total_monitor
=
total_monitor
,
total_monitor
=
total_monitor
,
...
...
unify_api/modules/home_page/views/security_info.py
View file @
95140e9a
...
@@ -120,7 +120,7 @@ async def post_alarm_content_distribution(
...
@@ -120,7 +120,7 @@ async def post_alarm_content_distribution(
date_type
=
body
.
date_type
date_type
=
body
.
date_type
if
product
==
Product
.
AndianUManage
.
value
:
if
product
==
Product
.
AndianUManage
.
value
:
user_id
=
request
.
ctx
.
user_id
user_id
=
jwt_user
(
request
)
# cids = await get_cids(user_id, product)
# cids = await get_cids(user_id, product)
proxy_id
=
body
.
proxy_id
proxy_id
=
body
.
proxy_id
cids
=
await
get_proxy_cids
(
user_id
,
product
,
proxy_id
)
cids
=
await
get_proxy_cids
(
user_id
,
product
,
proxy_id
)
...
@@ -129,7 +129,7 @@ async def post_alarm_content_distribution(
...
@@ -129,7 +129,7 @@ async def post_alarm_content_distribution(
else
:
else
:
raise
BusinessException
(
message
=
f
"暂时不支持其他产品"
)
raise
BusinessException
(
message
=
f
"暂时不支持其他产品"
)
alarm_info_map
=
await
alarm_content_time_distribution_pds
(
req_cids
,
start
,
end
,
date_type
)
alarm_info_map
=
await
alarm_content_time_distribution_pds
(
req_cids
,
start
,
end
)
temperature
,
residual_current
,
electric_param
,
electric_param_detail
=
(
temperature
,
residual_current
,
electric_param
,
electric_param_detail
=
(
alarm_info_map
[
"temperature"
],
alarm_info_map
[
"temperature"
],
alarm_info_map
[
"residual_current"
],
alarm_info_map
[
"residual_current"
],
...
...
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