diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index 1320f40a..8ec3d981 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -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: diff --git a/apps/wpm/services.py b/apps/wpm/services.py index d795ee03..dff05f1d 100644 --- a/apps/wpm/services.py +++ b/apps/wpm/services.py @@ -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