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
54b0d9c6
Commit
54b0d9c6
authored
Aug 02, 2023
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix lf_dev 2023-8-2
parent
20a1acad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
+23
-23
electric.py
unify_api/modules/electric/views/electric.py
+23
-23
No files found.
unify_api/modules/electric/views/electric.py
View file @
54b0d9c6
...
...
@@ -53,15 +53,15 @@ async def post_elec_history(req, body: PageRequest) -> ElecHistoryResponse:
except
:
log
.
error
(
"param error, ranges is NULL"
)
raise
ParamException
(
message
=
"param error, ranges is NULL"
)
try
:
intervel
,
slots
=
time_format
.
time_pick_transf
(
date_start
,
date_end
)
except
:
log
.
error
(
"param error, date format error"
)
raise
ParamException
(
message
=
"param error, date format error"
)
point_id
=
filed_value_from_list
(
body
.
filter
.
equals
,
"point_id"
)
if
point_id
<=
0
or
not
point_id
:
log
.
warning
(
"param exception, equals is NULL, no point_id"
)
raise
ParamException
(
...
...
@@ -162,12 +162,12 @@ async def post_elec_current(req, body: PageRequest) -> ElecCurrentResponse:
for
k
,
v
in
res
.
items
():
if
isinstance
(
v
,
(
str
,
int
)):
continue
res
[
k
]
=
add_random_change
(
v
)
except
Exception
as
e
:
log
.
error
(
f
"post_elec_current service error:{str(e)}"
)
raise
BusinessException
(
message
=
f
"{str(e)}"
)
return
ElecCurrentResponse
(
real_time
=
time_str
,
**
{
k
:
v
for
k
,
v
in
res
.
items
()
if
k
in
[
field
.
name
for
field
in
...
...
@@ -181,7 +181,7 @@ async def post_elec_index(req, body: PageRequest) -> ElecIndexResponse:
cid
=
req
.
json
.
get
(
"cid"
)
# 1. 获取point_id
point_id
=
filed_value_from_list
(
body
.
filter
.
equals
,
"point_id"
)
if
not
point_id
or
point_id
<=
0
:
msg
=
"param exception, equals is NULL, no point_id"
log
.
warning
(
msg
)
...
...
@@ -208,20 +208,20 @@ async def post_qual_history(req, body: PageRequest) -> QualHistoryResponse:
except
:
log
.
error
(
"param error, ranges is NULL"
)
raise
ParamException
(
message
=
"param error, ranges is NULL"
)
try
:
intervel
,
slots
=
time_format
.
time_pick_transf
(
date_start
,
date_end
)
except
:
log
.
error
(
"param error, date format error"
)
raise
ParamException
(
message
=
"param error, date format error"
)
point_id
=
filed_value_from_list
(
body
.
filter
.
equals
,
"point_id"
)
if
not
point_id
or
point_id
<=
0
:
msg
=
"param exception, equals is NULL, no point_id"
log
.
warning
(
msg
)
raise
ParamException
(
message
=
msg
)
return
await
qual_history_service
(
date_start
,
date_end
,
intervel
,
slots
,
point_id
)
...
...
@@ -272,15 +272,15 @@ async def qual_history_service(start, end, intervel, slots, pid):
if
slot
in
datas
.
keys
():
for
stats_item
in
stats_items
:
value
=
datas
[
slot
]
.
get
(
stats_item
,
""
)
if
value
and
stats_item
==
"freq_dev_mean"
:
# 如果频率偏差保留两位小数之后为0了,那么直接返回0,防止出现-0.00 的情况
if
abs
(
value
)
<
0.05
:
value
=
0
#
if value and stats_item == "freq_dev_mean":
# 如果频率偏差保留两位小数之后为0了,那么直接返回0,防止出现-0.00 的情况
#
if abs(value) < 0.05:
#
value = 0
elec_data
[
stats_item
]
.
append
(
value
)
else
:
for
stats_item
in
stats_items
:
elec_data
[
stats_item
]
.
append
(
""
)
voltage_dev
=
VoltageDev
(
**
{
k
.
rsplit
(
"_"
,
1
)[
0
]:
v
...
...
@@ -343,7 +343,7 @@ async def qual_history_service(start, end, intervel, slots, pid):
):
sdu_i
=
"ic"
sdu_u
=
"uc"
return
QualHistoryResponse
(
ctnum
=
ctnum
,
voltage_dev
=
voltage_dev
,
...
...
@@ -367,35 +367,35 @@ async def post_qual_current(req, body: PageRequest) -> QualCurrentResponse:
except
Exception
as
e
:
log
.
warning
(
f
"param exception, equals is NULL, no pid, e:{e}"
)
raise
ParamException
(
message
=
"param exception, equals is NULL, no pid"
)
if
point_id
<=
0
or
not
point_id
or
cid
<=
0
:
log
.
warning
(
"param exception, equals is NULL, no point_id"
)
raise
ParamException
(
message
=
"param exception, equals is NULL, no pid"
)
try
:
time_str
,
d_rt_ele
=
await
elec_current_service
(
point_id
)
if
d_rt_ele
is
None
:
d_rt_ele
=
{}
# 加些随机变化(防止数据一直不变化)
for
k
,
v
in
d_rt_ele
.
items
():
if
isinstance
(
v
,
(
str
,
int
)):
continue
d_rt_ele
[
k
]
=
add_random_change
(
v
)
except
Exception
as
e
:
log
.
error
(
f
"post_qual_current service error:{str(e)}"
)
raise
BusinessException
(
message
=
f
"{str(e)}"
)
d_vol_harm
,
d_cur_harm
=
{},
{}
for
k
in
[
field
.
name
for
field
in
fields
(
VoltageHarmonicRate
)]:
d_vol_harm
[
k
]
=
d_rt_ele
.
get
(
k
)
or
""
voltage_harmonic
=
VoltageHarmonicRate
(
**
d_vol_harm
)
for
k
in
[
field
.
name
for
field
in
fields
(
CurrentHarmonicRate
)]:
d_cur_harm
[
k
]
=
d_rt_ele
.
get
(
k
)
or
""
current_harmonic
=
CurrentHarmonicRate
(
**
d_cur_harm
)
health_index
=
await
health_score
.
load_health_index
(
cid
,
point_id
)
ret_items
=
[
"ua_dev"
,
"ub_dev"
,
"uc_dev"
,
"uab_dev"
,
"ucb_dev"
,
"freq_dev"
,
"ubl"
,
"ibl"
,
"sdu_i"
,
"sdu_u"
]
...
...
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