From ab11008d660832876dce7c6d05a2b5be0da1dd20 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期日, 23 七月 2023 23:51:16 +0800 Subject: [PATCH] 选票板块即将更改 --- third_data/kpl_block_util.py | 89 ++++++++++++++++++++++++++++++-------------- 1 files changed, 61 insertions(+), 28 deletions(-) diff --git a/third_data/kpl_block_util.py b/third_data/kpl_block_util.py index 7cc9c8f..2c75ef0 100644 --- a/third_data/kpl_block_util.py +++ b/third_data/kpl_block_util.py @@ -7,6 +7,7 @@ import datetime import time +import constant from utils import tool @@ -55,25 +56,16 @@ return False, "" -# 鏄惁鏄寷鎷夋澘鍧� +# 鏄惁涓绘澘寮�1 # limit_up_record_datas 浠婃棩鍘嗗彶娑ㄥ仠 -def is_soon_limit_up(code, block, limit_up_record_datas): - block_codes_infos = [] - limit_up_time = time.time() +def is_shsz_open_limit_up(code, block, limit_up_record_datas, code_block_dict): + # 鑾峰彇浠婃棩9锛�30鐨勬椂闂存埑 + time_str = datetime.datetime.now().strftime("%Y-%m-%d") + " 09:30:00" + timestamp = time.mktime(time.strptime(time_str, '%Y-%m-%d %H:%M:%S')) for k in limit_up_record_datas: - if k[2] == block: - if k[3] != code: - block_codes_infos.append((k[3], int(k[5]))) - else: - limit_up_time = int(k[5]) - # 鎺掑簭 - block_codes_infos.append((code, limit_up_time)) - block_codes_infos.sort(key=lambda x: x[1]) - if len(block_codes_infos) < 2: - return False, "" - if block_codes_infos[1][1] - block_codes_infos[0][1] < 30 * 60: - # 棣栨娑ㄥ仠鏃堕棿闂撮殧30鍒嗛挓鍐� - return True, f"鏉垮潡锛歿block} 榫�1锛歿block_codes_infos[0][0]} 榫�2锛歿block_codes_infos[1][0]}" + if code_block_dict.get(k[3]) == block: + if int(k[5]) < timestamp: + return True, f"{k[3]}寮�涓�" return False, "" @@ -90,14 +82,51 @@ return True -# 鑾峰彇涓绘澘韬綅 -def get_sh_sz_code_rank(code, block, limit_up_record_datas): +# 鏄惁鏄墠鍑犵殑鏉垮潡 +def is_top_block(code, block, limit_up_record_datas, topn): block_codes_infos = [] limit_up_time = time.time() for k in limit_up_record_datas: - if k[3].find("00") != 0 and k[3].find("60") != 0: + if k[3] != code: + block_codes_infos.append((k[3], k[2], int(k[5]))) + else: + limit_up_time = int(k[5]) + # 鎺掑簭 + block_codes_infos.append((code, block, limit_up_time)) + block_first_limit_up_dict = {} + for b in block_codes_infos: + if b[1] not in block_first_limit_up_dict: + block_first_limit_up_dict[b[1]] = b + else: + if b[2] < block_first_limit_up_dict[b[1]][2]: + block_first_limit_up_dict[b[1]] = b + block_codes_infos = [block_first_limit_up_dict[k] for k in block_first_limit_up_dict] + block_codes_infos.sort(key=lambda x: x[2]) + # 鍘婚櫎閫氱敤娑ㄥ仠鍘熷洜 + index = 0 + for d in block_codes_infos: + if d[1] in constant.KPL_INVALID_BLOCKS: continue - if k[2] == block: + if d[1] == block: + if index + 1 <= topn: + return True + else: + return False + index += 1 + if index <= topn: + return True + return False + + +# 鑾峰彇褰撴棩鍘嗗彶韬綅 +# shsz:鏄惁涓绘澘 +def get_code_record_rank(code, block, limit_up_record_datas, code_limit_up_reason_dict, shsz=True): + block_codes_infos = [] + limit_up_time = time.time() + for k in limit_up_record_datas: + if shsz and k[3].find("00") != 0 and k[3].find("60") != 0: + continue + if code_limit_up_reason_dict.get(k[3]) == block: if k[3] != code: block_codes_infos.append((k[3], int(k[5]))) else: @@ -110,16 +139,20 @@ return 0 -# 鑾峰彇韬綅 -def get_code_rank(code, block, limit_up_record_datas): +# 鑾峰彇褰撴棩瀹炴椂韬綅 +# before_blocks_dict鏍煎紡浣峽"浠g爜":set("鏉垮潡")} +def get_code_current_rank(code, block, current_limit_up_datas, code_limit_up_reason_dict, shsz=False): block_codes_infos = [] limit_up_time = time.time() - for k in limit_up_record_datas: - if k[2] == block: - if k[3] != code: - block_codes_infos.append((k[3], int(k[5]))) + for k in current_limit_up_datas: + if shsz and k[0].find("00") != 0 and k[0].find("60") != 0: + continue + if code_limit_up_reason_dict.get(k[0]) == block: + if k[0] != code: + # 浠g爜.娑ㄥ仠鏃堕棿 + block_codes_infos.append((k[0], int(k[2]))) else: - limit_up_time = int(k[5]) + limit_up_time = int(k[2]) block_codes_infos.append((code, limit_up_time)) block_codes_infos.sort(key=lambda x: x[1]) for i in range(0, len(block_codes_infos)): -- Gitblit v1.8.0