mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
fix woa at hasil produksi
This commit is contained in:
@@ -882,8 +882,6 @@ func (s *repportService) GetProductionResult(ctx *fiber.Ctx, params *validation.
|
||||
defaultBw = 0
|
||||
defaultUniformText = "90% up"
|
||||
)
|
||||
defaultStartWoa := config.LayingWeekStart()
|
||||
|
||||
if params.Limit <= 0 {
|
||||
params.Limit = 10
|
||||
}
|
||||
@@ -933,7 +931,7 @@ func (s *repportService) GetProductionResult(ctx *fiber.Ctx, params *validation.
|
||||
|
||||
weeks := make([]int, len(weeklyResults))
|
||||
for i := range weeklyResults {
|
||||
weeks[i] = defaultStartWoa + i
|
||||
weeks[i] = int(weeklyResults[i].Woa)
|
||||
}
|
||||
uniformityMap, err := s.getUniformityByWeek(ctx.Context(), params.ProjectFlockKandangID, weeks)
|
||||
if err != nil {
|
||||
@@ -943,13 +941,12 @@ func (s *repportService) GetProductionResult(ctx *fiber.Ctx, params *validation.
|
||||
var cumulativeButir int64
|
||||
var cumulativeKg float64
|
||||
for i := range weeklyResults {
|
||||
weeklyResults[i].Woa = float64(defaultStartWoa + i)
|
||||
weeklyResults[i].StdBw = defaultStdBw
|
||||
weeklyResults[i].Bw = defaultBw
|
||||
if weeklyResults[i].StdUniformity == "" {
|
||||
weeklyResults[i].StdUniformity = defaultUniformText
|
||||
}
|
||||
if uniformity, ok := uniformityMap[defaultStartWoa+i]; ok {
|
||||
if uniformity, ok := uniformityMap[int(weeklyResults[i].Woa)]; ok {
|
||||
weeklyResults[i].Uniformity = uniformity.Uniformity
|
||||
if uniformity.AvgWeight != nil {
|
||||
weeklyResults[i].Bw = *uniformity.AvgWeight
|
||||
@@ -1356,8 +1353,8 @@ func mapRecordingToProductionResultDTO(record entity.Recording) dto.ProductionRe
|
||||
Ew: valueOrZero(record.EggWeight),
|
||||
}
|
||||
|
||||
if record.Day != nil {
|
||||
result.Woa = float64(*record.Day)
|
||||
if record.Day != nil && *record.Day > 0 {
|
||||
result.Woa = float64((*record.Day + 6) / 7) // ceil(day/7)
|
||||
}
|
||||
avgWeight := 1.0
|
||||
if avgWeight > 0 {
|
||||
@@ -1588,6 +1585,7 @@ func aggregateProductionResultGroup(group []dto.ProductionResultDTO, groupSize i
|
||||
CreatedAt: group[0].CreatedAt,
|
||||
UpdatedAt: group[0].UpdatedAt,
|
||||
StdUniformity: group[0].StdUniformity,
|
||||
Woa: group[0].Woa,
|
||||
}
|
||||
|
||||
var sumBw, sumStdBw, sumUniformity float64
|
||||
|
||||
Reference in New Issue
Block a user