feat: 煤粉热值处理2
This commit is contained in:
parent
cc5b521f5d
commit
780564f6e1
|
@ -17,6 +17,8 @@ from apps.mtm.services import cal_material_count
|
|||
from apps.wf.models import Ticket
|
||||
from django.db import transaction
|
||||
from apps.utils.thread import MyThread
|
||||
import logging
|
||||
myLogger = logging.getLogger('log')
|
||||
|
||||
def generate_new_batch(old_batch: str, mlog: Mlog):
|
||||
new_batch = old_batch
|
||||
|
@ -97,11 +99,16 @@ def get_pcoal_heat(year_s: int, month_s: int, day_s: int):
|
|||
qs = SfLog.objects.get(work_date__year=year_s, work_date__month=month_s, work_date__day=day_s,
|
||||
mgroup__name='回转窑', shift__name__in=['白班', '早班']) # hardcode
|
||||
if qs.pcoal_heat is None or qs.pcoal_heat <=0:
|
||||
qs.pcoal_heat = 6000
|
||||
s = SfLog.objects.filter(pcoal_heat__isnull=False).order_by('-start_time').first()
|
||||
if s:
|
||||
qs.pcoal_heat = s.pcoal_heat
|
||||
else:
|
||||
qs.pcoal_heat = 6000
|
||||
qs.save(update_fields=['pcoal_heat'])
|
||||
cache.set(f'pcoal_heat_{year_s}_{month_s}_{day_s}', qs.pcoal_heat)
|
||||
cache.set(key, qs.pcoal_heat, timeout=60 * 60 * 48)
|
||||
return qs.pcoal_heat
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
myLogger.error(f'获取煤粉热值失败,{e}', exc_info=True)
|
||||
return 6000
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue