Update app.py
Browse files
app.py
CHANGED
|
@@ -482,38 +482,42 @@ def doanh_thu_theo_thang():
|
|
| 482 |
except Exception as e:
|
| 483 |
return {"error": str(e)}
|
| 484 |
@app.get("/doanh_thu_noi_bo")
|
| 485 |
-
def doanh_thu_noi_bo():
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
if phong and phong != "None" and row[0] >= 4:
|
| 505 |
data.append({
|
| 506 |
"Phòng": phong,
|
| 507 |
-
"Chuyển đến":
|
| 508 |
-
"Chuyển đi":
|
| 509 |
})
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
"
|
| 517 |
-
|
|
|
|
|
|
|
| 518 |
}
|
| 519 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 482 |
except Exception as e:
|
| 483 |
return {"error": str(e)}
|
| 484 |
@app.get("/doanh_thu_noi_bo")
|
| 485 |
+
async def doanh_thu_noi_bo():
|
| 486 |
+
try:
|
| 487 |
+
ds = hf_hub_download(repo_id="doluong6/Quatest1", filename="Theo doi DTNB & DT 2025.xlsx")
|
| 488 |
+
wb = openpyxl.load_workbook(ds, data_only=True)
|
| 489 |
+
ws = wb["Nội bộ"]
|
| 490 |
+
|
| 491 |
+
data = []
|
| 492 |
+
tong_cd = 0
|
| 493 |
+
tong_di = 0
|
| 494 |
+
|
| 495 |
+
for row in ws.iter_rows(min_row=4):
|
| 496 |
+
phong = row[1].value # cột B
|
| 497 |
+
chuyen_den = row[5].value # cột F
|
| 498 |
+
chuyen_di = row[6].value # cột G
|
| 499 |
+
|
| 500 |
+
if not phong: continue
|
| 501 |
+
cd = chuyen_den if isinstance(chuyen_den, (int, float)) else 0
|
| 502 |
+
di = chuyen_di if isinstance(chuyen_di, (int, float)) else 0
|
| 503 |
+
|
|
|
|
| 504 |
data.append({
|
| 505 |
"Phòng": phong,
|
| 506 |
+
"Chuyển đến": cd,
|
| 507 |
+
"Chuyển đi": di
|
| 508 |
})
|
| 509 |
+
|
| 510 |
+
tong_cd += cd
|
| 511 |
+
tong_di += di
|
| 512 |
+
|
| 513 |
+
return {
|
| 514 |
+
"data": data,
|
| 515 |
+
"tong": {
|
| 516 |
+
"Tổng chuyển đến": tong_cd,
|
| 517 |
+
"Tổng chuyển đi": tong_di
|
| 518 |
+
}
|
| 519 |
}
|
| 520 |
+
except Exception as e:
|
| 521 |
+
print("❌ Lỗi xử lý doanh_thu_noi_bo:", e)
|
| 522 |
+
traceback.print_exc()
|
| 523 |
+
return JSONResponse(status_code=500, content={"error": str(e)})
|