实现库存管理相关逻辑

This commit is contained in:
2025-11-25 18:10:28 +08:00
parent ae27eb142d
commit 44ff3b19d6
15 changed files with 1531 additions and 22 deletions

View File

@@ -9,6 +9,7 @@ import (
"git.huangwc.com/pig/pig-farm-controller/internal/app/webhook"
"git.huangwc.com/pig/pig-farm-controller/internal/domain/alarm"
"git.huangwc.com/pig/pig-farm-controller/internal/domain/device"
"git.huangwc.com/pig/pig-farm-controller/internal/domain/inventory"
domain_notify "git.huangwc.com/pig/pig-farm-controller/internal/domain/notify"
"git.huangwc.com/pig/pig-farm-controller/internal/domain/pig"
"git.huangwc.com/pig/pig-farm-controller/internal/domain/plan"
@@ -137,6 +138,7 @@ type DomainServices struct {
notifyService domain_notify.Service
alarmService alarm.AlarmService
recipeService recipe.Service
inventoryService inventory.InventoryCoreService
}
// initDomainServices 初始化所有的领域服务。
@@ -233,6 +235,9 @@ func initDomainServices(ctx context.Context, cfg *config.Config, infra *Infrastr
recipeCoreService,
)
// 库存管理
inventoryService := inventory.NewInventoryCoreService(logs.AddCompName(baseCtx, "InventoryCoreService"), infra.repos.unitOfWork, infra.repos.rawMaterialRepo)
return &DomainServices{
pigPenTransferManager: pigPenTransferManager,
pigTradeManager: pigTradeManager,
@@ -246,6 +251,7 @@ func initDomainServices(ctx context.Context, cfg *config.Config, infra *Infrastr
notifyService: notifyService,
alarmService: alarmService,
recipeService: recipeService,
inventoryService: inventoryService,
}, nil
}
@@ -265,6 +271,7 @@ type AppServices struct {
pigTypeService service.PigTypeService
rawMaterialService service.RawMaterialService
recipeService service.RecipeService
inventoryService service.InventoryService
}
// initAppServices 初始化所有的应用服务。
@@ -318,6 +325,7 @@ func initAppServices(ctx context.Context, infra *Infrastructure, domainServices
pigTypeService := service.NewPigTypeService(logs.AddCompName(baseCtx, "PigTypeService"), domainServices.recipeService)
rawMaterialService := service.NewRawMaterialService(logs.AddCompName(baseCtx, "RawMaterialService"), domainServices.recipeService)
recipeService := service.NewRecipeService(logs.AddCompName(baseCtx, "RecipeService"), domainServices.recipeService)
inventoryService := service.NewInventoryService(logs.AddCompName(baseCtx, "InventoryService"), domainServices.inventoryService, infra.repos.rawMaterialRepo)
return &AppServices{
pigFarmService: pigFarmService,
@@ -334,6 +342,7 @@ func initAppServices(ctx context.Context, infra *Infrastructure, domainServices
pigTypeService: pigTypeService,
rawMaterialService: rawMaterialService,
recipeService: recipeService,
inventoryService: inventoryService,
}
}