Commit f0fe05e6 authored by ZZH's avatar ZZH

remove es 2023-6-5

parent 15ba9fa7
from pot_libs.es_util.es_utils import EsUtil
from pot_libs.logger import log
from unify_api import constants
from pot_libs.mysql_util.mysql_util import MysqlUtil from pot_libs.mysql_util.mysql_util import MysqlUtil
...@@ -26,30 +23,3 @@ async def get_mean_datas_dao(pids, words, start, end): ...@@ -26,30 +23,3 @@ async def get_mean_datas_dao(pids, words, start, end):
datas = await conn.fetchall(sql, args=(pids,)) datas = await conn.fetchall(sql, args=(pids,))
return datas return datas
return [] return []
async def health_score_points_aggs(start, end, point_list):
"""根据points分组, 再求平均值"""
sql = f"""
SELECT
pid,
avg( uab_mean ) uab_mean_avg,
avg( costtl_mean ) costtl_mean_avg,
avg( lf_mean ) lf_mean_avg,
avg( thduab_mean ) thduab_mean_avg,
avg( ubl_mean ) ubl_mean_avg,
avg( freq_mean ) freq_mean_avg,
avg( ua_mean ) ua_mean_avg
FROM
point_15min_electric
WHERE
create_time > "{start}"
AND create_time < "{end}"
AND pid in %s
GROUP BY
pid
"""
async with MysqlUtil() as conn:
datas = await conn.fetchall(sql, args=(tuple(point_list),)) if point_list else []
return datas
...@@ -241,20 +241,7 @@ async def power_charge_p_point_aggs(date_start, date_end, pid_list, interval): ...@@ -241,20 +241,7 @@ async def power_charge_p_point_aggs(date_start, date_end, pid_list, interval):
return es_re["aggregations"]["pids"]["buckets"] return es_re["aggregations"]["pids"]["buckets"]
async def point_aggs_kwh(point_list, start=None, end=None): async def point_kwh_charge(point_list, start=None, end=None):
if start and end:
sql = f"SELECT sum(kwh) kwh, sum(charge) charge FROM " \
f"`point_15min_power` " \
f"where pid in %s and create_time BETWEEN {start} and {end}"
else:
sql = "SELECT sum(kwh) kwh,sum(charge) charge FROM point_15min_power" \
" where pid in %s"
async with MysqlUtil() as conn:
data = await conn.fetchone(sql, args=(point_list,))
return data
async def point_aggs_kwh_new15(point_list, start=None, end=None):
"""1.5版本根据pid,求电量电费""" """1.5版本根据pid,求电量电费"""
if start and end: if start and end:
sql = f"SELECT sum(kwh) kwh, sum(charge) charge FROM " \ sql = f"SELECT sum(kwh) kwh, sum(charge) charge FROM " \
......
...@@ -14,7 +14,7 @@ from unify_api.modules.electric_optimization.procedures.optimization_pds import ...@@ -14,7 +14,7 @@ from unify_api.modules.electric_optimization.procedures.optimization_pds import
) )
from unify_api.constants import ADD_ELE_PRICE from unify_api.constants import ADD_ELE_PRICE
from unify_api.modules.elec_charge.dao.elec_charge_dao import ( from unify_api.modules.elec_charge.dao.elec_charge_dao import (
point_aggs_kwh, point_aggs_kwh_new15 point_kwh_charge
) )
...@@ -84,7 +84,7 @@ async def power_factor_service(inline_id): ...@@ -84,7 +84,7 @@ async def power_factor_service(inline_id):
save_charge = None save_charge = None
inline = await tc_by_inline_id(inline_id) inline = await tc_by_inline_id(inline_id)
point_list = await pids_by_cid(inline.get("cid")) point_list = await pids_by_cid(inline.get("cid"))
charge_res = await point_aggs_kwh_new15(point_list) charge_res = await point_kwh_charge(point_list)
# total_charge = charge_res["aggregations"]["charge"]["value"] # total_charge = charge_res["aggregations"]["charge"]["value"]
total_charge = charge_res.get("charge") or 0 total_charge = charge_res.get("charge") or 0
if last_month_pf and 0.9 > last_month_pf >= 0: if last_month_pf and 0.9 > last_month_pf >= 0:
......
...@@ -9,7 +9,7 @@ from unify_api.modules.common.dao.common_dao import monitor_by_cid, tsp_by_cid, ...@@ -9,7 +9,7 @@ from unify_api.modules.common.dao.common_dao import monitor_by_cid, tsp_by_cid,
from unify_api.modules.common.procedures import health_score from unify_api.modules.common.procedures import health_score
from unify_api.modules.common.procedures.points import proxy_points, list_point from unify_api.modules.common.procedures.points import proxy_points, list_point
from unify_api.modules.elec_charge.dao.elec_charge_dao import \ from unify_api.modules.elec_charge.dao.elec_charge_dao import \
query_charge_aggs_points, point_aggs_kwh query_charge_aggs_points, point_kwh_charge
from unify_api.modules.elec_charge.procedures.elec_charge_pds import \ from unify_api.modules.elec_charge.procedures.elec_charge_pds import \
load_proxy_power load_proxy_power
from unify_api.modules.home_page.components.count_info_proxy_cps import \ from unify_api.modules.home_page.components.count_info_proxy_cps import \
...@@ -183,8 +183,8 @@ async def info_yang_chen_service(cid): ...@@ -183,8 +183,8 @@ async def info_yang_chen_service(cid):
# 获取全部雾炮监测点 # 获取全部雾炮监测点
storey_list = await storey_wp_by_cid(cid) storey_list = await storey_wp_by_cid(cid)
point_list = [storey["point_id"] for storey in storey_list] point_list = [storey["point_id"] for storey in storey_list]
kwh_res = await point_aggs_kwh(point_list) kwh_res = await point_kwh_charge(point_list)
total_kwh = kwh_res["aggregations"]["kwh"]["value"] total_kwh = kwh_res.get("kwh") or 0
return IycResp( return IycResp(
total_point=total_point, total_point=total_point,
air_quality=air_quality, air_quality=air_quality,
...@@ -352,26 +352,6 @@ async def alarm_safe_index_service(cid): ...@@ -352,26 +352,6 @@ async def alarm_safe_index_service(cid):
) )
async def health_status_index_service(cid):
"""首页-健康指数等"""
# 1. 健康评分, 雷达
score_info = await health_score.load_health_radar(cid)
# 2. 健康指数
health_index = await health_score.load_health_index(cid)
# 3. 状态
health_status = health_status_res(health_index, "wechat")
return HsiResp(
health_index=round(health_index),
health_status=health_status,
v_dev=round(score_info["v_score"]),
freq_dev=round(score_info["freq_score"]),
ubl=round(score_info["ubl_score"]),
costtl=round(score_info["costtl_score"]),
thdu=round(score_info["thdu_score"]),
lf=round(score_info["lf_score"]),
)
async def economic_index_res(cid): async def economic_index_res(cid):
"""经济指数""" """经济指数"""
count_info_map = await optimization_count_info(cid) count_info_map = await optimization_count_info(cid)
......
...@@ -31,8 +31,7 @@ from unify_api.modules.home_page.service.count_info_service import \ ...@@ -31,8 +31,7 @@ from unify_api.modules.home_page.service.count_info_service import \
post_zd_info_factory_service, risk_cost_service, info_yang_chen_service, \ post_zd_info_factory_service, risk_cost_service, info_yang_chen_service, \
info_yang_chen_map_service, rank_type_ranking_service, \ info_yang_chen_map_service, rank_type_ranking_service, \
condition_monitor_service, alarm_price_costtl_service, \ condition_monitor_service, alarm_price_costtl_service, \
alarm_safe_index_service, health_status_index_service, \ alarm_safe_index_service, all_index_info_service
all_index_info_service
@summary("获取首页统计信息") @summary("获取首页统计信息")
...@@ -316,7 +315,7 @@ async def post_health_status_index(req, body: CidReq) -> HsiResp: ...@@ -316,7 +315,7 @@ async def post_health_status_index(req, body: CidReq) -> HsiResp:
# 1. 获取参数 # 1. 获取参数
cid = body.cid cid = body.cid
# 2. 调service获取数据 # 2. 调service获取数据
return await health_status_index_service(cid) # return await health_status_index_service(cid)
@summary("首页-全部指数") @summary("首页-全部指数")
......
...@@ -56,9 +56,7 @@ async def post_health_radar(req, body: QueryDetails) -> HealthRadarResp: ...@@ -56,9 +56,7 @@ async def post_health_radar(req, body: QueryDetails) -> HealthRadarResp:
log.error("param error") log.error("param error")
raise ParamException(message="参数错误, cid参数必须是一个正整数!") raise ParamException(message="参数错误, cid参数必须是一个正整数!")
# score_info = await health_score.load_health_radar(cid) score_info = await health_score.load_health_radar(cid)
score_info = await health_score.load_health_radar_new15(cid)
return HealthRadarResp( return HealthRadarResp(
v_dev=score_info["v_score"], v_dev=score_info["v_score"],
freq_dev=score_info["freq_score"], freq_dev=score_info["freq_score"],
...@@ -73,7 +71,6 @@ async def post_health_radar(req, body: QueryDetails) -> HealthRadarResp: ...@@ -73,7 +71,6 @@ async def post_health_radar(req, body: QueryDetails) -> HealthRadarResp:
@description("每分钟刷新一次") @description("每分钟刷新一次")
async def post_health_ctl_rate(req, body: QueryDetails) -> HealthCtlRateRes: async def post_health_ctl_rate(req, body: QueryDetails) -> HealthCtlRateRes:
cid = body.cid cid = body.cid
# return await health_ctl_rate_service(cid)
return await health_ctl_rate_srv(cid) return await health_ctl_rate_srv(cid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment