diff --git a/apps/enm/services.py b/apps/enm/services.py index 29e319be..d91e3134 100644 --- a/apps/enm/services.py +++ b/apps/enm/services.py @@ -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) if item["total_production"] == 0: item["celec_consume_unit"] = 0 - item["en_consume_unit"] = 0 + item["cen_consume_unit"] = 0 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["en_consume_unit"] = round(item["coal_consume_unit"] + 0.1229 * item["elec_consume_unit"], 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["cen_consume_unit"] = round(item["coal_consume_unit"] + 0.1229 * item["elec_consume_unit"], 2) item["total_production"] = round(item["total_production"], 2) - return res \ No newline at end of file + return res + +def get_safe_value(value, default=1): + return value if value != 0 else default \ No newline at end of file