This commit is contained in:
caoqianming 2024-11-18 17:28:03 +08:00
commit a0423cbd3f
1 changed files with 7 additions and 4 deletions

View File

@ -474,9 +474,12 @@ def get_analyse_data_mgroups_duration(start_date: datetime, end_date: datetime)
elec_consume_mm = res_dict.get("煤磨", {}).get("elec_consume", 0) elec_consume_mm = res_dict.get("煤磨", {}).get("elec_consume", 0)
if item["total_production"] == 0: if item["total_production"] == 0:
item["celec_consume_unit"] = 0 item["celec_consume_unit"] = 0
item["en_consume_unit"] = 0 item["cen_consume_unit"] = 0
else: else:
item["celec_consume_unit"] = round((elec_consume_mm + item["elec_consume"]) / item["total_production"] + get_sysconfig("enm.enm_lhxs") * elec_consume_ylm / total_production_ylm, 2) item["celec_consume_unit"] = round((elec_consume_mm + item["elec_consume"]) / get_safe_value(item["total_production"]) + get_sysconfig("enm.enm_lhxs") * elec_consume_ylm / get_safe_value(total_production_ylm), 2)
item["en_consume_unit"] = round(item["coal_consume_unit"] + 0.1229 * item["elec_consume_unit"], 2) item["cen_consume_unit"] = round(item["coal_consume_unit"] + 0.1229 * item["elec_consume_unit"], 2)
item["total_production"] = round(item["total_production"], 2) item["total_production"] = round(item["total_production"], 2)
return res return res
def get_safe_value(value, default=1):
return value if value != 0 else default