Przeglądaj źródła

详情图抠图优化

rambo 5 miesięcy temu
rodzic
commit
86aea72216

+ 198 - 220
python/api.py

@@ -108,17 +108,28 @@ def fromExcelHandler(params: HandlerDetail):
     obj = None
     run_main = RunMain(obj, token)
     temp_class = {}
+    # 可用模板列表-需要导包
     temp_name_list = []
     for tempItem in params.temp_list:
         temp_class[tempItem.template_id] = tempItem.template_local_classes
         temp_name_list.append(tempItem.template_id)
+    # 抠图时用到的货号列表,与生成详情图有所区别
     goods_art_no_arrays = []
+    # # 详情图生成需要对同款商品进行分组,保证详情图可以生成多个色
+    goods_art_no_group_arrays = []
     for _, goods_row in excel_df.iterrows():
         goods_art_no = str(goods_row["商品货号"])
         goods_art_no_arrays.append(goods_art_no)
+        goods_no = str(goods_row["款号"])
+        a001_df = goods_art_dirs.get_group(goods_no)
+        goods_art_groups = a001_df["商品货号"].tolist()
+        if goods_art_groups in goods_art_no_group_arrays:
+            continue
+        goods_art_no_group_arrays.append(goods_art_groups)
     limit_path = "output/{}".format(
         time.strftime("%Y-%m-%d", time.localtime(time.time()))
     )
+    # 该数组表示是否需要后面的移动文件夹操作,减少重复抠图,提升抠图时间和速度
     move_folder_array = check_move_goods_art_no_folder(
         "output", goods_art_no_arrays, limit_path
     )
@@ -126,10 +137,6 @@ def fromExcelHandler(params: HandlerDetail):
         goods_art_no_image_dir = str(row["文件夹名称"])
         goods_art_no = str(row["商品货号"])
         print("货号数据", goods_art_no)
-        goods_no = str(row["款号"])
-        a001_df = goods_art_dirs.get_group(goods_no)
-        goods_art_nos = a001_df["商品货号"].tolist()
-        print("goods_art_nos", goods_art_nos)
         if not goods_art_no:
             raise UnicornException("货号不能为空")
         session = SqlQuery()
@@ -139,7 +146,9 @@ def fromExcelHandler(params: HandlerDetail):
             raise UnicornException("没有可用货号数据")
         # 货号目录不存在再去进行移动和创建操作
         if move_folder_array.get(goods_art_no) == None:
-            image_dir = "{}/data/{}".format(os.getcwd(), goods_no).replace("\\", "/")
+            image_dir = "{}/data/{}".format(os.getcwd(), goods_art_no).replace(
+                "\\", "/"
+            )
             check_path(image_dir)
             for itemImg in images:
                 if itemImg.image_path == "" or itemImg.image_path == None:
@@ -163,44 +172,46 @@ def fromExcelHandler(params: HandlerDetail):
                 raise UnicornException(path)
             shutil.rmtree(image_dir)
             # path = os.path.dirname(path)
+
+    config_data = {
+        "image_dir": limit_path,  # 这个目录作为本次生成的图片目录非常重要 例:./output/当前日期
+        "image_order": params.template_image_order,
+        "goods_art_no": goods_art_no,
+        "goods_art_nos": goods_art_no_arrays,
+        "is_check_number": False,
+        "resize_image_view": "后跟",
+        "cutout_mode": settings.CUTOUT_MODE,
+        "logo_path": params.logo_path,
+        "special_goods_art_no_folder_line": "",
+        "is_use_excel": (False if params.excel_path == "" else True),  # 是否使用excel
+        "excel_path": params.excel_path,  # excel路径
+        "is_check_color_is_all": False,
+        "cutout_is_pass": True,
+        "assigned_page_dict": {},
+        "detail_is_pass": True,
+        "upload_is_pass": False,
+        "upload_is_enable": False,
+        "is_filter": False,
+        "temp_class": temp_class,
+        "temp_name": params.temp_name,
+        "temp_name_list": temp_name_list,
+        "target_error_folder": f"{limit_path}/软件-生成详情错误",
+        "success_handler": [],
+    }
+    # 动态导入类
+    temp_class_dict = {}
+    for key, class_path in config_data["temp_class"].items():
+        module_path, class_name = class_path.rsplit(".", 1)
+        module = importlib.import_module(module_path)
+        cls = getattr(module, class_name)
+        temp_class_dict[key] = cls
+
+    config_data["temp_class"] = temp_class_dict
+    # 此处对抠图进行批量处理,保证所有的图片在生成详情图之前已经完成抠图,以保证详情图生成的效率
+    return_data = run_main.check_before_cutout(config_data)
+    cutout_res = run_main.check_for_cutout_image_first_call_back(return_data)
+    check_for_detail_first_res = None
     try:
