From 3d71a22002a2f538bd9695280a7b665c89985e8a Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 21 Apr 2025 15:48:29 +0700 Subject: [PATCH] update commander --- src/controllers/EvaluationController.ts | 60 +++++++++++++++++++++---- src/controllers/ReportController.ts | 2 +- src/entities/Evaluation.ts | 22 +++++++-- 3 files changed, 71 insertions(+), 13 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 27bcd20..c5ae332 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -85,19 +85,19 @@ export class EvaluationController { }) .select([ "evaluation.id", - "evaluation.dateAnnounce", "evaluation.type", "evaluation.subject", "evaluation.evaluationResult", + "evaluation.lastUpdatedAt", ]) - .orderBy("evaluation.dateAnnounce", "ASC") + .orderBy("evaluation.lastUpdatedAt", "ASC") .getMany(); const performance = list.map((item) => ({ id: item.id, - year: item.dateAnnounce?Extension.ToThaiYear(item.dateAnnounce.getFullYear()):null, + year: item.lastUpdatedAt?Extension.ToThaiYear(item.lastUpdatedAt.getFullYear()):null, type: item.type == "EXPERT" ? "ชำนาญการ" : item.type == "EXPERTISE" ? "เชียวชาญ" : item.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ": null, - subject: item.subject, + subject: item.subject?item.subject[0]:null, evaluationResult: item.evaluationResult == "PASS" ? "ผ่าน" : item.evaluationResult == "NOTPASS" ? "ไม่ผ่าน" : null, })); @@ -2091,6 +2091,14 @@ export class EvaluationController { evaluation.commanderPositionDoc2 = evaluation.commanderPosition; evaluation.commanderAboveFullnameDoc2 = evaluation.commanderAboveFullname; evaluation.commanderAbovePositionDoc2 = evaluation.commanderAbovePosition; + + evaluation.commanderOrgDoc2 = evaluation.commanderOrg; + evaluation.commanderOrgOldDoc2 = evaluation.commanderOrgOld; + evaluation.commanderPositionOldDoc2 = evaluation.commanderPositionOld; + evaluation.commanderAboveOrgDoc2 = evaluation.commanderAboveOrg; + evaluation.commanderAboveOrgOldDoc2 = evaluation.commanderAboveOrgOld; + evaluation.commanderAbovePositionOldDoc2 = evaluation.commanderAbovePositionOld; + evaluation.datePrepareDoc2 = new Date(); evaluation.lastUpdateUserId = request.user.sub; evaluation.lastUpdateFullName = request.user.name; @@ -2653,9 +2661,15 @@ export class EvaluationController { "author", "subject", "commanderFullname", + "commanderOrg", + "commanderOrgOld", "commanderPosition", + "commanderPositionOld", "commanderAboveFullname", + "commanderAboveOrg", + "commanderAboveOrgOld", "commanderAbovePosition", + "commanderAbovePositionOld", ], }); @@ -2689,9 +2703,15 @@ export class EvaluationController { "author", "subject", "commanderFullname", + "commanderOrg", + "commanderOrgOld", "commanderPosition", + "commanderPositionOld", "commanderAboveFullname", + "commanderAboveOrg", + "commanderAboveOrgOld", "commanderAbovePosition", + "commanderAbovePositionOld", ], }); if (!evaluation) { @@ -2722,9 +2742,15 @@ export class EvaluationController { "subjectDoc2", "assignedPosition", "commanderFullnameDoc2", + "commanderOrgDoc2", + "commanderOrgOldDoc2", "commanderPositionDoc2", + "commanderPositionOldDoc2", "commanderAboveFullnameDoc2", + "commanderAboveOrgDoc2", + "commanderAboveOrgOldDoc2", "commanderAbovePositionDoc2", + "commanderAbovePositionOldDoc2", "evaluationResult", ], }); @@ -2759,9 +2785,15 @@ export class EvaluationController { "subjectDoc2", "assignedPosition", "commanderFullnameDoc2", + "commanderOrgDoc2", + "commanderOrgOldDoc2", "commanderPositionDoc2", + "commanderPositionOldDoc2", "commanderAboveFullnameDoc2", + "commanderAboveOrgDoc2", + "commanderAboveOrgOldDoc2", "commanderAbovePositionDoc2", + "commanderAbovePositionOldDoc2", "evaluationResult", ], }); @@ -2799,11 +2831,17 @@ export class EvaluationController { @Body() body: { author: string; - subject: string; + subject: string[]; commanderFullname: string; + commanderOrg: string; + commanderOrgOld?: string; commanderPosition: string; + commanderPositionOld?: string; commanderAboveFullname: string; + commanderAboveOrg: string; + commanderAboveOrgOld?: string; commanderAbovePosition: string; + commanderAbovePositionOld?: string; }, @Request() request: RequestWithUser, ) { @@ -2813,13 +2851,19 @@ export class EvaluationController { if (!evaluation) { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); } - + const _null:any = null; evaluation.author = body.author; evaluation.subject = body.subject; evaluation.commanderFullname = body.commanderFullname; + evaluation.commanderOrg = body.commanderOrg; + evaluation.commanderOrgOld = body.commanderOrgOld??_null; evaluation.commanderPosition = body.commanderPosition; + evaluation.commanderPositionOld = body.commanderPositionOld??_null; evaluation.commanderAboveFullname = body.commanderAboveFullname; + evaluation.commanderAboveOrg = body.commanderAboveOrg; + evaluation.commanderAboveOrgOld = body.commanderAboveOrgOld??_null; evaluation.commanderAbovePosition = body.commanderAbovePosition; + evaluation.commanderAbovePositionOld = body.commanderAbovePositionOld??_null; evaluation.lastUpdateUserId = request.user.sub; evaluation.lastUpdateFullName = request.user.name; evaluation.lastUpdatedAt = new Date(); @@ -2859,7 +2903,7 @@ export class EvaluationController { @Body() body: { authorDoc2: string; - subjectDoc2: string; + subjectDoc2: string[]; assignedPosition: string; commanderFullnameDoc2: string; commanderPositionDoc2: string; @@ -2874,7 +2918,7 @@ export class EvaluationController { if (!evaluation) { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); } - + evaluation.authorDoc2 = body.authorDoc2; evaluation.subjectDoc2 = body.subjectDoc2; evaluation.assignedPosition = body.assignedPosition; diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index c687c2a..eac19d0 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -359,7 +359,7 @@ export class ReoportController { dateRetireLaw: dateRetireLaw ? Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date(dateRetireLaw))) : "-", - subject: evaluation.subject != null ? evaluation.subject : "-", + subject: evaluation.subject != null ? evaluation.subject[0] : "-", subjectOld: subjectOld, educations: evaluation.education.length > 0 diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index feedea1..657c46f 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -216,6 +216,20 @@ export class Evaluation extends EntityBase { @Column({ nullable: true, comment: "ตำแหน่งเดิม ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ" }) commanderAbovePositionOld: string; + @Column({ nullable: true, comment: "สังกัดปัจุบัน ผู้บังคับบัญชาชั้นต้น doc2" }) + commanderOrgDoc2: string; + @Column({ nullable: true, comment: "สังกัดเดิม ผู้บังคับบัญชาชั้นต้น doc2" }) + commanderOrgOldDoc2: string; + @Column({ nullable: true, comment: "ตำแหน่งเดิม ผู้บังคับบัญชาชั้นต้น doc2" }) + commanderPositionOldDoc2: string; + + @Column({ nullable: true, comment: "สังกัดปัจุบัน ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ doc2" }) + commanderAboveOrgDoc2: string; + @Column({ nullable: true, comment: "สังกัดเดิม ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ doc2" }) + commanderAboveOrgOldDoc2: string; + @Column({ nullable: true, comment: "ตำแหน่งเดิม ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ doc2" }) + commanderAbovePositionOldDoc2: string; + @Column({ nullable: true, comment: "ชื่อ-นามสกุล ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ (จัดเตรียมเอกสารเล่ม 2)", @@ -237,14 +251,14 @@ export class Evaluation extends EntityBase { @Column({ nullable: true, comment: "ชื่อเจ้าของผลงาน" }) author: string; - @Column({ nullable: true, comment: "ชื่อผลงาน" }) - subject: string; + @Column({ type: 'json', nullable: true, comment: 'ชื่อผลงาน' }) + subject: string[]; @Column({ nullable: true, comment: "ชื่อเจ้าของผลงาน2" }) authorDoc2: string; - @Column({ nullable: true, comment: "ชื่อผลงาน2" }) - subjectDoc2: string; + @Column({ type: 'json', nullable: true, comment: "ชื่อผลงาน2" }) + subjectDoc2: string[]; @Column({ nullable: true, comment: "ตำแหน่งที่ได้รับมอบหมาย" }) assignedPosition: string;