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"],
});
const _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"],
});
let _posMaster : any
if(["C-PM-38", "C-PM-40"].includes(commandCode)) {
_posMaster = await this.posMasterRepository.find({
where: {
orgRootId: In(posMaster.map((x) => x.orgRootId)),
orgChild1: IsNull(),
orgChild2: IsNull(),
orgChild3: IsNull(),
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(
_posMaster.map(async (item) => {
_posMaster.map(async (item:any) => {
const _commandSend = await this.commandSendRepository.findOne({
where: {
commandId: command.id,