|
|
@@ -14,7 +14,14 @@ from smartfarming.utils import get_addr_by_lag_lng
|
|
|
from smartfarming.serializers.device_serializers import DeviceSerializers
|
|
|
from smartfarming.models.device import MongoDevice, MongoCBDData, MongoSCDData, MongoXYCBData
|
|
|
from smartfarming.models.worm_forecast import MongoCBDphoto
|
|
|
-from smartfarming.models.weather import MongoQXZ_Base_Info, MongoQXZ_Alarm_Log_New, MongoQXZ_Conf, QXZdata_New, MongoQXZ_Alarm
|
|
|
+from smartfarming.models.weather import (
|
|
|
+ MongoQXZ_Base_Info,
|
|
|
+ MongoQXZ_Alarm_Log_New,
|
|
|
+ MongoQXZ_Conf,
|
|
|
+ QXZdata_New,
|
|
|
+ MongoQXZ_Alarm,
|
|
|
+ QXZThresholdWarning
|
|
|
+)
|
|
|
from django.db.models import Q
|
|
|
|
|
|
from smartfarming.qxz import data_deal
|
|
|
@@ -246,6 +253,14 @@ class QxzDeviceAddAPIViw(APIView):
|
|
|
if float(tp_value) < float(n_sp[1]):
|
|
|
result = f"为{tp_value},小于{n_sp[1]}"
|
|
|
if result:
|
|
|
+ QXZThresholdWarning.objects.create(
|
|
|
+ device_id=device_id,
|
|
|
+ warning_content= "大于预警" if n_sp[0] == "1" else "小于预警",
|
|
|
+ ekey=ek,
|
|
|
+ set_value=n_sp[1],
|
|
|
+ current_value=tp_value,
|
|
|
+ upltime=uptime_tp
|
|
|
+ )
|
|
|
result_tp = f"{zh_k[0]}{result}{zh_k[1]},"
|
|
|
result_tp_fin += result_tp
|
|
|
if result_tp_fin:
|