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

@ -156,17 +156,16 @@ export class ProfileGovernmentHistoryController extends Controller {
});
const record = await this.profileRepo.findOne({
where: { id: profileId },
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: profileId,
},
@ -183,10 +182,6 @@ export class ProfileGovernmentHistoryController extends Controller {
where: {
positionIsSelected: true,
posMaster: {
// orgRevision: {
// orgRevisionIsCurrent: true,
// orgRevisionIsDraft: false,
// },
orgRevisionId: orgRevision?.id,
current_holderId: profileId,
},
@ -220,12 +215,24 @@ export class ProfileGovernmentHistoryController 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, //สังกัด
positionField: position == null ? null : position.positionField, //สายงาน
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, //ประเภท
posExecutive:
position == null || position.posExecutive == null