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

View file

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