float64全部改float32
This commit is contained in:
@@ -67,9 +67,9 @@ type PigBatchService interface {
|
||||
|
||||
// ---交易子服务---
|
||||
// SellPigs 处理卖猪的业务逻辑。
|
||||
SellPigs(ctx context.Context, batchID uint, penID uint, quantity int, unitPrice float64, tatalPrice float64, traderName string, tradeDate time.Time, remarks string, operatorID uint) error
|
||||
SellPigs(ctx context.Context, batchID uint, penID uint, quantity int, unitPrice float32, tatalPrice float32, traderName string, tradeDate time.Time, remarks string, operatorID uint) error
|
||||
// BuyPigs 处理买猪的业务逻辑。
|
||||
BuyPigs(ctx context.Context, batchID uint, penID uint, quantity int, unitPrice float64, tatalPrice float64, traderName string, tradeDate time.Time, remarks string, operatorID uint) error
|
||||
BuyPigs(ctx context.Context, batchID uint, penID uint, quantity int, unitPrice float32, tatalPrice float32, traderName string, tradeDate time.Time, remarks string, operatorID uint) error
|
||||
|
||||
// ---调栏子服务 ---
|
||||
TransferPigsAcrossBatches(ctx context.Context, sourceBatchID uint, destBatchID uint, fromPenID uint, toPenID uint, quantity uint, operatorID uint, remarks string) error
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
// SellPigs 处理批量销售猪的业务逻辑。
|
||||
func (s *pigBatchService) SellPigs(ctx context.Context, batchID uint, penID uint, quantity int, unitPrice float64, tatalPrice float64, traderName string, tradeDate time.Time, remarks string, operatorID uint) error {
|
||||
func (s *pigBatchService) SellPigs(ctx context.Context, batchID uint, penID uint, quantity int, unitPrice float32, tatalPrice float32, traderName string, tradeDate time.Time, remarks string, operatorID uint) error {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "SellPigs")
|
||||
return s.uow.ExecuteInTransaction(serviceCtx, func(tx *gorm.DB) error {
|
||||
if quantity <= 0 {
|
||||
@@ -85,7 +85,7 @@ func (s *pigBatchService) SellPigs(ctx context.Context, batchID uint, penID uint
|
||||
}
|
||||
|
||||
// BuyPigs 处理批量购买猪的业务逻辑。
|
||||
func (s *pigBatchService) BuyPigs(ctx context.Context, batchID uint, penID uint, quantity int, unitPrice float64, totalPrice float64, traderName string, tradeDate time.Time, remarks string, operatorID uint) error {
|
||||
func (s *pigBatchService) BuyPigs(ctx context.Context, batchID uint, penID uint, quantity int, unitPrice float32, totalPrice float32, traderName string, tradeDate time.Time, remarks string, operatorID uint) error {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "BuyPigs")
|
||||
return s.uow.ExecuteInTransaction(serviceCtx, func(tx *gorm.DB) error {
|
||||
if quantity <= 0 {
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
type AreaThresholdCheckParams struct {
|
||||
AreaControllerID uint `json:"area_controller_id"` // 区域主控ID
|
||||
SensorType models.SensorType `json:"sensor_type"` // 传感器类型
|
||||
Thresholds float64 `json:"thresholds"` // 阈值
|
||||
Thresholds float32 `json:"thresholds"` // 阈值
|
||||
Operator models.Operator `json:"operator"` // 操作符
|
||||
Level models.SeverityLevel `json:"level"` // 告警级别
|
||||
ExcludeDeviceIDs []uint `json:"exclude_device_ids"` // 排除的传感器ID
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
type DelayTaskParams struct {
|
||||
DelayDuration float64 `json:"delay_duration"`
|
||||
DelayDuration float32 `json:"delay_duration"`
|
||||
}
|
||||
|
||||
// DelayTask 是一个用于模拟延迟的 Task 实现
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
type DeviceThresholdCheckParams struct {
|
||||
DeviceID uint `json:"device_id"` // 设备ID
|
||||
SensorType models.SensorType `json:"sensor_type"` // 传感器类型
|
||||
Thresholds float64 `json:"thresholds"` // 阈值
|
||||
Thresholds float32 `json:"thresholds"` // 阈值
|
||||
Operator models.Operator `json:"operator"` // 操作符
|
||||
Level models.SeverityLevel `json:"level"` // 告警等级
|
||||
}
|
||||
@@ -55,7 +55,7 @@ func (d *DeviceThresholdCheckTask) Execute(ctx context.Context) error {
|
||||
return fmt.Errorf("任务 %v: 获取最新传感器数据失败: %v", d.taskLog.TaskID, err)
|
||||
}
|
||||
|
||||
var currentValue float64
|
||||
var currentValue float32
|
||||
var alarmCode models.AlarmCode
|
||||
|
||||
switch d.params.SensorType {
|
||||
@@ -123,7 +123,7 @@ func (d *DeviceThresholdCheckTask) Execute(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// checkThreshold 校验当前值是否满足阈值条件
|
||||
func (d *DeviceThresholdCheckTask) checkThreshold(currentValue float64, operator models.Operator, threshold float64) bool {
|
||||
func (d *DeviceThresholdCheckTask) checkThreshold(currentValue float32, operator models.Operator, threshold float32) bool {
|
||||
switch operator {
|
||||
case models.OperatorLessThan:
|
||||
return currentValue < threshold
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
// ReleaseFeedWeightTaskParams 定义了 ReleaseFeedWeightTask 的参数结构
|
||||
type ReleaseFeedWeightTaskParams struct {
|
||||
ReleaseWeight float64 `json:"release_weight"` // 需要释放的重量
|
||||
ReleaseWeight float32 `json:"release_weight"` // 需要释放的重量
|
||||
FeedPortDeviceID uint `json:"feed_port_device_id"` // 下料口ID
|
||||
MixingTankDeviceID uint `json:"mixing_tank_device_id"` // 称重传感器ID
|
||||
}
|
||||
@@ -29,7 +29,7 @@ type ReleaseFeedWeightTask struct {
|
||||
claimedLog *models.TaskExecutionLog
|
||||
|
||||
feedPortDevice *models.Device
|
||||
releaseWeight float64
|
||||
releaseWeight float32
|
||||
mixingTankDeviceID uint
|
||||
|
||||
feedPort device.Service
|
||||
@@ -100,7 +100,7 @@ func (r *ReleaseFeedWeightTask) Execute(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// 获取当前搅拌罐重量
|
||||
func (r *ReleaseFeedWeightTask) getNowWeight(ctx context.Context) (float64, error) {
|
||||
func (r *ReleaseFeedWeightTask) getNowWeight(ctx context.Context) (float32, error) {
|
||||
taskCtx, logger := logs.Trace(ctx, r.ctx, "getNowWeight")
|
||||
sensorData, err := r.sensorDataRepo.GetLatestSensorDataByDeviceIDAndSensorType(taskCtx, r.mixingTankDeviceID, models.SensorTypeWeight)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user