From 309f295391c8fa8aae1147611976bc3b884eb0ba Mon Sep 17 00:00:00 2001 From: Moss <> Date: Thu, 12 Jun 2025 19:30:57 +0700 Subject: [PATCH 01/16] filter by dna --- src/controllers/EvaluationController.ts | 253 ++++++++++++++---------- 1 file changed, 145 insertions(+), 108 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 5457944..fe9e173 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -79,29 +79,41 @@ export class EvaluationController { @Get("performance/user") async listPerformance(@Request() request: RequestWithUser) { const list = await AppDataSource.getRepository(Evaluation) - .createQueryBuilder("evaluation") - .where("evaluation.userId = :userId", { userId: request.user.sub }) - .andWhere("evaluation.step = :step", { step: "DONE" }) - .andWhere("evaluation.evaluationResult IN (:...evaluationResult)", { - evaluationResult: ["PASS", "NOTPASS"], - }) - .select([ - "evaluation.id", - "evaluation.type", - "evaluation.subject", - "evaluation.evaluationResult", - "evaluation.lastUpdatedAt", - ]) - .orderBy("evaluation.lastUpdatedAt", "ASC") - .getMany(); + .createQueryBuilder("evaluation") + .where("evaluation.userId = :userId", { userId: request.user.sub }) + .andWhere("evaluation.step = :step", { step: "DONE" }) + .andWhere("evaluation.evaluationResult IN (:...evaluationResult)", { + evaluationResult: ["PASS", "NOTPASS"], + }) + .select([ + "evaluation.id", + "evaluation.type", + "evaluation.subject", + "evaluation.evaluationResult", + "evaluation.lastUpdatedAt", + ]) + .orderBy("evaluation.lastUpdatedAt", "ASC") + .getMany(); - const performance = list.map((item) => ({ - id: item.id, - year: item.lastUpdatedAt?Extension.ToThaiYear(item.lastUpdatedAt.getFullYear()):null, - type: item.type == "EXPERT" ? "ชำนาญการ" : item.type == "EXPERTISE" ? "เชียวชาญ" : item.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ": null, - subject: item.subject?item.subject[0]:null, - evaluationResult: item.evaluationResult == "PASS" ? "ผ่าน" : item.evaluationResult == "NOTPASS" ? "ไม่ผ่าน" : null, - })); + const performance = list.map((item) => ({ + id: item.id, + year: item.lastUpdatedAt ? Extension.ToThaiYear(item.lastUpdatedAt.getFullYear()) : null, + type: + item.type == "EXPERT" + ? "ชำนาญการ" + : item.type == "EXPERTISE" + ? "เชียวชาญ" + : item.type == "SPECIAL_EXPERT" + ? "ชำนาญการพิเศษ" + : null, + subject: item.subject ? item.subject[0] : null, + evaluationResult: + item.evaluationResult == "PASS" + ? "ผ่าน" + : item.evaluationResult == "NOTPASS" + ? "ไม่ผ่าน" + : null, + })); return new HttpSuccess(performance); } @@ -134,6 +146,12 @@ export class EvaluationController { try { // await new permission().PermissionList(request, "SYS_EVA_REQ"); let _data = await new permission().PermissionOrgList(request, "SYS_EVA_REQ"); + await new CallAPI() + .PostData(request, "/org/finddna", _data) + .then((x) => { + _data = x; + }) + .catch((x) => {}); const [evaluation, total] = await AppDataSource.getRepository(Evaluation) .createQueryBuilder("evaluation") .andWhere( @@ -349,18 +367,21 @@ export class EvaluationController { } else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error); } } - - /** + + /** * API get template ประกาศคัดเลือก * * @summary get template ประกาศคัดเลือก (ADMIN) * * @param {string} id id ข้อมูลการประเมิน */ - @Get("get-announce-template/{id}") - async getAnnounceTemp(@Path() id: string, @Request() request: RequestWithUser) { + @Get("get-announce-template/{id}") + async getAnnounceTemp(@Path() id: string, @Request() request: RequestWithUser) { try { - const evaluation = await this.evaluationRepository.findOne({ where: { id } , select: ["id","detailAnnounceStep5Body","detailAnnounceStep5Footer"]}); + const evaluation = await this.evaluationRepository.findOne({ + where: { id }, + select: ["id", "detailAnnounceStep5Body", "detailAnnounceStep5Footer"], + }); if (!evaluation) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน"); } @@ -370,7 +391,7 @@ export class EvaluationController { throw error; } else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error); } - } + } /** * ดึงข้อมูลรายละเอียด step การขอประเมิน @@ -510,24 +531,31 @@ export class EvaluationController { if (!evaluation) { return `not found data`; } - let _code = requestBody.type == "EXPERT" ? "ST05-1" : requestBody.type == "EXPERTISE" ? "ST05-1" : requestBody.type == "SPECIAL_EXPERT" ? "ST05-2" : "ST05-1"; + let _code = + requestBody.type == "EXPERT" + ? "ST05-1" + : requestBody.type == "EXPERTISE" + ? "ST05-1" + : requestBody.type == "SPECIAL_EXPERT" + ? "ST05-2" + : "ST05-1"; const announceTemplate5 = await this.announceTemplateRepository.findOne({ - where:{ - code : _code + where: { + code: _code, }, - select: ["detailBody","detailFooter"] - }) + select: ["detailBody", "detailFooter"], + }); const before = null; await new CallAPI() - .GetData(request, `/org/profile/keycloak/commander/${request.user.sub}`) - .then(async (x) => { - evaluation.rootDnaId = x.rootDnaId; - evaluation.child1DnaId = x.child1DnaId; - evaluation.child2DnaId = x.child2DnaId; - evaluation.child3DnaId = x.child3DnaId; - evaluation.child4DnaId = x.child4DnaId; - }) - .catch(); + .GetData(request, `/org/profile/keycloak/commander/${request.user.sub}`) + .then(async (x) => { + evaluation.rootDnaId = x.rootDnaId; + evaluation.child1DnaId = x.child1DnaId; + evaluation.child2DnaId = x.child2DnaId; + evaluation.child3DnaId = x.child3DnaId; + evaluation.child4DnaId = x.child4DnaId; + }) + .catch(); evaluation.step = "PREPARE_DOC_V1"; evaluation.type = requestBody.type == "EXPERT" ? "EXPERT" : "SPECIAL_EXPERT"; evaluation.fullName = requestBody.fullName; @@ -538,10 +566,16 @@ export class EvaluationController { evaluation.lastUpdateFullName = request.user.name; evaluation.lastUpdatedAt = new Date(); evaluation.userId = request.user.sub; - evaluation.detailAnnounceStep5Body = announceTemplate5?.detailBody??_null; - evaluation.detailAnnounceStep5Footer = announceTemplate5?.detailFooter??_null; - evaluation.positionArea = requestBody.positionArea && requestBody.positionArea !== "" ? requestBody.positionArea : _null; - evaluation.posExecutive = requestBody.posExecutive && requestBody.posExecutive !== "" ? requestBody.posExecutive : _null; + evaluation.detailAnnounceStep5Body = announceTemplate5?.detailBody ?? _null; + evaluation.detailAnnounceStep5Footer = announceTemplate5?.detailFooter ?? _null; + evaluation.positionArea = + requestBody.positionArea && requestBody.positionArea !== "" + ? requestBody.positionArea + : _null; + evaluation.posExecutive = + requestBody.posExecutive && requestBody.posExecutive !== "" + ? requestBody.posExecutive + : _null; await this.evaluationRepository.save(evaluation, { data: request }); setLogDataDiff(request, { before, after: evaluation }); @@ -663,7 +697,7 @@ export class EvaluationController { salaries.lastUpdateUserId = request.user.sub; salaries.lastUpdateFullName = request.user.name; salaries.lastUpdatedAt = new Date(); - + await this.salaryRepository.save(salaries, { data: request }); setLogDataDiff(request, { before, after: salaries }); }); @@ -714,7 +748,7 @@ export class EvaluationController { await this.assessmentRepository.save(assessment, { data: request }); setLogDataDiff(request, { before, after: assessment }); }); - + //Portfolio if (requestBody.portfolios != null) requestBody.portfolios.forEach(async (pfo) => { @@ -730,7 +764,7 @@ export class EvaluationController { portfolio.evaluation = evaluation; await this.portfolioRepository.save(portfolio, { data: request }); setLogDataDiff(request, { before, after: portfolio }); - }); + }); //Performance if (requestBody.performances != null) @@ -749,8 +783,8 @@ export class EvaluationController { performance.evaluation = evaluation; await this.performanceRepository.save(performance, { data: request }); setLogDataDiff(request, { before, after: performance }); - }); - + }); + //EvaluationLogs const evaluationLogs = new EvaluationLogs(); evaluationLogs.step = (await ConvertToThaiStep("PREPARE_DOC_V1")) ?? _null; @@ -1807,21 +1841,20 @@ export class EvaluationController { }) .catch((x) => {}); await Promise.all( - _director.map((director:any) => { + _director.map((director: any) => { return new CallAPI() - .PostData(request, "/placement/noti/keycloak", { - subject: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, - body: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, - receiverUserId: director.keycloak, - payload: "", - isSendMail: true, - isSendInbox: true, - isSendNotification: true, - }) - .then((x) => { - }) - .catch((x) => {}); - }) + .PostData(request, "/placement/noti/keycloak", { + subject: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, + body: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, + receiverUserId: director.keycloak, + payload: "", + isSendMail: true, + isSendInbox: true, + isSendNotification: true, + }) + .then((x) => {}) + .catch((x) => {}); + }), ); return new HttpSuccess(); } catch (error: any) { @@ -2115,39 +2148,43 @@ export class EvaluationController { } } - /** + /** * API แก้ไข template ประกาศคัดเลือก * * @summary แก้ไข template ประกาศคัดเลือก (ADMIN) * * @param {string} id id ข้อมูลการประเมิน */ - @Put("edit-announce-template/{id}") - async editAnnounceTemp(@Path() id: string, @Request() request: RequestWithUser, @Body() body: {detailBody: string, detailFooter: string}) { - try { - await new permission().PermissionUpdate(request, "SYS_EVA_REQ"); - - const evaluation = await this.evaluationRepository.findOne({ where: { id } }); - if (!evaluation) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); - } - const before = structuredClone(evaluation); - - evaluation.detailAnnounceStep5Body = body.detailBody; - evaluation.detailAnnounceStep5Footer = body.detailFooter; - evaluation.lastUpdateUserId = request.user.sub; - evaluation.lastUpdateFullName = request.user.name; - evaluation.lastUpdatedAt = new Date(); - await this.evaluationRepository.save(evaluation, { data: request }); - setLogDataDiff(request, { before, after: evaluation }); - - return new HttpSuccess(); - } catch (error: any) { - if (error instanceof HttpError) { - throw error; - } else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error); - } - } + @Put("edit-announce-template/{id}") + async editAnnounceTemp( + @Path() id: string, + @Request() request: RequestWithUser, + @Body() body: { detailBody: string; detailFooter: string }, + ) { + try { + await new permission().PermissionUpdate(request, "SYS_EVA_REQ"); + + const evaluation = await this.evaluationRepository.findOne({ where: { id } }); + if (!evaluation) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); + } + const before = structuredClone(evaluation); + + evaluation.detailAnnounceStep5Body = body.detailBody; + evaluation.detailAnnounceStep5Footer = body.detailFooter; + evaluation.lastUpdateUserId = request.user.sub; + evaluation.lastUpdateFullName = request.user.name; + evaluation.lastUpdatedAt = new Date(); + await this.evaluationRepository.save(evaluation, { data: request }); + setLogDataDiff(request, { before, after: evaluation }); + + return new HttpSuccess(); + } catch (error: any) { + if (error instanceof HttpError) { + throw error; + } else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error); + } + } /** * API บันทึกแจ้งผลการประกาศคัดเลือก @@ -2196,7 +2233,7 @@ export class EvaluationController { 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; @@ -2770,7 +2807,7 @@ export class EvaluationController { "commanderAbovePositionOld", ], }); - + if (!evaluation) { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); } @@ -2951,19 +2988,19 @@ export class EvaluationController { if (!evaluation) { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); } - const _null:any = null; + const _null: any = null; evaluation.author = body.author; evaluation.subject = body.subject; evaluation.commanderFullname = body.commanderFullname; - evaluation.commanderOrg = body.commanderOrg??_null; - evaluation.commanderOrgOld = body.commanderOrgOld??_null; + evaluation.commanderOrg = body.commanderOrg ?? _null; + evaluation.commanderOrgOld = body.commanderOrgOld ?? _null; evaluation.commanderPosition = body.commanderPosition; - evaluation.commanderPositionOld = body.commanderPositionOld??_null; + evaluation.commanderPositionOld = body.commanderPositionOld ?? _null; evaluation.commanderAboveFullname = body.commanderAboveFullname; - evaluation.commanderAboveOrg = body.commanderAboveOrg??_null; - evaluation.commanderAboveOrgOld = body.commanderAboveOrgOld??_null; + evaluation.commanderAboveOrg = body.commanderAboveOrg ?? _null; + evaluation.commanderAboveOrgOld = body.commanderAboveOrgOld ?? _null; evaluation.commanderAbovePosition = body.commanderAbovePosition; - evaluation.commanderAbovePositionOld = body.commanderAbovePositionOld??_null; + evaluation.commanderAbovePositionOld = body.commanderAbovePositionOld ?? _null; evaluation.lastUpdateUserId = request.user.sub; evaluation.lastUpdateFullName = request.user.name; evaluation.lastUpdatedAt = new Date(); @@ -3024,20 +3061,20 @@ export class EvaluationController { if (!evaluation) { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); } - const _null:any = null; + const _null: any = null; evaluation.authorDoc2 = body.authorDoc2; evaluation.subjectDoc2 = body.subjectDoc2; evaluation.assignedPosition = body.assignedPosition; evaluation.commanderFullnameDoc2 = body.commanderFullnameDoc2; - evaluation.commanderOrgDoc2 = body.commanderOrgDoc2??_null; - evaluation.commanderOrgOldDoc2 = body.commanderOrgOldDoc2??_null; + evaluation.commanderOrgDoc2 = body.commanderOrgDoc2 ?? _null; + evaluation.commanderOrgOldDoc2 = body.commanderOrgOldDoc2 ?? _null; evaluation.commanderPositionDoc2 = body.commanderPositionDoc2; - evaluation.commanderPositionOldDoc2 = body.commanderPositionOldDoc2??_null; + evaluation.commanderPositionOldDoc2 = body.commanderPositionOldDoc2 ?? _null; evaluation.commanderAboveFullnameDoc2 = body.commanderAboveFullnameDoc2; - evaluation.commanderAboveOrgDoc2 = body.commanderAboveOrgDoc2??_null; - evaluation.commanderAboveOrgOldDoc2 = body.commanderAboveOrgOldDoc2??_null; + evaluation.commanderAboveOrgDoc2 = body.commanderAboveOrgDoc2 ?? _null; + evaluation.commanderAboveOrgOldDoc2 = body.commanderAboveOrgOldDoc2 ?? _null; evaluation.commanderAbovePositionDoc2 = body.commanderAbovePositionDoc2; - evaluation.commanderAbovePositionOldDoc2 = body.commanderAbovePositionOldDoc2??_null; + evaluation.commanderAbovePositionOldDoc2 = body.commanderAbovePositionOldDoc2 ?? _null; evaluation.isUpdated = true; evaluation.lastUpdateUserId = request.user.sub; evaluation.lastUpdateFullName = request.user.name; From b2a725ae5491d573baa276642c3c114b3268dec1 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 13 Jun 2025 14:15:15 +0700 Subject: [PATCH 02/16] =?UTF-8?q?Fix=20Invalid=20Evaluate=20=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2=E0=B8=87=E0=B8=B2=E0=B8=99=E0=B8=9B=E0=B8=A3?= =?UTF-8?q?=E0=B8=B0=E0=B9=80=E0=B8=A1=E0=B8=B4=E0=B8=99=20#1,=20#5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ReportController.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 287e9af..7984dae 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -318,7 +318,7 @@ export class ReoportController { lastOneYear: Extension.ToThaiNumber((thaiYear - 1).toString()), currentYear: Extension.ToThaiNumber(thaiYear.toString()), }; - let _orgNoNewLine = (org ? org : "-").replace(/\n/g, " "); + let _orgNoNewLine = (evaluation.oc ? evaluation.oc : "-").replace(/\n/g, " "); let topic10 = evaluation.type == "EXPERT" || evaluation.type == "EXPERTISE" ? "หน่วยงาน" : evaluation.type == "SPECIAL_EXPERT" ? "กรุงเทพมหานคร" : "หน่วยงาน"; let footer10 = evaluation.type == "EXPERT" || evaluation.type == "EXPERTISE" ? "หัวหน้าหน่วยงาน" : evaluation.type == "SPECIAL_EXPERT" ? "ปลัดกรุงเทพมหานคร" : "หัวหน้าหน่วยงาน"; let typeTh = evaluation.type == "EXPERT" ? "ชำนาญการ" : evaluation.type == "EXPERTISE" ? "เชียวชาญ" : evaluation.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ":""; @@ -339,12 +339,12 @@ export class ReoportController { posAndTypeTh: (evaluation.position ? `${evaluation.position}` : "" ) + (typeTh ? `${typeTh}` : ""), posNo: evaluation.posNo ? Extension.ToThaiNumber(evaluation.posNo) : "", posNoWithSym: evaluation.posNo ? `(${Extension.ToThaiNumber(evaluation.posNo)})` : "", - oc: evaluation.oc ? evaluation.oc : "-", + oc: evaluation.oc ? evaluation.oc.replace(/\n/g, " ") : "-", org: org ? org : "-", //สังกัด orgNoNewLine: _orgNoNewLine ? _orgNoNewLine : "-", //สังกัดแบบไม่เว้นวรรค root: root ? root : "-", //หน่วยงาน - salary: evaluation.salary ? Extension.ToThaiNumber(evaluation.salary) : "-", - salaryWithPrefix: evaluation.salary ? "อัตราเงินเดือนปัจจุบัน" +" "+ Extension.ToThaiNumber(evaluation.salary) : "-", + salary: evaluation.salary ? Extension.ToThaiNumber(Number(evaluation.salary).toLocaleString()) : "-", + salaryWithPrefix: evaluation.salary ? "อัตราเงินเดือนปัจจุบัน" +" "+ Extension.ToThaiNumber(Number(evaluation.salary).toLocaleString()) : "-", positionLevel: evaluation.positionLevel ? evaluation.positionLevel : "", detailAnnounceStep5Body: evaluation.detailAnnounceStep5Body, detailAnnounceStep5Footer: evaluation.detailAnnounceStep5Footer, @@ -521,9 +521,9 @@ export class ReoportController { commanderAboveOrg: evaluation.commanderAboveOrg ? evaluation.commanderAboveOrg : "-", commanderAboveOrgOld: evaluation.commanderAboveOrgOld ? evaluation.commanderAboveOrgOld : "-", commanderPositionSign: (evaluation.commanderPosition ? evaluation.commanderPosition : "") + (evaluation.commanderOrg ? " " + evaluation.commanderOrg : "") - + (evaluation.commanderPosition || evaluation.commanderOrg ? `\n` + "ขณะดำรงตำแหน่ง" : "") + (evaluation.commanderPositionOld ? " " + evaluation.commanderPositionOld:"") + (evaluation.commanderOrgOld ? " " + evaluation.commanderOrgOld : ""), + + (evaluation.commanderPosition || evaluation.commanderOrg ? `\n` : "") + (evaluation.commanderPositionOld ? `ขณะดำรงตำแหน่ง ${evaluation.commanderPositionOld}` : "") + (evaluation.commanderOrgOld ? " " + evaluation.commanderOrgOld : ""), commanderAbovePositionSign: (evaluation.commanderAbovePosition ? evaluation.commanderAbovePosition : "") + (evaluation.commanderAboveOrg ? " " + evaluation.commanderAboveOrg : "") - + (evaluation.commanderAbovePosition || evaluation.commanderAboveOrg ? `\n` + "ขณะดำรงตำแหน่ง" : "") + (evaluation.commanderAbovePositionOld ? " " + evaluation.commanderAbovePositionOld: "") + (evaluation.commanderAboveOrgOld ? " " + evaluation.commanderAboveOrgOld : ""), + + (evaluation.commanderAbovePosition || evaluation.commanderAboveOrg ? `\n`: "") + (evaluation.commanderAbovePositionOld ? `ขณะดำรงตำแหน่ง ${evaluation.commanderAbovePositionOld}` : "") + (evaluation.commanderAboveOrgOld ? " " + evaluation.commanderAboveOrgOld : ""), years: years, }; From 3a4eb56629b49f3e73a7c7ac4dbdf19febad2a59 Mon Sep 17 00:00:00 2001 From: Moss <> Date: Fri, 13 Jun 2025 15:20:58 +0700 Subject: [PATCH 03/16] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=81?= =?UTF-8?q?=E0=B8=A3=E0=B8=A3=E0=B8=A1=E0=B8=81=E0=B8=B2=E0=B8=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/DirectorController.ts | 14 +++-- src/controllers/EvaluationController.ts | 51 ++++++++++++------- src/entities/Director.ts | 22 ++++---- src/entities/Evaluation.ts | 30 ++++++----- src/entities/evaluation_directors_director.ts | 35 +++++++++++++ .../1749798550561-update30062025603.ts | 20 ++++++++ 6 files changed, 128 insertions(+), 44 deletions(-) create mode 100644 src/entities/evaluation_directors_director.ts create mode 100644 src/migration/1749798550561-update30062025603.ts diff --git a/src/controllers/DirectorController.ts b/src/controllers/DirectorController.ts index fd63984..e524db8 100644 --- a/src/controllers/DirectorController.ts +++ b/src/controllers/DirectorController.ts @@ -22,6 +22,7 @@ import { Not, Brackets } from "typeorm"; import permission from "../interfaces/permission"; import { RequestWithUser } from "../middlewares/user"; import { setLogDataDiff } from "../interfaces/utils"; +import { evaluation_directors_director } from "../entities/evaluation_directors_director"; @Route("api/v1/evaluation/director") @Tags("director") @Security("bearerAuth") @@ -32,6 +33,9 @@ import { setLogDataDiff } from "../interfaces/utils"; @SuccessResponse(HttpStatusCode.OK, "สำเร็จ") export class DirectorController { private directorRepository = AppDataSource.getRepository(Director); + private evaluation_directors_directorRepository = AppDataSource.getRepository( + evaluation_directors_director, + ); /** * API สำหรับแสดงรายการกรรมการ @@ -200,10 +204,14 @@ export class DirectorController { * */ @Put("duty/{id}") - async updateDuty(@Path() id: string, @Body() body:{duty: string} , @Request() request: RequestWithUser) { + async updateDuty( + @Path() id: string, + @Body() body: { duty: string }, + @Request() request: RequestWithUser, + ) { try { await new permission().PermissionUpdate(request, "SYS_EVA_INFO"); - let director = await this.directorRepository.findOneBy({ id }); + let director = await this.evaluation_directors_directorRepository.findOneBy({ id }); if (!director) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกรรมการ"); } @@ -212,7 +220,7 @@ export class DirectorController { director.lastUpdateUserId = request.user.sub; director.lastUpdateFullName = request.user.name; director.lastUpdatedAt = new Date(); - await this.directorRepository.save(director, { data: request }); + await this.evaluation_directors_directorRepository.save(director, { data: request }); setLogDataDiff(request, { before, after: director }); return new HttpSuccess(); } catch (error: any) { diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index fe9e173..abd41dd 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -36,6 +36,7 @@ import Extension from "../interfaces/extension"; import { Portfolio } from "../entities/Portfolio"; import { Performance } from "../entities/Performance"; import { AnnounceTemplate } from "../entities/AnnounceTemplate"; +import { evaluation_directors_director } from "../entities/evaluation_directors_director"; @Route("api/v1/evaluation") @Tags("evaluation") @@ -58,6 +59,9 @@ export class EvaluationController { private directorRepository = AppDataSource.getRepository(Director); private meetingRepository = AppDataSource.getRepository(Meeting); private announceTemplateRepository = AppDataSource.getRepository(AnnounceTemplate); + private evaluation_directors_directorRepository = AppDataSource.getRepository( + evaluation_directors_director, + ); /** * API ล้างข้อมูล @@ -2221,7 +2225,7 @@ export class EvaluationController { evaluation.step = "PREPARE_DOC_V2"; evaluation.subjectDoc2 = evaluation.subject; evaluation.authorDoc2 = evaluation.author; - evaluation.assignedPosition = evaluation.position; + evaluation.assignedPosition = evaluation.position; //xxxxxxxxxx evaluation.commanderFullnameDoc2 = evaluation.commanderFullname; evaluation.commanderPositionDoc2 = evaluation.commanderPosition; evaluation.commanderAboveFullnameDoc2 = evaluation.commanderAboveFullname; @@ -2478,12 +2482,23 @@ export class EvaluationController { if (!evaluation) { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); } - if (!evaluation.directors) { - evaluation.directors = []; + if (!evaluation.evaluation_directors_director) { + evaluation.evaluation_directors_director = []; } body.directors.forEach(async (directorId) => { const director = await this.directorRepository.findOne({ where: { id: directorId } }); - if (director != null) evaluation.directors.push(director); + if (director != null) { + await this.evaluation_directors_directorRepository.save({ + directorId: director.id, + evaluationId: evaluation.id, + createdUserId: request.user.sub, + createdFullName: request.user.name, + lastUpdateUserId: request.user.sub, + lastUpdateFullName: request.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), + }); + } }); evaluation.lastUpdateUserId = request.user.sub; @@ -2580,20 +2595,24 @@ export class EvaluationController { const evaluation = await this.evaluationRepository.findOne({ where: { id }, - relations: ["directors", "meetings"], + relations: [ + "evaluation_directors_director", + "evaluation_directors_director.director", + "meetings", + ], }); if (!evaluation) { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); } - const directors = evaluation.directors.map((director) => ({ + const directors = evaluation.evaluation_directors_director.map((director) => ({ id: director.id, - prefix: director.prefix, - firstName: director.firstName, - lastName: director.lastName, - position: director.position, + prefix: director.director.prefix, + firstName: director.director.firstName, + lastName: director.director.lastName, + position: director.director.position, positionName: null, - email: director.email, - phone: director.phone, + email: director.director.email, + phone: director.director.phone, duty: director.duty, })); @@ -3104,7 +3123,7 @@ export class EvaluationController { // await new permission().PermissionDelete(request, "SYS_EVA_REQ"); const evaluation = await this.evaluationRepository.findOne({ where: { id }, - relations: ["meetings", "directors"], + relations: ["meetings", "evaluation_directors_director"], }); if (!evaluation) { @@ -3125,11 +3144,7 @@ export class EvaluationController { this.meetingRepository.remove(meeting, { data: request }), ), ); - await Promise.all( - evaluation.directors.map((director) => - this.directorRepository.remove(director, { data: request }), - ), - ); + await this.evaluation_directors_directorRepository.delete({ evaluationId: id }); await this.evaluationRepository.delete({ id }); return new HttpSuccess(); diff --git a/src/entities/Director.ts b/src/entities/Director.ts index 2710d23..d9dfa3b 100644 --- a/src/entities/Director.ts +++ b/src/entities/Director.ts @@ -1,10 +1,7 @@ -import { - Entity, - Column, - ManyToMany, -} from "typeorm"; +import { Entity, Column, ManyToMany, OneToMany, JoinTable } from "typeorm"; import { EntityBase } from "./base/Base"; import { Evaluation } from "./Evaluation"; +import { evaluation_directors_director } from "./evaluation_directors_director"; @Entity("director") export class Director extends EntityBase { @Column({ nullable: true, comment: "คำนำหน้าชื่อ" }) @@ -25,11 +22,18 @@ export class Director extends EntityBase { @Column({ nullable: true, comment: "ตำแหน่ง" }) position: string; - @Column({ nullable: true, comment: "หน้าที่" }) - duty: string; + // @Column({ nullable: true, comment: "หน้าที่" }) + // duty: string; - @ManyToMany(() => Evaluation, (evaluation) => evaluation.directors) - evaluations: Evaluation[]; + // @ManyToMany(() => Evaluation, (evaluation) => evaluation.directors) + // evaluations: Evaluation[]; + + @OneToMany( + () => evaluation_directors_director, + (evaluation_directors_director) => evaluation_directors_director.director, + ) + @JoinTable() + evaluation_directors_director: evaluation_directors_director[]; } export class CreateDirector { diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index 65c5baa..b3c4d03 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -10,6 +10,7 @@ import { Director } from "./Director"; import { Meeting } from "./Meeting"; import { Portfolio } from "./Portfolio"; import { Performance } from "./Performance"; +import { evaluation_directors_director } from "./evaluation_directors_director"; @Entity("evaluation") export class Evaluation extends EntityBase { @@ -201,7 +202,6 @@ export class Evaluation extends EntityBase { @Column({ nullable: true, comment: "ตำแหน่ง ผู้บังคับบัญชาชั้นต้น (จัดเตรียมเอกสารเล่ม 2)" }) commanderPositionDoc2: string; - @Column({ nullable: true, comment: "สังกัดปัจุบัน ผู้บังคับบัญชาชั้นต้น" }) commanderOrg: string; @Column({ nullable: true, comment: "สังกัดเดิม ผู้บังคับบัญชาชั้นต้น" }) @@ -256,13 +256,13 @@ export class Evaluation extends EntityBase { @Column({ nullable: true, comment: "ชื่อเจ้าของผลงาน" }) author: string; - @Column({ type: 'json', nullable: true, comment: 'ชื่อผลงาน' }) + @Column({ type: "json", nullable: true, comment: "ชื่อผลงาน" }) subject: string[]; @Column({ nullable: true, comment: "ชื่อเจ้าของผลงาน2" }) authorDoc2: string; - @Column({ type: 'json', nullable: true, comment: "ชื่อผลงาน2" }) + @Column({ type: "json", nullable: true, comment: "ชื่อผลงาน2" }) subjectDoc2: string[]; @Column({ nullable: true, comment: "ตำแหน่งที่ได้รับมอบหมาย" }) @@ -271,17 +271,15 @@ export class Evaluation extends EntityBase { @Column({ nullable: true, comment: "ผลการประเมิน", default: "PENDING" }) //PENDING,PASS,NOTPASS evaluationResult: string; - @Column({ type: 'text', nullable: true, comment: 'รายละเอียดประกาศ(STEP5)'}) + @Column({ type: "text", nullable: true, comment: "รายละเอียดประกาศ(STEP5)" }) detailAnnounceStep5Body: string; - @Column({ type: 'text', nullable: true, comment: 'รายละเอียดส่วนท้าย(STEP5)'}) + @Column({ type: "text", nullable: true, comment: "รายละเอียดส่วนท้าย(STEP5)" }) detailAnnounceStep5Footer: string; - @Column({ default: false, comment: 'สถานะเช็คการอัพเดทชื่อผลงาน (STEP6)'}) + @Column({ default: false, comment: "สถานะเช็คการอัพเดทชื่อผลงาน (STEP6)" }) isUpdated: boolean; - - @OneToMany(() => EvaluationLogs, (evaluationLogs) => evaluationLogs.evaluation) evaluationLogs: EvaluationLogs[]; @@ -306,15 +304,20 @@ export class Evaluation extends EntityBase { @OneToMany(() => Performance, (performance) => performance.evaluation) performances: Performance[]; - @ManyToMany(() => Director, (director) => director.evaluations) - @JoinTable() - directors: Director[]; + // @ManyToMany(() => Director, (director) => director.evaluations) + // @JoinTable() + // directors: Director[]; @ManyToMany(() => Meeting, (meeting) => meeting.evaluations) @JoinTable() meetings: Meeting[]; - + @OneToMany( + () => evaluation_directors_director, + (evaluation_directors_director) => evaluation_directors_director.evaluation, + ) + @JoinTable() + evaluation_directors_director: evaluation_directors_director[]; } export class CreateEvaluation { @@ -612,7 +615,7 @@ export class CreateEvaluationExpertise { @Column() oc?: string | null; - + @Column() citizenId?: string | null; @@ -639,7 +642,6 @@ export class CreateEvaluationExpertise { @Column() govAge?: string | null; - } export type UpdateEvaluation = Partial; diff --git a/src/entities/evaluation_directors_director.ts b/src/entities/evaluation_directors_director.ts new file mode 100644 index 0000000..402d8d8 --- /dev/null +++ b/src/entities/evaluation_directors_director.ts @@ -0,0 +1,35 @@ +import { Entity, Column, ManyToMany, ManyToOne, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { Evaluation } from "./Evaluation"; +import { Director } from "./Director"; +@Entity("evaluation_directors_director") +export class evaluation_directors_director extends EntityBase { + @Column({ + comment: "Id การทำรายการระบบประเมิน", + length: 40, + default: "00000000-0000-0000-0000-000000000000", + }) + directorId: string; + + @Column({ + comment: "Id การทำรายการระบบประเมิน", + length: 40, + default: "00000000-0000-0000-0000-000000000000", + }) + evaluationId: string; + + @Column({ + nullable: true, + comment: "หน้าที่", + default: null, + }) + duty: string; + + @ManyToOne(() => Director, (Director) => Director.evaluation_directors_director) + @JoinColumn({ name: "directorId" }) + director: Director; + + @ManyToOne(() => Evaluation, (Evaluation) => Evaluation.evaluation_directors_director) + @JoinColumn({ name: "evaluationId" }) + evaluation: Evaluation; +} diff --git a/src/migration/1749798550561-update30062025603.ts b/src/migration/1749798550561-update30062025603.ts new file mode 100644 index 0000000..02b0b79 --- /dev/null +++ b/src/migration/1749798550561-update30062025603.ts @@ -0,0 +1,20 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class Update300620256031749798550561 implements MigrationInterface { + name = 'Update300620256031749798550561' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE \`evaluation_directors_director\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`directorId\` varchar(40) NOT NULL COMMENT 'Id การทำรายการระบบประเมิน' DEFAULT '00000000-0000-0000-0000-000000000000', \`evaluationId\` varchar(40) NOT NULL COMMENT 'Id การทำรายการระบบประเมิน' DEFAULT '00000000-0000-0000-0000-000000000000', \`duty\` varchar(255) NULL COMMENT 'หน้าที่', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`ALTER TABLE \`director\` DROP COLUMN \`duty\``); + await queryRunner.query(`ALTER TABLE \`evaluation_directors_director\` ADD CONSTRAINT \`FK_a1b902762a4a2410a10b6728065\` FOREIGN KEY (\`directorId\`) REFERENCES \`director\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`evaluation_directors_director\` ADD CONSTRAINT \`FK_aee4e7f5076bf5ff10190ddb79b\` FOREIGN KEY (\`evaluationId\`) REFERENCES \`evaluation\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`evaluation_directors_director\` DROP FOREIGN KEY \`FK_aee4e7f5076bf5ff10190ddb79b\``); + await queryRunner.query(`ALTER TABLE \`evaluation_directors_director\` DROP FOREIGN KEY \`FK_a1b902762a4a2410a10b6728065\``); + await queryRunner.query(`ALTER TABLE \`director\` ADD \`duty\` varchar(255) NULL COMMENT 'หน้าที่'`); + await queryRunner.query(`DROP TABLE \`evaluation_directors_director\``); + } + +} From 264fafdcbf41b9f8919bf6b9a251f9ed983b0e96 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 13 Jun 2025 18:05:30 +0700 Subject: [PATCH 04/16] add field assignedPosLevel --- src/controllers/EvaluationController.ts | 12 ++++++++++++ src/controllers/ReportController.ts | 4 +++- src/entities/Evaluation.ts | 3 +++ .../1749811430532-add_field_assignedPosLevel.ts | 14 ++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/migration/1749811430532-add_field_assignedPosLevel.ts diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index abd41dd..e12b060 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -550,6 +550,7 @@ export class EvaluationController { select: ["detailBody", "detailFooter"], }); const before = null; + let typeTh = evaluation.type == "EXPERT" ? "ชำนาญการ" : evaluation.type == "EXPERTISE" ? "เชียวชาญ" : evaluation.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ":""; await new CallAPI() .GetData(request, `/org/profile/keycloak/commander/${request.user.sub}`) .then(async (x) => { @@ -560,6 +561,8 @@ export class EvaluationController { evaluation.child4DnaId = x.child4DnaId; }) .catch(); + evaluation.assignedPosition = requestBody.position ? requestBody.position : _null; + evaluation.assignedPosLevel = typeTh; evaluation.step = "PREPARE_DOC_V1"; evaluation.type = requestBody.type == "EXPERT" ? "EXPERT" : "SPECIAL_EXPERT"; evaluation.fullName = requestBody.fullName; @@ -837,6 +840,7 @@ export class EvaluationController { const evaluation = Object.assign(new Evaluation(), requestBody); const before = null; let org: any; + const __null: any = null; await new CallAPI() .GetData(request, `/org/profile/keycloak/commander/${request.user.sub}`) .then(async (x) => { @@ -849,6 +853,8 @@ export class EvaluationController { }) .catch(); //Evaluation + evaluation.assignedPosition = requestBody.position ? requestBody.position : __null; + evaluation.assignedPosLevel = "เชียวชาญ"; evaluation.oc = org; evaluation.step = "DONE"; evaluation.type = "EXPERTISE"; @@ -2226,6 +2232,7 @@ export class EvaluationController { evaluation.subjectDoc2 = evaluation.subject; evaluation.authorDoc2 = evaluation.author; evaluation.assignedPosition = evaluation.position; //xxxxxxxxxx + evaluation.assignedPosLevel = "xxxxxxxx"; //xxxxxxxxxx evaluation.commanderFullnameDoc2 = evaluation.commanderFullname; evaluation.commanderPositionDoc2 = evaluation.commanderPosition; evaluation.commanderAboveFullnameDoc2 = evaluation.commanderAboveFullname; @@ -2895,6 +2902,7 @@ export class EvaluationController { "authorDoc2", "subjectDoc2", "assignedPosition", + "assignedPosLevel", "commanderFullnameDoc2", "commanderOrgDoc2", "commanderOrgOldDoc2", @@ -2939,6 +2947,7 @@ export class EvaluationController { "authorDoc2", "subjectDoc2", "assignedPosition", + "assignedPosLevel", "commanderFullnameDoc2", "commanderOrgDoc2", "commanderOrgOldDoc2", @@ -3048,6 +3057,7 @@ export class EvaluationController { authorDoc2: "string", subjectDoc2: "string", assignedPosition: "string", + assignedPosLevel: "string", commanderFullnameDoc2: "string", commanderPositionDoc2: "string", commanderAboveFullnameDoc2: "string", @@ -3061,6 +3071,7 @@ export class EvaluationController { authorDoc2: string; subjectDoc2: string[]; assignedPosition: string; + assignedPosLevel?: string; commanderFullnameDoc2: string; commanderPositionDoc2: string; commanderAboveFullnameDoc2: string; @@ -3084,6 +3095,7 @@ export class EvaluationController { evaluation.authorDoc2 = body.authorDoc2; evaluation.subjectDoc2 = body.subjectDoc2; evaluation.assignedPosition = body.assignedPosition; + evaluation.assignedPosLevel = body.assignedPosLevel ? body.assignedPosLevel : _null; evaluation.commanderFullnameDoc2 = body.commanderFullnameDoc2; evaluation.commanderOrgDoc2 = body.commanderOrgDoc2 ?? _null; evaluation.commanderOrgOldDoc2 = body.commanderOrgOldDoc2 ?? _null; diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 7984dae..c1097dc 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -335,8 +335,10 @@ export class ReoportController { prefix: evaluation.prefix, fullName: evaluation.fullName ? `${evaluation.fullName}` : "", position: evaluation.position ? evaluation.position : "", + // ตำแหน่งเดิม, posAndPosLevel: (evaluation.position ? `${evaluation.position}` : "") + (evaluation.positionLevel ? `${evaluation.positionLevel}` : ""), - posAndTypeTh: (evaluation.position ? `${evaluation.position}` : "" ) + (typeTh ? `${typeTh}` : ""), + // ตำแหน่งใหม่ + posAndTypeTh: (evaluation.assignedPosition ? `${evaluation.assignedPosition}` : "" ) + (evaluation.assignedPosLevel ? `${evaluation.assignedPosLevel}` : ""), posNo: evaluation.posNo ? Extension.ToThaiNumber(evaluation.posNo) : "", posNoWithSym: evaluation.posNo ? `(${Extension.ToThaiNumber(evaluation.posNo)})` : "", oc: evaluation.oc ? evaluation.oc.replace(/\n/g, " ") : "-", diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index b3c4d03..7bb865a 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -268,6 +268,9 @@ export class Evaluation extends EntityBase { @Column({ nullable: true, comment: "ตำแหน่งที่ได้รับมอบหมาย" }) assignedPosition: string; + @Column({ nullable: true, comment: "ระดับที่ได้รับมอบหมาย" }) + assignedPosLevel: string; + @Column({ nullable: true, comment: "ผลการประเมิน", default: "PENDING" }) //PENDING,PASS,NOTPASS evaluationResult: string; diff --git a/src/migration/1749811430532-add_field_assignedPosLevel.ts b/src/migration/1749811430532-add_field_assignedPosLevel.ts new file mode 100644 index 0000000..130e652 --- /dev/null +++ b/src/migration/1749811430532-add_field_assignedPosLevel.ts @@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddFieldAssignedPosLevel1749811430532 implements MigrationInterface { + name = 'AddFieldAssignedPosLevel1749811430532' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`assignedPosLevel\` varchar(255) NULL COMMENT 'ระดับที่ได้รับมอบหมาย'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`assignedPosLevel\``); + } + +} From c5f712467a934f7da90cb7a0358993e080cd660c Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 13 Jun 2025 18:08:01 +0700 Subject: [PATCH 05/16] no message --- src/controllers/EvaluationController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index e12b060..8d26e8e 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -2227,12 +2227,12 @@ export class EvaluationController { setLogDataDiff(request, { before: null, after: evaluationLogs }); } const before = structuredClone(evaluation); - + let typeTh = evaluation.type == "EXPERT" ? "ชำนาญการ" : evaluation.type == "EXPERTISE" ? "เชียวชาญ" : evaluation.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ":""; evaluation.step = "PREPARE_DOC_V2"; evaluation.subjectDoc2 = evaluation.subject; evaluation.authorDoc2 = evaluation.author; evaluation.assignedPosition = evaluation.position; //xxxxxxxxxx - evaluation.assignedPosLevel = "xxxxxxxx"; //xxxxxxxxxx + evaluation.assignedPosLevel = typeTh; evaluation.commanderFullnameDoc2 = evaluation.commanderFullname; evaluation.commanderPositionDoc2 = evaluation.commanderPosition; evaluation.commanderAboveFullnameDoc2 = evaluation.commanderAboveFullname; From 436bcb002b4370099a3f3672595a564d882f44cf Mon Sep 17 00:00:00 2001 From: Moss <> Date: Fri, 13 Jun 2025 18:33:33 +0700 Subject: [PATCH 06/16] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=95?= =?UTF-8?q?=E0=B8=B3=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/EvaluationController.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 8d26e8e..f7e6d01 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -550,7 +550,14 @@ export class EvaluationController { select: ["detailBody", "detailFooter"], }); const before = null; - let typeTh = evaluation.type == "EXPERT" ? "ชำนาญการ" : evaluation.type == "EXPERTISE" ? "เชียวชาญ" : evaluation.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ":""; + let typeTh = + evaluation.type == "EXPERT" + ? "ชำนาญการ" + : evaluation.type == "EXPERTISE" + ? "เชียวชาญ" + : evaluation.type == "SPECIAL_EXPERT" + ? "ชำนาญการพิเศษ" + : ""; await new CallAPI() .GetData(request, `/org/profile/keycloak/commander/${request.user.sub}`) .then(async (x) => { @@ -2227,12 +2234,11 @@ export class EvaluationController { setLogDataDiff(request, { before: null, after: evaluationLogs }); } const before = structuredClone(evaluation); - let typeTh = evaluation.type == "EXPERT" ? "ชำนาญการ" : evaluation.type == "EXPERTISE" ? "เชียวชาญ" : evaluation.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ":""; evaluation.step = "PREPARE_DOC_V2"; evaluation.subjectDoc2 = evaluation.subject; evaluation.authorDoc2 = evaluation.author; - evaluation.assignedPosition = evaluation.position; //xxxxxxxxxx - evaluation.assignedPosLevel = typeTh; + evaluation.assignedPosition = evaluation.position; + evaluation.assignedPosLevel = evaluation.positionLevel; evaluation.commanderFullnameDoc2 = evaluation.commanderFullname; evaluation.commanderPositionDoc2 = evaluation.commanderPosition; evaluation.commanderAboveFullnameDoc2 = evaluation.commanderAboveFullname; @@ -3071,7 +3077,7 @@ export class EvaluationController { authorDoc2: string; subjectDoc2: string[]; assignedPosition: string; - assignedPosLevel?: string; + assignedPosLevel?: string; commanderFullnameDoc2: string; commanderPositionDoc2: string; commanderAboveFullnameDoc2: string; @@ -3095,7 +3101,7 @@ export class EvaluationController { evaluation.authorDoc2 = body.authorDoc2; evaluation.subjectDoc2 = body.subjectDoc2; evaluation.assignedPosition = body.assignedPosition; - evaluation.assignedPosLevel = body.assignedPosLevel ? body.assignedPosLevel : _null; + evaluation.assignedPosLevel = body.assignedPosLevel ? body.assignedPosLevel : ""; evaluation.commanderFullnameDoc2 = body.commanderFullnameDoc2; evaluation.commanderOrgDoc2 = body.commanderOrgDoc2 ?? _null; evaluation.commanderOrgOldDoc2 = body.commanderOrgOldDoc2 ?? _null; From c6f1db8670554b9ccee00b22bcb7d15d78d3b72a Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 16 Jun 2025 10:42:38 +0700 Subject: [PATCH 07/16] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20=E0=B8=87=E0=B8=B2=E0=B8=99/=E0=B8=9D=E0=B9=88?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2/=E0=B8=81=E0=B8=A5=E0=B8=B8=E0=B9=88?= =?UTF-8?q?=E0=B8=A1,=20=E0=B8=81=E0=B8=AD=E0=B8=87/=E0=B8=A8=E0=B8=B9?= =?UTF-8?q?=E0=B8=99=E0=B8=A2=E0=B9=8C/=E0=B8=AA=E0=B9=88=E0=B8=A7?= =?UTF-8?q?=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ReportController.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index c1097dc..8988b7e 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -344,7 +344,13 @@ export class ReoportController { oc: evaluation.oc ? evaluation.oc.replace(/\n/g, " ") : "-", org: org ? org : "-", //สังกัด orgNoNewLine: _orgNoNewLine ? _orgNoNewLine : "-", //สังกัดแบบไม่เว้นวรรค - root: root ? root : "-", //หน่วยงาน + root: evaluation.salaries.length > 0 ? evaluation.salaries[0].orgRoot : "-", //หน่วยงาน + child1: evaluation.salaries.length > 0 // กอง / ศูนย์ / ส่วน + ? evaluation.salaries[0].orgChild1 + : "-", + child432: evaluation.salaries.length > 0 // งาน / ฝ่าย / กลุ่ม + ? `${evaluation.salaries[0].orgChild4 ?? ""} ${evaluation.salaries[0].orgChild3 ?? ""} ${evaluation.salaries[0].orgChild2 ?? ""}`.trim() + : "-", salary: evaluation.salary ? Extension.ToThaiNumber(Number(evaluation.salary).toLocaleString()) : "-", salaryWithPrefix: evaluation.salary ? "อัตราเงินเดือนปัจจุบัน" +" "+ Extension.ToThaiNumber(Number(evaluation.salary).toLocaleString()) : "-", positionLevel: evaluation.positionLevel ? evaluation.positionLevel : "", From 89490e800c090b30e0d17b48fcfdbd26fe0facca Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 16 Jun 2025 14:43:05 +0700 Subject: [PATCH 08/16] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=E0=B8=A3=E0=B8=B0=E0=B8=94=E0=B8=B1=E0=B8=9A=E0=B8=97?= =?UTF-8?q?=E0=B8=B5=E0=B9=88=E0=B8=82=E0=B8=AD=E0=B8=9B=E0=B8=A3=E0=B8=B0?= =?UTF-8?q?=E0=B9=80=E0=B8=A1=E0=B8=B4=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ReportController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 8988b7e..2d61056 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -339,6 +339,7 @@ export class ReoportController { posAndPosLevel: (evaluation.position ? `${evaluation.position}` : "") + (evaluation.positionLevel ? `${evaluation.positionLevel}` : ""), // ตำแหน่งใหม่ posAndTypeTh: (evaluation.assignedPosition ? `${evaluation.assignedPosition}` : "" ) + (evaluation.assignedPosLevel ? `${evaluation.assignedPosLevel}` : ""), + posLevel: evaluation.assignedPosLevel ?? "-", //ระดับที่ขอประเมิน posNo: evaluation.posNo ? Extension.ToThaiNumber(evaluation.posNo) : "", posNoWithSym: evaluation.posNo ? `(${Extension.ToThaiNumber(evaluation.posNo)})` : "", oc: evaluation.oc ? evaluation.oc.replace(/\n/g, " ") : "-", From c4c88cf2462ae4bd5e1c3fbd65dca27911263c04 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 16 Jun 2025 15:44:47 +0700 Subject: [PATCH 09/16] Fix Invalid Evaluate Issue #1, #3, #5 --- src/controllers/ReportController.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 2d61056..cb04269 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -200,6 +200,9 @@ export class ReoportController { "evaluation.commanderAbovePositionOld", "evaluation.commanderAboveOrg", "evaluation.commanderAboveOrgOld", + "evaluation.root", + "evaluation.assignedPosition", + "evaluation.assignedPosLevel", "education.educationLevel", "education.institute", @@ -345,7 +348,7 @@ export class ReoportController { oc: evaluation.oc ? evaluation.oc.replace(/\n/g, " ") : "-", org: org ? org : "-", //สังกัด orgNoNewLine: _orgNoNewLine ? _orgNoNewLine : "-", //สังกัดแบบไม่เว้นวรรค - root: evaluation.salaries.length > 0 ? evaluation.salaries[0].orgRoot : "-", //หน่วยงาน + root: evaluation.root ?evaluation.root : "-", //หน่วยงาน child1: evaluation.salaries.length > 0 // กอง / ศูนย์ / ส่วน ? evaluation.salaries[0].orgChild1 : "-", From ea7601adbe7e9ad5ad6633b860f2efcbcfaba498 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 16 Jun 2025 15:49:13 +0700 Subject: [PATCH 10/16] no message --- src/controllers/ReportController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index cb04269..ce4e2b7 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -348,7 +348,7 @@ export class ReoportController { oc: evaluation.oc ? evaluation.oc.replace(/\n/g, " ") : "-", org: org ? org : "-", //สังกัด orgNoNewLine: _orgNoNewLine ? _orgNoNewLine : "-", //สังกัดแบบไม่เว้นวรรค - root: evaluation.root ?evaluation.root : "-", //หน่วยงาน + root: evaluation.salaries.length > 0 ? evaluation.salaries[0].orgRoot : "-", //หน่วยงาน child1: evaluation.salaries.length > 0 // กอง / ศูนย์ / ส่วน ? evaluation.salaries[0].orgChild1 : "-", From 6e4329f71fa6c07173e32ad4e1325b0acbec868b Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 16 Jun 2025 16:38:19 +0700 Subject: [PATCH 11/16] no message --- src/controllers/EvaluationController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index f7e6d01..9e253a9 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -860,6 +860,7 @@ export class EvaluationController { }) .catch(); //Evaluation + evaluation.positionLevel = requestBody.positionLevel ? requestBody.positionLevel : __null; evaluation.assignedPosition = requestBody.position ? requestBody.position : __null; evaluation.assignedPosLevel = "เชียวชาญ"; evaluation.oc = org; From 6c08461207dc27710d23bd799056b1a9f5f32dcc Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 16 Jun 2025 16:45:07 +0700 Subject: [PATCH 12/16] no message --- src/controllers/EvaluationController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 9e253a9..a298ad3 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -857,10 +857,10 @@ export class EvaluationController { evaluation.child2DnaId = x.child2DnaId; evaluation.child3DnaId = x.child3DnaId; evaluation.child4DnaId = x.child4DnaId; + evaluation.positionLevel = x.posLevelName; }) .catch(); //Evaluation - evaluation.positionLevel = requestBody.positionLevel ? requestBody.positionLevel : __null; evaluation.assignedPosition = requestBody.position ? requestBody.position : __null; evaluation.assignedPosLevel = "เชียวชาญ"; evaluation.oc = org; From 951592c758d18a70bb371a63a26f8c0318968f68 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 16 Jun 2025 17:52:30 +0700 Subject: [PATCH 13/16] fix --- src/controllers/EvaluationController.ts | 6 +++--- src/controllers/ReportController.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index a298ad3..ead33bd 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -551,11 +551,11 @@ export class EvaluationController { }); const before = null; let typeTh = - evaluation.type == "EXPERT" + requestBody.type == "EXPERT" ? "ชำนาญการ" - : evaluation.type == "EXPERTISE" + : requestBody.type == "EXPERTISE" ? "เชียวชาญ" - : evaluation.type == "SPECIAL_EXPERT" + : requestBody.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ" : ""; await new CallAPI() diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index ce4e2b7..c260dc4 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -341,7 +341,7 @@ export class ReoportController { // ตำแหน่งเดิม, posAndPosLevel: (evaluation.position ? `${evaluation.position}` : "") + (evaluation.positionLevel ? `${evaluation.positionLevel}` : ""), // ตำแหน่งใหม่ - posAndTypeTh: (evaluation.assignedPosition ? `${evaluation.assignedPosition}` : "" ) + (evaluation.assignedPosLevel ? `${evaluation.assignedPosLevel}` : ""), + posAndTypeTh: (evaluation.assignedPosition ? `${evaluation.assignedPosition}` : "" ) + (evaluation.assignedPosLevel ? `${evaluation.assignedPosLevel}` : `${typeTh??""}`), posLevel: evaluation.assignedPosLevel ?? "-", //ระดับที่ขอประเมิน posNo: evaluation.posNo ? Extension.ToThaiNumber(evaluation.posNo) : "", posNoWithSym: evaluation.posNo ? `(${Extension.ToThaiNumber(evaluation.posNo)})` : "", From ee7ba57b9af5d3c5a2f2ce5a0912161f80799f47 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 18 Jun 2025 10:11:03 +0700 Subject: [PATCH 14/16] =?UTF-8?q?fix=20bug=20=E0=B8=8A=E0=B9=87=E0=B8=AD?= =?UTF-8?q?=E0=B8=95=E0=B8=9A=E0=B8=B1=E0=B8=99=E0=B8=97=E0=B8=B6=E0=B8=81?= =?UTF-8?q?=E0=B8=81=E0=B9=88=E0=B8=AD=E0=B8=99=E0=B8=88=E0=B8=B1=E0=B8=94?= =?UTF-8?q?=E0=B9=80=E0=B8=95=E0=B8=A3=E0=B8=B5=E0=B8=A2=E0=B8=99=E0=B8=A1?= =?UTF-8?q?=E0=B9=80=E0=B8=AD=E0=B8=81=E0=B8=AA=E0=B8=B2=E0=B8=A3=E0=B9=80?= =?UTF-8?q?=E0=B8=A5=E0=B9=88=E0=B8=A12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/EvaluationController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index ead33bd..2bc1224 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -2238,8 +2238,8 @@ export class EvaluationController { evaluation.step = "PREPARE_DOC_V2"; evaluation.subjectDoc2 = evaluation.subject; evaluation.authorDoc2 = evaluation.author; - evaluation.assignedPosition = evaluation.position; - evaluation.assignedPosLevel = evaluation.positionLevel; + evaluation.assignedPosition = evaluation.assignedPosition; + evaluation.assignedPosLevel = evaluation.assignedPosLevel; evaluation.commanderFullnameDoc2 = evaluation.commanderFullname; evaluation.commanderPositionDoc2 = evaluation.commanderPosition; evaluation.commanderAboveFullnameDoc2 = evaluation.commanderAboveFullname; From aba0f330047709f87f1c42a1e3447a7f1ec5e001 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 18 Jun 2025 10:21:52 +0700 Subject: [PATCH 15/16] =?UTF-8?q?=E0=B8=96=E0=B9=89=E0=B8=B2=E0=B9=84?= =?UTF-8?q?=E0=B8=A1=E0=B9=88=E0=B8=AA=E0=B9=88=E0=B8=87=E0=B9=83=E0=B8=8A?= =?UTF-8?q?=E0=B9=89=E0=B8=A3=E0=B8=B0=E0=B8=94=E0=B8=B1=E0=B8=9A=E0=B8=97?= =?UTF-8?q?=E0=B8=B5=E0=B9=88=E0=B8=82=E0=B8=AD=E0=B8=9B=E0=B8=A3=E0=B8=B0?= =?UTF-8?q?=E0=B9=80=E0=B8=A1=E0=B8=B4=E0=B8=99=E0=B8=AD=E0=B8=B1=E0=B8=99?= =?UTF-8?q?=E0=B9=80=E0=B8=94=E0=B8=B4=E0=B8=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/EvaluationController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 2bc1224..8205155 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -3102,7 +3102,7 @@ export class EvaluationController { evaluation.authorDoc2 = body.authorDoc2; evaluation.subjectDoc2 = body.subjectDoc2; evaluation.assignedPosition = body.assignedPosition; - evaluation.assignedPosLevel = body.assignedPosLevel ? body.assignedPosLevel : ""; + evaluation.assignedPosLevel = body.assignedPosLevel ? evaluation.assignedPosLevel : ""; evaluation.commanderFullnameDoc2 = body.commanderFullnameDoc2; evaluation.commanderOrgDoc2 = body.commanderOrgDoc2 ?? _null; evaluation.commanderOrgOldDoc2 = body.commanderOrgOldDoc2 ?? _null; From 3174f23a142c3b8b7b90c47427eab156b433d239 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 18 Jun 2025 10:45:27 +0700 Subject: [PATCH 16/16] fix --- src/controllers/EvaluationController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 8205155..d418233 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -3102,7 +3102,7 @@ export class EvaluationController { evaluation.authorDoc2 = body.authorDoc2; evaluation.subjectDoc2 = body.subjectDoc2; evaluation.assignedPosition = body.assignedPosition; - evaluation.assignedPosLevel = body.assignedPosLevel ? evaluation.assignedPosLevel : ""; + evaluation.assignedPosLevel = body.assignedPosLevel ? body.assignedPosLevel : evaluation.assignedPosLevel; evaluation.commanderFullnameDoc2 = body.commanderFullnameDoc2; evaluation.commanderOrgDoc2 = body.commanderOrgDoc2 ?? _null; evaluation.commanderOrgOldDoc2 = body.commanderOrgOldDoc2 ?? _null;