order by
This commit is contained in:
parent
93873c6fd6
commit
a01f04a949
|
|
@ -36,8 +36,8 @@ func db(data *conf.Data_Database) *gorm.DB {
|
||||||
panic("failed to gormDB " + err.Error())
|
panic("failed to gormDB " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlDB.SetMaxIdleConns(100)
|
sqlDB.SetMaxIdleConns(50)
|
||||||
sqlDB.SetMaxOpenConns(1000)
|
sqlDB.SetMaxOpenConns(200)
|
||||||
|
|
||||||
return gormDB
|
return gormDB
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ func (p *OrderRepoImpl) SpecifyFindInBatches(ctx context.Context, req *bo.FindIn
|
||||||
tx = tx.Where("voucher_no IN (?)", req.VoucherNos)
|
tx = tx.Where("voucher_no IN (?)", req.VoucherNos)
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Order("") // 显式清除排序,移除默认的 ORDER BY
|
tx.Order("receive_success_time asc") // 显式清除排序,移除默认的 ORDER BY
|
||||||
|
|
||||||
var results = make([]*model.Order, 0)
|
var results = make([]*model.Order, 0)
|
||||||
|
|
||||||
|
|
@ -95,9 +95,9 @@ func (p *OrderRepoImpl) FinSucByStockIdInBatches(ctx context.Context, req *do.We
|
||||||
|
|
||||||
var results = make([]*model.Order, 0)
|
var results = make([]*model.Order, 0)
|
||||||
|
|
||||||
tx.Order("") // 显式清除排序,移除默认的 ORDER BY
|
tx.Order("receive_success_time asc") // 显式清除排序,移除默认的 ORDER BY
|
||||||
|
|
||||||
result := tx.FindInBatches(&results, 100, func(tx *gorm.DB, batch int) error {
|
result := tx.FindInBatches(&results, 1000, func(tx *gorm.DB, batch int) error {
|
||||||
|
|
||||||
return fun(ctx, p.ToBos(results))
|
return fun(ctx, p.ToBos(results))
|
||||||
})
|
})
|
||||||
|
|
@ -116,7 +116,7 @@ func (p *OrderRepoImpl) FinFailByStockIdInBatches(ctx context.Context, batchNo s
|
||||||
result := p.DB(ctx).
|
result := p.DB(ctx).
|
||||||
Where("batch_no = ?", batchNo).
|
Where("batch_no = ?", batchNo).
|
||||||
Where("`status` = ?", vo.OrderStatusFail.GetValue()).
|
Where("`status` = ?", vo.OrderStatusFail.GetValue()).
|
||||||
Order(""). // 显式清除排序,移除默认的 ORDER BY
|
Order("receive_success_time asc"). // 显式清除排序,移除默认的 ORDER BY
|
||||||
FindInBatches(&results, 100, func(tx *gorm.DB, batch int) error {
|
FindInBatches(&results, 100, func(tx *gorm.DB, batch int) error {
|
||||||
return fun(ctx, p.ToBos(results))
|
return fun(ctx, p.ToBos(results))
|
||||||
})
|
})
|
||||||
|
|
@ -135,7 +135,7 @@ func (p *OrderRepoImpl) FindIngInBatches(ctx context.Context, fun func(ctx conte
|
||||||
result := p.DB(ctx).
|
result := p.DB(ctx).
|
||||||
Where("`status` = ?", vo.OrderStatusIng.GetValue()).
|
Where("`status` = ?", vo.OrderStatusIng.GetValue()).
|
||||||
Limit(20).
|
Limit(20).
|
||||||
Order(""). // 显式清除排序,移除默认的 ORDER BY
|
Order("receive_success_time asc"). // 显式清除排序,移除默认的 ORDER BY
|
||||||
FindInBatches(&results, 10, func(tx *gorm.DB, batch int) error {
|
FindInBatches(&results, 10, func(tx *gorm.DB, batch int) error {
|
||||||
return fun(ctx, p.ToBos(results))
|
return fun(ctx, p.ToBos(results))
|
||||||
})
|
})
|
||||||
|
|
@ -155,7 +155,7 @@ func (p *OrderRepoImpl) FindInBatches(ctx context.Context, req *bo.FindInBatches
|
||||||
Where("activity_id = ''").
|
Where("activity_id = ''").
|
||||||
Where("`status` IN (?)", []uint8{vo.OrderStatusSuccess.GetValue(), vo.OrderStatusUse.GetValue()}).
|
Where("`status` IN (?)", []uint8{vo.OrderStatusSuccess.GetValue(), vo.OrderStatusUse.GetValue()}).
|
||||||
Where("receive_success_time BETWEEN ? AND ?", req.StartTime, req.EndTime).
|
Where("receive_success_time BETWEEN ? AND ?", req.StartTime, req.EndTime).
|
||||||
Order(""). // 显式清除排序,移除默认的 ORDER BY
|
Order("receive_success_time asc"). // 显式清除排序,移除默认的 ORDER BY
|
||||||
FindInBatches(&results, 1000, func(tx *gorm.DB, batch int) error {
|
FindInBatches(&results, 1000, func(tx *gorm.DB, batch int) error {
|
||||||
// tx.RowsAffected 提供当前批处理中记录的计数(the count of records in the current batch)
|
// tx.RowsAffected 提供当前批处理中记录的计数(the count of records in the current batch)
|
||||||
// 'batch' 变量表示当前批号(the current batch number)
|
// 'batch' 变量表示当前批号(the current batch number)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue