adjust get weight remaining

This commit is contained in:
giovanni
2026-01-24 14:17:50 +07:00
parent 8b1831fc73
commit 8c84981812
2 changed files with 10 additions and 13 deletions
@@ -1583,9 +1583,7 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
// for pfkID, egg := range eggMap {
// if rowIdx, ok := pfkIndex[pfkID]; ok {
// repoRows[rowIdx].EggProductionWeightKgRemaining = egg.EggProductionWeightKgRemaining
// // repoRows[rowIdx].EggProductionPiecesRemaining = egg.EggProductionPiecesRemaining
// // repoRows[rowIdx].EggProductionTotalWeightKg = egg.EggProductionTotalWeightKg
// // repoRows[rowIdx].EggProductionTotalPieces = egg.EggProductionTotalPieces
// repoRows[rowIdx].AverageWeightEggPerPiece = egg.AverageWeightEggPerPiece
// }
// }
}
@@ -1676,6 +1674,7 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
var eggRemainingWeightFloatRemaining float64
var eggTotalPiecesFloat float64
var eggWeightFloat float64
var avgWeight float64
eggHpp := 0.0
if s.HppSvc != nil {
hppCost, err := s.HppSvc.CalculateHppCost(row.ProjectFlockKandangID, &endOfDay)
@@ -1683,11 +1682,12 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
return nil, nil, err
}
if hppCost != nil {
eggRemainingWeightFloatRemaining = hppCost.Estimation.Kg - hppCost.Real.Kg
eggPiecesFloatRemaining = hppCost.Estimation.Butir - hppCost.Real.Butir
eggHpp = hppCost.Estimation.HargaKg
eggTotalPiecesFloat = hppCost.Estimation.Butir
eggWeightFloat = hppCost.Estimation.Kg
avgWeight = eggWeightFloat / eggTotalPiecesFloat
eggRemainingWeightFloatRemaining = avgWeight * eggPiecesFloatRemaining
}
}
if math.IsNaN(eggPiecesFloatRemaining) || math.IsInf(eggPiecesFloatRemaining, 0) {
@@ -1703,10 +1703,6 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
eggWeightFloat = 0
}
avgWeight := 0.0
if eggTotalPiecesFloat > 0 {
avgWeight = eggWeightFloat / eggTotalPiecesFloat
}
if params.WeightMin != nil && avgWeight < *params.WeightMin {
continue
}