summaryrefslogtreecommitdiff
path: root/lib/forms-plant/services.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/forms-plant/services.ts')
-rw-r--r--lib/forms-plant/services.ts23
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/forms-plant/services.ts b/lib/forms-plant/services.ts
index 7e1976e6..3f50bd47 100644
--- a/lib/forms-plant/services.ts
+++ b/lib/forms-plant/services.ts
@@ -173,8 +173,8 @@ export async function getEditableFieldsByTag(
// 1. 해당 contractItemId의 모든 태그 조회
const tagList = await db
.select({
- tagNo: tags.tagNo,
- tagClass: tags.class
+ tagNo: tagsPlant.tagNo,
+ tagClass: tagsPlant.class
})
.from(tagsPlant)
.where(
@@ -236,6 +236,8 @@ export async function getEditableFieldsByTag(
export async function getFormData(formCode: string, projectCode: string, packageCode:string) {
try {
+ console.log(formCode,projectCode, packageCode)
+
const project = await db.query.projects.findFirst({
where: eq(projects.code, projectCode),
columns: {
@@ -544,7 +546,7 @@ export async function syncMissingTags(
// Build a dynamic OR clause to match (tagType, class) pairs from the mappings.
const orConditions = formMappings.map((m) =>
- and(eq(tags.tagType, m.tagTypeLabel), eq(tags.class, m.classLabel))
+ and(eq(tagsPlant.tagType, m.tagTypeLabel), eq(tagsPlant.class, m.classLabel))
);
// (3) Fetch all matching `tags` for the contractItemId + any of the (tagType, class) pairs.
@@ -1357,17 +1359,18 @@ async function transformDataToSEDPFormat(
let tagClassCode = "";
// Get tagClass code if TAG_NO exists
- if (row.TAG_NO && contractItemId) {
- const cacheKey = `${contractItemId}-${row.TAG_NO}`;
+ if (row.TAG_NO && projectCode) {
+ const cacheKey = `${projectCode}-${row.TAG_NO}`;
if (tagClassCodeCache.has(cacheKey)) {
tagClassCode = tagClassCodeCache.get(cacheKey)!;
} else {
try {
- const tagResult = await db.query.tags.findFirst({
+ const tagResult = await db.query.tagsPlant.findFirst({
where: and(
- eq(tags.contractItemId, contractItemId),
- eq(tags.tagNo, row.TAG_NO)
+ eq(tagsPlant.projectCode, projectCode),
+ eq(tagsPlant.packageCode, packageCode),
+ eq(tagsPlant.tagNo, row.TAG_NO)
)
});
@@ -1997,9 +2000,9 @@ export async function deleteFormDataByTags({
}
// 4. 캐시 무효화
- const cacheKey = `form-data-${formCode}-${contractItemId}`
+ const cacheKey = `form-data-${formCode}-${projectCode}`
revalidateTag(cacheKey)
- revalidateTag(`tags-${contractItemId}`)
+ revalidateTag(`tags-${projectCode}`)
// 페이지 재검증 (필요한 경우)