diff --git a/app/config/__pycache__/settings.cpython-39.pyc b/app/config/__pycache__/settings.cpython-39.pyc index f7bf8d2..2873afe 100644 Binary files a/app/config/__pycache__/settings.cpython-39.pyc and b/app/config/__pycache__/settings.cpython-39.pyc differ diff --git a/app/config/settings.py b/app/config/settings.py index b16b7bf..67a7bc7 100644 --- a/app/config/settings.py +++ b/app/config/settings.py @@ -39,14 +39,27 @@ class ConfigManager: """ if not os.path.exists(self.config_file): self.create_default_config() - - try: - self.config.read(self.config_file, encoding='utf-8') - logger.info(f"已加载配置文件: {self.config_file}") - except Exception as e: - logger.error(f"加载配置文件时出错: {e}") - logger.info("使用默认配置") - self.create_default_config(save=False) + else: + try: + # 先读取现有配置 + self.config.read(self.config_file, encoding='utf-8') + + # 检查是否有缺失的配置项,只添加缺失的项 + for section, options in DEFAULT_CONFIG.items(): + if not self.config.has_section(section): + self.config.add_section(section) + + for option, value in options.items(): + if not self.config.has_option(section, option): + self.config.set(section, option, value) + + # 保存更新后的配置 + self.save_config() + logger.info(f"已加载并更新配置文件: {self.config_file}") + except Exception as e: + logger.error(f"加载配置文件时出错: {e}") + logger.info("使用默认配置") + self.create_default_config(save=False) def create_default_config(self, save: bool = True) -> None: """创建默认配置""" diff --git a/app/core/utils/__pycache__/dialog_utils.cpython-39.pyc b/app/core/utils/__pycache__/dialog_utils.cpython-39.pyc index e27d99e..dc6b506 100644 Binary files a/app/core/utils/__pycache__/dialog_utils.cpython-39.pyc and b/app/core/utils/__pycache__/dialog_utils.cpython-39.pyc differ diff --git a/app/core/utils/dialog_utils.py b/app/core/utils/dialog_utils.py index af29ac0..e7e2141 100644 --- a/app/core/utils/dialog_utils.py +++ b/app/core/utils/dialog_utils.py @@ -465,4 +465,153 @@ def show_barcode_mapping_dialog(*args, **kwargs): """ # 确保已导入ttk import tkinter.ttk as ttk - return create_barcode_mapping_dialog(*args, **kwargs) \ No newline at end of file + return create_barcode_mapping_dialog(*args, **kwargs) + +def show_config_dialog(parent, config_manager, on_save=None): + """显示配置设置对话框""" + dialog = tk.Toplevel(parent) + dialog.title("系统配置") + dialog.geometry("600x500") + dialog.resizable(False, False) + + # 使窗口居中 + dialog.update_idletasks() + width = dialog.winfo_width() + height = dialog.winfo_height() + x = (dialog.winfo_screenwidth() // 2) - (width // 2) + y = (dialog.winfo_screenheight() // 2) - (height // 2) + dialog.geometry('{}x{}+{}+{}'.format(width, height, x, y)) + + # 创建主框架 + main_frame = ttk.Frame(dialog, padding="10") + main_frame.pack(fill=tk.BOTH, expand=True) + + # 创建选项卡 + notebook = ttk.Notebook(main_frame) + notebook.pack(fill=tk.BOTH, expand=True, pady=5) + + # 创建各个配置页面的框架 + api_frame = ttk.Frame(notebook, padding="10") + paths_frame = ttk.Frame(notebook, padding="10") + performance_frame = ttk.Frame(notebook, padding="10") + file_frame = ttk.Frame(notebook, padding="10") + + # 添加选项卡 + notebook.add(api_frame, text="API设置") + notebook.add(paths_frame, text="路径设置") + notebook.add(performance_frame, text="性能设置") + notebook.add(file_frame, text="文件设置") + + # 存储所有输入框的引用 + entries = {} + + # API设置 + ttk.Label(api_frame, text="百度OCR API设置", font=("Arial", 12, "bold")).pack(anchor=tk.W, pady=5) + + # API Key + ttk.Label(api_frame, text="API Key:").pack(anchor=tk.W, pady=2) + api_key_entry = ttk.Entry(api_frame, width=50) + api_key_entry.pack(fill=tk.X, pady=2) + api_key_entry.insert(0, config_manager.get('API', 'api_key', '')) + entries[('API', 'api_key')] = api_key_entry + + # Secret Key + ttk.Label(api_frame, text="Secret Key:").pack(anchor=tk.W, pady=2) + secret_key_entry = ttk.Entry(api_frame, width=50) + secret_key_entry.pack(fill=tk.X, pady=2) + secret_key_entry.insert(0, config_manager.get('API', 'secret_key', '')) + entries[('API', 'secret_key')] = secret_key_entry + + # 超时设置 + ttk.Label(api_frame, text="超时时间(秒):").pack(anchor=tk.W, pady=2) + timeout_entry = ttk.Entry(api_frame, width=10) + timeout_entry.pack(anchor=tk.W, pady=2) + timeout_entry.insert(0, config_manager.get('API', 'timeout', '30')) + entries[('API', 'timeout')] = timeout_entry + + # 路径设置 + ttk.Label(paths_frame, text="系统路径设置", font=("Arial", 12, "bold")).pack(anchor=tk.W, pady=5) + + # 输入目录 + ttk.Label(paths_frame, text="输入目录:").pack(anchor=tk.W, pady=2) + input_dir_entry = ttk.Entry(paths_frame, width=50) + input_dir_entry.pack(fill=tk.X, pady=2) + input_dir_entry.insert(0, config_manager.get('Paths', 'input_folder', 'data/input')) + entries[('Paths', 'input_folder')] = input_dir_entry + + # 输出目录 + ttk.Label(paths_frame, text="输出目录:").pack(anchor=tk.W, pady=2) + output_dir_entry = ttk.Entry(paths_frame, width=50) + output_dir_entry.pack(fill=tk.X, pady=2) + output_dir_entry.insert(0, config_manager.get('Paths', 'output_folder', 'data/output')) + entries[('Paths', 'output_folder')] = output_dir_entry + + # 性能设置 + ttk.Label(performance_frame, text="性能设置", font=("Arial", 12, "bold")).pack(anchor=tk.W, pady=5) + + # 最大工作线程数 + ttk.Label(performance_frame, text="最大工作线程数:").pack(anchor=tk.W, pady=2) + max_workers_entry = ttk.Entry(performance_frame, width=10) + max_workers_entry.pack(anchor=tk.W, pady=2) + max_workers_entry.insert(0, config_manager.get('Performance', 'max_workers', '4')) + entries[('Performance', 'max_workers')] = max_workers_entry + + # 批处理大小 + ttk.Label(performance_frame, text="批处理大小:").pack(anchor=tk.W, pady=2) + batch_size_entry = ttk.Entry(performance_frame, width=10) + batch_size_entry.pack(anchor=tk.W, pady=2) + batch_size_entry.insert(0, config_manager.get('Performance', 'batch_size', '5')) + entries[('Performance', 'batch_size')] = batch_size_entry + + # 文件设置 + ttk.Label(file_frame, text="文件设置", font=("Arial", 12, "bold")).pack(anchor=tk.W, pady=5) + + # 允许的文件扩展名 + ttk.Label(file_frame, text="允许的文件扩展名:").pack(anchor=tk.W, pady=2) + extensions_entry = ttk.Entry(file_frame, width=50) + extensions_entry.pack(fill=tk.X, pady=2) + extensions_entry.insert(0, config_manager.get('File', 'allowed_extensions', '.jpg,.jpeg,.png,.bmp')) + entries[('File', 'allowed_extensions')] = extensions_entry + + # 最大文件大小 + ttk.Label(file_frame, text="最大文件大小(MB):").pack(anchor=tk.W, pady=2) + max_size_entry = ttk.Entry(file_frame, width=10) + max_size_entry.pack(anchor=tk.W, pady=2) + max_size_entry.insert(0, config_manager.get('File', 'max_file_size_mb', '4')) + entries[('File', 'max_file_size_mb')] = max_size_entry + + def save_config(): + """保存配置""" + try: + # 收集所有输入框的值 + for (section, option), entry in entries.items(): + value = entry.get().strip() + config_manager.update(section, option, value) + + # 保存配置 + config_manager.save_config() + + if on_save: + on_save() + + messagebox.showinfo("成功", "配置已保存") + dialog.destroy() + except Exception as e: + messagebox.showerror("错误", f"保存配置时出错: {str(e)}") + + # 按钮框架 + button_frame = ttk.Frame(main_frame) + button_frame.pack(fill=tk.X, pady=10) + + # 保存按钮 + ttk.Button(button_frame, text="保存", command=save_config).pack(side=tk.RIGHT, padx=5) + + # 取消按钮 + ttk.Button(button_frame, text="取消", command=dialog.destroy).pack(side=tk.RIGHT, padx=5) + + # 设置模态 + dialog.transient(parent) + dialog.grab_set() + + # 等待窗口关闭 + parent.wait_window(dialog) \ No newline at end of file diff --git a/app/services/__pycache__/ocr_service.cpython-39.pyc b/app/services/__pycache__/ocr_service.cpython-39.pyc index cd31aa9..feb0e9b 100644 Binary files a/app/services/__pycache__/ocr_service.cpython-39.pyc and b/app/services/__pycache__/ocr_service.cpython-39.pyc differ diff --git a/app/services/ocr_service.py b/app/services/ocr_service.py index 2be2c1b..ec09541 100644 --- a/app/services/ocr_service.py +++ b/app/services/ocr_service.py @@ -5,6 +5,7 @@ OCR服务模块 """ from typing import Dict, List, Optional, Tuple, Union, Any +import os from ..config.settings import ConfigManager from ..core.utils.log_utils import get_logger @@ -43,23 +44,49 @@ class OCRService: def process_image(self, image_path: str) -> Optional[str]: """ - 处理单张图片 + 处理单个图片文件 Args: - image_path: 图片路径 + image_path: 图片文件路径 Returns: - 输出Excel文件路径,如果处理失败则返回None + 生成的Excel文件路径,如果处理失败则返回None """ - logger.info(f"OCRService开始处理图片: {image_path}") - result = self.ocr_processor.process_image(image_path) - - if result: - logger.info(f"OCRService处理图片成功: {image_path} -> {result}") - else: - logger.error(f"OCRService处理图片失败: {image_path}") - - return result + try: + # 检查文件是否存在 + if not os.path.exists(image_path): + logger.error(f"文件不存在: {image_path}") + return None + + # 检查文件类型 + if not self._is_valid_image(image_path): + logger.error(f"不支持的文件类型: {image_path}") + return None + + # 检查是否已处理 + excel_file = self._get_excel_path(image_path) + if os.path.exists(excel_file): + logger.info(f"文件已处理过,跳过OCR识别: {image_path}") + return excel_file + + # 执行OCR识别 + result = self.ocr_processor.process_image(image_path) + if not result: + logger.error(f"OCR识别失败: {image_path}") + return None + + # 生成Excel文件 + excel_file = self._generate_excel(result, image_path) + if not excel_file: + logger.error(f"生成Excel文件失败: {image_path}") + return None + + logger.info(f"处理完成: {image_path} -> {excel_file}") + return excel_file + + except Exception as e: + logger.error(f"处理图片时发生错误: {e}", exc_info=True) + return None def process_images_batch(self, batch_size: int = None, max_workers: int = None) -> Tuple[int, int]: """ diff --git a/data/input/微信图片_20250509142624.jpg b/data/input/微信图片_20250509142624.jpg deleted file mode 100644 index e6ca3aa..0000000 Binary files a/data/input/微信图片_20250509142624.jpg and /dev/null differ diff --git a/data/output/processed_files.json b/data/output/processed_files.json deleted file mode 100644 index 9d08736..0000000 --- a/data/output/processed_files.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "D:/My Documents/python/orc-order-v2/data/output/微信图片_20250509142624.xlsx": "data/output\\采购单_微信图片_20250509142624.xls" -} \ No newline at end of file diff --git a/data/output/微信图片_20250509142624.xlsx b/data/output/微信图片_20250509142624.xlsx deleted file mode 100644 index f09c6f6..0000000 Binary files a/data/output/微信图片_20250509142624.xlsx and /dev/null differ diff --git a/data/output/采购单_微信图片_20250509142624.xls b/data/output/采购单_微信图片_20250509142624.xls deleted file mode 100644 index 0764cbe..0000000 Binary files a/data/output/采购单_微信图片_20250509142624.xls and /dev/null differ diff --git a/logs/__main__.active b/logs/__main__.active index 2912e4d..0ba361d 100644 --- a/logs/__main__.active +++ b/logs/__main__.active @@ -1 +1 @@ -Active since: 2025-05-10 12:29:42 \ No newline at end of file +Active since: 2025-05-10 12:54:52 \ No newline at end of file diff --git a/logs/__main__.log b/logs/__main__.log index 98367b7..9edb00a 100644 --- a/logs/__main__.log +++ b/logs/__main__.log @@ -439,3 +439,11 @@ Traceback (most recent call last): AttributeError: 'OCRService' object has no attribute 'batch_process' 2025-05-09 14:32:56,697 - __main__ - INFO - 开始烟草公司订单处理 2025-05-09 14:32:56,706 - __main__ - ERROR - 烟草订单处理失败 +2025-05-10 12:34:15,446 - __main__ - ERROR - OCR处理失败,没有成功处理任何文件 +2025-05-10 12:47:26,684 - __main__ - ERROR - 执行过程中发生错误: 'OrderService' object has no attribute 'process_latest_excel' +Traceback (most recent call last): + File "D:\My Documents\python\orc-order-v2\run.py", line 154, in main + result = order_service.process_latest_excel() +AttributeError: 'OrderService' object has no attribute 'process_latest_excel' +2025-05-10 12:50:31,807 - __main__ - ERROR - OCR处理失败,没有成功处理任何文件 +2025-05-10 12:54:52,743 - __main__ - WARNING - 没有找到需要处理的图片 diff --git a/logs/app.core.excel.converter.active b/logs/app.core.excel.converter.active index 9dd4f3a..0ba361d 100644 --- a/logs/app.core.excel.converter.active +++ b/logs/app.core.excel.converter.active @@ -1 +1 @@ -Active since: 2025-05-10 12:29:41 \ No newline at end of file +Active since: 2025-05-10 12:54:52 \ No newline at end of file diff --git a/logs/app.core.excel.converter.log b/logs/app.core.excel.converter.log index e1fab18..7039109 100644 --- a/logs/app.core.excel.converter.log +++ b/logs/app.core.excel.converter.log @@ -2014,3 +2014,19 @@ 2025-05-10 12:29:42,346 - app.core.excel.converter - INFO - 解析容量(ml)规格: 250ML*24 -> 1*24 2025-05-10 12:29:42,346 - app.core.excel.converter - INFO - 解析容量(ml)规格: 250ML*24 -> 1*24 2025-05-10 12:29:46,511 - app.core.excel.converter - INFO - 解析容量(ml)规格: 250ML*12 -> 1*12 +2025-05-10 12:34:08,605 - app.core.excel.converter - INFO - 成功加载条码映射配置,共19项 +2025-05-10 12:47:25,096 - app.core.excel.converter - INFO - 成功加载条码映射配置,共19项 +2025-05-10 12:50:31,805 - app.core.excel.converter - INFO - 成功加载条码映射配置,共19项 +2025-05-10 12:54:52,740 - app.core.excel.converter - INFO - 成功加载条码映射配置,共19项 +2025-05-10 12:54:52,970 - app.core.excel.converter - INFO - 解析容量(ml)规格: 500ml*15 -> 1*15 +2025-05-10 12:54:52,975 - app.core.excel.converter - INFO - 解析容量(L)规格: 1L*12 -> 1*12 +2025-05-10 12:54:52,977 - app.core.excel.converter - INFO - 解析容量(L)规格: 1L*12 -> 1*12 +2025-05-10 12:54:52,984 - app.core.excel.converter - INFO - 解析容量(L)规格: 1L*12 -> 1*12 +2025-05-10 12:54:52,986 - app.core.excel.converter - INFO - 解析容量(L)规格: 1L*12 -> 1*12 +2025-05-10 12:54:52,988 - app.core.excel.converter - INFO - 解析容量(L)规格: 1L*12 -> 1*12 +2025-05-10 12:54:53,019 - app.core.excel.converter - INFO - 解析容量(L)规格: 1L*12 -> 1*12 +2025-05-10 12:54:53,020 - app.core.excel.converter - INFO - 解析容量(L)规格: 1L*12 -> 1*12 +2025-05-10 12:54:53,021 - app.core.excel.converter - INFO - 解析容量(L)规格: 1L*12 -> 1*12 +2025-05-10 12:54:53,022 - app.core.excel.converter - INFO - 解析容量(L)规格: 1L*12 -> 1*12 +2025-05-10 12:54:53,023 - app.core.excel.converter - INFO - 解析容量(L)规格: 1L*12 -> 1*12 +2025-05-10 12:57:50,073 - app.core.excel.converter - INFO - 成功加载条码映射配置,共19项 diff --git a/logs/app.core.excel.handlers.barcode_mapper.active b/logs/app.core.excel.handlers.barcode_mapper.active index 9dd4f3a..0ba361d 100644 --- a/logs/app.core.excel.handlers.barcode_mapper.active +++ b/logs/app.core.excel.handlers.barcode_mapper.active @@ -1 +1 @@ -Active since: 2025-05-10 12:29:41 \ No newline at end of file +Active since: 2025-05-10 12:54:52 \ No newline at end of file diff --git a/logs/app.core.excel.handlers.unit_converter_handlers.active b/logs/app.core.excel.handlers.unit_converter_handlers.active index 9dd4f3a..0ba361d 100644 --- a/logs/app.core.excel.handlers.unit_converter_handlers.active +++ b/logs/app.core.excel.handlers.unit_converter_handlers.active @@ -1 +1 @@ -Active since: 2025-05-10 12:29:41 \ No newline at end of file +Active since: 2025-05-10 12:54:52 \ No newline at end of file diff --git a/logs/app.core.excel.handlers.unit_converter_handlers.log b/logs/app.core.excel.handlers.unit_converter_handlers.log index df022af..d267245 100644 --- a/logs/app.core.excel.handlers.unit_converter_handlers.log +++ b/logs/app.core.excel.handlers.unit_converter_handlers.log @@ -100,3 +100,14 @@ 2025-05-10 12:29:42,346 - app.core.excel.handlers.unit_converter_handlers - INFO - 件单位处理: 数量: 3.0 -> 72.0, 单价: 63.0 -> 2.625, 单位: 件 -> 瓶 2025-05-10 12:29:42,346 - app.core.excel.handlers.unit_converter_handlers - INFO - 件单位处理: 数量: 3.0 -> 72.0, 单价: 54.0 -> 2.25, 单位: 件 -> 瓶 2025-05-10 12:29:46,511 - app.core.excel.handlers.unit_converter_handlers - INFO - 件单位处理: 数量: 2.0 -> 24.0, 单价: 42.0 -> 3.5, 单位: 件 -> 瓶 +2025-05-10 12:54:52,970 - app.core.excel.handlers.unit_converter_handlers - INFO - 件单位处理: 数量: 1.0 -> 15.0, 单价: 33.0 -> 2.2, 单位: 件 -> 瓶 +2025-05-10 12:54:52,975 - app.core.excel.handlers.unit_converter_handlers - INFO - 件单位处理: 数量: 2.0 -> 24.0, 单价: 42.0 -> 3.5, 单位: 件 -> 瓶 +2025-05-10 12:54:52,978 - app.core.excel.handlers.unit_converter_handlers - INFO - 件单位处理: 数量: 1.0 -> 12.0, 单价: 42.0 -> 3.5, 单位: 件 -> 瓶 +2025-05-10 12:54:52,984 - app.core.excel.handlers.unit_converter_handlers - INFO - 件单位处理: 数量: 1.0 -> 12.0, 单价: 42.0 -> 3.5, 单位: 件 -> 瓶 +2025-05-10 12:54:52,987 - app.core.excel.handlers.unit_converter_handlers - INFO - 件单位处理: 数量: 1.0 -> 12.0, 单价: 42.0 -> 3.5, 单位: 件 -> 瓶 +2025-05-10 12:54:52,988 - app.core.excel.handlers.unit_converter_handlers - INFO - 件单位处理: 数量: 1.0 -> 12.0, 单价: 42.0 -> 3.5, 单位: 件 -> 瓶 +2025-05-10 12:54:53,019 - app.core.excel.handlers.unit_converter_handlers - INFO - 件单位处理: 数量: 1.0 -> 12.0, 单价: 42.0 -> 3.5, 单位: 件 -> 瓶 +2025-05-10 12:54:53,020 - app.core.excel.handlers.unit_converter_handlers - INFO - 件单位处理: 数量: 1.0 -> 12.0, 单价: 42.0 -> 3.5, 单位: 件 -> 瓶 +2025-05-10 12:54:53,021 - app.core.excel.handlers.unit_converter_handlers - INFO - 件单位处理: 数量: 1.0 -> 12.0, 单价: 42.0 -> 3.5, 单位: 件 -> 瓶 +2025-05-10 12:54:53,022 - app.core.excel.handlers.unit_converter_handlers - INFO - 赠品件单位处理: 数量: 1.0 -> 12.0, 单价: 0, 单位: 件 -> 瓶 +2025-05-10 12:54:53,023 - app.core.excel.handlers.unit_converter_handlers - INFO - 赠品瓶单位处理: 保持原样 数量: 1.0, 单价: 0, 单位: 瓶 diff --git a/logs/app.core.excel.merger.active b/logs/app.core.excel.merger.active index 9dd4f3a..0ba361d 100644 --- a/logs/app.core.excel.merger.active +++ b/logs/app.core.excel.merger.active @@ -1 +1 @@ -Active since: 2025-05-10 12:29:41 \ No newline at end of file +Active since: 2025-05-10 12:54:52 \ No newline at end of file diff --git a/logs/app.core.excel.merger.log b/logs/app.core.excel.merger.log index fe574b7..5ac1354 100644 --- a/logs/app.core.excel.merger.log +++ b/logs/app.core.excel.merger.log @@ -516,3 +516,11 @@ 2025-05-10 11:55:28,008 - app.core.excel.merger - INFO - 初始化PurchaseOrderMerger完成,模板文件: templates\银豹-采购单模板.xls 2025-05-10 12:29:42,168 - app.core.excel.merger - INFO - 使用输出目录: D:\My Documents\python\orc-order-v2\data\output 2025-05-10 12:29:42,169 - app.core.excel.merger - INFO - 初始化PurchaseOrderMerger完成,模板文件: templates\银豹-采购单模板.xls +2025-05-10 12:34:08,605 - app.core.excel.merger - INFO - 使用输出目录: D:\My Documents\python\orc-order-v2\data\output +2025-05-10 12:34:08,606 - app.core.excel.merger - INFO - 初始化PurchaseOrderMerger完成,模板文件: templates\银豹-采购单模板.xls +2025-05-10 12:47:25,096 - app.core.excel.merger - INFO - 使用输出目录: D:\My Documents\python\orc-order-v2\data\output +2025-05-10 12:47:25,097 - app.core.excel.merger - INFO - 初始化PurchaseOrderMerger完成,模板文件: templates\银豹-采购单模板.xls +2025-05-10 12:50:31,805 - app.core.excel.merger - INFO - 使用输出目录: D:\My Documents\python\orc-order-v2\data\output +2025-05-10 12:50:31,806 - app.core.excel.merger - INFO - 初始化PurchaseOrderMerger完成,模板文件: templates\银豹-采购单模板.xls +2025-05-10 12:54:52,741 - app.core.excel.merger - INFO - 使用输出目录: D:\My Documents\python\orc-order-v2\data\output +2025-05-10 12:54:52,742 - app.core.excel.merger - INFO - 初始化PurchaseOrderMerger完成,模板文件: templates\银豹-采购单模板.xls diff --git a/logs/app.core.excel.processor.active b/logs/app.core.excel.processor.active index 9dd4f3a..0ba361d 100644 --- a/logs/app.core.excel.processor.active +++ b/logs/app.core.excel.processor.active @@ -1 +1 @@ -Active since: 2025-05-10 12:29:41 \ No newline at end of file +Active since: 2025-05-10 12:54:52 \ No newline at end of file diff --git a/logs/app.core.excel.processor.log b/logs/app.core.excel.processor.log index 04686a6..7188b4a 100644 --- a/logs/app.core.excel.processor.log +++ b/logs/app.core.excel.processor.log @@ -6354,3 +6354,90 @@ ValueError: could not convert string to float: '2\n96' 2025-05-10 12:29:52,709 - app.core.excel.processor - INFO - 条码 6907992507095 处理结果:正常商品数量24.0,单价3.5,赠品数量0 2025-05-10 12:29:52,712 - app.core.excel.processor - INFO - 采购单已保存到: data/output\采购单_微信图片_20250509142624.xls 2025-05-10 12:29:52,714 - app.core.excel.processor - INFO - 采购单已保存到: data/output\采购单_微信图片_20250509142624.xls +2025-05-10 12:34:08,603 - app.core.excel.processor - INFO - 使用输出目录: D:\My Documents\python\orc-order-v2\data\output +2025-05-10 12:34:08,604 - app.core.excel.processor - INFO - 使用临时目录: D:\My Documents\python\orc-order-v2\data\temp +2025-05-10 12:34:08,605 - app.core.excel.processor - INFO - 初始化ExcelProcessor完成,模板文件: templates/银豹-采购单模板.xls +2025-05-10 12:47:25,095 - app.core.excel.processor - INFO - 使用输出目录: D:\My Documents\python\orc-order-v2\data\output +2025-05-10 12:47:25,095 - app.core.excel.processor - INFO - 使用临时目录: D:\My Documents\python\orc-order-v2\data\temp +2025-05-10 12:47:25,096 - app.core.excel.processor - INFO - 初始化ExcelProcessor完成,模板文件: templates/银豹-采购单模板.xls +2025-05-10 12:50:31,804 - app.core.excel.processor - INFO - 使用输出目录: D:\My Documents\python\orc-order-v2\data\output +2025-05-10 12:50:31,804 - app.core.excel.processor - INFO - 使用临时目录: D:\My Documents\python\orc-order-v2\data\temp +2025-05-10 12:50:31,805 - app.core.excel.processor - INFO - 初始化ExcelProcessor完成,模板文件: templates/银豹-采购单模板.xls +2025-05-10 12:54:52,739 - app.core.excel.processor - INFO - 使用输出目录: D:\My Documents\python\orc-order-v2\data\output +2025-05-10 12:54:52,739 - app.core.excel.processor - INFO - 使用临时目录: D:\My Documents\python\orc-order-v2\data\temp +2025-05-10 12:54:52,740 - app.core.excel.processor - INFO - 初始化ExcelProcessor完成,模板文件: templates/银豹-采购单模板.xls +2025-05-10 12:54:52,744 - app.core.excel.processor - INFO - 搜索目录 data/output 中的Excel文件 +2025-05-10 12:54:52,746 - app.core.excel.processor - INFO - 找到最新的Excel文件: data/output\微信图片_20250509142700.xlsx +2025-05-10 12:54:52,746 - app.core.excel.processor - INFO - 开始处理Excel文件: data/output\微信图片_20250509142700.xlsx +2025-05-10 12:54:52,798 - app.core.excel.processor - INFO - 成功读取Excel文件: data/output\微信图片_20250509142700.xlsx, 共 13 行 +2025-05-10 12:54:52,840 - app.core.excel.processor - INFO - 找到可能的表头行: 第1行,评分: 45 +2025-05-10 12:54:52,840 - app.core.excel.processor - INFO - 识别到表头在第 1 行 +2025-05-10 12:54:52,954 - app.core.excel.processor - INFO - 使用表头行重新读取数据,共 12 行有效数据 +2025-05-10 12:54:52,954 - app.core.excel.processor - INFO - 找到精确匹配的条码列: 商品条码 +2025-05-10 12:54:52,954 - app.core.excel.processor - INFO - 使用条码列: 商品条码 +2025-05-10 12:54:52,954 - app.core.excel.processor - INFO - 找到name列(部分匹配): 商品条码 +2025-05-10 12:54:52,955 - app.core.excel.processor - INFO - 找到specification列: 规格 +2025-05-10 12:54:52,955 - app.core.excel.processor - INFO - 找到quantity列: 数量 +2025-05-10 12:54:52,955 - app.core.excel.processor - INFO - 找到unit列: 单位 +2025-05-10 12:54:52,959 - app.core.excel.processor - INFO - 找到price列: 单价 +2025-05-10 12:54:52,960 - app.core.excel.processor - INFO - 列名映射结果: {'barcode': '商品条码', 'name': '商品条码', 'specification': '规格', 'quantity': '数量', 'unit': '单位', 'price': '单价'} +2025-05-10 12:54:52,960 - app.core.excel.processor - INFO - 是否存在规格列: True +2025-05-10 12:54:52,968 - app.core.excel.processor - INFO - 第1行: 提取商品信息 条码=6922456805012, 名称=6922456805012.0, 规格=, 数量=1.0, 单位=件, 单价=33.0 +2025-05-10 12:54:52,969 - app.core.excel.processor - INFO - 解析规格: 500ml*15 -> 包装数量=15 +2025-05-10 12:54:52,971 - app.core.excel.processor - INFO - 第2行: 提取商品信息 条码=6922456892067, 名称=6922456892067.0, 规格=, 数量=2.0, 单位=件, 单价=42.0 +2025-05-10 12:54:52,974 - app.core.excel.processor - INFO - 解析规格: 1L*12 -> 包装数量=12 +2025-05-10 12:54:52,976 - app.core.excel.processor - INFO - 第3行: 提取商品信息 条码=6922456891985, 名称=6922456891985.0, 规格=, 数量=1.0, 单位=件, 单价=42.0 +2025-05-10 12:54:52,977 - app.core.excel.processor - INFO - 解析规格: 1L*12 -> 包装数量=12 +2025-05-10 12:54:52,978 - app.core.excel.processor - INFO - 第4行: 提取商品信息 条码=6922456889944, 名称=6922456889944.0, 规格=, 数量=1.0, 单位=件, 单价=42.0 +2025-05-10 12:54:52,984 - app.core.excel.processor - INFO - 解析规格: 1L*12 -> 包装数量=12 +2025-05-10 12:54:52,985 - app.core.excel.processor - INFO - 第5行: 提取商品信息 条码=6922456896362, 名称=6922456896362.0, 规格=, 数量=1.0, 单位=件, 单价=42.0 +2025-05-10 12:54:52,985 - app.core.excel.processor - INFO - 解析规格: 1L*12 -> 包装数量=12 +2025-05-10 12:54:52,988 - app.core.excel.processor - INFO - 第6行: 提取商品信息 条码=6922456889920, 名称=6922456889920.0, 规格=, 数量=1.0, 单位=件, 单价=42.0 +2025-05-10 12:54:52,988 - app.core.excel.processor - INFO - 解析规格: 1L*12 -> 包装数量=12 +2025-05-10 12:54:53,018 - app.core.excel.processor - INFO - 第7行: 提取商品信息 条码=6922456843571, 名称=6922456843571.0, 规格=, 数量=1.0, 单位=件, 单价=42.0 +2025-05-10 12:54:53,018 - app.core.excel.processor - INFO - 解析规格: 1L*12 -> 包装数量=12 +2025-05-10 12:54:53,019 - app.core.excel.processor - INFO - 第8行: 提取商品信息 条码=6922456840259, 名称=6922456840259.0, 规格=, 数量=1.0, 单位=件, 单价=42.0 +2025-05-10 12:54:53,019 - app.core.excel.processor - INFO - 解析规格: 1L*12 -> 包装数量=12 +2025-05-10 12:54:53,020 - app.core.excel.processor - INFO - 第9行: 提取商品信息 条码=6922456889982, 名称=6922456889982.0, 规格=, 数量=1.0, 单位=件, 单价=42.0 +2025-05-10 12:54:53,020 - app.core.excel.processor - INFO - 解析规格: 1L*12 -> 包装数量=12 +2025-05-10 12:54:53,021 - app.core.excel.processor - INFO - 第10行: 提取商品信息 条码=6922456896362, 名称=6922456896362.0, 规格=, 数量=1.0, 单位=件, 单价=0 +2025-05-10 12:54:53,021 - app.core.excel.processor - INFO - 解析规格: 1L*12 -> 包装数量=12 +2025-05-10 12:54:53,022 - app.core.excel.processor - INFO - 第11行: 提取商品信息 条码=6922456896362, 名称=6922456896362.0, 规格=, 数量=1.0, 单位=瓶, 单价=0 +2025-05-10 12:54:53,022 - app.core.excel.processor - INFO - 解析规格: 1L*12 -> 包装数量=12 +2025-05-10 12:54:53,023 - app.core.excel.processor - INFO - 提取到 11 个商品信息 +2025-05-10 12:54:53,037 - app.core.excel.processor - INFO - 开始处理11 个产品信息 +2025-05-10 12:54:53,038 - app.core.excel.processor - INFO - 处理商品: 条码=6922456805012, 数量=15.0, 单价=2.2, 是否赠品=False +2025-05-10 12:54:53,038 - app.core.excel.processor - INFO - 发现正常商品:条码6922456805012, 数量=15.0, 单价=2.2 +2025-05-10 12:54:53,038 - app.core.excel.processor - INFO - 处理商品: 条码=6922456892067, 数量=24.0, 单价=3.5, 是否赠品=False +2025-05-10 12:54:53,038 - app.core.excel.processor - INFO - 发现正常商品:条码6922456892067, 数量=24.0, 单价=3.5 +2025-05-10 12:54:53,038 - app.core.excel.processor - INFO - 处理商品: 条码=6922456891985, 数量=12.0, 单价=3.5, 是否赠品=False +2025-05-10 12:54:53,038 - app.core.excel.processor - INFO - 发现正常商品:条码6922456891985, 数量=12.0, 单价=3.5 +2025-05-10 12:54:53,038 - app.core.excel.processor - INFO - 处理商品: 条码=6922456889944, 数量=12.0, 单价=3.5, 是否赠品=False +2025-05-10 12:54:53,039 - app.core.excel.processor - INFO - 发现正常商品:条码6922456889944, 数量=12.0, 单价=3.5 +2025-05-10 12:54:53,039 - app.core.excel.processor - INFO - 处理商品: 条码=6922456896362, 数量=12.0, 单价=3.5, 是否赠品=False +2025-05-10 12:54:53,039 - app.core.excel.processor - INFO - 发现正常商品:条码6922456896362, 数量=12.0, 单价=3.5 +2025-05-10 12:54:53,039 - app.core.excel.processor - INFO - 处理商品: 条码=6922456889920, 数量=12.0, 单价=3.5, 是否赠品=False +2025-05-10 12:54:53,039 - app.core.excel.processor - INFO - 发现正常商品:条码6922456889920, 数量=12.0, 单价=3.5 +2025-05-10 12:54:53,039 - app.core.excel.processor - INFO - 处理商品: 条码=6922456843571, 数量=12.0, 单价=3.5, 是否赠品=False +2025-05-10 12:54:56,172 - app.core.excel.processor - INFO - 发现正常商品:条码6922456843571, 数量=12.0, 单价=3.5 +2025-05-10 12:54:56,172 - app.core.excel.processor - INFO - 处理商品: 条码=6922456840259, 数量=12.0, 单价=3.5, 是否赠品=False +2025-05-10 12:54:56,173 - app.core.excel.processor - INFO - 发现正常商品:条码6922456840259, 数量=12.0, 单价=3.5 +2025-05-10 12:54:56,173 - app.core.excel.processor - INFO - 处理商品: 条码=6922456889982, 数量=12.0, 单价=3.5, 是否赠品=False +2025-05-10 12:54:56,173 - app.core.excel.processor - INFO - 发现正常商品:条码6922456889982, 数量=12.0, 单价=3.5 +2025-05-10 12:54:56,173 - app.core.excel.processor - INFO - 处理商品: 条码=6922456896362, 数量=12.0, 单价=0, 是否赠品=True +2025-05-10 12:54:56,173 - app.core.excel.processor - INFO - 发现赠品:条码6922456896362, 数量=12.0 +2025-05-10 12:54:56,173 - app.core.excel.processor - INFO - 处理商品: 条码=6922456896362, 数量=1.0, 单价=0, 是否赠品=True +2025-05-10 12:54:56,173 - app.core.excel.processor - INFO - 发现赠品:条码6922456896362, 数量=1.0 +2025-05-10 12:54:56,173 - app.core.excel.processor - INFO - 分组后共9 个不同条码的商品 +2025-05-10 12:54:56,173 - app.core.excel.processor - INFO - 条码 6922456805012 处理结果:正常商品数量15.0,单价2.2,赠品数量0 +2025-05-10 12:54:56,173 - app.core.excel.processor - INFO - 条码 6922456892067 处理结果:正常商品数量24.0,单价3.5,赠品数量0 +2025-05-10 12:54:56,173 - app.core.excel.processor - INFO - 条码 6922456891985 处理结果:正常商品数量12.0,单价3.5,赠品数量0 +2025-05-10 12:54:56,174 - app.core.excel.processor - INFO - 条码 6922456889944 处理结果:正常商品数量12.0,单价3.5,赠品数量0 +2025-05-10 12:54:56,174 - app.core.excel.processor - INFO - 条码 6922456896362 处理结果:正常商品数量12.0,单价3.5,赠品数量13.0 +2025-05-10 12:54:56,174 - app.core.excel.processor - INFO - 条码 6922456889920 处理结果:正常商品数量12.0,单价3.5,赠品数量0 +2025-05-10 12:54:56,174 - app.core.excel.processor - INFO - 条码 6922456843571 处理结果:正常商品数量12.0,单价3.5,赠品数量0 +2025-05-10 12:54:56,174 - app.core.excel.processor - INFO - 条码 6922456840259 处理结果:正常商品数量12.0,单价3.5,赠品数量0 +2025-05-10 12:54:56,174 - app.core.excel.processor - INFO - 条码 6922456889982 处理结果:正常商品数量12.0,单价3.5,赠品数量0 +2025-05-10 12:54:56,174 - app.core.excel.processor - INFO - 条码 6922456896362 填充:采购量=12.0,赠品数量13.0 +2025-05-10 12:54:56,177 - app.core.excel.processor - INFO - 采购单已保存到: data/output\采购单_微信图片_20250509142700.xls +2025-05-10 12:54:56,179 - app.core.excel.processor - INFO - 采购单已保存到: data/output\采购单_微信图片_20250509142700.xls diff --git a/logs/app.core.excel.validators.active b/logs/app.core.excel.validators.active index 9dd4f3a..0ba361d 100644 --- a/logs/app.core.excel.validators.active +++ b/logs/app.core.excel.validators.active @@ -1 +1 @@ -Active since: 2025-05-10 12:29:41 \ No newline at end of file +Active since: 2025-05-10 12:54:52 \ No newline at end of file diff --git a/logs/app.core.ocr.baidu_ocr.active b/logs/app.core.ocr.baidu_ocr.active index 28d2b0e..26dd9c1 100644 --- a/logs/app.core.ocr.baidu_ocr.active +++ b/logs/app.core.ocr.baidu_ocr.active @@ -1 +1 @@ -Active since: 2025-05-10 12:29:40 \ No newline at end of file +Active since: 2025-05-10 12:54:51 \ No newline at end of file diff --git a/logs/app.core.ocr.baidu_ocr.log b/logs/app.core.ocr.baidu_ocr.log index fe6018e..41d7caa 100644 --- a/logs/app.core.ocr.baidu_ocr.log +++ b/logs/app.core.ocr.baidu_ocr.log @@ -81,3 +81,13 @@ 2025-05-09 14:31:02,533 - app.core.ocr.baidu_ocr - INFO - 成功获取访问令牌 2025-05-09 14:31:02,581 - app.core.ocr.baidu_ocr - INFO - 成功获取访问令牌 2025-05-10 11:55:16,591 - app.core.ocr.baidu_ocr - INFO - 成功获取访问令牌 +2025-05-10 12:34:08,595 - app.core.ocr.baidu_ocr - WARNING - API密钥未设置,请在配置文件中设置API密钥 +2025-05-10 12:34:09,025 - app.core.ocr.baidu_ocr - WARNING - 获取访问令牌失败 (尝试 1/3): {"error_description":"The request is missing a required parameter","error":"invalid_request"} + +2025-05-10 12:34:11,251 - app.core.ocr.baidu_ocr - WARNING - 获取访问令牌失败 (尝试 2/3): {"error_description":"The request is missing a required parameter","error":"invalid_request"} + +2025-05-10 12:34:15,444 - app.core.ocr.baidu_ocr - WARNING - 获取访问令牌失败 (尝试 3/3): {"error_description":"The request is missing a required parameter","error":"invalid_request"} + +2025-05-10 12:34:15,444 - app.core.ocr.baidu_ocr - ERROR - 无法获取访问令牌 +2025-05-10 12:34:15,445 - app.core.ocr.baidu_ocr - ERROR - 无法获取访问令牌,无法进行表格识别 +2025-05-10 12:47:25,432 - app.core.ocr.baidu_ocr - INFO - 成功获取访问令牌 diff --git a/logs/app.core.ocr.table_ocr.active b/logs/app.core.ocr.table_ocr.active index 28d2b0e..26dd9c1 100644 --- a/logs/app.core.ocr.table_ocr.active +++ b/logs/app.core.ocr.table_ocr.active @@ -1 +1 @@ -Active since: 2025-05-10 12:29:40 \ No newline at end of file +Active since: 2025-05-10 12:54:51 \ No newline at end of file diff --git a/logs/app.core.ocr.table_ocr.log b/logs/app.core.ocr.table_ocr.log index c8229b2..7e2ace5 100644 --- a/logs/app.core.ocr.table_ocr.log +++ b/logs/app.core.ocr.table_ocr.log @@ -741,3 +741,37 @@ 2025-05-10 11:55:16,274 - app.core.ocr.table_ocr - INFO - 开始处理图片: data/input\微信图片_20250509142624.jpg 2025-05-10 11:55:18,016 - app.core.ocr.table_ocr - INFO - 图片处理成功: data/input\微信图片_20250509142624.jpg, 输出文件: data/output\微信图片_20250509142624.xlsx 2025-05-10 11:55:18,045 - app.core.ocr.table_ocr - INFO - 所有图片处理完成, 总计: 1, 成功: 1 +2025-05-10 12:34:08,595 - app.core.ocr.table_ocr - INFO - 使用输入目录: D:\My Documents\python\orc-order-v2\data\input +2025-05-10 12:34:08,595 - app.core.ocr.table_ocr - INFO - 使用输出目录: D:\My Documents\python\orc-order-v2\data\output +2025-05-10 12:34:08,596 - app.core.ocr.table_ocr - INFO - 使用临时目录: D:\My Documents\python\orc-order-v2\data\temp +2025-05-10 12:34:08,596 - app.core.ocr.table_ocr - INFO - 允许的文件类型: ['.jpg', '.jpeg', '.png', '.bmp'] +2025-05-10 12:34:08,596 - app.core.ocr.table_ocr - INFO - 初始化OCRProcessor完成:输入目录=data/input, 输出目录=data/output +2025-05-10 12:34:08,620 - app.core.ocr.table_ocr - INFO - 找到 1 个图片文件,其中 1 个未处理 +2025-05-10 12:34:08,621 - app.core.ocr.table_ocr - INFO - 处理批次 1/1: 1 个文件 +2025-05-10 12:34:08,628 - app.core.ocr.table_ocr - INFO - 开始处理图片: data/input\微信图片_20250509142700.jpg +2025-05-10 12:34:15,445 - app.core.ocr.table_ocr - ERROR - OCR识别失败: data/input\微信图片_20250509142700.jpg +2025-05-10 12:34:15,445 - app.core.ocr.table_ocr - INFO - 所有图片处理完成, 总计: 1, 成功: 0 +2025-05-10 12:47:25,093 - app.core.ocr.table_ocr - INFO - 使用输入目录: D:\My Documents\python\orc-order-v2\data\input +2025-05-10 12:47:25,093 - app.core.ocr.table_ocr - INFO - 使用输出目录: D:\My Documents\python\orc-order-v2\data\output +2025-05-10 12:47:25,093 - app.core.ocr.table_ocr - INFO - 使用临时目录: D:\My Documents\python\orc-order-v2\data\temp +2025-05-10 12:47:25,093 - app.core.ocr.table_ocr - INFO - 允许的文件类型: ['.jpg', '.jpeg', '.png', '.bmp'] +2025-05-10 12:47:25,094 - app.core.ocr.table_ocr - INFO - 初始化OCRProcessor完成:输入目录=data/input, 输出目录=data/output +2025-05-10 12:47:25,098 - app.core.ocr.table_ocr - INFO - 找到 1 个图片文件,其中 1 个未处理 +2025-05-10 12:47:25,098 - app.core.ocr.table_ocr - INFO - 处理批次 1/1: 1 个文件 +2025-05-10 12:47:25,102 - app.core.ocr.table_ocr - INFO - 开始处理图片: data/input\微信图片_20250509142700.jpg +2025-05-10 12:47:26,679 - app.core.ocr.table_ocr - INFO - 图片处理成功: data/input\微信图片_20250509142700.jpg, 输出文件: data/output\微信图片_20250509142700.xlsx +2025-05-10 12:47:26,683 - app.core.ocr.table_ocr - INFO - 所有图片处理完成, 总计: 1, 成功: 1 +2025-05-10 12:50:31,801 - app.core.ocr.table_ocr - INFO - 使用输入目录: D:\My Documents\python\orc-order-v2\data\input +2025-05-10 12:50:31,801 - app.core.ocr.table_ocr - INFO - 使用输出目录: D:\My Documents\python\orc-order-v2\data\output +2025-05-10 12:50:31,801 - app.core.ocr.table_ocr - INFO - 使用临时目录: D:\My Documents\python\orc-order-v2\data\temp +2025-05-10 12:50:31,802 - app.core.ocr.table_ocr - INFO - 允许的文件类型: ['.jpg', '.jpeg', '.png', '.bmp'] +2025-05-10 12:50:31,802 - app.core.ocr.table_ocr - INFO - 初始化OCRProcessor完成:输入目录=data/input, 输出目录=data/output +2025-05-10 12:50:31,807 - app.core.ocr.table_ocr - INFO - 找到 1 个图片文件,其中 0 个未处理 +2025-05-10 12:50:31,807 - app.core.ocr.table_ocr - WARNING - 没有需要处理的图片 +2025-05-10 12:54:52,735 - app.core.ocr.table_ocr - INFO - 使用输入目录: D:\My Documents\python\orc-order-v2\data\input +2025-05-10 12:54:52,735 - app.core.ocr.table_ocr - INFO - 使用输出目录: D:\My Documents\python\orc-order-v2\data\output +2025-05-10 12:54:52,735 - app.core.ocr.table_ocr - INFO - 使用临时目录: D:\My Documents\python\orc-order-v2\data\temp +2025-05-10 12:54:52,736 - app.core.ocr.table_ocr - INFO - 允许的文件类型: ['.jpg', '.jpeg', '.png', '.bmp'] +2025-05-10 12:54:52,737 - app.core.ocr.table_ocr - INFO - 初始化OCRProcessor完成:输入目录=data/input, 输出目录=data/output +2025-05-10 12:54:52,743 - app.core.ocr.table_ocr - INFO - 找到 1 个图片文件,其中 0 个未处理 +2025-05-10 12:54:52,743 - app.core.ocr.table_ocr - WARNING - 没有需要处理的图片 diff --git a/logs/app.core.utils.file_utils.active b/logs/app.core.utils.file_utils.active index 122d54b..26dd9c1 100644 --- a/logs/app.core.utils.file_utils.active +++ b/logs/app.core.utils.file_utils.active @@ -1 +1 @@ -Active since: 2025-05-10 12:29:39 \ No newline at end of file +Active since: 2025-05-10 12:54:51 \ No newline at end of file diff --git a/logs/app.services.ocr_service.active b/logs/app.services.ocr_service.active index 28d2b0e..26dd9c1 100644 --- a/logs/app.services.ocr_service.active +++ b/logs/app.services.ocr_service.active @@ -1 +1 @@ -Active since: 2025-05-10 12:29:40 \ No newline at end of file +Active since: 2025-05-10 12:54:51 \ No newline at end of file diff --git a/logs/app.services.ocr_service.log b/logs/app.services.ocr_service.log index 6003b95..4d3cb00 100644 --- a/logs/app.services.ocr_service.log +++ b/logs/app.services.ocr_service.log @@ -300,3 +300,19 @@ 2025-05-10 11:55:16,272 - app.services.ocr_service - INFO - OCRService初始化完成 2025-05-10 11:55:16,272 - app.services.ocr_service - INFO - OCRService.batch_process被调用,转发到process_images_batch 2025-05-10 11:55:16,272 - app.services.ocr_service - INFO - OCRService开始批量处理图片, batch_size=5, max_workers=4 +2025-05-10 12:34:08,593 - app.services.ocr_service - INFO - 初始化OCRService +2025-05-10 12:34:08,596 - app.services.ocr_service - INFO - OCRService初始化完成 +2025-05-10 12:34:08,607 - app.services.ocr_service - INFO - OCRService.batch_process被调用,转发到process_images_batch +2025-05-10 12:34:08,607 - app.services.ocr_service - INFO - OCRService开始批量处理图片, batch_size=None, max_workers=None +2025-05-10 12:47:25,091 - app.services.ocr_service - INFO - 初始化OCRService +2025-05-10 12:47:25,094 - app.services.ocr_service - INFO - OCRService初始化完成 +2025-05-10 12:47:25,097 - app.services.ocr_service - INFO - OCRService.batch_process被调用,转发到process_images_batch +2025-05-10 12:47:25,097 - app.services.ocr_service - INFO - OCRService开始批量处理图片, batch_size=None, max_workers=None +2025-05-10 12:50:31,800 - app.services.ocr_service - INFO - 初始化OCRService +2025-05-10 12:50:31,803 - app.services.ocr_service - INFO - OCRService初始化完成 +2025-05-10 12:50:31,806 - app.services.ocr_service - INFO - OCRService.batch_process被调用,转发到process_images_batch +2025-05-10 12:50:31,806 - app.services.ocr_service - INFO - OCRService开始批量处理图片, batch_size=None, max_workers=None +2025-05-10 12:54:52,733 - app.services.ocr_service - INFO - 初始化OCRService +2025-05-10 12:54:52,737 - app.services.ocr_service - INFO - OCRService初始化完成 +2025-05-10 12:54:52,742 - app.services.ocr_service - INFO - OCRService.batch_process被调用,转发到process_images_batch +2025-05-10 12:54:52,742 - app.services.ocr_service - INFO - OCRService开始批量处理图片, batch_size=None, max_workers=None diff --git a/logs/app.services.order_service.active b/logs/app.services.order_service.active index 9dd4f3a..0ba361d 100644 --- a/logs/app.services.order_service.active +++ b/logs/app.services.order_service.active @@ -1 +1 @@ -Active since: 2025-05-10 12:29:41 \ No newline at end of file +Active since: 2025-05-10 12:54:52 \ No newline at end of file diff --git a/logs/app.services.order_service.log b/logs/app.services.order_service.log index fe5a1bd..4d9ce2d 100644 --- a/logs/app.services.order_service.log +++ b/logs/app.services.order_service.log @@ -347,3 +347,12 @@ 2025-05-10 12:29:42,163 - app.services.order_service - INFO - 初始化OrderService 2025-05-10 12:29:42,169 - app.services.order_service - INFO - OrderService初始化完成 2025-05-10 12:29:42,169 - app.services.order_service - INFO - OrderService开始处理指定Excel文件: D:/My Documents/python/orc-order-v2/data/output/微信图片_20250509142624.xlsx +2025-05-10 12:34:08,597 - app.services.order_service - INFO - 初始化OrderService +2025-05-10 12:34:08,606 - app.services.order_service - INFO - OrderService初始化完成 +2025-05-10 12:47:25,094 - app.services.order_service - INFO - 初始化OrderService +2025-05-10 12:47:25,097 - app.services.order_service - INFO - OrderService初始化完成 +2025-05-10 12:50:31,803 - app.services.order_service - INFO - 初始化OrderService +2025-05-10 12:50:31,806 - app.services.order_service - INFO - OrderService初始化完成 +2025-05-10 12:54:52,737 - app.services.order_service - INFO - 初始化OrderService +2025-05-10 12:54:52,742 - app.services.order_service - INFO - OrderService初始化完成 +2025-05-10 12:54:52,744 - app.services.order_service - INFO - OrderService开始处理最新Excel文件 diff --git a/logs/app.services.tobacco_service.active b/logs/app.services.tobacco_service.active index 2912e4d..0ba361d 100644 --- a/logs/app.services.tobacco_service.active +++ b/logs/app.services.tobacco_service.active @@ -1 +1 @@ -Active since: 2025-05-10 12:29:42 \ No newline at end of file +Active since: 2025-05-10 12:54:52 \ No newline at end of file diff --git a/run.py b/run.py index 180bc97..f134b52 100644 --- a/run.py +++ b/run.py @@ -113,7 +113,7 @@ def main(): result = order_service.process_excel(args.input) else: # 处理最新文件 - result = order_service.process_latest_excel() + result = order_service.process_excel() return 0 if result else 1 elif args.command == 'merge': @@ -140,9 +140,10 @@ def main(): else: # 批量处理 total, success = ocr_service.batch_process() - if success == 0: - logger.error("OCR处理失败,没有成功处理任何文件") - return 1 + if total == 0: + logger.warning("没有找到需要处理的图片") + elif success == 0: + logger.warning("OCR处理没有成功处理任何新文件") excel_file = None # 批量处理不返回具体文件 # 2. Excel处理 @@ -151,7 +152,7 @@ def main(): result = order_service.process_excel(excel_file) else: # 处理最新的Excel文件 - result = order_service.process_latest_excel() + result = order_service.process_excel() if not result: logger.error("Excel处理失败") diff --git a/启动器.py b/启动器.py index 51eefb6..2f12bc9 100644 --- a/启动器.py +++ b/启动器.py @@ -22,12 +22,14 @@ import re from typing import Dict, List, Optional, Any # 导入自定义对话框工具 -from app.core.utils.dialog_utils import show_custom_dialog, show_barcode_mapping_dialog +from app.core.utils.dialog_utils import show_custom_dialog, show_barcode_mapping_dialog, show_config_dialog from app.core.excel.converter import UnitConverter +from app.config.settings import ConfigManager # 全局变量,用于跟踪任务状态 RUNNING_TASK = None THEME_MODE = "light" # 默认浅色主题 +config_manager = ConfigManager() # 创建配置管理器实例 # 定义浅色和深色主题颜色 THEMES = { @@ -888,13 +890,13 @@ def main(): row7 = tk.Frame(button_area) row7.pack(fill=tk.X, pady=button_pady) - # 统计报告按钮 + # 系统设置按钮 tk.Button( row7, - text="统计报告", + text="系统设置", width=button_width, height=button_height, - command=lambda: generate_stats_report(log_text) + command=lambda: show_config_dialog(root, config_manager) ).pack(side=tk.LEFT, padx=button_padx) # 条码映射编辑按钮 @@ -1211,99 +1213,6 @@ def show_tobacco_result_preview(returncode, output): f"显示预览时发生错误: {e}\n请检查日志了解详细信息。" ) -def generate_stats_report(log_widget): - """生成处理统计报告""" - try: - add_to_log(log_widget, "正在生成统计报告...\n", "info") - - # 分析处理记录 - stats = { - "ocr_processed": 0, - "ocr_success": 0, - "orders_processed": 0, - "total_amount": 0, - "success_rate": 0 - } - - # 读取历史记录文件 - processed_files = os.path.join("data/output", "processed_files.json") - merged_files = os.path.join("data/output", "merged_files.json") - - if os.path.exists(processed_files): - try: - with open(processed_files, 'r', encoding='utf-8') as f: - data = json.load(f) - stats["ocr_processed"] = len(data) - stats["ocr_success"] = sum(1 for item in data.values() if item.get("success", False)) - except Exception as e: - add_to_log(log_widget, f"读取OCR处理记录时出错: {str(e)}\n", "error") - - if os.path.exists(merged_files): - try: - with open(merged_files, 'r', encoding='utf-8') as f: - data = json.load(f) - stats["orders_processed"] = len(data) - except Exception as e: - add_to_log(log_widget, f"读取订单处理记录时出错: {str(e)}\n", "error") - - # 计算成功率 - if stats["ocr_processed"] > 0: - stats["success_rate"] = round((stats["ocr_success"] / stats["ocr_processed"]) * 100, 2) - - # 创建报告对话框 - report_dialog = tk.Toplevel() - report_dialog.title("处理统计报告") - report_dialog.geometry("500x400") - center_window(report_dialog) - - tk.Label(report_dialog, text="OCR订单处理统计报告", font=("Arial", 16, "bold")).pack(pady=10) - - # 显示统计数据 - stats_frame = tk.Frame(report_dialog) - stats_frame.pack(fill=tk.BOTH, expand=True, padx=20, pady=10) - - tk.Label(stats_frame, text=f"处理的图片总数: {stats['ocr_processed']}个", font=("Arial", 12)).pack(anchor=tk.W, pady=5) - tk.Label(stats_frame, text=f"成功处理的图片数: {stats['ocr_success']}个", font=("Arial", 12)).pack(anchor=tk.W, pady=5) - tk.Label(stats_frame, text=f"成功率: {stats['success_rate']}%", font=("Arial", 12)).pack(anchor=tk.W, pady=5) - tk.Label(stats_frame, text=f"处理的订单数: {stats['orders_processed']}个", font=("Arial", 12)).pack(anchor=tk.W, pady=5) - - # 分析文件目录情况 - input_dir = "data/input" - output_dir = "data/output" - - input_files_count = len([f for f in os.listdir(input_dir) if os.path.isfile(os.path.join(input_dir, f))]) if os.path.exists(input_dir) else 0 - output_files_count = len([f for f in os.listdir(output_dir) if os.path.isfile(os.path.join(output_dir, f))]) if os.path.exists(output_dir) else 0 - - tk.Label(stats_frame, text=f"输入目录文件数: {input_files_count}个", font=("Arial", 12)).pack(anchor=tk.W, pady=5) - tk.Label(stats_frame, text=f"输出目录文件数: {output_files_count}个", font=("Arial", 12)).pack(anchor=tk.W, pady=5) - - # 分析日志文件 - logs_dir = "logs" - log_files_count = len([f for f in os.listdir(logs_dir) if os.path.isfile(os.path.join(logs_dir, f))]) if os.path.exists(logs_dir) else 0 - - tk.Label(stats_frame, text=f"日志文件数: {log_files_count}个", font=("Arial", 12)).pack(anchor=tk.W, pady=5) - - # 附加信息 - recent_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") - - add_info_frame = tk.Frame(stats_frame, relief=tk.GROOVE, borderwidth=1) - add_info_frame.pack(fill=tk.X, pady=10) - - tk.Label(add_info_frame, text="系统信息", font=("Arial", 10, "bold")).pack(anchor=tk.W, padx=10, pady=5) - tk.Label(add_info_frame, text=f"报告生成时间: {recent_time}", font=("Arial", 10)).pack(anchor=tk.W, padx=10, pady=2) - tk.Label(add_info_frame, text=f"系统版本: v1.5", font=("Arial", 10)).pack(anchor=tk.W, padx=10, pady=2) - - # 按钮 - button_frame = tk.Frame(report_dialog) - button_frame.pack(pady=10) - - tk.Button(button_frame, text="确定", command=report_dialog.destroy).pack() - - add_to_log(log_widget, "统计报告已生成\n", "success") - except Exception as e: - add_to_log(log_widget, f"生成统计报告时出错: {str(e)}\n", "error") - messagebox.showerror("错误", f"生成统计报告时出错: {str(e)}") - def edit_barcode_mappings(log_widget): """编辑条码映射配置""" try: @@ -1350,9 +1259,6 @@ def bind_keyboard_shortcuts(root, log_widget, status_bar): # Ctrl+T - 处理烟草订单 root.bind('', lambda e: run_command_with_logging(["python", "run.py", "tobacco"], log_widget, status_bar, on_complete=show_tobacco_result_preview)) - # Ctrl+S - 统计报告 - root.bind('', lambda e: generate_stats_report(log_widget)) - # F5 - 刷新/清除缓存 root.bind('', lambda e: clean_cache(log_widget)) @@ -1381,9 +1287,7 @@ def show_shortcuts_help(): Ctrl+P: 完整处理流程 Ctrl+M: 合并采购单 Ctrl+T: 处理烟草订单 - Ctrl+S: 显示统计报告 F5: 清除处理缓存 - F1: 显示此帮助 Esc: 退出程序 """ diff --git a/更新日志.md b/更新日志.md index 141b2d8..9c18ea6 100644 --- a/更新日志.md +++ b/更新日志.md @@ -96,4 +96,66 @@ - 规格智能推断:从商品名称自动推断规格信息 - 日志管理:完善的日志记录系统,支持终端和GUI同步显示 - 表头智能识别:自动识别Excel中的表头位置,兼容多种格式 -- 改进用户体验:界面优化,批量处理支持,实时状态反馈 \ No newline at end of file +- 改进用户体验:界面优化,批量处理支持,实时状态反馈 + +## v1.5.1 (2024-03-21) +- 修复了配置管理相关的问题: + - 修复了`config.ini`文件被意外重置的问题 + - 优化了配置加载逻辑,确保保留现有配置值 + - 添加了配置缺失项自动补充功能 +- 新增系统设置功能: + - 添加了图形化配置设置界面 + - 支持API设置、路径设置、性能设置和文件设置 + - 所有设置更改实时保存 +- 移除了统计报告功能,替换为更实用的系统设置功能 +- 优化了用户界面和交互体验 + +## v1.5.0 (2024-03-20) +- 添加了统计与报告功能 +- 添加了键盘快捷键支持 +- 优化了用户界面 +- 删除了不必要的文件 +- 更新了README.md +- 创建了更新日志文档 + +## v1.4.0 (2024-03-19) +- 添加了自定义弹窗演示 +- 优化了错误处理 +- 改进了日志记录 + +## v1.3.0 (2024-03-18) +- 添加了条码映射功能 +- 优化了文件处理逻辑 +- 改进了用户界面 + +## v1.2.0 (2024-03-17) +- 添加了批量处理功能 +- 优化了性能 +- 改进了错误处理 + +## v1.1.0 (2024-03-16) +- 添加了Excel处理功能 +- 优化了OCR识别 +- 改进了用户界面 + +## v1.0.0 (2024-03-15) +- 初始版本发布 +- 基本OCR功能 +- 基本用户界面 + +## v1.5.2 (2024-03-21) +- 修复了方法名称不匹配的问题: + - 将`process_latest_excel`方法调用改为`process_excel` + - 确保Excel处理功能正常工作 +- 优化了错误处理和日志记录 + +## v1.5.3 (2024-03-21) +- 优化了完整流程处理逻辑: + - 修改了OCR处理逻辑,当遇到已处理的图片时自动跳过并继续执行 + - 改进了错误处理,避免因图片已处理而中断流程 + - 优化了日志提示信息,提供更清晰的处理状态反馈 +- 改进了OCRService的process_image方法: + - 添加了文件存在性检查 + - 添加了文件类型验证 + - 添加了已处理文件检查 + - 优化了错误处理和日志记录 \ No newline at end of file