|
|
@@ -108,13 +108,14 @@ def product_cbd_alarm():
|
|
|
for m, n in indentify_result.items():
|
|
|
total_warning += f"害虫{insect_dict.get(m)},数量{str(n)};"
|
|
|
# 写入数据库
|
|
|
- alarm_obj = MongoCBDPestWarning.objects.create(
|
|
|
- device_id = device_id,
|
|
|
- warning_content = f"{total_warning}请注意防范!",
|
|
|
- warning_types = "4",
|
|
|
- upltime = now_stamp
|
|
|
- )
|
|
|
- logger.warning(f"综合预警: {alarm_obj.id}")
|
|
|
+ if total_warning:
|
|
|
+ alarm_obj = MongoCBDPestWarning.objects.create(
|
|
|
+ device_id = device_id,
|
|
|
+ warning_content = f"{total_warning}请注意防范!",
|
|
|
+ warning_types = "4",
|
|
|
+ upltime = now_stamp
|
|
|
+ )
|
|
|
+ logger.warning(f"综合预警: {alarm_obj.id}")
|
|
|
|
|
|
# 每天的8点执行任务
|
|
|
schedule.every().day.at("05:00").do(product_cbd_alarm)
|