From fda9ecae9486b2c6eeefea50b03fb7dfee12ca43 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 11 Apr 2025 10:16:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20get=5Falldata=5Fwith=5Fbatch=E4=B8=AD?= =?UTF-8?q?=E5=B0=8F=E6=95=B0=E8=AE=A1=E7=AE=97=E5=BC=82=E5=B8=B8=E6=8D=95?= =?UTF-8?q?=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/services_2.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/wpm/services_2.py b/apps/wpm/services_2.py index fba8b134..9ff9241f 100644 --- a/apps/wpm/services_2.py +++ b/apps/wpm/services_2.py @@ -8,6 +8,9 @@ from datetime import datetime from server.conf import BASE_PROJECT_CODE import json from apps.utils.tools import MyJSONEncoder +import decimal +import logging +myLogger = logging.getLogger('log') def get_alldata_with_batch_and_store(batch: str): """ @@ -80,6 +83,9 @@ def get_alldata_with_batch(batch: str): data["棒料成型_合格率"] = round((data["棒料成型_count_ok"] * 100/ data["棒料成型_count_real"]), 1) except ZeroDivisionError: data["棒料成型_合格率"] = 0 + except decimal.InvalidOperation: + myLogger.error(f"棒料成型_合格率计算错误decimal.InvalidOperation-{data}") + data["棒料成型_合格率"] = 0 # 管料成型数据 mgroup_glcx = Mgroup.objects.get(name="管料成型")