-        config_data = {
-            "image_dir": limit_path,  # 这个目录作为本次生成的图片目录非常重要 例:./output/当前日期
-            "image_order": params.template_image_order,
-            "goods_art_no": goods_art_no,
-            "goods_art_nos": goods_art_no_arrays,
-            "is_check_number": False,
-            "resize_image_view": "后跟",
-            "cutout_mode": settings.CUTOUT_MODE,
-            "logo_path": params.logo_path,
-            "special_goods_art_no_folder_line": "",
-            "is_use_excel": (False if params.excel_path == "" else True),  # 是否使用excel
-            "excel_path": params.excel_path,  # excel路径
-            "is_check_color_is_all": False,
-            "cutout_is_pass": True,
-            "assigned_page_dict": {},
-            "detail_is_pass": True,
-            "upload_is_pass": False,
-            "upload_is_enable": False,
-            "is_filter": False,
-            "temp_class": temp_class,
-            "temp_name": params.temp_name,
-            "temp_name_list": temp_name_list,
-            "target_error_folder": f"{limit_path}/软件-生成详情错误",
-        }
-        # 动态导入类
-        temp_class_dict = {}
-        for key, class_path in config_data["temp_class"].items():
-            module_path, class_name = class_path.rsplit(".", 1)
-            module = importlib.import_module(module_path)
-            cls = getattr(module, class_name)
-            temp_class_dict[key] = cls
-
-        config_data["temp_class"] = temp_class_dict
-        # 此处对抠图进行批量处理,保证所有的图片在生成详情图之前已经完成抠图,以保证详情图生成的效率
-        return_data = run_main.check_before_cutout(config_data)
-        cutout_res = run_main.check_for_cutout_image_first_call_back(return_data)
-        check_for_detail_first_res = None
         if cutout_res:
             return_data_check_before_detail = run_main.check_before_detail(config_data)
             check_for_detail_first_res = run_main.check_for_detail_first_call_back(
@@ -213,7 +224,6 @@ def fromExcelHandler(params: HandlerDetail):
             except:
                 config_data = result
         if config_data["sign_text"] == "已结束详情处理":
-            # at_pic = AutoDealPics()
             print("config_data", config_data)
             if config_data["upload_is_enable"]:
                 to_deal_dir = "{}/软件-详情图生成".format(config_data["image_dir"])
@@ -228,18 +238,26 @@ def fromExcelHandler(params: HandlerDetail):
                     )
                     upload_pic.run()
             out_put_dir = config_data["out_put_dir"]
