From 04cbb1c2445ecbdd2b5222909777d3fbfcea8c82 Mon Sep 17 00:00:00 2001 From: TANGWY Date: Wed, 16 Oct 2024 21:45:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/sys_config.json | 40 ++++++++++-------------------- utils/base_dataclean_pg.py | 2 +- utils/dashboard_data_conversion.py | 20 +++++++-------- 3 files changed, 24 insertions(+), 38 deletions(-) diff --git a/conf/sys_config.json b/conf/sys_config.json index 116d36e..ade1c8e 100644 --- a/conf/sys_config.json +++ b/conf/sys_config.json @@ -4,33 +4,19 @@ "static_ext":[".js",".css",".png",".jpg",".ico",".html",".gif",".woff",".woff2",".ttf",".htm",".svg"], "region_dict":{ "10": "省公司", - "110": "武汉分公司", - "111": "武汉分公司", - "170": "襄阳分公司", - "171": "襄阳分公司", - "130": "鄂州分公司", - "131": "鄂州分公司", - "260": "孝感分公司", - "261": "孝感分公司", - "250": "黄冈分公司", - "251": "黄冈分公司", - "120": "黄石分公司", - "121": "黄石分公司", - "190": "咸宁分公司", - "191": "咸宁分公司", - "200": "荆州分公司", - "201": "荆州分公司", - "202": "荆州分公司", - "140": "宜昌分公司", - "141": "宜昌分公司", - "150": "恩施分公司", - "151": "恩施分公司", - "160": "十堰分公司", - "161": "十堰分公司", - "240": "随州分公司", - "241": "随州分公司", - "230": "荆门分公司", - "231": "荆门分公司", + "11": "武汉分公司", + "17": "襄阳分公司", + "13": "鄂州分公司", + "26": "孝感分公司", + "25": "黄冈分公司", + "12": "黄石分公司", + "19": "咸宁分公司", + "20": "荆州分公司", + "14": "宜昌分公司", + "15": "恩施分公司", + "16": "十堰分公司", + "24": "随州分公司", + "23": "荆门分公司", "1801": "江汉分公司", "1802": "潜江分公司", "1803": "天门分公司" diff --git a/utils/base_dataclean_pg.py b/utils/base_dataclean_pg.py index 4c69a6b..5fca22b 100644 --- a/utils/base_dataclean_pg.py +++ b/utils/base_dataclean_pg.py @@ -326,7 +326,7 @@ def group_and_write_to_file(data_ip, data_account, data_interface, data_menu, st ip = item.get('ip', '0.0.0.0') account = remove_commas(item.get('account', '')) jobnum = item.get('jobnum', '') - if menu == "" or len(jobnum) >jobnum_max_length: + if menu == "" or menu == "null" or len(jobnum) >jobnum_max_length: continue count = item.get('count', 0) datatype = DATA_TYPE.get("MENU",4) diff --git a/utils/dashboard_data_conversion.py b/utils/dashboard_data_conversion.py index 8e362eb..d9c7ee5 100644 --- a/utils/dashboard_data_conversion.py +++ b/utils/dashboard_data_conversion.py @@ -37,22 +37,22 @@ def safe_divide(numerator, denominator): return else: return numerator / denominator + def find_region_by_code(code, region_dict): """ 查询工号对应公司 未查询到 返回错误工号 """ code_str = keep_digits_filter(code) - # 在字典中特别检查 - if code_str in region_dict: - return region_dict[code_str] - - # 使用生成器表达式和next函数尝试找到匹配的前缀 - company = next( - (region_dict.get(code_str[:i]) for i in range(2, min(len(code_str), 5)) if code_str[:i] in region_dict), - "错误工号") - return company - + #只有7位或8位的工号才是合法 + if len(code_str)!=7 and len(code_str) != 8: + return u"其他" + # 如果code以"18"开头,检查前4位 + if code_str.startswith("18"): + return region_dict.get(code_str[:4], u"其他") + # 否则,检查前2位 + else: + return region_dict.get(code_str[:2], u"其他") def ip_summary_data_format(ip_summary_data): """ ip维度数据转换方法