From 13fb91e83a45a78c9e52a27e9a64d3145dc31195 Mon Sep 17 00:00:00 2001 From: zty Date: Thu, 15 Aug 2024 10:47:43 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9Aenm/service=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=A8=BFlast=5Fval?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/enm/services.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/enm/services.py b/apps/enm/services.py index 9958351f..0631d684 100644 --- a/apps/enm/services.py +++ b/apps/enm/services.py @@ -15,6 +15,7 @@ from server.settings import get_sysconfig from apps.enm.models import EnStat from django.db.models import Sum from typing import Dict, Any +from decimal import Decimal myLogger = logging.getLogger("log") @@ -176,7 +177,10 @@ class MpointCache: current_cache_val = self.data cache_key = self.cache_key last_data = current_cache_val["last_data"] - last_data["last_val"] = last_val*current_cache_val.get('coefficient', 1) + if last_val: + last_data["last_val"] = last_val*current_cache_val.get('coefficient', 1.0) + else: + last_data["last_val"] = last_val last_data["last_timex"] = last_timex last_mrs = None # 设备状态信号 mpoint_is_rep_ep_running_state = current_cache_val["is_rep_ep_running_state"]