From a2fb5598f86fa97e8a7b22f6495d0a521c0d2d63 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 28 Feb 2025 16:23:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20get=5Falldata=5Fwith=5Fbatch=20=E9=99=A4?= =?UTF-8?q?0bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/services_2.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/wpm/services_2.py b/apps/wpm/services_2.py index 7fea0f5c..914a7490 100644 --- a/apps/wpm/services_2.py +++ b/apps/wpm/services_2.py @@ -74,7 +74,10 @@ def get_alldata_with_batch(batch: str): data["棒料成型_出料人"] = ";".join([item.name for item in data["棒料成型_出料人"]]) data["棒料成型_切料人"] = list(set(data["棒料成型_切料人"])) data["棒料成型_切料人"] = ";".join([item.name for item in data["棒料成型_切料人"]]) - data["棒料成型_合格率"] = round((data["棒料成型_count_ok"] * 100/ data["棒料成型_count_real"]), 1) + try: + data["棒料成型_合格率"] = round((data["棒料成型_count_ok"] * 100/ data["棒料成型_count_real"]), 1) + except ZeroDivisionError: + data["棒料成型_合格率"] = 0 # 管料成型数据 mgroup_glcx = Mgroup.objects.get(name="管料成型")