Commit e601b279 authored by lcn's avatar lcn

bug修复

parent d9f4a706
...@@ -354,14 +354,14 @@ async def optimization_count_info(company_id: int): ...@@ -354,14 +354,14 @@ async def optimization_count_info(company_id: int):
last_month_dt = datetime(year=now.year - 1, month=12, day=1) last_month_dt = datetime(year=now.year - 1, month=12, day=1)
else: else:
last_month_dt = datetime(year=now.year, month=now.month - 1, day=1) last_month_dt = datetime(year=now.year, month=now.month - 1, day=1)
last_month_str = datetime.strftime(last_month_dt, "%Y-%m-%d")
# 功率因数 # 功率因数
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
sql = "SELECT inlid, `cos`, save_charge pf_cost, kpi_x, save_charge " \ sql = "SELECT inlid, `cos`, save_charge pf_cost, kpi_x, save_charge " \
"FROM algo_power_factor_result WHERE inlid in %s " \ "FROM algo_power_factor_result WHERE inlid in %s " \
"and month=%s" "and month=%s"
power_factor_results = await conn.fetchall(sql, args=( power_factor_results = await conn.fetchall(sql, args=(
inline_ids, last_month_dt)) inline_ids, last_month_str))
total_pf_save = round( total_pf_save = round(
sum([i["pf_cost"] for i in power_factor_results if sum([i["pf_cost"] for i in power_factor_results if
i["pf_cost"] and i["pf_cost"] >= 0]), i["pf_cost"] and i["pf_cost"] >= 0]),
...@@ -395,7 +395,6 @@ async def optimization_count_info(company_id: int): ...@@ -395,7 +395,6 @@ async def optimization_count_info(company_id: int):
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
sql = "select `score`, `cost_save` from `algo_plsi_result` " \ sql = "select `score`, `cost_save` from `algo_plsi_result` " \
"where `inlid` in %s and `month` = %s" "where `inlid` in %s and `month` = %s"
last_month_str = datetime.strftime(last_month_dt, "%Y-%m")
pcvfs = await conn.fetchall(sql, args=(inline_ids, last_month_str)) pcvfs = await conn.fetchall(sql, args=(inline_ids, last_month_str))
pcvf_kpi_x_list = [i["score"] for i in pcvfs if pcvf_kpi_x_list = [i["score"] for i in pcvfs if
...@@ -429,7 +428,6 @@ async def optimization_count_info(company_id: int): ...@@ -429,7 +428,6 @@ async def optimization_count_info(company_id: int):
sql = "select `kpi_x`, `save_charge`, `mean_load_factor` " \ sql = "select `kpi_x`, `save_charge`, `mean_load_factor` " \
"from `algo_economic_operation_result` where " \ "from `algo_economic_operation_result` where " \
"`inlid` in %s and `month` = %s" "`inlid` in %s and `month` = %s"
last_month_str = datetime.strftime(last_month_dt, "%Y-%m")
economic_operations = await conn.fetchall(sql, args=( economic_operations = await conn.fetchall(sql, args=(
inline_ids, last_month_str)) inline_ids, last_month_str))
economic_kpi_x_list = [ economic_kpi_x_list = [
...@@ -476,7 +474,6 @@ async def optimization_count_info(company_id: int): ...@@ -476,7 +474,6 @@ async def optimization_count_info(company_id: int):
" on a.space_analysis_id=b.id " " on a.space_analysis_id=b.id "
"where b.inlid in %s and a.month = %s and b.valid=1;" "where b.inlid in %s and a.month = %s and b.valid=1;"
) )
last_month_str = datetime.strftime(last_month_dt, "%Y-%m")
md_spaces = await conn.fetchall(sql, args=(inline_ids, last_month_str)) md_spaces = await conn.fetchall(sql, args=(inline_ids, last_month_str))
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
......
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