fix: enstat_cen_consume_unit change bug

This commit is contained in:
caoqianming 2024-12-24 18:35:04 +08:00
parent 4a642b9014
commit 71ab520f3e
1 changed files with 6 additions and 7 deletions

View File

@ -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: