From 0ce9846044d0df1ee12fe274910755241fd02ea2 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 28 Apr 2025 14:46:24 +0700 Subject: [PATCH] update issue #1436 (fix report kk1) --- src/controllers/ProfileController.ts | 80 +++++++++++++++++----------- 1 file changed, 48 insertions(+), 32 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 8051625c..103b8fb2 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -83,6 +83,7 @@ import { OrgChild2 } from "../entities/OrgChild2"; import { OrgChild3 } from "../entities/OrgChild3"; import { OrgChild4 } from "../entities/OrgChild4"; import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory"; +import { ProfileAssistance } from "../entities/ProfileAssistance"; @Route("api/v1/org/profile") @Tags("Profile") @@ -134,6 +135,7 @@ export class ProfileController extends Controller { private profileAssessmentsRepository = AppDataSource.getRepository(ProfileAssessment); private profileAbilityRepo = AppDataSource.getRepository(ProfileAbility); private permissionProflileRepository = AppDataSource.getRepository(PermissionProfile); + private profileAssistanceRepository = AppDataSource.getRepository(ProfileAssistance); /** * report ประวัติแบบย่อ ข้าราชการ @@ -1073,7 +1075,7 @@ export class ProfileController extends Controller { }, ]; const training_raw = await this.trainingRepository.find({ - select: ["startDate", "endDate", "place", "department", "name"], + select: ["place", "department", "name", "duration"], where: { profileId: id }, order: { createdAt: "ASC" }, }); @@ -1081,36 +1083,21 @@ export class ProfileController extends Controller { training_raw.length > 0 ? training_raw.map((item) => ({ institute: item.department ?? "", - start: - item.startDate == null - ? "" - : Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate)), - end: - item.endDate == null - ? "" - : Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate)), - date: - item.startDate && item.endDate - ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` - : "", - level: "", - degree: item.name, - field: "", + degree: item.name ? Extension.ToThaiNumber(item.name) : "", + place: item.place ? Extension.ToThaiNumber(item.place) : "", + duration: item.duration ? Extension.ToThaiNumber(item.duration) : "", })) : [ { institute: "-", - start: "-", - end: "-", - date: "-", - level: "-", degree: "-", - field: "-", + place: "-", + duration: "-" }, ]; const discipline_raw = await this.disciplineRepository.find({ - select: ["refCommandDate", "refCommandNo", "detail"], + select: ["refCommandDate", "refCommandNo", "detail", "level"], where: { profileId: id }, order: { createdAt: "ASC" }, }); @@ -1251,6 +1238,7 @@ export class ProfileController extends Controller { refCommandDate: item.refCommandDate ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.refCommandDate)) : "", + note: item.note ? Extension.ToThaiNumber(item.note) : "", })) : [ { @@ -1453,10 +1441,17 @@ export class ProfileController extends Controller { ]; const actposition_raw = await this.profileActpositionRepo.find({ + select: ["dateStart", "dateEnd", "position"], where: { profileId: id }, order: { createdAt: "ASC" }, }); - const actposition = + const assistance_raw = await this.profileAssistanceRepository.find({ + select: ["dateStart", "dateEnd", "commandName", "agency", "document"], + where: { profileId: id }, + order: { createdAt: "ASC" }, + }); + + const _actposition = actposition_raw.length > 0 ? actposition_raw.map((item) => ({ date: item.dateStart @@ -1464,22 +1459,43 @@ export class ProfileController extends Controller { : "" + item.dateEnd ? " - " + Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateEnd)) : "", - refCommandDate: item.refCommandDate - ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.refCommandDate)) - : "", - refCommandNo: item.refCommandNo ? Extension.ToThaiNumber(item.refCommandNo) : "", - position: item.position, - posNo: item.posNo, + position: item.position ? Extension.ToThaiNumber(item.position) : "", + commandName: "รักษาการในตำแหน่ง", + agency: "", + document: "" })) : [ { date: "-", - refCommandDate: "-", - refCommandNo: "-", position: "-", - posNo: "-", + commandName: "-", + agency: "-", + document: "-" }, ]; + const _assistance = + assistance_raw.length > 0 + ? assistance_raw.map((item) => ({ + date: item.dateStart + ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateStart)) + : "" + item.dateEnd + ? " - " + Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateEnd)) + : "", + position: "", + commandName: item.commandName ? Extension.ToThaiNumber(item.commandName): "", + agency: item.agency ? Extension.ToThaiNumber(item.agency): "", + document: item.document ? Extension.ToThaiNumber(item.document): "", + })) + : [ + { + date: "-", + position: "-", + commandName: "-", + agency: "-", + document: "-" + }, + ]; + const actposition = [..._actposition, ..._assistance] const duty_raw = await this.dutyRepository.find({ where: { profileId: id }, order: { createdAt: "ASC" },