uint/uint64全部改为uint32
This commit is contained in:
@@ -18,7 +18,7 @@ import (
|
||||
// 如果用户没有指定某个等级的配置, 则默认为该等级消息只发送一次
|
||||
type AlarmNotificationTaskParams struct {
|
||||
// NotificationIntervals 告警通知的发送间隔时间,键为告警等级,值为时间间隔(分钟)
|
||||
NotificationIntervals map[models.SeverityLevel]uint `json:"notification_intervals"`
|
||||
NotificationIntervals map[models.SeverityLevel]uint32 `json:"notification_intervals"`
|
||||
}
|
||||
|
||||
// AlarmNotificationTask 告警通知发送任务
|
||||
@@ -107,9 +107,9 @@ func (t *AlarmNotificationTask) OnFailure(ctx context.Context, executeErr error)
|
||||
}
|
||||
|
||||
// ResolveDeviceIDs 从任务配置中解析并返回所有关联的设备ID列表
|
||||
func (t *AlarmNotificationTask) ResolveDeviceIDs(ctx context.Context) ([]uint, error) {
|
||||
func (t *AlarmNotificationTask) ResolveDeviceIDs(ctx context.Context) ([]uint32, error) {
|
||||
// 告警通知任务与设备无关
|
||||
return []uint{}, nil
|
||||
return []uint32{}, nil
|
||||
}
|
||||
|
||||
// parseParameters 解析任务参数
|
||||
|
||||
@@ -14,12 +14,12 @@ import (
|
||||
|
||||
// AreaThresholdCheckParams 定义了区域阈值检查任务的参数
|
||||
type AreaThresholdCheckParams struct {
|
||||
AreaControllerID uint `json:"area_controller_id"` // 区域主控ID
|
||||
AreaControllerID uint32 `json:"area_controller_id"` // 区域主控ID
|
||||
SensorType models.SensorType `json:"sensor_type"` // 传感器类型
|
||||
Thresholds float32 `json:"thresholds"` // 阈值
|
||||
Operator models.Operator `json:"operator"` // 操作符
|
||||
Level models.SeverityLevel `json:"level"` // 告警级别
|
||||
ExcludeDeviceIDs []uint `json:"exclude_device_ids"` // 排除的传感器ID
|
||||
ExcludeDeviceIDs []uint32 `json:"exclude_device_ids"` // 排除的传感器ID
|
||||
}
|
||||
|
||||
// AreaThresholdCheckTask 是一个任务,用于检查区域阈值并触发告警, 区域主控下的所有没有独立校验任务的设备都会受到此任务的检查
|
||||
@@ -62,7 +62,7 @@ func (a *AreaThresholdCheckTask) Execute(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// 构建忽略设备ID的map,方便快速查找
|
||||
ignoredMap := make(map[uint]struct{})
|
||||
ignoredMap := make(map[uint32]struct{})
|
||||
for _, id := range a.params.ExcludeDeviceIDs {
|
||||
ignoredMap[id] = struct{}{}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ func (a *AreaThresholdCheckTask) OnFailure(ctx context.Context, executeErr error
|
||||
logger.Errorf("区域阈值检测任务执行失败, 任务ID: %v: 执行失败: %v", a.taskLog.TaskID, executeErr)
|
||||
}
|
||||
|
||||
func (a *AreaThresholdCheckTask) ResolveDeviceIDs(ctx context.Context) ([]uint, error) {
|
||||
func (a *AreaThresholdCheckTask) ResolveDeviceIDs(ctx context.Context) ([]uint32, error) {
|
||||
taskCtx := logs.AddFuncName(ctx, a.ctx, "ResolveDeviceIDs")
|
||||
if err := a.parseParameters(taskCtx); err != nil {
|
||||
return nil, err
|
||||
@@ -156,7 +156,7 @@ func (a *AreaThresholdCheckTask) parseParameters(ctx context.Context) error {
|
||||
params.Level = models.WarnLevel
|
||||
}
|
||||
if params.ExcludeDeviceIDs == nil {
|
||||
params.ExcludeDeviceIDs = []uint{}
|
||||
params.ExcludeDeviceIDs = []uint32{}
|
||||
}
|
||||
|
||||
a.params = params
|
||||
|
||||
@@ -70,6 +70,6 @@ func (d *DelayTask) OnFailure(ctx context.Context, executeErr error) {
|
||||
logger.Errorf("任务 %v: 执行失败: %v", d.executionTask.TaskID, executeErr)
|
||||
}
|
||||
|
||||
func (d *DelayTask) ResolveDeviceIDs(ctx context.Context) ([]uint, error) {
|
||||
return []uint{}, nil
|
||||
func (d *DelayTask) ResolveDeviceIDs(ctx context.Context) ([]uint32, error) {
|
||||
return []uint32{}, nil
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
type DeviceThresholdCheckParams struct {
|
||||
DeviceID uint `json:"device_id"` // 设备ID
|
||||
DeviceID uint32 `json:"device_id"` // 设备ID
|
||||
SensorType models.SensorType `json:"sensor_type"` // 传感器类型
|
||||
Thresholds float32 `json:"thresholds"` // 阈值
|
||||
Operator models.Operator `json:"operator"` // 操作符
|
||||
@@ -188,10 +188,10 @@ func (d *DeviceThresholdCheckTask) OnFailure(ctx context.Context, executeErr err
|
||||
logger.Errorf("设备阈值检测任务执行失败, 任务ID: %v: 执行失败: %v", d.taskLog.TaskID, executeErr)
|
||||
}
|
||||
|
||||
func (d *DeviceThresholdCheckTask) ResolveDeviceIDs(ctx context.Context) ([]uint, error) {
|
||||
func (d *DeviceThresholdCheckTask) ResolveDeviceIDs(ctx context.Context) ([]uint32, error) {
|
||||
taskCtx := logs.AddFuncName(ctx, d.ctx, "ResolveDeviceIDs")
|
||||
if err := d.parseParameters(taskCtx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return []uint{d.params.DeviceID}, nil
|
||||
return []uint32{d.params.DeviceID}, nil
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func (t *FullCollectionTask) Execute(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
sensorsByController := make(map[uint][]*models.Device)
|
||||
sensorsByController := make(map[uint32][]*models.Device)
|
||||
for _, sensor := range sensors {
|
||||
sensorsByController[sensor.AreaControllerID] = append(sensorsByController[sensor.AreaControllerID], sensor)
|
||||
}
|
||||
@@ -97,7 +97,7 @@ func (t *FullCollectionTask) OnFailure(ctx context.Context, executeErr error) {
|
||||
}
|
||||
|
||||
// ResolveDeviceIDs 获取当前任务需要使用的设备ID列表
|
||||
func (t *FullCollectionTask) ResolveDeviceIDs(ctx context.Context) ([]uint, error) {
|
||||
func (t *FullCollectionTask) ResolveDeviceIDs(ctx context.Context) ([]uint32, error) {
|
||||
// 全量采集任务不和任何设备绑定, 每轮采集都会重新获取全量传感器
|
||||
return []uint{}, nil
|
||||
return []uint32{}, nil
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ import (
|
||||
// ReleaseFeedWeightTaskParams 定义了 ReleaseFeedWeightTask 的参数结构
|
||||
type ReleaseFeedWeightTaskParams struct {
|
||||
ReleaseWeight float32 `json:"release_weight"` // 需要释放的重量
|
||||
FeedPortDeviceID uint `json:"feed_port_device_id"` // 下料口ID
|
||||
MixingTankDeviceID uint `json:"mixing_tank_device_id"` // 称重传感器ID
|
||||
FeedPortDeviceID uint32 `json:"feed_port_device_id"` // 下料口ID
|
||||
MixingTankDeviceID uint32 `json:"mixing_tank_device_id"` // 称重传感器ID
|
||||
}
|
||||
|
||||
// ReleaseFeedWeightTask 是一个控制下料口释放指定重量的任务
|
||||
@@ -30,7 +30,7 @@ type ReleaseFeedWeightTask struct {
|
||||
|
||||
feedPortDevice *models.Device
|
||||
releaseWeight float32
|
||||
mixingTankDeviceID uint
|
||||
mixingTankDeviceID uint32
|
||||
|
||||
feedPort device.Service
|
||||
|
||||
@@ -178,10 +178,10 @@ func (r *ReleaseFeedWeightTask) OnFailure(ctx context.Context, executeErr error)
|
||||
logger.Errorf("善后处理完成, 日志ID:%v", r.claimedLog.ID)
|
||||
}
|
||||
|
||||
func (r *ReleaseFeedWeightTask) ResolveDeviceIDs(ctx context.Context) ([]uint, error) {
|
||||
func (r *ReleaseFeedWeightTask) ResolveDeviceIDs(ctx context.Context) ([]uint32, error) {
|
||||
taskCtx := logs.AddFuncName(ctx, r.ctx, "ResolveDeviceIDs")
|
||||
if err := r.parseParameters(taskCtx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return []uint{r.feedPortDevice.ID, r.mixingTankDeviceID}, nil
|
||||
return []uint32{r.feedPortDevice.ID, r.mixingTankDeviceID}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user