Browse Source

详情页模板

rambo 1 tháng trước cách đây
mục cha
commit
93396a0cff

+ 17 - 27
python/api.py

@@ -145,8 +145,6 @@ def __createExcelGoodsArray(excel_path):
     '''创建通过excel形式得货号组数据'''
     try:
         excel_df = pd.read_excel(excel_path, sheet_name=0, header=0)
-        if "文件夹名称" not in excel_df.columns:
-            raise UnicornException("缺失 [文件夹名称] 列")
         if "商品货号" not in excel_df.columns:
             raise UnicornException("缺失 [商品货号] 列")
         if "款号" not in excel_df.columns:
@@ -187,10 +185,6 @@ async def handle_detail_background(
     request: Request, params: HandlerDetail, background_tasks: BackgroundTasks
 ):
     goods_art_no_arrays = params.goods_art_no
-    # 模板类型,0系统模板,1自定义模板
-    template_type = params.template_type
-    # 自定义模板数据
-    customer_template_json = params.customer_template_json
     is_check = params.is_check
     obj = None
     token = "Bearer " + params.token
@@ -255,10 +249,6 @@ async def process_handle_detail(request: Request, params: HandlerDetail):
         # 初始化基础变量
         handler_result = []
         handler_result_folder = ""
-        # 模板类型,0系统模板,1自定义模板
-        template_type = params.template_type
-        # 自定义模板数据
-        customer_template_json = params.customer_template_json
         # 处理参数
         obj, token, uuid = None, "Bearer " + params.token, params.uuid
         aigc_clazz = AIGCDataRequest(token)
@@ -296,7 +286,7 @@ async def process_handle_detail(request: Request, params: HandlerDetail):
             run_main, config_data, goods_art_no_arrays, move_folder_array
         )
         # 处理场景图和模特图
-        return_data_check_before_detail = run_main.check_before_detail(config_data,is_detail,template_type)
+        return_data_check_before_detail = run_main.check_before_detail(config_data,is_detail)
         
         # 检查处理结果
         success_handler = return_data_check_before_detail.get("data", {}).get("config_data", {}).get("success_handler", [])
@@ -419,7 +409,6 @@ async def _process_excel_mode(goods_art_no_arrays,excel_df):
     move_folder_array = check_move_goods_art_no_folder("output", goods_art_no_arrays, limit_path)
     session = SqlQuery()
     for index, row in excel_df.iterrows():
-            goods_art_no_image_dir = str(row["文件夹名称"])
             goods_art_no = str(row["商品货号"])
             print("货号数据", goods_art_no)
             if not goods_art_no:
@@ -432,7 +421,7 @@ async def _process_excel_mode(goods_art_no_arrays,excel_df):
                 )
             # 货号目录不存在再去进行移动和创建操作
             if move_folder_array.get(goods_art_no) is None:
-                await _process_image_copy_and_move(goods_art_no_image_dir, images,True)
+                await _process_image_copy_and_move(goods_art_no, images,True)
     session.close()
     return move_folder_array
 
@@ -469,9 +458,8 @@ async def _build_config_data(params, goods_art_no_arrays):
     temp_class = {}
     temp_name_list = []
     # 模板类型;0系统模板;1自定义模板
-    template_type = params.template_type
     for tempItem in params.temp_list:
-        temp_class[tempItem.template_id] = tempItem.template_local_classes
+        temp_class[tempItem.template_id] = {"class_path":tempItem.template_local_classes,"template_type":tempItem.template_type if tempItem.template_type else 0}
         temp_name_list.append(tempItem.template_id)
         
     cutOutMode = (
@@ -510,22 +498,24 @@ async def _build_config_data(params, goods_art_no_arrays):
         "temp_name_list": temp_name_list,
         "target_error_folder": f"{limit_path}/软件-生成详情错误",
         "success_handler": [],
-        "template_type":template_type,
     }
