| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -26,11 +26,11 @@ import (
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				// Infrastructure 聚合了所有基础设施层的组件。
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				type Infrastructure struct {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					Storage       database.Storage
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					Repos         *Repositories
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					Lora          *LoraComponents
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					NotifyService domain_notify.Service
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					TokenService  token.Service
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					storage       database.Storage
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					repos         *Repositories
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					lora          *LoraComponents
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					notifyService domain_notify.Service
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					tokenService  token.Service
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				// initInfrastructure 初始化所有基础设施层组件。
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -47,7 +47,7 @@ func initInfrastructure(cfg *config.Config, logger *logs.Logger) (*Infrastructur
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return nil, err
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					notifyService, err := initNotifyService(cfg.Notify, logger, repos.UserRepo, repos.NotificationRepo)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					notifyService, err := initNotifyService(cfg.Notify, logger, repos.userRepo, repos.notificationRepo)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					if err != nil {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return nil, fmt.Errorf("初始化通知服务失败: %w", err)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -55,112 +55,112 @@ func initInfrastructure(cfg *config.Config, logger *logs.Logger) (*Infrastructur
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					tokenService := token.NewTokenService([]byte(cfg.App.JWTSecret))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					return &Infrastructure{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Storage:       storage,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Repos:         repos,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Lora:          lora,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						NotifyService: notifyService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						TokenService:  tokenService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						storage:       storage,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						repos:         repos,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						lora:          lora,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						notifyService: notifyService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						tokenService:  tokenService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}, nil
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				// Repositories 聚合了所有的仓库实例。
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				type Repositories struct {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					UserRepo              repository.UserRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					DeviceRepo            repository.DeviceRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					AreaControllerRepo    repository.AreaControllerRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					DeviceTemplateRepo    repository.DeviceTemplateRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PlanRepo              repository.PlanRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PendingTaskRepo       repository.PendingTaskRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					ExecutionLogRepo      repository.ExecutionLogRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					SensorDataRepo        repository.SensorDataRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					DeviceCommandLogRepo  repository.DeviceCommandLogRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PendingCollectionRepo repository.PendingCollectionRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					UserActionLogRepo     repository.UserActionLogRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PigBatchRepo          repository.PigBatchRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PigBatchLogRepo       repository.PigBatchLogRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PigFarmRepo           repository.PigFarmRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PigPenRepo            repository.PigPenRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PigTransferLogRepo    repository.PigTransferLogRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PigTradeRepo          repository.PigTradeRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PigSickPigLogRepo     repository.PigSickLogRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					MedicationLogRepo     repository.MedicationLogRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					RawMaterialRepo       repository.RawMaterialRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					NotificationRepo      repository.NotificationRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					UnitOfWork            repository.UnitOfWork
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					userRepo              repository.UserRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					deviceRepo            repository.DeviceRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					areaControllerRepo    repository.AreaControllerRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					deviceTemplateRepo    repository.DeviceTemplateRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					planRepo              repository.PlanRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pendingTaskRepo       repository.PendingTaskRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					executionLogRepo      repository.ExecutionLogRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					sensorDataRepo        repository.SensorDataRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					deviceCommandLogRepo  repository.DeviceCommandLogRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pendingCollectionRepo repository.PendingCollectionRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					userActionLogRepo     repository.UserActionLogRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigBatchRepo          repository.PigBatchRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigBatchLogRepo       repository.PigBatchLogRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigFarmRepo           repository.PigFarmRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigPenRepo            repository.PigPenRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigTransferLogRepo    repository.PigTransferLogRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigTradeRepo          repository.PigTradeRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigSickPigLogRepo     repository.PigSickLogRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					medicationLogRepo     repository.MedicationLogRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					rawMaterialRepo       repository.RawMaterialRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					notificationRepo      repository.NotificationRepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					unitOfWork            repository.UnitOfWork
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				// initRepositories 初始化所有的仓库。
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				func initRepositories(db *gorm.DB, logger *logs.Logger) *Repositories {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					return &Repositories{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						UserRepo:              repository.NewGormUserRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						DeviceRepo:            repository.NewGormDeviceRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						AreaControllerRepo:    repository.NewGormAreaControllerRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						DeviceTemplateRepo:    repository.NewGormDeviceTemplateRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PlanRepo:              repository.NewGormPlanRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PendingTaskRepo:       repository.NewGormPendingTaskRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						ExecutionLogRepo:      repository.NewGormExecutionLogRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						SensorDataRepo:        repository.NewGormSensorDataRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						DeviceCommandLogRepo:  repository.NewGormDeviceCommandLogRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PendingCollectionRepo: repository.NewGormPendingCollectionRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						UserActionLogRepo:     repository.NewGormUserActionLogRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PigBatchRepo:          repository.NewGormPigBatchRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PigBatchLogRepo:       repository.NewGormPigBatchLogRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PigFarmRepo:           repository.NewGormPigFarmRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PigPenRepo:            repository.NewGormPigPenRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PigTransferLogRepo:    repository.NewGormPigTransferLogRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PigTradeRepo:          repository.NewGormPigTradeRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PigSickPigLogRepo:     repository.NewGormPigSickLogRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						MedicationLogRepo:     repository.NewGormMedicationLogRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						RawMaterialRepo:       repository.NewGormRawMaterialRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						NotificationRepo:      repository.NewGormNotificationRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						UnitOfWork:            repository.NewGormUnitOfWork(db, logger),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						userRepo:              repository.NewGormUserRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						deviceRepo:            repository.NewGormDeviceRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						areaControllerRepo:    repository.NewGormAreaControllerRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						deviceTemplateRepo:    repository.NewGormDeviceTemplateRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						planRepo:              repository.NewGormPlanRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pendingTaskRepo:       repository.NewGormPendingTaskRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						executionLogRepo:      repository.NewGormExecutionLogRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						sensorDataRepo:        repository.NewGormSensorDataRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						deviceCommandLogRepo:  repository.NewGormDeviceCommandLogRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pendingCollectionRepo: repository.NewGormPendingCollectionRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						userActionLogRepo:     repository.NewGormUserActionLogRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pigBatchRepo:          repository.NewGormPigBatchRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pigBatchLogRepo:       repository.NewGormPigBatchLogRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pigFarmRepo:           repository.NewGormPigFarmRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pigPenRepo:            repository.NewGormPigPenRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pigTransferLogRepo:    repository.NewGormPigTransferLogRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pigTradeRepo:          repository.NewGormPigTradeRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pigSickPigLogRepo:     repository.NewGormPigSickLogRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						medicationLogRepo:     repository.NewGormMedicationLogRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						rawMaterialRepo:       repository.NewGormRawMaterialRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						notificationRepo:      repository.NewGormNotificationRepository(db),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						unitOfWork:            repository.NewGormUnitOfWork(db, logger),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				// DomainServices 聚合了所有的领域服务实例。
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				type DomainServices struct {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PigPenTransferManager   pig.PigPenTransferManager
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PigTradeManager         pig.PigTradeManager
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PigSickManager          pig.SickPigManager
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PigBatchDomain          pig.PigBatchService
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					GeneralDeviceService    device.Service
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigPenTransferManager   pig.PigPenTransferManager
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigTradeManager         pig.PigTradeManager
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigSickManager          pig.SickPigManager
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigBatchDomain          pig.PigBatchService
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					generalDeviceService    device.Service
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					taskFactory             plan.TaskFactory
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PlanExecutionManager    plan.ExecutionManager
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					AnalysisPlanTaskManager plan.AnalysisPlanTaskManager
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					planExecutionManager    plan.ExecutionManager
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					analysisPlanTaskManager plan.AnalysisPlanTaskManager
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					planService             plan.Service
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				// initDomainServices 初始化所有的领域服务。
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				func initDomainServices(cfg *config.Config, infra *Infrastructure, logger *logs.Logger) *DomainServices {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					// 猪群管理相关
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigPenTransferManager := pig.NewPigPenTransferManager(infra.Repos.PigPenRepo, infra.Repos.PigTransferLogRepo, infra.Repos.PigBatchRepo)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigTradeManager := pig.NewPigTradeManager(infra.Repos.PigTradeRepo)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigSickManager := pig.NewSickPigManager(infra.Repos.PigSickPigLogRepo, infra.Repos.MedicationLogRepo)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigBatchDomain := pig.NewPigBatchService(infra.Repos.PigBatchRepo, infra.Repos.PigBatchLogRepo, infra.Repos.UnitOfWork,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigPenTransferManager := pig.NewPigPenTransferManager(infra.repos.pigPenRepo, infra.repos.pigTransferLogRepo, infra.repos.pigBatchRepo)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigTradeManager := pig.NewPigTradeManager(infra.repos.pigTradeRepo)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigSickManager := pig.NewSickPigManager(infra.repos.pigSickPigLogRepo, infra.repos.medicationLogRepo)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigBatchDomain := pig.NewPigBatchService(infra.repos.pigBatchRepo, infra.repos.pigBatchLogRepo, infra.repos.unitOfWork,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pigPenTransferManager, pigTradeManager, pigSickManager)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					// 通用设备服务
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					generalDeviceService := device.NewGeneralDeviceService(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.DeviceRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.DeviceCommandLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.PendingCollectionRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.deviceRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.deviceCommandLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.pendingCollectionRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						logger,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Lora.Comm,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.lora.comm,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					// 任务工厂
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					taskFactory := task.NewTaskFactory(logger, infra.Repos.SensorDataRepo, infra.Repos.DeviceRepo, generalDeviceService)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					taskFactory := task.NewTaskFactory(logger, infra.repos.sensorDataRepo, infra.repos.deviceRepo, generalDeviceService)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					// 计划任务管理器
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					analysisPlanTaskManager := plan.NewAnalysisPlanTaskManager(infra.Repos.PlanRepo, infra.Repos.PendingTaskRepo, infra.Repos.ExecutionLogRepo, logger)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					analysisPlanTaskManager := plan.NewAnalysisPlanTaskManager(infra.repos.planRepo, infra.repos.pendingTaskRepo, infra.repos.executionLogRepo, logger)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					// 任务执行器
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					planExecutionManager := plan.NewPlanExecutionManager(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.PendingTaskRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.ExecutionLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.DeviceRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.SensorDataRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.PlanRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.pendingTaskRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.executionLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.deviceRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.sensorDataRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.planRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						analysisPlanTaskManager,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						taskFactory,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						logger,
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -173,75 +173,75 @@ func initDomainServices(cfg *config.Config, infra *Infrastructure, logger *logs.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					planService := plan.NewPlanService(planExecutionManager, analysisPlanTaskManager, logger)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					return &DomainServices{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PigPenTransferManager:   pigPenTransferManager,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PigTradeManager:         pigTradeManager,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PigSickManager:          pigSickManager,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PigBatchDomain:          pigBatchDomain,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						GeneralDeviceService:    generalDeviceService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						AnalysisPlanTaskManager: analysisPlanTaskManager,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pigPenTransferManager:   pigPenTransferManager,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pigTradeManager:         pigTradeManager,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pigSickManager:          pigSickManager,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pigBatchDomain:          pigBatchDomain,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						generalDeviceService:    generalDeviceService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						analysisPlanTaskManager: analysisPlanTaskManager,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						taskFactory:             taskFactory,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PlanExecutionManager:    planExecutionManager,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						planExecutionManager:    planExecutionManager,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						planService:             planService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				// AppServices 聚合了所有的应用服务实例。
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				type AppServices struct {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PigFarmService  service.PigFarmService
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PigBatchService service.PigBatchService
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					MonitorService  service.MonitorService
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					DeviceService   service.DeviceService
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					PlanService     service.PlanService
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					UserService     service.UserService
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					AuditService    audit.Service
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigFarmService  service.PigFarmService
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigBatchService service.PigBatchService
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					monitorService  service.MonitorService
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					deviceService   service.DeviceService
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					planService     service.PlanService
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					userService     service.UserService
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					auditService    audit.Service
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				// initAppServices 初始化所有的应用服务。
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				func initAppServices(infra *Infrastructure, domainServices *DomainServices, logger *logs.Logger) *AppServices {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigFarmService := service.NewPigFarmService(infra.Repos.PigFarmRepo, infra.Repos.PigPenRepo, infra.Repos.PigBatchRepo, domainServices.PigBatchDomain, infra.Repos.UnitOfWork, logger)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigBatchService := service.NewPigBatchService(domainServices.PigBatchDomain, logger)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigFarmService := service.NewPigFarmService(infra.repos.pigFarmRepo, infra.repos.pigPenRepo, infra.repos.pigBatchRepo, domainServices.pigBatchDomain, infra.repos.unitOfWork, logger)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pigBatchService := service.NewPigBatchService(domainServices.pigBatchDomain, logger)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					monitorService := service.NewMonitorService(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.SensorDataRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.DeviceCommandLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.ExecutionLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.PlanRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.PendingCollectionRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.UserActionLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.RawMaterialRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.MedicationLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.PigBatchRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.PigBatchLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.PigTransferLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.PigSickPigLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.PigTradeRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.NotificationRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.sensorDataRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.deviceCommandLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.executionLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.planRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.pendingCollectionRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.userActionLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.rawMaterialRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.medicationLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.pigBatchRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.pigBatchLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.pigTransferLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.pigSickPigLogRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.pigTradeRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.notificationRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					deviceService := service.NewDeviceService(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.DeviceRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.AreaControllerRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.Repos.DeviceTemplateRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						domainServices.GeneralDeviceService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.deviceRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.areaControllerRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						infra.repos.deviceTemplateRepo,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						domainServices.generalDeviceService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					auditService := audit.NewService(infra.Repos.UserActionLogRepo, logger)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					planService := service.NewPlanService(logger, infra.Repos.PlanRepo, domainServices.AnalysisPlanTaskManager)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					userService := service.NewUserService(infra.Repos.UserRepo, infra.TokenService, infra.NotifyService, logger)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					auditService := audit.NewService(infra.repos.userActionLogRepo, logger)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					planService := service.NewPlanService(logger, infra.repos.planRepo, domainServices.analysisPlanTaskManager)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					userService := service.NewUserService(infra.repos.userRepo, infra.tokenService, infra.notifyService, logger)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					return &AppServices{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PigFarmService:  pigFarmService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PigBatchService: pigBatchService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						MonitorService:  monitorService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						DeviceService:   deviceService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						AuditService:    auditService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						PlanService:     planService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						UserService:     userService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pigFarmService:  pigFarmService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						pigBatchService: pigBatchService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						monitorService:  monitorService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						deviceService:   deviceService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						auditService:    auditService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						planService:     planService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						userService:     userService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				// LoraComponents 聚合了所有 LoRa 相关组件。
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				type LoraComponents struct {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					ListenHandler webhook.ListenHandler
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					Comm          transport.Communicator
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					LoraListener  transport.Listener
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					listenHandler webhook.ListenHandler
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					comm          transport.Communicator
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					loraListener  transport.Listener
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				// initLora 根据配置初始化 LoRa 相关组件。
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -256,13 +256,13 @@ func initLora(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					if cfg.Lora.Mode == config.LoraMode_LoRaWAN {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						logger.Info("当前运行模式: lora_wan。初始化 ChirpStack 监听器和传输层。")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						listenHandler = webhook.NewChirpStackListener(logger, repos.SensorDataRepo, repos.DeviceRepo, repos.AreaControllerRepo, repos.DeviceCommandLogRepo, repos.PendingCollectionRepo)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						listenHandler = webhook.NewChirpStackListener(logger, repos.sensorDataRepo, repos.deviceRepo, repos.areaControllerRepo, repos.deviceCommandLogRepo, repos.pendingCollectionRepo)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						comm = lora.NewChirpStackTransport(cfg.ChirpStack, logger)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						loraListener = lora.NewPlaceholderTransport(logger)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					} else {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						logger.Info("当前运行模式: lora_mesh。初始化 LoRa Mesh 传输层和占位符监听器。")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						listenHandler = webhook.NewPlaceholderListener(logger)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						tp, err := lora.NewLoRaMeshUartPassthroughTransport(cfg.LoraMesh, logger, repos.AreaControllerRepo, repos.PendingCollectionRepo, repos.DeviceRepo, repos.SensorDataRepo)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						tp, err := lora.NewLoRaMeshUartPassthroughTransport(cfg.LoraMesh, logger, repos.areaControllerRepo, repos.pendingCollectionRepo, repos.deviceRepo, repos.sensorDataRepo)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if err != nil {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return nil, fmt.Errorf("无法初始化 LoRa Mesh 模块: %w", err)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -271,9 +271,9 @@ func initLora(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					return &LoraComponents{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						ListenHandler: listenHandler,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						Comm:          comm,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						LoraListener:  loraListener,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						listenHandler: listenHandler,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						comm:          comm,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						loraListener:  loraListener,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}, nil
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				 
 |