zhangyong 4 miesięcy temu
rodzic
commit
b17db75d42
2 zmienionych plików z 61 dodań i 4 usunięć
  1. 19 0
      common/sql_help.py
  2. 42 4
      video_count_notification.py

+ 19 - 0
common/sql_help.py

@@ -89,12 +89,31 @@ class sqlCollect():
         count = MysqlHelper.get_values(sql, (str(platform)))
         return count
 
+
     @classmethod
     def get_ytd_crawler_count(cls, platform):
         sql = """SELECT count(0) FROM crawler_video where platform = %s and create_time >= CURRENT_DATE - INTERVAL 1 DAY AND create_time < CURRENT_DATE - INTERVAL 1 DAY + INTERVAL HOUR(NOW()) HOUR;"""
         count = MysqlHelper.get_values(sql, (str(platform)))
         return count
 
+    @classmethod
+    def get_bygj_count(cls, name):
+        sql = """SELECT count(0) FROM machine_making_data where name = %s and task_mark = "搬运工具" and  DATE(data_time) = CURRENT_DATE AND HOUR(data_time) < HOUR(NOW());"""
+        count = MysqlHelper.get_values(sql, (str(name)))
+        return count
+
+    @classmethod
+    def get_bygj_all_count(cls):
+        sql = """SELECT count(0) FROM machine_making_data where task_mark = %s  and  DATE(data_time) = CURRENT_DATE AND HOUR(data_time) < HOUR(NOW());"""
+        count = MysqlHelper.get_values(sql, (str("搬运工具")))
+        return count
+
+    @classmethod
+    def get_ytd_bygj_count(cls, name):
+        sql = """SELECT count(0) FROM machine_making_data where name = %s and task_mark = "搬运工具" and data_time >= CURRENT_DATE - INTERVAL 1 DAY AND data_time < CURRENT_DATE - INTERVAL 1 DAY + INTERVAL HOUR(NOW()) HOUR;"""
+        count = MysqlHelper.get_values(sql, (str(name)))
+        return count
+
     @classmethod
     def get_channel_count(cls, channel, name):
         sql = """SELECT count(0) FROM machine_making_data where channel = %s and name = %s and  DATE(data_time) = CURRENT_DATE AND HOUR(data_time) < HOUR(NOW());"""

+ 42 - 4
video_count_notification.py

@@ -10,6 +10,43 @@ from common.sql_help import sqlCollect
 
 
 
+def bot_bygj_data():
+    all_count = sqlCollect.get_bygj_all_count()
+    fj = sqlCollect.get_bygj_count("范军")
+    # ytd_lt = sqlCollect.get_ytd_bygj_count("范军")
+
+    lt = sqlCollect.get_bygj_count("鲁涛")
+    # ytd_lt = sqlCollect.get_ytd_bygj_count("鲁涛")
+
+    yht = sqlCollect.get_bygj_count("余海涛")
+    # ytd_yht = sqlCollect.get_ytd_bygj_count("余海涛")
+
+    lq = sqlCollect.get_bygj_count("罗情")
+    # ytd_lq = sqlCollect.get_ytd_bygj_count("罗情")
+
+    lsy = sqlCollect.get_bygj_count("刘诗雨")
+    # ytd_lsy = sqlCollect.get_ytd_bygj_count("刘诗雨")
+
+    zf = sqlCollect.get_bygj_count("张峰")
+    # ytd_zf = sqlCollect.get_ytd_bygj_count("张峰")
+
+    zxq = sqlCollect.get_bygj_count("周仙琴")
+    # ytd_zxq = sqlCollect.get_ytd_bygj_count("周仙琴")
+    text = (
+        f"**总条数: **{int(all_count[0][0])}**条**\n"
+        f"**范军: **{int(fj[0][0])}**条**\n"
+        f"**鲁涛: **{int(lt[0][0])}**条**\n"
+        f"**余海涛: **{int(yht[0][0])}**条**\n"
+        f"**罗情: **{int(lq[0][0])}**条**\n"
+        f"**刘诗雨: **{int(lsy[0][0])}**条**\n"
+        f"**张峰: **{int(zf[0][0])}**条**\n"
+        f"**周仙琴: **{int(zxq[0][0])}**条**\n"
+    )
+    Feishu.finish_bot(text,
+                      "https://open.feishu.cn/open-apis/bot/v2/hook/1f3aa0e0-f872-4541-8fc7-6dcc825920ea",
+                      f"【 搬运工具{datetime.now().strftime('%Y年%m月%d日 %H时')}之前的数据 】")
+
+
 """爬虫"""
 def bot_crawler_data():
     try:
@@ -120,10 +157,11 @@ def schedule_tasks():
 
 
 if __name__ == "__main__":
+    bot_bygj_data()
     # bot_crawler_data()
-    schedule_tasks()  # 调用任务调度函数
-    while True:
-        schedule.run_pending()
-        time.sleep(1)  # 每秒钟检查一次
+    # schedule_tasks()  # 调用任务调度函数
+    # while True:
+    #     schedule.run_pending()
+    #     time.sleep(1)  # 每秒钟检查一次
     # bot_carry_data()