rambo 5 månader sedan
förälder
incheckning
473eacdf05

+ 60 - 10
python/custom_plugins/plugins/detail_template/xinjunlue/detail_xinjunlue1.py

@@ -67,16 +67,31 @@ class DetailPicGet(DetailBase):
         print(f"run {template_name} ")
         self.base_bg_color = (255, 255, 255)
         self.deal_pic_func_list = [
-            self.deal_pic_1,
+            self.deal_pic_1(),
+            self.deal_pic_2(),
         ]
-        if test:
-            self.run_test()
-        else:
-            self.run_all()
+        img = self.add_pic(self.deal_pic_func_list)
+        file_path = self.get_text_value("图片路径")
+        # file_path = file_path.replace("\\", "/")
+        parent_folder = os.path.dirname(file_path)
+        if os.path.exists(parent_folder) == False:
+            # 确保目标目录存在
+            os.makedirs(parent_folder, exist_ok=True)
+        print("file_path是否存在",parent_folder, os.path.exists(parent_folder))
+        file_extension = file_path.split(".")[-1]
+        format_mapping = {"jpg": "JPEG", "png": "PNG", "webp": "WEBP", "avif": "AVIF"}
+        file_format = format_mapping[file_extension]
+        img.save(file_path, format=file_format)
+        img.show()
+        # if test:
+        #     self.run_test()
+        # else:
+        #     self.run_all()
 
     def run_test(self):
         detailed_images = []
         detailed_images.append(self.deal_pic_1())
+        detailed_images.append(self.deal_pic_2())
         img = self.add_pic(detailed_images)
         if img:
             self.create_folder(r"{}/{}".format(self.out_put_dir, template_name))
@@ -94,7 +109,17 @@ class DetailPicGet(DetailBase):
         base_bg_width = 1200
         base_limit_width = base_bg_width / 2
         font = ImageFont.truetype("msyh.ttc", 20)
-        dataList = ["款号", "面料", "内里", "垫脚", "大底", "饰扣", "客户", "日期"]
+        dataList = [
+            "款号",
+            "面料",
+            "内里",
+            "垫脚",
+            "大底",
+            "饰扣",
+            "客户",
+            "码数",
+            "日期",
+        ]
         height_total = 0
         text_list = []
         line_space = 15
@@ -152,12 +177,22 @@ class DetailPicGet(DetailBase):
         detailed_images.append(pp_image_jpg)
         return PictureProcessing(im=self.add_pic(detailed_images))
 
-    def deal_pic_1(self):
+    def deal_pic_2(self):
         detailed_images = []
         base_bg_width = 1200
         base_limit_width = base_bg_width / 2
-        font = ImageFont.truetype("msyh.ttc", 20)
-        dataList = ["款号", "面料", "内里", "垫脚", "大底", "饰扣", "客户", "日期"]
+        font = ImageFont.truetype("arial.ttf", 20)
+        dataList = [
+            "JEFFREY CAMPBELL",
+            "Supplier",
+            "款号",  # Fty No
+            "Material",
+            "Lining&Sock",
+            "码数",  # Size
+            "日期",  # Date
+            "Remark",
+            "MADE IN CHINA",
+        ]
         height_total = 0
         text_list = []
         line_space = 15
@@ -165,8 +200,19 @@ class DetailPicGet(DetailBase):
             info = self.get_text_value(item)
             if info == None or info == "":
                 continue
+            mapping = {
+                "JEFFREY CAMPBELL": "",
+                "Supplier": "Supplier:",
+                "款号": "Fty No:",
+                "Material": "Material:",
+                "Lining&Sock": "Lining&Sock:",
+                "码数": "Size:",
+                "日期": "Date:",
+                "Remark": "Remark:",
+                "MADE IN CHINA": "",
+            }
             _pp = PictureProcessing()
-            text = f"{item}: {self.get_text_value(item)}"
+            text = f"{mapping[item]} {self.get_text_value(item)}"
             duanluo = ""
             sum_width = 0
             line_count = 0
@@ -178,7 +224,11 @@ class DetailPicGet(DetailBase):
                     sum_width = 0
                     duanluo += "\n"
                 duanluo += char
+            value = (0,0)
+            if idx ==0 or idx == len(dataList)-1:
+                value = (-5,0)
             _pp = _pp.get_text_image_advanced(
+                value=value,
                 font=font,
                 text=duanluo,
                 spacing=10,

+ 2 - 2
python/detail_template_test.py

@@ -4,7 +4,7 @@ import settings
 settings.is_test_plugins = True
 
 
-from custom_plugins.plugins.detail_template.xinnuo.detail_xinnuo3 import (
+from custom_plugins.plugins.detail_template.xinjunlue.detail_xinjunlue1 import (
     DetailPicGet,
 )
 
@@ -14,7 +14,7 @@ for goods_no, value in data.items():
     d = DetailPicGet(
         goods_no=goods_no,
         goods_no_value=value,
-        out_put_dir=r"C:\Development\project\python\CameraMachine\python\output\xinnuo-3",
+        out_put_dir=r"C:\Development\project\python\CameraMachine\python\output\xinjunlue-1",
         test=True,
     )
 print("生成成功")

+ 9 - 3
python/detail_template_test_xinjunlue.json

@@ -60,7 +60,7 @@
             }
         ],
         "文件夹名称": "AC51016112",
-        "图片路径": "休闲运动",
+        "图片路径": "\\\\RAMBO\\Users\\15001\\Desktop\\panpanpan\\E305S\\E305-01003.jpg",
         "楦号": "E305S",
         "内里": "RL203黑色羊皮里+后套里:ZP3002黑色猪皮反面",
         "面料": "RB3721杏色网布+RJ262杏色长毛牛京+RN1982白色荔枝纹皮+RN2586黑色牛皮",
@@ -68,7 +68,13 @@
         "大底": "黑色大底+灰色EVA+白色EVA",
         "饰扣": "黑色松紧+金色日子扣",
         "客户": "strategy",
-        "码数": "",
-        "日期": "2025-6-12"
+        "码数": "7#",
+        "日期": "2025-6-12",
+        "JEFFREY CAMPBELL":"JEFFREY CAMPBELL",
+        "Supplier":"STRATEGY",
+        "Remark":"SHOW SAMPLE",
+        "Material":"RN3371# BROWN COW",
+        "Lining&Sock":"BROWN PU",
+        "MADE IN CHINA":"MADE IN CHINA"
     }
 }