diff options
Diffstat (limited to 'lib/evaluation-target-list/service.ts')
| -rw-r--r-- | lib/evaluation-target-list/service.ts | 80 |
1 files changed, 37 insertions, 43 deletions
diff --git a/lib/evaluation-target-list/service.ts b/lib/evaluation-target-list/service.ts index bb47fca4..0e209aa2 100644 --- a/lib/evaluation-target-list/service.ts +++ b/lib/evaluation-target-list/service.ts @@ -32,6 +32,7 @@ import { getServerSession } from "next-auth/next" import { authOptions } from "@/app/api/auth/[...nextauth]/route" import { sendEmail } from "../mail/sendEmail"; import type { SQL } from "drizzle-orm" +import { DEPARTMENT_CODE_LABELS } from "@/types/evaluation"; export async function selectEvaluationTargetsFromView( tx: PgTransaction<any, any, any>, @@ -685,17 +686,10 @@ export async function getAvailableVendors(search?: string) { // 부서 정보 조회 (상수에서) export async function getDepartmentInfo() { return Object.entries(EVALUATION_DEPARTMENT_CODES).map(([key, value]) => { - const departmentNames = { - ORDER_EVAL: "발주 평가 담당", - PROCUREMENT_EVAL: "조달 평가 담당", - QUALITY_EVAL: "품질 평가 담당", - DESIGN_EVAL: "설계 평가 담당", - CS_EVAL: "CS 평가 담당", - }; return { code: value, - name: departmentNames[key as keyof typeof departmentNames], + name: DEPARTMENT_CODE_LABELS[key as keyof typeof DEPARTMENT_CODE_LABELS], key, }; }); @@ -810,44 +804,44 @@ export async function confirmEvaluationTargets( const totalEsgItems = esgItemsCount[0]?.count || 0 // 5. 각 periodicEvaluation에 대해 담당자별 reviewerEvaluations도 생성 - if (periodicEvaluationsToCreate.length > 0) { - // 새로 생성된 periodicEvaluations 조회 - const newPeriodicEvaluations = await tx - .select({ - id: periodicEvaluations.id, - evaluationTargetId: periodicEvaluations.evaluationTargetId - }) - .from(periodicEvaluations) - .where( - and( - inArray(periodicEvaluations.evaluationTargetId, confirmedTargetIds), - eq(periodicEvaluations.evaluationPeriod, currentPeriod) - ) - ) + // if (periodicEvaluationsToCreate.length > 0) { + // // 새로 생성된 periodicEvaluations 조회 + // const newPeriodicEvaluations = await tx + // .select({ + // id: periodicEvaluations.id, + // evaluationTargetId: periodicEvaluations.evaluationTargetId + // }) + // .from(periodicEvaluations) + // .where( + // and( + // inArray(periodicEvaluations.evaluationTargetId, confirmedTargetIds), + // eq(periodicEvaluations.evaluationPeriod, currentPeriod) + // ) + // ) - // 각 평가에 대해 담당자별 reviewerEvaluations 생성 - for (const periodicEval of newPeriodicEvaluations) { - // 해당 evaluationTarget의 담당자들 조회 - const reviewers = await tx - .select() - .from(evaluationTargetReviewers) - .where(eq(evaluationTargetReviewers.evaluationTargetId, periodicEval.evaluationTargetId)) + // // 각 평가에 대해 담당자별 reviewerEvaluations 생성 + // for (const periodicEval of newPeriodicEvaluations) { + // // 해당 evaluationTarget의 담당자들 조회 + // const reviewers = await tx + // .select() + // .from(evaluationTargetReviewers) + // .where(eq(evaluationTargetReviewers.evaluationTargetId, periodicEval.evaluationTargetId)) - if (reviewers.length > 0) { - const reviewerEvaluationsToCreate = reviewers.map(reviewer => ({ - periodicEvaluationId: periodicEval.id, - evaluationTargetReviewerId: reviewer.id, - isCompleted: false, - createdAt: new Date(), - updatedAt: new Date() - })) + // if (reviewers.length > 0) { + // const reviewerEvaluationsToCreate = reviewers.map(reviewer => ({ + // periodicEvaluationId: periodicEval.id, + // evaluationTargetReviewerId: reviewer.id, + // isCompleted: false, + // createdAt: new Date(), + // updatedAt: new Date() + // })) - await tx - .insert(reviewerEvaluations) - .values(reviewerEvaluationsToCreate) - } - } - } + // await tx + // .insert(reviewerEvaluations) + // .values(reviewerEvaluationsToCreate) + // } + // } + // } // 6. 벤더별 evaluationSubmissions 레코드 생성 const evaluationSubmissionsToCreate = [] |
