From 71ab520f3eb9382b29cf8241bb8e561d96d50306 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 24 Dec 2024 18:35:04 +0800 Subject: [PATCH] fix: enstat_cen_consume_unit change bug --- apps/enm/tasks.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/apps/enm/tasks.py b/apps/enm/tasks.py index d077b448..1ab0cac9 100644 --- a/apps/enm/tasks.py +++ b/apps/enm/tasks.py @@ -693,17 +693,16 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s, elif enstat.mgroup.name == "水泥磨" and enstat.type not in ["month_st", "sflog"] and "pcoal" in this_cal_attrs: hzy_enstat = EnStat.objects.filter(type=enstat.type, year_s=enstat.year_s, month_s=enstat.month_s, day_s=enstat.day_s, hour=enstat.hour, mgroup__name="回转窑").first() - snm_enstat = enstat snbz_enstat = EnStat.objects.filter(type=enstat.type, year_s=enstat.year_s, month_s=enstat.month_s, day_s=enstat.day_s, hour=enstat.hour, mgroup__name="水泥包装").first() snbz_enstat_elec_consume = snbz_enstat.elec_consume if snbz_enstat else 0 hzy_enstat_cen_consume_unit = hzy_enstat.cen_consume_unit if hzy_enstat else 0 - if snm_enstat.total_production == 0: - snm_enstat_cen_consume_unit = 0 + if enstat.total_production == 0: + enstat_cen_consume_unit = 0 else: - slpb = snm_enstat.imaterial_data_dict.get("入磨熟料", {}).get("amount_consume", 0) / snm_enstat.total_production - snm_enstat_cen_consume_unit = ((snm_enstat.elec_consume + snbz_enstat_elec_consume)/snm_enstat.total_production) * 0.1229 + slpb * hzy_enstat_cen_consume_unit - snm_enstat.cen_consume_unit = snm_enstat_cen_consume_unit - snm_enstat.save() + slpb = enstat.imaterial_data_dict.get("入磨熟料", {}).get("amount_consume", 0) / enstat.total_production + enstat_cen_consume_unit = ((enstat.elec_consume + snbz_enstat_elec_consume)/enstat.total_production) * 0.1229 + slpb * hzy_enstat_cen_consume_unit + enstat.cen_consume_unit = enstat_cen_consume_unit + enstat.save() elif enstat.mgroup.name == "水泥包装" and enstat.type not in ["month_st", "sflog"] and "pcoal" in this_cal_attrs: snm_enstat = EnStat.objects.filter(type=enstat.type, year_s=enstat.year_s, month_s=enstat.month_s, day_s=enstat.day_s, hour=enstat.hour, mgroup__name="水泥磨").first() if snm_enstat: