Merge branch 'develop' into adiDev
This commit is contained in:
commit
ea93a223b1
1 changed files with 19 additions and 6 deletions
|
|
@ -782,8 +782,9 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
||||||
// 2. Batch load profiles ทั้งหมดในครั้งเดียว (แก้ปัญหา N+1 Query)
|
// 2. Batch load profiles ทั้งหมดในครั้งเดียว (แก้ปัญหา N+1 Query)
|
||||||
const profilesMap = new Map<string, Profile>();
|
const profilesMap = new Map<string, Profile>();
|
||||||
if (profileIds.length > 0) {
|
if (profileIds.length > 0) {
|
||||||
const profiles = await repoProfile.findBy({
|
const profiles = await repoProfile.find({
|
||||||
id: In(profileIds),
|
where: { id: In(profileIds) },
|
||||||
|
relations: ["posType", "posLevel"],
|
||||||
});
|
});
|
||||||
profiles.forEach((p) => profilesMap.set(p.id, p));
|
profiles.forEach((p) => profilesMap.set(p.id, p));
|
||||||
}
|
}
|
||||||
|
|
@ -878,6 +879,18 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
||||||
item.orgRoot?.orgRootShortName,
|
item.orgRoot?.orgRootShortName,
|
||||||
].find((name) => typeof name === "string" && name.trim().length > 0) ?? _null;
|
].find((name) => typeof name === "string" && name.trim().length > 0) ?? _null;
|
||||||
|
|
||||||
|
// ถ้าเป็นตำแหน่งนั่งทับ (isSit = true) และมีคนครอง ใช้ตำแหน่งจาก profile แทน
|
||||||
|
let positionName = selectedPosition?.positionName ?? _null;
|
||||||
|
let posTypeName = selectedPosition?.posType?.posTypeName ?? _null;
|
||||||
|
let posLevelName = selectedPosition?.posLevel?.posLevelName ?? _null;
|
||||||
|
let posExecutiveName = selectedPosition?.posExecutive?.posExecutiveName ?? _null;
|
||||||
|
if (item.isSit && nextHolderProfile) {
|
||||||
|
positionName = nextHolderProfile.position ?? _null;
|
||||||
|
posTypeName = nextHolderProfile.posType?.posTypeName ?? _null;
|
||||||
|
posLevelName = nextHolderProfile.posLevel?.posLevelName ?? _null;
|
||||||
|
posExecutiveName = nextHolderProfile.posExecutive ?? _null;
|
||||||
|
}
|
||||||
|
|
||||||
historyRowsToSave.push({
|
historyRowsToSave.push({
|
||||||
ancestorDNA: item.ancestorDNA ? item.ancestorDNA : _null,
|
ancestorDNA: item.ancestorDNA ? item.ancestorDNA : _null,
|
||||||
prefix: nextHolderProfile?.prefix || _null,
|
prefix: nextHolderProfile?.prefix || _null,
|
||||||
|
|
@ -887,10 +900,10 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
||||||
posMasterNoPrefix: item.posMasterNoPrefix ?? _null,
|
posMasterNoPrefix: item.posMasterNoPrefix ?? _null,
|
||||||
posMasterNo: item.posMasterNo ?? _null,
|
posMasterNo: item.posMasterNo ?? _null,
|
||||||
posMasterNoSuffix: item.posMasterNoSuffix ?? _null,
|
posMasterNoSuffix: item.posMasterNoSuffix ?? _null,
|
||||||
position: selectedPosition?.positionName ?? _null,
|
position: positionName,
|
||||||
posType: selectedPosition?.posType?.posTypeName ?? _null,
|
posType: posTypeName,
|
||||||
posLevel: selectedPosition?.posLevel?.posLevelName ?? _null,
|
posLevel: posLevelName,
|
||||||
posExecutive: selectedPosition?.posExecutive?.posExecutiveName ?? _null,
|
posExecutive: posExecutiveName,
|
||||||
profileId: _null,
|
profileId: _null,
|
||||||
rootDnaId: item.orgRoot?.ancestorDNA || _null,
|
rootDnaId: item.orgRoot?.ancestorDNA || _null,
|
||||||
child1DnaId: item.orgChild1?.ancestorDNA || _null,
|
child1DnaId: item.orgChild1?.ancestorDNA || _null,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue