Jelajahi Sumber

设备控制更新

yf_yzl 2 tahun lalu
induk
melakukan
a9af629f2e
1 mengubah file dengan 3 tambahan dan 2 penghapusan
  1. 3 2
      smartfarming/views/device.py

+ 3 - 2
smartfarming/views/device.py

@@ -231,13 +231,14 @@ class QxzDeviceAddAPIViw(APIView):
                                         if result:
                                         if result:
                                             result_tp = f"{zh_k[0]}{result}{zh_k[1]},"
                                             result_tp = f"{zh_k[0]}{result}{zh_k[1]},"
                                             result_tp_fin += result_tp
                                             result_tp_fin += result_tp
+                uptime_tp = int((datetime.datetime.strptime(uptime, "%Y-%m-%d %H: %M: %S")).timestamp())
                 if result_tp_fin:
                 if result_tp_fin:
                     alarm_new = MongoQXZ_Alarm_Log_New()
                     alarm_new = MongoQXZ_Alarm_Log_New()
                     alarm_new.warning_content = result_tp_fin
                     alarm_new.warning_content = result_tp_fin
+                    alarm_new.upl_time = uptime_tp
                     alarm_new.save()
                     alarm_new.save()
-                    logger.info(f"{device_id}  产生预警")
+                    logger.warning(f"{device_id}  产生预警")
                 # 30分钟上报一次的数据
                 # 30分钟上报一次的数据
-                uptime_tp = int((datetime.datetime.strptime(uptime, "%Y-%m-%d %H: %M: %S")).timestamp())
                 qx_ek["device_id"] = device_id
                 qx_ek["device_id"] = device_id
                 qx_ek["uptime"] = uptime_tp
                 qx_ek["uptime"] = uptime_tp
                 qxz_data = QXZdata_New(**qx_ek)
                 qxz_data = QXZdata_New(**qx_ek)