-    if template_type == 0:
-        # 如果是系统模板,才进行动态类导入操作
-    # 动态导入类
-        try:
-            temp_class_dict = {}
-            for key, class_path in config_data["temp_class"].items():
+    temp_class_dict = {}
+    try:
+        print("configdata 模板信息",config_data["temp_class"]) 
+        for key, val in config_data["temp_class"].items():
+            class_path = val.get("class_path")
+            template_type = val.get("template_type",0)
+            if template_type == 0:
+                # 如果是系统模板,才进行动态类导入操作
                 module_path, class_name = class_path.rsplit(".", 1)
                 module = importlib.import_module(module_path)
                 cls = getattr(module, class_name)
-                temp_class_dict[key] = cls
-        except:
-            raise UnicornException("详情页模板不存在或未下载完成,请重启软件后重试")
-            
-        config_data["temp_class"] = temp_class_dict
+                temp_class_dict[key] = {"cls":cls,"template_type":template_type}
+            else:
+                temp_class_dict[key] = {"cls":class_path,"template_type":template_type}
+    except:
+        raise UnicornException("详情页模板不存在或未下载完成,请重启软件后重试")
+    config_data["temp_class"] = temp_class_dict
     return config_data
 
 async def _process_cutout(run_main, config_data, goods_art_no_arrays, move_folder_array):

+ 1 - 0
python/custom_plugins/plugins_mode/detail_generate_base.py

@@ -390,6 +390,7 @@ class DetailBase(object):
 
     def create_folder(self, path):
         if not os.path.exists(path):
+            print(f"创建目录   详情页--系统---=================>>>>:{path}")
             os.makedirs(path)
 
     def get_all_process_pics(self):

+ 3 - 4
python/models.py

@@ -1,6 +1,6 @@
 from middleware import *
 import datetime
-
+from typing import Any
 
 class HlmForwardRequest(BaseModel):
     method: str = Field(default="GET", description="请求方法")
@@ -77,7 +77,8 @@ class TemplateItem(BaseModel):
     """模板项"""
 
     template_id: str = Field(description="模板名称")
-    template_local_classes: str = Field(description="模板名称")
+    template_local_classes: Any = Field(description="模板名称")
+    template_type : Optional[int] = Field(default=0, description="模板类型;0系统模板;1自定义模板")
 
 
 class MaineImageTest(BaseModel):
@@ -115,8 +116,6 @@ class HandlerDetail(BaseModel):
     upper_footer_params: Optional[dict] = Field(
         default=None, description="上脚图参数配置"
     )
-    template_type : Optional[int] = Field(default=0, description="模板类型;0系统模板;1自定义模板")
-    customer_template_json : Optional[list] = Field(default=None, description="自定义模板数据")
 
 
 class LogoParams(BaseModel):

+ 136 - 46
python/service/customer_template_service.py

@@ -7,11 +7,44 @@ from PIL import Image
 from io import BytesIO
 import base64,shutil
 from logger import logger
+from natsort import ns, natsorted
+from service.base import get_images, check_path, get_image_mask
 '''前端生图接口'''
+# 
 generate_templace = "/generate"
 class CustomerTemplateService:
     def __init__(self):
         pass
+    
+    def parse_template_json(self,template_json):
+        """
+        解析 template_json 数据(如果它是 URL)
+
+        参数:
+        - template_json: str,模板数据(可能是 URL 或 JSON 字符串)
+
+        返回:
+        - dict,解析后的 JSON 数据
+        """
+        try:
+            # 检查是否为 URL
+            if isinstance(template_json, str) and (template_json.startswith("http://") or template_json.startswith("https://")):
+                # 发送 GET 请求获取数据
+                response = requests.get(template_json)
+                response.raise_for_status()  # 检查请求是否成功
+                # 解析 JSON 数据
+                parsed_data = response.json()
+                return parsed_data
+            else:
+                # 如果不是 URL,直接解析为 JSON
+                return json.loads(template_json)
+        except requests.exceptions.RequestException as e:
+            print(f"网络请求失败: {e}")
+            return None
+        except json.JSONDecodeError as e:
+            print(f"JSON 解析失败: {e}")
+            return None
+    
     def generateTemplate(self,config_data,template_json,template_name,save_path):
         '''
         参数:
@@ -21,11 +54,12 @@ class CustomerTemplateService:
         save_path: 保存路径
         '''
         print("开始生成模板")
