|
@ -103,14 +103,14 @@ func (the *CalcHandler) calcFormula(p *common_models.ProcessData) *common_models |
|
|
for inK, inV := range resultData { |
|
|
for inK, inV := range resultData { |
|
|
inUnit := resultUnit[inK] |
|
|
inUnit := resultUnit[inK] |
|
|
outKey := device.DeviceFactorProto.FieldVal[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 |
|
|
outUnit := protoObj.GetProtoItem(outKey).UnitName |
|
|
k := the.unitHelper.GetUnitTransK(inUnit, outUnit) |
|
|
k := the.unitHelper.GetUnitTransK(inUnit, outUnit) |
|
|
if v, ok := inV.(float64); ok { |
|
|
if v, ok := inV.(float64); ok { |
|
|
if outKey != "" { |
|
|
outMap[outKey] = common_calc.Decimal(v*k, 5) |
|
|
outMap[outKey] = common_calc.Decimal(v*k, 5) |
|
|
|
|
|
} else { //无映射关系的 用原有key
|
|
|
|
|
|
outMap[inK] = common_calc.Decimal(v, 5) |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
outMap[outKey] = inV |
|
|
outMap[outKey] = inV |
|
|
} |
|
|
} |
|
|