修改节点分配方式

This commit is contained in:
2025-09-10 18:26:59 +08:00
parent 7e7d706f84
commit 1900f5e82d
13 changed files with 191 additions and 239 deletions

View File

@@ -32,21 +32,6 @@ func SaveEdges(tx *gorm.DB, edges []model.Edge) error {
return nil
}
// 分批处理边缘设备数据
// for i := 0; i < len(edges); i += batchSize {
// end := min(i+batchSize, len(edges))
// batch := edges[i:end]
// err := tx.Clauses(clause.OnConflict{
// Columns: []clause.Column{{Name: "macaddr"}},
// UpdateAll: true,
// }).Create(&batch).Error
// if err != nil {
// return fmt.Errorf("failed to save edges batch %d-%d: %w", i, end-1, err)
// }
// }
// 手动区分需要创建和更新的节点,以避免 on conflict 更新的 id 占用问题
macAddrs := make([]string, len(edges))
for i, e := range edges {