Browse Source

update 设备绑定工具没有配置 设备和监测原型,字段映射关系的,默认采用监测原型字段

dev
lucas 2 weeks ago
parent
commit
d7e190a8cf
  1. 40
      et_Info/InfoHandler.go

40
et_Info/InfoHandler.go

@ -29,11 +29,6 @@ func (the *InfoHandler) GetStage() stages.Stage {
func (the *InfoHandler) getStationInfo(p *common_models.ProcessData) *common_models.ProcessData {
// TODO 测试 DeviceId = 22c76344-1eb2-4508-8aa6-4550c010e8f7 ,sensorId=18
//if p.DeviceData.DeviceId != "22c76344-1eb2-4508-8aa6-4550c010e8f7" {
// return &common_models.ProcessData{}
//}
s, err := the.configHelper.GetDeviceStationObjs(p.DeviceData.DeviceId)
if err == nil && s != nil {
p.Stations = s
@ -51,12 +46,7 @@ func (the *InfoHandler) getStationInfo(p *common_models.ProcessData) *common_mod
p.DeviceData.RawUnit = p.DeviceData.DeviceInfo.DeviceMeta.GetOutputUnit()
//存储测点obj
if len(p.Stations) > 0 {
go func() {
errSet := the.configHelper.SetDeviceStationObjs(p.DeviceData.DeviceId, p.Stations)
if errSet != nil {
log.Printf("SetDeviceStationObjs 缓存异常 err=%s", errSet.Error())
}
}()
the.configHelper.SetDeviceStationObjs(p.DeviceData.DeviceId, p.Stations)
}
}
return p
@ -69,29 +59,27 @@ func (the *InfoHandler) getFormulaInfo(p *common_models.ProcessData) {
if err != nil {
panic(err)
}
//绑定工具没有配置 设备和监测原型,字段映射关系的
if len(deviceFactorProto.FieldVal) == 0 {
log.Printf("设备[%s]和原型[%s]无绑定关系,默认采用监测原型字段", p.DeviceData.DeviceId, p.Stations[i].Info.ProtoCode)
deviceFactorProto.FieldVal = the.defaultDeviceFactorProtoFieldVal(p.Stations[i].Info.Proto)
}
for i2, device := range p.Stations[i].Info.Devices {
formulaInfo, err := the.configHelper.GetFormulaInfo(device.FormulaId)
if err == nil {
p.Stations[i].Info.Devices[i2].FormulaInfo = formulaInfo
p.Stations[i].Info.Devices[i2].DeviceFactorProto = deviceFactorProto
}
}
// TODO #TEST BEGIN 2024-10-01 测点设备没有公式信息,测试时先从设备监测原型中获取
//for i2, _ := range p.Stations[i].Info.Devices {
// p.Stations[i].Info.Devices[i2].FormulaId = deviceFactorProto.Formula
// formulaInfo, err := the.configHelper.GetFormulaInfo(deviceFactorProto.Formula)
// if err == nil {
// p.Stations[i].Info.Devices[i2].FormulaInfo = formulaInfo
// p.Stations[i].Info.Devices[i2].DeviceFactorProto = deviceFactorProto
// }
//}
// #TEST END
}
}
//func (the *InfoHandler) getThresholdInfo(p *common_models.ProcessData) {
// for _, stationInfo := range p.Stations {
// the.configHelper.GetStationThreshold(stationInfo.Info.Id)
// }
//}
func (the *InfoHandler) defaultDeviceFactorProtoFieldVal(p common_models.Proto) map[string]string {
fieldMap := make(map[string]string)
for _, item := range p.Items {
fieldMap[item.FieldName] = item.FieldName
}
return fieldMap
}

Loading…
Cancel
Save