salary-leave-discipline

This commit is contained in:
mamoss 2025-04-08 18:00:05 +07:00
parent a56ba50954
commit e2ca88a988

View file

@ -3743,6 +3743,13 @@ export class CommandController extends Controller {
commandCode?: string | null; commandCode?: string | null;
commandName?: string | null; commandName?: string | null;
remark: string | null; remark: string | null;
orgRoot?: string | null;
orgChild1?: string | null;
orgChild2?: string | null;
orgChild3?: string | null;
orgChild4?: string | null;
posNo?: string | null;
posNoAbb?: string | null;
}[]; }[];
}, },
) { ) {
@ -3778,41 +3785,41 @@ export class CommandController extends Controller {
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
}, },
}); });
const orgRevisionRef = // const orgRevisionRef =
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; // profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
const orgRootRef = orgRevisionRef?.orgRoot ?? null; // const orgRootRef = orgRevisionRef?.orgRoot ?? null;
const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; // const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; // const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; // const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; // const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
const shortName = // const shortName =
!profile.current_holders || profile.current_holders.length == 0 // !profile.current_holders || profile.current_holders.length == 0
? null // ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && // : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) // profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild4 != null // ?.orgChild4 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}` // ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && // : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) // profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild3 != null // ?.orgChild3 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}` // ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != // : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
null && // null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) // profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild2 != null // ?.orgChild2 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}` // ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != // : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
null && // null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) // profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild1 != null // ?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}` // ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != // : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
null && // null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) // profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgRoot != null // ?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}` // ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}`
: null; // : null;
const posNo = `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`; // const posNo = `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`;
let position = let position =
profile.current_holders profile.current_holders
.filter((x) => x.orgRevisionId == orgRevision?.id)[0] .filter((x) => x.orgRevisionId == orgRevision?.id)[0]
@ -3837,11 +3844,11 @@ export class CommandController extends Controller {
? profile.profileSalary[0].order + 1 ? profile.profileSalary[0].order + 1
: 1 : 1
: null, : null,
orgRoot: orgRootRef?.orgRootName ?? null, orgRoot: item.orgRoot,
orgChild1: orgChild1Ref?.orgChild1Name ?? null, orgChild1: item.orgChild1,
orgChild2: orgChild2Ref?.orgChild2Name ?? null, orgChild2: item.orgChild2,
orgChild3: orgChild3Ref?.orgChild3Name ?? null, orgChild3: item.orgChild3,
orgChild4: orgChild4Ref?.orgChild4Name ?? null, orgChild4: item.orgChild4,
createdUserId: req.user.sub, createdUserId: req.user.sub,
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
@ -3852,8 +3859,8 @@ export class CommandController extends Controller {
isGovernment: item.isGovernment, isGovernment: item.isGovernment,
commandNo: item.commandNo, commandNo: item.commandNo,
commandYear: item.commandYear, commandYear: item.commandYear,
posNo: posNo ?? null, posNo: item.posNo,
posNoAbb: shortName ?? null, posNoAbb: item.posNoAbb,
commandDateAffect: item.commandDateAffect, commandDateAffect: item.commandDateAffect,
commandDateSign: item.commandDateSign, commandDateSign: item.commandDateSign,
commandCode: item.commandCode, commandCode: item.commandCode,
@ -3965,47 +3972,47 @@ export class CommandController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
} }
const orgRevision = await this.orgRevisionRepo.findOne({ // const orgRevision = await this.orgRevisionRepo.findOne({
where: { // where: {
orgRevisionIsCurrent: true, // orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, // orgRevisionIsDraft: false,
}, // },
}); // });
const orgRevisionRef = // const orgRevisionRef =
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; // profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
const orgRootRef = orgRevisionRef?.orgRoot ?? null; // const orgRootRef = orgRevisionRef?.orgRoot ?? null;
const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; // const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; // const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; // const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; // const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
const shortName = // const shortName =
!profile.current_holders || profile.current_holders.length == 0 // !profile.current_holders || profile.current_holders.length == 0
? null // ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && // : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) // profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild4 != null // ?.orgChild4 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}` // ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && // : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) // profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild3 != null // ?.orgChild3 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}` // ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != // : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
null && // null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) // profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild2 != null // ?.orgChild2 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}` // ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != // : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
null && // null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) // profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild1 != null // ?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}` // ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != // : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
null && // null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) // profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgRoot != null // ?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}` // ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}`
: null; // : null;
const posNo = `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`; // const posNo = `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`;
// let position = // let position =
// profile.current_holders // profile.current_holders
// .filter((x) => x.orgRevisionId == orgRevision?.id)[0] // .filter((x) => x.orgRevisionId == orgRevision?.id)[0]
@ -4028,11 +4035,11 @@ export class CommandController extends Controller {
? profile.profileSalary[0].order + 1 ? profile.profileSalary[0].order + 1
: 1 : 1
: null, : null,
orgRoot: orgRootRef?.orgRootName ?? null, orgRoot: item.orgRoot,
orgChild1: orgChild1Ref?.orgChild1Name ?? null, orgChild1: item.orgChild1,
orgChild2: orgChild2Ref?.orgChild2Name ?? null, orgChild2: item.orgChild2,
orgChild3: orgChild3Ref?.orgChild3Name ?? null, orgChild3: item.orgChild3,
orgChild4: orgChild4Ref?.orgChild4Name ?? null, orgChild4: item.orgChild4,
createdUserId: req.user.sub, createdUserId: req.user.sub,
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
@ -4043,8 +4050,8 @@ export class CommandController extends Controller {
isGovernment: item.isGovernment, isGovernment: item.isGovernment,
commandNo: item.commandNo, commandNo: item.commandNo,
commandYear: item.commandYear, commandYear: item.commandYear,
posNo: posNo ?? null, posNo: item.posNo,
posNoAbb: shortName ?? null, posNoAbb: item.posNoAbb,
commandDateAffect: item.commandDateAffect, commandDateAffect: item.commandDateAffect,
commandDateSign: item.commandDateSign, commandDateSign: item.commandDateSign,
commandCode: item.commandCode, commandCode: item.commandCode,
@ -4170,6 +4177,13 @@ export class CommandController extends Controller {
commandCode?: string | null; commandCode?: string | null;
commandName?: string | null; commandName?: string | null;
remark: string | null; remark: string | null;
orgRoot?: string | null;
orgChild1?: string | null;
orgChild2?: string | null;
orgChild3?: string | null;
orgChild4?: string | null;
posNo?: string | null;
posNoAbb?: string | null;
}[]; }[];
}, },
) { ) {
@ -4198,46 +4212,46 @@ export class CommandController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
} }
const orgRevision = await this.orgRevisionRepo.findOne({ // const orgRevision = await this.orgRevisionRepo.findOne({
where: { // where: {
orgRevisionIsCurrent: true, // orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, // orgRevisionIsDraft: false,
}, // },
}); // });
const orgRevisionRef = // const orgRevisionRef =
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null; // profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
const orgRootRef = orgRevisionRef?.orgRoot ?? null; // const orgRootRef = orgRevisionRef?.orgRoot ?? null;
const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null; // const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null; // const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null; // const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null; // const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
const shortName = // const shortName =
!profile.current_holders || profile.current_holders.length == 0 // !profile.current_holders || profile.current_holders.length == 0
? null // ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && // : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) // profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild4 != null // ?.orgChild4 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}` // ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4.orgChild4ShortName}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && // : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) // profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild3 != null // ?.orgChild3 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}` // ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3.orgChild3ShortName}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null && // : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) // profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild2 != null // ?.orgChild2 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}` // ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2.orgChild2ShortName}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != // : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
null && // null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) // profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgChild1 != null // ?.orgChild1 != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}` // ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1.orgChild1ShortName}`
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) != // : profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) !=
null && // null &&
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) // profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)
?.orgRoot != null // ?.orgRoot != null
? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}` // ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot.orgRootShortName}`
: null; // : null;
const posNo = `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`; // const posNo = `${profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.posMasterNo}`;
// let position = // let position =
// profile.current_holders // profile.current_holders
// .filter((x) => x.orgRevisionId == orgRevision?.id)[0] // .filter((x) => x.orgRevisionId == orgRevision?.id)[0]
@ -4260,11 +4274,11 @@ export class CommandController extends Controller {
? profile.profileSalary[0].order + 1 ? profile.profileSalary[0].order + 1
: 1 : 1
: null, : null,
orgRoot: orgRootRef?.orgRootName ?? null, orgRoot: item.orgRoot,
orgChild1: orgChild1Ref?.orgChild1Name ?? null, orgChild1: item.orgChild1,
orgChild2: orgChild2Ref?.orgChild2Name ?? null, orgChild2: item.orgChild2,
orgChild3: orgChild3Ref?.orgChild3Name ?? null, orgChild3: item.orgChild3,
orgChild4: orgChild4Ref?.orgChild4Name ?? null, orgChild4: item.orgChild4,
createdUserId: req.user.sub, createdUserId: req.user.sub,
createdFullName: req.user.name, createdFullName: req.user.name,
lastUpdateUserId: req.user.sub, lastUpdateUserId: req.user.sub,
@ -4275,8 +4289,8 @@ export class CommandController extends Controller {
isGovernment: item.isGovernment, isGovernment: item.isGovernment,
commandNo: item.commandNo, commandNo: item.commandNo,
commandYear: item.commandYear, commandYear: item.commandYear,
posNo: posNo, posNo: item.posNo,
posNoAbb: shortName, posNoAbb: item.posNoAbb,
commandDateAffect: item.commandDateAffect, commandDateAffect: item.commandDateAffect,
commandDateSign: item.commandDateSign, commandDateSign: item.commandDateSign,
commandCode: item.commandCode, commandCode: item.commandCode,