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
|
Summary *dto.HppPerKandangSummaryWeightRangeDTO
|
||||||
RemainingBirds int64
|
RemainingBirds int64
|
||||||
RemainingWeightKg float64
|
RemainingWeightKg float64
|
||||||
|
AvgWeightSum float64
|
||||||
|
AvgWeightCount int64
|
||||||
EggHppSum float64
|
EggHppSum float64
|
||||||
EggHppCount int
|
EggHppCount int
|
||||||
FeedSuppliers map[int64]dto.HppPerKandangSupplierDTO
|
FeedSuppliers map[int64]dto.HppPerKandangSupplierDTO
|
||||||
@@ -1078,6 +1080,8 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
|||||||
var totalDocPriceCount int
|
var totalDocPriceCount int
|
||||||
var totalEggHppSum float64
|
var totalEggHppSum float64
|
||||||
var totalEggHppCount int
|
var totalEggHppCount int
|
||||||
|
var totalAvgWeightSum float64
|
||||||
|
var totalAvgWeightCount int64
|
||||||
|
|
||||||
for _, row := range repoRows {
|
for _, row := range repoRows {
|
||||||
if !params.ShowUnrecorded && row.RecordingCount == 0 {
|
if !params.ShowUnrecorded && row.RecordingCount == 0 {
|
||||||
@@ -1178,6 +1182,8 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
|||||||
totalEggKg += eggWeightFloat
|
totalEggKg += eggWeightFloat
|
||||||
totalRemainingValueRp += rowRemainingValue
|
totalRemainingValueRp += rowRemainingValue
|
||||||
totalEggValueRp += rowEggValue
|
totalEggValueRp += rowEggValue
|
||||||
|
totalAvgWeightSum += avgWeight
|
||||||
|
totalAvgWeightCount++
|
||||||
if weightFloat > 0 {
|
if weightFloat > 0 {
|
||||||
totalHppSum += hppRp
|
totalHppSum += hppRp
|
||||||
totalHppCount++
|
totalHppCount++
|
||||||
@@ -1210,6 +1216,8 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
|||||||
rangeSummary := rangeAgg.Summary
|
rangeSummary := rangeAgg.Summary
|
||||||
rangeAgg.RemainingBirds += rowBirds
|
rangeAgg.RemainingBirds += rowBirds
|
||||||
rangeAgg.RemainingWeightKg += row.RemainingChickenWeight
|
rangeAgg.RemainingWeightKg += row.RemainingChickenWeight
|
||||||
|
rangeAgg.AvgWeightSum += avgWeight
|
||||||
|
rangeAgg.AvgWeightCount++
|
||||||
for _, supplier := range feedSupplierMap[row.KandangID] {
|
for _, supplier := range feedSupplierMap[row.KandangID] {
|
||||||
if _, ok := rangeAgg.FeedSuppliers[supplier.ID]; !ok {
|
if _, ok := rangeAgg.FeedSuppliers[supplier.ID]; !ok {
|
||||||
rangeAgg.FeedSuppliers[supplier.ID] = supplier
|
rangeAgg.FeedSuppliers[supplier.ID] = supplier
|
||||||
@@ -1246,8 +1254,8 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
|||||||
agg := perRangeMap[key]
|
agg := perRangeMap[key]
|
||||||
entry := agg.Summary
|
entry := agg.Summary
|
||||||
entry.ID = idx + 1
|
entry.ID = idx + 1
|
||||||
if agg.RemainingBirds > 0 {
|
if agg.AvgWeightCount > 0 {
|
||||||
entry.AvgWeightKg = agg.RemainingWeightKg / float64(agg.RemainingBirds)
|
entry.AvgWeightKg = agg.AvgWeightSum / float64(agg.AvgWeightCount)
|
||||||
}
|
}
|
||||||
if agg.EggHppCount > 0 {
|
if agg.EggHppCount > 0 {
|
||||||
entry.EggHppRpPerKg = agg.EggHppSum / float64(agg.EggHppCount)
|
entry.EggHppRpPerKg = agg.EggHppSum / float64(agg.EggHppCount)
|
||||||
@@ -1269,7 +1277,9 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
|||||||
TotalEggValueRp: totalEggValueRp,
|
TotalEggValueRp: totalEggValueRp,
|
||||||
}
|
}
|
||||||
if totalBirds > 0 {
|
if totalBirds > 0 {
|
||||||
totalSummary.AverageWeightKg = totalWeight / float64(totalBirds)
|
}
|
||||||
|
if totalAvgWeightCount > 0 {
|
||||||
|
totalSummary.AverageWeightKg = totalAvgWeightSum / float64(totalAvgWeightCount)
|
||||||
}
|
}
|
||||||
if totalEggHppCount > 0 {
|
if totalEggHppCount > 0 {
|
||||||
totalSummary.AverageEggHppRpPerKg = totalEggHppSum / float64(totalEggHppCount)
|
totalSummary.AverageEggHppRpPerKg = totalEggHppSum / float64(totalEggHppCount)
|
||||||
|
|||||||
Reference in New Issue
Block a user