From 780564f6e18f01e2839a08e63bd18b144a8820f8 Mon Sep 17 00:00:00 2001 From: zty Date: Mon, 30 Sep 2024 16:22:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=85=A4=E7=B2=89=E7=83=AD=E5=80=BC?= =?UTF-8?q?=E5=A4=84=E7=90=862?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/services.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/wpm/services.py b/apps/wpm/services.py index a85f9c46..1f85a113 100644 --- a/apps/wpm/services.py +++ b/apps/wpm/services.py @@ -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