feat: [bending] 절곡품 전용 테이블 분리 API
- bending_items 전용 테이블 생성 (items.options → 정규 컬럼 승격) - bending_models 전용 테이블 생성 (가이드레일/케이스/하단마감재 통합) - bending_data JSON 통합 (별도 테이블 → bending_items.bending_data 컬럼) - bending_item_mappings 테이블 DROP (bending_items.code에 흡수) - BendingItemService/BendingCodeService → BendingItem 모델 전환 - GuiderailModelService component 이미지 자동 복사 - ItemsFileController bending_items/bending_models 폴백 지원 - Swagger 스키마 업데이트
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Production\BendingItemMapping;
|
||||
use App\Models\BendingItem;
|
||||
use App\Models\Orders\Order;
|
||||
|
||||
class BendingCodeService extends Service
|
||||
{
|
||||
@@ -127,28 +128,38 @@ public function getCodeMap(): array
|
||||
}
|
||||
|
||||
/**
|
||||
* 드롭다운 선택 조합 → items 테이블 품목 매핑 조회
|
||||
* 드롭다운 선택 조합 → bending_items 품목 매핑 조회
|
||||
*
|
||||
* legacy_code 패턴: BD-{prod}{spec}-{length} (예: BD-CP-30)
|
||||
*/
|
||||
public function resolveItem(string $prodCode, string $specCode, string $lengthCode): ?array
|
||||
{
|
||||
$mapping = BendingItemMapping::where('tenant_id', $this->tenantId())
|
||||
->where('prod_code', $prodCode)
|
||||
->where('spec_code', $specCode)
|
||||
// 1차: code + length_code로 조회 (신규 LOT 체계)
|
||||
$item = BendingItem::where('tenant_id', $this->tenantId())
|
||||
->where('code', 'like', "{$prodCode}{$specCode}%")
|
||||
->where('length_code', $lengthCode)
|
||||
->where('is_active', true)
|
||||
->with('item:id,code,name,attributes,unit')
|
||||
->first();
|
||||
|
||||
if (! $mapping || ! $mapping->item) {
|
||||
// 2차: legacy_code 폴백
|
||||
if (! $item) {
|
||||
$legacyCode = "BD-{$prodCode}{$specCode}-{$lengthCode}";
|
||||
$item = BendingItem::where('tenant_id', $this->tenantId())
|
||||
->where('legacy_code', $legacyCode)
|
||||
->where('is_active', true)
|
||||
->first();
|
||||
}
|
||||
|
||||
if (! $item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'item_id' => $mapping->item->id,
|
||||
'item_code' => $mapping->item->code,
|
||||
'item_name' => $mapping->item->name,
|
||||
'specification' => $mapping->item->specification,
|
||||
'unit' => $mapping->item->unit ?? 'EA',
|
||||
'item_id' => $item->id,
|
||||
'item_code' => $item->code,
|
||||
'item_name' => $item->item_name,
|
||||
'specification' => $item->item_spec,
|
||||
'unit' => 'EA',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user