mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
adjust get weight remaining
This commit is contained in:
@@ -23,6 +23,7 @@ type HppPerKandangRow struct {
|
||||
// RemainingChickenBirds float64
|
||||
// RemainingChickenWeight float64
|
||||
EggProductionWeightKgRemaining float64
|
||||
// AverageWeightEggPerPiece float64
|
||||
// EggProductionPiecesRemaining float64
|
||||
// EggProductionTotalWeightKg float64
|
||||
// EggProductionTotalPieces float64
|
||||
@@ -229,8 +230,8 @@ func (r *hppPerKandangRepository) GetWeightRemainingByProjectFlockKandangIDs(ctx
|
||||
)
|
||||
|
||||
type eggRow struct {
|
||||
ProjectFlockKandangID uint
|
||||
EggProductionWeightKgRemaining float64
|
||||
ProjectFlockKandangID uint
|
||||
AverageWeightEggPerPiece float64
|
||||
// EggProductionPiecesRemaining float64
|
||||
// EggProductionTotalWeightKg float64
|
||||
// EggProductionTotalPieces float64
|
||||
@@ -241,7 +242,7 @@ func (r *hppPerKandangRepository) GetWeightRemainingByProjectFlockKandangIDs(ctx
|
||||
Table("recordings AS r").
|
||||
Select(`
|
||||
r.project_flock_kandangs_id AS project_flock_kandang_id,
|
||||
COALESCE((SUM(re.weight) / NULLIF(SUM(re.total_qty), 0)) * SUM(re.total_qty - re.total_used), 0) AS egg_production_weight_kg_remaining`).
|
||||
COALESCE(SUM(re.weight) / NULLIF(SUM(re.total_qty), 0), 0) AS average_weight_egg_per_piece`).
|
||||
Joins("LEFT JOIN (?) AS la ON la.approvable_id = r.id", latestApproval).
|
||||
Joins("LEFT JOIN recording_eggs AS re ON re.recording_id = r.id").
|
||||
Where("r.project_flock_kandangs_id IN ?", projectFlockKandangIDs).
|
||||
@@ -257,8 +258,8 @@ func (r *hppPerKandangRepository) GetWeightRemainingByProjectFlockKandangIDs(ctx
|
||||
result := make(map[uint]HppPerKandangRow, len(eggRows))
|
||||
for _, row := range eggRows {
|
||||
result[row.ProjectFlockKandangID] = HppPerKandangRow{
|
||||
ProjectFlockKandangID: row.ProjectFlockKandangID,
|
||||
EggProductionWeightKgRemaining: row.EggProductionWeightKgRemaining,
|
||||
ProjectFlockKandangID: row.ProjectFlockKandangID,
|
||||
// AverageWeightEggPerPiece: row.AverageWeightEggPerPiece,
|
||||
// EggProductionPiecesRemaining: row.EggProductionPiecesRemaining,
|
||||
// EggProductionTotalWeightKg: row.EggProductionTotalWeightKg,
|
||||
// EggProductionTotalPieces: row.EggProductionTotalPieces,
|
||||
|
||||
Reference in New Issue
Block a user