This commit is contained in:
Bright 2025-05-22 15:05:54 +07:00
parent fc92c378e8
commit fa7445275b
5 changed files with 71 additions and 65 deletions

View file

@ -148,17 +148,16 @@ export class ProfileGovernmentEmployeeController extends Controller {
});
const record = await this.profileEmployeeRepo.findOne({
where: { id: profileEmployeeId },
relations: {
posType: true,
posLevel: true,
},
relations: ["posType", "posLevel", "profileSalary"],
order: {
profileSalary: {
order: "DESC",
createdAt: "DESC"
}
}
});
const posMaster = await this.posMasterRepo.findOne({
where: {
// orgRevision: {
// orgRevisionIsCurrent: true,
// orgRevisionIsDraft: false,
// },
orgRevisionId: orgRevision?.id,
current_holderId: profileEmployeeId,
},
@ -171,20 +170,6 @@ export class ProfileGovernmentEmployeeController extends Controller {
orgChild4: true,
},
});
const position = await this.positionRepo.findOne({
where: {
positionIsSelected: true,
posMaster: {
// orgRevision: {
// orgRevisionIsCurrent: true,
// orgRevisionIsDraft: false,
// },
orgRevisionId: orgRevision?.id,
current_holderId: profileEmployeeId,
},
},
order: { createdAt: "DESC" },
});
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const fullNameParts = [
@ -209,14 +194,26 @@ export class ProfileGovernmentEmployeeController extends Controller {
orgShortName = posMaster.orgChild4?.orgChild4ShortName;
}
}
const _OrgLeave = [
record.profileSalary.length > 0 ? record.profileSalary[0].orgChild4 : null,
record.profileSalary.length > 0 ? record.profileSalary[0].orgChild3 : null,
record.profileSalary.length > 0 ? record.profileSalary[0].orgChild2 : null,
record.profileSalary.length > 0 ? record.profileSalary[0].orgChild1 : null,
record.profileSalary.length > 0 ? record.profileSalary[0].orgRoot : null,
];
const orgLeave = _OrgLeave.filter((x) => x !== undefined && x !== null).join("\n");
const data = {
org: org, //สังกัด
org: record.isLeave == false ? org : orgLeave, //สังกัด
position: record.position, //ตำแหน่ง
posLevel:
record.posLevel == null
? null
: `${record?.posType?.posTypeShortName ?? ""} ${record?.posLevel?.posLevelName ?? ""}`, //ระดับ
posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`, //เลขที่ตำแหน่ง
posMasterNo: record.isLeave == false
? posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`
: record.profileSalary.length > 0
? `${record.profileSalary[0].posNoAbb} ${record.profileSalary[0].posNo}`
: null, //เลขที่ตำแหน่ง
posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท
dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate), //วันเกษียณ
dateAppoint: record.dateAppoint, //วันที่สั่งบรรจุ