화면 복사문제 수정

This commit is contained in:
kjs 2025-12-15 14:51:41 +09:00
parent 665d1b51d8
commit 3c73c20292
11 changed files with 77 additions and 12 deletions

View File

@ -51,3 +51,4 @@ router.get("/data/:groupCode", getAutoFillData);
export default router;

View File

@ -47,3 +47,4 @@ router.get("/filtered-options/:relationCode", getFilteredOptions);
export default router;

View File

@ -63,3 +63,4 @@ router.get("/:groupCode/options/:levelOrder", getLevelOptions);
export default router;

View File

@ -51,3 +51,4 @@ router.get("/options/:exclusionCode", getExcludedOptions);
export default router;

View File

@ -332,6 +332,8 @@ export class MenuCopyService {
/**
*
* - flowId
* - dataflowConfig.flowConfig.flowId selectedDiagramId
*/
private async collectFlows(
screenIds: Set<number>,
@ -340,6 +342,7 @@ export class MenuCopyService {
logger.info(`🔄 플로우 수집 시작: ${screenIds.size}개 화면`);
const flowIds = new Set<number>();
const flowDetails: Array<{ flowId: number; flowName: string; screenId: number }> = [];
for (const screenId of screenIds) {
const layoutsResult = await client.query<ScreenLayout>(
@ -352,13 +355,35 @@ export class MenuCopyService {
// webTypeConfig.dataflowConfig.flowConfig.flowId
const flowId = props?.webTypeConfig?.dataflowConfig?.flowConfig?.flowId;
if (flowId) {
const flowName = props?.webTypeConfig?.dataflowConfig?.flowConfig?.flowName || "Unknown";
if (flowId && typeof flowId === "number" && flowId > 0) {
if (!flowIds.has(flowId)) {
flowIds.add(flowId);
flowDetails.push({ flowId, flowName, screenId });
logger.info(` 📎 화면 ${screenId}에서 플로우 발견: id=${flowId}, name="${flowName}"`);
}
}
// selectedDiagramId도 확인 (flowId와 동일할 수 있지만 다를 수도 있음)
const selectedDiagramId = props?.webTypeConfig?.dataflowConfig?.selectedDiagramId;
if (selectedDiagramId && typeof selectedDiagramId === "number" && selectedDiagramId > 0) {
if (!flowIds.has(selectedDiagramId)) {
flowIds.add(selectedDiagramId);
flowDetails.push({ flowId: selectedDiagramId, flowName: "SelectedDiagram", screenId });
logger.info(` 📎 화면 ${screenId}에서 selectedDiagramId 발견: id=${selectedDiagramId}`);
}
}
}
}
if (flowIds.size > 0) {
logger.info(`✅ 플로우 수집 완료: ${flowIds.size}`);
logger.info(` 📋 수집된 flowIds: [${Array.from(flowIds).join(", ")}]`);
} else {
logger.info(`📭 수집된 플로우 없음 (화면에 플로우 참조가 없음)`);
}
return flowIds;
}
@ -473,16 +498,22 @@ export class MenuCopyService {
}
}
// flowId 매핑 (숫자 또는 숫자 문자열)
if (key === "flowId") {
// flowId, selectedDiagramId 매핑 (숫자 또는 숫자 문자열)
// selectedDiagramId는 dataflowConfig에서 flowId와 동일한 값을 참조하므로 함께 변환
if (key === "flowId" || key === "selectedDiagramId") {
const numValue = typeof value === "number" ? value : parseInt(value);
if (!isNaN(numValue)) {
if (!isNaN(numValue) && numValue > 0) {
const newId = flowIdMap.get(numValue);
if (newId) {
obj[key] = typeof value === "number" ? newId : String(newId); // 원래 타입 유지
logger.debug(
logger.info(
` 🔗 플로우 참조 업데이트 (${currentPath}): ${value}${newId}`
);
} else {
// 매핑이 없으면 경고 로그
logger.warn(
` ⚠️ 플로우 매핑 없음 (${currentPath}): ${value} - 원본 플로우가 복사되지 않았을 수 있음`
);
}
}
}
@ -742,6 +773,8 @@ export class MenuCopyService {
/**
*
* - + (ID )
* -
*/
private async copyFlows(
flowIds: Set<number>,
@ -757,10 +790,11 @@ export class MenuCopyService {
}
logger.info(`🔄 플로우 복사 중: ${flowIds.size}`);
logger.info(` 📋 복사 대상 flowIds: [${Array.from(flowIds).join(", ")}]`);
for (const originalFlowId of flowIds) {
try {
// 1) flow_definition 조회
// 1) 원본 flow_definition 조회
const flowDefResult = await client.query<FlowDefinition>(
`SELECT * FROM flow_definition WHERE id = $1`,
[originalFlowId]
@ -772,8 +806,29 @@ export class MenuCopyService {
}
const flowDef = flowDefResult.rows[0];
logger.info(` 🔍 원본 플로우 발견: id=${originalFlowId}, name="${flowDef.name}", table="${flowDef.table_name}", company="${flowDef.company_code}"`);
// 2) flow_definition 복사
// 2) 대상 회사에 이미 같은 이름+테이블의 플로우가 있는지 확인
const existingFlowResult = await client.query<{ id: number }>(
`SELECT id FROM flow_definition
WHERE company_code = $1 AND name = $2 AND table_name = $3
LIMIT 1`,
[targetCompanyCode, flowDef.name, flowDef.table_name]
);
let newFlowId: number;
if (existingFlowResult.rows.length > 0) {
// 기존 플로우가 있으면 재사용
newFlowId = existingFlowResult.rows[0].id;
flowIdMap.set(originalFlowId, newFlowId);
logger.info(
` ♻️ 기존 플로우 재사용: ${originalFlowId}${newFlowId} (${flowDef.name})`
);
continue; // 스텝/연결 복사 생략 (기존 것 사용)
}
// 3) 새 flow_definition 복사
const newFlowResult = await client.query<{ id: number }>(
`INSERT INTO flow_definition (
name, description, table_name, is_active,
@ -792,11 +847,11 @@ export class MenuCopyService {
]
);
const newFlowId = newFlowResult.rows[0].id;
newFlowId = newFlowResult.rows[0].id;
flowIdMap.set(originalFlowId, newFlowId);
logger.info(
` ✅ 플로우 복사: ${originalFlowId}${newFlowId} (${flowDef.name})`
` ✅ 플로우 신규 복사: ${originalFlowId}${newFlowId} (${flowDef.name})`
);
// 3) flow_step 복사

View File

@ -583,3 +583,4 @@ const result = await executeNodeFlow(flowId, {

View File

@ -356,3 +356,4 @@
- [ ] 발송 버튼의 데이터 소스가 올바르게 설정되어 있는가?

View File

@ -193,3 +193,4 @@ export function applyAutoFillToFormData(
}

View File

@ -1685,3 +1685,4 @@ const 출고등록_설정: ScreenSplitPanel = {

View File

@ -532,3 +532,4 @@ const { data: config } = await getScreenSplitPanel(screenId);

View File

@ -519,3 +519,4 @@ function ScreenViewPage() {