summaryrefslogtreecommitdiff
path: root/lib/sedp/sync-package.ts
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-07-23 09:08:03 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-07-23 09:08:03 +0000
commita50bc9baea332f996e6bc3a5d70c69f6d2d0f194 (patch)
tree7493b8a4d9cc7cc3375068f1aa10b0067e85988f /lib/sedp/sync-package.ts
parent7402e759857d511add0d3eb19f1fa13cb957c1df (diff)
(대표님, 최겸) 기본계약 템플릿 및 에디터, 기술영업 벤더정보, 파일 보안다운로드, 벤더 document sync 상태 서비스, 메뉴 Config, 기술영업 미사용 제거
Diffstat (limited to 'lib/sedp/sync-package.ts')
-rw-r--r--lib/sedp/sync-package.ts11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/sedp/sync-package.ts b/lib/sedp/sync-package.ts
index cdbb5987..0261e448 100644
--- a/lib/sedp/sync-package.ts
+++ b/lib/sedp/sync-package.ts
@@ -2,7 +2,7 @@
// src/lib/cron/syncItemsFromCodeLists.ts
import db from "@/db/db";
import { projects, items } from '@/db/schema';
-import { eq } from 'drizzle-orm';
+import { eq, and } from 'drizzle-orm';
import { getSEDPToken } from "./sedp-token";
const SEDP_API_BASE_URL = process.env.SEDP_API_BASE_URL || 'http://sedpwebapi.ship.samsung.co.kr/api';
@@ -154,14 +154,15 @@ export async function syncItemsFromCodeLists(): Promise<void> {
// 기존 아이템 확인 (itemCode로 조회)
const existingItem = await db.select()
.from(items)
- .where(eq(items.itemCode, codeValue.VALUE))
+ .where(and(eq(items.itemCode, codeValue.VALUE),eq(items.ProjectNo, project.code)))
.limit(1);
if (existingItem.length > 0) {
// 기존 아이템 업데이트
await db.update(items)
.set(itemData)
- .where(eq(items.itemCode, codeValue.VALUE));
+ .where(and(eq(items.itemCode, codeValue.VALUE),eq(items.ProjectNo, project.code)))
+
totalItemsUpdated++;
} else {
// 새 아이템 삽입
@@ -253,13 +254,13 @@ export async function syncItemsForProject(projectCode: string): Promise<void> {
// 기존 아이템 확인
const existingItem = await db.select()
.from(items)
- .where(eq(items.itemCode, codeValue.VALUE))
+ .where(and(eq(items.itemCode, codeValue.VALUE),eq(items.ProjectNo, projectCode)))
.limit(1);
if (existingItem.length > 0) {
await db.update(items)
.set(itemData)
- .where(eq(items.itemCode, codeValue.VALUE));
+ .where(and(eq(items.itemCode, codeValue.VALUE),eq(items.ProjectNo, projectCode)));
itemsUpdated++;
} else {
await db.insert(items).values(itemData);