Explorar o código

详情页需求处理

rambo hai 1 mes
pai
achega
baf7124014
Modificáronse 2 ficheiros con 10 adicións e 5 borrados
  1. 2 5
      python/api.py
  2. 8 0
      python/service/customer_template_service.py

+ 2 - 5
python/api.py

@@ -291,7 +291,6 @@ async def process_handle_detail(request: Request, params: HandlerDetail):
         # 检查处理结果
         success_handler = return_data_check_before_detail.get("data", {}).get("config_data", {}).get("success_handler", [])
         failed_items = [item for item in success_handler if item.get('success') == False]
-        
         if failed_items:
             await sendAsyncMessage(
                 msg="处理结束",
@@ -540,7 +539,6 @@ async def _process_cutout(run_main, config_data, goods_art_no_arrays, move_folde
         )
     return_data = run_main.check_before_cutout(config_data)
     cutout_res = run_main.check_for_cutout_image_first_call_back(return_data)
-    
     if cutout_res:
         # sys_path = format(os.getcwd()).replace("\\", "/")
         handler_result_folder = f"{config_data['image_dir']}"
@@ -552,7 +550,7 @@ async def _process_cutout(run_main, config_data, goods_art_no_arrays, move_folde
                 "info": "处理成功",
             })
             
-    if len(have_handler_keys) == len(goods_art_no_arrays):
+    if len(have_handler_keys) == len(goods_art_no_arrays) or (len(have_handler_keys) == 0  and cutout_res):
         handler_result_folder = handler_result_folder.replace("\\", "/")
         success_items = [item for item in handler_result if item.get('success') == True]
         cutout_folder = handler_result_folder+"/"+success_items[0].get("goods_art_no")+"/800x800" if len(success_items) > 0 else ""
@@ -570,7 +568,6 @@ async def _process_cutout(run_main, config_data, goods_art_no_arrays, move_folde
             msg_type="segment_progress",
             progress=progress
         )
-        
     return handler_result_folder, handler_result
 
 async def _process_scene_images(aigc_clazz, run_main, return_data_check_before_detail, product_scene_prompt):
@@ -851,8 +848,8 @@ async def _process_detail_pages(run_main, return_data_check_before_detail, onlin
     )
     print("<======>check_for_detail_first_res<======>",check_for_detail_first_res)
     if isinstance(check_for_detail_first_res, partial):
-        result = check_for_detail_first_res()
         try:
+            result = check_for_detail_first_res()
             config_data = result["config_data"]
         except:
             config_data = result

+ 8 - 0
python/service/customer_template_service.py

@@ -98,6 +98,14 @@ class CustomerTemplateService:
             long_image.save(save_name,format="JPEG")
             self.move_other_pic(move_main_pic=True,save_path=save_path)
         print("模板生成成功")
+        try:
+            # 删除 800x800 目录及其内容
+            directory_to_remove = os.path.join(save_path, "800x800")
+            if os.path.exists(directory_to_remove):
+                shutil.rmtree(directory_to_remove)
+                print(f"目录 {directory_to_remove} 已成功删除")
+        except Exception as e:
+            print(f"删除目录失败: {e}")
     def create_folder(self, path):
         # 创建目录
         if  path and not os.path.exists(path):