feat: 견적 참조 데이터 API, 수주 전환 로직 개선, 검사기준서 필드 통합
- 견적 참조 데이터(현장명, 부호) 조회 API 추가 (GET /quotes/reference-data) - 수주 전환 시 floor_code/symbol_code를 quoteItem.note에서 파싱하도록 변경 - 수주 전환 시 note에 formula_category 저장 - 검사기준서 프리셋: standard + standard_criteria → text_with_criteria로 통합 - tolerance 컬럼 width 조정 (120px → 85px) - LOGICAL_RELATIONSHIPS.md 문서 갱신 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -101,6 +101,64 @@ public function index(array $params): LengthAwarePaginator
|
||||
return $query->paginate($size, ['*'], 'page', $page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 견적 참조 데이터 조회 (현장명, 부호 목록)
|
||||
*
|
||||
* 기존 견적/수주에서 사용된 현장명과 부호를 DISTINCT로 조회합니다.
|
||||
*/
|
||||
public function referenceData(): array
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
// 현장명: 견적 테이블에서 DISTINCT
|
||||
$siteNames = Quote::where('tenant_id', $tenantId)
|
||||
->whereNotNull('site_name')
|
||||
->where('site_name', '!=', '')
|
||||
->distinct()
|
||||
->orderBy('site_name')
|
||||
->pluck('site_name')
|
||||
->toArray();
|
||||
|
||||
// 부호(개소코드): calculation_inputs JSON 내 items[].code (예: FSS-01, SD-02)
|
||||
$locationCodes = collect();
|
||||
|
||||
// calculation_inputs JSON에서 items[].code 추출
|
||||
$quotesWithInputs = Quote::where('tenant_id', $tenantId)
|
||||
->whereNotNull('calculation_inputs')
|
||||
->select('calculation_inputs')
|
||||
->get();
|
||||
|
||||
foreach ($quotesWithInputs as $quote) {
|
||||
$inputs = is_string($quote->calculation_inputs)
|
||||
? json_decode($quote->calculation_inputs, true)
|
||||
: $quote->calculation_inputs;
|
||||
|
||||
if (! is_array($inputs)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$items = $inputs['items'] ?? $inputs['locations'] ?? [];
|
||||
foreach ($items as $item) {
|
||||
$code = $item['code'] ?? null;
|
||||
if ($code && trim($code) !== '') {
|
||||
$locationCodes->push(trim($code));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 중복 제거, 정렬
|
||||
$locationCodes = $locationCodes
|
||||
->unique()
|
||||
->sort()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
return [
|
||||
'site_names' => $siteNames,
|
||||
'location_codes' => $locationCodes,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 견적 단건 조회
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user