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);

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-employee/government")
@Tags("ProfileEmployeeGovernment")
@Security("bearerAuth")
@ -147,7 +148,27 @@ export class ProfileGovernmentEmployeeController extends Controller {
},
});
const record = await this.profileEmployeeRepo.findOne({
where: { id: profileEmployeeId },
where: {
id: profileEmployeeId,
profileSalary: {
commandCode: In([
"0",
"9",
"1",
"2",
"3",
"4",
"8",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
]),
}
},
relations: ["posType", "posLevel", "profileSalary"],
order: {
profileSalary: {
@ -194,14 +215,17 @@ 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");
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, //สังกัด
position: record.position, //ตำแหน่ง
@ -239,10 +263,31 @@ export class ProfileGovernmentEmployeeController extends Controller {
},
});
const record = await this.profileEmployeeRepo.findOne({
where: { id: profileEmployeeId },
where: {
id: profileEmployeeId,
profileSalary:{
commandCode: In([
"0",
"9",
"1",
"2",
"3",
"4",
"8",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
]),
}
},
relations: {
posType: true,
posLevel: true,
profileSalary: true
},
});
const posMaster = await this.posMasterRepo.findOne({
@ -259,16 +304,6 @@ export class ProfileGovernmentEmployeeController extends Controller {
orgChild4: true,
},
});
const position = await this.positionRepo.findOne({
where: {
positionIsSelected: true,
posMaster: {
orgRevisionId: orgRevision?.id,
current_holderId: profileEmployeeId,
},
},
order: { createdAt: "DESC" },
});
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const fullNameParts = [
@ -293,13 +328,31 @@ export class ProfileGovernmentEmployeeController 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, //สังกัด
position: record.position, //ตำแหน่ง
posLevel: record.posLevel == null && record.posType == 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, //วันที่สั่งบรรจุ
@ -311,6 +364,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
govAgeAbsent: record.govAgeAbsent ?? null, // ขาดราชการ
govAgePlus: record.govAgePlus, // อายุราชการเกื้อกูล
dateRetireLaw: record.dateRetireLaw ?? null, // วันที่เกษียฯอายุราชการตามกฎหมาย
isLeave: record.isLeave
};
return new HttpSuccess(data);
}