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