Fix ทะเบียนประวัติแบบย่อ กรณีพ้นสภาพไม่แสดงสำนัก & เลขที่ตำแหน่ง #1673

This commit is contained in:
Bright 2025-07-24 17:22:47 +07:00
parent c297572c79
commit 354dd4399b
2 changed files with 158 additions and 34 deletions

View file

@ -16,6 +16,7 @@ import {
} from "../interfaces/utils";
import permission from "../interfaces/permission";
import { OrgRevision } from "../entities/OrgRevision";
import { In } from "typeorm";
@Route("api/v1/org/profile/government")
@Tags("ProfileGovernment")
@Security("bearerAuth")
@ -155,7 +156,27 @@ export class ProfileGovernmentHistoryController extends Controller {
},
});
const record = await this.profileRepo.findOne({
where: { id: profileId },
where: {
id: profileId,
profileSalary: {
commandCode: In([
"0",
"9",
"1",
"2",
"3",
"4",
"8",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
]),
}
},
relations: ["posType", "posLevel", "profileSalary"],
order: {
profileSalary: {
@ -215,14 +236,17 @@ 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");
let _OrgLeave:any = []
if (record?.isLeave && record?.profileSalary.length > 0) {
_OrgLeave = [
record?.profileSalary[0].orgChild4 ? record?.profileSalary[0].orgChild4 : null,
record?.profileSalary[0].orgChild3 ? record?.profileSalary[0].orgChild3 : null,
record?.profileSalary[0].orgChild2 ? record?.profileSalary[0].orgChild2 : null,
record?.profileSalary[0].orgChild1 ? record?.profileSalary[0].orgChild1 : null,
record?.profileSalary[0].orgRoot ? record?.profileSalary[0].orgRoot : null,
];
}
const orgLeave = _OrgLeave.filter((x:any) => x !== undefined && x !== null).join("\n");
const data = {
org: record.isLeave == false ? org : orgLeave, //สังกัด
positionField: position == null ? null : position.positionField, //สายงาน
@ -264,11 +288,38 @@ export class ProfileGovernmentHistoryController extends Controller {
},
});
const record = await this.profileRepo.findOne({
where: { id: profileId },
where: {
id: profileId,
profileSalary: {
commandCode: In([
"0",
"9",
"1",
"2",
"3",
"4",
"8",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
]),
}
},
relations: {
posType: true,
posLevel: true,
profileSalary: true
},
order: {
profileSalary: {
order: "DESC",
createdAt: "DESC"
}
}
});
const posMaster = await this.posMasterRepo.findOne({
where: {
@ -321,12 +372,30 @@ export class ProfileGovernmentHistoryController extends Controller {
orgShortName = posMaster.orgChild4?.orgChild4ShortName;
}
}
let _OrgLeave:any = []
if (record?.isLeave && record?.profileSalary.length > 0) {
_OrgLeave = [
record?.profileSalary[0].orgChild4 ? record?.profileSalary[0].orgChild4 : null,
record?.profileSalary[0].orgChild3 ? record?.profileSalary[0].orgChild3 : null,
record?.profileSalary[0].orgChild2 ? record?.profileSalary[0].orgChild2 : null,
record?.profileSalary[0].orgChild1 ? record?.profileSalary[0].orgChild1 : null,
record?.profileSalary[0].orgRoot ? record?.profileSalary[0].orgRoot : null,
];
}
const orgLeave = _OrgLeave.filter((x:any) => 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
@ -343,6 +412,7 @@ export class ProfileGovernmentHistoryController extends Controller {
govAgeAbsent: record.govAgeAbsent,
govAgePlus: record.govAgePlus,
reasonSameDate: record.reasonSameDate,
isLeave: record.isLeave
};
return new HttpSuccess(data);