From c9d1d3dfd0ec4b769b2ec0c8d662a1271b091b9c Mon Sep 17 00:00:00 2001 From: python Date: Tue, 9 Dec 2025 09:12:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=EF=BC=8C=E8=B0=83=E6=95=B4=E6=B5=8B=E8=AF=95=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check_template_in_db.py | 122 +++++++++ fix_template_input_data.py | 233 ++++++++++++++++++ init_all_templates.py | 10 +- .../document_service.cpython-312.pyc | Bin 12484 -> 12761 bytes .../__pycache__/field_service.cpython-312.pyc | Bin 12078 -> 15895 bytes static/index.html | 2 +- .../走读式谈话审批/~$谈话前安全风险评估表.docx | Bin 162 -> 0 bytes .../走读式谈话审批/~$谈话后安全风险评估表.docx | Bin 162 -> 0 bytes test_template_query.py | 27 ++ verify_template_code.py | 92 +++++++ 10 files changed, 482 insertions(+), 4 deletions(-) create mode 100644 check_template_in_db.py create mode 100644 fix_template_input_data.py delete mode 100644 template_finish/2-初核模版/2.谈话审批/走读式谈话审批/~$谈话前安全风险评估表.docx delete mode 100644 template_finish/2-初核模版/2.谈话审批/走读式谈话审批/~$谈话后安全风险评估表.docx create mode 100644 test_template_query.py create mode 100644 verify_template_code.py diff --git a/check_template_in_db.py b/check_template_in_db.py new file mode 100644 index 0000000..23aaec9 --- /dev/null +++ b/check_template_in_db.py @@ -0,0 +1,122 @@ +""" +检查数据库中的模板配置 +""" +import pymysql +import json +import os + +# 数据库连接配置 +DB_CONFIG = { + 'host': os.getenv('DB_HOST', '152.136.177.240'), + 'port': int(os.getenv('DB_PORT', 5012)), + 'user': os.getenv('DB_USER', 'finyx'), + 'password': os.getenv('DB_PASSWORD', '6QsGK6MpePZDE57Z'), + 'database': os.getenv('DB_NAME', 'finyx'), + 'charset': 'utf8mb4' +} + +TENANT_ID = 615873064429507639 + +def check_template_code(): + """检查模板编码""" + print("="*80) + print("检查数据库中的模板配置") + print("="*80) + + try: + conn = pymysql.connect(**DB_CONFIG) + cursor = conn.cursor(pymysql.cursors.DictCursor) + + # 查询所有文件配置 + sql = """ + SELECT id, name, file_path, input_data, template_code, state + FROM f_polic_file_config + WHERE tenant_id = %s + ORDER BY name + """ + cursor.execute(sql, (TENANT_ID,)) + configs = cursor.fetchall() + + print(f"\n共找到 {len(configs)} 个文件配置\n") + + # 查找 REPORT_CARD + print("查找 REPORT_CARD 模板编码:") + print("-" * 80) + found = False + + for config in configs: + name = config['name'] + template_code_col = config.get('template_code') # 从 template_code 列 + input_data_str = config.get('input_data') + state = config.get('state', 0) + + # 从 input_data JSON 中解析 + template_code_json = None + if input_data_str: + try: + input_data = json.loads(input_data_str) if isinstance(input_data_str, str) else input_data_str + if isinstance(input_data, dict): + template_code_json = input_data.get('template_code') + except: + pass + + # 检查是否匹配 REPORT_CARD + if template_code_col == 'REPORT_CARD' or template_code_json == 'REPORT_CARD': + found = True + print(f"\n✓ 找到匹配的配置:") + print(f" - ID: {config['id']}") + print(f" - 名称: {name}") + print(f" - template_code 列: {template_code_col}") + print(f" - input_data 中的 template_code: {template_code_json}") + print(f" - 文件路径: {config['file_path']}") + print(f" - 状态: {'启用' if state == 1 else '未启用'}") + print(f" - input_data 完整内容: {input_data_str}") + print() + + if not found: + print("✗ 未找到 REPORT_CARD 模板编码") + print("\n所有模板配置列表:") + print("-" * 80) + for config in configs: + name = config['name'] + template_code_col = config.get('template_code') + input_data_str = config.get('input_data') + state = config.get('state', 0) + + # 从 input_data JSON 中解析 + template_code_json = None + if input_data_str: + try: + input_data = json.loads(input_data_str) if isinstance(input_data_str, str) else input_data_str + if isinstance(input_data, dict): + template_code_json = input_data.get('template_code') + except: + pass + + status_str = "启用" if state == 1 else "未启用" + code_info = f"列:{template_code_col or '(空)'}, JSON:{template_code_json or '(空)'}" + print(f" - {name} [{status_str}] [{code_info}]") + + # 检查表结构 + print("\n" + "="*80) + print("检查表结构") + print("="*80) + cursor.execute("DESCRIBE f_polic_file_config") + columns = cursor.fetchall() + print("\n表字段:") + for col in columns: + print(f" - {col['Field']}: {col['Type']}") + + except Exception as e: + print(f"✗ 查询失败: {str(e)}") + import traceback + traceback.print_exc() + finally: + if 'cursor' in locals(): + cursor.close() + if 'conn' in locals(): + conn.close() + + +if __name__ == '__main__': + check_template_code() diff --git a/fix_template_input_data.py b/fix_template_input_data.py new file mode 100644 index 0000000..f4fdcb6 --- /dev/null +++ b/fix_template_input_data.py @@ -0,0 +1,233 @@ +""" +修复数据库中模板配置的 input_data 字段 +确保所有记录的 input_data JSON 中包含正确的 template_code +""" +import pymysql +import json +import os +from datetime import datetime + +# 数据库连接配置 +DB_CONFIG = { + 'host': os.getenv('DB_HOST', '152.136.177.240'), + 'port': int(os.getenv('DB_PORT', 5012)), + 'user': os.getenv('DB_USER', 'finyx'), + 'password': os.getenv('DB_PASSWORD', '6QsGK6MpePZDE57Z'), + 'database': os.getenv('DB_NAME', 'finyx'), + 'charset': 'utf8mb4' +} + +TENANT_ID = 615873064429507639 +UPDATED_BY = 655162080928945152 +CURRENT_TIME = datetime.now() + +# 模板编码映射(从 init_all_templates.py 复制) +DOCUMENT_TYPE_MAPPING = { + "1.请示报告卡(XXX)": { + "template_code": "REPORT_CARD", + "business_type": "INVESTIGATION" + }, + "2.初步核实审批表(XXX)": { + "template_code": "PRELIMINARY_VERIFICATION_APPROVAL", + "business_type": "INVESTIGATION" + }, + "3.附件初核方案(XXX)": { + "template_code": "INVESTIGATION_PLAN", + "business_type": "INVESTIGATION" + }, + "谈话通知书第一联": { + "template_code": "NOTIFICATION_LETTER_1", + "business_type": "INVESTIGATION" + }, + "谈话通知书第二联": { + "template_code": "NOTIFICATION_LETTER_2", + "business_type": "INVESTIGATION" + }, + "谈话通知书第三联": { + "template_code": "NOTIFICATION_LETTER_3", + "business_type": "INVESTIGATION" + }, + "1.请示报告卡(初核谈话)": { + "template_code": "REPORT_CARD_INTERVIEW", + "business_type": "INVESTIGATION" + }, + "2谈话审批表": { + "template_code": "INTERVIEW_APPROVAL_FORM", + "business_type": "INVESTIGATION" + }, + "3.谈话前安全风险评估表": { + "template_code": "PRE_INTERVIEW_RISK_ASSESSMENT", + "business_type": "INVESTIGATION" + }, + "4.谈话方案": { + "template_code": "INTERVIEW_PLAN", + "business_type": "INVESTIGATION" + }, + "5.谈话后安全风险评估表": { + "template_code": "POST_INTERVIEW_RISK_ASSESSMENT", + "business_type": "INVESTIGATION" + }, + "1.谈话笔录": { + "template_code": "INTERVIEW_RECORD", + "business_type": "INVESTIGATION" + }, + "2.谈话询问对象情况摸底调查30问": { + "template_code": "INVESTIGATION_30_QUESTIONS", + "business_type": "INVESTIGATION" + }, + "3.被谈话人权利义务告知书": { + "template_code": "RIGHTS_OBLIGATIONS_NOTICE", + "business_type": "INVESTIGATION" + }, + "4.点对点交接单": { + "template_code": "HANDOVER_FORM", + "business_type": "INVESTIGATION" + }, + "4.点对点交接单2": { + "template_code": "HANDOVER_FORM_2", + "business_type": "INVESTIGATION" + }, + "5.陪送交接单(新)": { + "template_code": "ESCORT_HANDOVER_FORM", + "business_type": "INVESTIGATION" + }, + "6.1保密承诺书(谈话对象使用-非中共党员用)": { + "template_code": "CONFIDENTIALITY_COMMITMENT_NON_PARTY", + "business_type": "INVESTIGATION" + }, + "6.2保密承诺书(谈话对象使用-中共党员用)": { + "template_code": "CONFIDENTIALITY_COMMITMENT_PARTY", + "business_type": "INVESTIGATION" + }, + "7.办案人员-办案安全保密承诺书": { + "template_code": "INVESTIGATOR_CONFIDENTIALITY_COMMITMENT", + "business_type": "INVESTIGATION" + }, + "8-1请示报告卡(初核报告结论) ": { + "template_code": "REPORT_CARD_CONCLUSION", + "business_type": "INVESTIGATION" + }, + "8.XXX初核情况报告": { + "template_code": "INVESTIGATION_REPORT", + "business_type": "INVESTIGATION" + } +} + + +def fix_input_data(): + """修复所有记录的 input_data 字段""" + print("="*80) + print("修复模板配置的 input_data 字段") + print("="*80) + + try: + conn = pymysql.connect(**DB_CONFIG) + cursor = conn.cursor(pymysql.cursors.DictCursor) + + # 查询所有文件配置 + sql = """ + SELECT id, name, template_code, input_data, state + FROM f_polic_file_config + WHERE tenant_id = %s + ORDER BY name + """ + cursor.execute(sql, (TENANT_ID,)) + configs = cursor.fetchall() + + print(f"\n找到 {len(configs)} 个文件配置\n") + + updated_count = 0 + skipped_count = 0 + + for config in configs: + config_id = config['id'] + name = config['name'] + template_code_col = config.get('template_code') + input_data_str = config.get('input_data') + state = config.get('state', 0) + + # 确定应该使用的 template_code + target_template_code = None + target_business_type = "INVESTIGATION" # 默认值 + + # 方法1: 从映射表中查找 + if name in DOCUMENT_TYPE_MAPPING: + target_template_code = DOCUMENT_TYPE_MAPPING[name]['template_code'] + target_business_type = DOCUMENT_TYPE_MAPPING[name]['business_type'] + # 方法2: 使用 template_code 列的值 + elif template_code_col: + target_template_code = template_code_col + + if not target_template_code: + print(f"⚠ 跳过: {name} (无法确定 template_code)") + skipped_count += 1 + continue + + # 检查 input_data 是否需要更新 + need_update = False + current_input_data = {} + + if input_data_str: + try: + current_input_data = json.loads(input_data_str) if isinstance(input_data_str, str) else input_data_str + if not isinstance(current_input_data, dict): + current_input_data = {} + except: + current_input_data = {} + + # 检查 template_code 是否匹配 + if current_input_data.get('template_code') != target_template_code: + need_update = True + + # 检查 business_type 是否存在 + if not current_input_data.get('business_type'): + need_update = True + + if need_update: + # 更新 input_data + new_input_data = { + 'template_code': target_template_code, + 'business_type': target_business_type + } + # 保留原有的其他字段(如果有) + for key, value in current_input_data.items(): + if key not in ['template_code', 'business_type']: + new_input_data[key] = value + + new_input_data_str = json.dumps(new_input_data, ensure_ascii=False) + + update_sql = """ + UPDATE f_polic_file_config + SET input_data = %s, updated_time = %s, updated_by = %s + WHERE id = %s + """ + cursor.execute(update_sql, (new_input_data_str, CURRENT_TIME, UPDATED_BY, config_id)) + conn.commit() + + print(f"✓ 更新: {name}") + print(f" template_code: {target_template_code}") + print(f" business_type: {target_business_type}") + updated_count += 1 + else: + print(f"✓ 已正确: {name} (template_code: {target_template_code})") + + print("\n" + "="*80) + print("修复完成") + print("="*80) + print(f"更新: {updated_count} 个记录") + print(f"跳过: {skipped_count} 个记录") + print(f"总计: {len(configs)} 个记录") + + except Exception as e: + print(f"✗ 修复失败: {str(e)}") + import traceback + traceback.print_exc() + finally: + if 'cursor' in locals(): + cursor.close() + if 'conn' in locals(): + conn.close() + + +if __name__ == '__main__': + fix_input_data() diff --git a/init_all_templates.py b/init_all_templates.py index 63478c5..c3de671 100644 --- a/init_all_templates.py +++ b/init_all_templates.py @@ -256,13 +256,17 @@ def get_or_create_file_config(conn, doc_config: Dict, file_path: str) -> int: if existing: file_config_id = existing[0] - # 更新文件路径 + # 更新文件路径和 input_data(确保 input_data 中包含正确的 template_code) + input_data = json.dumps({ + 'template_code': doc_config['template_code'], + 'business_type': doc_config['business_type'] + }, ensure_ascii=False) update_sql = """ UPDATE f_polic_file_config - SET file_path = %s, updated_time = %s, updated_by = %s + SET file_path = %s, input_data = %s, updated_time = %s, updated_by = %s, state = 1 WHERE id = %s """ - cursor.execute(update_sql, (file_path, CURRENT_TIME, UPDATED_BY, file_config_id)) + cursor.execute(update_sql, (file_path, input_data, CURRENT_TIME, UPDATED_BY, file_config_id)) conn.commit() return file_config_id else: diff --git a/services/__pycache__/document_service.cpython-312.pyc b/services/__pycache__/document_service.cpython-312.pyc index 2c8066369f5a1865b9ad46b94e53cf2de297ca9b..8cb0c13fd0d07a22e945534da19f05d72b9b8550 100644 GIT binary patch delta 1607 zcmZWpOKcNI7@pae<40^q-Z+j!z=TI)l8_Q;C?$nJ98!hIRY;+P5`~R-ovd-}bnFxo z*+43_;t|ASDp9IF67|riR29e5kL^*x3!pDm_M6dW|ZyaA@F=1fDloc#qFfZk#2pUuo z%G>NHXH$i0rYCZaqth!YtDmheVapAru#WO&xw1qho#uQS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v)Jk(+j)<{?x36~4wI9E+>qiFjdEt`AB@iS`wx zG~dj^ObQRASd-HpSW~oyBH4UBZTkQ>@KzJ7J7l1W4{mtsWx|bdcFg^#(5bp79~p8G z?gV#Ic!fJb!u6#Mhl}uY_rUJzhTolyFyxwWn#S>&tZo{~R6cFMl56{(09)~)y+a2A zF&XvEW$~G`CFbgT#oa%vzPpbHR<-ky zvcG-xx$}u~aNA|&X0W#$>bf+sHgQ#5Z@m>7`O_{nHB=ffVSFk6PNM8^uM95@FUKo( zPHU>zwgPb9t!xvv%q`yif`fhN7yX_AmHS$4ABYLGzf|xn2&5nW(w52L(iz_`l5K>M z=sw7`Oun=q)iH!lgaZgKBVg%t9N{1XODyQG8*~EgLkz-dt$UN`NP*8k>U|YyN`BUy znKhGmF!TtV@(+`frE7jww2dNj1nvahR;pQ}Xdi@pu%+w&taY`l)w6p835OA?{3L2e z;IrUvavA;!e($j4Ob)k7>!x1%p?ys98jNDeQyC+h9@n$8MuPT3PiHvz7W0P{8pjOP zy#`U!5#|_Jjo^wlI_PP1)Vcs4b_Ti^(0&sMN_Ea^GeJ}65i@LHDMdyBVG{o6e1SE& zD?CcBm*&Gi@vYe8#Bca#hoy(QNe@9j(nQ8#F|vnpdjrmn>1Jz0b2Dg8yUPKyp$>OO&_k$Lj VBOk#^Y=^p6BwhD7MB2;Z{{c)HMdAPe diff --git a/services/__pycache__/field_service.cpython-312.pyc b/services/__pycache__/field_service.cpython-312.pyc index 868a3e0a23f133212375bd89890242f1a2e9d7db..adf73b9259d779bec80d1f045c463eae31090094 100644 GIT binary patch delta 5013 zcmbtYdvFuixj!rI>iw21$+BgyB|ng{6pR659w8=xV<1imPAE*M>u6;o*Vyin9H_gB zxEaz=>hQRyQy>YcGt&}td6~MsbsA_Py*HuL=~RljgQMH&w4E57PNz|DI!)6~r{CH2 z%9uX>>DvB%-#O>|zVqDQch(m_cS5xM)ND2&cxG3xh;Leb-0~Y{;`m2P(&`x3r4lp; z*g+&_S(H&>uv*O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>ED=bwF6!npV@;!B;7mpcAT%T3;AdELLxKmu`f#Zr^dqDZ4j^2n3=4 diff --git a/template_finish/2-初核模版/2.谈话审批/走读式谈话审批/~$谈话后安全风险评估表.docx b/template_finish/2-初核模版/2.谈话审批/走读式谈话审批/~$谈话后安全风险评估表.docx deleted file mode 100644 index 8efa2add58b5d5f87a575ca504cb02cda69d2af3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 162 acmZQM@NUmO22ueNgI{`bG^x7CQx5=>2n3=4 diff --git a/test_template_query.py b/test_template_query.py new file mode 100644 index 0000000..62b2dd4 --- /dev/null +++ b/test_template_query.py @@ -0,0 +1,27 @@ +""" +测试模板编码查询 +""" +import sys +import os +sys.path.insert(0, os.path.dirname(__file__)) + +from services.document_service import DocumentService + +# 测试查询 REPORT_CARD +print("="*60) +print("测试查询模板编码: REPORT_CARD") +print("="*60) + +service = DocumentService() +result = service.get_file_config_by_template_code('REPORT_CARD') + +if result: + print("\n✓ 找到模板配置:") + print(f" - ID: {result['id']}") + print(f" - 名称: {result['name']}") + print(f" - 文件路径: {result['file_path']}") + print(f" - 模板编码: {result['template_code']}") +else: + print("\n✗ 未找到模板配置") + print("\n请运行以下脚本修复:") + print(" python fix_template_input_data.py") diff --git a/verify_template_code.py b/verify_template_code.py new file mode 100644 index 0000000..9889de2 --- /dev/null +++ b/verify_template_code.py @@ -0,0 +1,92 @@ +""" +验证模板编码是否存在 +""" +import pymysql +import json +import os + +# 数据库连接配置 +DB_CONFIG = { + 'host': os.getenv('DB_HOST', '152.136.177.240'), + 'port': int(os.getenv('DB_PORT', 5012)), + 'user': os.getenv('DB_USER', 'finyx'), + 'password': os.getenv('DB_PASSWORD', '6QsGK6MpePZDE57Z'), + 'database': os.getenv('DB_NAME', 'finyx'), + 'charset': 'utf8mb4' +} + +TENANT_ID = 615873064429507639 + +def verify_template_code(template_code: str): + """验证指定的模板编码是否存在""" + print("="*60) + print(f"验证模板编码: {template_code}") + print("="*60) + + try: + conn = pymysql.connect(**DB_CONFIG) + cursor = conn.cursor(pymysql.cursors.DictCursor) + + # 查询所有文件配置 + sql = """ + SELECT id, name, file_path, input_data, state + FROM f_polic_file_config + WHERE tenant_id = %s + AND state = 1 + """ + cursor.execute(sql, (TENANT_ID,)) + configs = cursor.fetchall() + + found = False + print(f"\n查询到 {len(configs)} 个启用的文件配置\n") + + for config in configs: + try: + input_data = json.loads(config['input_data']) if config['input_data'] else {} + config_template_code = input_data.get('template_code') + + if config_template_code == template_code: + found = True + print(f"✓ 找到匹配的模板:") + print(f" - 名称: {config['name']}") + print(f" - ID: {config['id']}") + print(f" - 模板编码: {config_template_code}") + print(f" - 文件路径: {config['file_path']}") + print(f" - 状态: {'启用' if config['state'] == 1 else '未启用'}") + print() + except (json.JSONDecodeError, TypeError) as e: + continue + + if not found: + print(f"✗ 未找到模板编码: {template_code}") + print("\n可用的模板编码列表:") + print("-" * 60) + for config in configs: + try: + input_data = json.loads(config['input_data']) if config['input_data'] else {} + config_template_code = input_data.get('template_code') + if config_template_code: + print(f" - {config_template_code} ({config['name']})") + except: + continue + print() + + return found + + except Exception as e: + print(f"✗ 查询失败: {str(e)}") + return False + finally: + if 'cursor' in locals(): + cursor.close() + if 'conn' in locals(): + conn.close() + + +if __name__ == '__main__': + # 验证 REPORT_CARD 模板编码 + verify_template_code('REPORT_CARD') + + print("\n" + "="*60) + print("验证完成") + print("="*60)