mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
adjust grouping by project flock kandang
This commit is contained in:
@@ -1380,7 +1380,7 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
||||
|
||||
costMap := make(map[uint]HppCostAggregate, len(costRows))
|
||||
for _, row := range costRows {
|
||||
costMap[row.KandangID] = HppCostAggregate{
|
||||
costMap[row.ProjectFlockKandangID] = HppCostAggregate{
|
||||
FeedCost: row.FeedCost,
|
||||
OvkCost: row.OvkCost,
|
||||
DocCost: row.DocCost,
|
||||
@@ -1409,15 +1409,15 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
||||
category = "DOC"
|
||||
}
|
||||
|
||||
if seen[sup.KandangID] == nil {
|
||||
seen[sup.KandangID] = make(map[uint]bool)
|
||||
if seen[sup.ProjectFlockKandangID] == nil {
|
||||
seen[sup.ProjectFlockKandangID] = make(map[uint]bool)
|
||||
}
|
||||
if seen[sup.KandangID][sup.SupplierID] {
|
||||
if seen[sup.ProjectFlockKandangID][sup.SupplierID] {
|
||||
continue
|
||||
}
|
||||
seen[sup.KandangID][sup.SupplierID] = true
|
||||
seen[sup.ProjectFlockKandangID][sup.SupplierID] = true
|
||||
|
||||
targetMap[sup.KandangID] = append(targetMap[sup.KandangID], dto.HppPerKandangSupplierDTO{
|
||||
targetMap[sup.ProjectFlockKandangID] = append(targetMap[sup.ProjectFlockKandangID], dto.HppPerKandangSupplierDTO{
|
||||
ID: int64(sup.SupplierID),
|
||||
Name: sup.SupplierName,
|
||||
Alias: sup.SupplierAlias,
|
||||
@@ -1507,7 +1507,7 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
||||
rangeKey := weightRangeKey{Min: weightMin, Max: weightMax}
|
||||
|
||||
// rowBirds := int64(math.Round(birdsFloat))
|
||||
costEntry := costMap[row.KandangID]
|
||||
costEntry := costMap[row.ProjectFlockKandangID]
|
||||
totalCost := costEntry.FeedCost + costEntry.OvkCost + costEntry.DocCost + costEntry.BudgetCost + costEntry.ExpenseCost
|
||||
// hppRp := 0.0
|
||||
// if weightFloat > 0 {
|
||||
@@ -1526,8 +1526,10 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
||||
avgDocPrice = int64(math.Round(costEntry.DocCost / costEntry.DocQty))
|
||||
}
|
||||
|
||||
nameWithPeriod := fmt.Sprintf("%s Period %d", row.KandangName, row.ProjectFlockPeriod)
|
||||
|
||||
dataRows = append(dataRows, dto.HppPerKandangRowDTO{
|
||||
ID: int(row.KandangID),
|
||||
ID: int(row.ProjectFlockKandangID),
|
||||
Kandang: dto.HppPerKandangRowKandangDTO{
|
||||
ID: int64(row.KandangID),
|
||||
Name: row.KandangName,
|
||||
@@ -1545,11 +1547,12 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
||||
WeightMin: weightMin,
|
||||
WeightMax: weightMax,
|
||||
},
|
||||
AvgWeightKg: avgWeight,
|
||||
AvgWeightKg: avgWeight,
|
||||
NameWithPeriode: nameWithPeriod,
|
||||
// FeedCostRp: costEntry.FeedCost,
|
||||
// OvkCostRp: costEntry.OvkCost,
|
||||
DocSuppliers: docSupplierMap[row.KandangID],
|
||||
FeedSuppliers: feedSupplierMap[row.KandangID],
|
||||
DocSuppliers: docSupplierMap[row.ProjectFlockKandangID],
|
||||
FeedSuppliers: feedSupplierMap[row.ProjectFlockKandangID],
|
||||
EggProductionPieces: int64(math.Round(eggPiecesFloatRemaining)),
|
||||
EggProductionKg: eggRemainingWeightFloatRemaining,
|
||||
// EggProductionTotalWeightKg: eggWeightFloat,
|
||||
@@ -1603,12 +1606,12 @@ func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangRes
|
||||
// rangeAgg.RemainingWeightKg += row.RemainingChickenWeight
|
||||
rangeAgg.AvgWeightSum += avgWeight
|
||||
rangeAgg.AvgWeightCount++
|
||||
for _, supplier := range feedSupplierMap[row.KandangID] {
|
||||
for _, supplier := range feedSupplierMap[row.ProjectFlockKandangID] {
|
||||
if _, ok := rangeAgg.FeedSuppliers[supplier.ID]; !ok {
|
||||
rangeAgg.FeedSuppliers[supplier.ID] = supplier
|
||||
}
|
||||
}
|
||||
for _, supplier := range docSupplierMap[row.KandangID] {
|
||||
for _, supplier := range docSupplierMap[row.ProjectFlockKandangID] {
|
||||
if _, ok := rangeAgg.DocSuppliers[supplier.ID]; !ok {
|
||||
rangeAgg.DocSuppliers[supplier.ID] = supplier
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user