fix: 렉 구조 등록 카테고리 데이터 저장 방식 통일 및 중복 체크 수정

RackStructureComponent: context에 카테고리 코드 필드(floorCode, zoneCode 등) 추가
기존 데이터 조회 시 warehouse_id -> warehouse_code 컬럼명 수정
미리보기 생성 시 카테고리 코드로 저장하도록 변경
미리보기 테이블에서 카테고리 코드를 라벨로 변환하여 표시
buttonActions: 중복 체크 API 호출 시 filters -> search 파라미터로 변경
types: RackStructureContext 인터페이스에 카테고리 코드 필드 추가
This commit is contained in:
SeongHyun Kim 2026-01-12 17:25:52 +09:00
parent 8aa6008351
commit 821955cfac
3 changed files with 38 additions and 20 deletions

View File

@ -298,11 +298,16 @@ export const RackStructureComponent: React.FC<RackStructureComponentProps> = ({
warehouseName: fieldMapping.warehouseNameField
? formData[fieldMapping.warehouseNameField]
: undefined,
// 카테고리 값은 라벨로 변환
// 카테고리 값은 라벨로 변환 (화면 표시용)
floor: getCategoryLabel(rawFloor?.toString()),
zone: getCategoryLabel(rawZone),
locationType: getCategoryLabel(rawLocationType),
status: getCategoryLabel(rawStatus),
// 카테고리 코드 원본값 (DB 쿼리/저장용)
floorCode: rawFloor?.toString(),
zoneCode: rawZone?.toString(),
locationTypeCode: rawLocationType?.toString(),
statusCode: rawStatus?.toString(),
};
console.log("🏗️ [RackStructure] context 생성:", {
@ -399,8 +404,12 @@ export const RackStructureComponent: React.FC<RackStructureComponentProps> = ({
// 기존 데이터 조회를 위한 값 추출 (useMemo 객체 참조 문제 방지)
const warehouseCodeForQuery = context.warehouseCode;
const floorForQuery = context.floor; // 라벨 값 (예: "1층")
const zoneForQuery = context.zone; // 라벨 값 (예: "A구역")
// DB 쿼리 시에는 카테고리 코드 사용 (코드로 통일)
const floorForQuery = (context as any).floorCode || context.floor;
const zoneForQuery = (context as any).zoneCode || context.zone;
// 화면 표시용 라벨
const floorLabel = context.floor;
const zoneLabel = context.zone;
// 기존 데이터 조회 (창고/층/구역이 변경될 때마다)
useEffect(() => {
@ -426,7 +435,7 @@ export const RackStructureComponent: React.FC<RackStructureComponentProps> = ({
// DB에는 라벨 값으로 저장되어 있으므로 라벨 값으로 필터링
// equals 연산자를 사용하여 정확한 일치 검색 (ILIKE가 아닌 = 연산자 사용)
const searchParams = {
warehouse_id: { value: warehouseCodeForQuery, operator: "equals" },
warehouse_code: { value: warehouseCodeForQuery, operator: "equals" },
floor: { value: floorForQuery, operator: "equals" },
zone: { value: zoneForQuery, operator: "equals" },
};
@ -597,18 +606,20 @@ export const RackStructureComponent: React.FC<RackStructureComponentProps> = ({
for (let level = 1; level <= cond.levels; level++) {
const { code, name } = generateLocationCode(row, level);
// 테이블 컬럼명과 동일하게 생성
// DB 저장 시에는 카테고리 코드 사용 (코드로 통일)
const ctxAny = context as any;
locations.push({
row_num: String(row),
level_num: String(level),
location_code: code,
location_name: name,
location_type: context?.locationType || "선반",
status: context?.status || "사용",
// 추가 필드 (테이블 컬럼명과 동일)
location_type: ctxAny?.locationTypeCode || context?.locationType || "선반",
status: ctxAny?.statusCode || context?.status || "사용",
// 추가 필드 (테이블 컬럼명과 동일) - 카테고리 코드 사용
warehouse_code: context?.warehouseCode,
warehouse_name: context?.warehouseName,
floor: context?.floor,
zone: context?.zone,
floor: ctxAny?.floorCode || context?.floor,
zone: ctxAny?.zoneCode || context?.zone,
});
}
}
@ -930,13 +941,14 @@ export const RackStructureComponent: React.FC<RackStructureComponentProps> = ({
<TableCell className="text-center">{idx + 1}</TableCell>
<TableCell className="font-mono">{loc.location_code}</TableCell>
<TableCell>{loc.location_name}</TableCell>
<TableCell className="text-center">{loc.floor || context?.floor || "1"}</TableCell>
<TableCell className="text-center">{loc.zone || context?.zone || "A"}</TableCell>
{/* 미리보기에서는 카테고리 코드를 라벨로 변환하여 표시 */}
<TableCell className="text-center">{getCategoryLabel(loc.floor) || context?.floor || "1"}</TableCell>
<TableCell className="text-center">{getCategoryLabel(loc.zone) || context?.zone || "A"}</TableCell>
<TableCell className="text-center">
{loc.row_num.padStart(2, "0")}
</TableCell>
<TableCell className="text-center">{loc.level_num}</TableCell>
<TableCell className="text-center">{loc.location_type}</TableCell>
<TableCell className="text-center">{getCategoryLabel(loc.location_type) || loc.location_type}</TableCell>
<TableCell className="text-center">-</TableCell>
</TableRow>
))}

View File

@ -72,10 +72,15 @@ export interface RackStructureContext {
warehouseId?: string; // 창고 ID
warehouseCode?: string; // 창고 코드 (예: WH001)
warehouseName?: string; // 창고명 (예: 제1창고)
floor?: string; // 층 (예: 1)
zone?: string; // 구역 (예: A)
locationType?: string; // 위치 유형 (예: 선반)
status?: string; // 사용 여부 (예: 사용)
floor?: string; // 층 라벨 (예: 1층) - 화면 표시용
zone?: string; // 구역 라벨 (예: A구역) - 화면 표시용
locationType?: string; // 위치 유형 라벨 (예: 선반)
status?: string; // 사용 여부 라벨 (예: 사용)
// 카테고리 코드 (DB 저장/쿼리용)
floorCode?: string; // 층 카테고리 코드 (예: CATEGORY_767659DCUF)
zoneCode?: string; // 구역 카테고리 코드 (예: CATEGORY_82925656Q8)
locationTypeCode?: string; // 위치 유형 카테고리 코드
statusCode?: string; // 사용 여부 카테고리 코드
}
// 컴포넌트 Props

View File

@ -1467,11 +1467,12 @@ export class ButtonActionExecutor {
console.log("🔍 [handleRackStructureBatchSave] 기존 데이터 중복 체크:", { warehouseCode, floor, zone });
try {
// search 파라미터를 사용하여 백엔드에서 필터링 (filters는 백엔드에서 처리 안됨)
const existingResponse = await DynamicFormApi.getTableData(tableName, {
filters: {
warehouse_code: warehouseCode,
floor: floor,
zone: zone,
search: {
warehouse_code: { value: warehouseCode, operator: "equals" },
floor: { value: floor, operator: "equals" },
zone: { value: zone, operator: "equals" },
},
page: 1,
pageSize: 1000,