From d7e190a8cf01e3773b7c0ebaa1f63d3672dfc300 Mon Sep 17 00:00:00 2001 From: lucas Date: Tue, 15 Oct 2024 13:40:53 +0800 Subject: [PATCH] =?UTF-8?q?update=20=20=E8=AE=BE=E5=A4=87=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E5=B7=A5=E5=85=B7=E6=B2=A1=E6=9C=89=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=20=E8=AE=BE=E5=A4=87=E5=92=8C=E7=9B=91=E6=B5=8B=E5=8E=9F?= =?UTF-8?q?=E5=9E=8B,=E5=AD=97=E6=AE=B5=E6=98=A0=E5=B0=84=E5=85=B3?= =?UTF-8?q?=E7=B3=BB=E7=9A=84=EF=BC=8C=E9=BB=98=E8=AE=A4=E9=87=87=E7=94=A8?= =?UTF-8?q?=E7=9B=91=E6=B5=8B=E5=8E=9F=E5=9E=8B=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- et_Info/InfoHandler.go | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/et_Info/InfoHandler.go b/et_Info/InfoHandler.go index cf2a806..2f46137 100644 --- a/et_Info/InfoHandler.go +++ b/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 +}