feat(API): 작업지시 공정 연동 개선

- WorkOrder 모델에 process_id 추가
- process 관계 추가 (Process 모델)
- 공정별 다중 작업지시 생성 지원
- WorkOrderStoreRequest/UpdateRequest 수정

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-01-13 19:48:48 +09:00
parent 97f22f9b98
commit fc6d88bd26
5 changed files with 91 additions and 36 deletions

View File

@@ -4,6 +4,7 @@
use App\Models\Members\User;
use App\Models\Orders\Order;
use App\Models\Process;
use App\Models\Tenants\Department;
use App\Traits\BelongsToTenant;
use App\Traits\ModelTrait;
@@ -28,8 +29,8 @@ class WorkOrder extends Model
'tenant_id',
'work_order_no',
'sales_order_id',
'process_id',
'project_name',
'process_type',
'status',
'assignee_id',
'team_id',
@@ -60,14 +61,18 @@ class WorkOrder extends Model
// ──────────────────────────────────────────────────────────────
/**
* 공정 유형
* @deprecated 공정유형은 processes 테이블의 process_name으로 관리됨
* 하위 호환성을 위해 유지. process_id FK 사용 권장
*/
public const PROCESS_SCREEN = 'screen';
/** @deprecated process_id FK 사용 권장 */
public const PROCESS_SLAT = 'slat';
/** @deprecated process_id FK 사용 권장 */
public const PROCESS_BENDING = 'bending';
/** @deprecated process_id FK 사용 권장 */
public const PROCESS_TYPES = [
self::PROCESS_SCREEN,
self::PROCESS_SLAT,
@@ -123,6 +128,14 @@ public function salesOrder(): BelongsTo
return $this->belongsTo(Order::class, 'sales_order_id');
}
/**
* 공정 (processes 테이블 참조)
*/
public function process(): BelongsTo
{
return $this->belongsTo(Process::class);
}
/**
* 담당자 (주 담당자 - 하위 호환)
*/
@@ -208,11 +221,21 @@ public function scopeStatus($query, string $status)
}
/**
* 공정유형별 필터
* 공정 ID별 필터
*/
public function scopeProcessType($query, string $type)
public function scopeForProcess($query, int $processId)
{
return $query->where('process_type', $type);
return $query->where('process_id', $processId);
}
/**
* 공정명으로 필터 (process_name 기준)
*/
public function scopeForProcessName($query, string $processName)
{
return $query->whereHas('process', function ($q) use ($processName) {
$q->where('process_name', $processName);
});
}
/**
@@ -279,7 +302,15 @@ public function scopeScheduledBetween($query, $from, $to)
*/
public function isBending(): bool
{
return $this->process_type === self::PROCESS_BENDING;
return $this->process && $this->process->process_name === '절곡';
}
/**
* 특정 공정명인지 확인
*/
public function isProcessName(string $processName): bool
{
return $this->process && $this->process->process_name === $processName;
}
/**