Commit 746d8728 authored by peng.xiaozhe's avatar peng.xiaozhe

electric-economic-index-new 大屏接口修复

parent 3eca62e3
...@@ -56,7 +56,7 @@ async def alarm_aggs_point_location(date_start, date_end, cid): ...@@ -56,7 +56,7 @@ async def alarm_aggs_point_location(date_start, date_end, cid):
async def get_inline_by_cid(cid): async def get_inline_by_cid(cid):
sql = "SELECT inlid, `name` FROM inline WHERE cid_belongedto=%s" sql = "SELECT inlid, `name` FROM inline WHERE cid=%s"
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
inlines = await conn.fetchall(sql, args=(cid,)) inlines = await conn.fetchall(sql, args=(cid,))
return inlines return inlines
...@@ -66,7 +66,7 @@ async def get_inline_by_cid(cid): ...@@ -66,7 +66,7 @@ async def get_inline_by_cid(cid):
async def get_power_factor_kpi(inline_ids, month_str): async def get_power_factor_kpi(inline_ids, month_str):
sql = "SELECT b.name, a.inlid, a.save_charge pf_cost, a.kpi_x, " \ sql = "SELECT b.name, a.inlid, a.save_charge pf_cost, a.kpi_x, " \
"a.save_charge FROM algo_power_factor_result a LEFT JOIN inline b " \ "a.save_charge FROM algo_power_factor_result a LEFT JOIN inline b " \
"on a.inlid = b.inlid WHERE a.inlid in %s and a.res_time=%s" "on a.inlid = b.inlid WHERE a.inlid in %s and a.`month`=%s"
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
power_factor_results = await conn.fetchall(sql, args=( power_factor_results = await conn.fetchall(sql, args=(
inline_ids, month_str)) inline_ids, month_str))
...@@ -76,7 +76,7 @@ async def get_power_factor_kpi(inline_ids, month_str): ...@@ -76,7 +76,7 @@ async def get_power_factor_kpi(inline_ids, month_str):
# 移峰填谷 # 移峰填谷
async def get_pcvf_kpi(inline_ids, last_month_str): async def get_pcvf_kpi(inline_ids, last_month_str):
sql = "select b.name, a.score, a.cost_save " \ sql = "select b.name, a.score, a.cost_save " \
"from algorithm_plsi_result a left join inline b " \ "from algo_plsi_result a left join inline b " \
"on a.inlid = b.inlid where a.inlid in %s and a.month = %s" "on a.inlid = b.inlid where a.inlid in %s and a.month = %s"
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
pcvfs = await conn.fetchall(sql, args=(inline_ids, last_month_str)) pcvfs = await conn.fetchall(sql, args=(inline_ids, last_month_str))
...@@ -86,7 +86,7 @@ async def get_pcvf_kpi(inline_ids, last_month_str): ...@@ -86,7 +86,7 @@ async def get_pcvf_kpi(inline_ids, last_month_str):
# 经济运行 # 经济运行
async def get_economic_kpi(inline_ids, last_month_str): async def get_economic_kpi(inline_ids, last_month_str):
sql = "select b.name, a.kpi_x, a.save_charge, a.mean_load_factor " \ sql = "select b.name, a.kpi_x, a.save_charge, a.mean_load_factor " \
"from algorithm_economic_operation_result a " \ "from algo_economic_operation_result a " \
"left join inline b on a.inlid = b.inlid " \ "left join inline b on a.inlid = b.inlid " \
"where a.inlid in %s and a.month = %s" "where a.inlid in %s and a.month = %s"
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
...@@ -98,11 +98,11 @@ async def get_economic_kpi(inline_ids, last_month_str): ...@@ -98,11 +98,11 @@ async def get_economic_kpi(inline_ids, last_month_str):
async def get_md_space(inline_ids, last_month_str): async def get_md_space(inline_ids, last_month_str):
sql = ( sql = (
"select a.inline_md_charge, a.kpi_x, a.save_charge, " "select a.inline_md_charge, a.kpi_x, a.save_charge, "
"a.inline_md_predict, b.related_inlids,b.tc_runtime " "a.inline_md_predict, b.inlid,b.tc_runtime "
"from algorithm_md_space_analysis_result a " "from algo_md_space_analysis_result a "
"inner join algorithm_md_space_analysis_unit b " "inner join algo_md_space_analysis_unit b "
"on a.space_analysis_id=b.id " "on a.space_analysis_id=b.id "
"where b.related_inlids in %s and a.month = %s and valid=1;" "where b.inlid in %s and a.month = %s and valid=1;"
) )
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
md_spaces = await conn.fetchall(sql, args=(inline_ids, last_month_str)) md_spaces = await conn.fetchall(sql, args=(inline_ids, last_month_str))
......
...@@ -1453,6 +1453,7 @@ async def electric_use_info_points_sdu_new15(start, end, points): ...@@ -1453,6 +1453,7 @@ async def electric_use_info_points_sdu_new15(start, end, points):
electric_use_score=electric_use_score, electric_use_score=electric_use_score,
) )
async def optimization_count_info_new(company_id: int): async def optimization_count_info_new(company_id: int):
""" """
首页用电经济指数和用电优化模块统计数据 首页用电经济指数和用电优化模块统计数据
...@@ -1472,7 +1473,7 @@ async def optimization_count_info_new(company_id: int): ...@@ -1472,7 +1473,7 @@ async def optimization_count_info_new(company_id: int):
) )
es_end_time = pendulum.datetime(now.year, now.month, 1).strftime( es_end_time = pendulum.datetime(now.year, now.month, 1).strftime(
"%Y-%m-%dT%H:%M:%S+08:00") "%Y-%m-%dT%H:%M:%S+08:00")
power_use_info = await company_power_use_info(company_id, es_start_time, power_use_info = await company_power_use_info_new15(company_id, es_start_time,
es_end_time) es_end_time)
month_charge = power_use_info["charge"] month_charge = power_use_info["charge"]
count_info_map = { count_info_map = {
...@@ -1659,7 +1660,7 @@ async def optimization_count_info_new(company_id: int): ...@@ -1659,7 +1660,7 @@ async def optimization_count_info_new(company_id: int):
price_md = price_policy["price_md"] if price_policy["price_md"] else 0 price_md = price_policy["price_md"] if price_policy["price_md"] else 0
price_tc = price_policy["price_tc"] if price_policy["price_tc"] else 0 price_tc = price_policy["price_tc"] if price_policy["price_tc"] else 0
# 最大需量 # 最大需量
md_spaces = await get_md_space(inline_ids, last_month_str) md_spaces = await get_md_space(inline_ids, last_month_dt)
md_space_kpi_x_list = [i["kpi_x"] for i in md_spaces if md_space_kpi_x_list = [i["kpi_x"] for i in md_spaces if
type(i["kpi_x"]) in [int, float]] type(i["kpi_x"]) in [int, float]]
......
# /usr/bin/env python # /usr/bin/env python
# -*- coding: UTF-8 -*-l # -*- coding: UTF-8 -*-l
import sys import sys
sys.path.append(f'/home/ubuntu/data/code/unify_api2/unify_api/modules/' sys.path.append(f'/home/ubuntu/data/pxz_code/unify_api2/unify_api/modules/'
f'zhiwei_u/fault_foreast') f'zhiwei_u/fault_foreast')
from filterSteadyData import filterSteadyData, testFeat from filterSteadyData import filterSteadyData, testFeat
from knnForecast import classify from knnForecast import classify
......
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