no message

This commit is contained in:
Kittapath 2024-02-06 16:23:33 +07:00
parent 0d27451e16
commit 523991674c
2 changed files with 63 additions and 45 deletions

View file

@ -879,28 +879,35 @@ export class OrganizationController extends Controller {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootName: orgRoot.orgRootName, orgRootName: orgRoot.orgRootName,
totalPosition: await this.posMasterRepository.count({ totalPosition: await this.posMasterRepository.count({
where: { orgChild3Id: orgChild3.id }, where: {
orgRevisionId: orgRoot.orgRevisionId,
orgChild3Id: orgChild3.id,
},
}), }),
totalPositionCurrentUse: await this.posMasterRepository.count({ totalPositionCurrentUse: await this.posMasterRepository.count({
where: { where: {
orgRevisionId: orgRoot.orgRevisionId,
orgChild3Id: orgChild3.id, orgChild3Id: orgChild3.id,
current_holderId: Not(IsNull()) || Not(""), current_holderId: Not(IsNull()) || Not(""),
}, },
}), }),
totalPositionCurrentVacant: await this.posMasterRepository.count({ totalPositionCurrentVacant: await this.posMasterRepository.count({
where: { where: {
orgRevisionId: orgRoot.orgRevisionId,
orgChild3Id: orgChild3.id, orgChild3Id: orgChild3.id,
current_holderId: IsNull() || "", current_holderId: IsNull() || "",
}, },
}), }),
totalPositionNextUse: await this.posMasterRepository.count({ totalPositionNextUse: await this.posMasterRepository.count({
where: { where: {
orgRevisionId: orgRoot.orgRevisionId,
orgChild3Id: orgChild3.id, orgChild3Id: orgChild3.id,
next_holderId: Not(IsNull()) || Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}), }),
totalPositionNextVacant: await this.posMasterRepository.count({ totalPositionNextVacant: await this.posMasterRepository.count({
where: { where: {
orgRevisionId: orgRoot.orgRevisionId,
orgChild3Id: orgChild3.id, orgChild3Id: orgChild3.id,
next_holderId: IsNull() || "", next_holderId: IsNull() || "",
}, },
@ -926,10 +933,14 @@ export class OrganizationController extends Controller {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootName: orgRoot.orgRootName, orgRootName: orgRoot.orgRootName,
totalPosition: await this.posMasterRepository.count({ totalPosition: await this.posMasterRepository.count({
where: { orgChild4Id: orgChild4.id }, where: {
orgRevisionId: orgRoot.orgRevisionId,
orgChild4Id: orgChild4.id,
},
}), }),
totalPositionCurrentUse: await this.posMasterRepository.count({ totalPositionCurrentUse: await this.posMasterRepository.count({
where: { where: {
orgRevisionId: orgRoot.orgRevisionId,
orgChild4Id: orgChild4.id, orgChild4Id: orgChild4.id,
current_holderId: Not(IsNull()) || Not(""), current_holderId: Not(IsNull()) || Not(""),
}, },
@ -937,18 +948,21 @@ export class OrganizationController extends Controller {
totalPositionCurrentVacant: totalPositionCurrentVacant:
await this.posMasterRepository.count({ await this.posMasterRepository.count({
where: { where: {
orgRevisionId: orgRoot.orgRevisionId,
orgChild4Id: orgChild4.id, orgChild4Id: orgChild4.id,
current_holderId: IsNull() || "", current_holderId: IsNull() || "",
}, },
}), }),
totalPositionNextUse: await this.posMasterRepository.count({ totalPositionNextUse: await this.posMasterRepository.count({
where: { where: {
orgRevisionId: orgRoot.orgRevisionId,
orgChild4Id: orgChild4.id, orgChild4Id: orgChild4.id,
next_holderId: Not(IsNull()) || Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}), }),
totalPositionNextVacant: await this.posMasterRepository.count({ totalPositionNextVacant: await this.posMasterRepository.count({
where: { where: {
orgRevisionId: orgRoot.orgRevisionId,
orgChild4Id: orgChild4.id, orgChild4Id: orgChild4.id,
next_holderId: IsNull() || "", next_holderId: IsNull() || "",
}, },

View file

@ -653,44 +653,48 @@ export class PositionController extends Controller {
} }
let findPosition: any; let findPosition: any;
let masterId = new Array(); let masterId = new Array();
const findTypes: PosType[] = await this.posTypeRepository.find({ if (body.keyword != null && body.keyword != "") {
where: { posTypeName: Like(`%${body.keyword}%`) }, const findTypes: PosType[] = await this.posTypeRepository.find({
select: ["id"], where: { posTypeName: Like(`%${body.keyword}%`) },
}); select: ["id"],
findPosition = await this.positionRepository.find({ });
where: { posTypeId: In(findTypes.map((x) => x.id)) }, findPosition = await this.positionRepository.find({
select: ["posMasterId"], where: { posTypeId: In(findTypes.map((x) => x.id)) },
}); select: ["posMasterId"],
masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId)); });
const findLevel: PosLevel[] = await this.posLevelRepository.find({ masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId));
where: { posLevelName: Like(`%${body.keyword}%`) }, const findLevel: PosLevel[] = await this.posLevelRepository.find({
select: ["id"], where: { posLevelName: Like(`%${body.keyword}%`) },
}); select: ["id"],
findPosition = await this.positionRepository.find({ });
where: { posLevelId: In(findLevel.map((x) => x.id)) }, findPosition = await this.positionRepository.find({
select: ["posMasterId"], where: { posLevelId: In(findLevel.map((x) => x.id)) },
}); select: ["posMasterId"],
masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId)); });
const findExecutive: PosExecutive[] = await this.posExecutiveRepository.find({ masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId));
where: { posExecutiveName: Like(`%${body.keyword}%`) }, const findExecutive: PosExecutive[] = await this.posExecutiveRepository.find({
select: ["id"], where: { posExecutiveName: Like(`%${body.keyword}%`) },
}); select: ["id"],
findPosition = await this.positionRepository.find({ });
where: { posExecutiveId: In(findExecutive.map((x) => x.id)) }, findPosition = await this.positionRepository.find({
select: ["posMasterId"], where: { posExecutiveId: In(findExecutive.map((x) => x.id)) },
}); select: ["posMasterId"],
masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId)); });
findPosition = await this.positionRepository.find({ masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId));
where: { positionName: Like(`%${body.keyword}%`) }, findPosition = await this.positionRepository.find({
select: ["posMasterId"], where: { positionName: Like(`%${body.keyword}%`) },
}); select: ["posMasterId"],
masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId)); });
let keywordAsInt: any; masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId));
keywordAsInt = body.keyword == null ? null : parseInt(body.keyword, 10); let keywordAsInt: any;
if (isNaN(keywordAsInt)) { keywordAsInt = body.keyword == null ? null : parseInt(body.keyword, 10);
keywordAsInt = "P@ssw0rd!z"; if (isNaN(keywordAsInt)) {
keywordAsInt = "P@ssw0rd!z";
}
masterId = [...new Set(masterId)];
} }
masterId = [...new Set(masterId)]; console.log(masterId);
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
const keywordConditions = [ const keywordConditions = [
// { // {
@ -700,13 +704,13 @@ export class PositionController extends Controller {
{ {
...checkChildConditions, ...checkChildConditions,
...typeCondition, ...typeCondition,
id: In(masterId), id: masterId.length > 0 ? In(masterId) : false,
},
{
...checkChildConditions,
...typeCondition,
posMasterNo: Like(`%${keywordAsInt}%`),
}, },
// {
// ...checkChildConditions,
// ...typeCondition,
// posMasterNo: Like(`%${keywordAsInt}%`),
// },
]; ];
const [posMaster, total] = await this.posMasterRepository.findAndCount({ const [posMaster, total] = await this.posMasterRepository.findAndCount({