float64全部改float32

This commit is contained in:
2025-11-10 21:42:46 +08:00
parent 75306941c2
commit 3e711551e7
21 changed files with 74 additions and 73 deletions

View File

@@ -16,7 +16,7 @@ import (
type DeviceThresholdCheckParams struct {
DeviceID uint `json:"device_id"` // 设备ID
SensorType models.SensorType `json:"sensor_type"` // 传感器类型
Thresholds float64 `json:"thresholds"` // 阈值
Thresholds float32 `json:"thresholds"` // 阈值
Operator models.Operator `json:"operator"` // 操作符
Level models.SeverityLevel `json:"level"` // 告警等级
}
@@ -55,7 +55,7 @@ func (d *DeviceThresholdCheckTask) Execute(ctx context.Context) error {
return fmt.Errorf("任务 %v: 获取最新传感器数据失败: %v", d.taskLog.TaskID, err)
}
var currentValue float64
var currentValue float32
var alarmCode models.AlarmCode
switch d.params.SensorType {
@@ -123,7 +123,7 @@ func (d *DeviceThresholdCheckTask) Execute(ctx context.Context) error {
}
// checkThreshold 校验当前值是否满足阈值条件
func (d *DeviceThresholdCheckTask) checkThreshold(currentValue float64, operator models.Operator, threshold float64) bool {
func (d *DeviceThresholdCheckTask) checkThreshold(currentValue float32, operator models.Operator, threshold float32) bool {
switch operator {
case models.OperatorLessThan:
return currentValue < threshold