summaryrefslogtreecommitdiff
path: root/lib/sedp
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-08-21 06:57:36 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-08-21 06:57:36 +0000
commit02b1cf005cf3e1df64183d20ba42930eb2767a9f (patch)
treee932c54d5260b0e6fda2b46be2a6ba1c3ee30434 /lib/sedp
parentd78378ecd7ceede1429359f8058c7a99ac34b1b7 (diff)
(대표님, 최겸) 설계메뉴추가, 작업사항 업데이트
설계메뉴 - 문서관리 설계메뉴 - 벤더 데이터 gtc 메뉴 업데이트 정보시스템 - 메뉴리스트 및 정보 업데이트 파일 라우트 업데이트 엑셀임포트 개선 기본계약 개선 벤더 가입과정 변경 및 개선 벤더 기본정보 - pq 돌체 오류 수정 및 개선 벤더 로그인 과정 이메일 오류 수정
Diffstat (limited to 'lib/sedp')
-rw-r--r--lib/sedp/get-form-tags.ts8
-rw-r--r--lib/sedp/sync-form.ts4
-rw-r--r--lib/sedp/sync-object-class.ts69
3 files changed, 61 insertions, 20 deletions
diff --git a/lib/sedp/get-form-tags.ts b/lib/sedp/get-form-tags.ts
index 34f990f3..ef3a390d 100644
--- a/lib/sedp/get-form-tags.ts
+++ b/lib/sedp/get-form-tags.ts
@@ -41,7 +41,7 @@ interface Column {
key: string;
label: string;
type: string;
- shi?: boolean;
+ shi?: string | null;
}
/**
@@ -491,7 +491,7 @@ export async function importTagsFromSEDP(
if (Array.isArray(tagEntry.ATTRIBUTES)) {
for (const attr of tagEntry.ATTRIBUTES) {
const columnInfo = columnsJSON.find(col => col.key === attr.ATT_ID);
- if (columnInfo && columnInfo.shi === true) {
+ if (columnInfo && (columnInfo.shi === "BOTH" ||columnInfo.shi === "OUT" ||columnInfo.shi === null )) {
if (columnInfo.type === "NUMBER") {
if (attr.VALUE !== undefined && attr.VALUE !== null) {
if (typeof attr.VALUE === 'string') {
@@ -551,7 +551,7 @@ export async function importTagsFromSEDP(
}
const columnInfo = columnsJSON.find(col => col.key === key);
- if (columnInfo && columnInfo.shi === true) {
+ if (columnInfo && (columnInfo.shi === "BOTH" ||columnInfo.shi === "OUT" ||columnInfo.shi === null )) {
if (existingTag.data[key] !== tagObject[key]) {
updates[key] = tagObject[key];
hasUpdates = true;
@@ -663,7 +663,7 @@ export async function importTagsFromSEDP(
// 각 태그를 확인하여 신규/업데이트 분류
for (const tagRecord of upsertTagRecords) {
- const existingTagRecord = existingTagsMap.get(tagRecord.tagNo);
+ const existingTagRecord = existingTagsMap.get(tagRecord.tagIdx);
if (existingTagRecord) {
// 기존 태그가 있으면 업데이트 준비
diff --git a/lib/sedp/sync-form.ts b/lib/sedp/sync-form.ts
index 1f903c78..e3c3f6bb 100644
--- a/lib/sedp/sync-form.ts
+++ b/lib/sedp/sync-form.ts
@@ -248,7 +248,7 @@ interface FormColumn {
options?: string[];
uom?: string;
uomId?: string;
- shi?: Boolean;
+ shi?:string | null;
hidden?: boolean;
seq?: number;
head?: string;
@@ -983,7 +983,7 @@ export async function saveFormMappingsAndMetas(
if (!attribute) continue;
const tmplMeta = templateAttrMap.get(attId);
- const isShi = mapAtt.INOUT === null || mapAtt.INOUT === "OUT";
+ const isShi = mapAtt.INOUT;
let uomSymbol: string | undefined; let uomId: string | undefined;
if (legacy?.LNK_ATT) {
diff --git a/lib/sedp/sync-object-class.ts b/lib/sedp/sync-object-class.ts
index 1a325407..d48a8e7c 100644
--- a/lib/sedp/sync-object-class.ts
+++ b/lib/sedp/sync-object-class.ts
@@ -115,6 +115,43 @@ export async function getCodeListsByID(projectCode: string): Promise<SubClassCod
}
}
+function collectInheritedAttributes(
+ classId: string,
+ allClasses: ObjectClass[]
+): LinkAttribute[] {
+ const classMap = new Map(allClasses.map(cls => [cls.CLS_ID, cls]));
+ const collectedAttributes: LinkAttribute[] = [];
+ const seenAttributeIds = new Set<string>();
+
+ // 현재 클래스부터 시작해서 부모를 따라 올라가며 속성 수집
+ function collectFromClass(currentClassId: string | null): void {
+ if (!currentClassId) return;
+
+ const currentClass = classMap.get(currentClassId);
+ if (!currentClass) return;
+
+ // 먼저 부모 클래스의 속성을 수집 (상위부터 하위 순서로)
+ if (currentClass.PRT_CLS_ID) {
+ collectFromClass(currentClass.PRT_CLS_ID);
+ }
+
+ // 현재 클래스의 LNK_ATT 추가 (중복 제거)
+ if (currentClass.LNK_ATT && Array.isArray(currentClass.LNK_ATT)) {
+ for (const attr of currentClass.LNK_ATT) {
+ if (!seenAttributeIds.has(attr.ATT_ID)) {
+ seenAttributeIds.add(attr.ATT_ID);
+ collectedAttributes.push(attr);
+ }
+ }
+ }
+ }
+
+ collectFromClass(classId);
+
+ // SEQ 순서로 정렬
+ return collectedAttributes.sort((a, b) => (a.SEQ || 0) - (b.SEQ || 0));
+}
+
// 태그 클래스 속성 저장 함수
async function saveTagClassAttributes(
tagClassId: number,
@@ -579,15 +616,18 @@ async function saveObjectClassesToDatabase(
totalChanged += toInsert.length;
console.log(`프로젝트 ID ${projectId}에 ${toInsert.length}개의 새 오브젝트 클래스 추가 완료`);
- // 새로 삽입된 각 클래스의 LNK_ATT 속성 처리
+ // 새로 삽입된 각 클래스의 상속된 LNK_ATT 속성 처리
for (const insertedClass of insertedClasses) {
- const originalClass = classesToSave.find(cls => cls.CLS_ID === insertedClass.code);
- if (originalClass && originalClass.LNK_ATT && originalClass.LNK_ATT.length > 0) {
- try {
- await saveTagClassAttributes(insertedClass.id, originalClass.LNK_ATT);
- } catch (error) {
- console.error(`태그 클래스 ${insertedClass.code}의 속성 저장 실패:`, error);
+ try {
+ // 🔥 수정된 부분: 상속된 속성 수집
+ const inheritedAttributes = collectInheritedAttributes(insertedClass.code, classes);
+
+ if (inheritedAttributes.length > 0) {
+ await saveTagClassAttributes(insertedClass.id, inheritedAttributes);
+ console.log(`태그 클래스 ${insertedClass.code}에 ${inheritedAttributes.length}개의 상속된 속성 저장 완료`);
}
+ } catch (error) {
+ console.error(`태그 클래스 ${insertedClass.code}의 속성 저장 실패:`, error);
}
}
}
@@ -621,13 +661,14 @@ async function saveObjectClassesToDatabase(
.limit(1);
if (updatedClass.length > 0) {
- const originalClass = classesToSave.find(cls => cls.CLS_ID === item.code);
- if (originalClass && originalClass.LNK_ATT) {
- try {
- await saveTagClassAttributes(updatedClass[0].id, originalClass.LNK_ATT);
- } catch (error) {
- console.error(`태그 클래스 ${item.code}의 속성 업데이트 실패:`, error);
- }
+ try {
+ // 🔥 수정된 부분: 상속된 속성 수집
+ const inheritedAttributes = collectInheritedAttributes(item.code, classes);
+
+ await saveTagClassAttributes(updatedClass[0].id, inheritedAttributes);
+ console.log(`태그 클래스 ${item.code}에 ${inheritedAttributes.length}개의 상속된 속성 업데이트 완료`);
+ } catch (error) {
+ console.error(`태그 클래스 ${item.code}의 속성 업데이트 실패:`, error);
}
}