+        template_json_data = self.parse_template_json(template_json)
         # print("config_data",config_data)
-        handler_config_data,model_image,scene_image = self.__handler_config_data(config_data)
-        goods_no = list(handler_config_data.keys())[0]
+        handler_config_data,model_image,scene_image = self.__handler_config_data(config_data,save_path)
+        self.goods_no_value = handler_config_data
         headers = {"Content-Type": "application/json"}
-        json_data = {"goodsList":[handler_config_data],"canvasList":template_json}
+        json_data = {"goodsList":[{self.goods_no:handler_config_data}],"canvasList":template_json_data}
         json_data = json.dumps(json_data,ensure_ascii=False)
         # print("json_data",json_data)
         template_result = requests.post(CUSTOMER_TEMPLATE_URL+generate_templace,data=json_data,headers=headers)
@@ -39,7 +73,7 @@ class CustomerTemplateService:
         for image in images:
             canvasIndex = image.get("canvasIndex")
             dataUrl = image.get("dataUrl")
-            save_name = f"{save_path}/切片图-{template_name}/{goods_no}({int(canvasIndex)+1}).png"
+            save_name = f"{save_path}/切片图-{template_name}/{self.goods_no}({int(canvasIndex)+1}).png"
             match dataUrl:
                 case "model":
                     # 复制模特图进行拼接
@@ -59,10 +93,63 @@ class CustomerTemplateService:
                     pillowImage = self.save_base64_image(dataUrl,save_name)
                     concat_images_array.append(pillowImage)
         long_image = self.concat_images_vertically(concat_images_array)
-        save_name = f"{save_path}/详情页-{template_name}.jpg"
-        long_image.save(save_name,format="JPEG")
+        if long_image:
+            save_name = f"{save_path}/详情页-{template_name}.jpg"
+            long_image.save(save_name,format="JPEG")
+            self.move_other_pic(move_main_pic=True,save_path=save_path)
         print("模板生成成功")
-    
+    def create_folder(self, path):
+        # 创建目录
+        if  path and not os.path.exists(path):
+            print(f"创建目录   详情页=================>>>>:{path}")
+            os.makedirs(path)
+    def move_other_pic(self, move_main_pic=True,save_path=""):
+        sorted_list_800 = []
+        for goods_art_no_dict in self.goods_no_value["货号资料"]:
+            if "800x800" not in goods_art_no_dict:
+                continue
+            if not goods_art_no_dict["800x800"]:
+                continue
+            goods_art_no = ""
+            if "编号" in goods_art_no_dict:
+                if goods_art_no_dict["编号"]:
+                    goods_art_no = goods_art_no_dict["编号"]
+            if not goods_art_no:
+                goods_art_no = goods_art_no_dict["货号"]
+            sorted_list_800 = natsorted(goods_art_no_dict["800x800"], key=lambda x: x.split("(")[1].split(")")[0])
+            self.create_folder(save_path)
+            # 放入一张主图
+            old_pic_path_1 = sorted_list_800[0]
+            shutil.copy(
+                old_pic_path_1,
+                "{}/颜色图{}{}".format(
+                    save_path, goods_art_no, os.path.splitext(old_pic_path_1)[1]
+                ),
+            )
+
+            # 把其他主图放入作为款号图=====================
+            if move_main_pic:
+                for idx,pic_path in enumerate(sorted_list_800):
+                    index = idx + 1
+                    try:
+                        split_size = pic_path.split("_")[1].split(".")[0]
+                    except:
+                        split_size = ""
+                    suffix_name = "_"+split_size if split_size else ""
+                    print("pic_path=========>",split_size)
+                    e = os.path.splitext(pic_path)[1]
+                    shutil.copy(
+                        pic_path,
+                        "{out_put_dir}/主图{goods_no}({goods_no_main_pic_number}){suffix_name}{e}".format(
+                            out_put_dir=save_path,
+                            goods_no=goods_art_no,
+                            goods_no_main_pic_number=str(
+                                index
+                            ),
+                            e=e,
+                            suffix_name=suffix_name
+                        ),
+                    )
     def concat_images_vertically(self,image_array, custom_width=None):
         """
         按照顺序将图片数组拼接成长图,并统一图片宽度
@@ -75,7 +162,7 @@ class CustomerTemplateService:
         - concatenated_image: PIL.Image,拼接后的长图对象
         """
         if not image_array:
-            raise ValueError("图片数组为空,无法拼接")
+            return None
 
         # 1. 确定统一宽度
         base_width = custom_width or image_array[0].width
@@ -101,52 +188,57 @@ class CustomerTemplateService:
             y_offset += resized_img.height
 
         return concatenated_image
-    def __handler_config_data(self,config_data):
+    def __handler_config_data(self,config_data,scp_path):
         '''
         处理配置数据,返回一个新的数据对象
         '''
+        directory = os.path.dirname(scp_path)
+        self.create_folder(directory)
         # 深拷贝原始数据,确保不改变原数据对象
         new_config_data = copy.deepcopy(config_data)
+        print("传入的config数据",new_config_data)
         model_image = None
         scene_image = None
+        self.goods_no = new_config_data.get("款号")
         # 如果输入是字典,则将其转换为目标结构
-        if isinstance(new_config_data, dict):
-            # result = []
-            for key, item in new_config_data.items():
-                # 提取需要添加的数据
-                additional_data = {k: v for k, v in item.items() if k not in ["款号", "货号资料"]}
-                
-                # 遍历货号资料,将额外数据添加到每个货号对象中
-                for product in item.get("货号资料", []):
-                    product.update(additional_data)
-                    # 处理 pics 字段中的 xx-抠图 转换为 Base64 并新增字段
-                    pics = product.get("pics", {})
-                    if not model_image:
-                        model_image = product.get("模特图", None)
-                    if not scene_image:
-                        scene_image = product.get("场景图", None)
-                    new_pics = {}
-                    for pic_key, pic_path in pics.items():
-                        if "-抠图" in pic_key:
-                            # 读取图片并转换为 Base64
-                            try:
-                                # base64_data = self.crop_image_and_convert_to_base64(pic_path)
-                                # 新增字段(去除 -抠图)
-                                new_key = pic_key.replace("-抠图", "")
-                                new_pics[new_key] = pic_path
-                            except Exception as e:
-                                print(f"读取图片失败: {pic_path}, 错误: {e}")
-                        else:
-                            # 非 -抠图 字段保持不变
-                            new_pics[pic_key] = pic_path
-                    
-                    # 更新 pics 字段
-                    product["pics"] = new_pics
-                
+        # 提取需要添加的数据,排除特定字段
+        additional_data = {k: v for k, v in new_config_data.items() if k not in ["款号", "货号资料"]}
+        # 遍历货号资料,将额外数据添加到每个货号对象中
+        for product in new_config_data.get("货号资料", []):
+            product.update(additional_data)
+            # 处理 pics 字段中的 xx-抠图 转换为 Base64 并新增字段
+            pics = product.get("pics", {})
+            goods_art_no = product.get("货号",None)
+            goods_art_lens = len(new_config_data.get("货号资料", []))
+            concat_shuffix = "" if goods_art_lens == 1 else f"_{goods_art_no}"
+            if not model_image:
+                model_image = product.get("模特图", None)
+                if model_image:
+                    self.copyImage(model_image, f"{scp_path}/模特图{concat_shuffix}.jpg")
+            if not scene_image:
+                scene_image = product.get("场景图", None)
+                if scene_image:
+                    self.copyImage(scene_image, f"{scp_path}/场景图{concat_shuffix}.jpg")
+            new_pics = {}
+            for pic_key, pic_path in pics.items():
+                if "-抠图" in pic_key:
+                    # 读取图片并转换为 Base64
+                    try:
+                        base64_data = self.crop_image_and_convert_to_base64(pic_path)
+                        # 新增字段(去除 -抠图)
+                        new_key = pic_key.replace("-抠图", "")
+                        new_pics[new_key] = base64_data
+                    except Exception as e:
+                        print(f"读取图片失败: {pic_path}, 错误: {e}")
+                else:
+                    # 非 -抠图 字段保持不变
+                    new_pics[pic_key] = pic_path
+                # 更新 pics 字段
+                product["pics"] = new_pics
+            
                 # 构建目标结构
             #     result.append({key: item})
             # return result
-        
         return new_config_data,model_image,scene_image
     def save_base64_image(self,base64_data, output_path):
         """
@@ -166,9 +258,7 @@ class CustomerTemplateService:
             image = Image.open(BytesIO(image_data))
             # 3. 检查路径是否存在,如果不存在则创建
             directory = os.path.dirname(output_path)
-            if directory and not os.path.exists(directory):
-                os.makedirs(directory)
-                print(f"目录已创建: {directory}")
+            self.create_folder(directory)
             # 4. 保存图像到本地
             image.save(output_path)
             print(f"图像已成功保存到 {output_path}")

+ 11 - 11
python/service/data.py

@@ -169,10 +169,10 @@ class DataModeGenerateDetail(DataBaseModel):
     def get_basic_goods_art_data_form_excel(self, folder_name_list, excel_path, keys):
 
         # =====创建虚拟表格并进行连表处理
-        need_df = pd.DataFrame(columns=["文件夹名称"])
+        need_df = pd.DataFrame(columns=["商品货号"])
         for folder_name in folder_name_list:
             new_row = {
-                "文件夹名称": str(folder_name),
+                "商品货号": str(folder_name),
             }
             need_df = need_df._append(new_row, ignore_index=True)
 
@@ -181,7 +181,7 @@ class DataModeGenerateDetail(DataBaseModel):
         # 打开表格并进行匹配
         _df = pd.read_excel(excel_path, sheet_name=0, header=0)
         # 去重数据
-        duplicates = _df.duplicated(subset=["文件夹名称"], keep="first")
+        duplicates = _df.duplicated(subset=["商品货号"], keep="first")
         _df = _df.loc[~duplicates]
         _df = _df.fillna(value="")
         _df = _df.astype(str)
@@ -189,7 +189,7 @@ class DataModeGenerateDetail(DataBaseModel):
         need_df = pd.merge(
             need_df,
             _df,
-            on=["文件夹名称"],
+            on=["商品货号"],
             how="left",
             indicator=False,
         )
@@ -206,11 +206,11 @@ class DataModeGenerateDetail(DataBaseModel):
         message = ""
         for index, row in need_df.iterrows():
             if settings.PROJECT == "红蜻蜓":
-                if row["商品货号"] and row["款号"] and row["编号"]:
-                    return_dict[row["文件夹名称"]] = {
+                if row["商品货号"] and row["款号"]:
+                    return_dict[row["商品货号"]] = {
                         "type": "goods_art_no",
-                        "name": row["文件夹名称"].upper(),
-                        "文件夹名称": row["文件夹名称"],
+                        "name": row["商品货号"].upper(),
+                        "商品货号": row["商品货号"],
                         "template_name": row["模板名称"],
                         "data": row.to_dict(),
                     }
@@ -218,10 +218,10 @@ class DataModeGenerateDetail(DataBaseModel):
                     message = "商品货号、款号、编号必须有值"
             else:
                 if row["商品货号"] and row["款号"]:
-                    return_dict[row["文件夹名称"]] = {
+                    return_dict[row["商品货号"]] = {
                         "type": "goods_art_no",
-                        "name": row["文件夹名称"].upper(),
-                        "文件夹名称": row["文件夹名称"],
+                        "name": row["商品货号"].upper(),
+                        "商品货号": row["商品货号"],
                         "template_name": row["模板名称"],
                         "data": row.to_dict(),
                     }

+ 10 - 11
python/service/generate_goods_no_detail_pic/data.py

@@ -107,9 +107,9 @@ class DataModeGenerateDetail(DataBaseModel):
     def get_basic_goods_art_data_form_excel(self, folder_name_list, excel_path, keys):
 
         # =====创建虚拟表格并进行连表处理
-        need_df = pd.DataFrame(columns=["文件夹名称"])
+        need_df = pd.DataFrame(columns=["商品货号"])
         for folder_name in folder_name_list:
-            new_row = {"文件夹名称": str(folder_name),
+            new_row = {"商品货号": str(folder_name),
                        }
             need_df = need_df._append(new_row, ignore_index=True)
 
@@ -118,13 +118,13 @@ class DataModeGenerateDetail(DataBaseModel):
         # 打开表格并进行匹配
         _df = pd.read_excel(excel_path, sheet_name=0, header=0)
         # 去重数据
-        duplicates = _df.duplicated(subset=['文件夹名称'], keep="first")
+        duplicates = _df.duplicated(subset=['商品货号'], keep="first")
         _df = _df.loc[~duplicates]
         _df = _df.fillna(value='')
         _df = _df.astype(str)
 
         # 数据匹配关联,左关联
-        need_df = pd.merge(need_df, _df, on=["文件夹名称"], how="left", indicator=False, )
+        need_df = pd.merge(need_df, _df, on=["商品货号"], how="left", indicator=False, )
         # 补全字段
         header_list = need_df.columns.values.tolist()
         for key in keys:
@@ -138,11 +138,10 @@ class DataModeGenerateDetail(DataBaseModel):
         message = ""
         for index, row in need_df.iterrows():
             if settings.PROJECT == "红蜻蜓":
-                if row["商品货号"] and row["款号"] and row["编号"]:
-                    return_dict[row["文件夹名称"]] = {
+                if row["商品货号"] and row["款号"]:
+                    return_dict[row["商品货号"]] = {
                         "type": "goods_art_no",
-                        "name": row["文件夹名称"].upper(),
-                        "文件夹名称": row["文件夹名称"],
+                        "name": row["商品货号"].upper(),
                         "template_name": row["模板名称"],
                         "data": row.to_dict(),
                     }
@@ -150,10 +149,10 @@ class DataModeGenerateDetail(DataBaseModel):
                     message = "商品货号、款号、编号必须有值"
             else:
                 if row["商品货号"] and row["款号"]:
-                    return_dict[row["文件夹名称"]] = {
+                    return_dict[row["商品货号"]] = {
                         "type": "goods_art_no",
-                        "name": row["文件夹名称"].upper(),
-                        "文件夹名称": row["文件夹名称"],
+                        "name": row["商品货号"].upper(),
+                        "文件夹名称": row["商品货号"],
                         "template_name": row["模板名称"],
                         "data": row.to_dict(),
                     }

+ 24 - 25
python/service/run_main.py

@@ -390,7 +390,7 @@ class RunMain:
         config_data["sign_text"] = "已结束抠图处理"
         self.run_end_sign.emit(config_data)
 
-    def check_before_detail(self, config_data,is_detail,template_type):
+    def check_before_detail(self, config_data,is_detail):
 
         # =============
         # 整体数据校验,返回错误内容,以及
@@ -474,17 +474,20 @@ class RunMain:
         # 在访问 temp_class[temp_name].need_view 前增加检查
         need_view_list = []
         if is_detail == 1:
-            if template_type == 0:
-                if temp_name not in temp_class or temp_class[temp_name] is None:
-                    raise UnicornException(f"模板 {temp_name} 未正确初始化或不存在")
-
-                # 确保 temp_class[temp_name] 是可调用的
+            if temp_name not in temp_class or temp_class[temp_name] is None:
+                raise UnicornException(f"模板 {temp_name} 未正确初始化或不存在")
+            class_obj = temp_class[temp_name]
+            class_path = class_obj.get("cls")
+            template_type = class_obj.get("template_type")
+            # 确保 temp_class[temp_name] 是可调用的
+            if template_type ==0:
                 if not callable(temp_class[temp_name]):
                     raise UnicornException(f"模板 {temp_name} 不是有效的可调用对象")
-                try:
-                    need_view_list = temp_class[temp_name].need_view
-                except KeyError as ke:
-                    raise UnicornException("未选择详情页模板,请检查")
+            try:
+                if template_type ==0:
+                    need_view_list = class_path.need_view
+            except KeyError as ke:
+                raise UnicornException("未选择详情页模板,请检查")
         _all_dir_info_data = get_all_dir_info_and_pic_info(
             image_dir, folder_name_list, need_view_list
         )
@@ -761,10 +764,6 @@ class RunMain:
         code = data["code"]
         config_data = data["data"]["config_data"]
         target_error_folder = config_data["target_error_folder"]
-        # 模板类型,0系统模板,1自定义模板
-        template_type = request_parmas.template_type
-        # 自定义模板数据
-        customer_template_json = request_parmas.customer_template_json
         print("635  check_for_detail_first_call_back")
         print(data)
         if code != 0:
@@ -962,7 +961,6 @@ class RunMain:
                         temp_class=config_data["temp_class"],
                         target_error_folder=config_data["target_error_folder"],
                         image_dir=config_data["image_dir"],
-                        request_parmas=request_parmas,
                     )
                     config_data["success_handler"].append(
                         {"goods_art_no": goods_no, "success": True, "info": "处理成功"}
@@ -1067,31 +1065,31 @@ class RunMain:
         temp_class,
         target_error_folder,
         image_dir,
-        request_parmas,
     ):
         # 模板类型,0系统模板,1自定义模板
-        template_type = request_parmas.template_type
         # 自定义模板数据
-        customer_template_json = request_parmas.customer_template_json
         # if self.windows.state == 99:
         #     self.show_progress_detail("用户主动取消:{}".format(goods_no))
         #     return
         self.show_progress_detail("正在生成:{},模板:{}".format(goods_no, temp_name))
         is_deal_success = False
+        class_obj = temp_class[temp_name]
+        class_path = class_obj.get("cls")
+        template_type = class_obj.get("template_type")
         print("=================deal_one_data=====================")
         print("goods_no", goods_no)
         print("模板:", temp_name)
         print("value:", value)
         print("temp_class:", temp_class)
-        if template_type == 0:
-            if temp_name not in temp_class or temp_class[temp_name] is None:
+        print("class_obj:", class_obj)
+        if temp_name not in temp_class or temp_class[temp_name] is None:
                 raise UnicornException(f"详情页模板 {temp_name} 未正确加载")
-                
-            if not callable(temp_class[temp_name]):
+        if template_type == 0:
+            if not callable(class_path):
                 raise UnicornException(f"详情页模板 {temp_name} 不是有效的可调用对象")
             try:
                 # # 处理图片详情图生成
-                temp_class[temp_name](
+                class_path(
                     goods_no,
                     value,
                     out_put_dir=out_put_dir,
@@ -1117,13 +1115,14 @@ class RunMain:
             try:
                 is_deal_success = True
                 service = CustomerTemplateService()
-                goods_no = value["款号"]
                 save_path = f"{out_put_dir}/详情图-{goods_no}"
-                service.generateTemplate({goods_no:value},customer_template_json,temp_name,save_path)
+                print("传递的class信息====>",class_path)
+                service.generateTemplate(value,class_path,temp_name,save_path)
             except BaseException as e:
                 self.show_progress_detail("{}处理失败".format(goods_no))
                 error_text = "{}".format(e)
                 print("error_text",error_text)
+                print(f"发生错误的行号: {e.__traceback__.tb_lineno}")
                 print(
                     f"发生错误的文件: {e.__traceback__.tb_frame.f_globals['__file__']}"
                 )