Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
This commit is contained in:
commit
8ac7e81f95
4 changed files with 225 additions and 199 deletions
|
|
@ -500,7 +500,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild4?.id ?? null,
|
)?.orgChild4?.id ?? null,
|
||||||
};
|
};
|
||||||
let pos = await this.posMasterRepository.findOne({
|
let pos = await this.empPosMasterRepository.findOne({
|
||||||
relations: ["current_holder"],
|
relations: ["current_holder"],
|
||||||
where: {
|
where: {
|
||||||
orgRevision: {
|
orgRevision: {
|
||||||
|
|
@ -526,7 +526,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
commanderId = pos.current_holder?.id;
|
commanderId = pos.current_holder?.id;
|
||||||
commanderKeycloak = pos.current_holder?.keycloak;
|
commanderKeycloak = pos.current_holder?.keycloak;
|
||||||
} else {
|
} else {
|
||||||
let pos = await this.posMasterRepository.findOne({
|
let pos = await this.empPosMasterRepository.findOne({
|
||||||
relations: ["current_holder"],
|
relations: ["current_holder"],
|
||||||
where: {
|
where: {
|
||||||
orgRevision: {
|
orgRevision: {
|
||||||
|
|
@ -551,7 +551,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
commanderId = pos.current_holder?.id;
|
commanderId = pos.current_holder?.id;
|
||||||
commanderKeycloak = pos.current_holder?.keycloak;
|
commanderKeycloak = pos.current_holder?.keycloak;
|
||||||
} else {
|
} else {
|
||||||
let pos = await this.posMasterRepository.findOne({
|
let pos = await this.empPosMasterRepository.findOne({
|
||||||
relations: ["current_holder"],
|
relations: ["current_holder"],
|
||||||
where: {
|
where: {
|
||||||
orgRevision: {
|
orgRevision: {
|
||||||
|
|
@ -576,7 +576,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
commanderId = pos.current_holder?.id;
|
commanderId = pos.current_holder?.id;
|
||||||
commanderKeycloak = pos.current_holder?.keycloak;
|
commanderKeycloak = pos.current_holder?.keycloak;
|
||||||
} else {
|
} else {
|
||||||
let pos = await this.posMasterRepository.findOne({
|
let pos = await this.empPosMasterRepository.findOne({
|
||||||
relations: ["current_holder"],
|
relations: ["current_holder"],
|
||||||
where: {
|
where: {
|
||||||
orgRevision: {
|
orgRevision: {
|
||||||
|
|
@ -601,7 +601,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
commanderId = pos.current_holder?.id;
|
commanderId = pos.current_holder?.id;
|
||||||
commanderKeycloak = pos.current_holder?.keycloak;
|
commanderKeycloak = pos.current_holder?.keycloak;
|
||||||
} else {
|
} else {
|
||||||
let pos = await this.posMasterRepository.findOne({
|
let pos = await this.empPosMasterRepository.findOne({
|
||||||
relations: ["current_holder"],
|
relations: ["current_holder"],
|
||||||
where: {
|
where: {
|
||||||
orgRevision: {
|
orgRevision: {
|
||||||
|
|
@ -2658,9 +2658,13 @@ export class OrganizationDotnetController extends Controller {
|
||||||
posLevel: profile.posLevel?.posLevelName ?? "",
|
posLevel: profile.posLevel?.posLevelName ?? "",
|
||||||
posType: profile.posType?.posTypeName ?? "",
|
posType: profile.posType?.posTypeName ?? "",
|
||||||
profileSalary: profile.profileSalary,
|
profileSalary: profile.profileSalary,
|
||||||
profileInsignia: profile.profileInsignias.map((x) => {
|
// profileInsignia: profile.profileInsignias.map((x) => {
|
||||||
return { ...x, insignia: x.insignia.name };
|
// return { ...x, insignia: x.insignia.name };
|
||||||
}),
|
// }),
|
||||||
|
profileInsignia: profile.profileInsignias?.map((x) => ({
|
||||||
|
...x,
|
||||||
|
insignia: x.insignia?.name ?? null,
|
||||||
|
})) ?? [],
|
||||||
amount: profile.amount,
|
amount: profile.amount,
|
||||||
positionSalaryAmount: profile.positionSalaryAmount,
|
positionSalaryAmount: profile.positionSalaryAmount,
|
||||||
mouthSalaryAmount: profile.mouthSalaryAmount,
|
mouthSalaryAmount: profile.mouthSalaryAmount,
|
||||||
|
|
|
||||||
|
|
@ -1664,9 +1664,13 @@ export class OrganizationUnauthorizeController extends Controller {
|
||||||
posLevel: profile.posLevel?.posLevelName ?? "",
|
posLevel: profile.posLevel?.posLevelName ?? "",
|
||||||
posType: profile.posType?.posTypeName ?? "",
|
posType: profile.posType?.posTypeName ?? "",
|
||||||
profileSalary: profile.profileSalary,
|
profileSalary: profile.profileSalary,
|
||||||
profileInsignia: profile.profileInsignias.map((x) => {
|
// profileInsignia: profile.profileInsignias.map((x) => {
|
||||||
return { ...x, insignia: x.insignia.name };
|
// return { ...x, insignia: x.insignia.name };
|
||||||
}),
|
// }),
|
||||||
|
profileInsignia: profile.profileInsignias?.map((x) => ({
|
||||||
|
...x,
|
||||||
|
insignia: x.insignia?.name ?? null,
|
||||||
|
})) ?? [],
|
||||||
amount: profile.amount,
|
amount: profile.amount,
|
||||||
positionSalaryAmount: profile.positionSalaryAmount,
|
positionSalaryAmount: profile.positionSalaryAmount,
|
||||||
mouthSalaryAmount: profile.mouthSalaryAmount,
|
mouthSalaryAmount: profile.mouthSalaryAmount,
|
||||||
|
|
|
||||||
|
|
@ -10821,114 +10821,124 @@ export class ProfileController extends Controller {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||||
}
|
}
|
||||||
|
|
||||||
let findProfile: any;
|
let queryLike = "1=1";
|
||||||
let total: any;
|
|
||||||
const skip = (page - 1) * pageSize;
|
|
||||||
const take = pageSize;
|
|
||||||
switch (body.fieldName) {
|
switch (body.fieldName) {
|
||||||
case "citizenId":
|
case "citizenId":
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
queryLike = "profile.citizenId LIKE :keyword";
|
||||||
where: {
|
|
||||||
keycloak: IsNull(),
|
|
||||||
citizenId: Like(`%${body.keyword}%`),
|
|
||||||
},
|
|
||||||
relations: ["posType", "posLevel", "current_holders"],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "fullName":
|
case "fullName":
|
||||||
[findProfile, total] = await this.profileRepo
|
queryLike =
|
||||||
.createQueryBuilder("profile")
|
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
|
||||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
|
||||||
.where("profile.keycloak IS NULL")
|
|
||||||
.andWhere(
|
|
||||||
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword",
|
|
||||||
{ keyword: `%${body.keyword}%` }
|
|
||||||
)
|
|
||||||
.skip(skip)
|
|
||||||
.take(take)
|
|
||||||
.getManyAndCount();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "firstname":
|
case "firstName":
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
queryLike = "profile.firstName LIKE :keyword";
|
||||||
where: {
|
|
||||||
keycloak: IsNull(),
|
|
||||||
firstName: Like(`%${body.keyword}%`),
|
|
||||||
},
|
|
||||||
relations: ["posType", "posLevel", "current_holders"],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "lastname":
|
case "lastName":
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
queryLike = "profile.lastName LIKE :keyword";
|
||||||
where: {
|
|
||||||
keycloak: IsNull(),
|
|
||||||
lastName: Like(`%${body.keyword}%`),
|
|
||||||
},
|
|
||||||
relations: ["posType", "posLevel", "current_holders"],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
queryLike = "1=1";
|
||||||
where: {
|
|
||||||
keycloak: IsNull(),
|
|
||||||
},
|
|
||||||
relations: ["posType", "posLevel", "current_holders"],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let query = await this.profileRepo
|
||||||
|
.createQueryBuilder("profile")
|
||||||
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
|
.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("profile.keycloak IS NULL")
|
||||||
|
.andWhere(
|
||||||
|
new Brackets((qb) => {
|
||||||
|
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const [findProfile, total] = await query
|
||||||
|
.skip((page - 1) * pageSize)
|
||||||
|
.take(pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
const mapDataProfile = await Promise.all(
|
const mapDataProfile = await Promise.all(
|
||||||
findProfile.map(async (item: Profile) => {
|
findProfile.map(async (item: Profile) => {
|
||||||
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
||||||
const shortName =
|
let shortName = null;
|
||||||
item.current_holders.length == 0
|
let root = null;
|
||||||
? null
|
let posMasterNo = null;
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
if (item.isLeave == false) {
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
shortName =
|
||||||
null
|
item.current_holders.length == 0
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? null
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||||
null
|
null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||||
?.orgChild2 != null
|
null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
?.orgChild1 != null
|
?.orgChild2 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
null &&
|
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
?.orgRoot != null
|
?.orgChild1 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: null;
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||||
|
null &&
|
||||||
const root =
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
item.current_holders.length == 0 ||
|
?.orgRoot != null
|
||||||
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
: null;
|
||||||
? null
|
root =
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
item.current_holders.length == 0 ||
|
||||||
|
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
const posMasterNo = item.current_holders?.find(
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||||
(x) => x.orgRevisionId == findRevision.id,
|
? null
|
||||||
)?.posMasterNo;
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||||
|
root = root == null ? null : root.orgRootName;
|
||||||
|
posMasterNo = item.current_holders?.find(
|
||||||
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
|
)?.posMasterNo;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const profileSalary = await this.salaryRepo
|
||||||
|
.createQueryBuilder("s")
|
||||||
|
.where("s.profileId = :profileId", { profileId: item.id })
|
||||||
|
.andWhere("s.commandCode IN (:...codes)", {
|
||||||
|
codes: ["0","9","1","2","3","4","8","10","11","12","13","14","15","16"],
|
||||||
|
})
|
||||||
|
.orderBy("s.order", "DESC")
|
||||||
|
.addOrderBy("s.createdAt", "DESC")
|
||||||
|
.take(2)
|
||||||
|
.getMany();
|
||||||
|
if (profileSalary.length > 0) {
|
||||||
|
shortName = item.isRetirement
|
||||||
|
? profileSalary.length > 1
|
||||||
|
? `${profileSalary[1]?.posNoAbb} ${profileSalary[1]?.posNo}`
|
||||||
|
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`
|
||||||
|
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`;
|
||||||
|
posMasterNo = item.isRetirement
|
||||||
|
? profileSalary.length > 1
|
||||||
|
? profileSalary[1]?.posNo
|
||||||
|
: profileSalary[0]?.posNo
|
||||||
|
: profileSalary[0]?.posNo;
|
||||||
|
root = item.isRetirement
|
||||||
|
? profileSalary.length > 1
|
||||||
|
? profileSalary[1]?.orgRoot
|
||||||
|
: profileSalary[0]?.orgRoot
|
||||||
|
: profileSalary[0]?.orgRoot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const latestProfileEducation = await this.profileEducationRepo.findOne({
|
const latestProfileEducation = await this.profileEducationRepo.findOne({
|
||||||
where: { profileId: item.id },
|
where: { profileId: item.id },
|
||||||
|
|
@ -10952,7 +10962,7 @@ export class ProfileController extends Controller {
|
||||||
positionType: item.posTypeId,
|
positionType: item.posTypeId,
|
||||||
positionTypeName: item.posType?.posTypeName,
|
positionTypeName: item.posType?.posTypeName,
|
||||||
posNo: shortName,
|
posNo: shortName,
|
||||||
organization: root == null ? null : root.orgRootName,
|
organization: root,
|
||||||
salary: item.amount,
|
salary: item.amount,
|
||||||
posMasterNo: posMasterNo ?? null,
|
posMasterNo: posMasterNo ?? null,
|
||||||
posTypeId: item.posTypeId,
|
posTypeId: item.posTypeId,
|
||||||
|
|
|
||||||
|
|
@ -5735,119 +5735,127 @@ export class ProfileEmployeeController extends Controller {
|
||||||
if (!findRevision) {
|
if (!findRevision) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||||
}
|
}
|
||||||
|
|
||||||
let findProfile: any;
|
let queryLike = "1=1";
|
||||||
let total: any;
|
switch (body.fieldName) {
|
||||||
const skip = (page - 1) * pageSize;
|
case "citizenId":
|
||||||
const take = pageSize;
|
queryLike = "profile.citizenId LIKE :keyword";
|
||||||
switch (body.fieldName) {
|
break;
|
||||||
case "citizenId":
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
case "fullName":
|
||||||
where: {
|
queryLike =
|
||||||
keycloak: IsNull(),
|
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||||
citizenId: Like(`%${body.keyword}%`),
|
break;
|
||||||
employeeClass: "PERM",
|
|
||||||
},
|
case "firstName":
|
||||||
relations: ["posType", "posLevel", "current_holders"],
|
queryLike = "profile.firstName LIKE :keyword";
|
||||||
skip,
|
break;
|
||||||
take,
|
|
||||||
});
|
case "lastName":
|
||||||
break;
|
queryLike = "profile.lastName LIKE :keyword";
|
||||||
|
break;
|
||||||
case "fullName":
|
|
||||||
[findProfile, total] = await this.profileRepo
|
default:
|
||||||
.createQueryBuilder("profile")
|
queryLike = "1=1";
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
break;
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
}
|
||||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
|
||||||
.where("profile.keycloak IS NULL")
|
let query = await this.profileRepo
|
||||||
.andWhere(
|
.createQueryBuilder("profile")
|
||||||
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword",
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
{ keyword: `%${body.keyword}%` }
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
)
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
.skip(skip)
|
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
||||||
.take(take)
|
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
||||||
.getManyAndCount();
|
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||||
break;
|
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
case "firstname":
|
.where("profile.keycloak IS NULL")
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
.andWhere(
|
||||||
where: {
|
new Brackets((qb) => {
|
||||||
keycloak: IsNull(),
|
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
||||||
firstName: Like(`%${body.keyword}%`),
|
}),
|
||||||
employeeClass: "PERM",
|
);
|
||||||
},
|
|
||||||
relations: ["posType", "posLevel", "current_holders"],
|
const [findProfile, total] = await query
|
||||||
skip,
|
.skip((page - 1) * pageSize)
|
||||||
take,
|
.take(pageSize)
|
||||||
});
|
.getManyAndCount();
|
||||||
break;
|
|
||||||
|
|
||||||
case "lastname":
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: {
|
|
||||||
keycloak: IsNull(),
|
|
||||||
lastName: Like(`%${body.keyword}%`),
|
|
||||||
employeeClass: "PERM",
|
|
||||||
},
|
|
||||||
relations: ["posType", "posLevel", "current_holders"],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: {
|
|
||||||
keycloak: IsNull(),
|
|
||||||
employeeClass: "PERM",
|
|
||||||
},
|
|
||||||
relations: ["posType", "posLevel", "current_holders"],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const mapDataProfile = await Promise.all(
|
const mapDataProfile = await Promise.all(
|
||||||
findProfile.map(async (item: ProfileEmployee) => {
|
findProfile.map(async (item: ProfileEmployee) => {
|
||||||
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
||||||
const shortName =
|
let shortName = null;
|
||||||
item.current_holders.length == 0
|
let root = null;
|
||||||
? null
|
let posMasterNo = null;
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
if (item.isLeave == false) {
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
shortName =
|
||||||
null
|
item.current_holders.length == 0
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? null
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||||
null
|
null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||||
?.orgChild2 != null
|
null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
?.orgChild1 != null
|
?.orgChild2 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
null &&
|
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
?.orgRoot != null
|
?.orgChild1 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: null;
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||||
|
null &&
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
|
?.orgRoot != null
|
||||||
|
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
|
: null;
|
||||||
|
|
||||||
const root =
|
root =
|
||||||
item.current_holders.length == 0 ||
|
item.current_holders.length == 0 ||
|
||||||
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||||
? null
|
? null
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||||
|
root = root == null ? null : root.orgRootName;
|
||||||
const posMasterNo = item.current_holders?.find(
|
posMasterNo = item.current_holders?.find(
|
||||||
(x) => x.orgRevisionId == findRevision.id,
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
)?.posMasterNo;
|
)?.posMasterNo;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const profileSalary = await this.salaryRepo
|
||||||
|
.createQueryBuilder("s")
|
||||||
|
.where("s.profileEmployeeId = :profileId", { profileId: item.id })
|
||||||
|
.andWhere("s.commandCode IN (:...codes)", {
|
||||||
|
codes: ["0","9","1","2","3","4","8","10","11","12","13","14","15","16"],
|
||||||
|
})
|
||||||
|
.orderBy("s.order", "DESC")
|
||||||
|
.addOrderBy("s.createdAt", "DESC")
|
||||||
|
.take(2)
|
||||||
|
.getMany();
|
||||||
|
if (profileSalary.length > 0) {
|
||||||
|
shortName = item.isRetirement
|
||||||
|
? profileSalary.length > 1
|
||||||
|
? `${profileSalary[1]?.posNoAbb} ${profileSalary[1]?.posNo}`
|
||||||
|
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`
|
||||||
|
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`;
|
||||||
|
posMasterNo = item.isRetirement
|
||||||
|
? profileSalary.length > 1
|
||||||
|
? profileSalary[1]?.posNo
|
||||||
|
: profileSalary[0]?.posNo
|
||||||
|
: profileSalary[0]?.posNo;
|
||||||
|
root = item.isRetirement
|
||||||
|
? profileSalary.length > 1
|
||||||
|
? profileSalary[1]?.orgRoot
|
||||||
|
: profileSalary[0]?.orgRoot
|
||||||
|
: profileSalary[0]?.orgRoot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const latestProfileEducation = await this.profileEducationRepo.findOne({
|
const latestProfileEducation = await this.profileEducationRepo.findOne({
|
||||||
where: { profileEmployeeId: item.id },
|
where: { profileEmployeeId: item.id },
|
||||||
|
|
@ -5871,7 +5879,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
positionType: item.posTypeId,
|
positionType: item.posTypeId,
|
||||||
positionTypeName: item.posType?.posTypeName,
|
positionTypeName: item.posType?.posTypeName,
|
||||||
posNo: shortName,
|
posNo: shortName,
|
||||||
organization: root == null ? null : root.orgRootName,
|
organization: root,
|
||||||
salary: item.amount,
|
salary: item.amount,
|
||||||
posMasterNo: posMasterNo ?? null,
|
posMasterNo: posMasterNo ?? null,
|
||||||
posTypeId: item.posTypeId,
|
posTypeId: item.posTypeId,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue