mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
adjust avg weight
This commit is contained in:
@@ -1058,6 +1058,8 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
||||
Summary *dto.HppPerKandangSummaryWeightRangeDTO
|
||||
RemainingBirds int64
|
||||
RemainingWeightKg float64
|
||||
AvgWeightSum float64
|
||||
AvgWeightCount int64
|
||||
EggHppSum float64
|
||||
EggHppCount int
|
||||
FeedSuppliers map[int64]dto.HppPerKandangSupplierDTO
|
||||
@@ -1078,6 +1080,8 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
||||
var totalDocPriceCount int
|
||||
var totalEggHppSum float64
|
||||
var totalEggHppCount int
|
||||
var totalAvgWeightSum float64
|
||||
var totalAvgWeightCount int64
|
||||
|
||||
for _, row := range repoRows {
|
||||
if !params.ShowUnrecorded && row.RecordingCount == 0 {
|
||||
@@ -1178,6 +1182,8 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
||||
totalEggKg += eggWeightFloat
|
||||
totalRemainingValueRp += rowRemainingValue
|
||||
totalEggValueRp += rowEggValue
|
||||
totalAvgWeightSum += avgWeight
|
||||
totalAvgWeightCount++
|
||||
if weightFloat > 0 {
|
||||
totalHppSum += hppRp
|
||||
totalHppCount++
|
||||
@@ -1210,6 +1216,8 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
||||
rangeSummary := rangeAgg.Summary
|
||||
rangeAgg.RemainingBirds += rowBirds
|
||||
rangeAgg.RemainingWeightKg += row.RemainingChickenWeight
|
||||
rangeAgg.AvgWeightSum += avgWeight
|
||||
rangeAgg.AvgWeightCount++
|
||||
for _, supplier := range feedSupplierMap[row.KandangID] {
|
||||
if _, ok := rangeAgg.FeedSuppliers[supplier.ID]; !ok {
|
||||
rangeAgg.FeedSuppliers[supplier.ID] = supplier
|
||||
@@ -1246,8 +1254,8 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
||||
agg := perRangeMap[key]
|
||||
entry := agg.Summary
|
||||
entry.ID = idx + 1
|
||||
if agg.RemainingBirds > 0 {
|
||||
entry.AvgWeightKg = agg.RemainingWeightKg / float64(agg.RemainingBirds)
|
||||
if agg.AvgWeightCount > 0 {
|
||||
entry.AvgWeightKg = agg.AvgWeightSum / float64(agg.AvgWeightCount)
|
||||
}
|
||||
if agg.EggHppCount > 0 {
|
||||
entry.EggHppRpPerKg = agg.EggHppSum / float64(agg.EggHppCount)
|
||||
@@ -1269,7 +1277,9 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
||||
TotalEggValueRp: totalEggValueRp,
|
||||
}
|
||||
if totalBirds > 0 {
|
||||
totalSummary.AverageWeightKg = totalWeight / float64(totalBirds)
|
||||
}
|
||||
if totalAvgWeightCount > 0 {
|
||||
totalSummary.AverageWeightKg = totalAvgWeightSum / float64(totalAvgWeightCount)
|
||||
}
|
||||
if totalEggHppCount > 0 {
|
||||
totalSummary.AverageEggHppRpPerKg = totalEggHppSum / float64(totalEggHppCount)
|
||||
|
||||
Reference in New Issue
Block a user