fix: cm_version filled by ne version

This commit is contained in:
simon
2025-07-24 09:53:36 +08:00
parent f7f9572aef
commit 3e7c60ecd0
6 changed files with 188 additions and 188 deletions

View File

@@ -62,28 +62,28 @@ func SyncNbiCM() error {
Order("timestamp ASC").Pluck("value_json", &lastJson).Error
newValueJson := string(meJSON)
if err != nil || lastJson == "" {
common.InsertNbiCm(ne, "ManagedElement", newValueJson, common.ObjectOriginalEvent)
nbiCm := common.InsertNbiCm(ne, "ManagedElement", newValueJson, common.ObjectCreationEvent)
common.InsertNbiCm(ne, version, "ManagedElement", newValueJson, common.ObjectOriginalEvent)
nbiCm := common.InsertNbiCm(ne, version, "ManagedElement", newValueJson, common.ObjectCreationEvent)
redisqueue.AddNbiCMQueue([]string{strconv.Itoa(nbiCm.Id)})
} else {
var ids []string
added, modified, deleted, _ := common.CompareJSON(lastJson, newValueJson)
if len(added) > 0 {
nbiCm := common.InsertNbiCm(ne, "ManagedElement", common.ToJson(added), common.ObjectCreationEvent)
nbiCm := common.InsertNbiCm(ne, version, "ManagedElement", common.ToJson(added), common.ObjectCreationEvent)
ids = append(ids, strconv.Itoa(nbiCm.Id))
}
if len(modified) > 0 {
nbiCm := common.InsertNbiCm(ne, "ManagedElement", common.ToJson(modified), common.ObjectAttributeValueChangeEvent)
nbiCm := common.InsertNbiCm(ne, version, "ManagedElement", common.ToJson(modified), common.ObjectAttributeValueChangeEvent)
ids = append(ids, strconv.Itoa(nbiCm.Id))
}
if len(deleted) > 0 {
nbiCm := common.InsertNbiCm(ne, "ManagedElement", common.ToJson(deleted), common.ObjectDeletionEvent)
nbiCm := common.InsertNbiCm(ne, version, "ManagedElement", common.ToJson(deleted), common.ObjectDeletionEvent)
ids = append(ids, strconv.Itoa(nbiCm.Id))
}
if len(ids) > 0 {
redisqueue.AddNbiCMQueue(ids)
common.InsertNbiCm(ne, "ManagedElement", newValueJson, common.ObjectOriginalEvent)
common.InsertNbiCm(ne, version, "ManagedElement", newValueJson, common.ObjectOriginalEvent)
}
}
@@ -108,28 +108,28 @@ func SyncNbiCM() error {
Order("timestamp ASC").Pluck("value_json", &lastUdmJson).Error
newUdmValueJson := string(udmJSON)
if err != nil || lastUdmJson == "" {
common.InsertNbiCm(ne, "UdmFunction", newUdmValueJson, common.ObjectOriginalEvent)
nbiCm := common.InsertNbiCm(ne, "UdmFunction", newUdmValueJson, common.ObjectCreationEvent)
common.InsertNbiCm(ne, version, "UdmFunction", newUdmValueJson, common.ObjectOriginalEvent)
nbiCm := common.InsertNbiCm(ne, version, "UdmFunction", newUdmValueJson, common.ObjectCreationEvent)
redisqueue.AddNbiCMQueue([]string{strconv.Itoa(nbiCm.Id)})
} else {
var ids []string
added, modified, deleted, _ := common.CompareJSON(lastUdmJson, newUdmValueJson)
if len(added) > 0 {
nbiCm := common.InsertNbiCm(ne, "UdmFunction", common.ToJson(added), common.ObjectCreationEvent)
nbiCm := common.InsertNbiCm(ne, version, "UdmFunction", common.ToJson(added), common.ObjectCreationEvent)
ids = append(ids, strconv.Itoa(nbiCm.Id))
}
if len(modified) > 0 {
nbiCm := common.InsertNbiCm(ne, "UdmFunction", common.ToJson(modified), common.ObjectAttributeValueChangeEvent)
nbiCm := common.InsertNbiCm(ne, version, "UdmFunction", common.ToJson(modified), common.ObjectAttributeValueChangeEvent)
ids = append(ids, strconv.Itoa(nbiCm.Id))
}
if len(deleted) > 0 {
nbiCm := common.InsertNbiCm(ne, "UdmFunction", common.ToJson(deleted), common.ObjectDeletionEvent)
nbiCm := common.InsertNbiCm(ne, version, "UdmFunction", common.ToJson(deleted), common.ObjectDeletionEvent)
ids = append(ids, strconv.Itoa(nbiCm.Id))
}
if len(ids) > 0 {
redisqueue.AddNbiCMQueue(ids)
common.InsertNbiCm(ne, "UdmFunction", newUdmValueJson, common.ObjectOriginalEvent)
common.InsertNbiCm(ne, version, "UdmFunction", newUdmValueJson, common.ObjectOriginalEvent)
}
}
@@ -162,28 +162,28 @@ func SyncNbiCM() error {
Order("timestamp ASC").Pluck("value_json", &lastUdrJson).Error
newUdrValueJson := string(udrJSON)
if err != nil || lastUdrJson == "" {
common.InsertNbiCm(ne, "UdrFunction", newUdrValueJson, common.ObjectOriginalEvent)
nbiCm := common.InsertNbiCm(ne, "UdrFunction", newUdrValueJson, common.ObjectCreationEvent)
common.InsertNbiCm(ne, version, "UdrFunction", newUdrValueJson, common.ObjectOriginalEvent)
nbiCm := common.InsertNbiCm(ne, version, "UdrFunction", newUdrValueJson, common.ObjectCreationEvent)
redisqueue.AddNbiCMQueue([]string{strconv.Itoa(nbiCm.Id)})
} else {
var ids []string
added, modified, deleted, _ := common.CompareJSON(lastUdrJson, newUdrValueJson)
if len(added) > 0 {
nbiCm := common.InsertNbiCm(ne, "UdrFunction", common.ToJson(added), common.ObjectCreationEvent)
nbiCm := common.InsertNbiCm(ne, version, "UdrFunction", common.ToJson(added), common.ObjectCreationEvent)
ids = append(ids, strconv.Itoa(nbiCm.Id))
}
if len(modified) > 0 {
nbiCm := common.InsertNbiCm(ne, "UdrFunction", common.ToJson(modified), common.ObjectAttributeValueChangeEvent)
nbiCm := common.InsertNbiCm(ne, version, "UdrFunction", common.ToJson(modified), common.ObjectAttributeValueChangeEvent)
ids = append(ids, strconv.Itoa(nbiCm.Id))
}
if len(deleted) > 0 {
nbiCm := common.InsertNbiCm(ne, "UdrFunction", common.ToJson(deleted), common.ObjectDeletionEvent)
nbiCm := common.InsertNbiCm(ne, version, "UdrFunction", common.ToJson(deleted), common.ObjectDeletionEvent)
ids = append(ids, strconv.Itoa(nbiCm.Id))
}
if len(ids) > 0 {
redisqueue.AddNbiCMQueue(ids)
common.InsertNbiCm(ne, "UdrFunction", newUdrValueJson, common.ObjectOriginalEvent)
common.InsertNbiCm(ne, version, "UdrFunction", newUdrValueJson, common.ObjectOriginalEvent)
}
}
}
@@ -208,28 +208,28 @@ func SyncNbiCM() error {
Order("timestamp ASC").Pluck("value_json", &lastAusfJson).Error
newAusfValueJson := string(ausfJSON)
if err != nil || lastAusfJson == "" {
common.InsertNbiCm(ne, "AusfFunction", newAusfValueJson, common.ObjectOriginalEvent)
nbiCm := common.InsertNbiCm(ne, "AusfFunction", newAusfValueJson, common.ObjectCreationEvent)
common.InsertNbiCm(ne, version, "AusfFunction", newAusfValueJson, common.ObjectOriginalEvent)
nbiCm := common.InsertNbiCm(ne, version, "AusfFunction", newAusfValueJson, common.ObjectCreationEvent)
redisqueue.AddNbiCMQueue([]string{strconv.Itoa(nbiCm.Id)})
} else {
var ids []string
added, modified, deleted, _ := common.CompareJSON(lastAusfJson, newAusfValueJson)
if len(added) > 0 {
nbiCm := common.InsertNbiCm(ne, "AusfFunction", common.ToJson(added), common.ObjectCreationEvent)
nbiCm := common.InsertNbiCm(ne, version, "AusfFunction", common.ToJson(added), common.ObjectCreationEvent)
ids = append(ids, strconv.Itoa(nbiCm.Id))
}
if len(modified) > 0 {
nbiCm := common.InsertNbiCm(ne, "AusfFunction", common.ToJson(modified), common.ObjectAttributeValueChangeEvent)
nbiCm := common.InsertNbiCm(ne, version, "AusfFunction", common.ToJson(modified), common.ObjectAttributeValueChangeEvent)
ids = append(ids, strconv.Itoa(nbiCm.Id))
}
if len(deleted) > 0 {
nbiCm := common.InsertNbiCm(ne, "AusfFunction", common.ToJson(deleted), common.ObjectDeletionEvent)
nbiCm := common.InsertNbiCm(ne, version, "AusfFunction", common.ToJson(deleted), common.ObjectDeletionEvent)
ids = append(ids, strconv.Itoa(nbiCm.Id))
}
if len(ids) > 0 {
redisqueue.AddNbiCMQueue(ids)
common.InsertNbiCm(ne, "AusfFunction", newAusfValueJson, common.ObjectOriginalEvent)
common.InsertNbiCm(ne, version, "AusfFunction", newAusfValueJson, common.ObjectOriginalEvent)
}
}
}
@@ -252,28 +252,28 @@ func SyncNbiCM() error {
Order("timestamp ASC").Pluck("value_json", &lastIpJson).Error
newIpValueJson := string(ipJSON)
if err != nil || lastIpJson == "" {
common.InsertNbiCm(ne, "IPResource", newIpValueJson, common.ObjectOriginalEvent)
nbiCm := common.InsertNbiCm(ne, "IPResource", newIpValueJson, common.ObjectCreationEvent)
common.InsertNbiCm(ne, version, "IPResource", newIpValueJson, common.ObjectOriginalEvent)
nbiCm := common.InsertNbiCm(ne, version, "IPResource", newIpValueJson, common.ObjectCreationEvent)
redisqueue.AddNbiCMQueue([]string{strconv.Itoa(nbiCm.Id)})
} else {
var ids []string
added, modified, deleted, _ := common.CompareJSON(lastIpJson, newIpValueJson)
if len(added) > 0 {
nbiCm := common.InsertNbiCm(ne, "IPResource", common.ToJson(added), common.ObjectCreationEvent)
nbiCm := common.InsertNbiCm(ne, version, "IPResource", common.ToJson(added), common.ObjectCreationEvent)
ids = append(ids, strconv.Itoa(nbiCm.Id))
}
if len(modified) > 0 {
nbiCm := common.InsertNbiCm(ne, "IPResource", common.ToJson(modified), common.ObjectAttributeValueChangeEvent)
nbiCm := common.InsertNbiCm(ne, version, "IPResource", common.ToJson(modified), common.ObjectAttributeValueChangeEvent)
ids = append(ids, strconv.Itoa(nbiCm.Id))
}
if len(deleted) > 0 {
nbiCm := common.InsertNbiCm(ne, "IPResource", common.ToJson(deleted), common.ObjectDeletionEvent)
nbiCm := common.InsertNbiCm(ne, version, "IPResource", common.ToJson(deleted), common.ObjectDeletionEvent)
ids = append(ids, strconv.Itoa(nbiCm.Id))
}
if len(ids) > 0 {
redisqueue.AddNbiCMQueue(ids)
common.InsertNbiCm(ne, "IPResource", newIpValueJson, common.ObjectOriginalEvent)
common.InsertNbiCm(ne, version, "IPResource", newIpValueJson, common.ObjectOriginalEvent)
}
}
}