Browse Source

fix BUG#18666 阈值保留6位小数

dev
yfh 2 days ago
parent
commit
f8928cbd01
  1. 1
      dataSource/kafka/iotaData.go
  2. 2
      et_analyze/aggThreshold.go
  3. 2
      et_analyze/threshold.go
  4. 2
      et_calc/dataCalc.go
  5. 3
      master/app/et_master.go

1
dataSource/kafka/iotaData.go

@ -14,6 +14,7 @@ func (h IotaDataHandler) HandleMessage(message string) bool {
rawData := common_models.IotaData{} rawData := common_models.IotaData{}
err := json.Unmarshal([]byte(message), &rawData) err := json.Unmarshal([]byte(message), &rawData)
if err != nil { if err != nil {
log.Printf("[dataSource/kafka/iotaData/IotaHandler] Parse msg error: %v", err)
return false return false
} }
log.Printf("handler 处理[%s|%s]消息", rawData.DeviceId, rawData.TriggerTime) log.Printf("handler 处理[%s|%s]消息", rawData.DeviceId, rawData.TriggerTime)

2
et_analyze/aggThreshold.go

@ -121,7 +121,7 @@ func (t *AggThresholdHandler) judgeThreshold(aggData *common_models.AggData) *co
overThresholdItem := aggThreshold.FindThresholdInRange(protoItemThs, val) overThresholdItem := aggThreshold.FindThresholdInRange(protoItemThs, val)
if overThresholdItem != nil { if overThresholdItem != nil {
// content 格式如:应变的10分钟聚集变化率:-0.60με,超1级阈值[-1~-0.5] // content 格式如:应变的10分钟聚集变化率:-0.60με,超1级阈值[-1~-0.5]
content := fmt.Sprintf("%s的%s变化率:%.2f%s,超%d级阈值[%s]", protoItem.Name, aggTypeStr, val, protoItem.UnitName, overThresholdItem.Level, overThresholdItem.RangeText()) content := fmt.Sprintf("%s的%s变化率:%f%s,超%d级阈值[%s]", protoItem.Name, aggTypeStr, val, protoItem.UnitName, overThresholdItem.Level, overThresholdItem.RangeText())
ls = append(ls, common_models.ThresholdAlarmDetail{Level: overThresholdItem.Level, Content: content}) ls = append(ls, common_models.ThresholdAlarmDetail{Level: overThresholdItem.Level, Content: content})
} }
//log.Printf("[aggThreshold judgeThreshold] 测点[sensorId: %d] fieldName: %s, ChangedVal (float64): %f\n", aggData.SensorId, fieldName, val) //log.Printf("[aggThreshold judgeThreshold] 测点[sensorId: %d] fieldName: %s, ChangedVal (float64): %f\n", aggData.SensorId, fieldName, val)

2
et_analyze/threshold.go

@ -97,7 +97,7 @@ func (t *ThresholdHandler) judgeThreshold(station *common_models.Station) *commo
overThresholdItem := station.Threshold.FindThresholdInRange(protoItemThs, val) overThresholdItem := station.Threshold.FindThresholdInRange(protoItemThs, val)
if overThresholdItem != nil { if overThresholdItem != nil {
// content 格式如:1:湿度采集值:13.50%RH,超1级阈值[6~16] // content 格式如:1:湿度采集值:13.50%RH,超1级阈值[6~16]
content := fmt.Sprintf("%s采集值:%.2f%s,超%d级阈值[%s]", protoItem.Name, val, protoItem.UnitName, overThresholdItem.Level, overThresholdItem.RangeText()) content := fmt.Sprintf("%s采集值:%f%s,超%d级阈值[%s]", protoItem.Name, val, protoItem.UnitName, overThresholdItem.Level, overThresholdItem.RangeText())
ls = append(ls, common_models.ThresholdAlarmDetail{Level: overThresholdItem.Level, Content: content}) ls = append(ls, common_models.ThresholdAlarmDetail{Level: overThresholdItem.Level, Content: content})
} }
//fmt.Printf("[threshold judgeThreshold] 测点[%d-%s] fieldName: %s, ThemeVal (float64): %f\n", station.Info.Id, station.Info.Name, fieldName, val) //fmt.Printf("[threshold judgeThreshold] 测点[%d-%s] fieldName: %s, ThemeVal (float64): %f\n", station.Info.Id, station.Info.Name, fieldName, val)

2
et_calc/dataCalc.go

@ -111,7 +111,7 @@ func (the *CalcHandler) calcFormula(p *common_models.ProcessData) *common_models
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 {
outMap[outKey] = common_calc.Decimal(v*k, 5) outMap[outKey] = common_calc.Decimal(v*k, 6)
} else { } else {
if inV == "nil" { if inV == "nil" {
//数据模拟工具出现的称重 lane异常值 跳过 //数据模拟工具出现的称重 lane异常值 跳过

3
master/app/et_master.go

@ -198,7 +198,8 @@ func (the *EtMaster) callNodeService(node *NodeRpc, data common_models.IDataTrac
the.errorHandle(errorCode, node.args.Addr, fmt.Sprintf("%s|%s", data.R(), data.T())) the.errorHandle(errorCode, node.args.Addr, fmt.Sprintf("%s|%s", data.R(), data.T()))
} else { } else {
//log.Printf("node[%s]node处理后回复true。处理成功的数据*** %+v *** \n\n", node.args.Addr, data.R(), data.T()) //log.Printf("node[%s]node处理后回复true。处理成功的数据*** %+v *** \n\n", node.args.Addr, data.R(), data.T())
log.Printf("RPC[%s]node已处理的数据errorCode=%d *** %+v *** \n\n", serviceMethod, errorCode, v) //log.Printf("RPC[%s]node已处理的数据errorCode=%d *** %+v *** \n\n", serviceMethod, errorCode, v)
log.Printf("****** RPC[%s]node已处理的数据errorCode=%d ****** \n\n", serviceMethod, errorCode)
} }
} }

Loading…
Cancel
Save