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
d059b272
Commit
d059b272
authored
Jun 02, 2023
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove es 2023-6-2
parent
984a952d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
61 additions
and
240 deletions
+61
-240
scope_operations_serv.py
unify_api/modules/anshiu/service/scope_operations_serv.py
+2
-2
health_score.py
unify_api/modules/common/procedures/health_score.py
+2
-3
points.py
unify_api/modules/common/procedures/points.py
+1
-50
electric_util.py
unify_api/modules/electric/procedures/electric_util.py
+1
-1
proxy_safe_pds.py
unify_api/modules/electric/procedures/proxy_safe_pds.py
+2
-3
electric_service.py
unify_api/modules/electric/service/electric_service.py
+2
-2
electric.py
unify_api/modules/electric/views/electric.py
+3
-3
count_info_proxy_pds.py
..._api/modules/home_page/procedures/count_info_proxy_pds.py
+47
-150
count_info_proxy.py
unify_api/modules/home_page/views/count_info_proxy.py
+1
-26
No files found.
unify_api/modules/anshiu/service/scope_operations_serv.py
View file @
d059b272
...
@@ -25,7 +25,7 @@ from unify_api.modules.anshiu.procedures.scope_operations_pds import \
...
@@ -25,7 +25,7 @@ from unify_api.modules.anshiu.procedures.scope_operations_pds import \
from
unify_api.modules.device_cloud.procedures.mqtt_helper
import
\
from
unify_api.modules.device_cloud.procedures.mqtt_helper
import
\
change_param_to_config
change_param_to_config
from
unify_api.modules.electric.procedures.electric_util
import
\
from
unify_api.modules.electric.procedures.electric_util
import
\
get_wiring_type_new15
load_point_ctnum
from
unify_api.modules.zhiwei_u
import
config
from
unify_api.modules.zhiwei_u
import
config
from
unify_api.modules.zhiwei_u.dao.data_es_dao
import
query_search_scope
from
unify_api.modules.zhiwei_u.dao.data_es_dao
import
query_search_scope
from
unify_api.utils.time_format
import
get_time_duration
,
\
from
unify_api.utils.time_format
import
get_time_duration
,
\
...
@@ -490,7 +490,7 @@ async def scope_detail_service(event_id):
...
@@ -490,7 +490,7 @@ async def scope_detail_service(event_id):
if
not
scope_data
or
not
scope_data
.
get
(
"url"
):
if
not
scope_data
or
not
scope_data
.
get
(
"url"
):
return
{},
[],
[],
[],
[],
[],
[],
[],
[]
return
{},
[],
[],
[],
[],
[],
[],
[],
[]
# 接线法:二表/三表
# 接线法:二表/三表
ctnum
=
await
get_wiring_type_new15
(
pid
)
or
3
ctnum
=
await
load_point_ctnum
(
pid
)
or
3
# 查询录波详细数据 还不确定在哪儿拿,现在脚本是minio里边,但是家义说未来要在青云里面
# 查询录波详细数据 还不确定在哪儿拿,现在脚本是minio里边,但是家义说未来要在青云里面
# 测试数据存储
# 测试数据存储
# filedata/electric_ops/scope/A2004000519/2022/6/27/17/1656321462.json
# filedata/electric_ops/scope/A2004000519/2022/6/27/17/1656321462.json
...
...
unify_api/modules/common/procedures/health_score.py
View file @
d059b272
...
@@ -8,8 +8,7 @@ from pot_libs.logger import log
...
@@ -8,8 +8,7 @@ from pot_libs.logger import log
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
from
unify_api.modules.common.dao.health_score_dao
import
\
from
unify_api.modules.common.dao.health_score_dao
import
\
health_score_points_aggs
,
get_point_dats_dao
,
get_mean_datas_dao
health_score_points_aggs
,
get_point_dats_dao
,
get_mean_datas_dao
from
unify_api.modules.common.procedures.points
import
get_points
,
\
from
unify_api.modules.common.procedures.points
import
load_compy_points
get_points_new15
from
unify_api.modules.electric.procedures.electric_util
import
\
from
unify_api.modules.electric.procedures.electric_util
import
\
batch_get_wiring_type
batch_get_wiring_type
from
unify_api.modules.home_page.procedures
import
point_inlines
from
unify_api.modules.home_page.procedures
import
point_inlines
...
@@ -447,7 +446,7 @@ async def load_manage_health_radar(cids, recent_days=30):
...
@@ -447,7 +446,7 @@ async def load_manage_health_radar(cids, recent_days=30):
today
=
pendulum
.
today
()
today
=
pendulum
.
today
()
start_time
=
today
.
subtract
(
days
=
recent_days
)
.
format
(
"YYYY-MM-DD HH:mm:ss"
)
start_time
=
today
.
subtract
(
days
=
recent_days
)
.
format
(
"YYYY-MM-DD HH:mm:ss"
)
end_time
=
str
(
today
.
subtract
(
seconds
=
1
))
.
format
(
"YYYY-MM-DD HH:mm:ss"
)
end_time
=
str
(
today
.
subtract
(
seconds
=
1
))
.
format
(
"YYYY-MM-DD HH:mm:ss"
)
company_point_map
=
await
get_points_new15
(
cids
)
company_point_map
=
await
load_compy_points
(
cids
)
all_point_map
=
dict
()
all_point_map
=
dict
()
for
cid
,
points
in
company_point_map
.
items
():
for
cid
,
points
in
company_point_map
.
items
():
for
pid
,
point_info
in
points
.
items
():
for
pid
,
point_info
in
points
.
items
():
...
...
unify_api/modules/common/procedures/points.py
View file @
d059b272
...
@@ -6,56 +6,7 @@ from unify_api.modules.common.components.list_points_cps import CommonLocation,
...
@@ -6,56 +6,7 @@ from unify_api.modules.common.components.list_points_cps import CommonLocation,
from
unify_api.modules.common.dao.common_dao
import
query_points_by_storey
from
unify_api.modules.common.dao.common_dao
import
query_points_by_storey
async
def
get_points
(
company_ids
):
async
def
load_compy_points
(
cids
):
"""
获取一个工厂的有效监测点
:param company_id:
:return: 返回{"cid": {"point_id": point_info}}
"""
company_point_map
=
defaultdict
(
dict
)
async
with
MysqlUtil
()
as
conn
:
point_sql
=
(
"select pid, cid cid, inlid from point where cid in
%
s"
)
points
=
await
conn
.
fetchall
(
point_sql
,
args
=
(
company_ids
,))
company_point_ids_map
=
defaultdict
(
list
)
for
point
in
points
:
company_point_ids_map
[
point
[
"cid"
]]
.
append
(
point
[
"pid"
])
point_map
=
{
i
[
"pid"
]:
i
for
i
in
points
}
point_ids
=
list
(
point_map
.
keys
())
pid_field
,
start_time_field
=
"pid"
,
"start_time"
sql
=
f
"SELECT pid, mid FROM change_meter_record WHERE pid in
%
s ORDER BY {pid_field}, {start_time_field}"
records
=
await
conn
.
fetchall
(
sql
,
args
=
(
point_ids
,))
newest_point_meter_relation
=
{
i
[
"pid"
]:
i
[
"mid"
]
for
i
in
records
if
i
[
"mid"
]}
valid_mids
=
list
(
newest_point_meter_relation
.
values
())
newest_record_map
=
{
i
[
"pid"
]:
point_map
.
get
(
i
[
"pid"
])
for
i
in
records
if
i
[
"mid"
]}
# 根据有效的meter id查询meter参数
async
with
MysqlUtil
()
as
conn
:
mid_field
,
start_time_field
=
"mid"
,
"start_time"
mp_sql
=
f
"SELECT vc, mid, ctnum FROM meter_param_record WHERE mid in
%
s ORDER BY {mid_field}, {start_time_field}"
mps
=
await
conn
.
fetchall
(
mp_sql
,
args
=
(
valid_mids
,))
meter_param_map
=
{
i
[
"mid"
]:
i
for
i
in
mps
}
for
cid
,
point_ids
in
company_point_ids_map
.
items
():
for
point_id
in
point_ids
:
if
point_id
in
newest_record_map
:
mid
=
newest_point_meter_relation
[
point_id
]
meter_param
=
meter_param_map
.
get
(
mid
)
if
not
meter_param
:
# 如果不存在参数,拆了?
continue
point_info
=
newest_record_map
[
point_id
]
point_info
[
"meter_param"
]
=
meter_param
company_point_map
[
cid
][
point_id
]
=
point_info
return
company_point_map
async
def
get_points_new15
(
cids
):
sql
=
"SELECT p.pid,p.cid,p.inlid,vc,ctnum "
\
sql
=
"SELECT p.pid,p.cid,p.inlid,vc,ctnum "
\
"FROM `point` p INNER JOIN "
\
"FROM `point` p INNER JOIN "
\
"monitor m on m.mtid=p.mtid where p.cid in
%
s and m.demolished=0;"
"monitor m on m.mtid=p.mtid where p.cid in
%
s and m.demolished=0;"
...
...
unify_api/modules/electric/procedures/electric_util.py
View file @
d059b272
...
@@ -26,7 +26,7 @@ async def get_wiring_type(point_id):
...
@@ -26,7 +26,7 @@ async def get_wiring_type(point_id):
return
ctnum
,
mtid
return
ctnum
,
mtid
async
def
get_wiring_type_new15
(
pid
):
async
def
load_point_ctnum
(
pid
):
sql
=
"SELECT ctnum FROM `point` WHERE pid=
%
s"
sql
=
"SELECT ctnum FROM `point` WHERE pid=
%
s"
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
result
=
await
conn
.
fetchone
(
sql
,
args
=
(
pid
,))
result
=
await
conn
.
fetchone
(
sql
,
args
=
(
pid
,))
...
...
unify_api/modules/electric/procedures/proxy_safe_pds.py
View file @
d059b272
...
@@ -4,7 +4,7 @@ import pendulum
...
@@ -4,7 +4,7 @@ import pendulum
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
from
unify_api.modules.common.procedures.common_cps
import
proxy_safe_run_info
from
unify_api.modules.common.procedures.common_cps
import
proxy_safe_run_info
from
unify_api.modules.common.procedures.points
import
get_points
,
get_points_new15
from
unify_api.modules.common.procedures.points
import
load_compy_points
async
def
proxy_electric_count_info
(
cids
,
month_str
):
async
def
proxy_electric_count_info
(
cids
,
month_str
):
...
@@ -14,8 +14,7 @@ async def proxy_electric_count_info(cids, month_str):
...
@@ -14,8 +14,7 @@ async def proxy_electric_count_info(cids, month_str):
sql
=
"select * from safe_health_stats_cid where cid in
%
s and cal_month=
%
s"
sql
=
"select * from safe_health_stats_cid where cid in
%
s and cal_month=
%
s"
safe_stats_list
=
await
conn
.
fetchall
(
sql
,
args
=
(
cids
,
month_str
,))
safe_stats_list
=
await
conn
.
fetchall
(
sql
,
args
=
(
cids
,
month_str
,))
# company_point_map = await get_points(cids)
company_point_map
=
await
load_compy_points
(
cids
)
company_point_map
=
await
get_points_new15
(
cids
)
cid_alarm_score_map
=
{}
cid_alarm_score_map
=
{}
alarm_content_map
=
{
alarm_content_map
=
{
...
...
unify_api/modules/electric/service/electric_service.py
View file @
d059b272
...
@@ -16,7 +16,7 @@ from unify_api.modules.electric.procedures.electric_pds import \
...
@@ -16,7 +16,7 @@ from unify_api.modules.electric.procedures.electric_pds import \
from
unify_api.utils
import
time_format
from
unify_api.utils
import
time_format
from
unify_api.utils.common_utils
import
round_2
,
round_4
,
multiplication_two
from
unify_api.utils.common_utils
import
round_2
,
round_4
,
multiplication_two
from
unify_api.modules.electric.procedures.electric_util
import
\
from
unify_api.modules.electric.procedures.electric_util
import
\
get_wiring_type
,
get_wiring_type_new15
get_wiring_type
,
load_point_ctnum
from
datetime
import
datetime
from
datetime
import
datetime
from
unify_api.modules.common.procedures.location_temp_rcurrent
import
\
from
unify_api.modules.common.procedures.location_temp_rcurrent
import
\
location_stats_statics
location_stats_statics
...
@@ -415,7 +415,7 @@ async def qual_current_level_service(point_list):
...
@@ -415,7 +415,7 @@ async def qual_current_level_service(point_list):
async
def
elec_index_service
(
cid
,
point_id
,
start
,
end
):
async
def
elec_index_service
(
cid
,
point_id
,
start
,
end
):
ctnum
=
await
get_wiring_type_new15
(
point_id
)
ctnum
=
await
load_point_ctnum
(
point_id
)
ctnum
=
ctnum
if
ctnum
==
2
else
3
ctnum
=
ctnum
if
ctnum
==
2
else
3
now
=
str
(
datetime
.
now
())
now
=
str
(
datetime
.
now
())
if
start
[:
10
]
==
now
[:
10
]
and
end
[:
10
]
==
now
[:
10
]:
if
start
[:
10
]
==
now
[:
10
]
and
end
[:
10
]
==
now
[:
10
]:
...
...
unify_api/modules/electric/views/electric.py
View file @
d059b272
...
@@ -25,7 +25,7 @@ from unify_api.modules.electric.service.electric_service import (
...
@@ -25,7 +25,7 @@ from unify_api.modules.electric.service.electric_service import (
from
unify_api.utils
import
time_format
from
unify_api.utils
import
time_format
from
unify_api
import
constants
from
unify_api
import
constants
from
unify_api.modules.electric.procedures.electric_util
import
(
from
unify_api.modules.electric.procedures.electric_util
import
(
get_wiring_type
,
get_wiring_type_new15
,
get_wiring_type
,
load_point_ctnum
,
add_random_change
,
add_random_change
,
)
)
...
@@ -90,7 +90,7 @@ async def post_elec_history(req, body: PageRequest) -> ElecHistoryResponse:
...
@@ -90,7 +90,7 @@ async def post_elec_history(req, body: PageRequest) -> ElecHistoryResponse:
async
def
elec_history_service
(
start
,
end
,
pid
,
intervel
,
slots
):
async
def
elec_history_service
(
start
,
end
,
pid
,
intervel
,
slots
):
ctnum
=
await
get_wiring_type_new15
(
pid
)
ctnum
=
await
load_point_ctnum
(
pid
)
if
ctnum
==
2
:
if
ctnum
==
2
:
stats_items
=
[
stats_items
=
[
"lf_mean"
,
"pttl_mean"
,
"qttl_mean"
,
"costtl_mean"
,
"uab_mean"
,
"lf_mean"
,
"pttl_mean"
,
"qttl_mean"
,
"costtl_mean"
,
"uab_mean"
,
...
@@ -358,7 +358,7 @@ async def post_qual_history(req, body: PageRequest) -> QualHistoryResponse:
...
@@ -358,7 +358,7 @@ async def post_qual_history(req, body: PageRequest) -> QualHistoryResponse:
async
def
qual_history_service
(
start
,
end
,
intervel
,
slots
,
pid
):
async
def
qual_history_service
(
start
,
end
,
intervel
,
slots
,
pid
):
ctnum
=
await
get_wiring_type_new15
(
pid
)
ctnum
=
await
load_point_ctnum
(
pid
)
if
intervel
==
900
:
if
intervel
==
900
:
table_name
=
"point_15min_electric"
table_name
=
"point_15min_electric"
date_fmt
=
"
%%
H:
%%
i"
date_fmt
=
"
%%
H:
%%
i"
...
...
unify_api/modules/home_page/procedures/count_info_proxy_pds.py
View file @
d059b272
This diff is collapsed.
Click to expand it.
unify_api/modules/home_page/views/count_info_proxy.py
View file @
d059b272
...
@@ -9,7 +9,7 @@ from unify_api.modules.common.procedures.alarm_cps import alarm_count, \
...
@@ -9,7 +9,7 @@ from unify_api.modules.common.procedures.alarm_cps import alarm_count, \
from
unify_api.modules.common.procedures.cids
import
get_cids
,
get_cid_info
,
\
from
unify_api.modules.common.procedures.cids
import
get_cids
,
get_cid_info
,
\
get_proxy_cids
get_proxy_cids
from
unify_api.modules.common.procedures.common_cps
import
proxy_safe_run_info
from
unify_api.modules.common.procedures.common_cps
import
proxy_safe_run_info
from
unify_api.modules.common.procedures.points
import
proxy_points
,
get_points
from
unify_api.modules.common.procedures.points
import
proxy_points
from
unify_api.modules.common.procedures.power_cps
import
power_use_count
,
\
from
unify_api.modules.common.procedures.power_cps
import
power_use_count
,
\
load_cmpy_power
load_cmpy_power
from
unify_api.modules.elec_charge.procedures.elec_charge_pds
import
\
from
unify_api.modules.elec_charge.procedures.elec_charge_pds
import
\
...
@@ -189,31 +189,6 @@ async def post_proxy_map_info(request,
...
@@ -189,31 +189,6 @@ async def post_proxy_map_info(request,
)
)
@
summary
(
"识电U首页统计信息"
)
async
def
post_count_info_sdu
(
req
)
->
CountInfoSduResp
:
user_id
=
req
.
ctx
.
user_id
product
=
req
.
json
[
"product"
]
cids
=
await
get_cids
(
user_id
,
product
=
product
)
company_point_map
=
await
get_points
(
cids
)
safe_run_map
=
await
proxy_safe_run_info
(
cids
)
total_tenant
,
safe_operation_days
=
0
,
0
for
cid
in
cids
:
total_tenant
+=
len
(
company_point_map
[
cid
])
safe_operation_days
+=
safe_run_map
[
cid
][
"safe_run_days"
]
total_power
=
await
power_use_count
(
cids
)
total_alarm
=
await
alarm_count
(
cids
)
online_rate
=
93
+
random
.
choice
([
1
,
1.2
,
1.5
,
1.7
,
2
])
return
CountInfoSduResp
(
total_tenant
=
total_tenant
,
online_rate
=
online_rate
,
safe_operation_days
=
safe_operation_days
,
total_power
=
total_power
,
total_alarm
=
total_alarm
,
)
@
summary
(
"识电U首页报警分布"
)
@
summary
(
"识电U首页报警分布"
)
async
def
post_reg_alarm_distribution
(
request
,
async
def
post_reg_alarm_distribution
(
request
,
body
:
AlarmRankingReq
)
->
AlarmDistributionResp
:
body
:
AlarmRankingReq
)
->
AlarmDistributionResp
:
...
...
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