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
20a1acad
Commit
20a1acad
authored
Aug 01, 2023
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix anshiu 2023-7-31
parent
f21859b9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
181 deletions
+81
-181
fine_monitor_pds.py
unify_api/modules/anshiu/procedures/fine_monitor_pds.py
+81
-181
No files found.
unify_api/modules/anshiu/procedures/fine_monitor_pds.py
View file @
20a1acad
...
...
@@ -61,7 +61,7 @@ async def get_es_aiao_15min_data(query_body):
async
with
EsUtil
()
as
es
:
es_results
=
await
es
.
search_origin
(
body
=
query_body
,
index
=
constants
.
LOCATION_15MIN_AIAO
)
return
es_results
.
get
(
"aggregations"
,
{})
...
...
@@ -72,7 +72,7 @@ async def get_es_point_15min_data(query_body):
async
with
EsUtil
()
as
es
:
es_results
=
await
es
.
search_origin
(
body
=
query_body
,
index
=
constants
.
POINT_15MIN_INDEX
)
return
es_results
.
get
(
"aggregations"
,
{})
...
...
@@ -86,17 +86,17 @@ async def get_es_point_1min_data(query_body, start):
str
(
int
(
start
[
5
:
7
]))
es_results
=
await
es
.
search_origin
(
body
=
query_body
,
index
=
p_database
)
return
es_results
.
get
(
"hits"
,
{})
.
get
(
"hits"
,
{})
async
def
get_aiao_1min_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
=
{},
{},
{},
{},
{}
[
temp1
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"temp1"
)})
for
i
in
temp_res_data
]
[
temp2
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"temp2"
)})
for
i
in
temp_res_data
]
...
...
@@ -104,7 +104,7 @@ async def get_aiao_1min_pds(slots, temp_res_data, res_curr_th):
[
temp4
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"temp4"
)})
for
i
in
temp_res_data
]
[
res_curr
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"residual_current"
)})
for
i
in
temp_res_data
]
a_slot
,
b_slot
,
c_slot
,
n_slot
,
res_slot
=
[],
[],
[],
[],
[]
[
a_slot
.
append
(
temp1
.
get
(
i
,
""
))
for
i
in
slots
]
[
b_slot
.
append
(
temp2
.
get
(
i
,
""
))
for
i
in
slots
]
...
...
@@ -121,15 +121,17 @@ async def get_aiao_1min_pds(slots, temp_res_data, res_curr_th):
temp
.
append
(
c_value
)
temp
.
append
(
n_value
)
res
.
append
(
s_value
)
return
temp
,
res
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
:
if
i
.
get
(
'ad_field'
)
==
'temp1'
:
...
...
@@ -142,7 +144,7 @@ async def get_aiao_data_pds(slots, temp_res_data, res_curr_th):
temp4
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"value_avg"
)})
else
:
res_curr
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"value_avg"
)})
a_slot
,
b_slot
,
c_slot
,
n_slot
,
res_slot
=
[],
[],
[],
[],
[]
[
a_slot
.
append
(
temp1
.
get
(
i
,
""
))
for
i
in
slots
]
[
b_slot
.
append
(
temp2
.
get
(
i
,
""
))
for
i
in
slots
]
...
...
@@ -164,181 +166,79 @@ async def get_aiao_data_pds(slots, temp_res_data, res_curr_th):
async
def
get_point_1min_chart_pds
(
ctnum
,
slots
,
data
):
if
ctnum
==
3
:
i
,
v
,
power
,
ia_value
,
ib_value
,
ic_value
,
ua_value
,
ub_value
,
uc_value
,
pttl_value
,
qttl_value
\
=
[],
[],
[],
{
"item"
:
"ia"
},
{
"item"
:
"ib"
},
{
"item"
:
"ic"
},
{
"item"
:
"ua"
},
{
"item"
:
"ub"
},
{
"item"
:
"uc"
},
{
"item"
:
"pttl"
},
{
"item"
:
"qttl"
}
ia_dict
,
ib_dict
,
ic_dict
,
pttl_dict
,
qttl_dict
,
ua_dict
,
ub_dict
,
uc_dict
\
=
{},
{},
{},
{},
{},
{},
{},
{}
[
ia_dict
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"ia"
)})
for
i
in
data
]
[
ib_dict
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"ib"
)})
for
i
in
data
]
[
ic_dict
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"ic"
)})
for
i
in
data
]
[
pttl_dict
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"pttl"
)})
for
i
in
data
]
[
qttl_dict
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"qttl"
)})
for
i
in
data
]
[
ua_dict
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"ua"
)})
for
i
in
data
]
[
ub_dict
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"ub"
)})
for
i
in
data
]
[
uc_dict
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"uc"
)})
for
i
in
data
]
ia_list
,
ib_list
,
ic_list
,
pttl_list
,
qttl_list
,
ua_list
,
ub_list
,
uc_list
\
=
[],
[],
[],
[],
[],
[],
[],
[]
[
ia_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
ib_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
ic_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
pttl_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
qttl_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
ua_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
ub_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
uc_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
ia_value
.
update
({
"value_slots"
:
ia_list
})
ib_value
.
update
({
"value_slots"
:
ib_list
})
ic_value
.
update
({
"value_slots"
:
ic_list
})
pttl_value
.
update
({
"value_slots"
:
pttl_list
})
qttl_value
.
update
({
"value_slots"
:
qttl_list
})
ua_value
.
update
({
"value_slots"
:
ua_list
})
ub_value
.
update
({
"value_slots"
:
ub_list
})
uc_value
.
update
({
"value_slots"
:
uc_list
})
i
.
append
(
ia_value
)
i
.
append
(
ib_value
)
i
.
append
(
ic_value
)
v
.
append
(
ua_value
)
v
.
append
(
ub_value
)
v
.
append
(
uc_value
)
power
.
append
(
pttl_value
)
power
.
append
(
qttl_value
)
fields
=
[
"ia"
,
"ib"
,
"ic"
,
"ua"
,
"ub"
,
"uc"
,
"pttl"
,
"qttl"
]
else
:
fields
=
[
"ia"
,
"ic"
,
"uab"
,
"ucb"
,
"pttl"
,
"qttl"
]
d_parse
=
{
field
:
{}
for
field
in
fields
}
for
d_item
in
data
:
for
field
in
fields
:
d_parse
[
field
][
d_item
.
get
(
"ts"
)]
=
d_item
.
get
(
field
)
d_stats
=
{
field
:
[]
for
field
in
fields
}
for
field
in
fields
:
d_stats
[
field
]
=
[
d_parse
[
field
]
.
get
(
s
,
""
)
for
s
in
slots
]
if
ctnum
==
3
:
d_ia
=
dict
(
item
=
"ia"
,
value_slots
=
d_stats
[
"ia"
])
d_ib
=
dict
(
item
=
"ib"
,
value_slots
=
d_stats
[
"ib"
])
d_ic
=
dict
(
item
=
"ic"
,
value_slots
=
d_stats
[
"ic"
])
d_ua
=
dict
(
item
=
"ua"
,
value_slots
=
d_stats
[
"ua"
])
d_ub
=
dict
(
item
=
"ub"
,
value_slots
=
d_stats
[
"ub"
])
d_uc
=
dict
(
item
=
"uc"
,
value_slots
=
d_stats
[
"uc"
])
i
=
[
d_ia
,
d_ib
,
d_ic
]
v
=
[
d_ua
,
d_ub
,
d_uc
]
else
:
i
,
v
,
power
,
ia_value
,
ic_value
,
uab_value
,
ucb_value
,
pttl_value
,
qttl_value
\
=
[],
[],
[],
{
"item"
:
"ia"
},
{
"item"
:
"ic"
},
{
"item"
:
"uab"
},
{
"item"
:
"ucb"
},
{
"item"
:
"pttl"
},
{
"item"
:
"qttl"
}
ia_dict
,
ic_dict
,
pttl_dict
,
qttl_dict
,
uab_dict
,
ucb_dict
,
\
=
{},
{},
{},
{},
{},
{}
[
ia_dict
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"ia"
)})
for
i
in
data
]
[
ic_dict
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"ic"
)})
for
i
in
data
]
[
pttl_dict
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"pttl"
)})
for
i
in
data
]
[
qttl_dict
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"qttl"
)})
for
i
in
data
]
[
uab_dict
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"ua"
)})
for
i
in
data
]
[
ucb_dict
.
update
({
i
.
get
(
"ts"
):
i
.
get
(
"ub"
)})
for
i
in
data
]
ia_list
,
ic_list
,
pttl_list
,
qttl_list
,
uab_list
,
ucb_list
\
=
[],
[],
[],
[],
[],
[]
[
ia_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
ic_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
pttl_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
qttl_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
uab_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
ucb_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
ia_value
.
update
({
"value_slots"
:
ia_list
})
ic_value
.
update
({
"value_slots"
:
ic_list
})
pttl_value
.
update
({
"value_slots"
:
pttl_list
})
qttl_value
.
update
({
"value_slots"
:
qttl_list
})
uab_value
.
update
({
"value_slots"
:
uab_list
})
ucb_value
.
update
({
"value_slots"
:
ucb_list
})
i
.
append
(
ia_value
)
i
.
append
(
ic_value
)
v
.
append
(
uab_value
)
v
.
append
(
ucb_value
)
power
.
append
(
pttl_value
)
power
.
append
(
qttl_value
)
d_ia
=
dict
(
item
=
"ia"
,
value_slots
=
d_stats
[
"ia"
])
d_ic
=
dict
(
item
=
"ic"
,
value_slots
=
d_stats
[
"ic"
])
d_uab
=
dict
(
item
=
"uab"
,
value_slots
=
d_stats
[
"uab"
])
d_ucb
=
dict
(
item
=
"ucb"
,
value_slots
=
d_stats
[
"ucb"
])
i
=
[
d_ia
,
d_ic
]
v
=
[
d_uab
,
d_ucb
]
d_pttl
=
dict
(
item
=
"pttl"
,
value_slots
=
d_stats
[
"pttl"
])
d_qttl
=
dict
(
item
=
"qttl"
,
value_slots
=
d_stats
[
"qttl"
])
power
=
[
d_pttl
,
d_qttl
]
return
i
,
v
,
power
async
def
get_point_data_chart_pds
(
ctnum
,
slots
,
data
):
if
ctnum
==
3
:
i
,
v
,
power
,
ia_value
,
ib_value
,
ic_value
,
ua_value
,
ub_value
,
uc_value
,
pttl_value
,
qttl_value
\
=
[],
[],
[],
{
"item"
:
"ia"
},
{
"item"
:
"ib"
},
{
"item"
:
"ic"
},
{
"item"
:
"ua"
},
{
"item"
:
"ub"
},
{
"item"
:
"uc"
},
{
"item"
:
"pttl"
},
{
"item"
:
"qttl"
}
ia_dict
,
ib_dict
,
ic_dict
,
pttl_dict
,
qttl_dict
,
ua_dict
,
ub_dict
,
uc_dict
\
=
{},
{},
{},
{},
{},
{},
{},
{}
[
ia_dict
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"ia_mean"
)})
for
i
in
data
]
[
ib_dict
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"ib_mean"
)})
for
i
in
data
]
[
ic_dict
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"ic_mean"
)})
for
i
in
data
]
[
pttl_dict
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"pttl_mean"
)})
for
i
in
data
]
[
qttl_dict
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"qttl_mean"
)})
for
i
in
data
]
[
ua_dict
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"ua_mean"
)})
for
i
in
data
]
[
ub_dict
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"ub_mean"
)})
for
i
in
data
]
[
uc_dict
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"uc_mean"
)})
for
i
in
data
]
ia_list
,
ib_list
,
ic_list
,
pttl_list
,
qttl_list
,
ua_list
,
ub_list
,
uc_list
\
=
[],
[],
[],
[],
[],
[],
[],
[]
[
ia_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
ib_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
ic_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
pttl_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
qttl_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
ua_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
ub_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
uc_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
ia_value
.
update
({
"value_slots"
:
ia_list
})
ib_value
.
update
({
"value_slots"
:
ib_list
})
ic_value
.
update
({
"value_slots"
:
ic_list
})
pttl_value
.
update
({
"value_slots"
:
pttl_list
})
qttl_value
.
update
({
"value_slots"
:
qttl_list
})
ua_value
.
update
({
"value_slots"
:
ua_list
})
ub_value
.
update
({
"value_slots"
:
ub_list
})
uc_value
.
update
({
"value_slots"
:
uc_list
})
i
.
append
(
ia_value
)
i
.
append
(
ib_value
)
i
.
append
(
ic_value
)
v
.
append
(
ua_value
)
v
.
append
(
ub_value
)
v
.
append
(
uc_value
)
power
.
append
(
pttl_value
)
power
.
append
(
qttl_value
)
fields
=
[
"ia"
,
"ib"
,
"ic"
,
"ua"
,
"ub"
,
"uc"
,
"pttl"
,
"qttl"
]
else
:
i
,
v
,
power
,
ia_value
,
ic_value
,
uab_value
,
ucb_value
,
pttl_value
,
qttl_value
\
=
[],
[],
[],
{
"item"
:
"ia"
},
{
"item"
:
"ic"
},
{
"item"
:
"uab"
},
{
"item"
:
"ucb"
},
{
"item"
:
"pttl"
},
{
"item"
:
"qttl"
}
ia_dict
,
ic_dict
,
pttl_dict
,
qttl_dict
,
uab_dict
,
ucb_dict
,
\
=
{},
{},
{},
{},
{},
{}
[
ia_dict
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"ia_mean"
)})
for
i
in
data
]
[
ic_dict
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"ic_mean"
)})
for
i
in
data
]
[
pttl_dict
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"pttl_mean"
)})
for
i
in
data
]
[
qttl_dict
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"qttl_mean"
)})
for
i
in
data
]
[
uab_dict
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"ua_mean"
)})
for
i
in
data
]
[
ucb_dict
.
update
({
i
.
get
(
"create_time"
):
i
.
get
(
"ub_mean"
)})
for
i
in
data
]
ia_list
,
ic_list
,
pttl_list
,
qttl_list
,
uab_list
,
ucb_list
\
=
[],
[],
[],
[],
[],
[]
[
ia_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
ic_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
pttl_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
qttl_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
uab_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
[
ucb_list
.
append
(
ia_dict
.
get
(
i
,
""
))
for
i
in
slots
]
ia_value
.
update
({
"value_slots"
:
ia_list
})
ic_value
.
update
({
"value_slots"
:
ic_list
})
pttl_value
.
update
({
"value_slots"
:
pttl_list
})
qttl_value
.
update
({
"value_slots"
:
qttl_list
})
uab_value
.
update
({
"value_slots"
:
uab_list
})
ucb_value
.
update
({
"value_slots"
:
ucb_list
})
i
.
append
(
ia_value
)
i
.
append
(
ic_value
)
v
.
append
(
uab_value
)
v
.
append
(
ucb_value
)
power
.
append
(
pttl_value
)
power
.
append
(
qttl_value
)
fields
=
[
"ia"
,
"ic"
,
"uab"
,
"ucb"
,
"pttl"
,
"qttl"
]
d_parse
=
{
field
:
{}
for
field
in
fields
}
for
d_item
in
data
:
for
field
in
fields
:
ts
=
d_item
.
get
(
"create_time"
)
d_parse
[
field
][
ts
]
=
d_item
.
get
(
f
"{field}_mean"
)
d_stats
=
{
field
:
[]
for
field
in
fields
}
for
field
in
fields
:
d_stats
[
field
]
=
[
d_parse
[
field
]
.
get
(
s
,
""
)
for
s
in
slots
]
if
ctnum
==
3
:
d_ia
=
dict
(
item
=
"ia"
,
value_slots
=
d_stats
[
"ia"
])
d_ib
=
dict
(
item
=
"ib"
,
value_slots
=
d_stats
[
"ib"
])
d_ic
=
dict
(
item
=
"ic"
,
value_slots
=
d_stats
[
"ic"
])
d_ua
=
dict
(
item
=
"ua"
,
value_slots
=
d_stats
[
"ua"
])
d_ub
=
dict
(
item
=
"ub"
,
value_slots
=
d_stats
[
"ub"
])
d_uc
=
dict
(
item
=
"uc"
,
value_slots
=
d_stats
[
"uc"
])
i
=
[
d_ia
,
d_ib
,
d_ic
]
v
=
[
d_ua
,
d_ub
,
d_uc
]
else
:
d_ia
=
dict
(
item
=
"ia"
,
value_slots
=
d_stats
[
"ia"
])
d_ic
=
dict
(
item
=
"ic"
,
value_slots
=
d_stats
[
"ic"
])
d_uab
=
dict
(
item
=
"uab"
,
value_slots
=
d_stats
[
"uab"
])
d_ucb
=
dict
(
item
=
"ucb"
,
value_slots
=
d_stats
[
"ucb"
])
i
=
[
d_ia
,
d_ic
]
v
=
[
d_uab
,
d_ucb
]
d_pttl
=
dict
(
item
=
"pttl"
,
value_slots
=
d_stats
[
"pttl"
])
d_qttl
=
dict
(
item
=
"qttl"
,
value_slots
=
d_stats
[
"qttl"
])
power
=
[
d_pttl
,
d_qttl
]
return
i
,
v
,
power
...
...
@@ -493,7 +393,7 @@ def cal_aiao_value(location_datas, datas, mtid=None):
mean_value
=
round
(
mean_value
,
2
)
else
:
mean_value
=
""
if
mtid
:
mtid
=
str
(
mtid
)
electric_index
=
dict
(
...
...
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