|
@@ -4,13 +4,15 @@
|
|
|
#从es库中导出数据到测试环境mongo库
|
|
|
from lib.es_tools import esutil
|
|
|
from datetime import datetime, timedelta
|
|
|
-from lib.mongo_tools import Data_save
|
|
|
+from lib.mongo_tools import MongoUtil,Data_save,MongoSentence
|
|
|
+from lib.mysql_tools import MysqlUtil
|
|
|
+from lib.clickhouse_tools import ClickhouseUtil, logger
|
|
|
|
|
|
# 定义一周的时间范围,转换为Unix时间戳格式
|
|
|
end_date = int(datetime.now().timestamp())
|
|
|
start_date = int((datetime.now() - timedelta(days=7)).timestamp())
|
|
|
|
|
|
-class EScount:
|
|
|
+class monitorTools:
|
|
|
#标准库bidding-es 每周统计入库数量
|
|
|
def es_bidding(self):
|
|
|
"""
|
|
@@ -122,6 +124,79 @@ class EScount:
|
|
|
print("拟在建es入库数据总量:", count)
|
|
|
return count
|
|
|
|
|
|
+ #标准库bidding-mongo 每周统计入库数量
|
|
|
+ def bidding(self):
|
|
|
+ collection = MongoUtil.get_coon(host='127.0.0.1:27088', database='qfw',collection='bidding',authuser='viewdata',authpass='viewdata')
|
|
|
+ query = { "comeintime": {"$gte": start_date, "$lt": end_date}}
|
|
|
+ count=MongoSentence.count(collection,query)
|
|
|
+ print("标准库bidding-mongo 每周统计入库数量",count)
|
|
|
+ return count
|
|
|
+
|
|
|
+ #高质量库bidding-mongo 每周统计入库数量
|
|
|
+ def bidding_ai(self):
|
|
|
+ collection = MongoUtil.get_coon(host='127.0.0.1:27088', database='qfw',collection='bidding_ai',authuser='viewdata',authpass='viewdata')
|
|
|
+ query = { "comeintime": {"$gte": start_date, "$lt": end_date}}
|
|
|
+ count=MongoSentence.count(collection,query)
|
|
|
+ print("高质量库bidding-mongo 每周统计入库数量",count)
|
|
|
+ return count
|
|
|
+
|
|
|
+ #标准库bidding-mongo碎片化数据 每周统计入库数量
|
|
|
+ def bidding_fragment(self):
|
|
|
+ collection = MongoUtil.get_coon(host='127.0.0.1:27088', database='qfw',collection='bidding',authuser='viewdata',authpass='viewdata')
|
|
|
+ # 定义要监控的字段值
|
|
|
+ tags = [
|
|
|
+ "情报_法务",
|
|
|
+ "情报_财务审计",
|
|
|
+ "情报_招标代理",
|
|
|
+ "情报_管理咨询",
|
|
|
+ "情报_保险",
|
|
|
+ "情报_工程设计咨询",
|
|
|
+ "情报_安防",
|
|
|
+ "情报_印务商机",
|
|
|
+ "情报_环境采购",
|
|
|
+ "情报_家具招投标"
|
|
|
+ ]
|
|
|
+ data={}
|
|
|
+ for tag in tags:
|
|
|
+ query = {"comeintime": {"$gte": start_date, "$lt": end_date},"tag_topinformation":tag}
|
|
|
+ count=MongoSentence.count(collection,query)
|
|
|
+ print(f"标准库bidding-mongo{tag}每周统计入库数量",count)
|
|
|
+ data[tag]=count
|
|
|
+ return data
|
|
|
+
|
|
|
+ #拟在建baseinfo-mysql 每周统计入库数量
|
|
|
+ def nzj(self):
|
|
|
+ # MySQL 数据库连接配置
|
|
|
+ # mysql_db_config = {
|
|
|
+ # 'host': '192.168.3.149',
|
|
|
+ # 'port': 4000,
|
|
|
+ # 'user': 'datagroup',
|
|
|
+ # 'password': 'Dgrpdb#2024@36',
|
|
|
+ # 'database': 'jianyu_subjectdb',
|
|
|
+ # 'charset': 'utf8mb4'
|
|
|
+ # }
|
|
|
+ # SQL 查询
|
|
|
+ mysql_query = f"SELECT COUNT(*) FROM dwd_f_nzj_baseinfo WHERE create_time >={start_date} AND create_time <={end_date}"
|
|
|
+ conn=MysqlUtil.connect_to_mysql(host='192.168.3.149',port='4000',user='datagroup',password='Dgrpdb#2024@36',database='jianyu_subjectdb')
|
|
|
+ count=MysqlUtil.execute_sql(conn,mysql_query)
|
|
|
+ print("拟在建baseinfo-mysql每周统计入库数量", count)
|
|
|
+ return count
|
|
|
+
|
|
|
+ #人脉数据,每周统计入库数量
|
|
|
+ def connections(self):
|
|
|
+ try:
|
|
|
+ query = f"SELECT COUNT(*) FROM information.transaction_info_all WHERE create_time >={start_date} AND create_time <={end_date}"
|
|
|
+ # conn=ClickhouseUtil.connect_to_clickhouse(host='192.168.3.207',port='19000',user='jytop',password='pwdTopJy123',database='information')
|
|
|
+ conn=ClickhouseUtil.connect_to_clickhouse(host='127.0.0.1',port='9000',user='biservice',password='Bi_top95215#',database='information')
|
|
|
+ count=ClickhouseUtil.execute_sql(conn,query)
|
|
|
+ result=count[0][0]
|
|
|
+ print("人脉数据每周统计入库数量", result)
|
|
|
+ return result
|
|
|
+ except Exception as e:
|
|
|
+ logger.error("An error occurred: %s", e)
|
|
|
+ raise
|
|
|
+
|
|
|
+ #统计结果入库
|
|
|
def save_to_mongo(self,title,count):
|
|
|
collection=Data_save.save_con(host='192.168.3.149',port=27180,database='data_quality',collection='statistics')
|
|
|
now = datetime.now()
|
|
@@ -135,6 +210,6 @@ class EScount:
|
|
|
Data_save.insert_one(collection,document)
|
|
|
|
|
|
|
|
|
-escount=EScount()
|
|
|
+monitor=monitorTools()
|
|
|
|
|
|
|