search probation

This commit is contained in:
kittapath 2024-12-25 01:10:49 +07:00
parent 4cb2887784
commit 51c6d8f615
3 changed files with 99 additions and 96 deletions

View file

@ -4622,7 +4622,7 @@ export class ProfileController extends Controller {
citizenId: profile.citizenId,
posNo: shortNames[index],
positionName: positionName,
date: holder.createdAt
date: holder.createdAt,
};
});
})
@ -6728,15 +6728,18 @@ export class ProfileController extends Controller {
)
.andWhere(
new Brackets((qb) => {
qb.orWhere(`profile.prefix LIKE :keyword and profile.isProbation = ${isProbation}`, {
keyword: `%${body.keyword}%`,
})
.orWhere(`profile.firstName LIKE :keyword and profile.isProbation = ${isProbation}`, {
qb.orWhere(
`CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword and profile.isProbation = ${isProbation}`,
{
keyword: `%${body.keyword}%`,
})
.orWhere(`profile.lastName LIKE :keyword and profile.isProbation = ${isProbation}`, {
keyword: `%${body.keyword}%`,
})
},
)
// .orWhere(`profile.firstName LIKE :keyword and profile.isProbation = ${isProbation}`, {
// keyword: `%${body.keyword}%`,
// })
// .orWhere(`profile.lastName LIKE :keyword and profile.isProbation = ${isProbation}`, {
// keyword: `%${body.keyword}%`,
// })
.orWhere(`profile.position LIKE :keyword and profile.isProbation = ${isProbation}`, {
keyword: `%${body.keyword}%`,
})

View file

@ -1454,14 +1454,9 @@ export class ProfileEmployeeController extends Controller {
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.where(
node && nodeId
? "current_holders.orgRevisionId = :orgRevisionId"
: "1=1",
{
orgRevisionId: node && nodeId ? findRevision.id : undefined,
}
)
.where(node && nodeId ? "current_holders.orgRevisionId = :orgRevisionId" : "1=1", {
orgRevisionId: node && nodeId ? findRevision.id : undefined,
})
.andWhere(
_data.root != undefined && _data.root != null
? _data.root[0] != null
@ -1920,21 +1915,21 @@ export class ProfileEmployeeController extends Controller {
// return new HttpSuccess(mapData);
// }
/**
/**
* API
*
* @summary
*
*/
@Post("search/history/oc")
async searchOC(
@Body()
requestBody: {
posNo?: string;
position?: string;
},
) {
let queryLike = `
@Post("search/history/oc")
async searchOC(
@Body()
requestBody: {
posNo?: string;
position?: string;
},
) {
let queryLike = `
CASE
WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, current_holders.posMasterNo)
WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, current_holders.posMasterNo)
@ -1943,67 +1938,67 @@ export class ProfileEmployeeController extends Controller {
ELSE CONCAT(orgRoot.orgRootShortName, current_holders.posMasterNo)
END LIKE :keyword
`;
const profiles = await this.profileRepo
.createQueryBuilder("profileEmployee")
.leftJoinAndSelect("profileEmployee.current_holders", "current_holders")
.leftJoinAndSelect("current_holders.positions", "positions")
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.where("positions.positionIsSelected = :posIsSelected", { posIsSelected: true })
.andWhere(
new Brackets((qb) => {
qb.orWhere(
requestBody.posNo != undefined && requestBody.posNo != null && requestBody.posNo != ""
? queryLike
: "1=1",
{
keyword: `%${requestBody.posNo}%`,
},
);
}),
)
.andWhere(
requestBody.position != null && requestBody.position !== ""
? "positions.positionName LIKE :positionName"
: "1=1",
{ positionName: `${requestBody.position}` },
)
.getMany();
const mapData = profiles
.map((profile) => {
const shortNames = profile.current_holders.map((holder) => {
const shortName =
holder.orgChild4?.orgChild4ShortName ||
holder.orgChild3?.orgChild3ShortName ||
holder.orgChild2?.orgChild2ShortName ||
holder.orgChild1?.orgChild1ShortName ||
holder.orgRoot?.orgRootShortName;
return `${shortName || ""}${holder.posMasterNo || ""}`;
});
return profile.current_holders.map((holder, index) => {
const position = holder.positions.find((position) => position.posMasterId === holder.id);
const positionName = position ? position.positionName : null;
return {
id: profile.id,
posMasterId: holder.id,
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
citizenId: profile.citizenId,
posNo: shortNames[index],
positionName: positionName,
date: holder.createdAt
};
});
})
.flat();
return new HttpSuccess(mapData);
}
const profiles = await this.profileRepo
.createQueryBuilder("profileEmployee")
.leftJoinAndSelect("profileEmployee.current_holders", "current_holders")
.leftJoinAndSelect("current_holders.positions", "positions")
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.where("positions.positionIsSelected = :posIsSelected", { posIsSelected: true })
.andWhere(
new Brackets((qb) => {
qb.orWhere(
requestBody.posNo != undefined && requestBody.posNo != null && requestBody.posNo != ""
? queryLike
: "1=1",
{
keyword: `%${requestBody.posNo}%`,
},
);
}),
)
.andWhere(
requestBody.position != null && requestBody.position !== ""
? "positions.positionName LIKE :positionName"
: "1=1",
{ positionName: `${requestBody.position}` },
)
.getMany();
const mapData = profiles
.map((profile) => {
const shortNames = profile.current_holders.map((holder) => {
const shortName =
holder.orgChild4?.orgChild4ShortName ||
holder.orgChild3?.orgChild3ShortName ||
holder.orgChild2?.orgChild2ShortName ||
holder.orgChild1?.orgChild1ShortName ||
holder.orgRoot?.orgRootShortName;
return `${shortName || ""}${holder.posMasterNo || ""}`;
});
return profile.current_holders.map((holder, index) => {
const position = holder.positions.find((position) => position.posMasterId === holder.id);
const positionName = position ? position.positionName : null;
return {
id: profile.id,
posMasterId: holder.id,
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
citizenId: profile.citizenId,
posNo: shortNames[index],
positionName: positionName,
date: holder.createdAt,
};
});
})
.flat();
return new HttpSuccess(mapData);
}
/**
* API keycloak
@ -2157,7 +2152,7 @@ export class ProfileEmployeeController extends Controller {
node: null,
nodeId: null,
salary: profile ? profile.amount : null,
amountSpecial: profile ? profile.amountSpecial : null
amountSpecial: profile ? profile.amountSpecial : null,
};
return new HttpSuccess(_profile);
}
@ -2972,9 +2967,12 @@ export class ProfileEmployeeController extends Controller {
)
.andWhere(
new Brackets((qb) => {
qb.orWhere("profile.prefix LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("profile.firstName LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("profile.lastName LIKE :keyword", { keyword: `%${body.keyword}%` })
qb.orWhere(
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword",
{ keyword: `%${body.keyword}%` },
)
// .orWhere("profile.firstName LIKE :keyword", { keyword: `%${body.keyword}%` })
// .orWhere("profile.lastName LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("profile.position LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("posLevel.posLevelName LIKE :keyword", { keyword: `%${body.keyword}%` });
}),

View file

@ -1867,7 +1867,7 @@ export class ProfileEmployeeTempController extends Controller {
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4
.orgChild4Name,
salary: profile ? profile.amount : null,
amountSpecial: profile ? profile.amountSpecial : null
amountSpecial: profile ? profile.amountSpecial : null,
};
return new HttpSuccess(_profile);
}
@ -2472,9 +2472,11 @@ export class ProfileEmployeeTempController extends Controller {
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.where("profile.prefix LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("profile.firstName LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("profile.lastName LIKE :keyword", { keyword: `%${body.keyword}%` })
.where("CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword", {
keyword: `%${body.keyword}%`,
})
// .orWhere("profile.firstName LIKE :keyword", { keyword: `%${body.keyword}%` })
// .orWhere("profile.lastName LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("profile.position LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("posLevel.posLevelName LIKE :keyword", { keyword: `%${body.keyword}%` })
.orderBy("profile.citizenId", "ASC")