fix รายชื่อผู้รับสำเนาคำสั่งไม่แสดง

This commit is contained in:
Bright 2024-11-08 14:51:28 +07:00
parent d7c18c07df
commit f8672b081f

View file

@ -1520,6 +1520,7 @@ export class CommandController extends Controller {
lastName: string | null;
remarkVertical?: string | null;
remarkHorizontal?: string | null;
rootId?: string | null;
}[];
},
@Request() request: RequestWithUser,
@ -1690,6 +1691,45 @@ export class CommandController extends Controller {
commandSend.lastUpdateFullName = request.user.name;
commandSend.lastUpdatedAt = new Date();
await this.commandSendRepository.save(commandSend);
}),
);
const _posMasterNext = await this.posMasterRepository.find({
where: {
orgRootId: In(requestBody.persons
.filter((x) => x.rootId != undefined && x.rootId != null && x.rootId != "")
.map((x) => x.rootId)),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
isDirector: true,
current_holderId: Not(IsNull()),
},
relations: ["current_holder", "orgRoot"],
});
await Promise.all(
_posMasterNext.map(async (item) => {
const _commandSend = await this.commandSendRepository.findOne({
where: {
commandId: command.id,
profileId: item.current_holder.id,
},
});
if (_commandSend) return;
let commandSend = new CommandSend();
commandSend.citizenId = item.current_holder.citizenId;
commandSend.prefix = item.current_holder.prefix;
commandSend.firstName = item.current_holder.firstName;
commandSend.lastName = item.current_holder.lastName;
commandSend.position = item.current_holder.position;
commandSend.org = item.orgRoot.orgRootName;
commandSend.profileId = item.current_holder.id;
commandSend.commandId = command.id;
commandSend.createdUserId = request.user.sub;
commandSend.createdFullName = request.user.name;
commandSend.createdAt = new Date();
commandSend.lastUpdateUserId = request.user.sub;
commandSend.lastUpdateFullName = request.user.name;
commandSend.lastUpdatedAt = new Date();
await this.commandSendRepository.save(commandSend);
}),
);
}