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
f21859b9
Commit
f21859b9
authored
Aug 01, 2023
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix anshiu read tdengine 2023-7-31
parent
744236c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
24 deletions
+17
-24
fine_monitor_dao.py
unify_api/modules/anshiu/dao/fine_monitor_dao.py
+17
-24
No files found.
unify_api/modules/anshiu/dao/fine_monitor_dao.py
View file @
f21859b9
...
@@ -8,24 +8,20 @@ from pot_libs.mysql_util.mysql_util import MysqlUtil
...
@@ -8,24 +8,20 @@ from pot_libs.mysql_util.mysql_util import MysqlUtil
async
def
get_aiao_1min_dao
(
mtid
,
start_time
,
end_time
):
async
def
get_aiao_1min_dao
(
mtid
,
start_time
,
end_time
):
# 查1min温度漏电流
# 查1min温度漏电流
sid_data
=
await
get_sid_by_mtid_dao
(
mtid
)
sid_data
=
await
get_sid_by_mtid_dao
(
mtid
)
sid
=
sid_data
[
'sid'
]
.
lower
()
sid_lower
=
sid_data
[
"sid"
]
.
lower
()
su_table
=
"new_adio_stb"
td_mt_table
=
get_td_table_name
(
"adio"
,
mtid
)
td_mt_table
=
get_td_table_name
(
su_table
,
mtid
)
url
=
f
"{SETTING.stb_url}db_adio"
url
=
f
"{SETTING.stb_url}db_adio"
# td的精度过高,采用 >= start and < end的形式查询
sql
=
f
"select ts, temp1, temp2, temp3, temp4, residual_current "
\
f
"from db_adio.{td_mt_table} WHERE "
\
sql
=
f
"select last_row( ts, temp1, temp2, temp3, temp4, residual_current) "
\
f
"from adio_stb where TBNAME = '{td_mt_table}' and "
\
f
"ts >= '{start_time}' AND ts <'{end_time}' "
\
f
"ts >= '{start_time}' AND ts <'{end_time}' "
\
f
"
Interval(60s)
order by ts asc"
f
"order by ts asc"
is_succ
,
results
=
await
get_td_engine_data
(
url
,
sql
)
is_succ
,
results
=
await
get_td_engine_data
(
url
,
sql
)
if
not
results
:
if
not
results
:
su_table
=
"old_adio_stb"
td_mt_table
=
f
"s_{sid_lower}_a"
td_mt_table
=
get_td_table_name
(
su_table
,
sid
)
sql
=
f
"select ts, temp1, temp2, temp3, temp4, residual_current "
\
sql
=
f
"select last_row( ts, temp1, temp2, temp3, temp4, residual_current) "
\
f
"from db_adio.{td_mt_table} WHERE "
\
f
"from adio_stb where TBNAME = '{td_mt_table}' and "
\
f
"ts >= '{start_time}' AND ts <'{end_time}' "
\
f
"ts >= '{start_time}' AND ts <'{end_time}' "
\
f
"
Interval(60s)
order by ts asc"
f
"order by ts asc"
is_succ
,
results
=
await
get_td_engine_data
(
url
,
sql
)
is_succ
,
results
=
await
get_td_engine_data
(
url
,
sql
)
if
not
is_succ
:
if
not
is_succ
:
raise
BusinessException
()
raise
BusinessException
()
...
@@ -112,24 +108,21 @@ async def get_point_1min_chart_dao(mtid, ctnum, start_time, end_time):
...
@@ -112,24 +108,21 @@ async def get_point_1min_chart_dao(mtid, ctnum, start_time, end_time):
]
]
# 查1min温度漏电流
# 查1min温度漏电流
sid_data
=
await
get_sid_by_mtid_dao
(
mtid
)
sid_data
=
await
get_sid_by_mtid_dao
(
mtid
)
sid
=
sid_data
[
'sid'
]
.
lower
()
sid_lower
=
sid_data
[
"sid"
]
.
lower
()
su_table
=
"new_electric_stb"
td_mt_table
=
get_td_table_name
(
"electric"
,
mtid
)
td_mt_table
=
get_td_table_name
(
su_table
,
mtid
)
url
=
f
"{SETTING.stb_url}db_electric"
url
=
f
"{SETTING.stb_url}db_electric"
# td的精度过高,采用 >= start and < end的形式查询
# td的精度过高,采用 >= start and < end的形式查询
stats_items
.
insert
(
0
,
'ts'
)
stats_items
.
insert
(
0
,
'ts'
)
sql
=
f
"select
last_row({','.join(stats_items)})
"
\
sql
=
f
"select
{','.join(stats_items)}
"
\
f
"from
electric_stb where TBNAME = '{td_mt_table}' and
"
\
f
"from
db_electric.{td_mt_table} WHERE
"
\
f
"ts >= '{start_time}' AND ts <'{end_time}' "
\
f
"ts >= '{start_time}' AND ts <'{end_time}' "
\
f
"
Interval(60s)
order by ts asc"
f
"order by ts asc"
is_succ
,
results
=
await
get_td_engine_data
(
url
,
sql
)
is_succ
,
results
=
await
get_td_engine_data
(
url
,
sql
)
if
not
results
:
if
not
results
:
su_table
=
"old_electric_stb"
sql
=
f
"select {','.join(stats_items)} "
\
td_mt_table
=
get_td_table_name
(
su_table
,
sid
)
f
"from db_electric.s_{sid_lower}_e WHERE "
\
sql
=
f
"select last_row( {','.join(stats_items)}) "
\
f
"from electric_stb where TBNAME = '{td_mt_table}' and "
\
f
"ts >= '{start_time}' AND ts <'{end_time}' "
\
f
"ts >= '{start_time}' AND ts <'{end_time}' "
\
f
"
Interval(60s)
order by ts asc"
f
"order by ts asc"
is_succ
,
results
=
await
get_td_engine_data
(
url
,
sql
)
is_succ
,
results
=
await
get_td_engine_data
(
url
,
sql
)
if
not
is_succ
:
if
not
is_succ
:
raise
BusinessException
()
raise
BusinessException
()
...
...
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