diff --git a/et_calc/dataCalc.go b/et_calc/dataCalc.go index d0587a8..a6c4310 100644 --- a/et_calc/dataCalc.go +++ b/et_calc/dataCalc.go @@ -103,14 +103,14 @@ func (the *CalcHandler) calcFormula(p *common_models.ProcessData) *common_models for inK, inV := range resultData { inUnit := resultUnit[inK] outKey := device.DeviceFactorProto.FieldVal[inK] + if outKey == "" { + log.Printf("设备[%s]字段[%s]无绑定的监测原型[%s-%s] 字段输出", device.IotaDeviceId, inK, protoObj.Name, protoObj.Code) + continue + } outUnit := protoObj.GetProtoItem(outKey).UnitName k := the.unitHelper.GetUnitTransK(inUnit, outUnit) if v, ok := inV.(float64); ok { - if outKey != "" { - outMap[outKey] = common_calc.Decimal(v*k, 5) - } else { //无映射关系的 用原有key - outMap[inK] = common_calc.Decimal(v, 5) - } + outMap[outKey] = common_calc.Decimal(v*k, 5) } else { outMap[outKey] = inV }