Merge branch 'develop' of http://114.203.209.83:3000/SamProject/sam-api into develop

This commit is contained in:
김보곤
2026-02-25 14:10:53 +09:00
36 changed files with 3904 additions and 2779 deletions

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 선생산 완료 시 재고 입고를 위해 stock_lots에 work_order_id FK 추가
* - 구매입고: receiving_id 참조
* - 생산입고: work_order_id 참조
*/
public function up(): void
{
Schema::table('stock_lots', function (Blueprint $table) {
$table->unsignedBigInteger('work_order_id')
->nullable()
->after('receiving_id')
->comment('생산입고 시 작업지시 참조');
$table->foreign('work_order_id')
->references('id')
->on('work_orders')
->nullOnDelete();
});
}
public function down(): void
{
Schema::table('stock_lots', function (Blueprint $table) {
$table->dropForeign(['work_order_id']);
$table->dropColumn('work_order_id');
});
}
};

View File

@@ -0,0 +1,151 @@
<?php
namespace Database\Seeders\Kyungdong;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
/**
* BD-* 미등록 절곡 세부품목 일괄 등록
*
* Phase 0.1: BD-XX (7개), BD-YY (4개), BD-HH (2개)
* 추가 누락: BD-RM/RC/RD-42, BD-SM-24, BD-BS-35/43, BD-TS-43, BD-GI-54/84
*
* 실행: php artisan db:seed --class="Database\Seeders\Kyungdong\BendingItemSeeder"
*/
class BendingItemSeeder extends Seeder
{
private int $tenantId = 287; // 경동기업
/**
* 길이코드 → mm 매핑
*/
private const LENGTH_MAP = [
'12' => 1219,
'24' => 2438,
'30' => 3000,
'35' => 3500,
'40' => 4000,
'41' => 4150,
'42' => 4200,
'43' => 4300,
'53' => 3000, // 연기차단재50 전용
'54' => 4000, // 연기차단재50 전용
'83' => 3000, // 연기차단재80 전용
'84' => 4000, // 연기차단재80 전용
];
/**
* 등록 대상 정의
*/
private function getItemDefinitions(): array
{
return [
// Phase 0.1 대상
'XX' => [
'name' => '하부BASE/셔터 상부/마구리',
'lengthCodes' => ['12', '24', '30', '35', '40', '41', '43'],
],
'YY' => [
'name' => '별도SUS마감',
'lengthCodes' => ['30', '35', '40', '43'],
],
'HH' => [
'name' => '보강평철',
'lengthCodes' => ['30', '40'],
],
// 추가 누락분
'RM' => [
'name' => '가이드레일(벽면) 본체',
'lengthCodes' => ['42'],
],
'RC' => [
'name' => '가이드레일(벽면) C형',
'lengthCodes' => ['42'],
],
'RD' => [
'name' => '가이드레일(벽면) D형',
'lengthCodes' => ['42'],
],
'SM' => [
'name' => '가이드레일(측면) 본체',
'lengthCodes' => ['24'],
],
'BS' => [
'name' => '하단마감재 SUS',
'lengthCodes' => ['35', '43'],
],
'TS' => [
'name' => '하단마감재 철재SUS',
'lengthCodes' => ['43'],
],
'GI' => [
'name' => '연기차단재',
'lengthCodes' => ['54', '84'],
'nameOverrides' => [
'54' => '연기차단재 W50 4000mm',
'84' => '연기차단재 W80 4000mm',
],
],
];
}
public function run(): void
{
$definitions = $this->getItemDefinitions();
$created = 0;
$skipped = 0;
foreach ($definitions as $prefix => $def) {
foreach ($def['lengthCodes'] as $lengthCode) {
$code = "BD-{$prefix}-{$lengthCode}";
$lengthMm = self::LENGTH_MAP[$lengthCode];
$name = ($def['nameOverrides'][$lengthCode] ?? null)
?: "{$def['name']} {$lengthMm}mm";
$exists = DB::table('items')
->where('tenant_id', $this->tenantId)
->where('code', $code)
->whereNull('deleted_at')
->exists();
if ($exists) {
$this->command?->line(" ⏭️ skip (exists): {$code}");
$skipped++;
continue;
}
DB::table('items')->insert([
'tenant_id' => $this->tenantId,
'code' => $code,
'name' => $name,
'item_type' => 'PT',
'item_category' => 'BENDING',
'unit' => 'EA',
'bom' => null,
'attributes' => json_encode([]),
'attributes_archive' => json_encode([]),
'options' => json_encode([
'source' => 'bending_item_seeder',
'lot_managed' => true,
'consumption_method' => 'auto',
'production_source' => 'self_produced',
'input_tracking' => true,
'prefix' => $prefix,
'length_code' => $lengthCode,
'length_mm' => $lengthMm,
]),
'is_active' => true,
'created_at' => now(),
'updated_at' => now(),
]);
$this->command?->line(" ✅ created: {$code} ({$name})");
$created++;
}
}
$this->command?->info("BD-* 누락 품목 등록 완료: 생성 {$created}건, 스킵 {$skipped}");
}
}