filter command-type

This commit is contained in:
Bright 2024-11-08 15:29:39 +07:00
parent f8672b081f
commit f825914ec2

View file

@ -1656,18 +1656,35 @@ export class CommandController extends Controller {
}, },
select: ["orgRootId"], select: ["orgRootId"],
}); });
let _posMaster : any
const _posMaster = await this.posMasterRepository.find({ if(["C-PM-38", "C-PM-40"].includes(commandCode)) {
where: { _posMaster = await this.posMasterRepository.find({
orgRootId: In(posMaster.map((x) => x.orgRootId)), where: {
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, orgRootId: In(posMaster.map((x) => x.orgRootId)),
isDirector: true, orgChild1: IsNull(),
current_holderId: Not(IsNull()), orgChild2: IsNull(),
}, orgChild3: IsNull(),
relations: ["current_holder", "orgRoot"], orgChild4: IsNull(),
}); orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
isDirector: true,
current_holderId: Not(IsNull()),
},
relations: ["current_holder", "orgRoot"],
});
}
else {
_posMaster = await this.posMasterRepository.find({
where: {
orgRootId: In(posMaster.map((x) => x.orgRootId)),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
isDirector: true,
current_holderId: Not(IsNull()),
},
relations: ["current_holder", "orgRoot"],
});
}
await Promise.all( await Promise.all(
_posMaster.map(async (item) => { _posMaster.map(async (item:any) => {
const _commandSend = await this.commandSendRepository.findOne({ const _commandSend = await this.commandSendRepository.findOne({
where: { where: {
commandId: command.id, commandId: command.id,