mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 05:21:57 +00:00
Merge branch 'FEAT/BE/Production_standard' into 'development'
FEAT[BE] :add production standard detail creation for growing only FCR See merge request mbugroup/lti-api!302
This commit is contained in:
@@ -152,6 +152,23 @@ func (s *productionStandardService) CreateOne(c *fiber.Ctx, req *validation.Crea
|
||||
if err := productionStandardDetailRepoTx.CreateOne(c.Context(), productionStandardDetail, nil); err != nil {
|
||||
return fmt.Errorf("failed to create production standard detail for week %d: %w", detailReq.Week, err)
|
||||
}
|
||||
} else if req.ProjectCategory == string(utils.ProjectFlockCategoryGrowing) {
|
||||
if detailReq.ProductionStandardDetails != nil && detailReq.ProductionStandardDetails.StandardFCR != nil {
|
||||
var zero float64 = 0
|
||||
productionStandardDetail := &entity.ProductionStandardDetail{
|
||||
ProductionStandardId: newStandard.Id,
|
||||
Week: detailReq.Week,
|
||||
TargetHenDayProduction: &zero,
|
||||
TargetHenHouseProduction: &zero,
|
||||
TargetEggWeight: &zero,
|
||||
TargetEggMass: &zero,
|
||||
StandardFCR: detailReq.ProductionStandardDetails.StandardFCR,
|
||||
}
|
||||
|
||||
if err := productionStandardDetailRepoTx.CreateOne(c.Context(), productionStandardDetail, nil); err != nil {
|
||||
return fmt.Errorf("failed to create production standard detail for week %d: %w", detailReq.Week, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
standardGrowthDetail := &entity.StandardGrowthDetail{
|
||||
@@ -265,6 +282,23 @@ func (s productionStandardService) UpdateOne(c *fiber.Ctx, req *validation.Updat
|
||||
if err := productionStandardDetailRepoTx.CreateOne(c.Context(), productionStandardDetail, nil); err != nil {
|
||||
return fmt.Errorf("failed to create production standard detail for week %d: %w", detailReq.Week, err)
|
||||
}
|
||||
} else if projectCategory == "GROWING" {
|
||||
if detailReq.ProductionStandardDetails != nil && detailReq.ProductionStandardDetails.StandardFCR != nil {
|
||||
var zero float64 = 0
|
||||
productionStandardDetail := &entity.ProductionStandardDetail{
|
||||
ProductionStandardId: id,
|
||||
Week: detailReq.Week,
|
||||
TargetHenDayProduction: &zero,
|
||||
TargetHenHouseProduction: &zero,
|
||||
TargetEggWeight: &zero,
|
||||
TargetEggMass: &zero,
|
||||
StandardFCR: detailReq.ProductionStandardDetails.StandardFCR,
|
||||
}
|
||||
|
||||
if err := productionStandardDetailRepoTx.CreateOne(c.Context(), productionStandardDetail, nil); err != nil {
|
||||
return fmt.Errorf("failed to create production standard detail for week %d: %w", detailReq.Week, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
standardGrowthDetail := &entity.StandardGrowthDetail{
|
||||
|
||||
Reference in New Issue
Block a user