issue-18 优化代码(只保证编译通过没检查)

This commit is contained in:
2025-09-26 22:50:08 +08:00
parent d9fe1683d2
commit 23b7f66d74
17 changed files with 767 additions and 251 deletions

View File

@@ -83,6 +83,8 @@ type Scheduler struct {
executionLogRepo repository.ExecutionLogRepository
deviceRepo repository.DeviceRepository
sensorDataRepo repository.SensorDataRepository
deviceCommandLogRepo repository.DeviceCommandLogRepository
pendingCollectionRepo repository.PendingCollectionRepository
planRepo repository.PlanRepository
comm transport.Communicator
analysisPlanTaskManager *AnalysisPlanTaskManager
@@ -103,8 +105,11 @@ func NewScheduler(
comm transport.Communicator,
analysisPlanTaskManager *AnalysisPlanTaskManager,
logger *logs.Logger,
deviceCommandLogRepo repository.DeviceCommandLogRepository,
pendingCollectionRepo repository.PendingCollectionRepository,
interval time.Duration,
numWorkers int) *Scheduler {
numWorkers int,
) *Scheduler {
return &Scheduler{
pendingTaskRepo: pendingTaskRepo,
executionLogRepo: executionLogRepo,
@@ -114,6 +119,8 @@ func NewScheduler(
comm: comm,
analysisPlanTaskManager: analysisPlanTaskManager,
logger: logger,
deviceCommandLogRepo: deviceCommandLogRepo,
pendingCollectionRepo: pendingCollectionRepo,
pollingInterval: interval,
workers: numWorkers,
progressTracker: NewProgressTracker(),
@@ -289,7 +296,7 @@ func (s *Scheduler) taskFactory(claimedLog *models.TaskExecutionLog) Task {
case models.TaskTypeWaiting:
return NewDelayTask(s.logger, claimedLog)
case models.TaskTypeReleaseFeedWeight:
return NewReleaseFeedWeightTask(claimedLog, s.deviceRepo, s.sensorDataRepo, s.comm, s.logger)
return NewReleaseFeedWeightTask(claimedLog, s.deviceRepo, s.sensorDataRepo, s.deviceCommandLogRepo, s.pendingCollectionRepo, s.comm, s.logger)
default:
// TODO 这里直接panic合适吗? 不过这个场景确实不该出现任何异常的任务类型