From d95905057a66cd7823ade2a22e1b2debfcd20220 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 03 四月 2024 18:00:03 +0800
Subject: [PATCH] 前端代码修改

---
 kpl/kpl_data_manager.py |   33 ++++++++++++++++++++++++---------
 1 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/kpl/kpl_data_manager.py b/kpl/kpl_data_manager.py
index c2f9080..7e14a90 100644
--- a/kpl/kpl_data_manager.py
+++ b/kpl/kpl_data_manager.py
@@ -23,9 +23,12 @@
         return cls.__instance
 
     @classmethod
-    def __load_data(cls):
-        record_apth = cls.__get_record_path()
-        current_path = cls.__get_current_path()
+    def __load_data(cls, day=tool.get_now_date_str()):
+        record_apth = cls.__get_record_path(day)
+        current_path = cls.__get_current_path(day)
+        limit_up_records_dict = {}
+        limit_up_current_dict = {}
+
         # 鑾峰彇鍘嗗彶娑ㄥ仠
         if os.path.exists(record_apth):
             children = os.listdir(record_apth)
@@ -34,7 +37,7 @@
                     line = f.readline().strip()
                     if line:
                         data = json.loads(line)
-                        cls.limit_up_records_dict[data[0]] = data
+                        limit_up_records_dict[data[0]] = data
         # 鑾峰彇瀹炴椂娑ㄥ仠
         if os.path.exists(current_path):
             with open(current_path, mode="r") as f:
@@ -42,7 +45,11 @@
                 if line:
                     datas = json.loads(line)
                     for d in datas:
-                        cls.limit_up_current_dict[d[0]] = d
+                        limit_up_current_dict[d[0]] = d
+        if day == tool.get_now_date_str():
+            cls.limit_up_records_dict = limit_up_records_dict
+            cls.limit_up_current_dict = limit_up_current_dict
+        return limit_up_records_dict, limit_up_current_dict
 
     def __save_data(self, limit_up_datas):
         record_path = self.__get_record_path()
@@ -67,13 +74,21 @@
         # 淇濆瓨鏂囦欢
         threading.Thread(target=self.__save_data, args=(limit_up_datas,), daemon=True).start()
 
-    def get_limit_up_current_datas(self):
-        temps = [self.limit_up_current_dict[k] for k in self.limit_up_current_dict]
+    def get_limit_up_current_datas(self, day=tool.get_now_date_str()):
+        if day == tool.get_now_date_str():
+            temps = [self.limit_up_current_dict[k] for k in self.limit_up_current_dict]
+        else:
+            records, current = self.__load_data(day)
+            temps = [current[k] for k in current]
         temps.sort(key=lambda x: x[2], reverse=True)
         return temps
 
-    def get_limit_up_history_datas(self):
-        temps = [self.limit_up_records_dict[k] for k in self.limit_up_records_dict]
+    def get_limit_up_history_datas(self, day=tool.get_now_date_str()):
+        if day == tool.get_now_date_str():
+            temps = [self.limit_up_records_dict[k] for k in self.limit_up_records_dict]
+        else:
+            records, current = self.__load_data(day)
+            temps = [records[k] for k in records]
         temps.sort(key=lambda x: x[2], reverse=True)
         return temps
 

--
Gitblit v1.8.0