106 lines
5.3 KiB
Go
106 lines
5.3 KiB
Go
package service
|
|
|
|
import (
|
|
"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
|
|
"git.huangwc.com/pig/pig-farm-controller/internal/infra/repository"
|
|
)
|
|
|
|
// MonitorService 定义了监控相关的业务逻辑服务
|
|
type MonitorService struct {
|
|
sensorDataRepo repository.SensorDataRepository
|
|
deviceCommandLogRepo repository.DeviceCommandLogRepository
|
|
executionLogRepo repository.ExecutionLogRepository
|
|
pendingCollectionRepo repository.PendingCollectionRepository
|
|
userActionLogRepo repository.UserActionLogRepository
|
|
rawMaterialRepo repository.RawMaterialRepository
|
|
medicationRepo repository.MedicationLogRepository
|
|
pigBatchRepo repository.PigBatchRepository
|
|
pigBatchLogRepo repository.PigBatchLogRepository
|
|
// 在这里可以添加其他超表模型的仓库依赖
|
|
}
|
|
|
|
// NewMonitorService 创建一个新的 MonitorService 实例
|
|
func NewMonitorService(
|
|
sensorDataRepo repository.SensorDataRepository,
|
|
deviceCommandLogRepo repository.DeviceCommandLogRepository,
|
|
executionLogRepo repository.ExecutionLogRepository,
|
|
pendingCollectionRepo repository.PendingCollectionRepository,
|
|
userActionLogRepo repository.UserActionLogRepository,
|
|
rawMaterialRepo repository.RawMaterialRepository,
|
|
medicationRepo repository.MedicationLogRepository,
|
|
pigBatchRepo repository.PigBatchRepository,
|
|
pigBatchLogRepo repository.PigBatchLogRepository,
|
|
) *MonitorService {
|
|
return &MonitorService{
|
|
sensorDataRepo: sensorDataRepo,
|
|
deviceCommandLogRepo: deviceCommandLogRepo,
|
|
executionLogRepo: executionLogRepo,
|
|
pendingCollectionRepo: pendingCollectionRepo,
|
|
userActionLogRepo: userActionLogRepo,
|
|
rawMaterialRepo: rawMaterialRepo,
|
|
medicationRepo: medicationRepo,
|
|
pigBatchRepo: pigBatchRepo,
|
|
pigBatchLogRepo: pigBatchLogRepo,
|
|
}
|
|
}
|
|
|
|
// ListSensorData 负责处理查询传感器数据列表的业务逻辑
|
|
func (s *MonitorService) ListSensorData(opts repository.SensorDataListOptions, page, pageSize int) ([]models.SensorData, int64, error) {
|
|
return s.sensorDataRepo.List(opts, page, pageSize)
|
|
}
|
|
|
|
// ListDeviceCommandLogs 负责处理查询设备命令日志列表的业务逻辑
|
|
func (s *MonitorService) ListDeviceCommandLogs(opts repository.DeviceCommandLogListOptions, page, pageSize int) ([]models.DeviceCommandLog, int64, error) {
|
|
return s.deviceCommandLogRepo.List(opts, page, pageSize)
|
|
}
|
|
|
|
// ListPlanExecutionLogs 负责处理查询计划执行日志列表的业务逻辑
|
|
func (s *MonitorService) ListPlanExecutionLogs(opts repository.PlanExecutionLogListOptions, page, pageSize int) ([]models.PlanExecutionLog, int64, error) {
|
|
return s.executionLogRepo.ListPlanExecutionLogs(opts, page, pageSize)
|
|
}
|
|
|
|
// ListTaskExecutionLogs 负责处理查询任务执行日志列表的业务逻辑
|
|
func (s *MonitorService) ListTaskExecutionLogs(opts repository.TaskExecutionLogListOptions, page, pageSize int) ([]models.TaskExecutionLog, int64, error) {
|
|
return s.executionLogRepo.ListTaskExecutionLogs(opts, page, pageSize)
|
|
}
|
|
|
|
// ListPendingCollections 负责处理查询待采集请求列表的业务逻辑
|
|
func (s *MonitorService) ListPendingCollections(opts repository.PendingCollectionListOptions, page, pageSize int) ([]models.PendingCollection, int64, error) {
|
|
return s.pendingCollectionRepo.List(opts, page, pageSize)
|
|
}
|
|
|
|
// ListUserActionLogs 负责处理查询用户操作日志列表的业务逻辑
|
|
func (s *MonitorService) ListUserActionLogs(opts repository.UserActionLogListOptions, page, pageSize int) ([]models.UserActionLog, int64, error) {
|
|
return s.userActionLogRepo.List(opts, page, pageSize)
|
|
}
|
|
|
|
// ListRawMaterialPurchases 负责处理查询原料采购记录列表的业务逻辑
|
|
func (s *MonitorService) ListRawMaterialPurchases(opts repository.RawMaterialPurchaseListOptions, page, pageSize int) ([]models.RawMaterialPurchase, int64, error) {
|
|
return s.rawMaterialRepo.ListRawMaterialPurchases(opts, page, pageSize)
|
|
}
|
|
|
|
// ListRawMaterialStockLogs 负责处理查询原料库存日志列表的业务逻辑
|
|
func (s *MonitorService) ListRawMaterialStockLogs(opts repository.RawMaterialStockLogListOptions, page, pageSize int) ([]models.RawMaterialStockLog, int64, error) {
|
|
return s.rawMaterialRepo.ListRawMaterialStockLogs(opts, page, pageSize)
|
|
}
|
|
|
|
// ListFeedUsageRecords 负责处理查询饲料使用记录列表的业务逻辑
|
|
func (s *MonitorService) ListFeedUsageRecords(opts repository.FeedUsageRecordListOptions, page, pageSize int) ([]models.FeedUsageRecord, int64, error) {
|
|
return s.rawMaterialRepo.ListFeedUsageRecords(opts, page, pageSize)
|
|
}
|
|
|
|
// ListMedicationLogs 负责处理查询用药记录列表的业务逻辑
|
|
func (s *MonitorService) ListMedicationLogs(opts repository.MedicationLogListOptions, page, pageSize int) ([]models.MedicationLog, int64, error) {
|
|
return s.medicationRepo.ListMedicationLogs(opts, page, pageSize)
|
|
}
|
|
|
|
// ListPigBatchLogs 负责处理查询猪批次日志列表的业务逻辑
|
|
func (s *MonitorService) ListPigBatchLogs(opts repository.PigBatchLogListOptions, page, pageSize int) ([]models.PigBatchLog, int64, error) {
|
|
return s.pigBatchLogRepo.List(opts, page, pageSize)
|
|
}
|
|
|
|
// ListWeighingBatches 负责处理查询批次称重记录列表的业务逻辑
|
|
func (s *MonitorService) ListWeighingBatches(opts repository.WeighingBatchListOptions, page, pageSize int) ([]models.WeighingBatch, int64, error) {
|
|
return s.pigBatchRepo.ListWeighingBatches(opts, page, pageSize)
|
|
}
|