Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
All checks were successful
Build & Deploy on Dev / build (push) Successful in 49s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 49s
* 'develop' of github.com:Frappet/bma-ehr-organization: #2166
This commit is contained in:
commit
d7164b603a
1 changed files with 40 additions and 13 deletions
|
|
@ -85,7 +85,7 @@ export async function init() {
|
|||
|
||||
console.log("[AMQ] Listening for message...");
|
||||
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_command_noti, channel, handler_command_noti);
|
||||
// createConsumer(queue2, channel, handler2);
|
||||
|
|
@ -561,6 +561,14 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
"positions.posExecutive",
|
||||
],
|
||||
});
|
||||
|
||||
const oldPosMasters = await repoPosmaster.find({
|
||||
where: {
|
||||
orgRevisionId: orgRevisionPublish!.id,
|
||||
},
|
||||
select: ['id', 'current_holderId', 'ancestorDNA']
|
||||
});
|
||||
|
||||
// Task #2160 ดึง posMasterAssign ของ revision เดิม
|
||||
const oldposMasterAssigns = await posMasterAssignRepository.find({
|
||||
relations: ["posMaster"],
|
||||
|
|
@ -613,9 +621,20 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
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;
|
||||
for (const item of posMaster) {
|
||||
|
||||
const dna = item.ancestorDNA?.trim();
|
||||
const oldPm = dna ? oldPosMasterMap.get(dna) : null;
|
||||
|
||||
// Task #2160 Clone posMasterAssign
|
||||
const assigns = assignMap.get(item.ancestorDNA);
|
||||
if (assigns && assigns.length > 0) {
|
||||
|
|
@ -651,18 +670,26 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
await repoProfile.save(profile);
|
||||
}
|
||||
}
|
||||
item.current_holderId = item.next_holderId;
|
||||
// item.conditionReason = _null;
|
||||
// if (item.current_holderId) {
|
||||
// item.conditionReason = _null;
|
||||
// item.isCondition = false;
|
||||
// }
|
||||
item.next_holderId = null;
|
||||
item.lastUpdateUserId = lastUpdateUserId;
|
||||
item.lastUpdateFullName = lastUpdateFullName;
|
||||
item.lastUpdatedAt = lastUpdatedAt;
|
||||
await repoPosmaster.save(item).catch((e) => console.log(e));
|
||||
await CreatePosMasterHistoryOfficer(item.id, null);
|
||||
// item.current_holderId = item.next_holderId;
|
||||
// item.next_holderId = null;
|
||||
// item.lastUpdateUserId = lastUpdateUserId;
|
||||
// item.lastUpdateFullName = lastUpdateFullName;
|
||||
// item.lastUpdatedAt = lastUpdatedAt;
|
||||
await repoPosmaster.update(item.id, {
|
||||
current_holderId: item.next_holderId,
|
||||
next_holderId: null,
|
||||
lastUpdateUserId,
|
||||
lastUpdateFullName,
|
||||
lastUpdatedAt,
|
||||
});
|
||||
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue