Forráskód Böngészése

```
fix(customer-template-service): 修复配置数据处理中的异常并优化调试信息

- 在处理商品艺术编号重命名列表时添加异常处理,防止因缺少action_name字段导致程序崩溃
- 添加调试打印语句以更好地跟踪配置数据处理流程
- 修正索引递增逻辑的位置,确保正确遍历商品列表
```

rambo 1 hete
szülő
commit
393b9e9cf5
1 módosított fájl, 7 hozzáadás és 2 törlés
  1. 7 2
      python/service/customer_template_service.py

+ 7 - 2
python/service/customer_template_service.py

@@ -60,6 +60,7 @@ class CustomerTemplateService:
         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,save_path)
+        print("handler_config_data",handler_config_data)
         self.goods_no_value = handler_config_data
         headers = {"Content-Type": "application/json"}
         json_data = {"goodsList":[{self.goods_no:handler_config_data}],"canvasList":template_json_data}
@@ -296,17 +297,21 @@ class CustomerTemplateService:
                         base64_data = self.crop_image_and_convert_to_base64(pic_path)
                         # 新增字段(去除 -抠图)
                         new_key = pic_key.replace("-抠图", "")
-                        new_key = goods_art_no_rename_list[index].get("action_name")
+                        try:
+                            new_key = goods_art_no_rename_list[index].get("action_name")
+                        except:
+                            print("没有找到对应的action_name",index)
+                        # print("goods_art_no_rename_list",goods_art_no_rename_list)
                         new_pics[new_key] = base64_data
                     except Exception as e:
                         print(f"读取图片失败: {pic_path}, 错误: {e}")
+                    index += 1
                 else:
                     # 非 -抠图 字段保持不变
                     # new_pics[pic_key] = pic_path
                     pass
                 # 更新 pics 字段
                 product["pics"] = new_pics
-                index += 1
             
                 # 构建目标结构
             #     result.append({key: item})