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

@ -40,17 +40,16 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
}
const record = await this.profileEmployeeRepo.findOne({
where: { id: profile.id },
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: profile.id,
},
@ -63,19 +62,6 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
orgChild4: true,
},
});
// const position = await this.positionRepo.findOne({
// where: {
// positionIsSelected: true,
// posMaster: {
// orgRevision: {
// orgRevisionIsCurrent: true,
// orgRevisionIsDraft: false,
// },
// current_holderId: profile.id,
// },
// },
// order: { createdAt: "DESC" },
// });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const fullNameParts = [
@ -100,11 +86,23 @@ export class ProfileGovernmentEmployeeTempController 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.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),
dateRetireLaw: record.dateRetireLaw ?? null,