-            out_put_dir_path = "{}/{}".format(os.getcwd(), out_put_dir).replace("\\", "/")
-            handler_result_folder = os.path.dirname(out_put_dir_path)
-            handler_result.append(
-                {"goods_art_no": goods_art_no, "success": True, "info": "处理成功"}
+            out_put_dir_path = "{}/{}".format(os.getcwd(), out_put_dir).replace(
+                "\\", "/"
             )
+            handler_result_folder = os.path.dirname(out_put_dir_path)
+            if len(config_data["success_handler"])==0:
+                for good_art in goods_art_no_arrays:
+                    handler_result.append(
+                        {"goods_art_no": good_art, "success": False, "info": "处理失败"}
+                    )
+            else:
+                handler_result = config_data["success_handler"]
         else:
-            handler_result.append(
-                {"goods_art_no": goods_art_no, "success": False, "info": "处理失败"}
-            )
+            for good_art in goods_art_no_arrays:
+                handler_result.append(
+                    {"goods_art_no": good_art, "success": False, "info": "处理失败"}
+                )
     except Exception as e:
-        handler_result.append(
-                {"goods_art_no": goods_art_no, "success": False, "info": str(e)}
+        for good_art in goods_art_no_arrays:
+            handler_result.append(
+                {"goods_art_no": good_art, "success": False, "info": str(e)}
             )
     handler_result_folder = "/".join(handler_result_folder.split("/")[:-1])
     return {
@@ -266,38 +284,41 @@ async def handle_detail(request: Request, params: HandlerDetail):
     obj = None
     token = "Bearer " + params.token
     run_main = RunMain(obj, token)
-    goods_art_no_array = params.goods_art_no
+    goods_art_no_arrays = params.goods_art_no
     is_only_cutout = params.is_only_cutout
     handler_result = []
     handler_result_folder = ""
     if params.excel_path != "" and params.excel_path != None:
         return fromExcelHandler(params)
-    goods_art_list = run_main.data_mode_generate_detail.get_goods_art_no_info(
-        goods_art_list=goods_art_no_array
-    )
-    goods_art_nos = []
-    # for goods_no_values in goods_art_list_dict.values():
-    #     if goods_art_no in goods_no_values:
-    #         goods_art_nos = goods_no_values
-    #         break
-    goods_art_list_dict = group_by_style_number(goods_art_list)
+    # goods_art_list = run_main.data_mode_generate_detail.get_goods_art_no_info(
+    #     goods_art_list=goods_art_no_arrays
+    # )
+    # goods_art_nos = []
+    # goods_art_list_dict = group_by_style_number(goods_art_list)
     path = ""
-    for goods_art_no in goods_art_no_array:
-        try:
-            if not goods_art_no:
-                raise UnicornException("货号不能为空")
-            session = SqlQuery()
-            pr = CRUD(PhotoRecord)
-            images = pr.read_all(session, conditions={"goods_art_no": goods_art_no})
-            if not images:
-                raise UnicornException("没有可用货号数据")
-            if is_only_cutout != 1:
-                detail_counts = len(params.template_image_order.split(","))
-                image_counts = len(images)
-                if image_counts < detail_counts:
-                    raise UnicornException(
-                        f"货号:[{goods_art_no}],实际照片数量:{image_counts}张,小于详情图要求数量:{detail_counts}张"
-                    )
+    limit_path = "output/{}".format(
+        time.strftime("%Y-%m-%d", time.localtime(time.time()))
+    )
+    # 该数组表示是否需要后面的移动文件夹操作,减少重复抠图,提升抠图时间和速度
+    move_folder_array = check_move_goods_art_no_folder(
+        "output", goods_art_no_arrays, limit_path
+    )
+    for goods_art_no in goods_art_no_arrays:
+        if not goods_art_no:
+            raise UnicornException("货号不能为空")
+        session = SqlQuery()
+        pr = CRUD(PhotoRecord)
+        images = pr.read_all(session, conditions={"goods_art_no": goods_art_no})
+        if not images:
+            raise UnicornException("没有可用货号数据")
+        if is_only_cutout != 1:
+            detail_counts = len(params.template_image_order.split(","))
+            image_counts = len(images)
+            if image_counts < detail_counts:
+                raise UnicornException(
+                    f"货号:[{goods_art_no}],实际照片数量:{image_counts}张,小于详情图要求数量:{detail_counts}张"
+                )
+        if move_folder_array.get(goods_art_no) == None:
             image_dir = "{}/data/".format(os.getcwd()).replace("\\", "/")
             check_path(image_dir)
             for itemImg in images:
@@ -318,71 +339,65 @@ async def handle_detail(request: Request, params: HandlerDetail):
             )
             if not resFlag:
                 raise UnicornException(path)
-            temp_class = {}
-            temp_name_list = []
-            for tempItem in params.temp_list:
-                temp_class[tempItem.template_id] = tempItem.template_local_classes
-                temp_name_list.append(tempItem.template_id)
-            config_data = {
-                "image_dir": path,
-                "image_order": (
-                    "俯视,侧视,后跟,鞋底,内里"
-                    if params.template_image_order == None
-                    or params.template_image_order == ""
-                    else params.template_image_order
-                ),
-                "goods_art_no": goods_art_no,
-                "goods_art_nos": (
-                    goods_art_nos if len(goods_art_nos) > 0 else [goods_art_no]
-                ),
-                "is_check_number": False,
-                "resize_image_view": "后跟",
-                "cutout_mode": settings.CUTOUT_MODE,
-                "logo_path": params.logo_path,
-                "special_goods_art_no_folder_line": "",
-                "is_use_excel": (
-                    False if params.excel_path == "" else True
-                ),  # 是否使用excel
-                "excel_path": params.excel_path,  # excel路径
-                "is_check_color_is_all": False,
-                "cutout_is_pass": True,
-                "assigned_page_dict": {},
-                "detail_is_pass": True,
-                "upload_is_pass": False,
-                "upload_is_enable": True,
-                "is_filter": False,
-                "temp_class": temp_class,
-                "temp_name": params.temp_name,
-                "temp_name_list": temp_name_list,
-                "target_error_folder": f"{path}/软件-生成详情错误",
-            }
-            print("image_dir=====>>>>>", config_data["image_dir"])
-            # 动态导入类
-            temp_class_dict = {}
-            for key, class_path in config_data["temp_class"].items():
-                module_path, class_name = class_path.rsplit(".", 1)
-                module = importlib.import_module(module_path)
-                cls = getattr(module, class_name)
-                temp_class_dict[key] = cls
-
-            config_data["temp_class"] = temp_class_dict
-            return_data = run_main.check_before_cutout(config_data)
-            cutout_res = run_main.check_for_cutout_image_first_call_back(return_data)
-            check_for_detail_first_res = None
-            if cutout_res == True:
-                out_put_dir = return_data["data"]["image_dir"] + "/" + goods_art_no
-                out_put_dir_path = "{}/{}".format(os.getcwd(), out_put_dir).replace(
-                    "\\", "/"
-                )
-                # print("out_put_dir_path", out_put_dir_path)
-                handler_result_folder = os.path.dirname(out_put_dir_path)
-                handler_result.append(
-                    {"goods_art_no": goods_art_no, "success": True, "info": "处理成功"}
-                )
-                # print("检测到需要裁剪图片,开始裁剪图片", return_data)
-        except Exception as e:
+    # try:
+    temp_class = {}
+    temp_name_list = []
+    for tempItem in params.temp_list:
+        temp_class[tempItem.template_id] = tempItem.template_local_classes
+        temp_name_list.append(tempItem.template_id)
+    config_data = {
+        "image_dir": limit_path,
+        "image_order": (
+            "俯视,侧视,后跟,鞋底,内里"
+            if params.template_image_order == None
+            or params.template_image_order == ""
+            else params.template_image_order
+        ),
+        "goods_art_no": "",
+        "goods_art_nos": goods_art_no_arrays,
+        "is_check_number": False,
+        "resize_image_view": "后跟",
+        "cutout_mode": settings.CUTOUT_MODE,
+        "logo_path": params.logo_path,
+        "special_goods_art_no_folder_line": "",
+        "is_use_excel": False,  # 是否使用excel
+        "excel_path": "",  # excel路径
+        "is_check_color_is_all": False,
+        "cutout_is_pass": True,
+        "assigned_page_dict": {},
+        "detail_is_pass": True,
+        "upload_is_pass": False,
+        "upload_is_enable": settings.IS_UPLOAD_HLM,  # 是否上传到惠利玛商品库,通过config.ini得is_upload开启
+        "is_filter": False,
+        "temp_class": temp_class,
+        "temp_name": params.temp_name,
+        "temp_name_list": temp_name_list,
+        "target_error_folder": f"{limit_path}/软件-生成详情错误",
+        "success_handler": [],
+    }
+    print("image_dir=====>>>>>", config_data["image_dir"])
+    # 动态导入类
+    temp_class_dict = {}
+    for key, class_path in config_data["temp_class"].items():
+        module_path, class_name = class_path.rsplit(".", 1)
+        module = importlib.import_module(module_path)
+        cls = getattr(module, class_name)
+        temp_class_dict[key] = cls
+
+    config_data["temp_class"] = temp_class_dict
+    return_data = run_main.check_before_cutout(config_data)
+    cutout_res = run_main.check_for_cutout_image_first_call_back(return_data)
+    check_for_detail_first_res = None
+    if cutout_res == True:
+        sys_path = format(os.getcwd()).replace("\\", "/")
+        handler_result_folder = f"{sys_path}/{limit_path}"
+        for goods_art_item in goods_art_no_arrays:
             handler_result.append(
-                {"goods_art_no": goods_art_no, "success": False, "info": str(e)}
+                {
+                    "goods_art_no": goods_art_item,
+                    "success": True,
+                    "info": "处理成功",
+                }
             )
     if is_only_cutout == 1:
         return {
@@ -392,90 +407,53 @@ async def handle_detail(request: Request, params: HandlerDetail):
         }
     handler_result = []
     try:
-        for goods_art_no_arr in goods_art_list_dict.values():
-            temp_class = {}
-            temp_name_list = []
-            for tempItem in params.temp_list:
-                temp_class[tempItem.template_id] = tempItem.template_local_classes
-                temp_name_list.append(tempItem.template_id)
-            config_data = {
-                "image_dir": path,
-                "image_order": (
-                    "俯视,侧视,后跟,鞋底,内里"
-                    if params.template_image_order is None
-                    or params.template_image_order == ""
-                    else params.template_image_order
-                ),
-                "goods_art_no": "",
-                "goods_art_nos": goods_art_no_arr,
-                "is_check_number": False,
-                "resize_image_view": "后跟",
-                "cutout_mode": settings.CUTOUT_MODE,
-                "logo_path": params.logo_path,
-                "special_goods_art_no_folder_line": "",
-                "is_use_excel": (
-                    False if params.excel_path == "" else True
-                ),  # 是否使用excel
-                "excel_path": params.excel_path,  # excel路径
-                "is_check_color_is_all": False,
-                "cutout_is_pass": True,
-                "assigned_page_dict": {},
-                "detail_is_pass": True,
-                "upload_is_pass": False,
-                "upload_is_enable": True,
-                "is_filter": False,
-                "temp_class": temp_class,
-                "temp_name": params.temp_name,
-                "temp_name_list": temp_name_list,
-                "target_error_folder": f"{path}/软件-生成详情错误",
-            }
-            # 动态导入类
-            temp_class_dict = {}
-            for key, class_path in config_data["temp_class"].items():
-                module_path, class_name = class_path.rsplit(".", 1)
-                module = importlib.import_module(module_path)
-                cls = getattr(module, class_name)
-                temp_class_dict[key] = cls
-
-            config_data["temp_class"] = temp_class_dict
-            return_data_check_before_detail = run_main.check_before_detail(config_data)
-            check_for_detail_first_res = run_main.check_for_detail_first_call_back(
-                return_data_check_before_detail
-            )
-            if isinstance(check_for_detail_first_res, partial):
-                result = check_for_detail_first_res()
-                try:
-                    config_data = result["config_data"]
-                except:
-                    config_data = result
-            if config_data["sign_text"] == "已结束详情处理":
-                # at_pic = AutoDealPics()
-                print("config_data", config_data)
-                if config_data["upload_is_enable"]:
-                    to_deal_dir = "{}/软件-详情图生成".format(config_data["image_dir"])
-                    check_path(to_deal_dir)
-                    print("to_deal_dir", to_deal_dir)
-                    if os.path.exists(to_deal_dir):
-                        upload_pic = UploadPic(
-                            windows=None,
-                            to_deal_dir=to_deal_dir,
-                            config_data=config_data,
-                            token=token,
-                        )
-                        upload_pic.run()
-                out_put_dir = config_data["out_put_dir"]
+        return_data_check_before_detail = run_main.check_before_detail(config_data)
+        check_for_detail_first_res = run_main.check_for_detail_first_call_back(
+            return_data_check_before_detail
+        )
+        if isinstance(check_for_detail_first_res, partial):
+            result = check_for_detail_first_res()
+            try:
+                config_data = result["config_data"]
+            except:
+                config_data = result
+        if config_data["sign_text"] == "已结束详情处理":
+            # at_pic = AutoDealPics()
+            print("config_data", config_data)
+            # if config_data["upload_is_enable"]:
+            #     to_deal_dir = "{}/软件-详情图生成".format(config_data["image_dir"])
+            #     check_path(to_deal_dir)
+            #     print("to_deal_dir", to_deal_dir)
+            #     if os.path.exists(to_deal_dir):
+            #         upload_pic = UploadPic(
+            #             windows=None,
+            #             to_deal_dir=to_deal_dir,
+            #             config_data=config_data,
+            #             token=token,
+            #         )
+            #         upload_pic.run()
+            out_put_dir = config_data.get("out_put_dir")
+            if out_put_dir:
                 out_put_dir_path = "{}/{}".format(os.getcwd(), out_put_dir).replace(
                     "\\", "/"
                 )
                 handler_result_folder = os.path.dirname(out_put_dir_path)
-                handler_result.append(
-                    {"goods_art_no": "", "success": True, "info": "处理成功"}
-                )
             else:
-                handler_result.append(
-                    {"goods_art_no": "", "success": False, "info": "处理失败"}
-                )
+                handler_result_folder = ""
+            if len(config_data["success_handler"]) == 0:
+                for good_art in goods_art_no_arrays:
+                    handler_result.append(
+                        {"goods_art_no": good_art, "success": False, "info": "处理失败"}
+                    )
+            else:
+                handler_result = config_data["success_handler"]
+        else:
+            handler_result.append(
+                {"goods_art_no": "", "success": False, "info": "处理失败"}
+            )
     except Exception as e:
+        print(e.__traceback__.tb_frame.f_globals["__file__"])   # 发生异常所在的文件
+        print(e.__traceback__.tb_lineno)                        # 发生异常所在的行数
         handler_result.append({"goods_art_no": "", "success": False, "info": str(e)})
     return {
         "code": 0,

+ 1 - 0
python/config.ini

@@ -14,6 +14,7 @@ env=dev
 # 线程数
 works=3
 project=惠利玛
+is_upload=true
 [log]
 # 日志相关
 log_file_name=app.log

+ 15 - 7
python/service/auto_deal_pics/upload_pic.py

@@ -226,7 +226,18 @@ class UploadPic():
         # 上传所有图片
         self.pic_data = {}
         ignore_text = ["main", "拼接图", "货号素材"]
-        _Type = ['.png', '.PNG', '.jpg', '.JPG', '.gif', '.GIF']
+        _Type = [
+            ".png",
+            ".PNG",
+            ".jpg",
+            ".JPG",
+            ".gif",
+            ".GIF",
+            ".webp",
+            ".WEBP",
+            ".AVIF",
+            ".avif",
+        ]
         for dirpath, dirnames, filenames in os.walk(goods_no_path):
             for file in filenames:
                 if os.path.splitext(file)[1] in _Type:
@@ -241,9 +252,9 @@ class UploadPic():
                         print(f_path)
                         f_path = f_path.replace("\\", "/")
                         self.pic_data[f_path] = {"url": ""}
-
-        with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
-            for key in self.pic_data:
+        print("上传完成......................!!!!!!!!!!!!!!!!!!!")
+        # with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
+        for key in self.pic_data:
                 if "货号素材" in key:
                     # 货号素材图不上传
                     is_resize = False
@@ -252,7 +263,6 @@ class UploadPic():
                     is_resize = True
                 # executor.submit(self.to_upload_pic, file_path=key, is_resize=is_resize)
                 self.to_upload_pic(file_path=key, is_resize=is_resize)
-
         for key in self.pic_data:
             if "货号素材" in key:
                 is_resize = False
@@ -261,7 +271,6 @@ class UploadPic():
             if not self.pic_data[key]["url"]:
                 self.show_info("{} {} 图片未上传完成".format(key, goods_no))
                 raise UnicornException("{} {} 图片未上传完成".format(key, goods_no))
-                return
 
         up_data = {"goods_art_no": [],
                    "details": [],
@@ -398,7 +407,6 @@ class UploadPic():
              "PNG": "PNG", }
         e = _[e]
         image_io = im.save_to_io(e)
-
         # if is_resize:
         #     im = Picture(file_path)
         #     if im.x > 1200:

+ 6 - 3
python/service/base.py

@@ -230,16 +230,19 @@ def check_move_goods_art_no_folder(path, goods_art_nos,limit_folder):
     """
     folder_list = {}
     if not os.path.exists(path):
+        print("path不存在", path)
         return folder_list
     if os.path.isfile(path):
+        print("path是文件", path)
         return folder_list
     temp_folder_list = get_folder(path)
     for goods_art_no in goods_art_nos:
         for folder_data in temp_folder_list:
-            folder_path = folder_data["folder_path"]
-            _p = "{}/{}/原始图".format(folder_path, goods_art_no)
+            # folder_path = folder_data["folder_path"]
+            folder_name = folder_data["folder_name"]
+            _p = "output/{}/{}/原始图".format(folder_name, goods_art_no)
             if os.path.exists(_p):
-                folder_data["folder_path"] = f"{folder_path}/{goods_art_no}"
+                folder_data["folder_path"] = f"output/{folder_name}/{goods_art_no}"
                 # 整个目录移动到目标目录
                 folder_list[goods_art_no] = folder_data
                 if not os.path.exists(f"{limit_folder}/{goods_art_no}"):

+ 53 - 36
python/service/run_main.py

@@ -459,6 +459,13 @@ class RunMain():
                 return_data["message"] += "文件夹:{} 找不到对应数据\n".format(
                     one_folder
                 )
+                return_data["data"]["config_data"]["success_handler"].append(
+                    {
+                        "goods_art_no": one_folder,
+                        "success": True,
+                        "info":f"文件夹:{one_folder} 找不到对应数据",
+                    }
+                )
 
         print("===============goods_no_dict==================")
         if settings.IS_TEST:
@@ -592,7 +599,20 @@ class RunMain():
                         # output/2025-04-03/软件-详情图生成/huilima-2/AQN141132
                         return_data["data"]["config_data"]["out_put_dir"] = _path
                         if detail_is_pass:
-                            return_data["message"] += "\n款号:{},模板:{} 已存在".format(goods_no, __temp_name)
+                            return_data[
+                                "message"
+                            ] += "\n款号:{},模板:{} 已存在".format(
+                                goods_no, __temp_name
+                            )
+                            return_data["data"]["config_data"][
+                                "success_handler"
+                            ].append(
+                                {
+                                    "goods_art_no": goods_no,
+                                    "success": True,
+                                    "info": "处理成功",
+                                }
+                            )
                         else:
                             if goods_no not in finally_goods_no_need_temps:
                                 finally_goods_no_need_temps[goods_no] = []
@@ -600,24 +620,6 @@ class RunMain():
                             finally_goods_no_need_temps[goods_no].append(__temp_name)
 
             pass
-            # _path = "{}/{}".format(self.image_dir, "软件-详情图生成")
-            # if os.path.exists(_path):
-            #     _goods_no_dict = {}
-            #     # 数据返回为 已有的款数据,为款号列表
-            #     is_pass_goods_no = detail_func.get_all_detail_info(_path)
-            #     for goods_no, value in goods_no_dict.items():
-            #         if "软件" in goods_no:
-            #             continue
-            #
-            #         if value["模板名称"] in assigned_page_dict:
-            #             need_todo = True
-            #         else:
-            #             if goods_no in is_pass_goods_no:
-            #                 need_todo = False
-            #             else:
-            #                 need_todo = True
-            #         if need_todo:
-            #             _goods_no_dict[goods_no] = value
 
         print("-----------------2goods_no_dict---------------")
         print(json.dumps(_goods_no_dict, ensure_ascii=False))
@@ -767,8 +769,8 @@ class RunMain():
         all_detail_path_list = []
         out_put_dir_resp = ""
         for goods_no, temp_name_list in finally_goods_no_need_temps.items():
-            try:
-                for _temp_name in temp_name_list:
+            for _temp_name in temp_name_list:
+                try:
                     # if _temp_name != "xiaosushuoxie-4":
                     #     continue
                     assigned_page_list = []
@@ -786,25 +788,40 @@ class RunMain():
                                         temp_info_data[_key] = _key_value
                     print("goods_no:{},_temp_name:{}".format(goods_no, _temp_name))
                     out_put_dir_resp = "{}/{}/{}".format(
-                        out_put_dir, _temp_name, goods_no
-                    )
+                            out_put_dir, _temp_name, goods_no
+                        )
                     all_detail_path_list.append("{}/{}/{}".format(out_put_dir, _temp_name, goods_no))
                     # continue
                     self.detail_deal_one_data(
-                        goods_no=goods_no,
-                        value=temp_info_data,
-                        out_put_dir=out_put_dir,
-                        temp_name=_temp_name,
-                        assigned_page_list=assigned_page_list,
-                        temp_class=config_data["temp_class"],
-                        target_error_folder=config_data["target_error_folder"],
-                        image_dir=config_data["image_dir"],
+                            goods_no=goods_no,
+                            value=temp_info_data,
+                            out_put_dir=out_put_dir,
+                            temp_name=_temp_name,
+                            assigned_page_list=assigned_page_list,
+                            temp_class=config_data["temp_class"],
+                            target_error_folder=config_data["target_error_folder"],
+                            image_dir=config_data["image_dir"],
+                        )
+                    config_data["success_handler"].append(
+                            {"goods_art_no": goods_no, "success": True, "info": "处理成功"}
+                        )
+                except BaseException as e:
+                    self.show_progress_detail(
+                            {
+                                "goods_art_no": goods_no,
+                                "success": False,
+                                "info": "款:{}生成详情异常:{}".format(goods_no, e),
+                            }
+                        )
+                    print(e)
+                    # raise UnicornException("款:{}生成详情异常:{}".format(goods_no, e))
+                    config_data["success_handler"].append(
+                        {
+                            "goods_art_no": goods_no,
+                            "success": False,
+                            "info": "款:{}生成详情异常:{}".format(goods_no, e),
+                        }
                     )
-            except BaseException as e:
-                self.show_progress_detail(
-                    "款:{}生成详情异常:{}".format(goods_no, e))
-                print(e)
-                raise UnicornException("款:{}生成详情异常:{}".format(goods_no, e))
 
         # ==============完成处理==============
         self.set_state(state_value=2)

+ 1 - 0
python/settings.py

@@ -123,6 +123,7 @@ APP_NAME = config.get("app", "app_name")
 APP_VERSION = config.get("app", "version")
 # 是否开启调试模式
 IS_DEBUG = config.get("app", "debug")
+IS_UPLOAD_HLM = True if config.get("app", "is_upload") == "true" else False
 # 应用端口号
 PORT = config.get("app", "port")
 # 应用线程数