feat(Inventory): 實作批號溯源完整功能與 UI 呈現,包含文字敘述卡片與更完整的關聯屬性
This commit is contained in:
@@ -5,4 +5,21 @@ namespace App\Modules\Production\Contracts;
|
||||
interface ProductionServiceInterface
|
||||
{
|
||||
public function getPendingProductionCount(): int;
|
||||
|
||||
/**
|
||||
* 尋找產出特定批號的生產工單
|
||||
*
|
||||
* @param string $batchNumber
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getProductionOrdersByOutputBatch(string $batchNumber): \Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* 尋找使用了特定庫存批號的生產工單項目
|
||||
*
|
||||
* @param int $inventoryId
|
||||
* @param array $with
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function getProductionOrderItemsByInventoryId(int $inventoryId, array $with = []): \Illuminate\Support\Collection;
|
||||
}
|
||||
|
||||
@@ -26,4 +26,9 @@ class ProductionOrderItem extends Model
|
||||
{
|
||||
return $this->belongsTo(ProductionOrder::class);
|
||||
}
|
||||
|
||||
public function inventory(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Modules\Inventory\Models\Inventory::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Modules\Production\Services;
|
||||
|
||||
use App\Modules\Production\Contracts\ProductionServiceInterface;
|
||||
use App\Modules\Production\Models\ProductionOrder;
|
||||
use App\Modules\Production\Models\ProductionOrderItem;
|
||||
|
||||
class ProductionService implements ProductionServiceInterface
|
||||
{
|
||||
@@ -11,4 +12,18 @@ class ProductionService implements ProductionServiceInterface
|
||||
{
|
||||
return ProductionOrder::where('status', 'pending')->count();
|
||||
}
|
||||
|
||||
public function getProductionOrdersByOutputBatch(string $batchNumber): \Illuminate\Support\Collection
|
||||
{
|
||||
return ProductionOrder::with(['items.inventory.product', 'items.inventory'])
|
||||
->where('output_batch_number', $batchNumber)
|
||||
->get();
|
||||
}
|
||||
|
||||
public function getProductionOrderItemsByInventoryId(int $inventoryId, array $with = []): \Illuminate\Support\Collection
|
||||
{
|
||||
return ProductionOrderItem::with($with)
|
||||
->where('inventory_id', $inventoryId)
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user