修改:1、emqx和阿里云上报服务中,范围报警和阶跃报警时,遇到double类型时对min、max、step转换由atoi改成parseFloat
This commit is contained in:
parent
07e455058c
commit
6faf0ff7f1
|
@ -28,228 +28,228 @@ 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)
|
|
||||||
|
|
||||||
systemRouter.GET("/status", apiGetSystemStatus)
|
systemRouter.GET("/status", apiGetSystemStatus)
|
||||||
|
|
||||||
systemRouter.GET("/backup", apiBackupFiles)
|
systemRouter.GET("/backup", apiBackupFiles)
|
||||||
|
|
||||||
systemRouter.POST("/recover", apiRecoverFiles)
|
systemRouter.POST("/recover", apiRecoverFiles)
|
||||||
|
|
||||||
systemRouter.POST("/update", apiSystemUpdate)
|
systemRouter.POST("/update", apiSystemUpdate)
|
||||||
|
|
||||||
systemRouter.GET("/loginParam", apiSystemLoginParam)
|
systemRouter.GET("/loginParam", apiSystemLoginParam)
|
||||||
|
|
||||||
systemRouter.GET("/MemUseList", apiSystemMemoryUseList)
|
systemRouter.GET("/MemUseList", apiSystemMemoryUseList)
|
||||||
|
|
||||||
systemRouter.GET("/DiskUseList", apiSystemDiskUseList)
|
systemRouter.GET("/DiskUseList", apiSystemDiskUseList)
|
||||||
|
|
||||||
systemRouter.GET("/DeviceOnlineList", apiSystemDeviceOnlineList)
|
systemRouter.GET("/DeviceOnlineList", apiSystemDeviceOnlineList)
|
||||||
|
|
||||||
systemRouter.GET("/DevicePacketLossList", apiSystemDevicePacketLossList)
|
systemRouter.GET("/DevicePacketLossList", apiSystemDevicePacketLossList)
|
||||||
|
|
||||||
systemRouter.POST("/systemRTC", apiSystemSetSystemRTC)
|
systemRouter.POST("/systemRTC", apiSystemSetSystemRTC)
|
||||||
}
|
|
||||||
|
|
||||||
logRouter := router.Group("/api/v1/log")
|
|
||||||
{
|
|
||||||
logRouter.GET("/param", apiGetLogParam)
|
|
||||||
|
|
||||||
logRouter.POST("/param", apiSetLogParam)
|
|
||||||
|
|
||||||
logRouter.GET("/filesInfo", apiGetLogFilesInfo)
|
|
||||||
|
|
||||||
logRouter.DELETE("/files", apiDeleteLogFile)
|
|
||||||
|
|
||||||
logRouter.GET("/file", apiGetLogFile)
|
|
||||||
}
|
|
||||||
|
|
||||||
ntpRouter := router.Group("/api/v1/system/ntp")
|
|
||||||
{
|
|
||||||
ntpRouter.POST("/hostAddr", apiSystemSetNTPHost)
|
|
||||||
|
|
||||||
ntpRouter.GET("/hostAddr", apiSystemGetNTPHost)
|
|
||||||
}
|
|
||||||
|
|
||||||
networkRouter := router.Group("/api/v1/network")
|
|
||||||
{
|
|
||||||
networkRouter.POST("/param", apiAddNetwork)
|
|
||||||
|
|
||||||
networkRouter.PUT("/param", apiModifyNetwork)
|
|
||||||
|
|
||||||
networkRouter.DELETE("/param", apiDeleteNetwork)
|
|
||||||
|
|
||||||
networkRouter.GET("/param", apiGetNetwork)
|
|
||||||
|
|
||||||
networkRouter.GET("/linkstate", apiGetNetworkLinkState)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
serialRouter := router.Group("/api/v1/serial")
|
|
||||||
{
|
|
||||||
|
|
||||||
serialRouter.GET("/param", apiGetSerial)
|
|
||||||
}
|
|
||||||
|
|
||||||
deviceRouter := router.Group("/api/v1/device")
|
|
||||||
{
|
|
||||||
//增加采集接口
|
|
||||||
deviceRouter.POST("/interface", apiAddInterface)
|
|
||||||
|
|
||||||
//修改采集接口
|
|
||||||
deviceRouter.PUT("/interface", apiModifyInterface)
|
|
||||||
|
|
||||||
//删除采集接口
|
|
||||||
deviceRouter.DELETE("/interface", apiDeleteInterface)
|
|
||||||
|
|
||||||
//获取接口信息
|
|
||||||
deviceRouter.GET("/interface", apiGetInterfaceInfo)
|
|
||||||
|
|
||||||
//获取所有接口信息
|
|
||||||
deviceRouter.GET("/allInterface", apiGetAllInterfaceInfo)
|
|
||||||
|
|
||||||
//增加节点
|
|
||||||
deviceRouter.POST("/node", apiAddNode)
|
|
||||||
|
|
||||||
//修改单个节点
|
|
||||||
deviceRouter.PUT("/node", apiModifyNode)
|
|
||||||
|
|
||||||
//修改多个节点
|
|
||||||
deviceRouter.PUT("/nodes", apiModifyNodes)
|
|
||||||
|
|
||||||
//查看节点
|
|
||||||
deviceRouter.GET("/node", apiGetNode)
|
|
||||||
|
|
||||||
//查看节点变量
|
|
||||||
deviceRouter.GET("/nodeVariable", apiGetNodeVariableFromCache)
|
|
||||||
|
|
||||||
//查看节点历史变量
|
|
||||||
deviceRouter.GET("/nodeHistoryVariable", apiGetNodeHistoryVariableFromCache)
|
|
||||||
|
|
||||||
//查看节点变量实时值
|
|
||||||
deviceRouter.GET("/nodeRealVariable", apiGetNodeReadVariable)
|
|
||||||
|
|
||||||
//删除节点
|
|
||||||
deviceRouter.DELETE("/node", apiDeleteNode)
|
|
||||||
|
|
||||||
//增加设备模板
|
|
||||||
//deviceRouter.POST("/template", apiAddTemplate)
|
|
||||||
|
|
||||||
//获取设备模板
|
|
||||||
//deviceRouter.GET("/template", apiGetTemplate)
|
|
||||||
|
|
||||||
//增加设备物模型
|
|
||||||
deviceRouter.POST("/tsl", apiAddDeviceTSL)
|
|
||||||
|
|
||||||
//删除设备物模型
|
|
||||||
deviceRouter.DELETE("/tsl", apiDeleteDeviceTSL)
|
|
||||||
|
|
||||||
//修改设备物模型
|
|
||||||
deviceRouter.PUT("/tsl", apiModifyDeviceTSL)
|
|
||||||
|
|
||||||
//查看设备物模型
|
|
||||||
deviceRouter.GET("/tsl", apiGetDeviceTSL)
|
|
||||||
|
|
||||||
//查看设备物模型内容
|
|
||||||
deviceRouter.GET("/tsl/contents", apiGetDeviceTSLContents)
|
|
||||||
|
|
||||||
//批量导入设备物模型内容
|
|
||||||
deviceRouter.POST("/tsl/contents/csv", apiImportDeviceTSLContents)
|
|
||||||
|
|
||||||
//批量导出设备物模型内容
|
|
||||||
deviceRouter.GET("/tsl/contents/csv", apiExportDeviceTSLContents)
|
|
||||||
|
|
||||||
//导出设备物模型内容模板
|
|
||||||
deviceRouter.GET("/tsl/contents/template", apiExportDeviceTSLContentsTemplate)
|
|
||||||
|
|
||||||
//导入设备物模型插件
|
|
||||||
deviceRouter.POST("/tsl/plugin", apiImportDeviceTSLPlugin)
|
|
||||||
|
|
||||||
//导出设备物模型插件
|
|
||||||
deviceRouter.GET("/tsl/plugin", apiExportDeviceTSLPlugin)
|
|
||||||
|
|
||||||
//增加设备物模型属性
|
|
||||||
deviceRouter.POST("/tsl/property", apiAddDeviceTSLProperty)
|
|
||||||
|
|
||||||
//修改设备物模型属性
|
|
||||||
deviceRouter.PUT("/tsl/property", apiModifyDeviceTSLProperty)
|
|
||||||
|
|
||||||
//删除设备物模型属性
|
|
||||||
deviceRouter.DELETE("/tsl/properties", apiDeleteDeviceTSLProperties)
|
|
||||||
|
|
||||||
//查看设备物模型属性
|
|
||||||
deviceRouter.GET("/tsl/properties", apiGetDeviceTSLProperties)
|
|
||||||
|
|
||||||
//增加设备物模型服务
|
|
||||||
deviceRouter.POST("/tsl/service", apiAddDeviceTSLService)
|
|
||||||
|
|
||||||
//修改设备物模型服务
|
|
||||||
deviceRouter.PUT("/tsl/service", apiModifyDeviceTSLService)
|
|
||||||
|
|
||||||
//删除设备物模型服务
|
|
||||||
deviceRouter.DELETE("/tsl/services", apiDeleteDeviceTSLServices)
|
|
||||||
|
|
||||||
//获取通信接口
|
|
||||||
deviceRouter.GET("/commInterface", apiGetCommInterface)
|
|
||||||
|
|
||||||
//增加通信接口
|
|
||||||
deviceRouter.POST("/commInterface", apiAddCommInterface)
|
|
||||||
|
|
||||||
//修改通信接口
|
|
||||||
deviceRouter.PUT("/commInterface", apiModifyCommInterface)
|
|
||||||
|
|
||||||
//删除通信接口
|
|
||||||
deviceRouter.DELETE("/commInterface", apiDeleteCommInterface)
|
|
||||||
|
|
||||||
//增加串口通信接口
|
|
||||||
deviceRouter.POST("/commSerialInterface", apiAddCommSerialInterface)
|
|
||||||
|
|
||||||
//修改串口通信接口
|
|
||||||
deviceRouter.PUT("/commSerialInterface", apiModifyCommSerialInterface)
|
|
||||||
|
|
||||||
//删除串口通信接口
|
|
||||||
deviceRouter.DELETE("/commSerialInterface", apiDeleteCommSerialInterface)
|
|
||||||
|
|
||||||
//调用设备服务
|
|
||||||
deviceRouter.POST("/service", apiInvokeService)
|
|
||||||
|
|
||||||
//向采集接口发送透传数据
|
|
||||||
deviceRouter.POST("/interface/directData", apiSendDirectDataToCollInterface)
|
|
||||||
}
|
|
||||||
|
|
||||||
toolRouter := router.Group("/api/v1/tool")
|
|
||||||
{
|
|
||||||
//获取通信报文
|
|
||||||
toolRouter.POST("/commMessage", apiGetCommMessage)
|
|
||||||
}
|
|
||||||
|
|
||||||
pluginRouter := router.Group("/api/v1/update")
|
|
||||||
{
|
|
||||||
pluginRouter.POST("/plugin", apiUpdatePlugin)
|
|
||||||
}
|
|
||||||
|
|
||||||
reportRouter := router.Group("/api/v1/report")
|
|
||||||
{
|
|
||||||
reportRouter.POST("/param", apiSetReportGWParam)
|
|
||||||
|
|
||||||
reportRouter.GET("/param", apiGetReportGWParam)
|
|
||||||
|
|
||||||
reportRouter.DELETE("/param", apiDeleteReportGWParam)
|
|
||||||
|
|
||||||
reportRouter.POST("/node/param", apiSetReportNodeWParam)
|
|
||||||
|
|
||||||
reportRouter.POST("/nodes/param", apiBatchAddReportNodeParam)
|
|
||||||
|
|
||||||
reportRouter.GET("/node/param", apiGetReportNodeWParam)
|
|
||||||
|
|
||||||
reportRouter.DELETE("/node/param", apiDeleteReportNodeWParam)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logRouter := router.Group("/api/v1/log")
|
||||||
|
{
|
||||||
|
logRouter.GET("/param", apiGetLogParam)
|
||||||
|
|
||||||
|
logRouter.POST("/param", apiSetLogParam)
|
||||||
|
|
||||||
|
logRouter.GET("/filesInfo", apiGetLogFilesInfo)
|
||||||
|
|
||||||
|
logRouter.DELETE("/files", apiDeleteLogFile)
|
||||||
|
|
||||||
|
logRouter.GET("/file", apiGetLogFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
ntpRouter := router.Group("/api/v1/system/ntp")
|
||||||
|
{
|
||||||
|
ntpRouter.POST("/hostAddr", apiSystemSetNTPHost)
|
||||||
|
|
||||||
|
ntpRouter.GET("/hostAddr", apiSystemGetNTPHost)
|
||||||
|
}
|
||||||
|
|
||||||
|
networkRouter := router.Group("/api/v1/network")
|
||||||
|
{
|
||||||
|
networkRouter.POST("/param", apiAddNetwork)
|
||||||
|
|
||||||
|
networkRouter.PUT("/param", apiModifyNetwork)
|
||||||
|
|
||||||
|
networkRouter.DELETE("/param", apiDeleteNetwork)
|
||||||
|
|
||||||
|
networkRouter.GET("/param", apiGetNetwork)
|
||||||
|
|
||||||
|
networkRouter.GET("/linkstate", apiGetNetworkLinkState)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
serialRouter := router.Group("/api/v1/serial")
|
||||||
|
{
|
||||||
|
|
||||||
|
serialRouter.GET("/param", apiGetSerial)
|
||||||
|
}
|
||||||
|
|
||||||
|
deviceRouter := router.Group("/api/v1/device")
|
||||||
|
{
|
||||||
|
//增加采集接口
|
||||||
|
deviceRouter.POST("/interface", apiAddInterface)
|
||||||
|
|
||||||
|
//修改采集接口
|
||||||
|
deviceRouter.PUT("/interface", apiModifyInterface)
|
||||||
|
|
||||||
|
//删除采集接口
|
||||||
|
deviceRouter.DELETE("/interface", apiDeleteInterface)
|
||||||
|
|
||||||
|
//获取接口信息
|
||||||
|
deviceRouter.GET("/interface", apiGetInterfaceInfo)
|
||||||
|
|
||||||
|
//获取所有接口信息
|
||||||
|
deviceRouter.GET("/allInterface", apiGetAllInterfaceInfo)
|
||||||
|
|
||||||
|
//增加节点
|
||||||
|
deviceRouter.POST("/node", apiAddNode)
|
||||||
|
|
||||||
|
//修改单个节点
|
||||||
|
deviceRouter.PUT("/node", apiModifyNode)
|
||||||
|
|
||||||
|
//修改多个节点
|
||||||
|
deviceRouter.PUT("/nodes", apiModifyNodes)
|
||||||
|
|
||||||
|
//查看节点
|
||||||
|
deviceRouter.GET("/node", apiGetNode)
|
||||||
|
|
||||||
|
//查看节点变量
|
||||||
|
deviceRouter.GET("/nodeVariable", apiGetNodeVariableFromCache)
|
||||||
|
|
||||||
|
//查看节点历史变量
|
||||||
|
deviceRouter.GET("/nodeHistoryVariable", apiGetNodeHistoryVariableFromCache)
|
||||||
|
|
||||||
|
//查看节点变量实时值
|
||||||
|
deviceRouter.GET("/nodeRealVariable", apiGetNodeReadVariable)
|
||||||
|
|
||||||
|
//删除节点
|
||||||
|
deviceRouter.DELETE("/node", apiDeleteNode)
|
||||||
|
|
||||||
|
//增加设备模板
|
||||||
|
//deviceRouter.POST("/template", apiAddTemplate)
|
||||||
|
|
||||||
|
//获取设备模板
|
||||||
|
//deviceRouter.GET("/template", apiGetTemplate)
|
||||||
|
|
||||||
|
//增加设备物模型
|
||||||
|
deviceRouter.POST("/tsl", apiAddDeviceTSL)
|
||||||
|
|
||||||
|
//删除设备物模型
|
||||||
|
deviceRouter.DELETE("/tsl", apiDeleteDeviceTSL)
|
||||||
|
|
||||||
|
//修改设备物模型
|
||||||
|
deviceRouter.PUT("/tsl", apiModifyDeviceTSL)
|
||||||
|
|
||||||
|
//查看设备物模型
|
||||||
|
deviceRouter.GET("/tsl", apiGetDeviceTSL)
|
||||||
|
|
||||||
|
//查看设备物模型内容
|
||||||
|
deviceRouter.GET("/tsl/contents", apiGetDeviceTSLContents)
|
||||||
|
|
||||||
|
//批量导入设备物模型内容
|
||||||
|
deviceRouter.POST("/tsl/contents/csv", apiImportDeviceTSLContents)
|
||||||
|
|
||||||
|
//批量导出设备物模型内容
|
||||||
|
deviceRouter.GET("/tsl/contents/csv", apiExportDeviceTSLContents)
|
||||||
|
|
||||||
|
//导出设备物模型内容模板
|
||||||
|
deviceRouter.GET("/tsl/contents/template", apiExportDeviceTSLContentsTemplate)
|
||||||
|
|
||||||
|
//导入设备物模型插件
|
||||||
|
deviceRouter.POST("/tsl/plugin", apiImportDeviceTSLPlugin)
|
||||||
|
|
||||||
|
//导出设备物模型插件
|
||||||
|
deviceRouter.GET("/tsl/plugin", apiExportDeviceTSLPlugin)
|
||||||
|
|
||||||
|
//增加设备物模型属性
|
||||||
|
deviceRouter.POST("/tsl/property", apiAddDeviceTSLProperty)
|
||||||
|
|
||||||
|
//修改设备物模型属性
|
||||||
|
deviceRouter.PUT("/tsl/property", apiModifyDeviceTSLProperty)
|
||||||
|
|
||||||
|
//删除设备物模型属性
|
||||||
|
deviceRouter.DELETE("/tsl/properties", apiDeleteDeviceTSLProperties)
|
||||||
|
|
||||||
|
//查看设备物模型属性
|
||||||
|
deviceRouter.GET("/tsl/properties", apiGetDeviceTSLProperties)
|
||||||
|
|
||||||
|
//增加设备物模型服务
|
||||||
|
deviceRouter.POST("/tsl/service", apiAddDeviceTSLService)
|
||||||
|
|
||||||
|
//修改设备物模型服务
|
||||||
|
deviceRouter.PUT("/tsl/service", apiModifyDeviceTSLService)
|
||||||
|
|
||||||
|
//删除设备物模型服务
|
||||||
|
deviceRouter.DELETE("/tsl/services", apiDeleteDeviceTSLServices)
|
||||||
|
|
||||||
|
//获取通信接口
|
||||||
|
deviceRouter.GET("/commInterface", apiGetCommInterface)
|
||||||
|
|
||||||
|
//增加通信接口
|
||||||
|
deviceRouter.POST("/commInterface", apiAddCommInterface)
|
||||||
|
|
||||||
|
//修改通信接口
|
||||||
|
deviceRouter.PUT("/commInterface", apiModifyCommInterface)
|
||||||
|
|
||||||
|
//删除通信接口
|
||||||
|
deviceRouter.DELETE("/commInterface", apiDeleteCommInterface)
|
||||||
|
|
||||||
|
//增加串口通信接口
|
||||||
|
deviceRouter.POST("/commSerialInterface", apiAddCommSerialInterface)
|
||||||
|
|
||||||
|
//修改串口通信接口
|
||||||
|
deviceRouter.PUT("/commSerialInterface", apiModifyCommSerialInterface)
|
||||||
|
|
||||||
|
//删除串口通信接口
|
||||||
|
deviceRouter.DELETE("/commSerialInterface", apiDeleteCommSerialInterface)
|
||||||
|
|
||||||
|
//调用设备服务
|
||||||
|
deviceRouter.POST("/service", apiInvokeService)
|
||||||
|
|
||||||
|
//向采集接口发送透传数据
|
||||||
|
deviceRouter.POST("/interface/directData", apiSendDirectDataToCollInterface)
|
||||||
|
}
|
||||||
|
|
||||||
|
toolRouter := router.Group("/api/v1/tool")
|
||||||
|
{
|
||||||
|
//获取通信报文
|
||||||
|
toolRouter.POST("/commMessage", apiGetCommMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
pluginRouter := router.Group("/api/v1/update")
|
||||||
|
{
|
||||||
|
pluginRouter.POST("/plugin", apiUpdatePlugin)
|
||||||
|
}
|
||||||
|
|
||||||
|
reportRouter := router.Group("/api/v1/report")
|
||||||
|
{
|
||||||
|
reportRouter.POST("/param", apiSetReportGWParam)
|
||||||
|
|
||||||
|
reportRouter.GET("/param", apiGetReportGWParam)
|
||||||
|
|
||||||
|
reportRouter.DELETE("/param", apiDeleteReportGWParam)
|
||||||
|
|
||||||
|
reportRouter.POST("/node/param", apiSetReportNodeWParam)
|
||||||
|
|
||||||
|
reportRouter.POST("/nodes/param", apiBatchAddReportNodeParam)
|
||||||
|
|
||||||
|
reportRouter.GET("/node/param", apiGetReportNodeWParam)
|
||||||
|
|
||||||
|
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