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 AreaThresholdCheckParams struct {
AreaControllerID uint `json:"area_controller_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"` // 告警级别
ExcludeDeviceIDs []uint `json:"exclude_device_ids"` // 排除的传感器ID

View File

@@ -11,7 +11,7 @@ import (
)
type DelayTaskParams struct {
DelayDuration float64 `json:"delay_duration"`
DelayDuration float32 `json:"delay_duration"`
}
// DelayTask 是一个用于模拟延迟的 Task 实现

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

View File

@@ -15,7 +15,7 @@ import (
// ReleaseFeedWeightTaskParams 定义了 ReleaseFeedWeightTask 的参数结构
type ReleaseFeedWeightTaskParams struct {
ReleaseWeight float64 `json:"release_weight"` // 需要释放的重量
ReleaseWeight float32 `json:"release_weight"` // 需要释放的重量
FeedPortDeviceID uint `json:"feed_port_device_id"` // 下料口ID
MixingTankDeviceID uint `json:"mixing_tank_device_id"` // 称重传感器ID
}
@@ -29,7 +29,7 @@ type ReleaseFeedWeightTask struct {
claimedLog *models.TaskExecutionLog
feedPortDevice *models.Device
releaseWeight float64
releaseWeight float32
mixingTankDeviceID uint
feedPort device.Service
@@ -100,7 +100,7 @@ func (r *ReleaseFeedWeightTask) Execute(ctx context.Context) error {
}
// 获取当前搅拌罐重量
func (r *ReleaseFeedWeightTask) getNowWeight(ctx context.Context) (float64, error) {
func (r *ReleaseFeedWeightTask) getNowWeight(ctx context.Context) (float32, error) {
taskCtx, logger := logs.Trace(ctx, r.ctx, "getNowWeight")
sensorData, err := r.sensorDataRepo.GetLatestSensorDataByDeviceIDAndSensorType(taskCtx, r.mixingTankDeviceID, models.SensorTypeWeight)
if err != nil {