fix: 更新煤粉热值触发计算的bug

This commit is contained in:
caoqianming 2024-05-16 16:48:42 +08:00
parent 5093eb7b29
commit 9a1074caf8
2 changed files with 7 additions and 7 deletions

View File

@ -117,12 +117,12 @@ class SfLogSerializer(CustomModelSerializer):
mgroup: Mgroup = instance.mgroup
# 更新煤粉热值触发计算
if new_pcoal_heat: # 更新一下缓存
if instance.mgroup == '回转窑' and instance.shift.name in ['早班', '白班']:
year_s, month_s, day_s = instance.get_ymd
cache.set(f'pgoal_val_{year_s}_{month_s}_{day_s}', new_pcoal_heat)
if new_pcoal_heat != old_pcoal_heat and mgroup.need_enm:
year_s, month_s, day_s = instance.get_ymd
cal_enstat_when_pcoal_heat_change.delay(year_s, month_s, day_s)
if new_pcoal_heat: # 更新一下缓存
cache.set(f'pcoal_heat_{year_s}_{month_s}_{day_s}', new_pcoal_heat)
if new_pcoal_heat != old_pcoal_heat:
cal_enstat_when_pcoal_heat_change.delay(year_s, month_s, day_s)
# 更新班组触发计算
if new_team != old_team:

View File

@ -62,7 +62,7 @@ def get_pcoal_heat(year_s: int, month_s: int, day_s: int):
获取煤粉热值
只有回转窑需要录入煤粉热值
"""
key = f'pgoal_val_{year_s}_{month_s}_{day_s}'
key = f'pcoal_heat_{year_s}_{month_s}_{day_s}'
pcoal_heat = cache.get(key)
if pcoal_heat:
return pcoal_heat
@ -73,7 +73,7 @@ def get_pcoal_heat(year_s: int, month_s: int, day_s: int):
if qs.pcoal_heat is None:
qs.pcoal_heat = 6000
qs.save(update_fields=['pcoal_heat'])
cache.set(f'pgoal_val_{year_s}_{month_s}_{day_s}', qs.pcoal_heat)
cache.set(f'pcoal_heat_{year_s}_{month_s}_{day_s}', qs.pcoal_heat)
return qs.pcoal_heat
except Exception:
return 6000