From fb47d36048e94b9a506d5c153e3dd19a01e37df1 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期一, 30 十月 2023 16:30:27 +0800 Subject: [PATCH] bug修复 --- log_module/log_analyse.py | 62 ++++++++++++++++++++++++++++++ 1 files changed, 61 insertions(+), 1 deletions(-) diff --git a/log_module/log_analyse.py b/log_module/log_analyse.py index b91c89f..9c79325 100644 --- a/log_module/log_analyse.py +++ b/log_module/log_analyse.py @@ -2,6 +2,7 @@ 鏃ュ織鍒嗘瀽 """ # 鑾峰彇涓嶅彲浠ヤ笅鍗曠殑鍘熷洜 +import datetime import os import constant @@ -42,5 +43,64 @@ return dict_ +# 鑾峰彇鍗庨懌鐨勫鎵樻暟鎹� +def load_huaxin_delegate_datas(): + file_path = "{}/logs/gp/kpl/kpl_block_can_buy.{}.log".format(constant.get_path_prefix(), tool.get_now_date_str()) + dict_ = {} + if os.path.exists(file_path): + with open(file_path, encoding="utf-8") as f: + line = f.readline() + while line: + if True: + code = line.split("code=")[1][:6] + time_ = line.split("|")[0].split(" ")[1][:12] + reason = line.split(f"code={code}锛�")[1].strip() + dict_[code] = (time_, reason.replace("鍙互涓嬪崟", "")) + # print(time_, code, reason) + line = f.readline() + + +# 鍒嗘瀽L2鏁版嵁浼犺緭鏃堕棿 +def analyze_l2_data_transformation(path_): + with open(path_, 'r', encoding="utf-8") as f: + while True: + line = f.readline() + if not line: + break + try: + datas = line.split("|") + create_time = datas[0].strip() + data = datas[2].split(" - ")[1].strip() + contents = data.split("#") + code = contents[0] + use_time = int(contents[1].strip().split("锛�")[1].split("-")[-2]) + l2_data = contents[2] + l2_data = eval(l2_data) + max_time_data = None + min_time_data = None + for d in l2_data: + if len(d) > 10: + if max_time_data is None: + max_time_data = d + if min_time_data is None: + min_time_data = d + if d[10] > max_time_data[10]: + max_time_data = d + if d[10] < min_time_data[10]: + min_time_data = d + if max_time_data and min_time_data: + dt = datetime.datetime.strptime(create_time.split(".")[0], "%Y-%m-%d %H:%M:%S") + create_timestamp = int(dt.timestamp() * 1000) + int(create_time.split(".")[1]) + if use_time > 100: + print(create_time, f"鏁伴噺:{len(l2_data)}", f"鑰楁椂锛歿use_time}", code, + create_timestamp - min_time_data[10], + create_timestamp - max_time_data[10]) + except: + print(line) + pass + + pass + + if __name__ == "__main__": - print(get_kpl_can_buy_reasons_dict()) + analyze_l2_data_transformation("D:\\logs\\huaxin_l2\\orderdetail.2023-08-29.log") -- Gitblit v1.8.0