Pārlūkot izejas kodu

查询feedback数据到feedback_history 去重之后

李莎 2 gadi atpakaļ
vecāks
revīzija
e66aba417f
1 mainītis faili ar 25 papildinājumiem un 19 dzēšanām
  1. 25 19
      start.py

+ 25 - 19
start.py

@@ -113,22 +113,23 @@ def data_sql(SQL,tag):
 
 
 
-# with open("config.json", "r") as f:
-#     data = json.load(f)
-#     mysql = data["mysql"]
-#     my_database = mysql["database"]
-#     dingding = data["dingding"]
-
-mysql = {
-    "host": os.getenv("host"),
-    "port": int(os.getenv("port")),
-    "user": os.getenv("user"),
-    "passwd": os.getenv("passwd"),
-    "database": os.getenv("database")
-}
-my_database = os.getenv("database")
-dingding = os.getenv("dingding")
-at_mobiles = os.getenv("at_mobiles")
+with open("config.json", "r") as f:
+    data = json.load(f)
+    mysql = data["mysql"]
+    my_database = mysql["database"]
+    dingding = data["dingding"]
+    at_mobiles = data["at_mobiles"]
+
+# mysql = {
+#     "host": os.getenv("host"),
+#     "port": int(os.getenv("port")),
+#     "user": os.getenv("user"),
+#     "passwd": os.getenv("passwd"),
+#     "database": os.getenv("database")
+# }
+# my_database = os.getenv("database")
+# dingding = os.getenv("dingding")
+# at_mobiles = os.getenv("at_mobiles")
 
 while True:
     time_now = datetime.datetime.fromtimestamp(int(time.time()),
@@ -142,13 +143,17 @@ while True:
         # starttime = '20230301000000'
         # endtime = '20230319000000'
 
-        yesterday = (datetime.datetime.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")+"000000"
-        today = datetime.datetime.today().strftime("%Y%m%d")+"000000"
+        # yesterday = (datetime.datetime.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")+"000000"
+        # today = datetime.datetime.today().strftime("%Y%m%d")+"000000"
+        today = datetime.datetime.fromtimestamp(int(time.time()),
+                                        pytz.timezone('Asia/Shanghai')).strftime("%Y%m%d" ) +"000000"
+        yesterday = (datetime.datetime.fromtimestamp(int(time.time()),
+                                        pytz.timezone('Asia/Shanghai')) - datetime.timedelta(days=1)).strftime("%Y%m%d" )  +"000000"
+
 
         day_range = get_day(yesterday,today)
 
         for day in day_range:
-            sqls = []
             duplicate_data_sum = []
             create_time_start,create_time_end = day[0],day[1]
             feedback_sum = MysqlUtil.query(SELETE_FEEDBACK_COUNT_SQL%(my_database,create_time_start,create_time_end))[0][0]
@@ -169,4 +174,5 @@ while True:
                 send_message_mobiles(message,dingding,at_mobiles)
         MysqlUtil.close()
 
+        time.sleep(2)