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
2fb841ab
Commit
2fb841ab
authored
Jun 20, 2023
by
lcn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修复
parent
7129b651
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
65 deletions
+69
-65
fine_monitor_pds.py
unify_api/modules/anshiu/procedures/fine_monitor_pds.py
+27
-29
fine_monitor_serv.py
unify_api/modules/anshiu/service/fine_monitor_serv.py
+22
-22
electric_pds.py
unify_api/modules/electric/procedures/electric_pds.py
+2
-2
electric_service.py
unify_api/modules/electric/service/electric_service.py
+3
-1
time_format.py
unify_api/utils/time_format.py
+15
-11
No files found.
unify_api/modules/anshiu/procedures/fine_monitor_pds.py
View file @
2fb841ab
...
...
@@ -128,9 +128,7 @@ async def get_aiao_1min_pds(slots, temp_res_data, res_curr_th):
async
def
get_aiao_data_pds
(
slots
,
temp_res_data
,
res_curr_th
):
temp
,
res
,
s_value
,
a_value
,
b_value
,
c_value
,
n_value
=
[],
[],
{
"item"
:
"漏电流"
,
"threhold"
:
res_curr_th
},
{
"item"
:
"A相"
},
{
"item"
:
"B相"
},
{
"item"
:
"C相"
},
{
"item"
:
"N相"
}
"item"
:
"B相"
},
{
"item"
:
"C相"
},
{
"item"
:
"N线"
}
temp1
,
temp2
,
temp3
,
temp4
,
res_curr
=
{},
{},
{},
{},
{}
for
i
in
temp_res_data
:
...
...
unify_api/modules/anshiu/service/fine_monitor_serv.py
View file @
2fb841ab
...
...
@@ -87,19 +87,19 @@ async def get_point_chart_data(point_id, date_start, date_end, intervel,
elec_data
=
await
get_point_15min_chart_dao
(
mtid
,
stats_items
,
date_start
,
date_end
)
power
,
i
,
u
=
await
get_point_data_chart_pds
(
ctnum
,
slots
,
elec_data
)
i
,
v
,
power
=
await
get_point_data_chart_pds
(
ctnum
,
slots
,
elec_data
)
elif
intervel
==
86400
:
elec_data
=
await
get_point_1day_chart_dao
(
mtid
,
stats_items
,
date_start
,
date_end
)
power
,
i
,
u
=
await
get_point_data_chart_pds
(
ctnum
,
slots
,
elec_data
)
i
,
v
,
power
=
await
get_point_data_chart_pds
(
ctnum
,
slots
,
elec_data
)
else
:
elec_data
=
await
get_point_1min_chart_dao
(
mtid
,
ctnum
,
date_start
,
date_end
)
power
,
i
,
u
=
await
get_point_1min_chart_pds
(
ctnum
,
slots
,
elec_data
)
i
,
v
,
power
=
await
get_point_1min_chart_pds
(
ctnum
,
slots
,
elec_data
)
return
power
,
i
,
u
,
ctnum
return
power
,
i
,
v
,
ctnum
async
def
electric_index_list_service
(
mtid
,
start_time
,
end_time
,
...
...
unify_api/modules/electric/procedures/electric_pds.py
View file @
2fb841ab
...
...
@@ -5,12 +5,12 @@ from unify_api.constants import CST
from
unify_api.modules.common.service.td_engine_service
import
\
get_td_engine_data
from
unify_api.utils.taos_new
import
parse_td_columns
,
td3_tbl_compate
from
unify_api.utils.time_format
import
get_15min_ago
async
def
elec_current_data
(
mtids
,
cid
):
res_map
=
{}
last_15min_time
=
pendulum
.
now
(
tz
=
CST
)
.
subtract
(
minutes
=
15
)
.
format
(
"YYYY-MM-DD HH:mm:ss"
)
last_15min_time
=
get_15min_ago
()
url
=
f
"{SETTING.stb_url}db_electric?tz=Asia/Shanghai"
table_name
=
[
"mt{}_ele"
.
format
(
mtid
)
for
mtid
in
mtids
]
...
...
unify_api/modules/electric/service/electric_service.py
View file @
2fb841ab
...
...
@@ -24,6 +24,7 @@ from unify_api.modules.electric.components.electric import (
ElecIndexResponse
,
ElecIndex
,
EscResp
,
QcsResp
,
EclResp
,
QclResp
,
)
from
unify_api.utils.taos_new
import
parse_td_columns
from
unify_api.utils.time_format
import
get_15min_ago
async
def
elec_current_storeys_service
(
storeys
):
...
...
@@ -587,9 +588,10 @@ async def elec_current_service(point_id):
raise
BusinessException
(
message
=
"没有该监测点的monitor信息,请联系运维人员!"
)
mtid
=
meter_info
[
"mtid"
]
last_15min_time
=
get_15min_ago
()
# 获取子表中的实时数据
url
=
f
"{SETTING.stb_url}db_electric?tz=Asia/Shanghai"
sql
=
f
"select last_row(*) from mt{mtid}_ele where
pid={point_id}
"
sql
=
f
"select last_row(*) from mt{mtid}_ele where
ts>='{last_15min_time}'
"
is_succ
,
results
=
await
get_td_engine_data
(
url
,
sql
)
if
not
is_succ
or
not
results
or
results
.
get
(
"code"
)
>
0
:
return
''
,
{}
...
...
unify_api/utils/time_format.py
View file @
2fb841ab
...
...
@@ -1487,3 +1487,7 @@ def get_time_diff(start, end):
end_f
=
my_pendulum
.
from_format
(
end
,
YMD_Hms
)
diff
=
end_f
.
int_timestamp
-
start_f
.
int_timestamp
return
diff
def
get_15min_ago
(
time_fmt
=
"YYYY-MM-DD HH:mm:ss"
):
return
my_pendulum
.
now
(
tz
=
CST
)
.
subtract
(
minutes
=
15
)
.
format
(
time_fmt
)
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