zhangyong 1 month ago
parent
commit
eba7ca2a61
1 changed files with 11 additions and 0 deletions
  1. 11 0
      utils/sql_help.py

+ 11 - 0
utils/sql_help.py

@@ -7,6 +7,17 @@ from utils.mysql_db import MysqlHelper
 
 
 class sqlCollect:
+    @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());"""
+        count = MysqlHelper.get_values(sql, (str(channel), name))
+        return count
+
+    @classmethod
+    def get_ytd_channel_count(cls, channel, name):
+        sql = """SELECT count(0) FROM machine_making_data where channel = %s and name = %s 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(channel), name))
+        return count
 
     @classmethod
     def get_name_count(cls, name):