This commit is contained in:
parent
e92321d360
commit
8b46a2f0f2
1 changed files with 40 additions and 13 deletions
|
|
@ -85,7 +85,7 @@ export async function init() {
|
||||||
|
|
||||||
console.log("[AMQ] Listening for message...");
|
console.log("[AMQ] Listening for message...");
|
||||||
createConsumer(queue, channel, handler), //----> (3) Process Consumer
|
createConsumer(queue, channel, handler), //----> (3) Process Consumer
|
||||||
createConsumer(queue_org, channel, handler_org);
|
createConsumer(queue_org, channel, handler_org);
|
||||||
createConsumer(queue_org_draft, channel, handler_org_draft);
|
createConsumer(queue_org_draft, channel, handler_org_draft);
|
||||||
createConsumer(queue_command_noti, channel, handler_command_noti);
|
createConsumer(queue_command_noti, channel, handler_command_noti);
|
||||||
// createConsumer(queue2, channel, handler2);
|
// createConsumer(queue2, channel, handler2);
|
||||||
|
|
@ -561,6 +561,14 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
||||||
"positions.posExecutive",
|
"positions.posExecutive",
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const oldPosMasters = await repoPosmaster.find({
|
||||||
|
where: {
|
||||||
|
orgRevisionId: orgRevisionPublish!.id,
|
||||||
|
},
|
||||||
|
select: ['id', 'current_holderId', 'ancestorDNA']
|
||||||
|
});
|
||||||
|
|
||||||
// Task #2160 ดึง posMasterAssign ของ revision เดิม
|
// Task #2160 ดึง posMasterAssign ของ revision เดิม
|
||||||
const oldposMasterAssigns = await posMasterAssignRepository.find({
|
const oldposMasterAssigns = await posMasterAssignRepository.find({
|
||||||
relations: ["posMaster"],
|
relations: ["posMaster"],
|
||||||
|
|
@ -613,9 +621,20 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
||||||
posMasterIdMap.set(pm.ancestorDNA?.trim() ?? '', pm.id);
|
posMasterIdMap.set(pm.ancestorDNA?.trim() ?? '', pm.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const oldPosMasterMap = new Map<string, PosMaster>();
|
||||||
|
for (const oldPm of oldPosMasters) {
|
||||||
|
const dna = oldPm.ancestorDNA?.trim();
|
||||||
|
if (dna) {
|
||||||
|
oldPosMasterMap.set(dna, oldPm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const _null: any = null;
|
const _null: any = null;
|
||||||
for (const item of posMaster) {
|
for (const item of posMaster) {
|
||||||
|
|
||||||
|
const dna = item.ancestorDNA?.trim();
|
||||||
|
const oldPm = dna ? oldPosMasterMap.get(dna) : null;
|
||||||
|
|
||||||
// Task #2160 Clone posMasterAssign
|
// Task #2160 Clone posMasterAssign
|
||||||
const assigns = assignMap.get(item.ancestorDNA);
|
const assigns = assignMap.get(item.ancestorDNA);
|
||||||
if (assigns && assigns.length > 0) {
|
if (assigns && assigns.length > 0) {
|
||||||
|
|
@ -651,18 +670,26 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
||||||
await repoProfile.save(profile);
|
await repoProfile.save(profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
item.current_holderId = item.next_holderId;
|
// item.current_holderId = item.next_holderId;
|
||||||
// item.conditionReason = _null;
|
// item.next_holderId = null;
|
||||||
// if (item.current_holderId) {
|
// item.lastUpdateUserId = lastUpdateUserId;
|
||||||
// item.conditionReason = _null;
|
// item.lastUpdateFullName = lastUpdateFullName;
|
||||||
// item.isCondition = false;
|
// item.lastUpdatedAt = lastUpdatedAt;
|
||||||
// }
|
await repoPosmaster.update(item.id, {
|
||||||
item.next_holderId = null;
|
current_holderId: item.next_holderId,
|
||||||
item.lastUpdateUserId = lastUpdateUserId;
|
next_holderId: null,
|
||||||
item.lastUpdateFullName = lastUpdateFullName;
|
lastUpdateUserId,
|
||||||
item.lastUpdatedAt = lastUpdatedAt;
|
lastUpdateFullName,
|
||||||
await repoPosmaster.save(item).catch((e) => console.log(e));
|
lastUpdatedAt,
|
||||||
await CreatePosMasterHistoryOfficer(item.id, null);
|
});
|
||||||
|
|
||||||
|
const oldHolderId = oldPm ? oldPm.current_holderId : null;
|
||||||
|
const newHolderId = item ? item.next_holderId : null;
|
||||||
|
const isHolderChanged = oldHolderId !== newHolderId;
|
||||||
|
|
||||||
|
if (isHolderChanged) {
|
||||||
|
await CreatePosMasterHistoryOfficer(item.id, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const act of oldposMasterAct) {
|
for (const act of oldposMasterAct) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue