Update routes/ds_pyc_cho_xu_ly.py
Browse files- routes/ds_pyc_cho_xu_ly.py +17 -13
routes/ds_pyc_cho_xu_ly.py
CHANGED
|
@@ -17,7 +17,7 @@ async def ds_pyc_cho_xu_ly():
|
|
| 17 |
pyc_files = [
|
| 18 |
f for f in all_files
|
| 19 |
if f.startswith("Khach_hang/")
|
| 20 |
-
and "/
|
| 21 |
and f.endswith(".xlsx")
|
| 22 |
]
|
| 23 |
|
|
@@ -28,30 +28,34 @@ async def ds_pyc_cho_xu_ly():
|
|
| 28 |
|
| 29 |
for file in pyc_files:
|
| 30 |
try:
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
# === KIỂM TRA ĐÃ CÓ
|
| 35 |
-
|
| 36 |
-
f.startswith(f"Khach_hang/{ten_khach}/
|
| 37 |
-
and
|
| 38 |
for f in all_files
|
| 39 |
)
|
| 40 |
-
if
|
| 41 |
-
continue #
|
| 42 |
|
| 43 |
-
# === ĐỌC THÔNG TIN PYC ===
|
| 44 |
-
|
| 45 |
repo_id=REPO_ID,
|
| 46 |
repo_type="dataset",
|
| 47 |
filename=file,
|
| 48 |
token=HF_TOKEN,
|
| 49 |
cache_dir="/tmp"
|
| 50 |
)
|
| 51 |
-
wb = load_workbook(
|
| 52 |
sheet = wb.active
|
| 53 |
|
| 54 |
-
ten_file = file.split("/")[-1]
|
| 55 |
nguoi_lap = sheet["AH51"].value
|
| 56 |
ngay = sheet["BM3"].value
|
| 57 |
thang = sheet["BS3"].value
|
|
|
|
| 17 |
pyc_files = [
|
| 18 |
f for f in all_files
|
| 19 |
if f.startswith("Khach_hang/")
|
| 20 |
+
and "/6. Phieu yeu cau/" in f
|
| 21 |
and f.endswith(".xlsx")
|
| 22 |
]
|
| 23 |
|
|
|
|
| 28 |
|
| 29 |
for file in pyc_files:
|
| 30 |
try:
|
| 31 |
+
parts = file.split("/")
|
| 32 |
+
if len(parts) < 4:
|
| 33 |
+
continue
|
| 34 |
+
|
| 35 |
+
ten_khach = parts[1]
|
| 36 |
+
ten_file = parts[-1] # VD: DL6-0137.xlsx
|
| 37 |
+
ten_file_goc = os.path.splitext(ten_file)[0] # DL6-0137
|
| 38 |
|
| 39 |
+
# === KIỂM TRA ĐÃ CÓ SCAN HAY CHƯA ===
|
| 40 |
+
has_scan = any(
|
| 41 |
+
f.startswith(f"Khach_hang/{ten_khach}/5. Scan/")
|
| 42 |
+
and ten_file_goc in os.path.splitext(f.split('/')[-1])[0]
|
| 43 |
for f in all_files
|
| 44 |
)
|
| 45 |
+
if has_scan:
|
| 46 |
+
continue # đã có scan => đã hoàn thành
|
| 47 |
|
| 48 |
+
# === ĐỌC THÔNG TIN FILE PYC ===
|
| 49 |
+
local_path = hf_hub_download(
|
| 50 |
repo_id=REPO_ID,
|
| 51 |
repo_type="dataset",
|
| 52 |
filename=file,
|
| 53 |
token=HF_TOKEN,
|
| 54 |
cache_dir="/tmp"
|
| 55 |
)
|
| 56 |
+
wb = load_workbook(local_path, data_only=True)
|
| 57 |
sheet = wb.active
|
| 58 |
|
|
|
|
| 59 |
nguoi_lap = sheet["AH51"].value
|
| 60 |
ngay = sheet["BM3"].value
|
| 61 |
thang = sheet["BS3"].value
|