feat(WEB): 작업지시/출근부 기능 개선 및 마이그레이션 추가

- 작업지시 우선순위 필드 추가 (priority 마이그레이션)
- 수주-작업지시 품목 연동 source_order_item_id 컬럼 추가
- 수주 테이블에 account_code 필드 추가
- 작업지시 StoreRequest/UpdateRequest 우선순위 검증 추가
- WorkOrder 모델 priority fillable 추가
- 출근부 StoreRequest/UpdateRequest 검증 규칙 개선
- Employee Request 검증 규칙 수정
- SaleService/ItemService 수정
- WorkResultService 결과 처리 개선
- BankTransactionService 수정
- routes/api.php 엔드포인트 업데이트
- error.php 에러 메시지 추가

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-16 15:38:52 +09:00
parent 49d632b16b
commit 7543fd2256
19 changed files with 207 additions and 14 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Services;
use App\Models\Members\User;
use App\Models\Production\WorkOrderItem;
use Illuminate\Support\Facades\DB;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -81,7 +82,32 @@ public function index(array $params)
// 최신 완료순 정렬
$query->orderByDesc('options->result->completed_at')->orderByDesc('id');
return $query->paginate($size, ['*'], 'page', $page);
$paginated = $query->paginate($size, ['*'], 'page', $page);
// worker_id로 작업자 이름 조회하여 추가
$workerIds = $paginated->getCollection()
->map(fn ($item) => $item->options['result']['worker_id'] ?? null)
->filter()
->unique()
->values()
->toArray();
$workers = [];
if (! empty($workerIds)) {
$workers = User::whereIn('id', $workerIds)
->pluck('name', 'id')
->toArray();
}
// 각 아이템에 worker_name 추가
$paginated->getCollection()->transform(function ($item) use ($workers) {
$workerId = $item->options['result']['worker_id'] ?? null;
$item->worker_name = $workerId ? ($workers[$workerId] ?? null) : null;
return $item;
});
return $paginated;
}
/**
@@ -155,6 +181,14 @@ public function show(int $id)
throw new NotFoundHttpException(__('error.not_found'));
}
// worker_name 추가
$workerId = $item->options['result']['worker_id'] ?? null;
if ($workerId) {
$item->worker_name = User::where('id', $workerId)->value('name');
} else {
$item->worker_name = null;
}
return $item;
}