fix: get_alldata_with_batch中小数计算异常捕获

This commit is contained in:
caoqianming 2025-04-11 10:16:51 +08:00
parent 1ff822161a
commit fda9ecae94
1 changed files with 6 additions and 0 deletions

View File

@ -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="管料成型")