liumiaomiao 8 kuukautta sitten
vanhempi
commit
35a1ee3f02

+ 7 - 0
lib/mogodb_helper.py

@@ -76,6 +76,13 @@ class MongoDBInterface:
             return None
         return row.get("rules_id")
 
+    def find_rule_by_title(self, collection_name, title):
+        collection = self.db[collection_name]
+        row = collection.find_one({"title": title})
+        if not row:
+            return None
+        return row
+
     def insert2db(self, collection_name, data: dict):
         collection = self.db[collection_name]
         collection.insert_one(data)

+ 1 - 0
lib/monitor_tools.py

@@ -11,6 +11,7 @@ from lib.clickhouse_tools import ClickhouseUtil, logger
 # 定义一周的时间范围,转换为Unix时间戳格式
 end_date = int(datetime.now().timestamp())
 start_date = int((datetime.now() - timedelta(days=7)).timestamp())
+print(f"开始时间:{start_date}--结束时间{end_date}")
 
 class monitorTools:
     #标准库bidding-es 每周统计入库数量

+ 4 - 1
tools/mongo断流监控/es_monitor.py

@@ -14,8 +14,11 @@ es_bidding_fragment_count=monitor.es_bidding_fragment()
 es_nzj_count=monitor.es_nzj()
 #存库
 monitor.save_to_mongo("es_bidding",es_bidding_count)
+print("es_bidding入库成功")
 monitor.save_to_mongo("es_bidding_ai",es_bidding_ai_count)
+print("es_bidding_ai入库成功")
 monitor.save_to_mongo("es_bidding_fragment",es_bidding_fragment_count)
+print("es_bidding_fragment入库成功")
 monitor.save_to_mongo("es_nzj",es_nzj_count)
-
+print("es_nzj入库成功")
 

+ 5 - 0
tools/mongo断流监控/mongo_monitor.py

@@ -8,18 +8,23 @@ from lib.monitor_tools import monitor
 bidding_count=monitor.bidding()
 #存库
 monitor.save_to_mongo("bidding",bidding_count)
+print("bidding入库成功")
 #高质量库-mongo
 bidding_ai_count=monitor.bidding_ai()
 monitor.save_to_mongo("bidding_ai",bidding_ai_count)
+print("bidding_ai入库成功")
 #nzj-mysql
 nzj_count=monitor.nzj()
 monitor.save_to_mongo("nzj",nzj_count)
+print("nzj入库成功")
 #bidding_碎片化
 bidding_fragment_count=monitor.bidding_fragment()
 monitor.save_to_mongo("bidding_fragment",bidding_fragment_count)
+print("bidding_fragment入库成功")
 #人脉clickhouse数据
 connections_count=monitor.connections()
 monitor.save_to_mongo('connections',connections_count)
+print("connections入库成功")
 
 
 

+ 0 - 0
tools/从mongo导出数据/test.py


+ 0 - 0
tools/从mongo导出数据/test1.py


+ 9 - 3
tools/分数字段结果分析/DataExport_forTesting.py

@@ -201,7 +201,7 @@ columns_timeliness = ['日期'] + list(timeliness_data.keys())
 data_row_timeliness = [date_range] + list(timeliness_data.values())
 
 # 创建DataFrame并写入Excel
-excel_file = 'mongo_data_statistics_combined.xlsx'
+excel_file = 'mongo_data_statistics_combined1.xlsx'
 
 with pd.ExcelWriter(excel_file, engine='openpyxl') as writer:
     # 写入第一个sheet(断流监控_mongo库)
@@ -210,11 +210,17 @@ with pd.ExcelWriter(excel_file, engine='openpyxl') as writer:
 
     # 写入第二个sheet(断流监控—es)
     df_es = pd.DataFrame([data_row_es], columns=columns_es)
-    df_es.to_excel(writer, sheet_name='入库数据量监控-es(每周)', index=False)
+    df_es.to_excel(writer, sheet_name='入库量数据量监控-es(每周)', index=False)
+
+    # 将timeliness_data中的值转换为百分比字符串
+    for key in timeliness_data:
+        timeliness_data[key] = f"{timeliness_data[key]:.2f}%"
+
+    # 构建数据行
+    data_row_timeliness = [date_range] + list(timeliness_data.values())
 
     # 写入第三个sheet(数据时效监控)
     df_timeliness = pd.DataFrame([data_row_timeliness], columns=columns_timeliness)
     df_timeliness.to_excel(writer, sheet_name='数据时效监控(7天平均值)', index=False)
 
 print(f"统计结果已写入Excel文件: {excel_file}")
-