From d3534a30851f516b629acc0f88740da41f16df42 Mon Sep 17 00:00:00 2001 From: harid Date: Mon, 15 Dec 2025 17:05:36 +0700 Subject: [PATCH 1/2] =?UTF-8?q?fix=20=E0=B8=A3=E0=B8=B0=E0=B8=9A=E0=B8=9A?= =?UTF-8?q?=E0=B8=9E=E0=B8=B1=E0=B8=92=E0=B8=99=E0=B8=B2=20#2064,=20#2066,?= =?UTF-8?q?=20#2069,=20#2071?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/DevelopmentController.ts | 48 +++++----- .../DevelopmentEmployeeHistoryController.ts | 1 + .../DevelopmentScholarshipController.ts | 90 +++++++++++-------- src/controllers/ReportController.ts | 9 +- 4 files changed, 85 insertions(+), 63 deletions(-) diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 5522f9c..298c8a1 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -2952,8 +2952,8 @@ export class DevelopmentController extends Controller { const oldProfile: any = getDevelopment.developmentHistorys.find( (x) => x.citizenId == item["รหัสประจำตัวประชาชน"], ); - if (oldProfile != null) { - if (oldProfile.isDone == true) return; + if (oldProfile.length > 0) { + return; } if (item["ประเภท"] == undefined) return; let development = Object.assign(new DevelopmentHistory(), oldProfile); @@ -3202,30 +3202,28 @@ export class DevelopmentController extends Controller { let status = null; let _null: any = null; if (oldProfile != null) { - if (oldProfile.isDone == true) - throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ข้อมูลนี้ได้ถูกบันทึกแล้ว"); - oldProfile.dateStart = requestBody.dateStart == undefined ? _null : requestBody.dateStart; - oldProfile.dateEnd = requestBody.dateEnd == undefined ? _null : requestBody.dateEnd; - oldProfile.order = requestBody.commandNumber == undefined ? _null : requestBody.commandNumber; - oldProfile.dateOrder = - requestBody.commandDate == undefined ? _null : new Date(requestBody.commandDate); - oldProfile.trainingDays = - requestBody.trainingDays == undefined ? _null : requestBody.trainingDays; - oldProfile.createdUserId = request.user.sub; - oldProfile.createdFullName = request.user.name; - oldProfile.lastUpdateUserId = request.user.sub; - oldProfile.lastUpdateFullName = request.user.name; - oldProfile.createdAt = new Date(); - oldProfile.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(oldProfile, { data: request }); - setLogDataDiff(request, { before, after: oldProfile }); - status = oldProfile.isProfile; + throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ข้อมูลนี้ได้ถูกบันทึกแล้ว"); } + oldProfile.dateStart = requestBody.dateStart == undefined ? _null : requestBody.dateStart; + oldProfile.dateEnd = requestBody.dateEnd == undefined ? _null : requestBody.dateEnd; + oldProfile.order = requestBody.commandNumber == undefined ? _null : requestBody.commandNumber; + oldProfile.dateOrder = requestBody.commandDate == undefined ? _null : new Date(requestBody.commandDate); + oldProfile.trainingDays = requestBody.trainingDays == undefined ? _null : requestBody.trainingDays; + oldProfile.createdUserId = request.user.sub; + oldProfile.createdFullName = request.user.name; + oldProfile.lastUpdateUserId = request.user.sub; + oldProfile.lastUpdateFullName = request.user.name; + oldProfile.createdAt = new Date(); + oldProfile.lastUpdatedAt = new Date(); + // addLogSequence(request, { + // action: "database", + // status: "success", + // description: "Store DevelopmentHistory.", + // }); + await this.developmentHistoryRepository.save(oldProfile, { data: request }); + setLogDataDiff(request, { before, after: oldProfile }); + status = oldProfile.isProfile; + if (requestBody.type == "OFFICER") { await new CallAPI() diff --git a/src/controllers/DevelopmentEmployeeHistoryController.ts b/src/controllers/DevelopmentEmployeeHistoryController.ts index aeae26e..9fe87ae 100644 --- a/src/controllers/DevelopmentEmployeeHistoryController.ts +++ b/src/controllers/DevelopmentEmployeeHistoryController.ts @@ -260,6 +260,7 @@ export class DevelopmentEmployeeHistoryController extends Controller { .leftJoinAndSelect("developmentHistory.development", "development") .leftJoinAndSelect("developmentHistory.employeePosLevel", "employeePosLevel") .leftJoinAndSelect("developmentHistory.employeePosType", "employeePosType") + .where("developmentHistory.isProfile IS TRUE") .andWhere( body.year != 0 && body.year != null && body.year != undefined ? "development.year = :year" diff --git a/src/controllers/DevelopmentScholarshipController.ts b/src/controllers/DevelopmentScholarshipController.ts index fa3c5e9..57ec84c 100644 --- a/src/controllers/DevelopmentScholarshipController.ts +++ b/src/controllers/DevelopmentScholarshipController.ts @@ -170,6 +170,16 @@ export class DevelopmentScholarshipController extends Controller { _data = x; }) .catch((x) => {}); + + if (keyword && ["กำลังศึกษา", "เรียนไม่จบ", "เรียนจบ"].includes(keyword.trim())) { + const mapStatus: Record = { + "กำลังศึกษา": "PENDING", + "เรียนไม่จบ": "NOTGRADUATE", + "เรียนจบ": "GRADUATE", + }; + keyword = mapStatus[keyword.trim()]; + } + let query = await AppDataSource.getRepository(DevelopmentScholarship) .createQueryBuilder("developmentScholarship") .leftJoinAndSelect("developmentScholarship.posLevel", "posLevel") @@ -196,42 +206,50 @@ export class DevelopmentScholarshipController extends Controller { keyword: `%${keyword}%`, }, ) - .orWhere( - keyword != null && keyword != "" - ? "developmentScholarship.citizenId LIKE :keyword" - : "1=1", - { - keyword: `%${keyword}%`, - }, - ) - .orWhere( - keyword != null && keyword != "" - ? "developmentScholarship.position LIKE :keyword" - : "1=1", - { - keyword: `%${keyword}%`, - }, - ) - .orWhere( - keyword != null && keyword != "" - ? "developmentScholarship.posExecutive LIKE :keyword" - : "1=1", - { - keyword: `%${keyword}%`, - }, - ) - .orWhere( - keyword != null && keyword != "" ? "posType.posTypeName LIKE :keyword" : "1=1", - { - keyword: `%${keyword}%`, - }, - ) - .orWhere( - keyword != null && keyword != "" ? "posLevel.posLevelName LIKE :keyword" : "1=1", - { - keyword: `%${keyword}%`, - }, - ); + .orWhere( + keyword != null && keyword != "" + ? "developmentScholarship.citizenId LIKE :keyword" + : "1=1", + { + keyword: `%${keyword}%`, + }, + ) + .orWhere( + keyword != null && keyword != "" + ? "developmentScholarship.position LIKE :keyword" + : "1=1", + { + keyword: `%${keyword}%`, + }, + ) + .orWhere( + keyword != null && keyword != "" + ? "developmentScholarship.posExecutive LIKE :keyword" + : "1=1", + { + keyword: `%${keyword}%`, + }, + ) + .orWhere( + keyword != null && keyword != "" + ? "developmentScholarship.status LIKE :keyword" + : "1=1", + { + keyword: `${keyword}`, + }, + ) + .orWhere( + keyword != null && keyword != "" ? "posType.posTypeName LIKE :keyword" : "1=1", + { + keyword: `%${keyword}%`, + }, + ) + .orWhere( + keyword != null && keyword != "" ? "posLevel.posLevelName LIKE :keyword" : "1=1", + { + keyword: `%${keyword}%`, + }, + ); }), ) .andWhere( diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index e6b9826..d6307e1 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -658,13 +658,18 @@ export class ReportController extends Controller { : Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.graduatedDate)), graduatedReason: getDevelopment.graduatedReason == null ? "" : getDevelopment.graduatedReason, useOfficialTime: getDevelopment.useOfficialTime, - useOffTime: getDevelopment.useOfficialTime == "NOUSETIME" ? "🗹 ใช้ ☐ ไม่ใช้" : "☐ ใช้ 🗹 ไม่ใช้", + useOffTime: + getDevelopment.useOfficialTime == "NOUSETIME" + ? "☐ ใช้ 🗹 ไม่ใช้ เวลาราชการ" + : getDevelopment.useOfficialTime == "USETIME" + ? "🗹 ใช้ ☐ ไม่ใช้ เวลาราชการ" + : "🗹 ใช้ ☐ ไม่ใช้ เวลาราชการบางส่วน", isGraduated: getDevelopment.isGraduated, isG1: getDevelopment.isGraduated == true ? "🗹" : "☐", isG2: getDevelopment.isGraduated == true ? "☐" : "🗹", totalPeriod: getDevelopment.totalPeriod == null || getDevelopment.totalPeriod == "" - ? "" + ? "-" : Extension.ToThaiNumber(getDevelopment.totalPeriod), }; From 6a7082b5b146458386a89dfe1b8e67690329789b Mon Sep 17 00:00:00 2001 From: harid Date: Mon, 15 Dec 2025 17:50:54 +0700 Subject: [PATCH 2/2] revert #2064 --- src/controllers/DevelopmentController.ts | 47 +++++++++++++----------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 298c8a1..0649c2b 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -2952,8 +2952,8 @@ export class DevelopmentController extends Controller { const oldProfile: any = getDevelopment.developmentHistorys.find( (x) => x.citizenId == item["รหัสประจำตัวประชาชน"], ); - if (oldProfile.length > 0) { - return; + if (oldProfile != null) { + if (oldProfile.isDone == true) return; } if (item["ประเภท"] == undefined) return; let development = Object.assign(new DevelopmentHistory(), oldProfile); @@ -3204,26 +3204,29 @@ export class DevelopmentController extends Controller { if (oldProfile != null) { throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ข้อมูลนี้ได้ถูกบันทึกแล้ว"); } - oldProfile.dateStart = requestBody.dateStart == undefined ? _null : requestBody.dateStart; - oldProfile.dateEnd = requestBody.dateEnd == undefined ? _null : requestBody.dateEnd; - oldProfile.order = requestBody.commandNumber == undefined ? _null : requestBody.commandNumber; - oldProfile.dateOrder = requestBody.commandDate == undefined ? _null : new Date(requestBody.commandDate); - oldProfile.trainingDays = requestBody.trainingDays == undefined ? _null : requestBody.trainingDays; - oldProfile.createdUserId = request.user.sub; - oldProfile.createdFullName = request.user.name; - oldProfile.lastUpdateUserId = request.user.sub; - oldProfile.lastUpdateFullName = request.user.name; - oldProfile.createdAt = new Date(); - oldProfile.lastUpdatedAt = new Date(); - // addLogSequence(request, { - // action: "database", - // status: "success", - // description: "Store DevelopmentHistory.", - // }); - await this.developmentHistoryRepository.save(oldProfile, { data: request }); - setLogDataDiff(request, { before, after: oldProfile }); - status = oldProfile.isProfile; - + if (oldProfile != null) { + if (oldProfile.isDone == true) + throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ข้อมูลนี้ได้ถูกบันทึกแล้ว"); + oldProfile.dateStart = requestBody.dateStart == undefined ? _null : requestBody.dateStart; + oldProfile.dateEnd = requestBody.dateEnd == undefined ? _null : requestBody.dateEnd; + oldProfile.order = requestBody.commandNumber == undefined ? _null : requestBody.commandNumber; + oldProfile.dateOrder = requestBody.commandDate == undefined ? _null : new Date(requestBody.commandDate); + oldProfile.trainingDays = requestBody.trainingDays == undefined ? _null : requestBody.trainingDays; + oldProfile.createdUserId = request.user.sub; + oldProfile.createdFullName = request.user.name; + oldProfile.lastUpdateUserId = request.user.sub; + oldProfile.lastUpdateFullName = request.user.name; + oldProfile.createdAt = new Date(); + oldProfile.lastUpdatedAt = new Date(); + // addLogSequence(request, { + // action: "database", + // status: "success", + // description: "Store DevelopmentHistory.", + // }); + await this.developmentHistoryRepository.save(oldProfile, { data: request }); + setLogDataDiff(request, { before, after: oldProfile }); + status = oldProfile.isProfile; + } if (requestBody.type == "OFFICER") { await new CallAPI()