fix: 去除所有exception只保留zerodi

This commit is contained in:
caoqianming 2024-05-13 16:37:39 +08:00
parent 89d9ac84d8
commit a2ff2c0a2c
1 changed files with 7 additions and 11 deletions

View File

@ -394,7 +394,7 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
cost = amount_consume * price_unit
try:
cost_unit = cost / enstat.total_production
except Exception:
except ZeroDivisionError:
cost_unit = 0
imaterial_cost_unit = imaterial_cost_unit + cost_unit
if material.code == "elec":
@ -402,8 +402,8 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
enstat.elec_coal_consume = enstat.elec_consume * 0.1229 / 1000
try:
enstat.elec_consume_unit = enstat.elec_consume / enstat.total_production
except Exception:
pass
except ZeroDivisionError:
enstat.elec_consume_unit = 0
elif material.code == "water":
enstat.water_consume = amount_consume
elif material.code == "pcoal":
@ -452,8 +452,8 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
if enstat.mgroup.name != "回转窑":
try:
enstat.en_consume_unit = enstat.elec_coal_consume / enstat.total_production
except Exception:
pass
except ZeroDivisionError:
enstat.en_consume_unit = 0
enstat.save()
# 计算一些其他数据
if type == "month_st" and "material" in this_cal_attrs: # 如果计算的是班月,把主要设备电耗数据拉过来, 方便查询
@ -475,12 +475,8 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
if enstat.type in ["hour_s", "day_s", "year_s", "month_s"]:
pre_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 pre_enstat:
try:
# 料耗系数
enstat.celec_consume_unit = enstat.elec_consume_unit + get_sysconfig('enm.enm_lhxs') * pre_enstat.elec_consume_unit
enstat.save()
except Exception:
pass
# 算总煤耗
if "pcoal" in this_cal_attrs: