fix: 修复扇区推断及按CGI更新导入

This commit is contained in:
2026-08-26 17:08:19 +08:00
parent e007776093
commit b6cf0e61e7
6 changed files with 385 additions and 17 deletions
+11
View File
@@ -297,6 +297,17 @@ def import_table_csv(
if extra:
parts.append("多余字段: " + ", ".join(extra))
raise HTTPException(status_code=400, detail="CSV 字段与模板不一致,导入失败。" + ";".join(parts))
if database_source == "cell_data" and table_name.lower() == "sector":
stats = db.upsert_csv(str(tmp_path), table_name, "CGI", encoding=encoding)
return {
"success": True,
"message": (
f"导入成功,共 {stats['imported_rows']} 行:"
f"新增 {stats['inserted_rows']} 行,更新 {stats['updated_rows']} 行,"
f"清理历史重复 {stats['removed_duplicate_rows']} 行"
),
**stats,
}
imported = db.import_csv(str(tmp_path), table_name, encoding=encoding)
except HTTPException:
raise