This commit is contained in:
2023-08-24 22:34:50 +08:00
parent 486f1163e8
commit 5456eb0045
3 changed files with 25 additions and 4 deletions

View File

@@ -8,10 +8,10 @@ logger:
count: 10 count: 10
omc: omc:
name: SZOMC1 name: BJ_OMC01
hosturi: http://127.0.0.1:3040 hosturi: http://127.0.0.1:3040
hostno: S001 hostno: S001
province: GD province: BJ
netabbr: HX netabbr: HX
vendor: RJ vendor: RJ

View File

@@ -97,7 +97,7 @@ tasks:
params: params:
interval: 1 interval: 1
unit: Day unit: Day
at: 00:00,06:00,12:00,18:00,20:43 at: 00:00,06:00,12:00,18:00,22:27
do: GenCmXmlFile do: GenCmXmlFile
- name: Task of Generate measure threshold alarm - name: Task of Generate measure threshold alarm
status: Inactive status: Inactive

View File

@@ -60,6 +60,8 @@ func (t *TaskFunc) ReadCmYaml(cmfile string) (map[string]interface{}, error) {
} }
func (t *TaskFunc) GenNFXmlFile(neType string) error { func (t *TaskFunc) GenNFXmlFile(neType string) error {
log.Info("GenNFXmlFile processing...")
var nes []NeInfo var nes []NeInfo
_, err := XormGetNeInfoByType(neType, &nes) _, err := XormGetNeInfoByType(neType, &nes)
if err != nil { if err != nil {
@@ -118,6 +120,7 @@ func (t *TaskFunc) GenNFXmlFile(neType string) error {
continue continue
} }
log.Trace("cmResult:", cmResult) log.Trace("cmResult:", cmResult)
//dataMap := make(map[string]interface{})
valueMap := make(map[string]interface{}) valueMap := make(map[string]interface{})
if cmResult.ValueJSON != "" { if cmResult.ValueJSON != "" {
err = json.Unmarshal([]byte(cmResult.ValueJSON), &valueMap) err = json.Unmarshal([]byte(cmResult.ValueJSON), &valueMap)
@@ -126,6 +129,17 @@ func (t *TaskFunc) GenNFXmlFile(neType string) error {
continue continue
} }
} }
// for _, valueMaps := range dataMap {
// if len(valueMaps.([]map[string]interface{})) > 0 {
// valueMap = valueMaps.([]map[string]interface{})[0]
// // err = json.Unmarshal([]byte(valueMaps.([]map[string]interface{})[0]), &valueMap)
// // if err != nil {
// // log.Error("Failed to json.Unmarshal:", err)
// // continue
// // }
// }
// }
log.Trace("valueMap:", valueMap) log.Trace("valueMap:", valueMap)
rmUID := ne.RmUID rmUID := ne.RmUID
var object cmschema.Object var object cmschema.Object
@@ -172,7 +186,14 @@ func (t *TaskFunc) GenNFXmlFile(neType string) error {
// v = fmt.Sprintf("%s", sortResult[p]) // v = fmt.Sprintf("%s", sortResult[p])
// } // }
// } // }
object.V = append(object.V, cmschema.V{IAttr: i, Value: fmt.Sprintf("%v", valueMap[p])}) var v string
if valueMap[p] == nil || valueMap[p] == "" {
v = "-"
} else {
v = fmt.Sprintf("%v", valueMap[p])
}
object.V = append(object.V, cmschema.V{IAttr: i, Value: v})
i++ i++
} }
//objects.FieldValue.Object = append(objects.FieldValue.Object, object) //objects.FieldValue.Object = append(objects.FieldValue.Object, object)