Browse Source

优化烧录记录导入

zhangdongming 2 weeks ago
parent
commit
73051cbd50
1 changed files with 8 additions and 7 deletions
  1. 8 7
      AdminController/UIDBurnManageController.py

+ 8 - 7
AdminController/UIDBurnManageController.py

@@ -506,7 +506,7 @@ class UIDBurnManageView(View):
             base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
             upload_dir = os.path.join(base_dir, 'static', 'uploaded_files')
             os.makedirs(upload_dir, exist_ok=True)
-            file_path = os.path.join(upload_dir, f"{task_id}.xlsx")
+            file_path = os.path.join(upload_dir, f"{task_id}.xls")
 
             with open(file_path, 'wb+') as destination:
                 for chunk in excel_file.chunks():
@@ -544,9 +544,9 @@ class UIDBurnManageView(View):
             redis_obj.set_data(redis_key, json.dumps(task_data))
 
             # 1. 读取Excel文件获取总行数
-            wb = load_workbook(file_path)
-            ws = wb.active
-            total_rows = ws.max_row
+            workbook = xlrd.open_workbook(file_path)
+            sheet = workbook.sheet_by_index(0)
+            total_rows = sheet.nrows
 
             # 更新总行数和开始时间
             task_data['total'] = total_rows
@@ -572,9 +572,10 @@ class UIDBurnManageView(View):
             processed = 0
             uids_batch = []
 
-            for row in ws.iter_rows(min_row=1, values_only=True):
-                if row[0]:
-                    uid = str(row[0]).strip()
+            for row_idx in range(0, total_rows):
+                row = sheet.row_values(row_idx)
+                if len(row) > 2 and row[2]:
+                    uid = str(row[2]).strip()
                     if uid:
                         uids_batch.append(uid)
                         processed += 1