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
2e78d4a7
Commit
2e78d4a7
authored
Apr 21, 2023
by
lcn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复Bug
parent
313d2526
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
84 deletions
+106
-84
electric_service.py
unify_api/modules/electric/service/electric_service.py
+106
-84
No files found.
unify_api/modules/electric/service/electric_service.py
View file @
2e78d4a7
...
@@ -212,7 +212,8 @@ async def elec_card_level_service(point_list):
...
@@ -212,7 +212,8 @@ async def elec_card_level_service(point_list):
# point_mid = await batch_get_wiring_type(point_list)
# point_mid = await batch_get_wiring_type(point_list)
# # 3. 获取redis数据
# # 3. 获取redis数据
# res_redis = await elec_current_data(point_mid)
# res_redis = await elec_current_data(point_mid)
mtids
=
[
monitor
[
"mtid"
]
for
monitor
in
monitor_point_list
if
monitor
[
"mtid"
]]
mtids
=
[
monitor
[
"mtid"
]
for
monitor
in
monitor_point_list
if
monitor
[
"mtid"
]]
cid
=
monitor_point_list
[
0
][
'cid'
]
if
len
(
monitor_point_list
)
>
0
else
0
cid
=
monitor_point_list
[
0
][
'cid'
]
if
len
(
monitor_point_list
)
>
0
else
0
results
=
await
elec_current_data_new15
(
mtids
,
cid
)
results
=
await
elec_current_data_new15
(
mtids
,
cid
)
# 4. 返回数据
# 4. 返回数据
...
@@ -773,17 +774,18 @@ async def elec_index_service_new15(cid, point_id, start, end):
...
@@ -773,17 +774,18 @@ async def elec_index_service_new15(cid, point_id, start, end):
"ua_dev_mean"
,
"ua_dev_min"
,
"ua_dev_max"
,
"ua_dev_mean"
,
"ua_dev_min"
,
"ua_dev_max"
,
"freq_dev_mean"
,
"freq_dev_min"
,
"freq_dev_max"
]
"freq_dev_mean"
,
"freq_dev_min"
,
"freq_dev_max"
]
datas
=
await
get_electric_datas_dao
(
table_name
,
point_id
,
start
,
end
)
datas
=
await
get_electric_datas_dao
(
table_name
,
point_id
,
start
,
end
)
if
not
datas
:
#
if not datas:
return
ElecIndexResponse
(
#
return ElecIndexResponse(
ctnum
=
ctnum
,
common_indexes
=
[],
#
ctnum=ctnum, common_indexes=[],
elec_qual_indexes
=
[]
#
elec_qual_indexes=[]
)
#
)
df
=
pd
.
DataFrame
(
list
(
datas
))
df
=
pd
.
DataFrame
(
list
(
datas
))
# 常规参数统计
# 常规参数统计
common_indexes
=
[]
common_indexes
=
[]
_common_items
=
{
i
.
rsplit
(
"_"
,
1
)[
0
]
for
i
in
common_items
}
_common_items
=
{
i
.
rsplit
(
"_"
,
1
)[
0
]
for
i
in
common_items
}
for
item
in
_common_items
:
for
item
in
_common_items
:
item_name
=
item
.
rsplit
(
"_"
,
1
)[
0
]
item_name
=
item
.
rsplit
(
"_"
,
1
)[
0
]
if
datas
:
max_item_name
=
f
"{item}_max"
max_item_name
=
f
"{item}_max"
max_value
=
df
[
max_item_name
]
.
max
()
max_value
=
df
[
max_item_name
]
.
max
()
if
not
pd
.
isna
(
max_value
):
if
not
pd
.
isna
(
max_value
):
...
@@ -814,12 +816,22 @@ async def elec_index_service_new15(cid, point_id, start, end):
...
@@ -814,12 +816,22 @@ async def elec_index_service_new15(cid, point_id, start, end):
min_time
=
min_time
or
""
,
min_time
=
min_time
or
""
,
avg
=
avg_value
,
avg
=
avg_value
,
)
)
else
:
elec_index
=
ElecIndex
(
stats_index
=
item_name
,
max
=
""
,
max_time
=
""
,
min
=
""
,
min_time
=
""
,
avg
=
""
,
)
common_indexes
.
append
(
elec_index
)
common_indexes
.
append
(
elec_index
)
# 电能质量统计
# 电能质量统计
elec_qual_indexes
=
[]
elec_qual_indexes
=
[]
_elec_qual_items
=
{
i
.
rsplit
(
"_"
,
1
)[
0
]
for
i
in
elec_qual_items
}
_elec_qual_items
=
{
i
.
rsplit
(
"_"
,
1
)[
0
]
for
i
in
elec_qual_items
}
for
item
in
_elec_qual_items
:
for
item
in
_elec_qual_items
:
item_name
=
item
.
rsplit
(
"_"
,
1
)[
0
]
item_name
=
item
.
rsplit
(
"_"
,
1
)[
0
]
if
datas
:
max_item_name
=
f
"{item}_max"
max_item_name
=
f
"{item}_max"
max_value
=
df
[
max_item_name
]
.
max
()
max_value
=
df
[
max_item_name
]
.
max
()
if
not
pd
.
isna
(
max_value
):
if
not
pd
.
isna
(
max_value
):
...
@@ -850,6 +862,15 @@ async def elec_index_service_new15(cid, point_id, start, end):
...
@@ -850,6 +862,15 @@ async def elec_index_service_new15(cid, point_id, start, end):
min_time
=
min_time
,
min_time
=
min_time
,
avg
=
avg_value
,
avg
=
avg_value
,
)
)
else
:
elec_index
=
ElecIndex
(
stats_index
=
item_name
,
max
=
""
,
max_time
=
""
,
min
=
""
,
min_time
=
""
,
avg
=
""
,
)
elec_qual_indexes
.
append
(
elec_index
)
elec_qual_indexes
.
append
(
elec_index
)
# 小程序需要这漏电流和温度
# 小程序需要这漏电流和温度
if
cid
:
if
cid
:
...
@@ -877,6 +898,7 @@ async def elec_index_service_new15(cid, point_id, start, end):
...
@@ -877,6 +898,7 @@ async def elec_index_service_new15(cid, point_id, start, end):
elec_qual_indexes
=
elec_qual_indexes
elec_qual_indexes
=
elec_qual_indexes
)
)
async
def
elec_current_service_new15
(
point_id
):
async
def
elec_current_service_new15
(
point_id
):
# 获取mtid
# 获取mtid
meter_info
=
await
get_meter_by_point_new15
(
point_id
)
meter_info
=
await
get_meter_by_point_new15
(
point_id
)
...
@@ -903,7 +925,7 @@ async def elec_current_service_new15(point_id):
...
@@ -903,7 +925,7 @@ async def elec_current_service_new15(point_id):
time_str
=
str
(
res
[
"ts"
])[
0
:
19
]
time_str
=
str
(
res
[
"ts"
])[
0
:
19
]
else
:
else
:
time_str
=
time_format
.
get_datetime_str
(
0
)
time_str
=
time_format
.
get_datetime_str
(
0
)
return
time_str
,
res
return
time_str
,
res
def
get_sdu_i_and_u
(
res
,
ctnum
):
def
get_sdu_i_and_u
(
res
,
ctnum
):
...
...
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