feat: [bending] 담당자 기본값 + 원자재 LOT 조회 API + 취소 복원 지원

- STOCK 주문 생성 시 담당자(manager_name) 미입력이면 로그인 사용자명 자동 설정
- GET /bending/material-lots?material={재질}: 수입검사 완료 입고의 LOT 목록 조회
- 취소→등록 복원은 기존 CANCELLED→DRAFT 전환으로 이미 지원됨 (프론트 UI만 필요)
This commit is contained in:
김보곤
2026-03-17 14:20:36 +09:00
parent 9358c4112e
commit b60e44ea3a
3 changed files with 52 additions and 1 deletions

View File

@@ -4,6 +4,7 @@
use App\Helpers\ApiResponse;
use App\Http\Controllers\Controller;
use App\Models\Tenants\Receiving;
use App\Services\BendingCodeService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -48,6 +49,45 @@ public function resolveItem(Request $request): JsonResponse
}, __('message.fetched'));
}
/**
* 원자재 LOT 목록 조회 (수입검사 완료 입고 기준)
*
* 재질(material)이 일치하는 입고 LOT 목록 반환
*/
public function materialLots(Request $request): JsonResponse
{
return ApiResponse::handle(function () use ($request) {
$material = $request->query('material');
$query = Receiving::where('status', 'completed')
->whereNotNull('lot_no')
->where('lot_no', '!=', '');
// 재질(item_name 또는 specification)으로 필터링
if ($material) {
$query->where(function ($q) use ($material) {
$q->where('item_name', 'LIKE', "%{$material}%")
->orWhere('specification', 'LIKE', "%{$material}%");
});
}
return $query->select([
'id',
'lot_no',
'supplier_lot',
'item_name',
'specification',
'receiving_qty',
'receiving_date',
'supplier',
'options',
])
->orderByDesc('receiving_date')
->limit(50)
->get();
}, __('message.fetched'));
}
/**
* LOT 번호 생성 (프리뷰 + 일련번호 확정)
*/

View File

@@ -182,9 +182,19 @@ public function store(array $data)
$data['status_code'] = $data['status_code'] ?? Order::STATUS_DRAFT;
$data['order_type_code'] = $data['order_type_code'] ?? Order::TYPE_ORDER;
// 재고생산: 현장명 자동 설정
// 재고생산: 현장명 + 담당자 자동 설정
if ($isStock) {
$data['site_name'] = '재고생산';
// 담당자(manager_name)가 비어 있으면 로그인 사용자 이름으로 설정
$options = $data['options'] ?? [];
if (empty($options['manager_name'])) {
$user = \App\Models\Members\User::find($userId);
if ($user) {
$options['manager_name'] = $user->name;
$data['options'] = $options;
}
}
}
$items = $data['items'] ?? [];

View File

@@ -131,6 +131,7 @@
Route::get('/code-map', [BendingController::class, 'codeMap'])->name('v1.bending.code-map');
Route::get('/resolve-item', [BendingController::class, 'resolveItem'])->name('v1.bending.resolve-item');
Route::post('/generate-lot', [BendingController::class, 'generateLotNumber'])->name('v1.bending.generate-lot');
Route::get('/material-lots', [BendingController::class, 'materialLots'])->name('v1.bending.material-lots');
});
// Bending Item API (절곡품 기초관리)