Browse Source

sort_result

rambo 1 month ago
parent
commit
82dbacfd07
1 changed files with 5 additions and 4 deletions
  1. 5 4
      python/service/deal_image.py

+ 5 - 4
python/service/deal_image.py

@@ -31,7 +31,7 @@ class DealImage(BaseDealImage):
     def list_dir(self, path):
         listdir = os.listdir(path)
         sort_result = sorted(listdir, key=lambda x: int(re.findall(r'^(\d+)_', x)[0]) if re.findall(r'^(\d+)_', x) else 0)
-        print("listdir   排序排序排序排序排序排序", sort_result)
+        # print("listdir   排序排序排序排序排序排序", sort_result)
         # return natsorted(listdir, alg=ns.PATH)
         return sort_result
     def get_date_time_original(self, file_path):
@@ -320,10 +320,11 @@ class DealImage(BaseDealImage):
                     continue
 
                 all_original_images = os.listdir(_path)  # 遍历货号原始图文件夹
-                goods_pic_total = len(all_original_images)
-                if not all_original_images:
+                sort_result = sorted(all_original_images, key=lambda x: int(re.findall(r'^(\d+)_', x)[0]) if re.findall(r'^(\d+)_', x) else 0)
+                goods_pic_total = len(sort_result)
+                if not sort_result:
                     continue
-                image_file = all_original_images[0]  # 取第一个货号图
+                image_file = sort_result[0]  # 取第一个货号图
                 image_file_path = "{}/{}/原始图/{}".format(
                     dir_path, goods_art_no_folder, image_file
                 )