猪栏信息接口增加猪栏当前存栏量
This commit is contained in:
@@ -58,6 +58,8 @@ type PigBatchService interface {
|
||||
|
||||
// GetCurrentPigQuantity 获取指定猪批次的当前猪只数量。
|
||||
GetCurrentPigQuantity(batchID uint) (int, error)
|
||||
// GetCurrentPigsInPen 获取指定猪栏的当前存栏量。
|
||||
GetCurrentPigsInPen(penID uint) (int, error)
|
||||
|
||||
UpdatePigBatchQuantity(operatorID uint, batchID uint, changeType models.LogChangeType, changeAmount int, changeReason string, happenedAt time.Time) error
|
||||
|
||||
@@ -163,3 +165,16 @@ func (s *pigBatchService) RemoveEmptyPenFromBatch(batchID uint, penID uint) erro
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (s *pigBatchService) GetCurrentPigsInPen(penID uint) (int, error) {
|
||||
var currentPigs int
|
||||
err := s.uow.ExecuteInTransaction(func(tx *gorm.DB) error {
|
||||
pigs, err := s.transferSvc.GetCurrentPigsInPen(tx, penID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
currentPigs = pigs
|
||||
return nil
|
||||
})
|
||||
return currentPigs, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user