issue_49 #51
@@ -7,7 +7,6 @@ import (
 | 
				
			|||||||
	"git.huangwc.com/pig/pig-farm-controller/internal/app/dto"
 | 
						"git.huangwc.com/pig/pig-farm-controller/internal/app/dto"
 | 
				
			||||||
	"git.huangwc.com/pig/pig-farm-controller/internal/app/service"
 | 
						"git.huangwc.com/pig/pig-farm-controller/internal/app/service"
 | 
				
			||||||
	"git.huangwc.com/pig/pig-farm-controller/internal/infra/logs"
 | 
						"git.huangwc.com/pig/pig-farm-controller/internal/infra/logs"
 | 
				
			||||||
	"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
 | 
					 | 
				
			||||||
	"git.huangwc.com/pig/pig-farm-controller/internal/infra/repository"
 | 
						"git.huangwc.com/pig/pig-farm-controller/internal/infra/repository"
 | 
				
			||||||
	"github.com/labstack/echo/v4"
 | 
						"github.com/labstack/echo/v4"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -44,18 +43,7 @@ func (c *Controller) ListSensorData(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.SensorDataListOptions{
 | 
						resp, err := c.monitorService.ListSensorData(&req)
 | 
				
			||||||
		DeviceID:  req.DeviceID,
 | 
					 | 
				
			||||||
		OrderBy:   req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime: req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:   req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if req.SensorType != nil {
 | 
					 | 
				
			||||||
		sensorType := models.SensorType(*req.SensorType)
 | 
					 | 
				
			||||||
		opts.SensorType = &sensorType
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListSensorData(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -66,8 +54,7 @@ func (c *Controller) ListSensorData(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取传感器数据失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取传感器数据失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListSensorDataResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取传感器数据成功", resp, actionType, "获取传感器数据成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取传感器数据成功", resp, actionType, "获取传感器数据成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -89,15 +76,7 @@ func (c *Controller) ListDeviceCommandLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.DeviceCommandLogListOptions{
 | 
						resp, err := c.monitorService.ListDeviceCommandLogs(&req)
 | 
				
			||||||
		DeviceID:        req.DeviceID,
 | 
					 | 
				
			||||||
		ReceivedSuccess: req.ReceivedSuccess,
 | 
					 | 
				
			||||||
		OrderBy:         req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime:       req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:         req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListDeviceCommandLogs(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -108,8 +87,7 @@ func (c *Controller) ListDeviceCommandLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取设备命令日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取设备命令日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListDeviceCommandLogResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取设备命令日志成功", resp, actionType, "获取设备命令日志成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取设备命令日志成功", resp, actionType, "获取设备命令日志成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -131,18 +109,7 @@ func (c *Controller) ListPlanExecutionLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.PlanExecutionLogListOptions{
 | 
						resp, err := c.monitorService.ListPlanExecutionLogs(&req)
 | 
				
			||||||
		PlanID:    req.PlanID,
 | 
					 | 
				
			||||||
		OrderBy:   req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime: req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:   req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if req.Status != nil {
 | 
					 | 
				
			||||||
		status := models.ExecutionStatus(*req.Status)
 | 
					 | 
				
			||||||
		opts.Status = &status
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	planLogs, plans, total, err := c.monitorService.ListPlanExecutionLogs(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -153,8 +120,7 @@ func (c *Controller) ListPlanExecutionLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取计划执行日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取计划执行日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListPlanExecutionLogResponse(planLogs, plans, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(planLogs), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取计划执行日志成功", resp, actionType, "获取计划执行日志成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取计划执行日志成功", resp, actionType, "获取计划执行日志成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -176,19 +142,7 @@ func (c *Controller) ListTaskExecutionLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.TaskExecutionLogListOptions{
 | 
						resp, err := c.monitorService.ListTaskExecutionLogs(&req)
 | 
				
			||||||
		PlanExecutionLogID: req.PlanExecutionLogID,
 | 
					 | 
				
			||||||
		TaskID:             req.TaskID,
 | 
					 | 
				
			||||||
		OrderBy:            req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime:          req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:            req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if req.Status != nil {
 | 
					 | 
				
			||||||
		status := models.ExecutionStatus(*req.Status)
 | 
					 | 
				
			||||||
		opts.Status = &status
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListTaskExecutionLogs(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -199,8 +153,7 @@ func (c *Controller) ListTaskExecutionLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取任务执行日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取任务执行日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListTaskExecutionLogResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取任务执行日志成功", resp, actionType, "获取任务执行日志成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取任务执行日志成功", resp, actionType, "获取任务执行日志成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -222,18 +175,7 @@ func (c *Controller) ListPendingCollections(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.PendingCollectionListOptions{
 | 
						resp, err := c.monitorService.ListPendingCollections(&req)
 | 
				
			||||||
		DeviceID:  req.DeviceID,
 | 
					 | 
				
			||||||
		OrderBy:   req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime: req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:   req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if req.Status != nil {
 | 
					 | 
				
			||||||
		status := models.PendingCollectionStatus(*req.Status)
 | 
					 | 
				
			||||||
		opts.Status = &status
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListPendingCollections(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -244,8 +186,7 @@ func (c *Controller) ListPendingCollections(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取待采集请求失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取待采集请求失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListPendingCollectionResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取待采集请求成功", resp, actionType, "获取待采集请求成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取待采集请求成功", resp, actionType, "获取待采集请求成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -267,20 +208,7 @@ func (c *Controller) ListUserActionLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.UserActionLogListOptions{
 | 
						resp, err := c.monitorService.ListUserActionLogs(&req)
 | 
				
			||||||
		UserID:     req.UserID,
 | 
					 | 
				
			||||||
		Username:   req.Username,
 | 
					 | 
				
			||||||
		ActionType: req.ActionType,
 | 
					 | 
				
			||||||
		OrderBy:    req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime:  req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:    req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if req.Status != nil {
 | 
					 | 
				
			||||||
		status := models.AuditStatus(*req.Status)
 | 
					 | 
				
			||||||
		opts.Status = &status
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListUserActionLogs(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -291,8 +219,7 @@ func (c *Controller) ListUserActionLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取用户操作日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取用户操作日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListUserActionLogResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取用户操作日志成功", resp, actionType, "获取用户操作日志成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取用户操作日志成功", resp, actionType, "获取用户操作日志成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -314,15 +241,7 @@ func (c *Controller) ListRawMaterialPurchases(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.RawMaterialPurchaseListOptions{
 | 
						resp, err := c.monitorService.ListRawMaterialPurchases(&req)
 | 
				
			||||||
		RawMaterialID: req.RawMaterialID,
 | 
					 | 
				
			||||||
		Supplier:      req.Supplier,
 | 
					 | 
				
			||||||
		OrderBy:       req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime:     req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:       req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListRawMaterialPurchases(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -333,8 +252,7 @@ func (c *Controller) ListRawMaterialPurchases(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取原料采购记录失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取原料采购记录失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListRawMaterialPurchaseResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取原料采购记录成功", resp, actionType, "获取原料采购记录成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取原料采购记录成功", resp, actionType, "获取原料采购记录成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -356,19 +274,7 @@ func (c *Controller) ListRawMaterialStockLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.RawMaterialStockLogListOptions{
 | 
						resp, err := c.monitorService.ListRawMaterialStockLogs(&req)
 | 
				
			||||||
		RawMaterialID: req.RawMaterialID,
 | 
					 | 
				
			||||||
		SourceID:      req.SourceID,
 | 
					 | 
				
			||||||
		OrderBy:       req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime:     req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:       req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if req.SourceType != nil {
 | 
					 | 
				
			||||||
		sourceType := models.StockLogSourceType(*req.SourceType)
 | 
					 | 
				
			||||||
		opts.SourceType = &sourceType
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListRawMaterialStockLogs(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -379,8 +285,7 @@ func (c *Controller) ListRawMaterialStockLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取原料库存日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取原料库存日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListRawMaterialStockLogResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取原料库存日志成功", resp, actionType, "获取原料库存日志成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取原料库存日志成功", resp, actionType, "获取原料库存日志成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -402,16 +307,7 @@ func (c *Controller) ListFeedUsageRecords(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.FeedUsageRecordListOptions{
 | 
						resp, err := c.monitorService.ListFeedUsageRecords(&req)
 | 
				
			||||||
		PenID:         req.PenID,
 | 
					 | 
				
			||||||
		FeedFormulaID: req.FeedFormulaID,
 | 
					 | 
				
			||||||
		OperatorID:    req.OperatorID,
 | 
					 | 
				
			||||||
		OrderBy:       req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime:     req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:       req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListFeedUsageRecords(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -422,8 +318,7 @@ func (c *Controller) ListFeedUsageRecords(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取饲料使用记录失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取饲料使用记录失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListFeedUsageRecordResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取饲料使用记录成功", resp, actionType, "获取饲料使用记录成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取饲料使用记录成功", resp, actionType, "获取饲料使用记录成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -445,20 +340,7 @@ func (c *Controller) ListMedicationLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.MedicationLogListOptions{
 | 
						resp, err := c.monitorService.ListMedicationLogs(&req)
 | 
				
			||||||
		PigBatchID:   req.PigBatchID,
 | 
					 | 
				
			||||||
		MedicationID: req.MedicationID,
 | 
					 | 
				
			||||||
		OperatorID:   req.OperatorID,
 | 
					 | 
				
			||||||
		OrderBy:      req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime:    req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:      req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if req.Reason != nil {
 | 
					 | 
				
			||||||
		reason := models.MedicationReasonType(*req.Reason)
 | 
					 | 
				
			||||||
		opts.Reason = &reason
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListMedicationLogs(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -469,8 +351,7 @@ func (c *Controller) ListMedicationLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取用药记录失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取用药记录失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListMedicationLogResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取用药记录成功", resp, actionType, "获取用药记录成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取用药记录成功", resp, actionType, "获取用药记录成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -492,19 +373,7 @@ func (c *Controller) ListPigBatchLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.PigBatchLogListOptions{
 | 
						resp, err := c.monitorService.ListPigBatchLogs(&req)
 | 
				
			||||||
		PigBatchID: req.PigBatchID,
 | 
					 | 
				
			||||||
		OperatorID: req.OperatorID,
 | 
					 | 
				
			||||||
		OrderBy:    req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime:  req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:    req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if req.ChangeType != nil {
 | 
					 | 
				
			||||||
		changeType := models.LogChangeType(*req.ChangeType)
 | 
					 | 
				
			||||||
		opts.ChangeType = &changeType
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListPigBatchLogs(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -515,8 +384,7 @@ func (c *Controller) ListPigBatchLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取猪批次日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取猪批次日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListPigBatchLogResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取猪批次日志成功", resp, actionType, "获取猪批次日志成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取猪批次日志成功", resp, actionType, "获取猪批次日志成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -538,14 +406,7 @@ func (c *Controller) ListWeighingBatches(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.WeighingBatchListOptions{
 | 
						resp, err := c.monitorService.ListWeighingBatches(&req)
 | 
				
			||||||
		PigBatchID: req.PigBatchID,
 | 
					 | 
				
			||||||
		OrderBy:    req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime:  req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:    req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListWeighingBatches(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -556,8 +417,7 @@ func (c *Controller) ListWeighingBatches(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取批次称重记录失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取批次称重记录失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListWeighingBatchResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取批次称重记录成功", resp, actionType, "获取批次称重记录成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取批次称重记录成功", resp, actionType, "获取批次称重记录成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -579,16 +439,7 @@ func (c *Controller) ListWeighingRecords(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.WeighingRecordListOptions{
 | 
						resp, err := c.monitorService.ListWeighingRecords(&req)
 | 
				
			||||||
		WeighingBatchID: req.WeighingBatchID,
 | 
					 | 
				
			||||||
		PenID:           req.PenID,
 | 
					 | 
				
			||||||
		OperatorID:      req.OperatorID,
 | 
					 | 
				
			||||||
		OrderBy:         req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime:       req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:         req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListWeighingRecords(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -599,8 +450,7 @@ func (c *Controller) ListWeighingRecords(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取单次称重记录失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取单次称重记录失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListWeighingRecordResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取单次称重记录成功", resp, actionType, "获取单次称重记录成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取单次称重记录成功", resp, actionType, "获取单次称重记录成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -622,21 +472,7 @@ func (c *Controller) ListPigTransferLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.PigTransferLogListOptions{
 | 
						resp, err := c.monitorService.ListPigTransferLogs(&req)
 | 
				
			||||||
		PigBatchID:    req.PigBatchID,
 | 
					 | 
				
			||||||
		PenID:         req.PenID,
 | 
					 | 
				
			||||||
		OperatorID:    req.OperatorID,
 | 
					 | 
				
			||||||
		CorrelationID: req.CorrelationID,
 | 
					 | 
				
			||||||
		OrderBy:       req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime:     req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:       req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if req.TransferType != nil {
 | 
					 | 
				
			||||||
		transferType := models.PigTransferType(*req.TransferType)
 | 
					 | 
				
			||||||
		opts.TransferType = &transferType
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListPigTransferLogs(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -647,8 +483,7 @@ func (c *Controller) ListPigTransferLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取猪只迁移日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取猪只迁移日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListPigTransferLogResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取猪只迁移日志成功", resp, actionType, "获取猪只迁移日志成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取猪只迁移日志成功", resp, actionType, "获取猪只迁移日志成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -670,24 +505,7 @@ func (c *Controller) ListPigSickLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.PigSickLogListOptions{
 | 
						resp, err := c.monitorService.ListPigSickLogs(&req)
 | 
				
			||||||
		PigBatchID: req.PigBatchID,
 | 
					 | 
				
			||||||
		PenID:      req.PenID,
 | 
					 | 
				
			||||||
		OperatorID: req.OperatorID,
 | 
					 | 
				
			||||||
		OrderBy:    req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime:  req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:    req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if req.Reason != nil {
 | 
					 | 
				
			||||||
		reason := models.PigBatchSickPigReasonType(*req.Reason)
 | 
					 | 
				
			||||||
		opts.Reason = &reason
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if req.TreatmentLocation != nil {
 | 
					 | 
				
			||||||
		treatmentLocation := models.PigBatchSickPigTreatmentLocation(*req.TreatmentLocation)
 | 
					 | 
				
			||||||
		opts.TreatmentLocation = &treatmentLocation
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListPigSickLogs(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -698,8 +516,7 @@ func (c *Controller) ListPigSickLogs(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取病猪日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取病猪日志失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListPigSickLogResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取病猪日志成功", resp, actionType, "获取病猪日志成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取病猪日志成功", resp, actionType, "获取病猪日志成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -721,16 +538,7 @@ func (c *Controller) ListPigPurchases(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.PigPurchaseListOptions{
 | 
						resp, err := c.monitorService.ListPigPurchases(&req)
 | 
				
			||||||
		PigBatchID: req.PigBatchID,
 | 
					 | 
				
			||||||
		Supplier:   req.Supplier,
 | 
					 | 
				
			||||||
		OperatorID: req.OperatorID,
 | 
					 | 
				
			||||||
		OrderBy:    req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime:  req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:    req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListPigPurchases(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -741,8 +549,7 @@ func (c *Controller) ListPigPurchases(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取猪只采购记录失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取猪只采购记录失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListPigPurchaseResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取猪只采购记录成功", resp, actionType, "获取猪只采购记录成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取猪只采购记录成功", resp, actionType, "获取猪只采购记录成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -764,16 +571,7 @@ func (c *Controller) ListPigSales(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.PigSaleListOptions{
 | 
						resp, err := c.monitorService.ListPigSales(&req)
 | 
				
			||||||
		PigBatchID: req.PigBatchID,
 | 
					 | 
				
			||||||
		Buyer:      req.Buyer,
 | 
					 | 
				
			||||||
		OperatorID: req.OperatorID,
 | 
					 | 
				
			||||||
		OrderBy:    req.OrderBy,
 | 
					 | 
				
			||||||
		StartTime:  req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:    req.EndTime,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListPigSales(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -784,8 +582,7 @@ func (c *Controller) ListPigSales(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取猪只售卖记录失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取猪只售卖记录失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListPigSaleResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取猪只售卖记录成功", resp, actionType, "获取猪只售卖记录成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取猪只售卖记录成功", resp, actionType, "获取猪只售卖记录成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -807,17 +604,7 @@ func (c *Controller) ListNotifications(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts := repository.NotificationListOptions{
 | 
						resp, err := c.monitorService.ListNotifications(&req)
 | 
				
			||||||
		UserID:       req.UserID,
 | 
					 | 
				
			||||||
		NotifierType: req.NotifierType,
 | 
					 | 
				
			||||||
		Level:        req.Level,
 | 
					 | 
				
			||||||
		StartTime:    req.StartTime,
 | 
					 | 
				
			||||||
		EndTime:      req.EndTime,
 | 
					 | 
				
			||||||
		OrderBy:      req.OrderBy,
 | 
					 | 
				
			||||||
		Status:       req.Status,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, total, err := c.monitorService.ListNotifications(opts, req.Page, req.PageSize)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if errors.Is(err, repository.ErrInvalidPagination) {
 | 
							if errors.Is(err, repository.ErrInvalidPagination) {
 | 
				
			||||||
			c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
								c.logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
 | 
				
			||||||
@@ -828,7 +615,6 @@ func (c *Controller) ListNotifications(ctx echo.Context) error {
 | 
				
			|||||||
		return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "批量查询通知失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
							return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "批量查询通知失败: "+err.Error(), actionType, "服务层查询失败", req)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp := dto.NewListNotificationResponse(data, total, req.Page, req.PageSize)
 | 
						c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
 | 
				
			||||||
	c.logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(data), total)
 | 
					 | 
				
			||||||
	return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "批量查询通知成功", resp, actionType, "批量查询通知成功", req)
 | 
						return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "批量查询通知成功", resp, actionType, "批量查询通知成功", req)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,30 +1,31 @@
 | 
				
			|||||||
package service
 | 
					package service
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"git.huangwc.com/pig/pig-farm-controller/internal/app/dto"
 | 
				
			||||||
	"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
 | 
						"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
 | 
				
			||||||
	"git.huangwc.com/pig/pig-farm-controller/internal/infra/repository"
 | 
						"git.huangwc.com/pig/pig-farm-controller/internal/infra/repository"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// MonitorService 定义了监控相关的业务逻辑服务接口
 | 
					// MonitorService 定义了监控相关的业务逻辑服务接口
 | 
				
			||||||
type MonitorService interface {
 | 
					type MonitorService interface {
 | 
				
			||||||
	ListSensorData(opts repository.SensorDataListOptions, page, pageSize int) ([]models.SensorData, int64, error)
 | 
						ListSensorData(req *dto.ListSensorDataRequest) (*dto.ListSensorDataResponse, error)
 | 
				
			||||||
	ListDeviceCommandLogs(opts repository.DeviceCommandLogListOptions, page, pageSize int) ([]models.DeviceCommandLog, int64, error)
 | 
						ListDeviceCommandLogs(req *dto.ListDeviceCommandLogRequest) (*dto.ListDeviceCommandLogResponse, error)
 | 
				
			||||||
	ListPlanExecutionLogs(opts repository.PlanExecutionLogListOptions, page, pageSize int) ([]models.PlanExecutionLog, []models.Plan, int64, error)
 | 
						ListPlanExecutionLogs(req *dto.ListPlanExecutionLogRequest) (*dto.ListPlanExecutionLogResponse, error)
 | 
				
			||||||
	ListTaskExecutionLogs(opts repository.TaskExecutionLogListOptions, page, pageSize int) ([]models.TaskExecutionLog, int64, error)
 | 
						ListTaskExecutionLogs(req *dto.ListTaskExecutionLogRequest) (*dto.ListTaskExecutionLogResponse, error)
 | 
				
			||||||
	ListPendingCollections(opts repository.PendingCollectionListOptions, page, pageSize int) ([]models.PendingCollection, int64, error)
 | 
						ListPendingCollections(req *dto.ListPendingCollectionRequest) (*dto.ListPendingCollectionResponse, error)
 | 
				
			||||||
	ListUserActionLogs(opts repository.UserActionLogListOptions, page, pageSize int) ([]models.UserActionLog, int64, error)
 | 
						ListUserActionLogs(req *dto.ListUserActionLogRequest) (*dto.ListUserActionLogResponse, error)
 | 
				
			||||||
	ListRawMaterialPurchases(opts repository.RawMaterialPurchaseListOptions, page, pageSize int) ([]models.RawMaterialPurchase, int64, error)
 | 
						ListRawMaterialPurchases(req *dto.ListRawMaterialPurchaseRequest) (*dto.ListRawMaterialPurchaseResponse, error)
 | 
				
			||||||
	ListRawMaterialStockLogs(opts repository.RawMaterialStockLogListOptions, page, pageSize int) ([]models.RawMaterialStockLog, int64, error)
 | 
						ListRawMaterialStockLogs(req *dto.ListRawMaterialStockLogRequest) (*dto.ListRawMaterialStockLogResponse, error)
 | 
				
			||||||
	ListFeedUsageRecords(opts repository.FeedUsageRecordListOptions, page, pageSize int) ([]models.FeedUsageRecord, int64, error)
 | 
						ListFeedUsageRecords(req *dto.ListFeedUsageRecordRequest) (*dto.ListFeedUsageRecordResponse, error)
 | 
				
			||||||
	ListMedicationLogs(opts repository.MedicationLogListOptions, page, pageSize int) ([]models.MedicationLog, int64, error)
 | 
						ListMedicationLogs(req *dto.ListMedicationLogRequest) (*dto.ListMedicationLogResponse, error)
 | 
				
			||||||
	ListPigBatchLogs(opts repository.PigBatchLogListOptions, page, pageSize int) ([]models.PigBatchLog, int64, error)
 | 
						ListPigBatchLogs(req *dto.ListPigBatchLogRequest) (*dto.ListPigBatchLogResponse, error)
 | 
				
			||||||
	ListWeighingBatches(opts repository.WeighingBatchListOptions, page, pageSize int) ([]models.WeighingBatch, int64, error)
 | 
						ListWeighingBatches(req *dto.ListWeighingBatchRequest) (*dto.ListWeighingBatchResponse, error)
 | 
				
			||||||
	ListWeighingRecords(opts repository.WeighingRecordListOptions, page, pageSize int) ([]models.WeighingRecord, int64, error)
 | 
						ListWeighingRecords(req *dto.ListWeighingRecordRequest) (*dto.ListWeighingRecordResponse, error)
 | 
				
			||||||
	ListPigTransferLogs(opts repository.PigTransferLogListOptions, page, pageSize int) ([]models.PigTransferLog, int64, error)
 | 
						ListPigTransferLogs(req *dto.ListPigTransferLogRequest) (*dto.ListPigTransferLogResponse, error)
 | 
				
			||||||
	ListPigSickLogs(opts repository.PigSickLogListOptions, page, pageSize int) ([]models.PigSickLog, int64, error)
 | 
						ListPigSickLogs(req *dto.ListPigSickLogRequest) (*dto.ListPigSickLogResponse, error)
 | 
				
			||||||
	ListPigPurchases(opts repository.PigPurchaseListOptions, page, pageSize int) ([]models.PigPurchase, int64, error)
 | 
						ListPigPurchases(req *dto.ListPigPurchaseRequest) (*dto.ListPigPurchaseResponse, error)
 | 
				
			||||||
	ListPigSales(opts repository.PigSaleListOptions, page, pageSize int) ([]models.PigSale, int64, error)
 | 
						ListPigSales(req *dto.ListPigSaleRequest) (*dto.ListPigSaleResponse, error)
 | 
				
			||||||
	ListNotifications(opts repository.NotificationListOptions, page, pageSize int) ([]models.Notification, int64, error)
 | 
						ListNotifications(req *dto.ListNotificationRequest) (*dto.ListNotificationResponse, error)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// monitorService 是 MonitorService 接口的具体实现
 | 
					// monitorService 是 MonitorService 接口的具体实现
 | 
				
			||||||
@@ -81,22 +82,63 @@ func NewMonitorService(
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListSensorData 负责处理查询传感器数据列表的业务逻辑
 | 
					// ListSensorData 负责处理查询传感器数据列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListSensorData(opts repository.SensorDataListOptions, page, pageSize int) ([]models.SensorData, int64, error) {
 | 
					func (s *monitorService) ListSensorData(req *dto.ListSensorDataRequest) (*dto.ListSensorDataResponse, error) {
 | 
				
			||||||
	return s.sensorDataRepo.List(opts, page, pageSize)
 | 
						opts := repository.SensorDataListOptions{
 | 
				
			||||||
 | 
							DeviceID:  req.DeviceID,
 | 
				
			||||||
 | 
							OrderBy:   req.OrderBy,
 | 
				
			||||||
 | 
							StartTime: req.StartTime,
 | 
				
			||||||
 | 
							EndTime:   req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if req.SensorType != nil {
 | 
				
			||||||
 | 
							sensorType := models.SensorType(*req.SensorType)
 | 
				
			||||||
 | 
							opts.SensorType = &sensorType
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.sensorDataRepo.List(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListSensorDataResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListDeviceCommandLogs 负责处理查询设备命令日志列表的业务逻辑
 | 
					// ListDeviceCommandLogs 负责处理查询设备命令日志列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListDeviceCommandLogs(opts repository.DeviceCommandLogListOptions, page, pageSize int) ([]models.DeviceCommandLog, int64, error) {
 | 
					func (s *monitorService) ListDeviceCommandLogs(req *dto.ListDeviceCommandLogRequest) (*dto.ListDeviceCommandLogResponse, error) {
 | 
				
			||||||
	return s.deviceCommandLogRepo.List(opts, page, pageSize)
 | 
						opts := repository.DeviceCommandLogListOptions{
 | 
				
			||||||
 | 
							DeviceID:        req.DeviceID,
 | 
				
			||||||
 | 
							ReceivedSuccess: req.ReceivedSuccess,
 | 
				
			||||||
 | 
							OrderBy:         req.OrderBy,
 | 
				
			||||||
 | 
							StartTime:       req.StartTime,
 | 
				
			||||||
 | 
							EndTime:         req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.deviceCommandLogRepo.List(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListDeviceCommandLogResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListPlanExecutionLogs 负责处理查询计划执行日志列表的业务逻辑
 | 
					// ListPlanExecutionLogs 负责处理查询计划执行日志列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListPlanExecutionLogs(opts repository.PlanExecutionLogListOptions, page, pageSize int) ([]models.PlanExecutionLog, []models.Plan, int64, error) {
 | 
					func (s *monitorService) ListPlanExecutionLogs(req *dto.ListPlanExecutionLogRequest) (*dto.ListPlanExecutionLogResponse, error) {
 | 
				
			||||||
	planLogs, total, err := s.executionLogRepo.ListPlanExecutionLogs(opts, page, pageSize)
 | 
						opts := repository.PlanExecutionLogListOptions{
 | 
				
			||||||
	if err != nil {
 | 
							PlanID:    req.PlanID,
 | 
				
			||||||
		return nil, nil, 0, err
 | 
							OrderBy:   req.OrderBy,
 | 
				
			||||||
 | 
							StartTime: req.StartTime,
 | 
				
			||||||
 | 
							EndTime:   req.EndTime,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	planIds := []uint{}
 | 
						if req.Status != nil {
 | 
				
			||||||
 | 
							status := models.ExecutionStatus(*req.Status)
 | 
				
			||||||
 | 
							opts.Status = &status
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						planLogs, total, err := s.executionLogRepo.ListPlanExecutionLogs(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						planIds := make([]uint, 0, len(planLogs))
 | 
				
			||||||
	for _, datum := range planLogs {
 | 
						for _, datum := range planLogs {
 | 
				
			||||||
		has := false
 | 
							has := false
 | 
				
			||||||
		for _, id := range planIds {
 | 
							for _, id := range planIds {
 | 
				
			||||||
@@ -111,82 +153,322 @@ func (s *monitorService) ListPlanExecutionLogs(opts repository.PlanExecutionLogL
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	plans, err := s.planRepository.GetPlansByIDs(planIds)
 | 
						plans, err := s.planRepository.GetPlansByIDs(planIds)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, nil, 0, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return planLogs, plans, total, nil
 | 
						return dto.NewListPlanExecutionLogResponse(planLogs, plans, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListTaskExecutionLogs 负责处理查询任务执行日志列表的业务逻辑
 | 
					// ListTaskExecutionLogs 负责处理查询任务执行日志列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListTaskExecutionLogs(opts repository.TaskExecutionLogListOptions, page, pageSize int) ([]models.TaskExecutionLog, int64, error) {
 | 
					func (s *monitorService) ListTaskExecutionLogs(req *dto.ListTaskExecutionLogRequest) (*dto.ListTaskExecutionLogResponse, error) {
 | 
				
			||||||
	return s.executionLogRepo.ListTaskExecutionLogs(opts, page, pageSize)
 | 
						opts := repository.TaskExecutionLogListOptions{
 | 
				
			||||||
 | 
							PlanExecutionLogID: req.PlanExecutionLogID,
 | 
				
			||||||
 | 
							TaskID:             req.TaskID,
 | 
				
			||||||
 | 
							OrderBy:            req.OrderBy,
 | 
				
			||||||
 | 
							StartTime:          req.StartTime,
 | 
				
			||||||
 | 
							EndTime:            req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if req.Status != nil {
 | 
				
			||||||
 | 
							status := models.ExecutionStatus(*req.Status)
 | 
				
			||||||
 | 
							opts.Status = &status
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.executionLogRepo.ListTaskExecutionLogs(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListTaskExecutionLogResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListPendingCollections 负责处理查询待采集请求列表的业务逻辑
 | 
					// ListPendingCollections 负责处理查询待采集请求列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListPendingCollections(opts repository.PendingCollectionListOptions, page, pageSize int) ([]models.PendingCollection, int64, error) {
 | 
					func (s *monitorService) ListPendingCollections(req *dto.ListPendingCollectionRequest) (*dto.ListPendingCollectionResponse, error) {
 | 
				
			||||||
	return s.pendingCollectionRepo.List(opts, page, pageSize)
 | 
						opts := repository.PendingCollectionListOptions{
 | 
				
			||||||
 | 
							DeviceID:  req.DeviceID,
 | 
				
			||||||
 | 
							OrderBy:   req.OrderBy,
 | 
				
			||||||
 | 
							StartTime: req.StartTime,
 | 
				
			||||||
 | 
							EndTime:   req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if req.Status != nil {
 | 
				
			||||||
 | 
							status := models.PendingCollectionStatus(*req.Status)
 | 
				
			||||||
 | 
							opts.Status = &status
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.pendingCollectionRepo.List(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListPendingCollectionResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListUserActionLogs 负责处理查询用户操作日志列表的业务逻辑
 | 
					// ListUserActionLogs 负责处理查询用户操作日志列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListUserActionLogs(opts repository.UserActionLogListOptions, page, pageSize int) ([]models.UserActionLog, int64, error) {
 | 
					func (s *monitorService) ListUserActionLogs(req *dto.ListUserActionLogRequest) (*dto.ListUserActionLogResponse, error) {
 | 
				
			||||||
	return s.userActionLogRepo.List(opts, page, pageSize)
 | 
						opts := repository.UserActionLogListOptions{
 | 
				
			||||||
 | 
							UserID:     req.UserID,
 | 
				
			||||||
 | 
							Username:   req.Username,
 | 
				
			||||||
 | 
							ActionType: req.ActionType,
 | 
				
			||||||
 | 
							OrderBy:    req.OrderBy,
 | 
				
			||||||
 | 
							StartTime:  req.StartTime,
 | 
				
			||||||
 | 
							EndTime:    req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if req.Status != nil {
 | 
				
			||||||
 | 
							status := models.AuditStatus(*req.Status)
 | 
				
			||||||
 | 
							opts.Status = &status
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.userActionLogRepo.List(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListUserActionLogResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListRawMaterialPurchases 负责处理查询原料采购记录列表的业务逻辑
 | 
					// ListRawMaterialPurchases 负责处理查询原料采购记录列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListRawMaterialPurchases(opts repository.RawMaterialPurchaseListOptions, page, pageSize int) ([]models.RawMaterialPurchase, int64, error) {
 | 
					func (s *monitorService) ListRawMaterialPurchases(req *dto.ListRawMaterialPurchaseRequest) (*dto.ListRawMaterialPurchaseResponse, error) {
 | 
				
			||||||
	return s.rawMaterialRepo.ListRawMaterialPurchases(opts, page, pageSize)
 | 
						opts := repository.RawMaterialPurchaseListOptions{
 | 
				
			||||||
 | 
							RawMaterialID: req.RawMaterialID,
 | 
				
			||||||
 | 
							Supplier:      req.Supplier,
 | 
				
			||||||
 | 
							OrderBy:       req.OrderBy,
 | 
				
			||||||
 | 
							StartTime:     req.StartTime,
 | 
				
			||||||
 | 
							EndTime:       req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.rawMaterialRepo.ListRawMaterialPurchases(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListRawMaterialPurchaseResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListRawMaterialStockLogs 负责处理查询原料库存日志列表的业务逻辑
 | 
					// ListRawMaterialStockLogs 负责处理查询原料库存日志列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListRawMaterialStockLogs(opts repository.RawMaterialStockLogListOptions, page, pageSize int) ([]models.RawMaterialStockLog, int64, error) {
 | 
					func (s *monitorService) ListRawMaterialStockLogs(req *dto.ListRawMaterialStockLogRequest) (*dto.ListRawMaterialStockLogResponse, error) {
 | 
				
			||||||
	return s.rawMaterialRepo.ListRawMaterialStockLogs(opts, page, pageSize)
 | 
						opts := repository.RawMaterialStockLogListOptions{
 | 
				
			||||||
 | 
							RawMaterialID: req.RawMaterialID,
 | 
				
			||||||
 | 
							SourceID:      req.SourceID,
 | 
				
			||||||
 | 
							OrderBy:       req.OrderBy,
 | 
				
			||||||
 | 
							StartTime:     req.StartTime,
 | 
				
			||||||
 | 
							EndTime:       req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if req.SourceType != nil {
 | 
				
			||||||
 | 
							sourceType := models.StockLogSourceType(*req.SourceType)
 | 
				
			||||||
 | 
							opts.SourceType = &sourceType
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.rawMaterialRepo.ListRawMaterialStockLogs(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListRawMaterialStockLogResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListFeedUsageRecords 负责处理查询饲料使用记录列表的业务逻辑
 | 
					// ListFeedUsageRecords 负责处理查询饲料使用记录列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListFeedUsageRecords(opts repository.FeedUsageRecordListOptions, page, pageSize int) ([]models.FeedUsageRecord, int64, error) {
 | 
					func (s *monitorService) ListFeedUsageRecords(req *dto.ListFeedUsageRecordRequest) (*dto.ListFeedUsageRecordResponse, error) {
 | 
				
			||||||
	return s.rawMaterialRepo.ListFeedUsageRecords(opts, page, pageSize)
 | 
						opts := repository.FeedUsageRecordListOptions{
 | 
				
			||||||
 | 
							PenID:         req.PenID,
 | 
				
			||||||
 | 
							FeedFormulaID: req.FeedFormulaID,
 | 
				
			||||||
 | 
							OperatorID:    req.OperatorID,
 | 
				
			||||||
 | 
							OrderBy:       req.OrderBy,
 | 
				
			||||||
 | 
							StartTime:     req.StartTime,
 | 
				
			||||||
 | 
							EndTime:       req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.rawMaterialRepo.ListFeedUsageRecords(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListFeedUsageRecordResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListMedicationLogs 负责处理查询用药记录列表的业务逻辑
 | 
					// ListMedicationLogs 负责处理查询用药记录列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListMedicationLogs(opts repository.MedicationLogListOptions, page, pageSize int) ([]models.MedicationLog, int64, error) {
 | 
					func (s *monitorService) ListMedicationLogs(req *dto.ListMedicationLogRequest) (*dto.ListMedicationLogResponse, error) {
 | 
				
			||||||
	return s.medicationRepo.ListMedicationLogs(opts, page, pageSize)
 | 
						opts := repository.MedicationLogListOptions{
 | 
				
			||||||
 | 
							PigBatchID:   req.PigBatchID,
 | 
				
			||||||
 | 
							MedicationID: req.MedicationID,
 | 
				
			||||||
 | 
							OperatorID:   req.OperatorID,
 | 
				
			||||||
 | 
							OrderBy:      req.OrderBy,
 | 
				
			||||||
 | 
							StartTime:    req.StartTime,
 | 
				
			||||||
 | 
							EndTime:      req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if req.Reason != nil {
 | 
				
			||||||
 | 
							reason := models.MedicationReasonType(*req.Reason)
 | 
				
			||||||
 | 
							opts.Reason = &reason
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.medicationRepo.ListMedicationLogs(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListMedicationLogResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListPigBatchLogs 负责处理查询猪批次日志列表的业务逻辑
 | 
					// ListPigBatchLogs 负责处理查询猪批次日志列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListPigBatchLogs(opts repository.PigBatchLogListOptions, page, pageSize int) ([]models.PigBatchLog, int64, error) {
 | 
					func (s *monitorService) ListPigBatchLogs(req *dto.ListPigBatchLogRequest) (*dto.ListPigBatchLogResponse, error) {
 | 
				
			||||||
	return s.pigBatchLogRepo.List(opts, page, pageSize)
 | 
						opts := repository.PigBatchLogListOptions{
 | 
				
			||||||
 | 
							PigBatchID: req.PigBatchID,
 | 
				
			||||||
 | 
							OperatorID: req.OperatorID,
 | 
				
			||||||
 | 
							OrderBy:    req.OrderBy,
 | 
				
			||||||
 | 
							StartTime:  req.StartTime,
 | 
				
			||||||
 | 
							EndTime:    req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if req.ChangeType != nil {
 | 
				
			||||||
 | 
							changeType := models.LogChangeType(*req.ChangeType)
 | 
				
			||||||
 | 
							opts.ChangeType = &changeType
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.pigBatchLogRepo.List(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListPigBatchLogResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListWeighingBatches 负责处理查询批次称重记录列表的业务逻辑
 | 
					// ListWeighingBatches 负责处理查询批次称重记录列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListWeighingBatches(opts repository.WeighingBatchListOptions, page, pageSize int) ([]models.WeighingBatch, int64, error) {
 | 
					func (s *monitorService) ListWeighingBatches(req *dto.ListWeighingBatchRequest) (*dto.ListWeighingBatchResponse, error) {
 | 
				
			||||||
	return s.pigBatchRepo.ListWeighingBatches(opts, page, pageSize)
 | 
						opts := repository.WeighingBatchListOptions{
 | 
				
			||||||
 | 
							PigBatchID: req.PigBatchID,
 | 
				
			||||||
 | 
							OrderBy:    req.OrderBy,
 | 
				
			||||||
 | 
							StartTime:  req.StartTime,
 | 
				
			||||||
 | 
							EndTime:    req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.pigBatchRepo.ListWeighingBatches(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListWeighingBatchResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListWeighingRecords 负责处理查询单次称重记录列表的业务逻辑
 | 
					// ListWeighingRecords 负责处理查询单次称重记录列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListWeighingRecords(opts repository.WeighingRecordListOptions, page, pageSize int) ([]models.WeighingRecord, int64, error) {
 | 
					func (s *monitorService) ListWeighingRecords(req *dto.ListWeighingRecordRequest) (*dto.ListWeighingRecordResponse, error) {
 | 
				
			||||||
	return s.pigBatchRepo.ListWeighingRecords(opts, page, pageSize)
 | 
						opts := repository.WeighingRecordListOptions{
 | 
				
			||||||
 | 
							WeighingBatchID: req.WeighingBatchID,
 | 
				
			||||||
 | 
							PenID:           req.PenID,
 | 
				
			||||||
 | 
							OperatorID:      req.OperatorID,
 | 
				
			||||||
 | 
							OrderBy:         req.OrderBy,
 | 
				
			||||||
 | 
							StartTime:       req.StartTime,
 | 
				
			||||||
 | 
							EndTime:         req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.pigBatchRepo.ListWeighingRecords(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListWeighingRecordResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListPigTransferLogs 负责处理查询猪只迁移日志列表的业务逻辑
 | 
					// ListPigTransferLogs 负责处理查询猪只迁移日志列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListPigTransferLogs(opts repository.PigTransferLogListOptions, page, pageSize int) ([]models.PigTransferLog, int64, error) {
 | 
					func (s *monitorService) ListPigTransferLogs(req *dto.ListPigTransferLogRequest) (*dto.ListPigTransferLogResponse, error) {
 | 
				
			||||||
	return s.pigTransferLogRepo.ListPigTransferLogs(opts, page, pageSize)
 | 
						opts := repository.PigTransferLogListOptions{
 | 
				
			||||||
 | 
							PigBatchID:    req.PigBatchID,
 | 
				
			||||||
 | 
							PenID:         req.PenID,
 | 
				
			||||||
 | 
							OperatorID:    req.OperatorID,
 | 
				
			||||||
 | 
							CorrelationID: req.CorrelationID,
 | 
				
			||||||
 | 
							OrderBy:       req.OrderBy,
 | 
				
			||||||
 | 
							StartTime:     req.StartTime,
 | 
				
			||||||
 | 
							EndTime:       req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if req.TransferType != nil {
 | 
				
			||||||
 | 
							transferType := models.PigTransferType(*req.TransferType)
 | 
				
			||||||
 | 
							opts.TransferType = &transferType
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.pigTransferLogRepo.ListPigTransferLogs(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListPigTransferLogResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListPigSickLogs 负责处理查询病猪日志列表的业务逻辑
 | 
					// ListPigSickLogs 负责处理查询病猪日志列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListPigSickLogs(opts repository.PigSickLogListOptions, page, pageSize int) ([]models.PigSickLog, int64, error) {
 | 
					func (s *monitorService) ListPigSickLogs(req *dto.ListPigSickLogRequest) (*dto.ListPigSickLogResponse, error) {
 | 
				
			||||||
	return s.pigSickLogRepo.ListPigSickLogs(opts, page, pageSize)
 | 
						opts := repository.PigSickLogListOptions{
 | 
				
			||||||
 | 
							PigBatchID: req.PigBatchID,
 | 
				
			||||||
 | 
							PenID:      req.PenID,
 | 
				
			||||||
 | 
							OperatorID: req.OperatorID,
 | 
				
			||||||
 | 
							OrderBy:    req.OrderBy,
 | 
				
			||||||
 | 
							StartTime:  req.StartTime,
 | 
				
			||||||
 | 
							EndTime:    req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if req.Reason != nil {
 | 
				
			||||||
 | 
							reason := models.PigBatchSickPigReasonType(*req.Reason)
 | 
				
			||||||
 | 
							opts.Reason = &reason
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if req.TreatmentLocation != nil {
 | 
				
			||||||
 | 
							treatmentLocation := models.PigBatchSickPigTreatmentLocation(*req.TreatmentLocation)
 | 
				
			||||||
 | 
							opts.TreatmentLocation = &treatmentLocation
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.pigSickLogRepo.ListPigSickLogs(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListPigSickLogResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListPigPurchases 负责处理查询猪只采购记录列表的业务逻辑
 | 
					// ListPigPurchases 负责处理查询猪只采购记录列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListPigPurchases(opts repository.PigPurchaseListOptions, page, pageSize int) ([]models.PigPurchase, int64, error) {
 | 
					func (s *monitorService) ListPigPurchases(req *dto.ListPigPurchaseRequest) (*dto.ListPigPurchaseResponse, error) {
 | 
				
			||||||
	return s.pigTradeRepo.ListPigPurchases(opts, page, pageSize)
 | 
						opts := repository.PigPurchaseListOptions{
 | 
				
			||||||
 | 
							PigBatchID: req.PigBatchID,
 | 
				
			||||||
 | 
							Supplier:   req.Supplier,
 | 
				
			||||||
 | 
							OperatorID: req.OperatorID,
 | 
				
			||||||
 | 
							OrderBy:    req.OrderBy,
 | 
				
			||||||
 | 
							StartTime:  req.StartTime,
 | 
				
			||||||
 | 
							EndTime:    req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.pigTradeRepo.ListPigPurchases(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListPigPurchaseResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListPigSales 负责处理查询猪只销售记录列表的业务逻辑
 | 
					// ListPigSales 负责处理查询猪只销售记录列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListPigSales(opts repository.PigSaleListOptions, page, pageSize int) ([]models.PigSale, int64, error) {
 | 
					func (s *monitorService) ListPigSales(req *dto.ListPigSaleRequest) (*dto.ListPigSaleResponse, error) {
 | 
				
			||||||
	return s.pigTradeRepo.ListPigSales(opts, page, pageSize)
 | 
						opts := repository.PigSaleListOptions{
 | 
				
			||||||
 | 
							PigBatchID: req.PigBatchID,
 | 
				
			||||||
 | 
							Buyer:      req.Buyer,
 | 
				
			||||||
 | 
							OperatorID: req.OperatorID,
 | 
				
			||||||
 | 
							OrderBy:    req.OrderBy,
 | 
				
			||||||
 | 
							StartTime:  req.StartTime,
 | 
				
			||||||
 | 
							EndTime:    req.EndTime,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.pigTradeRepo.ListPigSales(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListPigSaleResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListNotifications 负责处理查询通知列表的业务逻辑
 | 
					// ListNotifications 负责处理查询通知列表的业务逻辑
 | 
				
			||||||
func (s *monitorService) ListNotifications(opts repository.NotificationListOptions, page, pageSize int) ([]models.Notification, int64, error) {
 | 
					func (s *monitorService) ListNotifications(req *dto.ListNotificationRequest) (*dto.ListNotificationResponse, error) {
 | 
				
			||||||
	return s.notificationRepo.List(opts, page, pageSize)
 | 
						opts := repository.NotificationListOptions{
 | 
				
			||||||
 | 
							UserID:       req.UserID,
 | 
				
			||||||
 | 
							NotifierType: req.NotifierType,
 | 
				
			||||||
 | 
							Level:        req.Level,
 | 
				
			||||||
 | 
							StartTime:    req.StartTime,
 | 
				
			||||||
 | 
							EndTime:      req.EndTime,
 | 
				
			||||||
 | 
							OrderBy:      req.OrderBy,
 | 
				
			||||||
 | 
							Status:       req.Status,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data, total, err := s.notificationRepo.List(opts, req.Page, req.PageSize)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dto.NewListNotificationResponse(data, total, req.Page, req.PageSize), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,16 +7,16 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
### 2.1 `monitor` 模块
 | 
					### 2.1 `monitor` 模块
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- [ ] 2.1.1 **修改 `internal/app/service/monitor_service.go`:**
 | 
					- [x] 2.1.1 **修改 `internal/app/service/monitor_service.go`:**
 | 
				
			||||||
    - [ ] 将所有 `List...` 方法的 `opts repository.ListOptions` 参数替换为服务层自定义的查询 DTO 或一系列基本参数。
 | 
					    - [x] 将所有 `List...` 方法的 `opts repository.ListOptions` 参数替换为服务层自定义的查询 DTO 或一系列基本参数。
 | 
				
			||||||
    - [ ] 将所有 `List...` 方法的返回值 `[]models.Xxx` 替换为 `[]dto.XxxResponse`。
 | 
					    - [x] 将所有 `List...` 方法的返回值 `[]models.Xxx` 替换为 `[]dto.XxxResponse`。
 | 
				
			||||||
    - [ ] 调整 `List...` 方法的实现,在服务层内部将服务层查询 DTO 转换为 `repository.ListOptions`。
 | 
					    - [x] 调整 `List...` 方法的实现,在服务层内部将服务层查询 DTO 转换为 `repository.ListOptions`。
 | 
				
			||||||
    - [ ] 调整 `List...` 方法的实现,在服务层内部将 `repository` 返回的 `models` 对象转换为 `dto.XxxResponse`。
 | 
					    - [x] 调整 `List...` 方法的实现,在服务层内部将 `repository` 返回的 `models` 对象转换为 `dto.XxxResponse`。
 | 
				
			||||||
- [ ] 2.1.2 **修改 `internal/app/controller/monitor/monitor_controller.go`:**
 | 
					- [x] 2.1.2 **修改 `internal/app/controller/monitor/monitor_controller.go`:**
 | 
				
			||||||
    - [ ] 移除控制器中构建 `repository.ListOptions` 的逻辑。
 | 
					    - [x] 移除控制器中构建 `repository.ListOptions` 的逻辑。
 | 
				
			||||||
    - [ ] 移除控制器中将 `models` 转换为 `dto.NewList...Response` 的逻辑。
 | 
					    - [x] 移除控制器中将 `models` 转换为 `dto.NewList...Response` 的逻辑。
 | 
				
			||||||
    - [ ] 移除控制器中直接使用 `models` 进行枚举类型转换的逻辑,将其下沉到服务层或 DTO 转换逻辑中。
 | 
					    - [x] 移除控制器中直接使用 `models` 进行枚举类型转换的逻辑,将其下沉到服务层或 DTO 转换逻辑中。
 | 
				
			||||||
    - [ ] 调整服务层方法的调用,使其接收新的服务层查询 DTO 或基本参数,并直接处理服务层返回的 `dto.XxxResponse`。
 | 
					    - [x] 调整服务层方法的调用,使其接收新的服务层查询 DTO 或基本参数,并直接处理服务层返回的 `dto.XxxResponse`。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### 2.2 `device` 模块
 | 
					### 2.2 `device` 模块
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user