'products', 'field_key' => 'margin_rate', 'field_name' => '마진율(%)', 'field_type' => 'decimal', 'aggregation_types' => ['avg', 'min', 'max'], 'is_critical' => true, 'display_order' => 1, 'description' => '제품별 마진율 통계 (평균, 최소, 최대)', ], // 가공비 통계 [ 'target_table' => 'products', 'field_key' => 'processing_cost', 'field_name' => '가공비(원)', 'field_type' => 'decimal', 'aggregation_types' => ['avg', 'sum', 'min', 'max'], 'is_critical' => true, 'display_order' => 2, 'description' => '가공비 통계 (평균, 합계, 최소, 최대)', ], // 인건비 통계 [ 'target_table' => 'products', 'field_key' => 'labor_cost', 'field_name' => '인건비(원)', 'field_type' => 'decimal', 'aggregation_types' => ['avg', 'sum', 'min', 'max'], 'is_critical' => true, 'display_order' => 3, 'description' => '인건비 통계 (평균, 합계, 최소, 최대)', ], // 설치비 통계 [ 'target_table' => 'products', 'field_key' => 'install_cost', 'field_name' => '설치비(원)', 'field_type' => 'decimal', 'aggregation_types' => ['avg', 'sum', 'min', 'max'], 'is_critical' => true, 'display_order' => 4, 'description' => '설치비 통계 (평균, 합계, 최소, 최대)', ], // 절곡 길이 통계 (선택적) [ 'target_table' => 'products', 'field_key' => 'bending_length', 'field_name' => '절곡길이(mm)', 'field_type' => 'decimal', 'aggregation_types' => ['avg', 'min', 'max'], 'is_critical' => false, 'display_order' => 10, 'description' => '절곡품 길이 통계 (선택적 집계)', ], // 조립 길이 통계 (선택적) [ 'target_table' => 'products', 'field_key' => 'assembly_length', 'field_name' => '조립길이(mm)', 'field_type' => 'decimal', 'aggregation_types' => ['avg', 'min', 'max'], 'is_critical' => false, 'display_order' => 11, 'description' => '부품 조립 길이 통계 (선택적 집계)', ], // 측면 규격 통계 (선택적) [ 'target_table' => 'products', 'field_key' => 'side_spec_width', 'field_name' => '측면규격_폭(mm)', 'field_type' => 'decimal', 'aggregation_types' => ['avg', 'min', 'max'], 'is_critical' => false, 'display_order' => 12, 'description' => '측면 규격 폭 통계 (선택적 집계)', ], [ 'target_table' => 'products', 'field_key' => 'side_spec_height', 'field_name' => '측면규격_높이(mm)', 'field_type' => 'decimal', 'aggregation_types' => ['avg', 'min', 'max'], 'is_critical' => false, 'display_order' => 13, 'description' => '측면 규격 높이 통계 (선택적 집계)', ], ]; // 2. materials 테이블의 통계 필드 정의 (향후 확장용 예시) $materialStatFields = [ // 예시: 자재 단가 통계 [ 'target_table' => 'materials', 'field_key' => 'unit_price', 'field_name' => '단가(원)', 'field_type' => 'decimal', 'aggregation_types' => ['avg', 'min', 'max'], 'is_critical' => false, 'display_order' => 1, 'description' => '자재 단가 통계 (향후 활용)', ], ]; // 3. products 통계 필드 생성 foreach ($productStatFields as $field) { $this->insertTenantStatField($field); } // 4. materials 통계 필드 생성 (향후 확장) foreach ($materialStatFields as $field) { $this->insertTenantStatField($field); } } /** * tenant_stat_fields 테이블에 필드 삽입 */ private function insertTenantStatField(array $field): void { DB::table('tenant_stat_fields')->insert([ 'tenant_id' => self::TENANT_ID, 'target_table' => $field['target_table'], 'field_key' => $field['field_key'], 'field_name' => $field['field_name'], 'field_type' => $field['field_type'], 'aggregation_types' => json_encode($field['aggregation_types']), 'is_critical' => $field['is_critical'], 'display_order' => $field['display_order'], 'description' => $field['description'], 'created_at' => now(), 'updated_at' => now(), ]); } }