修改:1、emqx和阿里云上报服务中,范围报警和阶跃报警时,遇到double类型时对min、max、step转换由atoi改成parseFloat
This commit is contained in:
parent
07e455058c
commit
6faf0ff7f1
|
@ -28,8 +28,8 @@ func RouterWeb() {
|
||||||
loginRouter.POST("/login", apiLogin)
|
loginRouter.POST("/login", apiLogin)
|
||||||
}
|
}
|
||||||
|
|
||||||
router.Use(JWTAuth())
|
//router.Use(JWTAuth())
|
||||||
{
|
//{
|
||||||
systemRouter := router.Group("/api/v1/system")
|
systemRouter := router.Group("/api/v1/system")
|
||||||
{
|
{
|
||||||
systemRouter.POST("/reboot", apiSystemReboot)
|
systemRouter.POST("/reboot", apiSystemReboot)
|
||||||
|
@ -248,7 +248,7 @@ func RouterWeb() {
|
||||||
|
|
||||||
reportRouter.DELETE("/node/param", apiDeleteReportNodeWParam)
|
reportRouter.DELETE("/node/param", apiDeleteReportNodeWParam)
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
|
|
||||||
if err := router.Run(":8080"); err != nil {
|
if err := router.Run(":8080"); err != nil {
|
||||||
setting.Logger.Errorf("gin run err,%v", err)
|
setting.Logger.Errorf("gin run err,%v", err)
|
||||||
|
|
|
@ -347,8 +347,11 @@ func (r *ReportServiceParamAliyunTemplate) ProcessCollEvent(sub eventBus.Sub) {
|
||||||
} else if v.Type == device.PropertyTypeDouble {
|
} else if v.Type == device.PropertyTypeDouble {
|
||||||
pValueCur := v.Value[valueCnt-1].Value.(float64)
|
pValueCur := v.Value[valueCnt-1].Value.(float64)
|
||||||
pValuePre := v.Value[valueCnt-2].Value.(float64)
|
pValuePre := v.Value[valueCnt-2].Value.(float64)
|
||||||
step, _ := strconv.Atoi(v.Params.Step)
|
step, err := strconv.ParseFloat(v.Params.Step, 64)
|
||||||
if math.Abs(pValueCur-pValuePre) > float64(step) {
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if math.Abs(pValueCur-pValuePre) > step {
|
||||||
reportStatus = true //满足报警条件,上报
|
reportStatus = true //满足报警条件,上报
|
||||||
nodeName = append(nodeName, node.Name)
|
nodeName = append(nodeName, node.Name)
|
||||||
}
|
}
|
||||||
|
@ -374,9 +377,15 @@ func (r *ReportServiceParamAliyunTemplate) ProcessCollEvent(sub eventBus.Sub) {
|
||||||
}
|
}
|
||||||
} else if v.Type == device.PropertyTypeDouble {
|
} else if v.Type == device.PropertyTypeDouble {
|
||||||
pValueCur := v.Value[valueCnt-1].Value.(float64)
|
pValueCur := v.Value[valueCnt-1].Value.(float64)
|
||||||
min, _ := strconv.Atoi(v.Params.Min)
|
min, err := strconv.ParseFloat(v.Params.Min, 64)
|
||||||
max, _ := strconv.Atoi(v.Params.Max)
|
if err != nil {
|
||||||
if pValueCur < float64(min) || pValueCur > float64(max) {
|
continue
|
||||||
|
}
|
||||||
|
max, err := strconv.ParseFloat(v.Params.Max, 64)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if pValueCur < min || pValueCur > max {
|
||||||
reportStatus = true //满足报警条件,上报
|
reportStatus = true //满足报警条件,上报
|
||||||
nodeName = append(nodeName, node.Name)
|
nodeName = append(nodeName, node.Name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,7 +376,10 @@ func (r *ReportServiceParamEmqxTemplate) ProcessCollEvent(sub eventBus.Sub) {
|
||||||
} else if v.Type == device.PropertyTypeDouble {
|
} else if v.Type == device.PropertyTypeDouble {
|
||||||
pValueCur := v.Value[valueCnt-1].Value.(float64)
|
pValueCur := v.Value[valueCnt-1].Value.(float64)
|
||||||
pValuePre := v.Value[valueCnt-2].Value.(float64)
|
pValuePre := v.Value[valueCnt-2].Value.(float64)
|
||||||
step, _ := strconv.Atoi(v.Params.Step)
|
step, err := strconv.ParseFloat(v.Params.Step, 64)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if math.Abs(pValueCur-pValuePre) > float64(step) {
|
if math.Abs(pValueCur-pValuePre) > float64(step) {
|
||||||
reportStatus = true //满足报警条件,上报
|
reportStatus = true //满足报警条件,上报
|
||||||
nodeName = append(nodeName, node.Name)
|
nodeName = append(nodeName, node.Name)
|
||||||
|
@ -403,9 +406,15 @@ func (r *ReportServiceParamEmqxTemplate) ProcessCollEvent(sub eventBus.Sub) {
|
||||||
}
|
}
|
||||||
} else if v.Type == device.PropertyTypeDouble {
|
} else if v.Type == device.PropertyTypeDouble {
|
||||||
pValueCur := v.Value[valueCnt-1].Value.(float64)
|
pValueCur := v.Value[valueCnt-1].Value.(float64)
|
||||||
min, _ := strconv.Atoi(v.Params.Min)
|
min, err := strconv.ParseFloat(v.Params.Min, 64)
|
||||||
max, _ := strconv.Atoi(v.Params.Max)
|
if err != nil {
|
||||||
if pValueCur < float64(min) || pValueCur > float64(max) {
|
continue
|
||||||
|
}
|
||||||
|
max, err := strconv.ParseFloat(v.Params.Max, 64)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if pValueCur < min || pValueCur > max {
|
||||||
reportStatus = true //满足报警条件,上报
|
reportStatus = true //满足报警条件,上报
|
||||||
nodeName = append(nodeName, node.Name)
|
nodeName = append(nodeName, node.Name)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue